@splinetool/loader 0.9.33 → 0.9.36

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,33 +1,14 @@
1
- var B_=Object.create;var ra=Object.defineProperty,G_=Object.defineProperties,j_=Object.getOwnPropertyDescriptor,E_=Object.getOwnPropertyDescriptors,R_=Object.getOwnPropertyNames,og=Object.getOwnPropertySymbols,z_=Object.getPrototypeOf,sg=Object.prototype.hasOwnProperty,F_=Object.prototype.propertyIsEnumerable;var ag=(i,e,t)=>e in i?ra(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,U=(i,e)=>{for(var t in e||(e={}))sg.call(e,t)&&ag(i,t,e[t]);if(og)for(var t of og(e))F_.call(e,t)&&ag(i,t,e[t]);return i},fe=(i,e)=>G_(i,E_(e)),lg=i=>ra(i,"__esModule",{value:!0});var cg=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),V_=(i,e)=>{lg(i);for(var t in e)ra(i,t,{get:e[t],enumerable:!0})},U_=(i,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of R_(e))!sg.call(i,r)&&r!=="default"&&ra(i,r,{get:()=>e[r],enumerable:!(t=j_(e,r))||t.enumerable});return i},ug=i=>U_(lg(ra(i!=null?B_(z_(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);var eb=cg((Eu,Qv)=>{(function(i,e){typeof Eu=="object"&&typeof Qv!="undefined"?e(Eu):typeof define=="function"&&define.amd?define(["exports"],e):e((i=typeof globalThis!="undefined"?globalThis:i||self).SVDJS={})})(Eu,function(i){"use strict";i.SVD=function(e,t,r,n,s){if(t=t===void 0||t,r=r===void 0||r,s=1e-64/(n=n||Math.pow(2,-52)),!e)throw new TypeError("Matrix a is not defined");var l,c,f,h,d,x,g,w,S,D,C,G,B=e[0].length,P=e.length;if(P<B)throw new TypeError("Invalid matrix: m < n");for(var W=[],M=[],q=[],E=t==="f"?P:B,b=D=g=0;b<P;b++)M[b]=new Array(E).fill(0);for(b=0;b<B;b++)q[b]=new Array(B).fill(0);var R,T=new Array(B).fill(0);for(b=0;b<P;b++)for(l=0;l<B;l++)M[b][l]=e[b][l];for(b=0;b<B;b++){for(W[b]=g,S=0,f=b+1,l=b;l<P;l++)S+=Math.pow(M[l][b],2);if(S<s)g=0;else for(w=(x=M[b][b])*(g=x<0?Math.sqrt(S):-Math.sqrt(S))-S,M[b][b]=x-g,l=f;l<B;l++){for(S=0,c=b;c<P;c++)S+=M[c][b]*M[c][l];for(x=S/w,c=b;c<P;c++)M[c][l]=M[c][l]+x*M[c][b]}for(T[b]=g,S=0,l=f;l<B;l++)S+=Math.pow(M[b][l],2);if(S<s)g=0;else{for(w=(x=M[b][b+1])*(g=x<0?Math.sqrt(S):-Math.sqrt(S))-S,M[b][b+1]=x-g,l=f;l<B;l++)W[l]=M[b][l]/w;for(l=f;l<P;l++){for(S=0,c=f;c<B;c++)S+=M[l][c]*M[b][c];for(c=f;c<B;c++)M[l][c]=M[l][c]+S*W[c]}}D<(C=Math.abs(T[b])+Math.abs(W[b]))&&(D=C)}if(r)for(b=B-1;0<=b;b--){if(g!==0){for(w=M[b][b+1]*g,l=f;l<B;l++)q[l][b]=M[b][l]/w;for(l=f;l<B;l++){for(S=0,c=f;c<B;c++)S+=M[b][c]*q[c][l];for(c=f;c<B;c++)q[c][l]=q[c][l]+S*q[c][b]}}for(l=f;l<B;l++)q[b][l]=0,q[l][b]=0;q[b][b]=1,g=W[b],f=b}if(t){if(t==="f")for(b=B;b<P;b++){for(l=B;l<P;l++)M[b][l]=0;M[b][b]=1}for(b=B-1;0<=b;b--){for(f=b+1,g=T[b],l=f;l<E;l++)M[b][l]=0;if(g!==0){for(w=M[b][b]*g,l=f;l<E;l++){for(S=0,c=f;c<P;c++)S+=M[c][b]*M[c][l];for(x=S/w,c=b;c<P;c++)M[c][l]=M[c][l]+x*M[c][b]}for(l=b;l<P;l++)M[l][b]=M[l][b]/g}else for(l=b;l<P;l++)M[l][b]=0;M[b][b]=M[b][b]+1}}for(n*=D,c=B-1;0<=c;c--)for(var z=0;z<50;z++){for(R=!1,f=c;0<=f;f--){if(Math.abs(W[f])<=n){R=!0;break}if(Math.abs(T[f-1])<=n)break}if(!R){for(d=0,h=f-(S=1),b=f;b<c+1&&(x=S*W[b],W[b]=d*W[b],!(Math.abs(x)<=n));b++)if(g=T[b],T[b]=Math.sqrt(x*x+g*g),d=g/(w=T[b]),S=-x/w,t)for(l=0;l<P;l++)C=M[l][h],G=M[l][b],M[l][h]=C*d+G*S,M[l][b]=-C*S+G*d}if(G=T[c],f===c){if(G<0&&(T[c]=-G,r))for(l=0;l<B;l++)q[l][c]=-q[l][c];break}for(D=T[f],x=(((C=T[c-1])-G)*(C+G)+((g=W[c-1])-(w=W[c]))*(g+w))/(2*w*C),g=Math.sqrt(x*x+1),x=((D-G)*(D+G)+w*(C/(x<0?x-g:x+g)-w))/D,b=f+(S=d=1);b<c+1;b++){if(g=W[b],C=T[b],w=S*g,g*=d,G=Math.sqrt(x*x+w*w),x=D*(d=x/(W[b-1]=G))+g*(S=w/G),g=-D*S+g*d,w=C*S,C*=d,r)for(l=0;l<B;l++)D=q[l][b-1],G=q[l][b],q[l][b-1]=D*d+G*S,q[l][b]=-D*S+G*d;if(G=Math.sqrt(x*x+w*w),x=(d=x/(T[b-1]=G))*g+(S=w/G)*C,D=-S*g+d*C,t)for(l=0;l<P;l++)C=M[l][b-1],G=M[l][b],M[l][b-1]=C*d+G*S,M[l][b]=-C*S+G*d}W[f]=0,W[c]=x,T[c]=D}for(b=0;b<B;b++)T[b]<n&&(T[b]=0);return{u:M,q:T,v:q}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})});var gb=cg((Fs,Xa)=>{(function(){var i,e="4.17.20",t=200,r="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",n="Expected a function",s="__lodash_hash_undefined__",l=500,c="__lodash_placeholder__",f=1,h=2,d=4,x=1,g=2,w=1,S=2,D=4,C=8,G=16,B=32,P=64,W=128,M=256,q=512,E=30,b="...",R=800,T=16,z=1,A=2,$=3,he=1/0,re=9007199254740991,Ne=17976931348623157e292,ye=0/0,Me=4294967295,Fe=Me-1,k=Me>>>1,H=[["ary",W],["bind",w],["bindKey",S],["curry",C],["curryRight",G],["flip",q],["partial",B],["partialRight",P],["rearg",M]],_="[object Arguments]",J="[object Array]",ee="[object AsyncFunction]",oe="[object Boolean]",se="[object Date]",ce="[object DOMException]",ue="[object Error]",K="[object Function]",ae="[object GeneratorFunction]",ne="[object Map]",Ce="[object Number]",Y="[object Null]",le="[object Object]",pe="[object Promise]",xe="[object Proxy]",_e="[object RegExp]",de="[object Set]",we="[object String]",Ve="[object Symbol]",Ge="[object Undefined]",Qe="[object WeakMap]",bt="[object WeakSet]",Lt="[object ArrayBuffer]",At="[object DataView]",sr="[object Float32Array]",Ur="[object Float64Array]",Ht="[object Int8Array]",kr="[object Int16Array]",wn="[object Int32Array]",Nn="[object Uint8Array]",dt="[object Uint8ClampedArray]",Wt="[object Uint16Array]",ar="[object Uint32Array]",Ao=/\b__p \+= '';/g,Oo=/\b(__p \+=) '' \+/g,Po=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ro=/&(?:amp|lt|gt|quot|#39);/g,no=/[&<>"']/g,Do=RegExp(ro.source),Mr=RegExp(no.source),io=/<%-([\s\S]+?)%>/g,Jt=/<%([\s\S]+?)%>/g,ti=/<%=([\s\S]+?)%>/g,Bo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ee=/^\w*$/,Xe=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,He=/[\\^$.*+?()[\]{}|]/g,$e=RegExp(He.source),tt=/^\s+|\s+$/g,at=/^\s+/,mt=/\s+$/,gt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ct=/\{\n\/\* \[wrapped with (.+)\] \*/,St=/,? & /,Rt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ar=/\\(\\)?/g,Cn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ln=/\w*$/,Rn=/^[-+]0x[0-9a-f]+$/i,Za=/^0b[01]+$/i,wb=/^\[object .+?Constructor\]$/,Nb=/^0o[0-7]+$/i,Cb=/^(?:0|[1-9]\d*)$/,Lb=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ya=/($^)/,_b=/['\n\r\u2028\u2029\\]/g,Qa="\\ud800-\\udfff",Tb="\\u0300-\\u036f",Ib="\\ufe20-\\ufe2f",Mb="\\u20d0-\\u20ff",jp=Tb+Ib+Mb,Ep="\\u2700-\\u27bf",Rp="a-z\\xdf-\\xf6\\xf8-\\xff",Ab="\\xac\\xb1\\xd7\\xf7",Ob="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Pb="\\u2000-\\u206f",Db=" \\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",zp="A-Z\\xc0-\\xd6\\xd8-\\xde",Fp="\\ufe0e\\ufe0f",Vp=Ab+Ob+Pb+Db,zu="['\u2019]",Bb="["+Qa+"]",Up="["+Vp+"]",el="["+jp+"]",kp="\\d+",Gb="["+Ep+"]",Hp="["+Rp+"]",Wp="[^"+Qa+Vp+kp+Ep+Rp+zp+"]",Fu="\\ud83c[\\udffb-\\udfff]",jb="(?:"+el+"|"+Fu+")",qp="[^"+Qa+"]",Vu="(?:\\ud83c[\\udde6-\\uddff]){2}",Uu="[\\ud800-\\udbff][\\udc00-\\udfff]",Go="["+zp+"]",$p="\\u200d",Jp="(?:"+Hp+"|"+Wp+")",Eb="(?:"+Go+"|"+Wp+")",Kp="(?:"+zu+"(?:d|ll|m|re|s|t|ve))?",Xp="(?:"+zu+"(?:D|LL|M|RE|S|T|VE))?",Zp=jb+"?",Yp="["+Fp+"]?",Rb="(?:"+$p+"(?:"+[qp,Vu,Uu].join("|")+")"+Yp+Zp+")*",zb="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Fb="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Qp=Yp+Zp+Rb,Vb="(?:"+[Gb,Vu,Uu].join("|")+")"+Qp,Ub="(?:"+[qp+el+"?",el,Vu,Uu,Bb].join("|")+")",kb=RegExp(zu,"g"),Hb=RegExp(el,"g"),ku=RegExp(Fu+"(?="+Fu+")|"+Ub+Qp,"g"),Wb=RegExp([Go+"?"+Hp+"+"+Kp+"(?="+[Up,Go,"$"].join("|")+")",Eb+"+"+Xp+"(?="+[Up,Go+Jp,"$"].join("|")+")",Go+"?"+Jp+"+"+Kp,Go+"+"+Xp,Fb,zb,kp,Vb].join("|"),"g"),qb=RegExp("["+$p+Qa+jp+Fp+"]"),$b=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Jb=["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"],Kb=-1,_t={};_t[sr]=_t[Ur]=_t[Ht]=_t[kr]=_t[wn]=_t[Nn]=_t[dt]=_t[Wt]=_t[ar]=!0,_t[_]=_t[J]=_t[Lt]=_t[oe]=_t[At]=_t[se]=_t[ue]=_t[K]=_t[ne]=_t[Ce]=_t[le]=_t[_e]=_t[de]=_t[we]=_t[Qe]=!1;var wt={};wt[_]=wt[J]=wt[Lt]=wt[At]=wt[oe]=wt[se]=wt[sr]=wt[Ur]=wt[Ht]=wt[kr]=wt[wn]=wt[ne]=wt[Ce]=wt[le]=wt[_e]=wt[de]=wt[we]=wt[Ve]=wt[Nn]=wt[dt]=wt[Wt]=wt[ar]=!0,wt[ue]=wt[K]=wt[Qe]=!1;var Xb={\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"},Zb={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Yb={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Qb={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},eS=parseFloat,tS=parseInt,ed=typeof global=="object"&&global&&global.Object===Object&&global,rS=typeof self=="object"&&self&&self.Object===Object&&self,rr=ed||rS||Function("return this")(),Hu=typeof Fs=="object"&&Fs&&!Fs.nodeType&&Fs,oo=Hu&&typeof Xa=="object"&&Xa&&!Xa.nodeType&&Xa,td=oo&&oo.exports===Hu,Wu=td&&ed.process,on=function(){try{var O=oo&&oo.require&&oo.require("util").types;return O||Wu&&Wu.binding&&Wu.binding("util")}catch(X){}}(),rd=on&&on.isArrayBuffer,nd=on&&on.isDate,id=on&&on.isMap,od=on&&on.isRegExp,sd=on&&on.isSet,ad=on&&on.isTypedArray;function Hr(O,X,V){switch(V.length){case 0:return O.call(X);case 1:return O.call(X,V[0]);case 2:return O.call(X,V[0],V[1]);case 3:return O.call(X,V[0],V[1],V[2])}return O.apply(X,V)}function nS(O,X,V,be){for(var Ue=-1,lt=O==null?0:O.length;++Ue<lt;){var Kt=O[Ue];X(be,Kt,V(Kt),O)}return be}function sn(O,X){for(var V=-1,be=O==null?0:O.length;++V<be&&X(O[V],V,O)!==!1;);return O}function iS(O,X){for(var V=O==null?0:O.length;V--&&X(O[V],V,O)!==!1;);return O}function ld(O,X){for(var V=-1,be=O==null?0:O.length;++V<be;)if(!X(O[V],V,O))return!1;return!0}function Ci(O,X){for(var V=-1,be=O==null?0:O.length,Ue=0,lt=[];++V<be;){var Kt=O[V];X(Kt,V,O)&&(lt[Ue++]=Kt)}return lt}function tl(O,X){var V=O==null?0:O.length;return!!V&&jo(O,X,0)>-1}function qu(O,X,V){for(var be=-1,Ue=O==null?0:O.length;++be<Ue;)if(V(X,O[be]))return!0;return!1}function Ot(O,X){for(var V=-1,be=O==null?0:O.length,Ue=Array(be);++V<be;)Ue[V]=X(O[V],V,O);return Ue}function Li(O,X){for(var V=-1,be=X.length,Ue=O.length;++V<be;)O[Ue+V]=X[V];return O}function $u(O,X,V,be){var Ue=-1,lt=O==null?0:O.length;for(be&&lt&&(V=O[++Ue]);++Ue<lt;)V=X(V,O[Ue],Ue,O);return V}function oS(O,X,V,be){var Ue=O==null?0:O.length;for(be&&Ue&&(V=O[--Ue]);Ue--;)V=X(V,O[Ue],Ue,O);return V}function Ju(O,X){for(var V=-1,be=O==null?0:O.length;++V<be;)if(X(O[V],V,O))return!0;return!1}var sS=Ku("length");function aS(O){return O.split("")}function lS(O){return O.match(Rt)||[]}function cd(O,X,V){var be;return V(O,function(Ue,lt,Kt){if(X(Ue,lt,Kt))return be=lt,!1}),be}function rl(O,X,V,be){for(var Ue=O.length,lt=V+(be?1:-1);be?lt--:++lt<Ue;)if(X(O[lt],lt,O))return lt;return-1}function jo(O,X,V){return X===X?bS(O,X,V):rl(O,ud,V)}function cS(O,X,V,be){for(var Ue=V-1,lt=O.length;++Ue<lt;)if(be(O[Ue],X))return Ue;return-1}function ud(O){return O!==O}function fd(O,X){var V=O==null?0:O.length;return V?Zu(O,X)/V:ye}function Ku(O){return function(X){return X==null?i:X[O]}}function Xu(O){return function(X){return O==null?i:O[X]}}function hd(O,X,V,be,Ue){return Ue(O,function(lt,Kt,yt){V=be?(be=!1,lt):X(V,lt,Kt,yt)}),V}function uS(O,X){var V=O.length;for(O.sort(X);V--;)O[V]=O[V].value;return O}function Zu(O,X){for(var V,be=-1,Ue=O.length;++be<Ue;){var lt=X(O[be]);lt!==i&&(V=V===i?lt:V+lt)}return V}function Yu(O,X){for(var V=-1,be=Array(O);++V<O;)be[V]=X(V);return be}function fS(O,X){return Ot(X,function(V){return[V,O[V]]})}function Wr(O){return function(X){return O(X)}}function Qu(O,X){return Ot(X,function(V){return O[V]})}function Vs(O,X){return O.has(X)}function pd(O,X){for(var V=-1,be=O.length;++V<be&&jo(X,O[V],0)>-1;);return V}function dd(O,X){for(var V=O.length;V--&&jo(X,O[V],0)>-1;);return V}function hS(O,X){for(var V=O.length,be=0;V--;)O[V]===X&&++be;return be}var pS=Xu(Xb),dS=Xu(Zb);function mS(O){return"\\"+Qb[O]}function gS(O,X){return O==null?i:O[X]}function Eo(O){return qb.test(O)}function yS(O){return $b.test(O)}function xS(O){for(var X,V=[];!(X=O.next()).done;)V.push(X.value);return V}function ef(O){var X=-1,V=Array(O.size);return O.forEach(function(be,Ue){V[++X]=[Ue,be]}),V}function md(O,X){return function(V){return O(X(V))}}function _i(O,X){for(var V=-1,be=O.length,Ue=0,lt=[];++V<be;){var Kt=O[V];(Kt===X||Kt===c)&&(O[V]=c,lt[Ue++]=V)}return lt}function nl(O){var X=-1,V=Array(O.size);return O.forEach(function(be){V[++X]=be}),V}function vS(O){var X=-1,V=Array(O.size);return O.forEach(function(be){V[++X]=[be,be]}),V}function bS(O,X,V){for(var be=V-1,Ue=O.length;++be<Ue;)if(O[be]===X)return be;return-1}function SS(O,X,V){for(var be=V+1;be--;)if(O[be]===X)return be;return be}function Ro(O){return Eo(O)?NS(O):sS(O)}function _n(O){return Eo(O)?CS(O):aS(O)}var wS=Xu(Yb);function NS(O){for(var X=ku.lastIndex=0;ku.test(O);)++X;return X}function CS(O){return O.match(ku)||[]}function LS(O){return O.match(Wb)||[]}var _S=function O(X){X=X==null?rr:Ti.defaults(rr.Object(),X,Ti.pick(rr,Jb));var V=X.Array,be=X.Date,Ue=X.Error,lt=X.Function,Kt=X.Math,yt=X.Object,tf=X.RegExp,TS=X.String,an=X.TypeError,il=V.prototype,IS=lt.prototype,zo=yt.prototype,ol=X["__core-js_shared__"],sl=IS.toString,pt=zo.hasOwnProperty,MS=0,gd=function(){var o=/[^.]+$/.exec(ol&&ol.keys&&ol.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),al=zo.toString,AS=sl.call(yt),OS=rr._,PS=tf("^"+sl.call(pt).replace(He,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ll=td?X.Buffer:i,Ii=X.Symbol,cl=X.Uint8Array,yd=ll?ll.allocUnsafe:i,ul=md(yt.getPrototypeOf,yt),xd=yt.create,vd=zo.propertyIsEnumerable,fl=il.splice,bd=Ii?Ii.isConcatSpreadable:i,Us=Ii?Ii.iterator:i,so=Ii?Ii.toStringTag:i,hl=function(){try{var o=fo(yt,"defineProperty");return o({},"",{}),o}catch(a){}}(),DS=X.clearTimeout!==rr.clearTimeout&&X.clearTimeout,BS=be&&be.now!==rr.Date.now&&be.now,GS=X.setTimeout!==rr.setTimeout&&X.setTimeout,pl=Kt.ceil,dl=Kt.floor,rf=yt.getOwnPropertySymbols,jS=ll?ll.isBuffer:i,Sd=X.isFinite,ES=il.join,RS=md(yt.keys,yt),Xt=Kt.max,dr=Kt.min,zS=be.now,FS=X.parseInt,wd=Kt.random,VS=il.reverse,nf=fo(X,"DataView"),ks=fo(X,"Map"),of=fo(X,"Promise"),Fo=fo(X,"Set"),Hs=fo(X,"WeakMap"),Ws=fo(yt,"create"),ml=Hs&&new Hs,Vo={},US=ho(nf),kS=ho(ks),HS=ho(of),WS=ho(Fo),qS=ho(Hs),gl=Ii?Ii.prototype:i,qs=gl?gl.valueOf:i,Nd=gl?gl.toString:i;function y(o){if(Gt(o)&&!ke(o)&&!(o instanceof rt)){if(o instanceof ln)return o;if(pt.call(o,"__wrapped__"))return Cm(o)}return new ln(o)}var Uo=function(){function o(){}return function(a){if(!Dt(a))return{};if(xd)return xd(a);o.prototype=a;var u=new o;return o.prototype=i,u}}();function yl(){}function ln(o,a){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!a,this.__index__=0,this.__values__=i}y.templateSettings={escape:io,evaluate:Jt,interpolate:ti,variable:"",imports:{_:y}},y.prototype=yl.prototype,y.prototype.constructor=y,ln.prototype=Uo(yl.prototype),ln.prototype.constructor=ln;function rt(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Me,this.__views__=[]}function $S(){var o=new rt(this.__wrapped__);return o.__actions__=Or(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=Or(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=Or(this.__views__),o}function JS(){if(this.__filtered__){var o=new rt(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function KS(){var o=this.__wrapped__.value(),a=this.__dir__,u=ke(o),p=a<0,m=u?o.length:0,v=a1(0,m,this.__views__),N=v.start,L=v.end,I=L-N,Q=p?L:N-1,te=this.__iteratees__,ie=te.length,me=0,Le=dr(I,this.__takeCount__);if(!u||!p&&m==I&&Le==I)return $d(o,this.__actions__);var Re=[];e:for(;I--&&me<Le;){Q+=a;for(var Je=-1,je=o[Q];++Je<ie;){var et=te[Je],nt=et.iteratee,Jr=et.type,wr=nt(je);if(Jr==A)je=wr;else if(!wr){if(Jr==z)continue e;break e}}Re[me++]=je}return Re}rt.prototype=Uo(yl.prototype),rt.prototype.constructor=rt;function ao(o){var a=-1,u=o==null?0:o.length;for(this.clear();++a<u;){var p=o[a];this.set(p[0],p[1])}}function XS(){this.__data__=Ws?Ws(null):{},this.size=0}function ZS(o){var a=this.has(o)&&delete this.__data__[o];return this.size-=a?1:0,a}function YS(o){var a=this.__data__;if(Ws){var u=a[o];return u===s?i:u}return pt.call(a,o)?a[o]:i}function QS(o){var a=this.__data__;return Ws?a[o]!==i:pt.call(a,o)}function ew(o,a){var u=this.__data__;return this.size+=this.has(o)?0:1,u[o]=Ws&&a===i?s:a,this}ao.prototype.clear=XS,ao.prototype.delete=ZS,ao.prototype.get=YS,ao.prototype.has=QS,ao.prototype.set=ew;function ri(o){var a=-1,u=o==null?0:o.length;for(this.clear();++a<u;){var p=o[a];this.set(p[0],p[1])}}function tw(){this.__data__=[],this.size=0}function rw(o){var a=this.__data__,u=xl(a,o);if(u<0)return!1;var p=a.length-1;return u==p?a.pop():fl.call(a,u,1),--this.size,!0}function nw(o){var a=this.__data__,u=xl(a,o);return u<0?i:a[u][1]}function iw(o){return xl(this.__data__,o)>-1}function ow(o,a){var u=this.__data__,p=xl(u,o);return p<0?(++this.size,u.push([o,a])):u[p][1]=a,this}ri.prototype.clear=tw,ri.prototype.delete=rw,ri.prototype.get=nw,ri.prototype.has=iw,ri.prototype.set=ow;function ni(o){var a=-1,u=o==null?0:o.length;for(this.clear();++a<u;){var p=o[a];this.set(p[0],p[1])}}function sw(){this.size=0,this.__data__={hash:new ao,map:new(ks||ri),string:new ao}}function aw(o){var a=Al(this,o).delete(o);return this.size-=a?1:0,a}function lw(o){return Al(this,o).get(o)}function cw(o){return Al(this,o).has(o)}function uw(o,a){var u=Al(this,o),p=u.size;return u.set(o,a),this.size+=u.size==p?0:1,this}ni.prototype.clear=sw,ni.prototype.delete=aw,ni.prototype.get=lw,ni.prototype.has=cw,ni.prototype.set=uw;function lo(o){var a=-1,u=o==null?0:o.length;for(this.__data__=new ni;++a<u;)this.add(o[a])}function fw(o){return this.__data__.set(o,s),this}function hw(o){return this.__data__.has(o)}lo.prototype.add=lo.prototype.push=fw,lo.prototype.has=hw;function Tn(o){var a=this.__data__=new ri(o);this.size=a.size}function pw(){this.__data__=new ri,this.size=0}function dw(o){var a=this.__data__,u=a.delete(o);return this.size=a.size,u}function mw(o){return this.__data__.get(o)}function gw(o){return this.__data__.has(o)}function yw(o,a){var u=this.__data__;if(u instanceof ri){var p=u.__data__;if(!ks||p.length<t-1)return p.push([o,a]),this.size=++u.size,this;u=this.__data__=new ni(p)}return u.set(o,a),this.size=u.size,this}Tn.prototype.clear=pw,Tn.prototype.delete=dw,Tn.prototype.get=mw,Tn.prototype.has=gw,Tn.prototype.set=yw;function Cd(o,a){var u=ke(o),p=!u&&po(o),m=!u&&!p&&Di(o),v=!u&&!p&&!m&&qo(o),N=u||p||m||v,L=N?Yu(o.length,TS):[],I=L.length;for(var Q in o)(a||pt.call(o,Q))&&!(N&&(Q=="length"||m&&(Q=="offset"||Q=="parent")||v&&(Q=="buffer"||Q=="byteLength"||Q=="byteOffset")||ai(Q,I)))&&L.push(Q);return L}function Ld(o){var a=o.length;return a?o[gf(0,a-1)]:i}function xw(o,a){return Ol(Or(o),co(a,0,o.length))}function vw(o){return Ol(Or(o))}function sf(o,a,u){(u!==i&&!In(o[a],u)||u===i&&!(a in o))&&ii(o,a,u)}function $s(o,a,u){var p=o[a];(!(pt.call(o,a)&&In(p,u))||u===i&&!(a in o))&&ii(o,a,u)}function xl(o,a){for(var u=o.length;u--;)if(In(o[u][0],a))return u;return-1}function bw(o,a,u,p){return Mi(o,function(m,v,N){a(p,m,u(m),N)}),p}function _d(o,a){return o&&Fn(a,nr(a),o)}function Sw(o,a){return o&&Fn(a,Dr(a),o)}function ii(o,a,u){a=="__proto__"&&hl?hl(o,a,{configurable:!0,enumerable:!0,value:u,writable:!0}):o[a]=u}function af(o,a){for(var u=-1,p=a.length,m=V(p),v=o==null;++u<p;)m[u]=v?i:Vf(o,a[u]);return m}function co(o,a,u){return o===o&&(u!==i&&(o=o<=u?o:u),a!==i&&(o=o>=a?o:a)),o}function cn(o,a,u,p,m,v){var N,L=a&f,I=a&h,Q=a&d;if(u&&(N=m?u(o,p,m,v):u(o)),N!==i)return N;if(!Dt(o))return o;var te=ke(o);if(te){if(N=c1(o),!L)return Or(o,N)}else{var ie=mr(o),me=ie==K||ie==ae;if(Di(o))return Xd(o,L);if(ie==le||ie==_||me&&!m){if(N=I||me?{}:mm(o),!L)return I?Yw(o,Sw(N,o)):Zw(o,_d(N,o))}else{if(!wt[ie])return m?o:{};N=u1(o,ie,L)}}v||(v=new Tn);var Le=v.get(o);if(Le)return Le;v.set(o,N),Hm(o)?o.forEach(function(je){N.add(cn(je,a,u,je,o,v))}):Um(o)&&o.forEach(function(je,et){N.set(et,cn(je,a,u,et,o,v))});var Re=Q?I?Tf:_f:I?Dr:nr,Je=te?i:Re(o);return sn(Je||o,function(je,et){Je&&(et=je,je=o[et]),$s(N,et,cn(je,a,u,et,o,v))}),N}function ww(o){var a=nr(o);return function(u){return Td(u,o,a)}}function Td(o,a,u){var p=u.length;if(o==null)return!p;for(o=yt(o);p--;){var m=u[p],v=a[m],N=o[m];if(N===i&&!(m in o)||!v(N))return!1}return!0}function Id(o,a,u){if(typeof o!="function")throw new an(n);return ea(function(){o.apply(i,u)},a)}function Js(o,a,u,p){var m=-1,v=tl,N=!0,L=o.length,I=[],Q=a.length;if(!L)return I;u&&(a=Ot(a,Wr(u))),p?(v=qu,N=!1):a.length>=t&&(v=Vs,N=!1,a=new lo(a));e:for(;++m<L;){var te=o[m],ie=u==null?te:u(te);if(te=p||te!==0?te:0,N&&ie===ie){for(var me=Q;me--;)if(a[me]===ie)continue e;I.push(te)}else v(a,ie,p)||I.push(te)}return I}var Mi=tm(zn),Md=tm(cf,!0);function Nw(o,a){var u=!0;return Mi(o,function(p,m,v){return u=!!a(p,m,v),u}),u}function vl(o,a,u){for(var p=-1,m=o.length;++p<m;){var v=o[p],N=a(v);if(N!=null&&(L===i?N===N&&!$r(N):u(N,L)))var L=N,I=v}return I}function Cw(o,a,u,p){var m=o.length;for(u=We(u),u<0&&(u=-u>m?0:m+u),p=p===i||p>m?m:We(p),p<0&&(p+=m),p=u>p?0:qm(p);u<p;)o[u++]=a;return o}function Ad(o,a){var u=[];return Mi(o,function(p,m,v){a(p,m,v)&&u.push(p)}),u}function lr(o,a,u,p,m){var v=-1,N=o.length;for(u||(u=h1),m||(m=[]);++v<N;){var L=o[v];a>0&&u(L)?a>1?lr(L,a-1,u,p,m):Li(m,L):p||(m[m.length]=L)}return m}var lf=rm(),Od=rm(!0);function zn(o,a){return o&&lf(o,a,nr)}function cf(o,a){return o&&Od(o,a,nr)}function bl(o,a){return Ci(a,function(u){return li(o[u])})}function uo(o,a){a=Oi(a,o);for(var u=0,p=a.length;o!=null&&u<p;)o=o[Vn(a[u++])];return u&&u==p?o:i}function Pd(o,a,u){var p=a(o);return ke(o)?p:Li(p,u(o))}function br(o){return o==null?o===i?Ge:Y:so&&so in yt(o)?s1(o):v1(o)}function uf(o,a){return o>a}function Lw(o,a){return o!=null&&pt.call(o,a)}function _w(o,a){return o!=null&&a in yt(o)}function Tw(o,a,u){return o>=dr(a,u)&&o<Xt(a,u)}function ff(o,a,u){for(var p=u?qu:tl,m=o[0].length,v=o.length,N=v,L=V(v),I=1/0,Q=[];N--;){var te=o[N];N&&a&&(te=Ot(te,Wr(a))),I=dr(te.length,I),L[N]=!u&&(a||m>=120&&te.length>=120)?new lo(N&&te):i}te=o[0];var ie=-1,me=L[0];e:for(;++ie<m&&Q.length<I;){var Le=te[ie],Re=a?a(Le):Le;if(Le=u||Le!==0?Le:0,!(me?Vs(me,Re):p(Q,Re,u))){for(N=v;--N;){var Je=L[N];if(!(Je?Vs(Je,Re):p(o[N],Re,u)))continue e}me&&me.push(Re),Q.push(Le)}}return Q}function Iw(o,a,u,p){return zn(o,function(m,v,N){a(p,u(m),v,N)}),p}function Ks(o,a,u){a=Oi(a,o),o=vm(o,a);var p=o==null?o:o[Vn(fn(a))];return p==null?i:Hr(p,o,u)}function Dd(o){return Gt(o)&&br(o)==_}function Mw(o){return Gt(o)&&br(o)==Lt}function Aw(o){return Gt(o)&&br(o)==se}function Xs(o,a,u,p,m){return o===a?!0:o==null||a==null||!Gt(o)&&!Gt(a)?o!==o&&a!==a:Ow(o,a,u,p,Xs,m)}function Ow(o,a,u,p,m,v){var N=ke(o),L=ke(a),I=N?J:mr(o),Q=L?J:mr(a);I=I==_?le:I,Q=Q==_?le:Q;var te=I==le,ie=Q==le,me=I==Q;if(me&&Di(o)){if(!Di(a))return!1;N=!0,te=!1}if(me&&!te)return v||(v=new Tn),N||qo(o)?hm(o,a,u,p,m,v):i1(o,a,I,u,p,m,v);if(!(u&x)){var Le=te&&pt.call(o,"__wrapped__"),Re=ie&&pt.call(a,"__wrapped__");if(Le||Re){var Je=Le?o.value():o,je=Re?a.value():a;return v||(v=new Tn),m(Je,je,u,p,v)}}return me?(v||(v=new Tn),o1(o,a,u,p,m,v)):!1}function Pw(o){return Gt(o)&&mr(o)==ne}function hf(o,a,u,p){var m=u.length,v=m,N=!p;if(o==null)return!v;for(o=yt(o);m--;){var L=u[m];if(N&&L[2]?L[1]!==o[L[0]]:!(L[0]in o))return!1}for(;++m<v;){L=u[m];var I=L[0],Q=o[I],te=L[1];if(N&&L[2]){if(Q===i&&!(I in o))return!1}else{var ie=new Tn;if(p)var me=p(Q,te,I,o,a,ie);if(!(me===i?Xs(te,Q,x|g,p,ie):me))return!1}}return!0}function Bd(o){if(!Dt(o)||d1(o))return!1;var a=li(o)?PS:wb;return a.test(ho(o))}function Dw(o){return Gt(o)&&br(o)==_e}function Bw(o){return Gt(o)&&mr(o)==de}function Gw(o){return Gt(o)&&El(o.length)&&!!_t[br(o)]}function Gd(o){return typeof o=="function"?o:o==null?Br:typeof o=="object"?ke(o)?Rd(o[0],o[1]):Ed(o):ng(o)}function pf(o){if(!Qs(o))return RS(o);var a=[];for(var u in yt(o))pt.call(o,u)&&u!="constructor"&&a.push(u);return a}function jw(o){if(!Dt(o))return x1(o);var a=Qs(o),u=[];for(var p in o)p=="constructor"&&(a||!pt.call(o,p))||u.push(p);return u}function df(o,a){return o<a}function jd(o,a){var u=-1,p=Pr(o)?V(o.length):[];return Mi(o,function(m,v,N){p[++u]=a(m,v,N)}),p}function Ed(o){var a=Mf(o);return a.length==1&&a[0][2]?ym(a[0][0],a[0][1]):function(u){return u===o||hf(u,o,a)}}function Rd(o,a){return Of(o)&&gm(a)?ym(Vn(o),a):function(u){var p=Vf(u,o);return p===i&&p===a?Uf(u,o):Xs(a,p,x|g)}}function Sl(o,a,u,p,m){o!==a&&lf(a,function(v,N){if(m||(m=new Tn),Dt(v))Ew(o,a,N,u,Sl,p,m);else{var L=p?p(Df(o,N),v,N+"",o,a,m):i;L===i&&(L=v),sf(o,N,L)}},Dr)}function Ew(o,a,u,p,m,v,N){var L=Df(o,u),I=Df(a,u),Q=N.get(I);if(Q){sf(o,u,Q);return}var te=v?v(L,I,u+"",o,a,N):i,ie=te===i;if(ie){var me=ke(I),Le=!me&&Di(I),Re=!me&&!Le&&qo(I);te=I,me||Le||Re?ke(L)?te=L:zt(L)?te=Or(L):Le?(ie=!1,te=Xd(I,!0)):Re?(ie=!1,te=Zd(I,!0)):te=[]:ta(I)||po(I)?(te=L,po(L)?te=$m(L):(!Dt(L)||li(L))&&(te=mm(I))):ie=!1}ie&&(N.set(I,te),m(te,I,p,v,N),N.delete(I)),sf(o,u,te)}function zd(o,a){var u=o.length;if(!!u)return a+=a<0?u:0,ai(a,u)?o[a]:i}function Fd(o,a,u){a.length?a=Ot(a,function(v){return ke(v)?function(N){return uo(N,v.length===1?v[0]:v)}:v}):a=[Br];var p=-1;a=Ot(a,Wr(De()));var m=jd(o,function(v,N,L){var I=Ot(a,function(Q){return Q(v)});return{criteria:I,index:++p,value:v}});return uS(m,function(v,N){return Xw(v,N,u)})}function Rw(o,a){return Vd(o,a,function(u,p){return Uf(o,p)})}function Vd(o,a,u){for(var p=-1,m=a.length,v={};++p<m;){var N=a[p],L=uo(o,N);u(L,N)&&Zs(v,Oi(N,o),L)}return v}function zw(o){return function(a){return uo(a,o)}}function mf(o,a,u,p){var m=p?cS:jo,v=-1,N=a.length,L=o;for(o===a&&(a=Or(a)),u&&(L=Ot(o,Wr(u)));++v<N;)for(var I=0,Q=a[v],te=u?u(Q):Q;(I=m(L,te,I,p))>-1;)L!==o&&fl.call(L,I,1),fl.call(o,I,1);return o}function Ud(o,a){for(var u=o?a.length:0,p=u-1;u--;){var m=a[u];if(u==p||m!==v){var v=m;ai(m)?fl.call(o,m,1):vf(o,m)}}return o}function gf(o,a){return o+dl(wd()*(a-o+1))}function Fw(o,a,u,p){for(var m=-1,v=Xt(pl((a-o)/(u||1)),0),N=V(v);v--;)N[p?v:++m]=o,o+=u;return N}function yf(o,a){var u="";if(!o||a<1||a>re)return u;do a%2&&(u+=o),a=dl(a/2),a&&(o+=o);while(a);return u}function Ze(o,a){return Bf(xm(o,a,Br),o+"")}function Vw(o){return Ld($o(o))}function Uw(o,a){var u=$o(o);return Ol(u,co(a,0,u.length))}function Zs(o,a,u,p){if(!Dt(o))return o;a=Oi(a,o);for(var m=-1,v=a.length,N=v-1,L=o;L!=null&&++m<v;){var I=Vn(a[m]),Q=u;if(I==="__proto__"||I==="constructor"||I==="prototype")return o;if(m!=N){var te=L[I];Q=p?p(te,I,L):i,Q===i&&(Q=Dt(te)?te:ai(a[m+1])?[]:{})}$s(L,I,Q),L=L[I]}return o}var kd=ml?function(o,a){return ml.set(o,a),o}:Br,kw=hl?function(o,a){return hl(o,"toString",{configurable:!0,enumerable:!1,value:Hf(a),writable:!0})}:Br;function Hw(o){return Ol($o(o))}function un(o,a,u){var p=-1,m=o.length;a<0&&(a=-a>m?0:m+a),u=u>m?m:u,u<0&&(u+=m),m=a>u?0:u-a>>>0,a>>>=0;for(var v=V(m);++p<m;)v[p]=o[p+a];return v}function Ww(o,a){var u;return Mi(o,function(p,m,v){return u=a(p,m,v),!u}),!!u}function wl(o,a,u){var p=0,m=o==null?p:o.length;if(typeof a=="number"&&a===a&&m<=k){for(;p<m;){var v=p+m>>>1,N=o[v];N!==null&&!$r(N)&&(u?N<=a:N<a)?p=v+1:m=v}return m}return xf(o,a,Br,u)}function xf(o,a,u,p){var m=0,v=o==null?0:o.length;if(v===0)return 0;a=u(a);for(var N=a!==a,L=a===null,I=$r(a),Q=a===i;m<v;){var te=dl((m+v)/2),ie=u(o[te]),me=ie!==i,Le=ie===null,Re=ie===ie,Je=$r(ie);if(N)var je=p||Re;else Q?je=Re&&(p||me):L?je=Re&&me&&(p||!Le):I?je=Re&&me&&!Le&&(p||!Je):Le||Je?je=!1:je=p?ie<=a:ie<a;je?m=te+1:v=te}return dr(v,Fe)}function Hd(o,a){for(var u=-1,p=o.length,m=0,v=[];++u<p;){var N=o[u],L=a?a(N):N;if(!u||!In(L,I)){var I=L;v[m++]=N===0?0:N}}return v}function Wd(o){return typeof o=="number"?o:$r(o)?ye:+o}function qr(o){if(typeof o=="string")return o;if(ke(o))return Ot(o,qr)+"";if($r(o))return Nd?Nd.call(o):"";var a=o+"";return a=="0"&&1/o==-he?"-0":a}function Ai(o,a,u){var p=-1,m=tl,v=o.length,N=!0,L=[],I=L;if(u)N=!1,m=qu;else if(v>=t){var Q=a?null:r1(o);if(Q)return nl(Q);N=!1,m=Vs,I=new lo}else I=a?[]:L;e:for(;++p<v;){var te=o[p],ie=a?a(te):te;if(te=u||te!==0?te:0,N&&ie===ie){for(var me=I.length;me--;)if(I[me]===ie)continue e;a&&I.push(ie),L.push(te)}else m(I,ie,u)||(I!==L&&I.push(ie),L.push(te))}return L}function vf(o,a){return a=Oi(a,o),o=vm(o,a),o==null||delete o[Vn(fn(a))]}function qd(o,a,u,p){return Zs(o,a,u(uo(o,a)),p)}function Nl(o,a,u,p){for(var m=o.length,v=p?m:-1;(p?v--:++v<m)&&a(o[v],v,o););return u?un(o,p?0:v,p?v+1:m):un(o,p?v+1:0,p?m:v)}function $d(o,a){var u=o;return u instanceof rt&&(u=u.value()),$u(a,function(p,m){return m.func.apply(m.thisArg,Li([p],m.args))},u)}function bf(o,a,u){var p=o.length;if(p<2)return p?Ai(o[0]):[];for(var m=-1,v=V(p);++m<p;)for(var N=o[m],L=-1;++L<p;)L!=m&&(v[m]=Js(v[m]||N,o[L],a,u));return Ai(lr(v,1),a,u)}function Jd(o,a,u){for(var p=-1,m=o.length,v=a.length,N={};++p<m;){var L=p<v?a[p]:i;u(N,o[p],L)}return N}function Sf(o){return zt(o)?o:[]}function wf(o){return typeof o=="function"?o:Br}function Oi(o,a){return ke(o)?o:Of(o,a)?[o]:Nm(ut(o))}var qw=Ze;function Pi(o,a,u){var p=o.length;return u=u===i?p:u,!a&&u>=p?o:un(o,a,u)}var Kd=DS||function(o){return rr.clearTimeout(o)};function Xd(o,a){if(a)return o.slice();var u=o.length,p=yd?yd(u):new o.constructor(u);return o.copy(p),p}function Nf(o){var a=new o.constructor(o.byteLength);return new cl(a).set(new cl(o)),a}function $w(o,a){var u=a?Nf(o.buffer):o.buffer;return new o.constructor(u,o.byteOffset,o.byteLength)}function Jw(o){var a=new o.constructor(o.source,Ln.exec(o));return a.lastIndex=o.lastIndex,a}function Kw(o){return qs?yt(qs.call(o)):{}}function Zd(o,a){var u=a?Nf(o.buffer):o.buffer;return new o.constructor(u,o.byteOffset,o.length)}function Yd(o,a){if(o!==a){var u=o!==i,p=o===null,m=o===o,v=$r(o),N=a!==i,L=a===null,I=a===a,Q=$r(a);if(!L&&!Q&&!v&&o>a||v&&N&&I&&!L&&!Q||p&&N&&I||!u&&I||!m)return 1;if(!p&&!v&&!Q&&o<a||Q&&u&&m&&!p&&!v||L&&u&&m||!N&&m||!I)return-1}return 0}function Xw(o,a,u){for(var p=-1,m=o.criteria,v=a.criteria,N=m.length,L=u.length;++p<N;){var I=Yd(m[p],v[p]);if(I){if(p>=L)return I;var Q=u[p];return I*(Q=="desc"?-1:1)}}return o.index-a.index}function Qd(o,a,u,p){for(var m=-1,v=o.length,N=u.length,L=-1,I=a.length,Q=Xt(v-N,0),te=V(I+Q),ie=!p;++L<I;)te[L]=a[L];for(;++m<N;)(ie||m<v)&&(te[u[m]]=o[m]);for(;Q--;)te[L++]=o[m++];return te}function em(o,a,u,p){for(var m=-1,v=o.length,N=-1,L=u.length,I=-1,Q=a.length,te=Xt(v-L,0),ie=V(te+Q),me=!p;++m<te;)ie[m]=o[m];for(var Le=m;++I<Q;)ie[Le+I]=a[I];for(;++N<L;)(me||m<v)&&(ie[Le+u[N]]=o[m++]);return ie}function Or(o,a){var u=-1,p=o.length;for(a||(a=V(p));++u<p;)a[u]=o[u];return a}function Fn(o,a,u,p){var m=!u;u||(u={});for(var v=-1,N=a.length;++v<N;){var L=a[v],I=p?p(u[L],o[L],L,u,o):i;I===i&&(I=o[L]),m?ii(u,L,I):$s(u,L,I)}return u}function Zw(o,a){return Fn(o,Af(o),a)}function Yw(o,a){return Fn(o,pm(o),a)}function Cl(o,a){return function(u,p){var m=ke(u)?nS:bw,v=a?a():{};return m(u,o,De(p,2),v)}}function ko(o){return Ze(function(a,u){var p=-1,m=u.length,v=m>1?u[m-1]:i,N=m>2?u[2]:i;for(v=o.length>3&&typeof v=="function"?(m--,v):i,N&&Sr(u[0],u[1],N)&&(v=m<3?i:v,m=1),a=yt(a);++p<m;){var L=u[p];L&&o(a,L,p,v)}return a})}function tm(o,a){return function(u,p){if(u==null)return u;if(!Pr(u))return o(u,p);for(var m=u.length,v=a?m:-1,N=yt(u);(a?v--:++v<m)&&p(N[v],v,N)!==!1;);return u}}function rm(o){return function(a,u,p){for(var m=-1,v=yt(a),N=p(a),L=N.length;L--;){var I=N[o?L:++m];if(u(v[I],I,v)===!1)break}return a}}function Qw(o,a,u){var p=a&w,m=Ys(o);function v(){var N=this&&this!==rr&&this instanceof v?m:o;return N.apply(p?u:this,arguments)}return v}function nm(o){return function(a){a=ut(a);var u=Eo(a)?_n(a):i,p=u?u[0]:a.charAt(0),m=u?Pi(u,1).join(""):a.slice(1);return p[o]()+m}}function Ho(o){return function(a){return $u(tg(eg(a).replace(kb,"")),o,"")}}function Ys(o){return function(){var a=arguments;switch(a.length){case 0:return new o;case 1:return new o(a[0]);case 2:return new o(a[0],a[1]);case 3:return new o(a[0],a[1],a[2]);case 4:return new o(a[0],a[1],a[2],a[3]);case 5:return new o(a[0],a[1],a[2],a[3],a[4]);case 6:return new o(a[0],a[1],a[2],a[3],a[4],a[5]);case 7:return new o(a[0],a[1],a[2],a[3],a[4],a[5],a[6])}var u=Uo(o.prototype),p=o.apply(u,a);return Dt(p)?p:u}}function e1(o,a,u){var p=Ys(o);function m(){for(var v=arguments.length,N=V(v),L=v,I=Wo(m);L--;)N[L]=arguments[L];var Q=v<3&&N[0]!==I&&N[v-1]!==I?[]:_i(N,I);if(v-=Q.length,v<u)return lm(o,a,Ll,m.placeholder,i,N,Q,i,i,u-v);var te=this&&this!==rr&&this instanceof m?p:o;return Hr(te,this,N)}return m}function im(o){return function(a,u,p){var m=yt(a);if(!Pr(a)){var v=De(u,3);a=nr(a),u=function(L){return v(m[L],L,m)}}var N=o(a,u,p);return N>-1?m[v?a[N]:N]:i}}function om(o){return si(function(a){var u=a.length,p=u,m=ln.prototype.thru;for(o&&a.reverse();p--;){var v=a[p];if(typeof v!="function")throw new an(n);if(m&&!N&&Ml(v)=="wrapper")var N=new ln([],!0)}for(p=N?p:u;++p<u;){v=a[p];var L=Ml(v),I=L=="wrapper"?If(v):i;I&&Pf(I[0])&&I[1]==(W|C|B|M)&&!I[4].length&&I[9]==1?N=N[Ml(I[0])].apply(N,I[3]):N=v.length==1&&Pf(v)?N[L]():N.thru(v)}return function(){var Q=arguments,te=Q[0];if(N&&Q.length==1&&ke(te))return N.plant(te).value();for(var ie=0,me=u?a[ie].apply(this,Q):te;++ie<u;)me=a[ie].call(this,me);return me}})}function Ll(o,a,u,p,m,v,N,L,I,Q){var te=a&W,ie=a&w,me=a&S,Le=a&(C|G),Re=a&q,Je=me?i:Ys(o);function je(){for(var et=arguments.length,nt=V(et),Jr=et;Jr--;)nt[Jr]=arguments[Jr];if(Le)var wr=Wo(je),Kr=hS(nt,wr);if(p&&(nt=Qd(nt,p,m,Le)),v&&(nt=em(nt,v,N,Le)),et-=Kr,Le&&et<Q){var Ft=_i(nt,wr);return lm(o,a,Ll,je.placeholder,u,nt,Ft,L,I,Q-et)}var Mn=ie?u:this,ui=me?Mn[o]:o;return et=nt.length,L?nt=b1(nt,L):Re&&et>1&&nt.reverse(),te&&I<et&&(nt.length=I),this&&this!==rr&&this instanceof je&&(ui=Je||Ys(ui)),ui.apply(Mn,nt)}return je}function sm(o,a){return function(u,p){return Iw(u,o,a(p),{})}}function _l(o,a){return function(u,p){var m;if(u===i&&p===i)return a;if(u!==i&&(m=u),p!==i){if(m===i)return p;typeof u=="string"||typeof p=="string"?(u=qr(u),p=qr(p)):(u=Wd(u),p=Wd(p)),m=o(u,p)}return m}}function Cf(o){return si(function(a){return a=Ot(a,Wr(De())),Ze(function(u){var p=this;return o(a,function(m){return Hr(m,p,u)})})})}function Tl(o,a){a=a===i?" ":qr(a);var u=a.length;if(u<2)return u?yf(a,o):a;var p=yf(a,pl(o/Ro(a)));return Eo(a)?Pi(_n(p),0,o).join(""):p.slice(0,o)}function t1(o,a,u,p){var m=a&w,v=Ys(o);function N(){for(var L=-1,I=arguments.length,Q=-1,te=p.length,ie=V(te+I),me=this&&this!==rr&&this instanceof N?v:o;++Q<te;)ie[Q]=p[Q];for(;I--;)ie[Q++]=arguments[++L];return Hr(me,m?u:this,ie)}return N}function am(o){return function(a,u,p){return p&&typeof p!="number"&&Sr(a,u,p)&&(u=p=i),a=ci(a),u===i?(u=a,a=0):u=ci(u),p=p===i?a<u?1:-1:ci(p),Fw(a,u,p,o)}}function Il(o){return function(a,u){return typeof a=="string"&&typeof u=="string"||(a=hn(a),u=hn(u)),o(a,u)}}function lm(o,a,u,p,m,v,N,L,I,Q){var te=a&C,ie=te?N:i,me=te?i:N,Le=te?v:i,Re=te?i:v;a|=te?B:P,a&=~(te?P:B),a&D||(a&=~(w|S));var Je=[o,a,m,Le,ie,Re,me,L,I,Q],je=u.apply(i,Je);return Pf(o)&&bm(je,Je),je.placeholder=p,Sm(je,o,a)}function Lf(o){var a=Kt[o];return function(u,p){if(u=hn(u),p=p==null?0:dr(We(p),292),p&&Sd(u)){var m=(ut(u)+"e").split("e"),v=a(m[0]+"e"+(+m[1]+p));return m=(ut(v)+"e").split("e"),+(m[0]+"e"+(+m[1]-p))}return a(u)}}var r1=Fo&&1/nl(new Fo([,-0]))[1]==he?function(o){return new Fo(o)}:$f;function cm(o){return function(a){var u=mr(a);return u==ne?ef(a):u==de?vS(a):fS(a,o(a))}}function oi(o,a,u,p,m,v,N,L){var I=a&S;if(!I&&typeof o!="function")throw new an(n);var Q=p?p.length:0;if(Q||(a&=~(B|P),p=m=i),N=N===i?N:Xt(We(N),0),L=L===i?L:We(L),Q-=m?m.length:0,a&P){var te=p,ie=m;p=m=i}var me=I?i:If(o),Le=[o,a,u,p,m,te,ie,v,N,L];if(me&&y1(Le,me),o=Le[0],a=Le[1],u=Le[2],p=Le[3],m=Le[4],L=Le[9]=Le[9]===i?I?0:o.length:Xt(Le[9]-Q,0),!L&&a&(C|G)&&(a&=~(C|G)),!a||a==w)var Re=Qw(o,a,u);else a==C||a==G?Re=e1(o,a,L):(a==B||a==(w|B))&&!m.length?Re=t1(o,a,u,p):Re=Ll.apply(i,Le);var Je=me?kd:bm;return Sm(Je(Re,Le),o,a)}function um(o,a,u,p){return o===i||In(o,zo[u])&&!pt.call(p,u)?a:o}function fm(o,a,u,p,m,v){return Dt(o)&&Dt(a)&&(v.set(a,o),Sl(o,a,i,fm,v),v.delete(a)),o}function n1(o){return ta(o)?i:o}function hm(o,a,u,p,m,v){var N=u&x,L=o.length,I=a.length;if(L!=I&&!(N&&I>L))return!1;var Q=v.get(o),te=v.get(a);if(Q&&te)return Q==a&&te==o;var ie=-1,me=!0,Le=u&g?new lo:i;for(v.set(o,a),v.set(a,o);++ie<L;){var Re=o[ie],Je=a[ie];if(p)var je=N?p(Je,Re,ie,a,o,v):p(Re,Je,ie,o,a,v);if(je!==i){if(je)continue;me=!1;break}if(Le){if(!Ju(a,function(et,nt){if(!Vs(Le,nt)&&(Re===et||m(Re,et,u,p,v)))return Le.push(nt)})){me=!1;break}}else if(!(Re===Je||m(Re,Je,u,p,v))){me=!1;break}}return v.delete(o),v.delete(a),me}function i1(o,a,u,p,m,v,N){switch(u){case At:if(o.byteLength!=a.byteLength||o.byteOffset!=a.byteOffset)return!1;o=o.buffer,a=a.buffer;case Lt:return!(o.byteLength!=a.byteLength||!v(new cl(o),new cl(a)));case oe:case se:case Ce:return In(+o,+a);case ue:return o.name==a.name&&o.message==a.message;case _e:case we:return o==a+"";case ne:var L=ef;case de:var I=p&x;if(L||(L=nl),o.size!=a.size&&!I)return!1;var Q=N.get(o);if(Q)return Q==a;p|=g,N.set(o,a);var te=hm(L(o),L(a),p,m,v,N);return N.delete(o),te;case Ve:if(qs)return qs.call(o)==qs.call(a)}return!1}function o1(o,a,u,p,m,v){var N=u&x,L=_f(o),I=L.length,Q=_f(a),te=Q.length;if(I!=te&&!N)return!1;for(var ie=I;ie--;){var me=L[ie];if(!(N?me in a:pt.call(a,me)))return!1}var Le=v.get(o),Re=v.get(a);if(Le&&Re)return Le==a&&Re==o;var Je=!0;v.set(o,a),v.set(a,o);for(var je=N;++ie<I;){me=L[ie];var et=o[me],nt=a[me];if(p)var Jr=N?p(nt,et,me,a,o,v):p(et,nt,me,o,a,v);if(!(Jr===i?et===nt||m(et,nt,u,p,v):Jr)){Je=!1;break}je||(je=me=="constructor")}if(Je&&!je){var wr=o.constructor,Kr=a.constructor;wr!=Kr&&"constructor"in o&&"constructor"in a&&!(typeof wr=="function"&&wr instanceof wr&&typeof Kr=="function"&&Kr instanceof Kr)&&(Je=!1)}return v.delete(o),v.delete(a),Je}function si(o){return Bf(xm(o,i,Tm),o+"")}function _f(o){return Pd(o,nr,Af)}function Tf(o){return Pd(o,Dr,pm)}var If=ml?function(o){return ml.get(o)}:$f;function Ml(o){for(var a=o.name+"",u=Vo[a],p=pt.call(Vo,a)?u.length:0;p--;){var m=u[p],v=m.func;if(v==null||v==o)return m.name}return a}function Wo(o){var a=pt.call(y,"placeholder")?y:o;return a.placeholder}function De(){var o=y.iteratee||Wf;return o=o===Wf?Gd:o,arguments.length?o(arguments[0],arguments[1]):o}function Al(o,a){var u=o.__data__;return p1(a)?u[typeof a=="string"?"string":"hash"]:u.map}function Mf(o){for(var a=nr(o),u=a.length;u--;){var p=a[u],m=o[p];a[u]=[p,m,gm(m)]}return a}function fo(o,a){var u=gS(o,a);return Bd(u)?u:i}function s1(o){var a=pt.call(o,so),u=o[so];try{o[so]=i;var p=!0}catch(v){}var m=al.call(o);return p&&(a?o[so]=u:delete o[so]),m}var Af=rf?function(o){return o==null?[]:(o=yt(o),Ci(rf(o),function(a){return vd.call(o,a)}))}:Jf,pm=rf?function(o){for(var a=[];o;)Li(a,Af(o)),o=ul(o);return a}:Jf,mr=br;(nf&&mr(new nf(new ArrayBuffer(1)))!=At||ks&&mr(new ks)!=ne||of&&mr(of.resolve())!=pe||Fo&&mr(new Fo)!=de||Hs&&mr(new Hs)!=Qe)&&(mr=function(o){var a=br(o),u=a==le?o.constructor:i,p=u?ho(u):"";if(p)switch(p){case US:return At;case kS:return ne;case HS:return pe;case WS:return de;case qS:return Qe}return a});function a1(o,a,u){for(var p=-1,m=u.length;++p<m;){var v=u[p],N=v.size;switch(v.type){case"drop":o+=N;break;case"dropRight":a-=N;break;case"take":a=dr(a,o+N);break;case"takeRight":o=Xt(o,a-N);break}}return{start:o,end:a}}function l1(o){var a=o.match(ct);return a?a[1].split(St):[]}function dm(o,a,u){a=Oi(a,o);for(var p=-1,m=a.length,v=!1;++p<m;){var N=Vn(a[p]);if(!(v=o!=null&&u(o,N)))break;o=o[N]}return v||++p!=m?v:(m=o==null?0:o.length,!!m&&El(m)&&ai(N,m)&&(ke(o)||po(o)))}function c1(o){var a=o.length,u=new o.constructor(a);return a&&typeof o[0]=="string"&&pt.call(o,"index")&&(u.index=o.index,u.input=o.input),u}function mm(o){return typeof o.constructor=="function"&&!Qs(o)?Uo(ul(o)):{}}function u1(o,a,u){var p=o.constructor;switch(a){case Lt:return Nf(o);case oe:case se:return new p(+o);case At:return $w(o,u);case sr:case Ur:case Ht:case kr:case wn:case Nn:case dt:case Wt:case ar:return Zd(o,u);case ne:return new p;case Ce:case we:return new p(o);case _e:return Jw(o);case de:return new p;case Ve:return Kw(o)}}function f1(o,a){var u=a.length;if(!u)return o;var p=u-1;return a[p]=(u>1?"& ":"")+a[p],a=a.join(u>2?", ":" "),o.replace(gt,`{
2
- /* [wrapped with `+a+`] */
3
- `)}function h1(o){return ke(o)||po(o)||!!(bd&&o&&o[bd])}function ai(o,a){var u=typeof o;return a=a==null?re:a,!!a&&(u=="number"||u!="symbol"&&Cb.test(o))&&o>-1&&o%1==0&&o<a}function Sr(o,a,u){if(!Dt(u))return!1;var p=typeof a;return(p=="number"?Pr(u)&&ai(a,u.length):p=="string"&&a in u)?In(u[a],o):!1}function Of(o,a){if(ke(o))return!1;var u=typeof o;return u=="number"||u=="symbol"||u=="boolean"||o==null||$r(o)?!0:Ee.test(o)||!Bo.test(o)||a!=null&&o in yt(a)}function p1(o){var a=typeof o;return a=="string"||a=="number"||a=="symbol"||a=="boolean"?o!=="__proto__":o===null}function Pf(o){var a=Ml(o),u=y[a];if(typeof u!="function"||!(a in rt.prototype))return!1;if(o===u)return!0;var p=If(u);return!!p&&o===p[0]}function d1(o){return!!gd&&gd in o}var m1=ol?li:Kf;function Qs(o){var a=o&&o.constructor,u=typeof a=="function"&&a.prototype||zo;return o===u}function gm(o){return o===o&&!Dt(o)}function ym(o,a){return function(u){return u==null?!1:u[o]===a&&(a!==i||o in yt(u))}}function g1(o){var a=Gl(o,function(p){return u.size===l&&u.clear(),p}),u=a.cache;return a}function y1(o,a){var u=o[1],p=a[1],m=u|p,v=m<(w|S|W),N=p==W&&u==C||p==W&&u==M&&o[7].length<=a[8]||p==(W|M)&&a[7].length<=a[8]&&u==C;if(!(v||N))return o;p&w&&(o[2]=a[2],m|=u&w?0:D);var L=a[3];if(L){var I=o[3];o[3]=I?Qd(I,L,a[4]):L,o[4]=I?_i(o[3],c):a[4]}return L=a[5],L&&(I=o[5],o[5]=I?em(I,L,a[6]):L,o[6]=I?_i(o[5],c):a[6]),L=a[7],L&&(o[7]=L),p&W&&(o[8]=o[8]==null?a[8]:dr(o[8],a[8])),o[9]==null&&(o[9]=a[9]),o[0]=a[0],o[1]=m,o}function x1(o){var a=[];if(o!=null)for(var u in yt(o))a.push(u);return a}function v1(o){return al.call(o)}function xm(o,a,u){return a=Xt(a===i?o.length-1:a,0),function(){for(var p=arguments,m=-1,v=Xt(p.length-a,0),N=V(v);++m<v;)N[m]=p[a+m];m=-1;for(var L=V(a+1);++m<a;)L[m]=p[m];return L[a]=u(N),Hr(o,this,L)}}function vm(o,a){return a.length<2?o:uo(o,un(a,0,-1))}function b1(o,a){for(var u=o.length,p=dr(a.length,u),m=Or(o);p--;){var v=a[p];o[p]=ai(v,u)?m[v]:i}return o}function Df(o,a){if(!(a==="constructor"&&typeof o[a]=="function")&&a!="__proto__")return o[a]}var bm=wm(kd),ea=GS||function(o,a){return rr.setTimeout(o,a)},Bf=wm(kw);function Sm(o,a,u){var p=a+"";return Bf(o,f1(p,S1(l1(p),u)))}function wm(o){var a=0,u=0;return function(){var p=zS(),m=T-(p-u);if(u=p,m>0){if(++a>=R)return arguments[0]}else a=0;return o.apply(i,arguments)}}function Ol(o,a){var u=-1,p=o.length,m=p-1;for(a=a===i?p:a;++u<a;){var v=gf(u,m),N=o[v];o[v]=o[u],o[u]=N}return o.length=a,o}var Nm=g1(function(o){var a=[];return o.charCodeAt(0)===46&&a.push(""),o.replace(Xe,function(u,p,m,v){a.push(m?v.replace(Ar,"$1"):p||u)}),a});function Vn(o){if(typeof o=="string"||$r(o))return o;var a=o+"";return a=="0"&&1/o==-he?"-0":a}function ho(o){if(o!=null){try{return sl.call(o)}catch(a){}try{return o+""}catch(a){}}return""}function S1(o,a){return sn(H,function(u){var p="_."+u[0];a&u[1]&&!tl(o,p)&&o.push(p)}),o.sort()}function Cm(o){if(o instanceof rt)return o.clone();var a=new ln(o.__wrapped__,o.__chain__);return a.__actions__=Or(o.__actions__),a.__index__=o.__index__,a.__values__=o.__values__,a}function w1(o,a,u){(u?Sr(o,a,u):a===i)?a=1:a=Xt(We(a),0);var p=o==null?0:o.length;if(!p||a<1)return[];for(var m=0,v=0,N=V(pl(p/a));m<p;)N[v++]=un(o,m,m+=a);return N}function N1(o){for(var a=-1,u=o==null?0:o.length,p=0,m=[];++a<u;){var v=o[a];v&&(m[p++]=v)}return m}function C1(){var o=arguments.length;if(!o)return[];for(var a=V(o-1),u=arguments[0],p=o;p--;)a[p-1]=arguments[p];return Li(ke(u)?Or(u):[u],lr(a,1))}var L1=Ze(function(o,a){return zt(o)?Js(o,lr(a,1,zt,!0)):[]}),_1=Ze(function(o,a){var u=fn(a);return zt(u)&&(u=i),zt(o)?Js(o,lr(a,1,zt,!0),De(u,2)):[]}),T1=Ze(function(o,a){var u=fn(a);return zt(u)&&(u=i),zt(o)?Js(o,lr(a,1,zt,!0),i,u):[]});function I1(o,a,u){var p=o==null?0:o.length;return p?(a=u||a===i?1:We(a),un(o,a<0?0:a,p)):[]}function M1(o,a,u){var p=o==null?0:o.length;return p?(a=u||a===i?1:We(a),a=p-a,un(o,0,a<0?0:a)):[]}function A1(o,a){return o&&o.length?Nl(o,De(a,3),!0,!0):[]}function O1(o,a){return o&&o.length?Nl(o,De(a,3),!0):[]}function P1(o,a,u,p){var m=o==null?0:o.length;return m?(u&&typeof u!="number"&&Sr(o,a,u)&&(u=0,p=m),Cw(o,a,u,p)):[]}function Lm(o,a,u){var p=o==null?0:o.length;if(!p)return-1;var m=u==null?0:We(u);return m<0&&(m=Xt(p+m,0)),rl(o,De(a,3),m)}function _m(o,a,u){var p=o==null?0:o.length;if(!p)return-1;var m=p-1;return u!==i&&(m=We(u),m=u<0?Xt(p+m,0):dr(m,p-1)),rl(o,De(a,3),m,!0)}function Tm(o){var a=o==null?0:o.length;return a?lr(o,1):[]}function D1(o){var a=o==null?0:o.length;return a?lr(o,he):[]}function B1(o,a){var u=o==null?0:o.length;return u?(a=a===i?1:We(a),lr(o,a)):[]}function G1(o){for(var a=-1,u=o==null?0:o.length,p={};++a<u;){var m=o[a];p[m[0]]=m[1]}return p}function Im(o){return o&&o.length?o[0]:i}function j1(o,a,u){var p=o==null?0:o.length;if(!p)return-1;var m=u==null?0:We(u);return m<0&&(m=Xt(p+m,0)),jo(o,a,m)}function E1(o){var a=o==null?0:o.length;return a?un(o,0,-1):[]}var R1=Ze(function(o){var a=Ot(o,Sf);return a.length&&a[0]===o[0]?ff(a):[]}),z1=Ze(function(o){var a=fn(o),u=Ot(o,Sf);return a===fn(u)?a=i:u.pop(),u.length&&u[0]===o[0]?ff(u,De(a,2)):[]}),F1=Ze(function(o){var a=fn(o),u=Ot(o,Sf);return a=typeof a=="function"?a:i,a&&u.pop(),u.length&&u[0]===o[0]?ff(u,i,a):[]});function V1(o,a){return o==null?"":ES.call(o,a)}function fn(o){var a=o==null?0:o.length;return a?o[a-1]:i}function U1(o,a,u){var p=o==null?0:o.length;if(!p)return-1;var m=p;return u!==i&&(m=We(u),m=m<0?Xt(p+m,0):dr(m,p-1)),a===a?SS(o,a,m):rl(o,ud,m,!0)}function k1(o,a){return o&&o.length?zd(o,We(a)):i}var H1=Ze(Mm);function Mm(o,a){return o&&o.length&&a&&a.length?mf(o,a):o}function W1(o,a,u){return o&&o.length&&a&&a.length?mf(o,a,De(u,2)):o}function q1(o,a,u){return o&&o.length&&a&&a.length?mf(o,a,i,u):o}var $1=si(function(o,a){var u=o==null?0:o.length,p=af(o,a);return Ud(o,Ot(a,function(m){return ai(m,u)?+m:m}).sort(Yd)),p});function J1(o,a){var u=[];if(!(o&&o.length))return u;var p=-1,m=[],v=o.length;for(a=De(a,3);++p<v;){var N=o[p];a(N,p,o)&&(u.push(N),m.push(p))}return Ud(o,m),u}function Gf(o){return o==null?o:VS.call(o)}function K1(o,a,u){var p=o==null?0:o.length;return p?(u&&typeof u!="number"&&Sr(o,a,u)?(a=0,u=p):(a=a==null?0:We(a),u=u===i?p:We(u)),un(o,a,u)):[]}function X1(o,a){return wl(o,a)}function Z1(o,a,u){return xf(o,a,De(u,2))}function Y1(o,a){var u=o==null?0:o.length;if(u){var p=wl(o,a);if(p<u&&In(o[p],a))return p}return-1}function Q1(o,a){return wl(o,a,!0)}function eN(o,a,u){return xf(o,a,De(u,2),!0)}function tN(o,a){var u=o==null?0:o.length;if(u){var p=wl(o,a,!0)-1;if(In(o[p],a))return p}return-1}function rN(o){return o&&o.length?Hd(o):[]}function nN(o,a){return o&&o.length?Hd(o,De(a,2)):[]}function iN(o){var a=o==null?0:o.length;return a?un(o,1,a):[]}function oN(o,a,u){return o&&o.length?(a=u||a===i?1:We(a),un(o,0,a<0?0:a)):[]}function sN(o,a,u){var p=o==null?0:o.length;return p?(a=u||a===i?1:We(a),a=p-a,un(o,a<0?0:a,p)):[]}function aN(o,a){return o&&o.length?Nl(o,De(a,3),!1,!0):[]}function lN(o,a){return o&&o.length?Nl(o,De(a,3)):[]}var cN=Ze(function(o){return Ai(lr(o,1,zt,!0))}),uN=Ze(function(o){var a=fn(o);return zt(a)&&(a=i),Ai(lr(o,1,zt,!0),De(a,2))}),fN=Ze(function(o){var a=fn(o);return a=typeof a=="function"?a:i,Ai(lr(o,1,zt,!0),i,a)});function hN(o){return o&&o.length?Ai(o):[]}function pN(o,a){return o&&o.length?Ai(o,De(a,2)):[]}function dN(o,a){return a=typeof a=="function"?a:i,o&&o.length?Ai(o,i,a):[]}function jf(o){if(!(o&&o.length))return[];var a=0;return o=Ci(o,function(u){if(zt(u))return a=Xt(u.length,a),!0}),Yu(a,function(u){return Ot(o,Ku(u))})}function Am(o,a){if(!(o&&o.length))return[];var u=jf(o);return a==null?u:Ot(u,function(p){return Hr(a,i,p)})}var mN=Ze(function(o,a){return zt(o)?Js(o,a):[]}),gN=Ze(function(o){return bf(Ci(o,zt))}),yN=Ze(function(o){var a=fn(o);return zt(a)&&(a=i),bf(Ci(o,zt),De(a,2))}),xN=Ze(function(o){var a=fn(o);return a=typeof a=="function"?a:i,bf(Ci(o,zt),i,a)}),vN=Ze(jf);function bN(o,a){return Jd(o||[],a||[],$s)}function SN(o,a){return Jd(o||[],a||[],Zs)}var wN=Ze(function(o){var a=o.length,u=a>1?o[a-1]:i;return u=typeof u=="function"?(o.pop(),u):i,Am(o,u)});function Om(o){var a=y(o);return a.__chain__=!0,a}function NN(o,a){return a(o),o}function Pl(o,a){return a(o)}var CN=si(function(o){var a=o.length,u=a?o[0]:0,p=this.__wrapped__,m=function(v){return af(v,o)};return a>1||this.__actions__.length||!(p instanceof rt)||!ai(u)?this.thru(m):(p=p.slice(u,+u+(a?1:0)),p.__actions__.push({func:Pl,args:[m],thisArg:i}),new ln(p,this.__chain__).thru(function(v){return a&&!v.length&&v.push(i),v}))});function LN(){return Om(this)}function _N(){return new ln(this.value(),this.__chain__)}function TN(){this.__values__===i&&(this.__values__=Wm(this.value()));var o=this.__index__>=this.__values__.length,a=o?i:this.__values__[this.__index__++];return{done:o,value:a}}function IN(){return this}function MN(o){for(var a,u=this;u instanceof yl;){var p=Cm(u);p.__index__=0,p.__values__=i,a?m.__wrapped__=p:a=p;var m=p;u=u.__wrapped__}return m.__wrapped__=o,a}function AN(){var o=this.__wrapped__;if(o instanceof rt){var a=o;return this.__actions__.length&&(a=new rt(this)),a=a.reverse(),a.__actions__.push({func:Pl,args:[Gf],thisArg:i}),new ln(a,this.__chain__)}return this.thru(Gf)}function ON(){return $d(this.__wrapped__,this.__actions__)}var PN=Cl(function(o,a,u){pt.call(o,u)?++o[u]:ii(o,u,1)});function DN(o,a,u){var p=ke(o)?ld:Nw;return u&&Sr(o,a,u)&&(a=i),p(o,De(a,3))}function BN(o,a){var u=ke(o)?Ci:Ad;return u(o,De(a,3))}var GN=im(Lm),jN=im(_m);function EN(o,a){return lr(Dl(o,a),1)}function RN(o,a){return lr(Dl(o,a),he)}function zN(o,a,u){return u=u===i?1:We(u),lr(Dl(o,a),u)}function Pm(o,a){var u=ke(o)?sn:Mi;return u(o,De(a,3))}function Dm(o,a){var u=ke(o)?iS:Md;return u(o,De(a,3))}var FN=Cl(function(o,a,u){pt.call(o,u)?o[u].push(a):ii(o,u,[a])});function VN(o,a,u,p){o=Pr(o)?o:$o(o),u=u&&!p?We(u):0;var m=o.length;return u<0&&(u=Xt(m+u,0)),Rl(o)?u<=m&&o.indexOf(a,u)>-1:!!m&&jo(o,a,u)>-1}var UN=Ze(function(o,a,u){var p=-1,m=typeof a=="function",v=Pr(o)?V(o.length):[];return Mi(o,function(N){v[++p]=m?Hr(a,N,u):Ks(N,a,u)}),v}),kN=Cl(function(o,a,u){ii(o,u,a)});function Dl(o,a){var u=ke(o)?Ot:jd;return u(o,De(a,3))}function HN(o,a,u,p){return o==null?[]:(ke(a)||(a=a==null?[]:[a]),u=p?i:u,ke(u)||(u=u==null?[]:[u]),Fd(o,a,u))}var WN=Cl(function(o,a,u){o[u?0:1].push(a)},function(){return[[],[]]});function qN(o,a,u){var p=ke(o)?$u:hd,m=arguments.length<3;return p(o,De(a,4),u,m,Mi)}function $N(o,a,u){var p=ke(o)?oS:hd,m=arguments.length<3;return p(o,De(a,4),u,m,Md)}function JN(o,a){var u=ke(o)?Ci:Ad;return u(o,jl(De(a,3)))}function KN(o){var a=ke(o)?Ld:Vw;return a(o)}function XN(o,a,u){(u?Sr(o,a,u):a===i)?a=1:a=We(a);var p=ke(o)?xw:Uw;return p(o,a)}function ZN(o){var a=ke(o)?vw:Hw;return a(o)}function YN(o){if(o==null)return 0;if(Pr(o))return Rl(o)?Ro(o):o.length;var a=mr(o);return a==ne||a==de?o.size:pf(o).length}function QN(o,a,u){var p=ke(o)?Ju:Ww;return u&&Sr(o,a,u)&&(a=i),p(o,De(a,3))}var eC=Ze(function(o,a){if(o==null)return[];var u=a.length;return u>1&&Sr(o,a[0],a[1])?a=[]:u>2&&Sr(a[0],a[1],a[2])&&(a=[a[0]]),Fd(o,lr(a,1),[])}),Bl=BS||function(){return rr.Date.now()};function tC(o,a){if(typeof a!="function")throw new an(n);return o=We(o),function(){if(--o<1)return a.apply(this,arguments)}}function Bm(o,a,u){return a=u?i:a,a=o&&a==null?o.length:a,oi(o,W,i,i,i,i,a)}function Gm(o,a){var u;if(typeof a!="function")throw new an(n);return o=We(o),function(){return--o>0&&(u=a.apply(this,arguments)),o<=1&&(a=i),u}}var Ef=Ze(function(o,a,u){var p=w;if(u.length){var m=_i(u,Wo(Ef));p|=B}return oi(o,p,a,u,m)}),jm=Ze(function(o,a,u){var p=w|S;if(u.length){var m=_i(u,Wo(jm));p|=B}return oi(a,p,o,u,m)});function Em(o,a,u){a=u?i:a;var p=oi(o,C,i,i,i,i,i,a);return p.placeholder=Em.placeholder,p}function Rm(o,a,u){a=u?i:a;var p=oi(o,G,i,i,i,i,i,a);return p.placeholder=Rm.placeholder,p}function zm(o,a,u){var p,m,v,N,L,I,Q=0,te=!1,ie=!1,me=!0;if(typeof o!="function")throw new an(n);a=hn(a)||0,Dt(u)&&(te=!!u.leading,ie="maxWait"in u,v=ie?Xt(hn(u.maxWait)||0,a):v,me="trailing"in u?!!u.trailing:me);function Le(Ft){var Mn=p,ui=m;return p=m=i,Q=Ft,N=o.apply(ui,Mn),N}function Re(Ft){return Q=Ft,L=ea(et,a),te?Le(Ft):N}function Je(Ft){var Mn=Ft-I,ui=Ft-Q,ig=a-Mn;return ie?dr(ig,v-ui):ig}function je(Ft){var Mn=Ft-I,ui=Ft-Q;return I===i||Mn>=a||Mn<0||ie&&ui>=v}function et(){var Ft=Bl();if(je(Ft))return nt(Ft);L=ea(et,Je(Ft))}function nt(Ft){return L=i,me&&p?Le(Ft):(p=m=i,N)}function Jr(){L!==i&&Kd(L),Q=0,p=I=m=L=i}function wr(){return L===i?N:nt(Bl())}function Kr(){var Ft=Bl(),Mn=je(Ft);if(p=arguments,m=this,I=Ft,Mn){if(L===i)return Re(I);if(ie)return Kd(L),L=ea(et,a),Le(I)}return L===i&&(L=ea(et,a)),N}return Kr.cancel=Jr,Kr.flush=wr,Kr}var rC=Ze(function(o,a){return Id(o,1,a)}),nC=Ze(function(o,a,u){return Id(o,hn(a)||0,u)});function iC(o){return oi(o,q)}function Gl(o,a){if(typeof o!="function"||a!=null&&typeof a!="function")throw new an(n);var u=function(){var p=arguments,m=a?a.apply(this,p):p[0],v=u.cache;if(v.has(m))return v.get(m);var N=o.apply(this,p);return u.cache=v.set(m,N)||v,N};return u.cache=new(Gl.Cache||ni),u}Gl.Cache=ni;function jl(o){if(typeof o!="function")throw new an(n);return function(){var a=arguments;switch(a.length){case 0:return!o.call(this);case 1:return!o.call(this,a[0]);case 2:return!o.call(this,a[0],a[1]);case 3:return!o.call(this,a[0],a[1],a[2])}return!o.apply(this,a)}}function oC(o){return Gm(2,o)}var sC=qw(function(o,a){a=a.length==1&&ke(a[0])?Ot(a[0],Wr(De())):Ot(lr(a,1),Wr(De()));var u=a.length;return Ze(function(p){for(var m=-1,v=dr(p.length,u);++m<v;)p[m]=a[m].call(this,p[m]);return Hr(o,this,p)})}),Rf=Ze(function(o,a){var u=_i(a,Wo(Rf));return oi(o,B,i,a,u)}),Fm=Ze(function(o,a){var u=_i(a,Wo(Fm));return oi(o,P,i,a,u)}),aC=si(function(o,a){return oi(o,M,i,i,i,a)});function lC(o,a){if(typeof o!="function")throw new an(n);return a=a===i?a:We(a),Ze(o,a)}function cC(o,a){if(typeof o!="function")throw new an(n);return a=a==null?0:Xt(We(a),0),Ze(function(u){var p=u[a],m=Pi(u,0,a);return p&&Li(m,p),Hr(o,this,m)})}function uC(o,a,u){var p=!0,m=!0;if(typeof o!="function")throw new an(n);return Dt(u)&&(p="leading"in u?!!u.leading:p,m="trailing"in u?!!u.trailing:m),zm(o,a,{leading:p,maxWait:a,trailing:m})}function fC(o){return Bm(o,1)}function hC(o,a){return Rf(wf(a),o)}function pC(){if(!arguments.length)return[];var o=arguments[0];return ke(o)?o:[o]}function dC(o){return cn(o,d)}function mC(o,a){return a=typeof a=="function"?a:i,cn(o,d,a)}function gC(o){return cn(o,f|d)}function yC(o,a){return a=typeof a=="function"?a:i,cn(o,f|d,a)}function xC(o,a){return a==null||Td(o,a,nr(a))}function In(o,a){return o===a||o!==o&&a!==a}var vC=Il(uf),bC=Il(function(o,a){return o>=a}),po=Dd(function(){return arguments}())?Dd:function(o){return Gt(o)&&pt.call(o,"callee")&&!vd.call(o,"callee")},ke=V.isArray,SC=rd?Wr(rd):Mw;function Pr(o){return o!=null&&El(o.length)&&!li(o)}function zt(o){return Gt(o)&&Pr(o)}function wC(o){return o===!0||o===!1||Gt(o)&&br(o)==oe}var Di=jS||Kf,NC=nd?Wr(nd):Aw;function CC(o){return Gt(o)&&o.nodeType===1&&!ta(o)}function LC(o){if(o==null)return!0;if(Pr(o)&&(ke(o)||typeof o=="string"||typeof o.splice=="function"||Di(o)||qo(o)||po(o)))return!o.length;var a=mr(o);if(a==ne||a==de)return!o.size;if(Qs(o))return!pf(o).length;for(var u in o)if(pt.call(o,u))return!1;return!0}function _C(o,a){return Xs(o,a)}function TC(o,a,u){u=typeof u=="function"?u:i;var p=u?u(o,a):i;return p===i?Xs(o,a,i,u):!!p}function zf(o){if(!Gt(o))return!1;var a=br(o);return a==ue||a==ce||typeof o.message=="string"&&typeof o.name=="string"&&!ta(o)}function IC(o){return typeof o=="number"&&Sd(o)}function li(o){if(!Dt(o))return!1;var a=br(o);return a==K||a==ae||a==ee||a==xe}function Vm(o){return typeof o=="number"&&o==We(o)}function El(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=re}function Dt(o){var a=typeof o;return o!=null&&(a=="object"||a=="function")}function Gt(o){return o!=null&&typeof o=="object"}var Um=id?Wr(id):Pw;function MC(o,a){return o===a||hf(o,a,Mf(a))}function AC(o,a,u){return u=typeof u=="function"?u:i,hf(o,a,Mf(a),u)}function OC(o){return km(o)&&o!=+o}function PC(o){if(m1(o))throw new Ue(r);return Bd(o)}function DC(o){return o===null}function BC(o){return o==null}function km(o){return typeof o=="number"||Gt(o)&&br(o)==Ce}function ta(o){if(!Gt(o)||br(o)!=le)return!1;var a=ul(o);if(a===null)return!0;var u=pt.call(a,"constructor")&&a.constructor;return typeof u=="function"&&u instanceof u&&sl.call(u)==AS}var Ff=od?Wr(od):Dw;function GC(o){return Vm(o)&&o>=-re&&o<=re}var Hm=sd?Wr(sd):Bw;function Rl(o){return typeof o=="string"||!ke(o)&&Gt(o)&&br(o)==we}function $r(o){return typeof o=="symbol"||Gt(o)&&br(o)==Ve}var qo=ad?Wr(ad):Gw;function jC(o){return o===i}function EC(o){return Gt(o)&&mr(o)==Qe}function RC(o){return Gt(o)&&br(o)==bt}var zC=Il(df),FC=Il(function(o,a){return o<=a});function Wm(o){if(!o)return[];if(Pr(o))return Rl(o)?_n(o):Or(o);if(Us&&o[Us])return xS(o[Us]());var a=mr(o),u=a==ne?ef:a==de?nl:$o;return u(o)}function ci(o){if(!o)return o===0?o:0;if(o=hn(o),o===he||o===-he){var a=o<0?-1:1;return a*Ne}return o===o?o:0}function We(o){var a=ci(o),u=a%1;return a===a?u?a-u:a:0}function qm(o){return o?co(We(o),0,Me):0}function hn(o){if(typeof o=="number")return o;if($r(o))return ye;if(Dt(o)){var a=typeof o.valueOf=="function"?o.valueOf():o;o=Dt(a)?a+"":a}if(typeof o!="string")return o===0?o:+o;o=o.replace(tt,"");var u=Za.test(o);return u||Nb.test(o)?tS(o.slice(2),u?2:8):Rn.test(o)?ye:+o}function $m(o){return Fn(o,Dr(o))}function VC(o){return o?co(We(o),-re,re):o===0?o:0}function ut(o){return o==null?"":qr(o)}var UC=ko(function(o,a){if(Qs(a)||Pr(a)){Fn(a,nr(a),o);return}for(var u in a)pt.call(a,u)&&$s(o,u,a[u])}),Jm=ko(function(o,a){Fn(a,Dr(a),o)}),zl=ko(function(o,a,u,p){Fn(a,Dr(a),o,p)}),kC=ko(function(o,a,u,p){Fn(a,nr(a),o,p)}),HC=si(af);function WC(o,a){var u=Uo(o);return a==null?u:_d(u,a)}var qC=Ze(function(o,a){o=yt(o);var u=-1,p=a.length,m=p>2?a[2]:i;for(m&&Sr(a[0],a[1],m)&&(p=1);++u<p;)for(var v=a[u],N=Dr(v),L=-1,I=N.length;++L<I;){var Q=N[L],te=o[Q];(te===i||In(te,zo[Q])&&!pt.call(o,Q))&&(o[Q]=v[Q])}return o}),$C=Ze(function(o){return o.push(i,fm),Hr(Km,i,o)});function JC(o,a){return cd(o,De(a,3),zn)}function KC(o,a){return cd(o,De(a,3),cf)}function XC(o,a){return o==null?o:lf(o,De(a,3),Dr)}function ZC(o,a){return o==null?o:Od(o,De(a,3),Dr)}function YC(o,a){return o&&zn(o,De(a,3))}function QC(o,a){return o&&cf(o,De(a,3))}function eL(o){return o==null?[]:bl(o,nr(o))}function tL(o){return o==null?[]:bl(o,Dr(o))}function Vf(o,a,u){var p=o==null?i:uo(o,a);return p===i?u:p}function rL(o,a){return o!=null&&dm(o,a,Lw)}function Uf(o,a){return o!=null&&dm(o,a,_w)}var nL=sm(function(o,a,u){a!=null&&typeof a.toString!="function"&&(a=al.call(a)),o[a]=u},Hf(Br)),iL=sm(function(o,a,u){a!=null&&typeof a.toString!="function"&&(a=al.call(a)),pt.call(o,a)?o[a].push(u):o[a]=[u]},De),oL=Ze(Ks);function nr(o){return Pr(o)?Cd(o):pf(o)}function Dr(o){return Pr(o)?Cd(o,!0):jw(o)}function sL(o,a){var u={};return a=De(a,3),zn(o,function(p,m,v){ii(u,a(p,m,v),p)}),u}function aL(o,a){var u={};return a=De(a,3),zn(o,function(p,m,v){ii(u,m,a(p,m,v))}),u}var lL=ko(function(o,a,u){Sl(o,a,u)}),Km=ko(function(o,a,u,p){Sl(o,a,u,p)}),cL=si(function(o,a){var u={};if(o==null)return u;var p=!1;a=Ot(a,function(v){return v=Oi(v,o),p||(p=v.length>1),v}),Fn(o,Tf(o),u),p&&(u=cn(u,f|h|d,n1));for(var m=a.length;m--;)vf(u,a[m]);return u});function uL(o,a){return Xm(o,jl(De(a)))}var fL=si(function(o,a){return o==null?{}:Rw(o,a)});function Xm(o,a){if(o==null)return{};var u=Ot(Tf(o),function(p){return[p]});return a=De(a),Vd(o,u,function(p,m){return a(p,m[0])})}function hL(o,a,u){a=Oi(a,o);var p=-1,m=a.length;for(m||(m=1,o=i);++p<m;){var v=o==null?i:o[Vn(a[p])];v===i&&(p=m,v=u),o=li(v)?v.call(o):v}return o}function pL(o,a,u){return o==null?o:Zs(o,a,u)}function dL(o,a,u,p){return p=typeof p=="function"?p:i,o==null?o:Zs(o,a,u,p)}var Zm=cm(nr),Ym=cm(Dr);function mL(o,a,u){var p=ke(o),m=p||Di(o)||qo(o);if(a=De(a,4),u==null){var v=o&&o.constructor;m?u=p?new v:[]:Dt(o)?u=li(v)?Uo(ul(o)):{}:u={}}return(m?sn:zn)(o,function(N,L,I){return a(u,N,L,I)}),u}function gL(o,a){return o==null?!0:vf(o,a)}function yL(o,a,u){return o==null?o:qd(o,a,wf(u))}function xL(o,a,u,p){return p=typeof p=="function"?p:i,o==null?o:qd(o,a,wf(u),p)}function $o(o){return o==null?[]:Qu(o,nr(o))}function vL(o){return o==null?[]:Qu(o,Dr(o))}function bL(o,a,u){return u===i&&(u=a,a=i),u!==i&&(u=hn(u),u=u===u?u:0),a!==i&&(a=hn(a),a=a===a?a:0),co(hn(o),a,u)}function SL(o,a,u){return a=ci(a),u===i?(u=a,a=0):u=ci(u),o=hn(o),Tw(o,a,u)}function wL(o,a,u){if(u&&typeof u!="boolean"&&Sr(o,a,u)&&(a=u=i),u===i&&(typeof a=="boolean"?(u=a,a=i):typeof o=="boolean"&&(u=o,o=i)),o===i&&a===i?(o=0,a=1):(o=ci(o),a===i?(a=o,o=0):a=ci(a)),o>a){var p=o;o=a,a=p}if(u||o%1||a%1){var m=wd();return dr(o+m*(a-o+eS("1e-"+((m+"").length-1))),a)}return gf(o,a)}var NL=Ho(function(o,a,u){return a=a.toLowerCase(),o+(u?Qm(a):a)});function Qm(o){return kf(ut(o).toLowerCase())}function eg(o){return o=ut(o),o&&o.replace(Lb,pS).replace(Hb,"")}function CL(o,a,u){o=ut(o),a=qr(a);var p=o.length;u=u===i?p:co(We(u),0,p);var m=u;return u-=a.length,u>=0&&o.slice(u,m)==a}function LL(o){return o=ut(o),o&&Mr.test(o)?o.replace(no,dS):o}function _L(o){return o=ut(o),o&&$e.test(o)?o.replace(He,"\\$&"):o}var TL=Ho(function(o,a,u){return o+(u?"-":"")+a.toLowerCase()}),IL=Ho(function(o,a,u){return o+(u?" ":"")+a.toLowerCase()}),ML=nm("toLowerCase");function AL(o,a,u){o=ut(o),a=We(a);var p=a?Ro(o):0;if(!a||p>=a)return o;var m=(a-p)/2;return Tl(dl(m),u)+o+Tl(pl(m),u)}function OL(o,a,u){o=ut(o),a=We(a);var p=a?Ro(o):0;return a&&p<a?o+Tl(a-p,u):o}function PL(o,a,u){o=ut(o),a=We(a);var p=a?Ro(o):0;return a&&p<a?Tl(a-p,u)+o:o}function DL(o,a,u){return u||a==null?a=0:a&&(a=+a),FS(ut(o).replace(at,""),a||0)}function BL(o,a,u){return(u?Sr(o,a,u):a===i)?a=1:a=We(a),yf(ut(o),a)}function GL(){var o=arguments,a=ut(o[0]);return o.length<3?a:a.replace(o[1],o[2])}var jL=Ho(function(o,a,u){return o+(u?"_":"")+a.toLowerCase()});function EL(o,a,u){return u&&typeof u!="number"&&Sr(o,a,u)&&(a=u=i),u=u===i?Me:u>>>0,u?(o=ut(o),o&&(typeof a=="string"||a!=null&&!Ff(a))&&(a=qr(a),!a&&Eo(o))?Pi(_n(o),0,u):o.split(a,u)):[]}var RL=Ho(function(o,a,u){return o+(u?" ":"")+kf(a)});function zL(o,a,u){return o=ut(o),u=u==null?0:co(We(u),0,o.length),a=qr(a),o.slice(u,u+a.length)==a}function FL(o,a,u){var p=y.templateSettings;u&&Sr(o,a,u)&&(a=i),o=ut(o),a=zl({},a,p,um);var m=zl({},a.imports,p.imports,um),v=nr(m),N=Qu(m,v),L,I,Q=0,te=a.interpolate||Ya,ie="__p += '",me=tf((a.escape||Ya).source+"|"+te.source+"|"+(te===ti?Cn:Ya).source+"|"+(a.evaluate||Ya).source+"|$","g"),Le="//# sourceURL="+(pt.call(a,"sourceURL")?(a.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Kb+"]")+`
4
- `;o.replace(me,function(je,et,nt,Jr,wr,Kr){return nt||(nt=Jr),ie+=o.slice(Q,Kr).replace(_b,mS),et&&(L=!0,ie+=`' +
5
- __e(`+et+`) +
6
- '`),wr&&(I=!0,ie+=`';
7
- `+wr+`;
8
- __p += '`),nt&&(ie+=`' +
9
- ((__t = (`+nt+`)) == null ? '' : __t) +
10
- '`),Q=Kr+je.length,je}),ie+=`';
11
- `;var Re=pt.call(a,"variable")&&a.variable;Re||(ie=`with (obj) {
12
- `+ie+`
13
- }
14
- `),ie=(I?ie.replace(Ao,""):ie).replace(Oo,"$1").replace(Po,"$1;"),ie="function("+(Re||"obj")+`) {
15
- `+(Re?"":`obj || (obj = {});
16
- `)+"var __t, __p = ''"+(L?", __e = _.escape":"")+(I?`, __j = Array.prototype.join;
17
- function print() { __p += __j.call(arguments, '') }
18
- `:`;
19
- `)+ie+`return __p
20
- }`;var Je=rg(function(){return lt(v,Le+"return "+ie).apply(i,N)});if(Je.source=ie,zf(Je))throw Je;return Je}function VL(o){return ut(o).toLowerCase()}function UL(o){return ut(o).toUpperCase()}function kL(o,a,u){if(o=ut(o),o&&(u||a===i))return o.replace(tt,"");if(!o||!(a=qr(a)))return o;var p=_n(o),m=_n(a),v=pd(p,m),N=dd(p,m)+1;return Pi(p,v,N).join("")}function HL(o,a,u){if(o=ut(o),o&&(u||a===i))return o.replace(mt,"");if(!o||!(a=qr(a)))return o;var p=_n(o),m=dd(p,_n(a))+1;return Pi(p,0,m).join("")}function WL(o,a,u){if(o=ut(o),o&&(u||a===i))return o.replace(at,"");if(!o||!(a=qr(a)))return o;var p=_n(o),m=pd(p,_n(a));return Pi(p,m).join("")}function qL(o,a){var u=E,p=b;if(Dt(a)){var m="separator"in a?a.separator:m;u="length"in a?We(a.length):u,p="omission"in a?qr(a.omission):p}o=ut(o);var v=o.length;if(Eo(o)){var N=_n(o);v=N.length}if(u>=v)return o;var L=u-Ro(p);if(L<1)return p;var I=N?Pi(N,0,L).join(""):o.slice(0,L);if(m===i)return I+p;if(N&&(L+=I.length-L),Ff(m)){if(o.slice(L).search(m)){var Q,te=I;for(m.global||(m=tf(m.source,ut(Ln.exec(m))+"g")),m.lastIndex=0;Q=m.exec(te);)var ie=Q.index;I=I.slice(0,ie===i?L:ie)}}else if(o.indexOf(qr(m),L)!=L){var me=I.lastIndexOf(m);me>-1&&(I=I.slice(0,me))}return I+p}function $L(o){return o=ut(o),o&&Do.test(o)?o.replace(ro,wS):o}var JL=Ho(function(o,a,u){return o+(u?" ":"")+a.toUpperCase()}),kf=nm("toUpperCase");function tg(o,a,u){return o=ut(o),a=u?i:a,a===i?yS(o)?LS(o):lS(o):o.match(a)||[]}var rg=Ze(function(o,a){try{return Hr(o,i,a)}catch(u){return zf(u)?u:new Ue(u)}}),KL=si(function(o,a){return sn(a,function(u){u=Vn(u),ii(o,u,Ef(o[u],o))}),o});function XL(o){var a=o==null?0:o.length,u=De();return o=a?Ot(o,function(p){if(typeof p[1]!="function")throw new an(n);return[u(p[0]),p[1]]}):[],Ze(function(p){for(var m=-1;++m<a;){var v=o[m];if(Hr(v[0],this,p))return Hr(v[1],this,p)}})}function ZL(o){return ww(cn(o,f))}function Hf(o){return function(){return o}}function YL(o,a){return o==null||o!==o?a:o}var QL=om(),e_=om(!0);function Br(o){return o}function Wf(o){return Gd(typeof o=="function"?o:cn(o,f))}function t_(o){return Ed(cn(o,f))}function r_(o,a){return Rd(o,cn(a,f))}var n_=Ze(function(o,a){return function(u){return Ks(u,o,a)}}),i_=Ze(function(o,a){return function(u){return Ks(o,u,a)}});function qf(o,a,u){var p=nr(a),m=bl(a,p);u==null&&!(Dt(a)&&(m.length||!p.length))&&(u=a,a=o,o=this,m=bl(a,nr(a)));var v=!(Dt(u)&&"chain"in u)||!!u.chain,N=li(o);return sn(m,function(L){var I=a[L];o[L]=I,N&&(o.prototype[L]=function(){var Q=this.__chain__;if(v||Q){var te=o(this.__wrapped__),ie=te.__actions__=Or(this.__actions__);return ie.push({func:I,args:arguments,thisArg:o}),te.__chain__=Q,te}return I.apply(o,Li([this.value()],arguments))})}),o}function o_(){return rr._===this&&(rr._=OS),this}function $f(){}function s_(o){return o=We(o),Ze(function(a){return zd(a,o)})}var a_=Cf(Ot),l_=Cf(ld),c_=Cf(Ju);function ng(o){return Of(o)?Ku(Vn(o)):zw(o)}function u_(o){return function(a){return o==null?i:uo(o,a)}}var f_=am(),h_=am(!0);function Jf(){return[]}function Kf(){return!1}function p_(){return{}}function d_(){return""}function m_(){return!0}function g_(o,a){if(o=We(o),o<1||o>re)return[];var u=Me,p=dr(o,Me);a=De(a),o-=Me;for(var m=Yu(p,a);++u<o;)a(u);return m}function y_(o){return ke(o)?Ot(o,Vn):$r(o)?[o]:Or(Nm(ut(o)))}function x_(o){var a=++MS;return ut(o)+a}var v_=_l(function(o,a){return o+a},0),b_=Lf("ceil"),S_=_l(function(o,a){return o/a},1),w_=Lf("floor");function N_(o){return o&&o.length?vl(o,Br,uf):i}function C_(o,a){return o&&o.length?vl(o,De(a,2),uf):i}function L_(o){return fd(o,Br)}function __(o,a){return fd(o,De(a,2))}function T_(o){return o&&o.length?vl(o,Br,df):i}function I_(o,a){return o&&o.length?vl(o,De(a,2),df):i}var M_=_l(function(o,a){return o*a},1),A_=Lf("round"),O_=_l(function(o,a){return o-a},0);function P_(o){return o&&o.length?Zu(o,Br):0}function D_(o,a){return o&&o.length?Zu(o,De(a,2)):0}return y.after=tC,y.ary=Bm,y.assign=UC,y.assignIn=Jm,y.assignInWith=zl,y.assignWith=kC,y.at=HC,y.before=Gm,y.bind=Ef,y.bindAll=KL,y.bindKey=jm,y.castArray=pC,y.chain=Om,y.chunk=w1,y.compact=N1,y.concat=C1,y.cond=XL,y.conforms=ZL,y.constant=Hf,y.countBy=PN,y.create=WC,y.curry=Em,y.curryRight=Rm,y.debounce=zm,y.defaults=qC,y.defaultsDeep=$C,y.defer=rC,y.delay=nC,y.difference=L1,y.differenceBy=_1,y.differenceWith=T1,y.drop=I1,y.dropRight=M1,y.dropRightWhile=A1,y.dropWhile=O1,y.fill=P1,y.filter=BN,y.flatMap=EN,y.flatMapDeep=RN,y.flatMapDepth=zN,y.flatten=Tm,y.flattenDeep=D1,y.flattenDepth=B1,y.flip=iC,y.flow=QL,y.flowRight=e_,y.fromPairs=G1,y.functions=eL,y.functionsIn=tL,y.groupBy=FN,y.initial=E1,y.intersection=R1,y.intersectionBy=z1,y.intersectionWith=F1,y.invert=nL,y.invertBy=iL,y.invokeMap=UN,y.iteratee=Wf,y.keyBy=kN,y.keys=nr,y.keysIn=Dr,y.map=Dl,y.mapKeys=sL,y.mapValues=aL,y.matches=t_,y.matchesProperty=r_,y.memoize=Gl,y.merge=lL,y.mergeWith=Km,y.method=n_,y.methodOf=i_,y.mixin=qf,y.negate=jl,y.nthArg=s_,y.omit=cL,y.omitBy=uL,y.once=oC,y.orderBy=HN,y.over=a_,y.overArgs=sC,y.overEvery=l_,y.overSome=c_,y.partial=Rf,y.partialRight=Fm,y.partition=WN,y.pick=fL,y.pickBy=Xm,y.property=ng,y.propertyOf=u_,y.pull=H1,y.pullAll=Mm,y.pullAllBy=W1,y.pullAllWith=q1,y.pullAt=$1,y.range=f_,y.rangeRight=h_,y.rearg=aC,y.reject=JN,y.remove=J1,y.rest=lC,y.reverse=Gf,y.sampleSize=XN,y.set=pL,y.setWith=dL,y.shuffle=ZN,y.slice=K1,y.sortBy=eC,y.sortedUniq=rN,y.sortedUniqBy=nN,y.split=EL,y.spread=cC,y.tail=iN,y.take=oN,y.takeRight=sN,y.takeRightWhile=aN,y.takeWhile=lN,y.tap=NN,y.throttle=uC,y.thru=Pl,y.toArray=Wm,y.toPairs=Zm,y.toPairsIn=Ym,y.toPath=y_,y.toPlainObject=$m,y.transform=mL,y.unary=fC,y.union=cN,y.unionBy=uN,y.unionWith=fN,y.uniq=hN,y.uniqBy=pN,y.uniqWith=dN,y.unset=gL,y.unzip=jf,y.unzipWith=Am,y.update=yL,y.updateWith=xL,y.values=$o,y.valuesIn=vL,y.without=mN,y.words=tg,y.wrap=hC,y.xor=gN,y.xorBy=yN,y.xorWith=xN,y.zip=vN,y.zipObject=bN,y.zipObjectDeep=SN,y.zipWith=wN,y.entries=Zm,y.entriesIn=Ym,y.extend=Jm,y.extendWith=zl,qf(y,y),y.add=v_,y.attempt=rg,y.camelCase=NL,y.capitalize=Qm,y.ceil=b_,y.clamp=bL,y.clone=dC,y.cloneDeep=gC,y.cloneDeepWith=yC,y.cloneWith=mC,y.conformsTo=xC,y.deburr=eg,y.defaultTo=YL,y.divide=S_,y.endsWith=CL,y.eq=In,y.escape=LL,y.escapeRegExp=_L,y.every=DN,y.find=GN,y.findIndex=Lm,y.findKey=JC,y.findLast=jN,y.findLastIndex=_m,y.findLastKey=KC,y.floor=w_,y.forEach=Pm,y.forEachRight=Dm,y.forIn=XC,y.forInRight=ZC,y.forOwn=YC,y.forOwnRight=QC,y.get=Vf,y.gt=vC,y.gte=bC,y.has=rL,y.hasIn=Uf,y.head=Im,y.identity=Br,y.includes=VN,y.indexOf=j1,y.inRange=SL,y.invoke=oL,y.isArguments=po,y.isArray=ke,y.isArrayBuffer=SC,y.isArrayLike=Pr,y.isArrayLikeObject=zt,y.isBoolean=wC,y.isBuffer=Di,y.isDate=NC,y.isElement=CC,y.isEmpty=LC,y.isEqual=_C,y.isEqualWith=TC,y.isError=zf,y.isFinite=IC,y.isFunction=li,y.isInteger=Vm,y.isLength=El,y.isMap=Um,y.isMatch=MC,y.isMatchWith=AC,y.isNaN=OC,y.isNative=PC,y.isNil=BC,y.isNull=DC,y.isNumber=km,y.isObject=Dt,y.isObjectLike=Gt,y.isPlainObject=ta,y.isRegExp=Ff,y.isSafeInteger=GC,y.isSet=Hm,y.isString=Rl,y.isSymbol=$r,y.isTypedArray=qo,y.isUndefined=jC,y.isWeakMap=EC,y.isWeakSet=RC,y.join=V1,y.kebabCase=TL,y.last=fn,y.lastIndexOf=U1,y.lowerCase=IL,y.lowerFirst=ML,y.lt=zC,y.lte=FC,y.max=N_,y.maxBy=C_,y.mean=L_,y.meanBy=__,y.min=T_,y.minBy=I_,y.stubArray=Jf,y.stubFalse=Kf,y.stubObject=p_,y.stubString=d_,y.stubTrue=m_,y.multiply=M_,y.nth=k1,y.noConflict=o_,y.noop=$f,y.now=Bl,y.pad=AL,y.padEnd=OL,y.padStart=PL,y.parseInt=DL,y.random=wL,y.reduce=qN,y.reduceRight=$N,y.repeat=BL,y.replace=GL,y.result=hL,y.round=A_,y.runInContext=O,y.sample=KN,y.size=YN,y.snakeCase=jL,y.some=QN,y.sortedIndex=X1,y.sortedIndexBy=Z1,y.sortedIndexOf=Y1,y.sortedLastIndex=Q1,y.sortedLastIndexBy=eN,y.sortedLastIndexOf=tN,y.startCase=RL,y.startsWith=zL,y.subtract=O_,y.sum=P_,y.sumBy=D_,y.template=FL,y.times=g_,y.toFinite=ci,y.toInteger=We,y.toLength=qm,y.toLower=VL,y.toNumber=hn,y.toSafeInteger=VC,y.toString=ut,y.toUpper=UL,y.trim=kL,y.trimEnd=HL,y.trimStart=WL,y.truncate=qL,y.unescape=$L,y.uniqueId=x_,y.upperCase=JL,y.upperFirst=kf,y.each=Pm,y.eachRight=Dm,y.first=Im,qf(y,function(){var o={};return zn(y,function(a,u){pt.call(y.prototype,u)||(o[u]=a)}),o}(),{chain:!1}),y.VERSION=e,sn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){y[o].placeholder=y}),sn(["drop","take"],function(o,a){rt.prototype[o]=function(u){u=u===i?1:Xt(We(u),0);var p=this.__filtered__&&!a?new rt(this):this.clone();return p.__filtered__?p.__takeCount__=dr(u,p.__takeCount__):p.__views__.push({size:dr(u,Me),type:o+(p.__dir__<0?"Right":"")}),p},rt.prototype[o+"Right"]=function(u){return this.reverse()[o](u).reverse()}}),sn(["filter","map","takeWhile"],function(o,a){var u=a+1,p=u==z||u==$;rt.prototype[o]=function(m){var v=this.clone();return v.__iteratees__.push({iteratee:De(m,3),type:u}),v.__filtered__=v.__filtered__||p,v}}),sn(["head","last"],function(o,a){var u="take"+(a?"Right":"");rt.prototype[o]=function(){return this[u](1).value()[0]}}),sn(["initial","tail"],function(o,a){var u="drop"+(a?"":"Right");rt.prototype[o]=function(){return this.__filtered__?new rt(this):this[u](1)}}),rt.prototype.compact=function(){return this.filter(Br)},rt.prototype.find=function(o){return this.filter(o).head()},rt.prototype.findLast=function(o){return this.reverse().find(o)},rt.prototype.invokeMap=Ze(function(o,a){return typeof o=="function"?new rt(this):this.map(function(u){return Ks(u,o,a)})}),rt.prototype.reject=function(o){return this.filter(jl(De(o)))},rt.prototype.slice=function(o,a){o=We(o);var u=this;return u.__filtered__&&(o>0||a<0)?new rt(u):(o<0?u=u.takeRight(-o):o&&(u=u.drop(o)),a!==i&&(a=We(a),u=a<0?u.dropRight(-a):u.take(a-o)),u)},rt.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},rt.prototype.toArray=function(){return this.take(Me)},zn(rt.prototype,function(o,a){var u=/^(?:filter|find|map|reject)|While$/.test(a),p=/^(?:head|last)$/.test(a),m=y[p?"take"+(a=="last"?"Right":""):a],v=p||/^find/.test(a);!m||(y.prototype[a]=function(){var N=this.__wrapped__,L=p?[1]:arguments,I=N instanceof rt,Q=L[0],te=I||ke(N),ie=function(et){var nt=m.apply(y,Li([et],L));return p&&me?nt[0]:nt};te&&u&&typeof Q=="function"&&Q.length!=1&&(I=te=!1);var me=this.__chain__,Le=!!this.__actions__.length,Re=v&&!me,Je=I&&!Le;if(!v&&te){N=Je?N:new rt(this);var je=o.apply(N,L);return je.__actions__.push({func:Pl,args:[ie],thisArg:i}),new ln(je,me)}return Re&&Je?o.apply(this,L):(je=this.thru(ie),Re?p?je.value()[0]:je.value():je)})}),sn(["pop","push","shift","sort","splice","unshift"],function(o){var a=il[o],u=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",p=/^(?:pop|shift)$/.test(o);y.prototype[o]=function(){var m=arguments;if(p&&!this.__chain__){var v=this.value();return a.apply(ke(v)?v:[],m)}return this[u](function(N){return a.apply(ke(N)?N:[],m)})}}),zn(rt.prototype,function(o,a){var u=y[a];if(u){var p=u.name+"";pt.call(Vo,p)||(Vo[p]=[]),Vo[p].push({name:a,func:u})}}),Vo[Ll(i,S).name]=[{name:"wrapper",func:i}],rt.prototype.clone=$S,rt.prototype.reverse=JS,rt.prototype.value=KS,y.prototype.at=CN,y.prototype.chain=LN,y.prototype.commit=_N,y.prototype.next=TN,y.prototype.plant=MN,y.prototype.reverse=AN,y.prototype.toJSON=y.prototype.valueOf=y.prototype.value=ON,y.prototype.first=y.prototype.head,Us&&(y.prototype[Us]=IN),y},Ti=_S();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(rr._=Ti,define(function(){return Ti})):oo?((oo.exports=Ti)._=Ti,Hu._=Ti):rr._=Ti}).call(Fs)});import{FileLoader as tB,Loader as rB}from"three";function fg(i){return Array.isArray(i)?i:[i]}var k_=typeof global=="object"&&global&&global.Object===Object&&global,Fl=k_;var H_=typeof self=="object"&&self&&self.Object===Object&&self,W_=Fl||H_||Function("return this")(),qt=W_;var q_=qt.Symbol,Nr=q_;var hg=Object.prototype,$_=hg.hasOwnProperty,J_=hg.toString,na=Nr?Nr.toStringTag:void 0;function K_(i){var e=$_.call(i,na),t=i[na];try{i[na]=void 0;var r=!0}catch(s){}var n=J_.call(i);return r&&(e?i[na]=t:delete i[na]),n}var pg=K_;var X_=Object.prototype,Z_=X_.toString;function Y_(i){return Z_.call(i)}var dg=Y_;var Q_="[object Null]",eT="[object Undefined]",mg=Nr?Nr.toStringTag:void 0;function tT(i){return i==null?i===void 0?eT:Q_:mg&&mg in Object(i)?pg(i):dg(i)}var Xr=tT;function rT(i){return i!=null&&typeof i=="object"}var gr=rT;var nT="[object Symbol]";function iT(i){return typeof i=="symbol"||gr(i)&&Xr(i)==nT}var Jo=iT;function oT(i,e){for(var t=-1,r=i==null?0:i.length,n=Array(r);++t<r;)n[t]=e(i[t],t,i);return n}var Vl=oT;var sT=Array.isArray,cr=sT;var aT=1/0,gg=Nr?Nr.prototype:void 0,yg=gg?gg.toString:void 0;function xg(i){if(typeof i=="string")return i;if(cr(i))return Vl(i,xg)+"";if(Jo(i))return yg?yg.call(i):"";var e=i+"";return e=="0"&&1/i==-aT?"-0":e}var vg=xg;function lT(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var yr=lT;function cT(i){return i}var Ul=cT;var uT="[object AsyncFunction]",fT="[object Function]",hT="[object GeneratorFunction]",pT="[object Proxy]";function dT(i){if(!yr(i))return!1;var e=Xr(i);return e==fT||e==hT||e==uT||e==pT}var Ko=dT;var mT=qt["__core-js_shared__"],kl=mT;var bg=function(){var i=/[^.]+$/.exec(kl&&kl.keys&&kl.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function gT(i){return!!bg&&bg in i}var Sg=gT;var yT=Function.prototype,xT=yT.toString;function vT(i){if(i!=null){try{return xT.call(i)}catch(e){}try{return i+""}catch(e){}}return""}var fi=vT;var bT=/[\\^$.*+?()[\]{}|]/g,ST=/^\[object .+?Constructor\]$/,wT=Function.prototype,NT=Object.prototype,CT=wT.toString,LT=NT.hasOwnProperty,_T=RegExp("^"+CT.call(LT).replace(bT,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function TT(i){if(!yr(i)||Sg(i))return!1;var e=Ko(i)?_T:ST;return e.test(fi(i))}var wg=TT;function IT(i,e){return i==null?void 0:i[e]}var Ng=IT;function MT(i,e){var t=Ng(i,e);return wg(t)?t:void 0}var Gr=MT;var AT=Gr(qt,"WeakMap"),Hl=AT;var Cg=Object.create,OT=function(){function i(){}return function(e){if(!yr(e))return{};if(Cg)return Cg(e);i.prototype=e;var t=new i;return i.prototype=void 0,t}}(),Lg=OT;function PT(i,e,t){switch(t.length){case 0:return i.call(e);case 1:return i.call(e,t[0]);case 2:return i.call(e,t[0],t[1]);case 3:return i.call(e,t[0],t[1],t[2])}return i.apply(e,t)}var _g=PT;function DT(i,e){var t=-1,r=i.length;for(e||(e=Array(r));++t<r;)e[t]=i[t];return e}var Wl=DT;var BT=800,GT=16,jT=Date.now;function ET(i){var e=0,t=0;return function(){var r=jT(),n=GT-(r-t);if(t=r,n>0){if(++e>=BT)return arguments[0]}else e=0;return i.apply(void 0,arguments)}}var Tg=ET;function RT(i){return function(){return i}}var Ig=RT;var zT=function(){try{var i=Gr(Object,"defineProperty");return i({},"",{}),i}catch(e){}}(),Xo=zT;var FT=Xo?function(i,e){return Xo(i,"toString",{configurable:!0,enumerable:!1,value:Ig(e),writable:!0})}:Ul,Mg=FT;var VT=Tg(Mg),ql=VT;function UT(i,e){for(var t=-1,r=i==null?0:i.length;++t<r&&e(i[t],t,i)!==!1;);return i}var Ag=UT;var kT=9007199254740991,HT=/^(?:0|[1-9]\d*)$/;function WT(i,e){var t=typeof i;return e=e==null?kT:e,!!e&&(t=="number"||t!="symbol"&&HT.test(i))&&i>-1&&i%1==0&&i<e}var $l=WT;function qT(i,e,t){e=="__proto__"&&Xo?Xo(i,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):i[e]=t}var Zo=qT;function $T(i,e){return i===e||i!==i&&e!==e}var Bi=$T;var JT=Object.prototype,KT=JT.hasOwnProperty;function XT(i,e,t){var r=i[e];(!(KT.call(i,e)&&Bi(r,t))||t===void 0&&!(e in i))&&Zo(i,e,t)}var Jl=XT;function ZT(i,e,t,r){var n=!t;t||(t={});for(var s=-1,l=e.length;++s<l;){var c=e[s],f=r?r(t[c],i[c],c,t,i):void 0;f===void 0&&(f=i[c]),n?Zo(t,c,f):Jl(t,c,f)}return t}var pn=ZT;var Og=Math.max;function YT(i,e,t){return e=Og(e===void 0?i.length-1:e,0),function(){for(var r=arguments,n=-1,s=Og(r.length-e,0),l=Array(s);++n<s;)l[n]=r[e+n];n=-1;for(var c=Array(e+1);++n<e;)c[n]=r[n];return c[e]=t(l),_g(i,this,c)}}var Kl=YT;function QT(i,e){return ql(Kl(i,e,Ul),i+"")}var Pg=QT;var eI=9007199254740991;function tI(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=eI}var Xl=tI;function rI(i){return i!=null&&Xl(i.length)&&!Ko(i)}var Gi=rI;function nI(i,e,t){if(!yr(t))return!1;var r=typeof e;return(r=="number"?Gi(t)&&$l(e,t.length):r=="string"&&e in t)?Bi(t[e],i):!1}var Dg=nI;function iI(i){return Pg(function(e,t){var r=-1,n=t.length,s=n>1?t[n-1]:void 0,l=n>2?t[2]:void 0;for(s=i.length>3&&typeof s=="function"?(n--,s):void 0,l&&Dg(t[0],t[1],l)&&(s=n<3?void 0:s,n=1),e=Object(e);++r<n;){var c=t[r];c&&i(e,c,r,s)}return e})}var Bg=iI;var oI=Object.prototype;function sI(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||oI;return i===t}var Yo=sI;function aI(i,e){for(var t=-1,r=Array(i);++t<i;)r[t]=e(t);return r}var Gg=aI;var lI="[object Arguments]";function cI(i){return gr(i)&&Xr(i)==lI}var Xf=cI;var jg=Object.prototype,uI=jg.hasOwnProperty,fI=jg.propertyIsEnumerable,hI=Xf(function(){return arguments}())?Xf:function(i){return gr(i)&&uI.call(i,"callee")&&!fI.call(i,"callee")},mo=hI;function pI(){return!1}var Eg=pI;var Rg=typeof exports=="object"&&exports&&!exports.nodeType&&exports,zg=Rg&&typeof module=="object"&&module&&!module.nodeType&&module,dI=zg&&zg.exports===Rg,Fg=dI?qt.Buffer:void 0,mI=Fg?Fg.isBuffer:void 0,gI=mI||Eg,Qo=gI;var yI="[object Arguments]",xI="[object Array]",vI="[object Boolean]",bI="[object Date]",SI="[object Error]",wI="[object Function]",NI="[object Map]",CI="[object Number]",LI="[object Object]",_I="[object RegExp]",TI="[object Set]",II="[object String]",MI="[object WeakMap]",AI="[object ArrayBuffer]",OI="[object DataView]",PI="[object Float32Array]",DI="[object Float64Array]",BI="[object Int8Array]",GI="[object Int16Array]",jI="[object Int32Array]",EI="[object Uint8Array]",RI="[object Uint8ClampedArray]",zI="[object Uint16Array]",FI="[object Uint32Array]",Tt={};Tt[PI]=Tt[DI]=Tt[BI]=Tt[GI]=Tt[jI]=Tt[EI]=Tt[RI]=Tt[zI]=Tt[FI]=!0;Tt[yI]=Tt[xI]=Tt[AI]=Tt[vI]=Tt[OI]=Tt[bI]=Tt[SI]=Tt[wI]=Tt[NI]=Tt[CI]=Tt[LI]=Tt[_I]=Tt[TI]=Tt[II]=Tt[MI]=!1;function VI(i){return gr(i)&&Xl(i.length)&&!!Tt[Xr(i)]}var Vg=VI;function UI(i){return function(e){return i(e)}}var es=UI;var Ug=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ia=Ug&&typeof module=="object"&&module&&!module.nodeType&&module,kI=ia&&ia.exports===Ug,Zf=kI&&Fl.process,HI=function(){try{var i=ia&&ia.require&&ia.require("util").types;return i||Zf&&Zf.binding&&Zf.binding("util")}catch(e){}}(),hi=HI;var kg=hi&&hi.isTypedArray,WI=kg?es(kg):Vg,Zl=WI;var qI=Object.prototype,$I=qI.hasOwnProperty;function JI(i,e){var t=cr(i),r=!t&&mo(i),n=!t&&!r&&Qo(i),s=!t&&!r&&!n&&Zl(i),l=t||r||n||s,c=l?Gg(i.length,String):[],f=c.length;for(var h in i)(e||$I.call(i,h))&&!(l&&(h=="length"||n&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||$l(h,f)))&&c.push(h);return c}var Yl=JI;function KI(i,e){return function(t){return i(e(t))}}var Ql=KI;var XI=Ql(Object.keys,Object),Hg=XI;var ZI=Object.prototype,YI=ZI.hasOwnProperty;function QI(i){if(!Yo(i))return Hg(i);var e=[];for(var t in Object(i))YI.call(i,t)&&t!="constructor"&&e.push(t);return e}var Wg=QI;function eM(i){return Gi(i)?Yl(i):Wg(i)}var ts=eM;function tM(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e}var qg=tM;var rM=Object.prototype,nM=rM.hasOwnProperty;function iM(i){if(!yr(i))return qg(i);var e=Yo(i),t=[];for(var r in i)r=="constructor"&&(e||!nM.call(i,r))||t.push(r);return t}var $g=iM;function oM(i){return Gi(i)?Yl(i,!0):$g(i)}var Un=oM;var sM=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,aM=/^\w*$/;function lM(i,e){if(cr(i))return!1;var t=typeof i;return t=="number"||t=="symbol"||t=="boolean"||i==null||Jo(i)?!0:aM.test(i)||!sM.test(i)||e!=null&&i in Object(e)}var Jg=lM;var cM=Gr(Object,"create"),pi=cM;function uM(){this.__data__=pi?pi(null):{},this.size=0}var Kg=uM;function fM(i){var e=this.has(i)&&delete this.__data__[i];return this.size-=e?1:0,e}var Xg=fM;var hM="__lodash_hash_undefined__",pM=Object.prototype,dM=pM.hasOwnProperty;function mM(i){var e=this.__data__;if(pi){var t=e[i];return t===hM?void 0:t}return dM.call(e,i)?e[i]:void 0}var Zg=mM;var gM=Object.prototype,yM=gM.hasOwnProperty;function xM(i){var e=this.__data__;return pi?e[i]!==void 0:yM.call(e,i)}var Yg=xM;var vM="__lodash_hash_undefined__";function bM(i,e){var t=this.__data__;return this.size+=this.has(i)?0:1,t[i]=pi&&e===void 0?vM:e,this}var Qg=bM;function rs(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}rs.prototype.clear=Kg;rs.prototype.delete=Xg;rs.prototype.get=Zg;rs.prototype.has=Yg;rs.prototype.set=Qg;var Yf=rs;function SM(){this.__data__=[],this.size=0}var ey=SM;function wM(i,e){for(var t=i.length;t--;)if(Bi(i[t][0],e))return t;return-1}var ji=wM;var NM=Array.prototype,CM=NM.splice;function LM(i){var e=this.__data__,t=ji(e,i);if(t<0)return!1;var r=e.length-1;return t==r?e.pop():CM.call(e,t,1),--this.size,!0}var ty=LM;function _M(i){var e=this.__data__,t=ji(e,i);return t<0?void 0:e[t][1]}var ry=_M;function TM(i){return ji(this.__data__,i)>-1}var ny=TM;function IM(i,e){var t=this.__data__,r=ji(t,i);return r<0?(++this.size,t.push([i,e])):t[r][1]=e,this}var iy=IM;function ns(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}ns.prototype.clear=ey;ns.prototype.delete=ty;ns.prototype.get=ry;ns.prototype.has=ny;ns.prototype.set=iy;var Ei=ns;var MM=Gr(qt,"Map"),Ri=MM;function AM(){this.size=0,this.__data__={hash:new Yf,map:new(Ri||Ei),string:new Yf}}var oy=AM;function OM(i){var e=typeof i;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?i!=="__proto__":i===null}var sy=OM;function PM(i,e){var t=i.__data__;return sy(e)?t[typeof e=="string"?"string":"hash"]:t.map}var zi=PM;function DM(i){var e=zi(this,i).delete(i);return this.size-=e?1:0,e}var ay=DM;function BM(i){return zi(this,i).get(i)}var ly=BM;function GM(i){return zi(this,i).has(i)}var cy=GM;function jM(i,e){var t=zi(this,i),r=t.size;return t.set(i,e),this.size+=t.size==r?0:1,this}var uy=jM;function is(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}is.prototype.clear=oy;is.prototype.delete=ay;is.prototype.get=ly;is.prototype.has=cy;is.prototype.set=uy;var oa=is;var EM="Expected a function";function Qf(i,e){if(typeof i!="function"||e!=null&&typeof e!="function")throw new TypeError(EM);var t=function(){var r=arguments,n=e?e.apply(this,r):r[0],s=t.cache;if(s.has(n))return s.get(n);var l=i.apply(this,r);return t.cache=s.set(n,l)||s,l};return t.cache=new(Qf.Cache||oa),t}Qf.Cache=oa;var fy=Qf;var RM=500;function zM(i){var e=fy(i,function(r){return t.size===RM&&t.clear(),r}),t=e.cache;return e}var hy=zM;var FM=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,VM=/\\(\\)?/g,UM=hy(function(i){var e=[];return i.charCodeAt(0)===46&&e.push(""),i.replace(FM,function(t,r,n,s){e.push(n?s.replace(VM,"$1"):r||t)}),e}),py=UM;function kM(i){return i==null?"":vg(i)}var dy=kM;function HM(i,e){return cr(i)?i:Jg(i,e)?[i]:py(dy(i))}var os=HM;var WM=1/0;function qM(i){if(typeof i=="string"||Jo(i))return i;var e=i+"";return e=="0"&&1/i==-WM?"-0":e}var ec=qM;function $M(i,e){e=os(e,i);for(var t=0,r=e.length;i!=null&&t<r;)i=i[ec(e[t++])];return t&&t==r?i:void 0}var my=$M;function JM(i,e){for(var t=-1,r=e.length,n=i.length;++t<r;)i[n+t]=e[t];return i}var ss=JM;var gy=Nr?Nr.isConcatSpreadable:void 0;function KM(i){return cr(i)||mo(i)||!!(gy&&i&&i[gy])}var yy=KM;function xy(i,e,t,r,n){var s=-1,l=i.length;for(t||(t=yy),n||(n=[]);++s<l;){var c=i[s];e>0&&t(c)?e>1?xy(c,e-1,t,r,n):ss(n,c):r||(n[n.length]=c)}return n}var vy=xy;function XM(i){var e=i==null?0:i.length;return e?vy(i,1):[]}var by=XM;function ZM(i){return ql(Kl(i,void 0,by),i+"")}var Sy=ZM;var YM=Ql(Object.getPrototypeOf,Object),as=YM;var QM="[object Object]",eA=Function.prototype,tA=Object.prototype,wy=eA.toString,rA=tA.hasOwnProperty,nA=wy.call(Object);function iA(i){if(!gr(i)||Xr(i)!=QM)return!1;var e=as(i);if(e===null)return!0;var t=rA.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&wy.call(t)==nA}var tc=iA;function oA(i,e,t){var r=-1,n=i.length;e<0&&(e=-e>n?0:n+e),t=t>n?n:t,t<0&&(t+=n),n=e>t?0:t-e>>>0,e>>>=0;for(var s=Array(n);++r<n;)s[r]=i[r+e];return s}var Ny=oA;function sA(){this.__data__=new Ei,this.size=0}var Cy=sA;function aA(i){var e=this.__data__,t=e.delete(i);return this.size=e.size,t}var Ly=aA;function lA(i){return this.__data__.get(i)}var _y=lA;function cA(i){return this.__data__.has(i)}var Ty=cA;var uA=200;function fA(i,e){var t=this.__data__;if(t instanceof Ei){var r=t.__data__;if(!Ri||r.length<uA-1)return r.push([i,e]),this.size=++t.size,this;t=this.__data__=new oa(r)}return t.set(i,e),this.size=t.size,this}var Iy=fA;function ls(i){var e=this.__data__=new Ei(i);this.size=e.size}ls.prototype.clear=Cy;ls.prototype.delete=Ly;ls.prototype.get=_y;ls.prototype.has=Ty;ls.prototype.set=Iy;var rc=ls;function hA(i,e){return i&&pn(e,ts(e),i)}var My=hA;function pA(i,e){return i&&pn(e,Un(e),i)}var Ay=pA;var Oy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Py=Oy&&typeof module=="object"&&module&&!module.nodeType&&module,dA=Py&&Py.exports===Oy,Dy=dA?qt.Buffer:void 0,By=Dy?Dy.allocUnsafe:void 0;function mA(i,e){if(e)return i.slice();var t=i.length,r=By?By(t):new i.constructor(t);return i.copy(r),r}var nc=mA;function gA(i,e){for(var t=-1,r=i==null?0:i.length,n=0,s=[];++t<r;){var l=i[t];e(l,t,i)&&(s[n++]=l)}return s}var Gy=gA;function yA(){return[]}var ic=yA;var xA=Object.prototype,vA=xA.propertyIsEnumerable,jy=Object.getOwnPropertySymbols,bA=jy?function(i){return i==null?[]:(i=Object(i),Gy(jy(i),function(e){return vA.call(i,e)}))}:ic,cs=bA;function SA(i,e){return pn(i,cs(i),e)}var Ey=SA;var wA=Object.getOwnPropertySymbols,NA=wA?function(i){for(var e=[];i;)ss(e,cs(i)),i=as(i);return e}:ic,oc=NA;function CA(i,e){return pn(i,oc(i),e)}var Ry=CA;function LA(i,e,t){var r=e(i);return cr(i)?r:ss(r,t(i))}var sc=LA;function _A(i){return sc(i,ts,cs)}var zy=_A;function TA(i){return sc(i,Un,oc)}var ac=TA;var IA=Gr(qt,"DataView"),lc=IA;var MA=Gr(qt,"Promise"),cc=MA;var AA=Gr(qt,"Set"),uc=AA;var Fy="[object Map]",OA="[object Object]",Vy="[object Promise]",Uy="[object Set]",ky="[object WeakMap]",Hy="[object DataView]",PA=fi(lc),DA=fi(Ri),BA=fi(cc),GA=fi(uc),jA=fi(Hl),go=Xr;(lc&&go(new lc(new ArrayBuffer(1)))!=Hy||Ri&&go(new Ri)!=Fy||cc&&go(cc.resolve())!=Vy||uc&&go(new uc)!=Uy||Hl&&go(new Hl)!=ky)&&(go=function(i){var e=Xr(i),t=e==OA?i.constructor:void 0,r=t?fi(t):"";if(r)switch(r){case PA:return Hy;case DA:return Fy;case BA:return Vy;case GA:return Uy;case jA:return ky}return e});var us=go;var EA=Object.prototype,RA=EA.hasOwnProperty;function zA(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&RA.call(i,"index")&&(t.index=i.index,t.input=i.input),t}var Wy=zA;var FA=qt.Uint8Array,eh=FA;function VA(i){var e=new i.constructor(i.byteLength);return new eh(e).set(new eh(i)),e}var fs=VA;function UA(i,e){var t=e?fs(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength)}var qy=UA;var kA=/\w*$/;function HA(i){var e=new i.constructor(i.source,kA.exec(i));return e.lastIndex=i.lastIndex,e}var $y=HA;var Jy=Nr?Nr.prototype:void 0,Ky=Jy?Jy.valueOf:void 0;function WA(i){return Ky?Object(Ky.call(i)):{}}var Xy=WA;function qA(i,e){var t=e?fs(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length)}var fc=qA;var $A="[object Boolean]",JA="[object Date]",KA="[object Map]",XA="[object Number]",ZA="[object RegExp]",YA="[object Set]",QA="[object String]",eO="[object Symbol]",tO="[object ArrayBuffer]",rO="[object DataView]",nO="[object Float32Array]",iO="[object Float64Array]",oO="[object Int8Array]",sO="[object Int16Array]",aO="[object Int32Array]",lO="[object Uint8Array]",cO="[object Uint8ClampedArray]",uO="[object Uint16Array]",fO="[object Uint32Array]";function hO(i,e,t){var r=i.constructor;switch(e){case tO:return fs(i);case $A:case JA:return new r(+i);case rO:return qy(i,t);case nO:case iO:case oO:case sO:case aO:case lO:case cO:case uO:case fO:return fc(i,t);case KA:return new r;case XA:case QA:return new r(i);case ZA:return $y(i);case YA:return new r;case eO:return Xy(i)}}var Zy=hO;function pO(i){return typeof i.constructor=="function"&&!Yo(i)?Lg(as(i)):{}}var hc=pO;var dO="[object Map]";function mO(i){return gr(i)&&us(i)==dO}var Yy=mO;var Qy=hi&&hi.isMap,gO=Qy?es(Qy):Yy,ex=gO;var yO="[object Set]";function xO(i){return gr(i)&&us(i)==yO}var tx=xO;var rx=hi&&hi.isSet,vO=rx?es(rx):tx,nx=vO;var bO=1,SO=2,wO=4,ix="[object Arguments]",NO="[object Array]",CO="[object Boolean]",LO="[object Date]",_O="[object Error]",ox="[object Function]",TO="[object GeneratorFunction]",IO="[object Map]",MO="[object Number]",sx="[object Object]",AO="[object RegExp]",OO="[object Set]",PO="[object String]",DO="[object Symbol]",BO="[object WeakMap]",GO="[object ArrayBuffer]",jO="[object DataView]",EO="[object Float32Array]",RO="[object Float64Array]",zO="[object Int8Array]",FO="[object Int16Array]",VO="[object Int32Array]",UO="[object Uint8Array]",kO="[object Uint8ClampedArray]",HO="[object Uint16Array]",WO="[object Uint32Array]",Nt={};Nt[ix]=Nt[NO]=Nt[GO]=Nt[jO]=Nt[CO]=Nt[LO]=Nt[EO]=Nt[RO]=Nt[zO]=Nt[FO]=Nt[VO]=Nt[IO]=Nt[MO]=Nt[sx]=Nt[AO]=Nt[OO]=Nt[PO]=Nt[DO]=Nt[UO]=Nt[kO]=Nt[HO]=Nt[WO]=!0;Nt[_O]=Nt[ox]=Nt[BO]=!1;function pc(i,e,t,r,n,s){var l,c=e&bO,f=e&SO,h=e&wO;if(t&&(l=n?t(i,r,n,s):t(i)),l!==void 0)return l;if(!yr(i))return i;var d=cr(i);if(d){if(l=Wy(i),!c)return Wl(i,l)}else{var x=us(i),g=x==ox||x==TO;if(Qo(i))return nc(i,c);if(x==sx||x==ix||g&&!n){if(l=f||g?{}:hc(i),!c)return f?Ry(i,Ay(l,i)):Ey(i,My(l,i))}else{if(!Nt[x])return n?i:{};l=Zy(i,x,c)}}s||(s=new rc);var w=s.get(i);if(w)return w;s.set(i,l),nx(i)?i.forEach(function(C){l.add(pc(C,e,t,C,i,s))}):ex(i)&&i.forEach(function(C,G){l.set(G,pc(C,e,t,G,i,s))});var S=h?f?ac:zy:f?Un:ts,D=d?void 0:S(i);return Ag(D||i,function(C,G){D&&(G=C,C=i[G]),Jl(l,G,pc(C,e,t,G,i,s))}),l}var dc=pc;var qO=1,$O=4;function JO(i){return dc(i,qO|$O)}var sa=JO;function KO(i){return function(e,t,r){for(var n=-1,s=Object(e),l=r(e),c=l.length;c--;){var f=l[i?c:++n];if(t(s[f],f,s)===!1)break}return e}}var ax=KO;var XO=ax(),lx=XO;function ZO(i,e,t){(t!==void 0&&!Bi(i[e],t)||t===void 0&&!(e in i))&&Zo(i,e,t)}var aa=ZO;function YO(i){return gr(i)&&Gi(i)}var cx=YO;function QO(i,e){if(!(e==="constructor"&&typeof i[e]=="function")&&e!="__proto__")return i[e]}var la=QO;function eP(i){return pn(i,Un(i))}var ux=eP;function tP(i,e,t,r,n,s,l){var c=la(i,t),f=la(e,t),h=l.get(f);if(h){aa(i,t,h);return}var d=s?s(c,f,t+"",i,e,l):void 0,x=d===void 0;if(x){var g=cr(f),w=!g&&Qo(f),S=!g&&!w&&Zl(f);d=f,g||w||S?cr(c)?d=c:cx(c)?d=Wl(c):w?(x=!1,d=nc(f,!0)):S?(x=!1,d=fc(f,!0)):d=[]:tc(f)||mo(f)?(d=c,mo(c)?d=ux(c):(!yr(c)||Ko(c))&&(d=hc(f))):x=!1}x&&(l.set(f,d),n(d,f,r,s,l),l.delete(f)),aa(i,t,d)}var fx=tP;function hx(i,e,t,r,n){i!==e&&lx(e,function(s,l){if(n||(n=new rc),yr(s))fx(i,e,l,t,hx,r,n);else{var c=r?r(la(i,l),s,l+"",i,e,n):void 0;c===void 0&&(c=s),aa(i,l,c)}},Un)}var px=hx;function rP(i){var e=i==null?0:i.length;return e?i[e-1]:void 0}var dx=rP;function nP(i,e){return e.length<2?i:my(i,Ny(e,0,-1))}var mx=nP;var iP=Bg(function(i,e,t){px(i,e,t)}),yo=iP;function oP(i,e){return e=os(e,i),i=mx(i,e),i==null||delete i[ec(dx(e))]}var gx=oP;function sP(i){return tc(i)?void 0:i}var yx=sP;var aP=1,lP=2,cP=4,uP=Sy(function(i,e){var t={};if(i==null)return t;var r=!1;e=Vl(e,function(s){return s=os(s,i),r||(r=s.length>1),s}),pn(i,ac(i),t),r&&(t=dc(t,aP|lP|cP,yx));for(var n=e.length;n--;)gx(t,e[n]);return t}),hs=uP;var ps;(function(t){t.all=["PerspectiveCamera","OrthographicCamera"];function e(r){return t.all.includes(r)}t.is=e})(ps||(ps={}));var xo;(function(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(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}n.getZoom=r})(xo||(xo={}));var ds;(function(r){r.x="x",r.y="y",r.z="z"})(ds||(ds={}));var xx;(function(s){s.Top="top",s.Right="right",s.Bottom="bottom",s.Left="left",s.Center="center"})(xx||(xx={}));var vx;(function(t){function i(r,n){return r[0]===n[0]&&r[1]===n[1]}t.isEqual=i;function e(r,n,s){return[r[0]+(n[0]-r[0])*s,r[1]+(n[1]-r[1])*s]}t.lerp=e})(vx||(vx={}));var ms;(function(n){function i(s,l){return s[0]===l[0]&&s[1]===l[1]&&s[2]===l[2]}n.isEqual=i;function e(s,l){return[s[0]+l[0],s[1]+l[1],s[2]+l[2]]}n.add=e;function t(s,l){return[s[0]-l[0],s[1]-l[1],s[2]-l[2]]}n.sub=t;function r(s,l,c){return[s[0]+(l[0]-s[0])*c,s[1]+(l[1]-s[1])*c,s[2]+(l[2]-s[2])*c]}n.lerp=r})(ms||(ms={}));var bx;(function(t){function i(r,n){return r[0]===n[0]&&r[1]===n[1]&&r[2]===n[2]&&r[3]===n[3]}t.isEqual=i;function e(r,n,s){return[r[0]+(n[0]-r[0])*s,r[1]+(n[1]-r[1])*s,r[2]+(n[2]-r[2])*s,r[3]+(n[3]-r[3])*s]}t.lerp=e})(bx||(bx={}));var Fi;(function(s){s.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function e(l,c){for(let f=0;f<16;f++)if(l[f]!==c[f])return!1;return!0}s.isEqual=e;function t(l){return l!=null?l:s.identity}s.simplify=t;function r(l,c){let f=c.slice(0);for(var h=0,d=c.length;h<d;h+=3){let x=1/(l[3]*c[h]+l[7]*c[h+1]+l[11]*c[h+2]+l[15]);f[h]=(l[0]*c[h]+l[4]*c[h+1]+l[8]*c[h+2]+l[12])*x,f[h+1]=(l[1]*c[h]+l[5]*c[h+1]+l[9]*c[h+2]+l[13])*x,f[h+2]=(l[2]*c[h]+l[6]*c[h+1]+l[10]*c[h+2]+l[14])*x}return f}s.applyMatrix4=r;function n(l,c){let f=c.slice(0);for(var h=0,d=c.length;h<d;h+=3)f[h]=l[0]*c[h]+l[4]*c[h+1]+l[8]*c[h+2],f[h+1]=l[1]*c[h]+l[5]*c[h+1]+l[9]*c[h+2],f[h+2]=l[2]*c[h]+l[6]*c[h+1]+l[10]*c[h+2];return f}s.applyMatrix3Components=n})(Fi||(Fi={}));var Zr;(function(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 s(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}f.fromHex=s;function l(h,d){return h.r===d.r&&h.g===d.g&&h.b===d.b}f.equals=l;function c(h,d,x){return{r:h.r+(d.r-h.r)*x,g:h.g+(d.g-h.g)*x,b:h.b+(d.b-h.b)*x}}f.lerp=c})(Zr||(Zr={}));var kn;(function(l){l.white=fe(U({},Zr.white),{a:1});function e(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}l.from0to1=e;function t(c,f){return fe(U({},Zr.fromHex(c)),{a:f})}l.fromHexAndA=t;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}}l.toRgb255a1=r;function n(c,f){return Zr.equals(c,f)&&c.a===f.a}l.equals=n;function s(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}}l.lerp=s})(kn||(kn={}));var mc;(function(e){e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]}})(mc||(mc={}));var Sx;(function(P){P[P.SKIP=0]="SKIP",P[P.ADD=1]="ADD",P[P.ALPHA=2]="ALPHA",P[P.AVERAGE=3]="AVERAGE",P[P.COLOR_BURN=4]="COLOR_BURN",P[P.COLOR_DODGE=5]="COLOR_DODGE",P[P.DARKEN=6]="DARKEN",P[P.DIFFERENCE=7]="DIFFERENCE",P[P.EXCLUSION=8]="EXCLUSION",P[P.LIGHTEN=9]="LIGHTEN",P[P.MULTIPLY=10]="MULTIPLY",P[P.DIVIDE=11]="DIVIDE",P[P.NEGATION=12]="NEGATION",P[P.NORMAL=13]="NORMAL",P[P.OVERLAY=14]="OVERLAY",P[P.REFLECT=15]="REFLECT",P[P.SCREEN=16]="SCREEN",P[P.SOFT_LIGHT=17]="SOFT_LIGHT",P[P.SUBTRACT=18]="SUBTRACT"})(Sx||(Sx={}));var wx;(function(c){c[c.LINEAR=0]="LINEAR",c[c.EASE=1]="EASE",c[c.EASE_IN=2]="EASE_IN",c[c.EASE_OUT=3]="EASE_OUT",c[c.EASE_IN_OUT=4]="EASE_IN_OUT",c[c.CUBIC=5]="CUBIC",c[c.SPRING=6]="SPRING"})(wx||(wx={}));var Nx;(function(e){e.defaultData={mass:1,stiffness:80,damping:10,velocity:0}})(Nx||(Nx={}));var Cx;(function(e){e.defaultData={control1:[.5,.05],control2:[.1,.3]}})(Cx||(Cx={}));var gc;(function(e){function i(t,r=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:ds.y,scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[t[0]+t[0]*r,0,0]},grid:{count:[2,2,2],size:t.map(n=>n*(1+r)),useCenter:!0}}}e.defaultData=i})(gc||(gc={}));var Hn;(function(e){e[e.Update=0]="Update"})(Hn||(Hn={}));var dn;(function(r){r[r.Add=1]="Add",r[r.Delete=2]="Delete",r[r.Unlink=3]="Unlink"})(dn||(dn={}));var Yr;(function(r){r[r.Add=4]="Add",r[r.Delete=5]="Delete",r[r.Move=6]="Move"})(Yr||(Yr={}));var jr;(function(r){r[r.Add=7]="Add",r[r.Delete=8]="Delete",r[r.Move=9]="Move"})(jr||(jr={}));var An=class{modifyById(e,t){let r=this;if(r[e]===void 0)throw new Error("not expected");{let s=fe(U({},r),{[e]:t});return Object.setPrototypeOf(s,An.prototype),s}}add(e,t){var n;let r=this.runOp({type:dn.Add,id:e,data:t});return(n=r==null?void 0:r.data)!=null?n:this}runOp(e){let t=this;if(e.type===dn.Add){let r=t[e.id],n;r===void 0?n={type:dn.Delete,id:e.id}:n={type:dn.Add,id:e.id,data:r};let{id:s,data:l}=e,c=fe(U({},t),{[s]:l});return Object.setPrototypeOf(c,An.prototype),{data:c,actual:e,reverse:n}}else if(e.type===dn.Delete){let{id:r}=e,n=t[r];if(n===void 0)return null;{let s=U({},t);return Object.setPrototypeOf(s,An.prototype),delete s[r],{data:s,actual:e,reverse:{type:dn.Add,id:r,data:n}}}}throw new Error("illegal arg")}};function ca(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let e=Object.getOwnPropertyNames(i);for(let t of e){let r=i[t];r&&typeof r=="object"&&ca(r)}return Object.freeze(i)}function Lx(i,e){let t=0;for(;t<i.length&&t<e.length;){if(i[t]<e[t])return-1;if(i[t]>e[t])return 1;t+=1}return t!==e.length?-1:t!==i.length?1:0}var th=class extends Error{};function Wn(i,e,t){if(i===void 0?e===void 0?(i=0,e=10):i=e-10:e===void 0&&(e=i+10),i>e){let s=i;i=e,e=s}let r=[],n=1/(t+1);for(let s=0;s<t;s++){let l=i+(e-i)*(s+.75+Math.random()*.5)*n;r.push(l)}return r}function _x(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 Tx(){return typeof process!="undefined"}function Ix(i,e){for(let t of i)e(t.id,t.data),Ix(t.children,e)}function Mx(i,e){e(i.id,i.data);for(let t of i.children)Mx(t,e)}var On=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,On.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ca(this[e]),e++}fillCaches0(e,t){var r;if((r=this.objCaches)==null?void 0:r.has(e.id))throw new Error("duplicated item");this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let n of e.children)this.fillCaches0(n,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,t){for(;e;){let r=this.parent(e);if(r===t)return!0;e=r}return!1}data(e){var t;return(t=this.get(e))==null?void 0:t.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){var t;return e===null?this:(t=this.get(e))==null?void 0:t.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let r=this.get(e);r&&Mx(r,t)}}traverse(e){Ix(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,t){if(this.get(e)===void 0)throw new Error("not expected");{let n=this.parent(e),s=this.childrenArray(n),l=s.findIndex(h=>h.id===e);if(l<0)throw new Error("not expected");let c=s[l];return s=[...s],s[l]=fe(U({},c),{data:t}),this.modifyArrayBy(n,s)}}modifyArrayBy(e,t){let r=e,n=t;for(;r!==null;){let l=n,c=r;if(r=this.parent(r),r===void 0)throw new Error;n=this.childrenArray(r);let f=n.findIndex(h=>h.id===c);if(f<0)throw new Error;n=[...n],n[f]=fe(U({},n[f]),{children:l})}Object.setPrototypeOf(n,On.prototype);let s=n;return s.fillCaches(),s}runOp(e){switch(e.type){case jr.Add:return this.addOp(e);case jr.Delete:return this.deleteOp(e);case jr.Move:return this.moveOp(e)}}addOp(e){let{parent:t,fi:r,id:n,data:s,children:l}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.get(n)!==void 0)return null;{let c=t,f=this.childrenArray(c),h={fi:r,id:n,data:s,children:l};return f=[...f,h],f.sort((x,g)=>x.fi-g.fi),e.localIndex=f.indexOf(h),{data:this.modifyArrayBy(c,f),actual:e,reverse:{type:jr.Delete,id:n}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let r=this.parent(t);if(r===void 0)return null;let n=this.childrenArray(r),s=n.findIndex(f=>f.id===t);e.localIndex=s,n=[...n];let l=n.splice(s,1)[0];return{data:this.modifyArrayBy(r,n),actual:e,reverse:fe(U({type:jr.Add},l),{parent:r})}}}moveOp(e){let{parent:t,fi:r,id:n}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:jr.Delete,id:n});if(t!==null){let g=t;for(;g!==null;){if(g===void 0)throw new Error;if(g===n)throw new th("cyclic tree");g=this.parent(g)}}let s=this.parent(n);if(s===void 0)return null;let l=s,c=this.childrenArray(s),f=c.findIndex(g=>g.id===n);c=[...c];let h=c.splice(f,1)[0],d=this.modifyArrayBy(s,c);s=t,c=d.childrenArray(s);let x=h.fi;return h=fe(U({},h),{fi:r}),c=[...c,h],c.sort((g,w)=>g.fi-w.fi),e.localIndex=c.indexOf(h),d=d.modifyArrayBy(s,c),{data:d,actual:e,reverse:{type:jr.Move,parent:l,fi:x,id:n}}}previous(e,t){if(t===null){let n=this.childrenArray(e);return n.length===0?null:n[n.length-1].id}let r=null;for(let n of this.childrenArray(e)){if(n.id===t)return r;r=n.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let r=this.childrenArray(t),n=r.findIndex(s=>s.id===e)+1;if(n<r.length)return r[n].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let r=this.childrenArray(t),n=r.findIndex(s=>s.id===e)-1;return n>=0?this.traverseSortPrevious(r[n].id):t}}getAllSorted(e){let t=[];for(let r of e){let n=this.getWithSortKey(r.id);n!==void 0&&t.push(U(U({},r),n))}t.sort((r,n)=>Lx(r.sortKey,n.sortKey));for(let r of t)delete r.sortKey;return t}getWithSortKey(e){var t=e;let r=[],n=this.get(t),s=n;if(n!==void 0){for(;t;)r.splice(0,0,n.fi),t=this.parent(t),t!==null&&(n=this.get(t));return fe(U({},s),{sortKey:r})}}insertBeforeHelper(e,t,r){return this.insertAfterHelper(e,this.previous(e,t),r)}insertAfterHelper(e,t,r){let n=this.childrenArray(e);if(t===null){if(n.length===0)return Wn(0,r,r);{let s=n[0].fi;return Wn(s-r,s,r)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let l=n.find(c=>c.fi>s.fi);if(l===void 0){let c=n[n.length-1].fi;return Wn(c,c+r,r)}else return Wn(s.fi,l.fi,r)}}};var yc;(function(e){function i(t,r){if(Array.isArray(t)){let n=r.props,s={},l=[...t],c=!1;if(n)for(let f of Object.keys(n)){let h=parseInt(f);if(isNaN(h))throw new Error("wrong index");s[f]=l[h],l[h]=n[f],c=!0}return c?{data:l,actual:r,reverse:{type:Hn.Update,props:s}}:null}else{let n=r.props,s={},l=U({},t),c=!1;if(n)for(let f of Object.keys(n)){s[f]=l[f];let h=n[f];h===void 0?delete l[f]:l[f]=h,c=!0}return c?{data:l,actual:r,reverse:{type:Hn.Update,props:s}}:null}}e.runOp=i})(yc||(yc={}));var jt=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,jt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ca(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 t;return(t=this.get(e))==null?void 0:t.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let n=this,s=n.findIndex(f=>f.id===e);if(s<0)throw new Error("not expected");let l=n[s];return n=[...n],n[s]=fe(U({},l),{data:t}),this.modifyArrayBy(n)}}modifyArrayBy(e){Object.setPrototypeOf(e,jt.prototype);let t=e;return Tx()||t.fillCaches(),t}runOp(e){switch(e.type){case Yr.Add:return this.addOp(e);case Yr.Delete:return this.deleteOp(e);case Yr.Move:return this.moveOp(e)}}addOp(e){let{fi:t,id:r,data:n}=e,s=this,l={fi:t,id:r,data:n};return s=[...s,l],s.sort((f,h)=>f.fi-h.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:Yr.Delete,id:r}}}deleteOp(e){let{id:t}=e,r=this,n=r.findIndex(c=>c.id===t);if(n===-1)return null;e.localIndex=n,r=[...r];let s=r.splice(n,1)[0];return{data:this.modifyArrayBy(r),actual:e,reverse:U({type:Yr.Add},s)}}moveOp(e){let{fi:t,id:r}=e,n=this;n=[...n];let s=n.findIndex(h=>h.id===r);if(s===-1)return null;let l=n[s].fi,c=fe(U({},n[s]),{fi:t});return n[s]=c,n.sort((h,d)=>h.fi-d.fi),e.localIndex=n.indexOf(c),{data:this.modifyArrayBy(n),actual:e,reverse:{type:Yr.Move,fi:l,id:r}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let r of this){if(r.id===e)return t;t=r.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let r=this;if(e===null){if(r.length===0)return Wn(0,t,t);{let n=r[0].fi;return Wn(n-t,n,t)}}else{let n=this.get(e);if(n===void 0)throw new Error("illegal args");let s=r.find(l=>l.fi>n.fi);if(s===void 0){let l=r[r.length-1].fi;return Wn(l,l+t,t)}else return Wn(n.fi,s.fi,t)}}};var Ax=Symbol(),xc=Symbol(),ua=class{reportOp(e,t){let r=this;if(t===null)return;r._current=t.data;let n=[];for(;!(r instanceof nh);){let s=r._path,l=r._current;if(s!==""&&n.splice(0,0,s),r=r._parent,r===null)return;r.update(s,l)}r.push(n,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let r=t[xc];r&&r(),delete this._children[e]}}}},Ox=class extends ua{constructor(e,t,r){super();this._parent=e,this._path=t,this._current=r}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current=fe(U({},this._current),{[e]:t})}runOp(e){this.reportOp(e,yc.runOp(this._current,e))}},Px=class extends ua{constructor(e,t,r){super();this._parent=e,this._path=t,this._current=r}update(e,t){this._current=fe(U({},this._current),{[e]:t}),Object.setPrototypeOf(this._current,An.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},Dx={get(i,e){if(e===xc)return()=>{i._parent=null};if(e===Ax)return i._current;let{_current:t,_children:r}=i;if(e==="push"&&Array.isArray(t))throw new Error("not supported to expand array");let n=r===void 0?void 0:r[e];if(n!==void 0)return n;let s=t[e],l=vc(i,e,s);return l!==s?(r===void 0&&(r={},i._children=r),r[e]=l,l):s},has(i,e){return e 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,e){let t=i._current,r=Reflect.getOwnPropertyDescriptor(t,e);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:t[e]}}},fP=fe(U({},Dx),{set(i,e,t){var n;let r={type:Hn.Update,props:{[e]:(n=sh(t))!=null?n:t}};return i.deleteChildren(e),i.runOp(r),!0},deleteProperty(i,e){let t={type:Hn.Update,props:{[e]:void 0}};return i.deleteChildren(e),i.runOp(t),!0}}),hP=fe(U({},Dx),{set(i,e,t){return t===void 0?this.deleteProperty(i,e):(i.deleteChildren(e),i.runOp({type:dn.Add,id:e,data:t})),!0},deleteProperty(i,e){return i.runOp({type:dn.Delete,id:e}),!0}}),fa=class extends ua{constructor(e,t,r){super();this._children={},this._parent=e,this._path=t,this._current=r,this[xc]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,r)=>{e(t,this.data(t))})}data(e){var c;let{_current:t,_children:r}=this,n=r===void 0?void 0:r[e];if(n!==void 0)return n;let s=(c=t.get(e))==null?void 0:c.data,l=vc(this,e,s);return l!==s?(r===void 0&&(r={},this._children=r),r[e]=l,l):s}add(e,t,r,n,s){this.runOp({type:jr.Add,parent:e,fi:t,id:r,data:n,children:s})}move(e,t,r){this.runOp({type:jr.Move,parent:e,fi:t,id:r})}insertAfter(e,t,r){let n=this._current.insertAfterHelper(e,t,r.length);for(let s=0;s<r.length;s++){let l=r[s];this.add(e,n[s],l.id,l.data,l.children)}}insertBefore(e,t,r){let n=this._current.insertBeforeHelper(e,t,r.length);for(let s=0;s<r.length;s++){let l=r[s];this.add(e,n[s],l.id,l.data,l.children)}}moveAfter(e,t,r){let n=this._current.insertAfterHelper(e,t,r.length);for(let s=0;s<r.length;s++){let l=r[s];this.move(e,n[s],l)}}moveBefore(e,t,r){let n=this._current.insertBeforeHelper(e,t,r.length);for(let s=0;s<r.length;s++){let l=r[s];this.move(e,n[s],l)}}delete(e){this.deleteChildren(e),this.runOp({type:jr.Delete,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},ha=class extends ua{constructor(e,t,r){super();this._children={},this._parent=e,this._path=t,this._current=r,this[xc]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let r=0;r<t;r++){let n=this._current[r].id;e(this.data(this._current[r].id),n)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return fe(U({},this._current.get(e)),{data:this.data(e)})}data(e){var c;let{_current:t,_children:r}=this,n=r===void 0?void 0:r[e];if(n!==void 0)return n;let s=(c=t.get(e))==null?void 0:c.data,l=vc(this,e,s);return l!==s?(r===void 0&&(r={},this._children=r),r[e]=l,l):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,r){this.runOp({type:Yr.Add,fi:e,id:t,data:r})}move(e,t){this.runOp({type:Yr.Move,fi:e,id:t})}insertAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let n=0;n<t.length;n++){let s=t[n];this.add(r[n],s.id,s.data)}}insertBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let n=0;n<t.length;n++){let s=t[n];this.add(r[n],s.id,s.data)}}moveAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let n=0;n<t.length;n++){let s=t[n];this.move(r[n],s)}}moveBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let n=0;n<t.length;n++){let s=t[n];this.move(r[n],s)}}delete(e){this.deleteChildren(e),this.runOp({type:Yr.Delete,id:e})}};function rh(i,e,t){if(i.length>0){let r=i[i.length-1];if(r.type===Hn.Update&&e.type===Hn.Update&&bc.equal(r.path,t)){Object.assign(r.props,e.props);return}}i.push(fe(U({},e),{path:t}))}var nh=class{constructor(e){this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,r,n){rh(this.ts,t,e),rh(this.actual,r,e),rh(this.reverse,n,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function vc(i,e,t){return t instanceof On?new fa(i,e,t):t instanceof jt?new ha(i,e,t):t instanceof An?new Proxy(new Px(i,e,t),hP):t!==null&&typeof t=="object"?_x(t)?t:new Proxy(new Ox(i,e,t),fP):t}function ih(i){let e=new nh(i);return[vc(e,"",i),e]}function oh(i,e){let[t,r]=ih(i);return e(t),r.result()}function sh(i){return i instanceof fa||i instanceof ha?i._current:i!==null&&typeof i=="object"?i[Ax]:i}var bc;(function(r){function i(n,s){if(s.length===n.length)for(var l=0;l<n.length;){if(n[l]!==s[l])return!1;l+=1}else return!1;return!0}r.equal=i;function e(n,s,l){let c=t(l,n);if(c!==void 0&&typeof c=="object"&&c!==null){let f=U({},s);return Object.keys(c).forEach(h=>{delete f[h]}),f}else return s}r.removeOverridden=e;function t(n,s,l=0){if(s.length<=l)return n;if((n instanceof On||n instanceof fa)&&typeof s[l]=="string")return t(n.data(s[l]),s,l+1);if((n instanceof jt||n instanceof ha)&&typeof s[l]=="string")return t(n.data(s[l]),s,l+1);if(typeof s[l]=="number"&&Array.isArray(n))return t(n[s[l]],s,l+1);if(typeof s[l]=="string"&&typeof n=="object")return t(n[s[l]],s,l+1)}r.zoom=t})(bc||(bc={}));var ah=class{},Sc=class extends ah{constructor(e){super();this.id=e}},wc=class extends ah{constructor(e){super();this.data=e}};"use strict";var lh;try{lh=new TextDecoder}catch(i){}var ge,Vi,j=0;var Bx=[],ch=Bx,uh=0,Er={},ot,Ui,mn=0,qn=0,Qr,di,Cr=[],ft,Gx={useRecords:!1,mapsAsObjects:!0},Nc=class{},fh=new Nc;fh.name="MessagePack 0xC1";var gs=!1,mi=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(ge)return qx(()=>(_c(),this?this.unpack(e,t):mi.prototype.unpack.call(Gx,e,t)));Vi=t>-1?t:e.length,j=0,uh=0,qn=0,Ui=null,ch=Bx,Qr=null,ge=e;try{ft=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(r){throw ge=null,e instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof mi){if(Er=this,this.structures)return ot=this.structures,Cc();(!ot||ot.length>0)&&(ot=[])}else Er=Gx,(!ot||ot.length>0)&&(ot=[]);return Cc()}unpackMultiple(e,t){let r,n=0;try{gs=!0;let s=e.length,l=this?this.unpack(e,s):Ic.unpack(e,s);if(t){for(t(l);j<s;)if(n=j,t(Cc())===!1)return}else{for(r=[l];j<s;)n=j,r.push(Cc());return r}}catch(s){throw s.lastPosition=n,s.values=r,s}finally{gs=!1,_c()}}_mergeStructures(e,t){e=e||[];for(let r=0,n=e.length;r<n;r++){let s=e[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}e.sharedLength=e.length;for(let r in t||[])if(r>=0){let n=e[r],s=t[r];s&&(n&&((e.restoreStructures||(e.restoreStructures=[]))[r]=n),e[r]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Cc(){try{if(!Er.trusted&&!gs){let e=ot.sharedLength||0;e<ot.length&&(ot.length=e)}let i=Et();if(j==Vi)ot.restoreStructures&&jx(),ot=null,ge=null,di&&(di=null);else if(j>Vi){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}else if(!gs)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw ot.restoreStructures&&jx(),_c(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function jx(){for(let i in ot.restoreStructures)ot[i]=ot.restoreStructures[i];ot.restoreStructures=null}function Et(){let i=ge[j++];if(i<160)if(i<128){if(i<64)return i;{let e=ot[i&63]||Er.getStructures&&Rx()[i&63];return e?(e.read||(e.read=hh(e,i&63)),e.read()):i}}else if(i<144)if(i-=128,Er.mapsAsObjects){let e={};for(let t=0;t<i;t++)e[kx()]=Et();return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(Et(),Et());return e}else{i-=144;let e=new Array(i);for(let t=0;t<i;t++)e[t]=Et();return e}else if(i<192){let e=i-160;if(qn>=j)return Ui.slice(j-mn,(j+=e)-mn);if(qn==0&&Vi<140){let t=e<16?dh(e):Vx(e);if(t!=null)return t}return ph(e)}else{let e;switch(i){case 192:return null;case 193:return Qr?(e=Et(),e>0?Qr[1].slice(Qr.position1,Qr.position1+=e):Qr[0].slice(Qr.position0,Qr.position0-=e)):fh;case 194:return!1;case 195:return!0;case 196:return mh(ge[j++]);case 197:return e=ft.getUint16(j),j+=2,mh(e);case 198:return e=ft.getUint32(j),j+=4,mh(e);case 199:return vo(ge[j++]);case 200:return e=ft.getUint16(j),j+=2,vo(e);case 201:return e=ft.getUint32(j),j+=4,vo(e);case 202:if(e=ft.getFloat32(j),Er.useFloat32>2){let t=Tc[(ge[j]&127)<<1|ge[j+1]>>7];return j+=4,(t*e+(e>0?.5:-.5)>>0)/t}return j+=4,e;case 203:return e=ft.getFloat64(j),j+=8,e;case 204:return ge[j++];case 205:return e=ft.getUint16(j),j+=2,e;case 206:return e=ft.getUint32(j),j+=4,e;case 207:return Er.int64AsNumber?(e=ft.getUint32(j)*4294967296,e+=ft.getUint32(j+4)):e=ft.getBigUint64(j),j+=8,e;case 208:return ft.getInt8(j++);case 209:return e=ft.getInt16(j),j+=2,e;case 210:return e=ft.getInt32(j),j+=4,e;case 211:return Er.int64AsNumber?(e=ft.getInt32(j)*4294967296,e+=ft.getUint32(j+4)):e=ft.getBigInt64(j),j+=8,e;case 212:if(e=ge[j++],e==114)return Hx(ge[j++]&63);{let t=Cr[e];if(t)return t.read?(j++,t.read(Et())):t.noBuffer?(j++,t()):t(ge.subarray(j,++j));throw new Error("Unknown extension "+e)}case 213:return e=ge[j],e==114?(j++,Hx(ge[j++]&63,ge[j++])):vo(2);case 214:return vo(4);case 215:return vo(8);case 216:return vo(16);case 217:return e=ge[j++],qn>=j?Ui.slice(j-mn,(j+=e)-mn):dP(e);case 218:return e=ft.getUint16(j),j+=2,qn>=j?Ui.slice(j-mn,(j+=e)-mn):mP(e);case 219:return e=ft.getUint32(j),j+=4,qn>=j?Ui.slice(j-mn,(j+=e)-mn):gP(e);case 220:return e=ft.getUint16(j),j+=2,zx(e);case 221:return e=ft.getUint32(j),j+=4,zx(e);case 222:return e=ft.getUint16(j),j+=2,Fx(e);case 223:return e=ft.getUint32(j),j+=4,Fx(e);default:if(i>=224)return i-256;if(i===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+i)}}}var pP=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function hh(i,e){function t(){if(t.count++>2){let n=i.read=new Function("r","return function(){return {"+i.map(s=>pP.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Et);return i.highByte===0&&(i.read=Ex(e,i.read)),n()}let r={};for(let n=0,s=i.length;n<s;n++){let l=i[n];r[l]=Et()}return r}return t.count=0,i.highByte===0?Ex(e,t):t}var Ex=(i,e)=>function(){let t=ge[j++];if(t===0)return e();let r=i<32?-(i+(t<<5)):i+(t<<5),n=ot[r]||Rx()[r];if(!n)throw new Error("Record id is not defined for "+r);return n.read||(n.read=hh(n,i)),n.read()};function Rx(){let i=qx(()=>(ge=null,Er.getStructures()));return ot=Er._mergeStructures(i,ot)}var ph=Lc,dP=Lc,mP=Lc,gP=Lc;function Lc(i){let e;if(i<16&&(e=dh(i)))return e;if(i>64&&lh)return lh.decode(ge.subarray(j,j+=i));let t=j+i,r=[];for(e="";j<t;){let n=ge[j++];if((n&128)==0)r.push(n);else if((n&224)==192){let s=ge[j++]&63;r.push((n&31)<<6|s)}else if((n&240)==224){let s=ge[j++]&63,l=ge[j++]&63;r.push((n&31)<<12|s<<6|l)}else if((n&248)==240){let s=ge[j++]&63,l=ge[j++]&63,c=ge[j++]&63,f=(n&7)<<18|s<<12|l<<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&&(e+=ir.apply(String,r),r.length=0)}return r.length>0&&(e+=ir.apply(String,r)),e}function zx(i){let e=new Array(i);for(let t=0;t<i;t++)e[t]=Et();return e}function Fx(i){if(Er.mapsAsObjects){let e={};for(let t=0;t<i;t++)e[kx()]=Et();return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(Et(),Et());return e}}var ir=String.fromCharCode;function Vx(i){let e=j,t=new Array(i);for(let r=0;r<i;r++){let n=ge[j++];if((n&128)>0){j=e;return}t[r]=n}return ir.apply(String,t)}function dh(i){if(i<4)if(i<2){if(i===0)return"";{let e=ge[j++];if((e&128)>1){j-=1;return}return ir(e)}}else{let e=ge[j++],t=ge[j++];if((e&128)>0||(t&128)>0){j-=2;return}if(i<3)return ir(e,t);let r=ge[j++];if((r&128)>0){j-=3;return}return ir(e,t,r)}else{let e=ge[j++],t=ge[j++],r=ge[j++],n=ge[j++];if((e&128)>0||(t&128)>0||(r&128)>0||(n&128)>0){j-=4;return}if(i<6){if(i===4)return ir(e,t,r,n);{let s=ge[j++];if((s&128)>0){j-=5;return}return ir(e,t,r,n,s)}}else if(i<8){let s=ge[j++],l=ge[j++];if((s&128)>0||(l&128)>0){j-=6;return}if(i<7)return ir(e,t,r,n,s,l);let c=ge[j++];if((c&128)>0){j-=7;return}return ir(e,t,r,n,s,l,c)}else{let s=ge[j++],l=ge[j++],c=ge[j++],f=ge[j++];if((s&128)>0||(l&128)>0||(c&128)>0||(f&128)>0){j-=8;return}if(i<10){if(i===8)return ir(e,t,r,n,s,l,c,f);{let h=ge[j++];if((h&128)>0){j-=9;return}return ir(e,t,r,n,s,l,c,f,h)}}else if(i<12){let h=ge[j++],d=ge[j++];if((h&128)>0||(d&128)>0){j-=10;return}if(i<11)return ir(e,t,r,n,s,l,c,f,h,d);let x=ge[j++];if((x&128)>0){j-=11;return}return ir(e,t,r,n,s,l,c,f,h,d,x)}else{let h=ge[j++],d=ge[j++],x=ge[j++],g=ge[j++];if((h&128)>0||(d&128)>0||(x&128)>0||(g&128)>0){j-=12;return}if(i<14){if(i===12)return ir(e,t,r,n,s,l,c,f,h,d,x,g);{let w=ge[j++];if((w&128)>0){j-=13;return}return ir(e,t,r,n,s,l,c,f,h,d,x,g,w)}}else{let w=ge[j++],S=ge[j++];if((w&128)>0||(S&128)>0){j-=14;return}if(i<15)return ir(e,t,r,n,s,l,c,f,h,d,x,g,w,S);let D=ge[j++];if((D&128)>0){j-=15;return}return ir(e,t,r,n,s,l,c,f,h,d,x,g,w,S,D)}}}}}function mh(i){return Er.copyBuffers?Uint8Array.prototype.slice.call(ge,j,j+=i):ge.subarray(j,j+=i)}function vo(i){let e=ge[j++];if(Cr[e])return Cr[e](ge.subarray(j,j+=i));throw new Error("Unknown extension type "+e)}var Ux=new Array(4096);function kx(){let i=ge[j++];if(i>=160&&i<192){if(i=i-160,qn>=j)return Ui.slice(j-mn,(j+=i)-mn);if(!(qn==0&&Vi<180))return ph(i)}else return j--,Et();let e=(i<<5^(i>1?ft.getUint16(j):i>0?ge[j]:0))&4095,t=Ux[e],r=j,n=j+i-3,s,l=0;if(t&&t.bytes==i){for(;r<n;){if(s=ft.getUint32(r),s!=t[l++]){r=1879048192;break}r+=4}for(n+=3;r<n;)if(s=ge[r++],s!=t[l++]){r=1879048192;break}if(r===n)return j=r,t.string;n-=3,r=j}for(t=[],Ux[e]=t,t.bytes=i;r<n;)s=ft.getUint32(r),t.push(s),r+=4;for(n+=3;r<n;)s=ge[r++],t.push(s);let c=i<16?dh(i):Vx(i);return c!=null?t.string=c:t.string=ph(i)}var Hx=(i,e)=>{var t=Et();let r=i;e!==void 0&&(i=i<32?-((e<<5)+i):(e<<5)+i,t.highByte=e);let n=ot[i];return n&&n.isShared&&((ot.restoreStructures||(ot.restoreStructures=[]))[i]=n),ot[i]=t,t.read=hh(t,r),t.read()},Wx=typeof self=="object"?self:global;Cr[0]=()=>{};Cr[0].noBuffer=!0;Cr[101]=()=>{let i=Et();return(Wx[i[0]]||Error)(i[1])};Cr[105]=i=>{let e=ft.getUint32(j-4);di||(di=new Map);let t=ge[j],r;t>=144&&t<160||t==220||t==221?r=[]:r={};let n={target:r};di.set(e,n);let s=Et();return n.used?Object.assign(r,s):(n.target=s,s)};Cr[112]=i=>{let e=ft.getUint32(j-4),t=di.get(e);return t.used=!0,t.target};Cr[115]=()=>new Set(Et());var gh=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");Cr[116]=i=>{let e=i[0],t=gh[e];if(!t)throw new Error("Could not find typed array for code "+e);return new Wx[t](Uint8Array.prototype.slice.call(i,1).buffer)};Cr[120]=()=>{let i=Et();return new RegExp(i[0],i[1])};Cr[98]=i=>{let e=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],t=j;j+=e-4,Qr=[Et(),Et()],Qr.position0=0,Qr.position1=0;let r=j;j=t;try{return Et()}finally{j=r}};Cr[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 qx(i){let e=Vi,t=j,r=uh,n=mn,s=qn,l=Ui,c=ch,f=di,h=Qr,d=new Uint8Array(ge.slice(0,Vi)),x=ot,g=ot.slice(0,ot.length),w=Er,S=gs,D=i();return Vi=e,j=t,uh=r,mn=n,qn=s,Ui=l,ch=c,di=f,Qr=h,ge=d,gs=S,ot=x,ot.splice(0,ot.length,...g),Er=w,ft=new DataView(ge.buffer,ge.byteOffset,ge.byteLength),D}function _c(){ge=null,di=null,ot=null}function $x(i){i.unpack?Cr[i.type]=i.unpack:Cr[i.type]=i}var Tc=new Array(147);for(let i=0;i<256;i++)Tc[i]=+("1e"+Math.floor(45.15-i*.30103));var Ic=new mi({useRecords:!1}),yP=Ic.unpack,xP=Ic.unpackMultiple,vP=Ic.unpack;var bP=new Float32Array(1),zU=new Uint8Array(bP.buffer,0,4);"use strict";var Mc;try{Mc=new TextEncoder}catch(i){}var Ac,yh,Oc=typeof Buffer!="undefined",xh=Oc?Buffer.allocUnsafeSlow:Uint8Array,Kx=Oc?Buffer:Uint8Array,Xx=Oc?4294967296:2144337920,Z,Vt,F=0,$n,Jn=null,SP=/[\u0080-\uFFFF]/,pa=Symbol("record-id"),ys=class extends mi{constructor(e){super(e);this.offset=0;let t,r,n,s,l,c,f=0,h=Kx.prototype.utf8Write?function(b,R,T){return Z.utf8Write(b,R,T)}:Mc&&Mc.encodeInto?function(b,R){return Mc.encodeInto(b,Z.subarray(R)).written}:!1,d=this;e||(e={});let x=e&&e.sequential,g=e.structures||e.saveStructures,w=e.maxSharedStructures;if(w==null&&(w=g?32:0),w>8160)throw new Error("Maximum maxSharedStructure is 8160");let S=e.maxOwnStructures;S==null&&(S=g?32:64),x&&!e.saveStructures&&(this.structures=[]);let D=w>32||S+w>64,C=w+64,G=w+S+64;if(G>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let B=[],P=0,W=0;this.pack=this.encode=function(b,R){if(Z||(Z=new xh(8192),Vt=new DataView(Z.buffer,0,8192),F=0),$n=Z.length-10,$n-F<2048?(Z=new xh(Z.length),Vt=new DataView(Z.buffer,0,Z.length),$n=Z.length-10,F=0):F=F+7&2147483640,r=F,c=d.structuredClone?new Map:null,d.bundleStrings?(Jn=["",""],Z[F++]=214,Z[F++]=98,Jn.position=F-r,F+=4):Jn=null,n=d.structures,n){n.uninitialized&&(n=d._mergeStructures(d.getStructures()));let T=n.sharedLength||0;if(T>w)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 z=0;z<T;z++){let A=n[z];if(!A)continue;let $,he=n.transitions;for(let re=0,Ne=A.length;re<Ne;re++){let ye=A[re];$=he[ye],$||($=he[ye]=Object.create(null)),he=$}he[pa]=z+64}f=T}x||(n.nextId=T+64)}s&&(s=!1),l=n||[];try{if(M(b),Jn){Vt.setUint32(Jn.position+r,F-Jn.position-r);let T=Jn;Jn=null,M(T[0]),M(T[1])}if(d.offset=F,c&&c.idsToInsert){F+=c.idsToInsert.length*6,F>$n&&E(F),d.offset=F;let T=NP(Z.subarray(r,F),c.idsToInsert);return c=null,T}return R&e0?(Z.start=r,Z.end=F,Z):Z.subarray(r,F)}finally{if(n){if(W<10&&W++,P>1e4)n.transitions=null,W=0,P=0,B.length>0&&(B=[]);else if(B.length>0&&!x){for(let T=0,z=B.length;T<z;T++)B[T][pa]=0;B=[]}if(s&&d.saveStructures){let T=n.sharedLength||w;n.length>T&&(n=n.slice(0,T));let z=Z.subarray(r,F);return d.saveStructures(n,f)===!1?(d._mergeStructures(d.getStructures()),d.pack(b)):(f=T,z)}}R&_P&&(F=r)}};let M=b=>{F>$n&&(Z=E(F));var R=typeof b,T;if(R==="string"){let z=b.length;if(Jn&&z>=8&&z<4096){let he=SP.test(b);Jn[he?0:1]+=b,Z[F++]=193,M(he?-z:z);return}let A;z<32?A=1:z<256?A=2:z<65536?A=3:A=5;let $=z*3;if(F+$>$n&&(Z=E(F+$)),z<64||!h){let he,re,Ne,ye=F+A;for(he=0;he<z;he++)re=b.charCodeAt(he),re<128?Z[ye++]=re:re<2048?(Z[ye++]=re>>6|192,Z[ye++]=re&63|128):(re&64512)==55296&&((Ne=b.charCodeAt(he+1))&64512)==56320?(re=65536+((re&1023)<<10)+(Ne&1023),he++,Z[ye++]=re>>18|240,Z[ye++]=re>>12&63|128,Z[ye++]=re>>6&63|128,Z[ye++]=re&63|128):(Z[ye++]=re>>12|224,Z[ye++]=re>>6&63|128,Z[ye++]=re&63|128);T=ye-F-A}else T=h(b,F+A,$);T<32?Z[F++]=160|T:T<256?(A<2&&Z.copyWithin(F+2,F+1,F+1+T),Z[F++]=217,Z[F++]=T):T<65536?(A<3&&Z.copyWithin(F+3,F+2,F+2+T),Z[F++]=218,Z[F++]=T>>8,Z[F++]=T&255):(A<5&&Z.copyWithin(F+5,F+3,F+3+T),Z[F++]=219,Vt.setUint32(F,T),F+=4),F+=T}else if(R==="number")if(b>>>0===b)b<64?Z[F++]=b:b<256?(Z[F++]=204,Z[F++]=b):b<65536?(Z[F++]=205,Z[F++]=b>>8,Z[F++]=b&255):(Z[F++]=206,Vt.setUint32(F,b),F+=4);else if(b>>0===b)b>=-32?Z[F++]=256+b:b>=-128?(Z[F++]=208,Z[F++]=b+256):b>=-32768?(Z[F++]=209,Vt.setInt16(F,b),F+=2):(Z[F++]=210,Vt.setInt32(F,b),F+=4);else{let z;if((z=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){Z[F++]=202,Vt.setFloat32(F,b);let A;if(z<4||(A=b*Tc[(Z[F]&127)<<1|Z[F+1]>>7])>>0===A){F+=4;return}else F--}Z[F++]=203,Vt.setFloat64(F,b),F+=8}else if(R==="object")if(!b)Z[F++]=192;else{if(c){let A=c.get(b);if(A){if(!A.id){let $=c.idsToInsert||(c.idsToInsert=[]);A.id=$.push(A)}Z[F++]=214,Z[F++]=112,Vt.setUint32(F,A.id),F+=4;return}else c.set(b,{offset:F-r})}let z=b.constructor;if(z===Object)q(b,!0);else if(z===Array){T=b.length,T<16?Z[F++]=144|T:T<65536?(Z[F++]=220,Z[F++]=T>>8,Z[F++]=T&255):(Z[F++]=221,Vt.setUint32(F,T),F+=4);for(let A=0;A<T;A++)M(b[A])}else if(z===Map){T=b.size,T<16?Z[F++]=128|T:T<65536?(Z[F++]=222,Z[F++]=T>>8,Z[F++]=T&255):(Z[F++]=223,Vt.setUint32(F,T),F+=4);for(let[A,$]of b)M(A),M($)}else{for(let A=0,$=Ac.length;A<$;A++){let he=yh[A];if(b instanceof he){let re=Ac[A];if(re.write){re.type&&(Z[F++]=212,Z[F++]=re.type,Z[F++]=0),M(re.write.call(this,b));return}let Ne=Z,ye=Vt,Me=F;Z=null;let Fe;try{Fe=re.pack.call(this,b,k=>(Z=Ne,Ne=null,F+=k,F>$n&&E(F),{target:Z,targetView:Vt,position:F-k}),M)}finally{Ne&&(Z=Ne,Vt=ye,F=Me,$n=Z.length-10)}Fe&&(Fe.length+F>$n&&E(Fe.length+F),F=wP(Fe,Z,F,re.type));return}}q(b,!b.hasOwnProperty)}}else if(R==="boolean")Z[F++]=b?195:194;else if(R==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))Z[F++]=211,Vt.setBigInt64(F,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)Z[F++]=207,Vt.setBigUint64(F,b);else if(this.largeBigIntToFloat)Z[F++]=203,Vt.setFloat64(F,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");F+=8}else if(R==="undefined")this.encodeUndefinedAsNil?Z[F++]=192:(Z[F++]=212,Z[F++]=0,Z[F++]=0);else if(R==="function")M(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+R)},q=this.useRecords===!1?this.variableMapSize?b=>{let R=Object.keys(b),T=R.length;T<16?Z[F++]=128|T:T<65536?(Z[F++]=222,Z[F++]=T>>8,Z[F++]=T&255):(Z[F++]=223,Vt.setUint32(F,T),F+=4);let z;for(let A=0;A<T;A++)M(z=R[A]),M(b[z])}:(b,R)=>{Z[F++]=222;let T=F-r;F+=2;let z=0;for(let A in b)(R||b.hasOwnProperty(A))&&(M(A),M(b[A]),z++);Z[T+++r]=z>>8,Z[T+r]=z&255}:b=>{let R=Object.keys(b),T,z=l.transitions||(l.transitions=Object.create(null)),A=0;for(let he=0,re=R.length;he<re;he++){let Ne=R[he];T=z[Ne],T||(T=z[Ne]=Object.create(null),A++),z=T}let $=z[pa];if($)$>=96&&D?(Z[F++]=(($-=96)&31)+96,Z[F++]=$>>5):Z[F++]=$;else{$=l.nextId,$||($=64),$<C&&this.shouldShareStructure&&!this.shouldShareStructure(R)?($=l.nextOwnId,$<G||($=C),l.nextOwnId=$+1):($>=G&&($=C),l.nextId=$+1);let he=R.highByte=$>=96&&D?$-96>>5:-1;z[pa]=$,l[$-64]=R,$<C?(R.isShared=!0,l.sharedLength=$-63,s=!0,he>=0?(Z[F++]=($&31)+96,Z[F++]=he):Z[F++]=$):(he>=0?(Z[F++]=213,Z[F++]=114,Z[F++]=($&31)+96,Z[F++]=he):(Z[F++]=212,Z[F++]=114,Z[F++]=$),A&&(P+=W*A),B.length>=S&&(B.shift()[pa]=0),B.push(z),M(R))}for(let he=0,re=R.length;he<re;he++)M(b[R[he]])},E=b=>{let R;if(b>16777216){if(b-r>Xx)throw new Error("Packed buffer would be larger than maximum buffer size");R=Math.min(Xx,Math.round(Math.max((b-r)*(b>67108864?1.25:2),4194304)/4096)*4096)}else R=(Math.max(b-r<<2,Z.length-1)>>12)+1<<12;let T=new xh(R);return Vt=new DataView(T.buffer,0,R),Z.copy?Z.copy(T,0,r,b):T.set(Z.slice(r,b)),F-=r,r=0,$n=T.length-10,Z=T}}useBuffer(e){Z=e,Vt=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),F=0}};yh=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Nc];Ac=[{pack(i,e,t){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:n,targetView:s,position:l}=e(6);n[l++]=214,n[l++]=255,s.setUint32(l,r)}else if(r>0&&r<17179869184){let{target:n,targetView:s,position:l}=e(10);n[l++]=215,n[l++]=255,s.setUint32(l,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(l+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:n,targetView:s,position:l}=e(3);n[l++]=212,n[l++]=255,n[l++]=255}else{let{target:n,targetView:s,position:l}=e(15);n[l++]=199,n[l++]=12,n[l++]=255,s.setUint32(l,i.getMilliseconds()*1e6),s.setBigInt64(l+4,BigInt(Math.floor(r)))}}},{pack(i,e,t){let r=Array.from(i),{target:n,position:s}=e(this.structuredClone?3:0);this.structuredClone&&(n[s++]=212,n[s++]=115,n[s++]=0),t(r)}},{pack(i,e,t){let{target:r,position:n}=e(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=101,r[n++]=0),t([i.name,i.message])}},{pack(i,e,t){let{target:r,position:n}=e(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=120,r[n++]=0),t([i.source,i.flags])}},{pack(i,e){this.structuredClone?Zx(i,16,e):Yx(Oc?Buffer.from(i):new Uint8Array(i),e)}},{pack(i,e){let t=i.constructor;t!==Kx&&this.structuredClone?Zx(i,gh.indexOf(t.name),e):Yx(i,e)}},{pack(i,e){let{target:t,position:r}=e(1);t[r]=193}}];function Zx(i,e,t,r){let n=i.byteLength;if(n+1<256){var{target:s,position:l}=t(4+n);s[l++]=199,s[l++]=n+1}else if(n+1<65536){var{target:s,position:l}=t(5+n);s[l++]=200,s[l++]=n+1>>8,s[l++]=n+1&255}else{var{target:s,position:l,targetView:c}=t(7+n);s[l++]=201,c.setUint32(l,n+1),l+=4}s[l++]=116,s[l++]=e,s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),l)}function Yx(i,e){let t=i.byteLength;var r,n;if(t<256){var{target:r,position:n}=e(t+2);r[n++]=196,r[n++]=t}else if(t<65536){var{target:r,position:n}=e(t+3);r[n++]=197,r[n++]=t>>8,r[n++]=t&255}else{var{target:r,position:n,targetView:s}=e(t+5);r[n++]=198,s.setUint32(n,t),n+=4}r.set(i,n)}function wP(i,e,t,r){let n=i.length;switch(n){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:n<256?(e[t++]=199,e[t++]=n):n<65536?(e[t++]=200,e[t++]=n>>8,e[t++]=n&255):(e[t++]=201,e[t++]=n>>24,e[t++]=n>>16&255,e[t++]=n>>8&255,e[t++]=n&255)}return e[t++]=r,e.set(i,t),t+=n,t}function NP(i,e){let t,r=e.length*6,n=i.length-r;for(e.sort((s,l)=>s.offset>l.offset?1:-1);t=e.pop();){let s=t.offset,l=t.id;i.copyWithin(s+r,s,n),r-=6;let c=s+r;i[c++]=214,i[c++]=105,i[c++]=l>>24,i[c++]=l>>16&255,i[c++]=l>>8&255,i[c++]=l&255,n=s}return i}function bo(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),Ac.unshift(i)}$x(i)}var Qx=new ys({useRecords:!1}),CP=Qx.pack,LP=Qx.pack;var e0=512,_P=1024;var t0=new ys({structuredClone:!0});bo({Class:An.prototype.constructor,type:1,write(i){return U({},i)},read(i){return Object.setPrototypeOf(i,An.prototype),i}});bo({Class:jt.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,jt.prototype),i}});bo({Class:On.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,On.prototype),i}});bo({Class:Sc.prototype.constructor,type:4,write(i){return i.id},read(i){return new Sc(i)}});bo({Class:wc.prototype.constructor,type:5,write(i){return i.data},read(i){return new wc(i)}});function TP(i){var e=0;if(i.length===0)return e;for(let t=0;t<i.length;t++){let r=i[t];e=(e<<5)-e+r,e=e&e}return e}var Pc;(function(r){function i(n){return t0.pack(n)}r.serialize=i;function e(n){return t0.unpack(n)}r.deserialize=e;function t(n){return TP(i(n)).toString()}r.checksum=t})(Pc||(Pc={}));var Dc;(function(t){t.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function e(r){return t.all.includes(r)}t.is=e})(Dc||(Dc={}));var Bc;(function(t){function i(r){return e(r)}t.defaultData=i;function e(r){if(r==="PointLight")return{type:r,color:kn.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:2500,helper:!0};if(r==="SpotLight")return{type:r,color:kn.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:kn.white,intensity:1,shadows:!0,size:2500,depth:2500,helper:!0};throw new Error("not implemented")}})(Bc||(Bc={}));var xs;(function(r){r[r.Front=0]="Front",r[r.Back=1]="Back",r[r.Double=2]="Double"})(xs||(xs={}));var vh;(function(t){t.defaultData={castShadow:!0,receiveShadow:!0};function e(r,n){return r.castShadow===n.castShadow&&r.receiveShadow===n.receiveShadow}t.equals=e})(vh||(vh={}));var bh;(function(t){t.defaultData={flatShading:!1,wireframe:!1,side:0};function e(r,n){return r.flatShading===n.flatShading&&r.side===n.side&&r.wireframe===n.wireframe}t.equals=e})(bh||(bh={}));var Gc;(function(e){e.defaultData=fe(U(U({},bh.defaultData),vh.defaultData),{cloner:null})})(Gc||(Gc={}));var Lr;(function(n){n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.Center=3]="Center",n[n.Justify=4]="Justify"})(Lr||(Lr={}));var gi;(function(r){r[r.Top=1]="Top",r[r.Center=2]="Center",r[r.Bottom=3]="Bottom"})(gi||(gi={}));var ki;(function(r){r[r.None=1]="None",r[r.Upper=2]="Upper",r[r.Lower=3]="Lower"})(ki||(ki={}));var jc;(function(e){e.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:kn.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"}})(jc||(jc={}));var Zt;(function(n){n[n.Normal=0]="Normal",n[n.Multiply=1]="Multiply",n[n.Screen=2]="Screen",n[n.Overlay=3]="Overlay"})(Zt||(Zt={}));var vs;(function(r){r[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar"})(vs||(vs={}));var Ec;(function(r){r[r.RepeatWrapping=1e3]="RepeatWrapping",r[r.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",r[r.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping"})(Ec||(Ec={}));var Rc;(function(n){n[n.UV=0]="UV",n[n.Planar=1]="Planar",n[n.Spherical=2]="Spherical",n[n.Cylindrical=3]="Cylindrical"})(Rc||(Rc={}));var zc;(function(s){s[s.Simplex=0]="Simplex",s[s.SimplexFractal=1]="SimplexFractal",s[s.Ashima=2]="Ashima",s[s.Fbm=3]="Fbm",s[s.Perlin=4]="Perlin"})(zc||(zc={}));var bs;(function(r){function i(n,s){return n==="light"&&s?e(s):t(n)}r.defaultData=i;function e(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:.2,g:.2,b:.2,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 t(n){switch(n){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:ds.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:Zr.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:fe(U({},Zr.fromHex(6710886)),{a:1}),colorB:fe(U({},Zr.fromHex(6710886)),{a:1}),colorC:fe(U({},Zr.fromHex(16777215)),{a:1}),colorD:fe(U({},Zr.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:kn.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}}}})(bs||(bs={}));var Ss;(function(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})&&!t(f)}c.isMergable=i;function e(f){let h="";return f.layers.forEach(d=>{Object.entries(d.data).forEach(([x,g])=>{h+=`${x}${g}`,Array.isArray(g)?g.forEach(w=>h+=`${w}`):typeof g=="object"?Object.values(g).forEach(w=>{typeof w=="number"?h+=`${w.toFixed(4)}`:h+=`${w}`}):h+=`${g}`})}),h}c.getHash=e;function t(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=t;function r(){return{layers:new jt}}c.defaultEmptyData=r;function n(f="layer1",h="layer2"){return s("phong",f,h)}c.defaultData=n;function s(f,h="layer1",d="layer2"){let x=new jt;return x.push({fi:0,data:bs.defaultData("light",f),id:h}),x.push({fi:1,data:bs.defaultData("color"),id:d}),{layers:x}}c.defaultTwoLayerData=s;function l(f,h="basic",d="layer1",x="layer2"){let g=bs.defaultData("texture");Object.assign(g.texture,{image:f});let w=new jt;return w.push({fi:0,data:g,id:d}),w.push({fi:1,data:bs.defaultData("light",h),id:x}),{layers:w}}c.defaultTwoLayerTextureData=l})(Ss||(Ss={}));var ws;(function(r){function i(){return{points:new jt,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=i;function e(n,s){let{points:l}=s;if(l){for(let c of l)if(c.data.position[0]===n[0]&&c.data.position[1]===n[1])return!0}return!1}r.isOverlappingExistingPoint=e;function t(n,s){let l=n.controlNext,c=s.controlPrevious;return n.position[0]===l.position[0]&&n.position[1]===l.position[1]&&s.position[0]===c.position[0]&&s.position[1]===c.position[1]}r.isStraightLine=t})(ws||(ws={}));var Fc;(function(e){function i(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=i})(Fc||(Fc={}));var Vc;(function(e){function i(t){if(t==="RectangleGeometry")return{width:320,height:320,type:t,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};if(t==="VectorGeometry")return{width:100,height:100,type:t,subdivisions:12,shape:ws.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};throw new Error("not implemented")}e.defaultData=i})(Vc||(Vc={}));var da;(function(n){n.identity=fe(U({},mc.identity),{hiddenMatrix:Fi.identity});function e(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}n.fromObject=e;function t(s,l){return{position:(l==null?void 0:l.position)||s.position,rotation:(l==null?void 0:l.rotation)||s.rotation,scale:(l==null?void 0:l.scale)||s.scale,hiddenMatrix:(l==null?void 0:l.hiddenMatrix)||s.hiddenMatrix}}n.merge=t;function r(s,l){return{position:ms.isEqual(s.position,l.position)?null:l.position,rotation:ms.isEqual(s.rotation,l.rotation)?null:l.rotation,scale:ms.isEqual(s.scale,l.scale)?null:l.scale,hiddenMatrix:Fi.isEqual(s.hiddenMatrix,l.hiddenMatrix)?null:l.hiddenMatrix}}n.diff=r})(da||(da={}));var Hi;(function(e){e.defaultData=U({states:new jt,events:new jt,visible:!0,raycastLock:!1},da.identity)})(Hi||(Hi={}));var r0;(function(e){e.defaultData=U({type:"Empty"},Hi.defaultData)})(r0||(r0={}));var Sh;(function(e){e.defaultData=U(U({type:"Mesh"},Hi.defaultData),Gc.defaultData)})(Sh||(Sh={}));var n0;(function(e){e.defaultData=U(U({type:"TextFrame"},Hi.defaultData),jc.defaultData)})(n0||(n0={}));var Uc;(function(e){e.defaultData=U(U(U({},Hi.defaultData),da.identity),xo.defaultData)})(Uc||(Uc={}));var i0;(function(e){function i(t){return U(U({},Hi.defaultData),Bc.defaultData(t))}e.defaultData=i})(i0||(i0={}));var o0;(function(t){t.defaultCamera=U({position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Fi.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new jt,events:new jt},xo.defaultData),t.defaultMeshObject=fe(U(U({name:"Rectangle"},Hi.defaultData),Sh.defaultData),{geometry:Vc.defaultData("RectangleGeometry"),material:Ss.defaultTwoLayerData("basic","layer1","layer2")})})(o0||(o0={}));var s0;(function(t){function i(r,n){if(n===void 0)return r;let s=U({},r);return"material"in s&&"material"in n&&n.material&&(s.material=oh(s.material,l=>{if(typeof l!="string")for(let[c,f]of Object.entries(n.material.layers)){let h=l.layers.data(c);h&&yo(h,f)}}).data),s.materials&&n.materials&&(s.materials=oh(s.materials,l=>{var c,f;for(let h=0;h<s.materials.length;h++){let d=n.materials[h];if(typeof d!="string")for(let[x,g]of Object.entries(d.layers)){let w=(f=(c=l[h])==null?void 0:c.layers)==null?void 0:f.data(x);w&&yo(w,g)}}}).data),s}t.patchMaterialState=i;function e(r,n){var l,c;if(n===void 0)return r;let s=U({},r);if(Object.assign(s,da.merge(s,n)),ps.is(r.type)){s.orthographic=U({},s.orthographic),s.perspective=U({},s.perspective);let f=n;((l=f.orthographic)==null?void 0:l.zoom)!==void 0&&(s.orthographic.zoom=f.orthographic.zoom),((c=f.perspective)==null?void 0:c.zoom)!==void 0&&(s.perspective.zoom=f.perspective.zoom)}else if(r.type==="Mesh")s.geometry=U({},s.geometry),Object.assign(s.geometry,n.geometry),s=i(s,n);else if(Dc.is(r.type)){let f=n;s.intensity!==void 0&&(s.intensity=f.intensity),f.color!==void 0&&(typeof f.color=="string"?s.color=f.color:s.color=Zr.clone(f.color))}return s}t.patch=e})(s0||(s0={}));var Yt=5855577;var a0=2857471;var wh=15711266;import{DoubleSide as IP,Mesh as MP,MeshBasicMaterial as AP,ShapeBufferGeometry as OP,Vector2 as PP,Vector3 as DP}from"three";import{FontLoader as BP}from"three/examples/jsm/loaders/FontLoader.js";var Ut=class extends MP{constructor({char:e,originalChar:t,fontFamily:r,letterSpacing:n,fontSize:s,LOD:l=16},c=new AP({color:0,opacity:1,visible:!0,transparent:!0,side:IP})){let f=Ut.loadChar(e,r,l);super(f.geometry,c);this.char=e,this.originalChar=t!=null?t:e,this.fontFamily=r,this.letterSpacing=n,this.fontSize=s,this.LOD=l,this.resolution=f.resolution,this.glyphsHa=f.glyphsHa,this.localPosition=new PP,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 Ut._fontPath}static set FONTS_PATH(e){Ut._fontPath=e}updatePosition(e,t){this.localPosition.copy(e);let r=new DP(this.localPosition.x,-this.localPosition.y,0);this.position.copy(r).add(t)}updateFontSize(e){let t=e/this.resolution;this.fontSize=e,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*t*this.letterSpacing}updateFontFamily(e){if(this.fontFamily===e)return;this.fontFamily=e;let t=Ut.loadChar(this.char,e,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.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 t=Ut.loadChar(e,this.fontFamily,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.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 t=Ut.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.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 Ut(e).copy(this)}static loadFont(e){return new Promise(function(t,r){Ut.fontCache[e]?t(Ut.fontCache[e]):new BP().load(Ut.FONTS_PATH+e+".json",s=>{Ut.fontCache[e]=s,t(s)},void 0,r)})}static loadChar(e,t,r){if(Ut.charCache[e]){if(Ut.charCache[e][r]&&Ut.charCache[e][r].fontFamily===t)return Ut.charCache[e][r]}else Ut.charCache[e]={};let n=Ut.fontCache[t],s=n.generateShapes(e,1);return Ut.charCache[e][r]={geometry:new OP(s,r),fontFamily:t,resolution:n.data.resolution,glyphsHa:n.data.glyphs[e].ha},Ut.charCache[e][r]}},Rr=Ut;Rr.charCache={},Rr.fontCache={},Rr._fontPath="/_assets/_fonts/";import{DoubleSide as ju,MeshBasicMaterial as Xv,Vector3 as Zv,Object3D as L3}from"three";import{Mesh as nD}from"three";import{BufferGeometry as lk,ConeBufferGeometry as EP,Float32BufferAttribute as ck,Vector2 as uk,Vector3 as fk}from"three";import{BufferGeometry as GP,CylinderBufferGeometry as jP,Float32BufferAttribute as Nh,Vector2 as Pn,Vector3 as kc}from"three";var l0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var l,c,f,h,d;let t=Object.assign({},(l=e==null?void 0:e.parameters)!=null?l:{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},i.parameters),r=t.width/2,n=(c=t.radiusTop)!=null?c:r,s=(f=t.radiusBottom)!=null?f:r;return n===s?(n=r,s=r):n>s?(n=r,s=s*r/n):(n=n*r/s,s=r),{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((h=t.height)!=null?h:t.width),depth:Math.abs((d=t.depth)!=null?d:t.width),radiusTop:n,radiusBottom:s})}}static build(i){let{width:e,depth:t,height:r,radialSegments:n,heightSegments:s,openEnded:l,thetaStart:c,thetaLength:f,radiusTop:h,radiusBottom:d,cornerRadius:x,cornerSegments:g,hollow:w}=i.parameters,S;return x||w?S=new Hc(h,d,r,n,s,l,c,f*Math.PI/180,x,x,g,w):S=new jP(h,d,r,n,s,l,c,f*Math.PI/180),S.scale(1,1,t/e),Object.assign(S,{userData:fe(U({},i),{type:"CylinderGeometry"})})}};function Wi(i,e,t){t.x=i.x*e.x,t.y=i.y,t.z=i.x*e.y}function c0(i){return new Pn(i.y,-i.x)}var Hc=class extends GP{constructor(e,t,r,n,s,l,c,f,h,d,x,g,w=!1){super();this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,r=r||1,n=Math.floor(n)||8,s=Math.floor(s)||1,l=l!==void 0?l:!1,c=c!==void 0?c:0,f=f!==void 0?f:Math.PI*2,l&&(h=0,d=0);let S=[],D=[],C=[],G=[],B=0,P=r/2,W=new kc,M=new kc;w&&e==0&&(e=h),w&&t==0&&(t=d);let q=new Pn(e,P),E=new Pn(t,-P),b=null,R=null,T=null,z=null,A=q.clone().sub(E),$=0,he=0,re=0;g>0&&($=Math.min(e,t)*(1-g),he=e-$,re=t-$);let Ne=q.clone();Ne.x-=$;let ye=Math.PI-A.angle(),Me=A.angle(),Fe=Math.tan(Me/2),k=Math.tan(ye/2),H=Fe+k,_=g?H:k,J=g?H:Fe;if(h=Math.min(h,(e-he)/_,A.length()/H),d=Math.min(d,(t-re)/J,A.length()/H),h>0){let K=h/Fe;b=q.clone().sub(new Pn(K,h)),g&&(T=b.clone(),T.x-=$-H*h),q.sub(A.clone().setLength(K))}if(d>0){let K=d/k;R=E.clone().sub(new Pn(K,-d)),E.add(A.clone().setLength(K)),g&&(z=R.clone(),z.x-=$-H*d,Ne.sub(A.clone().setLength(K)))}A=q.clone().sub(E);let ee=A.length()<.5,oe=[];for(let K=0;K<=n;K++){let ae=[],ne=K/n,Ce=ne*f+c,Y=new Pn(Math.sin(Ce),Math.cos(Ce));z&&R?(se(ae,ne,Y,ye,d,z,-1,!0),se(ae,ne,Y,Me,d,R,-1,!1)):R?(ce(ae,Y,R.x,0,-1),se(ae,ne,Y,Me,d,R,-1,!1)):l||ce(ae,Y,t,re,-1);let le=c0(A).normalize();if(Wi(le,Y,W),!ee)for(let pe=0;pe<=s;pe++){let xe=pe/s,_e=A.clone().multiplyScalar(xe).add(E);Wi(_e,Y,M),D.push(M.x,M.y,M.z),C.push(W.x,W.y,W.z),G.push(ne,.5+M.y/r),ae.push(B++)}if(T&&b?(se(ae,ne,Y,ye,h,b,1,!1),se(ae,ne,Y,Me,h,T,1,!0)):b?(se(ae,ne,Y,ye,h,b,1,!1),ce(ae,Y,b.x,0,1)):l||ce(ae,Y,e,he,1),g&&!ee){let pe=c0(A).multiplyScalar(-1).normalize();Wi(pe,Y,W);for(let xe=0;xe<=s;xe++){let _e=xe/s,de=A.clone().multiplyScalar(-_e).add(Ne);Wi(de,Y,M),D.push(M.x,M.y,M.z),C.push(W.x,W.y,W.z),G.push(ne,.5+M.y/r),ae.push(B++)}}g&&!l&&ae.push(ae[0]),oe.push(ae)}for(let K=0;K<oe.length-1;K++)for(let ae=0;ae<oe[0].length-1;ae++){if(l&&g&&ae==s)continue;let ne=oe[K][ae],Ce=oe[K+1][ae],Y=oe[K+1][ae+1],le=oe[K][ae+1],pe=D[Y*3+0],xe=D[Y*3+2];S.push(ne,Ce,le),(pe!=0||xe!=0)&&S.push(Ce,Y,le)}f<Math.PI*2&&(ue(-1,oe[0],c),ue(1,oe[oe.length-1],c+f)),this.setIndex(S),this.setAttribute("position",new Nh(D,3)),this.setAttribute("normal",new Nh(C,3)),this.setAttribute("uv",new Nh(G,2));function se(K,ae,ne,Ce,Y,le,pe,xe){for(let _e=0;_e<x+1;_e++){let de=_e/x,we=pe<0?de:1-de;xe&&(we-=1),we*=Ce;let Ve=new Pn(Math.sin(we),Math.cos(we)*pe),Ge=Ve.clone().multiplyScalar(Y).add(le);Wi(Ge,ne,M),D.push(M.x,M.y,M.z),Wi(Ve,ne,W),C.push(W.x,W.y,W.z),G.push(ae,.5+M.y/r),K.push(B++)}}function ce(K,ae,ne,Ce,Y){let le=new kc,pe=new Pn,xe=[ne,Ce];Y<0&&xe.reverse();for(let _e of xe)pe.set(_e,P*Y),Wi(pe,ae,le),D.push(le.x,le.y,le.z),C.push(0,Y,0),G.push(.5,.5),K.push(B++)}function ue(K,ae,ne){let Ce=new Pn(Math.sin(ne),Math.cos(ne)),Y=new Pn(-Math.cos(ne),Math.sin(ne)),le=new kc,pe=K<0?(de,we,Ve)=>S.push(de,we,Ve):(de,we,Ve)=>S.push(de,Ve,we),xe=new Pn((e+t+he+re)/4,0);Wi(xe,Ce,le),D.push(le.x,le.y,le.z),C.push(Y.x,0,Y.y),G.push(.5,.5);let _e=B++;for(let de of ae){let we=D.slice(de*3,de*3+3);D.push(...we),C.push(Y.x,0,Y.y);let Ve=G.slice(de*2,de*2+2);G.push(...Ve),B++}for(let de=_e+1;de<B-1;de++)pe(_e,de,de+1);pe(_e,B-1,_e+1)}}};var u0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.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(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,depth:t,height:r,radialSegments:n,heightSegments:s,openEnded:l,thetaStart:c,thetaLength:f,cornerRadiusTop:h,cornerRadiusBottom:d,cornerSegments:x}=i.parameters,g;return h>0||d>0||f<360?g=new Hc(0,e/2,r,n,s,l,c,f*Math.PI/180,h,d,x,0,!0):g=new EP(e/2,r,n,s,l),g.scale(1,1,t/e),Object.assign(g,{userData:fe(U({},i),{type:"ConeGeometry"})})}};import{BoxBufferGeometry as RP,BufferGeometry as zP,Float32BufferAttribute as Ch,Vector3 as ma}from"three";var f0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,height:t,depth:r,widthSegments:n,heightSegments:s,depthSegments:l,cornerRadius:c,cornerSegments:f}=i.parameters,h;return c==0?h=new RP(e,t,r,n,s,l):h=new h0(e,t,r,n,s,l,c,f),Object.assign(h,{userData:fe(U({},i),{type:"CubeGeometry"})})}},Lh=Math.PI/2,h0=class extends zP{constructor(e=1,t=1,r=1,n=1,s=1,l=1,c=0,f=4){super();this.type="BoxBufferGeometry";let h=this;n=Math.floor(n),s=Math.floor(s),l=Math.floor(l),f=Math.floor(f),c=Math.min(c,e/2,t/2,r/2);let d=[],x=[],g=[],w=[],S=0,D=0;C("z","y","x",-1,-1,r,t,e,l,s,0),C("z","y","x",1,-1,r,t,-e,l,s,1),C("x","z","y",1,1,e,r,t,n,l,2),C("x","z","y",1,-1,e,r,-t,n,l,3),C("x","y","z",1,-1,e,t,r,n,s,4),C("x","y","z",-1,-1,e,t,-r,n,s,5),c>0&&(G("z","y","x",-1,-1,1,r,t,e,l,0),G("z","y","x",1,-1,-1,r,t,e,l,1),G("z","y","x",-1,1,-1,r,t,e,l,1),G("z","y","x",1,1,1,r,t,e,l,0),G("x","y","z",-1,-1,-1,e,t,r,n,0),G("x","y","z",1,-1,1,e,t,r,n,1),G("x","y","z",-1,1,1,e,t,r,n,0),G("x","y","z",1,1,-1,e,t,r,n,1),G("y","x","z",-1,-1,1,t,e,r,s,0),G("y","x","z",1,-1,-1,t,e,r,s,1),G("y","x","z",1,1,1,t,e,r,s,1),G("y","x","z",-1,1,-1,t,e,r,s,0),B(1,1,1),B(-1,1,1),B(1,-1,1),B(-1,-1,1),B(1,1,-1),B(-1,1,-1),B(1,-1,-1),B(-1,-1,-1)),this.setIndex(d),this.setAttribute("position",new Ch(x,3)),this.setAttribute("normal",new Ch(g,3)),this.setAttribute("uv",new Ch(w,2));function C(P,W,M,q,E,b,R,T,z,A,$){let he=(b-2*c)/z,re=(R-2*c)/A,Ne=b/2-c,ye=R/2-c,Me=T/2,Fe=z+1,k=A+1,H=0,_=0,J=new ma;for(let ee=0;ee<k;ee++){let oe=ee*re-ye;for(let se=0;se<Fe;se++){let ce=se*he-Ne;J[P]=ce*q,J[W]=oe*E,J[M]=Me,x.push(J.x,J.y,J.z),J[P]=0,J[W]=0,J[M]=T>0?1:-1,g.push(J.x,J.y,J.z),w.push(se/z),w.push(1-ee/A),H+=1}}for(let ee=0;ee<A;ee++)for(let oe=0;oe<z;oe++){let se=S+oe+Fe*ee,ce=S+oe+Fe*(ee+1),ue=S+(oe+1)+Fe*(ee+1),K=S+(oe+1)+Fe*ee;d.push(se,ce,K),d.push(ce,ue,K),_+=6}h.addGroup(D,_,$),D+=_,S+=H}function G(P,W,M,q,E,b,R,T,z,A,$){let he=(R-2*c)/A,re=R/2-c,Ne=T/2-c,ye=z/2,Me=A+1,Fe=0,k=0,H=new ma,_=new ma;for(let J=0;J<f+1;J++){let ee=J/f*Lh,oe=Math.sin(ee)*c,se=(1-Math.cos(ee))*c,ce=Math.sin(ee),ue=Math.cos(ee);H[W]=(Ne+oe)*E,H[M]=(ye-se)*b,_[P]=0,_[W]=ce*Math.sign(H[W]),_[M]=ue*Math.sign(H[M]);for(let K=0;K<Me;K++){let ae=K*he-re;H[P]=ae*q,x.push(H.x,H.y,H.z),g.push(_.x,_.y,_.z),w.push(K/A),w.push(0),Fe+=1}}for(let J=0;J<f;J++)for(let ee=0;ee<A;ee++){let oe=S+ee+Me*J,se=S+ee+Me*(J+1),ce=S+(ee+1)+Me*(J+1),ue=S+(ee+1)+Me*J;d.push(oe,se,ue),d.push(se,ce,ue),k+=6}h.addGroup(D,k,$),D+=k,S+=Fe}function B(P,W,M){let q=new ma,E=new ma(e/2,t/2,r/2);E.subScalar(c);let b=[],R=P*W*M>0?(z,A,$)=>d.push(z,A,$):(z,A,$)=>d.push(z,$,A);for(let z=0;z<=f;z++){let A=[],$=Lh*(1-z/f),he=Math.cos($),re=Math.sin($),Ne=0;for(let ye=0;ye<=z;ye++){let Me=Math.cos(Ne),Fe=Math.sin(Ne);q.x=he*Me,q.y=re,q.z=he*Fe;let k=E.clone().addScaledVector(q,c);x.push(P*k.x,W*k.y,M*k.z),g.push(P*q.x,W*q.y,M*q.z),w.push(0,0),A.push(S++),Ne+=Lh/z}b.push(A)}let T=b.length-1;for(let z=0;z<T;z++){let A=b[z],$=b[z+1],he=A.length-1;R(A[0],$[1],$[0]);for(let re=1;re<=he;re++)R(A[re-1],A[re],$[re]),R(A[re],$[re+1],$[re])}}}};import{BufferGeometry as FP,Float32BufferAttribute as _h,Triangle as VP,Vector3 as yi,Vector2 as Th}from"three";var So=class extends FP{constructor(e=[],t=[],r="",n=1,s=.2,l=4){super();this.type="PolyhedronGeometryRound";let c=[],f=[],h=[];d(),x(),this.setAttribute("position",new _h(c,3)),this.setAttribute("normal",new _h(h,3)),this.setAttribute("uv",new _h(f,2));return;function d(){var Fe;s=Math.min(1-1e-5,s),s==0&&(l=0);let w={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],S=new yi,D=S.clone(),C=new VP,G=s*n,B=n-G,P=l+1,W=new yi,M=(k,H)=>W.subVectors(k,H).normalize(),q=(k,H)=>Array(k).fill(void 0).map(H),E=q(e.length/3,(k,H)=>new yi().fromArray(e,H*3).setLength(n)),b=[],R=1e6;for(let k=0;k<E.length;k++){let H=E[k],_=[],J,ee,oe,se=1e10,ce=-1;for(;(ce=t.indexOf(k,ce+1))!=-1;){let ne=ce-ce%3;J=t[ne+(ce+1)%3],ee=t[ne+(ce+2)%3],oe=H.distanceToSquared(E[J]),se=Math.min(se,oe),_.push([J,ee,oe])}se+=1e-6;let ue=[],K=0,ae=_.length;for(let ne=0;ne<ae;ne++){[J,ee,oe]=_[K];let Ce=((Fe=b[J])==null?void 0:Fe.includes(k))==!0;oe<=se&&ue.push(J+ +Ce*R),K=_.findIndex(Y=>Y[0]==ee)}b.push(ue)}let T=[];{let k=0,H=0,_,J,ee=w==3;for(let oe=0;oe<=l;oe++){_=oe*(oe+1)/2,J=(oe+1)*(oe+2)/2;for(let se=0;se<l-oe;se++)[k,H]=[_+se+oe+2,J+se+oe+3],T.push(_,J,...ee?[H,_]:[k,J],H,k),[_,J]=[k,H];T.push(_,J,_+l+2)}}let z=S.clone(),A=S.clone(),$=S.clone(),he=S.clone(),re=S.clone(),Ne=[],ye=q(E.length,()=>q(w,()=>S.clone()));for(let k=0;k<E.length;k++){S.copy(E[k]).normalize(),z.copy(S).multiplyScalar(B);let H=b[k];for(let ue=0;ue<H.length;ue++){let K=H[ue],ae=H[(ue+1)%w];C.setFromPointsAndIndices(E,k,K%R,ae%R),C.b.sub(C.a).setLength(1e10).add(C.a),C.c.sub(C.a).setLength(1e10).add(C.a),C.closestPointToPoint(z,ye[k][ue])}let _=[],J=[],ee=[],oe=new yi;l==0&&[...ye[k]].reduce((ue,K)=>ue.add(K),oe).multiplyScalar(1/w);for(let ue=0;ue<w;ue++){let K=[],ae=(ue-1+w)%w,ne=ye[k][ae],Ce=ye[k][ue];S.copy(ne).sub(z),D.copy(Ce).sub(z);let Y=z.angleTo(S),le=S.angleTo(D),pe=Math.cos(Y)*G;l==0?A.copy(oe):A.copy(z).setLength(B+pe),J.push(pe);let xe=[A,ne,Ce];for(let _e=0;_e<2;_e++){let de=xe[_e],we=xe[_e+1];he.subVectors(de,z),re.subVectors(we,z),$.crossVectors(he,re).normalize();for(let Ve=0;Ve<P;Ve++){let Ge=[Y,le][_e]*Ve/P;S.copy(he).applyAxisAngle($,Ge).add(z),_.push(S.clone()),_e&&(M(S,z),K.push([Ve==0?de:S.clone(),W.clone()]))}_e&&(M(we,z),K.push([we,W.clone()]))}ee.push(K)}Ne.push(ee);let se=2*P,ce=2;for(let ue=0;ue<w;ue++){let K=se*ue,ae=se*((ue+1)%w),ne=[_[K]];for(let Y=1;Y<P;Y++){he=_[K+Y],re=_[ae+Y],ne.push(he);for(let le=1,pe=Y-ce+1;le<=pe;le++)S.lerpVectors(he,re,le/(pe+1)),S.sub(z).setLength(J[ue]).add(z),ne.push(S.clone());ne.push(re)}for(let Y=0;Y<P;Y++)ne.push(_[Y+P+K]);ne.push(_[ae+P]);let Ce=T.map(Y=>ne[Y]);c.push(...Ce.map(Y=>[Y.x,Y.y,Y.z]).flat()),h.push(...Ce.map(Y=>(M(Y,z),[W.x,W.y,W.z])).flat())}}let Me=[];for(let k=0;k<b.length;k++)for(let H=0;H<w;H++){let _=b[k][H];if(_<R){let J=b[_].findIndex(se=>se%R==k),ee=Ne[k][H],oe=Ne[_][J];for(let se=0;se<P;se++){let ce=ee[se],ue=oe[P-se],K=ee[se+1],ae=oe[P-(se+1)];[ce,ue,K,K,ue,ae].forEach(ne=>{c.push(ne[0].x,ne[0].y,ne[0].z),h.push(ne[1].x,ne[1].y,ne[1].z)})}Me.push(ee[0][0],oe[P][0],ee[P][0],oe[0][0])}}for(;Me.length;){let k,H,_,J;[k,H]=Me.splice(0,2);let ee=[k];for(;k!=H;)ee.push(H),_=Me.indexOf(H),J=_%2,H=Me.splice(_-J,2)[1-J];W.subVectors(ee[0],ee[1]).cross(S.subVectors(ee[0],ee[2])).normalize();let oe=W.dot(ee[0])<0;oe&&W.negate();for(let se=1;se<=ee.length-2;se++)[ee[se+ +oe],ee[se+1-+oe],ee[0]].forEach(ce=>{c.push(ce.x,ce.y,ce.z),h.push(W.x,W.y,W.z)})}}function x(){let g=new yi;for(let E=0;E<c.length;E+=3){g.x=c[E+0],g.y=c[E+1],g.z=c[E+2];let b=M(g)/2/Math.PI+.5,R=q(g)/Math.PI+.5;f.push(b,1-R)}let w=new yi,S=new yi,D=new yi,C=new yi,G=new Th,B=new Th,P=new Th,W=(E,b,R,T)=>{T<0&&E.x===1&&(f[b]=E.x-1),R.x===0&&R.z===0&&(f[b]=T/2/Math.PI+.5)};for(let E=0,b=0;E<c.length;E+=9,b+=6){w.set(c[E+0],c[E+1],c[E+2]),S.set(c[E+3],c[E+4],c[E+5]),D.set(c[E+6],c[E+7],c[E+8]),G.set(f[b+0],f[b+1]),B.set(f[b+2],f[b+3]),P.set(f[b+4],f[b+5]),C.copy(w).add(S).add(D).divideScalar(3);let R=M(C);W(G,b+0,w,R),W(B,b+2,S,R),W(P,b+4,D,R)}for(let E=0;E<f.length;E+=6){let b=f[E+0],R=f[E+2],T=f[E+4],z=Math.max(b,R,T),A=Math.min(b,R,T);z>.9&&A<.1&&(b<.2&&(f[E+0]+=1),R<.2&&(f[E+2]+=1),T<.2&&(f[E+4]+=1))}function M(E){return Math.atan2(E.z,-E.x)}function q(E){return Math.atan2(-E.y,Math.sqrt(E.x*E.x+E.z*E.z))}}}static fromJSON(e){return new So(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};import{DodecahedronBufferGeometry as UP}from"three";var p0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,height:t,depth:r,detail:n,corner:s,cornerSides:l}=i.parameters,c=n===0&&s!==0?new Wc(e*.5,s,l):new UP(e*.5,n);return c.scale(1,t/e,r/e),Object.assign(c,{userData:fe(U({},i),{type:"DodecahedronGeometry"})})}},Wc=class extends So{constructor(e=1,t=.2,r=4){let n=(1+Math.sqrt(5))/2,s=1/n,l=[-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,-s,-n,0,-s,n,0,s,-n,0,s,n,-s,-n,0,-s,n,0,s,-n,0,s,n,0,-n,0,-s,n,0,-s,-n,0,s,n,0,s],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(l,c,f,e,t,r);this.type=f}static fromJSON(e){return new Wc(e.radius,e.corner,e.cornerSides)}};import{EventDispatcher as QP,Plane as e2,Shape as L0,Vector2 as xi,Vector3 as t2,MathUtils as Bh,LineCurve as Gh,QuadraticBezierCurve as _0,CubicBezierCurve as Jc}from"three";import{CubicBezierCurve as qc,EllipseCurve as kP,LineCurve as $c,LineCurve3 as HP,MathUtils as WP,QuadraticBezierCurve as Ih,SplineCurve as qP,Vector2 as Dn,Vector3 as d0}from"three";var ga=1e-12,ya=class{constructor(e){this.position=new Dn;this.startPosition=new Dn;this.uuid=WP.generateUUID();this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new ya(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},xa=class extends ya{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new xa(this.parent).copy(this)}},Kn=class extends ya{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new xa(this),new xa(this))}static create(e,t){let r=new Kn(e,new Dn(...t.position));return r.controls[0].position.set(...t.controlPrevious.position),r.controls[1].position.set(...t.controlNext.position),r.roundness=t.roundness,r.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,r}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let r=0,n=this.controls.length;r<n;r++){let s=this.controls[r];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.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 Kn(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}},Mh=i=>i,va=new Dn,Ah=new Dn,$P=new Dn,JP=new Dn,KP=new Dn,XP=new Dn,m0=new d0,g0=new d0;function y0(i){let e=new Dn;e.addVectors(i.v0,va.subVectors(i.v1,i.v0).multiplyScalar(2/3));let t=new Dn;return t.addVectors(i.v2,Ah.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new qc(i.v0,e,t,i.v2)}function ba(i,e,t=Number.EPSILON){return Math.abs(i-e)<t}function ZP(i,e,t=Number.EPSILON){return i.distanceTo(e)<t}function YP(i,e,t=Number.EPSILON){return i.distanceTo(e)<t}function Oh(i,e,t){let r=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2));return Math.acos((n*n+r*r-s*s)/(2*n*r))}function x0(i,e,t,r,n){let s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),l=(i.y+e.y)/2,c=(i.x+e.x)/2,f=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(i.y-e.y)/s,h=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(e.x-i.x)/s;return r.set(c+f,l+h),n.set(c-f,l-h),[r,n]}function v0(i,e,t){let r=i.distanceTo(t),n=e.distanceTo(t);return r<n?e:i}function b0(i,e,t,r,n,s){let l=e.x-i.x,c=e.y-i.y,f=t.x-i.x,h=t.y-i.y,d=Math.sqrt((l+f)*(l+f)+(c+h)*(c+h)),x;return Oh(e,i,t)>Math.PI&&(d*=-1),ba(h,c)?x=(c+h)*(r/d-.5)*8/3/(l-f):x=(l+f)*(r/d-.5)*8/3/(h-c),n.set(e.x-x*c,e.y+x*l),s.set(t.x+x*h,t.y-x*f),[n,s]}function Ph(i,e){return i.position.equals(i.controls[1].position)&&e.position.equals(e.controls[0].position)}function S0(i,e,t,r,n=.5){let s=va.subVectors(e,i).multiplyScalar(n).add(i),l=Ah.subVectors(t,e).multiplyScalar(n).add(e),c=$P.subVectors(r,t).multiplyScalar(n).add(t),f=s,h=JP.subVectors(l,s).multiplyScalar(n).add(s),d=KP.subVectors(c,l).multiplyScalar(n).add(l),x=c,g=XP.subVectors(d,h).multiplyScalar(n).add(h);return[i.x,i.y,f.x,f.y,h.x,h.y,g.x,g.y,d.x,d.y,x.x,x.y,r.x,r.y]}function w0(i,e,t=12,r=!0){let n=g0.set(0,0,0),s,l=0,c=[];for(let f=0;f<e.length;f++){let h=Mh(e[f]),d=va,x=qi(h,t);c.push(x);for(let g=0;g<=x;g++)if(h instanceof qc||h instanceof Ih||h instanceof $c){if(h.getPoint(g/x,d),n.set(d.x,d.y,0),s!==void 0&&YP(s,n))continue;s===void 0&&(s=m0),s.copy(n),i.setXYZ(l,n.x,n.y,n.z),l++}}return r&&l>1&&!(i.getX(l-1)===i.getX(0)&&i.getY(l-1)===i.getY(0)&&i.getZ(l-1)===i.getZ(0))&&(i.setXYZ(l,i.getX(0),i.getY(0),i.getZ(0)),l++),i}function N0(i,e,t,r=12,n=!0){let s=g0.set(0,0,0),l=0,c=[];for(let f=0;f<e.length;f++){if(t[f]===!1)continue;let h,d=Mh(e[f]),x=va,g=qi(d,r);c.push(g);for(let w=0;w<=g;w++)if(d instanceof qc||d instanceof Ih||d instanceof $c){if(d.getPoint(w/g,x),s.set(x.x,x.y,0),h==null?void 0:h.equals(s))continue;h===void 0?h=m0:(i.setXYZ(l,h.x,h.y,h.z),l++,i.setXYZ(l,s.x,s.y,s.z),l++),h.copy(s)}}return n&&l>1&&!(i.getX(l-1)===i.getX(0)&&i.getY(l-1)===i.getY(0)&&i.getZ(l-1)===i.getZ(0))&&(i.setXYZ(l,i.getX(0),i.getY(0),i.getZ(0)),l++),c}function Dh(i,e=12,t=!1){let r=[];for(let n=0,s=i.length;n<s;n++){let l=i[n],c=0;if(t&&l.roundedCurveCorner!==void 0){let f=qi(l.roundedCurveCorner,e)*.5;n>0&&(r[n-1]+=f),c+=f}l.curveAfter!==void 0&&(c+=qi(l.curveAfter,e)),r.push(c)}return i.length>0&&t&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=qi(i[0].roundedCurveCorner,e)*.5),r}function qi(i,e=12){return i&&i instanceof kP?e*2:i&&(i instanceof $c||i instanceof HP)?1:i&&i instanceof qP?e*i.points.length:e}function C0(i,e,t=12,r=!0){let n,s=0;for(let l=0;l<e.length;l++){let c=Mh(e[l]),f=qi(c,t),h=va;for(let d=0;d<=f;d++)if(c instanceof qc||c instanceof Ih||c instanceof $c){if(c.getPoint(d/f,h),n!==void 0&&ZP(n,h,ga))continue;n===void 0&&(n=Ah),n.copy(h),i.push(h.x,h.y),s++}}return ba(i[0],i[i.length-2],ga)&&ba(i[1],i[i.length-1],ga)&&(i.pop(),i.pop()),r&&s>1&&!(ba(i[s-1],i[1],ga)&&ba(i[s-2],i[0],ga))&&(i.push(i[0],i[1]),s++),i}var jh=new xi,r2=new xi,n2=new xi,i2=new xi,o2=new xi,s2=new xi,st=class extends L0{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new QP;this.plane=new e2(new t2(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=Bh.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,r){let n=new st;return n.isClosed=e.isClosed,n.points=e.points.map(s=>Kn.create(s.id,s.data)),typeof e.roundness=="number"&&(n.roundness=e.roundness),n.shapeHoles=e.shapeHoles.map(s=>st.createFromState(s)),t!==void 0&&r!==void 0&&n.applySize(t,r),n.update(),n}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 t=0,r=this.points.length;t<r;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){return this.points.findIndex(t=>t.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 t=0,r=this.shapeHoles.length;t<r;t++){let n=this.shapeHoles[t],s=e-this.points.length;if(s<=n.points.length-1)return n.points[s]}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let r=0,n=this.shapeHoles.length;r<n;r++){let s=this.shapeHoles[r],l=s.points.indexOf(e);if(l>=0)return t+l;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let r=jh.set(e,t);for(let n=0,s=this.points.length;n<s;n++){let l=this.points[n];l.position.multiply(r),l.controls[0].position.multiply(r),l.controls[1].position.multiply(r)}for(let n=0,s=this.shapeHoles.length;n<s;n++)this.shapeHoles[n].applyScale(e,t);this._update(!1)}createPoint(e,t=0,r=Bh.generateUUID()){let n;e instanceof xi?n=e:n=new xi(e,t);let s=new Kn(r,n);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,r=this.points.length;t<r;t++){let n=this.points[t];if(n.uuid===e)return n}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(r=>r.uuid===e);t&&this.removePoint(t)}update(e=!0){for(let t=0,r=this.shapeHoles.length;t<r;t++)this.shapeHoles[t].update(!1);this._update(e)}extractShapePointsToBuffer(e,t=12,r=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let n=r?this.roundedCurveDivisions:this.curveDivisions;return w0(e,r?this.roundedCurves:this.curves,t,this.autoClose),n.reduce((s,l)=>s+l,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Dh(this.points,e,!1),this.roundedCurveDivisions=Dh(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,r=12){return N0(e,this.curves,t,r,this.autoClose).reduce((s,l)=>s+l,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),C0(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let r=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let n=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=qi(this.points[0].roundedCurveCorner,this.subdivision)*.5);let l=e-s;l<0&&(l+=n.reduce((c,f)=>c+f,0));for(let c=0,f=n.length;c<f;c++){let h=n[c];if(l<r+h)return[c,(l-r+1)/h];r+=h}return[0,1]}getCurveT(e,t,r){let n=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],l=this.curveDivisions,c=l[e];if(Ph(n,s)){let d=n.position.distanceTo(s.position);return n.position.distanceTo(jh.set(r.x,r.y))/d}let f=0;for(let d=0;d<e;d++)f+=l[d];return(t-f)/c}dispose(){this.eventDispatcher=null}_applyCurveForPoint(e,t){Ph(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let r=this.curves[this.curves.length-1];e.curveBefore=r,t.curveAfter=r;let n=r.clone();e.roundedCurveBefore=n,t.roundedCurveAfter=n,e.roundedCurveCorner=void 0,this.roundedCurves.push(n)}_update(e=!0){var r;if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let n=0,s=this.points.length;n<s;n++){let l=this.points[n];if(n===0)this.moveTo(l.position.x,l.position.y);else{let c=this.points[n-1];this._applyCurveForPoint(l,c)}}let t=this.getLastPoint();if((t==null?void 0:t.curveAfter)&&(t.curveAfter=void 0),this.isClosed){let n=this.points[0],s=this.points[this.points.length-1];this._applyCurveForPoint(n,s)}if(this.points.length>2){let n=0;for(let s=0,l=this.points.length;s<l;s++){let c=this.points[s],f=c.roundness;if(!c.controlsMoved()&&f>0){let h=c.curveBefore,d=c.curveAfter;if(h===void 0||d===void 0)continue;let x=c.roundedCurveBefore,g=c.roundedCurveAfter,w=h.getLength(),S=d.getLength(),D=Math.min(f,w*.499),C=Math.min(f,S*.499),G=Math.min(D,C),B=1-G/w,P=G/S,W=h.getPointAt(B,jh),M=d.getPointAt(P,r2);this._subSplitCurve(h,x,B,W,void 0),this._subSplitCurve(d,g,P,void 0,M);let q;if(this.useCubicForRoundedCorners){let E=Oh(W,c.position,M)/2,b=Math.tan(E)*W.distanceTo(c.position),[R,T]=x0(W,M,b,n2,i2),z=v0(R,T,c.position),[A,$]=b0(z,W,M,b,o2,s2);q=new Jc(W.clone(),A.clone(),$.clone(),M.clone())}else q=new _0(W.clone(),c.position.clone(),M.clone());c.roundedCurveCorner=q,this.roundedCurves.splice(s+n,0,q),n++}}}e&&((r=this.eventDispatcher)==null||r.dispatchEvent({type:"update"}))}_subSplitCurve(e,t,r,n,s){if(e instanceof Gh)n!==void 0&&t.v2.copy(n),s!==void 0&&t.v1.copy(s);else{let l=e,c=t,f=l.getUtoTmapping(r,0),h=S0(l.v0,l.v1,l.v2,l.v3,f);return n!==void 0&&(c.v0.set(h[0],h[1]),c.v1.set(h[2],h[3]),c.v2.set(h[4],h[5]),c.v3.set(h[6],h[7])),s!==void 0&&(c.v0.set(h[6],h[7]),c.v1.set(h[8],h[9]),c.v2.set(h[10],h[11]),c.v3.set(h[12],h[13])),c}return t}clone(){let e=new st(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){var r;this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let n=0;n<t;n++){let s=n*7,l=e.points[s+0],c=e.points[s+1],f=e.points[s+2],h=e.points[s+3],d=e.points[s+4],x=e.points[s+5],g=e.points[s+6],w=new Kn(Bh.generateUUID(),new xi(l,c));w.controls[0].position.set(f,h),w.controls[1].position.set(d,x),w.roundness=g,this.points.push(w)}return this.shapeHoles=((r=e.shapeHoles)==null?void 0:r.length)?e.shapeHoles.map(n=>{let s=new st;return s.fromJSON(n),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(n,s)=>{s instanceof Jc&&s.v3.equals(n.position)&&n.controls[0].position.copy(s.v2)},r=n=>{let s=[],l,c;for(l=0,c=n.length;l<c;l++)n[l]instanceof _0&&(n[l]=y0(n[l]));for(l=0,c=n.length;l<c;l++){let d=n[l],x=l>0?n[l-1]:null,g;d instanceof Jc?(g=this.createPoint(d.v0),g.controls[1].position.copy(d.v1)):d instanceof Gh&&(g=this.createPoint(d.v1)),g!==void 0&&(x!==null&&t(g,x),s.push(g))}let f=n[n.length-1],h=!1;return f instanceof Jc?f.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(f.v2),h=!0):f instanceof Gh&&f.v2.equals(s[0].position)&&(h=!0),this.isClosed=h,s};return this.points=r(e.curves),e instanceof L0&&(this.shapeHoles=e.holes.map(n=>{let s=new st;return s.fromShape(n),s})),this.update(),this}};var Eh=Math.PI*2;function Rh({x:i,y:e},t,r,n,s){return{x:i*t+n,y:e*r+s}}function a2(i,e){let t=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:4/3*Math.tan(e/4),r=Math.cos(i),n=Math.sin(i),s=Math.cos(i+e),l=Math.sin(i+e);return[{x:r-n*t,y:n+r*t},{x:s+l*t,y:l-s*t},{x:s,y:l}]}function T0(i,e,t,r){let n=i*r-e*t<0?-1:1,s=Math.min(1,Math.max(-1,i*t+e*r));return n*Math.acos(s)}function l2(i,e,t,r,n,s,l,c,f,h){let d=Math.pow(n,2),x=Math.pow(s,2),g=Math.pow(l,2),w=Math.pow(c,2),S=d*x-d*w-x*g;S<0&&(S=0),S/=d*w+x*g,S=Math.sqrt(S)*(f===h?-1:1);let D=S*n/s*c,C=S*-s/n*l,G=D+(i+t)/2,B=C+(e+r)/2,P=(l-D)/n,W=(c-C)/s,M=(-l-D)/n,q=(-c-C)/s,E=T0(1,0,P,W),b=T0(P,W,M,q);return!h&&b>0&&(b-=Eh),h&&b<0&&(b+=Eh),{centerx:G,centery:B,ang1:E,ang2:b}}function I0({px:i,py:e,cx:t,cy:r,rx:n,ry:s,largeArcFlag:l,sweepFlag:c}){let f=[];if(n===0||s===0)return[];let h=(i-t)/2,d=(e-r)/2;if(h===0&&d===0)return[];n=Math.abs(n),s=Math.abs(s);let x=Math.pow(h,2)/Math.pow(n,2)+Math.pow(d,2)/Math.pow(s,2);x>1&&(n*=Math.sqrt(x),s*=Math.sqrt(x));let g=l2(i,e,t,r,n,s,h,d,l,c),{ang1:w,ang2:S}=g,{centerx:D,centery:C}=g,G=Math.abs(S)/(Eh/4);Math.abs(1-G)<1e-7&&(G=1);let B=Math.max(Math.ceil(G),1);S/=B;for(let P=0;P<B;P++)f.push(a2(w,S)),w+=S;return f.map(P=>{let{x:W,y:M}=Rh(P[0],n,s,D,C),{x:q,y:E}=Rh(P[1],n,s,D,C),{x:b,y:R}=Rh(P[2],n,s,D,C);return{x1:W,y1:M,x2:q,y2:E,x:b,y:R}})}import{BufferAttribute as Xc,BufferGeometry as p2}from"three";var Pt;(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"})(Pt||(Pt={}));var Qt;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Qt||(Qt={}));function Ae(i,e){if(!i)throw e||"Assertion Failed!"}var Te=function(){function i(){}return i.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},i.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},i.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},i.edgeGoesLeft=function(e){return i.vertLeq(e.Dst,e.Org)},i.edgeGoesRight=function(e){return i.vertLeq(e.Org,e.Dst)},i.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},i.edgeEval=function(e,t,r){Ae(i.vertLeq(e,t)&&i.vertLeq(t,r));var n=t.s-e.s,s=r.s-t.s;return n+s>0?n<s?t.t-e.t+(e.t-r.t)*(n/(n+s)):t.t-r.t+(r.t-e.t)*(s/(n+s)):0},i.edgeSign=function(e,t,r){Ae(i.vertLeq(e,t)&&i.vertLeq(t,r));var n=t.s-e.s,s=r.s-t.s;return n+s>0?(t.t-r.t)*n+(t.t-e.t)*s:0},i.transEval=function(e,t,r){Ae(i.transLeq(e,t)&&i.transLeq(t,r));var n=t.t-e.t,s=r.t-t.t;return n+s>0?n<s?t.s-e.s+(e.s-r.s)*(n/(n+s)):t.s-r.s+(r.s-e.s)*(s/(n+s)):0},i.transSign=function(e,t,r){Ae(i.transLeq(e,t)&&i.transLeq(t,r));var n=t.t-e.t,s=r.t-t.t;return n+s>0?(t.s-r.s)*n+(t.s-e.s)*s:0},i.vertCCW=function(e,t,r){return e.s*(t.t-r.t)+t.s*(r.t-e.t)+r.s*(e.t-t.t)>=0},i.interpolate=function(e,t,r,n){return e=e<0?0:e,r=r<0?0:r,e<=r?r===0?(t+n)/2:t+(n-t)*(e/(e+r)):n+(t-n)*(r/(e+r))},i.intersect=function(e,t,r,n,s){var l,c,f;i.vertLeq(e,t)||(f=e,e=t,t=f),i.vertLeq(r,n)||(f=r,r=n,n=f),i.vertLeq(e,r)||(f=e,e=r,r=f,f=t,t=n,n=f),i.vertLeq(r,t)?i.vertLeq(t,n)?(l=i.edgeEval(e,r,t),c=i.edgeEval(r,t,n),l+c<0&&(l=-l,c=-c),s.s=i.interpolate(l,r.s,c,t.s)):(l=i.edgeSign(e,r,t),c=-i.edgeSign(e,n,t),l+c<0&&(l=-l,c=-c),s.s=i.interpolate(l,r.s,c,n.s)):s.s=(r.s+t.s)/2,i.transLeq(e,t)||(f=e,e=t,t=f),i.transLeq(r,n)||(f=r,r=n,n=f),i.transLeq(e,r)||(f=e,e=r,r=f,f=t,t=n,n=f),i.transLeq(r,t)?i.transLeq(t,n)?(l=i.transEval(e,r,t),c=i.transEval(r,t,n),l+c<0&&(l=-l,c=-c),s.t=i.interpolate(l,r.t,c,t.t)):(l=i.transSign(e,r,t),c=-i.transSign(e,n,t),l+c<0&&(l=-l,c=-c),s.t=i.interpolate(l,r.t,c,n.t)):s.t=(r.t+t.t)/2},i}(),Sa=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}(),Kc=function(){function i(e){this.side=e,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(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),i}(),Ns=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}(),M0=function(){function i(){var e=new Ns,t=new Sa,r=new Kc(0),n=new Kc(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,r.next=r,r.Sym=n,n.next=n,n.Sym=r,this.vHead=e,this.fHead=t,this.eHead=r,this.eHeadSym=n}return i.prototype.makeEdge_=function(e){var t=new Kc(0),r=new Kc(1);e.Sym.side<e.side&&(e=e.Sym);var n=e.Sym.next;return r.next=n,n.Sym.next=t,t.next=e,e.Sym.next=r,t.Sym=r,t.Onext=t,t.Lnext=r,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,r.Sym=t,r.Onext=r,r.Lnext=t,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,t},i.prototype.splice_=function(e,t){var r=e.Onext,n=t.Onext;r.Sym.Lnext=t,n.Sym.Lnext=e,e.Onext=n,t.Onext=r},i.prototype.makeVertex_=function(e,t,r){var n=e;Ae(n,"Vertex can't be null!");var s=r.prev;n.prev=s,s.next=n,n.next=r,r.prev=n,n.anEdge=t;var l=t;do l.Org=n,l=l.Onext;while(l!==t)},i.prototype.makeFace_=function(e,t,r){var n=e;Ae(n,"Face can't be null");var s=r.prev;n.prev=s,s.next=n,n.next=r,r.prev=n,n.anEdge=t,n.trail=null,n.marked=!1,n.inside=r.inside;var l=t;do l.Lface=n,l=l.Lnext;while(l!==t)},i.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,r=e.Sym.next;t.Sym.next=r,r.Sym.next=t},i.prototype.killVertex_=function(e,t){var r=e.anEdge,n=r;do n.Org=t,n=n.Onext;while(n!==r);var s=e.prev,l=e.next;l.prev=s,s.next=l},i.prototype.killFace_=function(e,t){var r=e.anEdge,n=r;do n.Lface=t,n=n.Lnext;while(n!==r);var s=e.prev,l=e.next;l.prev=s,s.next=l},i.prototype.makeEdge=function(){var e=new Ns,t=new Ns,r=new Sa,n=this.makeEdge_(this.eHead);return this.makeVertex_(e,n,this.vHead),this.makeVertex_(t,n.Sym,this.vHead),this.makeFace_(r,n,this.fHead),n},i.prototype.splice=function(e,t){var r=!1,n=!1;if(e!==t){if(t.Org!==e.Org&&(n=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!n){var s=new Ns;this.makeVertex_(s,t,e.Org),e.Org.anEdge=e}if(!r){var l=new Sa;this.makeFace_(l,t,e.Lface),e.Lface.anEdge=e}}},i.prototype.delete=function(e){var t=e.Sym,r=!1;if(e.Lface!==e.Rface&&(r=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!r){var n=new Sa;this.makeFace_(n,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},i.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),r=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var n=new Ns;return this.makeVertex_(n,r,t.Org),t.Lface=r.Lface=e.Lface,t},i.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e),r=t.Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,r),e.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=e.Rface,r.winding=e.winding,r.Sym.winding=e.Sym.winding,r.idx=e.idx,r.Sym.idx=e.Sym.idx,r},i.prototype.connect=function(e,t){var r=!1,n=this.makeEdge_(e),s=n.Sym;if(t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(n,e.Lnext),this.splice_(s,t),n.Org=e.Dst,s.Org=t.Org,n.Lface=s.Lface=e.Lface,e.Lface.anEdge=s,!r){var l=new Sa;this.makeFace_(l,n,e.Lface)}return n},i.prototype.zapFace=function(e){var t=e.anEdge,r,n,s,l,c;n=t.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)),s=r.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=t);l=e.prev,c=e.next,c.prev=l,l.next=c},i.prototype.countFaceVerts_=function(e){var t=e.anEdge,r=0;do r++,t=t.Lnext;while(t!==e.anEdge);return r},i.prototype.mergeConvexFaces=function(e){var t,r,n,s,l,c,f;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(!!t.inside)for(r=t.anEdge,l=r.Org;n=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(c=this.countFaceVerts_(t),f=this.countFaceVerts_(s.Lface),c+f-2<=e&&Te.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&Te.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(n=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===l);)r=n;return!0},i.prototype.check=function(){var e=this.fHead,t=this.vHead,r=this.eHead,n,s,l,c,f,h;for(s=e,s=e;(n=s.next)!==e;s=n){Ae(n.prev===s),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===s&&n.anEdge===null),c=t,c=t;(l=c.next)!==t;c=l){Ae(l.prev===c),f=l.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===l),f=f.Onext;while(f!==l.anEdge)}for(Ae(l.prev===c&&l.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}(),A0=function(){function i(){this.handle=null}return i}(),O0=function(){function i(){this.key=null,this.node=0}return i}(),c2=function(){function i(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var r=0;r<e+1;r++)this.nodes[r]=new A0,this.handles[r]=new O0;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(e){var t=this.nodes,r=this.handles,n,s,l;for(n=t[e].handle;;){if(l=e<<1,l<this.size&&this.leq(r[t[l+1].handle].key,r[t[l].handle].key)&&++l,Ae(l<=this.max),s=t[l].handle,l>this.size||this.leq(r[n].key,r[s].key)){t[e].handle=n,r[n].node=e;break}t[e].handle=s,r[s].node=e,e=l}},i.prototype.floatUp_=function(e){var t=this.nodes,r=this.handles,n,s,l;for(n=t[e].handle;;){if(l=e>>1,s=t[l].handle,l===0||this.leq(r[s].key,r[n].key)){t[e].handle=n,r[n].node=e;break}t[e].handle=s,r[s].node=e,e=l}},i.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(e){var t,r;if(t=++this.size,t*2>this.max){this.max*=2;var n,s;for(s=this.nodes.length,this.nodes.length=this.max+1,n=s;n<this.nodes.length;n++)this.nodes[n]=new A0;for(s=this.handles.length,this.handles.length=this.max+1,n=s;n<this.handles.length;n++)this.handles[n]=new O0}return this.freeList===0?r=t:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[t].handle=r,this.handles[r].node=t,this.handles[r].key=e,this.initialized&&this.floatUp_(t),r},i.prototype.extractMin=function(){var e=this.nodes,t=this.handles,r=e[1].handle,n=t[r].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[r].key=null,t[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),n},i.prototype.delete=function(e){var t=this.nodes,r=this.handles,n;Ae(e>=1&&e<=this.max&&r[e].key!==null),n=r[e].node,t[n].handle=t[this.size].handle,r[t[n].handle].node=n,--this.size,n<=this.size&&(n<=1||this.leq(r[t[n>>1].handle].key,r[t[n].handle].key)?this.floatDown_(n):this.floatUp_(n)),r[e].key=null,r[e].node=this.freeList,this.freeList=e},i}(),zh=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}(),u2=function(){function i(e,t){this.frame=e,this.leq=t,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(e){return this.insertBefore(this.head,e)},i.prototype.search=function(e){var t=this.head;do t=t.next;while(t.key!==null&&!this.leq(this.frame,e,t.key));return t},i.prototype.insertBefore=function(e,t){do e=e.prev;while(e.key!==null&&!this.leq(this.frame,e.key,t));var r=new P0;return r.key=t,r.next=e.next,e.next.prev=r,r.prev=e,e.next=r,r},i.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},i}(),f2=function(){function i(){}return i.regionBelow=function(e){return e.nodeUp.prev.key},i.regionAbove=function(e){return e.nodeUp.next.key},i.debugEvent=function(e){},i.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},i.edgeLeq=function(e,t,r){var n=e.event,s=t.eUp,l=r.eUp;if(s.Dst===n)return l.Dst===n?Te.vertLeq(s.Org,l.Org)?Te.edgeSign(l.Dst,s.Org,l.Org)<=0:Te.edgeSign(s.Dst,l.Org,s.Org)>=0:Te.edgeSign(l.Dst,n,l.Org)<=0;if(l.Dst===n)return Te.edgeSign(s.Dst,n,s.Org)>=0;var c=Te.edgeEval(s.Dst,n,s.Org),f=Te.edgeEval(l.Dst,n,l.Org);return c>=f},i.deleteRegion=function(e,t){t.fixUpperEdge&&Ae(t.eUp.winding===0),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},i.fixUpperEdge=function(e,t,r){Ae(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=r,r.activeRegion=t},i.topLeftRegion=function(e,t){var r=t.eUp.Org,n;do t=i.regionAbove(t);while(t.eUp.Org===r);if(t.fixUpperEdge){if(n=e.mesh.connect(i.regionBelow(t).eUp.Sym,t.eUp.Lnext),n===null)return null;i.fixUpperEdge(e,t,n),t=i.regionAbove(t)}return t},i.topRightRegion=function(e){var t=e.eUp.Dst;do e=i.regionAbove(e);while(e.eUp.Dst===t);return e},i.addRegionBelow=function(e,t,r){var n=new zh;return n.eUp=r,n.nodeUp=e.dict.insertBefore(t.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,r.activeRegion=n,n},i.isWindingInside=function(e,t){switch(e.windingRule){case Pt.ODD:return(t&1)!=0;case Pt.NONZERO:return t!==0;case Pt.POSITIVE:return t>0;case Pt.NEGATIVE:return t<0;case Pt.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(e,t){t.windingNumber=i.regionAbove(t).windingNumber+t.eUp.winding,t.inside=i.isWindingInside(e,t.windingNumber)},i.finishRegion=function(e,t){var r=t.eUp,n=r.Lface;n.inside=t.inside,n.anEdge=r,i.deleteRegion(e,t)},i.finishLeftRegions=function(e,t,r){for(var n,s=null,l=t,c=t.eUp;l!==r;){if(l.fixUpperEdge=!1,s=i.regionBelow(l),n=s.eUp,n.Org!=c.Org){if(!s.fixUpperEdge){i.finishRegion(e,l);break}n=e.mesh.connect(c.Lprev,n.Sym),i.fixUpperEdge(e,s,n)}c.Onext!==n&&(e.mesh.splice(n.Oprev,n),e.mesh.splice(c,n)),i.finishRegion(e,l),c=s.eUp,l=s}return c},i.addRightEdges=function(e,t,r,n,s,l){var c,f,h,d,x=!0;h=r;do Ae(Te.vertLeq(h.Org,h.Dst)),i.addRegionBelow(e,t,h.Sym),h=h.Onext;while(h!==n);for(s===null&&(s=i.regionBelow(t).eUp.Rprev),f=t,d=s;c=i.regionBelow(f),h=c.eUp.Sym,h.Org===d.Org;)h.Onext!==d&&(e.mesh.splice(h.Oprev,h),e.mesh.splice(d.Oprev,h)),c.windingNumber=f.windingNumber-h.winding,c.inside=i.isWindingInside(e,c.windingNumber),f.dirty=!0,!x&&i.checkForRightSplice(e,f)&&(i.addWinding(h,d),i.deleteRegion(e,f),e.mesh.delete(d)),x=!1,f=c,d=h;f.dirty=!0,Ae(f.windingNumber-h.winding===c.windingNumber),l&&i.walkDirtyRegions(e,f)},i.spliceMergeVertices=function(e,t,r){e.mesh.splice(t,r)},i.vertexWeights=function(e,t,r){var n=Te.vertL1dist(t,e),s=Te.vertL1dist(r,e),l=.5*s/(n+s),c=.5*n/(n+s);e.coords[0]+=l*t.coords[0]+c*r.coords[0],e.coords[1]+=l*t.coords[1]+c*r.coords[1],e.coords[2]+=l*t.coords[2]+c*r.coords[2]},i.getIntersectData=function(e,t,r,n,s,l){t.coords[0]=t.coords[1]=t.coords[2]=0,t.idx=-1,i.vertexWeights(t,r,n),i.vertexWeights(t,s,l)},i.checkForRightSplice=function(e,t){var r=i.regionBelow(t),n=t.eUp,s=r.eUp;if(Te.vertLeq(n.Org,s.Org)){if(Te.edgeSign(s.Dst,n.Org,s.Org)>0)return!1;Te.vertEq(n.Org,s.Org)?n.Org!==s.Org&&(e.pq.delete(n.Org.pqHandle),i.spliceMergeVertices(e,s.Oprev,n)):(e.mesh.splitEdge(s.Sym),e.mesh.splice(n,s.Oprev),t.dirty=r.dirty=!0)}else{if(Te.edgeSign(n.Dst,s.Org,n.Org)<0)return!1;i.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(n.Sym),e.mesh.splice(s.Oprev,n)}return!0},i.checkForLeftSplice=function(e,t){var r=i.regionBelow(t),n=t.eUp,s=r.eUp,l;if(Ae(!Te.vertEq(n.Dst,s.Dst)),Te.vertLeq(n.Dst,s.Dst)){if(Te.edgeSign(n.Dst,s.Dst,n.Org)<0)return!1;i.regionAbove(t).dirty=t.dirty=!0,l=e.mesh.splitEdge(n),e.mesh.splice(s.Sym,l),l.Lface.inside=t.inside}else{if(Te.edgeSign(s.Dst,n.Dst,s.Org)>0)return!1;t.dirty=r.dirty=!0,l=e.mesh.splitEdge(s),e.mesh.splice(n.Lnext,s.Sym),l.Rface.inside=t.inside}return!0},i.checkForIntersect=function(e,t){var r=i.regionBelow(t),n=t.eUp,s=r.eUp,l=n.Org,c=s.Org,f=n.Dst,h=s.Dst,d,x,g=new Ns,w,S;if(Ae(!Te.vertEq(h,f)),Ae(Te.edgeSign(f,e.event,l)<=0),Ae(Te.edgeSign(h,e.event,c)>=0),Ae(l!==e.event&&c!==e.event),Ae(!t.fixUpperEdge&&!r.fixUpperEdge),l===c||(d=Math.min(l.t,f.t),x=Math.max(c.t,h.t),d>x))return!1;if(Te.vertLeq(l,c)){if(Te.edgeSign(h,l,c)>0)return!1}else if(Te.edgeSign(f,c,l)<0)return!1;return i.debugEvent(e),Te.intersect(f,l,h,c,g),Ae(Math.min(l.t,f.t)<=g.t),Ae(g.t<=Math.max(c.t,h.t)),Ae(Math.min(h.s,f.s)<=g.s),Ae(g.s<=Math.max(c.s,l.s)),Te.vertLeq(g,e.event)&&(g.s=e.event.s,g.t=e.event.t),w=Te.vertLeq(l,c)?l:c,Te.vertLeq(w,g)&&(g.s=w.s,g.t=w.t),Te.vertEq(g,l)||Te.vertEq(g,c)?(i.checkForRightSplice(e,t),!1):!Te.vertEq(f,e.event)&&Te.edgeSign(f,e.event,g)>=0||!Te.vertEq(h,e.event)&&Te.edgeSign(h,e.event,g)<=0?h===e.event?(e.mesh.splitEdge(n.Sym),e.mesh.splice(s.Sym,n),t=i.topLeftRegion(e,t),n=i.regionBelow(t).eUp,i.finishLeftRegions(e,i.regionBelow(t),r),i.addRightEdges(e,t,n.Oprev,n,n,!0),!0):f===e.event?(e.mesh.splitEdge(s.Sym),e.mesh.splice(n.Lnext,s.Oprev),r=t,t=i.topRightRegion(t),S=i.regionBelow(t).eUp.Rprev,r.eUp=s.Oprev,s=i.finishLeftRegions(e,r,null),i.addRightEdges(e,t,s.Onext,n.Rprev,S,!0),!0):(Te.edgeSign(f,e.event,g)>=0&&(i.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(n.Sym),n.Org.s=e.event.s,n.Org.t=e.event.t),Te.edgeSign(h,e.event,g)<=0&&(t.dirty=r.dirty=!0,e.mesh.splitEdge(s.Sym),s.Org.s=e.event.s,s.Org.t=e.event.t),!1):(e.mesh.splitEdge(n.Sym),e.mesh.splitEdge(s.Sym),e.mesh.splice(s.Oprev,n),n.Org.s=g.s,n.Org.t=g.t,n.Org.pqHandle=e.pq.insert(n.Org),i.getIntersectData(e,n.Org,l,f,c,h),i.regionAbove(t).dirty=t.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(e,t){for(var r=i.regionBelow(t),n,s;;){for(;r.dirty;)t=r,r=i.regionBelow(r);if(!t.dirty&&(r=t,t=i.regionAbove(t),t===null||!t.dirty))return;if(t.dirty=!1,n=t.eUp,s=r.eUp,n.Dst!==s.Dst&&i.checkForLeftSplice(e,t)&&(r.fixUpperEdge?(i.deleteRegion(e,r),e.mesh.delete(s),r=i.regionBelow(t),s=r.eUp):t.fixUpperEdge&&(i.deleteRegion(e,t),e.mesh.delete(n),t=i.regionAbove(r),n=t.eUp)),n.Org!==s.Org)if(n.Dst!==s.Dst&&!t.fixUpperEdge&&!r.fixUpperEdge&&(n.Dst===e.event||s.Dst===e.event)){if(i.checkForIntersect(e,t))return}else i.checkForRightSplice(e,t);n.Org===s.Org&&n.Dst===s.Dst&&(i.addWinding(s,n),i.deleteRegion(e,t),e.mesh.delete(n),t=i.regionAbove(r))}},i.connectRightVertex=function(e,t,r){var n,s=r.Onext,l=i.regionBelow(t),c=t.eUp,f=l.eUp,h=!1;if(c.Dst!==f.Dst&&i.checkForIntersect(e,t),Te.vertEq(c.Org,e.event)&&(e.mesh.splice(s.Oprev,c),t=i.topLeftRegion(e,t),s=i.regionBelow(t).eUp,i.finishLeftRegions(e,i.regionBelow(t),l),h=!0),Te.vertEq(f.Org,e.event)&&(e.mesh.splice(r,f.Oprev),r=i.finishLeftRegions(e,l,null),h=!0),h){i.addRightEdges(e,t,r.Onext,s,s,!0);return}Te.vertLeq(f.Org,c.Org)?n=f.Oprev:n=c,n=e.mesh.connect(r.Lprev,n),i.addRightEdges(e,t,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(e,t)},i.connectLeftDegenerate=function(e,t,r){var n,s,l,c,f;if(n=t.eUp,Te.vertEq(n.Org,r)){Ae(!1),i.spliceMergeVertices(e,n,r.anEdge);return}if(!Te.vertEq(n.Dst,r)){e.mesh.splitEdge(n.Sym),t.fixUpperEdge&&(e.mesh.delete(n.Onext),t.fixUpperEdge=!1),e.mesh.splice(r.anEdge,n),i.sweepEvent(e,r);return}Ae(!1),t=i.topRightRegion(t),f=i.regionBelow(t),l=f.eUp.Sym,s=c=l.Onext,f.fixUpperEdge&&(Ae(s!==l),i.deleteRegion(e,f),e.mesh.delete(l),l=s.Oprev),e.mesh.splice(r.anEdge,l),Te.edgeGoesLeft(s)||(s=null),i.addRightEdges(e,t,l.Onext,c,s,!0)},i.connectLeftVertex=function(e,t){var r,n,s,l,c,f,h=new zh;if(h.eUp=t.anEdge.Sym,r=e.dict.search(h).key,n=i.regionBelow(r),!!n){if(l=r.eUp,c=n.eUp,Te.edgeSign(l.Dst,t,l.Org)===0){i.connectLeftDegenerate(e,r,t);return}if(s=Te.vertLeq(c.Dst,l.Dst)?r:n,r.inside||s.fixUpperEdge){if(s===r)f=e.mesh.connect(t.anEdge.Sym,l.Lnext);else{var d=e.mesh.connect(c.Dnext,t.anEdge);f=d.Sym}s.fixUpperEdge?i.fixUpperEdge(e,s,f):i.computeWinding(e,i.addRegionBelow(e,r,f)),i.sweepEvent(e,t)}else i.addRightEdges(e,r,t.anEdge,t.anEdge,null,!0)}},i.sweepEvent=function(e,t){e.event=t,i.debugEvent(e);for(var r=t.anEdge;r.activeRegion===null;)if(r=r.Onext,r===t.anEdge){i.connectLeftVertex(e,t);return}var n=i.topLeftRegion(e,r.activeRegion);Ae(n!==null);var s=i.regionBelow(n),l=s.eUp,c=i.finishLeftRegions(e,s,null);c.Onext===l?i.connectRightVertex(e,n,c):i.addRightEdges(e,n,c.Onext,l,l,!0)},i.addSentinel=function(e,t,r,n){var s=new zh,l=e.mesh.makeEdge();l.Org.s=r,l.Org.t=n,l.Dst.s=t,l.Dst.t=n,e.event=l.Dst,s.eUp=l,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=e.dict.insert(s)},i.initEdgeDict=function(e){e.dict=new u2(e,i.edgeLeq);var t=e.bmax[0]-e.bmin[0],r=e.bmax[1]-e.bmin[1],n=e.bmin[0]-t,s=e.bmax[0]+t,l=e.bmin[1]-r,c=e.bmax[1]+r;i.addSentinel(e,n,s,l),i.addSentinel(e,n,s,c)},i.doneEdgeDict=function(e){for(var t,r=0;(t=e.dict.min().key)!==null;)t.sentinel||(Ae(t.fixUpperEdge),Ae(++r==1)),Ae(t.windingNumber===0),i.deleteRegion(e,t)},i.removeDegenerateEdges=function(e){var t,r,n,s=e.mesh.eHead;for(t=s.next;t!==s;t=r)r=t.next,n=t.Lnext,Te.vertEq(t.Org,t.Dst)&&t.Lnext.Lnext!==t&&(i.spliceMergeVertices(e,n,t),e.mesh.delete(t),t=n,n=t.Lnext),n.Lnext===t&&(n!==t&&((n===r||n===r.Sym)&&(r=r.next),e.mesh.delete(n)),(t===r||t===r.Sym)&&(r=r.next),e.mesh.delete(t))},i.initPriorityQ=function(e){var t,r,n,s=0;for(n=e.mesh.vHead,r=n.next;r!==n;r=r.next)s++;for(s+=8,t=e.pq=new c2(s,Te.vertLeq),n=e.mesh.vHead,r=n.next;r!==n;r=r.next)r.pqHandle=t.insert(r);return r!==n?!1:(t.init(),!0)},i.donePriorityQ=function(e){e.pq=null},i.removeDegenerateFaces=function(e,t){var r,n,s;for(r=t.fHead.next;r!==t.fHead;r=n)n=r.next,s=r.anEdge,Ae(s.Lnext!==s),s.Lnext.Lnext===s&&(i.addWinding(s.Onext,s),e.mesh.delete(s));return!0},i.computeInterior=function(e,t){t===void 0&&(t=!0);var r,n;if(i.removeDegenerateEdges(e),!i.initPriorityQ(e))return!1;for(i.initEdgeDict(e);(r=e.pq.extractMin())!==null;){for(;n=e.pq.min(),!(n===null||!Te.vertEq(n,r));)n=e.pq.extractMin(),i.spliceMergeVertices(e,r.anEdge,n.anEdge);i.sweepEvent(e,r)}return e.event=e.dict.min().key.eUp.Org,i.debugEvent(e),i.doneEdgeDict(e),i.donePriorityQ(e),i.removeDegenerateFaces(e,e.mesh)?(t&&e.mesh.check(),!0):!1},i}(),h2=function(){function i(){this.mesh=new M0,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=Pt.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(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},i.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},i.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},i.prototype.computeNormal_=function(e){var t,r,n,s,l,c,f=[0,0,0],h=[0,0,0],d=[0,0,0],x=[0,0,0],g=[0,0,0],w=[null,null,null],S=[null,null,null],D=this.mesh.vHead;t=D.next;for(var C=0;C<3;++C)s=t.coords[C],h[C]=s,S[C]=t,f[C]=s,w[C]=t;for(t=D.next;t!==D;t=t.next)for(var G=0;G<3;++G)s=t.coords[G],s<h[G]&&(h[G]=s,S[G]=t),s>f[G]&&(f[G]=s,w[G]=t);var B=0;if(f[1]-h[1]>f[0]-h[0]&&(B=1),f[2]-h[2]>f[B]-h[B]&&(B=2),h[B]>=f[B]){e[0]=0,e[1]=0,e[2]=1;return}for(c=0,r=S[B],n=w[B],d[0]=r.coords[0]-n.coords[0],d[1]=r.coords[1]-n.coords[1],d[2]=r.coords[2]-n.coords[2],t=D.next;t!==D;t=t.next)x[0]=t.coords[0]-n.coords[0],x[1]=t.coords[1]-n.coords[1],x[2]=t.coords[2]-n.coords[2],g[0]=d[1]*x[2]-d[2]*x[1],g[1]=d[2]*x[0]-d[0]*x[2],g[2]=d[0]*x[1]-d[1]*x[0],l=g[0]*g[0]+g[1]*g[1]+g[2]*g[2],l>c&&(c=l,e[0]=g[0],e[1]=g[1],e[2]=g[2]);c<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(d)]=1)},i.prototype.checkOrientation_=function(){for(var e=this.mesh.fHead,t,r=this.mesh.vHead,n,s=0,l=e.next;l!==e;l=l.next)if(n=l.anEdge,!(n.winding<=0))do s+=(n.Org.s-n.Dst.s)*(n.Org.t+n.Dst.t),n=n.Lnext;while(n!==l.anEdge);if(s<0){for(t=r.next;t!==r;t=t.next)t.t=-t.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var e=this.mesh.vHead,t=[0,0,0],r,n,s=!1;t[0]=this.normal[0],t[1]=this.normal[1],t[2]=this.normal[2],!t[0]&&!t[1]&&!t[2]&&(this.computeNormal_(t),s=!0),r=this.sUnit,n=this.tUnit;var l=this.longAxis_(t);r[l]=0,r[(l+1)%3]=1,r[(l+2)%3]=0,n[l]=0,n[(l+1)%3]=0,n[(l+2)%3]=t[l]>0?1:-1;for(var c=e.next;c!==e;c=c.next)c.s=this.dot_(c.coords,r),c.t=this.dot_(c.coords,n);s&&this.checkOrientation_();for(var f=!0,h=e.next;h!==e;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(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},i.prototype.tessellateMonoRegion_=function(e,t){var r,n;if(r=t.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Te.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Te.vertLeq(r.Org,r.Dst);r=r.Lnext);n=r.Lprev;for(var s=void 0;r.Lnext!==n;)if(Te.vertLeq(r.Dst,n.Org)){for(;n.Lnext!==r&&(Te.edgeGoesLeft(n.Lnext)||Te.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)s=e.connect(n.Lnext,n),n=s.Sym;n=n.Lprev}else{for(;n.Lnext!==r&&(Te.edgeGoesRight(r.Lprev)||Te.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=e.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(n.Lnext===r)throw"Mono region invalid";for(;n.Lnext.Lnext!==r;)s=e.connect(n.Lnext,n),n=s.Sym;return!0},i.prototype.tessellateInterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)if(t=r.next,r.inside&&!this.tessellateMonoRegion_(e,r))return!1;return!0},i.prototype.discardExterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)t=r.next,r.inside||e.zapFace(r)},i.prototype.setWindingNumber_=function(e,t,r){for(var n,s=e.eHead.next;s!==e.eHead;s=n)n=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?t:-t:r?e.delete(s):s.winding=0},i.prototype.getNeighbourFace_=function(e){return!e.Rface||!e.Rface.inside?-1:e.Rface.n},i.prototype.outputPolymesh_=function(e,t,r,n){var s,l=0,c=0,f;r>3&&e.mergeConvexFaces(r);for(var h=e.vHead.next;h!==e.vHead;h=h.next)h.n=-1;for(var d=e.fHead.next;d!==e.fHead;d=d.next)if(d.n=-1,!!d.inside){s=d.anEdge,f=0;do{var h=s.Org;h.n===-1&&(h.n=c,c++),f++,s=s.Lnext}while(s!==d.anEdge);if(f>r)throw"Face vertex greater that support polygon";d.n=l,++l}this.elementCount=l,t===Qt.CONNECTED_POLYGONS&&(l*=2),this.elements=[],this.elements.length=l*r,this.vertexCount=c,this.vertices=[],this.vertices.length=c*n,this.vertexIndices=[],this.vertexIndices.length=c;for(var h=e.vHead.next;h!==e.vHead;h=h.next)if(h.n!==-1){var x=h.n*n;this.vertices[x+0]=h.coords[0],this.vertices[x+1]=h.coords[1],n>2&&(this.vertices[x+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var g=0,d=e.fHead.next;d!==e.fHead;d=d.next)if(!!d.inside){s=d.anEdge,f=0;do{var h=s.Org;this.elements[g++]=h.n,f++,s=s.Lnext}while(s!==d.anEdge);for(var w=f;w<r;++w)this.elements[g++]=-1;if(t===Qt.CONNECTED_POLYGONS){s=d.anEdge;do this.elements[g++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==d.anEdge);for(var S=f;S<r;++S)this.elements[g++]=-1}}},i.prototype.outputContours_=function(e,t){var r,n,s=0,l=0;this.vertexCount=0,this.elementCount=0;for(var c=e.fHead.next;c!==e.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*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var f=0,h=0,d=0;s=0;for(var c=e.fHead.next;c!==e.fHead;c=c.next)if(!!c.inside){l=0,n=r=c.anEdge;do this.vertices[f++]=r.Org.coords[0],this.vertices[f++]=r.Org.coords[1],t>2&&(this.vertices[f++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,l++,r=r.Lnext;while(r!==n);this.elements[d++]=s,this.elements[d++]=l,s+=l}},i.prototype.addContour=function(e,t){this.mesh===null&&(this.mesh=new M0),e<2&&(e=2),e>3&&(e=3);for(var r=null,n=0;n<t.length;n+=e)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=t[n+0],r.Org.coords[1]=t[n+1],e>2?r.Org.coords[2]=t[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(e,t,r,n,s,l){if(e===void 0&&(e=Pt.ODD),t===void 0&&(t=Qt.POLYGONS),l===void 0&&(l=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=e,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),f2.computeInterior(this,l);var c=this.mesh;return t===Qt.BOUNDARY_CONTOURS?this.setWindingNumber_(c,1,!0):this.tessellateInterior_(c),l&&c.check(),t===Qt.BOUNDARY_CONTOURS?this.outputContours_(c,n):this.outputPolymesh_(c,t,r,n),!0},i}();function wo(i){var e=i.windingRule,t=e===void 0?Pt.ODD:e,r=i.elementType,n=r===void 0?Qt.POLYGONS:r,s=i.polySize,l=s===void 0?3:s,c=i.vertexSize,f=c===void 0?2:c,h=i.normal,d=h===void 0?[0,0,1]:h,x=i.contours,g=x===void 0?[]:x,w=i.strict,S=w===void 0?!0:w,D=i.debug,C=D===void 0?!1:D;if(!g&&S)throw new Error("Contours can't be empty");if(!!g){var G=new h2;i.edgeCreateCallback&&(G.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(G.vertexIdCallback=i.vertexIdCallback);for(var B=0;B<g.length;B++)G.addContour(f||2,g[B]);return G.tesselate(t,n,l,f,d,S),{vertices:G.vertices,vertexIndices:G.vertexIndices,vertexCount:G.vertexCount,elements:G.elements,elementCount:G.elementCount,mesh:C?G.mesh:void 0}}}var Pk=Pt.ODD,Dk=Pt.NONZERO,Bk=Pt.POSITIVE,Gk=Pt.NEGATIVE,jk=Pt.ABS_GEQ_TWO,Ek=Qt.POLYGONS,Rk=Qt.CONNECTED_POLYGONS,zk=Qt.BOUNDARY_CONTOURS;var No=class extends p2{constructor(e,t=12,r=100,n={}){super();this.type="ShapeGeometry";this.windingRule=Pt.ODD;this.elementType=Qt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._drawCount=0,this._shape=e,this._curveSegments=t,this._maxCount=r,this._maxDrawCount=r*3,this._triangulationOptions=Object.assign({windingRule:Pt.ODD,elementType:Qt.POLYGONS,polySize:3,vertexSize:2,strict:!0},n),this._positionAttribute=new Xc(new Float32Array(r*3),3),this._normalAttribute=new Xc(new Float32Array(r*3),3),this._uvAttribute=new Xc(new Float32Array(r*2),2),this._indexAttribute=new Xc(new Uint32Array(r*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),t=this._shape.shapeHoles.map(f=>f.extractShapePointsToFlatArray([],this._curveSegments)),r,n=!0,s=!0,l,c;for(let f=0,h=e.length/2;f<h;f++){let d=f*2,x=e[d+0],g=e[d+1];if(l!==void 0&&x!==l&&(n=!1),c!==void 0&&g!==c&&(s=!1),l=x,c=g,!n&&!s)break}if(!n&&!s&&(r=wo({contours:[e,...t],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,r){let f=1/0,h=-1/0,d=1/0,x=-1/0;for(let S=0,D=r.vertexCount;S<D;S++){let C=S*2,G=r.vertices[C+0],B=r.vertices[C+1];G<f&&(f=G),G>h&&(h=G),B<d&&(d=B),B>x&&(x=B)}let g=h-f,w=x-d;for(let S=0,D=r.vertexCount;S<D;S++){let C=S*2,G=r.vertices[C+0],B=r.vertices[C+1],P=(G-f)/g,W=(B-d)/w;this._positionAttribute.setXYZ(S,G,B,0),this._normalAttribute.setXYZ(S,0,0,1),this._uvAttribute.setXY(S,P,W)}for(let S=0,D=r.elementCount;S<D;S++){let C=S*3,G=r.elements[C+0],B=r.elements[C+1],P=r.elements[C+2];this._indexAttribute.setX(C+0,G),this._indexAttribute.setX(C+1,B),this._indexAttribute.setX(C+2,P),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 No(this._shape,this._curveSegments,this._maxCount);return e.userData=sa(this.userData),e}};import{BufferAttribute as Qc,BufferGeometry as d2}from"three";var Yc=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let r=e*Yc.eSize;this.buffer=new ArrayBuffer(r);let n=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*n,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*n,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*n,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let r=e*Yc.eSize,n=new ArrayBuffer(r),s=Float32Array.BYTES_PER_ELEMENT,l=0,c=new Float32Array(n,l*s,3*e);l+=3*e;let f=new Float32Array(n,l*s,3*e);l+=3*e;let h=new Float32Array(n,l*s,2*e);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=e}get(e=1){let t=this.size+e;if(t>this.capacity){let n=this.capacity;for(;t>n;)n*=2;this.realloc(n)}let r=this.size;return this.size=t,r}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Zc=Yc;Zc.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Fh=(i,e)=>([t,r])=>(r<t&&(r+=e),(i>=t?i:i+e)<=r),wa=class extends d2{constructor(e,t,r=0,n=12,s=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._bevel=r,this._curveSegments=n,this._bevelSegmentsInput=s,r<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(r,t/2-1e-12),this._bevelSegments=Math.floor(s));let l=this._shape.extractShapePointsToFlatArray([],n),c=this._shape.shapeHoles.map(q=>{let E=q.extractShapePointsToFlatArray([],n),b=[];for(let R=E.length-1;R>=1;R-=2){let T=E[R-1],z=E[R-0];b.push(T,z)}return b}),f=wo({windingRule:Pt.ODD,elementType:Qt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[l]}),h=wo({windingRule:Pt.ODD,elementType:Qt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]});if(!f)throw new Error("error generating geometry");let d=f.elementCount;if(h){f.elementCount+=h.elementCount;for(let q=0;q<h.elements.length;q++){let E=h.elements[q],b=q%2==0?f.vertexCount:0;f.elements.push(E+b)}for(let q=0;q<h.vertexIndices.length;q++){let E=h.vertexIndices[q],b=f.vertexCount;f.vertexIndices.push(E+b)}for(let q=0;q<h.vertices.length;q++){let E=h.vertices[q];f.vertices.push(E)}}let x=1/0,g=-1/0,w=1/0,S=-1/0;for(let q=0,E=f.vertexCount;q<E;q++){let b=q*2,R=f.vertices[b+0],T=f.vertices[b+1];R<x&&(x=R),R>g&&(g=R),T<w&&(w=T),T>S&&(S=T)}this._minX=x,this._minY=w,this._width=g-x,this._height=S-w;let D=f.vertexCount*2*(2+this._bevelSegments);this._buffer=new Zc(D);let C=[],G=[];for(let q=f.elementCount-1;q>=0;q--){let E=q>=d,b=q*2,R=f.elements[b+0],T=f.elements[b+1],z=R+T,A={start:R,count:T,normals:[],continuous:[],concave:[]},$=R,he=z-1,re=R+1,Ne=this._shape.roundedCurves.length;do{let k=$-R,H=f.vertices[he*2+0],_=f.vertices[he*2+1],J=f.vertices[$*2+0],ee=f.vertices[$*2+1],oe=f.vertices[re*2+0],se=f.vertices[re*2+1],ce=J-H,ue=ee-_,K=Math.sqrt(ce*ce+ue*ue);ce/=K,ue/=K;let ae=J-oe,ne=ee-se,Ce=Math.sqrt(ae*ae+ne*ne);ae/=Ce,ne/=Ce,A.normals[k*2+0]=-ne,A.normals[k*2+1]=ae,A.concave[k]=ce*ne-ue*ae>0;let Y=f.vertexIndices[$];if(Array.isArray(Y))A.continuous[k]=!1;else{let[le,pe]=this._shape.getCurveIndexFromVertexId(Y-1,!0);if(pe>0&&pe<1)A.continuous[k]=!0;else{let xe=pe===1?le+1:le-1;xe=(xe+Ne)%Ne;let _e=pe===1?0:1,de=this._shape.roundedCurves[le].getTangent(pe),we=this._shape.roundedCurves[xe].getTangent(_e);A.continuous[k]=de.dot(we)>.95}}E&&(A.normals[k*2+0]*=-1,A.normals[k*2+1]*=-1),[he,$,re]=[$,re,re+1],re>=z&&(re-=T)}while(re!==R+1);let ye=[];ye.push({bevelI:0,angle:0,size:0,boundary:{vertices:f.vertices.slice(R*2,z*2),vertexCount:T,vertexIndices:new Array(T).fill(!0).map((k,H)=>[H,H]),elements:[0,T],elementCount:1,mesh:null},reverseMap:[],insetPoints:f.vertices.slice(R*2,z*2)});for(let k=1;k<=this._bevelSegments;k++){let H=k/this._bevelSegments*Math.PI/2,_=(1-Math.cos(H))*this._bevelSize,J=[],ee=[],oe=[],se=[],ce=0;for(let K=0;K<T;K++){let ae=K*2,ne=(K-1+T)%T*2,Ce=f.vertices[A.start*2+ae+0],Y=f.vertices[A.start*2+ae+1],le=-A.normals[ne+0]*_,pe=-A.normals[ne+1]*_,xe=-A.normals[ae+0]*_,_e=-A.normals[ae+1]*_;if(A.concave[K]||!A.concave[K]&&E){let de=Math.atan2(pe,le),we=Math.atan2(_e,xe);we>de&&(we-=Math.PI*2);let Ve=we-de;if(A.continuous[K]||E){let Ge=de+Ve/2,Qe=Math.cos(Ge)*_,bt=Math.sin(Ge)*_;J[2*ce+0]=Ce+Qe*(E?-1:1),J[2*ce+1]=Y+bt*(E?-1:1),se[ce]=K,ce++}else{let Ge=Math.max(1,Math.floor(n/4*Math.abs(Ve)/Math.PI));for(let Qe=0;Qe<=Ge;Qe++){let bt=de+Ve*(Qe/Ge),Lt=Math.cos(bt)*_,At=Math.sin(bt)*_;J[2*ce+0]=Ce+Lt,J[2*ce+1]=Y+At,se[ce]=K,ce++}}}else J[2*ce+0]=Ce+le,J[2*ce+1]=Y+pe,se[ce]=K,ee[K]=ce,ce++,J[2*ce+0]=Ce,J[2*ce+1]=Y,se[ce]=K,ce++,J[2*ce+0]=Ce+xe,J[2*ce+1]=Y+_e,se[ce]=K,oe[K]=ce,ce++}let ue=wo({windingRule:Pt.POSITIVE,elementType:Qt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[J],edgeCreateCallback:K=>{let ne=K.Org.idx,Ce=se[ne],Y=se[(ne+1)%se.length];K.idx=[Ce,Y],K.Sym.idx=[Y,Ce]},vertexIdCallback:K=>{let ae=K.Lprev.idx;return[ae?ae[1]:0,K.idx[0]]}});if(!ue)throw console.log("Error"),new Error(`error generating bevel geometry for ${k}'th loop`);if(!ue.vertexCount)break;for(let K=0;K<ue.vertexIndices.length;K++){let[ae,ne]=ue.vertexIndices[K];if(ae===ne)continue;let Ce=ne;ne<ae&&(Ce+=T);for(let Y=ae;Y<Ce;Y++){let le=Y%T,pe=(Y+1)%T;if(!A.continuous[le]||!A.continuous[pe]){ue.vertexIndices[K]=[ae,le],ue.vertexIndices.splice(K+1,0,[pe,ne]),ue.vertices.splice((K+1)*2,0,ue.vertices[K*2],ue.vertices[K*2+1]);break}}}ye.push({bevelI:k,angle:H,size:_,boundary:ue,reverseMap:se,insetPoints:J})}let Me=(k,H,_)=>{let J=0,ee=k.boundary.vertexIndices.length;for(;J<ee&&_(k.boundary.vertexIndices[H]);)H=(H+1)%ee,J++;return J},Fe=C.length;for(let k=1;k<ye.length;k++){let H=ye[k-1],_=ye[k],J=H.boundary.vertexIndices.length,ee=_.boundary.vertexIndices.length;if(!J||!ee)break;let oe=A.concave.length,se=0,ce=Fh(se,T);for(;!H.boundary.vertexIndices.filter(ce).length||!_.boundary.vertexIndices.filter(ce).length;)se++,ce=Fh(se,T);let ue=H.boundary.vertexIndices.findIndex(ce),K=_.boundary.vertexIndices.findIndex(ce);do ue=(ue+1)%J;while(ce(H.boundary.vertexIndices[ue]));do K=(K+1)%ee;while(ce(_.boundary.vertexIndices[K]));se=(se+1)%T;let ae=se,ne=this.buildBevelVert(A,H,(ue-1+J)%J),Ce=this.buildBevelVert(A,_,(K-1+ee)%ee),Y=ne,le=Ce,pe,xe,_e=!1;do{ce=Fh(se,T);let de=Me(H,ue,ce),we=Me(_,K,ce),Ve=_e;if(_e=!1,de&&!we){for(let Ge=0;Ge<de;Ge++)pe=this.buildBevelVert(A,H,(ue+Ge)%J,Ge/(de-1)),C.push(Y.topN,pe.topP,le.topN),C.push(pe.bottomP,Y.bottomN,le.bottomN),Y=pe;_e=!0}else if(!de&&we)for(let Ge=0;Ge<we;Ge++)xe=this.buildBevelVert(A,_,(K+Ge)%ee,Ge/(we-1)),C.push(le.topN,Y.topP,xe.topP),C.push(Y.bottomP,le.bottomN,xe.bottomP),le=xe;else if(de&&we)if(pe=this.buildBevelVert(A,H,ue,0),xe=this.buildBevelVert(A,_,K,0),Ve?(C.push(Y.topN,xe.topP,le.topN),C.push(Y.topN,pe.topP,xe.topP),C.push(xe.bottomP,Y.bottomN,le.bottomN),C.push(pe.bottomP,Y.bottomN,xe.bottomP)):(C.push(Y.topN,pe.topP,le.topN),C.push(le.topN,pe.topP,xe.topP),C.push(pe.bottomP,Y.bottomN,le.bottomN),C.push(pe.bottomP,le.bottomN,xe.bottomP)),Y=pe,le=xe,de===we)for(let Ge=1;Ge<de;Ge++)pe=this.buildBevelVert(A,H,(ue+Ge)%J,Ge/(de-1)),xe=this.buildBevelVert(A,_,(K+Ge)%ee,Ge/(we-1)),C.push(Y.topN,pe.topP,le.topN),C.push(le.topN,pe.topP,xe.topP),C.push(pe.bottomP,Y.bottomN,le.bottomN),C.push(pe.bottomP,le.bottomN,xe.bottomP),Y=pe,le=xe;else if(de>we){let Ge=de/we,Qe=0;for(let bt=1;bt<de;bt++)pe=this.buildBevelVert(A,H,(ue+bt)%J,bt/(de-1)),C.push(Y.topN,pe.topP,le.topN),C.push(pe.bottomP,Y.bottomN,le.bottomN),Y=pe,bt>(Qe+1)*Ge&&(Qe++,xe=this.buildBevelVert(A,_,(K+Qe)%ee,Qe/(we-1)),C.push(le.topN,pe.topP,xe.topP),C.push(pe.bottomP,le.bottomN,xe.bottomP),le=xe)}else{let Ge=we/de,Qe=0;for(let bt=1;bt<we;bt++)xe=this.buildBevelVert(A,_,(K+bt)%ee,bt/(we-1)),C.push(le.topN,pe.topP,xe.topP),C.push(pe.bottomP,le.bottomN,xe.bottomP),le=xe,bt>(Qe+1)*Ge&&(Qe++,pe=this.buildBevelVert(A,H,(ue+Qe)%J,Qe/(de-1)),C.push(Y.topN,pe.topP,le.topN),C.push(pe.bottomP,Y.bottomN,le.bottomN),Y=pe)}ue=(ue+de)%J,K=(K+we)%ee,se=(se+1)%oe}while(se!==ae)}{let k=ye[0];for(let H=0,_=k.boundary.vertexCount;H<_;H++){let J=this.buildBevelVert(A,k,H),ee=this.buildBevelVert(A,k,(H+1)%_);C.push(ee.topP,J.topN,J.bottomN),C.push(ee.topP,J.bottomN,ee.bottomP)}}if(E){let k=[];for(let H=C.length-1;H>=Fe+2;H-=3){let _=C[H-2],J=C[H-1],ee=C[H-0];k.push(ee,J,_)}C.splice(Fe,C.length-Fe,...k)}if(E){let k=[];for(let H=ye[ye.length-1].boundary.vertices.length-1;H>=1;H-=2){let _=ye[ye.length-1].boundary.vertices[H-1],J=ye[ye.length-1].boundary.vertices[H-0];k.push(_,J)}G.push(k)}if(!E){let k=ye[ye.length-1],H=wo({windingRule:ye.length>1?Pt.POSITIVE:Pt.ODD,elementType:Qt.POLYGONS,vertexSize:2,strict:!0,contours:[k.insetPoints,...G]});if(!H)throw new Error("Error generating geometry for surface");for(let _=0;_<H.elementCount*3;_+=3){let J=this.buildSurfaceVert(H,H.elements[_+0]),ee=this.buildSurfaceVert(H,H.elements[_+1]),oe=this.buildSurfaceVert(H,H.elements[_+2]);C.push(J.top,ee.top,oe.top),C.push(oe.bottom,ee.bottom,J.bottom)}}this.vertexCache={}}this._buffer.shrink();let B=new Qc(Uint32Array.from(C),1),P=new Qc(this._buffer.positions,3),W=new Qc(this._buffer.normals,3),M=new Qc(this._buffer.uvs,2);P.needsUpdate=!0,W.needsUpdate=!0,M.needsUpdate=!0,B.needsUpdate=!0,this.setAttribute("position",P),this.setAttribute("normal",W),this.setAttribute("uv",M),this.setIndex(B)}buildSurfaceVert(e,t){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let n=e.vertices[t*2+0],s=e.vertices[t*2+1],l=(n-this._minX)/this._width,c=(s-this._minY)/this._height,f=this._buffer.get(2),h=f*3,d=f*2,x={top:f+0,bottom:f+1};return this._buffer.positions[h+0]=n,this._buffer.positions[h+1]=s,this._buffer.positions[h+2]=this._depth,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=c,this._buffer.positions[h+3]=n,this._buffer.positions[h+4]=s,this._buffer.positions[h+5]=0,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=c,this.vertexCache[r]=x,x}buildBevelVert(e,t,r,n=1){let s=`${t.bevelI}:${r}`;if(s in this.vertexCache)return this.vertexCache[s];let[l,c]=t.boundary.vertexIndices[r],f,h,d,x;l!==c?(h=l,f=c,x=!1,d=e.continuous[h]&&e.continuous[f]):(f=l,h=(f-1+e.count)%e.count,x=e.concave[f]&&t.bevelI>0,d=e.continuous[f]||x);let g=Math.cos(t.angle),w=Math.sin(t.angle),S=r*2,D=f*2,C=h*2,G=t.boundary.vertices[S+0],B=t.boundary.vertices[S+1],P=(1-w)*this._bevelSize,W=(G-this._minX)/this._width,M=(B-this._minY)/this._height,q=e.normals[D+0],E=e.normals[D+1],b=e.normals[C+0],R=e.normals[C+1];if(x){let he=b-q,re=R-E;q=q+he*(1-n),E=E+re*(1-n);let Ne=Math.sqrt(q*q+E*E);q/=Ne,E/=Ne}let T=this._buffer.get(d?2:4),z=T*3,A=T*2,$={i:r,fi:f,topP:T+0,topN:T+0,bottomP:T+1,bottomN:T+1};return this._buffer.positions[z+0]=G,this._buffer.positions[z+1]=B,this._buffer.positions[z+2]=this._depth-P,this._buffer.normals[z+0]=q*g,this._buffer.normals[z+1]=E*g,this._buffer.normals[z+2]=w,this._buffer.uvs[A+0]=W,this._buffer.uvs[A+1]=M,this._buffer.positions[z+3]=G,this._buffer.positions[z+4]=B,this._buffer.positions[z+5]=P,this._buffer.normals[z+3]=q*g,this._buffer.normals[z+4]=E*g,this._buffer.normals[z+5]=-w,this._buffer.uvs[A+2]=M,this._buffer.uvs[A+3]=W,d||(T+=2,z+=6,A+=4,$.topP=T+0,$.bottomP=T+1,this._buffer.positions[z+0]=G,this._buffer.positions[z+1]=B,this._buffer.positions[z+2]=this._depth-P,this._buffer.normals[z+0]=b*g,this._buffer.normals[z+1]=R*g,this._buffer.normals[z+2]=w,this._buffer.uvs[A+0]=W,this._buffer.uvs[A+1]=M,this._buffer.positions[z+3]=G,this._buffer.positions[z+4]=B,this._buffer.positions[z+5]=P,this._buffer.normals[z+3]=b*g,this._buffer.normals[z+4]=R*g,this._buffer.normals[z+5]=-w,this._buffer.uvs[A+2]=M,this._buffer.uvs[A+3]=W),this.vertexCache[s]=$,$}clone(){let e=new wa(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=sa(this.userData),e}};var ur=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var h,d,x,g,w,S,D;let t=Object.assign({},(h=e==null?void 0:e.parameters)!=null?h:{width:100,subdivisions:40,roundness:0,extrudeDepth:0,surfaceMaxCount:100,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(t.width),n=Math.abs((d=t.height)!=null?d:t.width),s=Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(x=t.depth)!=null?x:0),l=(g=i.shape)!=null?g:e==null?void 0:e.shape,c=(w=l==null?void 0:l.roundness)!=null?w:t.roundness;l!==void 0&&(l instanceof st?(l.width!==r||l.height!==n)&&l.applySize(r,n):l=new st(r,n).fromJSON(l),((S=i.parameters)==null?void 0:S.roundness)!==void 0&&((D=i.parameters)==null?void 0:D.roundness)>0&&l.update(!1));let f=l!=null?l:new st(r,n);return{parameters:Object.assign(t,{width:r,height:n,depth:s,extrudeDepth:s,roundness:c}),shape:f}}static build(i){let{extrudeDepth:e,extrudeBevelSize:t,extrudeBevelSegments:r,subdivisions:n,roundness:s,surfaceMaxCount:l}=i.parameters;i.shape.roundness=s;let c;return e<=0?c=new No(i.shape,n,l):c=new wa(i.shape,e,t,n,r),Object.assign(c,{userData:fe(U({},i),{type:"VectorGeometry"})})}};import{MathUtils as D0,Vector2 as B0}from"three";var G0=Math.PI*2,j0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,s,l;let t=Object.assign({},(n=e==null?void 0:e.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 st?i.shape:new st,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(l=t.depth)!=null?l:0)})}}static build(i){let{width:e,height:t,spikes:r,angle:n,innerRadius:s,depth:l,extrudeBevelSize:c,extrudeBevelSegments:f,surfaceMaxCount:h}=i.parameters,d=i.shape,x=e*.5,g=t*.5,w=m2(d,x,g,n*Math.PI/180,r,s);d.isClosed=!0,d.update();let S=ur.create({shape:d,parameters:{subdivisions:w,surfaceMaxCount:h,depth:l,extrudeBevelSize:c,extrudeBevelSegments:f}});return Object.assign(S,{userData:fe(U({},i),{type:"EllipseGeometry"})})}};function m2(i,e,t,r,n,s){if(r>=G0)return n>30||n%4==0?(y2(i,e,t,s),Math.round(n/4)):E0(i,r,n,e,t,s);let l={x:0,y:t},c=r+Math.PI*.5,f={x:Math.cos(c)*e,y:Math.sin(c)*t},h=I0({px:l.x,py:l.y,cx:f.x,cy:f.y,rx:e,ry:t,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%h.length==0?g2(i,l.x,l.y,h,n,e,t,s):E0(i,r,n,e,t,s)}function g2(i,e,t,r,n,s,l,c){let f=Math.round(n/r.length);i.addPoint(Cs(e,t));for(let h=0,d=r.length;h<d;h++){let x=r[h],g=i.points[h],w=Cs(x.x,x.y);g.controls[1].position.set(x.x1,x.y1),w.controls[0].position.set(x.x2,x.y2),i.addPoint(w)}return c>0?R0(i,s,l,c):i.addPoint(Cs(0,0)),f}function E0(i,e,t,r,n,s){let l=-e/t;for(let c=0;c<=t;c++){let f=l*c,h=Math.sin(f)*r,d=Math.cos(f)*n;i.addPoint(Cs(h,d))}return e<G0?s>0?R0(i,r,n,s):i.addPoint(Cs(0,0)):(i.removePoint(i.points[i.points.length-1]),s>0&&z0(i,r,n,s)),1}function y2(i,e,t,r=0,n=0,s=0){let l=.5522847498,c=e*l,f=t*l;i.addPoint(eu(n-e,s,n-e,s-f,n-e,s+f)),i.addPoint(eu(n,s+t,n-c,s+t,n+c,s+t)),i.addPoint(eu(n+e,s,n+e,s+f,n+e,s-f)),i.addPoint(eu(n,s-t,n+c,s-t,n-c,s-t)),r>0&&z0(i,e,t,r)}function Cs(i,e){return new Kn(D0.generateUUID(),new B0(i,e))}function eu(i,e,t,r,n,s){let l=Cs(i,e);return l.controls[0].position.set(t,r),l.controls[1].position.set(n,s),l}function R0(i,e,t,r){F0(i,e,t,r).forEach(s=>i.addPoint(s))}function z0(i,e,t,r){let n=F0(i,e,t,r),s=new st;n.forEach(l=>s.addPoint(l)),s.isClosed=!0,i.shapeHoles.push(s)}function F0(i,e,t,r){let n=r*e/100,s=n*(Math.abs(t)/Math.abs(e)),l=new B0(n/e,s/t),c=i.points.map(f=>{let h=f.clone();return h.uuid=D0.generateUUID(),h}).reverse();return c.forEach(f=>{f.position.multiply(l);let h=f.controls[0].position.clone().multiply(l),d=f.controls[1].position.clone().multiply(l);f.controls[0].position.copy(d),f.controls[1].position.copy(h)}),c}import{BufferGeometry as x2,Float32BufferAttribute as Vh,Vector3 as V0}from"three";var U0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var c,f,h;let t=Object.assign({},(c=e==null?void 0:e.parameters)!=null?c:{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(t.width),n=Math.abs((f=t.height)!=null?f:r),s=Math.abs((h=t.depth)!=null?h:r),l=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(t,{width:r,height:n,depth:s,radius:l,segments:Math.round(t.segments),pathSegments:Math.round(t.pathSegments),cornerSegments:Math.round(t.cornerSegments)})}}static build(i){let{width:e,height:t,depth:r,radius:n,revolutions:s,segments:l,pathRadius:c,pathType:f,pathSegments:h,cornerRadius:d,cornerSegments:x}=i.parameters,g=new tu(!1,e,t,r,n,s,l,c,f,h,d,x);return Object.assign(g,{userData:fe(U({},i),{type:"HelixGeometry"})})}},tu=class extends x2{constructor(e=!0,t=1,r=1,n=1,s=1,l=1,c=1,f=1,h=1,d=1,x=1,g=1){super();let w=e&&l===1;w&&(g=0),x>100&&(x=100);let S=()=>new V0,D=new V0,C=S(),G=S(),B=S(),P,W,M,q,E,b,R,T,z=S(),A=S(),$=S(),he=S(),re=S(),Ne=S(),ye=S(),Me=S(),Fe=r-2*f+.001,k=Fe/l,H=Math.ceil(c*l),_=H+1,J=Fe/H,ee=-Fe/2,oe=d+1,se=2*Math.PI/d,ce=Math.PI/2/g,ue=.01,K=Math.min((1-x/100)*f,f-ue),ae=f-K,ne=0,Ce=2,Y=g*Ce+Ce,le=oe*Y/Ce,pe=le+oe*_,xe=oe*(_+Y),[_e,de,we]=[3,3,2].map(dt=>Array(xe*dt).fill(0)),Ve=[],Ge=s-f;function Qe(dt,Wt){let ar=Math.PI/2;b=Wt*J,T=2*Math.PI*(b%k)/k+ar,b+=ee,R=Math.sin(T)*Ge,E=Math.cos(T)*Ge,e?dt.set(E,R,b):dt.set(E,b,R)}Qe(D,-1e-10),Qe(C,0),z.copy(D),Qe(D,1);let bt=D.distanceTo(C),Lt=ae+K,At=bt*H+2*Lt,sr=K,Ur=At-Lt;for(let dt=0;dt<=H;dt++){Qe(G,dt),Me.subVectors(G,z).normalize(),z.copy(G),Ne.copy(G).setComponent(+e+1,0).normalize(),ye.crossVectors(Me,Ne).normalize();let Wt=dt===0,ar=dt===H,Ao=Wt?3*Math.PI/2:ce,Oo=Wt?sr:Ur,Po=Wt?oe:pe,ro=Wt?0:xe-oe,no=Me.clone().multiplyScalar(Wt?-ae:ae).add(G),Do=Me.clone().multiplyScalar(Wt?-1:1).normalize();for(let Mr=0;Mr<oe;Mr++){let io=Mr*se;if(A.addVectors(D.copy(Ne).multiplyScalar(f*Math.cos(io)),C.copy(ye).multiplyScalar(f*Math.sin(io))),$.copy(A).normalize(),Wt||ar){w||(ne=ro+Mr,[0,1,2].forEach(Jt=>{_e[ne*3+Jt]=no.getComponent(Jt),de[ne*3+Jt]=Do.getComponent(Jt)}),we[ne*2]=+ar,we[ne*2+1]=Mr/d),C.copy($).multiplyScalar(K),B.addVectors(G,C);for(let Jt=0;Jt<g;Jt++){let ti=Jt*ce+Ao;he.addVectors(D.copy(Me).multiplyScalar(ae*Math.sin(ti)),C.copy($).multiplyScalar(ae*Math.cos(ti))),re.copy(he).normalize(),C.addVectors(B,he),he.normalize(),ne=Po+Jt*oe+Mr,[0,1,2].forEach(Ee=>{_e[ne*3+Ee]=C.getComponent(Ee),de[ne*3+Ee]=re.getComponent(Ee)});let Bo=+Wt+Math.sin(ti);we[ne*2]=(Oo+ae*Bo)/At,we[ne*2+1]=Mr/d}}C.addVectors(G,A),ne=le+dt*oe+Mr,[0,1,2].forEach(Jt=>{_e[ne*3+Jt]=C.getComponent(Jt),de[ne*3+Jt]=$.getComponent(Jt)}),we[ne*2]=(Lt+dt*bt)/At,we[ne*2+1]=Mr/d}}let Ht=_+2*g+Ce,kr=1,[wn,Nn]=w?[kr,kr+_-1]:[0,Ht-1];for(let dt=wn;dt<=Nn-1;dt++){let Wt=w&&dt===Nn-1;for(let ar=0;ar<oe-1;ar++)P=dt*oe+ar,W=P+1,M=(Wt?ar:P)+oe,q=(Wt?ar+1:W)+oe,dt===0?Ve.push(W,q,M):dt===Ht-2?Ve.push(P,W,M):Ve.push(P,W,M,W,q,M)}this.setIndex(Ve),this.setAttribute("position",new Vh(_e,3)),this.setAttribute("normal",new Vh(de,3)),this.setAttribute("uv",new Vh(we,2))}};import{IcosahedronBufferGeometry as v2}from"three";var k0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,height:t,depth:r,detail:n,corner:s,cornerSides:l}=i.parameters,c=n===0&&s!==0?new ru(e*.5,s,l):new v2(e*.5,n);return c.scale(1,t/e,r/e),Object.assign(c,{userData:fe(U({},i),{type:"IcosahedronGeometry"})})}},ru=class extends So{constructor(e=1,t=.2,r=4){let n=(1+Math.sqrt(5))/2,s=[-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],l=[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(s,l,c,e,t,r);this.type=c}static fromJSON(e){return new ru(e.radius,e.corner,e.cornerSides)}};import{LatheBufferGeometry as b2,Shape as S2}from"three";var H0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s,l,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 t=Object.assign({},(s=e==null?void 0:e.parameters)!=null?s:{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(t,{width:Math.abs(t.width),height:Math.abs((l=t.height)!=null?l:t.width),depth:Math.abs((c=t.depth)!=null?c:t.width)})}}static build(i){let{points:e,segments:t,verticalSegments:r}=i.parameters,n=new S2;n.moveTo(e[0].x,e[0].y),n.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let s=new b2(n.extractPoints(r).shape,t);return s.rotateZ(Math.PI),Object.assign(s,{userData:fe(U({},i),{type:"LatheGeometry"})})}};import{BufferGeometry as q0,BufferGeometryLoader as I2,Vector3 as M2,BoxBufferGeometry as $0}from"three";import{BufferGeometry as w2,Vector2 as Uh,Vector3 as W0}from"three";import{Geometry as N2,Face3 as C2}from"three/examples/jsm/deprecated/Geometry.js";var L2=["a","b","c"];function _2(i,e){switch(e){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function kh(i,e,t){let r=Math.min(i,e),n=Math.max(i,e),s=r+"_"+n;return t.get(s)}function Hh(i,e,t,r,n,s){let l=Math.min(i,e),c=Math.max(i,e),f=l+"_"+c,h;if(r.has(f))h=r.get(f);else{let d=t[l],x=t[c];h={a:d,b:x,newEdge:null,faces:[]},r.set(f,h)}h.faces.push(n),s[i].edges.push(h),s[e].edges.push(h)}function T2(i,e,t,r){let n,s,l;for(n=0,s=i.length;n<s;n++)t[n]={edges:[]};for(n=0,s=e.length;n<s;n++)l=e[n],Hh(l.a,l.b,i,r,l,t),Hh(l.b,l.c,i,r,l,t),Hh(l.c,l.a,i,r,l,t)}function nu(i,e,t,r,n){i.push(new C2(e,t,r,void 0,void 0,n))}function Ls(i,e){return Math.abs(e-i)/2+Math.min(i,e)}function iu(i,e,t,r){i.push([e.clone(),t.clone(),r.clone()])}var Wh=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof w2?e=new N2().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new W0,r,n,s,l,c,f=e.vertices,h=e.faces,d=e.faceVertexUvs[0],x=d!==void 0&&d.length>0,g=[],w=new Map;T2(f,h,g,w);let S=[],D,C,G,B,P,W,M;for(let ue of Array.from(w.keys())){for(C=w.get(ue),G=new W0,P=3/8,W=1/8,M=C.faces.length,M!=2&&(P=.5,W=0,M!=1),G.addVectors(C.a,C.b).multiplyScalar(P),t.set(0,0,0),l=0;l<M;l++){for(B=C.faces[l],c=0;c<3&&(D=f[_2(B,L2[c])],!(D!==C.a&&D!==C.b));c++);D&&t.add(D)}t.multiplyScalar(W),G.add(t),C.newEdge=S.length,S.push(G)}let q,E,b,R,T,z,A,$=[];for(n=0,s=f.length;n<s;n++){for(z=f[n],T=g[n].edges,r=T.length,r==3?q=3/16:r>3&&(q=3/(8*r)),E=1-r*Number(q),b=q,r<=2&&(r==2?(E=3/4,b=1/8):r==1||r==0),A=z.clone().multiplyScalar(E),t.set(0,0,0),l=0;l<r;l++)R=T[l],D=R.a!==z?R.a:R.b,t.add(D);t.multiplyScalar(Number(b)),A.add(t),$.push(A)}let he=$.concat(S),re=$.length,Ne,ye,Me,Fe=[],k=[],H,_,J,ee,oe=new Uh,se=new Uh,ce=new Uh;for(n=0,s=h.length;n<s;n++)B=h[n],Ne=Number(kh(B.a,B.b,w).newEdge)+re,ye=Number(kh(B.b,B.c,w).newEdge)+re,Me=Number(kh(B.c,B.a,w).newEdge)+re,nu(Fe,Ne,ye,Me,B.materialIndex),nu(Fe,B.a,Ne,Me,B.materialIndex),nu(Fe,B.b,ye,Ne,B.materialIndex),nu(Fe,B.c,Me,ye,B.materialIndex),x&&(H=d[n],_=H[0],J=H[1],ee=H[2],oe.set(Ls(_.x,J.x),Ls(_.y,J.y)),se.set(Ls(J.x,ee.x),Ls(J.y,ee.y)),ce.set(Ls(_.x,ee.x),Ls(_.y,ee.y)),iu(k,oe,se,ce),iu(k,_,oe,ce),iu(k,J,se,oe),iu(k,ee,ce,se));e.vertices=he,e.faces=Fe,x&&(e.faceVertexUvs[0]=k)}};var er=new M2,J0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var s,l;let t=(l=(s=i.geometry)!=null?s:e==null?void 0:e.geometry)!=null?l:new q0().copy(new $0(100,100,100)),r;e===void 0?(t.computeBoundingBox(),t.boundingBox.getSize(er),r={width:er.x,height:er.y,depth:er.z,subdivisions:0}):r=e.parameters;let n=U(U({},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:t}}static build(i){var f;let{width:e,height:t,depth:r,subdivisions:n}=i.parameters,s=(f=i.geometry)!=null?f:new q0().copy(new $0(100,100,100)),l=s.userData.parameters;l===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(er)):er.set(l.width,l.height,l.depth),(e!==er.x||t!==er.y||r!==er.z)&&s.scale(er.x===0?1:e/er.x,er.y===0?1:t/er.y,er.z===0?1:r/er.z);let c=s.originalGeometry;return n>0?(c===void 0||(l==null?void 0:l.subdivisions)!==n)&&(c===void 0&&(c=s),s=new Wh(n).modify(c).toBufferGeometry()):(c!==void 0&&(s=c),c=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()),c!==void 0&&Object.assign(s,{originalGeometry:c}),delete i.geometry,Object.assign(s,{userData:fe(U({},i),{type:"NonParametricGeometry"})})}static loadFromUrl(i,e,t){new I2(t).load(i,n=>{let s=this.normalizeInputs({geometry:n});n.boundingBox.getSize(er);let l=100/er.x;Object.assign(s.parameters,{width:100,height:er.y*l,depth:er.z*l}),e(this.build(s))})}};var K0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,s,l,c;let t=Object.assign({},(n=e==null?void 0:e.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 st?i.shape:new st,parameters:Object.assign(t,{surfaceMaxCount:((s=t.surfaceMaxCount)!=null?s:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((l=t.height)!=null?l:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(c=t.depth)!=null?c:0)})}}static build(i){let{width:e,height:t,spikes:r,cornerRadius:n,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,surfaceMaxCount:f}=i.parameters,h=i.shape,d=e*.5,x=t*.5,g=0,w=0,S=2*Math.PI/r;for(let C=0;C<r;C++){let G=S*C,B=g+Math.sin(G)*d,P=w+Math.cos(G)*x;h.addPoint(h.createPoint(B,P))}h.isClosed=!0;for(let C=0,G=h.points.length;C<G;C++)h.points[C].roundness=n;h.roundness=n,h.update();let D=ur.create({shape:h,parameters:{surfaceMaxCount:f,roundness:n,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(D,{userData:fe(U({},i),{type:"PolygonGeometry"})})}};import{BufferGeometry as A2,Float32BufferAttribute as qh,Vector2 as Xn,Vector3 as or}from"three";var X0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,height:t,depth:r,radialSegments:n,heightSegments:s,openEnded:l,cornerRadius:c,cornerSegments:f}=i.parameters,h=new Z0(e*.5,t,n,s,l,c,f);return h.scale(1,1,r/e),Object.assign(h,{userData:fe(U({},i),{type:"PyramidGeometry"})})}};function Na(i,e,t){t.x=i.x*e.x,t.y=i.y,t.z=i.x*e.y}function $h(i,e,t,r,n,s){let l=e.clone().sub(i),c=t.clone().sub(i),f=l.angleTo(c);if(l.normalize(),c.normalize(),r===n){let h=l.add(c).normalize();s.copy(i).addScaledVector(h,r/Math.sin(f/2))}else{let h=l.angleTo(c);s.copy(i),s.addScaledVector(l,n/Math.sin(h)),s.addScaledVector(c,r/Math.sin(h))}}function O2(i,e,t){let r=i.clone().sub(e),n=t.clone().sub(e);return r.projectOnVector(n),r.add(e)}var Z0=class extends A2{constructor(e=.5,t=1,r=4,n=1,s=!1,l=0,c=4){super();r=Math.floor(Math.max(3,r)),n=Math.floor(n),c=Math.floor(c);let f=[],h=[],d=[],x=[],g=0,w=t/2,S=Math.PI/r,D=e*Math.cos(Math.PI/r),C=2*Math.PI/r,G=(r-2)*Math.PI/r,B=Math.PI-G,P=new or(0,-w,0),W=new or(0,w,0),M=new Xn(e,-w),q=new Xn(D,-w),E=new Xn(0,W.y).sub(q),b=new Xn(0,W.y).sub(M),R=new Xn(E.y,-E.x).normalize(),T=new Xn(b.y,-b.x).normalize(),A=e*Math.cos(Math.PI/r)*Math.tan((Math.PI-E.angle())/2)-1e-8;l=Math.min(l,A);let $;{let k=new or(R.x,R.y,0),H=new or(Math.cos(C)*k.x,k.y,Math.sin(C)*k.x);$=k.angleTo(H)}let he=l/Math.tan((Math.PI-E.angle())/2),re=l/Math.tan((Math.PI-$)/2),Ne=new or;if(!s){h.push(P.x,P.y,P.z),d.push(0,-1,0),x.push(0,0);let k=g++,H=[],_=M.clone(),J=he/Math.cos(Math.PI/r);_.x-=J;for(let ee=0;ee<r;ee++){let oe=ee/r*Math.PI*2+S,se=new Xn(Math.sin(oe),Math.cos(oe));Na(_,se,Ne),h.push(Ne.x,Ne.y,Ne.z),d.push(0,-1,0),x.push(0,0),H.push(g++)}for(let ee=0;ee<H.length;ee++)f.push(H[ee],k,H[(ee+1)%H.length])}let ye=[];{let k=new or,H=new or,_=new or,J=new or,ee=new or,oe=new or;for(let se=0;se<r;se++){let ce=se/r*Math.PI*2+S,ue=(se+.5)/r*Math.PI*2+S,K=(se+1)/r*Math.PI*2+S,ae=new Xn(Math.sin(ce),Math.cos(ce)),ne=new Xn(Math.sin(ue),Math.cos(ue)),Ce=new Xn(Math.sin(K),Math.cos(K));Na(M,ae,H),Na(M,Ce,_),Na(R,ne,k),$h(W,H,_,re,re,J),h.push(J.x,J.y,J.z),$h(H,W,_,re,he,ee),h.push(ee.x,ee.y,ee.z),$h(_,H,W,he,re,oe),h.push(oe.x,oe.y,oe.z),d.push(k.x,k.y,k.z),d.push(k.x,k.y,k.z),d.push(k.x,k.y,k.z),x.push(0,0),x.push(0,0),x.push(0,0);let Y=g++,le=g++,pe=g++;if(f.push(Y,le,pe),l>0){{let de=H.clone().add(_).multiplyScalar(.5),we=W.clone().sub(de).normalize(),Ge=P.clone().sub(de).normalize().add(we).normalize().multiplyScalar(-1),Qe=oe.clone().sub(ee);Me(de,Qe,Ge,E.angle())}let xe,_e;{let de=new or;Na(T,Ce,de);let we=oe.clone().add(J).multiplyScalar(.5);we=O2(we,_,W);let Ve=oe.clone().sub(J);[xe,_e]=Me(we,Ve,de,$,J.y)}{let de=xe,we=de.clone().setY(0).normalize(),Ve=new or(0,-1,0),Ge=we.clone().cross(Ve);Fe(de,we,Ve,Ge)}ye.concat(_e);{let de=E.angle(),we=Math.PI-de,Ve=W.clone();Ve.y-=l/Math.sin(de-Math.PI/2);let Ge=new or,Qe=[];for(let Lt=0;Lt<c;Lt++){let At=[],sr=Math.PI/2-we*Lt/c,Ur=Math.cos(sr),Ht=Math.sin(sr),kr=ue;for(let wn=0;wn<=Lt;wn++){let Nn=Math.cos(kr),dt=Math.sin(kr);k.x=Ur*dt,k.y=Ht,k.z=Ur*Nn,Ge.copy(Ve).addScaledVector(k,l),h.push(Ge.x,Ge.y,Ge.z),d.push(k.x,k.y,k.z),x.push(0,0),At.push(g++),kr+=Math.PI*2/Lt/r}Qe.push(At)}_e.reverse(),Qe.push(_e);let bt=Qe.length-1;for(let Lt=0;Lt<bt;Lt++){let At=Qe[Lt],sr=Qe[Lt+1],Ur=At.length-1;f.push(sr[1],At[0],sr[0]);for(let Ht=1;Ht<=Ur;Ht++)f.push(At[Ht],At[Ht-1],sr[Ht]),f.push(sr[Ht+1],At[Ht],sr[Ht])}}}}}this.setIndex(f),this.setAttribute("position",new qh(h,3)),this.setAttribute("normal",new qh(d,3)),this.setAttribute("uv",new qh(x,2));function Me(k,H,_,J,ee){let oe=-J/2,se=(Math.PI-J)/2,ce=H.clone().normalize().cross(_);k.addScaledVector(_,-l/Math.sin(se));let ue=new or,K=new or,ae=1,ne=g,Ce=[];for(let Y=0;Y<=c;Y++){let le=oe+Y/c*J;K.set(0,0,0),K.addScaledVector(ce,Math.sin(le)),K.addScaledVector(_,Math.cos(le));for(let pe=0;pe<=ae;pe++){let xe=pe/ae-.5;if(ue.copy(k),ue.addScaledVector(H,xe),ue.addScaledVector(K,l),ee!=null){let _e=Math.max(0,ue.y-ee);ue.addScaledVector(H,-_e/H.y)}h.push(ue.x,ue.y,ue.z),d.push(K.x,K.y,K.z),x.push(0,0),pe===0&&Ce.push(g),g++}}for(let Y=0;Y<c;Y++)for(let le=0;le<ae;le++){let pe=ne+le+(ae+1)*Y,xe=pe+(ae+1),_e=xe+1,de=pe+1;f.push(pe,xe,de),f.push(xe,_e,de)}return[k.clone().addScaledVector(H,.5),Ce]}function Fe(k,H,_,J){let ee=Math.PI/2,oe=b.angle()-ee,se=[],ce=new or,ue=new or;for(let ae=0;ae<=c;ae++){let ne=[],Ce=ae/c;for(let Y=0;Y<=ae;Y++){let pe=((ae?Y/ae:0)-.5)*B,xe=Math.cos(pe),_e=Math.sin(pe),de=Math.atan(Math.tan(oe)*xe),we=(ee+de)*Ce,Ve=Math.cos(we),Ge=Math.sin(we);ce.set(0,0,0),ce.addScaledVector(H,Ge*xe),ce.addScaledVector(_,Ve),ce.addScaledVector(J,Ge*_e),ue.copy(k).addScaledVector(ce,l),h.push(ue.x,ue.y,ue.z),d.push(ce.x,ce.y,ce.z),x.push(0,0),ne.push(g++)}se.push(ne)}let K=se.length-1;for(let ae=0;ae<K;ae++){let ne=se[ae],Ce=se[ae+1],Y=ne.length-1;f.push(ne[0],Ce[1],Ce[0]);for(let le=1;le<=Y;le++)f.push(ne[le-1],ne[le],Ce[le]),f.push(ne[le],Ce[le+1],Ce[le])}}}};var ou=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var l,c,f,h,d;let t=Object.assign({},(l=e==null?void 0:e.parameters)!=null?l:{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign((c=e==null?void 0:e.ui)!=null?c:{enabledIndieCorners:!1},i.ui),n=t.cornerRadius.reduce((x,g)=>x+g,0);return{shape:i.shape&&i.shape instanceof st?i.shape:new st,parameters:Object.assign(t,{surfaceMaxCount:((f=t.surfaceMaxCount)!=null?f:n>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((h=t.height)!=null?h:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(d=t.depth)!=null?d:0)}),ui:r}}static build(i){let e=i.shape,{width:t,height:r,cornerRadius:n,cornerType:s,depth:l,extrudeBevelSize:c,extrudeBevelSegments:f,surfaceMaxCount:h}=i.parameters,d={x:t*.5,y:r*.5},x={x:-d.x,y:-d.y},g={x:d.x,y:d.y};function w(M,q,E){return q>t&&E>r?Math.min(M*t/q,M*r/E):q>t?M*t/q:E>r?M*r/E:M}let S=[];S[0]=n[0]===0?0:w(n[0],n[0]+n[3],n[0]+n[1]),S[1]=n[1]===0?0:w(n[1],n[1]+n[2],n[1]+n[0]),S[2]=n[2]===0?0:w(n[2],n[2]+n[1],n[2]+n[3]),S[3]=n[3]===0?0:w(n[3],n[3]+n[0],n[3]+n[2]);let D=x.x,C=g.x,G=g.y,B=x.y;e.addPoint(e.createPoint(D,G)),e.addPoint(e.createPoint(C,G)),e.addPoint(e.createPoint(C,B)),e.addPoint(e.createPoint(D,B)),e.isClosed=!0;let P=!0;for(let M=0,q=e.points.length;M<q;M++)e.points[M].roundness=S[M],M>0&&S[M]!==S[M-1]&&(P=!1);P&&(e.roundness=S[0]),e.useCubicForRoundedCorners=s!==1,e.update();let W=ur.create({shape:e,parameters:{surfaceMaxCount:h,depth:l,extrudeBevelSize:c,extrudeBevelSegments:f}});return Object.assign(W,{userData:fe(U({},i),{type:"RectangleGeometry"})})}};import{SphereBufferGeometry as P2}from"three";var Y0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.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(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e=100,height:t=e,depth:r=e,widthSegments:n=64,heightSegments:s=64,phiStart:l,phiLength:c,thetaStart:f,thetaLength:h}=i.parameters,d=new P2(.5*e,n,s,l,c,f,h);return d.scale(1,t/e,r/e),Object.assign(d,{userData:fe(U({},i),{type:"SphereGeometry"})})}};import{PlaneBufferGeometry as D2}from"three";var Q0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:0})}}static build(i){let{width:e=100,height:t=e,widthSegments:r=8,heightSegments:n=8}=i.parameters,s=new D2(e,t,r,n);return s.scale(1,1,1),Object.assign(s,{userData:fe(U({},i),{type:"PlaneGeometry"})})}};var ev=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,s,l,c;let t=Object.assign({},(n=e==null?void 0:e.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 st?i.shape:new st,parameters:Object.assign(t,{surfaceMaxCount:((s=t.surfaceMaxCount)!=null?s:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((l=t.height)!=null?l:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(c=t.depth)!=null?c:0)})}}static build(i){let{width:e,height:t,innerRadiusPercent:r,spikes:n,cornerRadius:s,angle:l,depth:c,extrudeBevelSize:f,extrudeBevelSegments:h,surfaceMaxCount:d}=i.parameters,x=i.shape,g=e*.5,w=t*.5,S=0,D=0,C=l*Math.PI/360/n,G=Math.PI/2*3*-1,B=g*r/100,P=w*r/100;if(n==3&&r==50){C=2*Math.PI/n;for(let M=0;M<n;M++){let q=C*M,E=S+Math.sin(q)*g,b=D+Math.cos(q)*w;x.addPoint(x.createPoint(E,b))}}else for(let M=0;M<n;M++){let q=S+Math.cos(G)*g,E=D+Math.sin(G)*w;x.addPoint(x.createPoint(q,E)),G+=C,q=S+Math.cos(G)*B,E=D+Math.sin(G)*P,M<=n,x.addPoint(x.createPoint(q,E)),G+=C}x.isClosed=!0;for(let M=0,q=x.points.length;M<q;M++)x.points[M].roundness=s;x.roundness=s,x.update();let W=ur.create({shape:x,parameters:{surfaceMaxCount:d,roundness:s,depth:c,extrudeBevelSize:f,extrudeBevelSegments:h}});return Object.assign(W,{userData:fe(U({},i),{type:"StarGeometry"})})}};import{PlaneBufferGeometry as B2}from"three";var su=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,depth:0},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:0)})}}static build(i){let{width:e,height:t}=i.parameters,r=new B2(e,t);return Object.assign(r,{userData:fe(U({},i),{type:"TextFrameGeometry"})})}};var tv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var l,c,f;let t=Object.assign({},(l=e==null?void 0:e.parameters)!=null?l:{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(t.width),n=Math.abs((c=t.height)!=null?c:t.width),s=Math.abs((f=t.depth)!=null?f:t.width*.25);return{parameters:Object.assign(t,{width:r,height:n,depth:s})}}static build(i){let{width:e,height:t,depth:r,radialSegments:n,tubularSegments:s,arc:l,cornerRadius:c,cornerSegments:f}=i.parameters,h=G2(e,t,r,e*.5,l,s,0,0,n,c,f);return h.scale(1,t/e,1),Object.assign(h,{userData:fe(U({},i),{type:"TorusGeometry"})})}};function G2(i,e,t,r,n,s,l,c,f,h,d){return[e,t]=[t,e],l=e/2,n/=2*Math.PI,n==1&&(h=0),new tu(!0,i,e,t,r,n,s,l,c,f,h,d)}import{TorusKnotBufferGeometry as j2}from"three";var rv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s,l;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width),tube:(l=t.tube)!=null?l:t.width*.125})}}static build(i){let{width:e,tube:t,tubularSegments:r,radialSegments:n,p:s,q:l}=i.parameters,c=e*.5;c!==t&&(c-=t);let f=new j2(c,t,r,n,s,l);return Object.assign(f,{userData:fe(U({},i),{type:"TorusKnotGeometry"})})}};var nv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,s,l,c;let t=Object.assign({},(n=e==null?void 0:e.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 st?i.shape:new st,parameters:Object.assign(t,{surfaceMaxCount:((s=t.surfaceMaxCount)!=null?s:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((l=t.height)!=null?l:t.width*(t.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(c=t.depth)!=null?c:0)})}}static build(i){let{width:e=100,height:t,cornerRadius:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:l,isRect:c,surfaceMaxCount:f}=i.parameters,h=i.shape,d=e*.5,x=t*.5;c?(h.addPoint(h.createPoint(-d,x)),h.addPoint(h.createPoint(d,-x)),h.addPoint(h.createPoint(-d,-x))):(h.addPoint(h.createPoint(0,x)),h.addPoint(h.createPoint(d,-x)),h.addPoint(h.createPoint(-d,-x))),h.isClosed=!0;for(let w=0,S=h.points.length;w<S;w++)h.points[w].roundness=r;h.roundness=r,h.update();let g=ur.create({shape:h,parameters:{surfaceMaxCount:f,roundness:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(g,{userData:fe(U({},i),{type:"TriangleGeometry"})})}};var Ca={};V_(Ca,{addBarycentricAttribute:()=>V2,fixUvs:()=>k2,loadFromUrl:()=>U2,resizeGeometry:()=>F2,roundShapePolygon:()=>z2});import{BufferGeometryLoader as E2,Float32BufferAttribute as R2,Vector3 as Jh}from"three";var iv=function(i,e){let t=e.x-i.x,r=e.y-i.y,n=Math.sqrt(t*t+r*r),s=t/n,l=r/n,c=Math.atan2(l,s);return{x:t,y:r,len:n,nx:s,ny:l,ang:c}},z2=(i,e,t)=>{let r,n,s,l,c,f,h,d,x,g,w,S,D,C,G=e.length;for(l=e[G-2],i.curves=[],r=1;r<G-1;r++){c=e[r%G],f=e[(r+1)%G];let B=iv(c,l),P=iv(c,f);h=B.nx*P.ny-B.ny*P.nx,d=B.nx*P.nx-B.ny*-P.ny,w=Math.asin(h),x=1,g=!1,d<0?w<0?w=Math.PI+w:(w=Math.PI-w,x=-1,g=!0):w>0&&(x=-1,g=!0),S=w/2,C=Math.abs(Math.cos(S)*t/Math.sin(S)),C>Math.min(B.len/2,P.len/2)?(C=Math.min(B.len/2,P.len/2),D=Math.abs(C*Math.sin(S)/Math.cos(S))):D=t,n=c.x+P.nx*C,s=c.y+P.ny*C,n+=-P.ny*D*x,s+=P.nx*D*x,i.absarc(n,s,D,B.ang+Math.PI/2*x,P.ang-Math.PI/2*x,g),l=c,c=f}i.closePath()},F2=(i,{width:e,height:t,depth:r})=>{e=Math.abs(e),t=Math.abs(t),r=Math.abs(r);let n=i.userData.parameters,s,l,c;e===0?(e=n.width,s=1):s=e/n.width,t===0?(t=n.height,l=1):l=t/n.height,r===0?(r=n.depth,c=1):c=r/n.depth,i.scale(s,l,c),n.width=e,n.height=t,n.depth=r},V2=(i,e)=>{let t=[new Jh(1,0,0),new Jh(0,1,0),new Jh(0,0,1)],r=i.attributes.position,n=new Float32Array(r.count*3);for(let s=0,l=r.count;s<l;s++)t[s%3].toArray(n,s*3);i.setAttribute(e,new R2(n,3))},U2=i=>new Promise(e=>{new E2().load(i,r=>e(r))}),k2=(i,e,t)=>{let r=i.getAttribute("uv");if(r)for(let n=0;n<r.count;n++){let s=r.getX(n),l=r.getY(n);r.setXY(n,(s+e/2)/e,1-(l-t/2)/t*-1)}};import{BufferGeometry as ov,BufferAttribute as sv,Uint32BufferAttribute as Kh,Float32BufferAttribute as Xh,Matrix4 as W2}from"three";import{mergeVertices as q2}from"three/examples/jsm/utils/BufferGeometryUtils.js";var H2,au=new Promise(i=>{H2=i});var Oe;au.then(i=>{Oe=i});var av=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),lv=new Uint32Array([0,1,2,3]),cv=new Uint8Array([4]),en=class{static build(i,e,t,r,n){let s,l,c;if(i===void 0)s=en.allocate(n,t),Oe.set_destination_refinement_level(s,0),l=en.buildLevel(s,!0,r);else if(i.positionWASM!==void 0){e&&e!==0&&(Oe.free_bvh(e),Oe.free_subdivision_surface(e));try{s=en.allocate(n,void 0,i)}catch(f){console.error(f,i),s=en.allocate(n,void 0,{positionWASM:av,indexWASM:lv,verticesPerFaceWASM:cv})}Oe.set_destination_refinement_level(s,0),l=en.buildLevel(s,!0,r)}else s=e;if(i!==void 0&&i.subdivisions!==void 0){let f=$2(i.subdivisions,i.positionWASM.length);Oe.set_destination_refinement_level(s,f),f>0?c=en.buildLevel(s,!1,r):c=null}return{subdivPointer:s,originalGeometry:l,subdividedGeometry:c}}static allocate(i,e,t){var M;let r,n,s,l=[],c=[];if(t)t.positionWASM&&t.positionWASM.length>0?(r=t.positionWASM,n=t.indexWASM,s=t.verticesPerFaceWASM):(r=av,n=lv,s=cv);else{e.deleteAttribute("normal"),e.deleteAttribute("uv");let q=q2(e);r=q.attributes.position.array;let E=q.getIndex().array,b=E.length;switch(e.userData.type==="TorusGeometry"&&(e==null?void 0:e.userData.parameters.arc)===Math.PI*2&&(e.userData.type="ClosedTorusGeometry"),e.userData.type){case"ClosedTorusGeometry":case"PlaneGeometry":case"TorusKnotGeometry":case"CubeGeometry":n=new Uint32Array(b/3*2),s=new Uint8Array(b/6).fill(4);for(let re=0,Ne=0;re<b;re+=6)n[Ne++]=E[re],n[Ne++]=E[re+1],n[Ne++]=E[re+4],n[Ne++]=E[re+5];break;case"TorusGeometry":case"SphereGeometry":case"HelixGeometry":case"CylinderGeometry":case"ConeGeometry":let R,T,z;if(e.userData.type==="SphereGeometry")T=e.parameters.heightSegments,R=e.parameters.widthSegments,e.parameters.thetaLength!==Math.PI&&(z=!0);else if(e.userData.type==="CylinderGeometry")T=e.parameters.heightSegments+2,R=e.parameters.radialSegments;else if(e.userData.type==="ConeGeometry")T=e.parameters.heightSegments+1,R=e.parameters.radialSegments;else if(e.userData.type==="TorusGeometry"){let re=e.userData.parameters;T=Math.ceil(re.tubularSegments*re.arc/(2*Math.PI))+2,R=re.radialSegments}else{let{pathSegments:re,segments:Ne,revolutions:ye}=e.userData.parameters;T=Math.ceil(Ne*ye)+2,R=re}z?(n=new Uint32Array(1*R*3+(T-1)*R*4),s=new Uint8Array(1*R+(T-1)*R)):(n=new Uint32Array(2*R*3+(T-2)*R*4),s=new Uint8Array(2*R+(T-2)*R));let A=0,$=0,he=0;if(e.userData.type==="SphereGeometry"||e.userData.type==="HelixGeometry"||e.userData.type==="TorusGeometry"){for(;$<3*R;)n[$++]=E[A++],n[$++]=E[A++],n[$++]=E[A++],s[he++]=3;let re=z?n.length:3*R+4*(T-2)*R;for(;$<re;A+=6)n[$++]=E[A],n[$++]=E[A+1],n[$++]=E[A+4],n[$++]=E[A+5],s[he++]=4}else for(;$<4*(T-2)*R;A+=6)n[$++]=E[A],n[$++]=E[A+1],n[$++]=E[A+4],n[$++]=E[A+5],s[he++]=4;for(;$<n.length;)n[$++]=E[A++],n[$++]=E[A++],n[$++]=E[A++],s[he++]=3;break;default:n=E,s=new Uint8Array(b/3).fill(3);break}}let f=r.length,h=n.length,d=s.length,x=r.length+l.length+c.length,g=n.length+s.length,w=x*Float32Array.BYTES_PER_ELEMENT+g*Uint32Array.BYTES_PER_ELEMENT,S=x*Float32Array.BYTES_PER_ELEMENT,D=g*Uint32Array.BYTES_PER_ELEMENT,C=Oe._malloc(w),G=new Float32Array(Oe.HEAPF32.buffer,C,x),B=new Uint32Array(Oe.HEAPU32.buffer,C+S,g);G.set(r,0),G.set(l,r.length),G.set(c,r.length+l.length),B.set(n,0),B.set(s,n.length);let P;((M=t==null?void 0:t.scaleBaked)==null?void 0:M.some(q=>q!==1))&&(P=new W2().makeScale(...t.scaleBaked)),i&&(P?P.premultiply(i):P=i);let W=P?Oe.alloc_subdivision_surface2(C,f,C+S,h,C+S+n.length*Uint32Array.BYTES_PER_ELEMENT,d,P.elements):Oe.alloc_subdivision_surface(C,f,C+S,h,C+S+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return Oe._free(C),W}static buildLevel(i,e,t,r,n){let s=n?Oe.get_mesh_data2(i,e?Oe.Level.CONTROL:Oe.Level.REFINED,t!=null?t:!e,n.elements):Oe.get_mesh_data(i,e?Oe.Level.CONTROL:Oe.Level.REFINED,t!=null?t:!e),l=8,c=Oe.HEAPU32.subarray(s>>2,(s>>2)+l),f=c.subarray(4,4+4),h=0,d=Oe.HEAPU32[c[h]>>2],x=Oe.HEAPF32.subarray(d>>2,(d>>2)+f[h]);h++;let g=Oe.HEAPU32[c[h]>>2],w=Oe.HEAPF32.subarray(g>>2,(g>>2)+f[h]);h++;let S=Oe.HEAPU32[c[h]>>2],D=Oe.HEAPU32.subarray(S>>2,(S>>2)+f[h]);h++;let C=Oe.HEAPU32[c[h]>>2],G=Oe.HEAPU32.subarray(C>>2,(C>>2)+f[h]);if(h++,r===void 0){let B=new ov;if(B.setIndex(new Kh(G,1)),B.setAttribute("position",new Xh(x,3)),B.setAttribute("normal",new Xh(w,3)),e){B.setAttribute("faceMap",new Kh(D,1));let P=new Float32Array(w.length/3*4).fill(0);B.setAttribute("color",new sv(P,4))}return Oe.free_mesh_data(s),B.userData.type="SubdivGeometry",B}r.getAttribute("position").copyArray(x),r.getAttribute("normal").copyArray(w),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,Oe.free_mesh_data(s)}static buildControlCageWireframe(i,e,t){let r=Oe.get_wireframe_data_for_base_level(i),n=4,s=Oe.HEAPU32.subarray(r>>2,(r>>2)+n),l=s.subarray(2,2+2),c=0,f=Oe.HEAPU32[s[c]>>2],h=Oe.HEAPF32.subarray(f>>2,(f>>2)+l[c]);c++;let d=Oe.HEAPU32[s[c]>>2],x=Oe.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(e===void 0){let g=new ov;g.setAttribute("position",new Xh(h,3));let w=new Float32Array(h.length);for(let S=0,D=h.length;S<D;)w[S++]=t.r,w[S++]=t.g,w[S++]=t.b;return g.setAttribute("color",new sv(w,3)),g.setIndex(new Kh(x,1)),Oe.free_wireframe_data_for_base_level(r),g}e.getAttribute("position").copyArray(h),e.attributes.position.needsUpdate=!0,Oe.free_wireframe_data_for_base_level(r)}static updateCollabMesh(i,e,t){e||Oe.set_destination_refinement_level(i,1);let r=t?Oe.get_topological_data2(i,e?Oe.Level.CONTROL:Oe.Level.REFINED,t.elements):Oe.get_topological_data(i,e?Oe.Level.CONTROL:Oe.Level.REFINED),n=6,s=Oe.HEAPU32.subarray(r>>2,(r>>2)+n),l=s.subarray(3,3+3),c=0,f=Oe.HEAPU32[s[c]>>2],h=new Float32Array(Oe.HEAPF32.subarray(f>>2,(f>>2)+l[c]));c++;let d=Oe.HEAPU32[s[c]>>2],x=new Uint32Array(Oe.HEAPU32.subarray(d>>2,(d>>2)+l[c]));c++;let g=Oe.HEAPU32[s[c]>>2],w=new Uint8Array(Oe.HEAPU32.subarray(g>>2,(g>>2)+l[c]));return Oe.free_topological_data(r),{positions:h,indices:x,verticesPerFace:w}}};function $2(i,e){let t=i;return t=Math.min(t,3-Math.ceil(Math.log(e/172e3)/Math.log(4))),Math.max(t,0)}var Zh={ConeGeometry:u0,CubeGeometry:f0,CylinderGeometry:l0,DodecahedronGeometry:p0,EllipseGeometry:j0,HelixGeometry:U0,IcosahedronGeometry:k0,LatheGeometry:H0,NonParametricGeometry:J0,PolygonGeometry:K0,PyramidGeometry:X0,RectangleGeometry:ou,SphereGeometry:Y0,PlaneGeometry:Q0,StarGeometry:ev,TextFrameGeometry:su,TorusGeometry:tv,TorusKnotGeometry:rv,TriangleGeometry:nv,VectorGeometry:ur},La=i=>Zh[i.type].create(i);import{Matrix4 as Qh}from"three";import{Box3 as pv,Line3 as gn,Matrix4 as Yh,Vector3 as Ct}from"three";import{HemisphereLight as uv}from"three";import{Color as J2}from"three";var tn=class extends J2{constructor(e,t,r,n){super(e,t,r);this.isColorA=!0;this.a=n}setRGBA(e,t,r,n){super.setRGB(e,t,r),this.a=n}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 kt(i,e){let t;if(typeof i=="string"){let r=e==null?void 0:e.getColor(i);r?t=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new tn(0,0,0,0))}else return"a"in i?new tn(i.r,i.g,i.b,i.a):new tn(i.r,i.g,i.b,1);return t}var lu=i=>"isEntity"in i,_s=i=>"isAbstractMesh"in i;var vi=i=>"objectHelper"in i;function K2(i,e){var r;let t=!1;e.position&&(i.position.fromArray(e.position),t=!0),e.rotation&&(i.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,i.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in i&&(t=!0,i.hiddenMatrix.fromArray((r=e.hiddenMatrix)!=null?r:Fi.identity)),t&&i.updateMatrix(),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&i.updateWorldMatrix(!1,!0),i.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(i.isUpVectorFlipped=e.isUpVectorFlipped),i.updateUp())}function X2(i,e){K2(i,e),e.name!==void 0&&(i.name=e.name),e.visible!==void 0&&(i.isEntity?i.visibility=e.visible:i.visible=e.visible)}function fv(i,e,t){X2(i,e),e.color!==void 0&&(i.color=kt(e.color,t)),e.intensity!==void 0&&(i.intensity=e.intensity),e.shadows!==void 0&&!(i instanceof uv)&&(i.castShadow=e.shadows),i.shadow&&!(i instanceof uv)&&e.depth!==void 0&&(i.shadow.camera.far=e.depth,i.shadow.needsUpdate=!0),e.helper!==void 0&&vi(i)&&(i.enableHelper=e.helper,i.gizmos.shadowmap.visible=e.helper)}function hv(i,e){i.shadow.camera.right=e/2,i.shadow.camera.left=-e/2,i.shadow.camera.top=e/2,i.shadow.camera.bottom=-e/2,i.shadow.needsUpdate=!0}var Ts=new pv,fr=new Ct,Ie=new Ct,$t=new Yh;function Z2(i,e,t=0,r=e.count){let n=1/0,s=1/0,l=1/0,c=-1/0,f=-1/0,h=-1/0;for(let d=t;d<r;d++){let x=e.getX(d),g=e.getY(d),w=e.getZ(d);x<n&&(n=x),g<s&&(s=g),w<l&&(l=w),x>c&&(c=x),g>f&&(f=g),w>h&&(h=w)}return i.min.set(n,s,l),i.max.set(c,f,h),i}var dv=(i,e,t,r)=>{var n;if(_s(i)){let s=i.geometry.userData.parameters,l=i.geometry.getAttribute("position");i.geometry.userData.type==="SubdivGeometry"?fr.copy(i.originalGeometry.boundingSphere.center):(Z2(Ts,l,i.geometry.drawRange.start,i.geometry.drawRange.count<1/0?i.geometry.drawRange.count:l.count),Ts.getCenter(fr)),i.forceComputeSize?Ts.getSize(Ie).multiplyScalar(.5):Ie.set(s.width,s.height,(n=s.depth)!=null?n:0).multiplyScalar(.5)}else if(vi(i)&&r===!0){let s=i.geometryHelper.getAttribute("position");Ts.setFromArray(s.array),Ts.getCenter(fr),Ts.getSize(Ie).multiplyScalar(.5)}else fr.setScalar(0),Ie.setScalar(0);$t.copy(e).multiply(i.matrixWorld),Ie.x===0&&Ie.y===0&&Ie.z===0?t.push(new Ct(fr.x,fr.y,fr.z).applyMatrix4($t)):t.push(new Ct(-Ie.x,Ie.y,Ie.z).add(fr).applyMatrix4($t),new Ct(-Ie.x,-Ie.y,Ie.z).add(fr).applyMatrix4($t),new Ct(Ie.x,-Ie.y,Ie.z).add(fr).applyMatrix4($t),new Ct(Ie.x,Ie.y,Ie.z).add(fr).applyMatrix4($t),new Ct(-Ie.x,Ie.y,-Ie.z).add(fr).applyMatrix4($t),new Ct(-Ie.x,-Ie.y,-Ie.z).add(fr).applyMatrix4($t),new Ct(Ie.x,-Ie.y,-Ie.z).add(fr).applyMatrix4($t),new Ct(Ie.x,Ie.y,-Ie.z).add(fr).applyMatrix4($t))},cu=class extends pv{constructor(){super(...arguments);this.matrix=new Yh;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let r=new Yh().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,r,t)}expandByObjectSize(e,t,r=!1){let n=[];return r===!0?e.traverseEntity(s=>dv(s,t,n,e.enableHelper===!0)):dv(e,t,n,e.enableHelper===!0),this.setFromPoints(n)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4($t.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Ie).multiplyScalar(.5),this.getCenter(fr),$t.copy(this.matrix).setPosition(fr),this.vertices=[new Ct(-Ie.x,Ie.y,Ie.z).applyMatrix4($t),new Ct(-Ie.x,-Ie.y,Ie.z).applyMatrix4($t),new Ct(Ie.x,-Ie.y,Ie.z).applyMatrix4($t),new Ct(Ie.x,Ie.y,Ie.z).applyMatrix4($t),new Ct(-Ie.x,Ie.y,-Ie.z).applyMatrix4($t),new Ct(-Ie.x,-Ie.y,-Ie.z).applyMatrix4($t),new Ct(Ie.x,-Ie.y,-Ie.z).applyMatrix4($t),new Ct(Ie.x,Ie.y,-Ie.z).applyMatrix4($t)]}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=[new gn(this.vertices[0],this.vertices[3]),new gn(this.vertices[1],this.vertices[2]),new gn(this.vertices[5],this.vertices[6]),new gn(this.vertices[4],this.vertices[7]),new gn(this.vertices[0],this.vertices[1]),new gn(this.vertices[3],this.vertices[2]),new gn(this.vertices[7],this.vertices[6]),new gn(this.vertices[4],this.vertices[5]),new gn(this.vertices[0],this.vertices[4]),new gn(this.vertices[1],this.vertices[5]),new gn(this.vertices[2],this.vertices[6]),new gn(this.vertices[3],this.vertices[7])],this.centerEdges=this.edges.map(e=>e.getCenter(new Ct))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=[new Ct().copy(this.vertices[0]).sub(this.vertices[2]).multiplyScalar(.5).add(this.vertices[2]),new Ct().copy(this.vertices[7]).sub(this.vertices[5]).multiplyScalar(.5).add(this.vertices[5]),new Ct().copy(this.vertices[4]).sub(this.vertices[1]).multiplyScalar(.5).add(this.vertices[1]),new Ct().copy(this.vertices[3]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6]),new Ct().copy(this.vertices[4]).sub(this.vertices[3]).multiplyScalar(.5).add(this.vertices[3]),new Ct().copy(this.vertices[1]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6])]}};import{Object3D as Y2,Matrix4 as Q2,Light as eD}from"three";function _a(i){let e=[];for(let t in i){let r=i[t];delete r.metadata,e.push(r)}return e}function tD(i){let e=[];for(let t in i)e.push(i[t]);return e}var uu=i=>class extends i{hasEntityChild(){return this.children.some(t=>lu(t))}isDescendantOf(t){t instanceof Y2&&(t=t.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===t)return!0;r=r.parent}return!1}attach(t,r){this.updateWorldMatrix(!0,!1);let n=new Q2().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),n.multiply(t.parent.matrixWorld)),lu(t)?t.hiddenMatrix.premultiply(n):t.applyMatrix4(n),t.updateWorldMatrix(!1,!1),this.add(t),r!==void 0&&(this.children.pop(),this.children.splice(r,0,t)),this}copy(t,r=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),r===!0)for(let n=0;n<t.children.length;n++){let s=t.children[n];this.add(s.clone())}return this}toJSON(t){let r=t===void 0,n={object:{uuid:"",objectType:""}};t===void 0&&(t={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},n.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let s={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(s.name=this.name),s.matrix=this.matrix.toArray(),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),s.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(s.userData=this.userData),this.children.length>0){s.children=[];for(let l of this.children)(lu(l)||l instanceof eD)&&s.children.push(l.toJSON(t).object)}if(r){let l=_a(t.geometries),c=_a(t.materials),f=_a(t.textures),h=_a(t.images),d=_a(t.interactionStates),x=tD(t.nodes);l.length>0&&(n.geometries=l),c.length>0&&(n.materials=c),f.length>0&&(n.textures=f),h.length>0&&(n.images=h),d.length>0&&(n.interactionStates=d),x.length>0&&(n.nodes=x)}return n.object=s,n}fromJSON(t){return this.uuid=t.uuid,t.name!==void 0&&(this.name=t.name),t.matrix!==void 0?(this.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=t.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(t.position!==void 0&&this.position.fromArray(t.position),t.rotation!==void 0&&this.rotation.fromArray(t.rotation),t.quaternion!==void 0&&this.quaternion.fromArray(t.quaternion),t.scale!==void 0&&this.scale.fromArray(t.scale)),this.castShadow=t.castShadow!==void 0,this.receiveShadow=t.receiveShadow!==void 0,t.visible!==void 0&&(this.visible=t.visible),t.frustumCulled!==void 0&&(this.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(this.renderOrder=t.renderOrder),t.layers!==void 0&&(this.layers.mask=t.layers),t.userData!==void 0&&(this.userData=t.userData),this}};var yn=i=>"isEntity"in i;var xn=i=>class extends uu(i){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Qh;this._singleBBox=new cu;this._recursiveBBox=new cu;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(t){this.visible=t;for(let r of this.children)yn(r)&&r.traverseEntity(n=>{vi(n)&&n.visible&&(n.objectHelper.visible=t)})}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(t=>{yn(t)&&(t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(t=>{t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0})}traverseEntity(t){t(this);for(let r of this.children)yn(r)&&r.traverseEntity(t)}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(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,t=!0);for(let r of this.children)r.updateMatrixWorld(t)}updateWorldMatrix(t,r){let n=this.parent;if(t&&n!==null&&n.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)),r)for(let s of this.children)s.updateWorldMatrix(!1,!0)}shallowClone(t){return new this.constructor().shallowCopy(this,t)}shallowCopy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),r===!0)for(let n of t.children)yn(n)&&this.add(n.shallowClone());return this}clone(t){return new this.constructor().copy(this,t)}copy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),r===!0)for(let n of t.children)yn(n)&&this.add(n.clone());return this}keepChildrenMatrixWorld(){let t=new Qh,r=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),t.copy(this.matrixWorld).invert(),t.multiply(r);for(let n of this.children)yn(n)&&n.hiddenMatrix.premultiply(t)}toJSON(t){let r=super.toJSON(t),n=r.object;return this.raycastLock===!0&&(n.raycastLock=!0),this.scaleLock===!0&&(n.scaleLock=!0),n.hiddenMatrix=this.hiddenMatrix.toArray(),r}fromJSON(t){return super.fromJSON(t),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.scaleLock!==void 0&&(this.scaleLock=t.scaleLock),this.hiddenMatrix.fromArray(t.hiddenMatrix),this}fromObject3D(t){let r=t.children;return t.children=[],Object.assign(t,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new Qh}),this.copy(t),t.children=r,this}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let r={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return hs(r,t)}fromObjectTransformState(t){return t.position&&this.position.fromArray(t.position),t.rotation&&this.rotation.fromArray(t.rotation),t.scale&&this.scale.fromArray(t.scale),t.hiddenMatrix&&this.hiddenMatrix.fromArray(t.hiddenMatrix),this.updateMatrix(),this}toState(t=[]){let r=U({name:this.name,visible:this.visible,raycastLock:this.raycastLock},this.toObjectTransformState(t));return hs(r,t)}fromState(t,r){return t.name&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.type!=="OrthographicCamera"&&t.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),t.visible!==void 0&&(this.visibility=t.visible),this.fromObjectTransformState(t),this}};import{Object3D as rD,Vector3 as Ta,Euler as mv,MathUtils as $i}from"three";var fu=class extends rD{constructor(e,t={}){super();this.object=e;let r=e.recursiveBBox.getSize(new Ta),n=.1;this.parameters=gc.defaultData(r.toArray(),n),yo(this.parameters,t),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 t of this.object.material)t.visible=!0;if(e){let t=this.object.material.map(r=>r.clone());for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material}for(let t of this.object.material)t.visible=!e}else{if(this.children.length>0)if(this.object.material.visible=!0,e){let t=this.object.material.clone();for(let r of this.children)r.material=t}else for(let t of this.children)t.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 t=0,r=e-this.children.length;t<r;++t){let n=this.object.shallowClone(!1);n.visible=!0,this.add(n),this.parameters.hideBase&&this.setHideBase(!0)}else for(let t=0,r=this.children.length-e;t<r;++t)this.remove(this.children[0])}_updateRadial(e){let t=e.radial,r=t.start*$i.DEG2RAD,n=t.end*$i.DEG2RAD,s=r-n,l=new mv(t.rotation[0]*$i.DEG2RAD,t.rotation[1]*$i.DEG2RAD,t.rotation[2]*$i.DEG2RAD),c;switch(t.axis){case"z":c=new Ta(0,0,1);break;case"y":c=new Ta(0,1,0);break;default:case"x":c=new Ta(1,0,0);break}for(let[f,h]of this.children.entries()){h.hiddenMatrix.identity(),h.scale.x=t.scale[0],h.scale.y=t.scale[1],h.scale.z=t.scale[2],h.position.setScalar(0);let d=s/e.count*f-r;switch(t.axis){case"x":h.rotation.set(0,d,0);break;case"y":h.rotation.set(0,0,d);break;case"z":h.rotation.set(d,0,0);break}h.translateOnAxis(c,t.radius),h.position.x+=t.position[0],h.position.y+=t.position[1],h.position.z+=t.position[2],t.alignment===!0?(h.rotation.x+=l.x,h.rotation.y+=l.y,h.rotation.z+=l.z):h.rotation.copy(l)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,r=new mv(t.rotation[0]*$i.DEG2RAD,t.rotation[1]*$i.DEG2RAD,t.rotation[2]*$i.DEG2RAD);for(let[n,s]of this.children.entries())s.hiddenMatrix.identity(),s.scale.x=1+(t.scale[0]-1)*n,s.scale.y=1+(t.scale[1]-1)*n,s.scale.z=1+(t.scale[2]-1)*n,s.rotation.x=r.x*n,s.rotation.y=r.y*n,s.rotation.z=r.z*n,s.position.x=t.position[0]*n,s.position.y=t.position[1]*n,s.position.z=t.position[2]*n}_updateGrid(e){let t=0,r=e.grid;if(r.useCenter===!0){let n={x:r.count[0]%2==0?2:1,y:r.count[1]%2==0?2:1,z:r.count[2]%2==0?2:1},s=new Ta(r.size[0]*(r.count[0]-n.x)*.5,r.size[1]*(r.count[1]-n.y)*.5,r.size[2]*(r.count[2]-n.z)*.5);for(let l=0;l<r.count[0];l++)for(let c=0;c<r.count[1];c++)for(let f=0;f<r.count[2];f++){let h=this.children[t++];h.hiddenMatrix.identity(),h.scale.setScalar(1),h.rotation.set(0,0,0),h.position.x=r.size[0]*l-s.x,h.position.y=r.size[1]*c-s.y,h.position.z=r.size[2]*f-s.z}}else for(let n=0;n<r.count[0];n++)for(let s=0;s<r.count[1];s++)for(let l=0;l<r.count[2];l++){let c=this.children[t++];c.hiddenMatrix.identity(),c.scale.setScalar(1),c.rotation.set(0,0,0),c.position.x=r.size[0]*n,c.position.y=-r.size[1]*s,c.position.z=-r.size[2]*l}}fromJSON(e){return this}toJSON(){return{}}fromClonerState(e){return e.hideBase!==void 0&&this.setHideBase(e.hideBase),yo(this.parameters,e),this.update(),this}};var hr=class extends xn(nD){constructor(e,t){super(e,t);this.isAbstractMesh=!0;Array.isArray(t)&&(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,t){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=t!=null?t:0),t=t!=null?t:this.selectedMaterial,this.material[t].dispose(),this.material[t]=e):(this.material.dispose(),this.material=e)}updateGeometry(e){let t=this.geometry,r=Zh[t.userData.type],n=this.objectType==="NonParametric"?Object.assign({},t.userData,{geometry:t}):t.userData,s=r.build(r.normalizeInputs(e,n)),l=t.uuid;if(this.geometry.dispose(),this.geometry=s,this.geometry.uuid=l,this.geometry.computeBoundingSphere(),this.cloner)for(let c of this.cloner.children)c.geometry=this.geometry}resizeGeometry(e,t,r){Ca.resizeGeometry(this.geometry,{width:e,height:t,depth:r})}shallowClone(e){return new this.constructor(this.geometry,this.material).shallowCopy(this,e)}clone(e){let t=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,r=La(t),n=Array.isArray(this.material)?this.material.map(s=>s.clone()):this.material.clone();return new this.constructor(r,n).copy(this,e)}copy(e,t=!0){return super.copy(e,t),e.cloner&&(this.cloner=new fu(e,e.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new fu(this)),this.cloner.fromClonerState(e))}fromState(e,t){var r,n;return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=(r=e.castShadow)!=null?r:!0,this.receiveShadow=(n=e.receiveShadow)!=null?n:!0),this}};import{NormalBlending as CD,ShaderMaterial as LD,FrontSide as _D}from"three";import{CubeReflectionMapping as mD,CubeRefractionMapping as gD,CubeUVReflectionMapping as yD,LinearEncoding as Sv,sRGBEncoding as xD}from"three";var hu=class{constructor(e){e=e!=null?e:{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}};import{MathUtils as iD}from"three";var Pe=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=iD.generateUUID(),this.type=e,this.name="",this.userData={}}analyze(e,t){t=t!=null?t:{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,r){return r=r!=null?r:{},this.analyze(e,r),this.flow(e,t,r)}flow(e,t,r){r=r!=null?r:{},e.addFlow(r.slot,r.cache,r.context);let n={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),n}build(e,t,r){t=t!=null?t:this.getType(e,t);let n=e.getNodeData(r!=null?r:this);return e.analyzing&&this.appendDepsNode(e,n,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,r)}updateFrame(e){}generateReadonly(e,t,r,n,s,l){return""}generate(e,t,r,n,s){return""}parse(e,t,r,n){}appendDepsNode(e,t,r){t.deps=(t.deps||0)+1;let n=e.getTypeLength(r);(n>(t.outputMax||0)||this.getType(e,r))&&(t.outputMax=n,t.output=r)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getJSONNode(e){if((e==null?void 0:e.materials)&&(e==null?void 0:e.materials[this.uuid])!==void 0)return e.materials[this.uuid]}getHash(){let e="{",t,r;for(t in this)r=this[t],r instanceof Pe&&(e+='"'+t+'":'+r.getHash()+",");if(this.hashProperties)for(let n=0;n<this.hashProperties.length;n++)t=this.hashProperties[n],r=this[t],e+='"'+t+'":"'+String(r)+'",';return e+='"id":"'+this.uuid+'"}',e}copy(e){return this.name=e.name,e.type&&(this.type=e.type),e.frameId&&(this.frameId=e.frameId),e.hashProperties&&(this.hashProperties=e.hashProperties.map(t=>t)),this.userData=JSON.parse(JSON.stringify(e.userData)),this.shortcuts=JSON.parse(JSON.stringify(e.shortcuts)),this}clone(){return new this.constructor().copy(this)}createJSONNode(e){let t=e===void 0||typeof e=="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),!t&&e&&(e.nodes[this.uuid]=r),r}toJSON(e){var t;return(t=this.getJSONNode(e))!=null?t:this.createJSONNode(e)}fromJSON(e,t){return this.uuid=e.uuid,this.type=e.type,e.name&&(this.name=e.name),e.userData&&(this.userData=e.userData),this}};var gv=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,r){r=r!==void 0?r:!0,this.keywords[e]={callback:t,cache:r}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},tr=new gv;import{Vector2 as yv}from"three";import{MathUtils as oD}from"three";var Be=class extends Pe{constructor(e,t){super(e);this.scope="";t=t!=null?t:{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,r,n){if(t=t!=null?t:this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=oD.generateUUID()),r=e.getUUID(r!=null?r:this.getUUID(),!s);let l=e.getNodeData(r),c=l.output||this.getType(e);if(e.analyzing)return(l.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,l,t),this.generate(e,t,r)):super.build(e,t,r);if(s)return l.name=l.name||super.build(e,t,r),l.name;if(!this.getLabel()&&(!this.getShared(e,c)||e.context.ignoreCache||l.deps===1))return super.build(e,t,r);r=this.getUUID(!1);let f=this.getTemp(e,r);if(f)return e.format(f,c,t);{f=super.generate(e,t,r,l.output,n);let h=this.generate(e,c,r);return e.addNodeCode(f+" = "+h+";"),e.format(f,c,t)}}return super.build(e,t,r)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let r=e.getVars()[t];return r?r.name:void 0}generate(e,t,r,n,s){return this.getShared(e,t)||console.error("TempNode is not shared"),r=r!=null?r:this.uuid,e.getTempVar(r,n!=null?n:this.getType(e),s,this.getLabel()).name}};var It=class extends Be{constructor(e,t){t=t!=null?t:{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}createJSONNode(e){let t=super.createJSONNode(e);return this.readonly===!0&&(t.readonly=this.readonly),t}fromJSON(e,t){return super.fromJSON(e,t),e.readonly!==void 0&&this.setReadonly(e.readonly),this}generate(e,t,r,n,s,l){r=e.getUUID(r!=null?r:this.getUUID()),n=n!=null?n:this.getType(e);let c=e.getNodeData(r);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,r,n,s,l):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(n,this,s,l,this.getLabel())),e.format(c.vertex.name,n,t)):(c.fragment||(c.fragment=e.createFragmentUniform(n,this,s,l,this.getLabel())),e.format(c.fragment.name,n,t))}copy(e){return super.copy(e),this.readonly=e.readonly,this}};var _r=class extends It{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof yv?e:new yv(e,t)}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,t,r,n,s,l){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};import{Vector3 as xv}from"three";var Tr=class extends It{constructor(e=0,t,r){super("v3");this.nodeType="Vector3";this.value=e instanceof xv?e:new xv(e,t,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}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,r,n,s,l){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var Ji=class extends It{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof tn?e:new tn(e.r,e.g,e.b,e.a)}generateReadonly(e,t,r,n,s,l){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var sD=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,vv=/[a-z_0-9]+/gi,Se=class extends Be{constructor(e,t,r,n,s){super(s);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,r,n)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,r,n,s){let l,c=0,f=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let h=[];for(;l=vv.exec(this.src);)h.push(l);for(let d=0;d<h.length;d++){let x=h[d],g=x[0],w=this.isMethod?!this.getInputByName(g):!0,S=g;if(this.keywords[g]||this.useKeywords&&w&&tr.containsKeyword(g)){let D=this.keywords[g];if(!D){let C=tr.getKeywordData(g);C.cache&&(D=e.keywords[g]),D=D||tr.getKeyword(g,e),C.cache&&(e.keywords[g]=D)}S=D.build(e)}g!==S&&(f=f.substring(0,x.index+c)+S+f.substring(x.index+g.length+c),c+=S.length-g.length),this.getIncludeByName(S)===void 0&&tr.contains(S)&&e.include(tr.get(S))}return t==="source"?f:this.isMethod?(this.isInterface||e.include(this,void 0,f),this.name):e.format("( "+f+" )",this.getType(e),t)}parse(e,t,r,n){if(this.src=e||"",this.includes=t!=null?t:[],this.extensions=r!=null?r:{},this.keywords=n!=null?n:{},this.isMethod){let s=sD.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let l=s[3].match(vv);if(l){let c=0;for(;c<l.length;){let f=l[c++],h;f==="in"||f==="out"||f==="inout"?h=l[c++]:(h=f,f="");let d=l[c++];this.inputs.push({name:d,type:h,qualifier:f})}}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 r;let t=this.getJSONNode(e);if(!t){t=this.createJSONNode(e),t.src=this.src,t.isMethod=this.isMethod,t.useKeywords=this.useKeywords,this.isMethod||(t.type=this.type),t.extensions=JSON.parse(JSON.stringify(this.extensions));let n={};for(let s in this.keywords)n[s]=this.keywords[s].toJSON(e).uuid;if(t.keywords=n,(r=this.includes)==null?void 0:r.length){let s=[];for(let l=0;l<this.includes.length;l++)s.push(this.includes[l].toJSON(e).uuid);t.includes=s}t.isMethod=this.isMethod,t.inputs=this.inputs}return t.nodeType=this.nodeType,t}fromJSON(e,t){if(super.fromJSON(e,t),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&&t){this.keywords={};for(let r in e.keywords)this.keywords[r]=t.getNode(e.keywords[r])}return e.includes&&t&&(this.includes=e.includes.map(r=>t.getNode(r))),this}};var aD=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,ep=class extends Be{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||ep.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,r,n,s){this.src=e||"";let l,c,f="",h=aD.exec(e);this.useDefine=s!=null?s:this.src.charAt(0)==="#",h&&h.length>1?(c=h[1],l=h[2],f=h[3]):(l=this.src,c="f"),this.name=l,this.type=c,this.value=f}build(e,t){if(t==="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),t)}generate(e,t,r,n,s){return e.format(this.name,this.getType(e),t)}copy(e){return super.copy(e),this.parse(e.src,void 0,void 0,void 0,e.useDefine),this}},it=ep;it.PI="PI",it.PI2="PI2",it.RECIPROCAL_PI="RECIPROCAL_PI",it.RECIPROCAL_PI2="RECIPROCAL_PI2",it.LOG2="LOG2",it.EPSILON="EPSILON";var lD=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
21
- )*?)}`,"gim"),cD=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Ia=class extends Be{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,r,n,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=lD.exec(e);if(t){let r=t[2],n;for(;n=cD.exec(r);)this.inputs.push({type:n[1],name:n[2]});this.name=t[1]}else this.name="";this.type=this.name}};var Ma=class extends Be{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e!=null?e:0}generate(e,t){e.requires.uv[this.index]=!0;let r=this.index>0?this.index+1:"",n=e.isShader("vertex")?"uv"+r:"vUv"+r;return e.format(n,this.getType(e),t)}copy(e){return super.copy(e),this.index=e.index,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.index=this.index),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.index&&(this.index=e.index),this}};tr.addKeyword("uv",function(){return new Ma});tr.addKeyword("uv2",function(){return new Ma(1)});import{LinearEncoding as uD,sRGBEncoding as fD}from"three";var Co=class extends Be{constructor(e=new Pe,t){super("v4");this.nodeType="ColorSpace";this.factor=new Pe;this.input=e,this.method=t!=null?t:Co.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case uD:return["Linear"];case fD:return["sRGB"];default:return[]}}generate(e,t){var c;let r=this.input.build(e,"v4"),n=this.getType(e),s=Co.Nodes[this.method],l=e.include(s);if(l===Co.LINEAR_TO_LINEAR)return e.format(r,n,t);if(((c=s.inputs)==null?void 0:c.length)===2){let f=this.factor.build(e,"f");return e.format(l+"( "+r+", "+f+" )",n,t)}else return e.format(l+"( "+r+" )",n,t)}fromEncoding(e){let t=Co.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Co.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}copy(e){return super.copy(e),this.input.copy(e.input),this.method=e.method,this.factor.copy(e.factor),this}},zr=Co;zr.Nodes={LinearToLinear:new Se(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
22
- `)),sRGBToLinear:new Se(["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
- `)),LinearTosRGB:new Se(["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
- `))},zr.LINEAR_TO_LINEAR="LinearToLinear",zr.SRGB_TO_LINEAR="sRGBToLinear",zr.LINEAR_TO_SRGB="LinearTosRGB";var xt=class extends Se{constructor(e="",t,r,n,s){super(e,s,n,r,t);this.nodeType="Expression"}};import{Texture as hD}from"three";var bi=class extends hD{toJSON(e){let t=super.toJSON(e),r=e===void 0||typeof e=="string";if(this.image!==void 0&&!r){let n=this.image;if(Array.isArray(n)){e.images[n.uuid].url=[];for(let s=0;s<n.length;s++)e.images[n.uuid].url[s]=bv(n[s])}else e.images[n.uuid].url=bv(n)}return t}};function bv(i){return typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap?pD(i):(console.warn("THREE.Texture: Unable to serialize Texture."),"")}var Is;function pD(i){if(/^data:/i.test(i.src))return i.src;let e;if(i instanceof HTMLCanvasElement)e=i;else{Is===void 0&&(Is=document.createElement("canvas")),Is.width=i.width,Is.height=i.height;let r=Is.getContext("2d");i instanceof ImageData?r.putImageData(i,0,0):r.drawImage(i,0,0,i.width,i.height),e=Is}let t=i.src.startsWith("blob:")?i.fileName:i.src;return/\.jpe?g$/i.test(t)?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}var Fr=class extends It{constructor(e=new bi,t,r,n){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t!=null?t:new Ma,this.bias=r,this.project=n!==void 0?n:!1}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){var d;if(t==="sampler2D")return this.getTexture(e,t);let r=this.getTexture(e,t),n=this.uv.build(e,this.project?"v4":"v2"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let l,c;this.project?l="texture2DProj":l=s?"tex2DBias":"tex2D",s?c=l+"( "+r+", "+n+", "+s+" )":c=l+"( "+r+", "+n+" )";let f={include:e.isShader("vertex"),ignoreCache:!0},h=this.getType(e);return e.addContext(f),this.colorSpace=(d=this.colorSpace)!=null?d:new zr(new xt("",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,t)}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 It{constructor(e){super("f");this.nodeType="Float";this.value=e!=null?e:0}generateReadonly(e,t,r,n,s,l){return e.format(this.value+(this.value%1?"":".0"),n,t)}copy(e){return super.copy(e),this.value=e.value,this}};var pu=class extends Be{constructor(e,t){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=t!=null?t:[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,r,n,s){n=this.getType(e);let l=this.value,c=l.build(e,t)+"( ",f=[];if(l.inputs){for(let h=0;h<l.inputs.length;h++){let d=l.inputs[h],x=this.inputs[h]||this.inputs[d.name];f.push(x.build(e,e.getTypeByFormat(d.type)))}c+=f.join(", ")+" )"}return e.format(c,n,t)}copy(e){return super.copy(e),this.value.copy(e.value),this.inputs=e.inputs.map(t=>t.clone()),this}toJSON(e){var r;let t=this.getJSONNode(e);if(!t){let n=this.value;if(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid,(r=n.inputs)==null?void 0:r.length){t.inputs={};for(let s=0;s<n.inputs.length;s++){let l=n.inputs[s],c=this.inputs[s];t.inputs[l.name]=c.toJSON(e).uuid}}}return t}};var Ms;(function(n){n.ADD="+",n.SUB="-",n.MUL="*",n.DIV="/"})(Ms||(Ms={}));var tp=class extends Be{constructor(e=new Pe,t=new Pe,r=tp.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=t,this.op=r}getType(e){let t=this.a.getType(e),r=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(r)>e.getTypeLength(t)?r:t}generate(e,t){let r=this.getType(e);this.type=r;let n=this.a.build(e,r),s=this.b.build(e,r);return e.format("( "+n+" "+this.op+" "+s+" )",r,t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this}},rn=tp;rn.ADD=Ms.ADD,rn.SUB=Ms.SUB,rn.MUL=Ms.MUL,rn.DIV=Ms.DIV;var Ke;(function(_){_.RAD="radians",_.DEG="degrees",_.EXP="exp",_.EXP2="exp2",_.LOG="log",_.LOG2="log2",_.SQRT="sqrt",_.INV_SQRT="inversesqrt",_.FLOOR="floor",_.CEIL="ceil",_.NORMALIZE="normalize",_.FRACT="fract",_.SATURATE="saturate",_.SIN="sin",_.COS="cos",_.TAN="tan",_.ASIN="asin",_.ACOS="acos",_.ARCTAN="atan",_.ABS="abs",_.SIGN="sign",_.LENGTH="length",_.NEGATE="negate",_.INVERT="invert",_.MIN="min",_.MAX="max",_.MOD="mod",_.STEP="step",_.REFLECT="reflect",_.DISTANCE="distance",_.DOT="dot",_.CROSS="cross",_.POW="pow",_.MIX="mix",_.CLAMP="clamp",_.REFRACT="refract",_.SMOOTHSTEP="smoothstep",_.FACEFORWARD="faceforward"})(Ke||(Ke={}));var ht=class extends Be{constructor(e=new Pe,t=ht.ABS,r,n){super();this.nodeType="Math";this.a=e,typeof t!="string"?this.b=t:n=t,typeof r!="string"?this.c=r:n=r,this.method=n,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case ht.MIX:case ht.CLAMP:case ht.REFRACT:case ht.SMOOTHSTEP:case ht.FACEFORWARD:return 3;case ht.MIN:case ht.MAX:case ht.MOD:case ht.STEP:case ht.REFLECT:case ht.DISTANCE:case ht.DOT:case ht.CROSS:case ht.POW:return 2;default:return 1}}getInputType(e){let t=e.getTypeLength(this.a.getType(e)),r=this.b?e.getTypeLength(this.b.getType(e)):0,n=this.c?e.getTypeLength(this.c.getType(e)):0;return t>r&&t>n?this.a.getType(e):r>n?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case ht.LENGTH:case ht.DISTANCE:case ht.DOT:return"f";case ht.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let r,n,s,l=this.a?e.getTypeLength(this.a.getType(e)):0,c=this.b?e.getTypeLength(this.b.getType(e)):0,f=this.c?e.getTypeLength(this.c.getType(e)):0,h=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case ht.NEGATE:return e.format("( -"+this.a.build(e,h)+" )",h,t);case ht.INVERT:return e.format("( 1.0 - "+this.a.build(e,h)+" )",h,t);case ht.CROSS:r=this.a.build(e,"v3"),n=this.b.build(e,"v3");break;case ht.STEP:r=this.a.build(e,l===1?"f":h),n=this.b.build(e,h);break;case ht.MIN:case ht.MAX:case ht.MOD:r=this.a.build(e,h),n=this.b.build(e,c===1?"f":h);break;case ht.REFRACT:r=this.a.build(e,h),n=this.b.build(e,h),s=this.c.build(e,"f");break;case ht.MIX:r=this.a.build(e,h),n=this.b.build(e,h),s=this.c.build(e,f===1?"f":h);break;default:r=this.a.build(e,h),this.b&&(n=this.b.build(e,h)),this.c&&(s=this.c.build(e,h));break}let x=[];x.push(r),n&&x.push(n),s&&x.push(s);let g=this.getNumInputs(e);if(x.length!==g)throw Error(`Arguments not match used in "${this.method}". Require ${g}, currently ${x.length}.`);return e.format(this.method+"( "+x.join(", ")+" )",d,t)}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}},ze=ht;ze.RAD=Ke.RAD,ze.DEG=Ke.DEG,ze.EXP=Ke.EXP,ze.EXP2=Ke.EXP2,ze.LOG=Ke.LOG,ze.LOG2=Ke.LOG2,ze.SQRT=Ke.SQRT,ze.INV_SQRT=Ke.INV_SQRT,ze.FLOOR=Ke.FLOOR,ze.CEIL=Ke.CEIL,ze.NORMALIZE=Ke.NORMALIZE,ze.FRACT=Ke.FRACT,ze.SATURATE=Ke.SATURATE,ze.SIN=Ke.SIN,ze.COS=Ke.COS,ze.TAN=Ke.TAN,ze.ASIN=Ke.ASIN,ze.ACOS=Ke.ACOS,ze.ARCTAN=Ke.ARCTAN,ze.ABS=Ke.ABS,ze.SIGN=Ke.SIGN,ze.LENGTH=Ke.LENGTH,ze.NEGATE=Ke.NEGATE,ze.INVERT=Ke.INVERT,ze.MIN=Ke.MIN,ze.MAX=Ke.MAX,ze.MOD=Ke.MOD,ze.STEP=Ke.STEP,ze.REFLECT=Ke.REFLECT,ze.DISTANCE=Ke.DISTANCE,ze.DOT=Ke.DOT,ze.CROSS=Ke.CROSS,ze.POW=Ke.POW,ze.MIX=Ke.MIX,ze.CLAMP=Ke.CLAMP,ze.REFRACT=Ke.REFRACT,ze.SMOOTHSTEP=Ke.SMOOTHSTEP,ze.FACEFORWARD=Ke.FACEFORWARD;var As=class extends Be{constructor(e=new Pe,t=new Pe,r=new Pe){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=t,this.bias=r}bilinearCubeUV(e,t,r,n){var f,h,d,x;let s=new pu(As.Nodes.bilinearCubeUV,[t,r,n]);this.colorSpaceTL=(f=this.colorSpaceTL)!=null?f:new zr(new xt("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(s.build(e)+".tl"),this.colorSpaceTR=(h=this.colorSpaceTR)!=null?h:new zr(new xt("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(s.build(e)+".tr"),this.colorSpaceBL=(d=this.colorSpaceBL)!=null?d:new zr(new xt("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(s.build(e)+".bl"),this.colorSpaceBR=(x=this.colorSpaceBR)!=null?x:new zr(new xt("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(s.build(e)+".br");let l={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(l),this.colorSpaceTLExp=new xt(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new xt(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new xt(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new xt(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let c=new xt("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return c.keywords.cubeUV_TL=this.colorSpaceTLExp,c.keywords.cubeUV_TR=this.colorSpaceTRExp,c.keywords.cubeUV_BL=this.colorSpaceBLExp,c.keywords.cubeUV_BR=this.colorSpaceBRExp,c.keywords.cubeUV=s,c}generate(e,t){if(e.isShader("fragment")){let r=this.uv,n=this.bias||e.context.roughness,s=new pu(As.Nodes.roughnessToMip,[n]),l=new ze(s,As.Nodes.m0,As.Nodes.cubeUV_maxMipLevel,ze.CLAMP),c=new ze(l,ze.FLOOR),f=new ze(l,ze.FRACT),h=this.bilinearCubeUV(e,this.value,r,c),d=this.bilinearCubeUV(e,this.value,r,new rn(c,new ve(1).setReadonly(!0),rn.ADD)),x=new ze(h,d,f,ze.MIX);return e.format(x.build(e),"v4",t)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)}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}},Aa=As;Aa.Nodes=function(){let e=new Ia(`struct TextureCubeUVData {
1
+ var sm=Object.create;var Dn=Object.defineProperty,am=Object.defineProperties,lm=Object.getOwnPropertyDescriptor,cm=Object.getOwnPropertyDescriptors,pm=Object.getOwnPropertyNames,tc=Object.getOwnPropertySymbols,um=Object.getPrototypeOf,ic=Object.prototype.hasOwnProperty,hm=Object.prototype.propertyIsEnumerable;var rc=(n,t,e)=>t in n?Dn(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,P=(n,t)=>{for(var e in t||(t={}))ic.call(t,e)&&rc(n,e,t[e]);if(tc)for(var e of tc(t))hm.call(t,e)&&rc(n,e,t[e]);return n},W=(n,t)=>am(n,cm(t));var dm=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),mm=(n,t)=>{for(var e in t)Dn(n,e,{get:t[e],enumerable:!0})},fm=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of pm(t))!ic.call(n,i)&&i!==e&&Dn(n,i,{get:()=>t[i],enumerable:!(r=lm(t,i))||r.enumerable});return n};var ym=(n,t,e)=>(e=n!=null?sm(um(n)):{},fm(t||!n||!n.__esModule?Dn(e,"default",{value:n,enumerable:!0}):e,n));var Rd=dm((Sa,zd)=>{(function(n,t){typeof Sa=="object"&&typeof zd<"u"?t(Sa):typeof define=="function"&&define.amd?define(["exports"],t):t((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(Sa,function(n){"use strict";n.SVD=function(t,e,r,i,o){if(e=e===void 0||e,r=r===void 0||r,o=1e-64/(i=i||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var s,a,l,c,p,u,h,m,f,L,S,y,w=t[0].length,I=t.length;if(I<w)throw new TypeError("Invalid matrix: m < n");for(var _=[],g=[],V=[],b=e==="f"?I:w,d=L=h=0;d<I;d++)g[d]=new Array(b).fill(0);for(d=0;d<w;d++)V[d]=new Array(w).fill(0);var O,x=new Array(w).fill(0);for(d=0;d<I;d++)for(s=0;s<w;s++)g[d][s]=t[d][s];for(d=0;d<w;d++){for(_[d]=h,f=0,l=d+1,s=d;s<I;s++)f+=Math.pow(g[s][d],2);if(f<o)h=0;else for(m=(u=g[d][d])*(h=u<0?Math.sqrt(f):-Math.sqrt(f))-f,g[d][d]=u-h,s=l;s<w;s++){for(f=0,a=d;a<I;a++)f+=g[a][d]*g[a][s];for(u=f/m,a=d;a<I;a++)g[a][s]=g[a][s]+u*g[a][d]}for(x[d]=h,f=0,s=l;s<w;s++)f+=Math.pow(g[d][s],2);if(f<o)h=0;else{for(m=(u=g[d][d+1])*(h=u<0?Math.sqrt(f):-Math.sqrt(f))-f,g[d][d+1]=u-h,s=l;s<w;s++)_[s]=g[d][s]/m;for(s=l;s<I;s++){for(f=0,a=l;a<w;a++)f+=g[s][a]*g[d][a];for(a=l;a<w;a++)g[s][a]=g[s][a]+f*_[a]}}L<(S=Math.abs(x[d])+Math.abs(_[d]))&&(L=S)}if(r)for(d=w-1;0<=d;d--){if(h!==0){for(m=g[d][d+1]*h,s=l;s<w;s++)V[s][d]=g[d][s]/m;for(s=l;s<w;s++){for(f=0,a=l;a<w;a++)f+=g[d][a]*V[a][s];for(a=l;a<w;a++)V[a][s]=V[a][s]+f*V[a][d]}}for(s=l;s<w;s++)V[d][s]=0,V[s][d]=0;V[d][d]=1,h=_[d],l=d}if(e){if(e==="f")for(d=w;d<I;d++){for(s=w;s<I;s++)g[d][s]=0;g[d][d]=1}for(d=w-1;0<=d;d--){for(l=d+1,h=x[d],s=l;s<b;s++)g[d][s]=0;if(h!==0){for(m=g[d][d]*h,s=l;s<b;s++){for(f=0,a=l;a<I;a++)f+=g[a][d]*g[a][s];for(u=f/m,a=d;a<I;a++)g[a][s]=g[a][s]+u*g[a][d]}for(s=d;s<I;s++)g[s][d]=g[s][d]/h}else for(s=d;s<I;s++)g[s][d]=0;g[d][d]=g[d][d]+1}}for(i*=L,a=w-1;0<=a;a--)for(var M=0;M<50;M++){for(O=!1,l=a;0<=l;l--){if(Math.abs(_[l])<=i){O=!0;break}if(Math.abs(x[l-1])<=i)break}if(!O){for(p=0,c=l-(f=1),d=l;d<a+1&&(u=f*_[d],_[d]=p*_[d],!(Math.abs(u)<=i));d++)if(h=x[d],x[d]=Math.sqrt(u*u+h*h),p=h/(m=x[d]),f=-u/m,e)for(s=0;s<I;s++)S=g[s][c],y=g[s][d],g[s][c]=S*p+y*f,g[s][d]=-S*f+y*p}if(y=x[a],l===a){if(y<0&&(x[a]=-y,r))for(s=0;s<w;s++)V[s][a]=-V[s][a];break}for(L=x[l],u=(((S=x[a-1])-y)*(S+y)+((h=_[a-1])-(m=_[a]))*(h+m))/(2*m*S),h=Math.sqrt(u*u+1),u=((L-y)*(L+y)+m*(S/(u<0?u-h:u+h)-m))/L,d=l+(f=p=1);d<a+1;d++){if(h=_[d],S=x[d],m=f*h,h*=p,y=Math.sqrt(u*u+m*m),u=L*(p=u/(_[d-1]=y))+h*(f=m/y),h=-L*f+h*p,m=S*f,S*=p,r)for(s=0;s<w;s++)L=V[s][d-1],y=V[s][d],V[s][d-1]=L*p+y*f,V[s][d]=-L*f+y*p;if(y=Math.sqrt(u*u+m*m),u=(p=u/(x[d-1]=y))*h+(f=m/y)*S,L=-f*h+p*S,e)for(s=0;s<I;s++)S=g[s][d-1],y=g[s][d],g[s][d-1]=S*p+y*f,g[s][d]=-S*f+y*p}_[l]=0,_[a]=u,x[a]=L}for(d=0;d<w;d++)x[d]<i&&(x[d]=0);return{u:g,q:x,v:V}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});import{FileLoader as Gw,Loader as zw}from"three";function oc(n){return Array.isArray(n)?n:[n]}var gm=typeof global=="object"&&global&&global.Object===Object&&global,_n=gm;var xm=typeof self=="object"&&self&&self.Object===Object&&self,bm=_n||xm||Function("return this")(),Ze=bm;var vm=Ze.Symbol,Ct=vm;var nc=Object.prototype,Sm=nc.hasOwnProperty,wm=nc.toString,Po=Ct?Ct.toStringTag:void 0;function Cm(n){var t=Sm.call(n,Po),e=n[Po];try{n[Po]=void 0;var r=!0}catch{}var i=wm.call(n);return r&&(t?n[Po]=e:delete n[Po]),i}var sc=Cm;var Lm=Object.prototype,Tm=Lm.toString;function Nm(n){return Tm.call(n)}var ac=Nm;var Mm="[object Null]",Om="[object Undefined]",lc=Ct?Ct.toStringTag:void 0;function Im(n){return n==null?n===void 0?Om:Mm:lc&&lc in Object(n)?sc(n):ac(n)}var Bt=Im;function Pm(n){return n!=null&&typeof n=="object"}var gt=Pm;var Am="[object Symbol]";function Dm(n){return typeof n=="symbol"||gt(n)&&Bt(n)==Am}var Ci=Dm;function _m(n,t){for(var e=-1,r=n==null?0:n.length,i=Array(r);++e<r;)i[e]=t(n[e],e,n);return i}var Bn=_m;var Bm=Array.isArray,Qe=Bm;var Em=1/0,cc=Ct?Ct.prototype:void 0,pc=cc?cc.toString:void 0;function uc(n){if(typeof n=="string")return n;if(Qe(n))return Bn(n,uc)+"";if(Ci(n))return pc?pc.call(n):"";var t=n+"";return t=="0"&&1/n==-Em?"-0":t}var hc=uc;function Gm(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var xt=Gm;function zm(n){return n}var En=zm;var Rm="[object AsyncFunction]",Vm="[object Function]",Fm="[object GeneratorFunction]",jm="[object Proxy]";function Um(n){if(!xt(n))return!1;var t=Bt(n);return t==Vm||t==Fm||t==Rm||t==jm}var Li=Um;var km=Ze["__core-js_shared__"],Gn=km;var dc=function(){var n=/[^.]+$/.exec(Gn&&Gn.keys&&Gn.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function Hm(n){return!!dc&&dc in n}var mc=Hm;var qm=Function.prototype,Wm=qm.toString;function $m(n){if(n!=null){try{return Wm.call(n)}catch{}try{return n+""}catch{}}return""}var wr=$m;var Jm=/[\\^$.*+?()[\]{}|]/g,Km=/^\[object .+?Constructor\]$/,Ym=Function.prototype,Xm=Object.prototype,Zm=Ym.toString,Qm=Xm.hasOwnProperty,ef=RegExp("^"+Zm.call(Qm).replace(Jm,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function tf(n){if(!xt(n)||mc(n))return!1;var t=Li(n)?ef:Km;return t.test(wr(n))}var fc=tf;function rf(n,t){return n==null?void 0:n[t]}var yc=rf;function of(n,t){var e=yc(n,t);return fc(e)?e:void 0}var Ot=of;var nf=Ot(Ze,"WeakMap"),zn=nf;var gc=Object.create,sf=function(){function n(){}return function(t){if(!xt(t))return{};if(gc)return gc(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),xc=sf;function af(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var bc=af;function lf(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}var Rn=lf;var cf=800,pf=16,uf=Date.now;function hf(n){var t=0,e=0;return function(){var r=uf(),i=pf-(r-e);if(e=r,i>0){if(++t>=cf)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var vc=hf;function df(n){return function(){return n}}var Sc=df;var mf=function(){try{var n=Ot(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Ti=mf;var ff=Ti?function(n,t){return Ti(n,"toString",{configurable:!0,enumerable:!1,value:Sc(t),writable:!0})}:En,wc=ff;var yf=vc(wc),Vn=yf;function gf(n,t){for(var e=-1,r=n==null?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}var Cc=gf;var xf=9007199254740991,bf=/^(?:0|[1-9]\d*)$/;function vf(n,t){var e=typeof n;return t=t==null?xf:t,!!t&&(e=="number"||e!="symbol"&&bf.test(n))&&n>-1&&n%1==0&&n<t}var Fn=vf;function Sf(n,t,e){t=="__proto__"&&Ti?Ti(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}var Ni=Sf;function wf(n,t){return n===t||n!==n&&t!==t}var Gr=wf;var Cf=Object.prototype,Lf=Cf.hasOwnProperty;function Tf(n,t,e){var r=n[t];(!(Lf.call(n,t)&&Gr(r,e))||e===void 0&&!(t in n))&&Ni(n,t,e)}var jn=Tf;function Nf(n,t,e,r){var i=!e;e||(e={});for(var o=-1,s=t.length;++o<s;){var a=t[o],l=r?r(e[a],n[a],a,e,n):void 0;l===void 0&&(l=n[a]),i?Ni(e,a,l):jn(e,a,l)}return e}var kt=Nf;var Lc=Math.max;function Mf(n,t,e){return t=Lc(t===void 0?n.length-1:t,0),function(){for(var r=arguments,i=-1,o=Lc(r.length-t,0),s=Array(o);++i<o;)s[i]=r[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=r[i];return a[t]=e(s),bc(n,this,a)}}var Un=Mf;function Of(n,t){return Vn(Un(n,t,En),n+"")}var Tc=Of;var If=9007199254740991;function Pf(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=If}var kn=Pf;function Af(n){return n!=null&&kn(n.length)&&!Li(n)}var zr=Af;function Df(n,t,e){if(!xt(e))return!1;var r=typeof t;return(r=="number"?zr(e)&&Fn(t,e.length):r=="string"&&t in e)?Gr(e[t],n):!1}var Nc=Df;function _f(n){return Tc(function(t,e){var r=-1,i=e.length,o=i>1?e[i-1]:void 0,s=i>2?e[2]:void 0;for(o=n.length>3&&typeof o=="function"?(i--,o):void 0,s&&Nc(e[0],e[1],s)&&(o=i<3?void 0:o,i=1),t=Object(t);++r<i;){var a=e[r];a&&n(t,a,r,o)}return t})}var Mc=_f;var Bf=Object.prototype;function Ef(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||Bf;return n===e}var Mi=Ef;function Gf(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var Oc=Gf;var zf="[object Arguments]";function Rf(n){return gt(n)&&Bt(n)==zf}var La=Rf;var Ic=Object.prototype,Vf=Ic.hasOwnProperty,Ff=Ic.propertyIsEnumerable,jf=La(function(){return arguments}())?La:function(n){return gt(n)&&Vf.call(n,"callee")&&!Ff.call(n,"callee")},si=jf;function Uf(){return!1}var Pc=Uf;var _c=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ac=_c&&typeof module=="object"&&module&&!module.nodeType&&module,kf=Ac&&Ac.exports===_c,Dc=kf?Ze.Buffer:void 0,Hf=Dc?Dc.isBuffer:void 0,qf=Hf||Pc,Oi=qf;var Wf="[object Arguments]",$f="[object Array]",Jf="[object Boolean]",Kf="[object Date]",Yf="[object Error]",Xf="[object Function]",Zf="[object Map]",Qf="[object Number]",ey="[object Object]",ty="[object RegExp]",ry="[object Set]",iy="[object String]",oy="[object WeakMap]",ny="[object ArrayBuffer]",sy="[object DataView]",ay="[object Float32Array]",ly="[object Float64Array]",cy="[object Int8Array]",py="[object Int16Array]",uy="[object Int32Array]",hy="[object Uint8Array]",dy="[object Uint8ClampedArray]",my="[object Uint16Array]",fy="[object Uint32Array]",je={};je[ay]=je[ly]=je[cy]=je[py]=je[uy]=je[hy]=je[dy]=je[my]=je[fy]=!0;je[Wf]=je[$f]=je[ny]=je[Jf]=je[sy]=je[Kf]=je[Yf]=je[Xf]=je[Zf]=je[Qf]=je[ey]=je[ty]=je[ry]=je[iy]=je[oy]=!1;function yy(n){return gt(n)&&kn(n.length)&&!!je[Bt(n)]}var Bc=yy;function gy(n){return function(t){return n(t)}}var Ii=gy;var Ec=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ao=Ec&&typeof module=="object"&&module&&!module.nodeType&&module,xy=Ao&&Ao.exports===Ec,Ta=xy&&_n.process,by=function(){try{var n=Ao&&Ao.require&&Ao.require("util").types;return n||Ta&&Ta.binding&&Ta.binding("util")}catch{}}(),Cr=by;var Gc=Cr&&Cr.isTypedArray,vy=Gc?Ii(Gc):Bc,Hn=vy;var Sy=Object.prototype,wy=Sy.hasOwnProperty;function Cy(n,t){var e=Qe(n),r=!e&&si(n),i=!e&&!r&&Oi(n),o=!e&&!r&&!i&&Hn(n),s=e||r||i||o,a=s?Oc(n.length,String):[],l=a.length;for(var c in n)(t||wy.call(n,c))&&!(s&&(c=="length"||i&&(c=="offset"||c=="parent")||o&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Fn(c,l)))&&a.push(c);return a}var qn=Cy;function Ly(n,t){return function(e){return n(t(e))}}var Wn=Ly;var Ty=Wn(Object.keys,Object),zc=Ty;var Ny=Object.prototype,My=Ny.hasOwnProperty;function Oy(n){if(!Mi(n))return zc(n);var t=[];for(var e in Object(n))My.call(n,e)&&e!="constructor"&&t.push(e);return t}var Rc=Oy;function Iy(n){return zr(n)?qn(n):Rc(n)}var Pi=Iy;function Py(n){var t=[];if(n!=null)for(var e in Object(n))t.push(e);return t}var Vc=Py;var Ay=Object.prototype,Dy=Ay.hasOwnProperty;function _y(n){if(!xt(n))return Vc(n);var t=Mi(n),e=[];for(var r in n)r=="constructor"&&(t||!Dy.call(n,r))||e.push(r);return e}var Fc=_y;function By(n){return zr(n)?qn(n,!0):Fc(n)}var nr=By;var Ey=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Gy=/^\w*$/;function zy(n,t){if(Qe(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||Ci(n)?!0:Gy.test(n)||!Ey.test(n)||t!=null&&n in Object(t)}var jc=zy;var Ry=Ot(Object,"create"),Lr=Ry;function Vy(){this.__data__=Lr?Lr(null):{},this.size=0}var Uc=Vy;function Fy(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var kc=Fy;var jy="__lodash_hash_undefined__",Uy=Object.prototype,ky=Uy.hasOwnProperty;function Hy(n){var t=this.__data__;if(Lr){var e=t[n];return e===jy?void 0:e}return ky.call(t,n)?t[n]:void 0}var Hc=Hy;var qy=Object.prototype,Wy=qy.hasOwnProperty;function $y(n){var t=this.__data__;return Lr?t[n]!==void 0:Wy.call(t,n)}var qc=$y;var Jy="__lodash_hash_undefined__";function Ky(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Lr&&t===void 0?Jy:t,this}var Wc=Ky;function Ai(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Ai.prototype.clear=Uc;Ai.prototype.delete=kc;Ai.prototype.get=Hc;Ai.prototype.has=qc;Ai.prototype.set=Wc;var Na=Ai;function Yy(){this.__data__=[],this.size=0}var $c=Yy;function Xy(n,t){for(var e=n.length;e--;)if(Gr(n[e][0],t))return e;return-1}var Rr=Xy;var Zy=Array.prototype,Qy=Zy.splice;function eg(n){var t=this.__data__,e=Rr(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():Qy.call(t,e,1),--this.size,!0}var Jc=eg;function tg(n){var t=this.__data__,e=Rr(t,n);return e<0?void 0:t[e][1]}var Kc=tg;function rg(n){return Rr(this.__data__,n)>-1}var Yc=rg;function ig(n,t){var e=this.__data__,r=Rr(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var Xc=ig;function Di(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Di.prototype.clear=$c;Di.prototype.delete=Jc;Di.prototype.get=Kc;Di.prototype.has=Yc;Di.prototype.set=Xc;var Vr=Di;var og=Ot(Ze,"Map"),Fr=og;function ng(){this.size=0,this.__data__={hash:new Na,map:new(Fr||Vr),string:new Na}}var Zc=ng;function sg(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var Qc=sg;function ag(n,t){var e=n.__data__;return Qc(t)?e[typeof t=="string"?"string":"hash"]:e.map}var jr=ag;function lg(n){var t=jr(this,n).delete(n);return this.size-=t?1:0,t}var ep=lg;function cg(n){return jr(this,n).get(n)}var tp=cg;function pg(n){return jr(this,n).has(n)}var rp=pg;function ug(n,t){var e=jr(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var ip=ug;function _i(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}_i.prototype.clear=Zc;_i.prototype.delete=ep;_i.prototype.get=tp;_i.prototype.has=rp;_i.prototype.set=ip;var Do=_i;var hg="Expected a function";function Ma(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(hg);var e=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=e.cache;if(o.has(i))return o.get(i);var s=n.apply(this,r);return e.cache=o.set(i,s)||o,s};return e.cache=new(Ma.Cache||Do),e}Ma.Cache=Do;var op=Ma;var dg=500;function mg(n){var t=op(n,function(r){return e.size===dg&&e.clear(),r}),e=t.cache;return t}var np=mg;var fg=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,yg=/\\(\\)?/g,gg=np(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(fg,function(e,r,i,o){t.push(i?o.replace(yg,"$1"):r||e)}),t}),sp=gg;function xg(n){return n==null?"":hc(n)}var ap=xg;function bg(n,t){return Qe(n)?n:jc(n,t)?[n]:sp(ap(n))}var Bi=bg;var vg=1/0;function Sg(n){if(typeof n=="string"||Ci(n))return n;var t=n+"";return t=="0"&&1/n==-vg?"-0":t}var $n=Sg;function wg(n,t){t=Bi(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[$n(t[e++])];return e&&e==r?n:void 0}var lp=wg;function Cg(n,t){for(var e=-1,r=t.length,i=n.length;++e<r;)n[i+e]=t[e];return n}var Ei=Cg;var cp=Ct?Ct.isConcatSpreadable:void 0;function Lg(n){return Qe(n)||si(n)||!!(cp&&n&&n[cp])}var pp=Lg;function up(n,t,e,r,i){var o=-1,s=n.length;for(e||(e=pp),i||(i=[]);++o<s;){var a=n[o];t>0&&e(a)?t>1?up(a,t-1,e,r,i):Ei(i,a):r||(i[i.length]=a)}return i}var hp=up;function Tg(n){var t=n==null?0:n.length;return t?hp(n,1):[]}var dp=Tg;function Ng(n){return Vn(Un(n,void 0,dp),n+"")}var mp=Ng;var Mg=Wn(Object.getPrototypeOf,Object),Gi=Mg;var Og="[object Object]",Ig=Function.prototype,Pg=Object.prototype,fp=Ig.toString,Ag=Pg.hasOwnProperty,Dg=fp.call(Object);function _g(n){if(!gt(n)||Bt(n)!=Og)return!1;var t=Gi(n);if(t===null)return!0;var e=Ag.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&fp.call(e)==Dg}var Jn=_g;function Bg(n,t,e){var r=-1,i=n.length;t<0&&(t=-t>i?0:i+t),e=e>i?i:e,e<0&&(e+=i),i=t>e?0:e-t>>>0,t>>>=0;for(var o=Array(i);++r<i;)o[r]=n[r+t];return o}var yp=Bg;function Eg(){this.__data__=new Vr,this.size=0}var gp=Eg;function Gg(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var xp=Gg;function zg(n){return this.__data__.get(n)}var bp=zg;function Rg(n){return this.__data__.has(n)}var vp=Rg;var Vg=200;function Fg(n,t){var e=this.__data__;if(e instanceof Vr){var r=e.__data__;if(!Fr||r.length<Vg-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new Do(r)}return e.set(n,t),this.size=e.size,this}var Sp=Fg;function zi(n){var t=this.__data__=new Vr(n);this.size=t.size}zi.prototype.clear=gp;zi.prototype.delete=xp;zi.prototype.get=bp;zi.prototype.has=vp;zi.prototype.set=Sp;var Kn=zi;function jg(n,t){return n&&kt(t,Pi(t),n)}var wp=jg;function Ug(n,t){return n&&kt(t,nr(t),n)}var Cp=Ug;var Mp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Lp=Mp&&typeof module=="object"&&module&&!module.nodeType&&module,kg=Lp&&Lp.exports===Mp,Tp=kg?Ze.Buffer:void 0,Np=Tp?Tp.allocUnsafe:void 0;function Hg(n,t){if(t)return n.slice();var e=n.length,r=Np?Np(e):new n.constructor(e);return n.copy(r),r}var Yn=Hg;function qg(n,t){for(var e=-1,r=n==null?0:n.length,i=0,o=[];++e<r;){var s=n[e];t(s,e,n)&&(o[i++]=s)}return o}var Op=qg;function Wg(){return[]}var Xn=Wg;var $g=Object.prototype,Jg=$g.propertyIsEnumerable,Ip=Object.getOwnPropertySymbols,Kg=Ip?function(n){return n==null?[]:(n=Object(n),Op(Ip(n),function(t){return Jg.call(n,t)}))}:Xn,Ri=Kg;function Yg(n,t){return kt(n,Ri(n),t)}var Pp=Yg;var Xg=Object.getOwnPropertySymbols,Zg=Xg?function(n){for(var t=[];n;)Ei(t,Ri(n)),n=Gi(n);return t}:Xn,Zn=Zg;function Qg(n,t){return kt(n,Zn(n),t)}var Ap=Qg;function ex(n,t,e){var r=t(n);return Qe(n)?r:Ei(r,e(n))}var Qn=ex;function tx(n){return Qn(n,Pi,Ri)}var Dp=tx;function rx(n){return Qn(n,nr,Zn)}var es=rx;var ix=Ot(Ze,"DataView"),ts=ix;var ox=Ot(Ze,"Promise"),rs=ox;var nx=Ot(Ze,"Set"),is=nx;var _p="[object Map]",sx="[object Object]",Bp="[object Promise]",Ep="[object Set]",Gp="[object WeakMap]",zp="[object DataView]",ax=wr(ts),lx=wr(Fr),cx=wr(rs),px=wr(is),ux=wr(zn),ai=Bt;(ts&&ai(new ts(new ArrayBuffer(1)))!=zp||Fr&&ai(new Fr)!=_p||rs&&ai(rs.resolve())!=Bp||is&&ai(new is)!=Ep||zn&&ai(new zn)!=Gp)&&(ai=function(n){var t=Bt(n),e=t==sx?n.constructor:void 0,r=e?wr(e):"";if(r)switch(r){case ax:return zp;case lx:return _p;case cx:return Bp;case px:return Ep;case ux:return Gp}return t});var Vi=ai;var hx=Object.prototype,dx=hx.hasOwnProperty;function mx(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&dx.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Rp=mx;var fx=Ze.Uint8Array,Oa=fx;function yx(n){var t=new n.constructor(n.byteLength);return new Oa(t).set(new Oa(n)),t}var Fi=yx;function gx(n,t){var e=t?Fi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Vp=gx;var xx=/\w*$/;function bx(n){var t=new n.constructor(n.source,xx.exec(n));return t.lastIndex=n.lastIndex,t}var Fp=bx;var jp=Ct?Ct.prototype:void 0,Up=jp?jp.valueOf:void 0;function vx(n){return Up?Object(Up.call(n)):{}}var kp=vx;function Sx(n,t){var e=t?Fi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var os=Sx;var wx="[object Boolean]",Cx="[object Date]",Lx="[object Map]",Tx="[object Number]",Nx="[object RegExp]",Mx="[object Set]",Ox="[object String]",Ix="[object Symbol]",Px="[object ArrayBuffer]",Ax="[object DataView]",Dx="[object Float32Array]",_x="[object Float64Array]",Bx="[object Int8Array]",Ex="[object Int16Array]",Gx="[object Int32Array]",zx="[object Uint8Array]",Rx="[object Uint8ClampedArray]",Vx="[object Uint16Array]",Fx="[object Uint32Array]";function jx(n,t,e){var r=n.constructor;switch(t){case Px:return Fi(n);case wx:case Cx:return new r(+n);case Ax:return Vp(n,e);case Dx:case _x:case Bx:case Ex:case Gx:case zx:case Rx:case Vx:case Fx:return os(n,e);case Lx:return new r;case Tx:case Ox:return new r(n);case Nx:return Fp(n);case Mx:return new r;case Ix:return kp(n)}}var Hp=jx;function Ux(n){return typeof n.constructor=="function"&&!Mi(n)?xc(Gi(n)):{}}var ns=Ux;var kx="[object Map]";function Hx(n){return gt(n)&&Vi(n)==kx}var qp=Hx;var Wp=Cr&&Cr.isMap,qx=Wp?Ii(Wp):qp,$p=qx;var Wx="[object Set]";function $x(n){return gt(n)&&Vi(n)==Wx}var Jp=$x;var Kp=Cr&&Cr.isSet,Jx=Kp?Ii(Kp):Jp,Yp=Jx;var Kx=1,Yx=2,Xx=4,Xp="[object Arguments]",Zx="[object Array]",Qx="[object Boolean]",e0="[object Date]",t0="[object Error]",Zp="[object Function]",r0="[object GeneratorFunction]",i0="[object Map]",o0="[object Number]",Qp="[object Object]",n0="[object RegExp]",s0="[object Set]",a0="[object String]",l0="[object Symbol]",c0="[object WeakMap]",p0="[object ArrayBuffer]",u0="[object DataView]",h0="[object Float32Array]",d0="[object Float64Array]",m0="[object Int8Array]",f0="[object Int16Array]",y0="[object Int32Array]",g0="[object Uint8Array]",x0="[object Uint8ClampedArray]",b0="[object Uint16Array]",v0="[object Uint32Array]",Re={};Re[Xp]=Re[Zx]=Re[p0]=Re[u0]=Re[Qx]=Re[e0]=Re[h0]=Re[d0]=Re[m0]=Re[f0]=Re[y0]=Re[i0]=Re[o0]=Re[Qp]=Re[n0]=Re[s0]=Re[a0]=Re[l0]=Re[g0]=Re[x0]=Re[b0]=Re[v0]=!0;Re[t0]=Re[Zp]=Re[c0]=!1;function ss(n,t,e,r,i,o){var s,a=t&Kx,l=t&Yx,c=t&Xx;if(e&&(s=i?e(n,r,i,o):e(n)),s!==void 0)return s;if(!xt(n))return n;var p=Qe(n);if(p){if(s=Rp(n),!a)return Rn(n,s)}else{var u=Vi(n),h=u==Zp||u==r0;if(Oi(n))return Yn(n,a);if(u==Qp||u==Xp||h&&!i){if(s=l||h?{}:ns(n),!a)return l?Ap(n,Cp(s,n)):Pp(n,wp(s,n))}else{if(!Re[u])return i?n:{};s=Hp(n,u,a)}}o||(o=new Kn);var m=o.get(n);if(m)return m;o.set(n,s),Yp(n)?n.forEach(function(S){s.add(ss(S,t,e,S,n,o))}):$p(n)&&n.forEach(function(S,y){s.set(y,ss(S,t,e,y,n,o))});var f=c?l?es:Dp:l?nr:Pi,L=p?void 0:f(n);return Cc(L||n,function(S,y){L&&(y=S,S=n[y]),jn(s,y,ss(S,t,e,y,n,o))}),s}var as=ss;var S0=1,w0=4;function C0(n){return as(n,S0|w0)}var _o=C0;function L0(n){return function(t,e,r){for(var i=-1,o=Object(t),s=r(t),a=s.length;a--;){var l=s[n?a:++i];if(e(o[l],l,o)===!1)break}return t}}var eu=L0;var T0=eu(),tu=T0;function N0(n,t,e){(e!==void 0&&!Gr(n[t],e)||e===void 0&&!(t in n))&&Ni(n,t,e)}var Bo=N0;function M0(n){return gt(n)&&zr(n)}var ru=M0;function O0(n,t){if(!(t==="constructor"&&typeof n[t]=="function")&&t!="__proto__")return n[t]}var Eo=O0;function I0(n){return kt(n,nr(n))}var iu=I0;function P0(n,t,e,r,i,o,s){var a=Eo(n,e),l=Eo(t,e),c=s.get(l);if(c){Bo(n,e,c);return}var p=o?o(a,l,e+"",n,t,s):void 0,u=p===void 0;if(u){var h=Qe(l),m=!h&&Oi(l),f=!h&&!m&&Hn(l);p=l,h||m||f?Qe(a)?p=a:ru(a)?p=Rn(a):m?(u=!1,p=Yn(l,!0)):f?(u=!1,p=os(l,!0)):p=[]:Jn(l)||si(l)?(p=a,si(a)?p=iu(a):(!xt(a)||Li(a))&&(p=ns(l))):u=!1}u&&(s.set(l,p),i(p,l,r,o,s),s.delete(l)),Bo(n,e,p)}var ou=P0;function nu(n,t,e,r,i){n!==t&&tu(t,function(o,s){if(i||(i=new Kn),xt(o))ou(n,t,s,e,nu,r,i);else{var a=r?r(Eo(n,s),o,s+"",n,t,i):void 0;a===void 0&&(a=o),Bo(n,s,a)}},nr)}var su=nu;function A0(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var au=A0;function D0(n,t){return t.length<2?n:lp(n,yp(t,0,-1))}var lu=D0;var _0=Mc(function(n,t,e){su(n,t,e)}),li=_0;function B0(n,t){return t=Bi(t,n),n=lu(n,t),n==null||delete n[$n(au(t))]}var cu=B0;function E0(n){return Jn(n)?void 0:n}var pu=E0;var G0=1,z0=2,R0=4,V0=mp(function(n,t){var e={};if(n==null)return e;var r=!1;t=Bn(t,function(o){return o=Bi(o,n),r||(r=o.length>1),o}),kt(n,es(n),e),r&&(e=as(e,G0|z0|R0,pu));for(var i=t.length;i--;)cu(e,t[i]);return e}),ji=V0;var Ui;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(Ui||(Ui={}));var ci;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function r(o){return o.type==="PerspectiveCamera"?o.perspective.zoom:o.orthographic.zoom}i.getZoom=r})(ci||(ci={}));var uu;(e=>{function n(r,i){return r[0]===i[0]&&r[1]===i[1]}e.isEqual=n;function t(r,i,o){return[r[0]+(i[0]-r[0])*o,r[1]+(i[1]-r[1])*o]}e.lerp=t})(uu||(uu={}));var ki;(i=>{function n(o,s){return o[0]===s[0]&&o[1]===s[1]&&o[2]===s[2]}i.isEqual=n;function t(o,s){return[o[0]+s[0],o[1]+s[1],o[2]+s[2]]}i.add=t;function e(o,s){return[o[0]-s[0],o[1]-s[1],o[2]-s[2]]}i.sub=e;function r(o,s,a){return[o[0]+(s[0]-o[0])*a,o[1]+(s[1]-o[1])*a,o[2]+(s[2]-o[2])*a]}i.lerp=r})(ki||(ki={}));var hu;(e=>{function n(r,i){return r[0]===i[0]&&r[1]===i[1]&&r[2]===i[2]&&r[3]===i[3]}e.isEqual=n;function t(r,i,o){return[r[0]+(i[0]-r[0])*o,r[1]+(i[1]-r[1])*o,r[2]+(i[2]-r[2])*o,r[3]+(i[3]-r[3])*o]}e.lerp=t})(hu||(hu={}));var Ur;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,a){for(let l=0;l<16;l++)if(s[l]!==a[l])return!1;return!0}o.isEqual=t;function e(s){return s!=null?s:o.identity}o.simplify=e;function r(s,a){let l=a.slice(0);for(var c=0,p=a.length;c<p;c+=3){let u=1/(s[3]*a[c]+s[7]*a[c+1]+s[11]*a[c+2]+s[15]);l[c]=(s[0]*a[c]+s[4]*a[c+1]+s[8]*a[c+2]+s[12])*u,l[c+1]=(s[1]*a[c]+s[5]*a[c+1]+s[9]*a[c+2]+s[13])*u,l[c+2]=(s[2]*a[c]+s[6]*a[c+1]+s[10]*a[c+2]+s[14])*u}return l}o.applyMatrix4=r;function i(s,a){let l=a.slice(0);for(var c=0,p=a.length;c<p;c+=3)l[c]=s[0]*a[c]+s[4]*a[c+1]+s[8]*a[c+2],l[c+1]=s[1]*a[c]+s[5]*a[c+1]+s[9]*a[c+2],l[c+2]=s[2]*a[c]+s[6]*a[c+1]+s[10]*a[c+2];return l}o.applyMatrix3Components=i})(Ur||(Ur={}));var Et;(l=>{l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.black={r:0,g:0,b:0};function r(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}l.toRgb255a1=r;function i(c){return{r:c.r,g:c.g,b:c.b}}l.clone=i;function o(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}l.fromHex=o;function s(c,p){return c.r===p.r&&c.g===p.g&&c.b===p.b}l.equals=s;function a(c,p,u){return{r:c.r+(p.r-c.r)*u,g:c.g+(p.g-c.g)*u,b:c.b+(p.b-c.b)*u}}l.lerp=a})(Et||(Et={}));var sr;(s=>{s.white=W(P({},Et.white),{a:1});function t(a){return{r:a[0],g:a[1],b:a[2],a:a[3]}}s.from0to1=t;function e(a,l){return W(P({},Et.fromHex(a)),{a:l})}s.fromHexAndA=e;function r(a){return{r:Math.round(a.r*255),g:Math.round(a.g*255),b:Math.round(a.b*255),a:a.a}}s.toRgb255a1=r;function i(a,l){return Et.equals(a,l)&&a.a===l.a}s.equals=i;function o(a,l,c){return{r:a.r+(l.r-a.r)*c,g:a.g+(l.g-a.g)*c,b:a.b+(l.b-a.b)*c,a:a.a+(l.a-a.a)*c}}s.lerp=o})(sr||(sr={}));var ls;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(ls||(ls={}));var du;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(du||(du={}));var mu;(t=>t.defaultData={control1:[.5,.05],control2:[.1,.3]})(mu||(mu={}));var cs;(t=>{function n(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(i=>i*(1+r)),useCenter:!0}}}t.defaultData=n})(cs||(cs={}));var Ht=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let o=W(P({},r),{[t]:e});return Object.setPrototypeOf(o,Ht.prototype),o}}add(t,e){var i;let r=this.runOp({type:1,id:t,data:e});return(i=r==null?void 0:r.data)!=null?i:this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],i;r===void 0?i={type:2,id:t.id}:i={type:1,id:t.id,data:r};let{id:o,data:s}=t,a=W(P({},e),{[o]:s});return Object.setPrototypeOf(a,Ht.prototype),{data:a,actual:t,reverse:i}}else if(t.type===2){let{id:r}=t,i=e[r];if(i===void 0)return null;{let o=P({},e);return Object.setPrototypeOf(o,Ht.prototype),delete o[r],{data:o,actual:t,reverse:{type:1,id:r,data:i}}}}throw new Error("illegal arg")}};function Go(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let t=Object.getOwnPropertyNames(n);for(let e of t){let r=n[e];r&&typeof r=="object"&&Go(r)}return Object.freeze(n)}function fu(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var ps=class extends Error{};function ar(n,t,e){if(n===void 0?t===void 0?(n=0,t=10):n=t-10:t===void 0&&(t=n+10),n>t){let o=n;n=t,t=o}let r=[],i=1/(e+1);for(let o=0;o<e;o++){let s=n+(t-n)*(o+.75+Math.random()*.5)*i;r.push(s)}return r}function yu(n){return n instanceof Uint8Array||n instanceof Uint16Array||n instanceof Uint32Array||n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof Float64Array}function gu(){return typeof process<"u"}function xu(n,t){for(let e of n)t(e.id,e.data),xu(e.children,t)}function bu(n,t){t(n.id,n.data);for(let e of n.children)bu(e,t)}var qt=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,qt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Go(this[e]),e++}fillCaches0(e,r){var i;if((i=this.objCaches)!=null&&i.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 i=this.parent(e);if(i===r)return!0;e=i}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 i=this.get(e);i&&bu(i,r)}}traverse(e){xu(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),s=this.childrenArray(o),a=s.findIndex(p=>p.id===e);if(a<0)throw new Error("not expected");let l=s[a];return s=[...s],s[a]=W(P({},l),{data:r}),this.modifyArrayBy(o,s)}}modifyArrayBy(e,r){let i=e,o=r;for(;i!==null;){let a=o,l=i;if(i=this.parent(i),i===void 0)throw new Error;o=this.childrenArray(i);let c=o.findIndex(p=>p.id===l);if(c<0)throw new Error;o=[...o],o[c]=W(P({},o[c]),{children:a})}Object.setPrototypeOf(o,qt.prototype);let s=o;return s.fillCaches(),s}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:i,id:o,data:s,children:a}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.get(o)!==void 0)return null;{let l=r,c=this.childrenArray(l),p={fi:i,id:o,data:s,children:a};return c=[...c,p],c.sort((h,m)=>h.fi-m.fi),e.localIndex=c.indexOf(p),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:o}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let i=this.parent(r);if(i===void 0)return null;let o=this.childrenArray(i),s=o.findIndex(c=>c.id===r);e.localIndex=s,o=[...o];let a=o.splice(s,1)[0];return{data:this.modifyArrayBy(i,o),actual:e,reverse:W(P({type:7},a),{parent:i})}}}moveOp(e){let{parent:r,fi:i,id:o}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:o});if(r!==null){let m=r;for(;m!==null;){if(m===void 0)throw new Error;if(m===o)throw new ps("cyclic tree");m=this.parent(m)}}let s=this.parent(o);if(s===void 0)return null;let a=s,l=this.childrenArray(s),c=l.findIndex(m=>m.id===o);l=[...l];let p=l.splice(c,1)[0],u=this.modifyArrayBy(s,l);s=r,l=u.childrenArray(s);let h=p.fi;return p=W(P({},p),{fi:i}),l=[...l,p],l.sort((m,f)=>m.fi-f.fi),e.localIndex=l.indexOf(p),u=u.modifyArrayBy(s,l),{data:u,actual:e,reverse:{type:9,parent:a,fi:h,id:o}}}previous(e,r){if(r===null){let o=this.childrenArray(e);return o.length===0?null:o[o.length-1].id}let i=null;for(let o of this.childrenArray(e)){if(o.id===r)return i;i=o.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let i=this.childrenArray(r),o=i.findIndex(s=>s.id===e)+1;if(o<i.length)return i[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 i=this.childrenArray(r),o=i.findIndex(s=>s.id===e)-1;return o>=0?this.traverseSortPrevious(i[o].id):r}}getAllSorted(e){let r=[];for(let i of e){let o=this.getWithSortKey(i.id);o!==void 0&&r.push(P(P({},i),o))}r.sort((i,o)=>fu(i.sortKey,o.sortKey));for(let i of r)delete i.sortKey;return r}getWithSortKey(e){var r=e;let i=[],o=this.get(r),s=o;if(o!==void 0){for(;r;)i.splice(0,0,o.fi),r=this.parent(r),r!==null&&(o=this.get(r));return W(P({},s),{sortKey:i})}}insertBeforeHelper(e,r,i){return this.insertAfterHelper(e,this.previous(e,r),i)}insertAfterHelper(e,r,i){let o=this.childrenArray(e);if(r===null){if(o.length===0)return ar(0,i,i);{let s=o[0].fi;return ar(s-i,s,i)}}else{let s=this.get(r);if(s===void 0||this.parent(r)!==e)throw new Error("illegal args");let a=o.find(l=>l.fi>s.fi);if(a===void 0){let l=o[o.length-1].fi;return ar(l,l+i,i)}else return ar(s.fi,a.fi,i)}}};var us;(t=>{function n(e,r){if(Array.isArray(e)){let i=r.props,o={},s=[...e],a=!1;if(i)for(let l of Object.keys(i)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");o[l]=s[c],s[c]=i[l],a=!0}return a?{data:s,actual:r,reverse:{type:0,props:o}}:null}else{let i=r.props,o={},s=P({},e),a=!1;if(i)for(let l of Object.keys(i)){o[l]=s[l];let c=i[l];c===void 0?delete s[l]:s[l]=c,a=!0}return a?{data:s,actual:r,reverse:{type:0,props:o}}:null}}t.runOp=n})(us||(us={}));var $e=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,$e.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Go(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,s=o.findIndex(c=>c.id===e);if(s<0)throw new Error("not expected");let a=o[s];return o=[...o],o[s]=W(P({},a),{data:r}),this.modifyArrayBy(o)}}modifyArrayBy(e){Object.setPrototypeOf(e,$e.prototype);let r=e;return gu()||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:i,data:o}=e,s=this,a={fi:r,id:i,data:o};return s=[...s,a],s.sort((c,p)=>c.fi-p.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:r}=e,i=this,o=i.findIndex(l=>l.id===r);if(o===-1)return null;e.localIndex=o,i=[...i];let s=i.splice(o,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:P({type:4},s)}}moveOp(e){let{fi:r,id:i}=e,o=this;o=[...o];let s=o.findIndex(p=>p.id===i);if(s===-1)return null;let a=o[s].fi,l=W(P({},o[s]),{fi:r});return o[s]=l,o.sort((p,u)=>p.fi-u.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(o),actual:e,reverse:{type:6,fi:a,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let i of this){if(i.id===e)return r;r=i.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let i=this;if(e===null){if(i.length===0)return ar(0,r,r);{let o=i[0].fi;return ar(o-r,o,r)}}else{let o=this.get(e);if(o===void 0)throw new Error("illegal args");let s=i.find(a=>a.fi>o.fi);if(s===void 0){let a=i[i.length-1].fi;return ar(a,a+r,r)}else return ar(o.fi,s.fi,r)}}};var vu=Symbol(),ds=Symbol(),Hi=class{reportOp(t,e){let r=this;if(e===null)return;r._current=e.data;let i=[];for(;!(r instanceof hs);){let o=r._path,s=r._current;if(o!==""&&i.splice(0,0,o),r=r._parent,r===null)return;r.update(o,s)}r.push(i,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[ds];r&&r(),delete this._children[t]}}}},Pa=class extends Hi{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=W(P({},this._current),{[t]:e})}runOp(t){this.reportOp(t,us.runOp(this._current,t))}},Aa=class extends Hi{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current=W(P({},this._current),{[t]:e}),Object.setPrototypeOf(this._current,Ht.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},Su={get(n,t){if(t===ds)return()=>{n._parent=null};if(t===vu)return n._current;let{_current:e,_children:r}=n;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let i=r===void 0?void 0:r[t];if(i!==void 0)return i;let o=e[t],s=ms(n,t,o);return s!==o?(r===void 0&&(r={},n._children=r),r[t]=s,s):o},has(n,t){return t in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,t){let e=n._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},F0=W(P({},Su),{set(n,t,e){var i;let r={type:0,props:{[t]:(i=Ba(e))!=null?i:e}};return n.deleteChildren(t),n.runOp(r),!0},deleteProperty(n,t){let e={type:0,props:{[t]:void 0}};return n.deleteChildren(t),n.runOp(e),!0}}),j0=W(P({},Su),{set(n,t,e){return e===void 0?this.deleteProperty(n,t):(n.deleteChildren(t),n.runOp({type:1,id:t,data:e})),!0},deleteProperty(n,t){return n.runOp({type:2,id:t}),!0}}),qi=class extends Hi{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[ds]=()=>{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 a;let{_current:e,_children:r}=this,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let o=(a=e.get(t))==null?void 0:a.data,s=ms(this,t,o);return s!==o?(r===void 0&&(r={},this._children=r),r[t]=s,s):o}add(t,e,r,i,o){this.runOp({type:7,parent:t,fi:e,id:r,data:i,children:o})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let o=0;o<r.length;o++){let s=r[o];this.add(t,i[o],s.id,s.data,s.children)}}insertBefore(t,e,r){let i=this._current.insertBeforeHelper(t,e,r.length);for(let o=0;o<r.length;o++){let s=r[o];this.add(t,i[o],s.id,s.data,s.children)}}moveAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let o=0;o<r.length;o++){let s=r[o];this.move(t,i[o],s)}}moveBefore(t,e,r){let i=this._current.insertBeforeHelper(t,e,r.length);for(let o=0;o<r.length;o++){let s=r[o];this.move(t,i[o],s)}}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)}},Wi=class extends Hi{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[ds]=()=>{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 i=this._current[r].id;t(this.data(this._current[r].id),i)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return W(P({},this._current.get(t)),{data:this.data(t)})}data(t){var a;let{_current:e,_children:r}=this,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let o=(a=e.get(t))==null?void 0:a.data,s=ms(this,t,o);return s!==o?(r===void 0&&(r={},this._children=r),r[t]=s,s):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 i=0;i<e.length;i++){let o=e[i];this.add(r[i],o.id,o.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.add(r[i],o.id,o.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.move(r[i],o)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.move(r[i],o)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Ia(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&fs.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push(W(P({},t),{path:e}))}var hs=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,i){Ia(this.ts,e,t),Ia(this.actual,r,t),Ia(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function ms(n,t,e){return e instanceof qt?new qi(n,t,e):e instanceof $e?new Wi(n,t,e):e instanceof Ht?new Proxy(new Aa(n,t,e),j0):e!==null&&typeof e=="object"?yu(e)?e:new Proxy(new Pa(n,t,e),F0):e}function Da(n){let t=new hs(n);return[ms(t,"",n),t]}function _a(n,t){let[e,r]=Da(n);return t(e),r.result()}function Ba(n){return n instanceof qi||n instanceof Wi?n._current:n!==null&&typeof n=="object"?n[vu]:n}var fs;(r=>{function n(i,o){if(o.length===i.length)for(var s=0;s<i.length;){if(i[s]!==o[s])return!1;s+=1}else return!1;return!0}r.equal=n;function t(i,o,s){let a=e(s,i);if(a!==void 0&&typeof a=="object"&&a!==null){let l=P({},o);return Object.keys(a).forEach(c=>{delete l[c]}),l}else return o}r.removeOverridden=t;function e(i,o,s=0){if(o.length<=s)return i;if((i instanceof qt||i instanceof qi)&&typeof o[s]=="string")return e(i.data(o[s]),o,s+1);if((i instanceof $e||i instanceof Wi)&&typeof o[s]=="string")return e(i.data(o[s]),o,s+1);if(typeof o[s]=="number"&&Array.isArray(i))return e(i[o[s]],o,s+1);if(typeof o[s]=="string"&&typeof i=="object")return e(i[o[s]],o,s+1)}r.zoom=e})(fs||(fs={}));var ys=class{},zo=class extends ys{constructor(e){super();this.id=e}},Ro=class extends ys{constructor(e){super();this.data=e}};var Ga;try{Ga=new TextDecoder}catch{}var ee,Hr,v=0;var Iu=[],za=Iu,Ra=0,It={},Oe,kr,Wt=0,lr=0,Gt,Tr,Lt=[],Ie,wu={useRecords:!1,mapsAsObjects:!0},Vo=class{},Fa=new Vo;Fa.name="MessagePack 0xC1";var $i=!1,cr=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(ee)return Bu(()=>(xs(),this?this.unpack(t,e):cr.prototype.unpack.call(wu,t,e)));Hr=e>-1?e:t.length,v=0,Ra=0,lr=0,kr=null,za=Iu,Gt=null,ee=t;try{Ie=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw ee=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 cr){if(It=this,this.structures)return Oe=this.structures,gs();(!Oe||Oe.length>0)&&(Oe=[])}else It=wu,(!Oe||Oe.length>0)&&(Oe=[]);return gs()}unpackMultiple(t,e){let r,i=0;try{$i=!0;let o=t.length,s=this?this.unpack(t,o):Ss.unpack(t,o);if(e){for(e(s);v<o;)if(i=v,e(gs())===!1)return}else{for(r=[s];v<o;)i=v,r.push(gs());return r}}catch(o){throw o.lastPosition=i,o.values=r,o}finally{$i=!1,xs()}}_mergeStructures(t,e){t=t||[];for(let r=0,i=t.length;r<i;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 i=t[r],o=e[r];o&&(i&&((t.restoreStructures||(t.restoreStructures=[]))[r]=i),t[r]=o)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function gs(){try{if(!It.trusted&&!$i){let t=Oe.sharedLength||0;t<Oe.length&&(Oe.length=t)}let n=Je();if(v==Hr)Oe.restoreStructures&&Cu(),Oe=null,ee=null,Tr&&(Tr=null);else if(v>Hr){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!$i)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Oe.restoreStructures&&Cu(),xs(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Cu(){for(let n in Oe.restoreStructures)Oe[n]=Oe.restoreStructures[n];Oe.restoreStructures=null}function Je(){let n=ee[v++];if(n<160)if(n<128){if(n<64)return n;{let t=Oe[n&63]||It.getStructures&&Pu()[n&63];return t?(t.read||(t.read=ja(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,It.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Du()]=Je();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(Je(),Je());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=Je();return t}else if(n<192){let t=n-160;if(lr>=v)return kr.slice(v-Wt,(v+=t)-Wt);if(lr==0&&Hr<140){let e=t<16?Ua(t):Au(t);if(e!=null)return e}return Va(t)}else{let t;switch(n){case 192:return null;case 193:return Gt?(t=Je(),t>0?Gt[1].slice(Gt.position1,Gt.position1+=t):Gt[0].slice(Gt.position0,Gt.position0-=t)):Fa;case 194:return!1;case 195:return!0;case 196:return Ea(ee[v++]);case 197:return t=Ie.getUint16(v),v+=2,Ea(t);case 198:return t=Ie.getUint32(v),v+=4,Ea(t);case 199:return pi(ee[v++]);case 200:return t=Ie.getUint16(v),v+=2,pi(t);case 201:return t=Ie.getUint32(v),v+=4,pi(t);case 202:if(t=Ie.getFloat32(v),It.useFloat32>2){let e=vs[(ee[v]&127)<<1|ee[v+1]>>7];return v+=4,(e*t+(t>0?.5:-.5)>>0)/e}return v+=4,t;case 203:return t=Ie.getFloat64(v),v+=8,t;case 204:return ee[v++];case 205:return t=Ie.getUint16(v),v+=2,t;case 206:return t=Ie.getUint32(v),v+=4,t;case 207:return It.int64AsNumber?(t=Ie.getUint32(v)*4294967296,t+=Ie.getUint32(v+4)):t=Ie.getBigUint64(v),v+=8,t;case 208:return Ie.getInt8(v++);case 209:return t=Ie.getInt16(v),v+=2,t;case 210:return t=Ie.getInt32(v),v+=4,t;case 211:return It.int64AsNumber?(t=Ie.getInt32(v)*4294967296,t+=Ie.getUint32(v+4)):t=Ie.getBigInt64(v),v+=8,t;case 212:if(t=ee[v++],t==114)return Ou(ee[v++]&63);{let e=Lt[t];if(e)return e.read?(v++,e.read(Je())):e.noBuffer?(v++,e()):e(ee.subarray(v,++v));throw new Error("Unknown extension "+t)}case 213:return t=ee[v],t==114?(v++,Ou(ee[v++]&63,ee[v++])):pi(2);case 214:return pi(4);case 215:return pi(8);case 216:return pi(16);case 217:return t=ee[v++],lr>=v?kr.slice(v-Wt,(v+=t)-Wt):k0(t);case 218:return t=Ie.getUint16(v),v+=2,lr>=v?kr.slice(v-Wt,(v+=t)-Wt):H0(t);case 219:return t=Ie.getUint32(v),v+=4,lr>=v?kr.slice(v-Wt,(v+=t)-Wt):q0(t);case 220:return t=Ie.getUint16(v),v+=2,Tu(t);case 221:return t=Ie.getUint32(v),v+=4,Tu(t);case 222:return t=Ie.getUint16(v),v+=2,Nu(t);case 223:return t=Ie.getUint32(v),v+=4,Nu(t);default:if(n>=224)return n-256;if(n===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+n)}}}var U0=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function ja(n,t){function e(){if(e.count++>2){let i=n.read=new Function("r","return function(){return {"+n.map(o=>U0.test(o)?o+":r()":"["+JSON.stringify(o)+"]:r()").join(",")+"}}")(Je);return n.highByte===0&&(n.read=Lu(t,n.read)),i()}let r={};for(let i=0,o=n.length;i<o;i++){let s=n[i];r[s]=Je()}return r}return e.count=0,n.highByte===0?Lu(t,e):e}var Lu=(n,t)=>function(){let e=ee[v++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),i=Oe[r]||Pu()[r];if(!i)throw new Error("Record id is not defined for "+r);return i.read||(i.read=ja(i,n)),i.read()};function Pu(){let n=Bu(()=>(ee=null,It.getStructures()));return Oe=It._mergeStructures(n,Oe)}var Va=bs,k0=bs,H0=bs,q0=bs;function bs(n){let t;if(n<16&&(t=Ua(n)))return t;if(n>64&&Ga)return Ga.decode(ee.subarray(v,v+=n));let e=v+n,r=[];for(t="";v<e;){let i=ee[v++];if((i&128)===0)r.push(i);else if((i&224)===192){let o=ee[v++]&63;r.push((i&31)<<6|o)}else if((i&240)===224){let o=ee[v++]&63,s=ee[v++]&63;r.push((i&31)<<12|o<<6|s)}else if((i&248)===240){let o=ee[v++]&63,s=ee[v++]&63,a=ee[v++]&63,l=(i&7)<<18|o<<12|s<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(i);r.length>=4096&&(t+=nt.apply(String,r),r.length=0)}return r.length>0&&(t+=nt.apply(String,r)),t}function Tu(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=Je();return t}function Nu(n){if(It.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Du()]=Je();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(Je(),Je());return t}}var nt=String.fromCharCode;function Au(n){let t=v,e=new Array(n);for(let r=0;r<n;r++){let i=ee[v++];if((i&128)>0){v=t;return}e[r]=i}return nt.apply(String,e)}function Ua(n){if(n<4)if(n<2){if(n===0)return"";{let t=ee[v++];if((t&128)>1){v-=1;return}return nt(t)}}else{let t=ee[v++],e=ee[v++];if((t&128)>0||(e&128)>0){v-=2;return}if(n<3)return nt(t,e);let r=ee[v++];if((r&128)>0){v-=3;return}return nt(t,e,r)}else{let t=ee[v++],e=ee[v++],r=ee[v++],i=ee[v++];if((t&128)>0||(e&128)>0||(r&128)>0||(i&128)>0){v-=4;return}if(n<6){if(n===4)return nt(t,e,r,i);{let o=ee[v++];if((o&128)>0){v-=5;return}return nt(t,e,r,i,o)}}else if(n<8){let o=ee[v++],s=ee[v++];if((o&128)>0||(s&128)>0){v-=6;return}if(n<7)return nt(t,e,r,i,o,s);let a=ee[v++];if((a&128)>0){v-=7;return}return nt(t,e,r,i,o,s,a)}else{let o=ee[v++],s=ee[v++],a=ee[v++],l=ee[v++];if((o&128)>0||(s&128)>0||(a&128)>0||(l&128)>0){v-=8;return}if(n<10){if(n===8)return nt(t,e,r,i,o,s,a,l);{let c=ee[v++];if((c&128)>0){v-=9;return}return nt(t,e,r,i,o,s,a,l,c)}}else if(n<12){let c=ee[v++],p=ee[v++];if((c&128)>0||(p&128)>0){v-=10;return}if(n<11)return nt(t,e,r,i,o,s,a,l,c,p);let u=ee[v++];if((u&128)>0){v-=11;return}return nt(t,e,r,i,o,s,a,l,c,p,u)}else{let c=ee[v++],p=ee[v++],u=ee[v++],h=ee[v++];if((c&128)>0||(p&128)>0||(u&128)>0||(h&128)>0){v-=12;return}if(n<14){if(n===12)return nt(t,e,r,i,o,s,a,l,c,p,u,h);{let m=ee[v++];if((m&128)>0){v-=13;return}return nt(t,e,r,i,o,s,a,l,c,p,u,h,m)}}else{let m=ee[v++],f=ee[v++];if((m&128)>0||(f&128)>0){v-=14;return}if(n<15)return nt(t,e,r,i,o,s,a,l,c,p,u,h,m,f);let L=ee[v++];if((L&128)>0){v-=15;return}return nt(t,e,r,i,o,s,a,l,c,p,u,h,m,f,L)}}}}}function Ea(n){return It.copyBuffers?Uint8Array.prototype.slice.call(ee,v,v+=n):ee.subarray(v,v+=n)}function pi(n){let t=ee[v++];if(Lt[t])return Lt[t](ee.subarray(v,v+=n));throw new Error("Unknown extension type "+t)}var Mu=new Array(4096);function Du(){let n=ee[v++];if(n>=160&&n<192){if(n=n-160,lr>=v)return kr.slice(v-Wt,(v+=n)-Wt);if(!(lr==0&&Hr<180))return Va(n)}else return v--,Je();let t=(n<<5^(n>1?Ie.getUint16(v):n>0?ee[v]:0))&4095,e=Mu[t],r=v,i=v+n-3,o,s=0;if(e&&e.bytes==n){for(;r<i;){if(o=Ie.getUint32(r),o!=e[s++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(o=ee[r++],o!=e[s++]){r=1879048192;break}if(r===i)return v=r,e.string;i-=3,r=v}for(e=[],Mu[t]=e,e.bytes=n;r<i;)o=Ie.getUint32(r),e.push(o),r+=4;for(i+=3;r<i;)o=ee[r++],e.push(o);let a=n<16?Ua(n):Au(n);return a!=null?e.string=a:e.string=Va(n)}var Ou=(n,t)=>{var e=Je();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let i=Oe[n];return i&&i.isShared&&((Oe.restoreStructures||(Oe.restoreStructures=[]))[n]=i),Oe[n]=e,e.read=ja(e,r),e.read()},_u=typeof self=="object"?self:global;Lt[0]=()=>{};Lt[0].noBuffer=!0;Lt[101]=()=>{let n=Je();return(_u[n[0]]||Error)(n[1])};Lt[105]=n=>{let t=Ie.getUint32(v-4);Tr||(Tr=new Map);let e=ee[v],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let i={target:r};Tr.set(t,i);let o=Je();return i.used?Object.assign(r,o):(i.target=o,o)};Lt[112]=n=>{let t=Ie.getUint32(v-4),e=Tr.get(t);return e.used=!0,e.target};Lt[115]=()=>new Set(Je());var ka=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");Lt[116]=n=>{let t=n[0],e=ka[t];if(!e)throw new Error("Could not find typed array for code "+t);return new _u[e](Uint8Array.prototype.slice.call(n,1).buffer)};Lt[120]=()=>{let n=Je();return new RegExp(n[0],n[1])};Lt[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=v;v+=t-4,Gt=[Je(),Je()],Gt.position0=0,Gt.position1=0;let r=v;v=e;try{return Je()}finally{v=r}};Lt[255]=n=>n.length==4?new Date((n[0]*16777216+(n[1]<<16)+(n[2]<<8)+n[3])*1e3):n.length==8?new Date(((n[0]<<22)+(n[1]<<14)+(n[2]<<6)+(n[3]>>2))/1e6+((n[3]&3)*4294967296+n[4]*16777216+(n[5]<<16)+(n[6]<<8)+n[7])*1e3):n.length==12?new Date(((n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3])/1e6+((n[4]&128?-281474976710656:0)+n[6]*1099511627776+n[7]*4294967296+n[8]*16777216+(n[9]<<16)+(n[10]<<8)+n[11])*1e3):new Date("invalid");function Bu(n){let t=Hr,e=v,r=Ra,i=Wt,o=lr,s=kr,a=za,l=Tr,c=Gt,p=new Uint8Array(ee.slice(0,Hr)),u=Oe,h=Oe.slice(0,Oe.length),m=It,f=$i,L=n();return Hr=t,v=e,Ra=r,Wt=i,lr=o,kr=s,za=a,Tr=l,Gt=c,ee=p,$i=f,Oe=u,Oe.splice(0,Oe.length,...h),It=m,Ie=new DataView(ee.buffer,ee.byteOffset,ee.byteLength),L}function xs(){ee=null,Tr=null,Oe=null}function Eu(n){n.unpack?Lt[n.type]=n.unpack:Lt[n.type]=n}var vs=new Array(147);for(let n=0;n<256;n++)vs[n]=+("1e"+Math.floor(45.15-n*.30103));var Ss=new cr({useRecords:!1}),W0=Ss.unpack,$0=Ss.unpackMultiple,J0=Ss.unpack,ws={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},K0=new Float32Array(1),dP=new Uint8Array(K0.buffer,0,4);var Cs;try{Cs=new TextEncoder}catch{}var Ls,qa,Ts=typeof Buffer<"u",Ha=Ts?Buffer.allocUnsafeSlow:Uint8Array,Vu=Ts?Buffer:Uint8Array,Gu=Ts?4294967296:2144337920,E,Ke,N=0,pr,ur=null,Y0=/[\u0080-\uFFFF]/,Fo=Symbol("record-id"),ui=class extends cr{constructor(t){super(t),this.offset=0;let e,r,i,o,s,a,l=0,c=Vu.prototype.utf8Write?function(d,O,x){return E.utf8Write(d,O,x)}:Cs&&Cs.encodeInto?function(d,O){return Cs.encodeInto(d,E.subarray(O)).written}:!1,p=this;t||(t={});let u=t&&t.sequential,h=t.structures||t.saveStructures,m=t.maxSharedStructures;if(m==null&&(m=h?32:0),m>8160)throw new Error("Maximum maxSharedStructure is 8160");let f=t.maxOwnStructures;f==null&&(f=h?32:64),u&&!t.saveStructures&&(this.structures=[]);let L=m>32||f+m>64,S=m+64,y=m+f+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let w=[],I=0,_=0;this.pack=this.encode=function(d,O){if(E||(E=new Ha(8192),Ke=new DataView(E.buffer,0,8192),N=0),pr=E.length-10,pr-N<2048?(E=new Ha(E.length),Ke=new DataView(E.buffer,0,E.length),pr=E.length-10,N=0):N=N+7&2147483640,r=N,a=p.structuredClone?new Map:null,p.bundleStrings?(ur=["",""],E[N++]=214,E[N++]=98,ur.position=N-r,N+=4):ur=null,i=p.structures,i){i.uninitialized&&(i=p._mergeStructures(p.getStructures()));let x=i.sharedLength||0;if(x>m)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let M=0;M<x;M++){let C=i[M];if(!C)continue;let T,$=i.transitions;for(let H=0,ie=C.length;H<ie;H++){let pe=C[H];T=$[pe],T||(T=$[pe]=Object.create(null)),$=T}$[Fo]=M+64}l=x}u||(i.nextId=x+64)}o&&(o=!1),s=i||[];try{if(g(d),ur){Ke.setUint32(ur.position+r,N-ur.position-r);let x=ur;ur=null,g(x[0]),g(x[1])}if(p.offset=N,a&&a.idsToInsert){N+=a.idsToInsert.length*6,N>pr&&b(N),p.offset=N;let x=Z0(E.subarray(r,N),a.idsToInsert);return a=null,x}return O&ju?(E.start=r,E.end=N,E):E.subarray(r,N)}finally{if(i){if(_<10&&_++,I>1e4)i.transitions=null,_=0,I=0,w.length>0&&(w=[]);else if(w.length>0&&!u){for(let x=0,M=w.length;x<M;x++)w[x][Fo]=0;w=[]}if(o&&p.saveStructures){let x=i.sharedLength||m;i.length>x&&(i=i.slice(0,x));let M=E.subarray(r,N);return p.saveStructures(i,l)===!1?(p._mergeStructures(p.getStructures()),p.pack(d)):(l=x,M)}}O&nb&&(N=r)}};let g=d=>{N>pr&&(E=b(N));var O=typeof d,x;if(O==="string"){let M=d.length;if(ur&&M>=8&&M<4096){let $=Y0.test(d);ur[$?0:1]+=d,E[N++]=193,g($?-M:M);return}let C;M<32?C=1:M<256?C=2:M<65536?C=3:C=5;let T=M*3;if(N+T>pr&&(E=b(N+T)),M<64||!c){let $,H,ie,pe=N+C;for($=0;$<M;$++)H=d.charCodeAt($),H<128?E[pe++]=H:H<2048?(E[pe++]=H>>6|192,E[pe++]=H&63|128):(H&64512)===55296&&((ie=d.charCodeAt($+1))&64512)===56320?(H=65536+((H&1023)<<10)+(ie&1023),$++,E[pe++]=H>>18|240,E[pe++]=H>>12&63|128,E[pe++]=H>>6&63|128,E[pe++]=H&63|128):(E[pe++]=H>>12|224,E[pe++]=H>>6&63|128,E[pe++]=H&63|128);x=pe-N-C}else x=c(d,N+C,T);x<32?E[N++]=160|x:x<256?(C<2&&E.copyWithin(N+2,N+1,N+1+x),E[N++]=217,E[N++]=x):x<65536?(C<3&&E.copyWithin(N+3,N+2,N+2+x),E[N++]=218,E[N++]=x>>8,E[N++]=x&255):(C<5&&E.copyWithin(N+5,N+3,N+3+x),E[N++]=219,Ke.setUint32(N,x),N+=4),N+=x}else if(O==="number")if(d>>>0===d)d<64?E[N++]=d:d<256?(E[N++]=204,E[N++]=d):d<65536?(E[N++]=205,E[N++]=d>>8,E[N++]=d&255):(E[N++]=206,Ke.setUint32(N,d),N+=4);else if(d>>0===d)d>=-32?E[N++]=256+d:d>=-128?(E[N++]=208,E[N++]=d+256):d>=-32768?(E[N++]=209,Ke.setInt16(N,d),N+=2):(E[N++]=210,Ke.setInt32(N,d),N+=4);else{let M;if((M=this.useFloat32)>0&&d<4294967296&&d>=-2147483648){E[N++]=202,Ke.setFloat32(N,d);let C;if(M<4||(C=d*vs[(E[N]&127)<<1|E[N+1]>>7])>>0===C){N+=4;return}else N--}E[N++]=203,Ke.setFloat64(N,d),N+=8}else if(O==="object")if(!d)E[N++]=192;else{if(a){let C=a.get(d);if(C){if(!C.id){let T=a.idsToInsert||(a.idsToInsert=[]);C.id=T.push(C)}E[N++]=214,E[N++]=112,Ke.setUint32(N,C.id),N+=4;return}else a.set(d,{offset:N-r})}let M=d.constructor;if(M===Object)V(d,!0);else if(M===Array){x=d.length,x<16?E[N++]=144|x:x<65536?(E[N++]=220,E[N++]=x>>8,E[N++]=x&255):(E[N++]=221,Ke.setUint32(N,x),N+=4);for(let C=0;C<x;C++)g(d[C])}else if(M===Map){x=d.size,x<16?E[N++]=128|x:x<65536?(E[N++]=222,E[N++]=x>>8,E[N++]=x&255):(E[N++]=223,Ke.setUint32(N,x),N+=4);for(let[C,T]of d)g(C),g(T)}else{for(let C=0,T=Ls.length;C<T;C++){let $=qa[C];if(d instanceof $){let H=Ls[C];if(H.write){H.type&&(E[N++]=212,E[N++]=H.type,E[N++]=0),g(H.write.call(this,d));return}let ie=E,pe=Ke,ce=N;E=null;let be;try{be=H.pack.call(this,d,F=>(E=ie,ie=null,N+=F,N>pr&&b(N),{target:E,targetView:Ke,position:N-F}),g)}finally{ie&&(E=ie,Ke=pe,N=ce,pr=E.length-10)}be&&(be.length+N>pr&&b(be.length+N),N=X0(be,E,N,H.type));return}}V(d,!d.hasOwnProperty)}}else if(O==="boolean")E[N++]=d?195:194;else if(O==="bigint"){if(d<BigInt(1)<<BigInt(63)&&d>=-(BigInt(1)<<BigInt(63)))E[N++]=211,Ke.setBigInt64(N,d);else if(d<BigInt(1)<<BigInt(64)&&d>0)E[N++]=207,Ke.setBigUint64(N,d);else if(this.largeBigIntToFloat)E[N++]=203,Ke.setFloat64(N,Number(d));else throw new RangeError(d+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");N+=8}else if(O==="undefined")this.encodeUndefinedAsNil?E[N++]=192:(E[N++]=212,E[N++]=0,E[N++]=0);else if(O==="function")g(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+O)},V=this.useRecords===!1?this.variableMapSize?d=>{let O=Object.keys(d),x=O.length;x<16?E[N++]=128|x:x<65536?(E[N++]=222,E[N++]=x>>8,E[N++]=x&255):(E[N++]=223,Ke.setUint32(N,x),N+=4);let M;for(let C=0;C<x;C++)g(M=O[C]),g(d[M])}:(d,O)=>{E[N++]=222;let x=N-r;N+=2;let M=0;for(let C in d)(O||d.hasOwnProperty(C))&&(g(C),g(d[C]),M++);E[x+++r]=M>>8,E[x+r]=M&255}:d=>{let O=Object.keys(d),x,M=s.transitions||(s.transitions=Object.create(null)),C=0;for(let $=0,H=O.length;$<H;$++){let ie=O[$];x=M[ie],x||(x=M[ie]=Object.create(null),C++),M=x}let T=M[Fo];if(T)T>=96&&L?(E[N++]=((T-=96)&31)+96,E[N++]=T>>5):E[N++]=T;else{T=s.nextId,T||(T=64),T<S&&this.shouldShareStructure&&!this.shouldShareStructure(O)?(T=s.nextOwnId,T<y||(T=S),s.nextOwnId=T+1):(T>=y&&(T=S),s.nextId=T+1);let $=O.highByte=T>=96&&L?T-96>>5:-1;M[Fo]=T,s[T-64]=O,T<S?(O.isShared=!0,s.sharedLength=T-63,o=!0,$>=0?(E[N++]=(T&31)+96,E[N++]=$):E[N++]=T):($>=0?(E[N++]=213,E[N++]=114,E[N++]=(T&31)+96,E[N++]=$):(E[N++]=212,E[N++]=114,E[N++]=T),C&&(I+=_*C),w.length>=f&&(w.shift()[Fo]=0),w.push(M),g(O))}for(let $=0,H=O.length;$<H;$++)g(d[O[$]])},b=d=>{let O;if(d>16777216){if(d-r>Gu)throw new Error("Packed buffer would be larger than maximum buffer size");O=Math.min(Gu,Math.round(Math.max((d-r)*(d>67108864?1.25:2),4194304)/4096)*4096)}else O=(Math.max(d-r<<2,E.length-1)>>12)+1<<12;let x=new Ha(O);return Ke=new DataView(x.buffer,0,O),E.copy?E.copy(x,0,r,d):x.set(E.slice(r,d)),N-=r,r=0,pr=x.length-10,E=x}}useBuffer(t){E=t,Ke=new DataView(E.buffer,E.byteOffset,E.byteLength),N=0}};qa=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Vo];Ls=[{pack(n,t,e){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:i,targetView:o,position:s}=t(6);i[s++]=214,i[s++]=255,o.setUint32(s,r)}else if(r>0&&r<17179869184){let{target:i,targetView:o,position:s}=t(10);i[s++]=215,i[s++]=255,o.setUint32(s,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),o.setUint32(s+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:i,targetView:o,position:s}=t(3);i[s++]=212,i[s++]=255,i[s++]=255}else{let{target:i,targetView:o,position:s}=t(15);i[s++]=199,i[s++]=12,i[s++]=255,o.setUint32(s,n.getMilliseconds()*1e6),o.setBigInt64(s+4,BigInt(Math.floor(r)))}}},{pack(n,t,e){let r=Array.from(n),{target:i,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(i[o++]=212,i[o++]=115,i[o++]=0),e(r)}},{pack(n,t,e){let{target:r,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=101,r[i++]=0),e([n.name,n.message])}},{pack(n,t,e){let{target:r,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=120,r[i++]=0),e([n.source,n.flags])}},{pack(n,t){this.structuredClone?zu(n,16,t):Ru(Ts?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==Vu&&this.structuredClone?zu(n,ka.indexOf(e.name),t):Ru(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function zu(n,t,e,r){let i=n.byteLength;if(i+1<256){var{target:o,position:s}=e(4+i);o[s++]=199,o[s++]=i+1}else if(i+1<65536){var{target:o,position:s}=e(5+i);o[s++]=200,o[s++]=i+1>>8,o[s++]=i+1&255}else{var{target:o,position:s,targetView:a}=e(7+i);o[s++]=201,a.setUint32(s,i+1),s+=4}o[s++]=116,o[s++]=t,o.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),s)}function Ru(n,t){let e=n.byteLength;var r,i;if(e<256){var{target:r,position:i}=t(e+2);r[i++]=196,r[i++]=e}else if(e<65536){var{target:r,position:i}=t(e+3);r[i++]=197,r[i++]=e>>8,r[i++]=e&255}else{var{target:r,position:i,targetView:o}=t(e+5);r[i++]=198,o.setUint32(i,e),i+=4}r.set(n,i)}function X0(n,t,e,r){let i=n.length;switch(i){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:i<256?(t[e++]=199,t[e++]=i):i<65536?(t[e++]=200,t[e++]=i>>8,t[e++]=i&255):(t[e++]=201,t[e++]=i>>24,t[e++]=i>>16&255,t[e++]=i>>8&255,t[e++]=i&255)}return t[e++]=r,t.set(n,e),e+=i,e}function Z0(n,t){let e,r=t.length*6,i=n.length-r;for(t.sort((o,s)=>o.offset>s.offset?1:-1);e=t.pop();){let o=e.offset,s=e.id;n.copyWithin(o+r,o,i),r-=6;let a=o+r;n[a++]=214,n[a++]=105,n[a++]=s>>24,n[a++]=s>>16&255,n[a++]=s>>8&255,n[a++]=s&255,i=o}return n}function hi(n){if(n.Class){if(!n.pack&&!n.write)throw new Error("Extension has no pack or write function");if(n.pack&&!n.type)throw new Error("Extension has no type (numeric code to identify the extension)");qa.unshift(n.Class),Ls.unshift(n)}Eu(n)}var Fu=new ui({useRecords:!1}),Q0=Fu.pack,eb=Fu.pack;var{NEVER:tb,ALWAYS:rb,DECIMAL_ROUND:ib,DECIMAL_FIT:ob}=ws,ju=512,nb=1024;var Uu=new ui({structuredClone:!0});hi({Class:Ht.prototype.constructor,type:1,write(n){return P({},n)},read(n){return Object.setPrototypeOf(n,Ht.prototype),n}});hi({Class:$e.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,$e.prototype),n}});hi({Class:qt.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,qt.prototype),n}});hi({Class:zo.prototype.constructor,type:4,write(n){return n.id},read(n){return new zo(n)}});hi({Class:Ro.prototype.constructor,type:5,write(n){return n.data},read(n){return new Ro(n)}});function sb(n){var t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){let r=n[e];t=(t<<5)-t+r,t=t&t}return t}var Ns;(r=>{function n(i){return Uu.pack(i)}r.serialize=n;function t(i){return Uu.unpack(i)}r.deserialize=t;function e(i){return sb(n(i)).toString()}r.checksum=e})(Ns||(Ns={}));var Ms;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Ms||(Ms={}));var Os;(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:sr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:2500,helper:!0};if(r==="SpotLight")return{type:r,color:sr.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:sr.white,intensity:1,shadows:!0,size:2500,depth:2500,helper:!0};throw new Error("not implemented")}})(Os||(Os={}));var Wa;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,i){return r.castShadow===i.castShadow&&r.receiveShadow===i.receiveShadow}e.equals=t})(Wa||(Wa={}));var $a;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,i){return r.flatShading===i.flatShading&&r.side===i.side&&r.wireframe===i.wireframe}e.equals=t})($a||($a={}));var Is;(t=>t.defaultData=W(P(P({},$a.defaultData),Wa.defaultData),{cloner:null}))(Is||(Is={}));var Ja=(i=>(i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.Center=3]="Center",i[i.Justify=4]="Justify",i))(Ja||{}),Ka=(r=>(r[r.Top=1]="Top",r[r.Center=2]="Center",r[r.Bottom=3]="Bottom",r))(Ka||{}),Ya=(r=>(r[r.None=1]="None",r[r.Upper=2]="Upper",r[r.Lower=3]="Lower",r))(Ya||{}),Ps;(t=>t.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:sr.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"})(Ps||(Ps={}));var Ji;(r=>{function n(i,o){return i==="light"&&o?t(o):e(i)}r.defaultData=n;function t(i){switch(i){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(i){switch(i){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:Et.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:W(P({},Et.fromHex(6710886)),{a:1}),colorB:W(P({},Et.fromHex(6710886)),{a:1}),colorC:W(P({},Et.fromHex(16777215)),{a:1}),colorD:W(P({},Et.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:sr.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}}}})(Ji||(Ji={}));var Ki;(a=>{function n(l){return!l.layers.some(p=>{if(p.data.type==="texture"&&p.data.projection!==0||p.data.type==="depth"&&!p.data.isWorldSpace||p.data.type==="noise"||p.data.type==="displace")return!0})&&!e(l)}a.isMergable=n;function t(l){let c="";return l.layers.forEach(p=>{Object.entries(p.data).forEach(([u,h])=>{c+=`${u}${h}`,Array.isArray(h)?h.forEach(m=>c+=`${m}`):typeof h=="object"?Object.values(h).forEach(m=>{typeof m=="number"?c+=`${m.toFixed(4)}`:c+=`${m}`}):c+=`${h}`})}),c}a.getHash=t;function e(l){let c=0;for(let p of l.layers)"alpha"in p.data&&p.data.type!=="light"&&p.data.type!=="fresnel"&&(c+=(1-c)*p.data.alpha);return c<1}a.isTransparent=e;function r(){return{layers:new $e}}a.defaultEmptyData=r;function i(l="layer1",c="layer2"){return o("phong",l,c)}a.defaultData=i;function o(l,c="layer1",p="layer2"){let u=new $e;return u.push({fi:0,data:Ji.defaultData("light",l),id:c}),u.push({fi:1,data:Ji.defaultData("color"),id:p}),{layers:u}}a.defaultTwoLayerData=o;function s(l,c="basic",p="layer1",u="layer2"){let h=Ji.defaultData("texture");Object.assign(h.texture,{image:l});let m=new $e;return m.push({fi:0,data:h,id:p}),m.push({fi:1,data:Ji.defaultData("light",c),id:u}),{layers:m}}a.defaultTwoLayerTextureData=s})(Ki||(Ki={}));var Yi;(r=>{function n(){return{points:new $e,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n;function t(i,o){let{points:s}=o;if(s){for(let a of s)if(a.data.position[0]===i[0]&&a.data.position[1]===i[1])return!0}return!1}r.isOverlappingExistingPoint=t;function e(i,o){let s=i.controlNext,a=o.controlPrevious;return i.position[0]===s.position[0]&&i.position[1]===s.position[1]&&o.position[0]===a.position[0]&&o.position[1]===a.position[1]}r.isStraightLine=e})(Yi||(Yi={}));var As;(t=>{function n(e){return e==="PolygonGeometry"||e==="RectangleGeometry"||e==="StarGeometry"||e==="TriangleGeometry"||e==="EllipseGeometry"}t.is2DParametricMesh=n})(As||(As={}));var Ds;(t=>{function n(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:Yi.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};throw new Error("not implemented")}t.defaultData=n})(Ds||(Ds={}));var jo;(i=>{i.identity=W(P({},ls.identity),{hiddenMatrix:Ur.identity});function t(o){return{position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix}}i.fromObject=t;function e(o,s){return{position:(s==null?void 0:s.position)||o.position,rotation:(s==null?void 0:s.rotation)||o.rotation,scale:(s==null?void 0:s.scale)||o.scale,hiddenMatrix:(s==null?void 0:s.hiddenMatrix)||o.hiddenMatrix}}i.merge=e;function r(o,s){return{position:ki.isEqual(o.position,s.position)?null:s.position,rotation:ki.isEqual(o.rotation,s.rotation)?null:s.rotation,scale:ki.isEqual(o.scale,s.scale)?null:s.scale,hiddenMatrix:Ur.isEqual(o.hiddenMatrix,s.hiddenMatrix)?null:s.hiddenMatrix}}i.diff=r})(jo||(jo={}));var qr;(t=>t.defaultData=P({states:new $e,events:new $e,visible:!0,raycastLock:!1},jo.identity))(qr||(qr={}));var ku;(t=>t.defaultData=P({type:"Empty"},qr.defaultData))(ku||(ku={}));var Xa;(t=>t.defaultData=P(P({type:"Mesh"},qr.defaultData),Is.defaultData))(Xa||(Xa={}));var Hu;(t=>t.defaultData=P(P({type:"TextFrame"},qr.defaultData),Ps.defaultData))(Hu||(Hu={}));var _s;(t=>t.defaultData=P(P(P({},qr.defaultData),jo.identity),ci.defaultData))(_s||(_s={}));var qu;(t=>{function n(e){return P(P({},qr.defaultData),Os.defaultData(e))}t.defaultData=n})(qu||(qu={}));var Wu;(e=>(e.defaultCamera=P({position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Ur.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new $e,events:new $e},ci.defaultData),e.defaultMeshObject=W(P(P({name:"Rectangle"},qr.defaultData),Xa.defaultData),{geometry:Ds.defaultData("RectangleGeometry"),material:Ki.defaultTwoLayerData("basic","layer1","layer2")})))(Wu||(Wu={}));var $u;(e=>{function n(r,i){if(i===void 0)return r;let o=P({},r);return"material"in o&&"material"in i&&i.material&&(o.material=_a(o.material,s=>{if(typeof s!="string")for(let[a,l]of Object.entries(i.material.layers)){let c=s.layers.data(a);c&&li(c,l)}}).data),o.materials&&i.materials&&(o.materials=_a(o.materials,s=>{var a,l;for(let c=0;c<o.materials.length;c++){let p=i.materials[c];if(typeof p!="string")for(let[u,h]of Object.entries(p.layers)){let m=(l=(a=s[c])==null?void 0:a.layers)==null?void 0:l.data(u);m&&li(m,h)}}}).data),o}e.patchMaterialState=n;function t(r,i){var s,a;if(i===void 0)return r;let o=P({},r);if(Object.assign(o,jo.merge(o,i)),Ui.is(r.type)){o.orthographic=P({},o.orthographic),o.perspective=P({},o.perspective);let l=i;((s=l.orthographic)==null?void 0:s.zoom)!==void 0&&(o.orthographic.zoom=l.orthographic.zoom),((a=l.perspective)==null?void 0:a.zoom)!==void 0&&(o.perspective.zoom=l.perspective.zoom)}else if(r.type==="Mesh")o.geometry=P({},o.geometry),Object.assign(o.geometry,i.geometry),o=n(o,i);else if(Ms.is(r.type)){let l=i;o.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=Et.clone(l.color))}return o}e.patch=t})($u||($u={}));import{BufferGeometry as OA,ConeBufferGeometry as cb,Float32BufferAttribute as IA,Vector2 as PA,Vector3 as AA}from"three";import{BufferGeometry as ab,CylinderBufferGeometry as lb,Float32BufferAttribute as Za,Vector2 as Xt,Vector3 as Bs}from"three";var Ku=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var s,a,l,c,p;let e=Object.assign({},(s=t==null?void 0:t.parameters)!=null?s:{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},n.parameters),r=e.width/2,i=(a=e.radiusTop)!=null?a:r,o=(l=e.radiusBottom)!=null?l:r;return i===o?(i=r,o=r):i>o?(i=r,o=o*r/i):(i=i*r/o,o=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((c=e.height)!=null?c:e.width),depth:Math.abs((p=e.depth)!=null?p:e.width),radiusTop:i,radiusBottom:o})}}static build(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:o,openEnded:s,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:p,cornerRadius:u,cornerSegments:h,hollow:m}=n.parameters,f;return u||m?f=new Uo(c,p,r,i,o,s,a,l*Math.PI/180,u,u,h,m):f=new lb(c,p,r,i,o,s,a,l*Math.PI/180),f.scale(1,1,e/t),Object.assign(f,{userData:W(P({},n),{type:"CylinderGeometry"})})}};function Wr(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function Ju(n){return new Xt(n.y,-n.x)}var Uo=class extends ab{constructor(t,e,r,i,o,s,a,l,c,p,u,h,m=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,i=Math.floor(i)||8,o=Math.floor(o)||1,s=s!==void 0?s:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,s&&(c=0,p=0);let f=[],L=[],S=[],y=[],w=0,I=r/2,_=new Bs,g=new Bs;m&&t==0&&(t=c),m&&e==0&&(e=p);let V=new Xt(t,I),b=new Xt(e,-I),d=null,O=null,x=null,M=null,C=V.clone().sub(b),T=0,$=0,H=0;h>0&&(T=Math.min(t,e)*(1-h),$=t-T,H=e-T);let ie=V.clone();ie.x-=T;let pe=Math.PI-C.angle(),ce=C.angle(),be=Math.tan(ce/2),F=Math.tan(pe/2),G=be+F,D=h?G:F,z=h?G:be;if(c=Math.min(c,(t-$)/D,C.length()/G),p=Math.min(p,(e-H)/z,C.length()/G),c>0){let j=c/be;d=V.clone().sub(new Xt(j,c)),h&&(x=d.clone(),x.x-=T-G*c),V.sub(C.clone().setLength(j))}if(p>0){let j=p/F;O=b.clone().sub(new Xt(j,-p)),b.add(C.clone().setLength(j)),h&&(M=O.clone(),M.x-=T-G*p,ie.sub(C.clone().setLength(j)))}C=V.clone().sub(b);let A=C.length()<.5,R=[];for(let j=0;j<=i;j++){let B=[],k=j/i,ne=k*l+a,q=new Xt(Math.sin(ne),Math.cos(ne));M&&O?(K(B,k,q,pe,p,M,-1,!0),K(B,k,q,ce,p,O,-1,!1)):O?(Z(B,q,O.x,0,-1),K(B,k,q,ce,p,O,-1,!1)):s||Z(B,q,e,H,-1);let J=Ju(C).normalize();if(Wr(J,q,_),!A)for(let Y=0;Y<=o;Y++){let X=Y/o,Q=C.clone().multiplyScalar(X).add(b);Wr(Q,q,g),L.push(g.x,g.y,g.z),S.push(_.x,_.y,_.z),y.push(k,.5+g.y/r),B.push(w++)}if(x&&d?(K(B,k,q,pe,c,d,1,!1),K(B,k,q,ce,c,x,1,!0)):d?(K(B,k,q,pe,c,d,1,!1),Z(B,q,d.x,0,1)):s||Z(B,q,t,$,1),h&&!A){let Y=Ju(C).multiplyScalar(-1).normalize();Wr(Y,q,_);for(let X=0;X<=o;X++){let Q=X/o,se=C.clone().multiplyScalar(-Q).add(ie);Wr(se,q,g),L.push(g.x,g.y,g.z),S.push(_.x,_.y,_.z),y.push(k,.5+g.y/r),B.push(w++)}}h&&!s&&B.push(B[0]),R.push(B)}for(let j=0;j<R.length-1;j++)for(let B=0;B<R[0].length-1;B++){if(s&&h&&B==o)continue;let k=R[j][B],ne=R[j+1][B],q=R[j+1][B+1],J=R[j][B+1],Y=L[q*3+0],X=L[q*3+2];f.push(k,ne,J),(Y!=0||X!=0)&&f.push(ne,q,J)}l<Math.PI*2&&(U(-1,R[0],a),U(1,R[R.length-1],a+l)),this.setIndex(f),this.setAttribute("position",new Za(L,3)),this.setAttribute("normal",new Za(S,3)),this.setAttribute("uv",new Za(y,2));function K(j,B,k,ne,q,J,Y,X){for(let Q=0;Q<u+1;Q++){let se=Q/u,oe=Y<0?se:1-se;X&&(oe-=1),oe*=ne;let ue=new Xt(Math.sin(oe),Math.cos(oe)*Y),Ee=ue.clone().multiplyScalar(q).add(J);Wr(Ee,k,g),L.push(g.x,g.y,g.z),Wr(ue,k,_),S.push(_.x,_.y,_.z),y.push(B,.5+g.y/r),j.push(w++)}}function Z(j,B,k,ne,q){let J=new Bs,Y=new Xt,X=[k,ne];q<0&&X.reverse();for(let Q of X)Y.set(Q,I*q),Wr(Y,B,J),L.push(J.x,J.y,J.z),S.push(0,q,0),y.push(.5,.5),j.push(w++)}function U(j,B,k){let ne=new Xt(Math.sin(k),Math.cos(k)),q=new Xt(-Math.cos(k),Math.sin(k)),J=new Bs,Y=j<0?(se,oe,ue)=>f.push(se,oe,ue):(se,oe,ue)=>f.push(se,ue,oe),X=new Xt((t+e+$+H)/4,0);Wr(X,ne,J),L.push(J.x,J.y,J.z),S.push(q.x,0,q.y),y.push(.5,.5);let Q=w++;for(let se of B){let oe=L.slice(se*3,se*3+3);L.push(...oe),S.push(q.x,0,q.y);let ue=y.slice(se*2,se*2+2);y.push(...ue),w++}for(let se=Q+1;se<w-1;se++)Y(Q,se,se+1);Y(Q,w-1,Q+1)}}};var Yu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,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},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:o,openEnded:s,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:p,cornerSegments:u}=n.parameters,h;return c>0||p>0||l<360?h=new Uo(0,t/2,r,i,o,s,a,l*Math.PI/180,c,p,u,0,!0):h=new cb(t/2,r,i,o,s),h.scale(1,1,e/t),Object.assign(h,{userData:W(P({},n),{type:"ConeGeometry"})})}};import{BoxBufferGeometry as pb,BufferGeometry as ub,Float32BufferAttribute as Qa,Vector3 as ko}from"three";var Xu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,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},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t,height:e,depth:r,widthSegments:i,heightSegments:o,depthSegments:s,cornerRadius:a,cornerSegments:l}=n.parameters,c;return a==0?c=new pb(t,e,r,i,o,s):c=new tl(t,e,r,i,o,s,a,l),Object.assign(c,{userData:W(P({},n),{type:"CubeGeometry"})})}},el=Math.PI/2,tl=class extends ub{constructor(t=1,e=1,r=1,i=1,o=1,s=1,a=0,l=4){super(),this.type="BoxBufferGeometry";let c=this;i=Math.floor(i),o=Math.floor(o),s=Math.floor(s),l=Math.floor(l),a=Math.min(a,t/2,e/2,r/2);let p=[],u=[],h=[],m=[],f=0,L=0;S("z","y","x",-1,-1,r,e,t,s,o,0),S("z","y","x",1,-1,r,e,-t,s,o,1),S("x","z","y",1,1,t,r,e,i,s,2),S("x","z","y",1,-1,t,r,-e,i,s,3),S("x","y","z",1,-1,t,e,r,i,o,4),S("x","y","z",-1,-1,t,e,-r,i,o,5),a>0&&(y("z","y","x",-1,-1,1,r,e,t,s,0),y("z","y","x",1,-1,-1,r,e,t,s,1),y("z","y","x",-1,1,-1,r,e,t,s,1),y("z","y","x",1,1,1,r,e,t,s,0),y("x","y","z",-1,-1,-1,t,e,r,i,0),y("x","y","z",1,-1,1,t,e,r,i,1),y("x","y","z",-1,1,1,t,e,r,i,0),y("x","y","z",1,1,-1,t,e,r,i,1),y("y","x","z",-1,-1,1,e,t,r,o,0),y("y","x","z",1,-1,-1,e,t,r,o,1),y("y","x","z",1,1,1,e,t,r,o,1),y("y","x","z",-1,1,-1,e,t,r,o,0),w(1,1,1),w(-1,1,1),w(1,-1,1),w(-1,-1,1),w(1,1,-1),w(-1,1,-1),w(1,-1,-1),w(-1,-1,-1)),this.setIndex(p),this.setAttribute("position",new Qa(u,3)),this.setAttribute("normal",new Qa(h,3)),this.setAttribute("uv",new Qa(m,2));function S(I,_,g,V,b,d,O,x,M,C,T){let $=(d-2*a)/M,H=(O-2*a)/C,ie=d/2-a,pe=O/2-a,ce=x/2,be=M+1,F=C+1,G=0,D=0,z=new ko;for(let A=0;A<F;A++){let R=A*H-pe;for(let K=0;K<be;K++){let Z=K*$-ie;z[I]=Z*V,z[_]=R*b,z[g]=ce,u.push(z.x,z.y,z.z),z[I]=0,z[_]=0,z[g]=x>0?1:-1,h.push(z.x,z.y,z.z),m.push(K/M),m.push(1-A/C),G+=1}}for(let A=0;A<C;A++)for(let R=0;R<M;R++){let K=f+R+be*A,Z=f+R+be*(A+1),U=f+(R+1)+be*(A+1),j=f+(R+1)+be*A;p.push(K,Z,j),p.push(Z,U,j),D+=6}c.addGroup(L,D,T),L+=D,f+=G}function y(I,_,g,V,b,d,O,x,M,C,T){let $=(O-2*a)/C,H=O/2-a,ie=x/2-a,pe=M/2,ce=C+1,be=0,F=0,G=new ko,D=new ko;for(let z=0;z<l+1;z++){let A=z/l*el,R=Math.sin(A)*a,K=(1-Math.cos(A))*a,Z=Math.sin(A),U=Math.cos(A);G[_]=(ie+R)*b,G[g]=(pe-K)*d,D[I]=0,D[_]=Z*Math.sign(G[_]),D[g]=U*Math.sign(G[g]);for(let j=0;j<ce;j++){let B=j*$-H;G[I]=B*V,u.push(G.x,G.y,G.z),h.push(D.x,D.y,D.z),m.push(j/C),m.push(0),be+=1}}for(let z=0;z<l;z++)for(let A=0;A<C;A++){let R=f+A+ce*z,K=f+A+ce*(z+1),Z=f+(A+1)+ce*(z+1),U=f+(A+1)+ce*z;p.push(R,K,U),p.push(K,Z,U),F+=6}c.addGroup(L,F,T),L+=F,f+=be}function w(I,_,g){let V=new ko,b=new ko(t/2,e/2,r/2);b.subScalar(a);let d=[],O=I*_*g>0?(M,C,T)=>p.push(M,C,T):(M,C,T)=>p.push(M,T,C);for(let M=0;M<=l;M++){let C=[],T=el*(1-M/l),$=Math.cos(T),H=Math.sin(T),ie=0;for(let pe=0;pe<=M;pe++){let ce=Math.cos(ie),be=Math.sin(ie);V.x=$*ce,V.y=H,V.z=$*be;let F=b.clone().addScaledVector(V,a);u.push(I*F.x,_*F.y,g*F.z),h.push(I*V.x,_*V.y,g*V.z),m.push(0,0),C.push(f++),ie+=el/M}d.push(C)}let x=d.length-1;for(let M=0;M<x;M++){let C=d[M],T=d[M+1],$=C.length-1;O(C[0],T[1],T[0]);for(let H=1;H<=$;H++)O(C[H-1],C[H],T[H]),O(C[H],T[H+1],T[H])}}}};import{BufferGeometry as hb,Float32BufferAttribute as rl,Triangle as db,Vector3 as Nr,Vector2 as il}from"three";var $r=class extends hb{constructor(t=[],e=[],r="",i=1,o=.2,s=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];p(),u(),this.setAttribute("position",new rl(a,3)),this.setAttribute("normal",new rl(c,3)),this.setAttribute("uv",new rl(l,2));return;function p(){var be;o=Math.min(1-1e-5,o),o==0&&(s=0);let m={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],f=new Nr,L=f.clone(),S=new db,y=o*i,w=i-y,I=s+1,_=new Nr,g=(F,G)=>_.subVectors(F,G).normalize(),V=(F,G)=>Array(F).fill(void 0).map(G),b=V(t.length/3,(F,G)=>new Nr().fromArray(t,G*3).setLength(i)),d=[],O=1e6;for(let F=0;F<b.length;F++){let G=b[F],D=[],z,A,R,K=1e10,Z=-1;for(;(Z=e.indexOf(F,Z+1))!=-1;){let k=Z-Z%3;z=e[k+(Z+1)%3],A=e[k+(Z+2)%3],R=G.distanceToSquared(b[z]),K=Math.min(K,R),D.push([z,A,R])}K+=1e-6;let U=[],j=0,B=D.length;for(let k=0;k<B;k++){[z,A,R]=D[j];let ne=((be=d[z])==null?void 0:be.includes(F))==!0;R<=K&&U.push(z+ +ne*O),j=D.findIndex(q=>q[0]==A)}d.push(U)}let x=[];{let F=0,G=0,D,z,A=m==3;for(let R=0;R<=s;R++){D=R*(R+1)/2,z=(R+1)*(R+2)/2;for(let K=0;K<s-R;K++)[F,G]=[D+K+R+2,z+K+R+3],x.push(D,z,...A?[G,D]:[F,z],G,F),[D,z]=[F,G];x.push(D,z,D+s+2)}}let M=f.clone(),C=f.clone(),T=f.clone(),$=f.clone(),H=f.clone(),ie=[],pe=V(b.length,()=>V(m,()=>f.clone()));for(let F=0;F<b.length;F++){f.copy(b[F]).normalize(),M.copy(f).multiplyScalar(w);let G=d[F];for(let U=0;U<G.length;U++){let j=G[U],B=G[(U+1)%m];S.setFromPointsAndIndices(b,F,j%O,B%O),S.b.sub(S.a).setLength(1e10).add(S.a),S.c.sub(S.a).setLength(1e10).add(S.a),S.closestPointToPoint(M,pe[F][U])}let D=[],z=[],A=[],R=new Nr;s==0&&[...pe[F]].reduce((U,j)=>U.add(j),R).multiplyScalar(1/m);for(let U=0;U<m;U++){let j=[],B=(U-1+m)%m,k=pe[F][B],ne=pe[F][U];f.copy(k).sub(M),L.copy(ne).sub(M);let q=M.angleTo(f),J=f.angleTo(L),Y=Math.cos(q)*y;s==0?C.copy(R):C.copy(M).setLength(w+Y),z.push(Y);let X=[C,k,ne];for(let Q=0;Q<2;Q++){let se=X[Q],oe=X[Q+1];$.subVectors(se,M),H.subVectors(oe,M),T.crossVectors($,H).normalize();for(let ue=0;ue<I;ue++){let Ee=[q,J][Q]*ue/I;f.copy($).applyAxisAngle(T,Ee).add(M),D.push(f.clone()),Q&&(g(f,M),j.push([ue==0?se:f.clone(),_.clone()]))}Q&&(g(oe,M),j.push([oe,_.clone()]))}A.push(j)}ie.push(A);let K=2*I,Z=2;for(let U=0;U<m;U++){let j=K*U,B=K*((U+1)%m),k=[D[j]];for(let q=1;q<I;q++){$=D[j+q],H=D[B+q],k.push($);for(let J=1,Y=q-Z+1;J<=Y;J++)f.lerpVectors($,H,J/(Y+1)),f.sub(M).setLength(z[U]).add(M),k.push(f.clone());k.push(H)}for(let q=0;q<I;q++)k.push(D[q+I+j]);k.push(D[B+I]);let ne=x.map(q=>k[q]);a.push(...ne.map(q=>[q.x,q.y,q.z]).flat()),c.push(...ne.map(q=>(g(q,M),[_.x,_.y,_.z])).flat())}}let ce=[];for(let F=0;F<d.length;F++)for(let G=0;G<m;G++){let D=d[F][G];if(D<O){let z=d[D].findIndex(K=>K%O==F),A=ie[F][G],R=ie[D][z];for(let K=0;K<I;K++){let Z=A[K],U=R[I-K],j=A[K+1],B=R[I-(K+1)];[Z,U,j,j,U,B].forEach(k=>{a.push(k[0].x,k[0].y,k[0].z),c.push(k[1].x,k[1].y,k[1].z)})}ce.push(A[0][0],R[I][0],A[I][0],R[0][0])}}for(;ce.length;){let F,G,D,z;[F,G]=ce.splice(0,2);let A=[F];for(;F!=G;)A.push(G),D=ce.indexOf(G),z=D%2,G=ce.splice(D-z,2)[1-z];_.subVectors(A[0],A[1]).cross(f.subVectors(A[0],A[2])).normalize();let R=_.dot(A[0])<0;R&&_.negate();for(let K=1;K<=A.length-2;K++)[A[K+ +R],A[K+1-+R],A[0]].forEach(Z=>{a.push(Z.x,Z.y,Z.z),c.push(_.x,_.y,_.z)})}}function u(){let h=new Nr;for(let b=0;b<a.length;b+=3){h.x=a[b+0],h.y=a[b+1],h.z=a[b+2];let d=g(h)/2/Math.PI+.5,O=V(h)/Math.PI+.5;l.push(d,1-O)}let m=new Nr,f=new Nr,L=new Nr,S=new Nr,y=new il,w=new il,I=new il,_=(b,d,O,x)=>{x<0&&b.x===1&&(l[d]=b.x-1),O.x===0&&O.z===0&&(l[d]=x/2/Math.PI+.5)};for(let b=0,d=0;b<a.length;b+=9,d+=6){m.set(a[b+0],a[b+1],a[b+2]),f.set(a[b+3],a[b+4],a[b+5]),L.set(a[b+6],a[b+7],a[b+8]),y.set(l[d+0],l[d+1]),w.set(l[d+2],l[d+3]),I.set(l[d+4],l[d+5]),S.copy(m).add(f).add(L).divideScalar(3);let O=g(S);_(y,d+0,m,O),_(w,d+2,f,O),_(I,d+4,L,O)}for(let b=0;b<l.length;b+=6){let d=l[b+0],O=l[b+2],x=l[b+4],M=Math.max(d,O,x),C=Math.min(d,O,x);M>.9&&C<.1&&(d<.2&&(l[b+0]+=1),O<.2&&(l[b+2]+=1),x<.2&&(l[b+4]+=1))}function g(b){return Math.atan2(b.z,-b.x)}function V(b){return Math.atan2(-b.y,Math.sqrt(b.x*b.x+b.z*b.z))}}}static fromJSON(t){return new $r(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};import{DodecahedronBufferGeometry as mb}from"three";var Zu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:i,corner:o,cornerSides:s}=n.parameters,a=i===0&&o!==0?new Ho(t*.5,o,s):new mb(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:W(P({},n),{type:"DodecahedronGeometry"})})}},Ho=class extends $r{constructor(t=1,e=.2,r=4){let i=(1+Math.sqrt(5))/2,o=1/i,s=[-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,-i,0,-o,i,0,o,-i,0,o,i,-o,-i,0,-o,i,0,o,-i,0,o,i,0,-i,0,-o,i,0,-o,-i,0,o,i,0,o],a=[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],l="DodecahedronGeometry";super(s,a,l,t,e,r),this.type=l}static fromJSON(t){return new Ho(t.radius,t.corner,t.cornerSides)}};import{EventDispatcher as Tb,Plane as Nb,Shape as ph,Vector2 as Mr,Vector3 as Mb,MathUtils as pl,LineCurve as ul,QuadraticBezierCurve as uh,CubicBezierCurve as zs}from"three";import{CubicBezierCurve as Es,EllipseCurve as fb,LineCurve as Gs,LineCurve3 as yb,MathUtils as gb,QuadraticBezierCurve as ol,SplineCurve as xb,Vector2 as Zt,Vector3 as Qu}from"three";var qo=1e-12,Xi=class{constructor(t){this.position=new Zt;this.startPosition=new Zt;this.uuid=gb.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 Xi(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Zi=class extends Xi{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Zi(this.parent).copy(this)}},Qt=class extends Xi{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Zi(this),new Zi(this))}static create(e,r){let i=new Qt(e,new Zt(...r.position));return i.controls[0].position.set(...r.controlPrevious.position),i.controls[1].position.set(...r.controlNext.position),i.roundness=r.roundness,i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,i}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 i=0,o=this.controls.length;i<o;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=r?s.position.copy(this.position):s.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 Qt(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}},nl=n=>n,$o=new Zt,sl=new Zt,bb=new Zt,vb=new Zt,Sb=new Zt,wb=new Zt,eh=new Qu,th=new Qu;function rh(n){let t=new Zt;t.addVectors(n.v0,$o.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Zt;return e.addVectors(n.v2,sl.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new Es(n.v0,t,e,n.v2)}function Wo(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function Cb(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function Lb(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function al(n,t,e){let r=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),o=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((i*i+r*r-o*o)/(2*i*r))}function ih(n,t,e,r,i){let o=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),s=(n.y+t.y)/2,a=(n.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(n.y-t.y)/o,c=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(t.x-n.x)/o;return r.set(a+l,s+c),i.set(a-l,s-c),[r,i]}function oh(n,t,e){let r=n.distanceTo(e),i=t.distanceTo(e);return r<i?t:n}function nh(n,t,e,r,i,o){let s=t.x-n.x,a=t.y-n.y,l=e.x-n.x,c=e.y-n.y,p=Math.sqrt((s+l)*(s+l)+(a+c)*(a+c)),u;return al(t,n,e)>Math.PI&&(p*=-1),Wo(c,a)?u=(a+c)*(r/p-.5)*8/3/(s-l):u=(s+l)*(r/p-.5)*8/3/(c-a),i.set(t.x-u*a,t.y+u*s),o.set(e.x+u*c,e.y-u*l),[i,o]}function ll(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function sh(n,t,e,r,i=.5){let o=$o.subVectors(t,n).multiplyScalar(i).add(n),s=sl.subVectors(e,t).multiplyScalar(i).add(t),a=bb.subVectors(r,e).multiplyScalar(i).add(e),l=o,c=vb.subVectors(s,o).multiplyScalar(i).add(o),p=Sb.subVectors(a,s).multiplyScalar(i).add(s),u=a,h=wb.subVectors(p,c).multiplyScalar(i).add(c);return[n.x,n.y,l.x,l.y,c.x,c.y,h.x,h.y,p.x,p.y,u.x,u.y,r.x,r.y]}function ah(n,t,e=12,r=!0){let i=th.set(0,0,0),o,s=0,a=[];for(let l=0;l<t.length;l++){let c=nl(t[l]),p=$o,u=Jr(c,e);a.push(u);for(let h=0;h<=u;h++)if(c instanceof Es||c instanceof ol||c instanceof Gs){if(c.getPoint(h/u,p),i.set(p.x,p.y,0),o!==void 0&&Lb(o,i))continue;o===void 0&&(o=eh),o.copy(i),n.setXYZ(s,i.x,i.y,i.z),s++}}return r&&s>1&&!(n.getX(s-1)===n.getX(0)&&n.getY(s-1)===n.getY(0)&&n.getZ(s-1)===n.getZ(0))&&(n.setXYZ(s,n.getX(0),n.getY(0),n.getZ(0)),s++),n}function lh(n,t,e,r=12,i=!0){let o=th.set(0,0,0),s=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,p=nl(t[l]),u=$o,h=Jr(p,r);a.push(h);for(let m=0;m<=h;m++)if(p instanceof Es||p instanceof ol||p instanceof Gs){if(p.getPoint(m/h,u),o.set(u.x,u.y,0),c!=null&&c.equals(o))continue;c===void 0?c=eh:(n.setXYZ(s,c.x,c.y,c.z),s++,n.setXYZ(s,o.x,o.y,o.z),s++),c.copy(o)}}return i&&s>1&&!(n.getX(s-1)===n.getX(0)&&n.getY(s-1)===n.getY(0)&&n.getZ(s-1)===n.getZ(0))&&(n.setXYZ(s,n.getX(0),n.getY(0),n.getZ(0)),s++),a}function cl(n,t=12,e=!1){let r=[];for(let i=0,o=n.length;i<o;i++){let s=n[i],a=0;if(e&&s.roundedCurveCorner!==void 0){let l=Jr(s.roundedCurveCorner,t)*.5;i>0&&(r[i-1]+=l),a+=l}s.curveAfter!==void 0&&(a+=Jr(s.curveAfter,t)),r.push(a)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=Jr(n[0].roundedCurveCorner,t)*.5),r}function Jr(n,t=12){return n&&n instanceof fb?t*2:n&&(n instanceof Gs||n instanceof yb)?1:n&&n instanceof xb?t*n.points.length:t}function ch(n,t,e=12,r=!0){let i,o=0;for(let s=0;s<t.length;s++){let a=nl(t[s]),l=Jr(a,e),c=$o;for(let p=0;p<=l;p++)if(a instanceof Es||a instanceof ol||a instanceof Gs){if(a.getPoint(p/l,c),i!==void 0&&Cb(i,c,qo))continue;i===void 0&&(i=sl),i.copy(c),n.push(c.x,c.y),o++}}return Wo(n[0],n[n.length-2],qo)&&Wo(n[1],n[n.length-1],qo)&&(n.pop(),n.pop()),r&&o>1&&!(Wo(n[o-1],n[1],qo)&&Wo(n[o-2],n[0],qo))&&(n.push(n[0],n[1]),o++),n}var hl=new Mr,Ob=new Mr,Ib=new Mr,Pb=new Mr,Ab=new Mr,Db=new Mr,Me=class extends ph{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new Tb;this.plane=new Nb(new Mb(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=pl.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,i){let o=new Me;return o.isClosed=e.isClosed,o.points=e.points.map(s=>Qt.create(s.id,s.data)),typeof e.roundness=="number"&&(o.roundness=e.roundness),o.shapeHoles=e.shapeHoles.map(s=>Me.createFromState(s)),r!==void 0&&i!==void 0&&o.applySize(r,i),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,i=this.points.length;r<i;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,i=this.shapeHoles.length;r<i;r++){let o=this.shapeHoles[r],s=e-this.points.length;if(s<=o.points.length-1)return o.points[s]}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 i=0,o=this.shapeHoles.length;i<o;i++){let s=this.shapeHoles[i],a=s.points.indexOf(e);if(a>=0)return r+a;r+=s.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 i=hl.set(e,r);for(let o=0,s=this.points.length;o<s;o++){let a=this.points[o];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let o=0,s=this.shapeHoles.length;o<s;o++)this.shapeHoles[o].applyScale(e,r);this._update(!1)}createPoint(e,r=0,i=pl.generateUUID()){let o;e instanceof Mr?o=e:o=new Mr(e,r);let s=new Qt(i,o);return s.roundness=this.roundness,s}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,i=this.points.length;r<i;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(i=>i.uuid===e);r&&this.removePoint(r)}update(e=!0){for(let r=0,i=this.shapeHoles.length;r<i;r++)this.shapeHoles[r].update(!1);this._update(e)}extractShapePointsToBuffer(e,r=12,i=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let o=i?this.roundedCurveDivisions:this.curveDivisions;return ah(e,i?this.roundedCurves:this.curves,r,this.autoClose),o.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=cl(this.points,e,!1),this.roundedCurveDivisions=cl(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,i=12){return lh(e,this.curves,r,i,this.autoClose).reduce((s,a)=>s+a,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),ch(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let o=r?this.roundedCurveDivisions:this.curveDivisions,s=0;r&&this.points[0].roundedCurveCorner!==void 0&&(s=Jr(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-s;a<0&&(a+=o.reduce((l,c)=>l+c,0));for(let l=0,c=o.length;l<c;l++){let p=o[l];if(a<i+p)return[l,(a-i+1)/p];i+=p}return[0,1]}getCurveT(e,r,i){let o=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(ll(o,s)){let u=o.position.distanceTo(s.position);return o.position.distanceTo(hl.set(i.x,i.y))/u}let c=0;for(let u=0;u<e;u++)c+=a[u];return(r-c)/l}dispose(){this.eventDispatcher=null}_applyCurveForPoint(e,r){ll(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 i=this.curves[this.curves.length-1];e.curveBefore=i,r.curveAfter=i;let o=i.clone();e.roundedCurveBefore=o,r.roundedCurveAfter=o,e.roundedCurveCorner=void 0,this.roundedCurves.push(o)}_update(e=!0){var i;if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let o=0,s=this.points.length;o<s;o++){let a=this.points[o];if(o===0)this.moveTo(a.position.x,a.position.y);else{let l=this.points[o-1];this._applyCurveForPoint(a,l)}}let r=this.getLastPoint();if(r!=null&&r.curveAfter&&(r.curveAfter=void 0),this.isClosed){let o=this.points[0],s=this.points[this.points.length-1];this._applyCurveForPoint(o,s)}if(this.points.length>2){let o=0;for(let s=0,a=this.points.length;s<a;s++){let l=this.points[s],c=l.roundness;if(!l.controlsMoved()&&c>0){let p=l.curveBefore,u=l.curveAfter;if(p===void 0||u===void 0)continue;let h=l.roundedCurveBefore,m=l.roundedCurveAfter,f=p.getLength(),L=u.getLength(),S=Math.min(c,f*.499),y=Math.min(c,L*.499),w=Math.min(S,y),I=1-w/f,_=w/L,g=p.getPointAt(I,hl),V=u.getPointAt(_,Ob);this._subSplitCurve(p,h,I,g,void 0),this._subSplitCurve(u,m,_,void 0,V);let b;if(this.useCubicForRoundedCorners){let d=al(g,l.position,V)/2,O=Math.tan(d)*g.distanceTo(l.position),[x,M]=ih(g,V,O,Ib,Pb),C=oh(x,M,l.position),[T,$]=nh(C,g,V,O,Ab,Db);b=new zs(g.clone(),T.clone(),$.clone(),V.clone())}else b=new uh(g.clone(),l.position.clone(),V.clone());l.roundedCurveCorner=b,this.roundedCurves.splice(s+o,0,b),o++}}}e&&((i=this.eventDispatcher)==null||i.dispatchEvent({type:"update"}))}_subSplitCurve(e,r,i,o,s){if(e instanceof ul)o!==void 0&&r.v2.copy(o),s!==void 0&&r.v1.copy(s);else{let a=e,l=r,c=a.getUtoTmapping(i,0),p=sh(a.v0,a.v1,a.v2,a.v3,c);return o!==void 0&&(l.v0.set(p[0],p[1]),l.v1.set(p[2],p[3]),l.v2.set(p[4],p[5]),l.v3.set(p[6],p[7])),s!==void 0&&(l.v0.set(p[6],p[7]),l.v1.set(p[8],p[9]),l.v2.set(p[10],p[11]),l.v3.set(p[12],p[13])),l}return r}clone(){let e=new Me(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 i;this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let o=0;o<r;o++){let s=o*7,a=e.points[s+0],l=e.points[s+1],c=e.points[s+2],p=e.points[s+3],u=e.points[s+4],h=e.points[s+5],m=e.points[s+6],f=new Qt(pl.generateUUID(),new Mr(a,l));f.controls[0].position.set(c,p),f.controls[1].position.set(u,h),f.roundness=m,this.points.push(f)}return this.shapeHoles=(i=e.shapeHoles)!=null&&i.length?e.shapeHoles.map(o=>{let s=new Me;return s.fromJSON(o),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let r=(o,s)=>{s instanceof zs&&s.v3.equals(o.position)&&o.controls[0].position.copy(s.v2)},i=o=>{let s=[],a,l;for(a=0,l=o.length;a<l;a++)o[a]instanceof uh&&(o[a]=rh(o[a]));for(a=0,l=o.length;a<l;a++){let u=o[a],h=a>0?o[a-1]:null,m;u instanceof zs?(m=this.createPoint(u.v0),m.controls[1].position.copy(u.v1)):u instanceof ul&&(m=this.createPoint(u.v1)),m!==void 0&&(h!==null&&r(m,h),s.push(m))}let c=o[o.length-1],p=!1;return c instanceof zs?c.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(c.v2),p=!0):c instanceof ul&&c.v2.equals(s[0].position)&&(p=!0),this.isClosed=p,s};return this.points=i(e.curves),e instanceof ph&&(this.shapeHoles=e.holes.map(o=>{let s=new Me;return s.fromShape(o),s})),this.update(),this}};var ml=Math.PI*2;function dl({x:n,y:t},e,r,i,o){return{x:n*e+i,y:t*r+o}}function _b(n,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(n),i=Math.sin(n),o=Math.cos(n+t),s=Math.sin(n+t);return[{x:r-i*e,y:i+r*e},{x:o+s*e,y:s-o*e},{x:o,y:s}]}function hh(n,t,e,r){let i=n*r-t*e<0?-1:1,o=Math.min(1,Math.max(-1,n*e+t*r));return i*Math.acos(o)}function Bb(n,t,e,r,i,o,s,a,l,c){let p=Math.pow(i,2),u=Math.pow(o,2),h=Math.pow(s,2),m=Math.pow(a,2),f=p*u-p*m-u*h;f<0&&(f=0),f/=p*m+u*h,f=Math.sqrt(f)*(l===c?-1:1);let L=f*i/o*a,S=f*-o/i*s,y=L+(n+e)/2,w=S+(t+r)/2,I=(s-L)/i,_=(a-S)/o,g=(-s-L)/i,V=(-a-S)/o,b=hh(1,0,I,_),d=hh(I,_,g,V);return!c&&d>0&&(d-=ml),c&&d<0&&(d+=ml),{centerx:y,centery:w,ang1:b,ang2:d}}function dh({px:n,py:t,cx:e,cy:r,rx:i,ry:o,largeArcFlag:s,sweepFlag:a}){let l=[];if(i===0||o===0)return[];let c=(n-e)/2,p=(t-r)/2;if(c===0&&p===0)return[];i=Math.abs(i),o=Math.abs(o);let u=Math.pow(c,2)/Math.pow(i,2)+Math.pow(p,2)/Math.pow(o,2);u>1&&(i*=Math.sqrt(u),o*=Math.sqrt(u));let h=Bb(n,t,e,r,i,o,c,p,s,a),{ang1:m,ang2:f}=h,{centerx:L,centery:S}=h,y=Math.abs(f)/(ml/4);Math.abs(1-y)<1e-7&&(y=1);let w=Math.max(Math.ceil(y),1);f/=w;for(let I=0;I<w;I++)l.push(_b(m,f)),m+=f;return l.map(I=>{let{x:_,y:g}=dl(I[0],i,o,L,S),{x:V,y:b}=dl(I[1],i,o,L,S),{x:d,y:O}=dl(I[2],i,o,L,S);return{x1:_,y1:g,x2:V,y2:b,x:d,y:O}})}import{BufferAttribute as Vs,BufferGeometry as Vb}from"three";var He;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(He||(He={}));var rt;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(rt||(rt={}));function de(n,t){if(!n)throw t||"Assertion Failed!"}var ae=function(){function n(){}return n.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},n.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},n.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},n.edgeGoesLeft=function(t){return n.vertLeq(t.Dst,t.Org)},n.edgeGoesRight=function(t){return n.vertLeq(t.Org,t.Dst)},n.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},n.edgeEval=function(t,e,r){de(n.vertLeq(t,e)&&n.vertLeq(e,r));var i=e.s-t.s,o=r.s-e.s;return i+o>0?i<o?e.t-t.t+(t.t-r.t)*(i/(i+o)):e.t-r.t+(r.t-t.t)*(o/(i+o)):0},n.edgeSign=function(t,e,r){de(n.vertLeq(t,e)&&n.vertLeq(e,r));var i=e.s-t.s,o=r.s-e.s;return i+o>0?(e.t-r.t)*i+(e.t-t.t)*o:0},n.transEval=function(t,e,r){de(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,o=r.t-e.t;return i+o>0?i<o?e.s-t.s+(t.s-r.s)*(i/(i+o)):e.s-r.s+(r.s-t.s)*(o/(i+o)):0},n.transSign=function(t,e,r){de(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,o=r.t-e.t;return i+o>0?(e.s-r.s)*i+(e.s-t.s)*o:0},n.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},n.interpolate=function(t,e,r,i){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+i)/2:e+(i-e)*(t/(t+r)):i+(e-i)*(r/(t+r))},n.intersect=function(t,e,r,i,o){var s,a,l;n.vertLeq(t,e)||(l=t,t=e,e=l),n.vertLeq(r,i)||(l=r,r=i,i=l),n.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.vertLeq(r,e)?n.vertLeq(e,i)?(s=n.edgeEval(t,r,e),a=n.edgeEval(r,e,i),s+a<0&&(s=-s,a=-a),o.s=n.interpolate(s,r.s,a,e.s)):(s=n.edgeSign(t,r,e),a=-n.edgeSign(t,i,e),s+a<0&&(s=-s,a=-a),o.s=n.interpolate(s,r.s,a,i.s)):o.s=(r.s+e.s)/2,n.transLeq(t,e)||(l=t,t=e,e=l),n.transLeq(r,i)||(l=r,r=i,i=l),n.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.transLeq(r,e)?n.transLeq(e,i)?(s=n.transEval(t,r,e),a=n.transEval(r,e,i),s+a<0&&(s=-s,a=-a),o.t=n.interpolate(s,r.t,a,e.t)):(s=n.transSign(t,r,e),a=-n.transSign(t,i,e),s+a<0&&(s=-s,a=-a),o.t=n.interpolate(s,r.t,a,i.t)):o.t=(r.t+e.t)/2},n}(),Jo=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return n}(),Rs=function(){function n(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(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),n}(),Qi=function(){function n(){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 n}(),mh=function(){function n(){var t=new Qi,e=new Jo,r=new Rs(0),i=new Rs(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=i,i.next=i,i.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=i}return n.prototype.makeEdge_=function(t){var e=new Rs(0),r=new Rs(1);t.Sym.side<t.side&&(t=t.Sym);var i=t.Sym.next;return r.next=i,i.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},n.prototype.splice_=function(t,e){var r=t.Onext,i=e.Onext;r.Sym.Lnext=e,i.Sym.Lnext=t,t.Onext=i,e.Onext=r},n.prototype.makeVertex_=function(t,e,r){var i=t;de(i,"Vertex can't be null!");var o=r.prev;i.prev=o,o.next=i,i.next=r,r.prev=i,i.anEdge=e;var s=e;do s.Org=i,s=s.Onext;while(s!==e)},n.prototype.makeFace_=function(t,e,r){var i=t;de(i,"Face can't be null");var o=r.prev;i.prev=o,o.next=i,i.next=r,r.prev=i,i.anEdge=e,i.trail=null,i.marked=!1,i.inside=r.inside;var s=e;do s.Lface=i,s=s.Lnext;while(s!==e)},n.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},n.prototype.killVertex_=function(t,e){var r=t.anEdge,i=r;do i.Org=e,i=i.Onext;while(i!==r);var o=t.prev,s=t.next;s.prev=o,o.next=s},n.prototype.killFace_=function(t,e){var r=t.anEdge,i=r;do i.Lface=e,i=i.Lnext;while(i!==r);var o=t.prev,s=t.next;s.prev=o,o.next=s},n.prototype.makeEdge=function(){var t=new Qi,e=new Qi,r=new Jo,i=this.makeEdge_(this.eHead);return this.makeVertex_(t,i,this.vHead),this.makeVertex_(e,i.Sym,this.vHead),this.makeFace_(r,i,this.fHead),i},n.prototype.splice=function(t,e){var r=!1,i=!1;if(t!==e){if(e.Org!==t.Org&&(i=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!i){var o=new Qi;this.makeVertex_(o,e,t.Org),t.Org.anEdge=t}if(!r){var s=new Jo;this.makeFace_(s,e,t.Lface),t.Lface.anEdge=t}}},n.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 i=new Jo;this.makeFace_(i,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)},n.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var i=new Qi;return this.makeVertex_(i,r,e.Org),e.Lface=r.Lface=t.Lface,e},n.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},n.prototype.connect=function(t,e){var r=!1,i=this.makeEdge_(t),o=i.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(i,t.Lnext),this.splice_(o,e),i.Org=t.Dst,o.Org=e.Org,i.Lface=o.Lface=t.Lface,t.Lface.anEdge=o,!r){var s=new Jo;this.makeFace_(s,i,t.Lface)}return i},n.prototype.zapFace=function(t){var e=t.anEdge,r,i,o,s,a;i=e.Lnext;do r=i,i=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);s=t.prev,a=t.next,a.prev=s,s.next=a},n.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},n.prototype.mergeConvexFaces=function(t){var e,r,i,o,s,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,s=r.Org;i=r.Lnext,o=r.Sym,o&&o.Lface&&o.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(o.Lface),a+l-2<=t&&ae.vertCCW(r.Lprev.Org,r.Org,o.Lnext.Lnext.Org)&&ae.vertCCW(o.Lprev.Org,o.Org,r.Lnext.Lnext.Org)&&(i=o.Lnext,this.delete(o),r=null,o=null)),!(r&&r.Lnext.Org===s);)r=i;return!0},n.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,i,o,s,a,l,c;for(o=t,o=t;(i=o.next)!==t;o=i){de(i.prev===o),l=i.anEdge;do de(l.Sym!==l),de(l.Sym.Sym===l),de(l.Lnext.Onext.Sym===l),de(l.Onext.Sym.Lnext===l),de(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(de(i.prev===o&&i.anEdge===null),a=e,a=e;(s=a.next)!==e;a=s){de(s.prev===a),l=s.anEdge;do de(l.Sym!==l),de(l.Sym.Sym===l),de(l.Lnext.Onext.Sym===l),de(l.Onext.Sym.Lnext===l),de(l.Org===s),l=l.Onext;while(l!==s.anEdge)}for(de(s.prev===a&&s.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)de(l.Sym.next===c.Sym),de(l.Sym!==l),de(l.Sym.Sym===l),de(l.Org!==null),de(l.Dst!==null),de(l.Lnext.Onext.Sym===l),de(l.Onext.Sym.Lnext===l);de(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},n}(),fh=function(){function n(){this.handle=null}return n}(),yh=function(){function n(){this.key=null,this.node=0}return n}(),Eb=function(){function n(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 fh,this.handles[r]=new yh;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,i,o,s;for(i=e[t].handle;;){if(s=t<<1,s<this.size&&this.leq(r[e[s+1].handle].key,r[e[s].handle].key)&&++s,de(s<=this.max),o=e[s].handle,s>this.size||this.leq(r[i].key,r[o].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=o,r[o].node=t,t=s}},n.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,i,o,s;for(i=e[t].handle;;){if(s=t>>1,o=e[s].handle,s===0||this.leq(r[o].key,r[i].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=o,r[o].node=t,t=s}},n.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var i,o;for(o=this.nodes.length,this.nodes.length=this.max+1,i=o;i<this.nodes.length;i++)this.nodes[i]=new fh;for(o=this.handles.length,this.handles.length=this.max+1,i=o;i<this.handles.length;i++)this.handles[i]=new yh}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},n.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,i=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)),i},n.prototype.delete=function(t){var e=this.nodes,r=this.handles,i;de(t>=1&&t<=this.max&&r[t].key!==null),i=r[t].node,e[i].handle=e[this.size].handle,r[e[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(r[e[i>>1].handle].key,r[e[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},n}(),fl=function(){function n(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return n}(),gh=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),Gb=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new gh,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(t){return this.insertBefore(this.head,t)},n.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},n.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new gh;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},n.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},n}(),zb=function(){function n(){}return n.regionBelow=function(t){return t.nodeUp.prev.key},n.regionAbove=function(t){return t.nodeUp.next.key},n.debugEvent=function(t){},n.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.edgeLeq=function(t,e,r){var i=t.event,o=e.eUp,s=r.eUp;if(o.Dst===i)return s.Dst===i?ae.vertLeq(o.Org,s.Org)?ae.edgeSign(s.Dst,o.Org,s.Org)<=0:ae.edgeSign(o.Dst,s.Org,o.Org)>=0:ae.edgeSign(s.Dst,i,s.Org)<=0;if(s.Dst===i)return ae.edgeSign(o.Dst,i,o.Org)>=0;var a=ae.edgeEval(o.Dst,i,o.Org),l=ae.edgeEval(s.Dst,i,s.Org);return a>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&de(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){de(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},n.topLeftRegion=function(t,e){var r=e.eUp.Org,i;do e=n.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(i=t.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),i===null)return null;n.fixUpperEdge(t,e,i),e=n.regionAbove(e)}return e},n.topRightRegion=function(t){var e=t.eUp.Dst;do t=n.regionAbove(t);while(t.eUp.Dst===e);return t},n.addRegionBelow=function(t,e,r){var i=new fl;return i.eUp=r,i.nodeUp=t.dict.insertBefore(e.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,r.activeRegion=i,i},n.isWindingInside=function(t,e){switch(t.windingRule){case He.ODD:return(e&1)!==0;case He.NONZERO:return e!==0;case He.POSITIVE:return e>0;case He.NEGATIVE:return e<0;case He.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(t,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(t,e.windingNumber)},n.finishRegion=function(t,e){var r=e.eUp,i=r.Lface;i.inside=e.inside,i.anEdge=r,n.deleteRegion(t,e)},n.finishLeftRegions=function(t,e,r){for(var i,o=null,s=e,a=e.eUp;s!==r;){if(s.fixUpperEdge=!1,o=n.regionBelow(s),i=o.eUp,i.Org!=a.Org){if(!o.fixUpperEdge){n.finishRegion(t,s);break}i=t.mesh.connect(a.Lprev,i.Sym),n.fixUpperEdge(t,o,i)}a.Onext!==i&&(t.mesh.splice(i.Oprev,i),t.mesh.splice(a,i)),n.finishRegion(t,s),a=o.eUp,s=o}return a},n.addRightEdges=function(t,e,r,i,o,s){var a,l,c,p,u=!0;c=r;do de(ae.vertLeq(c.Org,c.Dst)),n.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==i);for(o===null&&(o=n.regionBelow(e).eUp.Rprev),l=e,p=o;a=n.regionBelow(l),c=a.eUp.Sym,c.Org===p.Org;)c.Onext!==p&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(p.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=n.isWindingInside(t,a.windingNumber),l.dirty=!0,!u&&n.checkForRightSplice(t,l)&&(n.addWinding(c,p),n.deleteRegion(t,l),t.mesh.delete(p)),u=!1,l=a,p=c;l.dirty=!0,de(l.windingNumber-c.winding===a.windingNumber),s&&n.walkDirtyRegions(t,l)},n.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},n.vertexWeights=function(t,e,r){var i=ae.vertL1dist(e,t),o=ae.vertL1dist(r,t),s=.5*o/(i+o),a=.5*i/(i+o);t.coords[0]+=s*e.coords[0]+a*r.coords[0],t.coords[1]+=s*e.coords[1]+a*r.coords[1],t.coords[2]+=s*e.coords[2]+a*r.coords[2]},n.getIntersectData=function(t,e,r,i,o,s){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,r,i),n.vertexWeights(e,o,s)},n.checkForRightSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,o=r.eUp;if(ae.vertLeq(i.Org,o.Org)){if(ae.edgeSign(o.Dst,i.Org,o.Org)>0)return!1;ae.vertEq(i.Org,o.Org)?i.Org!==o.Org&&(t.pq.delete(i.Org.pqHandle),n.spliceMergeVertices(t,o.Oprev,i)):(t.mesh.splitEdge(o.Sym),t.mesh.splice(i,o.Oprev),e.dirty=r.dirty=!0)}else{if(ae.edgeSign(i.Dst,o.Org,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),t.mesh.splice(o.Oprev,i)}return!0},n.checkForLeftSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,o=r.eUp,s;if(de(!ae.vertEq(i.Dst,o.Dst)),ae.vertLeq(i.Dst,o.Dst)){if(ae.edgeSign(i.Dst,o.Dst,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,s=t.mesh.splitEdge(i),t.mesh.splice(o.Sym,s),s.Lface.inside=e.inside}else{if(ae.edgeSign(o.Dst,i.Dst,o.Org)>0)return!1;e.dirty=r.dirty=!0,s=t.mesh.splitEdge(o),t.mesh.splice(i.Lnext,o.Sym),s.Rface.inside=e.inside}return!0},n.checkForIntersect=function(t,e){var r=n.regionBelow(e),i=e.eUp,o=r.eUp,s=i.Org,a=o.Org,l=i.Dst,c=o.Dst,p,u,h=new Qi,m,f;if(de(!ae.vertEq(c,l)),de(ae.edgeSign(l,t.event,s)<=0),de(ae.edgeSign(c,t.event,a)>=0),de(s!==t.event&&a!==t.event),de(!e.fixUpperEdge&&!r.fixUpperEdge),s===a||(p=Math.min(s.t,l.t),u=Math.max(a.t,c.t),p>u))return!1;if(ae.vertLeq(s,a)){if(ae.edgeSign(c,s,a)>0)return!1}else if(ae.edgeSign(l,a,s)<0)return!1;return n.debugEvent(t),ae.intersect(l,s,c,a,h),de(Math.min(s.t,l.t)<=h.t),de(h.t<=Math.max(a.t,c.t)),de(Math.min(c.s,l.s)<=h.s),de(h.s<=Math.max(a.s,s.s)),ae.vertLeq(h,t.event)&&(h.s=t.event.s,h.t=t.event.t),m=ae.vertLeq(s,a)?s:a,ae.vertLeq(m,h)&&(h.s=m.s,h.t=m.t),ae.vertEq(h,s)||ae.vertEq(h,a)?(n.checkForRightSplice(t,e),!1):!ae.vertEq(l,t.event)&&ae.edgeSign(l,t.event,h)>=0||!ae.vertEq(c,t.event)&&ae.edgeSign(c,t.event,h)<=0?c===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(o.Sym,i),e=n.topLeftRegion(t,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),r),n.addRightEdges(t,e,i.Oprev,i,i,!0),!0):l===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Lnext,o.Oprev),r=e,e=n.topRightRegion(e),f=n.regionBelow(e).eUp.Rprev,r.eUp=o.Oprev,o=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,o.Onext,i.Rprev,f,!0),!0):(ae.edgeSign(l,t.event,h)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),ae.edgeSign(c,t.event,h)<=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(i.Sym),t.mesh.splitEdge(o.Sym),t.mesh.splice(o.Oprev,i),i.Org.s=h.s,i.Org.t=h.t,i.Org.pqHandle=t.pq.insert(i.Org),n.getIntersectData(t,i.Org,s,l,a,c),n.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(t,e){for(var r=n.regionBelow(e),i,o;;){for(;r.dirty;)e=r,r=n.regionBelow(r);if(!e.dirty&&(r=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,i=e.eUp,o=r.eUp,i.Dst!==o.Dst&&n.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(n.deleteRegion(t,r),t.mesh.delete(o),r=n.regionBelow(e),o=r.eUp):e.fixUpperEdge&&(n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r),i=e.eUp)),i.Org!==o.Org)if(i.Dst!==o.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(i.Dst===t.event||o.Dst===t.event)){if(n.checkForIntersect(t,e))return}else n.checkForRightSplice(t,e);i.Org===o.Org&&i.Dst===o.Dst&&(n.addWinding(o,i),n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r))}},n.connectRightVertex=function(t,e,r){var i,o=r.Onext,s=n.regionBelow(e),a=e.eUp,l=s.eUp,c=!1;if(a.Dst!==l.Dst&&n.checkForIntersect(t,e),ae.vertEq(a.Org,t.event)&&(t.mesh.splice(o.Oprev,a),e=n.topLeftRegion(t,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),s),c=!0),ae.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(t,s,null),c=!0),c){n.addRightEdges(t,e,r.Onext,o,o,!0);return}ae.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=t.mesh.connect(r.Lprev,i),n.addRightEdges(t,e,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(t,e)},n.connectLeftDegenerate=function(t,e,r){var i,o,s,a,l;if(i=e.eUp,ae.vertEq(i.Org,r)){de(!1),n.spliceMergeVertices(t,i,r.anEdge);return}if(!ae.vertEq(i.Dst,r)){t.mesh.splitEdge(i.Sym),e.fixUpperEdge&&(t.mesh.delete(i.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,i),n.sweepEvent(t,r);return}de(!1),e=n.topRightRegion(e),l=n.regionBelow(e),s=l.eUp.Sym,o=a=s.Onext,l.fixUpperEdge&&(de(o!==s),n.deleteRegion(t,l),t.mesh.delete(s),s=o.Oprev),t.mesh.splice(r.anEdge,s),ae.edgeGoesLeft(o)||(o=null),n.addRightEdges(t,e,s.Onext,a,o,!0)},n.connectLeftVertex=function(t,e){var r,i,o,s,a,l,c=new fl;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,i=n.regionBelow(r),!!i){if(s=r.eUp,a=i.eUp,ae.edgeSign(s.Dst,e,s.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(o=ae.vertLeq(a.Dst,s.Dst)?r:i,r.inside||o.fixUpperEdge){if(o===r)l=t.mesh.connect(e.anEdge.Sym,s.Lnext);else{var p=t.mesh.connect(a.Dnext,e.anEdge);l=p.Sym}o.fixUpperEdge?n.fixUpperEdge(t,o,l):n.computeWinding(t,n.addRegionBelow(t,r,l)),n.sweepEvent(t,e)}else n.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(t,e){t.event=e,n.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){n.connectLeftVertex(t,e);return}var i=n.topLeftRegion(t,r.activeRegion);de(i!==null);var o=n.regionBelow(i),s=o.eUp,a=n.finishLeftRegions(t,o,null);a.Onext===s?n.connectRightVertex(t,i,a):n.addRightEdges(t,i,a.Onext,s,s,!0)},n.addSentinel=function(t,e,r,i){var o=new fl,s=t.mesh.makeEdge();s.Org.s=r,s.Org.t=i,s.Dst.s=e,s.Dst.t=i,t.event=s.Dst,o.eUp=s,o.windingNumber=0,o.inside=!1,o.fixUpperEdge=!1,o.sentinel=!0,o.dirty=!1,o.nodeUp=t.dict.insert(o)},n.initEdgeDict=function(t){t.dict=new Gb(t,n.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],i=t.bmin[0]-e,o=t.bmax[0]+e,s=t.bmin[1]-r,a=t.bmax[1]+r;n.addSentinel(t,i,o,s),n.addSentinel(t,i,o,a)},n.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(de(e.fixUpperEdge),de(++r===1)),de(e.windingNumber===0),n.deleteRegion(t,e)},n.removeDegenerateEdges=function(t){var e,r,i,o=t.mesh.eHead;for(e=o.next;e!==o;e=r)r=e.next,i=e.Lnext,ae.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(t,i,e),t.mesh.delete(e),e=i,i=e.Lnext),i.Lnext===e&&(i!==e&&((i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},n.initPriorityQ=function(t){var e,r,i,o=0;for(i=t.mesh.vHead,r=i.next;r!==i;r=r.next)o++;for(o+=8,e=t.pq=new Eb(o,ae.vertLeq),i=t.mesh.vHead,r=i.next;r!==i;r=r.next)r.pqHandle=e.insert(r);return r!==i?!1:(e.init(),!0)},n.donePriorityQ=function(t){t.pq=null},n.removeDegenerateFaces=function(t,e){var r,i,o;for(r=e.fHead.next;r!==e.fHead;r=i)i=r.next,o=r.anEdge,de(o.Lnext!==o),o.Lnext.Lnext===o&&(n.addWinding(o.Onext,o),t.mesh.delete(o));return!0},n.computeInterior=function(t,e){e===void 0&&(e=!0);var r,i;if(n.removeDegenerateEdges(t),!n.initPriorityQ(t))return!1;for(n.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;i=t.pq.min(),!(i===null||!ae.vertEq(i,r));)i=t.pq.extractMin(),n.spliceMergeVertices(t,r.anEdge,i.anEdge);n.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,n.debugEvent(t),n.doneEdgeDict(t),n.donePriorityQ(t),n.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},n}(),Rb=function(){function n(){this.mesh=new mh,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=He.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 n.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},n.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},n.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},n.prototype.computeNormal_=function(t){var e,r,i,o,s,a,l=[0,0,0],c=[0,0,0],p=[0,0,0],u=[0,0,0],h=[0,0,0],m=[null,null,null],f=[null,null,null],L=this.mesh.vHead;e=L.next;for(var S=0;S<3;++S)o=e.coords[S],c[S]=o,f[S]=e,l[S]=o,m[S]=e;for(e=L.next;e!==L;e=e.next)for(var y=0;y<3;++y)o=e.coords[y],o<c[y]&&(c[y]=o,f[y]=e),o>l[y]&&(l[y]=o,m[y]=e);var w=0;if(l[1]-c[1]>l[0]-c[0]&&(w=1),l[2]-c[2]>l[w]-c[w]&&(w=2),c[w]>=l[w]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,r=f[w],i=m[w],p[0]=r.coords[0]-i.coords[0],p[1]=r.coords[1]-i.coords[1],p[2]=r.coords[2]-i.coords[2],e=L.next;e!==L;e=e.next)u[0]=e.coords[0]-i.coords[0],u[1]=e.coords[1]-i.coords[1],u[2]=e.coords[2]-i.coords[2],h[0]=p[1]*u[2]-p[2]*u[1],h[1]=p[2]*u[0]-p[0]*u[2],h[2]=p[0]*u[1]-p[1]*u[0],s=h[0]*h[0]+h[1]*h[1]+h[2]*h[2],s>a&&(a=s,t[0]=h[0],t[1]=h[1],t[2]=h[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(p)]=1)},n.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,i,o=0,s=t.next;s!==t;s=s.next)if(i=s.anEdge,!(i.winding<=0))do o+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==s.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]}},n.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,i,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,i=this.tUnit;var s=this.longAxis_(e);r[s]=0,r[(s+1)%3]=1,r[(s+2)%3]=0,i[s]=0,i[(s+1)%3]=0,i[(s+2)%3]=e[s]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,i);o&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},n.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(t,e){var r,i;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;ae.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ae.vertLeq(r.Org,r.Dst);r=r.Lnext);i=r.Lprev;for(var o=void 0;r.Lnext!==i;)if(ae.vertLeq(r.Dst,i.Org)){for(;i.Lnext!==r&&(ae.edgeGoesLeft(i.Lnext)||ae.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)o=t.connect(i.Lnext,i),i=o.Sym;i=i.Lprev}else{for(;i.Lnext!==r&&(ae.edgeGoesRight(r.Lprev)||ae.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)o=t.connect(r,r.Lprev),r=o.Sym;r=r.Lnext}if(i.Lnext===r)throw"Mono region invalid";for(;i.Lnext.Lnext!==r;)o=t.connect(i.Lnext,i),i=o.Sym;return!0},n.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},n.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},n.prototype.setWindingNumber_=function(t,e,r){for(var i,o=t.eHead.next;o!==t.eHead;o=i)i=o.next,o.Rface.inside!==o.Lface.inside?o.winding=o.Lface.inside?e:-e:r?t.delete(o):o.winding=0},n.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},n.prototype.outputPolymesh_=function(t,e,r,i){var o,s=0,a=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var p=t.fHead.next;p!==t.fHead;p=p.next)if(p.n=-1,!!p.inside){o=p.anEdge,l=0;do{var c=o.Org;c.n===-1&&(c.n=a,a++),l++,o=o.Lnext}while(o!==p.anEdge);if(l>r)throw"Face vertex greater that support polygon";p.n=s,++s}this.elementCount=s,e===rt.CONNECTED_POLYGONS&&(s*=2),this.elements=[],this.elements.length=s*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var u=c.n*i;this.vertices[u+0]=c.coords[0],this.vertices[u+1]=c.coords[1],i>2&&(this.vertices[u+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var h=0,p=t.fHead.next;p!==t.fHead;p=p.next)if(!!p.inside){o=p.anEdge,l=0;do{var c=o.Org;this.elements[h++]=c.n,l++,o=o.Lnext}while(o!==p.anEdge);for(var m=l;m<r;++m)this.elements[h++]=-1;if(e===rt.CONNECTED_POLYGONS){o=p.anEdge;do this.elements[h++]=this.getNeighbourFace_(o),o=o.Lnext;while(o!==p.anEdge);for(var f=l;f<r;++f)this.elements[h++]=-1}}},n.prototype.outputContours_=function(t,e){var r,i,o=0,s=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){i=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==i);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 l=0,c=0,p=0;o=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){s=0,i=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,s++,r=r.Lnext;while(r!==i);this.elements[p++]=o,this.elements[p++]=s,o+=s}},n.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new mh),t<2&&(t=2),t>3&&(t=3);for(var r=null,i=0;i<e.length;i+=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[i+0],r.Org.coords[1]=e[i+1],t>2?r.Org.coords[2]=e[i+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},n.prototype.tesselate=function(t,e,r,i,o,s){if(t===void 0&&(t=He.ODD),e===void 0&&(e=rt.POLYGONS),s===void 0&&(s=!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,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),zb.computeInterior(this,s);var a=this.mesh;return e===rt.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),s&&a.check(),e===rt.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,e,r,i),!0},n}();function di(n){var t=n.windingRule,e=t===void 0?He.ODD:t,r=n.elementType,i=r===void 0?rt.POLYGONS:r,o=n.polySize,s=o===void 0?3:o,a=n.vertexSize,l=a===void 0?2:a,c=n.normal,p=c===void 0?[0,0,1]:c,u=n.contours,h=u===void 0?[]:u,m=n.strict,f=m===void 0?!0:m,L=n.debug,S=L===void 0?!1:L;if(!h&&f)throw new Error("Contours can't be empty");if(!!h){var y=new Rb;n.edgeCreateCallback&&(y.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(y.vertexIdCallback=n.vertexIdCallback);for(var w=0;w<h.length;w++)y.addContour(l||2,h[w]);return y.tesselate(e,i,s,l,p,f),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:S?y.mesh:void 0}}}var tD=He.ODD,rD=He.NONZERO,iD=He.POSITIVE,oD=He.NEGATIVE,nD=He.ABS_GEQ_TWO,sD=rt.POLYGONS,aD=rt.CONNECTED_POLYGONS,lD=rt.BOUNDARY_CONTOURS;var Kr=class extends Vb{constructor(e,r=12,i=100,o={}){super();this.type="ShapeGeometry";this.windingRule=He.ODD;this.elementType=rt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._drawCount=0,this._shape=e,this._curveSegments=r,this._maxCount=i,this._maxDrawCount=i*3,this._triangulationOptions=Object.assign({windingRule:He.ODD,elementType:rt.POLYGONS,polySize:3,vertexSize:2,strict:!0},o),this._positionAttribute=new Vs(new Float32Array(i*3),3),this._normalAttribute=new Vs(new Float32Array(i*3),3),this._uvAttribute=new Vs(new Float32Array(i*2),2),this._indexAttribute=new Vs(new Uint32Array(i*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(c=>c.extractShapePointsToFlatArray([],this._curveSegments)),i,o=!0,s=!0,a,l;for(let c=0,p=e.length/2;c<p;c++){let u=c*2,h=e[u+0],m=e[u+1];if(a!==void 0&&h!==a&&(o=!1),l!==void 0&&m!==l&&(s=!1),a=h,l=m,!o&&!s)break}if(!o&&!s&&(i=di({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,i){let c=1/0,p=-1/0,u=1/0,h=-1/0;for(let L=0,S=i.vertexCount;L<S;L++){let y=L*2,w=i.vertices[y+0],I=i.vertices[y+1];w<c&&(c=w),w>p&&(p=w),I<u&&(u=I),I>h&&(h=I)}let m=p-c,f=h-u;for(let L=0,S=i.vertexCount;L<S;L++){let y=L*2,w=i.vertices[y+0],I=i.vertices[y+1],_=(w-c)/m,g=(I-u)/f;this._positionAttribute.setXYZ(L,w,I,0),this._normalAttribute.setXYZ(L,0,0,1),this._uvAttribute.setXY(L,_,g)}for(let L=0,S=i.elementCount;L<S;L++){let y=L*3,w=i.elements[y+0],I=i.elements[y+1],_=i.elements[y+2];this._indexAttribute.setX(y+0,w),this._indexAttribute.setX(y+1,I),this._indexAttribute.setX(y+2,_),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 Kr(this._shape,this._curveSegments,this._maxCount);return e.userData=_o(this.userData),e}};import{BufferAttribute as js,BufferGeometry as Fb}from"three";var Fs=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*Fs.eSize;this.buffer=new ArrayBuffer(r);let i=Float32Array.BYTES_PER_ELEMENT,o=0;this.positions=new Float32Array(this.buffer,o*i,3*t),o+=3*t,this.normals=new Float32Array(this.buffer,o*i,3*t),o+=3*t,this.uvs=new Float32Array(this.buffer,o*i,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*Fs.eSize,i=new ArrayBuffer(r),o=Float32Array.BYTES_PER_ELEMENT,s=0,a=new Float32Array(i,s*o,3*t);s+=3*t;let l=new Float32Array(i,s*o,3*t);s+=3*t;let c=new Float32Array(i,s*o,2*t);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),c.set(this.uvs.slice(0,this.size*2)),this.buffer=i,this.positions=a,this.normals=l,this.uvs=c,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let i=this.capacity;for(;e>i;)i*=2;this.realloc(i)}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)}},Ko=Fs;Ko.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var yl=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),eo=class extends Fb{constructor(e,r,i=0,o=12,s=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._bevel=i,this._curveSegments=o,this._bevelSegmentsInput=s,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,r/2-1e-12),this._bevelSegments=Math.floor(s));let a=this._shape.extractShapePointsToFlatArray([],o),l=this._shape.shapeHoles.map(b=>{let d=b.extractShapePointsToFlatArray([],o),O=[];for(let x=d.length-1;x>=1;x-=2){let M=d[x-1],C=d[x-0];O.push(M,C)}return O}),c=di({windingRule:He.ODD,elementType:rt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[a]}),p=di({windingRule:He.ODD,elementType:rt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]});if(!c)throw new Error("error generating geometry");let u=c.elementCount;if(p){c.elementCount+=p.elementCount;for(let b=0;b<p.elements.length;b++){let d=p.elements[b],O=b%2===0?c.vertexCount:0;c.elements.push(d+O)}for(let b=0;b<p.vertexIndices.length;b++){let d=p.vertexIndices[b],O=c.vertexCount;c.vertexIndices.push(d+O)}for(let b=0;b<p.vertices.length;b++){let d=p.vertices[b];c.vertices.push(d)}}let h=1/0,m=-1/0,f=1/0,L=-1/0;for(let b=0,d=c.vertexCount;b<d;b++){let O=b*2,x=c.vertices[O+0],M=c.vertices[O+1];x<h&&(h=x),x>m&&(m=x),M<f&&(f=M),M>L&&(L=M)}this._minX=h,this._minY=f,this._width=m-h,this._height=L-f;let S=c.vertexCount*2*(2+this._bevelSegments);this._buffer=new Ko(S);let y=[],w=[];for(let b=c.elementCount-1;b>=0;b--){let d=b>=u,O=b*2,x=c.elements[O+0],M=c.elements[O+1],C=x+M,T={start:x,count:M,normals:[],continuous:[],concave:[]},$=x,H=C-1,ie=x+1,pe=this._shape.roundedCurves.length;do{let G=$-x,D=c.vertices[H*2+0],z=c.vertices[H*2+1],A=c.vertices[$*2+0],R=c.vertices[$*2+1],K=c.vertices[ie*2+0],Z=c.vertices[ie*2+1],U=A-D,j=R-z,B=Math.sqrt(U*U+j*j);U/=B,j/=B;let k=A-K,ne=R-Z,q=Math.sqrt(k*k+ne*ne);k/=q,ne/=q,T.normals[G*2+0]=-ne,T.normals[G*2+1]=k,T.concave[G]=U*ne-j*k>0;let J=c.vertexIndices[$];if(Array.isArray(J))T.continuous[G]=!1;else{let[Y,X]=this._shape.getCurveIndexFromVertexId(J-1,!0);if(X>0&&X<1)T.continuous[G]=!0;else{let Q=X===1?Y+1:Y-1;Q=(Q+pe)%pe;let se=X===1?0:1,oe=this._shape.roundedCurves[Y].getTangent(X),ue=this._shape.roundedCurves[Q].getTangent(se);T.continuous[G]=oe.dot(ue)>.95}}d&&(T.normals[G*2+0]*=-1,T.normals[G*2+1]*=-1),[H,$,ie]=[$,ie,ie+1],ie>=C&&(ie-=M)}while(ie!==x+1);let ce=[];ce.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(x*2,C*2),vertexCount:M,vertexIndices:new Array(M).fill(!0).map((G,D)=>[D,D]),elements:[0,M],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(x*2,C*2)});for(let G=1;G<=this._bevelSegments;G++){let D=G/this._bevelSegments*Math.PI/2,z=(1-Math.cos(D))*this._bevelSize,A=[],R=[],K=[],Z=[],U=0;for(let B=0;B<M;B++){let k=B*2,ne=(B-1+M)%M*2,q=c.vertices[T.start*2+k+0],J=c.vertices[T.start*2+k+1],Y=-T.normals[ne+0]*z,X=-T.normals[ne+1]*z,Q=-T.normals[k+0]*z,se=-T.normals[k+1]*z;if(T.concave[B]||!T.concave[B]&&d){let oe=Math.atan2(X,Y),ue=Math.atan2(se,Q);ue>oe&&(ue-=Math.PI*2);let Ee=ue-oe;if(T.continuous[B]||d){let xe=oe+Ee/2,We=Math.cos(xe)*z,Le=Math.sin(xe)*z;A[2*U+0]=q+We*(d?-1:1),A[2*U+1]=J+Le*(d?-1:1),Z[U]=B,U++}else{let xe=Math.max(1,Math.floor(o/4*Math.abs(Ee)/Math.PI));for(let We=0;We<=xe;We++){let Le=oe+Ee*(We/xe),ct=Math.cos(Le)*z,wt=Math.sin(Le)*z;A[2*U+0]=q+ct,A[2*U+1]=J+wt,Z[U]=B,U++}}}else A[2*U+0]=q+Y,A[2*U+1]=J+X,Z[U]=B,R[B]=U,U++,A[2*U+0]=q,A[2*U+1]=J,Z[U]=B,U++,A[2*U+0]=q+Q,A[2*U+1]=J+se,Z[U]=B,K[B]=U,U++}let j=di({windingRule:He.POSITIVE,elementType:rt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[A],edgeCreateCallback:B=>{let ne=B.Org.idx,q=Z[ne],J=Z[(ne+1)%Z.length];B.idx=[q,J],B.Sym.idx=[J,q]},vertexIdCallback:B=>{let k=B.Lprev.idx;return[k?k[1]:0,B.idx[0]]}});if(!j)throw console.log("Error"),new Error(`error generating bevel geometry for ${G}'th loop`);if(!j.vertexCount)break;for(let B=0;B<j.vertexIndices.length;B++){let[k,ne]=j.vertexIndices[B];if(k===ne)continue;let q=ne;ne<k&&(q+=M);for(let J=k;J<q;J++){let Y=J%M,X=(J+1)%M;if(!T.continuous[Y]||!T.continuous[X]){j.vertexIndices[B]=[k,Y],j.vertexIndices.splice(B+1,0,[X,ne]),j.vertices.splice((B+1)*2,0,j.vertices[B*2],j.vertices[B*2+1]);break}}}ce.push({bevelI:G,angle:D,size:z,boundary:j,reverseMap:Z,insetPoints:A})}let be=(G,D,z)=>{let A=0,R=G.boundary.vertexIndices.length;for(;A<R&&z(G.boundary.vertexIndices[D]);)D=(D+1)%R,A++;return A},F=y.length;for(let G=1;G<ce.length;G++){let D=ce[G-1],z=ce[G],A=D.boundary.vertexIndices.length,R=z.boundary.vertexIndices.length;if(!A||!R)break;let K=T.concave.length,Z=0,U=yl(Z,M);for(;!D.boundary.vertexIndices.filter(U).length||!z.boundary.vertexIndices.filter(U).length;)Z++,U=yl(Z,M);let j=D.boundary.vertexIndices.findIndex(U),B=z.boundary.vertexIndices.findIndex(U);do j=(j+1)%A;while(U(D.boundary.vertexIndices[j]));do B=(B+1)%R;while(U(z.boundary.vertexIndices[B]));Z=(Z+1)%M;let k=Z,ne=this.buildBevelVert(T,D,(j-1+A)%A),q=this.buildBevelVert(T,z,(B-1+R)%R),J=ne,Y=q,X,Q,se=!1;do{U=yl(Z,M);let oe=be(D,j,U),ue=be(z,B,U),Ee=se;if(se=!1,oe&&!ue){for(let xe=0;xe<oe;xe++)X=this.buildBevelVert(T,D,(j+xe)%A,xe/(oe-1)),y.push(J.topN,X.topP,Y.topN),y.push(X.bottomP,J.bottomN,Y.bottomN),J=X;se=!0}else if(!oe&&ue)for(let xe=0;xe<ue;xe++)Q=this.buildBevelVert(T,z,(B+xe)%R,xe/(ue-1)),y.push(Y.topN,J.topP,Q.topP),y.push(J.bottomP,Y.bottomN,Q.bottomP),Y=Q;else if(oe&&ue)if(X=this.buildBevelVert(T,D,j,0),Q=this.buildBevelVert(T,z,B,0),Ee?(y.push(J.topN,Q.topP,Y.topN),y.push(J.topN,X.topP,Q.topP),y.push(Q.bottomP,J.bottomN,Y.bottomN),y.push(X.bottomP,J.bottomN,Q.bottomP)):(y.push(J.topN,X.topP,Y.topN),y.push(Y.topN,X.topP,Q.topP),y.push(X.bottomP,J.bottomN,Y.bottomN),y.push(X.bottomP,Y.bottomN,Q.bottomP)),J=X,Y=Q,oe===ue)for(let xe=1;xe<oe;xe++)X=this.buildBevelVert(T,D,(j+xe)%A,xe/(oe-1)),Q=this.buildBevelVert(T,z,(B+xe)%R,xe/(ue-1)),y.push(J.topN,X.topP,Y.topN),y.push(Y.topN,X.topP,Q.topP),y.push(X.bottomP,J.bottomN,Y.bottomN),y.push(X.bottomP,Y.bottomN,Q.bottomP),J=X,Y=Q;else if(oe>ue){let xe=oe/ue,We=0;for(let Le=1;Le<oe;Le++)X=this.buildBevelVert(T,D,(j+Le)%A,Le/(oe-1)),y.push(J.topN,X.topP,Y.topN),y.push(X.bottomP,J.bottomN,Y.bottomN),J=X,Le>(We+1)*xe&&(We++,Q=this.buildBevelVert(T,z,(B+We)%R,We/(ue-1)),y.push(Y.topN,X.topP,Q.topP),y.push(X.bottomP,Y.bottomN,Q.bottomP),Y=Q)}else{let xe=ue/oe,We=0;for(let Le=1;Le<ue;Le++)Q=this.buildBevelVert(T,z,(B+Le)%R,Le/(ue-1)),y.push(Y.topN,X.topP,Q.topP),y.push(X.bottomP,Y.bottomN,Q.bottomP),Y=Q,Le>(We+1)*xe&&(We++,X=this.buildBevelVert(T,D,(j+We)%A,We/(oe-1)),y.push(J.topN,X.topP,Y.topN),y.push(X.bottomP,J.bottomN,Y.bottomN),J=X)}j=(j+oe)%A,B=(B+ue)%R,Z=(Z+1)%K}while(Z!==k)}{let G=ce[0];for(let D=0,z=G.boundary.vertexCount;D<z;D++){let A=this.buildBevelVert(T,G,D),R=this.buildBevelVert(T,G,(D+1)%z);y.push(R.topP,A.topN,A.bottomN),y.push(R.topP,A.bottomN,R.bottomP)}}if(d){let G=[];for(let D=y.length-1;D>=F+2;D-=3){let z=y[D-2],A=y[D-1],R=y[D-0];G.push(R,A,z)}y.splice(F,y.length-F,...G)}if(d){let G=[];for(let D=ce[ce.length-1].boundary.vertices.length-1;D>=1;D-=2){let z=ce[ce.length-1].boundary.vertices[D-1],A=ce[ce.length-1].boundary.vertices[D-0];G.push(z,A)}w.push(G)}if(!d){let G=ce[ce.length-1],D=di({windingRule:ce.length>1?He.POSITIVE:He.ODD,elementType:rt.POLYGONS,vertexSize:2,strict:!0,contours:[G.insetPoints,...w]});if(!D)throw new Error("Error generating geometry for surface");for(let z=0;z<D.elementCount*3;z+=3){let A=this.buildSurfaceVert(D,D.elements[z+0]),R=this.buildSurfaceVert(D,D.elements[z+1]),K=this.buildSurfaceVert(D,D.elements[z+2]);y.push(A.top,R.top,K.top),y.push(K.bottom,R.bottom,A.bottom)}}this.vertexCache={}}this._buffer.shrink();let I=new js(Uint32Array.from(y),1),_=new js(this._buffer.positions,3),g=new js(this._buffer.normals,3),V=new js(this._buffer.uvs,2);_.needsUpdate=!0,g.needsUpdate=!0,V.needsUpdate=!0,I.needsUpdate=!0,this.setAttribute("position",_),this.setAttribute("normal",g),this.setAttribute("uv",V),this.setIndex(I)}buildSurfaceVert(e,r){let i=r.toString();if(i in this.vertexCache)return this.vertexCache[i];let o=e.vertices[r*2+0],s=e.vertices[r*2+1],a=(o-this._minX)/this._width,l=(s-this._minY)/this._height,c=this._buffer.get(2),p=c*3,u=c*2,h={top:c+0,bottom:c+1};return this._buffer.positions[p+0]=o,this._buffer.positions[p+1]=s,this._buffer.positions[p+2]=this._depth,this._buffer.normals[p+0]=0,this._buffer.normals[p+1]=0,this._buffer.normals[p+2]=1,this._buffer.uvs[u+0]=a,this._buffer.uvs[u+1]=l,this._buffer.positions[p+3]=o,this._buffer.positions[p+4]=s,this._buffer.positions[p+5]=0,this._buffer.normals[p+3]=0,this._buffer.normals[p+4]=0,this._buffer.normals[p+5]=-1,this._buffer.uvs[u+2]=a,this._buffer.uvs[u+3]=l,this.vertexCache[i]=h,h}buildBevelVert(e,r,i,o=1){let s=`${r.bevelI}:${i}`;if(s in this.vertexCache)return this.vertexCache[s];let[a,l]=r.boundary.vertexIndices[i],c,p,u,h;a!==l?(p=a,c=l,h=!1,u=e.continuous[p]&&e.continuous[c]):(c=a,p=(c-1+e.count)%e.count,h=e.concave[c]&&r.bevelI>0,u=e.continuous[c]||h);let m=Math.cos(r.angle),f=Math.sin(r.angle),L=i*2,S=c*2,y=p*2,w=r.boundary.vertices[L+0],I=r.boundary.vertices[L+1],_=(1-f)*this._bevelSize,g=(w-this._minX)/this._width,V=(I-this._minY)/this._height,b=e.normals[S+0],d=e.normals[S+1],O=e.normals[y+0],x=e.normals[y+1];if(h){let H=O-b,ie=x-d;b=b+H*(1-o),d=d+ie*(1-o);let pe=Math.sqrt(b*b+d*d);b/=pe,d/=pe}let M=this._buffer.get(u?2:4),C=M*3,T=M*2,$={i,fi:c,topP:M+0,topN:M+0,bottomP:M+1,bottomN:M+1};return this._buffer.positions[C+0]=w,this._buffer.positions[C+1]=I,this._buffer.positions[C+2]=this._depth-_,this._buffer.normals[C+0]=b*m,this._buffer.normals[C+1]=d*m,this._buffer.normals[C+2]=f,this._buffer.uvs[T+0]=g,this._buffer.uvs[T+1]=V,this._buffer.positions[C+3]=w,this._buffer.positions[C+4]=I,this._buffer.positions[C+5]=_,this._buffer.normals[C+3]=b*m,this._buffer.normals[C+4]=d*m,this._buffer.normals[C+5]=-f,this._buffer.uvs[T+2]=V,this._buffer.uvs[T+3]=g,u||(M+=2,C+=6,T+=4,$.topP=M+0,$.bottomP=M+1,this._buffer.positions[C+0]=w,this._buffer.positions[C+1]=I,this._buffer.positions[C+2]=this._depth-_,this._buffer.normals[C+0]=O*m,this._buffer.normals[C+1]=x*m,this._buffer.normals[C+2]=f,this._buffer.uvs[T+0]=g,this._buffer.uvs[T+1]=V,this._buffer.positions[C+3]=w,this._buffer.positions[C+4]=I,this._buffer.positions[C+5]=_,this._buffer.normals[C+3]=O*m,this._buffer.normals[C+4]=x*m,this._buffer.normals[C+5]=-f,this._buffer.uvs[T+2]=V,this._buffer.uvs[T+3]=g),this.vertexCache[s]=$,$}clone(){let e=new eo(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=_o(this.userData),e}};var ut=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var c,p,u,h,m,f,L;let e=Object.assign({},(c=t==null?void 0:t.parameters)!=null?c:{width:100,subdivisions:40,roundness:0,extrudeDepth:0,surfaceMaxCount:100,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(e.width),i=Math.abs((p=e.height)!=null?p:e.width),o=Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(u=e.depth)!=null?u:0),s=(h=n.shape)!=null?h:t==null?void 0:t.shape,a=(m=s==null?void 0:s.roundness)!=null?m:e.roundness;s!==void 0&&(s instanceof Me?(s.width!==r||s.height!==i)&&s.applySize(r,i):s=new Me(r,i).fromJSON(s),((f=n.parameters)==null?void 0:f.roundness)!==void 0&&((L=n.parameters)==null?void 0:L.roundness)>0&&s.update(!1));let l=s!=null?s:new Me(r,i);return{parameters:Object.assign(e,{width:r,height:i,depth:o,extrudeDepth:o,roundness:a}),shape:l}}static build(n){let{extrudeDepth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:i,roundness:o,surfaceMaxCount:s}=n.parameters;n.shape.roundness=o;let a;return t<=0?a=new Kr(n.shape,i,s):a=new eo(n.shape,t,e,i,r),Object.assign(a,{userData:W(P({},n),{type:"VectorGeometry"})})}};import{MathUtils as bh,Vector2 as vh}from"three";var Sh=Math.PI*2,wh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var i,o,s;let e=Object.assign({},(i=t==null?void 0:t.parameters)!=null?i:{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1e3},n.parameters);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,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:(s=e.depth)!=null?s:0)})}}static build(n){let{width:t,height:e,spikes:r,angle:i,innerRadius:o,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l,surfaceMaxCount:c}=n.parameters,p=n.shape,u=t*.5,h=e*.5,m=jb(p,u,h,i*Math.PI/180,r,o);p.isClosed=!0,p.update();let f=ut.create({shape:p,parameters:{subdivisions:m,surfaceMaxCount:c,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(f,{userData:W(P({},n),{type:"EllipseGeometry"})})}};function jb(n,t,e,r,i,o){if(r>=Sh)return i>30||i%4===0?(kb(n,t,e,o),Math.round(i/4)):xh(n,r,i,t,e,o);let s={x:0,y:e},a=r+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},c=dh({px:s.x,py:s.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return i>30||i%c.length===0?Ub(n,s.x,s.y,c,i,t,e,o):xh(n,r,i,t,e,o)}function Ub(n,t,e,r,i,o,s,a){let l=Math.round(i/r.length);n.addPoint(to(t,e));for(let c=0,p=r.length;c<p;c++){let u=r[c],h=n.points[c],m=to(u.x,u.y);h.controls[1].position.set(u.x1,u.y1),m.controls[0].position.set(u.x2,u.y2),n.addPoint(m)}return a>0?Ch(n,o,s,a):n.addPoint(to(0,0)),l}function xh(n,t,e,r,i,o){let s=-t/e;for(let a=0;a<=e;a++){let l=s*a,c=Math.sin(l)*r,p=Math.cos(l)*i;n.addPoint(to(c,p))}return t<Sh?o>0?Ch(n,r,i,o):n.addPoint(to(0,0)):(n.removePoint(n.points[n.points.length-1]),o>0&&Lh(n,r,i,o)),1}function kb(n,t,e,r=0,i=0,o=0){let s=.5522847498,a=t*s,l=e*s;n.addPoint(Us(i-t,o,i-t,o-l,i-t,o+l)),n.addPoint(Us(i,o+e,i-a,o+e,i+a,o+e)),n.addPoint(Us(i+t,o,i+t,o+l,i+t,o-l)),n.addPoint(Us(i,o-e,i+a,o-e,i-a,o-e)),r>0&&Lh(n,t,e,r)}function to(n,t){return new Qt(bh.generateUUID(),new vh(n,t))}function Us(n,t,e,r,i,o){let s=to(n,t);return s.controls[0].position.set(e,r),s.controls[1].position.set(i,o),s}function Ch(n,t,e,r){Th(n,t,e,r).forEach(o=>n.addPoint(o))}function Lh(n,t,e,r){let i=Th(n,t,e,r),o=new Me;i.forEach(s=>o.addPoint(s)),o.isClosed=!0,n.shapeHoles.push(o)}function Th(n,t,e,r){let i=r*t/100,o=i*(Math.abs(e)/Math.abs(t)),s=new vh(i/t,o/e),a=n.points.map(l=>{let c=l.clone();return c.uuid=bh.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(s);let c=l.controls[0].position.clone().multiply(s),p=l.controls[1].position.clone().multiply(s);l.controls[0].position.copy(p),l.controls[1].position.copy(c)}),a}import{BufferGeometry as Hb,Float32BufferAttribute as gl,Vector3 as Nh}from"three";var Mh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var a,l,c;let e=Object.assign({},(a=t==null?void 0:t.parameters)!=null?a:{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),r=Math.abs(e.width),i=Math.abs((l=e.height)!=null?l:r),o=Math.abs((c=e.depth)!=null?c:r),s=Math.abs(Math.min(r,o))/2;return{parameters:Object.assign(e,{width:r,height:i,depth:o,radius:s,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:t,height:e,depth:r,radius:i,revolutions:o,segments:s,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:p,cornerSegments:u}=n.parameters,h=new Yo(!1,t,e,r,i,o,s,a,l,c,p,u);return Object.assign(h,{userData:W(P({},n),{type:"HelixGeometry"})})}},Yo=class extends Hb{constructor(t=!0,e=1,r=1,i=1,o=1,s=1,a=1,l=1,c=1,p=1,u=1,h=1){super();let m=t&&s===1;m&&(h=0),u>100&&(u=100);let f=()=>new Nh,L=new Nh,S=f(),y=f(),w=f(),I,_,g,V,b,d,O,x,M=f(),C=f(),T=f(),$=f(),H=f(),ie=f(),pe=f(),ce=f(),be=r-2*l+.001,F=be/s,G=Math.ceil(a*s),D=G+1,z=be/G,A=-be/2,R=p+1,K=2*Math.PI/p,Z=Math.PI/2/h,U=.01,j=Math.min((1-u/100)*l,l-U),B=l-j,k=0,ne=2,q=h*ne+ne,J=R*q/ne,Y=J+R*D,X=R*(D+q),[Q,se,oe]=[3,3,2].map(Ue=>Array(X*Ue).fill(0)),ue=[],Ee=o-l;function xe(Ue,yt){let _t=Math.PI/2;d=yt*z,x=2*Math.PI*(d%F)/F+_t,d+=A,O=Math.sin(x)*Ee,b=Math.cos(x)*Ee,t?Ue.set(b,O,d):Ue.set(b,d,O)}xe(L,-1e-10),xe(S,0),M.copy(L),xe(L,1);let We=L.distanceTo(S),Le=B+j,ct=We*G+2*Le,wt=j,br=ct-Le;for(let Ue=0;Ue<=G;Ue++){xe(y,Ue),ce.subVectors(y,M).normalize(),M.copy(y),ie.copy(y).setComponent(+t+1,0).normalize(),pe.crossVectors(ce,ie).normalize();let yt=Ue===0,_t=Ue===G,Tn=yt?3*Math.PI/2:Z,Nn=yt?wt:br,Mn=yt?R:Y,On=yt?0:X-R,In=ce.clone().multiplyScalar(yt?-B:B).add(y),Pn=ce.clone().multiplyScalar(yt?-1:1).normalize();for(let jt=0;jt<R;jt++){let Io=jt*K;if(C.addVectors(L.copy(ie).multiplyScalar(l*Math.cos(Io)),S.copy(pe).multiplyScalar(l*Math.sin(Io))),T.copy(C).normalize(),yt||_t){m||(k=On+jt,[0,1,2].forEach(pt=>{Q[k*3+pt]=In.getComponent(pt),se[k*3+pt]=Pn.getComponent(pt)}),oe[k*2]=+_t,oe[k*2+1]=jt/p),S.copy(T).multiplyScalar(j),w.addVectors(y,S);for(let pt=0;pt<h;pt++){let wi=pt*Z+Tn;$.addVectors(L.copy(ce).multiplyScalar(B*Math.sin(wi)),S.copy(T).multiplyScalar(B*Math.cos(wi))),H.copy($).normalize(),S.addVectors(w,$),$.normalize(),k=Mn+pt*R+jt,[0,1,2].forEach(ge=>{Q[k*3+ge]=S.getComponent(ge),se[k*3+ge]=H.getComponent(ge)});let An=+yt+Math.sin(wi);oe[k*2]=(Nn+B*An)/ct,oe[k*2+1]=jt/p}}S.addVectors(y,C),k=J+Ue*R+jt,[0,1,2].forEach(pt=>{Q[k*3+pt]=S.getComponent(pt),se[k*3+pt]=T.getComponent(pt)}),oe[k*2]=(Le+Ue*We)/ct,oe[k*2+1]=jt/p}}let ft=D+2*h+ne,vr=1,[oi,ni]=m?[vr,vr+D-1]:[0,ft-1];for(let Ue=oi;Ue<=ni-1;Ue++){let yt=m&&Ue===ni-1;for(let _t=0;_t<R-1;_t++)I=Ue*R+_t,_=I+1,g=(yt?_t:I)+R,V=(yt?_t+1:_)+R,Ue===0?ue.push(_,V,g):Ue===ft-2?ue.push(I,_,g):ue.push(I,_,g,_,V,g)}this.setIndex(ue),this.setAttribute("position",new gl(Q,3)),this.setAttribute("normal",new gl(se,3)),this.setAttribute("uv",new gl(oe,2))}};import{IcosahedronBufferGeometry as qb}from"three";var Oh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:i,corner:o,cornerSides:s}=n.parameters,a=i===0&&o!==0?new Xo(t*.5,o,s):new qb(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:W(P({},n),{type:"IcosahedronGeometry"})})}},Xo=class extends $r{constructor(t=1,e=.2,r=4){let i=(1+Math.sqrt(5))/2,o=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[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],a="IcosahedronGeometry";super(o,s,a,t,e,r),this.type=a}static fromJSON(t){return new Xo(t.radius,t.corner,t.cornerSides)}};import{LatheBufferGeometry as Wb,Shape as $b}from"three";var Ih=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o,s,a;((i=(r=n.parameters)==null?void 0:r.points)!=null?i:[]).forEach(l=>{Array.isArray(l)&&(l.x=l[0],l.y=l[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}]},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((s=e.height)!=null?s:e.width),depth:Math.abs((a=e.depth)!=null?a:e.width)})}}static build(n){let{points:t,segments:e,verticalSegments:r}=n.parameters,i=new $b;i.moveTo(t[0].x,t[0].y),i.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let o=new Wb(i.extractPoints(r).shape,e);return o.rotateZ(Math.PI),Object.assign(o,{userData:W(P({},n),{type:"LatheGeometry"})})}};import{BufferGeometry as Ah,BufferGeometryLoader as ev,Vector3 as tv,BoxBufferGeometry as Dh}from"three";import{BufferGeometry as Jb,Vector2 as xl,Vector3 as Ph}from"three";import{Geometry as Kb,Face3 as Yb}from"three/examples/jsm/deprecated/Geometry.js";var Xb=["a","b","c"];function Zb(n,t){switch(t){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function bl(n,t,e){let r=Math.min(n,t),i=Math.max(n,t),o=r+"_"+i;return e.get(o)}function vl(n,t,e,r,i,o){let s=Math.min(n,t),a=Math.max(n,t),l=s+"_"+a,c;if(r.has(l))c=r.get(l);else{let p=e[s],u=e[a];c={a:p,b:u,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(i),o[n].edges.push(c),o[t].edges.push(c)}function Qb(n,t,e,r){let i,o,s;for(i=0,o=n.length;i<o;i++)e[i]={edges:[]};for(i=0,o=t.length;i<o;i++)s=t[i],vl(s.a,s.b,n,r,s,e),vl(s.b,s.c,n,r,s,e),vl(s.c,s.a,n,r,s,e)}function ks(n,t,e,r,i){n.push(new Yb(t,e,r,void 0,void 0,i))}function ro(n,t){return Math.abs(t-n)/2+Math.min(n,t)}function Hs(n,t,e,r){n.push([t.clone(),e.clone(),r.clone()])}var qs=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Jb?t=new Kb().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 Ph,r,i,o,s,a,l=t.vertices,c=t.faces,p=t.faceVertexUvs[0],u=p!==void 0&&p.length>0,h=[],m=new Map;Qb(l,c,h,m);let f=[],L,S,y,w,I,_,g;for(let U of Array.from(m.keys())){for(S=m.get(U),y=new Ph,I=3/8,_=1/8,g=S.faces.length,g!=2&&(I=.5,_=0,g!=1),y.addVectors(S.a,S.b).multiplyScalar(I),e.set(0,0,0),s=0;s<g;s++){for(w=S.faces[s],a=0;a<3&&(L=l[Zb(w,Xb[a])],!(L!==S.a&&L!==S.b));a++);L&&e.add(L)}e.multiplyScalar(_),y.add(e),S.newEdge=f.length,f.push(y)}let V,b,d,O,x,M,C,T=[];for(i=0,o=l.length;i<o;i++){for(M=l[i],x=h[i].edges,r=x.length,r==3?V=3/16:r>3&&(V=3/(8*r)),b=1-r*Number(V),d=V,r<=2&&(r==2?(b=3/4,d=1/8):r==1||r==0),C=M.clone().multiplyScalar(b),e.set(0,0,0),s=0;s<r;s++)O=x[s],L=O.a!==M?O.a:O.b,e.add(L);e.multiplyScalar(Number(d)),C.add(e),T.push(C)}let $=T.concat(f),H=T.length,ie,pe,ce,be=[],F=[],G,D,z,A,R=new xl,K=new xl,Z=new xl;for(i=0,o=c.length;i<o;i++)w=c[i],ie=Number(bl(w.a,w.b,m).newEdge)+H,pe=Number(bl(w.b,w.c,m).newEdge)+H,ce=Number(bl(w.c,w.a,m).newEdge)+H,ks(be,ie,pe,ce,w.materialIndex),ks(be,w.a,ie,ce,w.materialIndex),ks(be,w.b,pe,ie,w.materialIndex),ks(be,w.c,ce,pe,w.materialIndex),u&&(G=p[i],D=G[0],z=G[1],A=G[2],R.set(ro(D.x,z.x),ro(D.y,z.y)),K.set(ro(z.x,A.x),ro(z.y,A.y)),Z.set(ro(D.x,A.x),ro(D.y,A.y)),Hs(F,R,K,Z),Hs(F,D,R,Z),Hs(F,z,K,R),Hs(F,A,Z,K));t.vertices=$,t.faces=be,u&&(t.faceVertexUvs[0]=F)}};var it=new tv,_h=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var o,s;let e=(s=(o=n.geometry)!=null?o:t==null?void 0:t.geometry)!=null?s:new Ah().copy(new Dh(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(it),r={width:it.x,height:it.y,depth:it.z,subdivisions:0}):r=t.parameters;let i=P(P({},r),n.parameters);return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:e}}static build(n){var l;let{width:t,height:e,depth:r,subdivisions:i}=n.parameters,o=(l=n.geometry)!=null?l:new Ah().copy(new Dh(100,100,100)),s=o.userData.parameters;s===void 0?(o.computeBoundingBox(),o.boundingBox.getSize(it)):it.set(s.width,s.height,s.depth),(t!==it.x||e!==it.y||r!==it.z)&&o.scale(it.x===0?1:t/it.x,it.y===0?1:e/it.y,it.z===0?1:r/it.z);let a=o.originalGeometry;return i>0?(a===void 0||(s==null?void 0:s.subdivisions)!==i)&&(a===void 0&&(a=o),o=new qs(i).modify(a).toBufferGeometry()):(a!==void 0&&(o=a),a=void 0,o.getAttribute("normal")===void 0&&o.computeVertexNormals()),a!==void 0&&Object.assign(o,{originalGeometry:a}),delete n.geometry,Object.assign(o,{userData:W(P({},n),{type:"NonParametricGeometry"})})}static loadFromUrl(n,t,e){new ev(e).load(n,i=>{let o=this.normalizeInputs({geometry:i});i.boundingBox.getSize(it);let s=100/it.x;Object.assign(o.parameters,{width:100,height:it.y*s,depth:it.z*s}),t(this.build(o))})}};var Bh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var i,o,s,a;let e=Object.assign({},(i=t==null?void 0:t.parameters)!=null?i:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{surfaceMaxCount:((o=e.surfaceMaxCount)!=null?o:e.cornerRadius>0)?1e3:100,width:Math.abs(e.width),height:Math.abs((s=e.height)!=null?s: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(n){let{width:t,height:e,spikes:r,cornerRadius:i,depth:o,extrudeBevelSize:s,extrudeBevelSegments:a,surfaceMaxCount:l}=n.parameters,c=n.shape,p=t*.5,u=e*.5,h=0,m=0,f=2*Math.PI/r;for(let S=0;S<r;S++){let y=f*S,w=h+Math.sin(y)*p,I=m+Math.cos(y)*u;c.addPoint(c.createPoint(w,I))}c.isClosed=!0;for(let S=0,y=c.points.length;S<y;S++)c.points[S].roundness=i;c.roundness=i,c.update();let L=ut.create({shape:c,parameters:{surfaceMaxCount:l,roundness:i,depth:o,extrudeBevelSize:s,extrudeBevelSegments:a}});return Object.assign(L,{userData:W(P({},n),{type:"PolygonGeometry"})})}};import{BufferGeometry as rv,Float32BufferAttribute as Sl,Vector2 as hr,Vector3 as st}from"three";var Eh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,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},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t,height:e,depth:r,radialSegments:i,heightSegments:o,openEnded:s,cornerRadius:a,cornerSegments:l}=n.parameters,c=new Cl(t*.5,e,i,o,s,a,l);return c.scale(1,1,r/t),Object.assign(c,{userData:W(P({},n),{type:"PyramidGeometry"})})}};function Zo(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function wl(n,t,e,r,i,o){let s=t.clone().sub(n),a=e.clone().sub(n),l=s.angleTo(a);if(s.normalize(),a.normalize(),r===i){let c=s.add(a).normalize();o.copy(n).addScaledVector(c,r/Math.sin(l/2))}else{let c=s.angleTo(a);o.copy(n),o.addScaledVector(s,i/Math.sin(c)),o.addScaledVector(a,r/Math.sin(c))}}function iv(n,t,e){let r=n.clone().sub(t),i=e.clone().sub(t);return r.projectOnVector(i),r.add(t)}var Cl=class extends rv{constructor(t=.5,e=1,r=4,i=1,o=!1,s=0,a=4){super(),r=Math.floor(Math.max(3,r)),i=Math.floor(i),a=Math.floor(a);let l=[],c=[],p=[],u=[],h=0,m=e/2,f=Math.PI/r,L=t*Math.cos(Math.PI/r),S=2*Math.PI/r,y=(r-2)*Math.PI/r,w=Math.PI-y,I=new st(0,-m,0),_=new st(0,m,0),g=new hr(t,-m),V=new hr(L,-m),b=new hr(0,_.y).sub(V),d=new hr(0,_.y).sub(g),O=new hr(b.y,-b.x).normalize(),x=new hr(d.y,-d.x).normalize(),C=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-b.angle())/2)-1e-8;s=Math.min(s,C);let T;{let F=new st(O.x,O.y,0),G=new st(Math.cos(S)*F.x,F.y,Math.sin(S)*F.x);T=F.angleTo(G)}let $=s/Math.tan((Math.PI-b.angle())/2),H=s/Math.tan((Math.PI-T)/2),ie=new st;if(!o){c.push(I.x,I.y,I.z),p.push(0,-1,0),u.push(0,0);let F=h++,G=[],D=g.clone(),z=$/Math.cos(Math.PI/r);D.x-=z;for(let A=0;A<r;A++){let R=A/r*Math.PI*2+f,K=new hr(Math.sin(R),Math.cos(R));Zo(D,K,ie),c.push(ie.x,ie.y,ie.z),p.push(0,-1,0),u.push(0,0),G.push(h++)}for(let A=0;A<G.length;A++)l.push(G[A],F,G[(A+1)%G.length])}let pe=[];{let F=new st,G=new st,D=new st,z=new st,A=new st,R=new st;for(let K=0;K<r;K++){let Z=K/r*Math.PI*2+f,U=(K+.5)/r*Math.PI*2+f,j=(K+1)/r*Math.PI*2+f,B=new hr(Math.sin(Z),Math.cos(Z)),k=new hr(Math.sin(U),Math.cos(U)),ne=new hr(Math.sin(j),Math.cos(j));Zo(g,B,G),Zo(g,ne,D),Zo(O,k,F),wl(_,G,D,H,H,z),c.push(z.x,z.y,z.z),wl(G,_,D,H,$,A),c.push(A.x,A.y,A.z),wl(D,G,_,$,H,R),c.push(R.x,R.y,R.z),p.push(F.x,F.y,F.z),p.push(F.x,F.y,F.z),p.push(F.x,F.y,F.z),u.push(0,0),u.push(0,0),u.push(0,0);let q=h++,J=h++,Y=h++;if(l.push(q,J,Y),s>0){{let se=G.clone().add(D).multiplyScalar(.5),oe=_.clone().sub(se).normalize(),Ee=I.clone().sub(se).normalize().add(oe).normalize().multiplyScalar(-1),xe=R.clone().sub(A);ce(se,xe,Ee,b.angle())}let X,Q;{let se=new st;Zo(x,ne,se);let oe=R.clone().add(z).multiplyScalar(.5);oe=iv(oe,D,_);let ue=R.clone().sub(z);[X,Q]=ce(oe,ue,se,T,z.y)}{let se=X,oe=se.clone().setY(0).normalize(),ue=new st(0,-1,0),Ee=oe.clone().cross(ue);be(se,oe,ue,Ee)}pe.concat(Q);{let se=b.angle(),oe=Math.PI-se,ue=_.clone();ue.y-=s/Math.sin(se-Math.PI/2);let Ee=new st,xe=[];for(let Le=0;Le<a;Le++){let ct=[],wt=Math.PI/2-oe*Le/a,br=Math.cos(wt),ft=Math.sin(wt),vr=U;for(let oi=0;oi<=Le;oi++){let ni=Math.cos(vr),Ue=Math.sin(vr);F.x=br*Ue,F.y=ft,F.z=br*ni,Ee.copy(ue).addScaledVector(F,s),c.push(Ee.x,Ee.y,Ee.z),p.push(F.x,F.y,F.z),u.push(0,0),ct.push(h++),vr+=Math.PI*2/Le/r}xe.push(ct)}Q.reverse(),xe.push(Q);let We=xe.length-1;for(let Le=0;Le<We;Le++){let ct=xe[Le],wt=xe[Le+1],br=ct.length-1;l.push(wt[1],ct[0],wt[0]);for(let ft=1;ft<=br;ft++)l.push(ct[ft],ct[ft-1],wt[ft]),l.push(wt[ft+1],ct[ft],wt[ft])}}}}}this.setIndex(l),this.setAttribute("position",new Sl(c,3)),this.setAttribute("normal",new Sl(p,3)),this.setAttribute("uv",new Sl(u,2));function ce(F,G,D,z,A){let R=-z/2,K=(Math.PI-z)/2,Z=G.clone().normalize().cross(D);F.addScaledVector(D,-s/Math.sin(K));let U=new st,j=new st,B=1,k=h,ne=[];for(let q=0;q<=a;q++){let J=R+q/a*z;j.set(0,0,0),j.addScaledVector(Z,Math.sin(J)),j.addScaledVector(D,Math.cos(J));for(let Y=0;Y<=B;Y++){let X=Y/B-.5;if(U.copy(F),U.addScaledVector(G,X),U.addScaledVector(j,s),A!=null){let Q=Math.max(0,U.y-A);U.addScaledVector(G,-Q/G.y)}c.push(U.x,U.y,U.z),p.push(j.x,j.y,j.z),u.push(0,0),Y===0&&ne.push(h),h++}}for(let q=0;q<a;q++)for(let J=0;J<B;J++){let Y=k+J+(B+1)*q,X=Y+(B+1),Q=X+1,se=Y+1;l.push(Y,X,se),l.push(X,Q,se)}return[F.clone().addScaledVector(G,.5),ne]}function be(F,G,D,z){let A=Math.PI/2,R=d.angle()-A,K=[],Z=new st,U=new st;for(let B=0;B<=a;B++){let k=[],ne=B/a;for(let q=0;q<=B;q++){let Y=((B?q/B:0)-.5)*w,X=Math.cos(Y),Q=Math.sin(Y),se=Math.atan(Math.tan(R)*X),oe=(A+se)*ne,ue=Math.cos(oe),Ee=Math.sin(oe);Z.set(0,0,0),Z.addScaledVector(G,Ee*X),Z.addScaledVector(D,ue),Z.addScaledVector(z,Ee*Q),U.copy(F).addScaledVector(Z,s),c.push(U.x,U.y,U.z),p.push(Z.x,Z.y,Z.z),u.push(0,0),k.push(h++)}K.push(k)}let j=K.length-1;for(let B=0;B<j;B++){let k=K[B],ne=K[B+1],q=k.length-1;l.push(k[0],ne[1],ne[0]);for(let J=1;J<=q;J++)l.push(k[J-1],k[J],ne[J]),l.push(k[J],ne[J+1],ne[J])}}}};var Ws=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var s,a,l,c,p;let e=Object.assign({},(s=t==null?void 0:t.parameters)!=null?s:{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),r=Object.assign((a=t==null?void 0:t.ui)!=null?a:{enabledIndieCorners:!1},n.ui),i=e.cornerRadius.reduce((u,h)=>u+h,0);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{surfaceMaxCount:((l=e.surfaceMaxCount)!=null?l:i>0)?1e3:100,width:Math.abs(e.width),height:Math.abs((c=e.height)!=null?c:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(p=e.depth)!=null?p:0)}),ui:r}}static build(n){let t=n.shape,{width:e,height:r,cornerRadius:i,cornerType:o,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l,surfaceMaxCount:c}=n.parameters,p={x:e*.5,y:r*.5},u={x:-p.x,y:-p.y},h={x:p.x,y:p.y};function m(g,V,b){return V>e&&b>r?Math.min(g*e/V,g*r/b):V>e?g*e/V:b>r?g*r/b:g}let f=[];f[0]=i[0]===0?0:m(i[0],i[0]+i[3],i[0]+i[1]),f[1]=i[1]===0?0:m(i[1],i[1]+i[2],i[1]+i[0]),f[2]=i[2]===0?0:m(i[2],i[2]+i[1],i[2]+i[3]),f[3]=i[3]===0?0:m(i[3],i[3]+i[0],i[3]+i[2]);let L=u.x,S=h.x,y=h.y,w=u.y;t.addPoint(t.createPoint(L,y)),t.addPoint(t.createPoint(S,y)),t.addPoint(t.createPoint(S,w)),t.addPoint(t.createPoint(L,w)),t.isClosed=!0;let I=!0;for(let g=0,V=t.points.length;g<V;g++)t.points[g].roundness=f[g],g>0&&f[g]!==f[g-1]&&(I=!1);I&&(t.roundness=f[0]),t.useCubicForRoundedCorners=o!==1,t.update();let _=ut.create({shape:t,parameters:{surfaceMaxCount:c,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(_,{userData:W(P({},n),{type:"RectangleGeometry"})})}};import{SphereBufferGeometry as ov}from"three";var Gh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,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},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t=100,height:e=t,depth:r=t,widthSegments:i=64,heightSegments:o=64,phiStart:s,phiLength:a,thetaStart:l,thetaLength:c}=n.parameters,p=new ov(.5*t,i,o,s,a,l,c);return p.scale(1,e/t,r/t),Object.assign(p,{userData:W(P({},n),{type:"SphereGeometry"})})}};import{PlaneBufferGeometry as nv}from"three";var zh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:0})}}static build(n){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:i=8}=n.parameters,o=new nv(t,e,r,i);return o.scale(1,1,1),Object.assign(o,{userData:W(P({},n),{type:"PlaneGeometry"})})}};var Rh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var i,o,s,a;let e=Object.assign({},(i=t==null?void 0:t.parameters)!=null?i:{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{surfaceMaxCount:((o=e.surfaceMaxCount)!=null?o:e.cornerRadius>0)?1e3:100,width:Math.abs(e.width),height:Math.abs((s=e.height)!=null?s: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(n){let{width:t,height:e,innerRadiusPercent:r,spikes:i,cornerRadius:o,angle:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c,surfaceMaxCount:p}=n.parameters,u=n.shape,h=t*.5,m=e*.5,f=0,L=0,S=s*Math.PI/360/i,y=Math.PI/2*3*-1,w=h*r/100,I=m*r/100;if(i==3&&r==50){S=2*Math.PI/i;for(let g=0;g<i;g++){let V=S*g,b=f+Math.sin(V)*h,d=L+Math.cos(V)*m;u.addPoint(u.createPoint(b,d))}}else for(let g=0;g<i;g++){let V=f+Math.cos(y)*h,b=L+Math.sin(y)*m;u.addPoint(u.createPoint(V,b)),y+=S,V=f+Math.cos(y)*w,b=L+Math.sin(y)*I,g<=i,u.addPoint(u.createPoint(V,b)),y+=S}u.isClosed=!0;for(let g=0,V=u.points.length;g<V;g++)u.points[g].roundness=o;u.roundness=o,u.update();let _=ut.create({shape:u,parameters:{surfaceMaxCount:p,roundness:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(_,{userData:W(P({},n),{type:"StarGeometry"})})}};import{PlaneBufferGeometry as sv}from"three";var $s=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,depth:0},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:0)})}}static build(n){let{width:t,height:e}=n.parameters,r=new sv(t,e);return Object.assign(r,{userData:W(P({},n),{type:"TextFrameGeometry"})})}};var Vh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var s,a,l;let e=Object.assign({},(s=t==null?void 0:t.parameters)!=null?s:{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},n.parameters),r=Math.abs(e.width),i=Math.abs((a=e.height)!=null?a:e.width),o=Math.abs((l=e.depth)!=null?l:e.width*.25);return{parameters:Object.assign(e,{width:r,height:i,depth:o})}}static build(n){let{width:t,height:e,depth:r,radialSegments:i,tubularSegments:o,arc:s,cornerRadius:a,cornerSegments:l}=n.parameters,c=av(t,e,r,t*.5,s,o,0,0,i,a,l);return c.scale(1,e/t,1),Object.assign(c,{userData:W(P({},n),{type:"TorusGeometry"})})}};function av(n,t,e,r,i,o,s,a,l,c,p){return[t,e]=[e,t],s=t/2,i/=2*Math.PI,i==1&&(c=0),new Yo(!0,n,t,e,r,i,o,s,a,l,c,p)}import{TorusKnotBufferGeometry as lv}from"three";var Fh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o,s;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width),tube:(s=e.tube)!=null?s:e.width*.125})}}static build(n){let{width:t,tube:e,tubularSegments:r,radialSegments:i,p:o,q:s}=n.parameters,a=t*.5;a!==e&&(a-=e);let l=new lv(a,e,r,i,o,s);return Object.assign(l,{userData:W(P({},n),{type:"TorusKnotGeometry"})})}};var jh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var i,o,s,a;let e=Object.assign({},(i=t==null?void 0:t.parameters)!=null?i:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{surfaceMaxCount:((o=e.surfaceMaxCount)!=null?o:e.cornerRadius>0)?1e3:100,width:Math.abs(e.width),height:Math.abs((s=e.height)!=null?s:e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(a=e.depth)!=null?a:0)})}}static build(n){let{width:t=100,height:e,cornerRadius:r,depth:i,extrudeBevelSize:o,extrudeBevelSegments:s,isRect:a,surfaceMaxCount:l}=n.parameters,c=n.shape,p=t*.5,u=e*.5;a?(c.addPoint(c.createPoint(-p,u)),c.addPoint(c.createPoint(p,-u)),c.addPoint(c.createPoint(-p,-u))):(c.addPoint(c.createPoint(0,u)),c.addPoint(c.createPoint(p,-u)),c.addPoint(c.createPoint(-p,-u))),c.isClosed=!0;for(let m=0,f=c.points.length;m<f;m++)c.points[m].roundness=r;c.roundness=r,c.update();let h=ut.create({shape:c,parameters:{surfaceMaxCount:l,roundness:r,depth:i,extrudeBevelSize:o,extrudeBevelSegments:s}});return Object.assign(h,{userData:W(P({},n),{type:"TriangleGeometry"})})}};var Qo={};mm(Qo,{addBarycentricAttribute:()=>dv,fixUvs:()=>fv,loadFromUrl:()=>mv,resizeGeometry:()=>hv,roundShapePolygon:()=>uv});import{BufferGeometryLoader as cv,Float32BufferAttribute as pv,Vector3 as Ll}from"three";var Uh=function(n,t){let e=t.x-n.x,r=t.y-n.y,i=Math.sqrt(e*e+r*r),o=e/i,s=r/i,a=Math.atan2(s,o);return{x:e,y:r,len:i,nx:o,ny:s,ang:a}},uv=(n,t,e)=>{let r,i,o,s,a,l,c,p,u,h,m,f,L,S,y=t.length;for(s=t[y-2],n.curves=[],r=1;r<y-1;r++){a=t[r%y],l=t[(r+1)%y];let w=Uh(a,s),I=Uh(a,l);c=w.nx*I.ny-w.ny*I.nx,p=w.nx*I.nx-w.ny*-I.ny,m=Math.asin(c),u=1,h=!1,p<0?m<0?m=Math.PI+m:(m=Math.PI-m,u=-1,h=!0):m>0&&(u=-1,h=!0),f=m/2,S=Math.abs(Math.cos(f)*e/Math.sin(f)),S>Math.min(w.len/2,I.len/2)?(S=Math.min(w.len/2,I.len/2),L=Math.abs(S*Math.sin(f)/Math.cos(f))):L=e,i=a.x+I.nx*S,o=a.y+I.ny*S,i+=-I.ny*L*u,o+=I.nx*L*u,n.absarc(i,o,L,w.ang+Math.PI/2*u,I.ang-Math.PI/2*u,h),s=a,a=l}n.closePath()},hv=(n,{width:t,height:e,depth:r})=>{t=Math.abs(t),e=Math.abs(e),r=Math.abs(r);let i=n.userData.parameters,o,s,a;t===0?(t=i.width,o=1):o=t/i.width,e===0?(e=i.height,s=1):s=e/i.height,r===0?(r=i.depth,a=1):a=r/i.depth,n.scale(o,s,a),i.width=t,i.height=e,i.depth=r},dv=(n,t)=>{let e=[new Ll(1,0,0),new Ll(0,1,0),new Ll(0,0,1)],r=n.attributes.position,i=new Float32Array(r.count*3);for(let o=0,s=r.count;o<s;o++)e[o%3].toArray(i,o*3);n.setAttribute(t,new pv(i,3))},mv=n=>new Promise(t=>{new cv().load(n,r=>t(r))}),fv=(n,t,e)=>{let r=n.getAttribute("uv");if(r)for(let i=0;i<r.count;i++){let o=r.getX(i),s=r.getY(i);r.setXY(i,(o+t/2)/t,1-(s-e/2)/e*-1)}};import{BufferGeometry as kh,BufferAttribute as Hh,Uint32BufferAttribute as Tl,Float32BufferAttribute as Nl,Matrix4 as gv}from"three";import{mergeVertices as xv}from"three/examples/jsm/utils/BufferGeometryUtils.js";var yv,Js=new Promise(n=>{yv=n});var me;Js.then(n=>{me=n});var qh=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Wh=new Uint32Array([0,1,2,3]),$h=new Uint8Array([4]),zt=class{static build(n,t,e,r,i){let o,s,a;if(n===void 0)o=zt.allocate(i,e),me.set_destination_refinement_level(o,0),s=zt.buildLevel(o,!0,r);else if(n.positionWASM!==void 0){t&&t!==0&&(me.free_bvh(t),me.free_subdivision_surface(t));try{o=zt.allocate(i,void 0,n)}catch(l){console.error(l,n),o=zt.allocate(i,void 0,{positionWASM:qh,indexWASM:Wh,verticesPerFaceWASM:$h})}me.set_destination_refinement_level(o,0),s=zt.buildLevel(o,!0,r)}else o=t;if(n!==void 0&&n.subdivisions!==void 0){let l=bv(n.subdivisions,n.positionWASM.length);me.set_destination_refinement_level(o,l),l>0?a=zt.buildLevel(o,!1,r):a=null}return{subdivPointer:o,originalGeometry:s,subdividedGeometry:a}}static allocate(n,t,e){var g;let r,i,o,s=[],a=[];if(e)e.positionWASM&&e.positionWASM.length>0?(r=e.positionWASM,i=e.indexWASM,o=e.verticesPerFaceWASM):(r=qh,i=Wh,o=$h);else{t.deleteAttribute("normal"),t.deleteAttribute("uv");let V=xv(t);r=V.attributes.position.array;let b=V.getIndex().array,d=b.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":i=new Uint32Array(d/3*2),o=new Uint8Array(d/6).fill(4);for(let H=0,ie=0;H<d;H+=6)i[ie++]=b[H],i[ie++]=b[H+1],i[ie++]=b[H+4],i[ie++]=b[H+5];break;case"TorusGeometry":case"SphereGeometry":case"HelixGeometry":case"CylinderGeometry":case"ConeGeometry":let O,x,M;if(t.userData.type==="SphereGeometry")x=t.parameters.heightSegments,O=t.parameters.widthSegments,t.parameters.thetaLength!==Math.PI&&(M=!0);else if(t.userData.type==="CylinderGeometry")x=t.parameters.heightSegments+2,O=t.parameters.radialSegments;else if(t.userData.type==="ConeGeometry")x=t.parameters.heightSegments+1,O=t.parameters.radialSegments;else if(t.userData.type==="TorusGeometry"){let H=t.userData.parameters;x=Math.ceil(H.tubularSegments*H.arc/(2*Math.PI))+2,O=H.radialSegments}else{let{pathSegments:H,segments:ie,revolutions:pe}=t.userData.parameters;x=Math.ceil(ie*pe)+2,O=H}M?(i=new Uint32Array(1*O*3+(x-1)*O*4),o=new Uint8Array(1*O+(x-1)*O)):(i=new Uint32Array(2*O*3+(x-2)*O*4),o=new Uint8Array(2*O+(x-2)*O));let C=0,T=0,$=0;if(t.userData.type==="SphereGeometry"||t.userData.type==="HelixGeometry"||t.userData.type==="TorusGeometry"){for(;T<3*O;)i[T++]=b[C++],i[T++]=b[C++],i[T++]=b[C++],o[$++]=3;let H=M?i.length:3*O+4*(x-2)*O;for(;T<H;C+=6)i[T++]=b[C],i[T++]=b[C+1],i[T++]=b[C+4],i[T++]=b[C+5],o[$++]=4}else for(;T<4*(x-2)*O;C+=6)i[T++]=b[C],i[T++]=b[C+1],i[T++]=b[C+4],i[T++]=b[C+5],o[$++]=4;for(;T<i.length;)i[T++]=b[C++],i[T++]=b[C++],i[T++]=b[C++],o[$++]=3;break;default:i=b,o=new Uint8Array(d/3).fill(3);break}}let l=r.length,c=i.length,p=o.length,u=r.length+s.length+a.length,h=i.length+o.length,m=u*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,f=u*Float32Array.BYTES_PER_ELEMENT,L=h*Uint32Array.BYTES_PER_ELEMENT,S=me._malloc(m),y=new Float32Array(me.HEAPF32.buffer,S,u),w=new Uint32Array(me.HEAPU32.buffer,S+f,h);y.set(r,0),y.set(s,r.length),y.set(a,r.length+s.length),w.set(i,0),w.set(o,i.length);let I;(g=e==null?void 0:e.scaleBaked)!=null&&g.some(V=>V!==1)&&(I=new gv().makeScale(...e.scaleBaked)),n&&(I?I.premultiply(n):I=n);let _=I?me.alloc_subdivision_surface2(S,l,S+f,c,S+f+i.length*Uint32Array.BYTES_PER_ELEMENT,p,I.elements):me.alloc_subdivision_surface(S,l,S+f,c,S+f+i.length*Uint32Array.BYTES_PER_ELEMENT,p);return me._free(S),_}static buildLevel(n,t,e,r,i){let o=i?me.get_mesh_data2(n,t?me.Level.CONTROL:me.Level.REFINED,e!=null?e:!t,i.elements):me.get_mesh_data(n,t?me.Level.CONTROL:me.Level.REFINED,e!=null?e:!t),s=8,a=me.HEAPU32.subarray(o>>2,(o>>2)+s),l=a.subarray(4,4+4),c=0,p=me.HEAPU32[a[c]>>2],u=me.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=me.HEAPU32[a[c]>>2],m=me.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let f=me.HEAPU32[a[c]>>2],L=me.HEAPU32.subarray(f>>2,(f>>2)+l[c]);c++;let S=me.HEAPU32[a[c]>>2],y=me.HEAPU32.subarray(S>>2,(S>>2)+l[c]);if(c++,r===void 0){let w=new kh;if(w.setIndex(new Tl(y,1)),w.setAttribute("position",new Nl(u,3)),w.setAttribute("normal",new Nl(m,3)),t){w.setAttribute("faceMap",new Tl(L,1));let I=new Float32Array(m.length/3*4).fill(0);w.setAttribute("color",new Hh(I,4))}return me.free_mesh_data(o),w.userData.type="SubdivGeometry",w}r.getAttribute("position").copyArray(u),r.getAttribute("normal").copyArray(m),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,me.free_mesh_data(o)}static buildControlCageWireframe(n,t,e){let r=me.get_wireframe_data_for_base_level(n),i=4,o=me.HEAPU32.subarray(r>>2,(r>>2)+i),s=o.subarray(2,2+2),a=0,l=me.HEAPU32[o[a]>>2],c=me.HEAPF32.subarray(l>>2,(l>>2)+s[a]);a++;let p=me.HEAPU32[o[a]>>2],u=me.HEAPU32.subarray(p>>2,(p>>2)+s[a]);if(t===void 0){let h=new kh;h.setAttribute("position",new Nl(c,3));let m=new Float32Array(c.length);for(let f=0,L=c.length;f<L;)m[f++]=e.r,m[f++]=e.g,m[f++]=e.b;return h.setAttribute("color",new Hh(m,3)),h.setIndex(new Tl(u,1)),me.free_wireframe_data_for_base_level(r),h}t.getAttribute("position").copyArray(c),t.attributes.position.needsUpdate=!0,me.free_wireframe_data_for_base_level(r)}static updateCollabMesh(n,t,e){t||me.set_destination_refinement_level(n,1);let r=e?me.get_topological_data2(n,t?me.Level.CONTROL:me.Level.REFINED,e.elements):me.get_topological_data(n,t?me.Level.CONTROL:me.Level.REFINED),i=6,o=me.HEAPU32.subarray(r>>2,(r>>2)+i),s=o.subarray(3,3+3),a=0,l=me.HEAPU32[o[a]>>2],c=new Float32Array(me.HEAPF32.subarray(l>>2,(l>>2)+s[a]));a++;let p=me.HEAPU32[o[a]>>2],u=new Uint32Array(me.HEAPU32.subarray(p>>2,(p>>2)+s[a]));a++;let h=me.HEAPU32[o[a]>>2],m=new Uint8Array(me.HEAPU32.subarray(h>>2,(h>>2)+s[a]));return me.free_topological_data(r),{positions:c,indices:u,verticesPerFace:m}}};function bv(n,t){let e=n;return e=Math.min(e,3-Math.ceil(Math.log(t/172e3)/Math.log(4))),Math.max(e,0)}var Ml={ConeGeometry:Yu,CubeGeometry:Xu,CylinderGeometry:Ku,DodecahedronGeometry:Zu,EllipseGeometry:wh,HelixGeometry:Mh,IcosahedronGeometry:Oh,LatheGeometry:Ih,NonParametricGeometry:_h,PolygonGeometry:Bh,PyramidGeometry:Eh,RectangleGeometry:Ws,SphereGeometry:Gh,PlaneGeometry:zh,StarGeometry:Rh,TextFrameGeometry:$s,TorusGeometry:Vh,TorusKnotGeometry:Fh,TriangleGeometry:jh,VectorGeometry:ut},en=n=>Ml[n.type].create(n);import{HemisphereLight as Jh}from"three";import{Color as vv}from"three";var Pt=class extends vv{constructor(e,r,i,o){super(e,r,i);this.isColorA=!0;this.a=o}setRGBA(e,r,i,o){super.setRGB(e,r,i),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 Ye(n,t){let e;if(typeof n=="string"){let r=t==null?void 0:t.getColor(n);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 Pt(0,0,0,0))}else return"a"in n?new Pt(n.r,n.g,n.b,n.a):new Pt(n.r,n.g,n.b,1);return e}var Ks=n=>"isEntity"in n,io=n=>"isAbstractMesh"in n,Kh=n=>n.objectType==="CombinedCamera";var Or=n=>"objectHelper"in n;function Sv(n,t){var r;let e=!1;t.position&&(n.position.fromArray(t.position),e=!0),t.rotation&&(n.rotation.fromArray(t.rotation),e=!0),t.scale&&(e=!0,n.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&"hiddenMatrix"in n&&(e=!0,n.hiddenMatrix.fromArray((r=t.hiddenMatrix)!=null?r:Ur.identity)),e&&n.updateMatrix(),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&n.updateWorldMatrix(!1,!0),n.objectType==="CombinedCamera"&&(t.isUpVectorFlipped!==void 0&&(n.isUpVectorFlipped=t.isUpVectorFlipped),n.updateUp())}function wv(n,t){Sv(n,t),t.name!==void 0&&(n.name=t.name),t.visible!==void 0&&(n.isEntity?n.visibility=t.visible:n.visible=t.visible)}function Yh(n,t,e){wv(n,t),t.color!==void 0&&(n.color=Ye(t.color,e)),t.intensity!==void 0&&(n.intensity=t.intensity),t.shadows!==void 0&&!(n instanceof Jh)&&(n.castShadow=t.shadows),n.shadow&&!(n instanceof Jh)&&t.depth!==void 0&&(n.shadow.camera.far=t.depth,n.shadow.needsUpdate=!0),t.helper!==void 0&&Or(n)&&(n.enableHelper=t.helper,n.gizmos.shadowmap.visible=t.helper)}function Xh(n,t){n.shadow.camera.right=t/2,n.shadow.camera.left=-t/2,n.shadow.camera.top=t/2,n.shadow.camera.bottom=-t/2,n.shadow.needsUpdate=!0}import{VideoTexture as vS}from"three";import{Mesh as Iv}from"three";import{Matrix4 as Il}from"three";import{Box3 as Qh,Line3 as $t,Matrix4 as Ol,Vector3 as Ve}from"three";var oo=new Qh,ht=new Ve,le=new Ve,et=new Ol;function Cv(n,t,e=0,r=t.count){let i=1/0,o=1/0,s=1/0,a=-1/0,l=-1/0,c=-1/0;for(let p=e;p<r;p++){let u=t.getX(p),h=t.getY(p),m=t.getZ(p);u<i&&(i=u),h<o&&(o=h),m<s&&(s=m),u>a&&(a=u),h>l&&(l=h),m>c&&(c=m)}return n.min.set(i,o,s),n.max.set(a,l,c),n}var Zh=(n,t,e,r)=>{var i;if(io(n)){let o=n.geometry.userData.parameters,s=n.geometry.getAttribute("position");n.geometry.userData.type==="SubdivGeometry"?ht.copy(n.originalGeometry.boundingSphere.center):(Cv(oo,s,n.geometry.drawRange.start,n.geometry.drawRange.count<1/0?n.geometry.drawRange.count:s.count),oo.getCenter(ht)),n.forceComputeSize?oo.getSize(le).multiplyScalar(.5):le.set(o.width,o.height,(i=o.depth)!=null?i:0).multiplyScalar(.5)}else if(Or(n)&&r===!0){let o=n.geometryHelper.getAttribute("position");oo.setFromArray(o.array),oo.getCenter(ht),oo.getSize(le).multiplyScalar(.5)}else ht.setScalar(0),le.setScalar(0);et.copy(t).multiply(n.matrixWorld),le.x===0&&le.y===0&&le.z===0?e.push(new Ve(ht.x,ht.y,ht.z).applyMatrix4(et)):e.push(new Ve(-le.x,le.y,le.z).add(ht).applyMatrix4(et),new Ve(-le.x,-le.y,le.z).add(ht).applyMatrix4(et),new Ve(le.x,-le.y,le.z).add(ht).applyMatrix4(et),new Ve(le.x,le.y,le.z).add(ht).applyMatrix4(et),new Ve(-le.x,le.y,-le.z).add(ht).applyMatrix4(et),new Ve(-le.x,-le.y,-le.z).add(ht).applyMatrix4(et),new Ve(le.x,-le.y,-le.z).add(ht).applyMatrix4(et),new Ve(le.x,le.y,-le.z).add(ht).applyMatrix4(et))},tn=class extends Qh{constructor(){super(...arguments);this.matrix=new Ol;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 i=new Ol().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,r)}expandByObjectSize(e,r,i=!1){let o=[];return i===!0?e.traverseEntity(s=>{s.visible&&Zh(s,r,o,e.enableHelper===!0)}):Zh(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(et.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(le).multiplyScalar(.5),this.getCenter(ht),et.copy(this.matrix).setPosition(ht),this.vertices=[new Ve(-le.x,le.y,le.z).applyMatrix4(et),new Ve(-le.x,-le.y,le.z).applyMatrix4(et),new Ve(le.x,-le.y,le.z).applyMatrix4(et),new Ve(le.x,le.y,le.z).applyMatrix4(et),new Ve(-le.x,le.y,-le.z).applyMatrix4(et),new Ve(-le.x,-le.y,-le.z).applyMatrix4(et),new Ve(le.x,-le.y,-le.z).applyMatrix4(et),new Ve(le.x,le.y,-le.z).applyMatrix4(et)]}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=[new $t(this.vertices[0],this.vertices[3]),new $t(this.vertices[1],this.vertices[2]),new $t(this.vertices[5],this.vertices[6]),new $t(this.vertices[4],this.vertices[7]),new $t(this.vertices[0],this.vertices[1]),new $t(this.vertices[3],this.vertices[2]),new $t(this.vertices[7],this.vertices[6]),new $t(this.vertices[4],this.vertices[5]),new $t(this.vertices[0],this.vertices[4]),new $t(this.vertices[1],this.vertices[5]),new $t(this.vertices[2],this.vertices[6]),new $t(this.vertices[3],this.vertices[7])],this.centerEdges=this.edges.map(e=>e.getCenter(new Ve))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=[new Ve().copy(this.vertices[0]).sub(this.vertices[2]).multiplyScalar(.5).add(this.vertices[2]),new Ve().copy(this.vertices[7]).sub(this.vertices[5]).multiplyScalar(.5).add(this.vertices[5]),new Ve().copy(this.vertices[4]).sub(this.vertices[1]).multiplyScalar(.5).add(this.vertices[1]),new Ve().copy(this.vertices[3]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6]),new Ve().copy(this.vertices[4]).sub(this.vertices[3]).multiplyScalar(.5).add(this.vertices[3]),new Ve().copy(this.vertices[1]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6])]}};import{Object3D as Lv,Matrix4 as Tv,Light as Nv}from"three";function rn(n){let t=[];for(let e in n){let r=n[e];delete r.metadata,t.push(r)}return t}function Mv(n){let t=[];for(let e in n)t.push(n[e]);return t}var Ys=n=>class extends n{hasEntityChild(){return this.children.some(e=>Ks(e))}isDescendantOf(e){e instanceof Lv&&(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 i=new Tv().copy(this.matrixWorld).invert();return e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),i.multiply(e.parent.matrixWorld)),Ks(e)?e.hiddenMatrix.premultiply(i):e.applyMatrix4(i),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 i=0;i<e.children.length;i++){let o=e.children[i];this.add(o.clone())}return this}toJSON(e){let r=e===void 0,i={object:{uuid:"",objectType:""}};e===void 0&&(e={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},i.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 s of this.children)(Ks(s)||s instanceof Nv)&&o.children.push(s.toJSON(e).object)}if(r){let s=rn(e.geometries),a=rn(e.materials),l=rn(e.textures),c=rn(e.images),p=rn(e.interactionStates),u=Mv(e.nodes);s.length>0&&(i.geometries=s),a.length>0&&(i.materials=a),l.length>0&&(i.textures=l),c.length>0&&(i.images=c),p.length>0&&(i.interactionStates=p),u.length>0&&(i.nodes=u)}return i.object=o,i}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 Jt=n=>"isEntity"in n;var Kt=n=>class extends Ys(n){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Il;this._singleBBox=new tn;this._recursiveBBox=new tn;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(r){this.visible=r;for(let i of this.children)Jt(i)&&i.traverseEntity(o=>{Or(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=>{Jt(r)&&(r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(r=>{r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0})}traverseEntity(r){r(this);for(let i of this.children)Jt(i)&&i.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 i of this.children)i.updateMatrixWorld(r)}updateWorldMatrix(r,i){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)),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}shallowClone(r){return new this.constructor().shallowCopy(this,r)}shallowCopy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let o of r.children)Jt(o)&&this.add(o.shallowClone());return this}clone(r){return new this.constructor().copy(this,r)}copy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let o of r.children)Jt(o)&&this.add(o.clone());return this}keepChildrenMatrixWorld(){let r=new Il,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),r.copy(this.matrixWorld).invert(),r.multiply(i);for(let o of this.children)Jt(o)&&o.hiddenMatrix.premultiply(r)}toJSON(r){let i=super.toJSON(r),o=i.object;return this.raycastLock===!0&&(o.raycastLock=!0),this.scaleLock===!0&&(o.scaleLock=!0),o.hiddenMatrix=this.hiddenMatrix.toArray(),i}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 i=r.children;return r.children=[],Object.assign(r,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new Il}),this.copy(r),r.children=i,this}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ji(i,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 i=P({name:this.name,visible:this.visible,raycastLock:this.raycastLock},this.toObjectTransformState(r));return ji(i,r)}fromState(r,i){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 Ov,Vector3 as on,Euler as ed,MathUtils as Yr}from"three";var mi=class extends Ov{constructor(e,r={}){super();this.object=e;let i=e.recursiveBBox.getSize(new on),o=.1;this.parameters=cs.defaultData(i.toArray(),o),li(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(i=>i.clone());for(let i of this.children)i.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 i of this.children)i.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,i=e-this.children.length;r<i;++r){let o=this.object.shallowClone(!1);o.visible=!0,this.add(o),this.parameters.hideBase&&this.setHideBase(!0)}else for(let r=0,i=this.children.length-e;r<i;++r)this.remove(this.children[0])}_updateRadial(e){let r=e.radial,i=r.start*Yr.DEG2RAD,o=r.end*Yr.DEG2RAD,s=i-o,a=new ed(r.rotation[0]*Yr.DEG2RAD,r.rotation[1]*Yr.DEG2RAD,r.rotation[2]*Yr.DEG2RAD),l;switch(r.axis){case"z":l=new on(0,0,1);break;case"y":l=new on(0,1,0);break;default:case"x":l=new on(1,0,0);break}for(let[c,p]of this.children.entries()){p.hiddenMatrix.identity(),p.scale.x=r.scale[0],p.scale.y=r.scale[1],p.scale.z=r.scale[2],p.position.setScalar(0);let u=s/e.count*c-i;switch(r.axis){case"x":p.rotation.set(0,u,0);break;case"y":p.rotation.set(0,0,u);break;case"z":p.rotation.set(u,0,0);break}p.translateOnAxis(l,r.radius),p.position.x+=r.position[0],p.position.y+=r.position[1],p.position.z+=r.position[2],r.alignment===!0?(p.rotation.x+=a.x,p.rotation.y+=a.y,p.rotation.z+=a.z):p.rotation.copy(a)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let r=e.linear,i=new ed(r.rotation[0]*Yr.DEG2RAD,r.rotation[1]*Yr.DEG2RAD,r.rotation[2]*Yr.DEG2RAD);for(let[o,s]of this.children.entries())s.hiddenMatrix.identity(),s.scale.x=1+(r.scale[0]-1)*o,s.scale.y=1+(r.scale[1]-1)*o,s.scale.z=1+(r.scale[2]-1)*o,s.rotation.x=i.x*o,s.rotation.y=i.y*o,s.rotation.z=i.z*o,s.position.x=r.position[0]*o,s.position.y=r.position[1]*o,s.position.z=r.position[2]*o}_updateGrid(e){let r=0,i=e.grid;if(i.useCenter===!0){let o={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},s=new on(i.size[0]*(i.count[0]-o.x)*.5,i.size[1]*(i.count[1]-o.y)*.5,i.size[2]*(i.count[2]-o.z)*.5);for(let a=0;a<i.count[0];a++)for(let l=0;l<i.count[1];l++)for(let c=0;c<i.count[2];c++){let p=this.children[r++];p.hiddenMatrix.identity(),p.scale.setScalar(1),p.rotation.set(0,0,0),p.position.x=i.size[0]*a-s.x,p.position.y=i.size[1]*l-s.y,p.position.z=i.size[2]*c-s.z}}else for(let o=0;o<i.count[0];o++)for(let s=0;s<i.count[1];s++)for(let a=0;a<i.count[2];a++){let l=this.children[r++];l.hiddenMatrix.identity(),l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=i.size[0]*o,l.position.y=-i.size[1]*s,l.position.z=-i.size[2]*a}}fromJSON(e){return this}toJSON(){return{}}fromClonerState(e){return e.hideBase!==void 0&&this.setHideBase(e.hideBase),li(this.parameters,e),this.update(),this}};var at=class extends Kt(Iv){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,i=Ml[r.userData.type],o=this.objectType==="NonParametric"?Object.assign({},r.userData,{geometry:r}):r.userData,s=i.build(i.normalizeInputs(e,o)),a=r.uuid;if(this.geometry.dispose(),this.geometry=s,this.geometry.uuid=a,this.geometry.computeBoundingSphere(),this.cloner)for(let l of this.cloner.children)l.geometry=this.geometry}resizeGeometry(e,r,i){Qo.resizeGeometry(this.geometry,{width:e,height:r,depth:i})}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,i=en(r),o=Array.isArray(this.material)?this.material.map(s=>s.clone()):this.material.clone();return new this.constructor(i,o).copy(this,e)}copy(e,r=!0){return super.copy(e,r),e.cloner&&(this.cloner=new mi(e,e.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new mi(this)),this.cloner.fromClonerState(e))}fromState(e,r){var i,o;return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=(i=e.castShadow)!=null?i:!0,this.receiveShadow=(o=e.receiveShadow)!=null?o:!0),this}};import{NormalBlending as Yv,ShaderMaterial as Xv,FrontSide as Zv}from"three";import{CubeReflectionMapping as jv,CubeRefractionMapping as Uv,CubeUVReflectionMapping as kv,LinearEncoding as nd,sRGBEncoding as Hv}from"three";var nn=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 Pv}from"three";var he=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Pv.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 i={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),i}build(t,e,r){e=e!=null?e:this.getType(t,e);let i=t.getNodeData(r!=null?r:this);return t.analyzing&&this.appendDepsNode(t,i,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,i,o,s){return""}generate(t,e,r,i,o){return""}parse(t,e,r,i){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let i=t.getTypeLength(r);(i>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=i,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 he&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)e=this.hashProperties[i],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 Pl=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}},ot=new Pl;import{Vector2 as td}from"three";import{MathUtils as Av}from"three";var fe=class extends he{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,i,o){if(r=r!=null?r:this.getType(e),this.getShared(e,r)){let s=this.getUnique(e,r);s&&this.uuid===void 0&&(this.uuid=Av.generateUUID()),i=e.getUUID(i!=null?i:this.getUUID(),!s);let a=e.getNodeData(i),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,r),this.generate(e,r,i)):super.build(e,r,i);if(s)return a.name=a.name||super.build(e,r,i),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,r,i);i=this.getUUID(!1);let c=this.getTemp(e,i);if(c)return e.format(c,l,r);{c=super.generate(e,r,i,a.output,o);let p=this.generate(e,l,i);return e.addNodeCode(c+" = "+p+";"),e.format(c,l,r)}}return super.build(e,r,i)}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 i=e.getVars()[r];return i?i.name:void 0}generate(e,r,i,o,s){return this.getShared(e,r)||console.error("TempNode is not shared"),i=i!=null?i:this.uuid,e.getTempVar(i,o!=null?o:this.getType(e),s,this.getLabel()).name}};var Fe=class extends fe{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,i,o,s,a){i=e.getUUID(i!=null?i:this.getUUID()),o=o!=null?o:this.getType(e);let l=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,i,o,s,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(o,this,s,a,this.getLabel())),e.format(l.vertex.name,o,r)):(l.fragment||(l.fragment=e.createFragmentUniform(o,this,s,a,this.getLabel())),e.format(l.fragment.name,o,r))}copy(e){return super.copy(e),this.readonly=e.readonly,this}};var bt=class extends Fe{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof td?e:new td(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,i,o,s,a){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 rd}from"three";var vt=class extends Fe{constructor(e=0,r,i){super("v3");this.nodeType="Vector3";this.value=e instanceof rd?e:new rd(e,r,i)}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,i,o,s,a){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 Ir=class extends Fe{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Pt?e:new Pt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,i,o,s,a){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 Dv=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,id=/[a-z_0-9]+/gi,re=class extends fe{constructor(e,r,i,o,s){super(s);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,r,i,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,i,o,s){let a,l=0,c=this.src;if(this.includes)for(let u=0;u<this.includes.length;u++)e.include(this.includes[u],this);for(let u in this.extensions)e.extensions[u]=!0;let p=[];for(;a=id.exec(this.src);)p.push(a);for(let u=0;u<p.length;u++){let h=p[u],m=h[0],f=this.isMethod?!this.getInputByName(m):!0,L=m;if(this.keywords[m]||this.useKeywords&&f&&ot.containsKeyword(m)){let S=this.keywords[m];if(!S){let y=ot.getKeywordData(m);y.cache&&(S=e.keywords[m]),S=S||ot.getKeyword(m,e),y.cache&&(e.keywords[m]=S)}L=S.build(e)}m!==L&&(c=c.substring(0,h.index+l)+L+c.substring(h.index+m.length+l),l+=L.length-m.length),this.getIncludeByName(L)===void 0&&ot.contains(L)&&e.include(ot.get(L))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,i,o){if(this.src=e||"",this.includes=r!=null?r:[],this.extensions=i!=null?i:{},this.keywords=o!=null?o:{},this.isMethod){let s=Dv.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match(id);if(a){let l=0;for(;l<a.length;){let c=a[l++],p;c==="in"||c==="out"||c==="inout"?p=a[l++]:(p=c,c="");let u=a[l++];this.inputs.push({name:u,type:p,qualifier:c})}}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 i;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 s in this.keywords)o[s]=this.keywords[s].toJSON(e).uuid;if(r.keywords=o,(i=this.includes)!=null&&i.length){let s=[];for(let a=0;a<this.includes.length;a++)s.push(this.includes[a].toJSON(e).uuid);r.includes=s}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 i in e.keywords)this.keywords[i]=r.getNode(e.keywords[i])}return e.includes&&r&&(this.includes=e.includes.map(i=>r.getNode(i))),this}};var _v=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Al=class extends fe{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Al.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,i,o,s){this.src=e||"";let a,l,c="",p=_v.exec(e);this.useDefine=s!=null?s:this.src.charAt(0)==="#",p&&p.length>1?(l=p[1],a=p[2],c=p[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=c}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,i,o,s){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}},Te=Al;Te.PI="PI",Te.PI2="PI2",Te.RECIPROCAL_PI="RECIPROCAL_PI",Te.RECIPROCAL_PI2="RECIPROCAL_PI2",Te.LOG2="LOG2",Te.EPSILON="EPSILON";var Bv=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
2
+ )*?)}`,"gim"),Ev=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),no=class extends fe{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,i,o,s){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=Bv.exec(e);if(r){let i=r[2],o;for(;o=Ev.exec(i);)this.inputs.push({type:o[1],name:o[2]});this.name=r[1]}else this.name="";this.type=this.name}};var so=class extends fe{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 i=this.index>0?this.index+1:"",o=e.isShader("vertex")?"uv"+i:"vUv"+i;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}};ot.addKeyword("uv",function(){return new so});ot.addKeyword("uv2",function(){return new so(1)});import{LinearEncoding as Gv,sRGBEncoding as zv}from"three";var fi=class extends fe{constructor(e=new he,r){super("v4");this.nodeType="ColorSpace";this.factor=new he;this.input=e,this.method=r!=null?r:fi.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Gv:return["Linear"];case zv:return["sRGB"];default:return[]}}generate(e,r){var l;let i=this.input.build(e,"v4"),o=this.getType(e),s=fi.Nodes[this.method],a=e.include(s);if(a===fi.LINEAR_TO_LINEAR)return e.format(i,o,r);if(((l=s.inputs)==null?void 0:l.length)===2){let c=this.factor.build(e,"f");return e.format(a+"( "+i+", "+c+" )",o,r)}else return e.format(a+"( "+i+" )",o,r)}fromEncoding(e){let r=fi.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=fi.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}},Tt=fi;Tt.Nodes={LinearToLinear:new re(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3
+ `)),sRGBToLinear:new re(["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(`
4
+ `)),LinearTosRGB:new re(["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(`
5
+ `))},Tt.LINEAR_TO_LINEAR="LinearToLinear",Tt.SRGB_TO_LINEAR="sRGBToLinear",Tt.LINEAR_TO_SRGB="LinearTosRGB";var _e=class extends re{constructor(e="",r,i,o,s){super(e,s,o,i,r);this.nodeType="Expression"}};import{Texture as Rv}from"three";var dr=class extends Rv{toJSON(t){let e=super.toJSON(t),r=t===void 0||typeof t=="string";if(this.image!==void 0&&!r){let i=this.image;if(Array.isArray(i)){t.images[i.uuid].url=[];for(let o=0;o<i.length;o++)t.images[i.uuid].url[o]=od(i[o])}else t.images[i.uuid].url=od(i)}return e}};function od(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?Vv(n):(console.warn("THREE.Texture: Unable to serialize Texture."),"")}var ao;function Vv(n){if(/^data:/i.test(n.src))return n.src;let t;if(n instanceof HTMLCanvasElement)t=n;else{ao===void 0&&(ao=document.createElement("canvas")),ao.width=n.width,ao.height=n.height;let r=ao.getContext("2d");n instanceof ImageData?r.putImageData(n,0,0):r.drawImage(n,0,0,n.width,n.height),t=ao}let e=n.src.startsWith("blob:")?n.fileName:n.src;return/\.jpe?g$/i.test(e)?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}var Nt=class extends Fe{constructor(e=new dr,r,i,o){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r!=null?r:new so,this.bias=i,this.project=o!==void 0?o:!1}getTexture(e,r){return super.generate(e,r,this.value.uuid,"t")}generate(e,r){var u;if(r==="sampler2D")return this.getTexture(e,r);let i=this.getTexture(e,r),o=this.uv.build(e,this.project?"v4":"v2"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let a,l;this.project?a="texture2DProj":a=s?"tex2DBias":"tex2D",s?l=a+"( "+i+", "+o+", "+s+" )":l=a+"( "+i+", "+o+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},p=this.getType(e);return e.addContext(c),this.colorSpace=(u=this.colorSpace)!=null?u:new Tt(new _e("",p)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,p),e.removeContext(),e.format(l,p,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 te=class extends Fe{constructor(e){super("f");this.nodeType="Float";this.value=e!=null?e:0}generateReadonly(e,r,i,o,s,a){return e.format(this.value+(this.value%1?"":".0"),o,r)}copy(e){return super.copy(e),this.value=e.value,this}};var sn=class extends fe{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,i,o,s){o=this.getType(e);let a=this.value,l=a.build(e,r)+"( ",c=[];if(a.inputs){for(let p=0;p<a.inputs.length;p++){let u=a.inputs[p],h=this.inputs[p]||this.inputs[u.name];c.push(h.build(e,e.getTypeByFormat(u.type)))}l+=c.join(", ")+" )"}return e.format(l,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 i;let r=this.getJSONNode(e);if(!r){let o=this.value;if(r=this.createJSONNode(e),r.value=this.value.toJSON(e).uuid,(i=o.inputs)!=null&&i.length){r.inputs={};for(let s=0;s<o.inputs.length;s++){let a=o.inputs[s],l=this.inputs[s];r.inputs[a.name]=l.toJSON(e).uuid}}}return r}};var Dl=class extends fe{constructor(e=new he,r=new he,i=Dl.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=r,this.op=i}getType(e){let r=this.a.getType(e),i=this.b.getType(e);return e.isTypeMatrix(r)?"v4":e.getTypeLength(i)>e.getTypeLength(r)?i:r}generate(e,r){let i=this.getType(e);this.type=i;let o=this.a.build(e,i),s=this.b.build(e,i);return e.format("( "+o+" "+this.op+" "+s+" )",i,r)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this}},At=Dl;At.ADD="+",At.SUB="-",At.MUL="*",At.DIV="/";var Pe=class extends fe{constructor(e=new he,r=Pe.ABS,i,o){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:o=r,typeof i!="string"?this.c=i:o=i,this.method=o,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case Pe.MIX:case Pe.CLAMP:case Pe.REFRACT:case Pe.SMOOTHSTEP:case Pe.FACEFORWARD:return 3;case Pe.MIN:case Pe.MAX:case Pe.MOD:case Pe.STEP:case Pe.REFLECT:case Pe.DISTANCE:case Pe.DOT:case Pe.CROSS:case Pe.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),i=this.b?e.getTypeLength(this.b.getType(e)):0,o=this.c?e.getTypeLength(this.c.getType(e)):0;return r>i&&r>o?this.a.getType(e):i>o?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case Pe.LENGTH:case Pe.DISTANCE:case Pe.DOT:return"f";case Pe.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let i,o,s,a=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,c=this.c?e.getTypeLength(this.c.getType(e)):0,p=this.getInputType(e),u=this.getType(e);switch(this.type=u,this.method){case Pe.NEGATE:return e.format("( -"+this.a.build(e,p)+" )",p,r);case Pe.INVERT:return e.format("( 1.0 - "+this.a.build(e,p)+" )",p,r);case Pe.CROSS:i=this.a.build(e,"v3"),o=this.b.build(e,"v3");break;case Pe.STEP:i=this.a.build(e,a===1?"f":p),o=this.b.build(e,p);break;case Pe.MIN:case Pe.MAX:case Pe.MOD:i=this.a.build(e,p),o=this.b.build(e,l===1?"f":p);break;case Pe.REFRACT:i=this.a.build(e,p),o=this.b.build(e,p),s=this.c.build(e,"f");break;case Pe.MIX:i=this.a.build(e,p),o=this.b.build(e,p),s=this.c.build(e,c===1?"f":p);break;default:i=this.a.build(e,p),this.b&&(o=this.b.build(e,p)),this.c&&(s=this.c.build(e,p));break}let h=[];h.push(i),o&&h.push(o),s&&h.push(s);let m=this.getNumInputs(e);if(h.length!==m)throw Error(`Arguments not match used in "${this.method}". Require ${m}, currently ${h.length}.`);return e.format(this.method+"( "+h.join(", ")+" )",u,r)}copy(e){return super.copy(e),this.a.copy(e.a),this.b=e.b instanceof he?e.b.clone():e.b,this.c=e.c instanceof he?e.c.clone():e.c,this.method=e.method,this}},ye=Pe;ye.RAD="radians",ye.DEG="degrees",ye.EXP="exp",ye.EXP2="exp2",ye.LOG="log",ye.LOG2="log2",ye.SQRT="sqrt",ye.INV_SQRT="inversesqrt",ye.FLOOR="floor",ye.CEIL="ceil",ye.NORMALIZE="normalize",ye.FRACT="fract",ye.SATURATE="saturate",ye.SIN="sin",ye.COS="cos",ye.TAN="tan",ye.ASIN="asin",ye.ACOS="acos",ye.ARCTAN="atan",ye.ABS="abs",ye.SIGN="sign",ye.LENGTH="length",ye.NEGATE="negate",ye.INVERT="invert",ye.MIN="min",ye.MAX="max",ye.MOD="mod",ye.STEP="step",ye.REFLECT="reflect",ye.DISTANCE="distance",ye.DOT="dot",ye.CROSS="cross",ye.POW="pow",ye.MIX="mix",ye.CLAMP="clamp",ye.REFRACT="refract",ye.SMOOTHSTEP="smoothstep",ye.FACEFORWARD="faceforward";var lo=class extends fe{constructor(e=new he,r=new he,i=new he){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=i}bilinearCubeUV(e,r,i,o){var c,p,u,h;let s=new sn(lo.Nodes.bilinearCubeUV,[r,i,o]);this.colorSpaceTL=(c=this.colorSpaceTL)!=null?c:new Tt(new _e("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(s.build(e)+".tl"),this.colorSpaceTR=(p=this.colorSpaceTR)!=null?p:new Tt(new _e("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(s.build(e)+".tr"),this.colorSpaceBL=(u=this.colorSpaceBL)!=null?u:new Tt(new _e("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(s.build(e)+".bl"),this.colorSpaceBR=(h=this.colorSpaceBR)!=null?h:new Tt(new _e("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(s.build(e)+".br");let a={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(a),this.colorSpaceTLExp=new _e(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new _e(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new _e(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new _e(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new _e("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return l.keywords.cubeUV_TL=this.colorSpaceTLExp,l.keywords.cubeUV_TR=this.colorSpaceTRExp,l.keywords.cubeUV_BL=this.colorSpaceBLExp,l.keywords.cubeUV_BR=this.colorSpaceBRExp,l.keywords.cubeUV=s,l}generate(e,r){if(e.isShader("fragment")){let i=this.uv,o=this.bias||e.context.roughness,s=new sn(lo.Nodes.roughnessToMip,[o]),a=new ye(s,lo.Nodes.m0,lo.Nodes.cubeUV_maxMipLevel,ye.CLAMP),l=new ye(a,ye.FLOOR),c=new ye(a,ye.FRACT),p=this.bilinearCubeUV(e,this.value,i,l),u=this.bilinearCubeUV(e,this.value,i,new At(l,new te(1).setReadonly(!0),At.ADD)),h=new ye(p,u,c,ye.MIX);return e.format(h.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}},co=lo;co.Nodes=function(){let e=new no(`struct TextureCubeUVData {
25
6
  vec4 tl;
26
7
  vec4 tr;
27
8
  vec4 br;
28
9
  vec4 bl;
29
10
  vec2 f;
30
- }`),t=new it("float cubeUV_maxMipLevel 8.0",!0),r=new it("float cubeUV_minMipLevel 4.0",!0),n=new it("float cubeUV_maxTileSize 256.0",!0),s=new it("float cubeUV_minTileSize 16.0",!0),l=new Se(`float getFace(vec3 direction) {
11
+ }`),r=new Te("float cubeUV_maxMipLevel 8.0",!0),i=new Te("float cubeUV_minMipLevel 4.0",!0),o=new Te("float cubeUV_maxTileSize 256.0",!0),s=new Te("float cubeUV_minTileSize 16.0",!0),a=new re(`float getFace(vec3 direction) {
31
12
  vec3 absDirection = abs(direction);
32
13
  float face = -1.0;
33
14
  if (absDirection.x > absDirection.z) {
@@ -42,7 +23,7 @@ function print() { __p += __j.call(arguments, '') }
42
23
  face = direction.y > 0.0 ? 1.0 : 4.0;
43
24
  }
44
25
  return face;
45
- }`);l.useKeywords=!1;let c=new Se(`vec2 getUV(vec3 direction, float face) {
26
+ }`);a.useKeywords=!1;let l=new re(`vec2 getUV(vec3 direction, float face) {
46
27
  vec2 uv;
47
28
  if (face == 0.0) {
48
29
  uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x
@@ -58,7 +39,7 @@ function print() { __p += __j.call(arguments, '') }
58
39
  uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z
59
40
  }
60
41
  return 0.5 * (uv + 1.0);
61
- }`);c.useKeywords=!1;let f=new Se(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
42
+ }`);l.useKeywords=!1;let c=new re(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
62
43
  float face = getFace(direction);
63
44
  float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
64
45
  mipInt = max(mipInt, cubeUV_minMipLevel);
@@ -86,7 +67,7 @@ function print() { __p += __j.call(arguments, '') }
86
67
  uv.x -= texelSize;
87
68
  vec4 bl = texture2D(envMap, uv);
88
69
  return TextureCubeUVData( tl, tr, br, bl, f );
89
- }`,[e,l,c,t,r,n,s]);f.useKeywords=!1;let h=new it("float r0 1.0",!0),d=new it("float v0 0.339",!0),x=new it("float m0 -2.0",!0),g=new it("float r1 0.8",!0),w=new it("float v1 0.276",!0),S=new it("float m1 -1.0",!0),D=new it("float r4 0.4",!0),C=new it("float v4 0.046",!0),G=new it("float m4 2.0",!0),B=new it("float r5 0.305",!0),P=new it("float v5 0.016",!0),W=new it("float m5 3.0",!0),M=new it("float r6 0.21",!0),q=new it("float v6 0.0038",!0),E=new it("float m6 4.0",!0),b=[h,d,x,g,w,S,D,C,G,B,P,W,M,q,E],R=new Se(`float roughnessToMip(float roughness) {
70
+ }`,[e,a,l,r,i,o,s]);c.useKeywords=!1;let p=new Te("float r0 1.0",!0),u=new Te("float v0 0.339",!0),h=new Te("float m0 -2.0",!0),m=new Te("float r1 0.8",!0),f=new Te("float v1 0.276",!0),L=new Te("float m1 -1.0",!0),S=new Te("float r4 0.4",!0),y=new Te("float v4 0.046",!0),w=new Te("float m4 2.0",!0),I=new Te("float r5 0.305",!0),_=new Te("float v5 0.016",!0),g=new Te("float m5 3.0",!0),V=new Te("float r6 0.21",!0),b=new Te("float v6 0.0038",!0),d=new Te("float m6 4.0",!0),O=[p,u,h,m,f,L,S,y,w,I,_,g,V,b,d],x=new re(`float roughnessToMip(float roughness) {
90
71
  float mip = 0.0;
91
72
  if (roughness >= r1) {
92
73
  mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
@@ -100,8 +81,8 @@ function print() { __p += __j.call(arguments, '') }
100
81
  mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
101
82
  }
102
83
  return mip;
103
- }`,b);return{bilinearCubeUV:f,roughnessToMip:R,m0:x,cubeUV_maxMipLevel:t}}();var Lo=class extends Be{constructor(e){super("v3");this.nodeType="Normal";this.scope=e!=null?e:Lo.VIEW}getShared(){return this.scope===Lo.WORLD}build(e,t,r,n){let s=e.context[this.scope+"Normal"];return s?s.build(e,t,r,n):super.build(e,t,r)}generate(e,t,r,n,s){let l;switch(this.scope){case Lo.VIEW:e.isShader("vertex")?l="transformedNormal":l="geometryNormal";break;case Lo.LOCAL:e.isShader("vertex")?l="objectNormal":(e.requires.normal=!0,l="vObjectNormal");break;case Lo.WORLD:e.isShader("vertex")?l="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,l="vWNormal");break}return e.format(l,this.getType(e),t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},pr=Lo;pr.LOCAL="local",pr.WORLD="world",pr.VIEW="view",pr.NORMAL="normal";tr.addKeyword("viewNormal",function(){return new pr(pr.VIEW)});tr.addKeyword("localNormal",function(){return new pr(pr.NORMAL)});tr.addKeyword("worldNormal",function(){return new pr(pr.WORLD)});var Zn=class extends Be{constructor(e){super("v3");this.nodeType="Position";this.scope=e!=null?e:Zn.LOCAL}getType(){switch(this.scope){case Zn.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Zn.LOCAL:case Zn.WORLD:return!1}return!0}generate(e,t,r,n,s){let l;switch(this.scope){case Zn.LOCAL:e.isShader("vertex")?l="transformed":(e.requires.position=!0,l="vPosition");break;case Zn.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,l="vWPosition";break;case Zn.VIEW:l=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Zn.PROJECTION:l=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(l,this.getType(),t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},xr=Zn;xr.LOCAL="local",xr.WORLD="world",xr.VIEW="view",xr.PROJECTION="projection";tr.addKeyword("position",function(){return new xr});tr.addKeyword("worldPosition",function(){return new xr(xr.WORLD)});tr.addKeyword("viewPosition",function(){return new xr(xr.VIEW)});var Bn=class extends Be{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e!=null?e:Bn.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case Bn.SPHERE:return"v2"}return this.type}generate(e,t){let r=this.getUnique(e);if(e.isShader("fragment")){let n;switch(this.scope){case Bn.VECTOR:{let s=new pr(pr.VIEW),l=e.context.roughness,c=s.build(e,"v3"),f=new xr(xr.VIEW).build(e,"v3"),h=l?l.build(e,"f"):void 0,d=`reflect( -normalize( ${f} ), ${c} )`;h&&(d=`normalize( mix( ${d}, ${c}, ${h} * ${h} ) )`);let x=`inverseTransformDirection( ${d}, viewMatrix )`;r?(e.addNodeCode(`vec3 reflectVec = ${x};`),n="reflectVec"):n=x;break}case Bn.CUBE:{let s=new Bn(Bn.VECTOR).build(e,"v3"),l="vec3( -"+s+".x, "+s+".yz )";r?(e.addNodeCode(`vec3 reflectCubeVec = ${l};`),n="reflectCubeVec"):n=l;break}case Bn.SPHERE:{let s=new Bn(Bn.VECTOR).build(e,"v3"),l="normalize( ( viewMatrix * vec4( "+s+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";r?(e.addNodeCode(`vec2 reflectSphereVec = ${l};`),n="reflectSphereVec"):n=l;break}}return e.format(n,this.getType(),t)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},Si=Bn;Si.CUBE="cube",Si.SPHERE="sphere",Si.VECTOR="vector";var rp=class extends Be{constructor(e=new Fr,t,r){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Aa(this.value,t!=null?t:new Si(Si.VECTOR),r),this.irradianceNode=new Aa(this.value,new pr(pr.WORLD),new ve(1).setReadonly(!0))}generate(e,t){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,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}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 dD}from"three";var np=class extends It{constructor(e=new dD,t,r){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t!=null?t:new Si,this.bias=r}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){var h,d;if(t==="samplerCube")return this.getTexture(e,t);let r=this.getTexture(e,t),n=(h=this.uv)==null?void 0:h.build(e,"v3"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let l;s?l="texCubeBias( "+r+", "+n+", "+s+" )":l="texCube( "+r+", "+n+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},f=this.getType(e);return e.addContext(c),this.colorSpace=(d=this.colorSpace)!=null?d:new zr(new xt("",f)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,f),e.removeContext(),e.format(l,f,t)}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 wv=["x","y","z","w"],vD=["float","vec2","vec3","vec4"],bD={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},SD={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[]"},ip=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.getIncludesCode=function(){function e(t,r){return t.deps.length-r.deps.length}return function(r,n){let s=this.getIncludes(r,n);if(!s)return"";let l="";s=s.sort(e);for(let c=0;c<s.length;c++)s[c].src&&(l+=s[c].src+`
104
- `);return l}}();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",`
84
+ }`,O);return{bilinearCubeUV:c,roughnessToMip:x,m0:h,cubeUV_maxMipLevel:r}}();var yi=class extends fe{constructor(e){super("v3");this.nodeType="Normal";this.scope=e!=null?e:yi.VIEW}getShared(){return this.scope===yi.WORLD}build(e,r,i,o){let s=e.context[this.scope+"Normal"];return s?s.build(e,r,i,o):super.build(e,r,i)}generate(e,r,i,o,s){let a;switch(this.scope){case yi.VIEW:e.isShader("vertex")?a="transformedNormal":a="geometryNormal";break;case yi.LOCAL:e.isShader("vertex")?a="objectNormal":(e.requires.normal=!0,a="vObjectNormal");break;case yi.WORLD:e.isShader("vertex")?a="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,a="vWNormal");break}return e.format(a,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}},lt=yi;lt.LOCAL="local",lt.WORLD="world",lt.VIEW="view",lt.NORMAL="normal";ot.addKeyword("viewNormal",function(){return new lt(lt.VIEW)});ot.addKeyword("localNormal",function(){return new lt(lt.NORMAL)});ot.addKeyword("worldNormal",function(){return new lt(lt.WORLD)});var mr=class extends fe{constructor(e){super("v3");this.nodeType="Position";this.scope=e!=null?e:mr.LOCAL}getType(){switch(this.scope){case mr.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case mr.LOCAL:case mr.WORLD:return!1}return!0}generate(e,r,i,o,s){let a;switch(this.scope){case mr.LOCAL:e.isShader("vertex")?a="transformed":(e.requires.position=!0,a="vPosition");break;case mr.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,a="vWPosition";break;case mr.VIEW:a=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case mr.PROJECTION:a=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(a,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}},dt=mr;dt.LOCAL="local",dt.WORLD="world",dt.VIEW="view",dt.PROJECTION="projection";ot.addKeyword("position",function(){return new dt});ot.addKeyword("worldPosition",function(){return new dt(dt.WORLD)});ot.addKeyword("viewPosition",function(){return new dt(dt.VIEW)});var er=class extends fe{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e!=null?e:er.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case er.SPHERE:return"v2"}return this.type}generate(e,r){let i=this.getUnique(e);if(e.isShader("fragment")){let o;switch(this.scope){case er.VECTOR:{let s=new lt(lt.VIEW),a=e.context.roughness,l=s.build(e,"v3"),c=new dt(dt.VIEW).build(e,"v3"),p=a?a.build(e,"f"):void 0,u=`reflect( -normalize( ${c} ), ${l} )`;p&&(u=`normalize( mix( ${u}, ${l}, ${p} * ${p} ) )`);let h=`inverseTransformDirection( ${u}, viewMatrix )`;i?(e.addNodeCode(`vec3 reflectVec = ${h};`),o="reflectVec"):o=h;break}case er.CUBE:{let s=new er(er.VECTOR).build(e,"v3"),a="vec3( -"+s+".x, "+s+".yz )";i?(e.addNodeCode(`vec3 reflectCubeVec = ${a};`),o="reflectCubeVec"):o=a;break}case er.SPHERE:{let s=new er(er.VECTOR).build(e,"v3"),a="normalize( ( viewMatrix * vec4( "+s+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";i?(e.addNodeCode(`vec2 reflectSphereVec = ${a};`),o="reflectSphereVec"):o=a;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}},fr=er;fr.CUBE="cube",fr.SPHERE="sphere",fr.VECTOR="vector";var Xs=class extends fe{constructor(e=new Nt,r,i){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new co(this.value,r!=null?r:new fr(fr.VECTOR),i),this.irradianceNode=new co(this.value,new lt(lt.WORLD),new te(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 Fv}from"three";var Zs=class extends Fe{constructor(e=new Fv,r,i){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=r!=null?r:new fr,this.bias=i}getTexture(e,r){return super.generate(e,r,this.value.uuid,"tc")}generate(e,r){var p,u;if(r==="samplerCube")return this.getTexture(e,r);let i=this.getTexture(e,r),o=(p=this.uv)==null?void 0:p.build(e,"v3"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let a;s?a="texCubeBias( "+i+", "+o+", "+s+" )":a="texCube( "+i+", "+o+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=(u=this.colorSpace)!=null?u:new Tt(new _e("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(a),a=this.colorSpace.build(e,c),e.removeContext(),e.format(a,c,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 sd=["x","y","z","w"],qv=["float","vec2","vec3","vec4"],Wv={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},$v={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[]"},Qs=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,i){let o=this.getIncludes(r,i);if(!o)return"";let s="";o=o.sort(t);for(let a=0;a<o.length;a++)o[a].src&&(s+=o[a].src+`
85
+ `);return s}}();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
86
  // NOTE: Include Spline's blending modes. This could be part of BlendNode
106
87
  #define SPE_BLENDING_NORMAL 0
107
88
  #define SPE_BLENDING_MULTIPLY 1
@@ -138,15 +119,15 @@ function print() { __p += __j.call(arguments, '') }
138
119
  `),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
139
120
  accumAlpha += (1.0 - accumAlpha) * alpha;
140
121
  }`,""].join(`
141
- `)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(e,t){this.buildShader("vertex",e),this.buildShader("fragment",t);for(let r=0;r<this.requires.uv.length;r++)if(this.requires.uv[r]){let n=r>0?r+1:"";this.addVaryCode("varying vec2 vUv"+n+";"),r>0&&this.addVertexParsCode("attribute vec2 uv"+n+";"),this.addVertexFinalCode("vUv"+n+" = uv"+n+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition&&(this.addVaryCode("varying vec3 vWPosition;"),this.addVertexFinalCode("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;")),this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("vObjectNormal = normal;")),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this}buildShader(e,t){this.resultCode[e]=t.build(this.setShader(e),"v4")}setMaterial(e,t){return this.material=e,this.renderer=t,this.requires.lights=e.lights,this.requires.fog=e.fog,this.mergeDefines(e.defines),this}addFlow(e,t,r){return this.addSlot(e).addCache(t).addContext(r)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(e){return this.cache=e!=null?e:"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(e){return this.context=Object.assign({},this.context,e),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(e){return this.slot=e||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(e,t){this.fragmentVariables[e]===void 0&&(this.addFragmentCode(`${t} ${e};`),this.fragmentVariables[e]="")}addVertexCode(e){this.addCode(e,"vertex")}addFragmentCode(e){this.addCode(e,"fragment")}addCode(e,t){this.code[t!=null?t:this.shader]+=e+`
142
- `}addVertexNodeCode(e){this.addNodeCode(e,"vertex")}addFragmentNodeCode(e){this.addNodeCode(e,"fragment")}addNodeCode(e,t){this.nodeCode[t!=null?t:this.shader]+=e+`
143
- `}clearNodeCode(e){e=e!=null?e:this.shader;let t=this.nodeCode[e];return this.nodeCode[e]="",t}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(e){this.addFinalCode(e,"vertex")}addFragmentFinalCode(e){this.addFinalCode(e,"fragment")}addFinalCode(e,t){this.finalCode[t!=null?t:this.shader]+=e+`
144
- `}addVertexParsCode(e){this.addParsCode(e,"vertex")}addFragmentParsCode(e){this.addParsCode(e,"fragment")}addParsCode(e,t){this.parsCode[t!=null?t:this.shader]+=e+`
145
- `}addVaryCode(e){this.addVertexParsCode(e),this.addFragmentParsCode(e)}isCache(e){return this.caches.indexOf(e)!==-1}isSlot(e){return this.slots.indexOf(e)!==-1}define(e,t){this.defines[e]=t===void 0?1:t}require(e){this.requires[e]=!0}isDefined(e){return this.defines[e]!==void 0}getVar(e,t,r,n="varying",s="V",l=""){let c=this.getVars(n),f=c[e];if(!f){let h=c.length;f={name:r||"node"+s+h+(l?"_"+l:""),type:t},c.push(f),c[e]=f}return f}getTempVar(e,t,r,n){return this.getVar(e,t,r,this.shader,"T",n)}getAttribute(e,t){if(!this.attributes[e]){let r=this.getVar(e,t);this.addVertexParsCode("attribute "+t+" "+e+";"),this.addVertexFinalCode(r.name+" = "+e+";"),this.attributes[e]={varying:r,name:e,type:t}}return this.attributes[e]}getCode(e){return[this.prefixCode,this.parsCode[e],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[e],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[e],"uniform"),this.getIncludesCode("consts",e),this.getIncludesCode("structs",e),this.getIncludesCode("functions",e),"void main() {",this.getVarListCode(this.getVars(e)),this.code[e],this.resultCode[e],this.finalCode[e],"}"].join(`
146
- `)}getVarListCode(e,t){t=t!=null?t:"";let r="";for(let n=0,s=e.length;n<s;++n){let l=e[n],c=l.type,f=l.name,h=l.size,d=this.getFormatByType(c);if(d===void 0)throw new Error("Node pars "+d+" not found.");d.includes("[]")?r+=t+" "+d.substring(0,d.length-2)+" "+f+`[${h}];
147
- `:r+=t+" "+d+" "+f+`;
148
- `}return r}getVars(e){return this.inputs.vars[e!=null?e:this.shader]}getNodeData(e){let t=e instanceof Pe?e.uuid:e;return this.nodeData[t]=this.nodeData[t]||{}}createUniform(e,t,r,n,s,l){if(t.includes("[]")){let c=this.inputs.arrayUniforms,f=c.list.length,h=new hu({type:t,size:r.size,name:n||"nodeUA"+f+(l?"_"+l:""),node:r,needsUpdate:s});return c.list.push(h),c[e].push(h),c[e][h.name]=h,this.uniforms[h.name]=h,h}else{let c=this.inputs.uniforms,f=c.list.length,h=new hu({type:t,name:n||"nodeU"+f+(l?"_"+l:""),node:r,needsUpdate:s});return c.list.push(h),c[e].push(h),c[e][h.name]=h,this.uniforms[h.name]=h,h}}createVertexUniform(e,t,r,n,s){return this.createUniform("vertex",e,t,r,n,s)}createFragmentUniform(e,t,r,n,s){return this.createUniform("fragment",e,t,r,n,s)}include(e,t,r){var l;let n;if(e=typeof e=="string"?tr.get(e):e,this.context.include===!1)return e.name;e instanceof Se?n=this.includes.functions:e instanceof it?n=this.includes.consts:e instanceof Ia&&(n=this.includes.structs);let s=n[this.shader]=n[this.shader]||[];if(e){let c=s[e.name];if(c||(c=s[e.name]={node:e,deps:[]},s.push(c),c.src=e.build(this,"source")),e instanceof Se&&t&&s[t.name]&&s[t.name].deps.indexOf(e)===-1&&(s[t.name].deps.push(e),(l=e.includes)==null?void 0:l.length)){let f=0;do this.include(e.includes[f++],t);while(f<e.includes.length)}return r&&(c.src=r),e.name}else throw new Error("Include not found.")}colorToVectorProperties(e){return e.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(e){return e.replace(/c/g,"v3")}getIncludes(e,t){return this.includes[e][t||this.shader]}getConstructorFromLength(e){return vD[e-1]}isTypeMatrix(e){return/^m/.test(e)}getTypeLength(e){return e==="f"?1:parseInt(this.colorToVector(e).substr(1))}getTypeFromLength(e){return e===1?"f":"v"+e}findNode(...e){for(let t=0;t<arguments.length;t++){let r=e[t];if(r==null?void 0:r.isNode)return r}}resolve(...e){for(let t=0;t<arguments.length;t++){let r=e[t];if(r!==void 0){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case mD:case gD:return new np(r);case yD:return new rp(new Fr(r));default:return new Fr(r)}else{if(r.isVector2)return new _r(r);if(r.isVector3)return new Tr(r);if(r.isVector4)return new Ji(r)}}}}format(e,t,r){switch(this.colorToVector(r+" <- "+t)){case"f <- v2":return e+".x";case"f <- v3":return e+".x";case"f <- v4":return e+".x";case"f <- i":case"f <- b":return"float( "+e+" )";case"v2 <- f":return"vec2( "+e+" )";case"v2 <- v3":return e+".xy";case"v2 <- v4":return e+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+e+" ) )";case"v3 <- f":return"vec3( "+e+" )";case"v3 <- v2":return"vec3( "+e+", 0.0 )";case"v3 <- v4":return e+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+e+" ) )";case"v4 <- f":return"vec4( "+e+" )";case"v4 <- v2":return"vec4( "+e+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+e+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+e+" ) )";case"i <- f":case"i <- b":return"int( "+e+" )";case"i <- v2":return"int( "+e+".x )";case"i <- v3":return"int( "+e+".x )";case"i <- v4":return"int( "+e+".x )";case"b <- f":return"( "+e+" != 0.0 )";case"b <- v2":return"( "+e+" != vec2( 0.0 ) )";case"b <- v3":return"( "+e+" != vec3( 0.0 ) )";case"b <- v4":return"( "+e+" != vec4( 0.0 ) )";case"b <- i":return"( "+e+" != 0 )"}return e}getTypeByFormat(e){return bD[e]||e}getFormatByType(e){return SD[e]||e}getUUID(e,t){return t=t!==void 0?t:!0,t&&this.cache&&(e=this.cache+"-"+e),e}getElementByIndex(e){return wv[e]}getIndexByElement(e){return wv.indexOf(e)}isShader(e){return this.shader===e}setShader(e){return this.shader=e,this}mergeDefines(e){for(let t in e)this.defines[t]=e[t];return this.defines}mergeUniform(e){for(let t in e)this.uniforms[t]=e[t];return this.uniforms}getTextureEncodingFromMap(e){let t;return e?e.isTexture&&(t=e.encoding):t=Sv,t===Sv&&this.context.gamma&&(t=xD),t}};var du=class extends Pe{constructor(e=new Pe){super("v4");this.nodeType="Raw";this.value=e}generate(e){let t=this.value.analyzeAndFlow(e,this.type),r=t.code+`
149
- `;return e.isShader("vertex")?r+="gl_Position = "+t.result+";":r+="gl_FragColor = "+t.result+";",r}copy(e){return super.copy(e),this.value.copy(e.value),this}};var vt=class extends It{constructor(e=0,t,r,n){super("c");this.nodeType="Color";this.value=e instanceof tn?e:new tn(e||0,t,r,n)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,r,n,s,l){r=e.getUUID(r!=null?r:this.getUUID()),n=n!=null?n:this.getType(e);let c=e.getNodeData(r),f=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let h=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${h};`)}return f?this.generateReadonly(e,t,r,n,s,l):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(n,this,s,l,this.getLabel())),e.format(c.vertex.name,n,t)):(c.fragment||(c.fragment=e.createFragmentUniform(n,this,s,l,this.getLabel())),e.format(c.fragment.name,n,t))}generateReadonly(e,t,r,n,s,l){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",n,t)}};import{MathUtils as wi,Vector2 as Ki,Vector3 as Xi,Vector4 as _u}from"three";import{Texture as wD}from"three";var Ye=class extends It{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e!=null?e:0)}generateReadonly(e,t,r,n,s,l){return e.format(this.value.toString(),n,t)}copy(e){return super.copy(e),this.value=e.value,this}};var qe;(function(D){D.POSITION="position",D.LIGHTING="light",D.COLOR="color",D.GRADIENT="gradient",D.NORMAL="normal",D.DEPTH="depth",D.TEXTURE="texture",D.NOISE="noise",D.FRESNEL="fresnel",D.RAINBOW="rainbow",D.TRANSMISSION="transmission",D.POINTS="points",D.MATCAP="matcap",D.LINES="lines",D.DISPLACE="displace"})(qe||(qe={}));var Mt;(function(r){r.POSITION="position",r.LIGHTING="light",r.COLOR="color"})(Mt||(Mt={}));var Bt=class{constructor(e,t,r,n){this.next=void 0;this.uniforms={};this.textures={};this.defines={};if(this.id=e,this.uuid=t,r){this.type=r.type;for(let s in r)s!=="type"&&s!=="calpha"&&(this.uniforms[`f${this.id}_${s}`]=r[s]);for(let s in n)this.defines[s]=n[s]}}copy(e){this.id=e.id,this.type=e.type,this.defines=U({},e.defines);for(let t in e.uniforms)this.getName(t)==="transmissionSamplerMap"||this.getName(t)==="transmissionDepthMap"||(this.uniforms[t]?this.uniforms[t].copy(e.uniforms[t]):this.uniforms[t]=e.uniforms[t].clone());return this}clone(){return new Bt(this.id).copy(this)}fromJSON(e,t){this.id=e.id,this.defines=U({},e.defines);for(let r in e.uniforms)this.uniforms[r]=t.getNode(e.uniforms[r]);if(e.type===qe.TEXTURE){if(!(`f${this.id}_textureSize`in this.uniforms)){let r=this.uniforms[`f${this.id}_texture`].value.image;this.uniforms[`f${e.id}_textureSize`]=new Tr(r.width,r.height)}`f${this.id}_size`in this.uniforms||(this.uniforms[`f${e.id}_size`]=new _r(200,200)),`f${e.id}_axis`in this.uniforms||(this.uniforms[`f${e.id}_axis`]=new Ye(0)),`f${e.id}_projection`in this.uniforms||(this.uniforms[`f${e.id}_projection`]=new Ye(0))}else e.type===qe.NOISE?(`f${e.id}_noiseType`in this.uniforms||(this.uniforms[`f${e.id}_noiseType`]=new Ye(0)),`f${e.id}_size`in this.uniforms||(this.uniforms[`f${e.id}_size`]=new Tr(-1,-1,-1))):e.type===qe.DEPTH&&(`f${e.id}_isWorldSpace`in this.uniforms||(this.uniforms[`f${e.id}_isWorldSpace`]=new ve(1)));return this}toJSON(e){let t={};for(let n in this.uniforms)t[n]=this.uniforms[n].toJSON(e).uuid;return{id:this.id,type:this.type,defines:JSON.parse(JSON.stringify(this.defines)),uniforms:t,next:this.next==null?void 0:this.next.toJSON(e)}}copyUniforms(e){for(let t in this.uniforms){let r=this.getName(t);r!==void 0&&e.uniforms[`f${e.id}_${r}`]&&r!=="transmissionDepthMap"&&r!=="transmissionSamplerMap"&&this.uniforms[t].copy(e.uniforms[`f${e.id}_${r}`])}return this}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let r=`f${this.id}_${e}`;this.hasValueByKey(r)&&t!==void 0&&(this.uniforms[r].value=t)}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getValues(){let e={type:this.type};for(let t in this.uniforms){let r=this.getName(t);if(r===void 0)continue;let s=this.uniforms[`f${this.id}_${r}`].value;s!==void 0&&(Array.isArray(s)?e[r]=s.map(l=>l.clone?l.clone():l):e[r]=s.clone?s.clone():s)}return e}getName(e){let r=/f\d+_(.*)/.exec(e);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let r=this.getName(t);r&&e.push(r)}return e}isEqual(e){for(let t in e.uniforms){let r=e.getName(t);if(!r)return!1;let n=this.getValue(r),s=e.uniforms[t].value;if(s.value instanceof wD){if(n.image!==s.image)return!1}else if(Array.isArray(s)){let l=n;for(let c=0,f=l.length;c<f;++c)if(l[c]!==s[c])return!1}else{let l=n;if(l.equals){if(!l.equals(s))return!1}else if(n!==s)return!1}}return!0}dispose(){}};function Nv(i){let e=i instanceof Bt?i.type:i;return e==="texture"||e==="displace_map"||e==="matcap"}var mu=class extends It{constructor(e){super("b");this.nodeType="Bool";this.value=e!=null?e:!1}generateReadonly(e,t,r,n){return e.format(this.value?"true":"false",n,t)}copy(e){return super.copy(e),this.value=e.value,this}};import{Vector4 as Cv}from"three";var Os=class extends It{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof Cv?new Array(e).fill(t):new Array(e).fill(new Cv(0))}copy(e){return super.copy(e),this.value=e.value.map(t=>t.clone()),this}};var Ps=class extends It{constructor(e=1,t){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(t)?t:typeof t=="number"?new Array(e).fill(t):new Array(e).fill(0)}copy(e){return super.copy(e),this.size=e.size,this.value=[...e.value],this}};import{Matrix3 as ND}from"three";var Oa=class extends It{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e!=null?e:new ND}generateReadonly(e,t,r,n,s,l){return e.format("mat3("+this.value.elements.join(", ")+")",n,t)}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 Ds;(function(n){n[n.UV=0]="UV",n[n.PLANAR=1]="PLANAR",n[n.SPHERICAL=2]="SPHERICAL",n[n.CYLINDRICAL=3]="CYLINDRICAL"})(Ds||(Ds={}));var Pa=class extends Be{constructor(e=new Fr,t,r,n,s,l,c,f){super("v3");this.nodeType="CustomTexture";this.firstTime=!0,this.texture=e,this.textureSize=t,this.crop=r,this.projection=n,this.axis=s,this.size=l,this.mat=new Oa(this.texture.value.matrix),this.alpha=c,this.mode=f,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let r;switch(this.projection.value){case 3:r=e.include(Pa.Nodes.cylindrical);break;case 2:r=e.include(Pa.Nodes.spherical);break;case 1:let s=new Se(`
122
+ `)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(t,e){this.buildShader("vertex",t),this.buildShader("fragment",e);for(let r=0;r<this.requires.uv.length;r++)if(this.requires.uv[r]){let i=r>0?r+1:"";this.addVaryCode("varying vec2 vUv"+i+";"),r>0&&this.addVertexParsCode("attribute vec2 uv"+i+";"),this.addVertexFinalCode("vUv"+i+" = uv"+i+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition&&(this.addVaryCode("varying vec3 vWPosition;"),this.addVertexFinalCode("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;")),this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("vObjectNormal = normal;")),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this}buildShader(t,e){this.resultCode[t]=e.build(this.setShader(t),"v4")}setMaterial(t,e){return this.material=t,this.renderer=e,this.requires.lights=t.lights,this.requires.fog=t.fog,this.mergeDefines(t.defines),this}addFlow(t,e,r){return this.addSlot(t).addCache(e).addContext(r)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(t){return this.cache=t!=null?t:"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(t){return this.context=Object.assign({},this.context,t),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(t){return this.slot=t||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(t,e){this.fragmentVariables[t]===void 0&&(this.addFragmentCode(`${e} ${t};`),this.fragmentVariables[t]="")}addVertexCode(t){this.addCode(t,"vertex")}addFragmentCode(t){this.addCode(t,"fragment")}addCode(t,e){this.code[e!=null?e:this.shader]+=t+`
123
+ `}addVertexNodeCode(t){this.addNodeCode(t,"vertex")}addFragmentNodeCode(t){this.addNodeCode(t,"fragment")}addNodeCode(t,e){this.nodeCode[e!=null?e:this.shader]+=t+`
124
+ `}clearNodeCode(t){t=t!=null?t:this.shader;let e=this.nodeCode[t];return this.nodeCode[t]="",e}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(t){this.addFinalCode(t,"vertex")}addFragmentFinalCode(t){this.addFinalCode(t,"fragment")}addFinalCode(t,e){this.finalCode[e!=null?e:this.shader]+=t+`
125
+ `}addVertexParsCode(t){this.addParsCode(t,"vertex")}addFragmentParsCode(t){this.addParsCode(t,"fragment")}addParsCode(t,e){this.parsCode[e!=null?e:this.shader]+=t+`
126
+ `}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,i="varying",o="V",s=""){let a=this.getVars(i),l=a[t];if(!l){let c=a.length;l={name:r||"node"+o+c+(s?"_"+s:""),type:e},a.push(l),a[t]=l}return l}getTempVar(t,e,r,i){return this.getVar(t,e,r,this.shader,"T",i)}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(`
127
+ `)}getVarListCode(t,e){e=e!=null?e:"";let r="";for(let i=0,o=t.length;i<o;++i){let s=t[i],a=s.type,l=s.name,c=s.size,p=this.getFormatByType(a);if(p===void 0)throw new Error("Node pars "+p+" not found.");p.includes("[]")?r+=e+" "+p.substring(0,p.length-2)+" "+l+`[${c}];
128
+ `:r+=e+" "+p+" "+l+`;
129
+ `}return r}getVars(t){return this.inputs.vars[t!=null?t:this.shader]}getNodeData(t){let e=t instanceof he?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,r,i,o,s){if(e.includes("[]")){let a=this.inputs.arrayUniforms,l=a.list.length,c=new nn({type:e,size:r.size,name:i||"nodeUA"+l+(s?"_"+s:""),node:r,needsUpdate:o});return a.list.push(c),a[t].push(c),a[t][c.name]=c,this.uniforms[c.name]=c,c}else{let a=this.inputs.uniforms,l=a.list.length,c=new nn({type:e,name:i||"nodeU"+l+(s?"_"+s:""),node:r,needsUpdate:o});return a.list.push(c),a[t].push(c),a[t][c.name]=c,this.uniforms[c.name]=c,c}}createVertexUniform(t,e,r,i,o){return this.createUniform("vertex",t,e,r,i,o)}createFragmentUniform(t,e,r,i,o){return this.createUniform("fragment",t,e,r,i,o)}include(t,e,r){var s;let i;if(t=typeof t=="string"?ot.get(t):t,this.context.include===!1)return t.name;t instanceof re?i=this.includes.functions:t instanceof Te?i=this.includes.consts:t instanceof no&&(i=this.includes.structs);let o=i[this.shader]=i[this.shader]||[];if(t){let a=o[t.name];if(a||(a=o[t.name]={node:t,deps:[]},o.push(a),a.src=t.build(this,"source")),t instanceof re&&e&&o[e.name]&&o[e.name].deps.indexOf(t)===-1&&(o[e.name].deps.push(t),(s=t.includes)!=null&&s.length)){let l=0;do this.include(t.includes[l++],e);while(l<t.includes.length)}return r&&(a.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 qv[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 jv:case Uv:return new Zs(r);case kv:return new Xs(new Nt(r));default:return new Nt(r)}else{if(r.isVector2)return new bt(r);if(r.isVector3)return new vt(r);if(r.isVector4)return new Ir(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 Wv[t]||t}getFormatByType(t){return $v[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return sd[t]}getIndexByElement(t){return sd.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=nd,e===nd&&this.context.gamma&&(e=Hv),e}};var an=class extends he{constructor(e=new he){super("v4");this.nodeType="Raw";this.value=e}generate(e){let r=this.value.analyzeAndFlow(e,this.type),i=r.code+`
130
+ `;return e.isShader("vertex")?i+="gl_Position = "+r.result+";":i+="gl_FragColor = "+r.result+";",i}copy(e){return super.copy(e),this.value.copy(e.value),this}};var Be=class extends Fe{constructor(e=0,r,i,o){super("c");this.nodeType="Color";this.value=e instanceof Pt?e:new Pt(e||0,r,i,o)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,r,i,o,s,a){i=e.getUUID(i!=null?i:this.getUUID()),o=o!=null?o:this.getType(e);let l=e.getNodeData(i),c=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let p=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${p};`)}return c?this.generateReadonly(e,r,i,o,s,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(o,this,s,a,this.getLabel())),e.format(l.vertex.name,o,r)):(l.fragment||(l.fragment=e.createFragmentUniform(o,this,s,a,this.getLabel())),e.format(l.fragment.name,o,r))}generateReadonly(e,r,i,o,s,a){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",o,r)}};import{MathUtils as Pr,Vector2 as Xr,Vector3 as Zr,Vector4 as ea}from"three";import{Texture as Jv}from"three";var ve=class extends Fe{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e!=null?e:0)}generateReadonly(e,r,i,o,s,a){return e.format(this.value.toString(),o,r)}copy(e){return super.copy(e),this.value=e.value,this}};var qe=class{constructor(t,e,r,i){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 i)this.defines[o]=i[o]}}copy(t){this.id=t.id,this.type=t.type,this.defines=P({},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 qe(this.id).copy(this)}fromJSON(t,e){this.id=t.id,this.defines=P({},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 vt(r.width,r.height)}`f${this.id}_size`in this.uniforms||(this.uniforms[`f${t.id}_size`]=new bt(200,200)),`f${t.id}_axis`in this.uniforms||(this.uniforms[`f${t.id}_axis`]=new ve(0)),`f${t.id}_projection`in this.uniforms||(this.uniforms[`f${t.id}_projection`]=new ve(0))}else t.type==="noise"?(`f${t.id}_noiseType`in this.uniforms||(this.uniforms[`f${t.id}_noiseType`]=new ve(0)),`f${t.id}_size`in this.uniforms||(this.uniforms[`f${t.id}_size`]=new vt(-1,-1,-1))):t.type==="depth"&&(`f${t.id}_isWorldSpace`in this.uniforms||(this.uniforms[`f${t.id}_isWorldSpace`]=new te(1)));return this}toJSON(t){let e={};for(let i in this.uniforms)e[i]=this.uniforms[i].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(s=>s.clone?s.clone():s):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 i=this.getValue(r),o=t.uniforms[e].value;if(o.value instanceof Jv){if(i.image!==o.image)return!1}else if(Array.isArray(o)){let s=i;for(let a=0,l=s.length;a<l;++a)if(s[a]!==o[a])return!1}else{let s=i;if(s.equals){if(!s.equals(o))return!1}else if(i!==o)return!1}}return!0}dispose(){}};function ad(n){let t=n instanceof qe?n.type:n;return t==="texture"||t==="displace_map"||t==="matcap"}var ln=class extends Fe{constructor(e){super("b");this.nodeType="Bool";this.value=e!=null?e:!1}generateReadonly(e,r,i,o){return e.format(this.value?"true":"false",o,r)}copy(e){return super.copy(e),this.value=e.value,this}};import{Vector4 as ld}from"three";var gi=class extends Fe{constructor(e=1,r){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(r)?r:r instanceof ld?new Array(e).fill(r):new Array(e).fill(new ld(0))}copy(e){return super.copy(e),this.value=e.value.map(r=>r.clone()),this}};var xi=class extends Fe{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 Kv}from"three";var po=class extends Fe{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e!=null?e:new Kv}generateReadonly(e,r,i,o,s,a){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 pn=class extends fe{constructor(e=new Nt,r,i,o,s,a,l,c){super("v3");this.nodeType="CustomTexture";this.firstTime=!0,this.texture=e,this.textureSize=r,this.crop=i,this.projection=o,this.axis=s,this.size=a,this.mat=new po(this.texture.value.matrix),this.alpha=l,this.mode=c,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 i;switch(this.projection.value){case 3:i=e.include(pn.Nodes.cylindrical);break;case 2:i=e.include(pn.Nodes.spherical);break;case 1:let s=new re(`
150
131
  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
132
 
152
133
  vec2 uvs = ( mat * vec3( (g${this.uuid.toString().replace(/-/g,"")}_vCustomUv * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
@@ -163,7 +144,7 @@ function print() { __p += __j.call(arguments, '') }
163
144
  calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
164
145
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
165
146
  return col;
166
- }`);r=e.include(s);break;default:r=e.include(Pa.Nodes.uv);break}if(this.projection.value===1&&this.firstTime){let s=`g${this.uuid.toString().replace(/-/g,"")}`;e.addVertexParsCode(`varying vec2 ${s}_vCustomUv;`),e.addFragmentParsCode(`varying vec2 ${s}_vCustomUv;`),e.addVertexFinalCode(`
147
+ }`);i=e.include(s);break;default:i=e.include(pn.Nodes.uv);break}if(this.projection.value===1&&this.firstTime){let s=`g${this.uuid.toString().replace(/-/g,"")}`;e.addVertexParsCode(`varying vec2 ${s}_vCustomUv;`),e.addFragmentParsCode(`varying vec2 ${s}_vCustomUv;`),e.addVertexFinalCode(`
167
148
  vec3 ${s}_posN = transformed;
168
149
  ${this.axis.value===0?`
169
150
  float ${s}_u = (1. + (${s}_posN.z)) / 2.;
@@ -181,7 +162,7 @@ ${this.axis.value===2?`
181
162
  `:""}
182
163
 
183
164
  ${s}_vCustomUv = vec2(${s}_u, ${s}_v);
184
- `)}e.addFragmentVariable(this.calpha,"float");let n=[];return n.push(this.texture.getTexture(e,"t")),n.push(this.textureSize.build(e,"v2")),n.push(this.crop.build(e,"f")),n.push(this.mat.build(e,"mat3")),n.push(this.size.build(e,"v2")),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),n.push(this.calpha),this.firstTime=!this.firstTime,e.format(r+"("+n.join(",")+")",this.getType(e),t)}copy(e){return super.copy(e),this.texture.copy(e.texture),this.textureSize=e.textureSize.clone(),this.crop=e.crop.clone(),this.projection=e.projection.clone(),this.axis=e.axis.clone(),this.size=e.size.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this}},gu=Pa;gu.Nodes=function(){let e=new Se(`
165
+ `)}e.addFragmentVariable(this.calpha,"float");let o=[];return o.push(this.texture.getTexture(e,"t")),o.push(this.textureSize.build(e,"v2")),o.push(this.crop.build(e,"f")),o.push(this.mat.build(e,"mat3")),o.push(this.size.build(e,"v2")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),o.push(this.calpha),this.firstTime=!this.firstTime,e.format(i+"("+o.join(",")+")",this.getType(e),r)}copy(e){return super.copy(e),this.texture.copy(e.texture),this.textureSize=e.textureSize.clone(),this.crop=e.crop.clone(),this.projection=e.projection.clone(),this.axis=e.axis.clone(),this.size=e.size.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this}},cn=pn;cn.Nodes=function(){let e=new re(`
185
166
  vec3 cylindricalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
186
167
  vec3 posN = normalize(position);
187
168
  float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
@@ -211,7 +192,7 @@ vec3 cylindricalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, v
211
192
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
212
193
  return col;
213
194
  }
214
- `),t=new Se(`
195
+ `),r=new re(`
215
196
  vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
216
197
  vec3 posN = normalize(vPosition);
217
198
  float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
@@ -239,7 +220,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
239
220
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
240
221
  return col;
241
222
  }
242
- `),r=new Se(`vec3 uvTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
223
+ `),i=new re(`vec3 uvTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
243
224
 
244
225
  vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
245
226
  vec4 tmp = texture2D( tex, uvs );
@@ -255,14 +236,14 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
255
236
  calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
256
237
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
257
238
  return col;
258
- }`);return{cylindrical:e,spherical:t,uv:r}}();var op=class extends Be{constructor(e,t,r,n,s,l,c){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=t,this.scale=r,this.intensity=n,this.factor=s,this.alpha=l,this.mode=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let r=e.include(op.Nodes.fresnel),n=[];return n.push(this.color.build(e,"c")),n.push(this.bias.build(e,"f")),n.push(this.scale.build(e,"f")),n.push(this.intensity.build(e,"f")),n.push(this.factor.build(e,"f")),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),n.push(this.calpha),e.format(r+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.color=e.color.clone(),this.bias=e.bias.clone(),this.scale=e.scale.clone(),this.intensity=e.intensity.clone(),this.factor=e.factor.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this.calpha=e.calpha,this}},yu=op;yu.Nodes=function(){return{fresnel:new Se(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, float alpha, int mode, out float calpha) {
239
+ }`);return{cylindrical:e,spherical:r,uv:i}}();var _l=class extends fe{constructor(e,r,i,o,s,a,l){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=r,this.scale=i,this.intensity=o,this.factor=s,this.alpha=a,this.mode=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let i=e.include(_l.Nodes.fresnel),o=[];return o.push(this.color.build(e,"c")),o.push(this.bias.build(e,"f")),o.push(this.scale.build(e,"f")),o.push(this.intensity.build(e,"f")),o.push(this.factor.build(e,"f")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),o.push(this.calpha),e.format(i+"("+o.join(",")+")",this.getType(e),r)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.color=e.color.clone(),this.bias=e.bias.clone(),this.scale=e.scale.clone(),this.intensity=e.intensity.clone(),this.factor=e.factor.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this.calpha=e.calpha,this}},un=_l;un.Nodes=function(){return{fresnel:new re(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, float alpha, int mode, out float calpha) {
259
240
  float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );
260
241
 
261
242
  float lalpha = clamp( fresnel, 0.0, 1.0 ) * alpha;
262
243
  calpha = lalpha / clamp(lalpha + accumAlpha, 0.001, 1.0);
263
244
  accumAlpha += (1.0 - accumAlpha) * lalpha;
264
245
  return color;
265
- }`)}}();var Bs;(function(s){s.SIMPLEX="simplex3d",s.SIMPLEX_FRACTAL="simplex3dFractal",s.ASHIMA="simplexAshima",s.FBM="fbm",s.PERLIN="perlin"})(Bs||(Bs={}));var Vr=function(){let i=5,e=new Se(`vec3 random3(vec3 c) {
246
+ }`)}}();var hn=(o=>(o.SIMPLEX="simplex3d",o.SIMPLEX_FRACTAL="simplex3dFractal",o.ASHIMA="simplexAshima",o.FBM="fbm",o.PERLIN="perlin",o))(hn||{}),Dt=function(){let t=new re(`vec3 random3(vec3 c) {
266
247
  float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
267
248
  vec3 r;
268
249
  r.z = fract(512.0*j);
@@ -271,7 +252,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
271
252
  j *= .125;
272
253
  r.y = fract(512.0*j);
273
254
  return r-0.5;
274
- }`),t=new Se(`float simplex3d(vec3 p) {
255
+ }`),e=new re(`float simplex3d(vec3 p) {
275
256
  vec3 s = floor(p + dot(p, vec3(F3)));
276
257
  vec3 x = p - s + dot(s, vec3(G3));
277
258
 
@@ -302,7 +283,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
302
283
  d *= w;
303
284
 
304
285
  return dot(d, vec4(52.0));
305
- }`,[e]);t.keywords.F3=new it("float F3 0.3333333"),t.keywords.G3=new it("float G3 0.1666667");let r=new Se(`float simplex3dFractal(vec3 m) {
286
+ }`,[t]);e.keywords.F3=new Te("float F3 0.3333333"),e.keywords.G3=new Te("float G3 0.1666667");let r=new re(`float simplex3dFractal(vec3 m) {
306
287
  mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);
307
288
  mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);
308
289
  mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);
@@ -310,7 +291,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
310
291
  + 0.2666667 * simplex3d(2.0 * m * rot2)
311
292
  + 0.1333333 * simplex3d(4.0 * m * rot3)
312
293
  + 0.0666667 * simplex3d(8.0 * m);
313
- }`,[t]),n=new Se("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),s=new Se("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),l=new Se(`float simplexAshima(vec3 v) {
294
+ }`,[e]),i=new re("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),o=new re("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),s=new re(`float simplexAshima(vec3 v) {
314
295
  const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
315
296
  const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
316
297
  vec3 i = floor(v + dot(v, C.yyy) );
@@ -355,7 +336,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
355
336
  m = m * m;
356
337
  return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
357
338
  dot(p2,x2), dot(p3,x3) ) );
358
- }`,[n,s]),c=new Se("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),f=new Se("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[c]),h=new Se(`float noise(vec3 p){
339
+ }`,[i,o]),a=new re("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new re("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[a]),c=new re(`float noise(vec3 p){
359
340
  vec3 a = floor(p);
360
341
  vec3 d = p - a;
361
342
  d = d * d * (3.0 - 2.0 * d);
@@ -370,7 +351,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
370
351
  vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
371
352
  vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
372
353
  return o4.y * d.y + o4.x * (1.0 - d.y);
373
- }`,[f]),d=new Se(`float fbm(vec3 x) {
354
+ }`,[l]),p=new re(`float fbm(vec3 x) {
374
355
  float v = 0.0;
375
356
  float a = 0.5;
376
357
  vec3 shift = vec3(100);
@@ -380,7 +361,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
380
361
  a *= 0.5;
381
362
  }
382
363
  return v;
383
- }`,[h]);d.keywords.NUM_OCTAVES=new it(`int NUM_OCTAVES ${i}`);let x=new Se("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),g=new Se(`float perlin(vec3 P){
364
+ }`,[c]);p.keywords.NUM_OCTAVES=new Te(`int NUM_OCTAVES ${5}`);let u=new re("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),h=new re(`float perlin(vec3 P){
384
365
  vec3 Pi0 = floor(P);
385
366
  vec3 Pi1 = Pi0 + vec3(1.0);
386
367
  Pi0 = mod(Pi0, 289.0);
@@ -439,7 +420,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
439
420
  vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
440
421
  float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
441
422
  return 2.2 * n_xyz;
442
- }`,[n,s,x]);return{simplex:t,simplexFractal:r,simplexAshima:l,fbm:d,perlin:g}}();var sp=class extends Be{constructor(e,t,r,n,s,l,c){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=t,this.wavelengths=r,this.noiseStrength=n,this.noiseScale=s,this.offset=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let r=e.include(sp.Nodes.rainbow),n=[];return n.push(this.filmThickness.build(e,"f")),n.push(this.movement.build(e,"f")),n.push(this.wavelengths.build(e,"v3")),n.push(this.noiseStrength.build(e,"f")),n.push(this.noiseScale.build(e,"f")),n.push(this.offset.build(e,"v3")),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(r+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.filmThickness=e.filmThickness.clone(),this.movement=e.movement.clone(),this.wavelengths=e.wavelengths.clone(),this.noiseStrength=e.noiseStrength.clone(),this.noiseScale=e.noiseScale.clone(),this.offset=e.offset.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},xu=sp;xu.Nodes=function(){let e=new Se(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
423
+ }`,[i,o,u]);return{simplex:e,simplexFractal:r,simplexAshima:s,fbm:p,perlin:h}}();var Bl=class extends fe{constructor(e,r,i,o,s,a,l){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=r,this.wavelengths=i,this.noiseStrength=o,this.noiseScale=s,this.offset=a,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(Bl.Nodes.rainbow),o=[];return o.push(this.filmThickness.build(e,"f")),o.push(this.movement.build(e,"f")),o.push(this.wavelengths.build(e,"v3")),o.push(this.noiseStrength.build(e,"f")),o.push(this.noiseScale.build(e,"f")),o.push(this.offset.build(e,"v3")),o.push(this.alpha.build(e,"f")),o.push(this.calpha),e.format(i+"("+o.join(",")+")",this.getType(e),r)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.filmThickness=e.filmThickness.clone(),this.movement=e.movement.clone(),this.wavelengths=e.wavelengths.clone(),this.noiseStrength=e.noiseStrength.clone(),this.noiseScale=e.noiseScale.clone(),this.offset=e.offset.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},dn=Bl;dn.Nodes=function(){let e=new re(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
443
424
  vec3 st = position / noiseScale;
444
425
  vec3 q = vec3(simplex3d(st),
445
426
  simplex3d(st + vec3(1.0)),
@@ -452,7 +433,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
452
433
  float noise = simplex3d(st + r);
453
434
 
454
435
  return .5 + .5 * cos((((filmThickness + (noise * noiseStrength)) / (vec3(wavelengths.r * 1.0, wavelengths.g * 0.8, wavelengths.b * 0.6) + 1.0)) * dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal))) + movement);
455
- }`,[Vr.simplex]);return{rainbow:new Se(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, float alpha, out float calpha) {
436
+ }`,[Dt.simplex]);return{rainbow:new re(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, float alpha, out float calpha) {
456
437
  vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);
457
438
 
458
439
  float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);
@@ -461,11 +442,11 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
461
442
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
462
443
 
463
444
  return res;
464
- }`,[e])}}();var ap=class extends Be{constructor(e,t,r,n,s,l,c,f){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=t,this.roughness=r,this.transmissionSamplerSize=n,this.transmissionSamplerMap=s,this.transmissionDepthMap=l,this.aspectRatio=c,this.alpha=f,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",30),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let r=e.include(ap.Nodes.transmission),n=[];return n.push(this.thickness.build(e,"f")),n.push(this.ior.build(e,"f")),n.push(this.roughness.build(e,"f")),n.push(this.transmissionSamplerSize.build(e,"v2")),n.push(this.transmissionSamplerMap.getTexture(e,"t")),n.push(this.transmissionDepthMap.getTexture(e,"t")),n.push(this.aspectRatio.build(e,"v2")),n.push("normal"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(r+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(this),this.thickness=e.thickness.clone(),this.ior=e.ior.clone(),this.roughness=e.roughness.clone(),this.transmissionSamplerSize=e.transmissionSamplerSize.clone(),this.transmissionSamplerMap=e.transmissionSamplerMap,this.transmissionDepthMap=e.transmissionDepthMap,this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},vu=ap;vu.Nodes=function(){let e=new Se(`
445
+ }`,[e])}}();var El=class extends fe{constructor(e,r,i,o,s,a,l,c){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=r,this.roughness=i,this.transmissionSamplerSize=o,this.transmissionSamplerMap=s,this.transmissionDepthMap=a,this.aspectRatio=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",30),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let i=e.include(El.Nodes.transmission),o=[];return o.push(this.thickness.build(e,"f")),o.push(this.ior.build(e,"f")),o.push(this.roughness.build(e,"f")),o.push(this.transmissionSamplerSize.build(e,"v2")),o.push(this.transmissionSamplerMap.getTexture(e,"t")),o.push(this.transmissionDepthMap.getTexture(e,"t")),o.push(this.aspectRatio.build(e,"v2")),o.push("normal"),o.push(this.alpha.build(e,"f")),o.push(this.calpha),e.format(i+"("+o.join(",")+")",this.getType(e),r)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(this),this.thickness=e.thickness.clone(),this.ior=e.ior.clone(),this.roughness=e.roughness.clone(),this.transmissionSamplerSize=e.transmissionSamplerSize.clone(),this.transmissionSamplerMap=e.transmissionSamplerMap,this.transmissionDepthMap=e.transmissionDepthMap,this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},mn=El;mn.Nodes=function(){let e=new re(`
465
446
  float gaussian(vec2 i) {
466
447
  const float sigma = float(NUM_SAMPLES) * .25;
467
448
  return exp( -.5* dot(i/=sigma,i) ) / ( 6.28 * sigma*sigma );
468
- }`),t=new Se(`
449
+ }`),r=new re(`
469
450
  vec4 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
470
451
  // Slightly modified version of this:
471
452
  // https://www.shadertoy.com/view/ltScRG
@@ -492,7 +473,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
492
473
  #endif
493
474
  }
494
475
  return O / O.a;
495
- }`,[e]),r=new Se(`
476
+ }`,[e]),i=new re(`
496
477
  vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
497
478
  // Direction of refracted light.
498
479
  vec3 refractionVector = refract( -v, n, 1.0 / ior );
@@ -503,18 +484,18 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
503
484
  modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
504
485
  // The thickness is specified in local space.
505
486
  return normalize( refractionVector ) * thickness * modelScale;
506
- }`),n=new Se(`
487
+ }`),o=new re(`
507
488
  float applyIorToRoughness( float roughness, float ior ) {
508
489
  // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
509
490
  // an IOR of 1.5 results in the default amount of microfacet refraction.
510
491
  return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
511
- } `),s=new Se(`
492
+ } `),s=new re(`
512
493
  vec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {
513
494
  float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
514
495
  float lod = applyIorToRoughness(roughness, ior);
515
496
 
516
497
  return blur(transmissionSamplerMap, fragCoord, vec2(lod / (transmissionSamplerSize.x / 2.)), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
517
- }`,[n,t]),l=new Se(`
498
+ }`,[o,r]),a=new re(`
518
499
  vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) {
519
500
  vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
520
501
  vec3 refractedRayExit = position + transmissionRay;
@@ -534,7 +515,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
534
515
  vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );
535
516
  // Get the specular component.
536
517
  return vec4( ( 1.0 ) * transmittedLight.rgb, transmittedLight.a );
537
- }`,[s,r]);return{transmission:new Se(`
518
+ }`,[s,i]);return{transmission:new re(`
538
519
  vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float alpha, out float calpha) {
539
520
  vec3 v = vec3(0.);
540
521
  if (isOrthographic) {
@@ -548,14 +529,14 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
548
529
  calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
549
530
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
550
531
  return transmission.rgb;
551
- }`,[l])}}();var lp=class extends Be{constructor(e,t){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=t}generate(e,t){if(e.isShader("fragment")){let r=e.include(lp.Nodes.customNormal),n=[];return n.push(this.cnormal.build(e,"v3")),n.push("normal"),n.push(this.alpha.build(e,"f")),e.format(r+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.cnormal.copy(e.cnormal),this.alpha.copy(e.alpha),this}},bu=lp;bu.Nodes=function(){return{customNormal:new Se(`vec3 customNormal(vec3 cnormal, vec3 norm, float alpha) {
532
+ }`,[a])}}();var Gl=class extends fe{constructor(e,r){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=r}generate(e,r){if(e.isShader("fragment")){let i=e.include(Gl.Nodes.customNormal),o=[];return o.push(this.cnormal.build(e,"v3")),o.push("normal"),o.push(this.alpha.build(e,"f")),e.format(i+"("+o.join(",")+")",this.getType(e),r)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.cnormal.copy(e.cnormal),this.alpha.copy(e.alpha),this}},fn=Gl;fn.Nodes=function(){return{customNormal:new re(`vec3 customNormal(vec3 cnormal, vec3 norm, float alpha) {
552
533
  vec3 normal = packNormalToRGB( norm ).rgb;
553
534
  normal *= step( vec3(0.5), cnormal );
554
535
 
555
536
  accumAlpha += ( 1.0 - accumAlpha ) * alpha;
556
537
 
557
538
  return normal;
558
- }`)}}();var cp=class extends Be{constructor(e,t,r,n,s,l,c,f){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=t,this.colors=r,this.steps=n,this.offset=s,this.morph=l,this.angle=c,this.alpha=f,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let r=e.include(cp.Nodes.gradient),n=[];return n.push(this.gradientType.build(e,"i")),n.push(this.smooth.build(e,"b")),n.push(this.colors.build(e,"v4[]")),n.push(this.steps.build(e,"f[]")),n.push(this.offset.build(e,"v2")),n.push(this.morph.build(e,"v2")),n.push(this.angle.build(e,"f")),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(r+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.gradientType=e.gradientType.clone(),this.smooth=e.smooth.clone(),this.colors=e.colors.clone(),this.steps=e.steps.clone(),this.offset=e.offset.clone(),this.morph=e.morph.clone(),this.angle=e.angle.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},Su=cp;Su.Nodes=function(){return{gradient:new Se(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, float alpha, out float calpha) {
539
+ }`)}}();var zl=class extends fe{constructor(e,r,i,o,s,a,l,c){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=r,this.colors=i,this.steps=o,this.offset=s,this.morph=a,this.angle=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(zl.Nodes.gradient),o=[];return o.push(this.gradientType.build(e,"i")),o.push(this.smooth.build(e,"b")),o.push(this.colors.build(e,"v4[]")),o.push(this.steps.build(e,"f[]")),o.push(this.offset.build(e,"v2")),o.push(this.morph.build(e,"v2")),o.push(this.angle.build(e,"f")),o.push(this.alpha.build(e,"f")),o.push(this.calpha),e.format(i+"("+o.join(",")+")",this.getType(e),r)}else return console.warn("GradientNode 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.colors=e.colors.clone(),this.steps=e.steps.clone(),this.offset=e.offset.clone(),this.morph=e.morph.clone(),this.angle=e.angle.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},yn=zl;yn.Nodes=function(){return{gradient:new re(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, float alpha, out float calpha) {
559
540
  vec4 color = colors[0];
560
541
  vec2 m = morph / vUv.xy;
561
542
  vec2 rot = vec2( 0.5 + m.x, m.y );
@@ -597,11 +578,11 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
597
578
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
598
579
 
599
580
  return color.xyz;
600
- }`)}}();var _o;(function(t){t.NOISE="noise",t.MAP="map"})(_o||(_o={}));var up=class extends Be{constructor(e=new Ye(0),t,r,n,s,l){super("v3");this.nodeType="VertexDisplacement";this.displacementTypeIndex=e,this.intensity=t,this.movementOrTexture=r,Object.values(_o)[this.displacementTypeIndex.value]===_o.MAP&&(this.mat=new Oa(this.movementOrTexture.value.matrix)),this.cropOrOffset=n,this.scale=s,this.noiseFunctionIndex=l}generate(e,t){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let r,n=[];switch(n.push("displaced_position"),n.push("displaced_normal"),Object.values(_o)[this.displacementTypeIndex.value]){case _o.MAP:{r=e.include(up.Nodes.map),n.push(this.movementOrTexture.getTexture(e,"t")),n.push("uv"),n.push(this.cropOrOffset.build(e,"f")),this.mat&&n.push(this.mat.build(e,"mat3"));break}case _o.NOISE:{let l=Object.values(Bs)[this.noiseFunctionIndex.value],c=new Se(`vec3 orthogonal(vec3 v) {
581
+ }`)}}();var Rl=(e=>(e.NOISE="noise",e.MAP="map",e))(Rl||{}),Vl=class extends fe{constructor(e=new ve(0),r,i,o,s,a){super("v3");this.nodeType="VertexDisplacement";this.displacementTypeIndex=e,this.intensity=r,this.movementOrTexture=i,Object.values(Rl)[this.displacementTypeIndex.value]==="map"&&(this.mat=new po(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=s,this.noiseFunctionIndex=a}generate(e,r){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let i,o=[];switch(o.push("displaced_position"),o.push("displaced_normal"),Object.values(Rl)[this.displacementTypeIndex.value]){case"map":{i=e.include(Vl.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 a=Object.values(hn)[this.noiseFunctionIndex.value],l=new re(`vec3 orthogonal(vec3 v) {
601
582
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
602
- }`),f=new Se(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement) {
603
- return p + n * ${l}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
604
- }`,[Vr.simplex,Vr.simplexFractal,Vr.simplexAshima,Vr.fbm,Vr.perlin]),h=new Se(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, float intensity, out vec3 displaced_normal) {
583
+ }`),c=new re(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement) {
584
+ return p + n * ${a}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
585
+ }`,[Dt.simplex,Dt.simplexFractal,Dt.simplexAshima,Dt.fbm,Dt.perlin]),p=new re(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, float intensity, out vec3 displaced_normal) {
605
586
  vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement);
606
587
  vec3 tangent1 = orthogonal(normal);
607
588
  vec3 tangent2 = normalize(cross(normal, tangent1));
@@ -617,9 +598,9 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
617
598
  vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement);
618
599
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
619
600
  return displaced_position;
620
- }`,[f,c]);r=e.include(h),n.push(this.scale.build(e,"f")),n.push(this.cropOrOffset.build(e,"v3")),n.push(this.movementOrTexture.build(e,"f"));break}}return n.push(this.intensity.build(e,"f")),n.push("displaced_normal"),e.format(r+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){var t,r;return super.copy(e),this.noiseFunctionIndex=(t=e.noiseFunctionIndex)==null?void 0:t.clone(),this.scale=(r=e.scale)==null?void 0:r.clone(),this.cropOrOffset=e.cropOrOffset.clone(),this.intensity=e.intensity.clone(),this.movementOrTexture=e.movementOrTexture.clone(),this}},Da=up;Da.Nodes=function(){let e=new Se(`vec3 orthogonal(vec3 v) {
601
+ }`,[c,l]);i=e.include(p),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(i+"("+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,i;return super.copy(e),this.noiseFunctionIndex=(r=e.noiseFunctionIndex)==null?void 0:r.clone(),this.scale=(i=e.scale)==null?void 0:i.clone(),this.cropOrOffset=e.cropOrOffset.clone(),this.intensity=e.intensity.clone(),this.movementOrTexture=e.movementOrTexture.clone(),this}},uo=Vl;uo.Nodes=function(){let e=new re(`vec3 orthogonal(vec3 v) {
621
602
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
622
- }`),t=new Se(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
603
+ }`),r=new re(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
623
604
  vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
624
605
  vec4 tmp = texture2D(tex, uvs);
625
606
  vec3 col = tmp.rgb;
@@ -629,7 +610,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
629
610
  }
630
611
  }
631
612
  return col.r;
632
- }`);return{map:new Se(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {
613
+ }`);return{map:new re(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {
633
614
  vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity;
634
615
  vec3 tangent1 = normalize(orthogonal(normal));
635
616
  vec3 tangent2 = normalize(cross(normal, tangent1));
@@ -639,16 +620,16 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
639
620
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
640
621
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
641
622
  return displaced_position;
642
- }`,[e,t])}}();var wu=class extends Be{constructor(e=new Pe,t=new Pe,r=new Pe,n=new Pe,s=new Pe,l=new Pe,c=new Pe,f=new Pe,h=new Pe,d=new Pe,x=new Pe,g=new Pe){super("v3");this.nodeType="Noise";this.scale=e,this.size=t,this.move=r,this.fA=n,this.fB=s,this.distortion=l,this.colorA=c,this.colorB=f,this.colorC=h,this.colorD=d,this.alpha=x,this.noiseType=g,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t,r,n,s){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let l=Object.values(Bs)[this.noiseType.value],c=new Se(`vec3 ${l}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, float alpha, out float calpha) {
623
+ }`,[e,r])}}();var gn=class extends fe{constructor(e=new he,r=new he,i=new he,o=new he,s=new he,a=new he,l=new he,c=new he,p=new he,u=new he,h=new he,m=new he){super("v3");this.nodeType="Noise";this.scale=e,this.size=r,this.move=i,this.fA=o,this.fB=s,this.distortion=a,this.colorA=l,this.colorB=c,this.colorC=p,this.colorD=u,this.alpha=h,this.noiseType=m,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r,i,o,s){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let a=Object.values(hn)[this.noiseType.value],l=new re(`vec3 ${a}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, float alpha, out float calpha) {
643
624
  vec3 st = position / size;
644
625
  st /= scale;
645
- vec3 q = vec3(${l}(st),
646
- ${l}(st + vec3(1.0)),
647
- ${l}(st + vec3(1.0)));
648
- vec3 r = vec3(${l}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),
649
- ${l}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move),
650
- ${l}(st * q));
651
- float f = ${l}(st + r);
626
+ vec3 q = vec3(${a}(st),
627
+ ${a}(st + vec3(1.0)),
628
+ ${a}(st + vec3(1.0)));
629
+ vec3 r = vec3(${a}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),
630
+ ${a}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move),
631
+ ${a}(st * q));
632
+ float f = ${a}(st + r);
652
633
  vec4 color;
653
634
  color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));
654
635
  color = mix(color, colorC, clamp(length(q), 0.0, 1.0));
@@ -659,17 +640,17 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
659
640
 
660
641
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
661
642
  return clamp(color, 0.0, 1.0).rgb;
662
- }`,[Vr.simplex,Vr.simplexFractal,Vr.simplexAshima,Vr.fbm,Vr.perlin]),f=e.include(c),h=[];return h.push(this.scale.build(e,"f")),h.push(this.size.build(e,"v3")),h.push(this.move.build(e,"f")),h.push(this.fA.build(e,"v2")),h.push(this.fB.build(e,"v2")),h.push(this.distortion.build(e,"v2")),h.push(this.colorA.build(e,"v4")),h.push(this.colorB.build(e,"v4")),h.push(this.colorC.build(e,"v4")),h.push(this.colorD.build(e,"v4")),h.push(this.alpha.build(e,"f")),h.push(this.calpha),e.format(f+"("+h.join(",")+")",this.getType(e),t)}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}};wu.numOctaves=5;var Nu=class extends Be{constructor(e=new Pe,t=new Pe,r=new Pe,n=new Pe){super("v3");this.nodeType="Blend";this.a=e,this.b=t,this.alpha=r,this.mode=n}generate(e,t){if(e.isShader("fragment")){let r=[];return r.push(this.a.build(e,"c")),r.push(this.b.build(e,"c")),r.push(this.alpha.build(e,"f")),r.push(this.mode.build(e,"i")),e.format("spe_blend("+r.join(",")+")",this.getType(e),t)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}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 Gs=class extends Be{constructor(e,t,r,n,s,l,c,f,h,d,x,g){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=t,this.near=r,this.far=n,this.isVector=s,this.isWorldSpace=l,this.origin=c,this.direction=f,this.colors=h,this.steps=d,this.num=x,this.alpha=g,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let r=`g${this.uuid.toString().replace(/-/g,"")}`,n=new Se(`vec3 ${r}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${r}_MAX_COLORS], float steps[10], float alpha, out float calpha) {
643
+ }`,[Dt.simplex,Dt.simplexFractal,Dt.simplexAshima,Dt.fbm,Dt.perlin]),c=e.include(l),p=[];return p.push(this.scale.build(e,"f")),p.push(this.size.build(e,"v3")),p.push(this.move.build(e,"f")),p.push(this.fA.build(e,"v2")),p.push(this.fB.build(e,"v2")),p.push(this.distortion.build(e,"v2")),p.push(this.colorA.build(e,"v4")),p.push(this.colorB.build(e,"v4")),p.push(this.colorC.build(e,"v4")),p.push(this.colorD.build(e,"v4")),p.push(this.alpha.build(e,"f")),p.push(this.calpha),e.format(c+"("+p.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}};gn.numOctaves=5;var xn=class extends fe{constructor(e=new he,r=new he,i=new he,o=new he){super("v3");this.nodeType="Blend";this.a=e,this.b=r,this.alpha=i,this.mode=o}generate(e,r){if(e.isShader("fragment")){let i=[];return i.push(this.a.build(e,"c")),i.push(this.b.build(e,"c")),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),e.format("spe_blend("+i.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 ho=class extends fe{constructor(e,r,i,o,s,a,l,c,p,u,h,m){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=r,this.near=i,this.far=o,this.isVector=s,this.isWorldSpace=a,this.origin=l,this.direction=c,this.colors=p,this.steps=u,this.num=h,this.alpha=m,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let i=`g${this.uuid.toString().replace(/-/g,"")}`,o=new re(`vec3 ${i}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${i}_MAX_COLORS], float steps[10], float alpha, out float calpha) {
663
644
  vec4 color = colors[0];
664
- #ifdef ${r}_IS_VECTOR
665
- #ifdef ${r}_LINEAR
666
- #ifdef ${r}_WORLDSPACE
645
+ #ifdef ${i}_IS_VECTOR
646
+ #ifdef ${i}_LINEAR
647
+ #ifdef ${i}_WORLDSPACE
667
648
  float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far);
668
649
  #else
669
650
  float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far);
670
651
  #endif
671
652
  #else
672
- #ifdef ${r}_WORLDSPACE
653
+ #ifdef ${i}_WORLDSPACE
673
654
  float depth = vectorSphericalWorldSpaceDepth(origin, near, far);
674
655
  #else
675
656
  float depth = vectorSphericalObjectSpaceDepth(origin, near, far);
@@ -682,13 +663,13 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
682
663
 
683
664
 
684
665
  float p;
685
- #ifdef ${r}_SMOOTH
686
- for ( int i = 1; i < ${r}_MAX_COLORS; i++ ) {
666
+ #ifdef ${i}_SMOOTH
667
+ for ( int i = 1; i < ${i}_MAX_COLORS; i++ ) {
687
668
  p = clamp( ( depth - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
688
669
  color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
689
670
  }
690
671
  #else
691
- for ( int i = 1; i < ${r}_MAX_COLORS; i++ ) {
672
+ for ( int i = 1; i < ${i}_MAX_COLORS; i++ ) {
692
673
  p = clamp(( depth - steps[i - 1] ) / ( steps[i] - steps[i - 1] ), 0.0, 1.0);
693
674
  color = mix(color, colors[i], p);
694
675
  }
@@ -699,21 +680,21 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
699
680
 
700
681
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
701
682
  return color.rgb;
702
- }`,[Gs.Nodes.vectorLinearWorldSpaceDepth,Gs.Nodes.vectorLinearObjectSpaceDepth,Gs.Nodes.vectorSphericalObjectSpaceDepth,Gs.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${r}_MAX_COLORS`,this.num.value+1),this.smooth.value&&e.define(`${r}_SMOOTH`),this.isVector.value>.5&&e.define(`${r}_IS_VECTOR`),this.gradientType.value===vs.Linear&&e.define(`${r}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${r}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let s=e.include(n),l=[];return l.push(this.near.build(e,"f")),l.push(this.far.build(e,"f")),l.push(this.origin.build(e,"v3")),l.push(this.direction.build(e,"v3")),l.push(this.colors.build(e,"v4[]")),l.push(this.steps.build(e,"f[]")),l.push(this.alpha.build(e,"f")),l.push(this.calpha),e.format(s+"("+l.join(",")+")",this.getType(e),t)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}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}},Cu=Gs;Cu.Nodes=function(){let e=new Se(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
683
+ }`,[ho.Nodes.vectorLinearWorldSpaceDepth,ho.Nodes.vectorLinearObjectSpaceDepth,ho.Nodes.vectorSphericalObjectSpaceDepth,ho.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${i}_MAX_COLORS`,this.num.value+1),this.smooth.value&&e.define(`${i}_SMOOTH`),this.isVector.value>.5&&e.define(`${i}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${i}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${i}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let s=e.include(o),a=[];return a.push(this.near.build(e,"f")),a.push(this.far.build(e,"f")),a.push(this.origin.build(e,"v3")),a.push(this.direction.build(e,"v3")),a.push(this.colors.build(e,"v4[]")),a.push(this.steps.build(e,"f[]")),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(s+"("+a.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}},bn=ho;bn.Nodes=function(){let e=new re(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
703
684
  vec3 n = normalize(direction);
704
685
  float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
705
686
  return ( dist - near ) / ( far - near );
706
- }`),t=new Se(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
687
+ }`),r=new re(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
707
688
  vec3 n = normalize(direction);
708
689
  float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));
709
690
  return ( dist - near ) / ( far - near );
710
- }`),r=new Se(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
691
+ }`),i=new re(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
711
692
  float dist = length(vWPosition - origin);
712
693
  return ( dist - near ) / ( far - near );
713
- }`),n=new Se(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
694
+ }`),o=new re(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
714
695
  float dist = length(position - origin);
715
696
  return ( dist - near ) / ( far - near );
716
- }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:t,vectorSphericalWorldSpaceDepth:r,vectorSphericalObjectSpaceDepth:n}}();var fp=class extends Be{constructor(e,t,r){super("v3");this.nodeType="Matcap";this.texture=e,this.alpha=t,this.mode=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let r=e.include(fp.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let n=[];return n.push(this.texture.getTexture(e,"t")),n.push("normal"),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),n.push(this.calpha),e.format(r+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.texture=e.texture.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this.calpha=e.calpha,this}},Lu=fp;Lu.Nodes=function(){return{matcap:new Se(`vec3 matcap(sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) {
697
+ }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:r,vectorSphericalWorldSpaceDepth:i,vectorSphericalObjectSpaceDepth:o}}();var Fl=class extends fe{constructor(e,r,i){super("v3");this.nodeType="Matcap";this.texture=e,this.alpha=r,this.mode=i,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let i=e.include(Fl.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let o=[];return o.push(this.texture.getTexture(e,"t")),o.push("normal"),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),o.push(this.calpha),e.format(i+"("+o.join(",")+")",this.getType(e),r)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.texture=e.texture.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this.calpha=e.calpha,this}},vn=Fl;vn.Nodes=function(){return{matcap:new re(`vec3 matcap(sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) {
717
698
  vec3 viewDir = normalize( vViewPosition );
718
699
  vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
719
700
  vec3 y = cross( viewDir, x );
@@ -725,8 +706,8 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
725
706
 
726
707
  return matcapColor.rgb;
727
708
  }
728
- `)}}();var Ir=class{constructor(e){this.id=2,this.layerCount=2,this.uuid=wi.generateUUID(),this.needsUpdate=!1,this._material=e,this._layerNodes=[];let t=this._createLayer({id:0,type:qe.COLOR});this._material.color=t.color,this._material.alpha===void 0&&(this._material.alpha=new ve(1));let r=new ve(1),n=new Ye(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=r,this._material.shadingBlend=n),this._layerNodes.push({id:0,type:Mt.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),this._layerNodes.push({id:1,type:Mt.LIGHTING,alpha:r,mode:n}),this.head=t.layer,this.head.next=new Bt(1,void 0,{type:qe.LIGHTING,alpha:r,mode:n}),this.attachLightNodes(this.getLightLayer())}get material(){return this._material}set material(e){var s;this._material=e;let t,r,n=this.head;for(;n!==void 0;){if(n.type===qe.LIGHTING){t=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=t,this._material.shadingBlend=r),this.attachLightNodes((s=e.userData.layers)==null?void 0:s.getLightLayer()),this.blendColors(),this.blendAfterColors(),this.blendPositions()}getLayersOfType(e){let t=[],r=this.head;for(;r;)r.type===e&&t.push(r),r=r.next;return t}addLayer(e){var n;if(e.id=(n=e.id)!=null?n:++this.id,this.layerCount++,e.type===qe.LIGHTING){let s=this.createLightLayer(e);return this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}let t=this._createLayer(e),r=t.layer;if(this.head===void 0)this.head=r;else{let s=this.head;for(;s.next!=null;)s=s.next;s.next=r}return t.color&&this._layerNodes.push({id:r.id,type:Mt.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),t.position&&this._layerNodes.push({id:r.id,type:Mt.POSITION,position:t.position}),this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),r}addLayerBeforeAt(e,t){var c;let r=this.head;e.id=(c=e.id)!=null?c:++this.id,this.layerCount++;let n=this._createLayer(e),s=n.layer;s.next=t;let l=0;if(r===t)this.head=s,n.color&&this._layerNodes.splice(0,0,{id:s.id,type:Mt.COLOR,color:n.color,alpha:n.alpha,mode:n.mode}),n.position&&this._layerNodes.splice(0,0,{id:s.id,type:Mt.POSITION,position:n.position});else{for(l=1;(r==null?void 0:r.next)!==t;)r=r==null?void 0:r.next,l++;r.next=s,n.color&&this._layerNodes.splice(l,0,{id:s.id,type:Mt.COLOR,color:n.color,alpha:n.alpha,mode:n.mode}),n.position&&this._layerNodes.splice(l,0,{id:s.id,type:Mt.POSITION,position:n.position})}return this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}addLayerAt(e,t){var s;t.id=(s=t.id)!=null?s:++this.id,this.layerCount++;let r=this._createLayer(t),n=r.layer;if(r.color&&this._layerNodes.splice(e,0,{id:n.id,type:Mt.COLOR,color:r.color,alpha:r.alpha,mode:r.mode}),r.position&&this._layerNodes.splice(e,0,{id:n.id,type:Mt.POSITION,position:r.position}),e==0)n.next=this.head,this.head=n;else{let l=this.head,c=this.head.next;for(let f=0;f<e-1;f++)l=c,c=c.next;n.next=c,l.next=n}return this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}removeLayer(e){let t=this.head,r,n=0;if((t==null?void 0:t.id)==e)this.head=t.next;else for(n=1,r=t,t=t==null?void 0:t.next;t!=null;){if(t.id==e){r.next=t.next;break}n++,r=t,t=t.next}return this.cleanupChangedLayer(t),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.uuid=wi.generateUUID(),this.layerCount--,n}changeLayer(e,t){let r,n=this.head,s;if((n==null?void 0:n.id)==e){let l=this._createLayer(U({id:e,uuid:n.uuid},t));s=l.layer,s.next=n.next,this.head=s,l.color&&(this._layerNodes[0]={id:s.id,type:Mt.COLOR,color:l.color,alpha:l.alpha,mode:l.mode}),l.position&&(this._layerNodes[0]={id:s.id,type:Mt.POSITION,position:l.position}),s.uniforms[`f${e}_mode`].value=n.uniforms[`f${e}_mode`].value,s.uniforms[`f${e}_alpha`].value=n.uniforms[`f${e}_alpha`].value}else{r=n,n=n.next;let l=1;for(;n!=null;){if(n.id==e){let c=this._createLayer(U({id:e,uuid:n.uuid},t));s=c.layer,r.next=s,s.next=n.next,c.color&&(this._layerNodes[l]={id:e,type:Mt.COLOR,color:c.color,alpha:c.alpha,mode:c.mode}),c.position&&(this._layerNodes[l]={id:e,type:Mt.POSITION,position:c.position}),s.uniforms[`f${e}_mode`].value=n.uniforms[`f${e}_mode`].value,s.uniforms[`f${e}_alpha`].value=n.uniforms[`f${e}_alpha`].value;break}r=n,n=n.next,l++}}return this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}getLayer(e){let t=this.head;for(;t!=null&&t.id!=e;)t=t.next;return t}getLayerByUuid(e){let t=this.head;for(;t!==void 0;){if(t.uuid===e)return t;t=t.next}}getLayers(){let e=[],t=this.head;for(;t!=null;)e.push(t),t=t.next;return e}getLayerPosition(e){let t=this.head,r=0;for(;t!==void 0&&t.id!=e;)r++,t=t.next;return r}getDefines(){}getBeforeProgram(){}getLightingProgram(){}getAfterProgram(){}getVarPrograms(){}getUniforms(){}moveLayer(e,t){let r,n=this.head,s;if(e==0)r=this.head,this.head=r.next;else{for(let c=0;c<e;c++)s=n,n=n.next;s.next=n.next,r=n}if(n=this.head,s=void 0,t==0)r.next=this.head,this.head=r;else{for(let c=0;c<t-1;c++)n=n.next;r.next=n==null?void 0:n.next,n.next=r}let l=this._layerNodes.splice(e,1)[0];this._layerNodes.splice(t,0,l),this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors()}updateLayerUniform(){this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors()}copy(e){this.needsUpdate=!1,this.layerCount=e.layerCount,this._layerNodes=[],this.layerCount=0,this.head=void 0,this.rebuildLayerNodes(this.head,e.head);let t=e.head,r=this.head;for(;t.next!=null;)this.rebuildLayerNodes(r,t.next),r=r.next,t=t.next;return this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}createLightLayer(e){let t=new ve(e.alpha),r=new Ye(e.mode);this._material.shadingAlpha=t,this._material.shadingBlend=r,this._layerNodes.push({id:e.id,type:Mt.LIGHTING,alpha:t,mode:r});let n=new Bt(e.id,void 0,{type:qe.LIGHTING,alpha:t,mode:r});if(this.head===void 0)this.head=n;else{let s=this.head;for(;s.next!=null;)s=s.next;s.next=n}return this.attachLightNodes(this.getLightLayer()),n}rebuildLayerNodes(e,t,r=!1){if(t.type===qe.LIGHTING){let n=r?t.uniforms[`f${t.id}_alpha`]:new ve(t.uniforms[`f${t.id}_alpha`].value),s=r?t.uniforms[`f${t.id}_mode`]:new Ye(t.uniforms[`f${t.id}_mode`].value);this._material.shadingAlpha=n,this._material.shadingBlend=s,this._layerNodes.push({id:t.id,type:Mt.LIGHTING,alpha:n,mode:s}),this.head===void 0?this.head=new Bt(t.id,t.uuid,{type:qe.LIGHTING,alpha:n,mode:s}):e&&(e.next=new Bt(t.id,t.uuid,{type:qe.LIGHTING,alpha:n,mode:s})),this.attachLightNodes(t)}else{let n={type:t.type,id:t.id};for(let s in t.uniforms){let l=t.getName(s);if(!l)continue;let c=`f${t.id}_${l}`;if(Array.isArray(t.uniforms[c].value))n[l]=t.uniforms[c].value.map(f=>f.clone&&!r?f.clone():f);else{let f=t.uniforms[c].value;if(l==="transmissionDepthMap"){n[l]=f;continue}f!=null&&(n[l]=f.clone&&!r&&!f.isRenderTargetTexture?f.clone():f)}}this.addLayer(n)}}attachLightNodes(e){var n,s,l,c,f,h,d,x,g,w,S;let t={},r=this.getLightLayer();switch(this._material.userData.category){case"Lambert":t.emissive=new vt((s=(n=e==null?void 0:e.getValue("emissive"))==null?void 0:n.clone())!=null?s:0);break;case"Phong":t.shininess=new ve((l=e==null?void 0:e.getValue("shininess"))!=null?l:30),t.specular=new vt((f=(c=e==null?void 0:e.getValue("specular"))==null?void 0:c.clone())!=null?f:1118481);break;case"Toon":t.shininess=new ve((h=e==null?void 0:e.getValue("shininess"))!=null?h:30),t.specular=new vt((x=(d=e==null?void 0:e.getValue("specular"))==null?void 0:d.clone())!=null?x:1118481);break;case"Physical":t.roughness=new ve((g=e==null?void 0:e.getValue("roughness"))!=null?g:.3),t.metalness=new ve((w=e==null?void 0:e.getValue("metalness"))!=null?w:0),t.reflectivity=new ve((S=e==null?void 0:e.getValue("reflectivity"))!=null?S:.5);break;default:break}Object.keys(t).forEach(D=>{this._material[D]=t[D],r.uniforms[`f${r.id}_${D}`]=t[D]})}clone(e){return new Ir(e).copy(this)}toJSON(e){return{id:this.id,uuid:this.uuid,head:this.head.toJSON(e)}}fromJSON(e,t,r){let n=new Bt(e.head.id,void 0,{type:e.head.type}).fromJSON(e.head,t),s=e.head.next,l=n;for(;s!=null;)l.next=new Bt(s.id,void 0,{type:s.type}).fromJSON(s,t),s=s.next,l=l.next;this._layerNodes=[],this.head=void 0,this.rebuildLayerNodes(this.head,n,!0);let c=n;for(l=this.head;c.next!=null;)this.rebuildLayerNodes(l,c.next,!0),l=l.next,c=c.next;return this._material=r,this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}getLightLayer(){var t;let e=this.head;for(;e!==void 0&&e.type!=="light";)e=(t=e.next)!=null?t:e;return e}dispose(){let e=this.head;for(this._layerNodes=[],this.layerCount=0;e!==void 0;)e.hasOwnProperty("dispose")===!0&&e.dispose(),e=e.next;this.head=void 0}_createLayer(e){var r,n,s,l,c,f,h,d,x,g,w,S,D,C,G,B,P,W,M,q,E,b,R,T,z,A,$,he,re,Ne,ye,Me,Fe,k,H,_,J,ee,oe,se,ce,ue,K,ae,ne,Ce,Y,le,pe,xe,_e,de,we,Ve,Ge,Qe,bt,Lt,At,sr,Ur,Ht,kr,wn,Nn,dt,Wt,ar,Ao,Oo,Po,ro,no,Do,Mr,io,Jt,ti,Bo;let t=e.type;switch(t){case qe.COLOR:{let Ee=new vt((r=e.color)!=null?r:Yt),Xe=new ve((n=e.alpha)!=null?n:1),He=new xt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");He.keywords.alpha=Xe;let $e=new Ye((s=e.mode)!=null?s:0);return Ee.alpha=Xe,{layer:new Bt(e.id,e.uuid,{type:t,color:Ee,alpha:Xe,calpha:He,mode:$e}),color:Ee,alpha:He,mode:$e}}case qe.TEXTURE:{let Ee=(l=e.texture)!=null?l:new bi,Xe=Ee.matrix;e.mat&&Xe.copy(e.mat),Ee.needsUpdate=!0;let He=new ve((c=e.crop)!=null?c:0),$e=new Ye((f=e.projection)!=null?f:0),tt=new Ye((h=e.axis)!=null?h:0),at=new _r(e.size?new Ki(e.size[0],e.size[1]):new Ki(100,100)),mt=new ve((d=e.alpha)!=null?d:1),gt=new Ye((x=e.mode)!=null?x:0),ct=new Fr(Ee),St=new Tr((g=e.textureSize)!=null?g:new Xi(Ee.image?Ee.image.width:0,Ee.image?Ee.image.height:0)),Rt=new gu(ct,St,He,$e,tt,at,mt,gt),Ar=new xt(Rt.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,texture:ct,textureSize:St,crop:He,projection:$e,axis:tt,size:at,mat:Rt.mat,alpha:mt,calpha:Ar,mode:gt}),color:Rt,alpha:Ar,mode:gt}}case qe.MATCAP:{let Ee=(w=e.texture)!=null?w:new bi;Ee.needsUpdate=!0;let Xe=new ve((S=e.alpha)!=null?S:1),He=new Fr(Ee),$e=new Ye((D=e.mode)!=null?D:0),tt=new Lu(He,Xe,$e),at=new xt(tt.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,texture:He,alpha:Xe,calpha:at,mode:$e}),color:tt,alpha:at,mode:$e}}case qe.FRESNEL:{let Ee=new vt((C=e.color)!=null?C:16777215),Xe=new ve((G=e.bias)!=null?G:.1),He=new ve((B=e.scale)!=null?B:1),$e=new ve((P=e.intensity)!=null?P:2),tt=new ve((W=e.factor)!=null?W:1),at=new ve((M=e.alpha)!=null?M:1),mt=new Ye((q=e.mode)!=null?q:0),gt=new yu(Ee,Xe,He,$e,tt,at,mt),ct=new xt(gt.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,color:Ee,bias:Xe,scale:He,intensity:$e,factor:tt,alpha:at,calpha:ct,mode:mt}),color:gt,alpha:ct,mode:mt}}case qe.RAINBOW:{let Ee=new ve((E=e.filmThickness)!=null?E:30),Xe=new ve((b=e.movement)!=null?b:0),He=new Tr((R=e.wavelengths)!=null?R:new Xi(0,0,0)),$e=new ve((T=e.noiseStrength)!=null?T:0),tt=new ve((z=e.noiseScale)!=null?z:1),at=new Tr((A=e.offset)!=null?A:new Xi(0,0,0)),mt=new ve(($=e.alpha)!=null?$:1),gt=new xu(Ee,Xe,He,$e,tt,at,mt),ct=new xt(gt.calpha,"f"),St=new Ye((he=e.mode)!=null?he:0);return{layer:new Bt(e.id,e.uuid,{type:t,filmThickness:Ee,movement:Xe,wavelengths:He,noiseStrength:$e,noiseScale:tt,offset:at,alpha:mt,calpha:ct,mode:St}),color:gt,alpha:ct,mode:St}}case qe.TRANSMISSION:{let Ee=new ve((re=e.thickness)!=null?re:10),Xe=new ve((Ne=e.ior)!=null?Ne:1.5),He=new ve((ye=e.roughness)!=null?ye:.5),$e=new _r((Me=e.transmissionSamplerSize)!=null?Me:new Ki(2048,2048)),tt=(Fe=e.transmissionSamplerMap)!=null?Fe:new bi,at=(k=e.transmissionDepthMap)!=null?k:new bi,mt=new Fr(tt),gt=new Fr(at),ct=window.innerWidth,St=window.innerHeight,Rt=ct>=St?new _r(St/ct,1):new _r(1,ct/St),Ar=new ve((H=e.alpha)!=null?H:1),Cn=new vu(Ee,Xe,He,$e,mt,gt,Rt,Ar),Ln=new xt(Cn.calpha,"f"),Rn=new Ye((_=e.mode)!=null?_:0);return{layer:new Bt(e.id,e.uuid,{type:t,thickness:Ee,ior:Xe,roughness:He,transmissionSamplerSize:$e,transmissionSamplerMap:mt,transmissionDepthMap:gt,aspectRatio:Rt,alpha:Ar,calpha:Ln,mode:Rn}),color:Cn,alpha:Ln,mode:Rn}}case qe.DEPTH:{let Ee=new Ye((J=e.gradientType)!=null?J:0),Xe=new mu((ee=e.smooth)!=null?ee:!1),He=new ve((oe=e.near)!=null?oe:50),$e=new ve((se=e.far)!=null?se:200),tt=new ve((ce=e.isVector)!=null?ce:1),at=new ve((ue=e.isWorldSpace)!=null?ue:0),mt=new Tr((K=e.origin)!=null?K:new Xi),gt=new Tr((ae=e.direction)!=null?ae:new Xi),ct=new Ye((ne=e.num)!=null?ne:0),St;e.colors?St=new Os(ct.value+1,e.colors):(St=new Os(ct.value+1,new _u(0,0,0,1)),St.value[1]=new _u(1,1,1,1));let Rt;e.steps?Rt=new Ps(e.steps.length,e.steps):(Rt=new Ps(10,1),Rt.value[0]=0);let Ar=new ve((Ce=e.alpha)!=null?Ce:1),Cn=new Ye((Y=e.mode)!=null?Y:0),Ln=new Cu(Ee,Xe,He,$e,tt,at,mt,gt,St,Rt,ct,Ar),Rn=new xt(Ln.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,gradientType:Ee,smooth:Xe,near:He,far:$e,isVector:tt,isWorldSpace:at,origin:mt,direction:gt,colors:St,steps:Rt,num:ct,alpha:Ar,calpha:Rn,mode:Cn}),color:Ln,alpha:Rn,mode:Cn}}case qe.NOISE:{let Ee=new ve((le=e.scale)!=null?le:1),Xe=new Tr((pe=e.size)!=null?pe:new Xi(100,100,100)),He=new ve((xe=e.move)!=null?xe:1),$e=new _r((_e=e.fA)!=null?_e:new Ki(1.7,9.2)),tt=new _r((de=e.fB)!=null?de:new Ki(8.3,2.8)),at=new _r((we=e.distortion)!=null?we:new Ki(1,1)),mt=new Ji(e.colorA),gt=new Ji(e.colorB),ct=new Ji(e.colorC),St=new Ji(e.colorD),Rt=new ve((Ve=e.alpha)!=null?Ve:1),Ar=new Ye((Ge=e.mode)!=null?Ge:0),Cn=new Ye((Qe=e.noiseType)!=null?Qe:0),Ln=new wu(Ee,Xe,He,$e,tt,at,mt,gt,ct,St,Rt,Cn),Rn=new xt(Ln.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,scale:Ee,size:Xe,move:He,fA:$e,fB:tt,distortion:at,colorA:mt,colorB:gt,colorC:ct,colorD:St,alpha:Rt,calpha:Rn,mode:Ar,noiseType:Cn}),color:Ln,alpha:Rn,mode:Ar}}case qe.NORMAL:{let Ee=new Tr((bt=e.cnormal)!=null?bt:new Xi(1,1,1)),Xe=new ve((Lt=e.alpha)!=null?Lt:1),He=new Ye((At=e.mode)!=null?At:0),$e=new bu(Ee,Xe),tt=new xt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return tt.keywords.alpha=Xe,{layer:new Bt(e.id,e.uuid,{type:t,cnormal:Ee,alpha:Xe,calpha:tt,mode:He}),color:$e,alpha:tt,mode:He}}case qe.GRADIENT:{let Ee=new Ye((sr=e.gradientType)!=null?sr:0),Xe=new mu((Ur=e.smooth)!=null?Ur:!1),He;e.colors?He=new Os(e.colors.length,e.colors):(He=new Os(10,new _u(0,0,0,1)),He.value[1]=new _u(1,1,1,1));let $e;e.steps?$e=new Ps(e.steps.length,e.steps):($e=new Ps(10,1),$e.value[0]=0);let tt=new _r((Ht=e.offset)!=null?Ht:new Ki(0,0)),at=new _r((kr=e.morph)!=null?kr:new Ki(0,0)),mt=new ve((wn=e.angle)!=null?wn:0),gt=new ve((Nn=e.alpha)!=null?Nn:1),ct=new Ye((dt=e.mode)!=null?dt:0),St=new Su(Ee,Xe,He,$e,tt,at,mt,gt),Rt=new xt(St.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,gradientType:Ee,smooth:Xe,colors:He,steps:$e,offset:tt,morph:at,angle:mt,alpha:gt,calpha:Rt,mode:ct}),color:St,alpha:Rt,mode:ct}}case qe.DISPLACE:{let Ee=new Ye((Wt=e.displacementType)!=null?Wt:0);if(Ee.value===0){let Xe=new Tr((ar=e.offset)!=null?ar:new Xi(0,0,0)),He=new ve((Ao=e.scale)!=null?Ao:10),$e=new ve((Oo=e.intensity)!=null?Oo:8),tt=new ve((Po=e.movement)!=null?Po:1),at=new ve((ro=e.alpha)!=null?ro:1),mt=new Ye((no=e.mode)!=null?no:0),gt=new Ye((Do=e.noiseType)!=null?Do:0),ct=new Da(Ee,$e,tt,Xe,He,gt);return{layer:new Bt(e.id,e.uuid,{displacementType:Ee,type:t,offset:Xe,scale:He,intensity:$e,movement:tt,alpha:at,mode:mt,noiseType:gt}),position:ct}}else if(Ee.value===1){let Xe=(Mr=e.texture)!=null?Mr:new bi,He=Xe.matrix;e.mat&&He.copy(e.mat),Xe.needsUpdate=!0;let $e=new ve((io=e.intensity)!=null?io:8),tt=new Fr(Xe),at=new ve((Jt=e.crop)!=null?Jt:0),mt=new ve((ti=e.alpha)!=null?ti:1),gt=new Ye((Bo=e.mode)!=null?Bo:0),ct=new Da(Ee,$e,tt,at);return{layer:new Bt(e.id,e.uuid,{displacementType:Ee,type:t,intensity:$e,texture:tt,crop:at,mat:ct.mat,alpha:mt,mode:gt}),position:ct}}return{}}}return{}}blendColors(){let e=this._layerNodes.findIndex(r=>r.type===Mt.COLOR),t=this._layerNodes.findIndex(r=>r.type===Mt.LIGHTING);if(e!==-1&&e<t){let r=this._layerNodes[e].color;for(let n=e+1;n<t;++n){let s=this._layerNodes[n];s.type===Mt.COLOR&&(r=new Nu(r,s.color,s.alpha,s.mode))}this._material.color=r}else this._material.color=void 0}blendAfterColors(){let e=new xt("outgoingLight","f"),t=this._layerNodes.findIndex(r=>r.type===Mt.LIGHTING);if(this._layerNodes.length>t+1){for(let r=t+1;r<this._layerNodes.length;++r){let n=this._layerNodes[r];n.type===Mt.COLOR&&(e=new Nu(e,n.color,n.alpha,n.mode))}"afterColor"in this._material&&(this._material.afterColor=e)}else"afterColor"in this._material&&(this._material.afterColor=void 0)}blendPositions(){let e=this._layerNodes.filter(t=>t.type===Mt.POSITION);if(e.length>0){let t=e[0].position;for(let r=1;r<e.length;++r)e[r]&&(t=new rn(t,e[r].position,rn.ADD),t=new rn(t,new ve(.5).setReadonly(!0),rn.MUL));this._material.position=t}else this._material.position=void 0}cleanupChangedLayer(e){switch(this._layerNodes=this._layerNodes.filter(t=>t.id!==e.id),e.type){case qe.DISPLACE:{this.blendPositions();break}default:{this.blendColors(),this.blendAfterColors();break}}}};var vn=class extends LD{constructor(e,t,r){super(r);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 du(new xr(xr.PROJECTION)),this.fragment=t!=null?t:new du(new vt(Yt)),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,t){this.build({renderer:t}),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 t=new Ir(this);return e&&(async()=>{for(;e.image===void 0;)await new Promise(r=>requestAnimationFrame(r));t.addLayerAt(1,{type:qe.TEXTURE,texture:e}),this.dispose()})(),t}clampUniformsForPreview(e,t){let r=(n,s,l)=>Math.min(Math.max(n,s),l);if(this.userData.layers){for(let n of this.userData.layers.getLayers())if(n.type==qe.DISPLACE){this.uniformsBackup[`f${n.id}_intensity`]=n.uniforms[`f${n.id}_intensity`].value;let s=r(n.uniforms[`f${n.id}_intensity`].value,e,t);n.uniforms[`f${n.id}_intensity`].value=s}}}restoreClampedUniforms(){if(this.userData.layers)for(let e of this.userData.layers.getLayers())e.type==qe.DISPLACE&&(e.uniforms[`f${e.id}_intensity`].value=this.uniformsBackup[`f${e.id}_intensity`])}customProgramCacheKey(){return this.getHash()}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(e){var r;e=e!=null?e:{};let t=(r=e.builder)!=null?r:new ip;return t.setMaterial(this,e.renderer),t.build(this.vertex,this.fragment),this.vertexShader=t.getCode("vertex"),this.fragmentShader=t.getCode("fragment"),this.defines=t.defines,this.uniforms=t.uniforms,this.extensions=t.extensions,this.updaters=t.updaters,this.fog=t.requires.fog,this.lights=t.requires.lights,this.transparent=t.requires.transparent||this.blending>CD,this}getHash(){let e="{";return e+='"vertex":'+this.vertex.getHash()+",",e+='"fragment":'+this.fragment.getHash(),e+="}",e}copy(e){let t=this.uuid;for(let r in e)this[r]=e[r];return this.uuid=t,e.userData!==void 0&&(this.userData=JSON.parse(JSON.stringify(e.userData))),this}toJSON(e){let t=this.userData.layers;this.userData.layers=void 0;let r=super.toJSON(e);return r.type="ShaderMaterial",r.userData={type:this.userData.type,category:this.userData.category,nodeType:this.type,layers:t.toJSON(e)},r.vertex=this.vertex.toJSON(e).uuid,r.fragment=this.fragment.toJSON(e).uuid,delete r.vertexShader,delete r.fragmentShader,delete r.color,delete r.shininess,delete r.specular,delete r.roughness,delete r.metalness,delete r.uniforms,e&&!e.materials[this.uuid]&&(e.materials[this.uuid]=r),this.userData.layers=t,r}fromJSON(e,t){var r;this.defines=(r=e.defines)!=null?r:{},this.depthFunc=e.depthFunc,this.depthWrite=e.depthWrite,this.side=e.side!==void 0?e.side:_D,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,t,this)}};Object.defineProperties(vn.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 TD,UniformsUtils as ID}from"three";var hp=class extends Pe{constructor(){super("basic");this.nodeType="Basic";this.color=new vt(Yt)}generate(e){let t;if(e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(ID.merge([TD.fog])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
729
- `));let n=["#include <beginnormal_vertex>",`
709
+ `)}}();var St=class{constructor(t){this.id=2,this.layerCount=2,this.uuid=Pr.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 te(1));let r=new te(1),i=new ve(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=r,this._material.shadingBlend=i),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:i}),this.head=e.layer,this.head.next=new qe(1,void 0,{type:"light",alpha:r,mode:i}),this.attachLightNodes(this.getLightLayer())}get material(){return this._material}set material(t){var o;this._material=t;let e,r,i=this.head;for(;i!==void 0;){if(i.type==="light"){e=i.uniforms[`f${i.id}_alpha`],r=i.uniforms[`f${i.id}_mode`];break}i=i.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 i;if(t.id=(i=t.id)!=null?i:++this.id,this.layerCount++,t.type==="light"){let o=this.createLightLayer(t);return this.uuid=Pr.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=Pr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),r}addLayerBeforeAt(t,e){var a;let r=this.head;t.id=(a=t.id)!=null?a:++this.id,this.layerCount++;let i=this._createLayer(t),o=i.layer;o.next=e;let s=0;if(r===e)this.head=o,i.color&&this._layerNodes.splice(0,0,{id:o.id,type:"color",color:i.color,alpha:i.alpha,mode:i.mode}),i.position&&this._layerNodes.splice(0,0,{id:o.id,type:"position",position:i.position});else{for(s=1;(r==null?void 0:r.next)!==e;)r=r==null?void 0:r.next,s++;r.next=o,i.color&&this._layerNodes.splice(s,0,{id:o.id,type:"color",color:i.color,alpha:i.alpha,mode:i.mode}),i.position&&this._layerNodes.splice(s,0,{id:o.id,type:"position",position:i.position})}return this.uuid=Pr.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),i=r.layer;if(r.color&&this._layerNodes.splice(t,0,{id:i.id,type:"color",color:r.color,alpha:r.alpha,mode:r.mode}),r.position&&this._layerNodes.splice(t,0,{id:i.id,type:"position",position:r.position}),t==0)i.next=this.head,this.head=i;else{let s=this.head,a=this.head.next;for(let l=0;l<t-1;l++)s=a,a=a.next;i.next=a,s.next=i}return this.uuid=Pr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),i}removeLayer(t){let e=this.head,r,i=0;if((e==null?void 0:e.id)==t)this.head=e.next;else for(i=1,r=e,e=e==null?void 0:e.next;e!=null;){if(e.id==t){r.next=e.next;break}i++,r=e,e=e.next}return this.cleanupChangedLayer(e),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.uuid=Pr.generateUUID(),this.layerCount--,i}changeLayer(t,e){let r,i=this.head,o;if((i==null?void 0:i.id)==t){let s=this._createLayer(P({id:t,uuid:i.uuid},e));o=s.layer,o.next=i.next,this.head=o,s.color&&(this._layerNodes[0]={id:o.id,type:"color",color:s.color,alpha:s.alpha,mode:s.mode}),s.position&&(this._layerNodes[0]={id:o.id,type:"position",position:s.position}),o.uniforms[`f${t}_mode`].value=i.uniforms[`f${t}_mode`].value,o.uniforms[`f${t}_alpha`].value=i.uniforms[`f${t}_alpha`].value}else{r=i,i=i.next;let s=1;for(;i!=null;){if(i.id==t){let a=this._createLayer(P({id:t,uuid:i.uuid},e));o=a.layer,r.next=o,o.next=i.next,a.color&&(this._layerNodes[s]={id:t,type:"color",color:a.color,alpha:a.alpha,mode:a.mode}),a.position&&(this._layerNodes[s]={id:t,type:"position",position:a.position}),o.uniforms[`f${t}_mode`].value=i.uniforms[`f${t}_mode`].value,o.uniforms[`f${t}_alpha`].value=i.uniforms[`f${t}_alpha`].value;break}r=i,i=i.next,s++}}return this.uuid=Pr.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,i=this.head,o;if(t==0)r=this.head,this.head=r.next;else{for(let a=0;a<t;a++)o=i,i=i.next;o.next=i.next,r=i}if(i=this.head,o=void 0,e==0)r.next=this.head,this.head=r;else{for(let a=0;a<e-1;a++)i=i.next;r.next=i==null?void 0:i.next,i.next=r}let s=this._layerNodes.splice(t,1)[0];this._layerNodes.splice(e,0,s),this.uuid=Pr.generateUUID(),this.blendColors(),this.blendAfterColors()}updateLayerUniform(){this.uuid=Pr.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 te(t.alpha),r=new ve(t.mode);this._material.shadingAlpha=e,this._material.shadingBlend=r,this._layerNodes.push({id:t.id,type:"light",alpha:e,mode:r});let i=new qe(t.id,void 0,{type:"light",alpha:e,mode:r});if(this.head===void 0)this.head=i;else{let o=this.head;for(;o.next!=null;)o=o.next;o.next=i}return this.attachLightNodes(this.getLightLayer()),i}rebuildLayerNodes(t,e,r=!1){if(e.type==="light"){let i=r?e.uniforms[`f${e.id}_alpha`]:new te(e.uniforms[`f${e.id}_alpha`].value),o=r?e.uniforms[`f${e.id}_mode`]:new ve(e.uniforms[`f${e.id}_mode`].value);this._material.shadingAlpha=i,this._material.shadingBlend=o,this._layerNodes.push({id:e.id,type:"light",alpha:i,mode:o}),this.head===void 0?this.head=new qe(e.id,e.uuid,{type:"light",alpha:i,mode:o}):t&&(t.next=new qe(e.id,e.uuid,{type:"light",alpha:i,mode:o})),this.attachLightNodes(e)}else{let i={type:e.type,id:e.id};for(let o in e.uniforms){let s=e.getName(o);if(!s)continue;let a=`f${e.id}_${s}`;if(Array.isArray(e.uniforms[a].value))i[s]=e.uniforms[a].value.map(l=>l.clone&&!r?l.clone():l);else{let l=e.uniforms[a].value;if(s==="transmissionDepthMap"){i[s]=l;continue}l!=null&&(i[s]=l.clone&&!r&&!l.isRenderTargetTexture?l.clone():l)}}this.addLayer(i)}}attachLightNodes(t){var i,o,s,a,l,c,p,u,h,m,f;let e={},r=this.getLightLayer();switch(this._material.userData.category){case"Lambert":e.emissive=new Be((o=(i=t==null?void 0:t.getValue("emissive"))==null?void 0:i.clone())!=null?o:0);break;case"Phong":e.shininess=new te((s=t==null?void 0:t.getValue("shininess"))!=null?s:30),e.specular=new Be((l=(a=t==null?void 0:t.getValue("specular"))==null?void 0:a.clone())!=null?l:1118481);break;case"Toon":e.shininess=new te((c=t==null?void 0:t.getValue("shininess"))!=null?c:30),e.specular=new Be((u=(p=t==null?void 0:t.getValue("specular"))==null?void 0:p.clone())!=null?u:1118481);break;case"Physical":e.roughness=new te((h=t==null?void 0:t.getValue("roughness"))!=null?h:.3),e.metalness=new te((m=t==null?void 0:t.getValue("metalness"))!=null?m:0),e.reflectivity=new te((f=t==null?void 0:t.getValue("reflectivity"))!=null?f:.5);break;default:break}Object.keys(e).forEach(L=>{this._material[L]=e[L],r.uniforms[`f${r.id}_${L}`]=e[L]})}clone(t){return new St(t).copy(this)}toJSON(t){return{id:this.id,uuid:this.uuid,head:this.head.toJSON(t)}}fromJSON(t,e,r){let i=new qe(t.head.id,void 0,{type:t.head.type}).fromJSON(t.head,e),o=t.head.next,s=i;for(;o!=null;)s.next=new qe(o.id,void 0,{type:o.type}).fromJSON(o,e),o=o.next,s=s.next;this._layerNodes=[],this.head=void 0,this.rebuildLayerNodes(this.head,i,!0);let a=i;for(s=this.head;a.next!=null;)this.rebuildLayerNodes(s,a.next,!0),s=s.next,a=a.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,i,o,s,a,l,c,p,u,h,m,f,L,S,y,w,I,_,g,V,b,d,O,x,M,C,T,$,H,ie,pe,ce,be,F,G,D,z,A,R,K,Z,U,j,B,k,ne,q,J,Y,X,Q,se,oe,ue,Ee,xe,We,Le,ct,wt,br,ft,vr,oi,ni,Ue,yt,_t,Tn,Nn,Mn,On,In,Pn,jt,Io,pt,wi,An;let e=t.type;switch(e){case"color":{let ge=new Be((r=t.color)!=null?r:5855577),Ce=new te((i=t.alpha)!=null?i:1),Se=new _e("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");Se.keywords.alpha=Ce;let we=new ve((o=t.mode)!=null?o:0);return ge.alpha=Ce,{layer:new qe(t.id,t.uuid,{type:e,color:ge,alpha:Ce,calpha:Se,mode:we}),color:ge,alpha:Se,mode:we}}case"texture":{let ge=(s=t.texture)!=null?s:new dr,Ce=ge.matrix;t.mat&&Ce.copy(t.mat),ge.needsUpdate=!0;let Se=new te((a=t.crop)!=null?a:0),we=new ve((l=t.projection)!=null?l:0),Ne=new ve((c=t.axis)!=null?c:0),Ae=new bt(t.size?new Xr(t.size[0],t.size[1]):new Xr(100,100)),Ge=new te((p=t.alpha)!=null?p:1),ze=new ve((u=t.mode)!=null?u:0),De=new Nt(ge),ke=new vt((h=t.textureSize)!=null?h:new Zr(ge.image?ge.image.width:0,ge.image?ge.image.height:0)),tt=new cn(De,ke,Se,we,Ne,Ae,Ge,ze),Ut=new _e(tt.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,texture:De,textureSize:ke,crop:Se,projection:we,axis:Ne,size:Ae,mat:tt.mat,alpha:Ge,calpha:Ut,mode:ze}),color:tt,alpha:Ut,mode:ze}}case"matcap":{let ge=(m=t.texture)!=null?m:new dr;ge.needsUpdate=!0;let Ce=new te((f=t.alpha)!=null?f:1),Se=new Nt(ge),we=new ve((L=t.mode)!=null?L:0),Ne=new vn(Se,Ce,we),Ae=new _e(Ne.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,texture:Se,alpha:Ce,calpha:Ae,mode:we}),color:Ne,alpha:Ae,mode:we}}case"fresnel":{let ge=new Be((S=t.color)!=null?S:16777215),Ce=new te((y=t.bias)!=null?y:.1),Se=new te((w=t.scale)!=null?w:1),we=new te((I=t.intensity)!=null?I:2),Ne=new te((_=t.factor)!=null?_:1),Ae=new te((g=t.alpha)!=null?g:1),Ge=new ve((V=t.mode)!=null?V:0),ze=new un(ge,Ce,Se,we,Ne,Ae,Ge),De=new _e(ze.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,color:ge,bias:Ce,scale:Se,intensity:we,factor:Ne,alpha:Ae,calpha:De,mode:Ge}),color:ze,alpha:De,mode:Ge}}case"rainbow":{let ge=new te((b=t.filmThickness)!=null?b:30),Ce=new te((d=t.movement)!=null?d:0),Se=new vt((O=t.wavelengths)!=null?O:new Zr(0,0,0)),we=new te((x=t.noiseStrength)!=null?x:0),Ne=new te((M=t.noiseScale)!=null?M:1),Ae=new vt((C=t.offset)!=null?C:new Zr(0,0,0)),Ge=new te((T=t.alpha)!=null?T:1),ze=new dn(ge,Ce,Se,we,Ne,Ae,Ge),De=new _e(ze.calpha,"f"),ke=new ve(($=t.mode)!=null?$:0);return{layer:new qe(t.id,t.uuid,{type:e,filmThickness:ge,movement:Ce,wavelengths:Se,noiseStrength:we,noiseScale:Ne,offset:Ae,alpha:Ge,calpha:De,mode:ke}),color:ze,alpha:De,mode:ke}}case"transmission":{let ge=new te((H=t.thickness)!=null?H:10),Ce=new te((ie=t.ior)!=null?ie:1.5),Se=new te((pe=t.roughness)!=null?pe:.5),we=new bt((ce=t.transmissionSamplerSize)!=null?ce:new Xr(2048,2048)),Ne=(be=t.transmissionSamplerMap)!=null?be:new dr,Ae=(F=t.transmissionDepthMap)!=null?F:new dr,Ge=new Nt(Ne),ze=new Nt(Ae),De=window.innerWidth,ke=window.innerHeight,tt=De>=ke?new bt(ke/De,1):new bt(1,De/ke),Ut=new te((G=t.alpha)!=null?G:1),Sr=new mn(ge,Ce,Se,we,Ge,ze,tt,Ut),Br=new _e(Sr.calpha,"f"),Er=new ve((D=t.mode)!=null?D:0);return{layer:new qe(t.id,t.uuid,{type:e,thickness:ge,ior:Ce,roughness:Se,transmissionSamplerSize:we,transmissionSamplerMap:Ge,transmissionDepthMap:ze,aspectRatio:tt,alpha:Ut,calpha:Br,mode:Er}),color:Sr,alpha:Br,mode:Er}}case"depth":{let ge=new ve((z=t.gradientType)!=null?z:0),Ce=new ln((A=t.smooth)!=null?A:!1),Se=new te((R=t.near)!=null?R:50),we=new te((K=t.far)!=null?K:200),Ne=new te((Z=t.isVector)!=null?Z:1),Ae=new te((U=t.isWorldSpace)!=null?U:0),Ge=new vt((j=t.origin)!=null?j:new Zr),ze=new vt((B=t.direction)!=null?B:new Zr),De=new ve((k=t.num)!=null?k:0),ke;t.colors?ke=new gi(De.value+1,t.colors):(ke=new gi(De.value+1,new ea(0,0,0,1)),ke.value[1]=new ea(1,1,1,1));let tt;t.steps?tt=new xi(t.steps.length,t.steps):(tt=new xi(10,1),tt.value[0]=0);let Ut=new te((ne=t.alpha)!=null?ne:1),Sr=new ve((q=t.mode)!=null?q:0),Br=new bn(ge,Ce,Se,we,Ne,Ae,Ge,ze,ke,tt,De,Ut),Er=new _e(Br.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,gradientType:ge,smooth:Ce,near:Se,far:we,isVector:Ne,isWorldSpace:Ae,origin:Ge,direction:ze,colors:ke,steps:tt,num:De,alpha:Ut,calpha:Er,mode:Sr}),color:Br,alpha:Er,mode:Sr}}case"noise":{let ge=new te((J=t.scale)!=null?J:1),Ce=new vt((Y=t.size)!=null?Y:new Zr(100,100,100)),Se=new te((X=t.move)!=null?X:1),we=new bt((Q=t.fA)!=null?Q:new Xr(1.7,9.2)),Ne=new bt((se=t.fB)!=null?se:new Xr(8.3,2.8)),Ae=new bt((oe=t.distortion)!=null?oe:new Xr(1,1)),Ge=new Ir(t.colorA),ze=new Ir(t.colorB),De=new Ir(t.colorC),ke=new Ir(t.colorD),tt=new te((ue=t.alpha)!=null?ue:1),Ut=new ve((Ee=t.mode)!=null?Ee:0),Sr=new ve((xe=t.noiseType)!=null?xe:0),Br=new gn(ge,Ce,Se,we,Ne,Ae,Ge,ze,De,ke,tt,Sr),Er=new _e(Br.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,scale:ge,size:Ce,move:Se,fA:we,fB:Ne,distortion:Ae,colorA:Ge,colorB:ze,colorC:De,colorD:ke,alpha:tt,calpha:Er,mode:Ut,noiseType:Sr}),color:Br,alpha:Er,mode:Ut}}case"normal":{let ge=new vt((We=t.cnormal)!=null?We:new Zr(1,1,1)),Ce=new te((Le=t.alpha)!=null?Le:1),Se=new ve((ct=t.mode)!=null?ct:0),we=new fn(ge,Ce),Ne=new _e("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return Ne.keywords.alpha=Ce,{layer:new qe(t.id,t.uuid,{type:e,cnormal:ge,alpha:Ce,calpha:Ne,mode:Se}),color:we,alpha:Ne,mode:Se}}case"gradient":{let ge=new ve((wt=t.gradientType)!=null?wt:0),Ce=new ln((br=t.smooth)!=null?br:!1),Se;t.colors?Se=new gi(t.colors.length,t.colors):(Se=new gi(10,new ea(0,0,0,1)),Se.value[1]=new ea(1,1,1,1));let we;t.steps?we=new xi(t.steps.length,t.steps):(we=new xi(10,1),we.value[0]=0);let Ne=new bt((ft=t.offset)!=null?ft:new Xr(0,0)),Ae=new bt((vr=t.morph)!=null?vr:new Xr(0,0)),Ge=new te((oi=t.angle)!=null?oi:0),ze=new te((ni=t.alpha)!=null?ni:1),De=new ve((Ue=t.mode)!=null?Ue:0),ke=new yn(ge,Ce,Se,we,Ne,Ae,Ge,ze),tt=new _e(ke.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,gradientType:ge,smooth:Ce,colors:Se,steps:we,offset:Ne,morph:Ae,angle:Ge,alpha:ze,calpha:tt,mode:De}),color:ke,alpha:tt,mode:De}}case"displace":{let ge=new ve((yt=t.displacementType)!=null?yt:0);if(ge.value===0){let Ce=new vt((_t=t.offset)!=null?_t:new Zr(0,0,0)),Se=new te((Tn=t.scale)!=null?Tn:10),we=new te((Nn=t.intensity)!=null?Nn:8),Ne=new te((Mn=t.movement)!=null?Mn:1),Ae=new te((On=t.alpha)!=null?On:1),Ge=new ve((In=t.mode)!=null?In:0),ze=new ve((Pn=t.noiseType)!=null?Pn:0),De=new uo(ge,we,Ne,Ce,Se,ze);return{layer:new qe(t.id,t.uuid,{displacementType:ge,type:e,offset:Ce,scale:Se,intensity:we,movement:Ne,alpha:Ae,mode:Ge,noiseType:ze}),position:De}}else if(ge.value===1){let Ce=(jt=t.texture)!=null?jt:new dr,Se=Ce.matrix;t.mat&&Se.copy(t.mat),Ce.needsUpdate=!0;let we=new te((Io=t.intensity)!=null?Io:8),Ne=new Nt(Ce),Ae=new te((pt=t.crop)!=null?pt:0),Ge=new te((wi=t.alpha)!=null?wi:1),ze=new ve((An=t.mode)!=null?An:0),De=new uo(ge,we,Ne,Ae);return{layer:new qe(t.id,t.uuid,{displacementType:ge,type:e,intensity:we,texture:Ne,crop:Ae,mat:De.mat,alpha:Ge,mode:ze}),position:De}}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 i=t+1;i<e;++i){let o=this._layerNodes[i];o.type==="color"&&(r=new xn(r,o.color,o.alpha,o.mode))}this._material.color=r}else this._material.color=void 0}blendAfterColors(){let t=new _e("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 i=this._layerNodes[r];i.type==="color"&&(t=new xn(t,i.color,i.alpha,i.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 At(e,t[r].position,At.ADD),e=new At(e,new te(.5).setReadonly(!0),At.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 Rt=class extends Xv{constructor(e,r,i){super(i);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 an(new dt(dt.PROJECTION)),this.fragment=r!=null?r:new an(new Be(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 St(this);return e&&(async()=>{for(;e.image===void 0;)await new Promise(i=>requestAnimationFrame(i));r.addLayerAt(1,{type:"texture",texture:e}),this.dispose()})(),r}clampUniformsForPreview(e,r){let i=(o,s,a)=>Math.min(Math.max(o,s),a);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 s=i(o.uniforms[`f${o.id}_intensity`].value,e,r);o.uniforms[`f${o.id}_intensity`].value=s}}}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 i;e=e!=null?e:{};let r=(i=e.builder)!=null?i:new Qs;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>Yv,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 i in e)this[i]=e[i];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 i=super.toJSON(e);return i.type="ShaderMaterial",i.userData={type:this.userData.type,category:this.userData.category,nodeType:this.type,layers:r.toJSON(e)},i.vertex=this.vertex.toJSON(e).uuid,i.fragment=this.fragment.toJSON(e).uuid,delete i.vertexShader,delete i.fragmentShader,delete i.color,delete i.shininess,delete i.specular,delete i.roughness,delete i.metalness,delete i.uniforms,e&&!e.materials[this.uuid]&&(e.materials[this.uuid]=i),this.userData.layers=r,i}fromJSON(e,r){var i;this.defines=(i=e.defines)!=null?i:{},this.depthFunc=e.depthFunc,this.depthWrite=e.depthWrite,this.side=e.side!==void 0?e.side:Zv,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(Rt.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(n){n===!0&&this.version++,this.needsCompile=n},get:function(){return this.needsCompile}}});import{UniformsLib as Qv,UniformsUtils as eS}from"three";var ta=class extends he{constructor(){super("basic");this.nodeType="Basic";this.color=new Be(5855577)}generate(e){let r;if(e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(eS.merge([Qv.fog])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
710
+ `));let o=["#include <beginnormal_vertex>",`
730
711
  #if !defined( USE_LAYER_DISPLACE )
731
712
  #include <defaultnormal_vertex>
732
713
  #endif
@@ -742,11 +723,11 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
742
723
  #if !defined( USE_LAYER_DISPLACE )
743
724
  #include <begin_vertex>
744
725
  #endif /* !USE_LAYER_DISPLACE */
745
- `];r&&n.push(r.code,r.result?"displaced_position = "+r.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),t=n.join(`
746
- `)}else{this.color===void 0&&(this.color=new vt(Yt)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let r=this.color.flow(e,"c",{slot:"color"}),n=this.alpha?this.alpha.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=n!==void 0,e.addParsCode(["#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
747
- `));let l=["#include <normal_fragment_begin>",r.code];n&&l.push(n.code,"#ifdef ALPHATEST"," if ( "+n.result+" <= ALPHATEST ) discard;","#endif"),s?l.push(s.code,`vec3 outgoingLight = ${r.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):l.push(`vec3 finalColor = ${r.result};`),n?l.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${n.result} );`):l.push("gl_FragColor = vec4("+r.result+", 1.0 );"),l.push("#include <fog_fragment>","#include <dithering_fragment>"),t=l.join(`
748
- `)}return t}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 pp=class extends vn{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}constructor(e=new hp,t){super(e,e,t);this.type="BasicNodeMaterial",this.fragment=e}};var vr=class extends pp{constructor(e,t,r){super(t,e);this.userData.type="BasicMaterial",this.userData.category="Basic",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Ir){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new vr(void 0,n);return s.fromJSON(t,r),s}static fromMaterial(e){let t=new vr(e.map?{map:e.map}:{}),r=t.fragment;return r.color.value.copy(e.color),r.alpha.value=e.opacity,t}dispose(){super.dispose()}};import{UniformsLib as Lv,UniformsUtils as MD}from"three";var dp=class extends Pe{constructor(){super("phong");this.nodeType="Phong";this.color=new vt(Yt),this.specular=new vt(1118481),this.shininess=new ve(30),this.shadingAlpha=new ve(1),this.shadingBlend=new Ye(0)}build(e){let t;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(MD.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(`
749
- `));let n=["#include <beginnormal_vertex>",`
726
+ `];i&&o.push(i.code,i.result?"displaced_position = "+i.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(`
727
+ `)}else{this.color===void 0&&(this.color=new Be(5855577)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let i=this.color.flow(e,"c",{slot:"color"}),o=this.alpha?this.alpha.flow(e,"f"):void 0,s=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(`
728
+ `));let a=["#include <normal_fragment_begin>",i.code];o&&a.push(o.code,"#ifdef ALPHATEST"," if ( "+o.result+" <= ALPHATEST ) discard;","#endif"),s?a.push(s.code,`vec3 outgoingLight = ${i.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):a.push(`vec3 finalColor = ${i.result};`),o?a.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${o.result} );`):a.push("gl_FragColor = vec4("+i.result+", 1.0 );"),a.push("#include <fog_fragment>","#include <dithering_fragment>"),r=a.join(`
729
+ `)}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 ra=class extends Rt{constructor(e=new ta,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 mt=class extends ra{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 St){let e=t.userData.layers,r=t.fragment;super.copy(t);let i=r.clone();this.fragment=i,this.vertex=i;let o=e.clone(this);this.userData.layers=o}else super.copy(t);return this}static fromJSON(t,e,r){let i=r.getNode(e.vertex),o=new mt(void 0,i);return o.fromJSON(e,r),o}static fromMaterial(t){let e=new mt(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 pd,UniformsUtils as tS}from"three";var ia=class extends he{constructor(){super("phong");this.nodeType="Phong";this.color=new Be(5855577),this.specular=new Be(1118481),this.shininess=new te(30),this.shadingAlpha=new te(1),this.shadingBlend=new ve(0)}build(e){let r;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(tS.merge([pd.fog,pd.lights])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
730
+ `));let o=["#include <beginnormal_vertex>",`
750
731
  #ifndef USE_LAYER_DISPLACE
751
732
  #include <defaultnormal_vertex>
752
733
  #endif
@@ -762,9 +743,9 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
762
743
  #ifndef USE_LAYER_DISPLACE
763
744
  #include <begin_vertex>
764
745
  #endif
765
- `];r&&n.push(r.code,r.result?"displaced_position = "+r.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),t=n.join(`
766
- `)}else{this.color===void 0&&(this.color=new vt(Yt)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let r=this.color.flow(e,"c",{slot:"color"}),n=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),f=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,h=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=h!==void 0,e.addParsCode(["uniform vec3 emissive;","#include <normal_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <dithering_pars_fragment>"].join(`
767
- `));let d=["#include <normal_fragment_begin>",`
746
+ `];i&&o.push(i.code,i.result?"displaced_position = "+i.result+";":""),o.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),o.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),r=o.join(`
747
+ `)}else{this.color===void 0&&(this.color=new Be(5855577)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let i=this.color.flow(e,"c",{slot:"color"}),o=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),a=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=p!==void 0,e.addParsCode(["uniform vec3 emissive;","#include <normal_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <dithering_pars_fragment>"].join(`
748
+ `));let u=["#include <normal_fragment_begin>",`
768
749
  // NOTE: gl_FrontFacing alternative using face normal estimation.
769
750
  vec3 viewdx = dFdx(vViewPosition);
770
751
  vec3 viewdy = dFdy(vViewPosition);
@@ -772,15 +753,15 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
772
753
  if (dot(normal, faceNormal) < 0.0) {
773
754
  normal *= -1.0;
774
755
  }
775
- `," BlinnPhongMaterial material;"];d.push(r.code," vec3 diffuseColor = "+r.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",n.code," vec3 specular = "+n.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),h&&d.push(h.code,"#ifdef ALPHATEST","if ( "+h.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),d.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;"),d.push(`
756
+ `," BlinnPhongMaterial material;"];u.push(i.code," vec3 diffuseColor = "+i.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",o.code," vec3 specular = "+o.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),p&&u.push(p.code,"#ifdef ALPHATEST","if ( "+p.result+" <= ALPHATEST ) discard;","#endif"),u.push("material.diffuseColor = diffuseColor;"),u.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),u.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;"),u.push(`
776
757
  if (outgoingLight != diffuseColor) {
777
758
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
778
- accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * lightAccu;
779
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result}, ${c.result} );
759
+ accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * lightAccu;
760
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
780
761
  }
781
- `),f&&d.push(f.code,`outgoingLight = spe_blend(outgoingLight, ${f.result}, 1.0, SPE_BLENDING_NORMAL);`),h?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
782
- `)}return t}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 mp=class extends vn{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}constructor(e=new dp,t){super(e,e,t);this.type="PhongNodeMaterial",this.fragment=e}};var bn=class extends mp{constructor(e,t,r){super(t,e);this.userData.type="PhongMaterial",this.userData.category="Phong",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Ir){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new bn(void 0,n);return s.fromJSON(t,r),s}static fromMaterial(e){let t=new bn(e.map?{map:e.map}:{}),r=t.fragment;return r.color.value.copy(e.color),r.alpha.value=e.opacity,t}dispose(){super.dispose()}};import{UniformsLib as _v,UniformsUtils as AD}from"three";var gp=class extends Pe{constructor(){super("lambert");this.nodeType="Lambert";this.color=new vt(Yt),this.emissive=new vt(0),this.emissiveIntensity=new ve(1),this.shadingAlpha=new ve(1),this.shadingBlend=new Ye(0)}build(e){let t;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(AD.merge([_v.fog,_v.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
- `));let n=["#include <beginnormal_vertex>",`
762
+ `),c&&u.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),p?u.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result} );`):u.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),u.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=u.join(`
763
+ `)}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 oa=class extends Rt{constructor(e=new ia,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 Vt=class extends oa{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 St){let e=t.userData.layers,r=t.fragment;super.copy(t);let i=r.clone();this.fragment=i,this.vertex=i;let o=e.clone(this);this.userData.layers=o,i.shadingAlpha.value=r.shadingAlpha.value,i.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let i=r.getNode(e.vertex),o=new Vt(void 0,i);return o.fromJSON(e,r),o}static fromMaterial(t){let e=new Vt(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 ud,UniformsUtils as rS}from"three";var na=class extends he{constructor(){super("lambert");this.nodeType="Lambert";this.color=new Be(5855577),this.emissive=new Be(0),this.emissiveIntensity=new te(1),this.shadingAlpha=new te(1),this.shadingBlend=new ve(0)}build(e){let r;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(rS.merge([ud.fog,ud.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(`
764
+ `));let o=["#include <beginnormal_vertex>",`
784
765
  #ifndef USE_LAYER_DISPLACE
785
766
  #include <defaultnormal_vertex>
786
767
  #endif
@@ -796,7 +777,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
796
777
  #ifndef USE_LAYER_DISPLACE
797
778
  #include <begin_vertex>
798
779
  #endif
799
- `];r&&n.push(r.code,r.result?"displaced_position = "+r.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>",`
780
+ `];i&&o.push(i.code,i.result?"displaced_position = "+i.result+";":""),o.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),o.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>",`
800
781
  vec3 diffuse = vec3( 1.0 );
801
782
  GeometricContext geometry;
802
783
  geometry.position = mvPosition.xyz;
@@ -870,23 +851,23 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
870
851
  }
871
852
  #pragma unroll_loop_end
872
853
  #endif
873
- `," #include <shadowmap_vertex>"," #include <fog_vertex>"),t=n.join(`
874
- `)}else{this.color===void 0&&(this.color=new vt(Yt)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let r=this.color.flow(e,"c",{slot:"color"}),n=this.emissive.flow(e,"c",{slot:"emissive"}),s=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),f=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,h=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=h!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include <normal_pars_fragment>","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <fog_pars_fragment>","#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join(`
875
- `));let d=["#include <normal_fragment_begin>",`
854
+ `," #include <shadowmap_vertex>"," #include <fog_vertex>"),r=o.join(`
855
+ `)}else{this.color===void 0&&(this.color=new Be(5855577)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let i=this.color.flow(e,"c",{slot:"color"}),o=this.emissive.flow(e,"c",{slot:"emissive"}),s=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),a=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=p!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include <normal_pars_fragment>","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <fog_pars_fragment>","#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join(`
856
+ `));let u=["#include <normal_fragment_begin>",`
876
857
  // NOTE: gl_FrontFacing alternative using face normal estimation.
877
858
  vec3 viewdx = dFdx(vViewPosition);
878
859
  vec3 viewdy = dFdy(vViewPosition);
879
860
  vec3 faceNormal = normalize(cross(viewdx, viewdy));
880
861
  bool isFrontFacing = (dot(normal, faceNormal) >= 0.0);
881
- `,"#include <clipping_planes_fragment>"];d.push(r.code,"vec3 diffuseColor = "+r.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),h&&d.push(h.code,"#ifdef ALPHATEST","if ( "+h.result+" <= ALPHATEST ) discard;","#endif"),d.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include <lightmap_fragment>","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),n&&d.push(n.code,"reflectedLight.directDiffuse += "+n.result+" * "+s.result+";"),d.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;"),d.push(`
862
+ `,"#include <clipping_planes_fragment>"];u.push(i.code,"vec3 diffuseColor = "+i.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),p&&u.push(p.code,"#ifdef ALPHATEST","if ( "+p.result+" <= ALPHATEST ) discard;","#endif"),u.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include <lightmap_fragment>","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),o&&u.push(o.code,"reflectedLight.directDiffuse += "+o.result+" * "+s.result+";"),u.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;"),u.push(`
882
863
  if (outgoingLight != diffuseColor) {
883
864
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
884
- accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * lightAccu;
885
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result}, ${c.result} );
865
+ accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * lightAccu;
866
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
886
867
  }
887
- `),f&&d.push(f.code,`outgoingLight = spe_blend(outgoingLight, ${f.result}, 1.0, SPE_BLENDING_NORMAL);`),h?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
888
- `)}return t}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 yp=class extends vn{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}constructor(e=new gp,t){super(e,e,t);this.type="LambertNodeMaterial",this.fragment=e}};var Ba=class extends yp{constructor(e,t,r){super(t,e);this.userData.type="LambertMaterial",this.userData.category="Lambert",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Ir){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new Ba(void 0,n);return s.fromJSON(t,r),s}dispose(){super.dispose()}};import{UniformsLib as Tv,UniformsUtils as OD}from"three";var xp=class extends Pe{constructor(){super("toon");this.nodeType="Toon";this.color=new vt(Yt),this.specular=new vt(1118481),this.shininess=new ve(30),this.shadingAlpha=new ve(1),this.shadingBlend=new Ye(0)}build(e){let t;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(OD.merge([Tv.fog,Tv.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
- `));let n=["#include <beginnormal_vertex>",`
868
+ `),c&&u.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),p?u.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result} );`):u.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),u.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=u.join(`
869
+ `)}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 sa=class extends Rt{constructor(e=new na,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 mo=class extends sa{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 St){let e=t.userData.layers,r=t.fragment;super.copy(t);let i=r.clone();this.fragment=i,this.vertex=i;let o=e.clone(this);this.userData.layers=o,i.shadingAlpha.value=r.shadingAlpha.value,i.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let i=r.getNode(e.vertex),o=new mo(void 0,i);return o.fromJSON(e,r),o}dispose(){super.dispose()}};import{UniformsLib as hd,UniformsUtils as iS}from"three";var aa=class extends he{constructor(){super("toon");this.nodeType="Toon";this.color=new Be(5855577),this.specular=new Be(1118481),this.shininess=new te(30),this.shadingAlpha=new te(1),this.shadingBlend=new ve(0)}build(e){let r;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(iS.merge([hd.fog,hd.lights])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
870
+ `));let o=["#include <beginnormal_vertex>",`
890
871
  #ifndef USE_LAYER_DISPLACE
891
872
  #include <defaultnormal_vertex>
892
873
  #endif
@@ -902,8 +883,8 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
902
883
  #ifndef USE_LAYER_DISPLACE
903
884
  #include <begin_vertex>
904
885
  #endif
905
- `];r&&n.push(r.code,r.result?"displaced_position = "+r.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push(" #include <project_vertex>"," #include <fog_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),t=n.join(`
906
- `)}else{this.color===void 0&&(this.color=new vt(Yt)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let r=this.color.flow(e,"c",{slot:"color"}),n=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),f=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,h=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=h!==void 0,e.addParsCode(["#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
886
+ `];i&&o.push(i.code,i.result?"displaced_position = "+i.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>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),r=o.join(`
887
+ `)}else{this.color===void 0&&(this.color=new Be(5855577)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let i=this.color.flow(e,"c",{slot:"color"}),o=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),a=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=p!==void 0,e.addParsCode(["#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
907
888
  varying vec3 vViewPosition;
908
889
  struct ToonMaterial {
909
890
  vec3 diffuseColor;
@@ -924,7 +905,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
924
905
  #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
925
906
  #define Material_LightProbeLOD( material ) (0)
926
907
  `,"#include <shadowmap_pars_fragment>","#include <bumpmap_pars_fragment>","#include <normalmap_pars_fragment>"].join(`
927
- `));let d=["#include <normal_fragment_begin>",`
908
+ `));let u=["#include <normal_fragment_begin>",`
928
909
  // NOTE: gl_FrontFacing alternative using face normal estimation.
929
910
  vec3 viewdx = dFdx(vViewPosition);
930
911
  vec3 viewdy = dFdy(vViewPosition);
@@ -932,15 +913,15 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
932
913
  if (dot(normal, faceNormal) < 0.0) {
933
914
  normal *= -1.0;
934
915
  }
935
- `," ToonMaterial material;"];d.push(r.code," vec3 diffuseColor = "+r.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",n.code," vec3 specular = "+n.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),h&&d.push(h.code,"#ifdef ALPHATEST","if ( "+h.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),d.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;"),d.push(`
916
+ `," ToonMaterial material;"];u.push(i.code," vec3 diffuseColor = "+i.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",o.code," vec3 specular = "+o.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),p&&u.push(p.code,"#ifdef ALPHATEST","if ( "+p.result+" <= ALPHATEST ) discard;","#endif"),u.push("material.diffuseColor = diffuseColor;"),u.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),u.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;"),u.push(`
936
917
  if (outgoingLight != diffuseColor) {
937
918
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
938
- accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * lightAccu;
939
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result}, ${c.result} );
919
+ accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * lightAccu;
920
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
940
921
  }
941
- `),f&&d.push(f.code,`outgoingLight = spe_blend(outgoingLight, ${f.result}, 1.0, SPE_BLENDING_NORMAL);`),h?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
942
- `)}return t}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 vp=class extends vn{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}constructor(e=new xp,t){super(e,e,t);this.type="ToonNodeMaterial",this.fragment=e}};var Ga=class extends vp{constructor(e,t,r){super(t,e);this.userData.type="ToonMaterial",this.userData.category="Toon",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Ir){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new Ga(void 0,n);return s.fromJSON(t,r),s}dispose(){super.dispose()}};import{UniformsLib as bp,UniformsUtils as PD}from"three";var Sp=class extends Pe{constructor(){super("standard");this.nodeType="Standard";this.color=new vt(Yt),this.roughness=new ve(.3),this.metalness=new ve(0),this.reflectivity=new ve(.5),this.shadingAlpha=new ve(1),this.shadingBlend=new Ye(0)}build(e){let t;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(PD.merge([bp.fog,bp.lights])),bp.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
- `));let n=["#include <beginnormal_vertex>",`
922
+ `),c&&u.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),p?u.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result} );`):u.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),u.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=u.join(`
923
+ `)}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 la=class extends Rt{constructor(e=new aa,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 fo=class extends la{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 St){let e=t.userData.layers,r=t.fragment;super.copy(t);let i=r.clone();this.fragment=i,this.vertex=i;let o=e.clone(this);this.userData.layers=o,i.shadingAlpha.value=r.shadingAlpha.value,i.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let i=r.getNode(e.vertex),o=new fo(void 0,i);return o.fromJSON(e,r),o}dispose(){super.dispose()}};import{UniformsLib as jl,UniformsUtils as oS}from"three";var ca=class extends he{constructor(){super("standard");this.nodeType="Standard";this.color=new Be(5855577),this.roughness=new te(.3),this.metalness=new te(0),this.reflectivity=new te(.5),this.shadingAlpha=new te(1),this.shadingBlend=new ve(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 i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(oS.merge([jl.fog,jl.lights])),jl.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(`
924
+ `));let o=["#include <beginnormal_vertex>",`
944
925
  #if !defined( USE_LAYER_DISPLACE )
945
926
  #include <defaultnormal_vertex>
946
927
  #endif
@@ -956,9 +937,9 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
956
937
  #if !defined( USE_LAYER_DISPLACE )
957
938
  #include <begin_vertex>
958
939
  #endif /* !USE_LAYER_DISPLACE */
959
- `];r&&n.push(r.code,r.result?"displaced_position = "+r.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),t=n.join(`
960
- `)}else{let r={gamma:!0};this.color===void 0&&(this.color=new vt(Yt)),this.color.analyze(e,{slot:"color",context:r}),this.roughness.analyze(e),this.metalness.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let n=this.color.flow(e,"c",{slot:"color",context:r}),s=this.roughness.flow(e,"f"),l=this.metalness.flow(e,"f"),c=this.shadingAlpha.flow(e,"f"),f=this.shadingBlend.flow(e,"i"),h=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,x=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode(["varying vec3 vViewPosition;","#include <normal_pars_fragment>","#include <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join(`
961
- `));let g=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
940
+ `];i&&o.push(i.code,i.result?"displaced_position = "+i.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>","#include <shadowmap_vertex>"),r=o.join(`
941
+ `)}else{let i={gamma:!0};this.color===void 0&&(this.color=new Be(5855577)),this.color.analyze(e,{slot:"color",context:i}),this.roughness.analyze(e),this.metalness.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let o=this.color.flow(e,"c",{slot:"color",context:i}),s=this.roughness.flow(e,"f"),a=this.metalness.flow(e,"f"),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),p=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,u=this.alpha?this.alpha.flow(e,"f"):void 0,h=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=u!==void 0,e.addParsCode(["varying vec3 vViewPosition;","#include <normal_pars_fragment>","#include <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join(`
942
+ `));let m=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
962
943
  // NOTE: gl_FrontFacing alternative using face normal estimation.
963
944
  vec3 viewdx = dFdx(vViewPosition);
964
945
  vec3 viewdy = dFdy(vViewPosition);
@@ -966,12 +947,12 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
966
947
  if (dot(normal, faceNormal) < 0.0) {
967
948
  normal *= -1.0;
968
949
  }
969
- `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];g.push(n.code," vec3 diffuseColor = "+n.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",s.code," float roughnessFactor = "+s.result+";",l.code," float metalnessFactor = "+l.result+";"),d&&g.push(d.code,"#ifdef ALPHATEST"," if ( "+d.result+" <= ALPHATEST ) discard;","#endif"),g.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),g.push("material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),x?g.push(x.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+x.result+" ) ), diffuseColor, metalnessFactor );"):g.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),g.push("#include <lights_fragment_begin>"),g.push("#include <lights_fragment_end>"),g.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;"),g.push(`
950
+ `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];m.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",s.code," float roughnessFactor = "+s.result+";",a.code," float metalnessFactor = "+a.result+";"),u&&m.push(u.code,"#ifdef ALPHATEST"," if ( "+u.result+" <= ALPHATEST ) discard;","#endif"),m.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),m.push("material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),h?m.push(h.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+h.result+" ) ), diffuseColor, metalnessFactor );"):m.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),m.push("#include <lights_fragment_begin>"),m.push("#include <lights_fragment_end>"),m.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;"),m.push(`
970
951
  if (outgoingLight != diffuseColor) {
971
952
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
972
- accumAlpha += ( 1.0 - accumAlpha ) * ${c.result} * lightAccu;
973
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${c.result}, ${f.result} );
953
+ accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * lightAccu;
954
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result}, ${c.result} );
974
955
  }
975
- `),h&&g.push(h.code,`outgoingLight = spe_blend(outgoingLight, ${h.result}, 1.0, SPE_BLENDING_NORMAL);`),d?g.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):g.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),g.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=g.join(`
976
- `)}return t}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 wp=class extends vn{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}constructor(e=new Sp,t){super(e,e,t);this.type="StandardNodeMaterial",this.fragment=e}};var ja=class extends wp{constructor(e,t,r){super(t,e);this.userData.type="PhysicalMaterial",this.userData.category="Physical",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Ir){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new ja(void 0,n);return s.fromJSON(t,r),s}dispose(){super.dispose()}};import{Color as Cp}from"three";import{Matrix3 as Iv,Texture as Np,Vector2 as Ea,Vector3 as Zi,Vector4 as Mv}from"three";function Av(i,e){switch(i.data.type){case"light":return Gn(i);case"fresnel":return BD(i,e);case"gradient":return GD(i);case"depth":return jD(i);case"normal":return ED(i);case"noise":return RD(i,e);case"texture":return zD(i,e);case"rainbow":return FD(i);case"transmission":return VD(i,e);case"matcap":return UD(i,e);case"displace":return kD(i);case"color":default:return DD(i,e)}}function Ov(i){return{type:i.data.type}}function Gn(i){let{alpha:e,mode:t}=i.data;return fe(U({},Ov(i)),{alpha:e,mode:t})}function DD(i,e){return fe(U({},Gn(i)),{color:kt(i.data.color,e)})}function BD(i,e){let{bias:t,scale:r,intensity:n,factor:s,color:l}=i.data;return fe(U({},Gn(i)),{color:kt(l,e),bias:t,scale:r,intensity:n,factor:s})}function GD(i){let{gradientType:e,smooth:t,colors:r,steps:n,angle:s,offset:l,morph:c}=i.data;return fe(U({},Gn(i)),{gradientType:e,smooth:t,colors:r.map(f=>new Mv(f[0],f[1],f[2],f[3])),num:r.length,steps:n,offset:new Ea(...l),morph:new Ea(...c),angle:s})}function jD(i){let{gradientType:e,near:t,far:r,isVector:n,isWorldSpace:s,origin:l,direction:c,colors:f,steps:h,smooth:d,num:x}=i.data;return fe(U({},Gn(i)),{gradientType:e,near:t,far:r,isVector:n,isWorldSpace:s,origin:new Zi(...l),direction:c?new Zi(...c):new Zi(1,0,0),num:x,colors:f.map(g=>new Mv(g[0],g[1],g[2],g[3])),steps:h,smooth:d})}function ED(i){let{cnormal:e}=i.data;return fe(U({},Gn(i)),{cnormal:new Zi(e[0],e[1],e[2])})}function RD(i,e){let{data:t}=i;return fe(U({},Gn(i)),{scale:t.scale,move:t.move,fA:new Ea(...t.fA),fB:new Ea(...t.fB),size:new Zi(...t.size),distortion:new Ea(...t.distortion),colorA:kt(t.colorA,e),colorB:kt(t.colorB,e),colorC:kt(t.colorC,e),colorD:kt(t.colorD,e),noiseType:t.noiseType})}function zD(i,e){let{projection:t,axis:r,crop:n,size:s}=i.data,{image:l,wrapping:c,repeat:f,offset:h}=i.data.texture,d=new Np,x;if(typeof l=="string")x=e==null?void 0:e.getImage(l);else{let g=new Image;g.src=l.data,g.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(l.data))},x=g}return d.image=x,d.repeat.set(f[0],f[1]),d.offset.set(h[0],h[1]),d.wrapS=d.wrapT=c,fe(U({},Gn(i)),{texture:d,mat:new Iv().setUvTransform(h[0],h[1],f[0],f[1],0,0,0),crop:n,projection:t,axis:["x","y","z"].indexOf(r),size:s})}function FD(i){let{data:e}=i;return fe(U({},Gn(i)),{filmThickness:e.filmThickness,movement:e.movement,wavelengths:new Zi(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new Zi(...e.offset)})}function VD(i,e){let{data:t}=i;return fe(U({},Gn(i)),{thickness:t.thickness,ior:t.ior,roughness:t.roughness,transmissionSamplerMap:e.transmissionSamplerMap,transmissionDepthMap:e.transmissionDepthMap})}function UD(i,e){let t=new Np,{image:r}=i.data.texture,n;if(typeof r=="string")n=e==null?void 0:e.getImage(r);else{let l=new Image;l.src=r.data,l.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(r.data))},n=l}t.image=n;let s=16777215;return fe(U({},Gn(i)),{color:s,texture:t})}function kD(i){let{data:e}=i,t=fe(U({},Ov(i)),{intensity:e.intensity});if(e.displacementType==="noise")return fe(U({},t),{offset:new Zi(...e.offset),scale:e.scale,movement:e.movement,noiseType:e.noiseType});{let r=new Np,n=new Iv().setUvTransform(0,0,1,1,0,0,0);return fe(U({},t),{texture:r,mat:n,crop:e.crop})}}function Pv(i,e,t){if(t.type==="displace"&&(i==="intensity"||i==="visible")){let r=e.uniforms[`f${e.id}_intensity`];return r?(r.value=t.intensity*(t.visible?1:0),r):void 0}if(t.type!=="displace"&&(i==="alpha"||i==="visible")){let r=e.uniforms[`f${e.id}_alpha`];return r?(r.value=t.alpha*(t.visible?1:0),r):void 0}}import{Color as Dv,Vector4 as HD}from"three";var js;(function(e){function i(t){return new Dv(t.x,t.y,t.z).getHex()}e.getHex=i})(js||(js={}));var Bv;(function(e){function i(t){return new HD(t.r,t.g,t.b,t.a)}e.getThreeVector4=i})(Bv||(Bv={}));var Gv;(function(t){function i(r,n){r.setRGB(n.r,n.g,n.b)}t.setThreeColor=i;function e(r){return new Dv(r.r,r.g,r.b).getHex()}t.getHex=e})(Gv||(Gv={}));function Ra(i,e){return typeof i=="string"?e.getMaterialOrDeletedPlaceholder(i):Lp(i,e)}function jv(i,e){return i.map(t=>Ra(t,e))}function Lp(i,e){var l,c;let t=(l=i.layers)!=null?l:Ss.defaultTwoLayerData("phong").layers,r=WD(t),n;switch(r.category){case"basic":n=new vr;break;case"lambert":{n=new Ba;break}case"toon":{n=new Ga;break}case"physical":n=new ja;break;case"phong":default:{n=new bn;break}}n.name=(c=i.name)!=null?c:"Untitled Material";let s=n.userData.layers;qD(s);for(let f=t.length-1;f>=0;f--)$D(s,t[f],e);switch(r.category){case"basic":break;case"lambert":{let d=n,g=kt(r.emissive,e);g instanceof Cp?d.emissive.value=g:d.emissive.value.setHex(js.getHex(g));break}case"toon":{let d=n,x=r;d.shininess.value=x.shininess;let g=kt(x.specular,e);g instanceof Cp?d.specular.value=g:d.specular.value.setHex(js.getHex(g));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,x=r;d.shininess.value=x.shininess;let g=kt(x.specular,e);g instanceof Cp?d.specular.value=g:d.specular.value.setHex(js.getHex(g));break}}return s.blendColors(),s.blendAfterColors(),s.blendPositions(),n}function WD(i){for(let e of i)if(e.data.type==="light")return e.data;return{type:"light",category:"basic",visible:!0,alpha:1,mode:Zt.Normal}}function qD(i){for(let e of i.getLayers())i.removeLayer(e.id)}function $D(i,e,t){let r=Av(e,t);r.type==="transmission"&&(r.transmissionSamplerMap=t==null?void 0:t.transmissionSamplerMap,r.transmissionDepthMap=t==null?void 0:t.transmissionDepthMap);let n=i.addLayer(r);n.uuid=e.id;for(let s in e.data)Pv(s,n,e.data)}import{Vector2 as Ev}from"three";var Tu=new Ev,To=class{constructor(e,t,r){this.message=[];this.endLine=!0;this.yLinePos=e,this.lineHeight=t,this.maxCharSize=r,this.nextChar3DPos=new Ev(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=Lr.Left}addChar3D(e,t,r=this.message.length){this.message.splice(r,0,e),e.fontSize>this.maxCharSize?(this.maxCharSize=e.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(t)):(e.updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=e.charSize)}deleteChar3D(e=this.message.length-1){let t=this.message[e];if(t)return this.message.splice(e,1),this.nextChar3DPos.x-=t.charSize,t}isEndLine(e){this.endLine=e}fullUpdate(e,t=0){this.nextChar3DPos.x=0;for(let r=t,n=this.message.length;r<n;r+=1)this.message[r].updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(e){let t,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){t=this.message[r];break}r-=1}return!!(r>=0&&t&&t.localPosition.x+t.charSize>e)}containSpaceOverFlow(e=this.message.length-1){for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}containSpace(e=this.message.length-1){if(this.endLine)return!0;for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}popWord(e=this.message.length-1){let t=[],r=!0,n;for(n=e;n>=0;n-=1)if(this.message[n].char===" "){r=!1,t.length===0&&(n-=1,t.splice(0,0,this.message[n]));break}else t.splice(0,0,this.message[n]);return r?t=[]:this.message.splice(n+1,t.length),t}getWord(e=0,t=1){let r=[],n=e;for(n=e;;n+=t){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}t>0?(r.push(this.message[n]),this.message.splice(n,1),n-=t):(r.splice(0,0,this.message[n]),this.message.splice(n,1))}return r}getWordAtIndex(e){let t=[];for(let r=e;r<this.message.length&&this.message[r].char!==" ";r++)t.push(this.message[r]);for(let r=e-1;r>=0&&this.message[r].char!==" ";r--)t.splice(0,0,this.message[r]);return t}wordSize(e=0,t=-1){let r=0,n=e;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+=t}return(n<0||n>=this.message.length)&&!this.endLine?this.message[e]?this.message[e].charSize:999999999:r===0?999999999:r}spaceLeft(e){return e-this.nextChar3DPos.x}popChar(e=this.message.length-1){return this.nextChar3DPos.x-=this.message[e].charSize,this.message.splice(e,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(e){this.yLinePos=e,this.updateNextCharPosY()}updatelineHeight(e){this.lineHeight=e,this.updateNextCharPosY()}updateFontSize(e,t=0,r=this.message.length-1){for(let n=t;n<=r;n+=1)this.message[n].updateFontSize(e);this.maxCharSize=e,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let e=0;for(let t=0;t<this.message.length;t++)this.message[t].char===" "&&(e+=1);return e}alignText(e,t,r,n,s){switch(r){case Lr.Left:this.leftAlign(e,s);break;case Lr.Center:this.centerAlign(this.spaceLeft(t),e,s);break;case Lr.Right:this.rightAlign(this.spaceLeft(t),e,s);break;case Lr.Justify:this.justifyAlign(this.spaceLeft(t),e,s);break}}offsetCharacters(e,t,r){Tu.set(t,r);let n=this.message.length;for(let s=0;s<n;s++)this.message[s].updatePosition(this.message[s].localPosition.add(Tu),e)}leftAlign(e,t){this.align=Lr.Left,this.offsetCharacters(e,0,t)}centerAlign(e,t,r){this.align=Lr.Center,this.offsetCharacters(t,e/2,r)}rightAlign(e,t,r){this.align=Lr.Right,this.offsetCharacters(t,e,r)}justifyAlign(e,t,r){if(this.align=Lr.Justify,this.endLine){this.offsetCharacters(t,0,r);return}let n=this.countSpaces();if(n===0){this.offsetCharacters(t,0,r);return}let s=e/n,l=0;for(let c=0;c<this.message.length;c++)this.message[c].char===" "&&(l+=s),Tu.set(l,r),this.message[c].updatePosition(this.message[c].localPosition.add(Tu),t)}clone(){let e=new To(this.yLinePos,this.lineHeight,this.maxCharSize);e.nextChar3DPos=this.nextChar3DPos.clone(),e.align=this.align,e.endLine=this.endLine;for(let t=0;t<this.message.length;t++)e.message.push(this.message[t].clone());return e}};import{DoubleSide as JD,EventDispatcher as KD,Matrix3 as XD,Vector3 as _p}from"three";var ZD=new _p(0,0,1),Rv=new _p,zv=new _p,Fv=new XD,Io=class extends hr{constructor(e=ur.create({}),t=new vr({side:JD})){super(e,t);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new KD;this._onShapeUpdate=()=>{if(this.geometry instanceof No){if(this.geometry.updateFromShape()){let e=this.geometry.drawCount,t=this.geometry.userData;this.updateGeometry(Object.assign(this.geometry.userData,{parameters:Object.assign(t.parameters,{surfaceMaxCount:e+1e3})}))}}else this.updateGeometry({});this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};var r;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="VectorObject",t}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let t=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:t})}}setShape(e){var t,r;this.shape&&((t=this.shape.eventDispatcher)==null||t.removeEventListener("update",this._onShapeUpdate)),this.shape=e,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),Fv.getNormalMatrix(this.matrixWorld),Rv.copy(ZD).applyMatrix3(Fv).normalize(),zv.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(Rv,zv)}clone(e){let t=this.shape.clone(),r=this.material.clone(),n=this.geometry.userData,s=ur.create(Object.assign({},n,{shape:t})),l=new Io(s,r).copy(this,e);return l.shape=t,t.update(),l}raycast(e,t){hr.prototype.raycast.call(this,e,t)}};import{Camera as h3,OrthographicCamera as p3,PerspectiveCamera as d3,Vector3 as nn,Object3D as Hv,Quaternion as m3}from"three";import{BoxBufferGeometry as YD}from"three";var Yn=i=>{var e;return e=class extends i{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new YD(30,30,30),e};import{Camera as r3,LineSegments as n3,BufferGeometry as i3,LineBasicMaterial as o3,Color as Ip,Vector3 as s3,Float32BufferAttribute as Uv}from"three";import{Ray as QD,Sphere as e3,Matrix4 as t3,Vector3 as Ni}from"three";var Iu=new QD,Tp=new e3,Vv=new t3,Qn=(i,e,t,r,n=!1)=>{let s=e,l=i.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),Tp.copy(s.boundingSphere),Tp.applyMatrix4(l),t.ray.intersectsSphere(Tp)===!1||(Vv.copy(l).invert(),Iu.copy(t.ray).applyMatrix4(Vv),s.boundingBox!==null&&Iu.intersectsBox(s.boundingBox)===!1))return;let c,f,h,d,x=s.index,g=s.attributes.position,w=s.drawRange,S,D;if(n===!1){let G=Math.max(0,w.start),B=Math.min(x.count,w.start+w.count);for(S=G,D=B;S<D;S+=3)if(f=x.getX(S),h=x.getX(S+1),d=x.getX(S+2),c=C(i,t,Iu,g,f,h,d),c){c.faceIndex=Math.floor(S/3),r.push(c);return}}else{let B=s.attributes.position,P=new Ni,W=new Ni,M=new Ni,q=new Ni,E=2,R=1/((i.scale.x+i.scale.y+i.scale.z)/3),T=R*R,z=Math.max(0,w.start),A=Math.min(B.count,w.start+w.count);for(let $=z,he=A-1;$<he;$+=E){if(P.fromBufferAttribute(B,$),W.fromBufferAttribute(B,$+1),Iu.distanceSqToSegment(P,W,q,M)>T)continue;q.applyMatrix4(i.matrixWorld);let Ne=t.ray.origin.distanceTo(q);Ne<t.near||Ne>t.far||r.push({distance:Ne,point:M.clone().applyMatrix4(i.matrixWorld),object:i})}}function C(G,B,P,W,M,q,E){let b=new Ni,R=new Ni,T=new Ni,z=new Ni,A=new Ni;if(b.fromBufferAttribute(W,M),R.fromBufferAttribute(W,q),T.fromBufferAttribute(W,E),P.intersectTriangle(b,R,T,!1,z)===null)return null;A.copy(z),A.applyMatrix4(G.matrixWorld);let he=B.ray.origin.distanceTo(A);return he<B.near||he>B.far?null:{faceIndex:1,distance:he,point:A.clone(),object:G}}};var Mu=new s3,Sn=new r3,kv=class extends n3{constructor(e){let t=new i3,r=new o3({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],l={},c=new Ip(wh),f=new Ip(wh),h=new Ip(a0);d("n1","n2",c),d("n2","n4",c),d("n4","n3",c),d("n3","n1",c),d("f1","f2",c),d("f2","f4",c),d("f4","f3",c),d("f3","f1",c),d("n1","f1",c),d("n2","f2",c),d("n3","f3",c),d("n4","f4",c),d("p","n1",f),d("p","n2",f),d("p","n3",f),d("p","n4",f),d("u1","u2",h),d("u2","u3",h),d("u3","u1",h);function d(g,w,S){x(g,S),x(w,S)}function x(g,w){n.push(0,0,0),s.push(w.r,w.g,w.b),l[g]===void 0&&(l[g]=[]),l[g].push(n.length/3-1)}t.setAttribute("position",new Uv(n,3)),t.setAttribute("color",new Uv(s,3));super(t,r);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=l,this.update()}update(){let e=this.geometry,t=this.pointMap,r=!0;Sn.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let n=1,s=1,l=r?.8:1e-4;jn("n1",t,e,Sn,-n,-s,l),jn("n2",t,e,Sn,n,-s,l),jn("n3",t,e,Sn,-n,s,l),jn("n4",t,e,Sn,n,s,l);let c=l;jn("f1",t,e,Sn,-n,-s,c),jn("f2",t,e,Sn,n,-s,c),jn("f3",t,e,Sn,-n,s,c),jn("f4",t,e,Sn,n,s,c);let f=c,h=.5;jn("u1",t,e,Sn,n*.7*h,s*1.1,f),jn("u2",t,e,Sn,-n*.7*h,s*1.1,f),jn("u3",t,e,Sn,0,s*(1.1+.9*h),f),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function jn(i,e,t,r,n,s,l){Mu.set(n,s,l).unproject(r);let c=e[i];if(c!==void 0){let f=t.getAttribute("position");for(let h=0,d=c.length;h<d;h++)f.setXYZ(c[h],Mu.x,Mu.y,Mu.z)}}var Mp=class extends Yn(kv){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,t){Qn(this.object,this.geometry,e,t,!0)}};import{DirectionalLightHelper as a3}from"three";var za=class extends Yn(a3){constructor(e,t=15,r=10066329){super(e,t,r);this.object=e;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Qn(this.object,za.geometryHelper,e,t)}};import{AxesHelper as l3}from"three";var Fa=class extends Yn(l3){constructor(e,t=15){super(t);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,t){Qn(this.object,Fa.geometryHelper,e,t)}update(){}};import{PointLightHelper as c3}from"three";var Va=class extends Yn(c3){constructor(e,t=15,r=6710886){super(e,t,r);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Qn(this.object,Va.geometryHelper,e,t)}};import{SpotLightHelper as u3,Vector3 as f3}from"three";var Ou=class extends Yn(u3){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Qn(this.object,Ou.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=Ou._vector,t=this.object.distance?this.object.distance:1e3,r=t*Math.tan(this.object.angle);this.cone.scale.set(r,r,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,l=this.cone.material.length;s<l;s++)this.cone.material[s].color.set(n);else this.cone.material.color.set(n)}}},Au=Ou;Au._vector=new f3;var ei=(i,e)=>class extends i{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(r){this.visible=r,this.setHelperVisibility(r),this.setHelperChildrenVisibility(r)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(r){this.objectHelper.visible=r}setHelperChildrenVisibility(r){for(let n of this.children)yn(n)&&n.traverseEntity(s=>{vi(s)&&s.visible&&(s.objectHelper.visible=r)})}raycast(r,n){this.objectHelper.raycast(r,n)}copy(r,n=!0){return super.copy(r,n),r.enableHelper!==void 0&&(this.enableHelper=r.enableHelper),r.objectHelper!==void 0&&(this.objectHelper.visible=r.objectHelper.visible),this}toJSON(r){let n=super.toJSON(r),s=n.object;return s.enableHelper=this.enableHelper,n}fromJSON(r){return super.fromJSON(r),r.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(r,n){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let s=this;r.color!==void 0&&(s.color=kt(r.color,n)),r.intensity!==void 0&&(s.intensity=r.intensity),r.depth!==void 0&&(s.shadow.camera.far=r.depth,s.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows),r.helper!==void 0&&(this.enableHelper=r.helper,s.gizmos.shadowmap.visible=r.helper)}return this}};var Es=new nn,Ap=new nn,Yi=class extends ei(xn(h3),Mp){constructor(e=window.innerWidth,t=window.innerHeight,r=45,n,s=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=xo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=t,this.orthoCamera=new p3(e*-.5,e*.5,t*.5,t*-.5,n!=null?n:-5e4,s),this.perspCamera=new d3(r,e/t,n!=null?n:50,s),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,t){let r=new Yi().fromState(t);return r.enableHelper=!0,r.objectHelper.update(),r.uuid=e,r}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}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(Es),this.targetOffset=Es.distanceTo(e)}getTarget(e=new nn){return this.getWorldDirection(Ap),this.getWorldPosition(Es),Ap.multiplyScalar(this.targetOffset),e.copy(Es).add(Ap),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Es),Es.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new m3),t=new nn(0,0,1).applyQuaternion(e),r=new nn().copy(Hv.DefaultUp);this.isUpVectorFlipped&&r.negate(),r.applyQuaternion(e);let n=new nn().copy(Hv.DefaultUp).projectOnPlane(t),s=new nn().crossVectors(n,r).dot(t)>=0?1:-1;this.angleOffsetFromUp=n.angleTo(r)*s}getViewFrontToObject(e){let t=e.getWorldPosition(new nn),n=e.getWorldDirection(new nn).multiplyScalar(this.targetOffset);return{position:t.clone().add(n),target:t}}getViewToObject(e){let t=e.getWorldPosition(new nn),n=this.getWorldDirection(new nn).multiplyScalar(this.targetOffset);return{position:t.clone().sub(n),target:t}}setViewplaneSize(e,t){this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5,this.aspect=e/t,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,t,r,n,s,l){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,r,n,s,l):this.orthoCamera.setViewOffset(e,t,r,n,s,l)}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,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),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 t={near:this.orthoCamera.near,far:this.orthoCamera.far},r={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(e),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=t.near,this.orthoCamera.far=t.far,this.perspCamera.near=r.near,this.perspCamera.far=r.far,this.updateProjectionMatrix(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="CombinedCamera",r.cameraType=this.cameraType,r.targetOffset=this.targetOffset,r.isUpVectorFlipped=this.isUpVectorFlipped,r.angleOffsetFromUp=this.angleOffsetFromUp,r.left=this.left,r.right=this.right,r.top=this.top,r.bottom=this.bottom,this.view!==null&&(r.view=Object.assign({},this.view)),r.zoomOrtho=this.orthoCamera.zoom,r.nearOrtho=this.orthoCamera.near,r.far=this.far,r.aspect=this.aspect,r.fov=this.fov,r.focus=this.focus,r.filmGauge=this.filmGauge,r.filmOffset=this.filmOffset,r.zoomPersp=this.perspCamera.zoom,r.nearPersp=this.perspCamera.near,t}fromJSON(e){var t;if(super.fromJSON(e),this.cameraType=e.cameraType,e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.orbitControlsTarget!==void 0){let r=this.getWorldPosition(new nn),n=new nn().fromArray(e.orbitControlsTarget);this.targetOffset=n.distanceTo(r)}else e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=(t=e.angleOffsetFromUp)!=null?t: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 t={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 hs(t,e)}fromCameraState(e){let{orthographic:t,perspective:r}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),t!==void 0&&(t.near!==void 0&&(this.orthoCamera.near=t.near),t.zoom!==void 0&&(this.orthoCamera.zoom=t.zoom)),r!==void 0&&(r.near!==void 0&&(this.perspCamera.near=r.near),r.fov!==void 0&&(this.perspCamera.fov=r.fov),r.zoom!==void 0&&(this.perspCamera.zoom=r.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 fe(U(U({},super.toState(e)),this.toCameraState(e)),{type:this.cameraType})}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};import{Group as g3}from"three";var Qi=class extends ei(xn(g3),Fa){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,t){let r=new Qi().fromState(t);return r.uuid=e,r.enableHelper=!0,r.objectHelper.update(),r}toJSON(e){let t=super.toJSON(e);return t.object.objectType="EmptyObject",t}};import{DirectionalLight as y3,CameraHelper as Pu}from"three";var Ua=class extends ei(xn(y3),za){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=1,r.far=2500;let n=new Pu(this.shadow.camera);n.visible=!1,this._gizmos.shadowmap=n,this.update()}static createFromState(e,t,r){let n=new Ua().fromState(t,r);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Pu&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Pu&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Pu&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightDirectional",r.color=this.color.getHex(),r.intensity=this.intensity,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var n;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.shadow.normalBias=(n=e.shadow.normalBias)!=null?n:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.left=r.left,t.right=r.right,t.top=r.top,t.bottom=r.bottom,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromDirectionalLightState(e,t){let r=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,t),e.size!==void 0&&hv(this,e.size),r&&this.update(),this}fromState(e,t){return super.fromState(e),this.fromDirectionalLightState(e,t),this}};import{PointLight as x3,Vector3 as Du,Box3 as v3,Box3Helper as Bu,Color as b3}from"three";var ka=class extends ei(xn(x3),Va){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let n=new Du(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new Du(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),l=new v3(n,s),c=new Bu(l,new b3(16755200));c.visible=!1,this._gizmos.shadowmap=c,this.update()}static createFromState(e,t,r){let n=new ka().fromState(t,r);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Bu&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Bu&&(t.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let t=this._gizmos[e];if(t instanceof Bu){let r=this.shadow.camera,n=new Du(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new Du(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);t.box.set(n,s),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),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 t=super.toJSON(e),r=t.object;return r.objectType="LightPoint",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.decay=this.decay,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var n,s;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow.normalBias=(n=e.shadow.normalBias)!=null?n:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray((s=e.shadow.mapSize)!=null?s:[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromPointLightState(e,t){return super.fromLightState(e,t),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,t){return super.fromState(e),this.fromPointLightState(e,t),this}};import{SpotLight as S3,CameraHelper as Gu,MathUtils as w3,Vector3 as Wv,Quaternion as N3}from"three";var qv=new Wv,$v=new Wv,Jv=new N3,Ha=class extends ei(xn(S3),Au){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=w3.RAD2DEG*2*this.angle,r.aspect=1,r.near=100,r.far=2500;let n=new Gu(this.shadow.camera);n.visible=!1,this._gizmos.shadowmap=n,this.update()}static createFromState(e,t,r){let n=new Ha().fromState(t,r);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Gu&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Gu&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Gu&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),$v.setFromMatrixPosition(this.matrixWorld),Jv.setFromRotationMatrix(this.matrixWorld),qv.copy(this.up).applyQuaternion(Jv).negate().multiplyScalar(this.distance),this.target.position.copy($v).add(qv),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),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 t=super.toJSON(e),r=t.object;return r.objectType="LightSpot",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.angle=this.angle,r.decay=this.decay,r.penumbra=this.penumbra,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var n;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=(n=e.shadow.normalBias)!=null?n:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromSpotLightState(e,t){return super.fromLightState(e,t),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,t){return super.fromState(e),this.fromSpotLightState(e,t),this}};import{VideoTexture as C3}from"three";var Kv=i=>i.tagName==="VIDEO",Rs=class{static resize(e,t,r){let n=e/t,s;if(!r.image)return;let l=r.image;Kv(l)?s=l.videoWidth/l.videoHeight:s=l.width/l.height,n>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/n):r.repeat.set(1,1*s/n)),n<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*n/s*-1,1):r.repeat.set(1*n/s,1)),n==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(e,t,r){let n=e/t,s=r.image!==void 0?r.image.width/r.image.height:1,l;n>s?l={x:1,y:s/n}:n<s?l={x:n/s,y:1}:l={x:1,y:1},r.repeat.set(l.x,l.y),r.updateMatrix()}static resizeTextureLayers(e,t,r){let n=r.userData.layers,s=n.getLayers();for(let l=0;l<s.length;l++){let c=s[l];Nv(c)&&(Rs.resizeTextureLayer(e,t,c.uniforms[`f${c.id}_texture`].value),n.updateLayerUniform())}}static resizeComplex(e,t,r,n){let s=e/t,l,c=r.image;Kv(c)?l=c.videoWidth/c.videoHeight:l=c.width/c.height,n.geometry.type.includes("Shape")?(s>l&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t*l/s):r.repeat.set(1/e,1/t*l/s)),s<l&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*s/l*-1,1/t):r.repeat.set(1/e*s/l,1/t)),s==l&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t):r.repeat.set(1/e,1/t))):(s>l&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*l/s):r.repeat.set(1,1*l/s)),s<l&&(r.imageType=="WEBCAM"?r.repeat.set(1*s/l*-1,1):r.repeat.set(1*s/l,1)),s==l&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var Wa=class extends hr{constructor(e,t=new vr){super(e,t);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.userData.layers&&Rs.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(e,t){super.resizeGeometry(e,t,0),this.material.userData.layers&&Rs.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh2D",t}clone(){let e=super.clone();return e.updateGeometry({}),e}static fromTexture(e){let t,r;if(e instanceof C3){let l=e.image;t=l.videoWidth*.5,r=l.videoHeight*.5}else{let l=e.image;t=l.width*.5,r=l.height*.5}let n=ou.create({parameters:{width:t,height:r}}),s=new vr;return s.layersList.changeLayer(0,{type:qe.TEXTURE,texture:e}),s.layersList.moveLayer(0,1),s.dispose(),new Wa(n,s)}};var qa=class extends hr{constructor(e,t=new bn){super(e,t);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh3D",t}};var $a=class extends qa{constructor(e,t=new bn){super(e,t);this.objectType="NonParametric"}toJSON(e){let t=super.toJSON(e);return t.object.objectType="NonParametric",t}};var Ja;(function(t){t[t.TO_RIGHT=1]="TO_RIGHT",t[t.TO_LEFT=-1]="TO_LEFT"})(Ja||(Ja={}));var Op=class extends hr{constructor(e,t=new vr({transparent:!0,opacity:1,visible:!1,side:ju})){super(e,t);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:ki.None,horizontalAlignment:1,verticalAlignment:gi.Top,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new Zv(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,t,r){let n=su.create({parameters:{width:t.width,height:t.height}}),s=new Op(n).fromState(t,r);return s.uuid=e,s}async updateText(e){this.clearText();let t=this.userData.textFrame,r=t.fontFamily;await Rr.loadFont(r),t.text=e;let n=t.textOrigin,s=new Xv({visible:t.visible,transparent:!0,side:ju}),l=e.split(`
977
- `),c=0;this.userData.textFrame.textLines=l.map((f,h)=>{let d=new To(c,t.lineHeight,t.fontSize);return d.message=f.split("").map(x=>{let g={char:x,fontFamily:r,letterSpacing:t.letterSpacing,fontSize:t.fontSize,LOD:16},w=s.clone();w.color=t.hexColor,w.opacity=t.opacity;let S=new Rr(g,w);return d.addChar3D(S,n),this.charContainer.add(S),S}),c+=d.maxCharSize*d.lineHeight,d}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let t=this.charContainer.children[0];this.charContainer.remove(t)}for(;e.length;)e.pop()}raycast(e,t){let r=[];if(super.raycast(e,r),r.length>0){t.push(r[0]);return}let n=[];for(let s=0,l=this.charContainer.children.length;s<l;++s)if(this.charContainer.children[s]instanceof Rr&&(e.intersectObject(this.charContainer.children[s],!1,n),n.length>0)){n[0].object=this,t.push(n[0]);return}}updateGeometry(e){var h,d,x,g;let t=this.userData,r=this.geometry.userData,n=r.parameters.width,s=r.parameters.height,l=(d=(h=e.parameters)==null?void 0:h.width)!=null?d:n,c=(g=(x=e.parameters)==null?void 0:x.height)!=null?g:s,f=t.textFrame;super.updateGeometry(e),f.maxLineSize=l,f.textOrigin.set(-.5*l,.5*c,0),c!==s?(this.checkOverFlow(),this.checkCapacity()):l!==n&&(n<l?this.checkCapacity():n>l&&this.checkOverFlow())}checkOverFlow(e=0){let t=this.userData,r=t.textFrame.textOrigin,n=t.textFrame.textLines;for(let s=e;s<n.length;s++){n[s].updateYLinePos(this.getNewLinePosition(s)),n[s].fullUpdate(r);let l=[];for(;n[s].checkOverFlow(t.textFrame.maxLineSize);)n[s].containSpaceOverFlow()?l.unshift(n[s].getWord(n[s].message.length-1,-1)):l.unshift(n[s].popChar());if(l.length>0){n[s+1]===void 0?(n[s].isEndLine(!1),this.createTextLine()):n[s].endLine&&(this.createTextLine(s+1),n[s].isEndLine(!1),n[s+1].isEndLine(!0));let c=0;for(let f=0;f<l.length;f+=1)for(let h=0;h<l[f].length;h+=1)n[s+1].addChar3D(l[f][h],r,c),c+=1;n[s+1].fullUpdate(r)}n[s].fullUpdate(r)}this.textFullUpdate(e)}checkCapacity(e=0){let t=this.userData,r=t.textFrame.textOrigin,n=t.textFrame.maxLineSize,s=t.textFrame.textLines;for(let l=e;l<s.length;l+=1)if(s[l].updateYLinePos(this.getNewLinePosition(l)),s[l].fullUpdate(r),!!s[l-1])for(;!s[l-1].endLine;){let c,f=s[l-1].spaceLeft(n);if(s[l].wordSize(0,1)<=f){s[l].containSpace()?c=s[l].getWord(0,1):c=s[l].popChar(0);for(let h=0;h<c.length;h+=1)c[h]&&s[l-1].addChar3D(c[h],r)}else{s[l].isEmpty()?(s[l].endLine&&s[l-1].isEndLine(!0),s.splice(l,1),l-=1):(s[l].updateYLinePos(this.getNewLinePosition(l)),s[l].fullUpdate(r));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let r=this.userData.textFrame;r.textLines.splice(e,0,new To(this.getNewLinePosition(e),r.lineHeight,r.fontSize))}textFullUpdate(e=0){let r=this.userData.textFrame,n=r.textLines,s=this.getVerticalAlignmentOffSet();for(let l=e;l<n.length;l++)n[l].updateYLinePos(this.getNewLinePosition(l)),n[l].fullUpdate(r.textOrigin),n[l].alignText(r.textOrigin,r.maxLineSize,r.horizontalAlignment,r.verticalAlignment,s)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case gi.Top:return 0;case gi.Center:return this.getRemainingVerticalSpace()/2;case gi.Bottom:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let t=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(t.length)}getNewLinePosition(e){let r=this.userData.textFrame.textLines,n=0;for(let s=0;s<e;s+=1)n+=r[s].maxCharSize*r[s].lineHeight;return n}updateColor(e){var n;let t=this.userData;t.textFrame.hexColor=e;let r=t.textFrame.textLines;for(let s=0;s<r.length;s++){let l=r[s].message;for(let c=0;c<l.length;c++){let f=l[c].material;((n=f.color)==null?void 0:n.isColor)&&(f.color=e)}}}updateOpacity(e){let t=this.userData;t.textFrame.opacity=e;let r=t.textFrame.textLines;for(let n=0;n<r.length;n++){let s=r[n].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.opacity=e}}}updateVisible(e){let t=this.userData;t.textFrame.visible=e;let r=t.textFrame.textLines;for(let n=0;n<r.length;n++){let s=r[n].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.visible=e}}}async updateFontFamily(e){await Rr.loadFont(e);let r=this.userData.textFrame,n=r.textLines;r.fontFamily=e;for(let s=0;s<n.length;s++){let l=n[s].message;for(let c=0;c<l.length;c++)l[c].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let r=this.userData.textFrame,n=r.textLines,s=r.fontSize;r.fontSize=e;for(let l=0;l<n.length;l++)n[l].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let r=this.userData.textFrame;await Rr.loadFont(r.fontFamily);let n=r.textLines;switch(r.textTransform=e,e){case ki.Upper:for(let s=0;s<n.length;s++){let l=n[s].message;for(let c=0;c<l.length;c++)n[s].message[c].updateChar(l[c].char.toUpperCase())}break;case ki.Lower:for(let s=0;s<n.length;s++){let l=n[s].message;for(let c=0;c<l.length;c++)n[s].message[c].updateChar(l[c].char.toLowerCase())}break;default:for(let s=0;s<n.length;s++){let l=n[s].message;for(let c=0;c<l.length;c++)n[s].message[c].updateChar(l[c].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let t=this.userData,r=t.textFrame.textLines;t.textFrame.letterSpacing=e;for(let n=0;n<r.length;n++){let s=r[n].message;for(let l=0;l<s.length;l++)s[l].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let t=this.userData;t.textFrame.LOD=e;let r=t.textFrame.textLines;for(let n=0;n<r.length;n++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let t=this.userData,r=t.textFrame.textLines;t.textFrame.lineHeight=e;for(let n=0;n<r.length;n++)r[n].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let t=this.userData;t.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let t=this.userData;t.textFrame.horizontalAlignment=e,this.textFullUpdate()}toJSON(e){let t=super.toJSON(e),r=t.object;r.objectType="TextFrame";let s=this.userData.textFrame.textLines.map(l=>{let c=l.message.map(f=>({char:f.char,originalChar:f.originalChar,fontFamily:f.fontFamily,letterSpacing:f.letterSpacing,fontSize:f.fontSize,LOD:f.LOD}));return{align:l.align,endLine:l.endLine,lineHeight:l.lineHeight,maxCharSize:l.maxCharSize,yLinePos:l.yLinePos,message:c}});return r.userData.textFrame.textLinesData=s,t}async fromJSONasync(e){if(super.fromJSON(e),e.userData!==void 0){let t=e.userData.textFrame;await Rr.loadFont(t.fontFamily),t.textOrigin=new Zv(t.textOrigin.x,t.textOrigin.y,t.textOrigin.z);let r=new Xv({color:t.hexColor,opacity:t.opacity,visible:t.visible,transparent:!0,side:ju});t.textLinesData&&(t.textLines=t.textLinesData.map((n,s)=>{let l=new To(Number(n.yLinePos),Number(n.lineHeight),Number(n.maxCharSize)),c=n.message.map((f,h)=>{if(f.char===void 0){let g=t.textLines[s].message[h];if("geometries"in g){let w=g.geometries[0].userData.parameters;Object.assign(f,{LOD:w.lod,char:w.char,fontFamily:w.fontFamily,fontSize:w.fontSize,letterSpacing:w.letterSpacing,originalChar:w.char})}}let d={char:f.char,fontFamily:f.fontFamily,letterSpacing:Number(f.letterSpacing),fontSize:Number(f.fontSize),LOD:f.LOD},x=new Rr(d,r.clone());return l.addChar3D(x,t.textOrigin),this.charContainer.add(x),x});return l.message=c,l}),this.userData.textFrame=t),this.textFullUpdate()}return this}fromTextFrameData(e,t){if(e.color!==void 0){let r=kt(e.color,t);this.updateColor(r),this.updateOpacity(r.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,t){return super.fromState(e),this.fromTextFrameData(e,t),this}convertToVector(){let{fontFamily:e,hexColor:t}=this.userData.textFrame,r=new Qi;r.name="Text Shape";let n=Rr.fontCache[e];for(let s of this.charContainer.children)s instanceof Rr&&n.generateShapes(s.char,1).forEach(l=>{let c=new st().fromShape(l);c.applyScale(s.scale.x,s.scale.y);let f=ur.create({shape:c}),h=new vr({side:ju});h.color=t;let d=new Io(f,h);d.name=s.char,d.position.copy(s.position),d.rotation.copy(s.rotation),r.attach(d)});return r}},zs=Op;zs.VerticalAlign=gi,zs.HorizontalAlign=Lr,zs.TextTransform=ki;import{HemisphereLight as F3,Scene as V3,Vector3 as U3,Color as fb,Fog as k3,Box3 as H3}from"three";import{BufferGeometryLoader as _3}from"three";function Yv(i,e){return T3(i)}function T3(i){let e={parameters:i,type:i.type};if(i.type==="VectorGeometry"){let r=st.createFromState(i.shape,i.width,i.height);e.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)}),e.geometry=new _3().parse(i));let t;try{t=La(e)}catch(r){console.error(r)}if(!t){let r=st.createFromState(ws.defaultData(),100,100);e.shape=r,t=La(e)}return t}import{Box3 as I3,Matrix4 as Mo,Sphere as tb,Vector3 as M3}from"three";var rb=ug(eb());var Pp;au.then(i=>{Pp=i});var nb=new Mo,A3=new Mo,O3=new Mo,En=new I3,eo=new M3,P3=new Mo,D3=new Mo,Ka=class extends hr{constructor(e,t,r,n=new bn){super(r!=null?r:t,n);this.subdivPointer=e;this.originalGeometry=t;this.subdividedGeometry=r;this.objectType="SubdivObject";this.hiddenMatrixOld=new Mo;this.smoothShading=!0;this.matrixWorldRigid=new Mo;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,t,r){let{subdivPointer:n,originalGeometry:s,subdividedGeometry:l}=en.build(t.geometry,void 0,void 0,!t.flatShading),c=Ra(t.material,r),f=new Ka(n,s,l||void 0,c);return f.calcBoundingBox(),f.freeSubdivPointer(),f.uuid=e,f.fromState(t),f}shallowClone(e){return new $a(this.geometry,this.material).shallowCopy(this,e)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="SubdivObject",t}buildFromStore(e){var s,l,c;let{originalGeometry:t,subdividedGeometry:r,subdivPointer:n}=en.build(e,this.subdivPointer,void 0,this.smoothShading,this.shearScale);if(this.subdivPointer=n,t!==void 0&&((s=this.originalGeometry)==null||s.dispose(),this.originalGeometry=t),r!==void 0&&((l=this.subdividedGeometry)==null||l.dispose(),this.subdividedGeometry=r!=null?r:void 0),this.geometry=(c=this.subdividedGeometry)!=null?c:this.originalGeometry,this.cloner)for(let f of this.cloner.children)f.geometry=this.geometry;e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){en.buildLevel(this.subdivPointer,!0,this.smoothShading,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&en.buildLevel(this.subdivPointer,!1,this.smoothShading,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){var e;this.originalGeometry.dispose(),this.originalGeometry=en.buildLevel(this.subdivPointer,!0,this.smoothShading),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=en.buildLevel(this.subdivPointer,!1,this.smoothShading)),this.geometry=(e=this.subdividedGeometry)!=null?e:this.originalGeometry}raycast(e,t){var r;this.geometry=this.originalGeometry,hr.prototype.raycast.call(this,e,t),this.geometry=(r=this.subdividedGeometry)!=null?r:this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,t=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:r,v:n,q:s}=(0,rb.SVD)(t),l=nb.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),c=A3.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=O3.copy(c).transpose();this.shearScale=P3.makeScale(s[0],s[1],s[2]).multiply(f).premultiply(c),this.shearScaleInv=D3.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,f),s.every(h=>Math.abs(s[0]-h)<.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 tb);let t=e.attributes.position,r=e.boundingSphere.center;En.setFromBufferAttribute(t),En.getCenter(r),e.boundingSphere.radius=r.distanceTo(En.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),En.getSize(eo);let n={width:eo.x,height:eo.y,depth:eo.z};return this.geometry.userData.parameters=n,n}updateBoundingBox(e){let t=this.originalGeometry;En.min.set(e[0],e[2],e[4]),En.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(En.min.applyMatrix4(this.shearScaleInv),En.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new tb);let r=t.boundingSphere.center;En.getCenter(r),t.boundingSphere.radius=r.distanceTo(En.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),En.getSize(eo);let n={width:eo.x,height:eo.y,depth:eo.z};return this.geometry.userData.parameters=n,n}freeSubdivPointer(){this.subdivPointer&&(Pp.free_bvh(this.subdivPointer),Pp.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,ib(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(ib(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters=U({},e.parameters)}};function ib(i,e,t,r){let n=i.position.array,s=i.normal.array,l=nb.makeScale(e,t,r).invert().elements,c,f,h;for(var d=0,x=n.length;d<x;d+=3)n[d]*=e,n[d+1]*=t,n[d+2]*=r,c=s[d],f=s[d+1],h=s[d+2],s[d]=l[0]*c+l[4]*f+l[8]*h,s[d+1]=l[1]*c+l[5]*f+l[9]*h,s[d+2]=l[2]*c+l[6]*f+l[10]*h}import{BackSide as B3,DoubleSide as G3,FrontSide as j3}from"three";function ob(i,e){e.flatShading!==void 0&&(i.flatShading=e.flatShading,i.needsUpdate=!0),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.side!==void 0&&(e.side===xs.Front?i.side=j3:e.side===xs.Back?i.side=B3:i.side=G3)}function E3(i,e){if(Array.isArray(i.material))for(let t of i.material)ob(t,e);else{let t=i.material;ob(t,e)}i.objectType==="SubdivObject"&&e.flatShading!==void 0&&(i.material.flatShading=!1,i.smoothShading=!e.flatShading,i.updateMesh())}function sb(i,e,t){let r;if(e.geometry.type==="SubdivGeometry")r=Ka.createFromState(i,e,t);else{let n=Yv(e.geometry,t),s="materials"in e?jv(e.materials,t):Ra(e.material,t);Fc.is2DParametricMesh(n.userData.type)?r=new Wa(n,s):(n==null?void 0:n.userData.type)==="VectorGeometry"?r=new Io(n,s):e.geometry.type==="NonParametricGeometry"?r=new $a(n,s):r=new qa(n,s),r.uuid=i,r.fromState(e)}return E3(r,e),r}function ab(i,e,t){return e.type==="Mesh"?sb(i,e,t):e.type==="TextFrame"?zs.createFromState(i,e,t):e.type==="Empty"?Qi.createFromState(i,e):e.type==="PointLight"?ka.createFromState(i,e,t):e.type==="SpotLight"?Ha.createFromState(i,e,t):e.type==="DirectionalLight"?Ua.createFromState(i,e,t):ps.is(e.type)?Yi.createFromState(i,e):(console.error(e),new Qi)}function R3(i,e){e.uniforms[`f${e.id}_transmissionSamplerMap`].value=i.texture,e.uniforms[`f${e.id}_transmissionDepthMap`].value=i.depthTexture}function lb(i,e,t){if(!t.userData.layers)return!1;let r=!1,n=t.userData.layers.getLayersOfType(qe.TRANSMISSION);return n.length>0?(e.layers.set(3),r=!0,i!==void 0&&n.forEach(s=>R3(i,s))):e.layers.set(0),r}function cb(i,e){let t=!1;return e.traverseEntity(r=>{if(r instanceof hr)if(Array.isArray(r.material))for(let n=0;n<r.material.length;n++)lb(i,r,r.material[n])&&(t=!0);else lb(i,r,r.material)&&(t=!0)}),t}function ub(i,e){"material"in i&&z3(i.material,e),"geometry"in i&&i.geometry.dispose()}function z3(i,e){fg(i).forEach(t=>{e.isSharedMaterial(t)||t.dispose()})}var hb=new U3,Dp=class extends uu(V3){constructor(e,t){super();this.objectType="Scene";this.alpha=1;this.backupFog=new k3(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new fb(1,0,0);this.bgColor=new fb(1,1,1);this.entityByUuid={};this.ambientLight=new F3(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.sharedAssetManager=t,this.init(e,t)}needsTransmission(e){return this.needsTransmissionDirty&&(this._needsTransmission=cb(e,this),e!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}find(e){if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}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,t){if(this.createChildrenObjects(e.objects,this,t),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(kt(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let r=this.find(e.publish.playCamera);r instanceof Yi&&this.switchActiveCamera(r)}}clearScene(e){this.traverseEntity(t=>{ub(t,e)});for(let t of this.children)yn(t)&&t.removeFromParent()}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=Yi.createFromState(Dp.PERSONAL_CAMERA_ID,fe(U({},Uc.defaultData),{name:"Personal Camera"}));return e.enableHelper=!1,e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],r=n=>{for(let s of n.children)yn(s)&&!s.raycastLock&&s.visible&&((_s(s)||vi(s)&&s.enableHelper&&s.objectHelper.parent)&&e.intersectObject(s,!1,t),r(s))};return r(this),t}traverseEntity(e){for(let t of this.children)yn(t)&&t.traverseEntity(e)}updateFog(e,t){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=kt(e.color,t),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,t){fv(this.ambientLight,e,t),e.groundColor!==void 0&&(this.ambientLight.groundColor=kt(e.groundColor,t)),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,t,r){for(let n of e)this.createChildObject(n.id,n.data,n.children,t,r)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createChildObject(e,t,r,n,s){let l=ab(e,t,s);return l&&(this.entityByUuid[e]=l,n.add(l),this.createChildrenObjects(r,l,s)),l}getCenter(e){let t=[];for(let n=0,s=e.length;n<s;++n){let{id:l,recursive:c}=e[n],f=this.find(l),h=c?f.recursiveBBox:f.singleBBox;t.push(...h.vertices)}let r=new H3;return r.setFromPoints(t),r.getCenter(hb),hb}copyMatrixWorld(e,t){if(e===null){t.identity();return}let r=this.find(e);r?t.copy(r.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){var n;if(e===null){t.identity();return}let r=(n=this.find(e))==null?void 0:n.parent;r?t.copy(r.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof hr)if(Array.isArray(t.material))for(let r=0;r<t.material.length;r++)e(t.material[r]);else e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let r,n;e>=t?(r=t/e,n=1):(r=1,n=e/t),this.traverseMaterial(s=>{s.layersList.getLayersOfType(qe.TRANSMISSION).forEach(c=>{c.uniforms[`f${c.id}_aspectRatio`].value.x=r,c.uniforms[`f${c.id}_aspectRatio`].value.y=n})})}},Ru=Dp;Ru.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{DRACOLoader as W3}from"three/examples/jsm/loaders/DRACOLoader.js";var to;function q3(){return to||(to=new W3,to.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),to.decoderPending}async function $3(i){if(to){let e={attributeIDs:to.defaultAttributeIDs,attributeTypes:to.defaultAttributeTypes,useUniqueIDs:!1},t;try{t=await to.decodeGeometry(new Int8Array(i).buffer,e)}catch(r){console.error(r)}if(t)return{index:t.index?{array:t.index.array}:void 0,attributes:Object.entries(t.attributes).map(([r,n])=>({name:r,itemSize:n.itemSize,array:n.array}))}}return null}async function pb(i){let[e,t]=ih(Pc.deserialize(new Uint8Array(i))),r=[];e.scene.objects.traverse((n,s)=>{s.type==="Mesh"&&s.geometry.type==="NonParametricGeometry"&&s.geometry.data.draco!==void 0&&r.push(s)}),r.length&&await q3();for(let n of r){let s=await $3(sh(n.geometry.data.draco));if(s){s.index&&(n.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let l={};s.attributes.forEach(({name:c,array:f,itemSize:h})=>{l[c]={array:f,itemSize:h,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=l,n.geometry.data.draco=void 0}}return t.result().data}import{WebGLRenderTarget as J3,LinearMipmapLinearFilter as K3,LinearFilter as X3,ClampToEdgeWrapping as db,DepthTexture as Z3}from"three";var mb=new vr,Bp=class extends tn{},Gp=class{constructor(e){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new J3(2048,2048,{generateMipmaps:!0,minFilter:K3,magFilter:X3,wrapS:db,wrapT:db}),this.transmissionRenderTarget.depthTexture=new Z3(2048,2048),this.reset(e)}reset(e){for(let[t,r]of Object.entries(e.images))this.addImage(t,r.data);for(let[t,r]of Object.entries(e.colors))this.addColor(t,r);for(let[t,r]of Object.entries(e.materials))this.addMaterial(t,Lp(r,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}addMaterial(e,t){t.uuid=e,this.materials[e]=t}deleteMaterial(e){this.materials[e]&&(this.materials[e].dispose(),delete this.materials[e])}isSharedMaterial(e){return e.uuid in this.materials||e===mb}getMaterial(e){let t=this.materials[e];return t}getMaterialOrDeletedPlaceholder(e){var t;return(t=this.materials[e])!=null?t:mb}getMaterials(){return this.materials}addImage(e,t){if(this.images[e])return this.images[e].onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e].src=t,!0;{let r=new Image;return r.src=t,r.onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e]=r,!1}}deleteImage(e){this.images[e]&&delete this.images[e]}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]}getImages(){return this.images}addColor(e,t){return this.colors[e]?("a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):("a"in t?this.colors[e]=new Bp(t.r,t.g,t.b,t.a):this.colors[e]=new Bp(t.r,t.g,t.b,1),!1)}updateColor(e,t){var r,n,s,l;if(this.colors[e]){let c=this.colors[e];return this.colors[e].r=(r=t.r)!=null?r:c.r,this.colors[e].g=(n=t.g)!=null?n:c.g,this.colors[e].b=(s=t.b)!=null?s:c.b,this.colors[e].a=(l=t.a)!=null?l:c.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this.onImageLoad=void 0}};import{Color as yb,ShaderLib as Y3}from"three";var xb=ug(gb());function vb(i){let e=new Set;return i.traverse(t=>{if(_s(t))if((0,xb.isArray)(t.material))t.material.forEach(r=>{let n=r;e.has(n)||e.add(n)});else{let r=t.material;e.has(r)||e.add(r)}}),e.forEach(t=>{let r=t.onBeforeCompile.bind(t);Q3(t)?(Object.assign(t,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new yb,specularColor:new yb}),t.onBeforeCompile=(n,s)=>{r&&r(n,s),n.uniforms=Object.assign(Y3.physical.uniforms,n.uniforms),t.userData.layers.getLayersOfType(qe.TRANSMISSION).forEach(l=>{n.uniforms.transmissionSamplerMap.value&&(l.uniforms["f"+l.id+"_transmissionSamplerMap"].value=n.uniforms.transmissionSamplerMap.value,l.uniforms["f"+l.id+"_transmissionSamplerSize"].value=n.uniforms.transmissionSamplerSize.value)})}):eB(t)||(t.onBeforeCompile=(n,s)=>{r&&r(n,s),t.transparent=!1})}),i}function Q3(i){return i.userData.layers.getLayersOfType(qe.TRANSMISSION).length>0}function eB(i){let e=i.userData.layers.head,t=0;for(;e!==void 0;){if(e.type!==qe.LIGHTING&&e.type!==qe.FRESNEL){let r=e.uniforms["f"+e.id+"_alpha"];r&&(t+=(1-t)*r.value)}e=e.next}return t<1}function bb(i){return i.traverse(e=>{if(e.type==="Camera"){let t=e;t.type=t.cameraType}}),i}var Sb=class extends rB{load(e,t,r,n=console.error){let s=new tB(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,async l=>{try{if(typeof l=="string")throw new Error("The .spline file is not binary!");let c=await this.parse(l);t(c)}catch(c){n(c)}},r,n)}async parse(e){let t=await pb(e),r=new Gp(t.shared),n=new Ru(t.scene,r);return bb(vb(n))}};export{Sb as default};
956
+ `),p&&m.push(p.code,`outgoingLight = spe_blend(outgoingLight, ${p.result}, 1.0, SPE_BLENDING_NORMAL);`),u?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=m.join(`
957
+ `)}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 pa=class extends Rt{constructor(e=new ca,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 yo=class extends pa{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 St){let e=t.userData.layers,r=t.fragment;super.copy(t);let i=r.clone();this.fragment=i,this.vertex=i;let o=e.clone(this);this.userData.layers=o,i.shadingAlpha.value=r.shadingAlpha.value,i.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let i=r.getNode(e.vertex),o=new yo(void 0,i);return o.fromJSON(e,r),o}dispose(){super.dispose()}};import{Color as kl}from"three";import{Matrix3 as dd,Texture as Ul,Vector2 as Sn,Vector3 as Qr,Vector4 as md}from"three";function fd(n,t){switch(n.data.type){case"light":return rr(n);case"fresnel":return sS(n,t);case"gradient":return aS(n);case"depth":return lS(n);case"normal":return cS(n);case"noise":return pS(n,t);case"texture":return uS(n,t);case"rainbow":return hS(n);case"transmission":return dS(n,t);case"matcap":return mS(n,t);case"displace":return fS(n);case"color":default:return nS(n,t)}}function yd(n){return{type:n.data.type}}function rr(n){let{alpha:t,mode:e}=n.data;return W(P({},yd(n)),{alpha:t,mode:e})}function nS(n,t){return W(P({},rr(n)),{color:Ye(n.data.color,t)})}function sS(n,t){let{bias:e,scale:r,intensity:i,factor:o,color:s}=n.data;return W(P({},rr(n)),{color:Ye(s,t),bias:e,scale:r,intensity:i,factor:o})}function aS(n){let{gradientType:t,smooth:e,colors:r,steps:i,angle:o,offset:s,morph:a}=n.data;return W(P({},rr(n)),{gradientType:t,smooth:e,colors:r.map(l=>new md(l[0],l[1],l[2],l[3])),num:r.length,steps:i,offset:new Sn(...s),morph:new Sn(...a),angle:o})}function lS(n){let{gradientType:t,near:e,far:r,isVector:i,isWorldSpace:o,origin:s,direction:a,colors:l,steps:c,smooth:p,num:u}=n.data;return W(P({},rr(n)),{gradientType:t,near:e,far:r,isVector:i,isWorldSpace:o,origin:new Qr(...s),direction:a?new Qr(...a):new Qr(1,0,0),num:u,colors:l.map(h=>new md(h[0],h[1],h[2],h[3])),steps:c,smooth:p})}function cS(n){let{cnormal:t}=n.data;return W(P({},rr(n)),{cnormal:new Qr(t[0],t[1],t[2])})}function pS(n,t){let{data:e}=n;return W(P({},rr(n)),{scale:e.scale,move:e.move,fA:new Sn(...e.fA),fB:new Sn(...e.fB),size:new Qr(...e.size),distortion:new Sn(...e.distortion),colorA:Ye(e.colorA,t),colorB:Ye(e.colorB,t),colorC:Ye(e.colorC,t),colorD:Ye(e.colorD,t),noiseType:e.noiseType})}function uS(n,t){let{projection:e,axis:r,crop:i,size:o}=n.data,{image:s,wrapping:a,repeat:l,offset:c}=n.data.texture,p=new Ul,u;if(typeof s=="string")u=t==null?void 0:t.getImage(s);else{let h=new Image;h.src=s.data,h.onload=()=>{t!=null&&t.onImageLoad&&(t==null||t.onImageLoad(s.data))},u=h}return p.image=u,p.repeat.set(l[0],l[1]),p.offset.set(c[0],c[1]),p.wrapS=p.wrapT=a,W(P({},rr(n)),{texture:p,mat:new dd().setUvTransform(c[0],c[1],l[0],l[1],0,0,0),crop:i,projection:e,axis:["x","y","z"].indexOf(r),size:o})}function hS(n){let{data:t}=n;return W(P({},rr(n)),{filmThickness:t.filmThickness,movement:t.movement,wavelengths:new Qr(...t.wavelengths),noiseStrength:t.noiseStrength,noiseScale:t.noiseScale,offset:new Qr(...t.offset)})}function dS(n,t){let{data:e}=n;return W(P({},rr(n)),{thickness:e.thickness,ior:e.ior,roughness:e.roughness,transmissionSamplerMap:t.transmissionSamplerMap,transmissionDepthMap:t.transmissionDepthMap})}function mS(n,t){let e=new Ul,{image:r}=n.data.texture,i;if(typeof r=="string")i=t==null?void 0:t.getImage(r);else{let s=new Image;s.src=r.data,s.onload=()=>{t!=null&&t.onImageLoad&&(t==null||t.onImageLoad(r.data))},i=s}e.image=i;let o=16777215;return W(P({},rr(n)),{color:o,texture:e})}function fS(n){let{data:t}=n,e=W(P({},yd(n)),{intensity:t.intensity});if(t.displacementType==="noise")return W(P({},e),{offset:new Qr(...t.offset),scale:t.scale,movement:t.movement,noiseType:t.noiseType});{let r=new Ul,i=new dd().setUvTransform(0,0,1,1,0,0,0);return W(P({},e),{texture:r,mat:i,crop:t.crop})}}function gd(n,t,e){if(e.type==="displace"&&(n==="intensity"||n==="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"&&(n==="alpha"||n==="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 vd,Vector4 as yS}from"three";var go;(t=>{function n(e){return new vd(e.x,e.y,e.z).getHex()}t.getHex=n})(go||(go={}));var xd;(t=>{function n(e){return new yS(e.r,e.g,e.b,e.a)}t.getThreeVector4=n})(xd||(xd={}));var bd;(e=>{function n(r,i){r.setRGB(i.r,i.g,i.b)}e.setThreeColor=n;function t(r){return new vd(r.r,r.g,r.b).getHex()}e.getHex=t})(bd||(bd={}));function wn(n,t){return typeof n=="string"?t.getMaterialOrDeletedPlaceholder(n):Hl(n,t)}function Sd(n,t){return n.map(e=>wn(e,t))}function Hl(n,t){var s,a;let e=(s=n.layers)!=null?s:Ki.defaultTwoLayerData("phong").layers,r=gS(e),i;switch(r.category){case"basic":i=new mt;break;case"lambert":{i=new mo;break}case"toon":{i=new fo;break}case"physical":i=new yo;break;case"phong":default:{i=new Vt;break}}i.name=(a=n.name)!=null?a:"Untitled Material";let o=i.userData.layers;xS(o);for(let l=e.length-1;l>=0;l--)bS(o,e[l],t);switch(r.category){case"basic":break;case"lambert":{let p=i,h=Ye(r.emissive,t);h instanceof kl?p.emissive.value=h:p.emissive.value.setHex(go.getHex(h));break}case"toon":{let p=i,u=r;p.shininess.value=u.shininess;let h=Ye(u.specular,t);h instanceof kl?p.specular.value=h:p.specular.value.setHex(go.getHex(h));break}case"physical":let l=i,c=r;l.metalness.value=c.metalness,l.roughness.value=c.roughness,l.reflectivity.value=c.reflectivity;break;case"phong":default:{let p=i,u=r;p.shininess.value=u.shininess;let h=Ye(u.specular,t);h instanceof kl?p.specular.value=h:p.specular.value.setHex(go.getHex(h));break}}return o.blendColors(),o.blendAfterColors(),o.blendPositions(),i}function gS(n){for(let t of n)if(t.data.type==="light")return t.data;return{type:"light",category:"basic",visible:!0,alpha:1,mode:0}}function xS(n){for(let t of n.getLayers())n.removeLayer(t.id)}function bS(n,t,e){let r=fd(t,e);r.type==="transmission"&&(r.transmissionSamplerMap=e==null?void 0:e.transmissionSamplerMap,r.transmissionDepthMap=e==null?void 0:e.transmissionDepthMap);let i=n.addLayer(r);i.uuid=t.id;for(let o in t.data)gd(o,i,t.data)}var wd=n=>n.tagName==="VIDEO",bi=class{static resize(t,e,r){let i=t/e,o;if(!r.image)return;let s=r.image;wd(s)?o=s.videoWidth/s.videoHeight:o=s.width/s.height,i>o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*o/i):r.repeat.set(1,1*o/i)),i<o&&(r.imageType=="WEBCAM"?r.repeat.set(1*i/o*-1,1):r.repeat.set(1*i/o,1)),i==o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(t,e,r){let i=t/e,o=r.image!==void 0?r.image.width/r.image.height:1,s;i>o?s={x:1,y:o/i}:i<o?s={x:i/o,y:1}:s={x:1,y:1},r.repeat.set(s.x,s.y),r.updateMatrix()}static resizeTextureLayers(t,e,r){let i=r.userData.layers,o=i.getLayers();for(let s=0;s<o.length;s++){let a=o[s];ad(a)&&(bi.resizeTextureLayer(t,e,a.uniforms[`f${a.id}_texture`].value),i.updateLayerUniform())}}static resizeComplex(t,e,r,i){let o=t/e,s,a=r.image;wd(a)?s=a.videoWidth/a.videoHeight:s=a.width/a.height,i.geometry.type.includes("Shape")?(o>s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e*s/o):r.repeat.set(1/t,1/e*s/o)),o<s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*o/s*-1,1/e):r.repeat.set(1/t*o/s,1/e)),o==s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e):r.repeat.set(1/t,1/e))):(o>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/o):r.repeat.set(1,1*s/o)),o<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*o/s*-1,1):r.repeat.set(1*o/s,1)),o==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var xo=class extends at{constructor(e,r=new mt){super(e,r);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.userData.layers&&bi.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&&bi.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,i;if(e instanceof vS){let a=e.image;r=a.videoWidth*.5,i=a.videoHeight*.5}else{let a=e.image;r=a.width*.5,i=a.height*.5}let o=Ws.create({parameters:{width:r,height:i}}),s=new mt;return s.layersList.changeLayer(0,{type:"texture",texture:e}),s.layersList.moveLayer(0,1),s.dispose(),new xo(o,s)}};import{DoubleSide as SS,EventDispatcher as wS,Matrix3 as CS,Vector3 as ql}from"three";var LS=new ql(0,0,1),Cd=new ql,Ld=new ql,Td=new CS,ei=class extends at{constructor(e=ut.create({}),r=new mt({side:SS})){var i;super(e,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new wS;this._onShapeUpdate=()=>{if(this.geometry instanceof Kr){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,(i=this.shape.eventDispatcher)==null||i.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,i;this.shape&&((r=this.shape.eventDispatcher)==null||r.removeEventListener("update",this._onShapeUpdate)),this.shape=e,(i=this.shape.eventDispatcher)==null||i.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),Td.getNormalMatrix(this.matrixWorld),Cd.copy(LS).applyMatrix3(Td).normalize(),Ld.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(Cd,Ld)}clone(e){let r=this.shape.clone(),i=this.material.clone(),o=this.geometry.userData,s=ut.create(Object.assign({},o,{shape:r})),a=new ei(s,i).copy(this,e);return a.shape=r,r.update(),a}raycast(e,r){at.prototype.raycast.call(this,e,r)}};import{Camera as FS,OrthographicCamera as jS,PerspectiveCamera as US,Vector3 as Ft,Object3D as Od,Quaternion as kS}from"three";import{BoxBufferGeometry as TS}from"three";var yr=n=>{var t;return t=class extends n{constructor(){super(...arguments);this.isObjectHelper=!0}},t.geometryHelper=new TS(30,30,30),t};import{Camera as PS,LineSegments as AS,BufferGeometry as DS,LineBasicMaterial as _S,Color as $l,Vector3 as BS,Float32BufferAttribute as Md}from"three";import{Ray as NS,Sphere as MS,Matrix4 as OS,Vector3 as Ar}from"three";var ua=new NS,Wl=new MS,Nd=new OS,gr=(n,t,e,r,i=!1)=>{let o=t,s=n.matrixWorld;if(o.boundingSphere===null&&o.computeBoundingSphere(),Wl.copy(o.boundingSphere),Wl.applyMatrix4(s),e.ray.intersectsSphere(Wl)===!1||(Nd.copy(s).invert(),ua.copy(e.ray).applyMatrix4(Nd),o.boundingBox!==null&&ua.intersectsBox(o.boundingBox)===!1))return;let a,l,c,p,u=o.index,h=o.attributes.position,m=o.drawRange,f,L;if(i===!1){let y=Math.max(0,m.start),w=Math.min(u.count,m.start+m.count);for(f=y,L=w;f<L;f+=3)if(l=u.getX(f),c=u.getX(f+1),p=u.getX(f+2),a=S(n,e,ua,h,l,c,p),a){a.faceIndex=Math.floor(f/3),r.push(a);return}}else{let w=o.attributes.position,I=new Ar,_=new Ar,g=new Ar,V=new Ar,b=2,O=1/((n.scale.x+n.scale.y+n.scale.z)/3),x=O*O,M=Math.max(0,m.start),C=Math.min(w.count,m.start+m.count);for(let T=M,$=C-1;T<$;T+=b){if(I.fromBufferAttribute(w,T),_.fromBufferAttribute(w,T+1),ua.distanceSqToSegment(I,_,V,g)>x)continue;V.applyMatrix4(n.matrixWorld);let ie=e.ray.origin.distanceTo(V);ie<e.near||ie>e.far||r.push({distance:ie,point:g.clone().applyMatrix4(n.matrixWorld),object:n})}}function S(y,w,I,_,g,V,b){let d=new Ar,O=new Ar,x=new Ar,M=new Ar,C=new Ar;if(d.fromBufferAttribute(_,g),O.fromBufferAttribute(_,V),x.fromBufferAttribute(_,b),I.intersectTriangle(d,O,x,!1,M)===null)return null;C.copy(M),C.applyMatrix4(y.matrixWorld);let $=w.ray.origin.distanceTo(C);return $<w.near||$>w.far?null:{faceIndex:1,distance:$,point:C.clone(),object:y}}};var ha=new BS,Yt=new PS,Jl=class extends AS{constructor(e){let r=new DS,i=new _S({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],s=[],a={},l=new $l(15711266),c=new $l(15711266),p=new $l(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",p),u("u2","u3",p),u("u3","u1",p);function u(m,f,L){h(m,L),h(f,L)}function h(m,f){o.push(0,0,0),s.push(f.r,f.g,f.b),a[m]===void 0&&(a[m]=[]),a[m].push(o.length/3-1)}r.setAttribute("position",new Md(o,3)),r.setAttribute("color",new Md(s,3));super(r,i);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let e=this.geometry,r=this.pointMap,i=!0;Yt.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,s=1,a=i?.8:1e-4;ir("n1",r,e,Yt,-o,-s,a),ir("n2",r,e,Yt,o,-s,a),ir("n3",r,e,Yt,-o,s,a),ir("n4",r,e,Yt,o,s,a);let l=a;ir("f1",r,e,Yt,-o,-s,l),ir("f2",r,e,Yt,o,-s,l),ir("f3",r,e,Yt,-o,s,l),ir("f4",r,e,Yt,o,s,l);let c=l,p=.5;ir("u1",r,e,Yt,o*.7*p,s*1.1,c),ir("u2",r,e,Yt,-o*.7*p,s*1.1,c),ir("u3",r,e,Yt,0,s*(1.1+.9*p),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function ir(n,t,e,r,i,o,s){ha.set(i,o,s).unproject(r);let a=t[n];if(a!==void 0){let l=e.getAttribute("position");for(let c=0,p=a.length;c<p;c++)l.setXYZ(a[c],ha.x,ha.y,ha.z)}}var da=class extends yr(Jl){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){gr(this.object,this.geometry,e,r,!0)}};import{DirectionalLightHelper as ES}from"three";var bo=class extends yr(ES){constructor(e,r=15,i=10066329){super(e,r,i);this.object=e;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){gr(this.object,bo.geometryHelper,e,r)}};import{AxesHelper as GS}from"three";var vo=class extends yr(GS){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){gr(this.object,vo.geometryHelper,e,r)}update(){}};import{PointLightHelper as zS}from"three";var So=class extends yr(zS){constructor(e,r=15,i=6710886){super(e,r,i);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){gr(this.object,So.geometryHelper,e,r)}};import{SpotLightHelper as RS,Vector3 as VS}from"three";var ma=class extends yr(RS){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){gr(this.object,ma.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=ma._vector,r=this.object.distance?this.object.distance:1e3,i=r*Math.tan(this.object.angle);this.cone.scale.set(i,i,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 s=0,a=this.cone.material.length;s<a;s++)this.cone.material[s].color.set(o);else this.cone.material.color.set(o)}}},Cn=ma;Cn._vector=new VS;var xr=(n,t)=>class extends n{constructor(){super(...arguments);this.objectHelper=new t(this);this.enableHelper=!1}set visibility(i){this.visible=i,this.setHelperVisibility(i),this.setHelperChildrenVisibility(i)}get visibility(){return this.visible}get geometryHelper(){return t.geometryHelper}setHelperVisibility(i){this.objectHelper.visible=i}setHelperChildrenVisibility(i){for(let o of this.children)Jt(o)&&o.traverseEntity(s=>{Or(s)&&s.visible&&(s.objectHelper.visible=i)})}raycast(i,o){this.objectHelper.raycast(i,o)}copy(i,o=!0){return super.copy(i,o),i.enableHelper!==void 0&&(this.enableHelper=i.enableHelper),i.objectHelper!==void 0&&(this.objectHelper.visible=i.objectHelper.visible),this}toJSON(i){let o=super.toJSON(i),s=o.object;return s.enableHelper=this.enableHelper,o}fromJSON(i){return super.fromJSON(i),i.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(i,o){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let s=this;i.color!==void 0&&(s.color=Ye(i.color,o)),i.intensity!==void 0&&(s.intensity=i.intensity),i.depth!==void 0&&(s.shadow.camera.far=i.depth,s.shadow.needsUpdate=!0),i.shadows!==void 0&&(this.castShadow=i.shadows),i.helper!==void 0&&(this.enableHelper=i.helper,s.gizmos.shadowmap.visible=i.helper)}return this}};var wo=new Ft,Kl=new Ft,Dr=class extends xr(Kt(FS),da){constructor(e=window.innerWidth,r=window.innerHeight,i=45,o,s=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=ci.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=r,this.orthoCamera=new jS(e*-.5,e*.5,r*.5,r*-.5,o!=null?o:-5e4,s),this.perspCamera=new US(i,e/r,o!=null?o:50,s),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 i=new Dr().fromState(r);return i.enableHelper=!0,i.objectHelper.update(),i.uuid=e,i}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(wo),this.targetOffset=wo.distanceTo(e)}getTarget(e=new Ft){return this.getWorldDirection(Kl),this.getWorldPosition(wo),Kl.multiplyScalar(this.targetOffset),e.copy(wo).add(Kl),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(wo),wo.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new kS),r=new Ft(0,0,1).applyQuaternion(e),i=new Ft().copy(Od.DefaultUp);this.isUpVectorFlipped&&i.negate(),i.applyQuaternion(e);let o=new Ft().copy(Od.DefaultUp).projectOnPlane(r),s=new Ft().crossVectors(o,i).dot(r)>=0?1:-1;this.angleOffsetFromUp=o.angleTo(i)*s}getViewFrontToObject(e){let r=e.getWorldPosition(new Ft),o=e.getWorldDirection(new Ft).multiplyScalar(this.targetOffset);return{position:r.clone().add(o),target:r}}getViewToObject(e){let r=e.getWorldPosition(new Ft),o=this.getWorldDirection(new Ft).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,i,o,s,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,i,o,s,a):this.orthoCamera.setViewOffset(e,r,i,o,s,a)}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},i={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=i.near,this.perspCamera.far=i.far,this.updateProjectionMatrix(),this}toJSON(e){let r=super.toJSON(e),i=r.object;return i.objectType="CombinedCamera",i.cameraType=this.cameraType,i.targetOffset=this.targetOffset,i.isUpVectorFlipped=this.isUpVectorFlipped,i.angleOffsetFromUp=this.angleOffsetFromUp,i.left=this.left,i.right=this.right,i.top=this.top,i.bottom=this.bottom,this.view!==null&&(i.view=Object.assign({},this.view)),i.zoomOrtho=this.orthoCamera.zoom,i.nearOrtho=this.orthoCamera.near,i.far=this.far,i.aspect=this.aspect,i.fov=this.fov,i.focus=this.focus,i.filmGauge=this.filmGauge,i.filmOffset=this.filmOffset,i.zoomPersp=this.perspCamera.zoom,i.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 i=this.getWorldPosition(new Ft),o=new Ft().fromArray(e.orbitControlsTarget);this.targetOffset=o.distanceTo(i)}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 ji(r,e)}fromCameraState(e){let{orthographic:r,perspective:i}=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)),i!==void 0&&(i.near!==void 0&&(this.perspCamera.near=i.near),i.fov!==void 0&&(this.perspCamera.fov=i.fov),i.zoom!==void 0&&(this.perspCamera.zoom=i.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 W(P(P({},super.toState(e)),this.toCameraState(e)),{type:this.cameraType})}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};import{Group as HS}from"three";var _r=class extends xr(Kt(HS),vo){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,r){let i=new _r().fromState(r);return i.uuid=e,i.enableHelper=!0,i.objectHelper.update(),i}toJSON(e){let r=super.toJSON(e);return r.object.objectType="EmptyObject",r}};import{DirectionalLight as qS,CameraHelper as fa}from"three";var Co=class extends xr(Kt(qS),bo){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=1,i.far=2500;let o=new fa(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,r,i){let o=new Co().fromState(r,i);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof fa&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof fa&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof fa&&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),i=r.object;return i.objectType="LightDirectional",i.color=this.color.getHex(),i.intensity=this.intensity,i.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,i=e.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.left=i.left,r.right=i.right,r.top=i.top,r.bottom=i.bottom,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromDirectionalLightState(e,r){let i=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&&Xh(this,e.size),i&&this.update(),this}fromState(e,r){return super.fromState(e),this.fromDirectionalLightState(e,r),this}};import{PointLight as WS,Vector3 as ya,Box3 as $S,Box3Helper as ga,Color as JS}from"three";var Lo=class extends xr(Kt(WS),So){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let o=new ya(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new ya(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),a=new $S(o,s),l=new ga(a,new JS(16755200));l.visible=!1,this._gizmos.shadowmap=l,this.update()}static createFromState(e,r,i){let o=new Lo().fromState(r,i);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ga&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ga&&(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 ga){let i=this.shadow.camera,o=new ya(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new ya(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);r.box.set(o,s),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),i=r.object;return i.objectType="LightPoint",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.decay=this.decay,i.shadow=this.shadow.toJSON(),r}fromJSON(e){var o,s;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((s=e.shadow.mapSize)!=null?s:[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let r=this.shadow.camera,i=e.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.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 KS,CameraHelper as xa,MathUtils as YS,Vector3 as Dd,Quaternion as XS}from"three";var Id=new Dd,Pd=new Dd,Ad=new XS,To=class extends xr(Kt(KS),Cn){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let i=this.shadow.camera;i.fov=YS.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let o=new xa(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,r,i){let o=new To().fromState(r,i);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof xa&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof xa&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof xa&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),Pd.setFromMatrixPosition(this.matrixWorld),Ad.setFromRotationMatrix(this.matrixWorld),Id.copy(this.up).applyQuaternion(Ad).negate().multiplyScalar(this.distance),this.target.position.copy(Pd).add(Id),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),i=r.object;return i.objectType="LightSpot",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.angle=this.angle,i.decay=this.decay,i.penumbra=this.penumbra,i.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,i=e.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.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 No=class extends at{constructor(e,r=new Vt){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 Mo=class extends No{constructor(e,r=new Vt){super(e,r);this.objectType="NonParametric"}toJSON(e){let r=super.toJSON(e);return r.object.objectType="NonParametric",r}};import{DoubleSide as ZS,Mesh as QS,MeshBasicMaterial as ew,ShapeBufferGeometry as tw,Vector2 as rw,Vector3 as iw}from"three";import{FontLoader as ow}from"three/examples/jsm/loaders/FontLoader.js";var Xe=class extends QS{constructor({char:e,originalChar:r,fontFamily:i,letterSpacing:o,fontSize:s,LOD:a=16},l=new ew({color:0,opacity:1,visible:!0,transparent:!0,side:ZS})){let c=Xe.loadChar(e,i,a);super(c.geometry,l);this.char=e,this.originalChar=r!=null?r:e,this.fontFamily=i,this.letterSpacing=o,this.fontSize=s,this.LOD=a,this.resolution=c.resolution,this.glyphsHa=c.glyphsHa,this.localPosition=new rw,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 Xe._fontPath}static set FONTS_PATH(e){Xe._fontPath=e}updatePosition(e,r){this.localPosition.copy(e);let i=new iw(this.localPosition.x,-this.localPosition.y,0);this.position.copy(i).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=Xe.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=Xe.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=Xe.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 Xe(e).copy(this)}static loadFont(e){return new Promise(function(r,i){Xe.fontCache[e]?r(Xe.fontCache[e]):new ow().load(Xe.FONTS_PATH+e+".json",s=>{Xe.fontCache[e]=s,r(s)},void 0,i)})}static loadChar(e,r,i){if(Xe.charCache[e]){if(Xe.charCache[e][i]&&Xe.charCache[e][i].fontFamily===r)return Xe.charCache[e][i]}else Xe.charCache[e]={};let o=Xe.fontCache[r],s=o.generateShapes(e,1);return Xe.charCache[e][i]={geometry:new tw(s,i),fontFamily:r,resolution:o.data.resolution,glyphsHa:o.data.glyphs[e].ha},Xe.charCache[e][i]}},Mt=Xe;Mt.charCache={},Mt.fontCache={},Mt._fontPath="/_assets/_fonts/";import{DoubleSide as va,MeshBasicMaterial as Bd,Vector3 as Ed,Object3D as nw}from"three";import{Vector2 as _d}from"three";var ba=new _d,ti=class{constructor(t,e,r){this.message=[];this.endLine=!0;this.yLinePos=t,this.lineHeight=e,this.maxCharSize=r,this.nextChar3DPos=new _d(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,i=this.message.length;r<i;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,i;for(i=t;i>=0;i-=1)if(this.message[i].char===" "){r=!1,e.length===0&&(i-=1,e.splice(0,0,this.message[i]));break}else e.splice(0,0,this.message[i]);return r?e=[]:this.message.splice(i+1,e.length),e}getWord(t=0,e=1){let r=[],i=t;for(i=t;;i+=e){if(!this.message[i]||this.message[i].char===" "){r.length===0&&this.message[i]&&(r.push(this.message[i]),this.message.splice(i,1));break}e>0?(r.push(this.message[i]),this.message.splice(i,1),i-=e):(r.splice(0,0,this.message[i]),this.message.splice(i,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,i=t;for(;i>=0&&i<this.message.length;){if(this.message[i].char===" "){r===0&&(r=this.message[i].charSize);break}r+=this.message[i].charSize,i+=e}return(i<0||i>=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 i=e;i<=r;i+=1)this.message[i].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,i,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){ba.set(e,r);let i=this.message.length;for(let o=0;o<i;o++)this.message[o].updatePosition(this.message[o].localPosition.add(ba),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 i=this.countSpaces();if(i===0){this.offsetCharacters(e,0,r);return}let o=t/i,s=0;for(let a=0;a<this.message.length;a++)this.message[a].char===" "&&(s+=o),ba.set(s,r),this.message[a].updatePosition(this.message[a].localPosition.add(ba),e)}clone(){let t=new ti(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 Yl=class extends at{constructor(e,r=new mt({transparent:!0,opacity:1,visible:!1,side:va})){super(e,r);this.objectType="TextFrame";this.charContainer=new nw,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 Ed(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,r,i){let o=$s.create({parameters:{width:r.width,height:r.height}}),s=new Yl(o).fromState(r,i);return s.uuid=e,s}async updateText(e){this.clearText();let r=this.userData.textFrame,i=r.fontFamily;await Mt.loadFont(i),r.text=e;let o=r.textOrigin,s=new Bd({visible:r.visible,transparent:!0,side:va}),a=e.split(`
958
+ `),l=0;this.userData.textFrame.textLines=a.map((c,p)=>{let u=new ti(l,r.lineHeight,r.fontSize);return u.message=c.split("").map(h=>{let m={char:h,fontFamily:i,letterSpacing:r.letterSpacing,fontSize:r.fontSize,LOD:16},f=s.clone();f.color=r.hexColor,f.opacity=r.opacity;let L=new Mt(m,f);return u.addChar3D(L,o),this.charContainer.add(L),L}),l+=u.maxCharSize*u.lineHeight,u}),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 i=[];if(super.raycast(e,i),i.length>0){r.push(i[0]);return}let o=[];for(let s=0,a=this.charContainer.children.length;s<a;++s)if(this.charContainer.children[s]instanceof Mt&&(e.intersectObject(this.charContainer.children[s],!1,o),o.length>0)){o[0].object=this,r.push(o[0]);return}}updateGeometry(e){var p,u,h,m;let r=this.userData,i=this.geometry.userData,o=i.parameters.width,s=i.parameters.height,a=(u=(p=e.parameters)==null?void 0:p.width)!=null?u:o,l=(m=(h=e.parameters)==null?void 0:h.height)!=null?m:s,c=r.textFrame;super.updateGeometry(e),c.maxLineSize=a,c.textOrigin.set(-.5*a,.5*l,0),l!==s?(this.checkOverFlow(),this.checkCapacity()):a!==o&&(o<a?this.checkCapacity():o>a&&this.checkOverFlow())}checkOverFlow(e=0){let r=this.userData,i=r.textFrame.textOrigin,o=r.textFrame.textLines;for(let s=e;s<o.length;s++){o[s].updateYLinePos(this.getNewLinePosition(s)),o[s].fullUpdate(i);let a=[];for(;o[s].checkOverFlow(r.textFrame.maxLineSize);)o[s].containSpaceOverFlow()?a.unshift(o[s].getWord(o[s].message.length-1,-1)):a.unshift(o[s].popChar());if(a.length>0){o[s+1]===void 0?(o[s].isEndLine(!1),this.createTextLine()):o[s].endLine&&(this.createTextLine(s+1),o[s].isEndLine(!1),o[s+1].isEndLine(!0));let l=0;for(let c=0;c<a.length;c+=1)for(let p=0;p<a[c].length;p+=1)o[s+1].addChar3D(a[c][p],i,l),l+=1;o[s+1].fullUpdate(i)}o[s].fullUpdate(i)}this.textFullUpdate(e)}checkCapacity(e=0){let r=this.userData,i=r.textFrame.textOrigin,o=r.textFrame.maxLineSize,s=r.textFrame.textLines;for(let a=e;a<s.length;a+=1)if(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(i),!!s[a-1])for(;!s[a-1].endLine;){let l,c=s[a-1].spaceLeft(o);if(s[a].wordSize(0,1)<=c){s[a].containSpace()?l=s[a].getWord(0,1):l=s[a].popChar(0);for(let p=0;p<l.length;p+=1)l[p]&&s[a-1].addChar3D(l[p],i)}else{s[a].isEmpty()?(s[a].endLine&&s[a-1].isEndLine(!0),s.splice(a,1),a-=1):(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(i));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let i=this.userData.textFrame;i.textLines.splice(e,0,new ti(this.getNewLinePosition(e),i.lineHeight,i.fontSize))}textFullUpdate(e=0){let i=this.userData.textFrame,o=i.textLines,s=this.getVerticalAlignmentOffSet();for(let a=e;a<o.length;a++)o[a].updateYLinePos(this.getNewLinePosition(a)),o[a].fullUpdate(i.textOrigin),o[a].alignText(i.textOrigin,i.maxLineSize,i.horizontalAlignment,i.verticalAlignment,s)}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 i=this.userData.textFrame.textLines,o=0;for(let s=0;s<e;s+=1)o+=i[s].maxCharSize*i[s].lineHeight;return o}updateColor(e){var o;let r=this.userData;r.textFrame.hexColor=e;let i=r.textFrame.textLines;for(let s=0;s<i.length;s++){let a=i[s].message;for(let l=0;l<a.length;l++){let c=a[l].material;(o=c.color)!=null&&o.isColor&&(c.color=e)}}}updateOpacity(e){let r=this.userData;r.textFrame.opacity=e;let i=r.textFrame.textLines;for(let o=0;o<i.length;o++){let s=i[o].message;for(let a=0;a<s.length;a++){let l=s[a].material;l.opacity=e}}}updateVisible(e){let r=this.userData;r.textFrame.visible=e;let i=r.textFrame.textLines;for(let o=0;o<i.length;o++){let s=i[o].message;for(let a=0;a<s.length;a++){let l=s[a].material;l.visible=e}}}async updateFontFamily(e){await Mt.loadFont(e);let i=this.userData.textFrame,o=i.textLines;i.fontFamily=e;for(let s=0;s<o.length;s++){let a=o[s].message;for(let l=0;l<a.length;l++)a[l].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let i=this.userData.textFrame,o=i.textLines,s=i.fontSize;i.fontSize=e;for(let a=0;a<o.length;a++)o[a].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let i=this.userData.textFrame;await Mt.loadFont(i.fontFamily);let o=i.textLines;switch(i.textTransform=e,e){case 2:for(let s=0;s<o.length;s++){let a=o[s].message;for(let l=0;l<a.length;l++)o[s].message[l].updateChar(a[l].char.toUpperCase())}break;case 3:for(let s=0;s<o.length;s++){let a=o[s].message;for(let l=0;l<a.length;l++)o[s].message[l].updateChar(a[l].char.toLowerCase())}break;default:for(let s=0;s<o.length;s++){let a=o[s].message;for(let l=0;l<a.length;l++)o[s].message[l].updateChar(a[l].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let r=this.userData,i=r.textFrame.textLines;r.textFrame.letterSpacing=e;for(let o=0;o<i.length;o++){let s=i[o].message;for(let a=0;a<s.length;a++)s[a].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let r=this.userData;r.textFrame.LOD=e;let i=r.textFrame.textLines;for(let o=0;o<i.length;o++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let r=this.userData,i=r.textFrame.textLines;r.textFrame.lineHeight=e;for(let o=0;o<i.length;o++)i[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),i=r.object;i.objectType="TextFrame";let s=this.userData.textFrame.textLines.map(a=>{let l=a.message.map(c=>({char:c.char,originalChar:c.originalChar,fontFamily:c.fontFamily,letterSpacing:c.letterSpacing,fontSize:c.fontSize,LOD:c.LOD}));return{align:a.align,endLine:a.endLine,lineHeight:a.lineHeight,maxCharSize:a.maxCharSize,yLinePos:a.yLinePos,message:l}});return i.userData.textFrame.textLinesData=s,r}async fromJSONasync(e){if(super.fromJSON(e),e.userData!==void 0){let r=e.userData.textFrame;await Mt.loadFont(r.fontFamily),r.textOrigin=new Ed(r.textOrigin.x,r.textOrigin.y,r.textOrigin.z);let i=new Bd({color:r.hexColor,opacity:r.opacity,visible:r.visible,transparent:!0,side:va});r.textLinesData&&(r.textLines=r.textLinesData.map((o,s)=>{let a=new ti(Number(o.yLinePos),Number(o.lineHeight),Number(o.maxCharSize)),l=o.message.map((c,p)=>{if(c.char===void 0){let m=r.textLines[s].message[p];if("geometries"in m){let f=m.geometries[0].userData.parameters;Object.assign(c,{LOD:f.lod,char:f.char,fontFamily:f.fontFamily,fontSize:f.fontSize,letterSpacing:f.letterSpacing,originalChar:f.char})}}let u={char:c.char,fontFamily:c.fontFamily,letterSpacing:Number(c.letterSpacing),fontSize:Number(c.fontSize),LOD:c.LOD},h=new Mt(u,i.clone());return a.addChar3D(h,r.textOrigin),this.charContainer.add(h),h});return a.message=l,a}),this.userData.textFrame=r),this.textFullUpdate()}return this}fromTextFrameData(e,r){if(e.color!==void 0){let i=Ye(e.color,r);this.updateColor(i),this.updateOpacity(i.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,i=new _r;i.name="Text Shape";let o=Mt.fontCache[e];for(let s of this.charContainer.children)s instanceof Mt&&o.generateShapes(s.char,1).forEach(a=>{let l=new Me().fromShape(a);l.applyScale(s.scale.x,s.scale.y);let c=ut.create({shape:l}),p=new mt({side:va});p.color=r;let u=new ei(c,p);u.name=s.char,u.position.copy(s.position),u.rotation.copy(s.rotation),i.attach(u)});return i}},vi=Yl;vi.VerticalAlign=Ka,vi.HorizontalAlign=Ja,vi.TextTransform=Ya;import{HemisphereLight as vw,Scene as Sw,Vector3 as ww,Color as Kd,Fog as Cw,Box3 as Lw}from"three";import{BufferGeometryLoader as sw}from"three";function Gd(n,t){return aw(n)}function aw(n){let t={parameters:n,type:n.type};if(n.type==="VectorGeometry"){let r=Me.createFromState(n.shape,n.width,n.height);t.shape=r}else n.type==="NonParametricGeometry"&&(n.data.groups&&n.data.groups.forEach(r=>{var i;return r.materialIndex=Math.max((i=r.materialIndex)!=null?i:0,0)}),t.geometry=new sw().parse(n));let e;try{e=en(t)}catch(r){console.error(r)}if(!e){let r=Me.createFromState(Yi.defaultData(),100,100);t.shape=r,e=en(t)}return e}import{Box3 as lw,Matrix4 as Si,Sphere as Vd,Vector3 as cw}from"three";var jd=ym(Rd());var Xl;Js.then(n=>{Xl=n});var Ud=new Si,pw=new Si,uw=new Si,or=new lw,ri=new cw,hw=new Si,dw=new Si,Oo=class extends at{constructor(e,r,i,o=new Vt){super(i!=null?i:r,o);this.subdivPointer=e;this.originalGeometry=r;this.subdividedGeometry=i;this.objectType="SubdivObject";this.hiddenMatrixOld=new Si;this.smoothShading=!0;this.matrixWorldRigid=new Si;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,r,i){let{subdivPointer:o,originalGeometry:s,subdividedGeometry:a}=zt.build(r.geometry,void 0,void 0,!r.flatShading),l=wn(r.material,i),c=new Oo(o,s,a||void 0,l);return c.calcBoundingBox(),c.freeSubdivPointer(),c.uuid=e,c.fromState(r),c}shallowClone(e){return new Mo(this.geometry,this.material).shallowCopy(this,e)}toJSON(e){let r=super.toJSON(e);return r.object.objectType="SubdivObject",r}buildFromStore(e){var s,a,l;let{originalGeometry:r,subdividedGeometry:i,subdivPointer:o}=zt.build(e,this.subdivPointer,void 0,this.smoothShading,this.shearScale);if(this.subdivPointer=o,r!==void 0&&((s=this.originalGeometry)==null||s.dispose(),this.originalGeometry=r),i!==void 0&&((a=this.subdividedGeometry)==null||a.dispose(),this.subdividedGeometry=i!=null?i:void 0),this.geometry=(l=this.subdividedGeometry)!=null?l:this.originalGeometry,this.cloner)for(let c of this.cloner.children)c.geometry=this.geometry;e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){zt.buildLevel(this.subdivPointer,!0,this.smoothShading,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&zt.buildLevel(this.subdivPointer,!1,this.smoothShading,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){var e;this.originalGeometry.dispose(),this.originalGeometry=zt.buildLevel(this.subdivPointer,!0,this.smoothShading),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=zt.buildLevel(this.subdivPointer,!1,this.smoothShading)),this.geometry=(e=this.subdividedGeometry)!=null?e:this.originalGeometry}raycast(e,r){var i;this.geometry=this.originalGeometry,at.prototype.raycast.call(this,e,r),this.geometry=(i=this.subdividedGeometry)!=null?i: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:i,v:o,q:s}=(0,jd.SVD)(r),a=Ud.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),l=pw.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),c=uw.copy(l).transpose();this.shearScale=hw.makeScale(s[0],s[1],s[2]).multiply(c).premultiply(l),this.shearScaleInv=dw.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,c),s.every(p=>Math.abs(s[0]-p)<.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 Vd);let r=e.attributes.position,i=e.boundingSphere.center;or.setFromBufferAttribute(r),or.getCenter(i),e.boundingSphere.radius=i.distanceTo(or.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),or.getSize(ri);let o={width:ri.x,height:ri.y,depth:ri.z};return this.geometry.userData.parameters=o,o}updateBoundingBox(e){let r=this.originalGeometry;or.min.set(e[0],e[2],e[4]),or.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(or.min.applyMatrix4(this.shearScaleInv),or.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new Vd);let i=r.boundingSphere.center;or.getCenter(i),r.boundingSphere.radius=i.distanceTo(or.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),or.getSize(ri);let o={width:ri.x,height:ri.y,depth:ri.z};return this.geometry.userData.parameters=o,o}freeSubdivPointer(){this.subdivPointer&&(Xl.free_bvh(this.subdivPointer),Xl.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,Fd(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Fd(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters=P({},e.parameters)}};function Fd(n,t,e,r){let i=n.position.array,o=n.normal.array,s=Ud.makeScale(t,e,r).invert().elements,a,l,c;for(var p=0,u=i.length;p<u;p+=3)i[p]*=t,i[p+1]*=e,i[p+2]*=r,a=o[p],l=o[p+1],c=o[p+2],o[p]=s[0]*a+s[4]*l+s[8]*c,o[p+1]=s[1]*a+s[5]*l+s[9]*c,o[p+2]=s[2]*a+s[6]*l+s[10]*c}import{BackSide as mw,DoubleSide as fw,FrontSide as yw}from"three";function kd(n,t){t.flatShading!==void 0&&(n.flatShading=t.flatShading,n.needsUpdate=!0),t.wireframe!==void 0&&(n.wireframe=t.wireframe),t.side!==void 0&&(t.side===0?n.side=yw:t.side===1?n.side=mw:n.side=fw)}function gw(n,t){if(Array.isArray(n.material))for(let e of n.material)kd(e,t);else{let e=n.material;kd(e,t)}n.objectType==="SubdivObject"&&t.flatShading!==void 0&&(n.material.flatShading=!1,n.smoothShading=!t.flatShading,n.updateMesh())}function Hd(n,t,e){let r;if(t.geometry.type==="SubdivGeometry")r=Oo.createFromState(n,t,e);else{let i=Gd(t.geometry,e),o="materials"in t?Sd(t.materials,e):wn(t.material,e);As.is2DParametricMesh(i.userData.type)?r=new xo(i,o):(i==null?void 0:i.userData.type)==="VectorGeometry"?r=new ei(i,o):t.geometry.type==="NonParametricGeometry"?r=new Mo(i,o):r=new No(i,o),r.uuid=n,r.fromState(t)}return gw(r,t),r}function qd(n,t,e){return t.type==="Mesh"?Hd(n,t,e):t.type==="TextFrame"?vi.createFromState(n,t,e):t.type==="Empty"?_r.createFromState(n,t):t.type==="PointLight"?Lo.createFromState(n,t,e):t.type==="SpotLight"?To.createFromState(n,t,e):t.type==="DirectionalLight"?Co.createFromState(n,t,e):Ui.is(t.type)?Dr.createFromState(n,t):(console.error(t),new _r)}function xw(n,t){t.uniforms[`f${t.id}_transmissionSamplerMap`].value=n.texture,t.uniforms[`f${t.id}_transmissionDepthMap`].value=n.depthTexture}function Wd(n,t,e){if(!e.userData.layers)return!1;let r=!1,i=e.userData.layers.getLayersOfType("transmission");return i.length>0?(t.layers.set(3),r=!0,n!==void 0&&i.forEach(o=>xw(n,o))):t.layers.set(0),r}function $d(n,t){let e=!1;return t.traverseEntity(r=>{if(r instanceof at)if(Array.isArray(r.material))for(let i=0;i<r.material.length;i++)Wd(n,r,r.material[i])&&(e=!0);else Wd(n,r,r.material)&&(e=!0)}),e}function Jd(n,t){"material"in n&&bw(n.material,t),"geometry"in n&&n.geometry.dispose()}function bw(n,t){oc(n).forEach(e=>{t.isSharedMaterial(e)||e.dispose()})}var Yd=new ww,Zl=class extends Ys(Sw){constructor(e,r){super();this.objectType="Scene";this.alpha=1;this.backupFog=new Cw(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new Kd(1,0,0);this.bgColor=new Kd(1,1,1);this.entityByUuid={};this.ambientLight=new vw(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=$d(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(Ye(e.backgroundColor,r)),this.updateFog(e.fog,r),this.updateAmbientLight(e.environment.ambientLight,r),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let i=this.find(e.publish.playCamera);i instanceof Dr&&this.switchActiveCamera(i)}}clearScene(e){this.traverseEntity(r=>{Jd(r,e)});for(let r of this.children)Jt(r)&&r.removeFromParent()}resetAfterClear(e,r){this.init(e,r)}createPersonalCamera(){let e=Dr.createFromState(Zl.PERSONAL_CAMERA_ID,W(P({},_s.defaultData),{name:"Personal Camera"}));return e.enableHelper=!1,e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let r=[],i=o=>{for(let s of o.children)Jt(s)&&!s.raycastLock&&s.visible&&((io(s)||Or(s)&&s.enableHelper&&s.objectHelper.parent)&&e.intersectObject(s,!1,r),i(s))};return i(this),r}traverseEntity(e){for(let r of this.children)Jt(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=Ye(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){Yh(this.ambientLight,e,r),e.groundColor!==void 0&&(this.ambientLight.groundColor=Ye(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,i){for(let o of e)this.createChildObject(o.id,o.data,o.children,r,i)}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,i,o,s){let a=qd(e,r,s);return a&&(this.entityByUuid[e]=a,o.add(a),this.createChildrenObjects(i,a,s)),a}getCenter(e){let r=[];for(let o=0,s=e.length;o<s;++o){let{id:a,recursive:l}=e[o],c=this.find(a),p=l?c.recursiveBBox:c.singleBBox;r.push(...p.vertices)}let i=new Lw;return i.setFromPoints(r),i.getCenter(Yd),Yd}copyMatrixWorld(e,r){if(e===null){r.identity();return}let i=this.find(e);i?r.copy(i.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){var o;if(e===null){r.identity();return}let i=(o=this.find(e))==null?void 0:o.parent;i?r.copy(i.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof at)if(Array.isArray(r.material))for(let i=0;i<r.material.length;i++)e(r.material[i]);else e(r.material)})}updateCanvasSize(e,r){this.activeCamera.setViewplaneSize(e,r);let i,o;e>=r?(i=r/e,o=1):(i=1,o=e/r),this.traverseMaterial(s=>{s.layersList.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=i,l.uniforms[`f${l.id}_aspectRatio`].value.y=o})})}},Ln=Zl;Ln.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{DRACOLoader as Tw}from"three/examples/jsm/loaders/DRACOLoader.js";var ii;function Nw(){return ii||(ii=new Tw,ii.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),ii.decoderPending}async function Mw(n){if(ii){let t={attributeIDs:ii.defaultAttributeIDs,attributeTypes:ii.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await ii.decodeGeometry(new Int8Array(n).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,i])=>({name:r,itemSize:i.itemSize,array:i.array}))}}return null}async function Xd(n){let[t,e]=Da(Ns.deserialize(new Uint8Array(n))),r=[];t.scene.objects.traverse((i,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&r.push(o)}),r.length&&await Nw();for(let i of r){let o=await Mw(Ba(i.geometry.data.draco));if(o){o.index&&(i.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let s={};o.attributes.forEach(({name:a,array:l,itemSize:c})=>{s[a]={array:l,itemSize:c,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=s,i.geometry.data.draco=void 0}}return e.result().data}import{WebGLRenderTarget as Ow,LinearMipmapLinearFilter as Iw,LinearFilter as Pw,ClampToEdgeWrapping as Zd,DepthTexture as Aw}from"three";var Qd=new mt,wa=class extends Pt{},Ca=class{constructor(t){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new Ow(2048,2048,{generateMipmaps:!0,minFilter:Iw,magFilter:Pw,wrapS:Zd,wrapT:Zd}),this.transmissionRenderTarget.depthTexture=new Aw(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,Hl(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===Qd}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){var e;return(e=this.materials[t])!=null?e:Qd}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 wa(e.r,e.g,e.b,e.a):this.colors[t]=new wa(e.r,e.g,e.b,1),!1)}updateColor(t,e){var r,i,o,s;if(this.colors[t]){let a=this.colors[t];return this.colors[t].r=(r=e.r)!=null?r:a.r,this.colors[t].g=(i=e.g)!=null?i:a.g,this.colors[t].b=(o=e.b)!=null?o:a.b,this.colors[t].a=(s=e.a)!=null?s:a.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 Gk}from"three";import{mergeBufferGeometries as Vk}from"three/examples/jsm/utils/BufferGeometryUtils.js";function em(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}import{Color as tm,ShaderLib as Dw}from"three";function rm(n){let t=new Set;return n.traverse(e=>{if(io(e))if(Qe(e.material))e.material.forEach(r=>{let i=r;t.has(i)||t.add(i)});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);_w(e)?(Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new tm,specularColor:new tm}),e.onBeforeCompile=(i,o)=>{r&&r(i,o),i.uniforms=Object.assign(Dw.physical.uniforms,i.uniforms),e.userData.layers.getLayersOfType("transmission").forEach(s=>{i.uniforms.transmissionSamplerMap.value&&(s.uniforms["f"+s.id+"_transmissionSamplerMap"].value=i.uniforms.transmissionSamplerMap.value,s.uniforms["f"+s.id+"_transmissionSamplerSize"].value=i.uniforms.transmissionSamplerSize.value)})}):Bw(e)||(e.onBeforeCompile=(i,o)=>{r&&r(i,o),e.transparent=!1})}),n}function _w(n){return n.userData.layers.getLayersOfType("transmission").length>0}function Bw(n){let t=n.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 im(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function om(n){let t=[],e=(r,i=0)=>{let o=i>0?r+i:r;return t.includes(o)?e(r,i+1):o};return n.traverse(r=>{if(t.includes(r.name)){let i=r.name,o=e(r.name);if(r.name=o,r.isMesh){let s=r;s.material instanceof Array?s.material.forEach(a=>{a.name=a.name.replace(i,o)}):s.material.isAsset||(s.material.name=s.material.name.replace(i,o))}}t.push(r.name)}),n}import{mergeBufferGeometries as Ew}from"three/examples/jsm/utils/BufferGeometryUtils";function nm(n){let t=[];return n.traverse(e=>{e instanceof mi&&t.push(e)}),t.forEach(e=>{let r=e.object,i=e.children,o=i.map(a=>{a.updateMatrix();let l=a.geometry.clone().applyMatrix4(a.matrix);return a.matrix.determinant()<0&&em(l),l}),s=Ew(e.parameters.hideBase?o:[r.geometry,...o]);r.geometry=s,r.material=i[0].material,r.remove(e)}),n}var Ql=class extends zw{load(t,e,r,i=console.error){let o=new Gw(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(s);e(a)}catch(a){i(a)}},r,i)}async parse(t){let e=await Xd(t),r=new Ca(e.shared);Object.values(r.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let i=new Ln(e.scene,r);i.remove(i.personalCamera),e.scene.environment.ambientLight.enabled||i.remove(i.ambientLight);let o=e.scene.publish.playCamera;if(o){let s=i.find(o);s&&Kh(s)&&Object.assign(s,{makeDefault:!0})}return i=nm(i),i=rm(i),i=im(i),i=om(i),i}};export{Ql as default};