@splinetool/loader 1.0.70 → 1.0.71

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,11 +1,11 @@
1
- var KS=Object.create;var Cl=Object.defineProperty;var QS=Object.getOwnPropertyDescriptor;var ZS=Object.getOwnPropertyNames;var JS=Object.getPrototypeOf,e1=Object.prototype.hasOwnProperty;var t1=(n,r,e)=>r in n?Cl(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e;var Dn=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),r1=(n,r)=>{for(var e in r)Cl(n,e,{get:r[e],enumerable:!0})},o1=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of ZS(r))!e1.call(n,o)&&o!==e&&Cl(n,o,{get:()=>r[o],enumerable:!(t=QS(r,o))||t.enumerable});return n};var hi=(n,r,e)=>(e=n!=null?KS(JS(n)):{},o1(r||!n||!n.__esModule?Cl(e,"default",{value:n,enumerable:!0}):e,n));var En=(n,r,e)=>(t1(n,typeof r!="symbol"?r+"":r,e),e);var ax=Dn((lp,ix)=>{(function(n,r){typeof lp=="object"?ix.exports=r():typeof define=="function"&&define.amd?define(r):n.Alea=r()})(lp,function(){"use strict";return n.importState=function(e){var t=new n;return t.importState(e),t},n;function n(){return function(e){var t=0,o=0,i=0,a=1;e.length==0&&(e=[+new Date]);var s=r();t=s(" "),o=s(" "),i=s(" ");for(var l=0;l<e.length;l++)t-=s(e[l]),t<0&&(t+=1),o-=s(e[l]),o<0&&(o+=1),i-=s(e[l]),i<0&&(i+=1);s=null;var c=function(){var u=2091639*t+a*23283064365386963e-26;return t=o,o=i,i=u-(a=u|0)};return c.next=c,c.uint32=function(){return c()*4294967296},c.fract53=function(){return c()+(c()*2097152|0)*11102230246251565e-32},c.version="Alea 0.9",c.args=e,c.exportState=function(){return[t,o,i,a]},c.importState=function(u){t=+u[0]||0,o=+u[1]||0,i=+u[2]||0,a=+u[3]||0},c}(Array.prototype.slice.call(arguments))}function r(){var e=4022871197,t=function(o){o=o.toString();for(var i=0;i<o.length;i++){e+=o.charCodeAt(i);var a=.02519603282416938*e;e=a>>>0,a-=e,a*=e,e=a>>>0,a-=e,e+=a*4294967296}return(e>>>0)*23283064365386963e-26};return t.version="Mash 0.9",t}})});var dx=Dn((kc,ux)=>{(function(n,r){typeof kc=="object"&&typeof ux<"u"?r(kc):typeof define=="function"&&define.amd?define(["exports"],r):r((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(kc,function(n){"use strict";n.SVD=function(r,e,t,o,i){if(e=e===void 0||e,t=t===void 0||t,i=1e-64/(o=o||Math.pow(2,-52)),!r)throw new TypeError("Matrix a is not defined");var a,s,l,c,u,p,d,h,f,m,y,g,v=r[0].length,O=r.length;if(O<v)throw new TypeError("Invalid matrix: m < n");for(var P=[],S=[],T=[],I=e==="f"?O:v,x=m=d=0;x<O;x++)S[x]=new Array(I).fill(0);for(x=0;x<v;x++)T[x]=new Array(v).fill(0);var _,D=new Array(v).fill(0);for(x=0;x<O;x++)for(a=0;a<v;a++)S[x][a]=r[x][a];for(x=0;x<v;x++){for(P[x]=d,f=0,l=x+1,a=x;a<O;a++)f+=Math.pow(S[a][x],2);if(f<i)d=0;else for(h=(p=S[x][x])*(d=p<0?Math.sqrt(f):-Math.sqrt(f))-f,S[x][x]=p-d,a=l;a<v;a++){for(f=0,s=x;s<O;s++)f+=S[s][x]*S[s][a];for(p=f/h,s=x;s<O;s++)S[s][a]=S[s][a]+p*S[s][x]}for(D[x]=d,f=0,a=l;a<v;a++)f+=Math.pow(S[x][a],2);if(f<i)d=0;else{for(h=(p=S[x][x+1])*(d=p<0?Math.sqrt(f):-Math.sqrt(f))-f,S[x][x+1]=p-d,a=l;a<v;a++)P[a]=S[x][a]/h;for(a=l;a<O;a++){for(f=0,s=l;s<v;s++)f+=S[a][s]*S[x][s];for(s=l;s<v;s++)S[a][s]=S[a][s]+f*P[s]}}m<(y=Math.abs(D[x])+Math.abs(P[x]))&&(m=y)}if(t)for(x=v-1;0<=x;x--){if(d!==0){for(h=S[x][x+1]*d,a=l;a<v;a++)T[a][x]=S[x][a]/h;for(a=l;a<v;a++){for(f=0,s=l;s<v;s++)f+=S[x][s]*T[s][a];for(s=l;s<v;s++)T[s][a]=T[s][a]+f*T[s][x]}}for(a=l;a<v;a++)T[x][a]=0,T[a][x]=0;T[x][x]=1,d=P[x],l=x}if(e){if(e==="f")for(x=v;x<O;x++){for(a=v;a<O;a++)S[x][a]=0;S[x][x]=1}for(x=v-1;0<=x;x--){for(l=x+1,d=D[x],a=l;a<I;a++)S[x][a]=0;if(d!==0){for(h=S[x][x]*d,a=l;a<I;a++){for(f=0,s=l;s<O;s++)f+=S[s][x]*S[s][a];for(p=f/h,s=x;s<O;s++)S[s][a]=S[s][a]+p*S[s][x]}for(a=x;a<O;a++)S[a][x]=S[a][x]/d}else for(a=x;a<O;a++)S[a][x]=0;S[x][x]=S[x][x]+1}}for(o*=m,s=v-1;0<=s;s--)for(var A=0;A<50;A++){for(_=!1,l=s;0<=l;l--){if(Math.abs(P[l])<=o){_=!0;break}if(Math.abs(D[l-1])<=o)break}if(!_){for(u=0,c=l-(f=1),x=l;x<s+1&&(p=f*P[x],P[x]=u*P[x],!(Math.abs(p)<=o));x++)if(d=D[x],D[x]=Math.sqrt(p*p+d*d),u=d/(h=D[x]),f=-p/h,e)for(a=0;a<O;a++)y=S[a][c],g=S[a][x],S[a][c]=y*u+g*f,S[a][x]=-y*f+g*u}if(g=D[s],l===s){if(g<0&&(D[s]=-g,t))for(a=0;a<v;a++)T[a][s]=-T[a][s];break}for(m=D[l],p=(((y=D[s-1])-g)*(y+g)+((d=P[s-1])-(h=P[s]))*(d+h))/(2*h*y),d=Math.sqrt(p*p+1),p=((m-g)*(m+g)+h*(y/(p<0?p-d:p+d)-h))/m,x=l+(f=u=1);x<s+1;x++){if(d=P[x],y=D[x],h=f*d,d*=u,g=Math.sqrt(p*p+h*h),p=m*(u=p/(P[x-1]=g))+d*(f=h/g),d=-m*f+d*u,h=y*f,y*=u,t)for(a=0;a<v;a++)m=T[a][x-1],g=T[a][x],T[a][x-1]=m*u+g*f,T[a][x]=-m*f+g*u;if(g=Math.sqrt(p*p+h*h),p=(u=p/(D[x-1]=g))*d+(f=h/g)*y,m=-f*d+u*y,e)for(a=0;a<O;a++)y=S[a][x-1],g=S[a][x],S[a][x-1]=y*u+g*f,S[a][x]=-y*f+g*u}P[l]=0,P[s]=p,D[s]=m}for(x=0;x<v;x++)D[x]<o&&(D[x]=0);return{u:S,q:D,v:T}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var Hx=Dn((Lp,Rp)=>{(function(n,r){typeof Lp=="object"&&typeof Rp<"u"?Rp.exports=r():typeof define=="function"&&define.amd?define(r):(n=n||self,n.TinyQueue=r())})(Lp,function(){"use strict";var n=function(t,o){if(t===void 0&&(t=[]),o===void 0&&(o=r),this.data=t,this.length=this.data.length,this.compare=o,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)};n.prototype.push=function(t){this.data.push(t),this.length++,this._up(this.length-1)},n.prototype.pop=function(){if(this.length!==0){var t=this.data[0],o=this.data.pop();return this.length--,this.length>0&&(this.data[0]=o,this._down(0)),t}},n.prototype.peek=function(){return this.data[0]},n.prototype._up=function(t){for(var o=this,i=o.data,a=o.compare,s=i[t];t>0;){var l=t-1>>1,c=i[l];if(a(s,c)>=0)break;i[t]=c,t=l}i[t]=s},n.prototype._down=function(t){for(var o=this,i=o.data,a=o.compare,s=this.length>>1,l=i[t];t<s;){var c=(t<<1)+1,u=i[c],p=c+1;if(p<this.length&&a(i[p],u)<0&&(c=p,u=i[p]),a(u,l)>=0)break;i[t]=u,t=c}i[t]=l};function r(e,t){return e<t?-1:e>t?1:0}return n})});var qx=Dn((DW,Vp)=>{"use strict";var eu=Hx();eu.default&&(eu=eu.default);Vp.exports=Wx;Vp.exports.default=Wx;function Wx(n,r,e){r=r||1;for(var t,o,i,a,s=0;s<n[0].length;s++){var l=n[0][s];(!s||l[0]<t)&&(t=l[0]),(!s||l[1]<o)&&(o=l[1]),(!s||l[0]>i)&&(i=l[0]),(!s||l[1]>a)&&(a=l[1])}var c=i-t,u=a-o,p=Math.min(c,u),d=p/2;if(p===0){var h=[t,o];return h.distance=0,h}for(var f=new eu(void 0,bM),m=t;m<i;m+=p)for(var y=o;y<a;y+=p)f.push(new un(m+d,y+d,d,n));var g=SM(n),v=new un(t+c/2,o+u/2,0,n);v.d>g.d&&(g=v);for(var O=f.length;f.length;){var P=f.pop();P.d>g.d&&(g=P,e&&console.log("found best %d after %d probes",Math.round(1e4*P.d)/1e4,O)),!(P.max-g.d<=r)&&(d=P.h/2,f.push(new un(P.x-d,P.y-d,d,n)),f.push(new un(P.x+d,P.y-d,d,n)),f.push(new un(P.x-d,P.y+d,d,n)),f.push(new un(P.x+d,P.y+d,d,n)),O+=4)}e&&(console.log("num probes: "+O),console.log("best distance: "+g.d));var S=[g.x,g.y];return S.distance=g.d,S}function bM(n,r){return r.max-n.max}function un(n,r,e,t){this.x=n,this.y=r,this.h=e,this.d=vM(n,r,t),this.max=this.d+this.h*Math.SQRT2}function vM(n,r,e){for(var t=!1,o=1/0,i=0;i<e.length;i++)for(var a=e[i],s=0,l=a.length,c=l-1;s<l;c=s++){var u=a[s],p=a[c];u[1]>r!=p[1]>r&&n<(p[0]-u[0])*(r-u[1])/(p[1]-u[1])+u[0]&&(t=!t),o=Math.min(o,wM(n,r,u,p))}return o===0?0:(t?1:-1)*Math.sqrt(o)}function SM(n){for(var r=0,e=0,t=0,o=n[0],i=0,a=o.length,s=a-1;i<a;s=i++){var l=o[i],c=o[s],u=l[0]*c[1]-c[0]*l[1];e+=(l[0]+c[0])*u,t+=(l[1]+c[1])*u,r+=u*3}return r===0?new un(o[0][0],o[0][1],0,n):new un(e/r,t/r,0,n)}function wM(n,r,e,t){var o=e[0],i=e[1],a=t[0]-o,s=t[1]-i;if(a!==0||s!==0){var l=((n-o)*a+(r-i)*s)/(a*a+s*s);l>1?(o=t[0],i=t[1]):l>0&&(o+=a*l,i+=s*l)}return a=n-o,s=r-i,a*a+s*s}});var Pv=Dn((gie,wv)=>{"use strict";function cD(n,r){function e(){this.constructor=n}e.prototype=r.prototype,n.prototype=new e}function ai(n,r,e,t){this.message=n,this.expected=r,this.found=e,this.location=t,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,ai)}cD(ai,Error);ai.buildMessage=function(n,r){var e={literal:function(c){return'"'+o(c.text)+'"'},class:function(c){var u="",p;for(p=0;p<c.parts.length;p++)u+=c.parts[p]instanceof Array?i(c.parts[p][0])+"-"+i(c.parts[p][1]):i(c.parts[p]);return"["+(c.inverted?"^":"")+u+"]"},any:function(c){return"any character"},end:function(c){return"end of input"},other:function(c){return c.description}};function t(c){return c.charCodeAt(0).toString(16).toUpperCase()}function o(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+t(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+t(u)})}function i(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+t(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+t(u)})}function a(c){return e[c.type](c)}function s(c){var u=new Array(c.length),p,d;for(p=0;p<c.length;p++)u[p]=a(c[p]);if(u.sort(),u.length>0){for(p=1,d=1;p<u.length;p++)u[p-1]!==u[p]&&(u[d]=u[p],d++);u.length=d}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}function l(c){return c?'"'+o(c)+'"':"end of input"}return"Expected "+s(n)+" but "+l(r)+" found."};function uD(n,r){r=r!==void 0?r:{};var e={},t={svg_path:fs},o=fs,i=function(b){if(!b)return[];for(var w=[],L=0;L<b.length;L++)w=w.concat.apply(w,b[L]);var M=w[0];return M&&M.code=="m"&&(delete M.relative,M.code="M"),w},a=function(b,w){return XS(b,w)},s=/^[Mm]/,l=Ye(["M","m"],!1,!1),c=function(b,w,L){var M=pi(b,[w]);return L&&(M=M.concat(pi(b=="M"?"L":"l",L[1]))),M},u=/^[Zz]/,p=Ye(["Z","z"],!1,!1),d=function(){return pi("Z")},h=/^[Ll]/,f=Ye(["L","l"],!1,!1),m=function(b,w){return pi(b,w)},y=/^[Hh]/,g=Ye(["H","h"],!1,!1),v=function(b,w){return pi(b,w.map(function(L){return{x:L}}))},O=/^[Vv]/,P=Ye(["V","v"],!1,!1),S=function(b,w){return pi(b,w.map(function(L){return{y:L}}))},T=/^[Cc]/,I=Ye(["C","c"],!1,!1),x=function(b,w,L){return{x1:b.x,y1:b.y,x2:w.x,y2:w.y,x:L.x,y:L.y}},_=/^[Ss]/,D=Ye(["S","s"],!1,!1),A=function(b,w){return{x2:b.x,y2:b.y,x:w.x,y:w.y}},N=/^[Qq]/,E=Ye(["Q","q"],!1,!1),B=function(b,w){return{x1:b.x,y1:b.y,x:w.x,y:w.y}},V=/^[Tt]/,j=Ye(["T","t"],!1,!1),R=/^[Aa]/,W=Ye(["A","a"],!1,!1),F=function(b,w,L,M,z,oe){return{rx:b,ry:w,xAxisRotation:L,largeArc:M,sweep:z,x:oe.x,y:oe.y}},k=function(b,w){return{x:b,y:w}},H=function(b){return b*1},$=function(b){return b.join("")*1},J=/^[01]/,Z=Ye(["0","1"],!1,!1),X=function(b){return b=="1"},te=function(){return""},Y=",",ee=tt(",",!1),K=function(b){return b.join("")},q=".",ue=tt(".",!1),le=/^[eE]/,ne=Ye(["e","E"],!1,!1),ce=/^[+\-]/,ae=Ye(["+","-"],!1,!1),he=/^[0-9]/,pe=Ye([["0","9"]],!1,!1),fe=function(b){return b.join("")},ge=/^[ \t\n\r]/,me=Ye([" "," ",`
2
- `,"\r"],!1,!1),C=0,ie=0,De=[{line:1,column:1}],Re=0,Ee=[],Pe=0,bt;if("startRule"in r){if(!(r.startRule in t))throw new Error(`Can't start parsing from rule "`+r.startRule+'".');o=t[r.startRule]}function Me(){return n.substring(ie,C)}function yt(){return Mn(ie,C)}function vt(b,w){throw w=w!==void 0?w:Mn(ie,C),hr([dd(b)],n.substring(ie,C),w)}function An(b,w){throw w=w!==void 0?w:Mn(ie,C),pd(b,w)}function tt(b,w){return{type:"literal",text:b,ignoreCase:w}}function Ye(b,w,L){return{type:"class",parts:b,inverted:w,ignoreCase:L}}function Ar(){return{type:"any"}}function ud(){return{type:"end"}}function dd(b){return{type:"other",description:b}}function vl(b){var w=De[b],L;if(w)return w;for(L=b-1;!De[L];)L--;for(w=De[L],w={line:w.line,column:w.column};L<b;)n.charCodeAt(L)===10?(w.line++,w.column=1):w.column++,L++;return De[b]=w,w}function Mn(b,w){var L=vl(b),M=vl(w);return{start:{offset:b,line:L.line,column:L.column},end:{offset:w,line:M.line,column:M.column}}}function lt(b){C<Re||(C>Re&&(Re=C,Ee=[]),Ee.push(b))}function pd(b,w){return new ai(b,null,null,w)}function hr(b,w,L){return new ai(ai.buildMessage(b,w),b,w,L)}function fs(){var b,w,L,M,z;for(b=C,w=[],L=Ve();L!==e;)w.push(L),L=Ve();if(w!==e)if(L=jt(),L===e&&(L=null),L!==e){for(M=[],z=Ve();z!==e;)M.push(z),z=Ve();M!==e?(ie=b,w=i(L),b=w):(C=b,b=e)}else C=b,b=e;else C=b,b=e;return b}function jt(){var b,w,L,M,z,oe;if(b=C,w=In(),w!==e){for(L=[],M=C,z=[],oe=Ve();oe!==e;)z.push(oe),oe=Ve();for(z!==e?(oe=In(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;){for(L.push(M),M=C,z=[],oe=Ve();oe!==e;)z.push(oe),oe=Ve();z!==e?(oe=In(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e)}L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function In(){var b,w,L,M,z,oe;if(b=C,w=ui(),w!==e){for(L=[],M=C,z=[],oe=Ve();oe!==e;)z.push(oe),oe=Ve();for(z!==e?(oe=Sl(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;){for(L.push(M),M=C,z=[],oe=Ve();oe!==e;)z.push(oe),oe=Ve();z!==e?(oe=Sl(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e)}L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function Sl(){var b;return b=BS(),b===e&&(b=LS(),b===e&&(b=RS(),b===e&&(b=VS(),b===e&&(b=zS(),b===e&&(b=jS(),b===e&&(b=US(),b===e&&(b=HS(),b===e&&(b=qS())))))))),b}function ui(){var b,w,L,M,z,oe,fi;if(b=C,s.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&lt(l)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=kt(),M!==e?(z=C,oe=Ze(),oe===e&&(oe=null),oe!==e?(fi=xh(),fi!==e?(oe=[oe,fi],z=oe):(C=z,z=e)):(C=z,z=e),z===e&&(z=null),z!==e?(ie=b,w=c(w,M,z),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function BS(){var b,w;return b=C,u.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&lt(p)),w!==e&&(ie=b,w=d()),b=w,b}function LS(){var b,w,L,M;if(b=C,h.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&lt(f)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=xh(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function xh(){var b,w,L,M,z,oe;if(b=C,w=kt(),w!==e){for(L=[],M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=kt(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=kt(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function RS(){var b,w,L,M;if(b=C,y.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&lt(g)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=bh(),M!==e?(ie=b,w=v(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function bh(){var b,w,L,M,z,oe;if(b=C,w=di(),w!==e){for(L=[],M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=di(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=di(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function VS(){var b,w,L,M;if(b=C,O.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&lt(P)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=bh(),M!==e?(ie=b,w=S(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function zS(){var b,w,L,M;if(b=C,T.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&lt(I)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=GS(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function GS(){var b,w,L,M,z,oe;if(b=C,w=fd(),w!==e){for(L=[],M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=fd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=fd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function fd(){var b,w,L,M,z,oe;return b=C,w=kt(),w!==e?(L=Ze(),L===e&&(L=null),L!==e?(M=kt(),M!==e?(z=Ze(),z===e&&(z=null),z!==e?(oe=kt(),oe!==e?(ie=b,w=x(w,M,oe),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function jS(){var b,w,L,M;if(b=C,_.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&lt(D)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=FS(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function FS(){var b,w,L,M,z,oe;if(b=C,w=hd(),w!==e){for(L=[],M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=hd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=hd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function hd(){var b,w,L,M;return b=C,w=kt(),w!==e?(L=Ze(),L===e&&(L=null),L!==e?(M=kt(),M!==e?(ie=b,w=A(w,M),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function US(){var b,w,L,M;if(b=C,N.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&lt(E)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=kS(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function kS(){var b,w,L,M,z,oe;if(b=C,w=md(),w!==e){for(L=[],M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=md(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=md(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function md(){var b,w,L,M;return b=C,w=kt(),w!==e?(L=Ze(),L===e&&(L=null),L!==e?(M=kt(),M!==e?(ie=b,w=B(w,M),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function HS(){var b,w,L,M;if(b=C,V.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&lt(j)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=WS(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function WS(){var b,w,L,M,z,oe;if(b=C,w=kt(),w!==e){for(L=[],M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=kt(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=kt(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function qS(){var b,w,L,M;if(b=C,R.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&lt(W)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=$S(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function $S(){var b,w,L,M,z,oe;if(b=C,w=yd(),w!==e){for(L=[],M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=yd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=yd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function yd(){var b,w,L,M,z,oe,fi,xd,Pl,bd,Ol,vd;return b=C,w=vh(),w!==e?(L=Ze(),L===e&&(L=null),L!==e?(M=vh(),M!==e?(z=Ze(),z===e&&(z=null),z!==e?(oe=di(),oe!==e?(fi=Ze(),fi!==e?(xd=Sh(),xd!==e?(Pl=Ze(),Pl===e&&(Pl=null),Pl!==e?(bd=Sh(),bd!==e?(Ol=Ze(),Ol===e&&(Ol=null),Ol!==e?(vd=kt(),vd!==e?(ie=b,w=F(w,M,oe,xd,bd,vd),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function kt(){var b,w,L,M;return b=C,w=di(),w!==e?(L=Ze(),L===e&&(L=null),L!==e?(M=di(),M!==e?(ie=b,w=k(w,M),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function vh(){var b,w;return b=C,w=Ph(),w===e&&(w=Nn()),w!==e&&(ie=b,w=H(w)),b=w,b}function di(){var b,w,L,M;return b=C,w=C,L=gd(),L===e&&(L=null),L!==e?(M=Ph(),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e),w===e&&(w=C,L=gd(),L===e&&(L=null),L!==e?(M=Nn(),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e)),w!==e&&(ie=b,w=$(w)),b=w,b}function Sh(){var b,w;return b=C,J.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&lt(Z)),w!==e&&(ie=b,w=X(w)),b=w,b}function Ze(){var b,w,L,M,z;if(b=C,w=[],L=Ve(),L!==e)for(;L!==e;)w.push(L),L=Ve();else w=e;if(w!==e)if(L=wh(),L===e&&(L=null),L!==e){for(M=[],z=Ve();z!==e;)M.push(z),z=Ve();M!==e?(w=[w,L,M],b=w):(C=b,b=e)}else C=b,b=e;else C=b,b=e;if(b===e){if(b=C,w=C,L=wh(),L!==e){for(M=[],z=Ve();z!==e;)M.push(z),z=Ve();M!==e?(L=[L,M],w=L):(C=w,w=e)}else C=w,w=e;w!==e&&(ie=b,w=te()),b=w}return b}function wh(){var b;return n.charCodeAt(C)===44?(b=Y,C++):(b=e,Pe===0&&lt(ee)),b}function Ph(){var b,w,L,M;return b=C,w=C,L=YS(),L!==e?(M=Oh(),M===e&&(M=null),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e),w===e&&(w=C,L=Nn(),L!==e?(M=Oh(),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e)),w!==e&&(ie=b,w=K(w)),b=w,b}function YS(){var b,w,L,M,z;return b=C,w=C,L=Nn(),L===e&&(L=null),L!==e?(n.charCodeAt(C)===46?(M=q,C++):(M=e,Pe===0&&lt(ue)),M!==e?(z=Nn(),z!==e?(L=[L,M,z],w=L):(C=w,w=e)):(C=w,w=e)):(C=w,w=e),w===e&&(w=C,L=Nn(),L!==e?(n.charCodeAt(C)===46?(M=q,C++):(M=e,Pe===0&&lt(ue)),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e)),w!==e&&(ie=b,w=K(w)),b=w,b}function Oh(){var b,w,L,M,z;return b=C,w=C,le.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Pe===0&&lt(ne)),L!==e?(M=gd(),M===e&&(M=null),M!==e?(z=Nn(),z!==e?(L=[L,M,z],w=L):(C=w,w=e)):(C=w,w=e)):(C=w,w=e),w!==e&&(ie=b,w=K(w)),b=w,b}function gd(){var b;return ce.test(n.charAt(C))?(b=n.charAt(C),C++):(b=e,Pe===0&&lt(ae)),b}function Nn(){var b,w,L;if(b=C,w=[],he.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Pe===0&&lt(pe)),L!==e)for(;L!==e;)w.push(L),he.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Pe===0&&lt(pe));else w=e;return w!==e&&(ie=b,w=fe(w)),b=w,b}function Ve(){var b,w;return b=C,ge.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&lt(me)),w!==e&&(ie=b,w=te()),b=w,b}function XS(b,w){if(!w)return[b];for(var L=[b],M=0,z=w.length;M<z;M++)L[M+1]=w[M][1];return L}var wl={m:"moveto",l:"lineto",h:"horizontal lineto",v:"vertical lineto",c:"curveto",s:"smooth curveto",q:"quadratic curveto",t:"smooth quadratic curveto",a:"elliptical arc",z:"closepath"};for(var Ch in wl)wl[Ch.toUpperCase()]=wl[Ch];function pi(b,w){w||(w=[{}]);for(var L=w.length;L--;){var M={code:b,command:wl[b]};b==b.toLowerCase()&&(M.relative=!0);for(var z in w[L])M[z]=w[L][z];w[L]=M}return w}if(bt=o(),bt!==e&&C===n.length)return bt;throw bt!==e&&C<n.length&&lt(ud()),hr(Ee,Re<n.length?n.charAt(Re):null,Re<n.length?Mn(Re,Re+1):Mn(Re,Re))}wv.exports={SyntaxError:ai,parse:uD}});var rh=Dn((xie,Ov)=>{var $u=Pv().parse;$u.parseSVG=$u;$u.makeAbsolute=dD;Ov.exports=$u;function dD(n){var r,e={x:0,y:0},t={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return n.forEach(function(o){o.command==="moveto"&&(r=o),o.x0=e.x,o.y0=e.y;for(var i in t)i in o&&(o[i]+=o.relative?o[t[i]]:0);"x"in o||(o.x=e.x),"y"in o||(o.y=e.y),o.relative=!1,o.code=o.code.toUpperCase(),o.command=="closepath"&&(o.x=r.x,o.y=r.y),e=o}),n}});var NS=Dn((dpe,IS)=>{IS.exports=function(r,e){for(var t=r.split("."),o=e.split("."),i=0;i<3;i++){var a=Number(t[i]),s=Number(o[i]);if(a>s)return 1;if(s>a)return-1;if(!isNaN(a)&&isNaN(s))return 1;if(isNaN(a)&&!isNaN(s))return-1}return 0}});import{FileLoader as LE,Loader as RE}from"three";function Tl(n){for(let r of Object.keys(n))n[r]===void 0&&delete n[r];return n}function Ht(n,r){return Object.setPrototypeOf(n,r),n}function Al(n){return Array.isArray(n)?n:[n]}function Ml(n,r){let e=0;for(;e<n.length&&e<r.length;){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1;e+=1}return e!==r.length?-1:e!==n.length?1:0}var n1=typeof global=="object"&&global&&global.Object===Object&&global,Il=n1;var i1=typeof self=="object"&&self&&self.Object===Object&&self,a1=Il||i1||Function("return this")(),gt=a1;var s1=gt.Symbol,At=s1;var Th=Object.prototype,l1=Th.hasOwnProperty,c1=Th.toString,hs=At?At.toStringTag:void 0;function u1(n){var r=l1.call(n,hs),e=n[hs];try{n[hs]=void 0;var t=!0}catch{}var o=c1.call(n);return t&&(r?n[hs]=e:delete n[hs]),o}var Ah=u1;var d1=Object.prototype,p1=d1.toString;function f1(n){return p1.call(n)}var Mh=f1;var h1="[object Null]",m1="[object Undefined]",Ih=At?At.toStringTag:void 0;function y1(n){return n==null?n===void 0?m1:h1:Ih&&Ih in Object(n)?Ah(n):Mh(n)}var ar=y1;function g1(n){return n!=null&&typeof n=="object"}var Bt=g1;var x1="[object Symbol]";function b1(n){return typeof n=="symbol"||Bt(n)&&ar(n)==x1}var mi=b1;function v1(n,r){for(var e=-1,t=n==null?0:n.length,o=Array(t);++e<t;)o[e]=r(n[e],e,n);return o}var Nl=v1;var S1=Array.isArray,ct=S1;var w1=1/0,Nh=At?At.prototype:void 0,Dh=Nh?Nh.toString:void 0;function Eh(n){if(typeof n=="string")return n;if(ct(n))return Nl(n,Eh)+"";if(mi(n))return Dh?Dh.call(n):"";var r=n+"";return r=="0"&&1/n==-w1?"-0":r}var _h=Eh;function P1(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}var sr=P1;function O1(n){return n}var Bh=O1;var C1="[object AsyncFunction]",T1="[object Function]",A1="[object GeneratorFunction]",M1="[object Proxy]";function I1(n){if(!sr(n))return!1;var r=ar(n);return r==T1||r==A1||r==C1||r==M1}var Dl=I1;var N1=gt["__core-js_shared__"],El=N1;var Lh=function(){var n=/[^.]+$/.exec(El&&El.keys&&El.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function D1(n){return!!Lh&&Lh in n}var Rh=D1;var E1=Function.prototype,_1=E1.toString;function B1(n){if(n!=null){try{return _1.call(n)}catch{}try{return n+""}catch{}}return""}var yo=B1;var L1=/[\\^$.*+?()[\]{}|]/g,R1=/^\[object .+?Constructor\]$/,V1=Function.prototype,z1=Object.prototype,G1=V1.toString,j1=z1.hasOwnProperty,F1=RegExp("^"+G1.call(j1).replace(L1,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function U1(n){if(!sr(n)||Rh(n))return!1;var r=Dl(n)?F1:R1;return r.test(yo(n))}var Vh=U1;function k1(n,r){return n?.[r]}var zh=k1;function H1(n,r){var e=zh(n,r);return Vh(e)?e:void 0}var Qt=H1;var W1=Qt(gt,"WeakMap"),_l=W1;var Gh=Object.create,q1=function(){function n(){}return function(r){if(!sr(r))return{};if(Gh)return Gh(r);n.prototype=r;var e=new n;return n.prototype=void 0,e}}(),jh=q1;function $1(n,r,e){switch(e.length){case 0:return n.call(r);case 1:return n.call(r,e[0]);case 2:return n.call(r,e[0],e[1]);case 3:return n.call(r,e[0],e[1],e[2])}return n.apply(r,e)}var Fh=$1;function Y1(n,r){var e=-1,t=n.length;for(r||(r=Array(t));++e<t;)r[e]=n[e];return r}var Uh=Y1;var X1=800,K1=16,Q1=Date.now;function Z1(n){var r=0,e=0;return function(){var t=Q1(),o=K1-(t-e);if(e=t,o>0){if(++r>=X1)return arguments[0]}else r=0;return n.apply(void 0,arguments)}}var kh=Z1;function J1(n){return function(){return n}}var Hh=J1;var ew=function(){try{var n=Qt(Object,"defineProperty");return n({},"",{}),n}catch{}}(),yi=ew;var tw=yi?function(n,r){return yi(n,"toString",{configurable:!0,enumerable:!1,value:Hh(r),writable:!0})}:Bh,Wh=tw;var rw=kh(Wh),qh=rw;function ow(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}var $h=ow;var nw=9007199254740991,iw=/^(?:0|[1-9]\d*)$/;function aw(n,r){var e=typeof n;return r=r??nw,!!r&&(e=="number"||e!="symbol"&&iw.test(n))&&n>-1&&n%1==0&&n<r}var gi=aw;function sw(n,r,e){r=="__proto__"&&yi?yi(n,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[r]=e}var Bl=sw;function lw(n,r){return n===r||n!==n&&r!==r}var xi=lw;var cw=Object.prototype,uw=cw.hasOwnProperty;function dw(n,r,e){var t=n[r];(!(uw.call(n,r)&&xi(t,e))||e===void 0&&!(r in n))&&Bl(n,r,e)}var bi=dw;function pw(n,r,e,t){var o=!e;e||(e={});for(var i=-1,a=r.length;++i<a;){var s=r[i],l=t?t(e[s],n[s],s,e,n):void 0;l===void 0&&(l=n[s]),o?Bl(e,s,l):bi(e,s,l)}return e}var Hr=pw;var Yh=Math.max;function fw(n,r,e){return r=Yh(r===void 0?n.length-1:r,0),function(){for(var t=arguments,o=-1,i=Yh(t.length-r,0),a=Array(i);++o<i;)a[o]=t[r+o];o=-1;for(var s=Array(r+1);++o<r;)s[o]=t[o];return s[r]=e(a),Fh(n,this,s)}}var Xh=fw;var hw=9007199254740991;function mw(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=hw}var vi=mw;function yw(n){return n!=null&&vi(n.length)&&!Dl(n)}var Ll=yw;var gw=Object.prototype;function xw(n){var r=n&&n.constructor,e=typeof r=="function"&&r.prototype||gw;return n===e}var Si=xw;function bw(n,r){for(var e=-1,t=Array(n);++e<n;)t[e]=r(e);return t}var Kh=bw;var vw="[object Arguments]";function Sw(n){return Bt(n)&&ar(n)==vw}var Sd=Sw;var Qh=Object.prototype,ww=Qh.hasOwnProperty,Pw=Qh.propertyIsEnumerable,Ow=Sd(function(){return arguments}())?Sd:function(n){return Bt(n)&&ww.call(n,"callee")&&!Pw.call(n,"callee")},wi=Ow;function Cw(){return!1}var Zh=Cw;var tm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Jh=tm&&typeof module=="object"&&module&&!module.nodeType&&module,Tw=Jh&&Jh.exports===tm,em=Tw?gt.Buffer:void 0,Aw=em?em.isBuffer:void 0,Mw=Aw||Zh,_n=Mw;var Iw="[object Arguments]",Nw="[object Array]",Dw="[object Boolean]",Ew="[object Date]",_w="[object Error]",Bw="[object Function]",Lw="[object Map]",Rw="[object Number]",Vw="[object Object]",zw="[object RegExp]",Gw="[object Set]",jw="[object String]",Fw="[object WeakMap]",Uw="[object ArrayBuffer]",kw="[object DataView]",Hw="[object Float32Array]",Ww="[object Float64Array]",qw="[object Int8Array]",$w="[object Int16Array]",Yw="[object Int32Array]",Xw="[object Uint8Array]",Kw="[object Uint8ClampedArray]",Qw="[object Uint16Array]",Zw="[object Uint32Array]",Je={};Je[Hw]=Je[Ww]=Je[qw]=Je[$w]=Je[Yw]=Je[Xw]=Je[Kw]=Je[Qw]=Je[Zw]=!0;Je[Iw]=Je[Nw]=Je[Uw]=Je[Dw]=Je[kw]=Je[Ew]=Je[_w]=Je[Bw]=Je[Lw]=Je[Rw]=Je[Vw]=Je[zw]=Je[Gw]=Je[jw]=Je[Fw]=!1;function Jw(n){return Bt(n)&&vi(n.length)&&!!Je[ar(n)]}var rm=Jw;function e2(n){return function(r){return n(r)}}var Pi=e2;var om=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ms=om&&typeof module=="object"&&module&&!module.nodeType&&module,t2=ms&&ms.exports===om,wd=t2&&Il.process,r2=function(){try{var n=ms&&ms.require&&ms.require("util").types;return n||wd&&wd.binding&&wd.binding("util")}catch{}}(),go=r2;var nm=go&&go.isTypedArray,o2=nm?Pi(nm):rm,Rl=o2;var n2=Object.prototype,i2=n2.hasOwnProperty;function a2(n,r){var e=ct(n),t=!e&&wi(n),o=!e&&!t&&_n(n),i=!e&&!t&&!o&&Rl(n),a=e||t||o||i,s=a?Kh(n.length,String):[],l=s.length;for(var c in n)(r||i2.call(n,c))&&!(a&&(c=="length"||o&&(c=="offset"||c=="parent")||i&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||gi(c,l)))&&s.push(c);return s}var Vl=a2;function s2(n,r){return function(e){return n(r(e))}}var zl=s2;var l2=zl(Object.keys,Object),im=l2;var c2=Object.prototype,u2=c2.hasOwnProperty;function d2(n){if(!Si(n))return im(n);var r=[];for(var e in Object(n))u2.call(n,e)&&e!="constructor"&&r.push(e);return r}var am=d2;function p2(n){return Ll(n)?Vl(n):am(n)}var Oi=p2;function f2(n){var r=[];if(n!=null)for(var e in Object(n))r.push(e);return r}var sm=f2;var h2=Object.prototype,m2=h2.hasOwnProperty;function y2(n){if(!sr(n))return sm(n);var r=Si(n),e=[];for(var t in n)t=="constructor"&&(r||!m2.call(n,t))||e.push(t);return e}var lm=y2;function g2(n){return Ll(n)?Vl(n,!0):lm(n)}var Ci=g2;var x2=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,b2=/^\w*$/;function v2(n,r){if(ct(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||mi(n)?!0:b2.test(n)||!x2.test(n)||r!=null&&n in Object(r)}var cm=v2;var S2=Qt(Object,"create"),xo=S2;function w2(){this.__data__=xo?xo(null):{},this.size=0}var um=w2;function P2(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}var dm=P2;var O2="__lodash_hash_undefined__",C2=Object.prototype,T2=C2.hasOwnProperty;function A2(n){var r=this.__data__;if(xo){var e=r[n];return e===O2?void 0:e}return T2.call(r,n)?r[n]:void 0}var pm=A2;var M2=Object.prototype,I2=M2.hasOwnProperty;function N2(n){var r=this.__data__;return xo?r[n]!==void 0:I2.call(r,n)}var fm=N2;var D2="__lodash_hash_undefined__";function E2(n,r){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=xo&&r===void 0?D2:r,this}var hm=E2;function Ti(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}Ti.prototype.clear=um;Ti.prototype.delete=dm;Ti.prototype.get=pm;Ti.prototype.has=fm;Ti.prototype.set=hm;var Pd=Ti;function _2(){this.__data__=[],this.size=0}var mm=_2;function B2(n,r){for(var e=n.length;e--;)if(xi(n[e][0],r))return e;return-1}var Ho=B2;var L2=Array.prototype,R2=L2.splice;function V2(n){var r=this.__data__,e=Ho(r,n);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():R2.call(r,e,1),--this.size,!0}var ym=V2;function z2(n){var r=this.__data__,e=Ho(r,n);return e<0?void 0:r[e][1]}var gm=z2;function G2(n){return Ho(this.__data__,n)>-1}var xm=G2;function j2(n,r){var e=this.__data__,t=Ho(e,n);return t<0?(++this.size,e.push([n,r])):e[t][1]=r,this}var bm=j2;function Ai(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}Ai.prototype.clear=mm;Ai.prototype.delete=ym;Ai.prototype.get=gm;Ai.prototype.has=xm;Ai.prototype.set=bm;var Wo=Ai;var F2=Qt(gt,"Map"),qo=F2;function U2(){this.size=0,this.__data__={hash:new Pd,map:new(qo||Wo),string:new Pd}}var vm=U2;function k2(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}var Sm=k2;function H2(n,r){var e=n.__data__;return Sm(r)?e[typeof r=="string"?"string":"hash"]:e.map}var $o=H2;function W2(n){var r=$o(this,n).delete(n);return this.size-=r?1:0,r}var wm=W2;function q2(n){return $o(this,n).get(n)}var Pm=q2;function $2(n){return $o(this,n).has(n)}var Om=$2;function Y2(n,r){var e=$o(this,n),t=e.size;return e.set(n,r),this.size+=e.size==t?0:1,this}var Cm=Y2;function Mi(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}Mi.prototype.clear=vm;Mi.prototype.delete=wm;Mi.prototype.get=Pm;Mi.prototype.has=Om;Mi.prototype.set=Cm;var Bn=Mi;var X2="Expected a function";function Od(n,r){if(typeof n!="function"||r!=null&&typeof r!="function")throw new TypeError(X2);var e=function(){var t=arguments,o=r?r.apply(this,t):t[0],i=e.cache;if(i.has(o))return i.get(o);var a=n.apply(this,t);return e.cache=i.set(o,a)||i,a};return e.cache=new(Od.Cache||Bn),e}Od.Cache=Bn;var Tm=Od;var K2=500;function Q2(n){var r=Tm(n,function(t){return e.size===K2&&e.clear(),t}),e=r.cache;return r}var Am=Q2;var Z2=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,J2=/\\(\\)?/g,eP=Am(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(Z2,function(e,t,o,i){r.push(o?i.replace(J2,"$1"):t||e)}),r}),Mm=eP;function tP(n){return n==null?"":_h(n)}var Im=tP;function rP(n,r){return ct(n)?n:cm(n,r)?[n]:Mm(Im(n))}var mr=rP;var oP=1/0;function nP(n){if(typeof n=="string"||mi(n))return n;var r=n+"";return r=="0"&&1/n==-oP?"-0":r}var Yo=nP;function iP(n,r){r=mr(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[Yo(r[e++])];return e&&e==t?n:void 0}var Gl=iP;function aP(n,r){for(var e=-1,t=r.length,o=n.length;++e<t;)n[o+e]=r[e];return n}var Ii=aP;var Nm=At?At.isConcatSpreadable:void 0;function sP(n){return ct(n)||wi(n)||!!(Nm&&n&&n[Nm])}var Dm=sP;function Em(n,r,e,t,o){var i=-1,a=n.length;for(e||(e=Dm),o||(o=[]);++i<a;){var s=n[i];r>0&&e(s)?r>1?Em(s,r-1,e,t,o):Ii(o,s):t||(o[o.length]=s)}return o}var _m=Em;function lP(n){var r=n==null?0:n.length;return r?_m(n,1):[]}var Bm=lP;function cP(n){return qh(Xh(n,void 0,Bm),n+"")}var jl=cP;var uP=zl(Object.getPrototypeOf,Object),Ni=uP;var dP="[object Object]",pP=Function.prototype,fP=Object.prototype,Lm=pP.toString,hP=fP.hasOwnProperty,mP=Lm.call(Object);function yP(n){if(!Bt(n)||ar(n)!=dP)return!1;var r=Ni(n);if(r===null)return!0;var e=hP.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&Lm.call(e)==mP}var Rm=yP;function gP(n,r,e){var t=-1,o=n.length;r<0&&(r=-r>o?0:o+r),e=e>o?o:e,e<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var i=Array(o);++t<o;)i[t]=n[t+r];return i}var Vm=gP;function xP(){this.__data__=new Wo,this.size=0}var zm=xP;function bP(n){var r=this.__data__,e=r.delete(n);return this.size=r.size,e}var Gm=bP;function vP(n){return this.__data__.get(n)}var jm=vP;function SP(n){return this.__data__.has(n)}var Fm=SP;var wP=200;function PP(n,r){var e=this.__data__;if(e instanceof Wo){var t=e.__data__;if(!qo||t.length<wP-1)return t.push([n,r]),this.size=++e.size,this;e=this.__data__=new Bn(t)}return e.set(n,r),this.size=e.size,this}var Um=PP;function Di(n){var r=this.__data__=new Wo(n);this.size=r.size}Di.prototype.clear=zm;Di.prototype.delete=Gm;Di.prototype.get=jm;Di.prototype.has=Fm;Di.prototype.set=Um;var Ei=Di;function OP(n,r){return n&&Hr(r,Oi(r),n)}var km=OP;function CP(n,r){return n&&Hr(r,Ci(r),n)}var Hm=CP;var Ym=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Wm=Ym&&typeof module=="object"&&module&&!module.nodeType&&module,TP=Wm&&Wm.exports===Ym,qm=TP?gt.Buffer:void 0,$m=qm?qm.allocUnsafe:void 0;function AP(n,r){if(r)return n.slice();var e=n.length,t=$m?$m(e):new n.constructor(e);return n.copy(t),t}var Xm=AP;function MP(n,r){for(var e=-1,t=n==null?0:n.length,o=0,i=[];++e<t;){var a=n[e];r(a,e,n)&&(i[o++]=a)}return i}var Km=MP;function IP(){return[]}var Fl=IP;var NP=Object.prototype,DP=NP.propertyIsEnumerable,Qm=Object.getOwnPropertySymbols,EP=Qm?function(n){return n==null?[]:(n=Object(n),Km(Qm(n),function(r){return DP.call(n,r)}))}:Fl,_i=EP;function _P(n,r){return Hr(n,_i(n),r)}var Zm=_P;var BP=Object.getOwnPropertySymbols,LP=BP?function(n){for(var r=[];n;)Ii(r,_i(n)),n=Ni(n);return r}:Fl,Ul=LP;function RP(n,r){return Hr(n,Ul(n),r)}var Jm=RP;function VP(n,r,e){var t=r(n);return ct(n)?t:Ii(t,e(n))}var kl=VP;function zP(n){return kl(n,Oi,_i)}var ys=zP;function GP(n){return kl(n,Ci,Ul)}var Hl=GP;var jP=Qt(gt,"DataView"),Wl=jP;var FP=Qt(gt,"Promise"),ql=FP;var UP=Qt(gt,"Set"),$l=UP;var ey="[object Map]",kP="[object Object]",ty="[object Promise]",ry="[object Set]",oy="[object WeakMap]",ny="[object DataView]",HP=yo(Wl),WP=yo(qo),qP=yo(ql),$P=yo($l),YP=yo(_l),Ln=ar;(Wl&&Ln(new Wl(new ArrayBuffer(1)))!=ny||qo&&Ln(new qo)!=ey||ql&&Ln(ql.resolve())!=ty||$l&&Ln(new $l)!=ry||_l&&Ln(new _l)!=oy)&&(Ln=function(n){var r=ar(n),e=r==kP?n.constructor:void 0,t=e?yo(e):"";if(t)switch(t){case HP:return ny;case WP:return ey;case qP:return ty;case $P:return ry;case YP:return oy}return r});var bo=Ln;var XP=Object.prototype,KP=XP.hasOwnProperty;function QP(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&KP.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var iy=QP;var ZP=gt.Uint8Array,Bi=ZP;function JP(n){var r=new n.constructor(n.byteLength);return new Bi(r).set(new Bi(n)),r}var Li=JP;function eO(n,r){var e=r?Li(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var ay=eO;var tO=/\w*$/;function rO(n){var r=new n.constructor(n.source,tO.exec(n));return r.lastIndex=n.lastIndex,r}var sy=rO;var ly=At?At.prototype:void 0,cy=ly?ly.valueOf:void 0;function oO(n){return cy?Object(cy.call(n)):{}}var uy=oO;function nO(n,r){var e=r?Li(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var dy=nO;var iO="[object Boolean]",aO="[object Date]",sO="[object Map]",lO="[object Number]",cO="[object RegExp]",uO="[object Set]",dO="[object String]",pO="[object Symbol]",fO="[object ArrayBuffer]",hO="[object DataView]",mO="[object Float32Array]",yO="[object Float64Array]",gO="[object Int8Array]",xO="[object Int16Array]",bO="[object Int32Array]",vO="[object Uint8Array]",SO="[object Uint8ClampedArray]",wO="[object Uint16Array]",PO="[object Uint32Array]";function OO(n,r,e){var t=n.constructor;switch(r){case fO:return Li(n);case iO:case aO:return new t(+n);case hO:return ay(n,e);case mO:case yO:case gO:case xO:case bO:case vO:case SO:case wO:case PO:return dy(n,e);case sO:return new t;case lO:case dO:return new t(n);case cO:return sy(n);case uO:return new t;case pO:return uy(n)}}var py=OO;function CO(n){return typeof n.constructor=="function"&&!Si(n)?jh(Ni(n)):{}}var fy=CO;var TO="[object Map]";function AO(n){return Bt(n)&&bo(n)==TO}var hy=AO;var my=go&&go.isMap,MO=my?Pi(my):hy,yy=MO;var IO="[object Set]";function NO(n){return Bt(n)&&bo(n)==IO}var gy=NO;var xy=go&&go.isSet,DO=xy?Pi(xy):gy,by=DO;var EO=1,_O=2,BO=4,vy="[object Arguments]",LO="[object Array]",RO="[object Boolean]",VO="[object Date]",zO="[object Error]",Sy="[object Function]",GO="[object GeneratorFunction]",jO="[object Map]",FO="[object Number]",wy="[object Object]",UO="[object RegExp]",kO="[object Set]",HO="[object String]",WO="[object Symbol]",qO="[object WeakMap]",$O="[object ArrayBuffer]",YO="[object DataView]",XO="[object Float32Array]",KO="[object Float64Array]",QO="[object Int8Array]",ZO="[object Int16Array]",JO="[object Int32Array]",eC="[object Uint8Array]",tC="[object Uint8ClampedArray]",rC="[object Uint16Array]",oC="[object Uint32Array]",Qe={};Qe[vy]=Qe[LO]=Qe[$O]=Qe[YO]=Qe[RO]=Qe[VO]=Qe[XO]=Qe[KO]=Qe[QO]=Qe[ZO]=Qe[JO]=Qe[jO]=Qe[FO]=Qe[wy]=Qe[UO]=Qe[kO]=Qe[HO]=Qe[WO]=Qe[eC]=Qe[tC]=Qe[rC]=Qe[oC]=!0;Qe[zO]=Qe[Sy]=Qe[qO]=!1;function Yl(n,r,e,t,o,i){var a,s=r&EO,l=r&_O,c=r&BO;if(e&&(a=o?e(n,t,o,i):e(n)),a!==void 0)return a;if(!sr(n))return n;var u=ct(n);if(u){if(a=iy(n),!s)return Uh(n,a)}else{var p=bo(n),d=p==Sy||p==GO;if(_n(n))return Xm(n,s);if(p==wy||p==vy||d&&!o){if(a=l||d?{}:fy(n),!s)return l?Jm(n,Hm(a,n)):Zm(n,km(a,n))}else{if(!Qe[p])return o?n:{};a=py(n,p,s)}}i||(i=new Ei);var h=i.get(n);if(h)return h;i.set(n,a),by(n)?n.forEach(function(y){a.add(Yl(y,r,e,y,n,i))}):yy(n)&&n.forEach(function(y,g){a.set(g,Yl(y,r,e,g,n,i))});var f=c?l?Hl:ys:l?Ci:Oi,m=u?void 0:f(n);return $h(m||n,function(y,g){m&&(g=y,y=n[g]),bi(a,g,Yl(y,r,e,g,n,i))}),a}var Xl=Yl;var nC=1,iC=4;function aC(n){return Xl(n,nC|iC)}var vo=aC;var sC="__lodash_hash_undefined__";function lC(n){return this.__data__.set(n,sC),this}var Py=lC;function cC(n){return this.__data__.has(n)}var Oy=cC;function Kl(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new Bn;++r<e;)this.add(n[r])}Kl.prototype.add=Kl.prototype.push=Py;Kl.prototype.has=Oy;var Cy=Kl;function uC(n,r){for(var e=-1,t=n==null?0:n.length;++e<t;)if(r(n[e],e,n))return!0;return!1}var Ty=uC;function dC(n,r){return n.has(r)}var Ay=dC;var pC=1,fC=2;function hC(n,r,e,t,o,i){var a=e&pC,s=n.length,l=r.length;if(s!=l&&!(a&&l>s))return!1;var c=i.get(n),u=i.get(r);if(c&&u)return c==r&&u==n;var p=-1,d=!0,h=e&fC?new Cy:void 0;for(i.set(n,r),i.set(r,n);++p<s;){var f=n[p],m=r[p];if(t)var y=a?t(m,f,p,r,n,i):t(f,m,p,n,r,i);if(y!==void 0){if(y)continue;d=!1;break}if(h){if(!Ty(r,function(g,v){if(!Ay(h,v)&&(f===g||o(f,g,e,t,i)))return h.push(v)})){d=!1;break}}else if(!(f===m||o(f,m,e,t,i))){d=!1;break}}return i.delete(n),i.delete(r),d}var Ql=hC;function mC(n){var r=-1,e=Array(n.size);return n.forEach(function(t,o){e[++r]=[o,t]}),e}var My=mC;function yC(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Iy=yC;var gC=1,xC=2,bC="[object Boolean]",vC="[object Date]",SC="[object Error]",wC="[object Map]",PC="[object Number]",OC="[object RegExp]",CC="[object Set]",TC="[object String]",AC="[object Symbol]",MC="[object ArrayBuffer]",IC="[object DataView]",Ny=At?At.prototype:void 0,Cd=Ny?Ny.valueOf:void 0;function NC(n,r,e,t,o,i,a){switch(e){case IC:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case MC:return!(n.byteLength!=r.byteLength||!i(new Bi(n),new Bi(r)));case bC:case vC:case PC:return xi(+n,+r);case SC:return n.name==r.name&&n.message==r.message;case OC:case TC:return n==r+"";case wC:var s=My;case CC:var l=t&gC;if(s||(s=Iy),n.size!=r.size&&!l)return!1;var c=a.get(n);if(c)return c==r;t|=xC,a.set(n,r);var u=Ql(s(n),s(r),t,o,i,a);return a.delete(n),u;case AC:if(Cd)return Cd.call(n)==Cd.call(r)}return!1}var Dy=NC;var DC=1,EC=Object.prototype,_C=EC.hasOwnProperty;function BC(n,r,e,t,o,i){var a=e&DC,s=ys(n),l=s.length,c=ys(r),u=c.length;if(l!=u&&!a)return!1;for(var p=l;p--;){var d=s[p];if(!(a?d in r:_C.call(r,d)))return!1}var h=i.get(n),f=i.get(r);if(h&&f)return h==r&&f==n;var m=!0;i.set(n,r),i.set(r,n);for(var y=a;++p<l;){d=s[p];var g=n[d],v=r[d];if(t)var O=a?t(v,g,d,r,n,i):t(g,v,d,n,r,i);if(!(O===void 0?g===v||o(g,v,e,t,i):O)){m=!1;break}y||(y=d=="constructor")}if(m&&!y){var P=n.constructor,S=r.constructor;P!=S&&"constructor"in n&&"constructor"in r&&!(typeof P=="function"&&P instanceof P&&typeof S=="function"&&S instanceof S)&&(m=!1)}return i.delete(n),i.delete(r),m}var Ey=BC;var LC=1,_y="[object Arguments]",By="[object Array]",Zl="[object Object]",RC=Object.prototype,Ly=RC.hasOwnProperty;function VC(n,r,e,t,o,i){var a=ct(n),s=ct(r),l=a?By:bo(n),c=s?By:bo(r);l=l==_y?Zl:l,c=c==_y?Zl:c;var u=l==Zl,p=c==Zl,d=l==c;if(d&&_n(n)){if(!_n(r))return!1;a=!0,u=!1}if(d&&!u)return i||(i=new Ei),a||Rl(n)?Ql(n,r,e,t,o,i):Dy(n,r,l,e,t,o,i);if(!(e&LC)){var h=u&&Ly.call(n,"__wrapped__"),f=p&&Ly.call(r,"__wrapped__");if(h||f){var m=h?n.value():n,y=f?r.value():r;return i||(i=new Ei),o(m,y,e,t,i)}}return d?(i||(i=new Ei),Ey(n,r,e,t,o,i)):!1}var Ry=VC;function Vy(n,r,e,t,o){return n===r?!0:n==null||r==null||!Bt(n)&&!Bt(r)?n!==n&&r!==r:Ry(n,r,e,t,Vy,o)}var zy=Vy;function zC(n,r){return n!=null&&r in Object(n)}var Gy=zC;function GC(n,r,e){r=mr(r,n);for(var t=-1,o=r.length,i=!1;++t<o;){var a=Yo(r[t]);if(!(i=n!=null&&e(n,a)))break;n=n[a]}return i||++t!=o?i:(o=n==null?0:n.length,!!o&&vi(o)&&gi(a,o)&&(ct(n)||wi(n)))}var jy=GC;function jC(n,r){return n!=null&&jy(n,r,Gy)}var Fy=jC;function FC(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}var Uy=FC;function UC(n,r){return r.length<2?n:Gl(n,Vm(r,0,-1))}var ky=UC;function kC(n,r){return zy(n,r)}var Td=kC;function HC(n,r){return r=mr(r,n),n=ky(n,r),n==null||delete n[Yo(Uy(r))]}var Hy=HC;function WC(n){return Rm(n)?void 0:n}var Wy=WC;var qC=1,$C=2,YC=4,XC=jl(function(n,r){var e={};if(n==null)return e;var t=!1;r=Nl(r,function(i){return i=mr(i,n),t||(t=i.length>1),i}),Hr(n,Hl(n),e),t&&(e=Xl(e,qC|$C|YC,Wy));for(var o=r.length;o--;)Hy(e,r[o]);return e}),Ri=XC;function KC(n,r,e,t){if(!sr(n))return n;r=mr(r,n);for(var o=-1,i=r.length,a=i-1,s=n;s!=null&&++o<i;){var l=Yo(r[o]),c=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return n;if(o!=a){var u=s[l];c=t?t(u,l,s):void 0,c===void 0&&(c=sr(u)?u:gi(r[o+1])?[]:{})}bi(s,l,c),s=s[l]}return n}var qy=KC;function QC(n,r,e){for(var t=-1,o=r.length,i={};++t<o;){var a=r[t],s=Gl(n,a);e(s,a)&&qy(i,mr(a,n),s)}return i}var $y=QC;function ZC(n,r){return $y(n,r,function(e,t){return Fy(n,t)})}var Yy=ZC;var JC=jl(function(n,r){return n==null?{}:Yy(n,r)}),Mr=JC;var xe=class{modifyById(r,e){let t=this;if(t[r]===void 0)throw new Error("not expected");{let i={...t,[r]:e};return Object.setPrototypeOf(i,xe.prototype),i}}add(r,e){return this.runOp({type:1,id:r,data:e})?.data??this}runOp(r){let e=this;if(r.type===1){let t=e[r.id],o;t===void 0?o={type:2,id:r.id}:o={type:1,id:r.id,data:t};let{id:i,data:a}=r,s={...e,[i]:a};return Object.setPrototypeOf(s,xe.prototype),{data:s,actual:r,reverse:o}}else if(r.type===2){let{id:t}=r,o=e[t];if(o===void 0)return null;{let i={...e};return Object.setPrototypeOf(i,xe.prototype),delete i[t],{data:i,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function gs(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let r=Object.getOwnPropertyNames(n);for(let e of r){let t=n[e];t&&typeof t=="object"&&gs(t)}return Object.freeze(n)}function Xy(n,r){let e=0;for(;e<n.length&&e<r.length;){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1;e+=1}return e!==r.length?-1:e!==n.length?1:0}var Vi=class extends Error{};function Jl(n){let r={...n};return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function Wr(n,r,e){if(n===void 0?r===void 0?(n=0,r=10):n=r-10:r===void 0&&(r=n+10),n>r){let i=n;n=r,r=i}let t=[],o=1/(e+1);for(let i=0;i<e;i++){let a=n+(r-n)*(i+.75+Math.random()*.5)*o;t.push(a)}return t}function zi(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 Ky(){return typeof process<"u"}function Qy(n,r){for(let e of n)r(e.id,e.data)!==!0&&Qy(e.children,r)}function Zy(n,r){if(r(n.id,n.data)!==!0)for(let e of n.children)Zy(e,r)}var Xe=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Xe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)gs(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);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)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let o=this.parent(e);if(o===t)return!0;e=o}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let o=this.parent(e);if(o===t)return!0;e=o}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let o=this.get(e);o&&Zy(o,t)}}traverse(e){Qy(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 i=this.parent(e),a=this.childrenArray(i),s=a.findIndex(u=>u.id===e);if(s<0)throw new Error("not expected");let l=a[s];return a=[...a],a[s]={...l,data:t},this.modifyArrayBy(i,a)}}modifyArrayBy(e,t){let o=e,i=t;for(;o!==null;){let s=i,l=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let c=i.findIndex(u=>u.id===l);if(c<0)throw new Error;i=[...i],i[c]={...i[c],children:s}}Object.setPrototypeOf(i,Xe.prototype);let a=i;return a.fillCaches(),a}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let o of t)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:t,fi:o,id:i,data:a,children:s}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=t,c=this.childrenArray(l),u={fi:o,id:i,data:a,children:s};return c=[...c,u],c.sort((d,h)=>d.fi-h.fi),e.localIndex=c.indexOf(u),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:i}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let o=this.parent(t);if(o===void 0)return null;let i=this.childrenArray(o),a=i.findIndex(c=>c.id===t);e.localIndex=a,i=[...i];let s=i.splice(a,1)[0];return{data:this.modifyArrayBy(o,i),actual:e,reverse:{type:7,...s,parent:o}}}}moveOp(e){let{parent:t,fi:o,id:i}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:i});if(t!==null){let h=t;for(;h!==null;){if(h===void 0)throw new Error;if(h===i)throw new Vi("cyclic tree");h=this.parent(h)}}let a=this.parent(i);if(a===void 0)return null;let s=a,l=this.childrenArray(a),c=l.findIndex(h=>h.id===i);l=[...l];let u=l.splice(c,1)[0],p=this.modifyArrayBy(a,l);a=t,l=p.childrenArray(a);let d=u.fi;return u={...u,fi:o},l=[...l,u],l.sort((h,f)=>h.fi-f.fi),e.localIndex=l.indexOf(u),p=p.modifyArrayBy(a,l),{data:p,actual:e,reverse:{type:9,parent:s,fi:d,id:i}}}previous(e,t){if(t===null){let i=this.childrenArray(e);return i.length===0?null:i[i.length-1].id}let o=null;for(let i of this.childrenArray(e)){if(i.id===t)return o;o=i.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let o=this.childrenArray(t),i=o.findIndex(a=>a.id===e)+1;if(i<o.length)return o[i].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 o=this.childrenArray(t),i=o.findIndex(a=>a.id===e)-1;return i>=0?this.traverseSortPrevious(o[i].id):t}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push({...o,...i})}t.sort((o,i)=>Xy(o.sortKey,i.sortKey));for(let o of t)delete o.sortKey;return t}getWithSortKey(e){var t=e;let o=[],i=this.get(t),a=i;if(i!==void 0){for(;t;)o.splice(0,0,i.fi),t=this.parent(t),t!==null&&(i=this.get(t));return{...a,sortKey:o}}}insertBeforeHelper(e,t,o){return this.insertAfterHelper(e,this.previous(e,t),o)}insertAfterHelper(e,t,o){let i=this.childrenArray(e);if(t===null){if(i.length===0)return Wr(0,o,o);{let a=i[0].fi;return Wr(a-o,a,o)}}else{let a=this.get(t);if(a===void 0||this.parent(t)!==e)throw new Error("illegal args");let s=i.find(l=>l.fi>a.fi);if(s===void 0){let l=i[i.length-1].fi;return Wr(l,l+o,o)}else return Wr(a.fi,s.fi,o)}}};var Gi;(r=>{function n(e,t){if(t.type!==0)return null;if(Array.isArray(e)){let o=t.props,i={},a=[...e],s=!1;if(o)for(let l of Object.keys(o)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");i[l]=a[c],a[c]=o[l],s=!0}return s?{data:a,actual:t,reverse:{type:0,props:i}}:null}else{let o=t.props,i={},a={...e},s=!1;if(o)for(let l of Object.keys(o)){i[l]=a[l];let c=o[l];c===void 0?delete a[l]:a[l]=c,s=!0}return s?{data:a,actual:t,reverse:{type:0,props:i}}:null}}r.runOp=n})(Gi||(Gi={}));var ve=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ve.prototype)}deepFreeze(){let e=0;for(;e<this.length;)gs(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){return this.get(e)?.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 i=this,a=i.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let s=i[a];return i=[...i],i[a]={...s,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,ve.prototype);let t=e;return Ky()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:o,data:i}=e,a=this,s={fi:t,id:o,data:i};return a=[...a,s],a.sort((c,u)=>c.fi-u.fi),e.localIndex=a.indexOf(s),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:o}}}deleteOp(e){let{id:t}=e,o=this,i=o.findIndex(l=>l.id===t);if(i===-1)return null;e.localIndex=i,o=[...o];let a=o.splice(i,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:t,id:o}=e,i=this;i=[...i];let a=i.findIndex(u=>u.id===o);if(a===-1)return null;let s=i[a].fi,l={...i[a],fi:t};return i[a]=l,i.sort((u,p)=>u.fi-p.fi),e.localIndex=i.indexOf(l),{data:this.modifyArrayBy(i),actual:e,reverse:{type:6,fi:s,id:o}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let o of this){if(o.id===e)return t;t=o.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let o=this;if(e===null){if(o.length===0)return Wr(0,t,t);{let i=o[0].fi;return Wr(i-t,i,t)}}else{let i=this.get(e);if(i===void 0)throw new Error("illegal args");let a=o.find(s=>s.fi>i.fi);if(a===void 0){let s=o[o.length-1].fi;return Wr(s,s+t,t)}else return Wr(i.fi,a.fi,t)}}};function ji(n){return n&&typeof n=="object"&&n instanceof Ke}var Ke=class{unusedFunOverridesTable(r){}runOp(r){let e=[],t=this,o=0,i={};for(;o<r.path.length;){if(e.push(t),t=t===void 0?void 0:t[r.path[o]],t!==void 0&&!ji(t))return null;o+=1}t=t?Jl(t):new Ke;for(let[l,c]of Object.entries(r.props)){let u=t[l];i[l]=u,c===void 0?delete t[l]:t[l]=c}for(;o>0;){if(Object.keys(t).length===0){let l=e[o-1];l&&(t=Jl(l),delete t[r.path[o-1]])}else{let l=e[o-1];if(l){let c=Jl(l);c[r.path[o-1]]=t,t=c}else{let c=new Ke;c[r.path[o-1]]=t,t=c}}o-=1}let a=Object.setPrototypeOf(t,Ke.prototype),s={...r,props:i};return{data:a,actual:r,reverse:s}}},qr;(t=>{function n(o,i){return xs(o,i)??o}t.apply=n;function r(o,i){return Md(o,i)}t.merge=r;function e(o,i){let a=0,s=i.path,l=o;for(;a<s.length&&l!==void 0;){if(l=rt.zoomOnce(l,s[a]),l===void 0)return i;if(!ji(l))return;a+=1}if(l===void 0)return i;if(!!ji(l))if(i.type===0){let c={...i.props};for(let u of Object.keys(l))delete c[u];return{...i,props:c}}else if(i.type===1||i.type===4||i.type===7){let c=Ad([i],l);return c?(console.log(c),c):i}else return i}t.filterOp=e})(qr||(qr={}));function Ad(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,a=xs(o.data,r[i]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=Ad(o.children,r);return s!==void 0?e=!0:s=o.children,{...o,id:i,data:a,children:s}}else return{...o,id:i,data:a}});if(e)return t}function eT(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,a=xs(o.data,r[i]);return e=e||a!==void 0,a===void 0&&(a=o.data),{...o,id:i,data:a}});if(e)return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function xs(n,r){if(!ji(r))return r;if(n instanceof Xe){let e=Ad(n,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof ve)return eT(n,r);if(Array.isArray(n)){let e=!1,t=n.map((o,i)=>{let a=xs(o,r[i]);return e=e||a!==void 0,a===void 0&&(a=o),a});return e?(Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t):void 0}else{if(n instanceof Ke)return Md(n,r);if(n&&typeof n=="object"){let e={},t=!1;for(let[o,i]of Object.entries(n)){let a=xs(i,r[o]);t=t||a!==void 0,a===void 0&&(a=i),e[o]=a}return t?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function Md(n,r){if(n===void 0)return r;if(r===void 0)return n;if(!ji(r))return r;if(!ji(n))return qr.apply(n,r);let e=new Set;for(let o of Object.keys(n))e.add(o);for(let o of Object.keys(r))e.add(o);let t=new Ke;for(let o of e){let i=Md(n===void 0?void 0:n[o],r===void 0?void 0:r[o]);t[o]=i}return t}function Jy(n,r){let e={cur:[],result:[],len:0};return n=bs(n,r,e)??n,[n,e.result]}function ec(n,r){return n===null?null:(n.cur[n.len]=r,n.len+=1,n)}function tc(n){n&&(n.len-=1)}function tT(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function eg(n,r,e){let t=!1,o=n.map(i=>{let a=i.id,s=r[a];if(s!==void 0&&typeof s=="string"&&(t=!0,a=s,e!==null))throw new Error("not supported");let l=bs(i.data,r,ec(e,a));tc(e),t=t||l!==void 0,l===void 0&&(l=i.data);let c=eg(i.children,r,e);return c!==void 0?t=!0:c=i.children,{...i,id:a,data:l,children:c}});if(t)return o}function rT(n,r,e){let t=!1,o=n.map(i=>{let a=i.id,s=r[a];if(s!==void 0&&typeof s=="string"&&(t=!0,a=s,e!==null))throw new Error("not supported");let l=bs(i.data,r,ec(e,a));return tc(e),t=t||l!==void 0,l===void 0&&(l=i.data),{...i,id:a,data:l}});if(t)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}function bs(n,r,e){if(n instanceof Xe){let t=eg(n,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else{if(n instanceof ve)return rT(n,r,e);if(Array.isArray(n)){let t=!1,o=n.map((i,a)=>{let s=bs(i,r,ec(e,a));return tc(e),t=t||s!==void 0,s===void 0&&(s=i),s});return t?(Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o):void 0}else if(n&&typeof n=="object"&&!zi(n)){let t={},o=!1;for(let[i,a]of Object.entries(n))if(i!=="name"){let s=r[i];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,i=s}let l=bs(a,r,ec(e,i));tc(e),o=o||l!==void 0,l===void 0&&(l=a),t[i]=l}else t[i]=a;return o?(Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t):void 0}else if(typeof n=="string"){let t=r[n];return t!==void 0&&tT(e),t}else return}}var Fi;(r=>{function n(e,t){let o=rt.zoom(t,e.path);if(typeof o=="object"){let i={};for(let a of Object.keys(e.props))i[a]=o[a];return{...e,props:i}}else return{...e,props:{}}}r.replaceProps=n})(Fi||(Fi={}));var ot;(s=>{function n(l,c){return{...l,path:l.path.slice(c)}}s.drop=n;function r(l,c){return e(l,c)?.data??l}s.applySimple=r;function e(l,c){let u=c.path;for(var p=[];;){let d;if(l instanceof Ke&&c.type===0&&(d=l.runOp({...c,path:u.slice(p.length)}),d===null&&(d=void 0)),d===void 0&&p.length===u.length&&(l instanceof Xe||l instanceof ve||l instanceof xe?d=l.runOp(c):d=Gi.runOp(l,c)),d!==void 0)if(d!==null){let m=d.data;for(let y=p.length-1;y>=0;y--){let g=u[y],v=p[y];if(v instanceof Xe){if(typeof g=="number")throw new Error("illegal arg");m=v.modifyById(g,m)}else if(v instanceof ve){if(typeof g=="number")throw new Error("illegal arg");m=v.modifyById(g,m)}else if(v instanceof xe){if(typeof g=="number")throw new Error("illegal arg");m=v.modifyById(g,m)}else if(v instanceof Ke){let O={...v,[g]:m};m=Object.setPrototypeOf(O,Ke.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let O=m;m=[...v],m[g]=O}else m={...v,[g]:m};else return null}return{data:m,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let h=u[p.length],f;if(l instanceof Xe){if(typeof h=="number")throw new Error("");f=l.get(h)?.data}else if(l instanceof ve){if(typeof h=="number")throw new Error("");f=l.get(h)?.data}else l!==null&&(f=l[h]);if(f!==void 0)p.push(l),l=f;else return null}}s.apply=e;function t(l,c){for(let u=0;u<l.length&&u<c.length;u++)if(l[u]!==c[u])return!0;return!1}s.pathDisjoint=t;function o(l,c){if(l.length!==c.length)return!1;for(let u=0;u<l.length;u++)if(l[u]!==c[u])return!1;return!0}s.pathEq=o;function i(l,c){return t(l.path,c.path)}s.commutative=i;function a(l,c){return l.type===0&&c.type===0&&o(l.path,c.path)?Object.keys(l.props).every(u=>c.props[u]!==void 0):!1}s.subsumed=a})(ot||(ot={}));var vs;(l=>{function n(){return[]}l.empty=n;function r(c,u){let p=[];for(let d of c){let[h,...f]=d.path;h===u&&p.push({...d,path:f})}return p}l.removePrefix=r;function e(c,u){return c.map(p=>({...p,path:[u,...p.path]}))}l.addPrefix=e;function t(c,u){return[...c,...u]}l.concat=t;function o(c,u){return[...c.filter(d=>!u.some(h=>ot.subsumed(d,h))),...u]}l.compress=o;function i(c,u){return c.every(p=>u.every(d=>ot.commutative(p,d)))}l.commutative=i;function a(c,u){for(let p of u){let d=s(c,p);d!==null&&(c=d.data)}return c}l.applyAll=a;function s(c,u){var p=c;let d=[],h=[];for(let f of u)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let m,y,g;if(f.type===3?(m=rt.zoom(p,[...f.path,f.id]),g=ot.apply(p,{...f,type:2})):(m=rt.zoom(p,[...f.path,f.id,"value"]),g=ot.apply(p,f)),g!==null){p=g.data;let[v,O]=Jy(p,{[f.id]:m});p=v;for(let P=0;P<O.length;P++){let S=O[P],T=S.pop();if(typeof T=="number"){let I=[T];for(let _=P+1;_<O.length;_++){let D=O[_],A=D[D.length-1];if(typeof A=="number"&&rt.equal(S,D.slice(0,D.length-1)))I.push(A),O.splice(_,1);else break}let x=rt.zoom(p,S);y=x.map((_,D)=>I.includes(D)?f.id:_),m=x,T=S.pop()}else{if(T==="alphaOverride"||T==="alpha"){m/=100;let I=m,x=rt.zoom(p,S.slice(0,S.length-2)),_=x.layers.map(D=>D.id===S[S.length-1]?{...D,data:{...D.data,[T]:I}}:D);Object.setPrototypeOf(_,Object.getPrototypeOf(x.layers)),x.layers=_}y=f.id}d.push({type:0,path:S,props:{[T]:m}}),h.push({type:0,path:S,props:{[T]:y}})}h.push(g.reverse),d.push(g.actual)}}else{let m=ot.apply(p,f);m!==null&&(d.push(m.actual),p=m.data,h.push(m.reverse))}}catch(m){if(m instanceof Vi)return null;throw m}return{data:p,actual:d,reverse:h.reverse()}}l.apply=s})(vs||(vs={}));var tg=Symbol(),oT=Symbol(),oc=Symbol(),Rn=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let i=t;for(;!(o instanceof rc);){let a=o._path,s=o._current;if(a!==""&&i.splice(0,0,a),o=o._parent,o===null)return;o.update(a,s)}o.push(i,r,e.actual,e.reverse)}deleteChildren(r){if(this._children){let e=this._children[r];if(e){let t=e[oc];t&&t(),delete this._children[r]}}}},Nd=class extends Rn{constructor(r,e,t){super(),this._parent=r,this._path=e,this._current=t}update(r,e){if(Array.isArray(this._current)){if(typeof r=="string"&&(r=parseInt(r),isNaN(r)))throw new Error("Invalid path");this._current=[...this._current],this._current[r]=e}else this._current={...this._current,[r]:e}}runOp(r){this.reportOp(r,Gi.runOp(this._current,r),r.path)}},Dd=class extends Rn{constructor(r,e,t){super(),this._parent=r,this._path=e,this._current=t}update(r,e){this._current={...this._current,[r]:e},Object.setPrototypeOf(this._current,xe.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},rg={get(n,r){if(r===oc)return()=>{n._parent=null};if(r===tg)return n._current;if(r===oT)return n;let{_current:e,_children:t}=n;if(r==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e[r],a=nc(n,r,i);return a!==i?(t===void 0&&(t={},n._children=t),t[r]=a,a):i},has(n,r){return r 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,r){let e=n._current,t=Reflect.getOwnPropertyDescriptor(e,r);return t&&{writable:!0,configurable:!0,enumerable:t.enumerable,value:e[r]}}},nT={...rg,set(n,r,e){let t={type:0,props:{[r]:ut(e)??e}};return n.deleteChildren(r),n.runOp(t),!0},deleteProperty(n,r){let e={type:0,props:{[r]:void 0}};return n.deleteChildren(r),n.runOp(e),!0}},iT={...rg,set(n,r,e){return e===void 0?this.deleteProperty(n,r):(n.deleteChildren(r),n.runOp({type:1,id:r,data:e})),!0},deleteProperty(n,r){return n.runOp({type:2,id:r}),!0}},Ui=class extends Rn{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[oc]=()=>{this._parent=null}}unproxy(){return this._current}update(r,e){this._current=this._current.modifyById(r,e)}runOp(r){this.reportOp(r,this._current.runOp(r))}randomId(){return this._current.randomId()}isDescendantOf(r,e){return this._current.isDescendantOf(r,e)}childrenOf(r){return this._current.childrenOf(r)}traverse(r){return this._current.traverse(r)}get(r){return this._current.get(r)}parent(r){return this._current.parent(r)}traverse(r){this._current.traverse((e,t)=>{r(e,this.data(e))})}data(r){let{_current:e,_children:t}=this,o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e.get(r)?.data,a=nc(this,r,i);return a!==i?(t===void 0&&(t={},this._children=t),t[r]=a,a):i}add(r,e,t,o,i){this.runOp({type:7,parent:r,fi:e,id:t,data:o,children:i})}move(r,e,t){this.runOp({type:9,parent:r,fi:e,id:t})}insertAfter(r,e,t){let o=this._current.insertAfterHelper(r,e,t.length);for(let i=0;i<t.length;i++){let a=t[i];this.add(r,o[i],a.id,a.data,a.children)}}insertBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let i=0;i<t.length;i++){let a=t[i];this.add(r,o[i],a.id,a.data,a.children)}}moveAfter(r,e,t){let o=this._current.insertAfterHelper(r,e,t.length);for(let i=0;i<t.length;i++){let a=t[i];this.move(r,o[i],a)}}moveBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let i=0;i<t.length;i++){let a=t[i];this.move(r,o[i],a)}}delete(r){this.deleteChildren(r),this.runOp({type:8,id:r})}sortNext(r){return this._current.sortNext(r)}sortPrevious(r){return this._current.sortPrevious(r)}getAllSorted(r){return this._current.getAllSorted(r)}},ki=class extends Rn{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[oc]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(r){let e=this.length;for(let t=0;t<e;t++){let o=this._current[t].id,i=this._current[t].fi;r(this.data(this._current[t].id),o,i)}}find(r){let e=this.length;for(let t=0;t<e;t++){let o=this._current[t].id;if(r(this.data(o),o))return this.get(o)}}update(r,e){this._current=this._current.modifyById(r,e)}randomId(){return this._current.randomId()}get(r){return{...this._current.get(r),data:this.data(r)}}data(r){let{_current:e,_children:t}=this,o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e.get(r)?.data,a=nc(this,r,i);return a!==i?(t===void 0&&(t={},this._children=t),t[r]=a,a):i}runOp(r){this.reportOp(r,this._current.runOp(r))}add(r,e,t){this.runOp({type:4,fi:r,id:e,data:t})}move(r,e){this.runOp({type:6,fi:r,id:e})}insertAfter(r,e){let t=this._current.insertAfterHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(t[o],i.id,i.data)}}insertBefore(r,e){let t=this._current.insertBeforeHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(t[o],i.id,i.data)}}moveAfter(r,e){let t=this._current.insertAfterHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(t[o],i)}}moveBefore(r,e){let t=this._current.insertBeforeHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(t[o],i)}}delete(r){this.deleteChildren(r),this.runOp({type:5,id:r})}};function Id(n,r,e){if(n.length>0){let t=n[n.length-1];if(t.type===0&&r.type===0&&rt.equal(t.path,e)){Object.assign(t.props,r.props);return}}n.push({...r,path:e})}var rc=class extends Rn{constructor(r){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=r}update(r,e){if(r!=="")throw new Error("");this._current=e}push(r,e,t,o){Id(this.ts,e,r),Id(this.actual,t,r),Id(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function nc(n,r,e){return e instanceof Xe?new Ui(n,r,e):e instanceof ve?new ki(n,r,e):e instanceof xe?new Proxy(new Dd(n,r,e),iT):e!==null&&typeof e=="object"?zi(e)?e:new Proxy(new Nd(n,r,e),nT):e}function Ed(n){let r=new rc(n);return[nc(r,"",n),r]}function Xo(n,r){let[e,t]=Ed(n);return r(e),t.result()}function ut(n){return n instanceof Ui||n instanceof ki?n._current:n!==null&&typeof n=="object"?n[tg]:n}var rt;(o=>{function n(i,a){if(a.length===i.length)for(var s=0;s<i.length;){if(i[s]!==a[s])return!1;s+=1}else return!1;return!0}o.equal=n;function r(i,a,s){let l=t(s,i);if(l!==void 0&&typeof l=="object"&&l!==null){let c={...a};return Object.keys(l).forEach(u=>{delete c[u]}),c}else return a}o.removeOverridden=r;function e(i,a){if((i instanceof Xe||i instanceof Ui)&&typeof a=="string")return i.data(a);if((i instanceof ve||i instanceof ki)&&typeof a=="string")return i.data(a);if(typeof a=="number"&&Array.isArray(i))return i[a];if(typeof a=="string"&&typeof i=="object"&&i!==null)return i[a]}o.zoomOnce=e;function t(i,a,s=0){for(;s<a.length&&i!==void 0;)i=e(i,a[s]),s+=1;return i}o.zoom=t})(rt||(rt={}));function og(n,r){let e=[];if(r.length===n.length)for(var t=0;t<n.length;){if(r[t]==="*")e.push(n[t]);else if(n[t]!==r[t])return null;t+=1}else return null;return e}function Be(n,r){let e=[];if(r.length<=n.length)for(var t=0;t<r.length;){if(r[t]==="*")e.push(n[t]);else if(n[t]!==r[t])return null;t+=1}else return null;return e}var ic=class{},Ss=class extends ic{constructor(e){super();this.id=e}},ws=class extends ic{constructor(e){super();this.data=e}};var Bd;try{Bd=new TextDecoder}catch{}var de,Qo,G=0;var dg=[],Ld=dg,Rd=0,Zt={},ke,Ko,yr=0,$r=0,lr,So,Wt=[],We,ng={useRecords:!1,mapsAsObjects:!0},Ps=class{},zd=new Ps;zd.name="MessagePack 0xC1";var Hi=!1,Yr=class{constructor(r){r&&(r.useRecords===!1&&r.mapsAsObjects===void 0&&(r.mapsAsObjects=!0),r.structures?r.structures.sharedLength=r.structures.length:r.getStructures&&((r.structures=[]).uninitialized=!0,r.structures.sharedLength=0)),Object.assign(this,r)}unpack(r,e){if(de)return yg(()=>(sc(),this?this.unpack(r,e):Yr.prototype.unpack.call(ng,r,e)));Qo=e>-1?e:r.length,G=0,Rd=0,$r=0,Ko=null,Ld=dg,lr=null,de=r;try{We=r.dataView||(r.dataView=new DataView(r.buffer,r.byteOffset,r.byteLength))}catch(t){throw de=null,r instanceof Uint8Array?t:new Error("Source must be a Uint8Array or Buffer but was a "+(r&&typeof r=="object"?r.constructor.name:typeof r))}if(this instanceof Yr){if(Zt=this,this.structures)return ke=this.structures,ac();(!ke||ke.length>0)&&(ke=[])}else Zt=ng,(!ke||ke.length>0)&&(ke=[]);return ac()}unpackMultiple(r,e){let t,o=0;try{Hi=!0;let i=r.length,a=this?this.unpack(r,i):uc.unpack(r,i);if(e){for(e(a);G<i;)if(o=G,e(ac())===!1)return}else{for(t=[a];G<i;)o=G,t.push(ac());return t}}catch(i){throw i.lastPosition=o,i.values=t,i}finally{Hi=!1,sc()}}_mergeStructures(r,e){r=r||[];for(let t=0,o=r.length;t<o;t++){let i=r[t];i&&(i.isShared=!0,t>=32&&(i.highByte=t-32>>5))}r.sharedLength=r.length;for(let t in e||[])if(t>=0){let o=r[t],i=e[t];i&&(o&&((r.restoreStructures||(r.restoreStructures=[]))[t]=o),r[t]=i)}return this.structures=r}decode(r,e){return this.unpack(r,e)}};function ac(){try{if(!Zt.trusted&&!Hi){let r=ke.sharedLength||0;r<ke.length&&(ke.length=r)}let n=dt();if(G==Qo)ke.restoreStructures&&ig(),ke=null,de=null,So&&(So=null);else if(G>Qo){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}else if(!Hi)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw ke.restoreStructures&&ig(),sc(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function ig(){for(let n in ke.restoreStructures)ke[n]=ke.restoreStructures[n];ke.restoreStructures=null}function dt(){let n=de[G++];if(n<160)if(n<128){if(n<64)return n;{let r=ke[n&63]||Zt.getStructures&&pg()[n&63];return r?(r.read||(r.read=Gd(r,n&63)),r.read()):n}}else if(n<144)if(n-=128,Zt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[hg()]=dt();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(dt(),dt());return r}else{n-=144;let r=new Array(n);for(let e=0;e<n;e++)r[e]=dt();return r}else if(n<192){let r=n-160;if($r>=G)return Ko.slice(G-yr,(G+=r)-yr);if($r==0&&Qo<140){let e=r<16?jd(r):fg(r);if(e!=null)return e}return Vd(r)}else{let r;switch(n){case 192:return null;case 193:return lr?(r=dt(),r>0?lr[1].slice(lr.position1,lr.position1+=r):lr[0].slice(lr.position0,lr.position0-=r)):zd;case 194:return!1;case 195:return!0;case 196:return _d(de[G++]);case 197:return r=We.getUint16(G),G+=2,_d(r);case 198:return r=We.getUint32(G),G+=4,_d(r);case 199:return Vn(de[G++]);case 200:return r=We.getUint16(G),G+=2,Vn(r);case 201:return r=We.getUint32(G),G+=4,Vn(r);case 202:if(r=We.getFloat32(G),Zt.useFloat32>2){let e=cc[(de[G]&127)<<1|de[G+1]>>7];return G+=4,(e*r+(r>0?.5:-.5)>>0)/e}return G+=4,r;case 203:return r=We.getFloat64(G),G+=8,r;case 204:return de[G++];case 205:return r=We.getUint16(G),G+=2,r;case 206:return r=We.getUint32(G),G+=4,r;case 207:return Zt.int64AsNumber?(r=We.getUint32(G)*4294967296,r+=We.getUint32(G+4)):r=We.getBigUint64(G),G+=8,r;case 208:return We.getInt8(G++);case 209:return r=We.getInt16(G),G+=2,r;case 210:return r=We.getInt32(G),G+=4,r;case 211:return Zt.int64AsNumber?(r=We.getInt32(G)*4294967296,r+=We.getUint32(G+4)):r=We.getBigInt64(G),G+=8,r;case 212:if(r=de[G++],r==114)return ug(de[G++]&63);{let e=Wt[r];if(e)return e.read?(G++,e.read(dt())):e.noBuffer?(G++,e()):e(de.subarray(G,++G));throw new Error("Unknown extension "+r)}case 213:return r=de[G],r==114?(G++,ug(de[G++]&63,de[G++])):Vn(2);case 214:return Vn(4);case 215:return Vn(8);case 216:return Vn(16);case 217:return r=de[G++],$r>=G?Ko.slice(G-yr,(G+=r)-yr):sT(r);case 218:return r=We.getUint16(G),G+=2,$r>=G?Ko.slice(G-yr,(G+=r)-yr):lT(r);case 219:return r=We.getUint32(G),G+=4,$r>=G?Ko.slice(G-yr,(G+=r)-yr):cT(r);case 220:return r=We.getUint16(G),G+=2,sg(r);case 221:return r=We.getUint32(G),G+=4,sg(r);case 222:return r=We.getUint16(G),G+=2,lg(r);case 223:return r=We.getUint32(G),G+=4,lg(r);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 aT=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Gd(n,r){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>aT.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(dt);return n.highByte===0&&(n.read=ag(r,n.read)),o()}let t={};for(let o=0,i=n.length;o<i;o++){let a=n[o];t[a]=dt()}return t}return e.count=0,n.highByte===0?ag(r,e):e}var ag=(n,r)=>function(){let e=de[G++];if(e===0)return r();let t=n<32?-(n+(e<<5)):n+(e<<5),o=ke[t]||pg()[t];if(!o)throw new Error("Record id is not defined for "+t);return o.read||(o.read=Gd(o,n)),o.read()};function pg(){let n=yg(()=>(de=null,Zt.getStructures()));return ke=Zt._mergeStructures(n,ke)}var Vd=lc,sT=lc,lT=lc,cT=lc;function lc(n){let r;if(n<16&&(r=jd(n)))return r;if(n>64&&Bd)return Bd.decode(de.subarray(G,G+=n));let e=G+n,t=[];for(r="";G<e;){let o=de[G++];if((o&128)===0)t.push(o);else if((o&224)===192){let i=de[G++]&63;t.push((o&31)<<6|i)}else if((o&240)===224){let i=de[G++]&63,a=de[G++]&63;t.push((o&31)<<12|i<<6|a)}else if((o&248)===240){let i=de[G++]&63,a=de[G++]&63,s=de[G++]&63,l=(o&7)<<18|i<<12|a<<6|s;l>65535&&(l-=65536,t.push(l>>>10&1023|55296),l=56320|l&1023),t.push(l)}else t.push(o);t.length>=4096&&(r+=Mt.apply(String,t),t.length=0)}return t.length>0&&(r+=Mt.apply(String,t)),r}function sg(n){let r=new Array(n);for(let e=0;e<n;e++)r[e]=dt();return r}function lg(n){if(Zt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[hg()]=dt();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(dt(),dt());return r}}var Mt=String.fromCharCode;function fg(n){let r=G,e=new Array(n);for(let t=0;t<n;t++){let o=de[G++];if((o&128)>0){G=r;return}e[t]=o}return Mt.apply(String,e)}function jd(n){if(n<4)if(n<2){if(n===0)return"";{let r=de[G++];if((r&128)>1){G-=1;return}return Mt(r)}}else{let r=de[G++],e=de[G++];if((r&128)>0||(e&128)>0){G-=2;return}if(n<3)return Mt(r,e);let t=de[G++];if((t&128)>0){G-=3;return}return Mt(r,e,t)}else{let r=de[G++],e=de[G++],t=de[G++],o=de[G++];if((r&128)>0||(e&128)>0||(t&128)>0||(o&128)>0){G-=4;return}if(n<6){if(n===4)return Mt(r,e,t,o);{let i=de[G++];if((i&128)>0){G-=5;return}return Mt(r,e,t,o,i)}}else if(n<8){let i=de[G++],a=de[G++];if((i&128)>0||(a&128)>0){G-=6;return}if(n<7)return Mt(r,e,t,o,i,a);let s=de[G++];if((s&128)>0){G-=7;return}return Mt(r,e,t,o,i,a,s)}else{let i=de[G++],a=de[G++],s=de[G++],l=de[G++];if((i&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){G-=8;return}if(n<10){if(n===8)return Mt(r,e,t,o,i,a,s,l);{let c=de[G++];if((c&128)>0){G-=9;return}return Mt(r,e,t,o,i,a,s,l,c)}}else if(n<12){let c=de[G++],u=de[G++];if((c&128)>0||(u&128)>0){G-=10;return}if(n<11)return Mt(r,e,t,o,i,a,s,l,c,u);let p=de[G++];if((p&128)>0){G-=11;return}return Mt(r,e,t,o,i,a,s,l,c,u,p)}else{let c=de[G++],u=de[G++],p=de[G++],d=de[G++];if((c&128)>0||(u&128)>0||(p&128)>0||(d&128)>0){G-=12;return}if(n<14){if(n===12)return Mt(r,e,t,o,i,a,s,l,c,u,p,d);{let h=de[G++];if((h&128)>0){G-=13;return}return Mt(r,e,t,o,i,a,s,l,c,u,p,d,h)}}else{let h=de[G++],f=de[G++];if((h&128)>0||(f&128)>0){G-=14;return}if(n<15)return Mt(r,e,t,o,i,a,s,l,c,u,p,d,h,f);let m=de[G++];if((m&128)>0){G-=15;return}return Mt(r,e,t,o,i,a,s,l,c,u,p,d,h,f,m)}}}}}function _d(n){return Zt.copyBuffers?Uint8Array.prototype.slice.call(de,G,G+=n):de.subarray(G,G+=n)}function Vn(n){let r=de[G++];if(Wt[r])return Wt[r](de.subarray(G,G+=n));throw new Error("Unknown extension type "+r)}var cg=new Array(4096);function hg(){let n=de[G++];if(n>=160&&n<192){if(n=n-160,$r>=G)return Ko.slice(G-yr,(G+=n)-yr);if(!($r==0&&Qo<180))return Vd(n)}else return G--,dt();let r=(n<<5^(n>1?We.getUint16(G):n>0?de[G]:0))&4095,e=cg[r],t=G,o=G+n-3,i,a=0;if(e&&e.bytes==n){for(;t<o;){if(i=We.getUint32(t),i!=e[a++]){t=1879048192;break}t+=4}for(o+=3;t<o;)if(i=de[t++],i!=e[a++]){t=1879048192;break}if(t===o)return G=t,e.string;o-=3,t=G}for(e=[],cg[r]=e,e.bytes=n;t<o;)i=We.getUint32(t),e.push(i),t+=4;for(o+=3;t<o;)i=de[t++],e.push(i);let s=n<16?jd(n):fg(n);return s!=null?e.string=s:e.string=Vd(n)}var ug=(n,r)=>{var e=dt();let t=n;r!==void 0&&(n=n<32?-((r<<5)+n):(r<<5)+n,e.highByte=r);let o=ke[n];return o&&o.isShared&&((ke.restoreStructures||(ke.restoreStructures=[]))[n]=o),ke[n]=e,e.read=Gd(e,t),e.read()},mg=typeof self=="object"?self:global;Wt[0]=()=>{};Wt[0].noBuffer=!0;Wt[101]=()=>{let n=dt();return(mg[n[0]]||Error)(n[1])};Wt[105]=n=>{let r=We.getUint32(G-4);So||(So=new Map);let e=de[G],t;e>=144&&e<160||e==220||e==221?t=[]:t={};let o={target:t};So.set(r,o);let i=dt();return o.used?Object.assign(t,i):(o.target=i,i)};Wt[112]=n=>{let r=We.getUint32(G-4),e=So.get(r);return e.used=!0,e.target};Wt[115]=()=>new Set(dt());var Fd=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");Wt[116]=n=>{let r=n[0],e=Fd[r];if(!e)throw new Error("Could not find typed array for code "+r);return new mg[e](Uint8Array.prototype.slice.call(n,1).buffer)};Wt[120]=()=>{let n=dt();return new RegExp(n[0],n[1])};Wt[98]=n=>{let r=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=G;G+=r-4,lr=[dt(),dt()],lr.position0=0,lr.position1=0;let t=G;G=e;try{return dt()}finally{G=t}};Wt[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 yg(n){let r=Qo,e=G,t=Rd,o=yr,i=$r,a=Ko,s=Ld,l=So,c=lr,u=new Uint8Array(de.slice(0,Qo)),p=ke,d=ke.slice(0,ke.length),h=Zt,f=Hi,m=n();return Qo=r,G=e,Rd=t,yr=o,$r=i,Ko=a,Ld=s,So=l,lr=c,de=u,Hi=f,ke=p,ke.splice(0,ke.length,...d),Zt=h,We=new DataView(de.buffer,de.byteOffset,de.byteLength),m}function sc(){de=null,So=null,ke=null}function gg(n){n.unpack?Wt[n.type]=n.unpack:Wt[n.type]=n}var cc=new Array(147);for(let n=0;n<256;n++)cc[n]=+("1e"+Math.floor(45.15-n*.30103));var uc=new Yr({useRecords:!1}),uT=uc.unpack,dT=uc.unpackMultiple,pT=uc.unpack,dc={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},fT=new Float32Array(1),tU=new Uint8Array(fT.buffer,0,4);var pc;try{pc=new TextEncoder}catch{}var fc,kd,hc=typeof Buffer<"u",Ud=hc?Buffer.allocUnsafeSlow:Uint8Array,Sg=hc?Buffer:Uint8Array,xg=hc?4294967296:2144337920,Q,ft,U=0,Xr,Kr=null,hT=/[\u0080-\uFFFF]/,Os=Symbol("record-id"),zn=class extends Yr{constructor(r){super(r),this.offset=0;let e,t,o,i,a,s,l=0,c=Sg.prototype.utf8Write?function(x,_,D){return Q.utf8Write(x,_,D)}:pc&&pc.encodeInto?function(x,_){return pc.encodeInto(x,Q.subarray(_)).written}:!1,u=this;r||(r={});let p=r&&r.sequential,d=r.structures||r.saveStructures,h=r.maxSharedStructures;if(h==null&&(h=d?32:0),h>8160)throw new Error("Maximum maxSharedStructure is 8160");let f=r.maxOwnStructures;f==null&&(f=d?32:64),p&&!r.saveStructures&&(this.structures=[]);let m=h>32||f+h>64,y=h+64,g=h+f+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],O=0,P=0;this.pack=this.encode=function(x,_){if(Q||(Q=new Ud(8192),ft=new DataView(Q.buffer,0,8192),U=0),Xr=Q.length-10,Xr-U<2048?(Q=new Ud(Q.length),ft=new DataView(Q.buffer,0,Q.length),Xr=Q.length-10,U=0):U=U+7&2147483640,t=U,s=u.structuredClone?new Map:null,u.bundleStrings?(Kr=["",""],Q[U++]=214,Q[U++]=98,Kr.position=U-t,U+=4):Kr=null,o=u.structures,o){o.uninitialized&&(o=u._mergeStructures(u.getStructures()));let D=o.sharedLength||0;if(D>h)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+o.sharedLength);if(!o.transitions){o.transitions=Object.create(null);for(let A=0;A<D;A++){let N=o[A];if(!N)continue;let E,B=o.transitions;for(let V=0,j=N.length;V<j;V++){let R=N[V];E=B[R],E||(E=B[R]=Object.create(null)),B=E}B[Os]=A+64}l=D}p||(o.nextId=D+64)}i&&(i=!1),a=o||[];try{if(S(x),Kr){ft.setUint32(Kr.position+t,U-Kr.position-t);let D=Kr;Kr=null,S(D[0]),S(D[1])}if(u.offset=U,s&&s.idsToInsert){U+=s.idsToInsert.length*6,U>Xr&&I(U),u.offset=U;let D=yT(Q.subarray(t,U),s.idsToInsert);return s=null,D}return _&Pg?(Q.start=t,Q.end=U,Q):Q.subarray(t,U)}finally{if(o){if(P<10&&P++,O>1e4)o.transitions=null,P=0,O=0,v.length>0&&(v=[]);else if(v.length>0&&!p){for(let D=0,A=v.length;D<A;D++)v[D][Os]=0;v=[]}if(i&&u.saveStructures){let D=o.sharedLength||h;o.length>D&&(o=o.slice(0,D));let A=Q.subarray(t,U);return u.saveStructures(o,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(x)):(l=D,A)}}_&PT&&(U=t)}};let S=x=>{U>Xr&&(Q=I(U));var _=typeof x,D;if(_==="string"){let A=x.length;if(Kr&&A>=8&&A<4096){let B=hT.test(x);Kr[B?0:1]+=x,Q[U++]=193,S(B?-A:A);return}let N;A<32?N=1:A<256?N=2:A<65536?N=3:N=5;let E=A*3;if(U+E>Xr&&(Q=I(U+E)),A<64||!c){let B,V,j,R=U+N;for(B=0;B<A;B++)V=x.charCodeAt(B),V<128?Q[R++]=V:V<2048?(Q[R++]=V>>6|192,Q[R++]=V&63|128):(V&64512)===55296&&((j=x.charCodeAt(B+1))&64512)===56320?(V=65536+((V&1023)<<10)+(j&1023),B++,Q[R++]=V>>18|240,Q[R++]=V>>12&63|128,Q[R++]=V>>6&63|128,Q[R++]=V&63|128):(Q[R++]=V>>12|224,Q[R++]=V>>6&63|128,Q[R++]=V&63|128);D=R-U-N}else D=c(x,U+N,E);D<32?Q[U++]=160|D:D<256?(N<2&&Q.copyWithin(U+2,U+1,U+1+D),Q[U++]=217,Q[U++]=D):D<65536?(N<3&&Q.copyWithin(U+3,U+2,U+2+D),Q[U++]=218,Q[U++]=D>>8,Q[U++]=D&255):(N<5&&Q.copyWithin(U+5,U+3,U+3+D),Q[U++]=219,ft.setUint32(U,D),U+=4),U+=D}else if(_==="number")if(x>>>0===x)x<64?Q[U++]=x:x<256?(Q[U++]=204,Q[U++]=x):x<65536?(Q[U++]=205,Q[U++]=x>>8,Q[U++]=x&255):(Q[U++]=206,ft.setUint32(U,x),U+=4);else if(x>>0===x)x>=-32?Q[U++]=256+x:x>=-128?(Q[U++]=208,Q[U++]=x+256):x>=-32768?(Q[U++]=209,ft.setInt16(U,x),U+=2):(Q[U++]=210,ft.setInt32(U,x),U+=4);else{let A;if((A=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){Q[U++]=202,ft.setFloat32(U,x);let N;if(A<4||(N=x*cc[(Q[U]&127)<<1|Q[U+1]>>7])>>0===N){U+=4;return}else U--}Q[U++]=203,ft.setFloat64(U,x),U+=8}else if(_==="object")if(!x)Q[U++]=192;else{if(s){let N=s.get(x);if(N){if(!N.id){let E=s.idsToInsert||(s.idsToInsert=[]);N.id=E.push(N)}Q[U++]=214,Q[U++]=112,ft.setUint32(U,N.id),U+=4;return}else s.set(x,{offset:U-t})}let A=x.constructor;if(A===Object)T(x,!0);else if(A===Array){D=x.length,D<16?Q[U++]=144|D:D<65536?(Q[U++]=220,Q[U++]=D>>8,Q[U++]=D&255):(Q[U++]=221,ft.setUint32(U,D),U+=4);for(let N=0;N<D;N++)S(x[N])}else if(A===Map){D=x.size,D<16?Q[U++]=128|D:D<65536?(Q[U++]=222,Q[U++]=D>>8,Q[U++]=D&255):(Q[U++]=223,ft.setUint32(U,D),U+=4);for(let[N,E]of x)S(N),S(E)}else{for(let N=0,E=fc.length;N<E;N++){let B=kd[N];if(x instanceof B){let V=fc[N];if(V.write){V.type&&(Q[U++]=212,Q[U++]=V.type,Q[U++]=0),S(V.write.call(this,x));return}let j=Q,R=ft,W=U;Q=null;let F;try{F=V.pack.call(this,x,k=>(Q=j,j=null,U+=k,U>Xr&&I(U),{target:Q,targetView:ft,position:U-k}),S)}finally{j&&(Q=j,ft=R,U=W,Xr=Q.length-10)}F&&(F.length+U>Xr&&I(F.length+U),U=mT(F,Q,U,V.type));return}}T(x,!x.hasOwnProperty)}}else if(_==="boolean")Q[U++]=x?195:194;else if(_==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))Q[U++]=211,ft.setBigInt64(U,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)Q[U++]=207,ft.setBigUint64(U,x);else if(this.largeBigIntToFloat)Q[U++]=203,ft.setFloat64(U,Number(x));else throw new RangeError(x+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");U+=8}else if(_==="undefined")this.encodeUndefinedAsNil?Q[U++]=192:(Q[U++]=212,Q[U++]=0,Q[U++]=0);else if(_==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+_)},T=this.useRecords===!1?this.variableMapSize?x=>{let _=Object.keys(x),D=_.length;D<16?Q[U++]=128|D:D<65536?(Q[U++]=222,Q[U++]=D>>8,Q[U++]=D&255):(Q[U++]=223,ft.setUint32(U,D),U+=4);let A;for(let N=0;N<D;N++)S(A=_[N]),S(x[A])}:(x,_)=>{Q[U++]=222;let D=U-t;U+=2;let A=0;for(let N in x)(_||x.hasOwnProperty(N))&&(S(N),S(x[N]),A++);Q[D+++t]=A>>8,Q[D+t]=A&255}:x=>{let _=Object.keys(x),D,A=a.transitions||(a.transitions=Object.create(null)),N=0;for(let B=0,V=_.length;B<V;B++){let j=_[B];D=A[j],D||(D=A[j]=Object.create(null),N++),A=D}let E=A[Os];if(E)E>=96&&m?(Q[U++]=((E-=96)&31)+96,Q[U++]=E>>5):Q[U++]=E;else{E=a.nextId,E||(E=64),E<y&&this.shouldShareStructure&&!this.shouldShareStructure(_)?(E=a.nextOwnId,E<g||(E=y),a.nextOwnId=E+1):(E>=g&&(E=y),a.nextId=E+1);let B=_.highByte=E>=96&&m?E-96>>5:-1;A[Os]=E,a[E-64]=_,E<y?(_.isShared=!0,a.sharedLength=E-63,i=!0,B>=0?(Q[U++]=(E&31)+96,Q[U++]=B):Q[U++]=E):(B>=0?(Q[U++]=213,Q[U++]=114,Q[U++]=(E&31)+96,Q[U++]=B):(Q[U++]=212,Q[U++]=114,Q[U++]=E),N&&(O+=P*N),v.length>=f&&(v.shift()[Os]=0),v.push(A),S(_))}for(let B=0,V=_.length;B<V;B++)S(x[_[B]])},I=x=>{let _;if(x>16777216){if(x-t>xg)throw new Error("Packed buffer would be larger than maximum buffer size");_=Math.min(xg,Math.round(Math.max((x-t)*(x>67108864?1.25:2),4194304)/4096)*4096)}else _=(Math.max(x-t<<2,Q.length-1)>>12)+1<<12;let D=new Ud(_);return ft=new DataView(D.buffer,0,_),Q.copy?Q.copy(D,0,t,x):D.set(Q.slice(t,x)),U-=t,t=0,Xr=D.length-10,Q=D}}useBuffer(r){Q=r,ft=new DataView(Q.buffer,Q.byteOffset,Q.byteLength),U=0}};kd=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Ps];fc=[{pack(n,r,e){let t=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&t>=0&&t<4294967296){let{target:o,targetView:i,position:a}=r(6);o[a++]=214,o[a++]=255,i.setUint32(a,t)}else if(t>0&&t<17179869184){let{target:o,targetView:i,position:a}=r(10);o[a++]=215,o[a++]=255,i.setUint32(a,n.getMilliseconds()*4e6+(t/1e3/4294967296>>0)),i.setUint32(a+4,t)}else if(isNaN(t)){if(this.onInvalidDate)return r(0),e(this.onInvalidDate());let{target:o,targetView:i,position:a}=r(3);o[a++]=212,o[a++]=255,o[a++]=255}else{let{target:o,targetView:i,position:a}=r(15);o[a++]=199,o[a++]=12,o[a++]=255,i.setUint32(a,n.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(t)))}}},{pack(n,r,e){let t=Array.from(n),{target:o,position:i}=r(this.structuredClone?3:0);this.structuredClone&&(o[i++]=212,o[i++]=115,o[i++]=0),e(t)}},{pack(n,r,e){let{target:t,position:o}=r(this.structuredClone?3:0);this.structuredClone&&(t[o++]=212,t[o++]=101,t[o++]=0),e([n.name,n.message])}},{pack(n,r,e){let{target:t,position:o}=r(this.structuredClone?3:0);this.structuredClone&&(t[o++]=212,t[o++]=120,t[o++]=0),e([n.source,n.flags])}},{pack(n,r){this.structuredClone?bg(n,16,r):vg(hc?Buffer.from(n):new Uint8Array(n),r)}},{pack(n,r){let e=n.constructor;e!==Sg&&this.structuredClone?bg(n,Fd.indexOf(e.name),r):vg(n,r)}},{pack(n,r){let{target:e,position:t}=r(1);e[t]=193}}];function bg(n,r,e,t){let o=n.byteLength;if(o+1<256){var{target:i,position:a}=e(4+o);i[a++]=199,i[a++]=o+1}else if(o+1<65536){var{target:i,position:a}=e(5+o);i[a++]=200,i[a++]=o+1>>8,i[a++]=o+1&255}else{var{target:i,position:a,targetView:s}=e(7+o);i[a++]=201,s.setUint32(a,o+1),a+=4}i[a++]=116,i[a++]=r,i.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),a)}function vg(n,r){let e=n.byteLength;var t,o;if(e<256){var{target:t,position:o}=r(e+2);t[o++]=196,t[o++]=e}else if(e<65536){var{target:t,position:o}=r(e+3);t[o++]=197,t[o++]=e>>8,t[o++]=e&255}else{var{target:t,position:o,targetView:i}=r(e+5);t[o++]=198,i.setUint32(o,e),o+=4}t.set(n,o)}function mT(n,r,e,t){let o=n.length;switch(o){case 1:r[e++]=212;break;case 2:r[e++]=213;break;case 4:r[e++]=214;break;case 8:r[e++]=215;break;case 16:r[e++]=216;break;default:o<256?(r[e++]=199,r[e++]=o):o<65536?(r[e++]=200,r[e++]=o>>8,r[e++]=o&255):(r[e++]=201,r[e++]=o>>24,r[e++]=o>>16&255,r[e++]=o>>8&255,r[e++]=o&255)}return r[e++]=t,r.set(n,e),e+=o,e}function yT(n,r){let e,t=r.length*6,o=n.length-t;for(r.sort((i,a)=>i.offset>a.offset?1:-1);e=r.pop();){let i=e.offset,a=e.id;n.copyWithin(i+t,i,o),t-=6;let s=i+t;n[s++]=214,n[s++]=105,n[s++]=a>>24,n[s++]=a>>16&255,n[s++]=a>>8&255,n[s++]=a&255,o=i}return n}function Zo(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)");kd.unshift(n.Class),fc.unshift(n)}gg(n)}var wg=new zn({useRecords:!1}),gT=wg.pack,xT=wg.pack;var{NEVER:bT,ALWAYS:vT,DECIMAL_ROUND:ST,DECIMAL_FIT:wT}=dc,Pg=512,PT=1024;var Og=new zn({structuredClone:!0});Zo({Class:xe.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,xe.prototype),n}});Zo({Class:ve.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,ve.prototype),n}});Zo({Class:Xe.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Xe.prototype),n}});Zo({Class:Ss.prototype.constructor,type:4,write(n){return n.id},read(n){return new Ss(n)}});Zo({Class:ws.prototype.constructor,type:5,write(n){return n.data},read(n){return new ws(n)}});Zo({Class:Ke.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Ke.prototype),n}});function OT(n){var r=0;if(n.length===0)return r;for(let e=0;e<n.length;e++){let t=n[e];r=(r<<5)-r+t,r=r&r}return r}function Hd(n){if(zi(n))return n;if(Array.isArray(n))return n.map(Hd);if(typeof n=="object"&&n!==null){let r={};for(let e of Object.keys(n).sort())r[e]=Hd(n[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else return n}var mc;(t=>{function n(o){return Og.pack(o)}t.serialize=n;function r(o){return Og.unpack(o)}t.deserialize=r;function e(o){return OT(n(Hd(o))).toString()}t.checksum=e})(mc||(mc={}));var tn="personal camera",rn="a218fcc3-276b-49b9-b485-49037fd14f5f",Ig=2960946,ht=5526619;var Wi;(h=>{function n(f,m){return f[0]===m[0]&&f[1]===m[1]}h.isEqual=n;function r(f,m,y){return[f[0]+(m[0]-f[0])*y,f[1]+(m[1]-f[1])*y]}h.lerp=r;function e(f,m){return[f[0]+m[0],f[1]+m[1]]}h.add=e;function t(f,m){return[f[0]-m[0],f[1]-m[1]]}h.sub=t;function o(f,m){return[f[0]*m[0],f[1]*m[1]]}h.multiply=o;function i(f,m){return[f[0]/m[0],f[1]/m[1]]}h.divide=i;function a(f,m){return Math.pow(m[0]-f[0],2)+Math.pow(m[1]-f[1],2)}h.distanceSquared=a;function s(f,m){return Math.sqrt(a(f,m))}h.distance=s;function l(f,m){return f[0]*m[0]+f[1]*m[1]}h.dot=l;function c(f,m){return[f[0]*m,f[1]*m]}h.scalarMultiply=c;function u(f,m,y){let g=h.sub(m,f),v=h.sub(y,f),O=h.dot(g,v)/h.dot(g,g),P=h.scalarMultiply(g,O);return h.add(f,P)}h.projectionOnto=u;function p(f,m,y){return s(f,u(f,m,y))}h.projectionOntoDistance=p;function d(f,m){return[(f[0]+m[0])*.5,(f[1]+m[1])*.5]}h.center=d})(Wi||(Wi={}));var Jo;(s=>{function n(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}s.isEqual=n;function r(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]}s.add=r;function e(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]}s.sub=e;function t(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]}s.div=t;function o(l,c){return[l[0]*c[0],l[1]*c[1],l[2]*c[2]]}s.mul=o;function i(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])}s.dist=i;function a(l,c,u){return[l[0]+(c[0]-l[0])*u,l[1]+(c[1]-l[1])*u,l[2]+(c[2]-l[2])*u]}s.lerp=a})(Jo||(Jo={}));var Cg;(e=>{function n(t,o){return t[0]===o[0]&&t[1]===o[1]&&t[2]===o[2]&&t[3]===o[3]}e.isEqual=n;function r(t,o,i){return[t[0]+(o[0]-t[0])*i,t[1]+(o[1]-t[1])*i,t[2]+(o[2]-t[2])*i,t[3]+(o[3]-t[3])*i]}e.lerp=r})(Cg||(Cg={}));var en;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function r(i,a){for(let s=0;s<16;s++)if(i[s]!==a[s])return!1;return!0}o.isEqual=r;function e(i){return i??o.identity}o.simplify=e;function t(i,a){let s=a.slice(0);for(var l=0,c=a.length;l<c;l+=3){let u=i[3]*a[l]+i[7]*a[l+1]+i[11]*a[l+2]+i[15];s[l]=(i[0]*a[l]+i[4]*a[l+1]+i[8]*a[l+2]+i[12])/u,s[l+1]=(i[1]*a[l]+i[5]*a[l+1]+i[9]*a[l+2]+i[13])/u,s[l+2]=(i[2]*a[l]+i[6]*a[l+1]+i[10]*a[l+2]+i[14])/u}return s}o.applyMatrix4=t})(en||(en={}));var St;(p=>{function n(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}p.isRGB=n,p.white={r:1,g:1,b:1},p.red={r:1,g:0,b:0},p.black={r:0,g:0,b:0};function o(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}p.toRgb255a1=o;function i(d){return{r:d.r,g:d.g,b:d.b}}p.clone=i;function a(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}p.fromHex=a;function s(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}p.toHex=s;function l(d,h){return d.r===h.r&&d.g===h.g&&d.b===h.b}p.equals=l;function c(d,h){return d.r.toFixed(2)===h.r.toFixed(2)&&d.g.toFixed(2)===h.g.toFixed(2)&&d.b.toFixed(2)===h.b.toFixed(2)}p.equalsFixed=c;function u(d,h,f){return{r:d.r+(h.r-d.r)*f,g:d.g+(h.g-d.g)*f,b:d.b+(h.b-d.b)*f}}p.lerp=u})(St||(St={}));var Ie;(c=>{c.white={...St.white,a:1},c.transparent={...St.white,a:0};function e(u){return{r:u[0],g:u[1],b:u[2],a:u[3]}}c.from0to1=e;function t(u,p){return{...St.fromHex(u),a:p}}c.fromHexAndA=t;function o(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:u.a}}c.toRgb255a1=o;function i(u,p){return St.equals(u,p)&&u.a===p.a}c.equals=i;function a(u,p){return St.equalsFixed(u,p)&&u.a.toFixed(2)===p.a.toFixed(2)}c.equalsFixed=a;function s(u,p,d){return{r:u.r+(p.r-u.r)*d,g:u.g+(p.g-u.g)*d,b:u.b+(p.b-u.b)*d,a:u.a+(p.a-u.a)*d}}c.lerp=s;function l({r:u,g:p,b:d,a:h}=c.white){return`rgba(${u*255}, ${p*255}, ${d*255}, ${h})`}c.toStyle=l})(Ie||(Ie={}));var yc;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(yc||(yc={}));var Tg;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(Tg||(Tg={}));var Ag;(r=>r.defaultData={control1:[.5,0],control2:[.5,1]})(Ag||(Ag={}));var Mg;(i=>(i.linear=[0,0,1,1],i.ease=[.25,.1,.25,1],i.easeIn=[.42,0,1,1],i.easeOut=[0,0,.58,1],i.easeInOut=[.42,0,.58,1]))(Mg||(Mg={}));function Wd(n){return typeof n=="string"&&n.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n):!1}var Ir;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(Ir||(Ir={}));var on;(o=>{o.DefaultUp=[0,1,0],o.DefaultTargetOffset=1e3,o.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective?.zoom??1:i.orthographic?.zoom??1}o.getZoom=t})(on||(on={}));var Qr;(e=>{function n(t,o=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[t[0]+t[0]*o,0,0]},grid:{count:[2,2,2],size:t.map(i=>i*(1+o)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=n;function r(t,o){let i={...t};if(CT.forEach(a=>{Object.assign(i,{[a]:o[a]??t[a]})}),i.radial={...t.radial},o.radial){let a=t.radial,s=o.radial;TT.forEach(l=>{Object.assign(i.radial,{[l]:s[l]??a[l]})})}if(i.linear={...t.linear},o.linear){let a=t.linear,s=o.linear;AT.forEach(l=>{Object.assign(i.linear,{[l]:s[l]??a[l]})})}if(i.grid={...t.grid},o.grid){let a=t.grid,s=o.grid;MT.forEach(l=>{Object.assign(i.grid,{[l]:s[l]??a[l]})})}if(i.toObject={...t.toObject},o.toObject){let a=t.toObject,s=o.toObject;IT.forEach(l=>{Object.assign(i.toObject,{[l]:s[l]??a[l]})})}if(i.randomnessObject={...t.randomnessObject},o.randomnessObject){let a=t.randomnessObject,s=o.randomnessObject;NT.forEach(l=>{Object.assign(i.randomnessObject,{[l]:s[l]??a[l]})})}return i}e.merge=r})(Qr||(Qr={}));var gc;(t=>{t.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let r=["radial","linear","grid","toObject","randomnessObject"];function e(o,i){let a=[];o.count!==void 0&&a.push({type:0,path:i,props:{count:o.count}});for(let s of r){let l=o[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...i,s],props:l})}return a}t.toOps=e})(gc||(gc={}));var CT=["count"],TT=["radius","start","end","position","scale","rotation"],AT=["position","scale","rotation"],MT=["count","size"],IT=["count","position","scale","rotation"],NT=["strength","scale","rotation","position","movement","seed","freqScale"];var xc;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function r(t){return e.all.includes(t)}e.is=r})(xc||(xc={}));var bc;(e=>{function n(t){return r(t)}e.defaultData=n;function r(t){if(t==="PointLight")return{type:t,color:Ie.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(t==="SpotLight")return{type:t,color:Ie.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(t==="DirectionalLight")return{type:t,color:Ie.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(bc||(bc={}));var qi;(t=>(t.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},t.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},t.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:t.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeLoopDelayStart:"end",emitTimeDuration:1,...t.defaultCollisionData}))(qi||(qi={}));var nn;(r=>r.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(nn||(nn={}));var qd;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function r(t,o){return t.castShadow===o.castShadow&&t.receiveShadow===o.receiveShadow}e.equals=r})(qd||(qd={}));var $d;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function r(t,o){return t.flatShading===o.flatShading&&t.side===o.side&&t.wireframe===o.wireframe}e.equals=r})($d||($d={}));var vc;(r=>r.defaultData={...$d.defaultData,...qd.defaultData})(vc||(vc={}));var Ng;(r=>{function n(e,t){let o=[];if("material"in e){let i=typeof e.material=="string"?t.materials[e.material]??t.lib.materials[e.material]?.asset:e.material;i&&o.push(i)}else if("materials"in e)for(let i of e.materials){let a=typeof i=="string"?t.materials[i]??t.lib.materials[i]?.asset:i;a&&o.push(a)}return o}r.getMaterialData=n})(Ng||(Ng={}));var $i;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))($i||($i={}));var Dg;(r=>{function n(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="particle"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}r.is=n})(Dg||(Dg={}));function _g(n){return n.type!=="displace"}var Eg;(r=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}r.is=n})(Eg||(Eg={}));var Bg=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],Lg=["wrapping","image","video","name","minFilter"],xt;(o=>{function n(i,a){let{texture:s,...l}=a;if(Object.assign(i,l),s){let c=i.texture;c&&Object.assign(c,s)}}o.patch=n;function r(i,a){return i==="light"&&a?e(a):t(i)}o.defaultData=r;function e(i){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(i){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function t(i){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(i){case"texture":return{...a,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:$i.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},crop:!1};case"color":return{...a,type:"color",color:St.fromHex(ht)};case"depth":return{...a,type:"depth",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]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",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{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...St.fromHex(6710886),a:1},colorB:{...St.fromHex(6710886),a:1},colorC:{...St.fromHex(16777215),a:1},colorD:{...St.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:Ie.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,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,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Ie.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:Ie.fromHexAndA(0,1),contourColor:Ie.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008}};case"transmission":return{...a,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...St.fromHex(0),a:1},colorB:{...St.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(xt||(xt={}));var Lt;(c=>{function n(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}c.isMergable=n;function r(u){let p="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([h,f])=>{p+=`${h}${f}`,Array.isArray(f)?f.forEach(m=>p+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?p+=`${m.toFixed(4)}`:p+=`${m}`}):p+=`${f}`})}),p}c.getHash=r;function e(){return{layers:new ve}}c.defaultEmptyData=e;function t(u="layer1",p="layer2"){return i("phong",u,p)}c.defaultData=t;function o(u,p){return{...u,name:p}}c.withName=o;function i(u,p="layer1",d="layer2"){let h=new ve;return h.push({fi:0,data:xt.defaultData("light",u),id:p}),h.push({fi:1,data:xt.defaultData("color"),id:d}),{layers:h}}c.defaultTwoLayerData=i;function a(u){let p=xt.defaultData("texture");u&&Object.assign(p.texture,{image:u});let d=new ve;return d.push({fi:0,data:p,id:"layer1"}),d.push({fi:1,data:{...xt.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...xt.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}c.defaultUIObjectMaterial=a;function s(u,p="phong",d="layer1",h="layer2"){let f=xt.defaultData("texture");Object.assign(f.texture,{image:u});let m=new ve;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:xt.defaultData("light",p),id:h}),{layers:m}}c.defaultTwoLayerTextureData=s;function l(u,p="phong",d="layer1",h="layer2"){let f=xt.defaultData("video");Object.assign(f.texture,{video:u});let m=new ve;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:xt.defaultData("light",p),id:h}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})(Lt||(Lt={}));var Yi;(r=>{function n(){return{points:new ve,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n})(Yi||(Yi={}));var Xi;(r=>{function n(){return{points:new ve,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}r.defaultData=n})(Xi||(Xi={}));var Yd={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Sc;(r=>{function n(e,t){let o={...e};return DT.forEach(i=>{Object.assign(o,{[i]:t[i]??e[i]})}),o}r.merge=n})(Sc||(Sc={}));var wc={shape:Yd,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},DT=["depth","offset","angle","twist","startScale","endScale"];var Cs;(e=>{function n(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"||t==="UIGeometry"}e.is2DParametricMesh=n;function r(t){return t==="PolygonGeometry"||t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"||t==="PathGeometry"||t==="VectorGeometry"||t==="ConeGeometry"||t==="CubeGeometry"||t==="CylinderGeometry"||t==="DodecahedronGeometry"||t==="HelixGeometry"||t==="IcosahedronGeometry"||t==="LatheGeometry"||t==="PyramidGeometry"||t==="SphereGeometry"||t==="PlaneGeometry"||t==="BackdropGeometry"||t==="TorusGeometry"||t==="TorusKnotGeometry"||t==="BooleanGeometry"||t==="TextGeometry"}e.isParametricMesh=r})(Cs||(Cs={}));var Pc;(r=>{function n(e,t){let o={...e};return Object.assign(o,t),o.type==="PathGeometry"&&"extrusion"in t&&t.extrusion&&(o.extrusion={...e.extrusion},Object.assign(o.extrusion,Sc.merge(o.extrusion,t.extrusion))),o}r.merge=n})(Pc||(Pc={}));var an;(r=>{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};if(e==="UIGeometry")return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:Xi.defaultData(),extrusion:wc};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Yi.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}r.defaultData=n})(an||(an={}));var Oc;(r=>r.defaultData={enabled:!1,useBackgroundColor:!1,color:St.white,near:.1,far:2e3})(Oc||(Oc={}));var Cc;(e=>{let n={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...n,blendFunction:16,granularity:15},bloom:{...n,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...n,offset:[2,2]},vignette:{...n,darkness:1,offset:0},hueSaturation:{...n,hue:3,saturation:0},brightnessContrast:{...n,brightness:.25,contrast:0},depthOfField:{...n,focalLength:2,focusDistance:2,bokehScale:2},noise:{...n,blendFunction:16}}})(Cc||(Cc={}));var Xd;(r=>r.defaultData={softShadowQuality:"low"})(Xd||(Xd={}));var Kd;(r=>r.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Kd||(Kd={}));var Qd;(r=>r.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Qd||(Qd={}));var Ts;(r=>r.defaultData={usePhysics:!1,gravity:-10})(Ts||(Ts={}));var Zd;(r=>r.defaultData={playCamera:tn,gameControlObject:null})(Zd||(Zd={}));var Tc;(r=>r.defaultData={backgroundColor:Ie.fromHexAndA(Ig,1),postprocessing:Cc.defaultData,fog:Oc.defaultData,globalPhysics:Ts.defaultData,ambient:Kd.defaultData,ao:Qd.defaultData,shadow:Xd.defaultData,publish:Zd.defaultData})(Tc||(Tc={}));var Ac;(r=>r.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(Ac||(Ac={}));var Rg;(e=>{function n(t){return t==="Component"||t==="Instance"}e.isComponentRelated=n;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(Rg||(Rg={}));var Ki;(o=>{o.identity={...yc.identity,hiddenMatrix:en.identity};function r(i){return{position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix}}o.fromObject=r;function e(i,a){return{position:a?.position||i.position,rotation:a?.rotation||i.rotation,scale:a?.scale||i.scale,hiddenMatrix:a?.hiddenMatrix||i.hiddenMatrix}}o.merge=e;function t(i,a){return Tl({position:Jo.isEqual(i.position,a.position)?void 0:a.position,rotation:Jo.isEqual(i.rotation,a.rotation)?void 0:a.rotation,scale:Jo.isEqual(i.scale,a.scale)?null:a.scale,hiddenMatrix:en.isEqual(i.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=t})(Ki||(Ki={}));var wt;(r=>r.defaultData={states:new ve,events:new ve,visible:!0,raycastLock:!1,physics:nn.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Ki.identity,cloner:null})(wt||(wt={}));var Mc;(r=>r.defaultData={type:"Empty",...wt.defaultData})(Mc||(Mc={}));var Vg;(r=>r.defaultData={type:"ParticleCollider",...Ac.defaultData,...wt.defaultData})(Vg||(Vg={}));var zg;(r=>r.defaultData={type:"Component",...wt.defaultData})(zg||(zg={}));var Gg;(r=>r.defaultData={type:"Particle",...wt.defaultData,...qi.defaultData})(Gg||(Gg={}));var Gn;(r=>r.defaultData={type:"Mesh",...wt.defaultData,...vc.defaultData})(Gn||(Gn={}));var jn;(r=>r.defaultData={...wt.defaultData,...Ki.identity,position:[0,0,on.DefaultTargetOffset],...on.defaultData})(jn||(jn={}));var Ic;(e=>{function n(t){return{...wt.defaultData,...bc.defaultData(t)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Ic||(Ic={}));var Qi;(e=>{function n(t,o,i=0){for(;i<o.length;){let a=t?t[o[i]]:void 0;if(o.length===i+1)return a;if(a)t=a.descendants,i+=1;else return}}e.resolveWithDes=n;function r(t,o,i=0){let a=n(t,o,i);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=r})(Qi||(Qi={}));var Zr;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function t(a,s){return{...wt.defaultData,...s,component:a,overrides:new Ke,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=t;function o(a){let s=Ki.fromObject(a.data);return t(a.id,s)}i.fromComponentData=o})(Zr||(Zr={}));var wo;(e=>{e.defaultData={type:"Page",...wt.defaultData,physics:{...nn.defaultData,fusedBody:!1},...Tc.defaultData,camera:jn.defaultData};function r(t){return t.uiScene!==void 0}e.isUIPage=r})(wo||(wo={}));var Nc;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:en.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:nn.defaultData,states:new ve,events:new ve,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...on.defaultData},i.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},i.defaultMeshObject={name:"Rectangle",...wt.defaultData,...Gn.defaultData,geometry:an.defaultData("RectangleGeometry"),material:Lt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...wt.defaultData,...Gn.defaultData,geometry:an.defaultData("BooleanGeometry"),material:Lt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...wt.defaultData,...Gn.defaultData,geometry:an.defaultData("TextGeometry"),material:Lt.defaultTwoLayerData("phong","layer1","layer2")}))(Nc||(Nc={}));var Fn;(o=>{function n(i,a){let s={name:a};return i.type==="Mesh"?(s.geometry={},"material"in i&&(s.material={layers:new Ke}),"materials"in i&&(s.materials=i.materials.map(l=>({layers:new Ke})))):Ir.is(i.type)&&(s.perspective={},s.orthographic={}),s}o.newEmpty=n;function r(i,a){if(a===void 0)return i;let s={...i};return"material"in s&&"material"in a&&a.material&&(s.material=Xo(s.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(a.material.layers)){let p=l.layers.data(c);p&&xt.patch(p,u)}}).data),s.materials&&a.materials&&(s.materials=Xo(s.materials,l=>{for(let c=0;c<s.materials.length;c++){let u=a.materials[c];if(typeof u!="string")for(let[p,d]of Object.entries(u.layers)){let h=l[c]?.layers?.data(p);h&&xt.patch(h,d)}}}).data),s}function e(i,a){let s,l=[],c={orthographic:0,perspective:0,geometry:0};function u(p,d){for(let[h,f]of Object.entries(d.layers)){let{texture:m,...y}=f;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...p,"layers",h,"texture"],props:m,type:0};l.push(g)}if(Object.keys(y).length>0){let g={path:[...p,"layers",h],props:y,type:0};l.push(g)}}}for(let[p,d]of Object.entries(a))if(p!=="name")if(p==="cloner")l.push(...gc.toOps(d,["cloner"]));else if(p==="pathSnapping")l.push({path:[p],props:{slide:d.slide,offset:d.offset},type:0});else if(p==="material")u(["material"],d);else if(p==="materials")for(let[h,f]of Object.entries(d))u(["materials",h],f);else if(c[p]===0){if(p==="geometry"&&d.extrusion!==void 0){let h={path:[p,"extrusion"],props:d.extrusion,type:0};l.push(h),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let h={path:[p],props:d,type:0};l.push(h)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[p]=d;return l}o.toOps=e;function t(i,a){if(a===void 0)return i;let s={...i};if(Object.assign(s,Ki.merge(s,a)),Object.assign(s,{pathSnapping:Object.assign({},s.pathSnapping,{slide:a.pathSnapping?.slide??s.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??s.pathSnapping?.offset??0})}),Ir.is(i.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let l=a;l.orthographic?.zoom!==void 0&&(s.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(s.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(s.targetOffset=l.targetOffset)}else if(i.type==="Mesh")"geometry"in a&&Object.assign(s,{geometry:Pc.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=r(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Qr.merge(s.cloner,a.cloner)});else if(i.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Qr.merge(s.cloner,a.cloner)});else if(xc.is(i.type)){let l=a;l.intensity!==void 0&&(s.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?s.color=l.color:s.color=St.clone(l.color))}return s}o.patch=t})(Fn||(Fn={}));var Zi;(r=>r.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Zi||(Zi={}));var Nr;(r=>r.defaultData={orbitControls:Zi.defaultData,playPage:rn,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,t)=>{let o=0,i=0;return t<5?i=-30:t<10&&(i=30),t===0||t===10||t===5?o=30:(t===4||t===11||t===9)&&(o=-30),[120,[o,i],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Nr||(Nr={}));var Jd;(r=>r.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Jd||(Jd={}));var ep;(r=>r.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(ep||(ep={}));var Po;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Jd.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:ep.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Po||(Po={}));var jg;(e=>{function n(t){return t.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=n;function r(t,o,i){t.scene.objects.traverseFrom(o,(a,s)=>{if(s.type==="Instance"){let l=Ji.getComponentData(t,s.component)?.data;l&&i(a,s,l.events)}else i(a,s,s.events)})}e.traverseModuleInstances=r})(jg||(jg={}));var Oo;(l=>{l.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function r(c=!0){let u=[],p=Nc.defaultMeshObject;c&&(u.push({fi:-1,data:Ic.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),u.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:p,children:[]}));let d=new Xe;return d.push({fi:1,id:rn,data:{...wo.defaultData,name:"Scene 1"},children:u}),d}l.defaultData={objects:r(),publish:Nr.defaultData,styles:Po.defaultData()},l.emptyDataWithoutPage=function(){return{objects:new Xe,publish:Nr.defaultData,styles:Po.defaultData()}},l.emptyDataWithPage=function(c=!0){return{objects:r(c),publish:Nr.defaultData,styles:Po.defaultData()}},l.emptyData=function(){return{objects:new Xe,publish:{...Nr.defaultData},styles:Po.defaultData()}};function a(c){return{...l.defaultData,objects:Ht(c,Xe.prototype)}}l.withObjs=a;function s(c,u){return a([{id:c,data:u,children:[],fi:0}])}l.withObj=s})(Oo||(Oo={}));var ea;(r=>r.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(ea||(ea={}));var Dc;(i=>{function n(a){return a.textValue!==void 0}i.isTextValue=n;function r(a){return typeof a=="number"}i.isNumber=r;function e(a){return typeof a=="boolean"}i.isBoolean=e;function t(a){return n(a)?"string":e(a)?"boolean":"number"}i.typeOfVariable=t;function o(a){return i.isTextValue(a)?Array.isArray(a.textValue)?a.textValue.map(s=>s.toString().padStart(a.padding??2,"0")).join(a.deliminator??":")+(a.suffix!==void 0?" "+a.suffix:""):a.textValue.toString():i.isBoolean(a)?a?"True":"False":i.isNumber(a)?parseFloat(a.toFixed(3)).toString():a.toString()}i.getDisplayedValue=o})(Dc||(Dc={}));var tp;(r=>r.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(tp||(tp={}));var Fg;(r=>r.all=[...tp.all,"components"])(Fg||(Fg={}));var Ug;(r=>{function n(){return{images:new xe,videos:new xe,colors:new xe,audios:new xe,particles:new xe,fonts:new xe,materials:new xe,components:new xe,variables:new xe}}r.defaultData=n})(Ug||(Ug={}));var Co;(r=>{function n(){return{images:new xe,videos:new xe,colors:new xe,audios:new xe,particles:new xe,fonts:new xe,materials:new xe,components:new xe,variables:new xe}}r.defaultData=n})(Co||(Co={}));var xr;(i=>{function n(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ht(a,xe.prototype)}i.defaultColors=n;function r(){return Ht({},xe.prototype)}i.defaultImages=r;function e(){return{catelogs:new xe,materials:new xe,images:new xe,videos:new xe,colors:new xe,audios:new xe,particles:new xe,fonts:new xe,variables:new ve,lib:Co.defaultData()}}i.emptyData=e;function t(a){switch(a){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let s=[0,0,0];return{name:"Time",value:{textValue:s,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:s,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",a)}}i.defaultVariables=t;function o(a,s){if(s.format==="HH:mm:ss"){let l=Math.floor(a/3600),c=Math.floor((a-l*3600)/60),u=Math.round(a-l*3600-c*60);return{textValue:[l,c,u]}}else if(s.format==="mm:ss"){let l=Math.floor(a/60),c=Math.round(a-l*60);return{textValue:[l,c]}}else return s.format==="number"?a=Math.round(a):a=Math.round(a*1e3)/1e3,a}i.getFormattedTimerTime=o})(xr||(xr={}));import{MathUtils as Bc}from"three";var Ec;(r=>r.list=["idle","move","jump","run"])(Ec||(Ec={}));var _c;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new ve,move:new ve,jump:new ve,run:new ve},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Ie.fromHexAndA(3728051,1)}}))(_c||(_c={}));function kg(n){n.layers.forEach(r=>{if(r.type==="depth"&&r.colorA!==void 0){let e=r.colorA,t=r.colorB,o=[[e.r,e.g,e.b,e.a],[t.r,t.g,t.b,t.a]],i=[0,1];for(let s=2;s<10;s++)o.push(o[1]),i.push(1);let a={...Mr(ut(r),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,r.near),far:Math.max(0,r.far),colors:o,steps:i,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(r,a)}else if(r.type==="depth"&&r.gradientType===1&&(r.near<0||r.far<0)){let e={...ut(r),near:Math.max(r.near,0),far:Math.max(r.far,0)};Object.assign(r,e)}})}function To(n,r){Object.values(n.shared.materials).forEach(e=>r(e))}function Ao(n,r){n.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach((o,i)=>{o===void 0&&(t.materials[i]=Lt.defaultData(),o=t.materials[i]),typeof o!="string"&&r(o)}):"material"in t?typeof t.material!="string"&&(t.material===void 0&&(t.material=Lt.defaultData()),r(t.material)):t.type==="Mesh"&&(t.material===void 0&&(t.material=Lt.defaultData()),r(t.material)),"overrides"in t&&Object.values(t.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&Object.getPrototypeOf(o.material)!==Ke.prototype&&r(o.material)})})}function ET(n){Object.assign(n.scene.publish,{orbitControls:{...Zi.defaultData,...ut(n.scene.publish.orbitControls)}})}function _T(n){Object.assign(n.scene.publish.settings,{video:{...Nr.defaultData.settings.video,...ut(n.scene.publish.settings.video)}})}function BT(n){function r(e){if(e.layers){for(let t of Object.values(e.layers))if(t){for(let[o,i]of Object.entries(t))if((Bg.includes(o)||typeof i=="boolean")&&delete t[o],o==="texture")for(let[a,s]of Object.entries(i))(Lg.includes(a)||typeof s=="boolean")&&delete i[a]}}}n.scene.objects.traverse((e,t)=>{t.states.forEach(o=>{let i=o;i.material?r(i.material):i.materials&&i.materials.forEach(a=>{r(a)})})})}function LT(n){n.scene.publish.withBackground=!0}function RT(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function VT(n){n.scene.objects.traverse((r,e)=>{let t=e.cloner;t&&(t.radial.scale=t.radial.scale.map(o=>o+1),t.linear.scale=t.linear.scale.map(o=>o+1))})}function zT(n){n.scene.objects.traverse((r,e)=>{let t=e.geometry;t&&(t.type==="DodecahedronGeometry"||t.type==="IcosahedronGeometry")&&(t.detail=Math.round(t.detail))})}function GT(n){n.scene.objects.traverse((r,e)=>{let t=n.scene.objects.unproxy().parent(r);if(t){let o=ut(n.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=ut(e).booleanExclude!==!0)}})}function jT(n){n.scene.objects.traverse((r,e)=>{if(e.type==="Mesh"){let t=e;e.geometry.type==="NonParametricGeometry"?t.material!==void 0&&delete t.material:t.materials!==void 0&&delete t.materials}})}function FT(n){function r(t){Object.setPrototypeOf(t,Ke.prototype),t.texture&&Object.setPrototypeOf(t.texture,Ke.prototype)}function e(t){Object.setPrototypeOf(t,Ke.prototype);for(let o in t)r(t[o])}n.scene.objects.traverse((t,o)=>{o.states.forEach(i=>{let a=i;if(a.material){let s=ut(a.material).layers;e(s),a.material.layers=s}if(a.materials)for(let s=0;s<a.materials.length;s++){let l=a.materials[s],c=ut(l).layers;e(c),l.layers=c}})})}function Hg(n){n.layers===void 0&&Object.assign(n,Lt.defaultTwoLayerData("lambert"))}function rp(n){!n.layers||n.layers.forEach(r=>{if(r.type==="depth"&&r.colors.length===10){let e=[...r.colors];e.push(r.colors[9]);let t=[...r.steps];t.push(r.steps[9]);let o={...ut(r),colors:e,steps:t};Object.assign(r,o)}})}function UT(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function Wg(n){n.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&rp(t)}):"material"in e&&typeof e.material!="string"&&rp(e.material)}),Object.values(n.shared.materials).forEach(r=>rp(r))}function kT(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((r,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}function HT(n){n.shared.audios=Ht({},xe.prototype)}function WT(n){n.shared.videos=Ht({},xe.prototype)}function qT(n){let r=n.shared.materials;Object.entries(r).forEach(([e,t])=>{if(!t.layers){let o={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(r,{[e]:o})}})}function $T(n){Object.entries(ut(n.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.images[t]}),Object.entries(ut(n.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.audios[t]})}function YT(n){n.scene.publish.settings.web.preload=!1}function qg(n){n.layers&&n.layers.forEach(r=>{r.type==="depth"&&r.num!==void 0&&(r.colors=r.colors.slice(0,r.num),r.steps=r.steps.slice(0,r.num),delete r.num)})}function $g(n){n.layers&&n.layers.forEach(r=>{_g(r)&&r.isMask===void 0&&(r.isMask=!1),(r.type==="texture"||r.type==="video")&&r.blending===void 0&&(r.blending=0),(r.type==="noise"||r.type==="displace"&&r.displacementType==="noise")&&(r.voronoiStyle===void 0&&(r.voronoiStyle=0),r.highCut===void 0&&(r.highCut=1),r.lowCut===void 0&&(r.lowCut=0),r.smoothness===void 0&&(r.smoothness=.3),r.seed===void 0&&(r.seed=0),r.quality===void 0&&(r.quality=1))})}function XT(n){n.shared.fonts=Ht({},xe.prototype)}function KT(n){return n.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function QT(n){let r=[];n.scene.objects.traverse((e,t)=>{let o=t;if(o.type==="TextFrame"){let i=Lt.defaultTwoLayerData("phong"),a=typeof o.color=="string"?n.shared.colors[o.color]:o.color;i.layers[1].data.color={r:a.r,g:a.g,b:a.b},i.layers[1].data.alpha=o.alpha;let s=KT(o.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let l={name:o.name,...wt.defaultData,...Gn.defaultData,flatShading:!1,wireframe:!1,geometry:{...an.defaultData("TextGeometry"),width:o.width,height:o.height,font:s,depth:0,horizontalAlign:o.horizontalAlign,verticalAlign:o.verticalAlign,fontSize:o.fontSize*1.40625,lineHeight:o.lineHeight/1.40625,letterSpacing:o.letterSpacing-1,text:o.text,textTransform:o.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:i,states:ut(o.states),events:ut(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},c=ut(n.scene.objects).parent(e);n.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),r.push(e)}}),r.forEach(e=>{n.scene.objects.delete(e)})}function ZT(n){let r={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};n.scene.objects.traverse((e,t)=>{t.events.forEach(o=>{if(!!r[Number(o.type)])if(Object.assign(o,{type:r[Number(o.type)]}),o.type==="Audio"&&"audioEvent"in o&&(Object.assign(o,{playAudio:o.audioEvent}),delete o.audioEvent),o.type==="GameControl")Object.assign(o,{gameActions:{idle:new ve,move:new ve,jump:new ve}});else{let i=new ve;Object.assign(o,{actions:i}),(o.type==="MouseDown"||o.type==="MouseUp"||o.type==="KeyDown"||o.type==="KeyUp")&&"url"in o&&i.push({fi:0,id:Bc.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((a,s,l)=>{let c={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(u,Mr(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(u,{control1:{...a.control1},control2:{...a.control2}});let p={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},d={state:a.state,...p,...u},h={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ve({fi:0,id:Bc.generateUUID(),data:c},{fi:1,id:Bc.generateUUID(),data:d})};i.push({fi:l,id:s,data:h})}),delete o.targets)}})})}function JT(n){n.scene.objects.traverse((r,e)=>{function t(o,i){let a=new ve,s=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===i){let p;s.push(c),l.interaction==="play"?p={...Mr(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(p={...Mr(l,"interaction","delay","object","playAudio"),type:"Audio"}),p&&a.push({fi:u,id:c,data:p})}}),s.forEach(l=>e.events.delete(l)),a.length){let l=e.events.find(c=>c.type===o)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):e.events.insertBefore(null,[{id:Bc.generateUUID(),data:{type:o,actions:a}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function Yg(n){let r=n.layers.find(e=>e.type==="light")?.data;if(r?.category==="basic"){let e=xt.defaultData("light","phong"),t=r;Object.assign(t,e),t.visible=!1}}function Xg(n){To(n,Yg),Ao(n,Yg)}function eA(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function tA(n){n.scene.objects.traverse((r,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function rA(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Lt.defaultTwoLayerData("phong"))})}function oA(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((r,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function nA(n){n.scene.objects.traverse((r,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function iA(n){n.scene.publish.mouseEventTarget===void 0&&(n.scene.publish.mouseEventTarget="canvas"),n.scene.publish.settings.web.hint===void 0&&(n.scene.publish.settings.web.hint=!1)}function aA(n){let{video:r}=n.scene.publish.settings;r.format==="gif"&&r.fps>48&&(r.fps=15)}function sA(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.resetYPosition=Math.abs(t.resetYPosition-e.position[1]))})})}function lA(n){let r=n.scene.environment.usePhysics;n.scene.objects.traverse((e,t)=>{r&&t.physics===null?t.collision=!1:t.collision="visibility"})}function cA(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.navmesh=_c.defaultDataThirdPerson.navmesh)})})}function uA(n){n.scene.styles||(n.scene.styles=Po.defaultData())}function Kg(n){n.layers.forEach(r=>{r.type==="light"&&r.category!=="toon"&&r.occlusion===void 0&&(r.occlusion=!0)})}function dA(n){n.scene.environment.ambientLight.occlusion===void 0&&(n.scene.environment.ambientLight.occlusion=!1),n.scene.environment.ambientLight.aoFullRes===void 0&&(n.scene.environment.ambientLight.aoFullRes=!1),n.scene.environment.ambientLight.radius===void 0&&(n.scene.environment.ambientLight.radius=256),n.scene.environment.ambientLight.bias===void 0&&(n.scene.environment.ambientLight.bias=.5),n.scene.environment.ambientLight.aoColor===void 0&&(n.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Ao(n,Kg),To(n,Kg)}function pA(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&Object.assign(t.gameActions,{run:new ve})})})}function fA(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.keyAssignments=[...t.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function Qg(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.bumpMapIntensity===void 0&&(r.bumpMapIntensity=5)})}function Zg(n,r){if(r<1&&(Ao(n,kg),To(n,kg),n.schema=1),r<2&&(ET(n),n.schema=2),r<3&&(BT(n),n.schema=3),r<4&&(LT(n),n.schema=4),r<5&&(RT(n),n.schema=5),r<6&&(VT(n),n.schema=6),r<7&&(zT(n),n.schema=7),r<8&&(n.schema=8),r<9&&(Wg(n),n.schema=9),r<10&&(UT(n),n.schema=10),r<11&&(kT(n),n.schema=11),r<12&&(Wg(n),n.schema=12),r<13&&(HT(n),n.schema=13),r<14&&(qT(n),n.schema=14),r<15&&($T(n),n.schema=15),r<16&&(YT(n),n.schema=16),r<17&&(Ao(n,qg),To(n,qg),n.schema=17),r<18&&(Ao(n,Hg),To(n,Hg),n.schema=18),r<19&&(_T(n),n.schema=19),r<20&&(XT(n),QT(n),n.schema=20),r<21&&(ZT(n),JT(n),n.schema=21),r<22&&(Xg(n),n.schema=22),r<23&&(eA(n),n.schema=23),r<24&&(tA(n),n.schema=24),(r<25||n.shared.videos===void 0)&&(WT(n),r<25&&(n.schema=25)),r<26&&(GT(n),n.schema=26),r<27&&(jT(n),n.schema=27),r<28&&(Xg(n),n.schema=28),r<29&&(FT(n),n.schema=29),r<30&&(rA(n),n.schema=30),r<31&&(oA(n),n.schema=31),r<33&&(nA(n),n.schema=33),r<34&&(iA(n),n.schema=34),r<35&&(aA(n),n.schema=35),r<36&&(sA(n),n.schema=36),r<37&&(lA(n),n.schema=37),r<38&&(Ao(n,$g),To(n,$g),n.schema=38),r<39&&(cA(n),n.schema=39),r<40&&(uA(n),n.schema=40),r<41&&(dA(n),n.schema=41),r<42&&(pA(n),n.schema=42),r<43&&(fA(n),n.schema=43),r<99){Ao(n,Qg),To(n,Qg),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=tn);let e=ut(n.scene.objects),t=n.scene.objects;n.scene.publish.playPage=rn,t.insertBefore(null,null,[{id:rn,data:{...wo.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:Mr(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:Mr(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Ts.defaultData,...Mr(n.scene.environment,"usePhysics","gravity")},camera:ut(n.scene.ownerCamera)??wo.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==Oo.TRASH_CAN_ID&&t.move(rn,a.fi,a.id);let o=0,i=0;n.shared.penumbraSize&&n.scene.objects.traverse((a,s)=>{s.type==="DirectionalLight"?(s.penumbraSize=n.shared.penumbraSize[Math.min(o,2)],o+=1):s.type==="SpotLight"&&(s.penumbraSize=n.shared.penumbraSize[3+Math.min(i,1)],i+=1),(s.physics===void 0||s.physics===null)&&s.type!=="Instance"&&(s.physics={},Object.assign(s.physics,nn.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),n.schema=99}}function Jg(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.alphaOverride===void 0&&(r.alphaOverride=1)})}function hA(n){n.scene.objects.traverse((r,e)=>{let t=e.geometry;t&&t.type==="PathGeometry"&&(t.extrusion.capType="flat",t.extrusion.bevel=50,t.extrusion.bevelSides=6,t.extrusion.shape.type==="Custom"&&(t.extrusion.shape.shapeQuality="low"))})}function mA(n){Array.isArray(ut(n.events))&&n.events?.forEach(r=>{"disabled"in r||(r.disabled=!1),(r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress")&&(r.mode=r.mode||"Object")})}var ta=180/Math.PI;function ex(n){n.rotation=n.rotation.slice(0,3).map(r=>r*ta)}function tx(n){ex(n),n.type==="Page"&&ex(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(t=>t*ta))});let r=n.geometry;r&&r.type==="SphereGeometry"&&(r.thetaLength=(r.thetaLength??180)*ta),r&&r.type==="TorusGeometry"&&(r.arc=r.arc*ta),r&&r.type==="PathGeometry"&&(r.extrusion.angle*=ta,r.extrusion.twist*=ta),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(ut(n.events))&&n.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Repeat")})}function yA(n){n.shared.variables=Ht({},xe.prototype)}function gA(n){let r=ut(n.shared.variables);n.shared.variables=Ht(Object.entries(r??{}).map(([e,t],o)=>({fi:o,id:e,data:t})),ve.prototype)}var Jr=111;function rx(n,r){r(n.data);for(let e of n.children)rx(e,r)}function xA(n){let r=n.schema??104;r!==Jr&&r<105&&(rx(n.asset,tx),n.schema=105)}function bA(n){n.shared.particles=Ht({},xe.prototype),n.shared.lib&&(n.shared.lib.particles=Co.defaultData().particles)}function vA(n){n.scene.objects.traverse((r,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function Lc(n){let r=n.schema??0;if(r!==Jr){console.warn("updating from ",r,"to ",Jr),Zg(n,r),r<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Nr.defaultData.joystickSizeAndXYOffset),n.schema=100),r<101&&(Ao(n,Jg),To(n,Jg),n.schema=101),r<102&&(hA(n),n.schema=102),r<104&&(n.shared.catelogs=new xe,n.shared.lib=Co.defaultData(),n.schema=104),r<105&&(yA(n),n.scene.objects.traverse((e,t)=>{tx(t)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))xA(e);r<106&&(gA(n),n.schema=106),r<107&&(n.shared.lib.variables=Co.defaultData().variables,n.schema=107),r<109&&(bA(n),n.schema=109),r<110&&(vA(n),n.schema=110),r<111&&(n.scene.objects.traverse((e,t)=>{mA(t)}),n.schema=111)}}var Ji;(l=>{l.defaultData={schema:Jr,scene:Oo.defaultData,frames:new xe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ea.defaultData),shared:{...xr.emptyData(),colors:xr.defaultColors()}},l.emptyDataForImports=function(){let c=Oo.emptyDataWithPage();return{schema:Jr,scene:c,frames:new xe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ea.defaultData),shared:{...xr.emptyData(),colors:xr.defaultColors(),images:xr.defaultImages()}}},l.emptyData=function(){return{schema:Jr,scene:Oo.emptyDataWithPage(),frames:new xe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ea.defaultData),shared:xr.emptyData()}},l.clipboard2dData=function(){return{schema:Jr,scene:Oo.emptyData(),frames:new xe,shared:xr.emptyData()}},l.collabHelper={...vs,updateSchema(c){return(c.schema??0)<Jr?Xo(c,Lc):(c.schema??0)-Jr}};function i(c){let u=l.collabHelper.updateSchema(c);return typeof u=="number"?u===0?c:null:u.data}l.updateSchemaDirectly=i;function a(c){return{...c,shared:{...c.shared,lib:Co.defaultData()}}}l.withoutLib=a;function s(c,u){let p=c.scene.objects.get(u);if(p&&p.data.type==="Component")return p;{let d=c.shared.lib.components[u];if(d)return d.asset}}l.getComponentData=s})(Ji||(Ji={}));var Rc;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Rc||(Rc={}));var ox;(r=>{function n(e){return!0}r.is=n})(ox||(ox={}));var Vc;(t=>{t.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function r(o,i){return{position:i?.position??o.position,rotation:i?.rotation??o.rotation,scale:i?.scale??o.scale,shear:i?.shear??o.shear}}t.merge=r;function e(o,i){return Tl({position:Wi.isEqual(o.position,i.position)?void 0:i.position,rotation:o.rotation===i.rotation?void 0:i.rotation,scale:Wi.isEqual(o.scale,i.scale)?void 0:i.scale,shear:o.shear&&i.shear&&Wi.isEqual(o.shear,i.shear)?void 0:i.shear})}t.diff=e})(Vc||(Vc={}));var op;(r=>r.defaultData={horizontalConstraint:0,verticalConstraint:0})(op||(op={}));var zc;(r=>r.defaultData={opacity:1,fill:{color:Ie.fromHexAndA(ht,1),enabled:!0},stroke:{color:Ie.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Ie.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Ie.from0to1([0,0,0,1]),enabled:!1,spread:0}})(zc||(zc={}));var Un;(i=>{function n(a,s){return{name:s}}i.newEmpty=n;function r(a,s){if(s===void 0)return a;let l={...a},c=["width","height","cornerRadius"];for(let u of c)u in l&&u in s&&s[u]!==void 0&&Object.assign(l,{[u]:s[u]});return l}function e(a,s){if(s===void 0)return a;let l={...a};return"fill"in l&&"fill"in s&&s.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...s.fill}}),"stroke"in l&&"stroke"in s&&s.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...s.stroke}}),"layerBlur"in l&&"layerBlur"in s&&s.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...s.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in s&&s.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...s.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in s&&s.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...s.dropShadow}}),"innerShadow"in l&&"innerShadow"in s&&s.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...s.innerShadow}}),l}function t(a,s){if(s===void 0)return a;let l={...a};return Object.assign(l,Vc.merge(l,s)),l=r(l,s),l=e(l,s),l}i.patch=t;function o(a,s){let l,c=[];for(let[u,p]of Object.entries(s))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[u]=p);return c}i.toOps=o})(Un||(Un={}));var As;(r=>r.defaultData={...Vc.defaultData,...op.defaultData,states:new ve,events:new ve,visible:!0,raycastLock:!1})(As||(As={}));var ra;(r=>r.defaultData={...As.defaultData,...zc.defaultData})(ra||(ra={}));var Gc;(r=>r.defaultData={cornerRadius:[0,0,0,0]})(Gc||(Gc={}));var np;(r=>r.defaultData={...ra.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(np||(np={}));var oa;(r=>r.defaultData={...ra.defaultData,...Gc.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(oa||(oa={}));var ip;(r=>r.defaultData={...ra.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(ip||(ip={}));var ap;(r=>r.defaultData={...ra.defaultData,type:"path2d",path:"",name:"Path"})(ap||(ap={}));var nx;(r=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}r.is=n})(nx||(nx={}));var Ms;(r=>r.defaultData={...As.defaultData,name:"Group",type:"group2d"})(Ms||(Ms={}));var sp;(r=>r.defaultData=()=>({...As.defaultData,...Gc.defaultData,...zc.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Ie.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Ie.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(sp||(sp={}));var Mo;(o=>{function n(i){switch(i){case"rectangle2d":return{...oa.defaultData};case"ellipse2d":return{...np.defaultData};case"text2d":return{...ip.defaultData};case"vector2d":return{...oa.defaultData};case"path2d":return{...ap.defaultData};case"frame2d":return{...sp.defaultData()};case"group2d":return{...Ms.defaultData}}}o.defaultData=n;function r(i){return"width"in i&&"height"in i?[typeof i.width=="number"?i.width*.5:0,typeof i.height=="number"?i.height*.5:0]:[0,0]}o.getPivot=r;function e(i){return i.type==="rectangle2d"||i.type==="ellipse2d"||i.type==="text2d"||i.type==="frame2d"}o.isResizeable=e;function t(i){return i.type==="rectangle2d"||i.type==="frame2d"}o.hasCorners=t})(Mo||(Mo={}));var jc;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new Xe},e.emptyData=function(){return{type:"scene2d",objects:new Xe}}))(jc||(jc={}));var Ja=hi(ax());import{Object3D as b3,Vector3 as pr,Euler as Uf,MathUtils as Fb,Matrix4 as ii}from"three";var SA=.5*(Math.sqrt(3)-1),Is=(3-Math.sqrt(3))/6,wA=1/3,eo=1/6,q5=(Math.sqrt(5)-1)/4,$5=(5-Math.sqrt(5))/20,Ns=n=>Math.floor(n)|0,sx=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),cp=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function Fc(n=Math.random){let r=cx(n),e=new Float64Array(r).map(o=>sx[o%12*2]),t=new Float64Array(r).map(o=>sx[o%12*2+1]);return function(i,a){let s=0,l=0,c=0,u=(i+a)*SA,p=Ns(i+u),d=Ns(a+u),h=(p+d)*Is,f=p-h,m=d-h,y=i-f,g=a-m,v,O;y>g?(v=1,O=0):(v=0,O=1);let P=y-v+Is,S=g-O+Is,T=y-1+2*Is,I=g-1+2*Is,x=p&255,_=d&255,D=.5-y*y-g*g;if(D>=0){let E=x+r[_],B=e[E],V=t[E];D*=D,s=D*D*(B*y+V*g)}let A=.5-P*P-S*S;if(A>=0){let E=x+v+r[_+O],B=e[E],V=t[E];A*=A,l=A*A*(B*P+V*S)}let N=.5-T*T-I*I;if(N>=0){let E=x+1+r[_+1],B=e[E],V=t[E];N*=N,c=N*N*(B*T+V*I)}return 70*(s+l+c)}}function lx(n=Math.random){let r=cx(n),e=new Float64Array(r).map(i=>cp[i%12*3]),t=new Float64Array(r).map(i=>cp[i%12*3+1]),o=new Float64Array(r).map(i=>cp[i%12*3+2]);return function(a,s,l){let c,u,p,d,h=(a+s+l)*wA,f=Ns(a+h),m=Ns(s+h),y=Ns(l+h),g=(f+m+y)*eo,v=f-g,O=m-g,P=y-g,S=a-v,T=s-O,I=l-P,x,_,D,A,N,E;S>=T?T>=I?(x=1,_=0,D=0,A=1,N=1,E=0):S>=I?(x=1,_=0,D=0,A=1,N=0,E=1):(x=0,_=0,D=1,A=1,N=0,E=1):T<I?(x=0,_=0,D=1,A=0,N=1,E=1):S<I?(x=0,_=1,D=0,A=0,N=1,E=1):(x=0,_=1,D=0,A=1,N=1,E=0);let B=S-x+eo,V=T-_+eo,j=I-D+eo,R=S-A+2*eo,W=T-N+2*eo,F=I-E+2*eo,k=S-1+3*eo,H=T-1+3*eo,$=I-1+3*eo,J=f&255,Z=m&255,X=y&255,te=.6-S*S-T*T-I*I;if(te<0)c=0;else{let q=J+r[Z+r[X]];te*=te,c=te*te*(e[q]*S+t[q]*T+o[q]*I)}let Y=.6-B*B-V*V-j*j;if(Y<0)u=0;else{let q=J+x+r[Z+_+r[X+D]];Y*=Y,u=Y*Y*(e[q]*B+t[q]*V+o[q]*j)}let ee=.6-R*R-W*W-F*F;if(ee<0)p=0;else{let q=J+A+r[Z+N+r[X+E]];ee*=ee,p=ee*ee*(e[q]*R+t[q]*W+o[q]*F)}let K=.6-k*k-H*H-$*$;if(K<0)d=0;else{let q=J+1+r[Z+1+r[X+1]];K*=K,d=K*K*(e[q]*k+t[q]*H+o[q]*$)}return 32*(c+u+p+d)}}function cx(n){let e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){let o=t+~~(n()*(256-t)),i=e[t];e[t]=e[o],e[o]=i}for(let t=256;t<512;t++)e[t]=e[t-256];return e}import{Triangle as PA}from"three";var Dr=new PA,Uc=class{constructor(r){this.weightAttribute=null;let e=r.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let r=this.positionAttribute,e=new Float32Array(r.count/3);for(let o=0;o<r.count;o+=3){let i=1;Dr.a.fromBufferAttribute(r,o),Dr.b.fromBufferAttribute(r,o+1),Dr.c.fromBufferAttribute(r,o+2),i*=Dr.getArea(),e[o/3]=i}this.distribution=new Float32Array(r.count/3);let t=0;for(let o=0;o<e.length;o++)t+=e[o],this.distribution[o]=t;return this}setRandomGenerator(r){return this.randomFunction=r,this}sample(r,e){if(this.distribution){let t=this.distribution[this.distribution.length-1],o=this.binarySearch(this.randomFunction()*t);return this.sampleFace(o,r,e)}}binarySearch(r){if(!this.distribution)return 0;let e=this.distribution,t=0,o=e.length-1,i=-1;for(;t<=o;){let a=Math.ceil((t+o)/2);if(a===0||e[a-1]<=r&&e[a]>r){i=a;break}else r<e[a]?o=a-1:t=a+1}return i}sampleFace(r,e,t){let o=this.randomFunction(),i=this.randomFunction();return o+i>1&&(o=1-o,i=1-i),Dr.a.fromBufferAttribute(this.positionAttribute,r*3),Dr.b.fromBufferAttribute(this.positionAttribute,r*3+1),Dr.c.fromBufferAttribute(this.positionAttribute,r*3+2),e.set(0,0,0).addScaledVector(Dr.a,o).addScaledVector(Dr.b,i).addScaledVector(Dr.c,1-(o+i)),Dr.getNormal(t),this}};import{Object3D as MA}from"three";var px=hi(dx());import{Object3D as OA,Matrix4 as to}from"three";var CA=new to,TA=new to,AA=new to,na;(r=>{function n(e){return e&&e.__isSPEObject}r.is=n})(na||(na={}));var ia=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new to;this.copyPreviousMatrix=!0;this.hiddenMatrix=new to;this.matrixWorldRigid=new to;this.shearScale=new to;this.shearScaleInv=new to}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof OA&&(t=t.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===t)return!0;o=o.parent}return!1}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 o of this.children)o.updateMatrixWorld(t)}updateWorldMatrix(t,o){let i=this.parent;if(t&&i!==null&&i.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)),o)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(t,o=0){for(let i of this.children)na.is(i)&&i.traverseObject(t,o+1)}traverseObject(t,o=0){if(t(this,o)!==!0)for(let a of this.children)na.is(a)&&a.traverseObject(t,o+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,o=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:i,v:a,q:s}=(0,px.SVD)(o),l=CA.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),c=TA.set(a[0][0],a[0][1],a[0][2],0,a[1][0],a[1][1],a[1][2],0,a[2][0],a[2][1],a[2][2],0,0,0,0,1),u=AA.copy(c).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(u).premultiply(c),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,u).copyPosition(this.matrixWorld),s.every(p=>Math.abs(s[0]-p)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,o){this.updateWorldMatrix(!0,!1);let i=new to().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof to?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),o!==void 0&&(this.children.pop(),this.children.splice(o,0,t)),this}copy(t,o=!1){return super.copy(t,o),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,o,i,a,s,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var up=class extends ia(MA){},IA=n=>n.type==="Mesh",Io=class extends up{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let o=this.children[e];o?.object!==t&&(o&&this.remove(o),o=new Io(t),this.add(o),this.children.splice(e,0,this.children.pop()),o.matrixWorldNeedsUpdate=!0,o.matrixAutoUpdate=!1,o.matrix=t.matrix,o.hiddenMatrix=t.hiddenMatrix),o.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return IA(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};import{Box3 as jI,BufferGeometry as FI,MeshBasicMaterial as UI}from"three";import{Matrix4 as zI,Mesh as GI}from"three";import{Matrix4 as Wc,Vector3 as mx,Euler as LA,MathUtils as Es}from"three";import{Box3 as NA,Line3 as DA,Matrix4 as dp,Vector3 as cr}from"three";var kn=new cr,Hn=new cr,aa=new dp,hx=[new cr(-1,1,1),new cr(-1,-1,1),new cr(1,-1,1),new cr(1,1,1),new cr(-1,1,-1),new cr(-1,-1,-1),new cr(1,-1,-1),new cr(1,1,-1)],EA=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],_A=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],fx=(n,r,e)=>{n.updateEntityBoxSize(kn,Hn),aa.copy(r).multiply(n.matrixWorld),Hn.x===0&&Hn.y===0&&Hn.z===0?e.push(new cr(kn.x,kn.y,kn.z).applyMatrix4(aa)):hx.forEach(t=>{e.push(t.clone().multiply(Hn).add(kn).applyMatrix4(aa))})},Ds=class extends NA{constructor(){super(...arguments);this.matrix=new dp;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 o=new dp().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,t)}expandByObjectSize(e,t,o=!1){let i=[];return o===!0?e.traverseEntity(a=>{if(a.visible||a.cloner&&a.data.visible){if(!("geometry"in a)){i.push(new cr);return}fx(a,t,i)}}):fx(e,t,i),this.setFromPoints(i)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(aa.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Hn).multiplyScalar(.5),this.getCenter(kn),aa.copy(this.matrix).setPosition(kn),this.vertices=hx.map(e=>e.clone().multiply(Hn).applyMatrix4(aa))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=EA.map(([e,t])=>new DA(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new cr))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=_A.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var Er={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};import{CurvePath as BA,CubicBezierCurve3 as pp,Vector3 as _r}from"three";var hp=class extends BA{constructor(){super()}getPoints(r=12){let e=[],t,o=this.getCurveLengths(),a=o[o.length-1]/o.length;for(let s=0,l=this.curves;s<l.length;s++){let c=l[s],u=s===0?o[s]:o[s]-o[s-1],p=Math.ceil(r*u/a),d=c.getPoints(p);for(let h=0;h<d.length;h++){let f=d[h];t&&t.equals(f)||(e.push(f),t=f)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var mp=.001;function yp(n,r,e){return r.clone().sub(n).cross(r.clone().sub(e)).length()<=mp}function fp(n,r){let e=new _r(...n.position),t=new _r(...n.controlNext.position),o=new _r(...r.controlPrevious.position),i=new _r(...r.position);return yp(e,t,i)&&yp(e,o,i)}function Hc(n){let r=n.points.map(u=>new _r(...u.data.position)),e=[n.points[0]],t=new _r(...e[0].data.position);for(let u=0;u<n.points.length-1;u++)yp(t,r[u],r[u+1])||(e.push(n.points[u]),t=r[u]);e.push(n.points[n.points.length-1]);let o=n.isClosed,i=e.length-(o?0:1),a=e.length,s=[];for(let u=0;u<a;u++){let p=e[u].data,d=new _r(...p.position),h=new _r(...p.controlPrevious.position),f=new _r(...p.controlNext.position),m={position:d,baseRoundness:p.roundness,controlPrevious:h,controlNext:f};if(p.roundness===0||!n.isClosed&&(u===0||u===a-1)){s[u]={...m,removedLength:0};continue}let y=o&&u==0?a-1:u-1,g=o&&u==a-1?0:u+1,v=e[y].data,O=e[g].data,P=new _r(...v.position),S=new _r(...O.position),T=P.clone().sub(d).normalize(),I=S.clone().sub(d).normalize();Object.assign(m,{prevDir:T,nextDir:I});let x=fp(v,p),_=fp(p,O);if(!x||!_)s[u]={...m,removedLength:0};else{let D=T.clone().add(I).normalize(),A=D.clone().cross(T).length()/T.dot(D);s[u]={...m,tan:A,removedLength:p.roundness/A}}}for(let u=0;u<i;u++){let p=u,d=o&&u===a-1?0:u+1,h=s[p],f=s[d];if(h.removedLength!==0||f.removedLength!==0){let m=h.position.distanceTo(f.position);h.removedLength=Math.min(h.removedLength,m/2),f.removedLength=Math.min(f.removedLength,m/2)}}let l=[];for(let u=0;u<i;u++){let p=u,d=o&&u===a-1?0:u+1,h=s[p],f=s[d],m=null;if(!fp(e[p].data,e[d].data))h.position.distanceTo(f.position)>mp&&(m=new pp(h.position,h.controlNext,f.controlPrevious,f.position));else{let y=h.position.clone(),g=f.position.clone();(h.removedLength!==0||f.removedLength!==0)&&(h.nextDir&&y.add(h.nextDir.clone().setLength(h.removedLength)),f.prevDir&&g.add(f.prevDir.clone().setLength(f.removedLength))),y.distanceTo(g)>mp&&(m=new pp(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}l[2*u+1]=m}for(let u=0;u<a;u++){let p=s[u];if(p.removedLength===0){l[2*u]=null;continue}let d=p.position,h=p.prevDir.clone().multiplyScalar(p.removedLength).add(d),f=p.nextDir.clone().multiplyScalar(p.removedLength).add(d),m=p.tan*p.removedLength,y=p.prevDir.clone().add(p.nextDir).normalize(),g=h.clone().lerp(f,.5),v=h.distanceTo(f)/2,O=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(v,2))).add(g),P=y.clone().multiplyScalar(-m).add(O),S=d.distanceTo(P)/d.distanceTo(g),T=p.prevDir.clone().multiplyScalar(S*d.distanceTo(h)).add(d),I=T.clone().lerp(P,2),x=h.clone().lerp(T,4/3),_=f.clone().lerp(I,4/3);l[2*u]=new pp(h,x,_,f)}let c=new hp;return l.forEach(u=>{u&&c.add(u)}),c}var Le;(r=>{function n(e){return e&&e.__isEntity}r.is=n})(Le||(Le={}));var sa=n=>Le.is(n),RA={type:"completeState",isfromEntity:!0},VA=["x","y","z"],gp=new mx,zA=new mx().set(0,1,0),la=n=>class extends ia(n){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.destroyedInAction=!1;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Ds;this._recursiveBBox=new Ds;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let o=this.children[t];if(Le.is(o))return o}entityChildrenCount(){let t=this.children.length;for(;t--;)if(Le.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let o=t.parent;if(Le.is(o))t=o;else return}return t}forInstancesRec(t){this.instances.forEach(o=>{o.disposed||t(o),o.forInstancesRec(t)})}super_Entity(t,o){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=o,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,o,i=!1){if(!(this.data.states.length===0&&!i)){for(let a of this.data.states)Fn.toOps(this.data,a.data).forEach(l=>{let c=Fi.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(c,this.data,o)});if(t!==null){let a=this.data.states.data(t);a&&(this.dataPatched=Fn.patch(this.data,a),Fn.toOps(this.data,a).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,o)}))}i&&this.updateTransformState(this.dataPatched,o),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}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}updateEntityBoxSize(t,o){t.setScalar(0),o.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{sa(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let o;return this.traverseEntity(i=>{i.uuid===t&&(o=i)}),o}traverseSortNextHelper(){let t=this.parent;if(t){let o=t.children,i=o.indexOf(this)+1;if(Le.is(o[i]))return o[i];if(Le.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&Le.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let o=this;for(;t>0&&o!==null;)o=o.parent,t-=1;return o}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let o=this.parent;for(;o;){if(t===o)return!0;o=o.parent}return!1}countToAccestor(t){let o=0,i=this;for(;i!==t;){if(i===null)return-1;i=i.parent,o+=1}return o}forEachEntity(t){for(let o of this.children)sa(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{Le.is(o)&&t(o)})}traverseConcreteEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)sa(a)&&a.isConcreteEntity&&a.traverseEntity(t,o+1)}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)sa(a)&&a.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)sa(o)&&o.visible&&o.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,o=!1){return super.copy(t,o),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>sa(t))}isAncestorOf(t){if(this.uuid===t)return!1;let o=!1;return this.traverseEntity(i=>{i.uuid===t&&(o=!0)}),o}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x*Es.RAD2DEG,this.rotation.y*Es.RAD2DEG,this.rotation.z*Es.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Ri(o,t)}getTransformValues(t,o,i){return o[t].map((a,s)=>i?.shared.getVariable(a,[this.uuid,t,VA[s]])??a)}updateTransformState(t,o){let i=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,o)),i=!0),t.rotation&&(gp.fromArray(this.getTransformValues("rotation",t,o)).multiplyScalar(Es.DEG2RAD),this.rotation.setFromVector3(gp),i=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,o)),i=!0),t.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??en.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(a=>{a.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}onVariableUpdate(t=!1){if(t){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)Le.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{Le.is(t)&&t.disposeRecursively()})}toState(t=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return Ri(o,t)}updateByObjUpdateOp(t,o){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},o,!1)}updateByOp(t,o,i,a){let s=this.data;this.data=o;let l=t,c=Be(t.path,["states","*"]);if(c!==null){if(t.type===0){let[u]=c;if(this?.stateSelection===u){let p={...t.props};if(delete p.name,Object.values(t.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let h=rt.zoom(d,t.path.slice(2));if(h)for(let f in t.props)t.props[f]===void 0&&f in h&&(p[f]=h[f])}}l={...t,props:p,path:t.path.slice(2)}}}}else if(t.type===0){let u=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(u!==void 0){if(t.props.name!==void 0&&u.name){let{name:d,...h}=u;u=h}if(t.props.material!==void 0&&"material"in u){let{material:d,...h}=u;u=h}let p=rt.removeOverridden(t.path,t.props,u);l={...t,props:p}}}if(this.updateByPatchedOpBase(l,Fn.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),Be(t.path,["overrides"])){let u=[],p=[...t.path];for(u.push(p[1]),p.splice(0,2);p.length>0&&p[0]==="descendants";)u.push(p[1]),p.splice(0,2);if(u[u.length-1]===void 0){if(t.type===0)for(let d of Object.keys(t.props)){u[u.length-1]=d;let h=i.scene.findInstance([this.uuid,...u]);h&&(h.overrideData=t.props[d],h.updateState(qr.apply(h.component.data,h.overrideData),i))}}else{let d=i.scene.findInstance([this.uuid,...u]);if(d){let h=rt.zoom(d.component.data,p);if(t={...t,path:p},t.type===0){let f=t.props;if(h)for(let[m,y]of Object.entries(t.props))y===void 0&&(f===t.props&&(f={...t.props}),f[m]=h[m]);t={...t,props:f}}d.overrideData=Qi.resolve(o.overrides,u),d.updateByOp(t,ot.applySimple(d.data,t),i,!1)}}}else if(this.instances.length>0){let u;if(t.path.length===0&&t.type===0){let p;for(let d of Zr.rootOverrideProps)d in t.props&&(p===void 0&&(p={}),p[d]=t.props[d]);p&&(u={...t,props:p})}else for(let p of Zr.rootOverrideProps)if(Be(t.path,[p])){u=t;break}u!==void 0&&this.instances.forEach(p=>{if(p.isInstanceRoot){let d=qr.filterOp(p.overrideData,u);d&&p.updateByOp(d,ot.applySimple(p.data,d),i,!0)}}),this.instances.forEach(p=>{if(!p.isInstanceRoot){let d=qr.filterOp(p.overrideData,t);if(d){let h;s===p.data&&t===d?h=o:h=ot.applySimple(p.data,d),p.updateByOp(d,h,i,!0)}}})}}updateByPatchedOpBase(t,o,i){if(this.dataPatched=o,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Ir.is(t.props.type)&&Er.changeEntityProptotype(this,o,i);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){Er.changeEntityProptotype(this,o,i);for(let a of this.children)Le.is(a)&&a.updateVisible(i.scene)}this.updateByPatchedOp(t,o,i)}updateByPatchedOp(t,o,i){if(t.path.length===0&&t.type===0&&this.updateState(t.props,i),Be(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Be(t.path,["cloner"])!==null){let a=ot.drop(t,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,i):this.cloner?this.cloner.updateState(o.cloner,i.scene):(this.setFromClonerState(o.cloner,i),this.expandCloner(i.scene)),this.updateVisible(i.scene)}}updatePathSnapping(t=this.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let o=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,i=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,a=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(o===null)return;let l=t.find(o);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let c=l.data;if(c.geometry.path.points.length<=1)return;let u=Hc(c.geometry.path),p=(i+a)%1;i+a===1&&p===0&&(p=1);let d=u.getPointAt(p);if(d===null)return;let h=this.parent?this.parent?.matrixWorld:new Wc;l.updateMatrixWorld();let f=new Wc().multiplyMatrices(h.clone().invert(),l.matrixWorld);d.applyMatrix4(f);let m={position:d.toArray(),rotation:c.rotation};if(s==="tangential"){let y=new Wc().extractRotation(l.matrixWorld),g=u.getTangentAt(p).applyMatrix4(y).add(d),v=new Wc().lookAt(d,g,zA),O=gp.setFromEuler(new LA().setFromRotationMatrix(v)).multiplyScalar(Es.RAD2DEG);m={...m,rotation:O.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(RA)})}updateVisible(t){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!t)return;let o=!1;this.traverseEntity(i=>{if(i.data.type==="Splat")return o=!0,!0}),o&&t.reloadSplats()}updateState_Entity(t,o){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(o?.scene),this.resetBBoxNeedsUpdate()),o&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,o),this.updateVisible(o.scene)),this.updateTransformState(t,o)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof Er.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,o){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Er.Cloner(this,t),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,o.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}};import{BufferGeometry as FA,ConeGeometry as UA,Float32BufferAttribute as kA,MathUtils as HA}from"three";import{BufferGeometry as gx,CylinderGeometry as GA,Float32BufferAttribute as $c,MathUtils as jA,Vector2 as Br,Vector3 as qc}from"three";var xx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);e.thetaLength=jA.clamp(e.thetaLength,0,360);let t=e.width/2,o=e.radiusTop??t,i=e.radiusBottom??t;return o===i?(o=t,i=t):o>i?(o=t,i=i*t/o):(o=o*t/i,i=t),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:o,radiusBottom:i})}}static build(n){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:p,cornerSegments:d,hollow:h}=n.parameters,f;return l===0?(f=new gx,f.setAttribute("position",new $c([],3))):p||h?f=new _s(c,u,t,o,i,a,s,l*Math.PI/180,p,p,d,h):f=new GA(c,u,t,o,i,a,s,l*Math.PI/180),f.scale(1,1,e/r),Object.assign(f,{userData:{...n,type:"CylinderGeometry"}})}};function sn(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function yx(n){return new Br(n.y,-n.x)}var _s=class extends gx{constructor(r,e,t,o,i,a,s,l,c,u,p,d,h=!1){super(),this.type="RoundedCylinderBufferGeometry",r=r!==void 0?r:1,e=e!==void 0?e:1,t=t||1,o=Math.floor(o)||8,i=Math.floor(i)||1,a=a!==void 0?a:!1,s=s!==void 0?s:0,l=l!==void 0?l:Math.PI*2,a&&(c=0,u=0);let f=[],m=[],y=[],g=[],v=0,O=t/2,P=new qc,S=new qc;h&&r==0&&(r=c),h&&e==0&&(e=u);let T=new Br(r,O),I=new Br(e,-O),x=null,_=null,D=null,A=null,N=T.clone().sub(I),E=0,B=0,V=0;d>0&&(E=Math.min(r,e)*(1-d),B=r-E,V=e-E);let j=T.clone();j.x-=E;let R=Math.PI-N.angle(),W=N.angle(),F=Math.tan(W/2),k=Math.tan(R/2),H=F+k,$=d?H:k,J=d?H:F;if(c=Math.min(c,(r-B)/$,N.length()/H),u=Math.min(u,(e-V)/J,N.length()/H),c>0){let K=c/F;x=T.clone().sub(new Br(K,c)),d&&(D=x.clone(),D.x-=E-H*c),T.sub(N.clone().setLength(K))}if(u>0){let K=u/k;_=I.clone().sub(new Br(K,-u)),I.add(N.clone().setLength(K)),d&&(A=_.clone(),A.x-=E-H*u,j.sub(N.clone().setLength(K)))}N=T.clone().sub(I);let Z=N.length()<.5,X=[];for(let K=0;K<=o;K++){let q=[],ue=K/o,le=ue*l+s,ne=new Br(Math.sin(le),Math.cos(le));A&&_?(te(q,ue,ne,R,u,A,-1,!0),te(q,ue,ne,W,u,_,-1,!1)):_?(Y(q,ne,_.x,0,-1),te(q,ue,ne,W,u,_,-1,!1)):a||Y(q,ne,e,V,-1);let ce=yx(N).normalize();if(sn(ce,ne,P),!Z)for(let ae=0;ae<=i;ae++){let he=ae/i,pe=N.clone().multiplyScalar(he).add(I);sn(pe,ne,S),m.push(S.x,S.y,S.z),y.push(P.x,P.y,P.z),g.push(ue,.5+S.y/t),q.push(v++)}if(D&&x?(te(q,ue,ne,R,c,x,1,!1),te(q,ue,ne,W,c,D,1,!0)):x?(te(q,ue,ne,R,c,x,1,!1),Y(q,ne,x.x,0,1)):a||Y(q,ne,r,B,1),d&&!Z){let ae=yx(N).multiplyScalar(-1).normalize();sn(ae,ne,P);for(let he=0;he<=i;he++){let pe=he/i,fe=N.clone().multiplyScalar(-pe).add(j);sn(fe,ne,S),m.push(S.x,S.y,S.z),y.push(P.x,P.y,P.z),g.push(ue,.5+S.y/t),q.push(v++)}}d&&!a&&q.push(q[0]),X.push(q)}for(let K=0;K<X.length-1;K++)for(let q=0;q<X[0].length-1;q++){if(a&&d&&q==i)continue;let ue=X[K][q],le=X[K+1][q],ne=X[K+1][q+1],ce=X[K][q+1],ae=m[ne*3+0],he=m[ne*3+2];f.push(ue,le,ce),(ae!=0||he!=0)&&f.push(le,ne,ce)}l<Math.PI*2&&(ee(-1,X[0],s),ee(1,X[X.length-1],s+l)),this.setIndex(f),this.setAttribute("position",new $c(m,3)),this.setAttribute("normal",new $c(y,3)),this.setAttribute("uv",new $c(g,2));function te(K,q,ue,le,ne,ce,ae,he){for(let pe=0;pe<p+1;pe++){let fe=pe/p,ge=ae<0?fe:1-fe;he&&(ge-=1),ge*=le;let me=new Br(Math.sin(ge),Math.cos(ge)*ae),C=me.clone().multiplyScalar(ne).add(ce);sn(C,ue,S),m.push(S.x,S.y,S.z),sn(me,ue,P),y.push(P.x,P.y,P.z),g.push(q,.5+S.y/t),K.push(v++)}}function Y(K,q,ue,le,ne){let ce=new qc,ae=new Br,he=[ue,le];ne<0&&he.reverse();for(let pe of he)ae.set(pe,O*ne),sn(ae,q,ce),m.push(ce.x,ce.y,ce.z),y.push(0,ne,0),g.push(.5,.5),K.push(v++)}function ee(K,q,ue){let le=new Br(Math.sin(ue),Math.cos(ue)),ne=new Br(-Math.cos(ue),Math.sin(ue)),ce=new qc,ae=K<0?(fe,ge,me)=>f.push(fe,ge,me):(fe,ge,me)=>f.push(fe,me,ge),he=new Br((r+e+B+V)/4,0);sn(he,le,ce),m.push(ce.x,ce.y,ce.z),y.push(ne.x,0,ne.y),g.push(.5,.5);let pe=v++;for(let fe of q){let ge=m.slice(fe*3,fe*3+3);m.push(...ge),y.push(ne.x,0,ne.y);let me=g.slice(fe*2,fe*2+2);g.push(...me),v++}for(let fe=pe+1;fe<v-1;fe++)ae(pe,fe,fe+1);ae(pe,v-1,pe+1)}}};var bx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},n.parameters);return e.thetaLength=HA.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:u,cornerSegments:p}=n.parameters,d;return l===0?(d=new FA,d.setAttribute("position",new kA([],3))):c>0||u>0||l<360?d=new _s(0,r/2,t,o,i,a,s,l*Math.PI/180,c,u,p,0,!0):d=new UA(r/2,t,o,i,a),d.scale(1,1,e/r),Object.assign(d,{userData:{...n,type:"ConeGeometry"}})}};import{BoxGeometry as WA,BufferGeometry as qA,Float32BufferAttribute as xp,Vector3 as Bs}from"three";var vx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,widthSegments:o,heightSegments:i,depthSegments:a,cornerRadius:s,cornerSegments:l}=n.parameters,c;return s==0?c=new WA(r,e,t,o,i,a):c=new vp(r,e,t,o,i,a,s,l),Object.assign(c,{userData:{...n,type:"CubeGeometry"}})}},bp=Math.PI/2,vp=class extends qA{constructor(r=1,e=1,t=1,o=1,i=1,a=1,s=0,l=4){super(),this.type="BoxGeometry";let c=this;o=Math.floor(o),i=Math.floor(i),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,r/2,e/2,t/2);let u=[],p=[],d=[],h=[],f=0,m=0;y("z","y","x",-1,-1,t,e,r,a,i,0),y("z","y","x",1,-1,t,e,-r,a,i,1),y("x","z","y",1,1,r,t,e,o,a,2),y("x","z","y",1,-1,r,t,-e,o,a,3),y("x","y","z",1,-1,r,e,t,o,i,4),y("x","y","z",-1,-1,r,e,-t,o,i,5),s>0&&(g("z","y","x",-1,-1,1,t,e,r,a,0),g("z","y","x",1,-1,-1,t,e,r,a,1),g("z","y","x",-1,1,-1,t,e,r,a,1),g("z","y","x",1,1,1,t,e,r,a,0),g("x","y","z",-1,-1,-1,r,e,t,o,0),g("x","y","z",1,-1,1,r,e,t,o,1),g("x","y","z",-1,1,1,r,e,t,o,0),g("x","y","z",1,1,-1,r,e,t,o,1),g("y","x","z",-1,-1,1,e,r,t,i,0),g("y","x","z",1,-1,-1,e,r,t,i,1),g("y","x","z",1,1,1,e,r,t,i,1),g("y","x","z",-1,1,-1,e,r,t,i,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(u),this.setAttribute("position",new xp(p,3)),this.setAttribute("normal",new xp(d,3)),this.setAttribute("uv",new xp(h,2));function y(O,P,S,T,I,x,_,D,A,N,E){let B=(x-2*s)/A,V=(_-2*s)/N,j=x/2-s,R=_/2-s,W=D/2,F=A+1,k=N+1,H=0,$=0,J=new Bs;for(let Z=0;Z<k;Z++){let X=Z*V-R;for(let te=0;te<F;te++){let Y=te*B-j;J[O]=Y*T,J[P]=X*I,J[S]=W,p.push(J.x,J.y,J.z),J[O]=0,J[P]=0,J[S]=D>0?1:-1,d.push(J.x,J.y,J.z),h.push(te/A),h.push(1-Z/N),H+=1}}for(let Z=0;Z<N;Z++)for(let X=0;X<A;X++){let te=f+X+F*Z,Y=f+X+F*(Z+1),ee=f+(X+1)+F*(Z+1),K=f+(X+1)+F*Z;u.push(te,Y,K),u.push(Y,ee,K),$+=6}c.addGroup(m,$,E),m+=$,f+=H}function g(O,P,S,T,I,x,_,D,A,N,E){let B=(_-2*s)/N,V=_/2-s,j=D/2-s,R=A/2,W=N+1,F=0,k=0,H=new Bs,$=new Bs;for(let J=0;J<l+1;J++){let Z=J/l*bp,X=Math.sin(Z)*s,te=(1-Math.cos(Z))*s,Y=Math.sin(Z),ee=Math.cos(Z);H[P]=(j+X)*I,H[S]=(R-te)*x,$[O]=0,$[P]=Y*Math.sign(H[P]),$[S]=ee*Math.sign(H[S]);for(let K=0;K<W;K++){let q=K*B-V;H[O]=q*T,p.push(H.x,H.y,H.z),d.push($.x,$.y,$.z),h.push(K/N),h.push(0),F+=1}}for(let J=0;J<l;J++)for(let Z=0;Z<N;Z++){let X=f+Z+W*J,te=f+Z+W*(J+1),Y=f+(Z+1)+W*(J+1),ee=f+(Z+1)+W*J;u.push(X,te,ee),u.push(te,Y,ee),k+=6}c.addGroup(m,k,E),m+=k,f+=F}function v(O,P,S){let T=new Bs,I=new Bs(r/2,e/2,t/2);I.subScalar(s);let x=[],_=O*P*S>0?(A,N,E)=>u.push(A,N,E):(A,N,E)=>u.push(A,E,N);for(let A=0;A<=l;A++){let N=[],E=bp*(1-A/l),B=Math.cos(E),V=Math.sin(E),j=0;for(let R=0;R<=A;R++){let W=Math.cos(j),F=Math.sin(j);T.x=B*W,T.y=V,T.z=B*F;let k=I.clone().addScaledVector(T,s);p.push(O*k.x,P*k.y,S*k.z),d.push(O*T.x,P*T.y,S*T.z),h.push(0,0),N.push(f++),j+=bp/A}x.push(N)}let D=x.length-1;for(let A=0;A<D;A++){let N=x[A],E=x[A+1],B=N.length-1;_(N[0],E[1],E[0]);for(let V=1;V<=B;V++)_(N[V-1],N[V],E[V]),_(N[V],E[V+1],E[V])}}}};import{BufferGeometry as $A,Float32BufferAttribute as Sp,Triangle as YA,Vector3 as No,Vector2 as wp}from"three";var ln=class extends $A{constructor(r=[],e=[],t="",o=1,i=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],c=[];u(),p(),this.setAttribute("position",new Sp(s,3)),this.setAttribute("normal",new Sp(c,3)),this.setAttribute("uv",new Sp(l,2));return;function u(){i=Math.min(1-1e-5,i),i==0&&(a=0);let h={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[t],f=new No,m=f.clone(),y=new YA,g=i*o,v=o-g,O=a+1,P=new No,S=(F,k)=>P.subVectors(F,k).normalize(),T=(F,k)=>Array(F).fill(void 0).map(k),I=T(r.length/3,(F,k)=>new No().fromArray(r,k*3).setLength(o)),x=[],_=1e6;for(let F=0;F<I.length;F++){let k=I[F],H=[],$,J,Z,X=1e10,te=-1;for(;(te=e.indexOf(F,te+1))!=-1;){let q=te-te%3;$=e[q+(te+1)%3],J=e[q+(te+2)%3],Z=k.distanceToSquared(I[$]),X=Math.min(X,Z),H.push([$,J,Z])}X+=1e-6;let Y=[],ee=0,K=H.length;for(let q=0;q<K;q++){[$,J,Z]=H[ee];let ue=x[$]?.includes(F)==!0;Z<=X&&Y.push($+ +ue*_),ee=H.findIndex(le=>le[0]==J)}x.push(Y)}let D=[];{let F=0,k=0,H,$,J=h==3;for(let Z=0;Z<=a;Z++){H=Z*(Z+1)/2,$=(Z+1)*(Z+2)/2;for(let X=0;X<a-Z;X++)[F,k]=[H+X+Z+2,$+X+Z+3],D.push(H,$,...J?[k,H]:[F,$],k,F),[H,$]=[F,k];D.push(H,$,H+a+2)}}let A=f.clone(),N=f.clone(),E=f.clone(),B=f.clone(),V=f.clone(),j=[],R=T(I.length,()=>T(h,()=>f.clone()));for(let F=0;F<I.length;F++){f.copy(I[F]).normalize(),A.copy(f).multiplyScalar(v);let k=x[F];for(let Y=0;Y<k.length;Y++){let ee=k[Y],K=k[(Y+1)%h];y.setFromPointsAndIndices(I,F,ee%_,K%_),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(A,R[F][Y])}let H=[],$=[],J=[],Z=new No;a==0&&[...R[F]].reduce((Y,ee)=>Y.add(ee),Z).multiplyScalar(1/h);for(let Y=0;Y<h;Y++){let ee=[],K=(Y-1+h)%h,q=R[F][K],ue=R[F][Y];f.copy(q).sub(A),m.copy(ue).sub(A);let le=A.angleTo(f),ne=f.angleTo(m),ce=Math.cos(le)*g;a==0?N.copy(Z):N.copy(A).setLength(v+ce),$.push(ce);let ae=[N,q,ue];for(let he=0;he<2;he++){let pe=ae[he],fe=ae[he+1];B.subVectors(pe,A),V.subVectors(fe,A),E.crossVectors(B,V).normalize();for(let ge=0;ge<O;ge++){let me=[le,ne][he]*ge/O;f.copy(B).applyAxisAngle(E,me).add(A),H.push(f.clone()),he&&(S(f,A),ee.push([ge==0?pe:f.clone(),P.clone()]))}he&&(S(fe,A),ee.push([fe,P.clone()]))}J.push(ee)}j.push(J);let X=2*O,te=2;for(let Y=0;Y<h;Y++){let ee=X*Y,K=X*((Y+1)%h),q=[H[ee]];for(let le=1;le<O;le++){B=H[ee+le],V=H[K+le],q.push(B);for(let ne=1,ce=le-te+1;ne<=ce;ne++)f.lerpVectors(B,V,ne/(ce+1)),f.sub(A).setLength($[Y]).add(A),q.push(f.clone());q.push(V)}for(let le=0;le<O;le++)q.push(H[le+O+ee]);q.push(H[K+O]);let ue=D.map(le=>q[le]);s.push(...ue.map(le=>[le.x,le.y,le.z]).flat()),c.push(...ue.map(le=>(S(le,A),[P.x,P.y,P.z])).flat())}}let W=[];for(let F=0;F<x.length;F++)for(let k=0;k<h;k++){let H=x[F][k];if(H<_){let $=x[H].findIndex(X=>X%_==F),J=j[F][k],Z=j[H][$];for(let X=0;X<O;X++){let te=J[X],Y=Z[O-X],ee=J[X+1],K=Z[O-(X+1)];[te,Y,ee,ee,Y,K].forEach(q=>{s.push(q[0].x,q[0].y,q[0].z),c.push(q[1].x,q[1].y,q[1].z)})}W.push(J[0][0],Z[O][0],J[O][0],Z[0][0])}}for(;W.length;){let F,k,H,$;[F,k]=W.splice(0,2);let J=[F];for(;F!=k;)J.push(k),H=W.indexOf(k),$=H%2,k=W.splice(H-$,2)[1-$];P.subVectors(J[0],J[1]).cross(f.subVectors(J[0],J[2])).normalize();let Z=P.dot(J[0])<0;Z&&P.negate();for(let X=1;X<=J.length-2;X++)[J[X+ +Z],J[X+1-+Z],J[0]].forEach(te=>{s.push(te.x,te.y,te.z),c.push(P.x,P.y,P.z)})}}function p(){let d=new No;for(let I=0;I<s.length;I+=3){d.x=s[I+0],d.y=s[I+1],d.z=s[I+2];let x=S(d)/2/Math.PI+.5,_=T(d)/Math.PI+.5;l.push(x,1-_)}let h=new No,f=new No,m=new No,y=new No,g=new wp,v=new wp,O=new wp,P=(I,x,_,D)=>{D<0&&I.x===1&&(l[x]=I.x-1),_.x===0&&_.z===0&&(l[x]=D/2/Math.PI+.5)};for(let I=0,x=0;I<s.length;I+=9,x+=6){h.set(s[I+0],s[I+1],s[I+2]),f.set(s[I+3],s[I+4],s[I+5]),m.set(s[I+6],s[I+7],s[I+8]),g.set(l[x+0],l[x+1]),v.set(l[x+2],l[x+3]),O.set(l[x+4],l[x+5]),y.copy(h).add(f).add(m).divideScalar(3);let _=S(y);P(g,x+0,h,_),P(v,x+2,f,_),P(O,x+4,m,_)}for(let I=0;I<l.length;I+=6){let x=l[I+0],_=l[I+2],D=l[I+4],A=Math.max(x,_,D),N=Math.min(x,_,D);A>.9&&N<.1&&(x<.2&&(l[I+0]+=1),_<.2&&(l[I+2]+=1),D<.2&&(l[I+4]+=1))}function S(I){return Math.atan2(I.z,-I.x)}function T(I){return Math.atan2(-I.y,Math.sqrt(I.x*I.x+I.z*I.z))}}}static fromJSON(r){return new ln(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};import{DodecahedronGeometry as XA}from"three";var Sx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new Ls(r*.5,i,a):new XA(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},Ls=class extends ln{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,i=1/o,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-o,0,-i,o,0,i,-o,0,i,o,-i,-o,0,-i,o,0,i,-o,0,i,o,0,-o,0,-i,o,0,-i,-o,0,i,o,0,i],s=[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(a,s,l,r,e,t),this.type=l}static fromJSON(r){return new Ls(r.radius,r.corner,r.cornerSides)}};import{Plane as aM,Shape as Rx,Vector2 as Do,Vector3 as sM,MathUtils as Ip,LineCurve as Np,QuadraticBezierCurve as Vx,CubicBezierCurve as Qc}from"three";import{CubicBezierCurve as Yc,EllipseCurve as KA,LineCurve as Xc,LineCurve3 as QA,MathUtils as ZA,QuadraticBezierCurve as Op,SplineCurve as JA,Vector2 as Ft,Vector3 as Ox}from"three";var Rs=1e-12,ca=class{constructor(r){this.position=new Ft;this.startPosition=new Ft;this.uuid=ZA.generateUUID();this.position=r.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(r){this.position.copy(this.startPosition).add(r)}copy(r){return this.position.copy(r.position),this.startPosition.copy(r.startPosition),this}clone(){return new ca(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},ua=class extends ca{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new ua(this.parent).copy(this)}},Lr=class extends ca{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new ua(this),new ua(this))}static create(e,t){let o=new Lr(e,new Ft(...t.position));return o.controls[0].position.set(...t.controlPrevious.position),o.controls[1].position.set(...t.controlNext.position),o.roundness=t.roundness,o.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,o}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 o=0,i=this.controls.length;o<i;o++){let a=this.controls[o];this.position.distanceTo(a.position)<=t?a.position.copy(this.position):a.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Lr(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new Ft,t=new Ft){let[o,i]=this.computeTangents();return o&&i&&(wx(o,e),wx(i,t)),[e,t]}computeTangent(e=new Ft){let[t,o]=this.computeTangents();return t&&o&&e.copy(t).add(o).normalize(),e}computeNormal(e=new Ft){let[t,o]=this.computeNormals();return e.copy(t).add(o).normalize(),e}};function wx(n,r=new Ft){let e=n.length();return r.set(-n.y/e,n.x/e)}var Cp=n=>n,da=new Ft,Kc=new Ft,eM=new Ft,tM=new Ft,rM=new Ft,oM=new Ft,Cx=new Ox,Tx=new Ox;function Ax(n){let r=new Ft;r.addVectors(n.v0,da.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Ft;return e.addVectors(n.v2,Kc.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new Yc(n.v0,r,e,n.v2)}function Vs(n,r,e=Number.EPSILON){return Math.abs(n-r)<e}function nM(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function iM(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function Tp(n,r,e){let t=Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2)),o=Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2)),i=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((o*o+t*t-i*i)/(2*o*t))}function Mx(n,r,e){return Px(n,r)&&Px(r,e)&&Pp(n.position,r.position,e.position)}function Pp(n,r,e){return da.copy(r).sub(n).cross(Kc.copy(e).sub(n))===0}function Ix(n,r,e,t,o){let i=Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2)),a=(n.y+r.y)/2,s=(n.x+r.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(n.y-r.y)/i,c=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(r.x-n.x)/i;return t.set(s+l,a+c),o.set(s-l,a-c),[t,o]}function Nx(n,r,e){let t=n.distanceTo(e),o=r.distanceTo(e);return t<o?r:n}function Dx(n,r,e,t,o,i){let a=r.x-n.x,s=r.y-n.y,l=e.x-n.x,c=e.y-n.y,u=Math.sqrt((a+l)*(a+l)+(s+c)*(s+c)),p;return Tp(r,n,e)>Math.PI&&(u*=-1),Vs(c,s)?p=(s+c)*(t/u-.5)*8/3/(a-l):p=(a+l)*(t/u-.5)*8/3/(c-s),o.set(r.x-p*s,r.y+p*a),i.set(e.x+p*c,e.y-p*l),[o,i]}function Ap(n,r){return n.position.equals(n.controls[1].position)&&r.position.equals(r.controls[0].position)}function Px(n,r){return Pp(n.position,n.controls[1].position,r.position)&&Pp(n.position,r.controls[0].position,r.position)}function Ex(n,r,e,t,o=.5){let i=da.subVectors(r,n).multiplyScalar(o).add(n),a=Kc.subVectors(e,r).multiplyScalar(o).add(r),s=eM.subVectors(t,e).multiplyScalar(o).add(e),l=i,c=tM.subVectors(a,i).multiplyScalar(o).add(i),u=rM.subVectors(s,a).multiplyScalar(o).add(a),p=s,d=oM.subVectors(u,c).multiplyScalar(o).add(c);return[n.x,n.y,l.x,l.y,c.x,c.y,d.x,d.y,u.x,u.y,p.x,p.y,t.x,t.y]}function _x(n,r,e=12,t=!0){let o=Tx.set(0,0,0),i,a=0,s=[];for(let l=0;l<r.length;l++){let c=Cp(r[l]),u=da,p=cn(c,e);s.push(p);for(let d=0;d<=p;d++)if(c instanceof Yc||c instanceof Op||c instanceof Xc){if(c.getPoint(d/p,u),o.set(u.x,u.y,0),i!==void 0&&iM(i,o))continue;i===void 0&&(i=Cx),i.copy(o),n.setXYZ(a,o.x,o.y,o.z),a++}}return t&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),n}function Bx(n,r,e,t=12,o=!0){let i=Tx.set(0,0,0),a=0,s=[];for(let l=0;l<r.length;l++){if(e[l]===!1)continue;let c,u=Cp(r[l]),p=da,d=cn(u,t);s.push(d);for(let h=0;h<=d;h++)if(u instanceof Yc||u instanceof Op||u instanceof Xc){if(u.getPoint(h/d,p),i.set(p.x,p.y,0),c?.equals(i))continue;c===void 0?c=Cx:(n.setXYZ(a,c.x,c.y,c.z),a++,n.setXYZ(a,i.x,i.y,i.z),a++),c.copy(i)}}return o&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),s}function Mp(n,r=12,e=!1){let t=[];for(let o=0,i=n.length;o<i;o++){let a=n[o],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=cn(a.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=cn(a.curveAfter,r)),t.push(s)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(t[n.length-1]+=cn(n[0].roundedCurveCorner,r)*.5),t}function cn(n,r=12){return n&&n instanceof KA?r*2:n&&(n instanceof Xc||n instanceof QA)?1:n&&n instanceof JA?r*n.points.length:r}function Lx(n,r,e=12,t=!0){let o,i=0;for(let a=0;a<r.length;a++){let s=Cp(r[a]),l=cn(s,e),c=da;for(let u=0;u<=l;u++)if(s instanceof Yc||s instanceof Op||s instanceof Xc){if(s.getPoint(u/l,c),o!==void 0&&nM(o,c,Rs))continue;o===void 0&&(o=Kc),o.copy(c),n.push(c.x,c.y),i++}}return Vs(n[0],n[n.length-2],Rs)&&Vs(n[1],n[n.length-1],Rs)&&(n.pop(),n.pop()),t&&i>1&&!(Vs(n[i-1],n[1],Rs)&&Vs(n[i-2],n[0],Rs))&&(n.push(n[0],n[1]),i++),n}var Dp=new Do,lM=new Do,cM=new Do,uM=new Do,dM=new Do,pM=new Do,Fe=class extends Rx{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new aM(new sM(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this.isText=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Ip.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,o){let i=new Fe;return i.isClosed=e.isClosed,i.points=e.points.map(a=>Lr.create(a.id,a.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(a=>Fe.createFromState(a)),t!==void 0&&o!==void 0&&i.applySize(t,o),i.update(),i}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,o=this.points.length;t<o;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,o=this.points.findIndex(i=>i.uuid===e);if(o<0){let i=t;for(let a=0,s=this.shapeHoles.length;a<s;a++){let l=this.shapeHoles[a],c=l.points.length,u=l.getPointIndexById(e);if(u<0)i+=c;else return u+i}}return o}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let o=0,i=this.shapeHoles.length;o<i;o++){let a=this.shapeHoles[o],s=e-t;if(s<=a.points.length-1)return a.points[s];t+=a.points.length}}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 o=0,i=this.shapeHoles.length;o<i;o++){let a=this.shapeHoles[o],s=a.points.indexOf(e);if(s>=0)return t+s;t+=a.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 o=Dp.set(e,t);for(let i=0,a=this.points.length;i<a;i++){let s=this.points[i];s.position.multiply(o),s.controls[0].position.multiply(o),s.controls[1].position.multiply(o)}for(let i=0,a=this.shapeHoles.length;i<a;i++)this.shapeHoles[i].applyScale(e,t);this._update()}createPoint(e,t=0,o=Ip.generateUUID()){let i;e instanceof Do?i=e:i=new Do(e,t);let a=new Lr(o,i);return a.roundness=this.roundness,a}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,o=this.points.length;t<o;t++){let i=this.points[t];if(i.uuid===e)return i}for(let t=0,o=this.shapeHoles.length;t<o;t++){let a=this.shapeHoles[t].getPointByUuid(e);if(a)return a}}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(o=>o.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,o=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let i=o?this.roundedCurveDivisions:this.curveDivisions;return _x(e,o?this.roundedCurves:this.curves,t,this.autoClose),i.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Mp(this.points,e,!1),this.roundedCurveDivisions=Mp(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,o=12){return Bx(e,this.curves,t,o,this.autoClose).reduce((a,s)=>a+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),Lx(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let i=t?this.roundedCurveDivisions:this.curveDivisions,a=0;t&&this.points[0].roundedCurveCorner!==void 0&&(a=cn(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=i.reduce((l,c)=>l+c,0));for(let l=0,c=i.length;l<c;l++){let u=i[l];if(s<o+u)return[l,(s-o+1)/u];o+=u}return[0,1]}getCurveT(e,t,o){let i=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(Ap(i,a)){let p=i.position.distanceTo(a.position);return i.position.distanceTo(Dp.set(o.x,o.y))/p}let c=0;for(let p=0;p<e;p++)c+=s[p];return(t-c)/l}dispose(){}_applyCurveForPoint(e,t){Ap(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 o=this.curves[this.curves.length-1];e.curveBefore=o,t.curveAfter=o;let i=o.clone();e.roundedCurveBefore=i,t.roundedCurveAfter=i,e.roundedCurveCorner=void 0,this.roundedCurves.push(i)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,o=this.points.length;t<o;t++){let i=this.points[t];if(t===0)this.moveTo(i.position.x,i.position.y);else{let a=this.points[t-1];this._applyCurveForPoint(i,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],o=this.points[this.points.length-1];this._applyCurveForPoint(t,o)}if(this.points.length>2){let t=0;for(let o=0,i=this.points.length;o<i;o++){let a=this.points[o],s=this.points[o-1]??this.points[this.points.length-1],l=this.points[o+1]??this.points[0],c=a.roundness,u=s&&l&&Mx(s,a,l);if(!a.controlsMoved()&&c>0&&!u){let p=a.curveBefore,d=a.curveAfter;if(p===void 0||d===void 0)continue;let h=a.roundedCurveBefore,f=a.roundedCurveAfter,m=p.getLength(),y=d.getLength(),g=Math.min(c,m*.499),v=Math.min(c,y*.499),O=Math.min(g,v),P=1-O/m,S=O/y,T=p.getPointAt(P,Dp),I=d.getPointAt(S,lM);this._subSplitCurve(p,h,P,T,void 0),this._subSplitCurve(d,f,S,void 0,I);let x;if(this.useCubicForRoundedCorners){let _=Tp(T,a.position,I)/2,D=Math.tan(_)*T.distanceTo(a.position),[A,N]=Ix(T,I,D,cM,uM),E=Nx(A,N,a.position),[B,V]=Dx(E,T,I,D,dM,pM);x=new Qc(T.clone(),B.clone(),V.clone(),I.clone())}else x=new Vx(T.clone(),a.position.clone(),I.clone());a.roundedCurveCorner=x,this.roundedCurves.splice(o+t,0,x),t++}}}}_subSplitCurve(e,t,o,i,a){if(e instanceof Np)i!==void 0&&t.v2.copy(i),a!==void 0&&t.v1.copy(a);else{let s=e,l=t,c=s.getUtoTmapping(o,0),u=Ex(s.v0,s.v1,s.v2,s.v3,c);return i!==void 0&&(l.v0.set(u[0],u[1]),l.v1.set(u[2],u[3]),l.v2.set(u[4],u[5]),l.v3.set(u[6],u[7])),a!==void 0&&(l.v0.set(u[6],u[7]),l.v1.set(u[8],u[9]),l.v2.set(u[10],u[11]),l.v3.set(u[12],u[13])),l}return t}clone(){let e=new Fe(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){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let o=0;o<t;o++){let i=o*7,a=e.points[i+0],s=e.points[i+1],l=e.points[i+2],c=e.points[i+3],u=e.points[i+4],p=e.points[i+5],d=e.points[i+6],h=new Lr(Ip.generateUUID(),new Do(a,s));h.controls[0].position.set(l,c),h.controls[1].position.set(u,p),h.roundness=d,this.points.push(h)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new Fe;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let o=(a,s)=>{s instanceof Qc&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},i=a=>{let s=[],l,c;for(l=0,c=a.length;l<c;l++)a[l]instanceof Vx&&(a[l]=Ax(a[l]));for(l=0,c=a.length;l<c;l++){let d=a[l],h=l>0?a[l-1]:null,f;d instanceof Qc?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Np&&(f=this.createPoint(d.v1)),f!==void 0&&(h!==null&&o(f,h),s.push(f))}let u=a[a.length-1],p=!1;return u instanceof Qc?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),p=!0):u instanceof Np&&u.v2.equals(s[0].position)&&(p=!0),this.isClosed=p,s};return this.points=i(e.curves),e instanceof Rx&&(this.shapeHoles=e.holes.map(a=>{let s=new Fe;return s.fromShape(a),s})),this.update(),this}updatePoint(e,t){let o=this.getPointByUuid(e);o&&(t.position!==void 0&&o.position.fromArray(t.position),t.roundness!==void 0&&(o.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(o.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}};var _p=Math.PI*2;function Ep({x:n,y:r},e,t,o,i){return{x:n*e+o,y:r*t+i}}function fM(n,r){let e=r===1.5707963267948966?.551915024494:r===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(r/4),t=Math.cos(n),o=Math.sin(n),i=Math.cos(n+r),a=Math.sin(n+r);return[{x:t-o*e,y:o+t*e},{x:i+a*e,y:a-i*e},{x:i,y:a}]}function zx(n,r,e,t){let o=n*t-r*e<0?-1:1,i=Math.min(1,Math.max(-1,n*e+r*t));return o*Math.acos(i)}function hM(n,r,e,t,o,i,a,s,l,c){let u=Math.pow(o,2),p=Math.pow(i,2),d=Math.pow(a,2),h=Math.pow(s,2),f=u*p-u*h-p*d;f<0&&(f=0),f/=u*h+p*d,f=Math.sqrt(f)*(l===c?-1:1);let m=f*o/i*s,y=f*-i/o*a,g=m+(n+e)/2,v=y+(r+t)/2,O=(a-m)/o,P=(s-y)/i,S=(-a-m)/o,T=(-s-y)/i,I=zx(1,0,O,P),x=zx(O,P,S,T);return!c&&x>0&&(x-=_p),c&&x<0&&(x+=_p),{centerx:g,centery:v,ang1:I,ang2:x}}function Gx({px:n,py:r,cx:e,cy:t,rx:o,ry:i,largeArcFlag:a,sweepFlag:s}){let l=[];if(o===0||i===0)return[];let c=(n-e)/2,u=(r-t)/2;if(c===0&&u===0)return[];o=Math.abs(o),i=Math.abs(i);let p=Math.pow(c,2)/Math.pow(o,2)+Math.pow(u,2)/Math.pow(i,2);p>1&&(o*=Math.sqrt(p),i*=Math.sqrt(p));let d=hM(n,r,e,t,o,i,c,u,a,s),{ang1:h,ang2:f}=d,{centerx:m,centery:y}=d,g=Math.abs(f)/(_p/4);Math.abs(1-g)<1e-7&&(g=1);let v=Math.max(Math.ceil(g),1);f/=v;for(let O=0;O<v;O++)l.push(fM(h,f)),h+=f;return l.map(O=>{let{x:P,y:S}=Ep(O[0],o,i,m,y),{x:T,y:I}=Ep(O[1],o,i,m,y),{x,y:_}=Ep(O[2],o,i,m,y);return{x1:P,y1:S,x2:T,y2:I,x,y:_}})}import{BufferAttribute as ru,BufferGeometry as TM}from"three";var Ge;(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"})(Ge||(Ge={}));var nt;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(nt||(nt={}));function we(n,r){if(!n)throw r||"Assertion Failed!"}var be=function(){function n(){}return n.vertEq=function(r,e){return r.s===e.s&&r.t===e.t},n.vertLeq=function(r,e){return r.s<e.s||r.s===e.s&&r.t<=e.t},n.transLeq=function(r,e){return r.t<e.t||r.t===e.t&&r.s<=e.s},n.edgeGoesLeft=function(r){return n.vertLeq(r.Dst,r.Org)},n.edgeGoesRight=function(r){return n.vertLeq(r.Org,r.Dst)},n.vertL1dist=function(r,e){return Math.abs(r.s-e.s)+Math.abs(r.t-e.t)},n.edgeEval=function(r,e,t){we(n.vertLeq(r,e)&&n.vertLeq(e,t));var o=e.s-r.s,i=t.s-e.s;return o+i>0?o<i?e.t-r.t+(r.t-t.t)*(o/(o+i)):e.t-t.t+(t.t-r.t)*(i/(o+i)):0},n.edgeSign=function(r,e,t){we(n.vertLeq(r,e)&&n.vertLeq(e,t));var o=e.s-r.s,i=t.s-e.s;return o+i>0?(e.t-t.t)*o+(e.t-r.t)*i:0},n.transEval=function(r,e,t){we(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?o<i?e.s-r.s+(r.s-t.s)*(o/(o+i)):e.s-t.s+(t.s-r.s)*(i/(o+i)):0},n.transSign=function(r,e,t){we(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?(e.s-t.s)*o+(e.s-r.s)*i:0},n.vertCCW=function(r,e,t){return r.s*(e.t-t.t)+e.s*(t.t-r.t)+t.s*(r.t-e.t)>=0},n.interpolate=function(r,e,t,o){return r=r<0?0:r,t=t<0?0:t,r<=t?t===0?(e+o)/2:e+(o-e)*(r/(r+t)):o+(e-o)*(t/(r+t))},n.intersect=function(r,e,t,o,i){var a,s,l;n.vertLeq(r,e)||(l=r,r=e,e=l),n.vertLeq(t,o)||(l=t,t=o,o=l),n.vertLeq(r,t)||(l=r,r=t,t=l,l=e,e=o,o=l),n.vertLeq(t,e)?n.vertLeq(e,o)?(a=n.edgeEval(r,t,e),s=n.edgeEval(t,e,o),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,t.s,s,e.s)):(a=n.edgeSign(r,t,e),s=-n.edgeSign(r,o,e),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,t.s,s,o.s)):i.s=(t.s+e.s)/2,n.transLeq(r,e)||(l=r,r=e,e=l),n.transLeq(t,o)||(l=t,t=o,o=l),n.transLeq(r,t)||(l=r,r=t,t=l,l=e,e=o,o=l),n.transLeq(t,e)?n.transLeq(e,o)?(a=n.transEval(r,t,e),s=n.transEval(t,e,o),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,t.t,s,e.t)):(a=n.transSign(r,t,e),s=-n.transSign(r,o,e),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,t.t,s,o.t)):i.t=(t.t+e.t)/2},n}(),zs=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}(),Zc=function(){function n(r){this.side=r,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(r){this.Sym.Lface=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(r){this.Sym.Org=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(r){this.Sym.Lnext=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(r){this.Onext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(r){this.Lnext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(r){this.Sym.Onext=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(r){this.Sym.Onext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(r){this.Sym.Lnext.Sym=r},enumerable:!0,configurable:!0}),n}(),pa=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}(),jx=function(){function n(){var r=new pa,e=new zs,t=new Zc(0),o=new Zc(1);r.next=r.prev=r,r.anEdge=null,e.next=e.prev=e,t.next=t,t.Sym=o,o.next=o,o.Sym=t,this.vHead=r,this.fHead=e,this.eHead=t,this.eHeadSym=o}return n.prototype.makeEdge_=function(r){var e=new Zc(0),t=new Zc(1);r.Sym.side<r.side&&(r=r.Sym);var o=r.Sym.next;return t.next=o,o.Sym.next=e,e.next=r,r.Sym.next=t,e.Sym=t,e.Onext=e,e.Lnext=t,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,t.Sym=e,t.Onext=t,t.Lnext=e,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,e},n.prototype.splice_=function(r,e){var t=r.Onext,o=e.Onext;t.Sym.Lnext=e,o.Sym.Lnext=r,r.Onext=o,e.Onext=t},n.prototype.makeVertex_=function(r,e,t){var o=r;we(o,"Vertex can't be null!");var i=t.prev;o.prev=i,i.next=o,o.next=t,t.prev=o,o.anEdge=e;var a=e;do a.Org=o,a=a.Onext;while(a!==e)},n.prototype.makeFace_=function(r,e,t){var o=r;we(o,"Face can't be null");var i=t.prev;o.prev=i,i.next=o,o.next=t,t.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=t.inside;var a=e;do a.Lface=o,a=a.Lnext;while(a!==e)},n.prototype.killEdge_=function(r){r.Sym.side<r.side&&(r=r.Sym);var e=r.next,t=r.Sym.next;e.Sym.next=t,t.Sym.next=e},n.prototype.killVertex_=function(r,e){var t=r.anEdge,o=t;do o.Org=e,o=o.Onext;while(o!==t);var i=r.prev,a=r.next;a.prev=i,i.next=a},n.prototype.killFace_=function(r,e){var t=r.anEdge,o=t;do o.Lface=e,o=o.Lnext;while(o!==t);var i=r.prev,a=r.next;a.prev=i,i.next=a},n.prototype.makeEdge=function(){var r=new pa,e=new pa,t=new zs,o=this.makeEdge_(this.eHead);return this.makeVertex_(r,o,this.vHead),this.makeVertex_(e,o.Sym,this.vHead),this.makeFace_(t,o,this.fHead),o},n.prototype.splice=function(r,e){var t=!1,o=!1;if(r!==e){if(e.Org!==r.Org&&(o=!0,this.killVertex_(e.Org,r.Org)),e.Lface!==r.Lface&&(t=!0,this.killFace_(e.Lface,r.Lface)),this.splice_(e,r),!o){var i=new pa;this.makeVertex_(i,e,r.Org),r.Org.anEdge=r}if(!t){var a=new zs;this.makeFace_(a,e,r.Lface),r.Lface.anEdge=r}}},n.prototype.delete=function(r){var e=r.Sym,t=!1;if(r.Lface!==r.Rface&&(t=!0,this.killFace_(r.Lface,r.Rface)),r.Onext===r)this.killVertex_(r.Org,null);else if(r.Rface.anEdge=r.Oprev,r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev),!t){var o=new zs;this.makeFace_(o,r,r.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(r.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(r)},n.prototype.addEdgeVertex=function(r){var e=this.makeEdge_(r),t=e.Sym;this.splice_(e,r.Lnext),e.Org=r.Dst;var o=new pa;return this.makeVertex_(o,t,e.Org),e.Lface=t.Lface=r.Lface,e},n.prototype.splitEdge=function(r){var e=this.addEdgeVertex(r),t=e.Sym;return this.splice_(r.Sym,r.Sym.Oprev),this.splice_(r.Sym,t),r.Dst=t.Org,t.Dst.anEdge=t.Sym,t.Rface=r.Rface,t.winding=r.winding,t.Sym.winding=r.Sym.winding,t.idx=r.idx,t.Sym.idx=r.Sym.idx,t},n.prototype.connect=function(r,e){var t=!1,o=this.makeEdge_(r),i=o.Sym;if(e.Lface!==r.Lface&&(t=!0,this.killFace_(e.Lface,r.Lface)),this.splice_(o,r.Lnext),this.splice_(i,e),o.Org=r.Dst,i.Org=e.Org,o.Lface=i.Lface=r.Lface,r.Lface.anEdge=i,!t){var a=new zs;this.makeFace_(a,o,r.Lface)}return o},n.prototype.zapFace=function(r){var e=r.anEdge,t,o,i,a,s;o=e.Lnext;do t=o,o=t.Lnext,t.Lface=null,t.Rface===null&&(t.Onext===t?this.killVertex_(t.Org,null):(t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),i=t.Sym,i.Onext===i?this.killVertex_(i.Org,null):(i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t));while(t!=e);a=r.prev,s=r.next,s.prev=a,a.next=s},n.prototype.countFaceVerts_=function(r){var e=r.anEdge,t=0;do t++,e=e.Lnext;while(e!==r.anEdge);return t},n.prototype.mergeConvexFaces=function(r){var e,t,o,i,a,s,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(t=e.anEdge,a=t.Org;o=t.Lnext,i=t.Sym,i&&i.Lface&&i.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(i.Lface),s+l-2<=r&&be.vertCCW(t.Lprev.Org,t.Org,i.Lnext.Lnext.Org)&&be.vertCCW(i.Lprev.Org,i.Org,t.Lnext.Lnext.Org)&&(o=i.Lnext,this.delete(i),t=null,i=null)),!(t&&t.Lnext.Org===a);)t=o;return!0},n.prototype.check=function(){var r=this.fHead,e=this.vHead,t=this.eHead,o,i,a,s,l,c;for(i=r,i=r;(o=i.next)!==r;i=o){we(o.prev===i),l=o.anEdge;do we(l.Sym!==l),we(l.Sym.Sym===l),we(l.Lnext.Onext.Sym===l),we(l.Onext.Sym.Lnext===l),we(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(we(o.prev===i&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){we(a.prev===s),l=a.anEdge;do we(l.Sym!==l),we(l.Sym.Sym===l),we(l.Lnext.Onext.Sym===l),we(l.Onext.Sym.Lnext===l),we(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(we(a.prev===s&&a.anEdge===null),c=t,c=t;(l=c.next)!==t;c=l)we(l.Sym.next===c.Sym),we(l.Sym!==l),we(l.Sym.Sym===l),we(l.Org!==null),we(l.Dst!==null),we(l.Lnext.Onext.Sym===l),we(l.Onext.Sym.Lnext===l);we(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}(),Fx=function(){function n(){this.handle=null}return n}(),Ux=function(){function n(){this.key=null,this.node=0}return n}(),mM=function(){function n(r,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=r,this.nodes=[],this.handles=[];for(var t=0;t<r+1;t++)this.nodes[t]=new Fx,this.handles[t]=new Ux;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(r){var e=this.nodes,t=this.handles,o,i,a;for(o=e[r].handle;;){if(a=r<<1,a<this.size&&this.leq(t[e[a+1].handle].key,t[e[a].handle].key)&&++a,we(a<=this.max),i=e[a].handle,a>this.size||this.leq(t[o].key,t[i].key)){e[r].handle=o,t[o].node=r;break}e[r].handle=i,t[i].node=r,r=a}},n.prototype.floatUp_=function(r){var e=this.nodes,t=this.handles,o,i,a;for(o=e[r].handle;;){if(a=r>>1,i=e[a].handle,a===0||this.leq(t[i].key,t[o].key)){e[r].handle=o,t[o].node=r;break}e[r].handle=i,t[i].node=r,r=a}},n.prototype.init=function(){for(var r=this.size;r>=1;--r)this.floatDown_(r);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(r){var e,t;if(e=++this.size,e*2>this.max){this.max*=2;var o,i;for(i=this.nodes.length,this.nodes.length=this.max+1,o=i;o<this.nodes.length;o++)this.nodes[o]=new Fx;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new Ux}return this.freeList===0?t=e:(t=this.freeList,this.freeList=this.handles[t].node),this.nodes[e].handle=t,this.handles[t].node=e,this.handles[t].key=r,this.initialized&&this.floatUp_(e),t},n.prototype.extractMin=function(){var r=this.nodes,e=this.handles,t=r[1].handle,o=e[t].key;return this.size>0&&(r[1].handle=r[this.size].handle,e[r[1].handle].node=1,e[t].key=null,e[t].node=this.freeList,this.freeList=t,--this.size,this.size>0&&this.floatDown_(1)),o},n.prototype.delete=function(r){var e=this.nodes,t=this.handles,o;we(r>=1&&r<=this.max&&t[r].key!==null),o=t[r].node,e[o].handle=e[this.size].handle,t[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(t[e[o>>1].handle].key,t[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),t[r].key=null,t[r].node=this.freeList,this.freeList=r},n}(),Bp=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}(),kx=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),yM=function(){function n(r,e){this.frame=r,this.leq=e,this.head=new kx,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(r){return this.insertBefore(this.head,r)},n.prototype.search=function(r){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,r,e.key));return e},n.prototype.insertBefore=function(r,e){do r=r.prev;while(r.key!==null&&!this.leq(this.frame,r.key,e));var t=new kx;return t.key=e,t.next=r.next,r.next.prev=t,t.prev=r,r.next=t,t},n.prototype.delete=function(r){r.next.prev=r.prev,r.prev.next=r.next},n}(),gM=function(){function n(){}return n.regionBelow=function(r){return r.nodeUp.prev.key},n.regionAbove=function(r){return r.nodeUp.next.key},n.debugEvent=function(r){},n.addWinding=function(r,e){r.winding+=e.winding,r.Sym.winding+=e.Sym.winding},n.edgeLeq=function(r,e,t){var o=r.event,i=e.eUp,a=t.eUp;if(i.Dst===o)return a.Dst===o?be.vertLeq(i.Org,a.Org)?be.edgeSign(a.Dst,i.Org,a.Org)<=0:be.edgeSign(i.Dst,a.Org,i.Org)>=0:be.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return be.edgeSign(i.Dst,o,i.Org)>=0;var s=be.edgeEval(i.Dst,o,i.Org),l=be.edgeEval(a.Dst,o,a.Org);return s>=l},n.deleteRegion=function(r,e){e.fixUpperEdge&&we(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},n.fixUpperEdge=function(r,e,t){we(e.fixUpperEdge),r.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=t,t.activeRegion=e},n.topLeftRegion=function(r,e){var t=e.eUp.Org,o;do e=n.regionAbove(e);while(e.eUp.Org===t);if(e.fixUpperEdge){if(o=r.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;n.fixUpperEdge(r,e,o),e=n.regionAbove(e)}return e},n.topRightRegion=function(r){var e=r.eUp.Dst;do r=n.regionAbove(r);while(r.eUp.Dst===e);return r},n.addRegionBelow=function(r,e,t){var o=new Bp;return o.eUp=t,o.nodeUp=r.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,t.activeRegion=o,o},n.isWindingInside=function(r,e){switch(r.windingRule){case Ge.ODD:return(e&1)!==0;case Ge.NONZERO:return e!==0;case Ge.POSITIVE:return e>0;case Ge.NEGATIVE:return e<0;case Ge.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(r,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(r,e.windingNumber)},n.finishRegion=function(r,e){var t=e.eUp,o=t.Lface;o.inside=e.inside,o.anEdge=t,n.deleteRegion(r,e)},n.finishLeftRegions=function(r,e,t){for(var o,i=null,a=e,s=e.eUp;a!==t;){if(a.fixUpperEdge=!1,i=n.regionBelow(a),o=i.eUp,o.Org!=s.Org){if(!i.fixUpperEdge){n.finishRegion(r,a);break}o=r.mesh.connect(s.Lprev,o.Sym),n.fixUpperEdge(r,i,o)}s.Onext!==o&&(r.mesh.splice(o.Oprev,o),r.mesh.splice(s,o)),n.finishRegion(r,a),s=i.eUp,a=i}return s},n.addRightEdges=function(r,e,t,o,i,a){var s,l,c,u,p=!0;c=t;do we(be.vertLeq(c.Org,c.Dst)),n.addRegionBelow(r,e,c.Sym),c=c.Onext;while(c!==o);for(i===null&&(i=n.regionBelow(e).eUp.Rprev),l=e,u=i;s=n.regionBelow(l),c=s.eUp.Sym,c.Org===u.Org;)c.Onext!==u&&(r.mesh.splice(c.Oprev,c),r.mesh.splice(u.Oprev,c)),s.windingNumber=l.windingNumber-c.winding,s.inside=n.isWindingInside(r,s.windingNumber),l.dirty=!0,!p&&n.checkForRightSplice(r,l)&&(n.addWinding(c,u),n.deleteRegion(r,l),r.mesh.delete(u)),p=!1,l=s,u=c;l.dirty=!0,we(l.windingNumber-c.winding===s.windingNumber),a&&n.walkDirtyRegions(r,l)},n.spliceMergeVertices=function(r,e,t){r.mesh.splice(e,t)},n.vertexWeights=function(r,e,t){var o=be.vertL1dist(e,r),i=be.vertL1dist(t,r),a=.5*i/(o+i),s=.5*o/(o+i);r.coords[0]+=a*e.coords[0]+s*t.coords[0],r.coords[1]+=a*e.coords[1]+s*t.coords[1],r.coords[2]+=a*e.coords[2]+s*t.coords[2]},n.getIntersectData=function(r,e,t,o,i,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,t,o),n.vertexWeights(e,i,a)},n.checkForRightSplice=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp;if(be.vertLeq(o.Org,i.Org)){if(be.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;be.vertEq(o.Org,i.Org)?o.Org!==i.Org&&(r.pq.delete(o.Org.pqHandle),n.spliceMergeVertices(r,i.Oprev,o)):(r.mesh.splitEdge(i.Sym),r.mesh.splice(o,i.Oprev),e.dirty=t.dirty=!0)}else{if(be.edgeSign(o.Dst,i.Org,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,r.mesh.splitEdge(o.Sym),r.mesh.splice(i.Oprev,o)}return!0},n.checkForLeftSplice=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp,a;if(we(!be.vertEq(o.Dst,i.Dst)),be.vertLeq(o.Dst,i.Dst)){if(be.edgeSign(o.Dst,i.Dst,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,a=r.mesh.splitEdge(o),r.mesh.splice(i.Sym,a),a.Lface.inside=e.inside}else{if(be.edgeSign(i.Dst,o.Dst,i.Org)>0)return!1;e.dirty=t.dirty=!0,a=r.mesh.splitEdge(i),r.mesh.splice(o.Lnext,i.Sym),a.Rface.inside=e.inside}return!0},n.checkForIntersect=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp,a=o.Org,s=i.Org,l=o.Dst,c=i.Dst,u,p,d=new pa,h,f;if(we(!be.vertEq(c,l)),we(be.edgeSign(l,r.event,a)<=0),we(be.edgeSign(c,r.event,s)>=0),we(a!==r.event&&s!==r.event),we(!e.fixUpperEdge&&!t.fixUpperEdge),a===s||(u=Math.min(a.t,l.t),p=Math.max(s.t,c.t),u>p))return!1;if(be.vertLeq(a,s)){if(be.edgeSign(c,a,s)>0)return!1}else if(be.edgeSign(l,s,a)<0)return!1;return n.debugEvent(r),be.intersect(l,a,c,s,d),we(Math.min(a.t,l.t)<=d.t),we(d.t<=Math.max(s.t,c.t)),we(Math.min(c.s,l.s)<=d.s),we(d.s<=Math.max(s.s,a.s)),be.vertLeq(d,r.event)&&(d.s=r.event.s,d.t=r.event.t),h=be.vertLeq(a,s)?a:s,be.vertLeq(h,d)&&(d.s=h.s,d.t=h.t),be.vertEq(d,a)||be.vertEq(d,s)?(n.checkForRightSplice(r,e),!1):!be.vertEq(l,r.event)&&be.edgeSign(l,r.event,d)>=0||!be.vertEq(c,r.event)&&be.edgeSign(c,r.event,d)<=0?c===r.event?(r.mesh.splitEdge(o.Sym),r.mesh.splice(i.Sym,o),e=n.topLeftRegion(r,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(r,n.regionBelow(e),t),n.addRightEdges(r,e,o.Oprev,o,o,!0),!0):l===r.event?(r.mesh.splitEdge(i.Sym),r.mesh.splice(o.Lnext,i.Oprev),t=e,e=n.topRightRegion(e),f=n.regionBelow(e).eUp.Rprev,t.eUp=i.Oprev,i=n.finishLeftRegions(r,t,null),n.addRightEdges(r,e,i.Onext,o.Rprev,f,!0),!0):(be.edgeSign(l,r.event,d)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,r.mesh.splitEdge(o.Sym),o.Org.s=r.event.s,o.Org.t=r.event.t),be.edgeSign(c,r.event,d)<=0&&(e.dirty=t.dirty=!0,r.mesh.splitEdge(i.Sym),i.Org.s=r.event.s,i.Org.t=r.event.t),!1):(r.mesh.splitEdge(o.Sym),r.mesh.splitEdge(i.Sym),r.mesh.splice(i.Oprev,o),o.Org.s=d.s,o.Org.t=d.t,o.Org.pqHandle=r.pq.insert(o.Org),n.getIntersectData(r,o.Org,a,l,s,c),n.regionAbove(e).dirty=e.dirty=t.dirty=!0,!1)},n.walkDirtyRegions=function(r,e){for(var t=n.regionBelow(e),o,i;;){for(;t.dirty;)e=t,t=n.regionBelow(t);if(!e.dirty&&(t=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,i=t.eUp,o.Dst!==i.Dst&&n.checkForLeftSplice(r,e)&&(t.fixUpperEdge?(n.deleteRegion(r,t),r.mesh.delete(i),t=n.regionBelow(e),i=t.eUp):e.fixUpperEdge&&(n.deleteRegion(r,e),r.mesh.delete(o),e=n.regionAbove(t),o=e.eUp)),o.Org!==i.Org)if(o.Dst!==i.Dst&&!e.fixUpperEdge&&!t.fixUpperEdge&&(o.Dst===r.event||i.Dst===r.event)){if(n.checkForIntersect(r,e))return}else n.checkForRightSplice(r,e);o.Org===i.Org&&o.Dst===i.Dst&&(n.addWinding(i,o),n.deleteRegion(r,e),r.mesh.delete(o),e=n.regionAbove(t))}},n.connectRightVertex=function(r,e,t){var o,i=t.Onext,a=n.regionBelow(e),s=e.eUp,l=a.eUp,c=!1;if(s.Dst!==l.Dst&&n.checkForIntersect(r,e),be.vertEq(s.Org,r.event)&&(r.mesh.splice(i.Oprev,s),e=n.topLeftRegion(r,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(r,n.regionBelow(e),a),c=!0),be.vertEq(l.Org,r.event)&&(r.mesh.splice(t,l.Oprev),t=n.finishLeftRegions(r,a,null),c=!0),c){n.addRightEdges(r,e,t.Onext,i,i,!0);return}be.vertLeq(l.Org,s.Org)?o=l.Oprev:o=s,o=r.mesh.connect(t.Lprev,o),n.addRightEdges(r,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(r,e)},n.connectLeftDegenerate=function(r,e,t){var o,i,a,s,l;if(o=e.eUp,be.vertEq(o.Org,t)){we(!1),n.spliceMergeVertices(r,o,t.anEdge);return}if(!be.vertEq(o.Dst,t)){r.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(r.mesh.delete(o.Onext),e.fixUpperEdge=!1),r.mesh.splice(t.anEdge,o),n.sweepEvent(r,t);return}we(!1),e=n.topRightRegion(e),l=n.regionBelow(e),a=l.eUp.Sym,i=s=a.Onext,l.fixUpperEdge&&(we(i!==a),n.deleteRegion(r,l),r.mesh.delete(a),a=i.Oprev),r.mesh.splice(t.anEdge,a),be.edgeGoesLeft(i)||(i=null),n.addRightEdges(r,e,a.Onext,s,i,!0)},n.connectLeftVertex=function(r,e){var t,o,i,a,s,l,c=new Bp;if(c.eUp=e.anEdge.Sym,t=r.dict.search(c).key,o=n.regionBelow(t),!!o){if(a=t.eUp,s=o.eUp,be.edgeSign(a.Dst,e,a.Org)===0){n.connectLeftDegenerate(r,t,e);return}if(i=be.vertLeq(s.Dst,a.Dst)?t:o,t.inside||i.fixUpperEdge){if(i===t)l=r.mesh.connect(e.anEdge.Sym,a.Lnext);else{var u=r.mesh.connect(s.Dnext,e.anEdge);l=u.Sym}i.fixUpperEdge?n.fixUpperEdge(r,i,l):n.computeWinding(r,n.addRegionBelow(r,t,l)),n.sweepEvent(r,e)}else n.addRightEdges(r,t,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(r,e){r.event=e,n.debugEvent(r);for(var t=e.anEdge;t.activeRegion===null;)if(t=t.Onext,t===e.anEdge){n.connectLeftVertex(r,e);return}var o=n.topLeftRegion(r,t.activeRegion);we(o!==null);var i=n.regionBelow(o),a=i.eUp,s=n.finishLeftRegions(r,i,null);s.Onext===a?n.connectRightVertex(r,o,s):n.addRightEdges(r,o,s.Onext,a,a,!0)},n.addSentinel=function(r,e,t,o){var i=new Bp,a=r.mesh.makeEdge();a.Org.s=t,a.Org.t=o,a.Dst.s=e,a.Dst.t=o,r.event=a.Dst,i.eUp=a,i.windingNumber=0,i.inside=!1,i.fixUpperEdge=!1,i.sentinel=!0,i.dirty=!1,i.nodeUp=r.dict.insert(i)},n.initEdgeDict=function(r){r.dict=new yM(r,n.edgeLeq);var e=r.bmax[0]-r.bmin[0],t=r.bmax[1]-r.bmin[1],o=r.bmin[0]-e,i=r.bmax[0]+e,a=r.bmin[1]-t,s=r.bmax[1]+t;n.addSentinel(r,o,i,a),n.addSentinel(r,o,i,s)},n.doneEdgeDict=function(r){for(var e,t=0;(e=r.dict.min().key)!==null;)e.sentinel||(we(e.fixUpperEdge),we(++t===1)),we(e.windingNumber===0),n.deleteRegion(r,e)},n.removeDegenerateEdges=function(r){var e,t,o,i=r.mesh.eHead;for(e=i.next;e!==i;e=t)t=e.next,o=e.Lnext,be.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(r,o,e),r.mesh.delete(e),e=o,o=e.Lnext),o.Lnext===e&&(o!==e&&((o===t||o===t.Sym)&&(t=t.next),r.mesh.delete(o)),(e===t||e===t.Sym)&&(t=t.next),r.mesh.delete(e))},n.initPriorityQ=function(r){var e,t,o,i=0;for(o=r.mesh.vHead,t=o.next;t!==o;t=t.next)i++;for(i+=8,e=r.pq=new mM(i,be.vertLeq),o=r.mesh.vHead,t=o.next;t!==o;t=t.next)t.pqHandle=e.insert(t);return t!==o?!1:(e.init(),!0)},n.donePriorityQ=function(r){r.pq=null},n.removeDegenerateFaces=function(r,e){var t,o,i;for(t=e.fHead.next;t!==e.fHead;t=o)o=t.next,i=t.anEdge,we(i.Lnext!==i),i.Lnext.Lnext===i&&(n.addWinding(i.Onext,i),r.mesh.delete(i));return!0},n.computeInterior=function(r,e){e===void 0&&(e=!0);var t,o;if(n.removeDegenerateEdges(r),!n.initPriorityQ(r))return!1;for(n.initEdgeDict(r);(t=r.pq.extractMin())!==null;){for(;o=r.pq.min(),!(o===null||!be.vertEq(o,t));)o=r.pq.extractMin(),n.spliceMergeVertices(r,t.anEdge,o.anEdge);n.sweepEvent(r,t)}return r.event=r.dict.min().key.eUp.Org,n.debugEvent(r),n.doneEdgeDict(r),n.donePriorityQ(r),n.removeDegenerateFaces(r,r.mesh)?(e&&r.mesh.check(),!0):!1},n}(),xM=function(){function n(){this.mesh=new jx,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=Ge.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(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]},n.prototype.normalize_=function(r){var e=r[0]*r[0]+r[1]*r[1]+r[2]*r[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),r[0]/=e,r[1]/=e,r[2]/=e},n.prototype.longAxis_=function(r){var e=0;return Math.abs(r[1])>Math.abs(r[0])&&(e=1),Math.abs(r[2])>Math.abs(r[e])&&(e=2),e},n.prototype.computeNormal_=function(r){var e,t,o,i,a,s,l=[0,0,0],c=[0,0,0],u=[0,0,0],p=[0,0,0],d=[0,0,0],h=[null,null,null],f=[null,null,null],m=this.mesh.vHead;e=m.next;for(var y=0;y<3;++y)i=e.coords[y],c[y]=i,f[y]=e,l[y]=i,h[y]=e;for(e=m.next;e!==m;e=e.next)for(var g=0;g<3;++g)i=e.coords[g],i<c[g]&&(c[g]=i,f[g]=e),i>l[g]&&(l[g]=i,h[g]=e);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){r[0]=0,r[1]=0,r[2]=1;return}for(s=0,t=f[v],o=h[v],u[0]=t.coords[0]-o.coords[0],u[1]=t.coords[1]-o.coords[1],u[2]=t.coords[2]-o.coords[2],e=m.next;e!==m;e=e.next)p[0]=e.coords[0]-o.coords[0],p[1]=e.coords[1]-o.coords[1],p[2]=e.coords[2]-o.coords[2],d[0]=u[1]*p[2]-u[2]*p[1],d[1]=u[2]*p[0]-u[0]*p[2],d[2]=u[0]*p[1]-u[1]*p[0],a=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],a>s&&(s=a,r[0]=d[0],r[1]=d[1],r[2]=d[2]);s<=0&&(r[0]=r[1]=r[2]=0,r[this.longAxis_(u)]=1)},n.prototype.checkOrientation_=function(){for(var r=this.mesh.fHead,e,t=this.mesh.vHead,o,i=0,a=r.next;a!==r;a=a.next)if(o=a.anEdge,!(o.winding<=0))do i+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==a.anEdge);if(i<0){for(e=t.next;e!==t;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 r=this.mesh.vHead,e=[0,0,0],t,o,i=!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),i=!0),t=this.sUnit,o=this.tUnit;var a=this.longAxis_(e);t[a]=0,t[(a+1)%3]=1,t[(a+2)%3]=0,o[a]=0,o[(a+1)%3]=0,o[(a+2)%3]=e[a]>0?1:-1;for(var s=r.next;s!==r;s=s.next)s.s=this.dot_(s.coords,t),s.t=this.dot_(s.coords,o);i&&this.checkOrientation_();for(var l=!0,c=r.next;c!==r;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(r,e){r.winding+=e.winding,r.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(r,e){var t,o;if(t=e.anEdge,!(t.Lnext!==t&&t.Lnext.Lnext!==t))throw"Mono region invalid";for(;be.vertLeq(t.Dst,t.Org);t=t.Lprev);for(;be.vertLeq(t.Org,t.Dst);t=t.Lnext);o=t.Lprev;for(var i=void 0;t.Lnext!==o;)if(be.vertLeq(t.Dst,o.Org)){for(;o.Lnext!==t&&(be.edgeGoesLeft(o.Lnext)||be.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)i=r.connect(o.Lnext,o),o=i.Sym;o=o.Lprev}else{for(;o.Lnext!==t&&(be.edgeGoesRight(t.Lprev)||be.edgeSign(t.Dst,t.Org,t.Lprev.Org)>=0);)i=r.connect(t,t.Lprev),t=i.Sym;t=t.Lnext}if(o.Lnext===t)throw"Mono region invalid";for(;o.Lnext.Lnext!==t;)i=r.connect(o.Lnext,o),o=i.Sym;return!0},n.prototype.tessellateInterior_=function(r){for(var e,t=r.fHead.next;t!==r.fHead;t=e)if(e=t.next,t.inside&&!this.tessellateMonoRegion_(r,t))return!1;return!0},n.prototype.discardExterior_=function(r){for(var e,t=r.fHead.next;t!==r.fHead;t=e)e=t.next,t.inside||r.zapFace(t)},n.prototype.setWindingNumber_=function(r,e,t){for(var o,i=r.eHead.next;i!==r.eHead;i=o)o=i.next,i.Rface.inside!==i.Lface.inside?i.winding=i.Lface.inside?e:-e:t?r.delete(i):i.winding=0},n.prototype.getNeighbourFace_=function(r){return!r.Rface||!r.Rface.inside?-1:r.Rface.n},n.prototype.outputPolymesh_=function(r,e,t,o){var i,a=0,s=0,l;t>3&&r.mergeConvexFaces(t);for(var c=r.vHead.next;c!==r.vHead;c=c.next)c.n=-1;for(var u=r.fHead.next;u!==r.fHead;u=u.next)if(u.n=-1,!!u.inside){i=u.anEdge,l=0;do{var c=i.Org;c.n===-1&&(c.n=s,s++),l++,i=i.Lnext}while(i!==u.anEdge);if(l>t)throw"Face vertex greater that support polygon";u.n=a,++a}this.elementCount=a,e===nt.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*t,this.vertexCount=s,this.vertices=[],this.vertices.length=s*o,this.vertexIndices=[],this.vertexIndices.length=s;for(var c=r.vHead.next;c!==r.vHead;c=c.next)if(c.n!==-1){var p=c.n*o;this.vertices[p+0]=c.coords[0],this.vertices[p+1]=c.coords[1],o>2&&(this.vertices[p+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var d=0,u=r.fHead.next;u!==r.fHead;u=u.next)if(!!u.inside){i=u.anEdge,l=0;do{var c=i.Org;this.elements[d++]=c.n,l++,i=i.Lnext}while(i!==u.anEdge);for(var h=l;h<t;++h)this.elements[d++]=-1;if(e===nt.CONNECTED_POLYGONS){i=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==u.anEdge);for(var f=l;f<t;++f)this.elements[d++]=-1}}},n.prototype.outputContours_=function(r,e){var t,o,i=0,a=0;this.vertexCount=0,this.elementCount=0;for(var s=r.fHead.next;s!==r.fHead;s=s.next)if(!!s.inside){o=t=s.anEdge;do this.vertexCount++,t=t.Lnext;while(t!==o);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,u=0;i=0;for(var s=r.fHead.next;s!==r.fHead;s=s.next)if(!!s.inside){a=0,o=t=s.anEdge;do this.vertices[l++]=t.Org.coords[0],this.vertices[l++]=t.Org.coords[1],e>2&&(this.vertices[l++]=t.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(t):t.Org.idx,a++,t=t.Lnext;while(t!==o);this.elements[u++]=i,this.elements[u++]=a,i+=a}},n.prototype.addContour=function(r,e){this.mesh===null&&(this.mesh=new jx),r<2&&(r=2),r>3&&(r=3);for(var t=null,o=0;o<e.length;o+=r)t===null?(t=this.mesh.makeEdge(),this.mesh.splice(t,t.Sym)):(this.mesh.splitEdge(t),t=t.Lnext),t.Org.coords[0]=e[o+0],t.Org.coords[1]=e[o+1],r>2?t.Org.coords[2]=e[o+2]:t.Org.coords[2]=0,t.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(t),t.winding=1,t.Sym.winding=-1},n.prototype.tesselate=function(r,e,t,o,i,a){if(r===void 0&&(r=Ge.ODD),e===void 0&&(e=nt.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,i&&(this.normal[0]=i[0],this.normal[1]=i[1],this.normal[2]=i[2]),this.windingRule=r,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),gM.computeInterior(this,a);var s=this.mesh;return e===nt.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===nt.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,t,o),!0},n}();function Rr(n){var r=n.windingRule,e=r===void 0?Ge.ODD:r,t=n.elementType,o=t===void 0?nt.POLYGONS:t,i=n.polySize,a=i===void 0?3:i,s=n.vertexSize,l=s===void 0?2:s,c=n.normal,u=c===void 0?[0,0,1]:c,p=n.contours,d=p===void 0?[]:p,h=n.strict,f=h===void 0?!0:h,m=n.debug,y=m===void 0?!1:m;if(!d&&f)throw new Error("Contours can't be empty");if(!!d){var g=new xM;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var v=0;v<d.length;v++)g.addContour(l||2,d[v]);return g.tesselate(e,o,a,l,u,f),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var SW=Ge.ODD,wW=Ge.NONZERO,PW=Ge.POSITIVE,OW=Ge.NEGATIVE,CW=Ge.ABS_GEQ_TWO,TW=nt.POLYGONS,AW=nt.CONNECTED_POLYGONS,MW=nt.BOUNDARY_CONTOURS;import{Box2 as PM,BufferAttribute as tu,BufferGeometry as OM,Vector2 as CM}from"three";var Jc=class{constructor(r=256,e=!1){this.capacity=r,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${r}`);let t=r*Jc.eSize;this.buffer=new ArrayBuffer(t);let o=Float32Array.BYTES_PER_ELEMENT,i=0;this.positions=new Float32Array(this.buffer,i*o,3*r),i+=3*r,this.normals=new Float32Array(this.buffer,i*o,3*r),i+=3*r,this.uvs=new Float32Array(this.buffer,i*o,2*r)}realloc(r,e=!1){if(r<this.size)throw Error("cannot shrink buffer");if(r<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${r}`);let t=r*Jc.eSize,o=new ArrayBuffer(t),i=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*i,3*r);a+=3*r;let l=new Float32Array(o,a*i,3*r);a+=3*r;let c=new Float32Array(o,a*i,2*r);e?(s.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),c.set(this.uvs.subarray(0,this.size*2))):(s.set(this.positions),l.set(this.normals),c.set(this.uvs)),this.buffer=o,this.positions=s,this.normals=l,this.uvs=c,this.capacity=r}get(r=1){let e=this.size+r;if(e>this.capacity){let o=this.capacity;for(;e>o;)o*=2;this.realloc(o)}let t=this.size;return this.size=e,t}reserve(r){let e=this.size+r;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Gs=Jc;Gs.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var $x=hi(qx()),js={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Gp={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},jp={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},zp=(n,r)=>([e,t])=>(t<e&&(t+=r),(n>=e?n:n+r)<=t),dn=class extends OM{constructor(e,t,o=0,i=12,a=3,s=Ge.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._curveSegments=i,this._bevelSegmentsInput=a;let c=this._shape.extractShapePointsToFlatArray([],i),u=this._shape.shapeHoles.map(A=>{let N=A.extractShapePointsToFlatArray([],i),E=[];for(let B=N.length-1;B>=1;B-=2){let V=N[B-1],j=N[B-0];E.push(V,j)}return E}),p=[],d=[];for(let A=0;A<c.length;A+=2)d.push([c[A],c[A+1]]);p.push(d);for(let A=0;A<u.length;A++){let N=u[A],E=[];for(let B=0;B<N.length;B+=2)E.push([N[B],N[B+1]]);p.push(E)}let h;e.isText?h=new PM().setFromPoints(e.points.map(N=>N.position)).getSize(new CM).length()*.1:p[0].length===0?h=o:h=(0,$x.default)(p).distance,o<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(o,h,t/2),this._bevelSegments=Math.floor(a));let f;try{f=Rr({windingRule:s,elementType:nt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{f=js}let m;try{m=Rr({windingRule:Ge.ODD,elementType:nt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{m=Gp}if(!f)throw new Error("error generating geometry");let y=f.elementCount;if(m){f.elementCount+=m.elementCount;for(let A=0;A<m.elements.length;A++){let N=m.elements[A],E=A%2===0?f.vertexCount:0;f.elements.push(N+E)}for(let A=0;A<m.vertexIndices.length;A++){let N=m.vertexIndices[A],E=f.vertexCount;f.vertexIndices.push(N+E)}for(let A=0;A<m.vertices.length;A++){let N=m.vertices[A];f.vertices.push(N)}}let g=1/0,v=-1/0,O=1/0,P=-1/0;for(let A=0,N=f.vertexCount;A<N;A++){let E=A*2,B=f.vertices[E+0],V=f.vertices[E+1];B<g&&(g=B),B>v&&(v=B),V<O&&(O=V),V>P&&(P=V)}this._minX=g,this._minY=O,this._width=v-g,this._height=P-O,this._buffer=new Gs(this._computeBufferEstimatedSize(f));let S=[],T=[];for(let A=f.elementCount-1;A>=0;A--){let N=A>=y,E=A*2,B=f.elements[E+0],V=f.elements[E+1],j=B+V,R={start:B,count:V,normals:[],continuous:[],concave:[]},W=B,F=j-1,k=B+1,H=this._shape.roundedCurves.length;do{let te=W-B,Y=f.vertices[F*2+0],ee=f.vertices[F*2+1],K=f.vertices[W*2+0],q=f.vertices[W*2+1],ue=f.vertices[k*2+0],le=f.vertices[k*2+1],ne=K-Y,ce=q-ee,ae=Math.sqrt(ne*ne+ce*ce);ne/=ae,ce/=ae;let he=K-ue,pe=q-le,fe=Math.sqrt(he*he+pe*pe);he/=fe,pe/=fe,R.normals[te*2+0]=-pe,R.normals[te*2+1]=he,R.concave[te]=ne*pe-ce*he>0;let ge=f.vertexIndices[W];if(Array.isArray(ge))R.continuous[te]=!1;else{let[me,C]=this._shape.getCurveIndexFromVertexId(ge-1,!0);if(C>0&&C<1)R.continuous[te]=!0;else{let ie=C===1?me+1:me-1;ie=(ie+H)%H;let De=C===1?0:1,Re=this._shape.roundedCurves[me].getTangent(C),Ee=this._shape.roundedCurves[ie].getTangent(De);R.continuous[te]=Re.dot(Ee)>.95}}N&&(R.normals[te*2+0]*=-1,R.normals[te*2+1]*=-1),[F,W,k]=[W,k,k+1],k>=j&&(k-=V)}while(k!==B+1);let $=[];$.push({bevelI:0,angle:0,size:0,boundary:{vertices:f.vertices.slice(B*2,j*2),vertexCount:V,vertexIndices:new Array(V).fill(!0).map((te,Y)=>[Y,Y]),elements:[0,V],elementCount:1,mesh:null},reverseMap:[],insetPoints:f.vertices.slice(B*2,j*2)});let J=0;for(let te=1;te<=this._bevelSegments;te++){let Y=te/this._bevelSegments*Math.PI/2,ee=(1-Math.cos(Y))*this._bevel,K=[],q=[],ue=[],le=[],ne=0;for(let ae=0;ae<V;ae++){let he=ae*2,pe=(ae-1+V)%V*2,fe=f.vertices[R.start*2+he+0],ge=f.vertices[R.start*2+he+1],me=-R.normals[pe+0]*ee,C=-R.normals[pe+1]*ee,ie=-R.normals[he+0]*ee,De=-R.normals[he+1]*ee;if(R.concave[ae]||!R.concave[ae]&&N){let Re=Math.atan2(C,me),Ee=Math.atan2(De,ie);Ee>Re&&(Ee-=Math.PI*2);let Pe=Ee-Re;if(R.continuous[ae]||N){let bt=Re+Pe/2,Me=Math.cos(bt)*ee,yt=Math.sin(bt)*ee;K[2*ne+0]=fe+Me*(N?-1:1),K[2*ne+1]=ge+yt*(N?-1:1),le[ne]=ae,ne++}else{let bt=Math.max(1,Math.floor(i/4*Math.abs(Pe)/Math.PI));for(let Me=0;Me<=bt;Me++){let yt=Re+Pe*(Me/bt),vt=Math.cos(yt)*ee,An=Math.sin(yt)*ee;K[2*ne+0]=fe+vt,K[2*ne+1]=ge+An,le[ne]=ae,ne++}}}else K[2*ne+0]=fe+me,K[2*ne+1]=ge+C,le[ne]=ae,q[ae]=ne,ne++,K[2*ne+0]=fe,K[2*ne+1]=ge,le[ne]=ae,ne++,K[2*ne+0]=fe+ie,K[2*ne+1]=ge+De,le[ne]=ae,ue[ae]=ne,ne++}let ce=Rr({windingRule:Ge.POSITIVE,elementType:nt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[K],edgeCreateCallback:ae=>{let pe=ae.Org.idx,fe=le[pe],ge=le[(pe+1)%le.length];ae.idx=[fe,ge],ae.Sym.idx=[ge,fe]},vertexIdCallback:ae=>{let he=ae.Lprev.idx;return[he?he[1]:0,ae.idx?ae.idx[0]:0]}});if(!ce)throw console.log("Error"),new Error(`error generating bevel geometry for ${te}'th loop`);if(!ce.vertexCount){let ae=(te-1)/this._bevelSegments*Math.PI/2;J=(1-Math.sin(ae))*this._bevel;break}for(let ae=0;ae<ce.vertexIndices.length;ae++){let[he,pe]=ce.vertexIndices[ae];if(he===pe)continue;let fe=pe;pe<he&&(fe+=V);for(let ge=he;ge<fe;ge++){let me=ge%V,C=(ge+1)%V;if(!R.continuous[me]||!R.continuous[C]){ce.vertexIndices[ae]=[he,me],ce.vertexIndices.splice(ae+1,0,[C,pe]),ce.vertices.splice((ae+1)*2,0,ce.vertices[ae*2],ce.vertices[ae*2+1]);break}}}$.push({bevelI:te,angle:Y,size:ee,boundary:ce,reverseMap:le,insetPoints:K})}let Z=(te,Y,ee)=>{let K=0,q=te.boundary.vertexIndices.length;for(;K<q&&ee(te.boundary.vertexIndices[Y]);)Y=(Y+1)%q,K++;return K},X=S.length;for(let te=1;te<$.length;te++){let Y=$[te-1],ee=$[te],K=Y.boundary.vertexIndices.length,q=ee.boundary.vertexIndices.length;if(!K||!q)break;let ue=R.concave.length,le=0,ne=zp(le,V);for(;!Y.boundary.vertexIndices.filter(ne).length||!ee.boundary.vertexIndices.filter(ne).length;)le++,ne=zp(le,V);let ce=Y.boundary.vertexIndices.findIndex(ne),ae=ee.boundary.vertexIndices.findIndex(ne);do ce=(ce+1)%K;while(ne(Y.boundary.vertexIndices[ce]));do ae=(ae+1)%q;while(ne(ee.boundary.vertexIndices[ae]));le=(le+1)%V;let he=le,pe=0,fe=this._buildBevelVert(R,Y,(ce-1+K)%K,void 0,pe),ge=this._buildBevelVert(R,ee,(ae-1+q)%q,void 0,pe),me=fe,C=ge,ie,De,Re=!1;do{pe=(le||ue)/ue,ne=zp(le,V);let Ee=Z(Y,ce,ne),Pe=Z(ee,ae,ne),bt=Re;if(Re=!1,Ee&&!Pe){for(let Me=0;Me<Ee;Me++)ie=this._buildBevelVert(R,Y,(ce+Me)%K,Me/(Ee-1),pe),S.push(me.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,me.bottomN,C.bottomN),me=ie;Re=!0}else if(!Ee&&Pe)for(let Me=0;Me<Pe;Me++)De=this._buildBevelVert(R,ee,(ae+Me)%q,Me/(Pe-1),pe),S.push(C.topN,me.topP,De.topP),l===!1&&S.push(me.bottomP,C.bottomN,De.bottomP),C=De;else if(Ee&&Pe)if(ie=this._buildBevelVert(R,Y,ce,0,pe),De=this._buildBevelVert(R,ee,ae,0,pe),bt?(S.push(me.topN,De.topP,C.topN),S.push(me.topN,ie.topP,De.topP),l===!1&&(S.push(De.bottomP,me.bottomN,C.bottomN),S.push(De.bottomP,ie.bottomP,me.bottomN))):(S.push(C.topN,me.topN,ie.topP),S.push(C.topN,ie.topP,De.topP),l===!1&&(S.push(ie.bottomP,me.bottomN,C.bottomN),S.push(ie.bottomP,C.bottomN,De.bottomP))),me=ie,C=De,Ee===Pe)for(let Me=1;Me<Ee;Me++)ie=this._buildBevelVert(R,Y,(ce+Me)%K,Me/(Ee-1),pe),De=this._buildBevelVert(R,ee,(ae+Me)%q,Me/(Pe-1),pe),S.push(me.topN,ie.topP,C.topN),S.push(C.topN,ie.topP,De.topP),l===!1&&(S.push(ie.bottomP,me.bottomN,C.bottomN),S.push(ie.bottomP,C.bottomN,De.bottomP)),me=ie,C=De;else if(Ee>Pe){let Me=Ee/Pe,yt=0;for(let vt=1;vt<Ee;vt++)ie=this._buildBevelVert(R,Y,(ce+vt)%K,vt/(Ee-1),pe),S.push(me.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,me.bottomN,C.bottomN),me=ie,vt>(yt+1)*Me&&(yt++,De=this._buildBevelVert(R,ee,(ae+yt)%q,yt/(Pe-1),pe),S.push(C.topN,ie.topP,De.topP),l===!1&&S.push(ie.bottomP,C.bottomN,De.bottomP),C=De)}else{let Me=Pe/Ee,yt=0;for(let vt=1;vt<Pe;vt++)De=this._buildBevelVert(R,ee,(ae+vt)%q,vt/(Pe-1),pe),S.push(C.topN,ie.topP,De.topP),l===!1&&S.push(ie.bottomP,C.bottomN,De.bottomP),C=De,vt>(yt+1)*Me&&(yt++,ie=this._buildBevelVert(R,Y,(ce+yt)%K,yt/(Ee-1),pe),S.push(me.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,me.bottomN,C.bottomN),me=ie)}ce=(ce+Ee)%K,ae=(ae+Pe)%q,le=(le+1)%ue}while(le!==he)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall($,R,S),N){let te=[];for(let Y=S.length-1;Y>=X+2;Y-=3){let ee=S[Y-2],K=S[Y-1],q=S[Y-0];te.push(q,K,ee)}S.splice(X,S.length-X,...te)}if(N){let te=[];for(let Y=$[$.length-1].boundary.vertices.length-1;Y>=1;Y-=2){let ee=$[$.length-1].boundary.vertices[Y-1],K=$[$.length-1].boundary.vertices[Y-0];te.push(ee,K)}T.push(te)}if(!N){let te=$[$.length-1],Y;try{Y=Rr({windingRule:$.length>1?Ge.POSITIVE:Ge.ODD,elementType:nt.POLYGONS,vertexSize:2,strict:!0,contours:[te.insetPoints,...T]})}catch{Y=jp}if(!Y)throw new Error("Error generating geometry for surface");u.length===0&&this._bevel<h&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let ee=0;ee<Y.elementCount*3;ee+=3){let K=this._buildSurfaceVert(Y,Y.elements[ee+0],J),q=this._buildSurfaceVert(Y,Y.elements[ee+1],J),ue=this._buildSurfaceVert(Y,Y.elements[ee+2],J);S.push(K.top,q.top,ue.top),l===!1&&S.push(ue.bottom,q.bottom,K.bottom)}}this.vertexCache={}}this._buffer.shrink();let I=new tu(Uint32Array.from(S),1),x=new tu(this._buffer.positions,3),_=new tu(this._buffer.normals,3),D=new tu(this._buffer.uvs,2);x.needsUpdate=!0,_.needsUpdate=!0,D.needsUpdate=!0,I.needsUpdate=!0,this.setAttribute("position",x),this.setAttribute("normal",_),this.setAttribute("uv",D),this.setIndex(I)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(t,i,a),c=this._buildBevelVert(t,i,(a+1)%s);o.push(c.topP,l.topN,l.bottomN),o.push(c.topP,l.bottomN,c.bottomP)}}_buildSurfaceVert(e,t,o){let i=t.toString();if(i in this.vertexCache)return this.vertexCache[i];let a=e.vertices[t*2+0],s=e.vertices[t*2+1],l=(a-this._minX)/this._width,c=(s-this._minY)/this._height;this.forPathBevel&&(c=1);let u=this._buffer.get(this.forPathBevel?1:2),p=u*3,d=u*2,h={top:u+0,bottom:u+1};return this._buffer.positions[p+0]=a,this._buffer.positions[p+1]=s,this._buffer.positions[p+2]=this.forPathBevel?this._bevel:this._depth-o,this._buffer.normals[p+0]=0,this._buffer.normals[p+1]=0,this._buffer.normals[p+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=c,this.forPathBevel===!1&&(this._buffer.positions[p+3]=a,this._buffer.positions[p+4]=s,this._buffer.positions[p+5]=o,this._buffer.normals[p+3]=0,this._buffer.normals[p+4]=0,this._buffer.normals[p+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=c),this.vertexCache[i]=h,h}_buildBevelVert(e,t,o,i=1,a){let s=`${t.bevelI}:${o}`;if(s in this.vertexCache&&a!==0&&a!==1&&(!a||a===this.vertexCache[s].pathBevelUCoord))return this.vertexCache[s];let[l,c]=t.boundary.vertexIndices[o],u,p,d,h;l!==c?(p=l,u=c,h=!1,d=e.continuous[p]&&e.continuous[u]):(u=l,p=(u-1+e.count)%e.count,h=e.concave[u]&&t.bevelI>0,d=e.continuous[u]||h);let f=Math.cos(t.angle),m=Math.sin(t.angle),y=o*2,g=u*2,v=p*2,O=t.boundary.vertices[y+0],P=t.boundary.vertices[y+1],S=(1-m)*this._bevel,T=(O-this._minX)/this._width,I=(P-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(T=a),I=1);let x=e.normals[g+0],_=e.normals[g+1],D=e.normals[v+0],A=e.normals[v+1];if(h){let j=D-x,R=A-_;x=x+j*(1-i),_=_+R*(1-i);let W=Math.sqrt(x*x+_*_);x/=W,_/=W}let N=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),E=N*3,B=N*2,V={i:o,fi:u,topP:N+0,topN:N+0,bottomP:N+1,bottomN:N+1,pathBevelUCoord:a};return this._buffer.positions[E+0]=O,this._buffer.positions[E+1]=P,this._buffer.positions[E+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[E+0]=x*f,this._buffer.normals[E+1]=_*f,this._buffer.normals[E+2]=m,this._buffer.uvs[B+0]=T,this._buffer.uvs[B+1]=I,this.forPathBevel===!1&&(this._buffer.positions[E+3]=O,this._buffer.positions[E+4]=P,this._buffer.positions[E+5]=S,this._buffer.normals[E+3]=x*f,this._buffer.normals[E+4]=_*f,this._buffer.normals[E+5]=-m,this._buffer.uvs[B+2]=I,this._buffer.uvs[B+3]=T),d||(this.forPathBevel?(N+=1,E+=3,B+=2):(N+=2,E+=6,B+=4),V.topP=N+0,V.bottomP=N+1,this._buffer.positions[E+0]=O,this._buffer.positions[E+1]=P,this._buffer.positions[E+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[E+0]=D*f,this._buffer.normals[E+1]=A*f,this._buffer.normals[E+2]=m,this._buffer.uvs[B+0]=T,this._buffer.uvs[B+1]=I,this.forPathBevel===!1&&(this._buffer.positions[E+3]=O,this._buffer.positions[E+4]=P,this._buffer.positions[E+5]=S,this._buffer.normals[E+3]=D*f,this._buffer.normals[E+4]=A*f,this._buffer.normals[E+5]=-m,this._buffer.uvs[B+2]=I,this._buffer.uvs[B+3]=T)),this.vertexCache[s]=V,V}clone(){let e=new dn(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=vo(this.userData),e}};var fa=class extends TM{constructor(e,t=12,o={}){super();this.type="ShapeGeometry";this.windingRule=Ge.ODD;this.elementType=nt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Ge.ODD,elementType:nt.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let i=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(f=>f.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,c=!0,u,p;for(let f=0,m=i.length/2;f<m;f++){let y=f*2,g=i[y+0],v=i[y+1];if(u!==void 0&&g!==u&&(l=!1),p!==void 0&&v!==p&&(c=!1),u=g,p=v,!l&&!c)break}if(!l&&!c)try{s=Rr({contours:[i,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=js}let d=s?.vertexCount??1,h=s?.elementCount??1;if(this._positionAttribute=new ru(new Float32Array(d*3),3),this._normalAttribute=new ru(new Float32Array(d*3),3),this._uvAttribute=new ru(new Float32Array(d*2),2),this._indexAttribute=new ru(new Uint32Array(h*3),1),s){let f=1/0,m=-1/0,y=1/0,g=-1/0;for(let P=0,S=d;P<S;P++){let T=P*2,I=s.vertices[T+0],x=s.vertices[T+1];I<f&&(f=I),I>m&&(m=I),x<y&&(y=x),x>g&&(g=x)}let v=m-f,O=g-y;for(let P=0,S=d;P<S;P++){let T=P*2,I=s.vertices[T+0],x=s.vertices[T+1],_=(I-f)/v,D=(x-y)/O;this._positionAttribute.setXYZ(P,I,x,0),this._normalAttribute.setXYZ(P,0,0,1),this._uvAttribute.setXY(P,_,D)}for(let P=0,S=h;P<S;P++){let T=P*3,I=s.elements[T+0],x=s.elements[T+1],_=s.elements[T+2];this._indexAttribute.setX(T+0,I),this._indexAttribute.setX(T+1,x),this._indexAttribute.setX(T+2,_)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(s?.elementCount??1)*3)}clone(){let e=new fa(this._shape,this._curveSegments);return e.userData=vo(this.userData),e}};var ha=class extends dn{constructor(e,t,o=0,i=12,a=3,s=Ge.ODD){super(e,t,o,i,a,s);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(t,i,a),c=this._buildBevelVert(t,i,(a+1)%s);o.push(c.topP,l.topN,l.bottomN),o.push(c.topP,l.bottomN,c.bottomP)}}clone(){let e=new ha(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=vo(this.userData),e}};var Jt=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Ge.ODD},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=n.shape??r?.shape,s=a?.roundness??e.roundness;a!==void 0&&(a instanceof Fe?(a.width!==t||a.height!==o)&&a.applySize(t,o):a=new Fe(t,o).fromJSON(a),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&a.update());let l=a??new Fe(t,o);return{parameters:Object.assign(e,{width:t,height:o,depth:i,roundness:s}),shape:l}}static build(n){let{depth:r,extrudeBevelSize:e,extrudeBevelSegments:t,subdivisions:o,roundness:i,windingRule:a}=n.parameters;n.shape.roundness=i;let s;return r<=0?s=new fa(n.shape,o,{windingRule:a}):s=new ha(n.shape,r,e,o,t,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};import{BufferGeometry as AM,Float32BufferAttribute as MM,MathUtils as Fp,Vector2 as Xx}from"three";var Kx=Math.PI*2,ya=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return e.angle=Fp.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof Fe?n.shape:new Fe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,spikes:t,angle:o,innerRadius:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,c=n.shape,u=r*.5,p=e*.5,d=IM(c,u,p,o*Math.PI/180,t,i);c.isClosed=!0,c.update();let h;return o===0?(h=new AM,h.setAttribute("position",new MM([],3))):h=Jt.create({shape:c,parameters:{subdivisions:d,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(h,{userData:{...n,type:"EllipseGeometry"}})}};function IM(n,r,e,t,o,i){if(t>=Kx)return o>30||o%4===0?(DM(n,r,e,i),Math.round(o/4)):Yx(n,t,o,r,e,i);t=Math.max(t,.001);let a={x:0,y:e},s=t+Math.PI*.5,l={x:Math.cos(s)*r,y:Math.sin(s)*e},c=Gx({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:r,ry:e,largeArcFlag:t>Math.PI,sweepFlag:!0});return o>30||o%c.length===0?NM(n,a.x,a.y,c,o,r,e,i):Yx(n,t,o,r,e,i)}function NM(n,r,e,t,o,i,a,s){let l=Math.round(o/t.length);n.addPoint(ma(r,e));for(let c=0,u=t.length;c<u;c++){let p=t[c],d=n.points[c],h=ma(p.x,p.y);d.controls[1].position.set(p.x1,p.y1),h.controls[0].position.set(p.x2,p.y2),n.addPoint(h)}return s>0?Qx(n,i,a,s):n.addPoint(ma(0,0)),l}function Yx(n,r,e,t,o,i){let a=-r/e;for(let s=0;s<=e;s++){let l=a*s,c=Math.sin(l)*t,u=Math.cos(l)*o;n.addPoint(ma(c,u))}return r<Kx?i>0?Qx(n,t,o,i):n.addPoint(ma(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&Zx(n,t,o,i)),1}function DM(n,r,e,t=0,o=0,i=0){let a=.5522847498,s=r*a,l=e*a;n.addPoint(ou(o-r,i,o-r,i-l,o-r,i+l)),n.addPoint(ou(o,i+e,o-s,i+e,o+s,i+e)),n.addPoint(ou(o+r,i,o+r,i+l,o+r,i-l)),n.addPoint(ou(o,i-e,o+s,i-e,o-s,i-e)),t>0&&Zx(n,r,e,t)}function ma(n,r){return new Lr(Fp.generateUUID(),new Xx(n,r))}function ou(n,r,e,t,o,i){let a=ma(n,r);return a.controls[0].position.set(e,t),a.controls[1].position.set(o,i),a}function Qx(n,r,e,t){Jx(n,r,e,t).forEach(i=>n.addPoint(i))}function Zx(n,r,e,t){let o=Jx(n,r,e,t),i=new Fe;o.forEach(a=>i.addPoint(a)),i.isClosed=!0,n.shapeHoles.push(i)}function Jx(n,r,e,t){let o=t*r/100,i=o*(Math.abs(e)/Math.abs(r)),a=new Xx(o/r,i/e),s=n.points.map(l=>{let c=l.clone();return c.uuid=Fp.generateUUID(),c}).reverse();return s.forEach(l=>{l.position.multiply(a);let c=l.controls[0].position.clone().multiply(a),u=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(u),l.controls[1].position.copy(c)}),s}import{BufferGeometry as EM,Float32BufferAttribute as Up,Uint32BufferAttribute as _M,Vector3 as e0}from"three";var t0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??t),i=Math.abs(e.depth??t),a=Math.abs(Math.min(t,i))/2;return{parameters:Object.assign(e,{width:t,height:o,depth:i,radius:a,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:r,height:e,depth:t,radius:o,revolutions:i,segments:a,pathRadius:s,pathType:l,pathSegments:c,cornerRadius:u,cornerSegments:p}=n.parameters,d=new Fs(!1,r,e,t,o,i,a,s,l,c,u,p);return Object.assign(d,{userData:{...n,type:"HelixGeometry"}})}},kp=new _M([0,0,0],1),Fs=class extends EM{constructor(r=!0,e=1,t=1,o=1,i=1,a=1,s=1,l=1,c=1,u=1,p=1,d=1){if(super(),a===0)return;let h=r&&a===1;h&&(d=0),p>100&&(p=100),p===0&&(d=0);let f=()=>new e0,m=new e0,y=f(),g=f(),v=f(),O,P,S,T,I,x,_,D,A=f(),N=f(),E=f(),B=f(),V=f(),j=f(),R=f(),W=f(),F=t-2*l+.001,k=F/a,H=Math.ceil(s*a),$=H+1,J=F/H,Z=-F/2,X=u+1,te=2*Math.PI/u,Y=Math.PI/2/d,ee=.01,K=Math.min((1-p/100)*l,l-ee),q=l-K,ue=0,le=2,ne=d*le+le,ce=X*ne/le,ae=ce+X*$,he=Math.max(0,X*($+ne)),[pe,fe,ge]=[3,3,2].map(tt=>Array(he*tt).fill(0)),me=[],C=i-l;function ie(tt,Ye){let Ar=Math.PI/2;x=Ye*J,D=2*Math.PI*(x%k)/k+Ar,x+=Z,_=Math.sin(D)*C,I=Math.cos(D)*C,r?tt.set(I,_,x):tt.set(I,x,_)}ie(m,-1e-10),ie(y,0),A.copy(m),ie(m,1);let De=m.distanceTo(y),Re=h?0:q+K,Ee=De*H+2*Re,Pe=K,bt=Ee-Re;for(let tt=0;tt<=H;tt++){ie(g,tt),W.subVectors(g,A).normalize(),A.copy(g),j.copy(g).setComponent(+r+1,0).normalize(),R.crossVectors(W,j).normalize();let Ye=tt===0,Ar=tt===H,ud=Ye?3*Math.PI/2:Y,dd=Ye?Pe:bt,vl=Ye?X:ae,Mn=Ye?0:he-X,lt=W.clone().multiplyScalar(Ye?-q:q).add(g),pd=W.clone().multiplyScalar(Ye?-1:1).normalize();for(let hr=0;hr<X;hr++){let fs=hr*te;if(N.addVectors(m.copy(j).multiplyScalar(l*Math.cos(fs)),y.copy(R).multiplyScalar(l*Math.sin(fs))),E.copy(N).normalize(),Ye||Ar){h||(ue=Mn+hr,[0,1,2].forEach(jt=>{pe[ue*3+jt]=lt.getComponent(jt),fe[ue*3+jt]=pd.getComponent(jt)}),ge[ue*2]=+Ar,ge[ue*2+1]=hr/u),y.copy(E).multiplyScalar(K),v.addVectors(g,y);for(let jt=0;jt<d;jt++){let In=jt*Y+ud;B.addVectors(m.copy(W).multiplyScalar(q*Math.sin(In)),y.copy(E).multiplyScalar(q*Math.cos(In))),V.copy(B).normalize(),y.addVectors(v,B),B.normalize(),ue=vl+jt*X+hr,[0,1,2].forEach(ui=>{pe[ue*3+ui]=y.getComponent(ui),fe[ue*3+ui]=V.getComponent(ui)});let Sl=+Ye+Math.sin(In);ge[ue*2]=(dd+q*Sl)/Ee,ge[ue*2+1]=hr/u}}y.addVectors(g,N),ue=ce+tt*X+hr,[0,1,2].forEach(jt=>{pe[ue*3+jt]=y.getComponent(jt),fe[ue*3+jt]=E.getComponent(jt)}),ge[ue*2]=(Re+tt*De)/Ee,ge[ue*2+1]=hr/u}}let Me=$+2*d+le,yt=1,[vt,An]=[+h,Me-1];for(let tt=vt;tt<=An-1;tt++){let Ye=h&&tt===An-1;for(let Ar=0;Ar<X-1;Ar++)O=tt*X+Ar,P=O+1,S=(Ye?Ar:O)+X,T=(Ye?Ar+1:P)+X,tt===0?me.push(P,T,S):tt===Me-2?me.push(O,P,S):me.push(O,P,S,P,T,S)}this.setIndex(me),this.setAttribute("position",new Up(pe,3)),this.setAttribute("normal",new Up(fe,3)),this.setAttribute("uv",new Up(ge,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let r=this.userData.parameters,e=Math.ceil(r.tubularSegments),t=r.radialSegments+1,o=Array.from(this.getIndex().array),i,a,s,l,c=6*(e-1)*r.radialSegments,u=e,p=u===e;for(let d=0;d<r.radialSegments;d++)i=u*t+d,a=i+1,s=(p?d:i)+t,l=(p?d+1:a)+t,o[c++]=i,o[c++]=a,o[c++]=s,o[c++]=a,o[c++]=l,o[c++]=s;return o.length=c,kp.array=o,kp.count=o.length,kp}};import{IcosahedronGeometry as BM}from"three";var r0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new Us(r*.5,i,a):new BM(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},Us=class extends ln{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,i=[-1,o,0,1,o,0,-1,-o,0,1,-o,0,0,-1,o,0,1,o,0,-1,-o,0,1,-o,o,0,-1,o,0,1,-o,0,-1,-o,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],s="IcosahedronGeometry";super(i,a,s,r,e,t),this.type=s}static fromJSON(r){return new Us(r.radius,r.corner,r.cornerSides)}};import{LatheGeometry as LM,Shape as RM}from"three";var o0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){(n.parameters?.points??[]).forEach(t=>{Array.isArray(t)&&(t.x=t[0],t.y=t[1])});let e=Object.assign({},r?.parameters??{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(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{points:r,segments:e,verticalSegments:t}=n.parameters,o=new RM;o.moveTo(r[0].x,r[0].y),o.bezierCurveTo(r[1].x,r[1].y,r[2].x,r[2].y,r[3].x,r[3].y);let i=new LM(o.extractPoints(t).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};import{BufferGeometry as d0,BufferGeometryLoader as YM,Vector3 as XM,BoxGeometry as p0}from"three";import{BufferGeometry as HM,Vector2 as $p,Vector3 as u0}from"three";import{Box3 as VM,BufferAttribute as ks,BufferGeometry as n0,Color as qp,EventDispatcher as zM,Float32BufferAttribute as ga,Matrix3 as i0,Matrix4 as c0,MathUtils as GM,Object3D as jM,Sphere as FM,Vector2 as ur,Vector3 as Rt,Vector4 as UM}from"three";var ro=new c0,Hp=new jM,nu=new Rt,pn=class extends zM{constructor(){super(),this.uuid=GM.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(r){let e=new i0().getNormalMatrix(r);for(let t=0,o=this.vertices.length;t<o;t++)this.vertices[t].applyMatrix4(r);for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t];i.normal.applyMatrix3(e).normalize();for(let a=0,s=i.vertexNormals.length;a<s;a++)i.vertexNormals[a].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(r){return ro.makeRotationX(r),this.applyMatrix4(ro),this}rotateY(r){return ro.makeRotationY(r),this.applyMatrix4(ro),this}rotateZ(r){return ro.makeRotationZ(r),this.applyMatrix4(ro),this}translate(r,e,t){return ro.makeTranslation(r,e,t),this.applyMatrix4(ro),this}scale(r,e,t){return ro.makeScale(r,e,t),this.applyMatrix4(ro),this}lookAt(r){return Hp.lookAt(r),Hp.updateMatrix(),this.applyMatrix4(Hp.matrix),this}fromBufferGeometry(r){let e=this,t=r.index!==null?r.index:void 0,o=r.attributes;if(o.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let i=o.position,a=o.normal,s=o.color,l=o.uv,c=o.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<i.count;d++)e.vertices.push(new Rt().fromBufferAttribute(i,d)),s!==void 0&&e.colors.push(new qp().fromBufferAttribute(s,d));function u(d,h,f,m){let y=s===void 0?[]:[e.colors[d].clone(),e.colors[h].clone(),e.colors[f].clone()],g=a===void 0?[]:[new Rt().fromBufferAttribute(a,d),new Rt().fromBufferAttribute(a,h),new Rt().fromBufferAttribute(a,f)],v=new xa(d,h,f,g,y,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new ur().fromBufferAttribute(l,d),new ur().fromBufferAttribute(l,h),new ur().fromBufferAttribute(l,f)]),c!==void 0&&e.faceVertexUvs[1].push([new ur().fromBufferAttribute(c,d),new ur().fromBufferAttribute(c,h),new ur().fromBufferAttribute(c,f)])}let p=r.groups;if(p.length>0)for(let d=0;d<p.length;d++){let h=p[d],f=h.start,m=h.count;for(let y=f,g=f+m;y<g;y+=3)t!==void 0?u(t.getX(y),t.getX(y+1),t.getX(y+2),h.materialIndex):u(y,y+1,y+2,h.materialIndex)}else if(t!==void 0)for(let d=0;d<t.count;d+=3)u(t.getX(d),t.getX(d+1),t.getX(d+2));else for(let d=0;d<i.count;d+=3)u(d,d+1,d+2);return this.computeFaceNormals(),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(nu).negate(),this.translate(nu.x,nu.y,nu.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new c0;return o.set(t,0,0,-t*r.x,0,t,0,-t*r.y,0,0,t,-t*r.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let r=new Rt,e=new Rt;for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],a=this.vertices[i.a],s=this.vertices[i.b],l=this.vertices[i.c];r.subVectors(l,s),e.subVectors(a,s),r.cross(e),r.normalize(),i.normal.copy(r)}}computeVertexNormals(r=!0){let e=new Array(this.vertices.length);for(let t=0,o=this.vertices.length;t<o;t++)e[t]=new Rt;if(r){let t=new Rt,o=new Rt;for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=this.vertices[s.a],c=this.vertices[s.b],u=this.vertices[s.c];t.subVectors(u,c),o.subVectors(l,c),t.cross(o),e[s.a].add(t),e[s.b].add(t),e[s.c].add(t)}}else{this.computeFaceNormals();for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t];e[i.a].add(i.normal),e[i.b].add(i.normal),e[i.c].add(i.normal)}}for(let t=0,o=this.vertices.length;t<o;t++)e[t].normalize();for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],a=i.vertexNormals;a.length===3?(a[0].copy(e[i.a]),a[1].copy(e[i.b]),a[2].copy(e[i.c])):(a[0]=e[i.a].clone(),a[1]=e[i.b].clone(),a[2]=e[i.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let r=0,e=this.faces.length;r<e;r++){let t=this.faces[r],o=t.vertexNormals;o.length===3?(o[0].copy(t.normal),o[1].copy(t.normal),o[2].copy(t.normal)):(o[0]=t.normal.clone(),o[1]=t.normal.clone(),o[2]=t.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,t=this.faces.length;e<t;e++){let o=this.faces[e];o.__originalFaceNormal?o.__originalFaceNormal.copy(o.normal):o.__originalFaceNormal=o.normal.clone(),o.__originalVertexNormals||(o.__originalVertexNormals=[]);for(let i=0,a=o.vertexNormals.length;i<a;i++)o.__originalVertexNormals[i]?o.__originalVertexNormals[i].copy(o.vertexNormals[i]):o.__originalVertexNormals[i]=o.vertexNormals[i].clone()}let r=new pn;r.faces=this.faces;for(let e=0,t=this.morphTargets.length;e<t;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let i=this.morphNormals[e].faceNormals,a=this.morphNormals[e].vertexNormals;for(let s=0,l=this.faces.length;s<l;s++){let c=new Rt,u={a:new Rt,b:new Rt,c:new Rt};i.push(c),a.push(u)}}let o=this.morphNormals[e];r.vertices=this.morphTargets[e].vertices,r.computeFaceNormals(),r.computeVertexNormals();for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=o.faceNormals[i],c=o.vertexNormals[i];l.copy(s.normal),c.a.copy(s.vertexNormals[0]),c.b.copy(s.vertexNormals[1]),c.c.copy(s.vertexNormals[2])}}for(let e=0,t=this.faces.length;e<t;e++){let o=this.faces[e];o.normal=o.__originalFaceNormal,o.vertexNormals=o.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new VM),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new FM),this.boundingSphere.setFromPoints(this.vertices)}merge(r,e,t=0){if(!(r&&r.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",r);return}let o,i=this.vertices.length,a=this.vertices,s=r.vertices,l=this.faces,c=r.faces,u=this.colors,p=r.colors;e!==void 0&&(o=new i0().getNormalMatrix(e));for(let d=0,h=s.length;d<h;d++){let m=s[d].clone();e!==void 0&&m.applyMatrix4(e),a.push(m)}for(let d=0,h=p.length;d<h;d++)u.push(p[d].clone());for(let d=0,h=c.length;d<h;d++){let f=c[d],m,y,g=f.vertexNormals,v=f.vertexColors,O=new xa(f.a+i,f.b+i,f.c+i);O.normal.copy(f.normal),o!==void 0&&O.normal.applyMatrix3(o).normalize();for(let P=0,S=g.length;P<S;P++)m=g[P].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),O.vertexNormals.push(m);O.color.copy(f.color);for(let P=0,S=v.length;P<S;P++)y=v[P],O.vertexColors.push(y.clone());O.materialIndex=f.materialIndex+t,l.push(O)}for(let d=0,h=r.faceVertexUvs.length;d<h;d++){let f=r.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,y=f.length;m<y;m++){let g=f[m],v=[];for(let O=0,P=g.length;O<P;O++)v.push(g[O].clone());this.faceVertexUvs[d].push(v)}}}mergeMesh(r){if(!(r&&r.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",r);return}r.matrixAutoUpdate&&r.updateMatrix(),this.merge(r.geometry,r.matrix)}mergeVertices(r=4){let e={},t=[],o=[],i=Math.pow(10,r);for(let l=0,c=this.vertices.length;l<c;l++){let u=this.vertices[l],p=Math.round(u.x*i)+"_"+Math.round(u.y*i)+"_"+Math.round(u.z*i);e[p]===void 0?(e[p]=l,t.push(this.vertices[l]),o[l]=t.length-1):o[l]=o[e[p]]}let a=[];for(let l=0,c=this.faces.length;l<c;l++){let u=this.faces[l];u.a=o[u.a],u.b=o[u.b],u.c=o[u.c];let p=[u.a,u.b,u.c];for(let d=0;d<3;d++)if(p[d]===p[(d+1)%3]){a.push(l);break}}for(let l=a.length-1;l>=0;l--){let c=a[l];this.faces.splice(c,1);for(let u=0,p=this.faceVertexUvs.length;u<p;u++)this.faceVertexUvs[u].splice(c,1)}let s=this.vertices.length-t.length;return this.vertices=t,s}setFromPoints(r){this.vertices=[];for(let e=0,t=r.length;e<t;e++){let o=r[e];this.vertices.push(new Rt(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let r=this.faces,e=r.length;for(let l=0;l<e;l++)r[l]._id=l;function t(l,c){return l.materialIndex-c.materialIndex}r.sort(t);let o=this.faceVertexUvs[0],i=this.faceVertexUvs[1],a,s;o&&o.length===e&&(a=[]),i&&i.length===e&&(s=[]);for(let l=0;l<e;l++){let c=r[l]._id;a&&a.push(o[c]),s&&s.push(i[c])}a&&(this.faceVertexUvs[0]=a),s&&(this.faceVertexUvs[1]=s)}toJSON(){let r={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.parameters!==void 0){let f=this.parameters;for(let m in f)f[m]!==void 0&&(r[m]=f[m]);return r}let e=[];for(let f=0;f<this.vertices.length;f++){let m=this.vertices[f];e.push(m.x,m.y,m.z)}let t=[],o=[],i={},a=[],s={},l=[],c={};for(let f=0;f<this.faces.length;f++){let m=this.faces[f],y=!0,g=!1,v=this.faceVertexUvs[0][f]!==void 0,O=m.normal.length()>0,P=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,T=m.vertexColors.length>0,I=0;if(I=u(I,0,0),I=u(I,1,y),I=u(I,2,g),I=u(I,3,v),I=u(I,4,O),I=u(I,5,P),I=u(I,6,S),I=u(I,7,T),t.push(I),t.push(m.a,m.b,m.c),t.push(m.materialIndex),v){let x=this.faceVertexUvs[0][f];t.push(h(x[0]),h(x[1]),h(x[2]))}if(O&&t.push(p(m.normal)),P){let x=m.vertexNormals;t.push(p(x[0]),p(x[1]),p(x[2]))}if(S&&t.push(d(m.color)),T){let x=m.vertexColors;t.push(d(x[0]),d(x[1]),d(x[2]))}}function u(f,m,y){return y?f|1<<m:f&~(1<<m)}function p(f){let m=f.x.toString()+f.y.toString()+f.z.toString();return i[m]!==void 0||(i[m]=o.length/3,o.push(f.x,f.y,f.z)),i[m]}function d(f){let m=f.r.toString()+f.g.toString()+f.b.toString();return s[m]!==void 0||(s[m]=a.length,a.push(f.getHex())),s[m]}function h(f){let m=f.x.toString()+f.y.toString();return c[m]!==void 0||(c[m]=l.length/2,l.push(f.x,f.y)),c[m]}return r.data={},r.data.vertices=e,r.data.normals=o,a.length>0&&(r.data.colors=a),l.length>0&&(r.data.uvs=[l]),r.data.faces=t,r}clone(){return new pn().copy(this)}copy(r){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=r.name;let e=r.vertices;for(let d=0,h=e.length;d<h;d++)this.vertices.push(e[d].clone());let t=r.colors;for(let d=0,h=t.length;d<h;d++)this.colors.push(t[d].clone());let o=r.faces;for(let d=0,h=o.length;d<h;d++)this.faces.push(o[d].clone());for(let d=0,h=r.faceVertexUvs.length;d<h;d++){let f=r.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,y=f.length;m<y;m++){let g=f[m],v=[];for(let O=0,P=g.length;O<P;O++){let S=g[O];v.push(S.clone())}this.faceVertexUvs[d].push(v)}}let i=r.morphTargets;for(let d=0,h=i.length;d<h;d++){let f={};if(f.name=i[d].name,i[d].vertices!==void 0){f.vertices=[];for(let m=0,y=i[d].vertices.length;m<y;m++)f.vertices.push(i[d].vertices[m].clone())}if(i[d].normals!==void 0){f.normals=[];for(let m=0,y=i[d].normals.length;m<y;m++)f.normals.push(i[d].normals[m].clone())}this.morphTargets.push(f)}let a=r.morphNormals;for(let d=0,h=a.length;d<h;d++){let f={};if(a[d].vertexNormals!==void 0){f.vertexNormals=[];for(let m=0,y=a[d].vertexNormals.length;m<y;m++){let g=a[d].vertexNormals[m],v={};v.a=g.a.clone(),v.b=g.b.clone(),v.c=g.c.clone(),f.vertexNormals.push(v)}}if(a[d].faceNormals!==void 0){f.faceNormals=[];for(let m=0,y=a[d].faceNormals.length;m<y;m++)f.faceNormals.push(a[d].faceNormals[m].clone())}this.morphNormals.push(f)}let s=r.skinWeights;for(let d=0,h=s.length;d<h;d++)this.skinWeights.push(s[d].clone());let l=r.skinIndices;for(let d=0,h=l.length;d<h;d++)this.skinIndices.push(l[d].clone());let c=r.lineDistances;for(let d=0,h=c.length;d<h;d++)this.lineDistances.push(c[d]);let u=r.boundingBox;u!==null&&(this.boundingBox=u.clone());let p=r.boundingSphere;return p!==null&&(this.boundingSphere=p.clone()),this.elementsNeedUpdate=r.elementsNeedUpdate,this.verticesNeedUpdate=r.verticesNeedUpdate,this.uvsNeedUpdate=r.uvsNeedUpdate,this.normalsNeedUpdate=r.normalsNeedUpdate,this.colorsNeedUpdate=r.colorsNeedUpdate,this.lineDistancesNeedUpdate=r.lineDistancesNeedUpdate,this.groupsNeedUpdate=r.groupsNeedUpdate,this}toBufferGeometry(){let r=new Wp().fromGeometry(this),e=new n0,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",iu.call(new ks(t,3),r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",iu.call(new ks(o,3),r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",a0.call(new ks(o,3),r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",s0.call(new ks(o,2),r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",s0.call(new ks(o,2),r.uvs2))}e.groups=r.groups;for(let o in r.morphTargets){let i=[],a=r.morphTargets[o];for(let s=0,l=a.length;s<l;s++){let c=a[s],u=new ga(c.data.length*3,3);u.name=c.name,i.push(iu.call(u,c.data))}e.morphAttributes[o]=i}if(r.skinIndices.length>0){let o=new ga(r.skinIndices.length*4,4);e.setAttribute("skinIndex",l0.call(o,r.skinIndices))}if(r.skinWeights.length>0){let o=new ga(r.skinWeights.length*4,4);e.setAttribute("skinWeight",l0.call(o,r.skinWeights))}return r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(r){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(r)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(r){let e=new n0,t=r.geometry;if(r.isPoints||r.isLine){let o=new ga(t.vertices.length*3,3),i=new ga(t.colors.length*3,3);if(e.setAttribute("position",iu.call(o,t.vertices)),e.setAttribute("color",a0.call(i,t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let a=new ga(t.lineDistances.length,1);e.setAttribute("lineDistance",kM.call(a,t.lineDistances))}t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone())}else r.isMesh&&(e=t.toBufferGeometry());return e}};pn.prototype.isGeometry=!0;var Wp=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(r){let e=[],t,o,i,a=r.faces;for(o=0;o<a.length;o++){let s=a[o];s.materialIndex!==i&&(i=s.materialIndex,t!==void 0&&(t.count=o*3-t.start,e.push(t)),t={start:o*3,materialIndex:i})}t!==void 0&&(t.count=o*3-t.start,e.push(t)),this.groups=e}fromGeometry(r){let e=r.faces,t=r.vertices,o=r.faceVertexUvs,i=o[0]&&o[0].length>0,a=o[1]&&o[1].length>0,s=r.morphTargets,l=s.length,c;if(l>0){c=[];for(let g=0;g<l;g++)c[g]={name:s[g].name,data:[]};this.morphTargets.position=c}let u=r.morphNormals,p=u.length,d;if(p>0){d=[];for(let g=0;g<p;g++)d[g]={name:u[g].name,data:[]};this.morphTargets.normal=d}let h=r.skinIndices,f=r.skinWeights,m=h.length===t.length,y=f.length===t.length;t.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<e.length;g++){let v=e[g];this.vertices.push(t[v.a],t[v.b],t[v.c]);let O=v.vertexNormals;if(O.length===3)this.normals.push(O[0],O[1],O[2]);else{let S=v.normal;this.normals.push(S,S,S)}let P=v.vertexColors;if(P.length===3)this.colors.push(P[0],P[1],P[2]);else{let S=v.color;this.colors.push(S,S,S)}if(i===!0){let S=o[0][g];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new ur,new ur,new ur))}if(a===!0){let S=o[1][g];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new ur,new ur,new ur))}for(let S=0;S<l;S++){let T=s[S].vertices;c[S].data.push(T[v.a],T[v.b],T[v.c])}for(let S=0;S<p;S++){let T=u[S].vertexNormals[g];d[S].data.push(T.a,T.b,T.c)}m&&this.skinIndices.push(h[v.a],h[v.b],h[v.c]),y&&this.skinWeights.push(f[v.a],f[v.b],f[v.c])}return this.computeGroups(r),this.verticesNeedUpdate=r.verticesNeedUpdate,this.normalsNeedUpdate=r.normalsNeedUpdate,this.colorsNeedUpdate=r.colorsNeedUpdate,this.uvsNeedUpdate=r.uvsNeedUpdate,this.groupsNeedUpdate=r.groupsNeedUpdate,r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),this}},xa=class{constructor(r,e,t,o,i,a=0){this.a=r,this.b=e,this.c=t,this.normal=o&&o.isVector3?o:new Rt,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new qp,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=a}clone(){return new this.constructor().copy(this)}copy(r){this.a=r.a,this.b=r.b,this.c=r.c,this.normal.copy(r.normal),this.color.copy(r.color),this.materialIndex=r.materialIndex;for(let e=0,t=r.vertexNormals.length;e<t;e++)this.vertexNormals[e]=r.vertexNormals[e].clone();for(let e=0,t=r.vertexColors.length;e<t;e++)this.vertexColors[e]=r.vertexColors[e].clone();return this}};function kM(n){return this.array.set(n),this}function a0(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",t),i=new qp),r[e++]=i.r,r[e++]=i.g,r[e++]=i.b}return this}function s0(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",t),i=new ur),r[e++]=i.x,r[e++]=i.y}return this}function iu(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",t),i=new Rt),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z}return this}function l0(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",t),i=new UM),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z,r[e++]=i.w}return this}var WM=["a","b","c"];function qM(n,r){switch(r){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function Yp(n,r,e){let t=Math.min(n,r),o=Math.max(n,r),i=t+"_"+o;return e.get(i)}function Xp(n,r,e,t,o,i){let a=Math.min(n,r),s=Math.max(n,r),l=a+"_"+s,c;if(t.has(l))c=t.get(l);else{let u=e[a],p=e[s];c={a:u,b:p,newEdge:null,faces:[]},t.set(l,c)}c.faces.push(o),i[n].edges.push(c),i[r].edges.push(c)}function $M(n,r,e,t){let o,i,a;for(o=0,i=n.length;o<i;o++)e[o]={edges:[]};for(o=0,i=r.length;o<i;o++)a=r[o],Xp(a.a,a.b,n,t,a,e),Xp(a.b,a.c,n,t,a,e),Xp(a.c,a.a,n,t,a,e)}function au(n,r,e,t,o){n.push(new xa(r,e,t,void 0,void 0,o))}function ba(n,r){return Math.abs(r-n)/2+Math.min(n,r)}function su(n,r,e,t){n.push([r.clone(),e.clone(),t.clone()])}var lu=class{constructor(r=1){this.subdivisions=r}modify(r){r instanceof HM?r=new pn().fromBufferGeometry(r):r=r.clone(),r.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(r);return r.computeFaceNormals(),r.computeVertexNormals(),r}_smooth(r){let e=new u0,t,o,i,a,s,l=r.vertices,c=r.faces,u=r.faceVertexUvs[0],p=u!==void 0&&u.length>0,d=[],h=new Map;$M(l,c,d,h);let f=[],m,y,g,v,O,P,S;for(let ee of Array.from(h.keys())){for(y=h.get(ee),g=new u0,O=3/8,P=1/8,S=y.faces.length,S!=2&&(O=.5,P=0,S!=1),g.addVectors(y.a,y.b).multiplyScalar(O),e.set(0,0,0),a=0;a<S;a++){for(v=y.faces[a],s=0;s<3&&(m=l[qM(v,WM[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(P),g.add(e),y.newEdge=f.length,f.push(g)}let T,I,x,_,D,A,N,E=[];for(o=0,i=l.length;o<i;o++){for(A=l[o],D=d[o].edges,t=D.length,t==3?T=3/16:t>3&&(T=3/(8*t)),I=1-t*Number(T),x=T,t<=2&&(t==2?(I=3/4,x=1/8):t==1||t==0),N=A.clone().multiplyScalar(I),e.set(0,0,0),a=0;a<t;a++)_=D[a],m=_.a!==A?_.a:_.b,e.add(m);e.multiplyScalar(Number(x)),N.add(e),E.push(N)}let B=E.concat(f),V=E.length,j,R,W,F=[],k=[],H,$,J,Z,X=new $p,te=new $p,Y=new $p;for(o=0,i=c.length;o<i;o++)v=c[o],j=Number(Yp(v.a,v.b,h).newEdge)+V,R=Number(Yp(v.b,v.c,h).newEdge)+V,W=Number(Yp(v.c,v.a,h).newEdge)+V,au(F,j,R,W,v.materialIndex),au(F,v.a,j,W,v.materialIndex),au(F,v.b,R,j,v.materialIndex),au(F,v.c,W,R,v.materialIndex),p&&(H=u[o],$=H[0],J=H[1],Z=H[2],X.set(ba($.x,J.x),ba($.y,J.y)),te.set(ba(J.x,Z.x),ba(J.y,Z.y)),Y.set(ba($.x,Z.x),ba($.y,Z.y)),su(k,X,te,Y),su(k,$,X,Y),su(k,J,te,X),su(k,Z,Y,te));r.vertices=B,r.faces=F,p&&(r.faceVertexUvs[0]=k)}};var Pt=new XM,f0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=n.geometry??r?.geometry??new d0().copy(new p0(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Pt),t={width:Pt.x,height:Pt.y,depth:Pt.z,subdivisions:0}):t=r.parameters;let o={...t,...n.parameters};return{parameters:{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth),subdivisions:Math.abs(o.subdivisions)},geometry:e}}static build(n){let{width:r,height:e,depth:t,subdivisions:o}=n.parameters,i=n.geometry??new d0().copy(new p0(100,100,100)),a=i.userData.parameters;a===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(Pt)):Pt.set(a.width,a.height,a.depth),(r!==Pt.x||e!==Pt.y||t!==Pt.z)&&i.scale(Pt.x===0?1:r/Pt.x,Pt.y===0?1:e/Pt.y,Pt.z===0?1:t/Pt.z);let s=i.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=i),i=new lu(o).modify(s).toBufferGeometry()):(s!==void 0&&(i=s),s=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals())}catch{s!==void 0&&(i=s),s=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals()}return s!==void 0&&Object.assign(i,{originalGeometry:s}),delete n.geometry,Object.assign(i,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,r,e){new YM(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(Pt);let a=100/Pt.x;Object.assign(i.parameters,{width:100,height:Pt.y*a,depth:Pt.z*a}),r(this.build(i))})}};var cu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof Fe?n.shape:new Fe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,spikes:t,cornerRadius:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}=n.parameters,l=n.shape,c=r*.5,u=e*.5,p=0,d=0,h=2*Math.PI/t;for(let m=0;m<t;m++){let y=h*m,g=p+Math.sin(y)*c,v=d+Math.cos(y)*u;l.addPoint(l.createPoint(g,v))}l.isClosed=!0;for(let m=0,y=l.points.length;m<y;m++)l.points[m].roundness=o;l.roundness=o,l.update();let f=Jt.create({shape:l,parameters:{roundness:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(f,{userData:{...n,type:"PolygonGeometry"}})}};import{BufferGeometry as KM,Float32BufferAttribute as Kp,Vector2 as oo,Vector3 as It}from"three";var h0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{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(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,radialSegments:o,heightSegments:i,openEnded:a,cornerRadius:s,cornerSegments:l}=n.parameters,c=new Zp(r*.5,e,o,i,a,s,l);return c.scale(1,1,t/r),Object.assign(c,{userData:{...n,type:"PyramidGeometry"}})}};function Hs(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function Qp(n,r,e,t,o,i){let a=r.clone().sub(n),s=e.clone().sub(n),l=a.angleTo(s);if(a.normalize(),s.normalize(),t===o){let c=a.add(s).normalize();i.copy(n).addScaledVector(c,t/Math.sin(l/2))}else{let c=a.angleTo(s);i.copy(n),i.addScaledVector(a,o/Math.sin(c)),i.addScaledVector(s,t/Math.sin(c))}}function QM(n,r,e){let t=n.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var Zp=class extends KM{constructor(r=.5,e=1,t=4,o=1,i=!1,a=0,s=4){super(),t=Math.floor(Math.max(3,t)),o=Math.floor(o),s=Math.floor(s);let l=[],c=[],u=[],p=[],d=0,h=e/2,f=Math.PI/t,m=r*Math.cos(Math.PI/t),y=2*Math.PI/t,g=(t-2)*Math.PI/t,v=Math.PI-g,O=new It(0,-h,0),P=new It(0,h,0),S=new oo(r,-h),T=new oo(m,-h),I=new oo(0,P.y).sub(T),x=new oo(0,P.y).sub(S),_=new oo(I.y,-I.x).normalize(),D=new oo(x.y,-x.x).normalize(),N=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-I.angle())/2)-1e-8;a=Math.min(a,N);let E;{let k=new It(_.x,_.y,0),H=new It(Math.cos(y)*k.x,k.y,Math.sin(y)*k.x);E=k.angleTo(H)}let B=a/Math.tan((Math.PI-I.angle())/2),V=a/Math.tan((Math.PI-E)/2),j=new It;if(!i){c.push(O.x,O.y,O.z),u.push(0,-1,0),p.push(0,0);let k=d++,H=[],$=S.clone(),J=B/Math.cos(Math.PI/t);$.x-=J;for(let Z=0;Z<t;Z++){let X=Z/t*Math.PI*2+f,te=new oo(Math.sin(X),Math.cos(X));Hs($,te,j),c.push(j.x,j.y,j.z),u.push(0,-1,0),p.push(0,0),H.push(d++)}for(let Z=0;Z<H.length;Z++)l.push(H[Z],k,H[(Z+1)%H.length])}let R=[];{let k=new It,H=new It,$=new It,J=new It,Z=new It,X=new It;for(let te=0;te<t;te++){let Y=te/t*Math.PI*2+f,ee=(te+.5)/t*Math.PI*2+f,K=(te+1)/t*Math.PI*2+f,q=new oo(Math.sin(Y),Math.cos(Y)),ue=new oo(Math.sin(ee),Math.cos(ee)),le=new oo(Math.sin(K),Math.cos(K));Hs(S,q,H),Hs(S,le,$),Hs(_,ue,k),Qp(P,H,$,V,V,J),c.push(J.x,J.y,J.z),Qp(H,P,$,V,B,Z),c.push(Z.x,Z.y,Z.z),Qp($,H,P,B,V,X),c.push(X.x,X.y,X.z),u.push(k.x,k.y,k.z),u.push(k.x,k.y,k.z),u.push(k.x,k.y,k.z),p.push(0,0),p.push(0,0),p.push(0,0);let ne=d++,ce=d++,ae=d++;if(l.push(ne,ce,ae),a>0){{let fe=H.clone().add($).multiplyScalar(.5),ge=P.clone().sub(fe).normalize(),C=O.clone().sub(fe).normalize().add(ge).normalize().multiplyScalar(-1),ie=X.clone().sub(Z);W(fe,ie,C,I.angle())}let he,pe;{let fe=new It;Hs(D,le,fe);let ge=X.clone().add(J).multiplyScalar(.5);ge=QM(ge,$,P);let me=X.clone().sub(J);[he,pe]=W(ge,me,fe,E,J.y)}{let fe=he,ge=fe.clone().setY(0).normalize(),me=new It(0,-1,0),C=ge.clone().cross(me);F(fe,ge,me,C)}R.concat(pe);{let fe=I.angle(),ge=Math.PI-fe,me=P.clone();me.y-=a/Math.sin(fe-Math.PI/2);let C=new It,ie=[];for(let Re=0;Re<s;Re++){let Ee=[],Pe=Math.PI/2-ge*Re/s,bt=Math.cos(Pe),Me=Math.sin(Pe),yt=ee;for(let vt=0;vt<=Re;vt++){let An=Math.cos(yt),tt=Math.sin(yt);k.x=bt*tt,k.y=Me,k.z=bt*An,C.copy(me).addScaledVector(k,a),c.push(C.x,C.y,C.z),u.push(k.x,k.y,k.z),p.push(0,0),Ee.push(d++),yt+=Math.PI*2/Re/t}ie.push(Ee)}pe.reverse(),ie.push(pe);let De=ie.length-1;for(let Re=0;Re<De;Re++){let Ee=ie[Re],Pe=ie[Re+1],bt=Ee.length-1;l.push(Pe[1],Ee[0],Pe[0]);for(let Me=1;Me<=bt;Me++)l.push(Ee[Me],Ee[Me-1],Pe[Me]),l.push(Pe[Me+1],Ee[Me],Pe[Me])}}}}}this.setIndex(l),this.setAttribute("position",new Kp(c,3)),this.setAttribute("normal",new Kp(u,3)),this.setAttribute("uv",new Kp(p,2));function W(k,H,$,J,Z){let X=-J/2,te=(Math.PI-J)/2,Y=H.clone().normalize().cross($);k.addScaledVector($,-a/Math.sin(te));let ee=new It,K=new It,q=1,ue=d,le=[];for(let ne=0;ne<=s;ne++){let ce=X+ne/s*J;K.set(0,0,0),K.addScaledVector(Y,Math.sin(ce)),K.addScaledVector($,Math.cos(ce));for(let ae=0;ae<=q;ae++){let he=ae/q-.5;if(ee.copy(k),ee.addScaledVector(H,he),ee.addScaledVector(K,a),Z!=null){let pe=Math.max(0,ee.y-Z);ee.addScaledVector(H,-pe/H.y)}c.push(ee.x,ee.y,ee.z),u.push(K.x,K.y,K.z),p.push(0,0),ae===0&&le.push(d),d++}}for(let ne=0;ne<s;ne++)for(let ce=0;ce<q;ce++){let ae=ue+ce+(q+1)*ne,he=ae+(q+1),pe=he+1,fe=ae+1;l.push(ae,he,fe),l.push(he,pe,fe)}return[k.clone().addScaledVector(H,.5),le]}function F(k,H,$,J){let Z=Math.PI/2,X=x.angle()-Z,te=[],Y=new It,ee=new It;for(let q=0;q<=s;q++){let ue=[],le=q/s;for(let ne=0;ne<=q;ne++){let ae=((q?ne/q:0)-.5)*v,he=Math.cos(ae),pe=Math.sin(ae),fe=Math.atan(Math.tan(X)*he),ge=(Z+fe)*le,me=Math.cos(ge),C=Math.sin(ge);Y.set(0,0,0),Y.addScaledVector(H,C*he),Y.addScaledVector($,me),Y.addScaledVector(J,C*pe),ee.copy(k).addScaledVector(Y,a),c.push(ee.x,ee.y,ee.z),u.push(Y.x,Y.y,Y.z),p.push(0,0),ue.push(d++)}te.push(ue)}let K=te.length-1;for(let q=0;q<K;q++){let ue=te[q],le=te[q+1],ne=ue.length-1;l.push(ue[0],le[1],le[0]);for(let ce=1;ce<=ne;ce++)l.push(ue[ce-1],ue[ce],le[ce]),l.push(ue[ce],le[ce+1],le[ce])}}}};var va=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),t=Object.assign(r?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof Fe?n.shape:new Fe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:t}}static build(n){let r=n.shape,{width:e,height:t,cornerRadius:o,cornerType:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,c={x:e*.5,y:t*.5},u={x:-c.x,y:-c.y},p={x:c.x,y:c.y};function d(P,S,T){return S>e&&T>t?Math.min(P*e/S,P*t/T):S>e?P*e/S:T>t?P*t/T:P}let h=[];h[0]=o[0]===0?0:d(o[0],o[0]+o[3],o[0]+o[1]),h[1]=o[1]===0?0:d(o[1],o[1]+o[2],o[1]+o[0]),h[2]=o[2]===0?0:d(o[2],o[2]+o[1],o[2]+o[3]),h[3]=o[3]===0?0:d(o[3],o[3]+o[0],o[3]+o[2]);let f=u.x,m=p.x,y=p.y,g=u.y;r.addPoint(r.createPoint(f,y)),r.addPoint(r.createPoint(m,y)),r.addPoint(r.createPoint(m,g)),r.addPoint(r.createPoint(f,g)),r.isClosed=!0;let v=!0;for(let P=0,S=r.points.length;P<S;P++)r.points[P].roundness=h[P],P>0&&h[P]!==h[P-1]&&(v=!1);v&&(r.roundness=h[0]),r.useCubicForRoundedCorners=i!==1,r.update();let O=Jt.create({shape:r,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(O,{userData:{...n,type:"RectangleGeometry"}})}};import{BufferGeometry as ZM,Float32BufferAttribute as JM,MathUtils as m0,SphereGeometry as eI}from"three";var y0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},n.parameters);return e.thetaLength=m0.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r=100,height:e=r,depth:t=r,widthSegments:o=64,heightSegments:i=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:c}=n.parameters,u;return c===0?(u=new ZM,u.setAttribute("position",new JM([],3))):u=new eI(.5*r,o,i,a,s,l,c*m0.DEG2RAD),u.scale(1,e/r,t/r),Object.assign(u,{userData:{...n,type:"SphereGeometry"}})}};import{PlaneGeometry as tI}from"three";var g0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(n){let{width:r=100,height:e=r,widthSegments:t=8,heightSegments:o=8}=n.parameters,i=new tI(r,e,t,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};import{BufferGeometry as rI,Float32BufferAttribute as Jp,Vector3 as oI}from"three";var x0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,angle:o,cornerRadius:i,cornerSegments:a}=n.parameters,s=new ef(r,e,t,o,i,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},ef=class extends rI{constructor(r=1,e=1,t=1,o=90,i=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],c=[],u=.001;i==0&&(a=1),a=Math.max(1,Math.floor(a)),i=Math.min(i,100),o=Math.min(180-u,o),o*=Math.PI/180;let p=[],d=Math.PI/2,h=(ee=0,K=0,q=0)=>new oI(ee,K,q),f=h(),m=h(),[y,g,v]=[e/2,r/2,t/2],O=-g,P=+g,[S,T,I]=[h(O,-y,+v),h(O,-y,-v),h(O,+y,-v)],x=(ee,K=!1)=>Math.sin(ee-Math.PI/(1+ +K)),_=(ee,K=!1)=>Math.cos(ee-Math.PI/(1+ +K));I.y=Math.sin(o)*e-y;let D=Math.cos(o)*e-v,A=S.z-u;o<=d?(I.z=Math.min(D,A),I.z==A&&(I.y-=(D-A)/Math.tan(d-o))):T.z=Math.min(T.z-D-v,S.z-u),f.subVectors(S,T),m.subVectors(I,T);let N=Math.min(f.length(),m.length())*i/100,E=N*Math.tan(o/2),B=N/Math.cos(o/2),V=f.clone().normalize().add(m.normalize()).setLength(B).add(T);f.set(0,x(o,!0),_(o,!0)),p.push([I,f.clone()]);let j=(Math.PI-o)/a;for(let ee=0;ee<=a;ee++){let K=d+o+ee*j;f.set(0,Math.sin(K)*E,Math.cos(K)*E),f.add(V),m.set(0,x(K),_(K)),p.push([f.clone(),m.clone()])}p.push([S,h(0,1,0)]);let R=Math.sin(j/2)*E*2,W=p.length-1,F=p[0][0].distanceTo(p[1][0]),k=p[W-1][0].distanceTo(p[W][0]),H=F+R*a+k;p[0].push(1);for(let ee=0;ee<=a;ee++)p[ee+1].push(1-(F+ee*R)/H);p[W].push(0);let[$,J,Z]=p[0],X,te,Y;for(let ee=1;ee<p.length;ee++)[X,te,Y]=p[ee],s.push(O,$.y,$.z,O,X.y,X.z,P,$.y,$.z,P,$.y,$.z,O,X.y,X.z,P,X.y,X.z),l.push(0,J.y,J.z,0,te.y,te.z,0,J.y,J.z,0,J.y,J.z,0,te.y,te.z,0,te.y,te.z),c.push(0,Z,0,Y,1,Z,1,Z,0,Y,1,Y),[$,J,Z]=[X,te,Y];this.setAttribute("position",new Jp(s,3)),this.setAttribute("normal",new Jp(l,3)),this.setAttribute("uv",new Jp(c,2))}};var uu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Fe?n.shape:new Fe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,innerRadiusPercent:t,spikes:o,cornerRadius:i,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}=n.parameters,u=n.shape,p=r*.5,d=e*.5,h=0,f=0,m=a*Math.PI/360/o,y=Math.PI/2*3*-1,g=p*t/100,v=d*t/100;if(o===3&&t===50){m=2*Math.PI/o;for(let P=0;P<o;P++){let S=m*P,T=h+Math.sin(S)*p,I=f+Math.cos(S)*d;u.addPoint(u.createPoint(T,I))}}else for(let P=0;P<o;P++){let S=h+Math.cos(y)*p,T=f+Math.sin(y)*d;u.addPoint(u.createPoint(S,T)),y+=m,S=h+Math.cos(y)*g,T=f+Math.sin(y)*v,P<=o,u.addPoint(u.createPoint(S,T)),y+=m}u.isClosed=!0;for(let P=0,S=u.points.length;P<S;P++)u.points[P].roundness=i;u.roundness=i,u.update();let O=Jt.create({shape:u,parameters:{roundness:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(O,{userData:{...n,type:"StarGeometry"}})}};import{PlaneGeometry as nI}from"three";var b0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e}=n.parameters,t=new nI(r,e);return Object.assign(t,{userData:{...n,type:"TextFrameGeometry"}})}};import{BufferGeometry as iI,Float32BufferAttribute as aI,MathUtils as sI}from"three";var v0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:t,height:o,depth:i})}}static build(n){let{width:r,height:e,depth:t,radialSegments:o,tubularSegments:i,arc:a,cornerRadius:s,cornerSegments:l}=n.parameters,c=lI(r,e,t,r*.5,a,i,0,0,o,s,l);return c.scale(1,e/r,1),Object.assign(c,{userData:{...n,type:"TorusGeometry"}})}};function lI(n,r,e,t,o,i,a,s,l,c,u){[r,e]=[e,r],a=r/2;let p=sI.clamp(o/360,0,1);if(p===0){let d=new iI;return d.setAttribute("position",new aI([],3)),d}return p===1&&(c=0),new Fs(!0,n,r,e,t,p,i,a,s,l,c,u)}import{TorusKnotGeometry as cI}from"three";var S0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{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(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(n){let{width:r,tube:e,tubularSegments:t,radialSegments:o,p:i,q:a}=n.parameters,s=r*.5;s!==e&&(s-=e);let l=new cI(s,e,t,o,i,a);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var w0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof Fe?n.shape:new Fe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r=100,height:e,cornerRadius:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a,isRect:s}=n.parameters,l=n.shape,c=r*.5,u=e*.5;s?(l.addPoint(l.createPoint(-c,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))):(l.addPoint(l.createPoint(0,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))),l.isClosed=!0;for(let d=0,h=l.points.length;d<h;d++)l.points[d].roundness=t;l.roundness=t,l.update();let p=Jt.create({shape:l,parameters:{roundness:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...n,type:"TriangleGeometry"}})}};import{Vector2 as O0,Vector3 as Nt,Matrix3 as uI,Matrix4 as Wn,BufferGeometry as C0,BufferAttribute as Sa,MathUtils as du}from"three";function P0(n,r){let e=2*Math.PI;return(n%e+e)%e===(r%e+e)%e}var dI=new Wn,pI=new Wn;function fI(n,r,e){let t=[new Nt,new Nt,new Nt],o=[new Nt,new Nt,new Nt];return n.extractBasis(t[0],t[1],t[2]),r.extractBasis(o[0],o[1],o[2]),t.forEach((i,a)=>{let s=o[a],l=du.lerp(i.length(),s.length(),e);i.lerp(s,e).setLength(l)}),new Wn().makeBasis(t[0],t[1],t[2])}var T0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=r?.shapeData??ya.create({parameters:Yd}).userData.shape;return{path:n.path??Xi.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:i,extrusion:{...wc,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new tf(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new C0,{userData:{...n,type:"PathGeometry"}})}},tf=class extends C0{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!P0(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:o,offset:i}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),i=Math.max(0,Math.min(i,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(i*a),l=this.inputs.path.isClosed?Math.ceil((o+i)*a):Math.ceil(Math.min(1,o+i)*a),c=Math.min(Math.max(2,l-s+1),a+2),u=[],p=[];for(let F=0;F<c;F++){let k=this.inputs.path.isClosed?(F+s)%e.length:Math.min(F+s,e.length-1);u.push(e[k].clone()),p.push(t[k].clone())}let d=(F,k,H)=>{u[F]=u[F].clone().lerp(u[k],H),p[F]=fI(p[F],p[k],H)},h=0,f=i*a%1;(!this.inputs.path.isClosed||o<=1)&&(f||i===0)&&(h=f,d(0,1,h));let m=0,y=(i+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&i+o<1)&&y&&(m=y,d(u.length-1,u.length-2,1-m)),o===0){let F=u.length-1;u[F].copy(u[0]),p[F].copy(p[0])}this._applyPathModifiers(p,h,m);let{bevel:g,bevelSides:v}=this.inputs.parameters.extrusion,O=g>0?this.inputs.parameters.extrusion.capType:"flat",P=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(P=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:I}=this._computeShapePoints(P),x=0,_;O==="round"&&(_=new dn(this.inputs.shapeData,2*g,g,P,v,void 0,!0),x=_.getAttribute("position").count);let D=0,A=0;T.sort((F,k)=>F.start-k.start),T.forEach(F=>{F.verticesStart=D,F.verticesCount=F.continuous.reduce((k,H,$)=>k+($===0||!H?2:1),0),A+=F.verticesCount,D=A});let N=A*c,E,B=0;if(this._isOpenEnded()&&O==="flat"){try{E=Rr({windingRule:Ge.ODD,elementType:nt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{E=jp}B=E.vertexCount}let V=N+2*B+x*2,j=N+2*B,R={positions:new Float32Array(V*3),normals:new Float32Array(V*3),uvs:new Float32Array(V*2)},W=[];if(T.forEach(F=>{this._extrudeRegion(F,I,p,u,R,W,this._isGeometryClosed()&&!this._isOpenEnded())}),E&&(this._closeEnd(E,N,W,R,p[0],u[0],!1),this._closeEnd(E,N+B,W,R,p[p.length-1],u[u.length-1],!0)),_){R.positions.set(_.getAttribute("position").array,j*3),R.normals.set(_.getAttribute("normal").array,j*3),R.uvs.set(_.getAttribute("uv").array,j*2);for(let $=j;$<j+x;$++)R.uvs[$*2+1]=1e-4;let F=W.length;W.push(..._.getIndex().array.map($=>$+j)),j+=x,R.positions.set(_.getAttribute("position").array,j*3),R.normals.set(_.getAttribute("normal").array,j*3),R.uvs.set(_.getAttribute("uv").array,j*2);let k=W.length;W.push(..._.getIndex().array.map($=>$+j)),this.setAttribute("position",new Sa(R.positions,3)),this.setAttribute("normal",new Sa(R.normals,3)),this.setAttribute("uv",new Sa(R.uvs,2)),this.setIndex(W);let H=dI;H.copy(p[p.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,j,V),H.copy(p[0]).setPosition(u[0]).multiply(pI.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,j-x,j),this.reverseIndicesOnRange(F,k)}else this.setAttribute("position",new Sa(R.positions,3)),this.setAttribute("normal",new Sa(R.normals,3)),this.setAttribute("uv",new Sa(R.uvs,2)),this.setIndex(W)}_extractPathPoints(){let t=Hc(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(t.length<2)return[];let o=[t[0]];return t.forEach(a=>{o[o.length-1].distanceToSquared(a)>.001&&o.push(a)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let t=[],o=e.length,i=this.inputs.path.isClosed,a=new Nt,s=new Nt,l=new Nt,c=new Nt,u=new Nt(0,1,0);for(let y=0;y<o;y++){let g=e[y],v;y===0?v=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let O;y===o-1?O=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):O=e[y+1];let P=g.clone().sub(v).normalize(),S=O.clone().sub(g).normalize(),T=P.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let I=u.clone().cross(T).normalize(),x=T.clone().cross(I).normalize();u.copy(x),c.copy(I),y===0&&(a.copy(x),s.copy(T));let _=new Wn().makeBasis(I,x,T);t.push(_)}let p=i?s:l,d=i?a:new Nt(0,1,0),h=p.clone().cross(c).normalize(),f=Math.acos(d.dot(h));if(isNaN(f))return t;let m=d.clone().cross(h);p.dot(m)>0&&(f*=-1);for(let y=1;y<t.length;y++){let g=new Wn().makeRotationZ(f*y/t.length);t[y].multiply(g)}return t}_applyPathModifiers(e,t,o){let i=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new Wn,p=new Wn;return e.forEach((d,h)=>{let f=h===0?0:h===i-1?1:(h-t)/(i-(o===0?0:1)-(t+(1-o)));u.makeRotationZ(du.lerp(a,a+s,f)*du.DEG2RAD);let m=du.lerp(l,c,f);p.makeScale(m,m,m),d.multiply(u).multiply(p)}),e}_computeShapePoints(e=12,t=Ge.ODD){let o=this.inputs.shapeData,i=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let v=y.length-1;v>=1;v-=2){let O=y[v-1],P=y[v-0];g.push(O,P)}return g}),s;try{s=Rr({windingRule:t,elementType:nt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{s=js}let l;try{l=Rr({windingRule:Ge.ODD,elementType:nt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Gp}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let u=1/0,p=-1/0,d=1/0,h=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,v=s.vertices[g+0],O=s.vertices[g+1];v<u&&(u=v),v>p&&(p=v),O<d&&(d=O),O>h&&(h=O)}let f=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,v=s.elements[g+0],O=s.elements[g+1],P=v+O,S={start:v,count:O,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};f.push(S);let T=v,I=P-1,x=v+1,_=o.roundedCurves.length;do{let D=T-v,A=s.vertices[I*2+0],N=s.vertices[I*2+1],E=s.vertices[T*2+0],B=s.vertices[T*2+1],V=s.vertices[x*2+0],j=s.vertices[x*2+1],R=E-A,W=B-N,F=Math.sqrt(R*R+W*W);R/=F,W/=F;let k=E-V,H=B-j,$=Math.sqrt(k*k+H*H);k/=$,H/=$,S.normals[D*2+0]=-H,S.normals[D*2+1]=k;let J=s.vertexIndices[T];if(Array.isArray(J))S.continuous[D]=!1;else{let[Z,X]=o.getCurveIndexFromVertexId(J-1,!0);if(X>0&&X<1)S.continuous[D]=!0;else{let te=X===1?Z+1:Z-1;te=(te+_)%_;let Y=X===1?0:1,ee=o.roundedCurves[Z].getTangent(X),K=o.roundedCurves[te].getTangent(Y);S.continuous[D]=ee.dot(K)>.95}}y&&(S.normals[D*2+0]*=-1,S.normals[D*2+1]*=-1),[I,T,x]=[T,x,x+1],x>=P&&(x-=O)}while(x!==v+1)}return{regions:[i,...a],infos:f,vertices:s.vertices}}_insertVertex(e,t,o,i,a){let s=t*2,l=t*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=i.x,e.normals[l+1]=i.y,e.normals[l+2]=i.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,t,o,i,a,s,l){let c=new Nt,u=new Nt,p=new Nt,d=new Nt,h=new O0;o.forEach((m,y)=>{let g=i[y],v=e.verticesStart*o.length+e.verticesCount*y;for(let O=0;O<e.count;O++){let P=(e.start+O)*2;if(c.set(t[P+0],t[P+1],0),p.copy(c).applyMatrix4(m).add(g),e.continuous[O])d.set(e.normals[O*2+0],e.normals[O*2+1],0);else{let S=O===0?(e.start+e.count-1)*2:P-2;u.set(t[S+0],t[S+1],0),d.copy(c).sub(u),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(m).normalize(),h.set(O===0?1:O/e.count,y/(o.length-1)),this._insertVertex(a,v,p,d,h),v++,!e.continuous[O]||O===0){if(O===0)d.set(e.normals[O*2+0],e.normals[O*2+1],0),h.set(0,y/(o.length-1));else{let S=O===e.count-1?e.start*2:P+2;u.set(t[S+0],t[S+1],0),d.copy(u).sub(c),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(m).normalize(),this._insertVertex(a,v,p,d,h),v++}}});let f=o.length-1;for(let m=0;m<f;m++){let y=e.verticesStart*o.length+e.verticesCount*m,g=e.verticesStart*o.length+e.verticesCount*(m+1),v=0;for(let O=0;O<e.count;O++){(!e.continuous[O]||O===0)&&v++;let P=O===e.count-1?0:v+1,S=y+v,T=y+P,I=g+P,x=g+v;e.isHole?s.push(S,I,T,S,x,I):s.push(S,T,I,S,I,x),v++}}}_closeEnd(e,t,o,i,a,s,l){let c=e.vertexCount,u=new Nt(0,0,l?-1:1).applyMatrix4(a),p=new Nt,d=new O0;for(let f=0;f<c;f++){let m=2*f;p.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(i,t+f,p,u,d)}let h=e.elements;for(let f=0;f<e.elementCount;f++){let m=3*f,y=h[m+0]+t,g=h[m+(l?1:2)]+t,v=h[m+(l?2:1)]+t;o.push(y,g,v)}}applyMatrix4OnRange(e,t,o){let i=e.elements,a=new uI().getNormalMatrix(e).elements,s,l,c,u,p=this.attributes.position,d=this.attributes.normal;if(!p||!d)return;let h=p.array,f=d.array,m=p.itemSize;for(let y=t*m,g=o*m;y<g;y+=m){if(y===t)debugger;s=h[y+0],l=h[y+1],c=h[y+2],u=1/(i[3]*s+i[7]*l+i[11]*c+i[15]),h[y+0]=(i[0]*s+i[4]*l+i[8]*c+i[12])*u,h[y+1]=(i[1]*s+i[5]*l+i[9]*c+i[13])*u,h[y+2]=(i[2]*s+i[6]*l+i[10]*c+i[14])*u,s=f[y+0],l=f[y+1],c=f[y+2],f[y+0]=a[0]*s+a[3]*l+a[6]*c,f[y+1]=a[1]*s+a[4]*l+a[7]*c,f[y+2]=a[2]*s+a[5]*l+a[8]*c}p.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,t){let o=this.index;if(o){for(let i=e;i<t;i+=3){let a=o.getX(i),s=o.getX(i+1),l=o.getX(i+2);o.setXYZ(i,l,s,a)}o.needsUpdate=!0}}};import{BufferAttribute as A0,BufferGeometry as rf}from"three";import{mergeBufferGeometries as mI}from"three/examples/jsm/utils/BufferGeometryUtils.js";function M0(){let n=new rf;return n.setAttribute("position",new A0(new Float32Array([]),3)),n.setIndex(new A0(new Uint16Array([]),1)),n}var yI=M0().attributes,gI=12,xI=1,wa=class extends rf{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,yI),this.userData={parameters:e,type:"TextGeometry"};let o=t.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let o=t.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l,text:c,textTransform:u}=e,p=Dc.getDisplayedValue(c),d=u===2?p.toUpperCase():u===3?p.toLowerCase():p,h=bI(e,t,d),{shapes:f,charWidths:m,charCoords:y}=t.generateShapes(h,e),g=(typeof o=="number"?o:1)*.5,v=(typeof i=="number"?i:1)*.5,O=f.map(T=>new Fe().fromShape(T,!0));this.vectorShapes=O;let P=O.map(T=>Jt.create({shape:T,parameters:{depth:a,extrudeBevelSegments:l,extrudeBevelSize:s,windingRule:a<=0?Ge.NONZERO:Ge.ODD,subdivisions:this.isLowResolution&&a>0?xI:gI}})),S=P.length?mI(P):M0();S.translate(-g,v,0),this.dispose(),this.wrappedText=h,this.charCoords=y,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(S.attributes).forEach(([T,I])=>{this.setAttribute(T,I)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=Ht(new rf,wa.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,o])=>{this.setAttribute(t,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function bI(n,r,e){let t=[""],o="";for(let i of e)o+=i,i===" "||i===`
1
+ var QS=Object.create;var Ol=Object.defineProperty;var ZS=Object.getOwnPropertyDescriptor;var JS=Object.getOwnPropertyNames;var e1=Object.getPrototypeOf,t1=Object.prototype.hasOwnProperty;var r1=(n,r,e)=>r in n?Ol(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e;var Nn=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),o1=(n,r)=>{for(var e in r)Ol(n,e,{get:r[e],enumerable:!0})},n1=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of JS(r))!t1.call(n,o)&&o!==e&&Ol(n,o,{get:()=>r[o],enumerable:!(t=ZS(r,o))||t.enumerable});return n};var fi=(n,r,e)=>(e=n!=null?QS(e1(n)):{},n1(r||!n||!n.__esModule?Ol(e,"default",{value:n,enumerable:!0}):e,n));var Dn=(n,r,e)=>(r1(n,typeof r!="symbol"?r+"":r,e),e);var s0=Nn((sp,a0)=>{(function(n,r){typeof sp=="object"?a0.exports=r():typeof define=="function"&&define.amd?define(r):n.Alea=r()})(sp,function(){"use strict";return n.importState=function(e){var t=new n;return t.importState(e),t},n;function n(){return function(e){var t=0,o=0,i=0,a=1;e.length==0&&(e=[+new Date]);var s=r();t=s(" "),o=s(" "),i=s(" ");for(var l=0;l<e.length;l++)t-=s(e[l]),t<0&&(t+=1),o-=s(e[l]),o<0&&(o+=1),i-=s(e[l]),i<0&&(i+=1);s=null;var c=function(){var u=2091639*t+a*23283064365386963e-26;return t=o,o=i,i=u-(a=u|0)};return c.next=c,c.uint32=function(){return c()*4294967296},c.fract53=function(){return c()+(c()*2097152|0)*11102230246251565e-32},c.version="Alea 0.9",c.args=e,c.exportState=function(){return[t,o,i,a]},c.importState=function(u){t=+u[0]||0,o=+u[1]||0,i=+u[2]||0,a=+u[3]||0},c}(Array.prototype.slice.call(arguments))}function r(){var e=4022871197,t=function(o){o=o.toString();for(var i=0;i<o.length;i++){e+=o.charCodeAt(i);var a=.02519603282416938*e;e=a>>>0,a-=e,a*=e,e=a>>>0,a-=e,e+=a*4294967296}return(e>>>0)*23283064365386963e-26};return t.version="Mash 0.9",t}})});var p0=Nn((Uc,d0)=>{(function(n,r){typeof Uc=="object"&&typeof d0<"u"?r(Uc):typeof define=="function"&&define.amd?define(["exports"],r):r((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(Uc,function(n){"use strict";n.SVD=function(r,e,t,o,i){if(e=e===void 0||e,t=t===void 0||t,i=1e-64/(o=o||Math.pow(2,-52)),!r)throw new TypeError("Matrix a is not defined");var a,s,l,c,u,p,d,h,f,m,y,g,v=r[0].length,O=r.length;if(O<v)throw new TypeError("Invalid matrix: m < n");for(var P=[],S=[],T=[],I=e==="f"?O:v,x=m=d=0;x<O;x++)S[x]=new Array(I).fill(0);for(x=0;x<v;x++)T[x]=new Array(v).fill(0);var _,D=new Array(v).fill(0);for(x=0;x<O;x++)for(a=0;a<v;a++)S[x][a]=r[x][a];for(x=0;x<v;x++){for(P[x]=d,f=0,l=x+1,a=x;a<O;a++)f+=Math.pow(S[a][x],2);if(f<i)d=0;else for(h=(p=S[x][x])*(d=p<0?Math.sqrt(f):-Math.sqrt(f))-f,S[x][x]=p-d,a=l;a<v;a++){for(f=0,s=x;s<O;s++)f+=S[s][x]*S[s][a];for(p=f/h,s=x;s<O;s++)S[s][a]=S[s][a]+p*S[s][x]}for(D[x]=d,f=0,a=l;a<v;a++)f+=Math.pow(S[x][a],2);if(f<i)d=0;else{for(h=(p=S[x][x+1])*(d=p<0?Math.sqrt(f):-Math.sqrt(f))-f,S[x][x+1]=p-d,a=l;a<v;a++)P[a]=S[x][a]/h;for(a=l;a<O;a++){for(f=0,s=l;s<v;s++)f+=S[a][s]*S[x][s];for(s=l;s<v;s++)S[a][s]=S[a][s]+f*P[s]}}m<(y=Math.abs(D[x])+Math.abs(P[x]))&&(m=y)}if(t)for(x=v-1;0<=x;x--){if(d!==0){for(h=S[x][x+1]*d,a=l;a<v;a++)T[a][x]=S[x][a]/h;for(a=l;a<v;a++){for(f=0,s=l;s<v;s++)f+=S[x][s]*T[s][a];for(s=l;s<v;s++)T[s][a]=T[s][a]+f*T[s][x]}}for(a=l;a<v;a++)T[x][a]=0,T[a][x]=0;T[x][x]=1,d=P[x],l=x}if(e){if(e==="f")for(x=v;x<O;x++){for(a=v;a<O;a++)S[x][a]=0;S[x][x]=1}for(x=v-1;0<=x;x--){for(l=x+1,d=D[x],a=l;a<I;a++)S[x][a]=0;if(d!==0){for(h=S[x][x]*d,a=l;a<I;a++){for(f=0,s=l;s<O;s++)f+=S[s][x]*S[s][a];for(p=f/h,s=x;s<O;s++)S[s][a]=S[s][a]+p*S[s][x]}for(a=x;a<O;a++)S[a][x]=S[a][x]/d}else for(a=x;a<O;a++)S[a][x]=0;S[x][x]=S[x][x]+1}}for(o*=m,s=v-1;0<=s;s--)for(var A=0;A<50;A++){for(_=!1,l=s;0<=l;l--){if(Math.abs(P[l])<=o){_=!0;break}if(Math.abs(D[l-1])<=o)break}if(!_){for(u=0,c=l-(f=1),x=l;x<s+1&&(p=f*P[x],P[x]=u*P[x],!(Math.abs(p)<=o));x++)if(d=D[x],D[x]=Math.sqrt(p*p+d*d),u=d/(h=D[x]),f=-p/h,e)for(a=0;a<O;a++)y=S[a][c],g=S[a][x],S[a][c]=y*u+g*f,S[a][x]=-y*f+g*u}if(g=D[s],l===s){if(g<0&&(D[s]=-g,t))for(a=0;a<v;a++)T[a][s]=-T[a][s];break}for(m=D[l],p=(((y=D[s-1])-g)*(y+g)+((d=P[s-1])-(h=P[s]))*(d+h))/(2*h*y),d=Math.sqrt(p*p+1),p=((m-g)*(m+g)+h*(y/(p<0?p-d:p+d)-h))/m,x=l+(f=u=1);x<s+1;x++){if(d=P[x],y=D[x],h=f*d,d*=u,g=Math.sqrt(p*p+h*h),p=m*(u=p/(P[x-1]=g))+d*(f=h/g),d=-m*f+d*u,h=y*f,y*=u,t)for(a=0;a<v;a++)m=T[a][x-1],g=T[a][x],T[a][x-1]=m*u+g*f,T[a][x]=-m*f+g*u;if(g=Math.sqrt(p*p+h*h),p=(u=p/(D[x-1]=g))*d+(f=h/g)*y,m=-f*d+u*y,e)for(a=0;a<O;a++)y=S[a][x-1],g=S[a][x],S[a][x-1]=y*u+g*f,S[a][x]=-y*f+g*u}P[l]=0,P[s]=p,D[s]=m}for(x=0;x<v;x++)D[x]<o&&(D[x]=0);return{u:S,q:D,v:T}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var W0=Nn((Bp,Lp)=>{(function(n,r){typeof Bp=="object"&&typeof Lp<"u"?Lp.exports=r():typeof define=="function"&&define.amd?define(r):(n=n||self,n.TinyQueue=r())})(Bp,function(){"use strict";var n=function(t,o){if(t===void 0&&(t=[]),o===void 0&&(o=r),this.data=t,this.length=this.data.length,this.compare=o,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)};n.prototype.push=function(t){this.data.push(t),this.length++,this._up(this.length-1)},n.prototype.pop=function(){if(this.length!==0){var t=this.data[0],o=this.data.pop();return this.length--,this.length>0&&(this.data[0]=o,this._down(0)),t}},n.prototype.peek=function(){return this.data[0]},n.prototype._up=function(t){for(var o=this,i=o.data,a=o.compare,s=i[t];t>0;){var l=t-1>>1,c=i[l];if(a(s,c)>=0)break;i[t]=c,t=l}i[t]=s},n.prototype._down=function(t){for(var o=this,i=o.data,a=o.compare,s=this.length>>1,l=i[t];t<s;){var c=(t<<1)+1,u=i[c],p=c+1;if(p<this.length&&a(i[p],u)<0&&(c=p,u=i[p]),a(u,l)>=0)break;i[t]=u,t=c}i[t]=l};function r(e,t){return e<t?-1:e>t?1:0}return n})});var $0=Nn((DW,Rp)=>{"use strict";var Jc=W0();Jc.default&&(Jc=Jc.default);Rp.exports=q0;Rp.exports.default=q0;function q0(n,r,e){r=r||1;for(var t,o,i,a,s=0;s<n[0].length;s++){var l=n[0][s];(!s||l[0]<t)&&(t=l[0]),(!s||l[1]<o)&&(o=l[1]),(!s||l[0]>i)&&(i=l[0]),(!s||l[1]>a)&&(a=l[1])}var c=i-t,u=a-o,p=Math.min(c,u),d=p/2;if(p===0){var h=[t,o];return h.distance=0,h}for(var f=new Jc(void 0,vM),m=t;m<i;m+=p)for(var y=o;y<a;y+=p)f.push(new un(m+d,y+d,d,n));var g=wM(n),v=new un(t+c/2,o+u/2,0,n);v.d>g.d&&(g=v);for(var O=f.length;f.length;){var P=f.pop();P.d>g.d&&(g=P,e&&console.log("found best %d after %d probes",Math.round(1e4*P.d)/1e4,O)),!(P.max-g.d<=r)&&(d=P.h/2,f.push(new un(P.x-d,P.y-d,d,n)),f.push(new un(P.x+d,P.y-d,d,n)),f.push(new un(P.x-d,P.y+d,d,n)),f.push(new un(P.x+d,P.y+d,d,n)),O+=4)}e&&(console.log("num probes: "+O),console.log("best distance: "+g.d));var S=[g.x,g.y];return S.distance=g.d,S}function vM(n,r){return r.max-n.max}function un(n,r,e,t){this.x=n,this.y=r,this.h=e,this.d=SM(n,r,t),this.max=this.d+this.h*Math.SQRT2}function SM(n,r,e){for(var t=!1,o=1/0,i=0;i<e.length;i++)for(var a=e[i],s=0,l=a.length,c=l-1;s<l;c=s++){var u=a[s],p=a[c];u[1]>r!=p[1]>r&&n<(p[0]-u[0])*(r-u[1])/(p[1]-u[1])+u[0]&&(t=!t),o=Math.min(o,PM(n,r,u,p))}return o===0?0:(t?1:-1)*Math.sqrt(o)}function wM(n){for(var r=0,e=0,t=0,o=n[0],i=0,a=o.length,s=a-1;i<a;s=i++){var l=o[i],c=o[s],u=l[0]*c[1]-c[0]*l[1];e+=(l[0]+c[0])*u,t+=(l[1]+c[1])*u,r+=u*3}return r===0?new un(o[0][0],o[0][1],0,n):new un(e/r,t/r,0,n)}function PM(n,r,e,t){var o=e[0],i=e[1],a=t[0]-o,s=t[1]-i;if(a!==0||s!==0){var l=((n-o)*a+(r-i)*s)/(a*a+s*s);l>1?(o=t[0],i=t[1]):l>0&&(o+=a*l,i+=s*l)}return a=n-o,s=r-i,a*a+s*s}});var Ov=Nn((gie,Pv)=>{"use strict";function cD(n,r){function e(){this.constructor=n}e.prototype=r.prototype,n.prototype=new e}function ii(n,r,e,t){this.message=n,this.expected=r,this.found=e,this.location=t,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,ii)}cD(ii,Error);ii.buildMessage=function(n,r){var e={literal:function(c){return'"'+o(c.text)+'"'},class:function(c){var u="",p;for(p=0;p<c.parts.length;p++)u+=c.parts[p]instanceof Array?i(c.parts[p][0])+"-"+i(c.parts[p][1]):i(c.parts[p]);return"["+(c.inverted?"^":"")+u+"]"},any:function(c){return"any character"},end:function(c){return"end of input"},other:function(c){return c.description}};function t(c){return c.charCodeAt(0).toString(16).toUpperCase()}function o(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+t(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+t(u)})}function i(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+t(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+t(u)})}function a(c){return e[c.type](c)}function s(c){var u=new Array(c.length),p,d;for(p=0;p<c.length;p++)u[p]=a(c[p]);if(u.sort(),u.length>0){for(p=1,d=1;p<u.length;p++)u[p-1]!==u[p]&&(u[d]=u[p],d++);u.length=d}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}function l(c){return c?'"'+o(c)+'"':"end of input"}return"Expected "+s(n)+" but "+l(r)+" found."};function uD(n,r){r=r!==void 0?r:{};var e={},t={svg_path:ps},o=ps,i=function(b){if(!b)return[];for(var w=[],L=0;L<b.length;L++)w=w.concat.apply(w,b[L]);var M=w[0];return M&&M.code=="m"&&(delete M.relative,M.code="M"),w},a=function(b,w){return KS(b,w)},s=/^[Mm]/,l=Ye(["M","m"],!1,!1),c=function(b,w,L){var M=di(b,[w]);return L&&(M=M.concat(di(b=="M"?"L":"l",L[1]))),M},u=/^[Zz]/,p=Ye(["Z","z"],!1,!1),d=function(){return di("Z")},h=/^[Ll]/,f=Ye(["L","l"],!1,!1),m=function(b,w){return di(b,w)},y=/^[Hh]/,g=Ye(["H","h"],!1,!1),v=function(b,w){return di(b,w.map(function(L){return{x:L}}))},O=/^[Vv]/,P=Ye(["V","v"],!1,!1),S=function(b,w){return di(b,w.map(function(L){return{y:L}}))},T=/^[Cc]/,I=Ye(["C","c"],!1,!1),x=function(b,w,L){return{x1:b.x,y1:b.y,x2:w.x,y2:w.y,x:L.x,y:L.y}},_=/^[Ss]/,D=Ye(["S","s"],!1,!1),A=function(b,w){return{x2:b.x,y2:b.y,x:w.x,y:w.y}},N=/^[Qq]/,E=Ye(["Q","q"],!1,!1),B=function(b,w){return{x1:b.x,y1:b.y,x:w.x,y:w.y}},V=/^[Tt]/,j=Ye(["T","t"],!1,!1),R=/^[Aa]/,W=Ye(["A","a"],!1,!1),F=function(b,w,L,M,z,oe){return{rx:b,ry:w,xAxisRotation:L,largeArc:M,sweep:z,x:oe.x,y:oe.y}},k=function(b,w){return{x:b,y:w}},H=function(b){return b*1},$=function(b){return b.join("")*1},J=/^[01]/,Z=Ye(["0","1"],!1,!1),X=function(b){return b=="1"},te=function(){return""},Y=",",ee=tt(",",!1),K=function(b){return b.join("")},q=".",ue=tt(".",!1),le=/^[eE]/,ne=Ye(["e","E"],!1,!1),ce=/^[+\-]/,ae=Ye(["+","-"],!1,!1),he=/^[0-9]/,pe=Ye([["0","9"]],!1,!1),fe=function(b){return b.join("")},ge=/^[ \t\n\r]/,me=Ye([" "," ",`
2
+ `,"\r"],!1,!1),C=0,ie=0,De=[{line:1,column:1}],Re=0,Ee=[],Pe=0,xt;if("startRule"in r){if(!(r.startRule in t))throw new Error(`Can't start parsing from rule "`+r.startRule+'".');o=t[r.startRule]}function Me(){return n.substring(ie,C)}function mt(){return An(ie,C)}function bt(b,w){throw w=w!==void 0?w:An(ie,C),hr([ud(b)],n.substring(ie,C),w)}function Tn(b,w){throw w=w!==void 0?w:An(ie,C),dd(b,w)}function tt(b,w){return{type:"literal",text:b,ignoreCase:w}}function Ye(b,w,L){return{type:"class",parts:b,inverted:w,ignoreCase:L}}function Ar(){return{type:"any"}}function cd(){return{type:"end"}}function ud(b){return{type:"other",description:b}}function bl(b){var w=De[b],L;if(w)return w;for(L=b-1;!De[L];)L--;for(w=De[L],w={line:w.line,column:w.column};L<b;)n.charCodeAt(L)===10?(w.line++,w.column=1):w.column++,L++;return De[b]=w,w}function An(b,w){var L=bl(b),M=bl(w);return{start:{offset:b,line:L.line,column:L.column},end:{offset:w,line:M.line,column:M.column}}}function st(b){C<Re||(C>Re&&(Re=C,Ee=[]),Ee.push(b))}function dd(b,w){return new ii(b,null,null,w)}function hr(b,w,L){return new ii(ii.buildMessage(b,w),b,w,L)}function ps(){var b,w,L,M,z;for(b=C,w=[],L=Ve();L!==e;)w.push(L),L=Ve();if(w!==e)if(L=jt(),L===e&&(L=null),L!==e){for(M=[],z=Ve();z!==e;)M.push(z),z=Ve();M!==e?(ie=b,w=i(L),b=w):(C=b,b=e)}else C=b,b=e;else C=b,b=e;return b}function jt(){var b,w,L,M,z,oe;if(b=C,w=Mn(),w!==e){for(L=[],M=C,z=[],oe=Ve();oe!==e;)z.push(oe),oe=Ve();for(z!==e?(oe=Mn(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;){for(L.push(M),M=C,z=[],oe=Ve();oe!==e;)z.push(oe),oe=Ve();z!==e?(oe=Mn(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e)}L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function Mn(){var b,w,L,M,z,oe;if(b=C,w=ci(),w!==e){for(L=[],M=C,z=[],oe=Ve();oe!==e;)z.push(oe),oe=Ve();for(z!==e?(oe=vl(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;){for(L.push(M),M=C,z=[],oe=Ve();oe!==e;)z.push(oe),oe=Ve();z!==e?(oe=vl(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e)}L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function vl(){var b;return b=LS(),b===e&&(b=RS(),b===e&&(b=VS(),b===e&&(b=zS(),b===e&&(b=GS(),b===e&&(b=FS(),b===e&&(b=kS(),b===e&&(b=WS(),b===e&&(b=$S())))))))),b}function ci(){var b,w,L,M,z,oe,pi;if(b=C,s.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&st(l)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=kt(),M!==e?(z=C,oe=Ze(),oe===e&&(oe=null),oe!==e?(pi=bh(),pi!==e?(oe=[oe,pi],z=oe):(C=z,z=e)):(C=z,z=e),z===e&&(z=null),z!==e?(ie=b,w=c(w,M,z),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function LS(){var b,w;return b=C,u.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&st(p)),w!==e&&(ie=b,w=d()),b=w,b}function RS(){var b,w,L,M;if(b=C,h.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&st(f)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=bh(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function bh(){var b,w,L,M,z,oe;if(b=C,w=kt(),w!==e){for(L=[],M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=kt(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=kt(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function VS(){var b,w,L,M;if(b=C,y.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&st(g)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=vh(),M!==e?(ie=b,w=v(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function vh(){var b,w,L,M,z,oe;if(b=C,w=ui(),w!==e){for(L=[],M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=ui(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=ui(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function zS(){var b,w,L,M;if(b=C,O.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&st(P)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=vh(),M!==e?(ie=b,w=S(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function GS(){var b,w,L,M;if(b=C,T.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&st(I)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=jS(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function jS(){var b,w,L,M,z,oe;if(b=C,w=pd(),w!==e){for(L=[],M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=pd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=pd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function pd(){var b,w,L,M,z,oe;return b=C,w=kt(),w!==e?(L=Ze(),L===e&&(L=null),L!==e?(M=kt(),M!==e?(z=Ze(),z===e&&(z=null),z!==e?(oe=kt(),oe!==e?(ie=b,w=x(w,M,oe),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function FS(){var b,w,L,M;if(b=C,_.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&st(D)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=US(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function US(){var b,w,L,M,z,oe;if(b=C,w=fd(),w!==e){for(L=[],M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=fd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=fd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function fd(){var b,w,L,M;return b=C,w=kt(),w!==e?(L=Ze(),L===e&&(L=null),L!==e?(M=kt(),M!==e?(ie=b,w=A(w,M),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function kS(){var b,w,L,M;if(b=C,N.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&st(E)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=HS(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function HS(){var b,w,L,M,z,oe;if(b=C,w=hd(),w!==e){for(L=[],M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=hd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=hd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function hd(){var b,w,L,M;return b=C,w=kt(),w!==e?(L=Ze(),L===e&&(L=null),L!==e?(M=kt(),M!==e?(ie=b,w=B(w,M),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function WS(){var b,w,L,M;if(b=C,V.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&st(j)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=qS(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function qS(){var b,w,L,M,z,oe;if(b=C,w=kt(),w!==e){for(L=[],M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=kt(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=kt(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function $S(){var b,w,L,M;if(b=C,R.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&st(W)),w!==e){for(L=[],M=Ve();M!==e;)L.push(M),M=Ve();L!==e?(M=YS(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function YS(){var b,w,L,M,z,oe;if(b=C,w=md(),w!==e){for(L=[],M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=md(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=Ze(),z===e&&(z=null),z!==e?(oe=md(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function md(){var b,w,L,M,z,oe,pi,gd,wl,xd,Pl,bd;return b=C,w=Sh(),w!==e?(L=Ze(),L===e&&(L=null),L!==e?(M=Sh(),M!==e?(z=Ze(),z===e&&(z=null),z!==e?(oe=ui(),oe!==e?(pi=Ze(),pi!==e?(gd=wh(),gd!==e?(wl=Ze(),wl===e&&(wl=null),wl!==e?(xd=wh(),xd!==e?(Pl=Ze(),Pl===e&&(Pl=null),Pl!==e?(bd=kt(),bd!==e?(ie=b,w=F(w,M,oe,gd,xd,bd),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function kt(){var b,w,L,M;return b=C,w=ui(),w!==e?(L=Ze(),L===e&&(L=null),L!==e?(M=ui(),M!==e?(ie=b,w=k(w,M),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function Sh(){var b,w;return b=C,w=Oh(),w===e&&(w=In()),w!==e&&(ie=b,w=H(w)),b=w,b}function ui(){var b,w,L,M;return b=C,w=C,L=yd(),L===e&&(L=null),L!==e?(M=Oh(),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e),w===e&&(w=C,L=yd(),L===e&&(L=null),L!==e?(M=In(),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e)),w!==e&&(ie=b,w=$(w)),b=w,b}function wh(){var b,w;return b=C,J.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&st(Z)),w!==e&&(ie=b,w=X(w)),b=w,b}function Ze(){var b,w,L,M,z;if(b=C,w=[],L=Ve(),L!==e)for(;L!==e;)w.push(L),L=Ve();else w=e;if(w!==e)if(L=Ph(),L===e&&(L=null),L!==e){for(M=[],z=Ve();z!==e;)M.push(z),z=Ve();M!==e?(w=[w,L,M],b=w):(C=b,b=e)}else C=b,b=e;else C=b,b=e;if(b===e){if(b=C,w=C,L=Ph(),L!==e){for(M=[],z=Ve();z!==e;)M.push(z),z=Ve();M!==e?(L=[L,M],w=L):(C=w,w=e)}else C=w,w=e;w!==e&&(ie=b,w=te()),b=w}return b}function Ph(){var b;return n.charCodeAt(C)===44?(b=Y,C++):(b=e,Pe===0&&st(ee)),b}function Oh(){var b,w,L,M;return b=C,w=C,L=XS(),L!==e?(M=Ch(),M===e&&(M=null),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e),w===e&&(w=C,L=In(),L!==e?(M=Ch(),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e)),w!==e&&(ie=b,w=K(w)),b=w,b}function XS(){var b,w,L,M,z;return b=C,w=C,L=In(),L===e&&(L=null),L!==e?(n.charCodeAt(C)===46?(M=q,C++):(M=e,Pe===0&&st(ue)),M!==e?(z=In(),z!==e?(L=[L,M,z],w=L):(C=w,w=e)):(C=w,w=e)):(C=w,w=e),w===e&&(w=C,L=In(),L!==e?(n.charCodeAt(C)===46?(M=q,C++):(M=e,Pe===0&&st(ue)),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e)),w!==e&&(ie=b,w=K(w)),b=w,b}function Ch(){var b,w,L,M,z;return b=C,w=C,le.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Pe===0&&st(ne)),L!==e?(M=yd(),M===e&&(M=null),M!==e?(z=In(),z!==e?(L=[L,M,z],w=L):(C=w,w=e)):(C=w,w=e)):(C=w,w=e),w!==e&&(ie=b,w=K(w)),b=w,b}function yd(){var b;return ce.test(n.charAt(C))?(b=n.charAt(C),C++):(b=e,Pe===0&&st(ae)),b}function In(){var b,w,L;if(b=C,w=[],he.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Pe===0&&st(pe)),L!==e)for(;L!==e;)w.push(L),he.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Pe===0&&st(pe));else w=e;return w!==e&&(ie=b,w=fe(w)),b=w,b}function Ve(){var b,w;return b=C,ge.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Pe===0&&st(me)),w!==e&&(ie=b,w=te()),b=w,b}function KS(b,w){if(!w)return[b];for(var L=[b],M=0,z=w.length;M<z;M++)L[M+1]=w[M][1];return L}var Sl={m:"moveto",l:"lineto",h:"horizontal lineto",v:"vertical lineto",c:"curveto",s:"smooth curveto",q:"quadratic curveto",t:"smooth quadratic curveto",a:"elliptical arc",z:"closepath"};for(var Th in Sl)Sl[Th.toUpperCase()]=Sl[Th];function di(b,w){w||(w=[{}]);for(var L=w.length;L--;){var M={code:b,command:Sl[b]};b==b.toLowerCase()&&(M.relative=!0);for(var z in w[L])M[z]=w[L][z];w[L]=M}return w}if(xt=o(),xt!==e&&C===n.length)return xt;throw xt!==e&&C<n.length&&st(cd()),hr(Ee,Re<n.length?n.charAt(Re):null,Re<n.length?An(Re,Re+1):An(Re,Re))}Pv.exports={SyntaxError:ii,parse:uD}});var oh=Nn((xie,Cv)=>{var qu=Ov().parse;qu.parseSVG=qu;qu.makeAbsolute=dD;Cv.exports=qu;function dD(n){var r,e={x:0,y:0},t={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return n.forEach(function(o){o.command==="moveto"&&(r=o),o.x0=e.x,o.y0=e.y;for(var i in t)i in o&&(o[i]+=o.relative?o[t[i]]:0);"x"in o||(o.x=e.x),"y"in o||(o.y=e.y),o.relative=!1,o.code=o.code.toUpperCase(),o.command=="closepath"&&(o.x=r.x,o.y=r.y),e=o}),n}});var DS=Nn((dpe,NS)=>{NS.exports=function(r,e){for(var t=r.split("."),o=e.split("."),i=0;i<3;i++){var a=Number(t[i]),s=Number(o[i]);if(a>s)return 1;if(s>a)return-1;if(!isNaN(a)&&isNaN(s))return 1;if(isNaN(a)&&!isNaN(s))return-1}return 0}});import{FileLoader as LE,Loader as RE}from"three";function Cl(n){for(let r of Object.keys(n))n[r]===void 0&&delete n[r];return n}function Ht(n,r){return Object.setPrototypeOf(n,r),n}function Tl(n){return Array.isArray(n)?n:[n]}function Al(n,r){let e=0;for(;e<n.length&&e<r.length;){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1;e+=1}return e!==r.length?-1:e!==n.length?1:0}var i1=typeof global=="object"&&global&&global.Object===Object&&global,Ml=i1;var a1=typeof self=="object"&&self&&self.Object===Object&&self,s1=Ml||a1||Function("return this")(),yt=s1;var l1=yt.Symbol,Tt=l1;var Ah=Object.prototype,c1=Ah.hasOwnProperty,u1=Ah.toString,fs=Tt?Tt.toStringTag:void 0;function d1(n){var r=c1.call(n,fs),e=n[fs];try{n[fs]=void 0;var t=!0}catch{}var o=u1.call(n);return t&&(r?n[fs]=e:delete n[fs]),o}var Mh=d1;var p1=Object.prototype,f1=p1.toString;function h1(n){return f1.call(n)}var Ih=h1;var m1="[object Null]",y1="[object Undefined]",Nh=Tt?Tt.toStringTag:void 0;function g1(n){return n==null?n===void 0?y1:m1:Nh&&Nh in Object(n)?Mh(n):Ih(n)}var ar=g1;function x1(n){return n!=null&&typeof n=="object"}var Bt=x1;var b1="[object Symbol]";function v1(n){return typeof n=="symbol"||Bt(n)&&ar(n)==b1}var hi=v1;function S1(n,r){for(var e=-1,t=n==null?0:n.length,o=Array(t);++e<t;)o[e]=r(n[e],e,n);return o}var Il=S1;var w1=Array.isArray,lt=w1;var P1=1/0,Dh=Tt?Tt.prototype:void 0,Eh=Dh?Dh.toString:void 0;function _h(n){if(typeof n=="string")return n;if(lt(n))return Il(n,_h)+"";if(hi(n))return Eh?Eh.call(n):"";var r=n+"";return r=="0"&&1/n==-P1?"-0":r}var Bh=_h;function O1(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}var sr=O1;function C1(n){return n}var Lh=C1;var T1="[object AsyncFunction]",A1="[object Function]",M1="[object GeneratorFunction]",I1="[object Proxy]";function N1(n){if(!sr(n))return!1;var r=ar(n);return r==A1||r==M1||r==T1||r==I1}var Nl=N1;var D1=yt["__core-js_shared__"],Dl=D1;var Rh=function(){var n=/[^.]+$/.exec(Dl&&Dl.keys&&Dl.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function E1(n){return!!Rh&&Rh in n}var Vh=E1;var _1=Function.prototype,B1=_1.toString;function L1(n){if(n!=null){try{return B1.call(n)}catch{}try{return n+""}catch{}}return""}var go=L1;var R1=/[\\^$.*+?()[\]{}|]/g,V1=/^\[object .+?Constructor\]$/,z1=Function.prototype,G1=Object.prototype,j1=z1.toString,F1=G1.hasOwnProperty,U1=RegExp("^"+j1.call(F1).replace(R1,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function k1(n){if(!sr(n)||Vh(n))return!1;var r=Nl(n)?U1:V1;return r.test(go(n))}var zh=k1;function H1(n,r){return n?.[r]}var Gh=H1;function W1(n,r){var e=Gh(n,r);return zh(e)?e:void 0}var Qt=W1;var q1=Qt(yt,"WeakMap"),El=q1;var jh=Object.create,$1=function(){function n(){}return function(r){if(!sr(r))return{};if(jh)return jh(r);n.prototype=r;var e=new n;return n.prototype=void 0,e}}(),Fh=$1;function Y1(n,r,e){switch(e.length){case 0:return n.call(r);case 1:return n.call(r,e[0]);case 2:return n.call(r,e[0],e[1]);case 3:return n.call(r,e[0],e[1],e[2])}return n.apply(r,e)}var Uh=Y1;function X1(n,r){var e=-1,t=n.length;for(r||(r=Array(t));++e<t;)r[e]=n[e];return r}var kh=X1;var K1=800,Q1=16,Z1=Date.now;function J1(n){var r=0,e=0;return function(){var t=Z1(),o=Q1-(t-e);if(e=t,o>0){if(++r>=K1)return arguments[0]}else r=0;return n.apply(void 0,arguments)}}var Hh=J1;function ew(n){return function(){return n}}var Wh=ew;var tw=function(){try{var n=Qt(Object,"defineProperty");return n({},"",{}),n}catch{}}(),mi=tw;var rw=mi?function(n,r){return mi(n,"toString",{configurable:!0,enumerable:!1,value:Wh(r),writable:!0})}:Lh,qh=rw;var ow=Hh(qh),$h=ow;function nw(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}var Yh=nw;var iw=9007199254740991,aw=/^(?:0|[1-9]\d*)$/;function sw(n,r){var e=typeof n;return r=r??iw,!!r&&(e=="number"||e!="symbol"&&aw.test(n))&&n>-1&&n%1==0&&n<r}var yi=sw;function lw(n,r,e){r=="__proto__"&&mi?mi(n,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[r]=e}var _l=lw;function cw(n,r){return n===r||n!==n&&r!==r}var gi=cw;var uw=Object.prototype,dw=uw.hasOwnProperty;function pw(n,r,e){var t=n[r];(!(dw.call(n,r)&&gi(t,e))||e===void 0&&!(r in n))&&_l(n,r,e)}var xi=pw;function fw(n,r,e,t){var o=!e;e||(e={});for(var i=-1,a=r.length;++i<a;){var s=r[i],l=t?t(e[s],n[s],s,e,n):void 0;l===void 0&&(l=n[s]),o?_l(e,s,l):xi(e,s,l)}return e}var Hr=fw;var Xh=Math.max;function hw(n,r,e){return r=Xh(r===void 0?n.length-1:r,0),function(){for(var t=arguments,o=-1,i=Xh(t.length-r,0),a=Array(i);++o<i;)a[o]=t[r+o];o=-1;for(var s=Array(r+1);++o<r;)s[o]=t[o];return s[r]=e(a),Uh(n,this,s)}}var Kh=hw;var mw=9007199254740991;function yw(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=mw}var bi=yw;function gw(n){return n!=null&&bi(n.length)&&!Nl(n)}var Bl=gw;var xw=Object.prototype;function bw(n){var r=n&&n.constructor,e=typeof r=="function"&&r.prototype||xw;return n===e}var vi=bw;function vw(n,r){for(var e=-1,t=Array(n);++e<n;)t[e]=r(e);return t}var Qh=vw;var Sw="[object Arguments]";function ww(n){return Bt(n)&&ar(n)==Sw}var vd=ww;var Zh=Object.prototype,Pw=Zh.hasOwnProperty,Ow=Zh.propertyIsEnumerable,Cw=vd(function(){return arguments}())?vd:function(n){return Bt(n)&&Pw.call(n,"callee")&&!Ow.call(n,"callee")},Si=Cw;function Tw(){return!1}var Jh=Tw;var rm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,em=rm&&typeof module=="object"&&module&&!module.nodeType&&module,Aw=em&&em.exports===rm,tm=Aw?yt.Buffer:void 0,Mw=tm?tm.isBuffer:void 0,Iw=Mw||Jh,En=Iw;var Nw="[object Arguments]",Dw="[object Array]",Ew="[object Boolean]",_w="[object Date]",Bw="[object Error]",Lw="[object Function]",Rw="[object Map]",Vw="[object Number]",zw="[object Object]",Gw="[object RegExp]",jw="[object Set]",Fw="[object String]",Uw="[object WeakMap]",kw="[object ArrayBuffer]",Hw="[object DataView]",Ww="[object Float32Array]",qw="[object Float64Array]",$w="[object Int8Array]",Yw="[object Int16Array]",Xw="[object Int32Array]",Kw="[object Uint8Array]",Qw="[object Uint8ClampedArray]",Zw="[object Uint16Array]",Jw="[object Uint32Array]",Je={};Je[Ww]=Je[qw]=Je[$w]=Je[Yw]=Je[Xw]=Je[Kw]=Je[Qw]=Je[Zw]=Je[Jw]=!0;Je[Nw]=Je[Dw]=Je[kw]=Je[Ew]=Je[Hw]=Je[_w]=Je[Bw]=Je[Lw]=Je[Rw]=Je[Vw]=Je[zw]=Je[Gw]=Je[jw]=Je[Fw]=Je[Uw]=!1;function e2(n){return Bt(n)&&bi(n.length)&&!!Je[ar(n)]}var om=e2;function t2(n){return function(r){return n(r)}}var wi=t2;var nm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,hs=nm&&typeof module=="object"&&module&&!module.nodeType&&module,r2=hs&&hs.exports===nm,Sd=r2&&Ml.process,o2=function(){try{var n=hs&&hs.require&&hs.require("util").types;return n||Sd&&Sd.binding&&Sd.binding("util")}catch{}}(),xo=o2;var im=xo&&xo.isTypedArray,n2=im?wi(im):om,Ll=n2;var i2=Object.prototype,a2=i2.hasOwnProperty;function s2(n,r){var e=lt(n),t=!e&&Si(n),o=!e&&!t&&En(n),i=!e&&!t&&!o&&Ll(n),a=e||t||o||i,s=a?Qh(n.length,String):[],l=s.length;for(var c in n)(r||a2.call(n,c))&&!(a&&(c=="length"||o&&(c=="offset"||c=="parent")||i&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||yi(c,l)))&&s.push(c);return s}var Rl=s2;function l2(n,r){return function(e){return n(r(e))}}var Vl=l2;var c2=Vl(Object.keys,Object),am=c2;var u2=Object.prototype,d2=u2.hasOwnProperty;function p2(n){if(!vi(n))return am(n);var r=[];for(var e in Object(n))d2.call(n,e)&&e!="constructor"&&r.push(e);return r}var sm=p2;function f2(n){return Bl(n)?Rl(n):sm(n)}var Pi=f2;function h2(n){var r=[];if(n!=null)for(var e in Object(n))r.push(e);return r}var lm=h2;var m2=Object.prototype,y2=m2.hasOwnProperty;function g2(n){if(!sr(n))return lm(n);var r=vi(n),e=[];for(var t in n)t=="constructor"&&(r||!y2.call(n,t))||e.push(t);return e}var cm=g2;function x2(n){return Bl(n)?Rl(n,!0):cm(n)}var Oi=x2;var b2=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,v2=/^\w*$/;function S2(n,r){if(lt(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||hi(n)?!0:v2.test(n)||!b2.test(n)||r!=null&&n in Object(r)}var um=S2;var w2=Qt(Object,"create"),bo=w2;function P2(){this.__data__=bo?bo(null):{},this.size=0}var dm=P2;function O2(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}var pm=O2;var C2="__lodash_hash_undefined__",T2=Object.prototype,A2=T2.hasOwnProperty;function M2(n){var r=this.__data__;if(bo){var e=r[n];return e===C2?void 0:e}return A2.call(r,n)?r[n]:void 0}var fm=M2;var I2=Object.prototype,N2=I2.hasOwnProperty;function D2(n){var r=this.__data__;return bo?r[n]!==void 0:N2.call(r,n)}var hm=D2;var E2="__lodash_hash_undefined__";function _2(n,r){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=bo&&r===void 0?E2:r,this}var mm=_2;function Ci(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}Ci.prototype.clear=dm;Ci.prototype.delete=pm;Ci.prototype.get=fm;Ci.prototype.has=hm;Ci.prototype.set=mm;var wd=Ci;function B2(){this.__data__=[],this.size=0}var ym=B2;function L2(n,r){for(var e=n.length;e--;)if(gi(n[e][0],r))return e;return-1}var Ho=L2;var R2=Array.prototype,V2=R2.splice;function z2(n){var r=this.__data__,e=Ho(r,n);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():V2.call(r,e,1),--this.size,!0}var gm=z2;function G2(n){var r=this.__data__,e=Ho(r,n);return e<0?void 0:r[e][1]}var xm=G2;function j2(n){return Ho(this.__data__,n)>-1}var bm=j2;function F2(n,r){var e=this.__data__,t=Ho(e,n);return t<0?(++this.size,e.push([n,r])):e[t][1]=r,this}var vm=F2;function Ti(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}Ti.prototype.clear=ym;Ti.prototype.delete=gm;Ti.prototype.get=xm;Ti.prototype.has=bm;Ti.prototype.set=vm;var Wo=Ti;var U2=Qt(yt,"Map"),qo=U2;function k2(){this.size=0,this.__data__={hash:new wd,map:new(qo||Wo),string:new wd}}var Sm=k2;function H2(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}var wm=H2;function W2(n,r){var e=n.__data__;return wm(r)?e[typeof r=="string"?"string":"hash"]:e.map}var $o=W2;function q2(n){var r=$o(this,n).delete(n);return this.size-=r?1:0,r}var Pm=q2;function $2(n){return $o(this,n).get(n)}var Om=$2;function Y2(n){return $o(this,n).has(n)}var Cm=Y2;function X2(n,r){var e=$o(this,n),t=e.size;return e.set(n,r),this.size+=e.size==t?0:1,this}var Tm=X2;function Ai(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}Ai.prototype.clear=Sm;Ai.prototype.delete=Pm;Ai.prototype.get=Om;Ai.prototype.has=Cm;Ai.prototype.set=Tm;var _n=Ai;var K2="Expected a function";function Pd(n,r){if(typeof n!="function"||r!=null&&typeof r!="function")throw new TypeError(K2);var e=function(){var t=arguments,o=r?r.apply(this,t):t[0],i=e.cache;if(i.has(o))return i.get(o);var a=n.apply(this,t);return e.cache=i.set(o,a)||i,a};return e.cache=new(Pd.Cache||_n),e}Pd.Cache=_n;var Am=Pd;var Q2=500;function Z2(n){var r=Am(n,function(t){return e.size===Q2&&e.clear(),t}),e=r.cache;return r}var Mm=Z2;var J2=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,eP=/\\(\\)?/g,tP=Mm(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(J2,function(e,t,o,i){r.push(o?i.replace(eP,"$1"):t||e)}),r}),Im=tP;function rP(n){return n==null?"":Bh(n)}var Nm=rP;function oP(n,r){return lt(n)?n:um(n,r)?[n]:Im(Nm(n))}var mr=oP;var nP=1/0;function iP(n){if(typeof n=="string"||hi(n))return n;var r=n+"";return r=="0"&&1/n==-nP?"-0":r}var Yo=iP;function aP(n,r){r=mr(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[Yo(r[e++])];return e&&e==t?n:void 0}var zl=aP;function sP(n,r){for(var e=-1,t=r.length,o=n.length;++e<t;)n[o+e]=r[e];return n}var Mi=sP;var Dm=Tt?Tt.isConcatSpreadable:void 0;function lP(n){return lt(n)||Si(n)||!!(Dm&&n&&n[Dm])}var Em=lP;function _m(n,r,e,t,o){var i=-1,a=n.length;for(e||(e=Em),o||(o=[]);++i<a;){var s=n[i];r>0&&e(s)?r>1?_m(s,r-1,e,t,o):Mi(o,s):t||(o[o.length]=s)}return o}var Bm=_m;function cP(n){var r=n==null?0:n.length;return r?Bm(n,1):[]}var Lm=cP;function uP(n){return $h(Kh(n,void 0,Lm),n+"")}var Gl=uP;var dP=Vl(Object.getPrototypeOf,Object),Ii=dP;var pP="[object Object]",fP=Function.prototype,hP=Object.prototype,Rm=fP.toString,mP=hP.hasOwnProperty,yP=Rm.call(Object);function gP(n){if(!Bt(n)||ar(n)!=pP)return!1;var r=Ii(n);if(r===null)return!0;var e=mP.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&Rm.call(e)==yP}var Vm=gP;function xP(n,r,e){var t=-1,o=n.length;r<0&&(r=-r>o?0:o+r),e=e>o?o:e,e<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var i=Array(o);++t<o;)i[t]=n[t+r];return i}var zm=xP;function bP(){this.__data__=new Wo,this.size=0}var Gm=bP;function vP(n){var r=this.__data__,e=r.delete(n);return this.size=r.size,e}var jm=vP;function SP(n){return this.__data__.get(n)}var Fm=SP;function wP(n){return this.__data__.has(n)}var Um=wP;var PP=200;function OP(n,r){var e=this.__data__;if(e instanceof Wo){var t=e.__data__;if(!qo||t.length<PP-1)return t.push([n,r]),this.size=++e.size,this;e=this.__data__=new _n(t)}return e.set(n,r),this.size=e.size,this}var km=OP;function Ni(n){var r=this.__data__=new Wo(n);this.size=r.size}Ni.prototype.clear=Gm;Ni.prototype.delete=jm;Ni.prototype.get=Fm;Ni.prototype.has=Um;Ni.prototype.set=km;var Di=Ni;function CP(n,r){return n&&Hr(r,Pi(r),n)}var Hm=CP;function TP(n,r){return n&&Hr(r,Oi(r),n)}var Wm=TP;var Xm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,qm=Xm&&typeof module=="object"&&module&&!module.nodeType&&module,AP=qm&&qm.exports===Xm,$m=AP?yt.Buffer:void 0,Ym=$m?$m.allocUnsafe:void 0;function MP(n,r){if(r)return n.slice();var e=n.length,t=Ym?Ym(e):new n.constructor(e);return n.copy(t),t}var Km=MP;function IP(n,r){for(var e=-1,t=n==null?0:n.length,o=0,i=[];++e<t;){var a=n[e];r(a,e,n)&&(i[o++]=a)}return i}var Qm=IP;function NP(){return[]}var jl=NP;var DP=Object.prototype,EP=DP.propertyIsEnumerable,Zm=Object.getOwnPropertySymbols,_P=Zm?function(n){return n==null?[]:(n=Object(n),Qm(Zm(n),function(r){return EP.call(n,r)}))}:jl,Ei=_P;function BP(n,r){return Hr(n,Ei(n),r)}var Jm=BP;var LP=Object.getOwnPropertySymbols,RP=LP?function(n){for(var r=[];n;)Mi(r,Ei(n)),n=Ii(n);return r}:jl,Fl=RP;function VP(n,r){return Hr(n,Fl(n),r)}var ey=VP;function zP(n,r,e){var t=r(n);return lt(n)?t:Mi(t,e(n))}var Ul=zP;function GP(n){return Ul(n,Pi,Ei)}var ms=GP;function jP(n){return Ul(n,Oi,Fl)}var kl=jP;var FP=Qt(yt,"DataView"),Hl=FP;var UP=Qt(yt,"Promise"),Wl=UP;var kP=Qt(yt,"Set"),ql=kP;var ty="[object Map]",HP="[object Object]",ry="[object Promise]",oy="[object Set]",ny="[object WeakMap]",iy="[object DataView]",WP=go(Hl),qP=go(qo),$P=go(Wl),YP=go(ql),XP=go(El),Bn=ar;(Hl&&Bn(new Hl(new ArrayBuffer(1)))!=iy||qo&&Bn(new qo)!=ty||Wl&&Bn(Wl.resolve())!=ry||ql&&Bn(new ql)!=oy||El&&Bn(new El)!=ny)&&(Bn=function(n){var r=ar(n),e=r==HP?n.constructor:void 0,t=e?go(e):"";if(t)switch(t){case WP:return iy;case qP:return ty;case $P:return ry;case YP:return oy;case XP:return ny}return r});var vo=Bn;var KP=Object.prototype,QP=KP.hasOwnProperty;function ZP(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&QP.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var ay=ZP;var JP=yt.Uint8Array,_i=JP;function eO(n){var r=new n.constructor(n.byteLength);return new _i(r).set(new _i(n)),r}var Bi=eO;function tO(n,r){var e=r?Bi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var sy=tO;var rO=/\w*$/;function oO(n){var r=new n.constructor(n.source,rO.exec(n));return r.lastIndex=n.lastIndex,r}var ly=oO;var cy=Tt?Tt.prototype:void 0,uy=cy?cy.valueOf:void 0;function nO(n){return uy?Object(uy.call(n)):{}}var dy=nO;function iO(n,r){var e=r?Bi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var py=iO;var aO="[object Boolean]",sO="[object Date]",lO="[object Map]",cO="[object Number]",uO="[object RegExp]",dO="[object Set]",pO="[object String]",fO="[object Symbol]",hO="[object ArrayBuffer]",mO="[object DataView]",yO="[object Float32Array]",gO="[object Float64Array]",xO="[object Int8Array]",bO="[object Int16Array]",vO="[object Int32Array]",SO="[object Uint8Array]",wO="[object Uint8ClampedArray]",PO="[object Uint16Array]",OO="[object Uint32Array]";function CO(n,r,e){var t=n.constructor;switch(r){case hO:return Bi(n);case aO:case sO:return new t(+n);case mO:return sy(n,e);case yO:case gO:case xO:case bO:case vO:case SO:case wO:case PO:case OO:return py(n,e);case lO:return new t;case cO:case pO:return new t(n);case uO:return ly(n);case dO:return new t;case fO:return dy(n)}}var fy=CO;function TO(n){return typeof n.constructor=="function"&&!vi(n)?Fh(Ii(n)):{}}var hy=TO;var AO="[object Map]";function MO(n){return Bt(n)&&vo(n)==AO}var my=MO;var yy=xo&&xo.isMap,IO=yy?wi(yy):my,gy=IO;var NO="[object Set]";function DO(n){return Bt(n)&&vo(n)==NO}var xy=DO;var by=xo&&xo.isSet,EO=by?wi(by):xy,vy=EO;var _O=1,BO=2,LO=4,Sy="[object Arguments]",RO="[object Array]",VO="[object Boolean]",zO="[object Date]",GO="[object Error]",wy="[object Function]",jO="[object GeneratorFunction]",FO="[object Map]",UO="[object Number]",Py="[object Object]",kO="[object RegExp]",HO="[object Set]",WO="[object String]",qO="[object Symbol]",$O="[object WeakMap]",YO="[object ArrayBuffer]",XO="[object DataView]",KO="[object Float32Array]",QO="[object Float64Array]",ZO="[object Int8Array]",JO="[object Int16Array]",eC="[object Int32Array]",tC="[object Uint8Array]",rC="[object Uint8ClampedArray]",oC="[object Uint16Array]",nC="[object Uint32Array]",Qe={};Qe[Sy]=Qe[RO]=Qe[YO]=Qe[XO]=Qe[VO]=Qe[zO]=Qe[KO]=Qe[QO]=Qe[ZO]=Qe[JO]=Qe[eC]=Qe[FO]=Qe[UO]=Qe[Py]=Qe[kO]=Qe[HO]=Qe[WO]=Qe[qO]=Qe[tC]=Qe[rC]=Qe[oC]=Qe[nC]=!0;Qe[GO]=Qe[wy]=Qe[$O]=!1;function $l(n,r,e,t,o,i){var a,s=r&_O,l=r&BO,c=r&LO;if(e&&(a=o?e(n,t,o,i):e(n)),a!==void 0)return a;if(!sr(n))return n;var u=lt(n);if(u){if(a=ay(n),!s)return kh(n,a)}else{var p=vo(n),d=p==wy||p==jO;if(En(n))return Km(n,s);if(p==Py||p==Sy||d&&!o){if(a=l||d?{}:hy(n),!s)return l?ey(n,Wm(a,n)):Jm(n,Hm(a,n))}else{if(!Qe[p])return o?n:{};a=fy(n,p,s)}}i||(i=new Di);var h=i.get(n);if(h)return h;i.set(n,a),vy(n)?n.forEach(function(y){a.add($l(y,r,e,y,n,i))}):gy(n)&&n.forEach(function(y,g){a.set(g,$l(y,r,e,g,n,i))});var f=c?l?kl:ms:l?Oi:Pi,m=u?void 0:f(n);return Yh(m||n,function(y,g){m&&(g=y,y=n[g]),xi(a,g,$l(y,r,e,g,n,i))}),a}var Yl=$l;var iC=1,aC=4;function sC(n){return Yl(n,iC|aC)}var So=sC;var lC="__lodash_hash_undefined__";function cC(n){return this.__data__.set(n,lC),this}var Oy=cC;function uC(n){return this.__data__.has(n)}var Cy=uC;function Xl(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new _n;++r<e;)this.add(n[r])}Xl.prototype.add=Xl.prototype.push=Oy;Xl.prototype.has=Cy;var Ty=Xl;function dC(n,r){for(var e=-1,t=n==null?0:n.length;++e<t;)if(r(n[e],e,n))return!0;return!1}var Ay=dC;function pC(n,r){return n.has(r)}var My=pC;var fC=1,hC=2;function mC(n,r,e,t,o,i){var a=e&fC,s=n.length,l=r.length;if(s!=l&&!(a&&l>s))return!1;var c=i.get(n),u=i.get(r);if(c&&u)return c==r&&u==n;var p=-1,d=!0,h=e&hC?new Ty:void 0;for(i.set(n,r),i.set(r,n);++p<s;){var f=n[p],m=r[p];if(t)var y=a?t(m,f,p,r,n,i):t(f,m,p,n,r,i);if(y!==void 0){if(y)continue;d=!1;break}if(h){if(!Ay(r,function(g,v){if(!My(h,v)&&(f===g||o(f,g,e,t,i)))return h.push(v)})){d=!1;break}}else if(!(f===m||o(f,m,e,t,i))){d=!1;break}}return i.delete(n),i.delete(r),d}var Kl=mC;function yC(n){var r=-1,e=Array(n.size);return n.forEach(function(t,o){e[++r]=[o,t]}),e}var Iy=yC;function gC(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Ny=gC;var xC=1,bC=2,vC="[object Boolean]",SC="[object Date]",wC="[object Error]",PC="[object Map]",OC="[object Number]",CC="[object RegExp]",TC="[object Set]",AC="[object String]",MC="[object Symbol]",IC="[object ArrayBuffer]",NC="[object DataView]",Dy=Tt?Tt.prototype:void 0,Od=Dy?Dy.valueOf:void 0;function DC(n,r,e,t,o,i,a){switch(e){case NC:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case IC:return!(n.byteLength!=r.byteLength||!i(new _i(n),new _i(r)));case vC:case SC:case OC:return gi(+n,+r);case wC:return n.name==r.name&&n.message==r.message;case CC:case AC:return n==r+"";case PC:var s=Iy;case TC:var l=t&xC;if(s||(s=Ny),n.size!=r.size&&!l)return!1;var c=a.get(n);if(c)return c==r;t|=bC,a.set(n,r);var u=Kl(s(n),s(r),t,o,i,a);return a.delete(n),u;case MC:if(Od)return Od.call(n)==Od.call(r)}return!1}var Ey=DC;var EC=1,_C=Object.prototype,BC=_C.hasOwnProperty;function LC(n,r,e,t,o,i){var a=e&EC,s=ms(n),l=s.length,c=ms(r),u=c.length;if(l!=u&&!a)return!1;for(var p=l;p--;){var d=s[p];if(!(a?d in r:BC.call(r,d)))return!1}var h=i.get(n),f=i.get(r);if(h&&f)return h==r&&f==n;var m=!0;i.set(n,r),i.set(r,n);for(var y=a;++p<l;){d=s[p];var g=n[d],v=r[d];if(t)var O=a?t(v,g,d,r,n,i):t(g,v,d,n,r,i);if(!(O===void 0?g===v||o(g,v,e,t,i):O)){m=!1;break}y||(y=d=="constructor")}if(m&&!y){var P=n.constructor,S=r.constructor;P!=S&&"constructor"in n&&"constructor"in r&&!(typeof P=="function"&&P instanceof P&&typeof S=="function"&&S instanceof S)&&(m=!1)}return i.delete(n),i.delete(r),m}var _y=LC;var RC=1,By="[object Arguments]",Ly="[object Array]",Ql="[object Object]",VC=Object.prototype,Ry=VC.hasOwnProperty;function zC(n,r,e,t,o,i){var a=lt(n),s=lt(r),l=a?Ly:vo(n),c=s?Ly:vo(r);l=l==By?Ql:l,c=c==By?Ql:c;var u=l==Ql,p=c==Ql,d=l==c;if(d&&En(n)){if(!En(r))return!1;a=!0,u=!1}if(d&&!u)return i||(i=new Di),a||Ll(n)?Kl(n,r,e,t,o,i):Ey(n,r,l,e,t,o,i);if(!(e&RC)){var h=u&&Ry.call(n,"__wrapped__"),f=p&&Ry.call(r,"__wrapped__");if(h||f){var m=h?n.value():n,y=f?r.value():r;return i||(i=new Di),o(m,y,e,t,i)}}return d?(i||(i=new Di),_y(n,r,e,t,o,i)):!1}var Vy=zC;function zy(n,r,e,t,o){return n===r?!0:n==null||r==null||!Bt(n)&&!Bt(r)?n!==n&&r!==r:Vy(n,r,e,t,zy,o)}var Gy=zy;function GC(n,r){return n!=null&&r in Object(n)}var jy=GC;function jC(n,r,e){r=mr(r,n);for(var t=-1,o=r.length,i=!1;++t<o;){var a=Yo(r[t]);if(!(i=n!=null&&e(n,a)))break;n=n[a]}return i||++t!=o?i:(o=n==null?0:n.length,!!o&&bi(o)&&yi(a,o)&&(lt(n)||Si(n)))}var Fy=jC;function FC(n,r){return n!=null&&Fy(n,r,jy)}var Uy=FC;function UC(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}var ky=UC;function kC(n,r){return r.length<2?n:zl(n,zm(r,0,-1))}var Hy=kC;function HC(n,r){return Gy(n,r)}var Cd=HC;function WC(n,r){return r=mr(r,n),n=Hy(n,r),n==null||delete n[Yo(ky(r))]}var Wy=WC;function qC(n){return Vm(n)?void 0:n}var qy=qC;var $C=1,YC=2,XC=4,KC=Gl(function(n,r){var e={};if(n==null)return e;var t=!1;r=Il(r,function(i){return i=mr(i,n),t||(t=i.length>1),i}),Hr(n,kl(n),e),t&&(e=Yl(e,$C|YC|XC,qy));for(var o=r.length;o--;)Wy(e,r[o]);return e}),Li=KC;function QC(n,r,e,t){if(!sr(n))return n;r=mr(r,n);for(var o=-1,i=r.length,a=i-1,s=n;s!=null&&++o<i;){var l=Yo(r[o]),c=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return n;if(o!=a){var u=s[l];c=t?t(u,l,s):void 0,c===void 0&&(c=sr(u)?u:yi(r[o+1])?[]:{})}xi(s,l,c),s=s[l]}return n}var $y=QC;function ZC(n,r,e){for(var t=-1,o=r.length,i={};++t<o;){var a=r[t],s=zl(n,a);e(s,a)&&$y(i,mr(a,n),s)}return i}var Yy=ZC;function JC(n,r){return Yy(n,r,function(e,t){return Uy(n,t)})}var Xy=JC;var eT=Gl(function(n,r){return n==null?{}:Xy(n,r)}),Mr=eT;var xe=class{modifyById(r,e){let t=this;if(t[r]===void 0)throw new Error("not expected");{let i={...t,[r]:e};return Object.setPrototypeOf(i,xe.prototype),i}}add(r,e){return this.runOp({type:1,id:r,data:e})?.data??this}runOp(r){let e=this;if(r.type===1){let t=e[r.id],o;t===void 0?o={type:2,id:r.id}:o={type:1,id:r.id,data:t};let{id:i,data:a}=r,s={...e,[i]:a};return Object.setPrototypeOf(s,xe.prototype),{data:s,actual:r,reverse:o}}else if(r.type===2){let{id:t}=r,o=e[t];if(o===void 0)return null;{let i={...e};return Object.setPrototypeOf(i,xe.prototype),delete i[t],{data:i,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function ys(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let r=Object.getOwnPropertyNames(n);for(let e of r){let t=n[e];t&&typeof t=="object"&&ys(t)}return Object.freeze(n)}function Ky(n,r){let e=0;for(;e<n.length&&e<r.length;){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1;e+=1}return e!==r.length?-1:e!==n.length?1:0}var Ri=class extends Error{};function Zl(n){let r={...n};return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function Wr(n,r,e){if(n===void 0?r===void 0?(n=0,r=10):n=r-10:r===void 0&&(r=n+10),n>r){let i=n;n=r,r=i}let t=[],o=1/(e+1);for(let i=0;i<e;i++){let a=n+(r-n)*(i+.75+Math.random()*.5)*o;t.push(a)}return t}function Vi(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 Qy(){return typeof process<"u"}function Zy(n,r){for(let e of n)r(e.id,e.data)!==!0&&Zy(e.children,r)}function Jy(n,r){if(r(n.id,n.data)!==!0)for(let e of n.children)Jy(e,r)}var Xe=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Xe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ys(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);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)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let o=this.parent(e);if(o===t)return!0;e=o}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let o=this.parent(e);if(o===t)return!0;e=o}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let o=this.get(e);o&&Jy(o,t)}}traverse(e){Zy(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 i=this.parent(e),a=this.childrenArray(i),s=a.findIndex(u=>u.id===e);if(s<0)throw new Error("not expected");let l=a[s];return a=[...a],a[s]={...l,data:t},this.modifyArrayBy(i,a)}}modifyArrayBy(e,t){let o=e,i=t;for(;o!==null;){let s=i,l=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let c=i.findIndex(u=>u.id===l);if(c<0)throw new Error;i=[...i],i[c]={...i[c],children:s}}Object.setPrototypeOf(i,Xe.prototype);let a=i;return a.fillCaches(),a}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let o of t)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:t,fi:o,id:i,data:a,children:s}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=t,c=this.childrenArray(l),u={fi:o,id:i,data:a,children:s};return c=[...c,u],c.sort((d,h)=>d.fi-h.fi),e.localIndex=c.indexOf(u),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:i}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let o=this.parent(t);if(o===void 0)return null;let i=this.childrenArray(o),a=i.findIndex(c=>c.id===t);e.localIndex=a,i=[...i];let s=i.splice(a,1)[0];return{data:this.modifyArrayBy(o,i),actual:e,reverse:{type:7,...s,parent:o}}}}moveOp(e){let{parent:t,fi:o,id:i}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:i});if(t!==null){let h=t;for(;h!==null;){if(h===void 0)throw new Error;if(h===i)throw new Ri("cyclic tree");h=this.parent(h)}}let a=this.parent(i);if(a===void 0)return null;let s=a,l=this.childrenArray(a),c=l.findIndex(h=>h.id===i);l=[...l];let u=l.splice(c,1)[0],p=this.modifyArrayBy(a,l);a=t,l=p.childrenArray(a);let d=u.fi;return u={...u,fi:o},l=[...l,u],l.sort((h,f)=>h.fi-f.fi),e.localIndex=l.indexOf(u),p=p.modifyArrayBy(a,l),{data:p,actual:e,reverse:{type:9,parent:s,fi:d,id:i}}}previous(e,t){if(t===null){let i=this.childrenArray(e);return i.length===0?null:i[i.length-1].id}let o=null;for(let i of this.childrenArray(e)){if(i.id===t)return o;o=i.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let o=this.childrenArray(t),i=o.findIndex(a=>a.id===e)+1;if(i<o.length)return o[i].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 o=this.childrenArray(t),i=o.findIndex(a=>a.id===e)-1;return i>=0?this.traverseSortPrevious(o[i].id):t}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push({...o,...i})}t.sort((o,i)=>Ky(o.sortKey,i.sortKey));for(let o of t)delete o.sortKey;return t}getWithSortKey(e){var t=e;let o=[],i=this.get(t),a=i;if(i!==void 0){for(;t;)o.splice(0,0,i.fi),t=this.parent(t),t!==null&&(i=this.get(t));return{...a,sortKey:o}}}insertBeforeHelper(e,t,o){return this.insertAfterHelper(e,this.previous(e,t),o)}insertAfterHelper(e,t,o){let i=this.childrenArray(e);if(t===null){if(i.length===0)return Wr(0,o,o);{let a=i[0].fi;return Wr(a-o,a,o)}}else{let a=this.get(t);if(a===void 0||this.parent(t)!==e)throw new Error("illegal args");let s=i.find(l=>l.fi>a.fi);if(s===void 0){let l=i[i.length-1].fi;return Wr(l,l+o,o)}else return Wr(a.fi,s.fi,o)}}};var zi;(r=>{function n(e,t){if(t.type!==0)return null;if(Array.isArray(e)){let o=t.props,i={},a=[...e],s=!1;if(o)for(let l of Object.keys(o)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");i[l]=a[c],a[c]=o[l],s=!0}return s?{data:a,actual:t,reverse:{type:0,props:i}}:null}else{let o=t.props,i={},a={...e},s=!1;if(o)for(let l of Object.keys(o)){i[l]=a[l];let c=o[l];c===void 0?delete a[l]:a[l]=c,s=!0}return s?{data:a,actual:t,reverse:{type:0,props:i}}:null}}r.runOp=n})(zi||(zi={}));var ve=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ve.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ys(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){return this.get(e)?.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 i=this,a=i.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let s=i[a];return i=[...i],i[a]={...s,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,ve.prototype);let t=e;return Qy()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:o,data:i}=e,a=this,s={fi:t,id:o,data:i};return a=[...a,s],a.sort((c,u)=>c.fi-u.fi),e.localIndex=a.indexOf(s),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:o}}}deleteOp(e){let{id:t}=e,o=this,i=o.findIndex(l=>l.id===t);if(i===-1)return null;e.localIndex=i,o=[...o];let a=o.splice(i,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:t,id:o}=e,i=this;i=[...i];let a=i.findIndex(u=>u.id===o);if(a===-1)return null;let s=i[a].fi,l={...i[a],fi:t};return i[a]=l,i.sort((u,p)=>u.fi-p.fi),e.localIndex=i.indexOf(l),{data:this.modifyArrayBy(i),actual:e,reverse:{type:6,fi:s,id:o}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let o of this){if(o.id===e)return t;t=o.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let o=this;if(e===null){if(o.length===0)return Wr(0,t,t);{let i=o[0].fi;return Wr(i-t,i,t)}}else{let i=this.get(e);if(i===void 0)throw new Error("illegal args");let a=o.find(s=>s.fi>i.fi);if(a===void 0){let s=o[o.length-1].fi;return Wr(s,s+t,t)}else return Wr(i.fi,a.fi,t)}}};function Gi(n){return n&&typeof n=="object"&&n instanceof Ke}var Ke=class{unusedFunOverridesTable(r){}runOp(r){let e=[],t=this,o=0,i={};for(;o<r.path.length;){if(e.push(t),t=t===void 0?void 0:t[r.path[o]],t!==void 0&&!Gi(t))return null;o+=1}t=t?Zl(t):new Ke;for(let[l,c]of Object.entries(r.props)){let u=t[l];i[l]=u,c===void 0?delete t[l]:t[l]=c}for(;o>0;){if(Object.keys(t).length===0){let l=e[o-1];l&&(t=Zl(l),delete t[r.path[o-1]])}else{let l=e[o-1];if(l){let c=Zl(l);c[r.path[o-1]]=t,t=c}else{let c=new Ke;c[r.path[o-1]]=t,t=c}}o-=1}let a=Object.setPrototypeOf(t,Ke.prototype),s={...r,props:i};return{data:a,actual:r,reverse:s}}},qr;(t=>{function n(o,i){return gs(o,i)??o}t.apply=n;function r(o,i){return Ad(o,i)}t.merge=r;function e(o,i){let a=0,s=i.path,l=o;for(;a<s.length&&l!==void 0;){if(l=rt.zoomOnce(l,s[a]),l===void 0)return i;if(!Gi(l))return;a+=1}if(l===void 0)return i;if(!!Gi(l))if(i.type===0){let c={...i.props};for(let u of Object.keys(l))delete c[u];return{...i,props:c}}else if(i.type===1||i.type===4||i.type===7){let c=Td([i],l);return c?(console.log(c),c):i}else return i}t.filterOp=e})(qr||(qr={}));function Td(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,a=gs(o.data,r[i]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=Td(o.children,r);return s!==void 0?e=!0:s=o.children,{...o,id:i,data:a,children:s}}else return{...o,id:i,data:a}});if(e)return t}function tT(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,a=gs(o.data,r[i]);return e=e||a!==void 0,a===void 0&&(a=o.data),{...o,id:i,data:a}});if(e)return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function gs(n,r){if(!Gi(r))return r;if(n instanceof Xe){let e=Td(n,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof ve)return tT(n,r);if(Array.isArray(n)){let e=!1,t=n.map((o,i)=>{let a=gs(o,r[i]);return e=e||a!==void 0,a===void 0&&(a=o),a});return e?(Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t):void 0}else{if(n instanceof Ke)return Ad(n,r);if(n&&typeof n=="object"){let e={},t=!1;for(let[o,i]of Object.entries(n)){let a=gs(i,r[o]);t=t||a!==void 0,a===void 0&&(a=i),e[o]=a}return t?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function Ad(n,r){if(n===void 0)return r;if(r===void 0)return n;if(!Gi(r))return r;if(!Gi(n))return qr.apply(n,r);let e=new Set;for(let o of Object.keys(n))e.add(o);for(let o of Object.keys(r))e.add(o);let t=new Ke;for(let o of e){let i=Ad(n===void 0?void 0:n[o],r===void 0?void 0:r[o]);t[o]=i}return t}function eg(n,r){let e={cur:[],result:[],len:0};return n=xs(n,r,e)??n,[n,e.result]}function Jl(n,r){return n===null?null:(n.cur[n.len]=r,n.len+=1,n)}function ec(n){n&&(n.len-=1)}function rT(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function tg(n,r,e){let t=!1,o=n.map(i=>{let a=i.id,s=r[a];if(s!==void 0&&typeof s=="string"&&(t=!0,a=s,e!==null))throw new Error("not supported");let l=xs(i.data,r,Jl(e,a));ec(e),t=t||l!==void 0,l===void 0&&(l=i.data);let c=tg(i.children,r,e);return c!==void 0?t=!0:c=i.children,{...i,id:a,data:l,children:c}});if(t)return o}function oT(n,r,e){let t=!1,o=n.map(i=>{let a=i.id,s=r[a];if(s!==void 0&&typeof s=="string"&&(t=!0,a=s,e!==null))throw new Error("not supported");let l=xs(i.data,r,Jl(e,a));return ec(e),t=t||l!==void 0,l===void 0&&(l=i.data),{...i,id:a,data:l}});if(t)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}function xs(n,r,e){if(n instanceof Xe){let t=tg(n,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else{if(n instanceof ve)return oT(n,r,e);if(Array.isArray(n)){let t=!1,o=n.map((i,a)=>{let s=xs(i,r,Jl(e,a));return ec(e),t=t||s!==void 0,s===void 0&&(s=i),s});return t?(Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o):void 0}else if(n&&typeof n=="object"&&!Vi(n)){let t={},o=!1;for(let[i,a]of Object.entries(n))if(i!=="name"){let s=r[i];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,i=s}let l=xs(a,r,Jl(e,i));ec(e),o=o||l!==void 0,l===void 0&&(l=a),t[i]=l}else t[i]=a;return o?(Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t):void 0}else if(typeof n=="string"){let t=r[n];return t!==void 0&&rT(e),t}else return}}var ji;(r=>{function n(e,t){let o=rt.zoom(t,e.path);if(typeof o=="object"){let i={};for(let a of Object.keys(e.props))i[a]=o[a];return{...e,props:i}}else return{...e,props:{}}}r.replaceProps=n})(ji||(ji={}));var ot;(s=>{function n(l,c){return{...l,path:l.path.slice(c)}}s.drop=n;function r(l,c){return e(l,c)?.data??l}s.applySimple=r;function e(l,c){let u=c.path;for(var p=[];;){let d;if(l instanceof Ke&&c.type===0&&(d=l.runOp({...c,path:u.slice(p.length)}),d===null&&(d=void 0)),d===void 0&&p.length===u.length&&(l instanceof Xe||l instanceof ve||l instanceof xe?d=l.runOp(c):d=zi.runOp(l,c)),d!==void 0)if(d!==null){let m=d.data;for(let y=p.length-1;y>=0;y--){let g=u[y],v=p[y];if(v instanceof Xe){if(typeof g=="number")throw new Error("illegal arg");m=v.modifyById(g,m)}else if(v instanceof ve){if(typeof g=="number")throw new Error("illegal arg");m=v.modifyById(g,m)}else if(v instanceof xe){if(typeof g=="number")throw new Error("illegal arg");m=v.modifyById(g,m)}else if(v instanceof Ke){let O={...v,[g]:m};m=Object.setPrototypeOf(O,Ke.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let O=m;m=[...v],m[g]=O}else m={...v,[g]:m};else return null}return{data:m,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let h=u[p.length],f;if(l instanceof Xe){if(typeof h=="number")throw new Error("");f=l.get(h)?.data}else if(l instanceof ve){if(typeof h=="number")throw new Error("");f=l.get(h)?.data}else l!==null&&(f=l[h]);if(f!==void 0)p.push(l),l=f;else return null}}s.apply=e;function t(l,c){for(let u=0;u<l.length&&u<c.length;u++)if(l[u]!==c[u])return!0;return!1}s.pathDisjoint=t;function o(l,c){if(l.length!==c.length)return!1;for(let u=0;u<l.length;u++)if(l[u]!==c[u])return!1;return!0}s.pathEq=o;function i(l,c){return t(l.path,c.path)}s.commutative=i;function a(l,c){return l.type===0&&c.type===0&&o(l.path,c.path)?Object.keys(l.props).every(u=>c.props[u]!==void 0):!1}s.subsumed=a})(ot||(ot={}));var bs;(l=>{function n(){return[]}l.empty=n;function r(c,u){let p=[];for(let d of c){let[h,...f]=d.path;h===u&&p.push({...d,path:f})}return p}l.removePrefix=r;function e(c,u){return c.map(p=>({...p,path:[u,...p.path]}))}l.addPrefix=e;function t(c,u){return[...c,...u]}l.concat=t;function o(c,u){return[...c.filter(d=>!u.some(h=>ot.subsumed(d,h))),...u]}l.compress=o;function i(c,u){return c.every(p=>u.every(d=>ot.commutative(p,d)))}l.commutative=i;function a(c,u){for(let p of u){let d=s(c,p);d!==null&&(c=d.data)}return c}l.applyAll=a;function s(c,u){var p=c;let d=[],h=[];for(let f of u)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let m,y,g;if(f.type===3?(m=rt.zoom(p,[...f.path,f.id]),g=ot.apply(p,{...f,type:2})):(m=rt.zoom(p,[...f.path,f.id,"value"]),g=ot.apply(p,f)),g!==null){p=g.data;let[v,O]=eg(p,{[f.id]:m});p=v;for(let P=0;P<O.length;P++){let S=O[P],T=S.pop();if(typeof T=="number"){let I=[T];for(let _=P+1;_<O.length;_++){let D=O[_],A=D[D.length-1];if(typeof A=="number"&&rt.equal(S,D.slice(0,D.length-1)))I.push(A),O.splice(_,1);else break}let x=rt.zoom(p,S);y=x.map((_,D)=>I.includes(D)?f.id:_),m=x,T=S.pop()}else{if(T==="alphaOverride"||T==="alpha"){m/=100;let I=m,x=rt.zoom(p,S.slice(0,S.length-2)),_=x.layers.map(D=>D.id===S[S.length-1]?{...D,data:{...D.data,[T]:I}}:D);Object.setPrototypeOf(_,Object.getPrototypeOf(x.layers)),x.layers=_}y=f.id}d.push({type:0,path:S,props:{[T]:m}}),h.push({type:0,path:S,props:{[T]:y}})}h.push(g.reverse),d.push(g.actual)}}else{let m=ot.apply(p,f);m!==null&&(d.push(m.actual),p=m.data,h.push(m.reverse))}}catch(m){if(m instanceof Ri)return null;throw m}return{data:p,actual:d,reverse:h.reverse()}}l.apply=s})(bs||(bs={}));var rg=Symbol(),nT=Symbol(),rc=Symbol(),Ln=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let i=t;for(;!(o instanceof tc);){let a=o._path,s=o._current;if(a!==""&&i.splice(0,0,a),o=o._parent,o===null)return;o.update(a,s)}o.push(i,r,e.actual,e.reverse)}deleteChildren(r){if(this._children){let e=this._children[r];if(e){let t=e[rc];t&&t(),delete this._children[r]}}}},Id=class extends Ln{constructor(r,e,t){super(),this._parent=r,this._path=e,this._current=t}update(r,e){if(Array.isArray(this._current)){if(typeof r=="string"&&(r=parseInt(r),isNaN(r)))throw new Error("Invalid path");this._current=[...this._current],this._current[r]=e}else this._current={...this._current,[r]:e}}runOp(r){this.reportOp(r,zi.runOp(this._current,r),r.path)}},Nd=class extends Ln{constructor(r,e,t){super(),this._parent=r,this._path=e,this._current=t}update(r,e){this._current={...this._current,[r]:e},Object.setPrototypeOf(this._current,xe.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},og={get(n,r){if(r===rc)return()=>{n._parent=null};if(r===rg)return n._current;if(r===nT)return n;let{_current:e,_children:t}=n;if(r==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e[r],a=oc(n,r,i);return a!==i?(t===void 0&&(t={},n._children=t),t[r]=a,a):i},has(n,r){return r 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,r){let e=n._current,t=Reflect.getOwnPropertyDescriptor(e,r);return t&&{writable:!0,configurable:!0,enumerable:t.enumerable,value:e[r]}}},iT={...og,set(n,r,e){let t={type:0,props:{[r]:ct(e)??e}};return n.deleteChildren(r),n.runOp(t),!0},deleteProperty(n,r){let e={type:0,props:{[r]:void 0}};return n.deleteChildren(r),n.runOp(e),!0}},aT={...og,set(n,r,e){return e===void 0?this.deleteProperty(n,r):(n.deleteChildren(r),n.runOp({type:1,id:r,data:e})),!0},deleteProperty(n,r){return n.runOp({type:2,id:r}),!0}},Fi=class extends Ln{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[rc]=()=>{this._parent=null}}unproxy(){return this._current}update(r,e){this._current=this._current.modifyById(r,e)}runOp(r){this.reportOp(r,this._current.runOp(r))}randomId(){return this._current.randomId()}isDescendantOf(r,e){return this._current.isDescendantOf(r,e)}childrenOf(r){return this._current.childrenOf(r)}traverse(r){return this._current.traverse(r)}get(r){return this._current.get(r)}parent(r){return this._current.parent(r)}traverse(r){this._current.traverse((e,t)=>{r(e,this.data(e))})}data(r){let{_current:e,_children:t}=this,o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e.get(r)?.data,a=oc(this,r,i);return a!==i?(t===void 0&&(t={},this._children=t),t[r]=a,a):i}add(r,e,t,o,i){this.runOp({type:7,parent:r,fi:e,id:t,data:o,children:i})}move(r,e,t){this.runOp({type:9,parent:r,fi:e,id:t})}insertAfter(r,e,t){let o=this._current.insertAfterHelper(r,e,t.length);for(let i=0;i<t.length;i++){let a=t[i];this.add(r,o[i],a.id,a.data,a.children)}}insertBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let i=0;i<t.length;i++){let a=t[i];this.add(r,o[i],a.id,a.data,a.children)}}moveAfter(r,e,t){let o=this._current.insertAfterHelper(r,e,t.length);for(let i=0;i<t.length;i++){let a=t[i];this.move(r,o[i],a)}}moveBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let i=0;i<t.length;i++){let a=t[i];this.move(r,o[i],a)}}delete(r){this.deleteChildren(r),this.runOp({type:8,id:r})}sortNext(r){return this._current.sortNext(r)}sortPrevious(r){return this._current.sortPrevious(r)}getAllSorted(r){return this._current.getAllSorted(r)}},Ui=class extends Ln{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[rc]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(r){let e=this.length;for(let t=0;t<e;t++){let o=this._current[t].id,i=this._current[t].fi;r(this.data(this._current[t].id),o,i)}}find(r){let e=this.length;for(let t=0;t<e;t++){let o=this._current[t].id;if(r(this.data(o),o))return this.get(o)}}update(r,e){this._current=this._current.modifyById(r,e)}randomId(){return this._current.randomId()}get(r){return{...this._current.get(r),data:this.data(r)}}data(r){let{_current:e,_children:t}=this,o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e.get(r)?.data,a=oc(this,r,i);return a!==i?(t===void 0&&(t={},this._children=t),t[r]=a,a):i}runOp(r){this.reportOp(r,this._current.runOp(r))}add(r,e,t){this.runOp({type:4,fi:r,id:e,data:t})}move(r,e){this.runOp({type:6,fi:r,id:e})}insertAfter(r,e){let t=this._current.insertAfterHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(t[o],i.id,i.data)}}insertBefore(r,e){let t=this._current.insertBeforeHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(t[o],i.id,i.data)}}moveAfter(r,e){let t=this._current.insertAfterHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(t[o],i)}}moveBefore(r,e){let t=this._current.insertBeforeHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(t[o],i)}}delete(r){this.deleteChildren(r),this.runOp({type:5,id:r})}};function Md(n,r,e){if(n.length>0){let t=n[n.length-1];if(t.type===0&&r.type===0&&rt.equal(t.path,e)){Object.assign(t.props,r.props);return}}n.push({...r,path:e})}var tc=class extends Ln{constructor(r){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=r}update(r,e){if(r!=="")throw new Error("");this._current=e}push(r,e,t,o){Md(this.ts,e,r),Md(this.actual,t,r),Md(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function oc(n,r,e){return e instanceof Xe?new Fi(n,r,e):e instanceof ve?new Ui(n,r,e):e instanceof xe?new Proxy(new Nd(n,r,e),aT):e!==null&&typeof e=="object"?Vi(e)?e:new Proxy(new Id(n,r,e),iT):e}function Dd(n){let r=new tc(n);return[oc(r,"",n),r]}function Xo(n,r){let[e,t]=Dd(n);return r(e),t.result()}function ct(n){return n instanceof Fi||n instanceof Ui?n._current:n!==null&&typeof n=="object"?n[rg]:n}var rt;(o=>{function n(i,a){if(a.length===i.length)for(var s=0;s<i.length;){if(i[s]!==a[s])return!1;s+=1}else return!1;return!0}o.equal=n;function r(i,a,s){let l=t(s,i);if(l!==void 0&&typeof l=="object"&&l!==null){let c={...a};return Object.keys(l).forEach(u=>{delete c[u]}),c}else return a}o.removeOverridden=r;function e(i,a){if((i instanceof Xe||i instanceof Fi)&&typeof a=="string")return i.data(a);if((i instanceof ve||i instanceof Ui)&&typeof a=="string")return i.data(a);if(typeof a=="number"&&Array.isArray(i))return i[a];if(typeof a=="string"&&typeof i=="object"&&i!==null)return i[a]}o.zoomOnce=e;function t(i,a,s=0){for(;s<a.length&&i!==void 0;)i=e(i,a[s]),s+=1;return i}o.zoom=t})(rt||(rt={}));function ng(n,r){let e=[];if(r.length===n.length)for(var t=0;t<n.length;){if(r[t]==="*")e.push(n[t]);else if(n[t]!==r[t])return null;t+=1}else return null;return e}function Be(n,r){let e=[];if(r.length<=n.length)for(var t=0;t<r.length;){if(r[t]==="*")e.push(n[t]);else if(n[t]!==r[t])return null;t+=1}else return null;return e}var nc=class{},vs=class extends nc{constructor(e){super();this.id=e}},Ss=class extends nc{constructor(e){super();this.data=e}};var _d;try{_d=new TextDecoder}catch{}var de,Qo,G=0;var pg=[],Bd=pg,Ld=0,Zt={},ke,Ko,yr=0,$r=0,lr,wo,Wt=[],We,ig={useRecords:!1,mapsAsObjects:!0},ws=class{},Vd=new ws;Vd.name="MessagePack 0xC1";var ki=!1,Yr=class{constructor(r){r&&(r.useRecords===!1&&r.mapsAsObjects===void 0&&(r.mapsAsObjects=!0),r.structures?r.structures.sharedLength=r.structures.length:r.getStructures&&((r.structures=[]).uninitialized=!0,r.structures.sharedLength=0)),Object.assign(this,r)}unpack(r,e){if(de)return gg(()=>(ac(),this?this.unpack(r,e):Yr.prototype.unpack.call(ig,r,e)));Qo=e>-1?e:r.length,G=0,Ld=0,$r=0,Ko=null,Bd=pg,lr=null,de=r;try{We=r.dataView||(r.dataView=new DataView(r.buffer,r.byteOffset,r.byteLength))}catch(t){throw de=null,r instanceof Uint8Array?t:new Error("Source must be a Uint8Array or Buffer but was a "+(r&&typeof r=="object"?r.constructor.name:typeof r))}if(this instanceof Yr){if(Zt=this,this.structures)return ke=this.structures,ic();(!ke||ke.length>0)&&(ke=[])}else Zt=ig,(!ke||ke.length>0)&&(ke=[]);return ic()}unpackMultiple(r,e){let t,o=0;try{ki=!0;let i=r.length,a=this?this.unpack(r,i):cc.unpack(r,i);if(e){for(e(a);G<i;)if(o=G,e(ic())===!1)return}else{for(t=[a];G<i;)o=G,t.push(ic());return t}}catch(i){throw i.lastPosition=o,i.values=t,i}finally{ki=!1,ac()}}_mergeStructures(r,e){r=r||[];for(let t=0,o=r.length;t<o;t++){let i=r[t];i&&(i.isShared=!0,t>=32&&(i.highByte=t-32>>5))}r.sharedLength=r.length;for(let t in e||[])if(t>=0){let o=r[t],i=e[t];i&&(o&&((r.restoreStructures||(r.restoreStructures=[]))[t]=o),r[t]=i)}return this.structures=r}decode(r,e){return this.unpack(r,e)}};function ic(){try{if(!Zt.trusted&&!ki){let r=ke.sharedLength||0;r<ke.length&&(ke.length=r)}let n=ut();if(G==Qo)ke.restoreStructures&&ag(),ke=null,de=null,wo&&(wo=null);else if(G>Qo){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}else if(!ki)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw ke.restoreStructures&&ag(),ac(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function ag(){for(let n in ke.restoreStructures)ke[n]=ke.restoreStructures[n];ke.restoreStructures=null}function ut(){let n=de[G++];if(n<160)if(n<128){if(n<64)return n;{let r=ke[n&63]||Zt.getStructures&&fg()[n&63];return r?(r.read||(r.read=zd(r,n&63)),r.read()):n}}else if(n<144)if(n-=128,Zt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[mg()]=ut();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(ut(),ut());return r}else{n-=144;let r=new Array(n);for(let e=0;e<n;e++)r[e]=ut();return r}else if(n<192){let r=n-160;if($r>=G)return Ko.slice(G-yr,(G+=r)-yr);if($r==0&&Qo<140){let e=r<16?Gd(r):hg(r);if(e!=null)return e}return Rd(r)}else{let r;switch(n){case 192:return null;case 193:return lr?(r=ut(),r>0?lr[1].slice(lr.position1,lr.position1+=r):lr[0].slice(lr.position0,lr.position0-=r)):Vd;case 194:return!1;case 195:return!0;case 196:return Ed(de[G++]);case 197:return r=We.getUint16(G),G+=2,Ed(r);case 198:return r=We.getUint32(G),G+=4,Ed(r);case 199:return Rn(de[G++]);case 200:return r=We.getUint16(G),G+=2,Rn(r);case 201:return r=We.getUint32(G),G+=4,Rn(r);case 202:if(r=We.getFloat32(G),Zt.useFloat32>2){let e=lc[(de[G]&127)<<1|de[G+1]>>7];return G+=4,(e*r+(r>0?.5:-.5)>>0)/e}return G+=4,r;case 203:return r=We.getFloat64(G),G+=8,r;case 204:return de[G++];case 205:return r=We.getUint16(G),G+=2,r;case 206:return r=We.getUint32(G),G+=4,r;case 207:return Zt.int64AsNumber?(r=We.getUint32(G)*4294967296,r+=We.getUint32(G+4)):r=We.getBigUint64(G),G+=8,r;case 208:return We.getInt8(G++);case 209:return r=We.getInt16(G),G+=2,r;case 210:return r=We.getInt32(G),G+=4,r;case 211:return Zt.int64AsNumber?(r=We.getInt32(G)*4294967296,r+=We.getUint32(G+4)):r=We.getBigInt64(G),G+=8,r;case 212:if(r=de[G++],r==114)return dg(de[G++]&63);{let e=Wt[r];if(e)return e.read?(G++,e.read(ut())):e.noBuffer?(G++,e()):e(de.subarray(G,++G));throw new Error("Unknown extension "+r)}case 213:return r=de[G],r==114?(G++,dg(de[G++]&63,de[G++])):Rn(2);case 214:return Rn(4);case 215:return Rn(8);case 216:return Rn(16);case 217:return r=de[G++],$r>=G?Ko.slice(G-yr,(G+=r)-yr):lT(r);case 218:return r=We.getUint16(G),G+=2,$r>=G?Ko.slice(G-yr,(G+=r)-yr):cT(r);case 219:return r=We.getUint32(G),G+=4,$r>=G?Ko.slice(G-yr,(G+=r)-yr):uT(r);case 220:return r=We.getUint16(G),G+=2,lg(r);case 221:return r=We.getUint32(G),G+=4,lg(r);case 222:return r=We.getUint16(G),G+=2,cg(r);case 223:return r=We.getUint32(G),G+=4,cg(r);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 sT=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function zd(n,r){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>sT.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(ut);return n.highByte===0&&(n.read=sg(r,n.read)),o()}let t={};for(let o=0,i=n.length;o<i;o++){let a=n[o];t[a]=ut()}return t}return e.count=0,n.highByte===0?sg(r,e):e}var sg=(n,r)=>function(){let e=de[G++];if(e===0)return r();let t=n<32?-(n+(e<<5)):n+(e<<5),o=ke[t]||fg()[t];if(!o)throw new Error("Record id is not defined for "+t);return o.read||(o.read=zd(o,n)),o.read()};function fg(){let n=gg(()=>(de=null,Zt.getStructures()));return ke=Zt._mergeStructures(n,ke)}var Rd=sc,lT=sc,cT=sc,uT=sc;function sc(n){let r;if(n<16&&(r=Gd(n)))return r;if(n>64&&_d)return _d.decode(de.subarray(G,G+=n));let e=G+n,t=[];for(r="";G<e;){let o=de[G++];if((o&128)===0)t.push(o);else if((o&224)===192){let i=de[G++]&63;t.push((o&31)<<6|i)}else if((o&240)===224){let i=de[G++]&63,a=de[G++]&63;t.push((o&31)<<12|i<<6|a)}else if((o&248)===240){let i=de[G++]&63,a=de[G++]&63,s=de[G++]&63,l=(o&7)<<18|i<<12|a<<6|s;l>65535&&(l-=65536,t.push(l>>>10&1023|55296),l=56320|l&1023),t.push(l)}else t.push(o);t.length>=4096&&(r+=At.apply(String,t),t.length=0)}return t.length>0&&(r+=At.apply(String,t)),r}function lg(n){let r=new Array(n);for(let e=0;e<n;e++)r[e]=ut();return r}function cg(n){if(Zt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[mg()]=ut();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(ut(),ut());return r}}var At=String.fromCharCode;function hg(n){let r=G,e=new Array(n);for(let t=0;t<n;t++){let o=de[G++];if((o&128)>0){G=r;return}e[t]=o}return At.apply(String,e)}function Gd(n){if(n<4)if(n<2){if(n===0)return"";{let r=de[G++];if((r&128)>1){G-=1;return}return At(r)}}else{let r=de[G++],e=de[G++];if((r&128)>0||(e&128)>0){G-=2;return}if(n<3)return At(r,e);let t=de[G++];if((t&128)>0){G-=3;return}return At(r,e,t)}else{let r=de[G++],e=de[G++],t=de[G++],o=de[G++];if((r&128)>0||(e&128)>0||(t&128)>0||(o&128)>0){G-=4;return}if(n<6){if(n===4)return At(r,e,t,o);{let i=de[G++];if((i&128)>0){G-=5;return}return At(r,e,t,o,i)}}else if(n<8){let i=de[G++],a=de[G++];if((i&128)>0||(a&128)>0){G-=6;return}if(n<7)return At(r,e,t,o,i,a);let s=de[G++];if((s&128)>0){G-=7;return}return At(r,e,t,o,i,a,s)}else{let i=de[G++],a=de[G++],s=de[G++],l=de[G++];if((i&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){G-=8;return}if(n<10){if(n===8)return At(r,e,t,o,i,a,s,l);{let c=de[G++];if((c&128)>0){G-=9;return}return At(r,e,t,o,i,a,s,l,c)}}else if(n<12){let c=de[G++],u=de[G++];if((c&128)>0||(u&128)>0){G-=10;return}if(n<11)return At(r,e,t,o,i,a,s,l,c,u);let p=de[G++];if((p&128)>0){G-=11;return}return At(r,e,t,o,i,a,s,l,c,u,p)}else{let c=de[G++],u=de[G++],p=de[G++],d=de[G++];if((c&128)>0||(u&128)>0||(p&128)>0||(d&128)>0){G-=12;return}if(n<14){if(n===12)return At(r,e,t,o,i,a,s,l,c,u,p,d);{let h=de[G++];if((h&128)>0){G-=13;return}return At(r,e,t,o,i,a,s,l,c,u,p,d,h)}}else{let h=de[G++],f=de[G++];if((h&128)>0||(f&128)>0){G-=14;return}if(n<15)return At(r,e,t,o,i,a,s,l,c,u,p,d,h,f);let m=de[G++];if((m&128)>0){G-=15;return}return At(r,e,t,o,i,a,s,l,c,u,p,d,h,f,m)}}}}}function Ed(n){return Zt.copyBuffers?Uint8Array.prototype.slice.call(de,G,G+=n):de.subarray(G,G+=n)}function Rn(n){let r=de[G++];if(Wt[r])return Wt[r](de.subarray(G,G+=n));throw new Error("Unknown extension type "+r)}var ug=new Array(4096);function mg(){let n=de[G++];if(n>=160&&n<192){if(n=n-160,$r>=G)return Ko.slice(G-yr,(G+=n)-yr);if(!($r==0&&Qo<180))return Rd(n)}else return G--,ut();let r=(n<<5^(n>1?We.getUint16(G):n>0?de[G]:0))&4095,e=ug[r],t=G,o=G+n-3,i,a=0;if(e&&e.bytes==n){for(;t<o;){if(i=We.getUint32(t),i!=e[a++]){t=1879048192;break}t+=4}for(o+=3;t<o;)if(i=de[t++],i!=e[a++]){t=1879048192;break}if(t===o)return G=t,e.string;o-=3,t=G}for(e=[],ug[r]=e,e.bytes=n;t<o;)i=We.getUint32(t),e.push(i),t+=4;for(o+=3;t<o;)i=de[t++],e.push(i);let s=n<16?Gd(n):hg(n);return s!=null?e.string=s:e.string=Rd(n)}var dg=(n,r)=>{var e=ut();let t=n;r!==void 0&&(n=n<32?-((r<<5)+n):(r<<5)+n,e.highByte=r);let o=ke[n];return o&&o.isShared&&((ke.restoreStructures||(ke.restoreStructures=[]))[n]=o),ke[n]=e,e.read=zd(e,t),e.read()},yg=typeof self=="object"?self:global;Wt[0]=()=>{};Wt[0].noBuffer=!0;Wt[101]=()=>{let n=ut();return(yg[n[0]]||Error)(n[1])};Wt[105]=n=>{let r=We.getUint32(G-4);wo||(wo=new Map);let e=de[G],t;e>=144&&e<160||e==220||e==221?t=[]:t={};let o={target:t};wo.set(r,o);let i=ut();return o.used?Object.assign(t,i):(o.target=i,i)};Wt[112]=n=>{let r=We.getUint32(G-4),e=wo.get(r);return e.used=!0,e.target};Wt[115]=()=>new Set(ut());var jd=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");Wt[116]=n=>{let r=n[0],e=jd[r];if(!e)throw new Error("Could not find typed array for code "+r);return new yg[e](Uint8Array.prototype.slice.call(n,1).buffer)};Wt[120]=()=>{let n=ut();return new RegExp(n[0],n[1])};Wt[98]=n=>{let r=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=G;G+=r-4,lr=[ut(),ut()],lr.position0=0,lr.position1=0;let t=G;G=e;try{return ut()}finally{G=t}};Wt[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 gg(n){let r=Qo,e=G,t=Ld,o=yr,i=$r,a=Ko,s=Bd,l=wo,c=lr,u=new Uint8Array(de.slice(0,Qo)),p=ke,d=ke.slice(0,ke.length),h=Zt,f=ki,m=n();return Qo=r,G=e,Ld=t,yr=o,$r=i,Ko=a,Bd=s,wo=l,lr=c,de=u,ki=f,ke=p,ke.splice(0,ke.length,...d),Zt=h,We=new DataView(de.buffer,de.byteOffset,de.byteLength),m}function ac(){de=null,wo=null,ke=null}function xg(n){n.unpack?Wt[n.type]=n.unpack:Wt[n.type]=n}var lc=new Array(147);for(let n=0;n<256;n++)lc[n]=+("1e"+Math.floor(45.15-n*.30103));var cc=new Yr({useRecords:!1}),dT=cc.unpack,pT=cc.unpackMultiple,fT=cc.unpack,uc={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},hT=new Float32Array(1),tU=new Uint8Array(hT.buffer,0,4);var dc;try{dc=new TextEncoder}catch{}var pc,Ud,fc=typeof Buffer<"u",Fd=fc?Buffer.allocUnsafeSlow:Uint8Array,wg=fc?Buffer:Uint8Array,bg=fc?4294967296:2144337920,Q,pt,U=0,Xr,Kr=null,mT=/[\u0080-\uFFFF]/,Ps=Symbol("record-id"),Vn=class extends Yr{constructor(r){super(r),this.offset=0;let e,t,o,i,a,s,l=0,c=wg.prototype.utf8Write?function(x,_,D){return Q.utf8Write(x,_,D)}:dc&&dc.encodeInto?function(x,_){return dc.encodeInto(x,Q.subarray(_)).written}:!1,u=this;r||(r={});let p=r&&r.sequential,d=r.structures||r.saveStructures,h=r.maxSharedStructures;if(h==null&&(h=d?32:0),h>8160)throw new Error("Maximum maxSharedStructure is 8160");let f=r.maxOwnStructures;f==null&&(f=d?32:64),p&&!r.saveStructures&&(this.structures=[]);let m=h>32||f+h>64,y=h+64,g=h+f+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],O=0,P=0;this.pack=this.encode=function(x,_){if(Q||(Q=new Fd(8192),pt=new DataView(Q.buffer,0,8192),U=0),Xr=Q.length-10,Xr-U<2048?(Q=new Fd(Q.length),pt=new DataView(Q.buffer,0,Q.length),Xr=Q.length-10,U=0):U=U+7&2147483640,t=U,s=u.structuredClone?new Map:null,u.bundleStrings?(Kr=["",""],Q[U++]=214,Q[U++]=98,Kr.position=U-t,U+=4):Kr=null,o=u.structures,o){o.uninitialized&&(o=u._mergeStructures(u.getStructures()));let D=o.sharedLength||0;if(D>h)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+o.sharedLength);if(!o.transitions){o.transitions=Object.create(null);for(let A=0;A<D;A++){let N=o[A];if(!N)continue;let E,B=o.transitions;for(let V=0,j=N.length;V<j;V++){let R=N[V];E=B[R],E||(E=B[R]=Object.create(null)),B=E}B[Ps]=A+64}l=D}p||(o.nextId=D+64)}i&&(i=!1),a=o||[];try{if(S(x),Kr){pt.setUint32(Kr.position+t,U-Kr.position-t);let D=Kr;Kr=null,S(D[0]),S(D[1])}if(u.offset=U,s&&s.idsToInsert){U+=s.idsToInsert.length*6,U>Xr&&I(U),u.offset=U;let D=gT(Q.subarray(t,U),s.idsToInsert);return s=null,D}return _&Og?(Q.start=t,Q.end=U,Q):Q.subarray(t,U)}finally{if(o){if(P<10&&P++,O>1e4)o.transitions=null,P=0,O=0,v.length>0&&(v=[]);else if(v.length>0&&!p){for(let D=0,A=v.length;D<A;D++)v[D][Ps]=0;v=[]}if(i&&u.saveStructures){let D=o.sharedLength||h;o.length>D&&(o=o.slice(0,D));let A=Q.subarray(t,U);return u.saveStructures(o,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(x)):(l=D,A)}}_&OT&&(U=t)}};let S=x=>{U>Xr&&(Q=I(U));var _=typeof x,D;if(_==="string"){let A=x.length;if(Kr&&A>=8&&A<4096){let B=mT.test(x);Kr[B?0:1]+=x,Q[U++]=193,S(B?-A:A);return}let N;A<32?N=1:A<256?N=2:A<65536?N=3:N=5;let E=A*3;if(U+E>Xr&&(Q=I(U+E)),A<64||!c){let B,V,j,R=U+N;for(B=0;B<A;B++)V=x.charCodeAt(B),V<128?Q[R++]=V:V<2048?(Q[R++]=V>>6|192,Q[R++]=V&63|128):(V&64512)===55296&&((j=x.charCodeAt(B+1))&64512)===56320?(V=65536+((V&1023)<<10)+(j&1023),B++,Q[R++]=V>>18|240,Q[R++]=V>>12&63|128,Q[R++]=V>>6&63|128,Q[R++]=V&63|128):(Q[R++]=V>>12|224,Q[R++]=V>>6&63|128,Q[R++]=V&63|128);D=R-U-N}else D=c(x,U+N,E);D<32?Q[U++]=160|D:D<256?(N<2&&Q.copyWithin(U+2,U+1,U+1+D),Q[U++]=217,Q[U++]=D):D<65536?(N<3&&Q.copyWithin(U+3,U+2,U+2+D),Q[U++]=218,Q[U++]=D>>8,Q[U++]=D&255):(N<5&&Q.copyWithin(U+5,U+3,U+3+D),Q[U++]=219,pt.setUint32(U,D),U+=4),U+=D}else if(_==="number")if(x>>>0===x)x<64?Q[U++]=x:x<256?(Q[U++]=204,Q[U++]=x):x<65536?(Q[U++]=205,Q[U++]=x>>8,Q[U++]=x&255):(Q[U++]=206,pt.setUint32(U,x),U+=4);else if(x>>0===x)x>=-32?Q[U++]=256+x:x>=-128?(Q[U++]=208,Q[U++]=x+256):x>=-32768?(Q[U++]=209,pt.setInt16(U,x),U+=2):(Q[U++]=210,pt.setInt32(U,x),U+=4);else{let A;if((A=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){Q[U++]=202,pt.setFloat32(U,x);let N;if(A<4||(N=x*lc[(Q[U]&127)<<1|Q[U+1]>>7])>>0===N){U+=4;return}else U--}Q[U++]=203,pt.setFloat64(U,x),U+=8}else if(_==="object")if(!x)Q[U++]=192;else{if(s){let N=s.get(x);if(N){if(!N.id){let E=s.idsToInsert||(s.idsToInsert=[]);N.id=E.push(N)}Q[U++]=214,Q[U++]=112,pt.setUint32(U,N.id),U+=4;return}else s.set(x,{offset:U-t})}let A=x.constructor;if(A===Object)T(x,!0);else if(A===Array){D=x.length,D<16?Q[U++]=144|D:D<65536?(Q[U++]=220,Q[U++]=D>>8,Q[U++]=D&255):(Q[U++]=221,pt.setUint32(U,D),U+=4);for(let N=0;N<D;N++)S(x[N])}else if(A===Map){D=x.size,D<16?Q[U++]=128|D:D<65536?(Q[U++]=222,Q[U++]=D>>8,Q[U++]=D&255):(Q[U++]=223,pt.setUint32(U,D),U+=4);for(let[N,E]of x)S(N),S(E)}else{for(let N=0,E=pc.length;N<E;N++){let B=Ud[N];if(x instanceof B){let V=pc[N];if(V.write){V.type&&(Q[U++]=212,Q[U++]=V.type,Q[U++]=0),S(V.write.call(this,x));return}let j=Q,R=pt,W=U;Q=null;let F;try{F=V.pack.call(this,x,k=>(Q=j,j=null,U+=k,U>Xr&&I(U),{target:Q,targetView:pt,position:U-k}),S)}finally{j&&(Q=j,pt=R,U=W,Xr=Q.length-10)}F&&(F.length+U>Xr&&I(F.length+U),U=yT(F,Q,U,V.type));return}}T(x,!x.hasOwnProperty)}}else if(_==="boolean")Q[U++]=x?195:194;else if(_==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))Q[U++]=211,pt.setBigInt64(U,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)Q[U++]=207,pt.setBigUint64(U,x);else if(this.largeBigIntToFloat)Q[U++]=203,pt.setFloat64(U,Number(x));else throw new RangeError(x+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");U+=8}else if(_==="undefined")this.encodeUndefinedAsNil?Q[U++]=192:(Q[U++]=212,Q[U++]=0,Q[U++]=0);else if(_==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+_)},T=this.useRecords===!1?this.variableMapSize?x=>{let _=Object.keys(x),D=_.length;D<16?Q[U++]=128|D:D<65536?(Q[U++]=222,Q[U++]=D>>8,Q[U++]=D&255):(Q[U++]=223,pt.setUint32(U,D),U+=4);let A;for(let N=0;N<D;N++)S(A=_[N]),S(x[A])}:(x,_)=>{Q[U++]=222;let D=U-t;U+=2;let A=0;for(let N in x)(_||x.hasOwnProperty(N))&&(S(N),S(x[N]),A++);Q[D+++t]=A>>8,Q[D+t]=A&255}:x=>{let _=Object.keys(x),D,A=a.transitions||(a.transitions=Object.create(null)),N=0;for(let B=0,V=_.length;B<V;B++){let j=_[B];D=A[j],D||(D=A[j]=Object.create(null),N++),A=D}let E=A[Ps];if(E)E>=96&&m?(Q[U++]=((E-=96)&31)+96,Q[U++]=E>>5):Q[U++]=E;else{E=a.nextId,E||(E=64),E<y&&this.shouldShareStructure&&!this.shouldShareStructure(_)?(E=a.nextOwnId,E<g||(E=y),a.nextOwnId=E+1):(E>=g&&(E=y),a.nextId=E+1);let B=_.highByte=E>=96&&m?E-96>>5:-1;A[Ps]=E,a[E-64]=_,E<y?(_.isShared=!0,a.sharedLength=E-63,i=!0,B>=0?(Q[U++]=(E&31)+96,Q[U++]=B):Q[U++]=E):(B>=0?(Q[U++]=213,Q[U++]=114,Q[U++]=(E&31)+96,Q[U++]=B):(Q[U++]=212,Q[U++]=114,Q[U++]=E),N&&(O+=P*N),v.length>=f&&(v.shift()[Ps]=0),v.push(A),S(_))}for(let B=0,V=_.length;B<V;B++)S(x[_[B]])},I=x=>{let _;if(x>16777216){if(x-t>bg)throw new Error("Packed buffer would be larger than maximum buffer size");_=Math.min(bg,Math.round(Math.max((x-t)*(x>67108864?1.25:2),4194304)/4096)*4096)}else _=(Math.max(x-t<<2,Q.length-1)>>12)+1<<12;let D=new Fd(_);return pt=new DataView(D.buffer,0,_),Q.copy?Q.copy(D,0,t,x):D.set(Q.slice(t,x)),U-=t,t=0,Xr=D.length-10,Q=D}}useBuffer(r){Q=r,pt=new DataView(Q.buffer,Q.byteOffset,Q.byteLength),U=0}};Ud=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,ws];pc=[{pack(n,r,e){let t=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&t>=0&&t<4294967296){let{target:o,targetView:i,position:a}=r(6);o[a++]=214,o[a++]=255,i.setUint32(a,t)}else if(t>0&&t<17179869184){let{target:o,targetView:i,position:a}=r(10);o[a++]=215,o[a++]=255,i.setUint32(a,n.getMilliseconds()*4e6+(t/1e3/4294967296>>0)),i.setUint32(a+4,t)}else if(isNaN(t)){if(this.onInvalidDate)return r(0),e(this.onInvalidDate());let{target:o,targetView:i,position:a}=r(3);o[a++]=212,o[a++]=255,o[a++]=255}else{let{target:o,targetView:i,position:a}=r(15);o[a++]=199,o[a++]=12,o[a++]=255,i.setUint32(a,n.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(t)))}}},{pack(n,r,e){let t=Array.from(n),{target:o,position:i}=r(this.structuredClone?3:0);this.structuredClone&&(o[i++]=212,o[i++]=115,o[i++]=0),e(t)}},{pack(n,r,e){let{target:t,position:o}=r(this.structuredClone?3:0);this.structuredClone&&(t[o++]=212,t[o++]=101,t[o++]=0),e([n.name,n.message])}},{pack(n,r,e){let{target:t,position:o}=r(this.structuredClone?3:0);this.structuredClone&&(t[o++]=212,t[o++]=120,t[o++]=0),e([n.source,n.flags])}},{pack(n,r){this.structuredClone?vg(n,16,r):Sg(fc?Buffer.from(n):new Uint8Array(n),r)}},{pack(n,r){let e=n.constructor;e!==wg&&this.structuredClone?vg(n,jd.indexOf(e.name),r):Sg(n,r)}},{pack(n,r){let{target:e,position:t}=r(1);e[t]=193}}];function vg(n,r,e,t){let o=n.byteLength;if(o+1<256){var{target:i,position:a}=e(4+o);i[a++]=199,i[a++]=o+1}else if(o+1<65536){var{target:i,position:a}=e(5+o);i[a++]=200,i[a++]=o+1>>8,i[a++]=o+1&255}else{var{target:i,position:a,targetView:s}=e(7+o);i[a++]=201,s.setUint32(a,o+1),a+=4}i[a++]=116,i[a++]=r,i.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),a)}function Sg(n,r){let e=n.byteLength;var t,o;if(e<256){var{target:t,position:o}=r(e+2);t[o++]=196,t[o++]=e}else if(e<65536){var{target:t,position:o}=r(e+3);t[o++]=197,t[o++]=e>>8,t[o++]=e&255}else{var{target:t,position:o,targetView:i}=r(e+5);t[o++]=198,i.setUint32(o,e),o+=4}t.set(n,o)}function yT(n,r,e,t){let o=n.length;switch(o){case 1:r[e++]=212;break;case 2:r[e++]=213;break;case 4:r[e++]=214;break;case 8:r[e++]=215;break;case 16:r[e++]=216;break;default:o<256?(r[e++]=199,r[e++]=o):o<65536?(r[e++]=200,r[e++]=o>>8,r[e++]=o&255):(r[e++]=201,r[e++]=o>>24,r[e++]=o>>16&255,r[e++]=o>>8&255,r[e++]=o&255)}return r[e++]=t,r.set(n,e),e+=o,e}function gT(n,r){let e,t=r.length*6,o=n.length-t;for(r.sort((i,a)=>i.offset>a.offset?1:-1);e=r.pop();){let i=e.offset,a=e.id;n.copyWithin(i+t,i,o),t-=6;let s=i+t;n[s++]=214,n[s++]=105,n[s++]=a>>24,n[s++]=a>>16&255,n[s++]=a>>8&255,n[s++]=a&255,o=i}return n}function Zo(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)");Ud.unshift(n.Class),pc.unshift(n)}xg(n)}var Pg=new Vn({useRecords:!1}),xT=Pg.pack,bT=Pg.pack;var{NEVER:vT,ALWAYS:ST,DECIMAL_ROUND:wT,DECIMAL_FIT:PT}=uc,Og=512,OT=1024;var Cg=new Vn({structuredClone:!0});Zo({Class:xe.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,xe.prototype),n}});Zo({Class:ve.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,ve.prototype),n}});Zo({Class:Xe.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Xe.prototype),n}});Zo({Class:vs.prototype.constructor,type:4,write(n){return n.id},read(n){return new vs(n)}});Zo({Class:Ss.prototype.constructor,type:5,write(n){return n.data},read(n){return new Ss(n)}});Zo({Class:Ke.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Ke.prototype),n}});function CT(n){var r=0;if(n.length===0)return r;for(let e=0;e<n.length;e++){let t=n[e];r=(r<<5)-r+t,r=r&r}return r}function kd(n){if(Vi(n))return n;if(Array.isArray(n))return n.map(kd);if(typeof n=="object"&&n!==null){let r={};for(let e of Object.keys(n).sort())r[e]=kd(n[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else return n}var hc;(t=>{function n(o){return Cg.pack(o)}t.serialize=n;function r(o){return Cg.unpack(o)}t.deserialize=r;function e(o){return CT(n(kd(o))).toString()}t.checksum=e})(hc||(hc={}));var tn="personal camera",rn="a218fcc3-276b-49b9-b485-49037fd14f5f",Ng=2960946,ft=5526619;var Hi;(h=>{function n(f,m){return f[0]===m[0]&&f[1]===m[1]}h.isEqual=n;function r(f,m,y){return[f[0]+(m[0]-f[0])*y,f[1]+(m[1]-f[1])*y]}h.lerp=r;function e(f,m){return[f[0]+m[0],f[1]+m[1]]}h.add=e;function t(f,m){return[f[0]-m[0],f[1]-m[1]]}h.sub=t;function o(f,m){return[f[0]*m[0],f[1]*m[1]]}h.multiply=o;function i(f,m){return[f[0]/m[0],f[1]/m[1]]}h.divide=i;function a(f,m){return Math.pow(m[0]-f[0],2)+Math.pow(m[1]-f[1],2)}h.distanceSquared=a;function s(f,m){return Math.sqrt(a(f,m))}h.distance=s;function l(f,m){return f[0]*m[0]+f[1]*m[1]}h.dot=l;function c(f,m){return[f[0]*m,f[1]*m]}h.scalarMultiply=c;function u(f,m,y){let g=h.sub(m,f),v=h.sub(y,f),O=h.dot(g,v)/h.dot(g,g),P=h.scalarMultiply(g,O);return h.add(f,P)}h.projectionOnto=u;function p(f,m,y){return s(f,u(f,m,y))}h.projectionOntoDistance=p;function d(f,m){return[(f[0]+m[0])*.5,(f[1]+m[1])*.5]}h.center=d})(Hi||(Hi={}));var Jo;(s=>{function n(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}s.isEqual=n;function r(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]}s.add=r;function e(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]}s.sub=e;function t(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]}s.div=t;function o(l,c){return[l[0]*c[0],l[1]*c[1],l[2]*c[2]]}s.mul=o;function i(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])}s.dist=i;function a(l,c,u){return[l[0]+(c[0]-l[0])*u,l[1]+(c[1]-l[1])*u,l[2]+(c[2]-l[2])*u]}s.lerp=a})(Jo||(Jo={}));var Tg;(e=>{function n(t,o){return t[0]===o[0]&&t[1]===o[1]&&t[2]===o[2]&&t[3]===o[3]}e.isEqual=n;function r(t,o,i){return[t[0]+(o[0]-t[0])*i,t[1]+(o[1]-t[1])*i,t[2]+(o[2]-t[2])*i,t[3]+(o[3]-t[3])*i]}e.lerp=r})(Tg||(Tg={}));var en;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function r(i,a){for(let s=0;s<16;s++)if(i[s]!==a[s])return!1;return!0}o.isEqual=r;function e(i){return i??o.identity}o.simplify=e;function t(i,a){let s=a.slice(0);for(var l=0,c=a.length;l<c;l+=3){let u=i[3]*a[l]+i[7]*a[l+1]+i[11]*a[l+2]+i[15];s[l]=(i[0]*a[l]+i[4]*a[l+1]+i[8]*a[l+2]+i[12])/u,s[l+1]=(i[1]*a[l]+i[5]*a[l+1]+i[9]*a[l+2]+i[13])/u,s[l+2]=(i[2]*a[l]+i[6]*a[l+1]+i[10]*a[l+2]+i[14])/u}return s}o.applyMatrix4=t})(en||(en={}));var vt;(p=>{function n(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}p.isRGB=n,p.white={r:1,g:1,b:1},p.red={r:1,g:0,b:0},p.black={r:0,g:0,b:0};function o(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}p.toRgb255a1=o;function i(d){return{r:d.r,g:d.g,b:d.b}}p.clone=i;function a(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}p.fromHex=a;function s(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}p.toHex=s;function l(d,h){return d.r===h.r&&d.g===h.g&&d.b===h.b}p.equals=l;function c(d,h){return d.r.toFixed(2)===h.r.toFixed(2)&&d.g.toFixed(2)===h.g.toFixed(2)&&d.b.toFixed(2)===h.b.toFixed(2)}p.equalsFixed=c;function u(d,h,f){return{r:d.r+(h.r-d.r)*f,g:d.g+(h.g-d.g)*f,b:d.b+(h.b-d.b)*f}}p.lerp=u})(vt||(vt={}));var Ie;(c=>{c.white={...vt.white,a:1},c.transparent={...vt.white,a:0};function e(u){return{r:u[0],g:u[1],b:u[2],a:u[3]}}c.from0to1=e;function t(u,p){return{...vt.fromHex(u),a:p}}c.fromHexAndA=t;function o(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:u.a}}c.toRgb255a1=o;function i(u,p){return vt.equals(u,p)&&u.a===p.a}c.equals=i;function a(u,p){return vt.equalsFixed(u,p)&&u.a.toFixed(2)===p.a.toFixed(2)}c.equalsFixed=a;function s(u,p,d){return{r:u.r+(p.r-u.r)*d,g:u.g+(p.g-u.g)*d,b:u.b+(p.b-u.b)*d,a:u.a+(p.a-u.a)*d}}c.lerp=s;function l({r:u,g:p,b:d,a:h}=c.white){return`rgba(${u*255}, ${p*255}, ${d*255}, ${h})`}c.toStyle=l})(Ie||(Ie={}));var mc;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(mc||(mc={}));var Ag;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(Ag||(Ag={}));var Mg;(r=>r.defaultData={control1:[.5,0],control2:[.5,1]})(Mg||(Mg={}));var Ig;(i=>(i.linear=[0,0,1,1],i.ease=[.25,.1,.25,1],i.easeIn=[.42,0,1,1],i.easeOut=[0,0,.58,1],i.easeInOut=[.42,0,.58,1]))(Ig||(Ig={}));function Hd(n){return typeof n=="string"&&n.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n):!1}var Ir;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(Ir||(Ir={}));var on;(o=>{o.DefaultUp=[0,1,0],o.DefaultTargetOffset=1e3,o.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective?.zoom??1:i.orthographic?.zoom??1}o.getZoom=t})(on||(on={}));var Qr;(e=>{function n(t,o=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[t[0]+t[0]*o,0,0]},grid:{count:[2,2,2],size:t.map(i=>i*(1+o)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=n;function r(t,o){let i={...t};if(TT.forEach(a=>{Object.assign(i,{[a]:o[a]??t[a]})}),i.radial={...t.radial},o.radial){let a=t.radial,s=o.radial;AT.forEach(l=>{Object.assign(i.radial,{[l]:s[l]??a[l]})})}if(i.linear={...t.linear},o.linear){let a=t.linear,s=o.linear;MT.forEach(l=>{Object.assign(i.linear,{[l]:s[l]??a[l]})})}if(i.grid={...t.grid},o.grid){let a=t.grid,s=o.grid;IT.forEach(l=>{Object.assign(i.grid,{[l]:s[l]??a[l]})})}if(i.toObject={...t.toObject},o.toObject){let a=t.toObject,s=o.toObject;NT.forEach(l=>{Object.assign(i.toObject,{[l]:s[l]??a[l]})})}if(i.randomnessObject={...t.randomnessObject},o.randomnessObject){let a=t.randomnessObject,s=o.randomnessObject;DT.forEach(l=>{Object.assign(i.randomnessObject,{[l]:s[l]??a[l]})})}return i}e.merge=r})(Qr||(Qr={}));var yc;(t=>{t.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let r=["radial","linear","grid","toObject","randomnessObject"];function e(o,i){let a=[];o.count!==void 0&&a.push({type:0,path:i,props:{count:o.count}});for(let s of r){let l=o[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...i,s],props:l})}return a}t.toOps=e})(yc||(yc={}));var TT=["count"],AT=["radius","start","end","position","scale","rotation"],MT=["position","scale","rotation"],IT=["count","size"],NT=["count","position","scale","rotation"],DT=["strength","scale","rotation","position","movement","seed","freqScale"];var gc;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function r(t){return e.all.includes(t)}e.is=r})(gc||(gc={}));var xc;(e=>{function n(t){return r(t)}e.defaultData=n;function r(t){if(t==="PointLight")return{type:t,color:Ie.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(t==="SpotLight")return{type:t,color:Ie.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(t==="DirectionalLight")return{type:t,color:Ie.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(xc||(xc={}));var Wi;(t=>(t.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},t.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},t.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:t.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeLoopDelayStart:"end",emitTimeDuration:1,...t.defaultCollisionData}))(Wi||(Wi={}));var nn;(r=>r.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(nn||(nn={}));var Wd;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function r(t,o){return t.castShadow===o.castShadow&&t.receiveShadow===o.receiveShadow}e.equals=r})(Wd||(Wd={}));var qd;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function r(t,o){return t.flatShading===o.flatShading&&t.side===o.side&&t.wireframe===o.wireframe}e.equals=r})(qd||(qd={}));var bc;(r=>r.defaultData={...qd.defaultData,...Wd.defaultData})(bc||(bc={}));var Dg;(r=>{function n(e,t){let o=[];if("material"in e){let i=typeof e.material=="string"?t.materials[e.material]??t.lib.materials[e.material]?.asset:e.material;i&&o.push(i)}else if("materials"in e)for(let i of e.materials){let a=typeof i=="string"?t.materials[i]??t.lib.materials[i]?.asset:i;a&&o.push(a)}return o}r.getMaterialData=n})(Dg||(Dg={}));var qi;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(qi||(qi={}));var Eg;(r=>{function n(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="particle"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}r.is=n})(Eg||(Eg={}));function Bg(n){return n.type!=="displace"}var _g;(r=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}r.is=n})(_g||(_g={}));var Lg=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],Rg=["wrapping","image","video","name","minFilter"],gt;(o=>{function n(i,a){let{texture:s,...l}=a;if(Object.assign(i,l),s){let c=i.texture;c&&Object.assign(c,s)}}o.patch=n;function r(i,a){return i==="light"&&a?e(a):t(i)}o.defaultData=r;function e(i){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(i){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function t(i){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(i){case"texture":return{...a,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:qi.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},crop:!1};case"color":return{...a,type:"color",color:vt.fromHex(ft)};case"depth":return{...a,type:"depth",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]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",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{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...vt.fromHex(6710886),a:1},colorB:{...vt.fromHex(6710886),a:1},colorC:{...vt.fromHex(16777215),a:1},colorD:{...vt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:Ie.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,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,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Ie.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:Ie.fromHexAndA(0,1),contourColor:Ie.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008}};case"transmission":return{...a,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...vt.fromHex(0),a:1},colorB:{...vt.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(gt||(gt={}));var Lt;(c=>{function n(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}c.isMergable=n;function r(u){let p="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([h,f])=>{p+=`${h}${f}`,Array.isArray(f)?f.forEach(m=>p+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?p+=`${m.toFixed(4)}`:p+=`${m}`}):p+=`${f}`})}),p}c.getHash=r;function e(){return{layers:new ve}}c.defaultEmptyData=e;function t(u="layer1",p="layer2"){return i("phong",u,p)}c.defaultData=t;function o(u,p){return{...u,name:p}}c.withName=o;function i(u,p="layer1",d="layer2"){let h=new ve;return h.push({fi:0,data:gt.defaultData("light",u),id:p}),h.push({fi:1,data:gt.defaultData("color"),id:d}),{layers:h}}c.defaultTwoLayerData=i;function a(u){let p=gt.defaultData("texture");u&&Object.assign(p.texture,{image:u});let d=new ve;return d.push({fi:0,data:p,id:"layer1"}),d.push({fi:1,data:{...gt.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...gt.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}c.defaultUIObjectMaterial=a;function s(u,p="phong",d="layer1",h="layer2"){let f=gt.defaultData("texture");Object.assign(f.texture,{image:u});let m=new ve;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:gt.defaultData("light",p),id:h}),{layers:m}}c.defaultTwoLayerTextureData=s;function l(u,p="phong",d="layer1",h="layer2"){let f=gt.defaultData("video");Object.assign(f.texture,{video:u});let m=new ve;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:gt.defaultData("light",p),id:h}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})(Lt||(Lt={}));var $i;(r=>{function n(){return{points:new ve,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n})($i||($i={}));var Yi;(r=>{function n(){return{points:new ve,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}r.defaultData=n})(Yi||(Yi={}));var $d={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var vc;(r=>{function n(e,t){let o={...e};return ET.forEach(i=>{Object.assign(o,{[i]:t[i]??e[i]})}),o}r.merge=n})(vc||(vc={}));var Sc={shape:$d,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},ET=["depth","offset","angle","twist","startScale","endScale"];var Os;(e=>{function n(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"||t==="UIGeometry"}e.is2DParametricMesh=n;function r(t){return t==="PolygonGeometry"||t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"||t==="PathGeometry"||t==="VectorGeometry"||t==="ConeGeometry"||t==="CubeGeometry"||t==="CylinderGeometry"||t==="DodecahedronGeometry"||t==="HelixGeometry"||t==="IcosahedronGeometry"||t==="LatheGeometry"||t==="PyramidGeometry"||t==="SphereGeometry"||t==="PlaneGeometry"||t==="BackdropGeometry"||t==="TorusGeometry"||t==="TorusKnotGeometry"||t==="BooleanGeometry"||t==="TextGeometry"}e.isParametricMesh=r})(Os||(Os={}));var wc;(r=>{function n(e,t){let o={...e};return Object.assign(o,t),o.type==="PathGeometry"&&"extrusion"in t&&t.extrusion&&(o.extrusion={...e.extrusion},Object.assign(o.extrusion,vc.merge(o.extrusion,t.extrusion))),o}r.merge=n})(wc||(wc={}));var an;(r=>{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};if(e==="UIGeometry")return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:Yi.defaultData(),extrusion:Sc};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:$i.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}r.defaultData=n})(an||(an={}));var Pc;(r=>r.defaultData={enabled:!1,useBackgroundColor:!1,color:vt.white,near:.1,far:2e3})(Pc||(Pc={}));var Oc;(e=>{let n={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...n,blendFunction:16,granularity:15},bloom:{...n,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...n,offset:[2,2]},vignette:{...n,darkness:1,offset:0},hueSaturation:{...n,hue:3,saturation:0},brightnessContrast:{...n,brightness:.25,contrast:0},depthOfField:{...n,focalLength:2,focusDistance:2,bokehScale:2},noise:{...n,blendFunction:16}}})(Oc||(Oc={}));var Yd;(r=>r.defaultData={softShadowQuality:"low"})(Yd||(Yd={}));var Xd;(r=>r.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Xd||(Xd={}));var Kd;(r=>r.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Kd||(Kd={}));var Cs;(r=>r.defaultData={usePhysics:!1,gravity:-10})(Cs||(Cs={}));var Qd;(r=>r.defaultData={playCamera:tn,gameControlObject:null})(Qd||(Qd={}));var Cc;(r=>r.defaultData={backgroundColor:Ie.fromHexAndA(Ng,1),postprocessing:Oc.defaultData,fog:Pc.defaultData,globalPhysics:Cs.defaultData,ambient:Xd.defaultData,ao:Kd.defaultData,shadow:Yd.defaultData,publish:Qd.defaultData})(Cc||(Cc={}));var Tc;(r=>r.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(Tc||(Tc={}));var Vg;(e=>{function n(t){return t==="Component"||t==="Instance"}e.isComponentRelated=n;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(Vg||(Vg={}));var Xi;(o=>{o.identity={...mc.identity,hiddenMatrix:en.identity};function r(i){return{position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix}}o.fromObject=r;function e(i,a){return{position:a?.position||i.position,rotation:a?.rotation||i.rotation,scale:a?.scale||i.scale,hiddenMatrix:a?.hiddenMatrix||i.hiddenMatrix}}o.merge=e;function t(i,a){return Cl({position:Jo.isEqual(i.position,a.position)?void 0:a.position,rotation:Jo.isEqual(i.rotation,a.rotation)?void 0:a.rotation,scale:Jo.isEqual(i.scale,a.scale)?null:a.scale,hiddenMatrix:en.isEqual(i.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=t})(Xi||(Xi={}));var St;(r=>r.defaultData={states:new ve,events:new ve,visible:!0,raycastLock:!1,physics:nn.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Xi.identity,cloner:null})(St||(St={}));var Ac;(r=>r.defaultData={type:"Empty",...St.defaultData})(Ac||(Ac={}));var zg;(r=>r.defaultData={type:"ParticleCollider",...Tc.defaultData,...St.defaultData})(zg||(zg={}));var Gg;(r=>r.defaultData={type:"Component",...St.defaultData})(Gg||(Gg={}));var jg;(r=>r.defaultData={type:"Particle",...St.defaultData,...Wi.defaultData})(jg||(jg={}));var zn;(r=>r.defaultData={type:"Mesh",...St.defaultData,...bc.defaultData})(zn||(zn={}));var Gn;(r=>r.defaultData={...St.defaultData,...Xi.identity,position:[0,0,on.DefaultTargetOffset],...on.defaultData})(Gn||(Gn={}));var Mc;(e=>{function n(t){return{...St.defaultData,...xc.defaultData(t)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Mc||(Mc={}));var Ki;(e=>{function n(t,o,i=0){for(;i<o.length;){let a=t?t[o[i]]:void 0;if(o.length===i+1)return a;if(a)t=a.descendants,i+=1;else return}}e.resolveWithDes=n;function r(t,o,i=0){let a=n(t,o,i);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=r})(Ki||(Ki={}));var Zr;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function t(a,s){return{...St.defaultData,...s,component:a,overrides:new Ke,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=t;function o(a){let s=Xi.fromObject(a.data);return t(a.id,s)}i.fromComponentData=o})(Zr||(Zr={}));var Po;(e=>{e.defaultData={type:"Page",...St.defaultData,physics:{...nn.defaultData,fusedBody:!1},...Cc.defaultData,camera:Gn.defaultData};function r(t){return t.uiScene!==void 0}e.isUIPage=r})(Po||(Po={}));var Ic;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:en.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:nn.defaultData,states:new ve,events:new ve,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...on.defaultData},i.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},i.defaultMeshObject={name:"Rectangle",...St.defaultData,...zn.defaultData,geometry:an.defaultData("RectangleGeometry"),material:Lt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...St.defaultData,...zn.defaultData,geometry:an.defaultData("BooleanGeometry"),material:Lt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...St.defaultData,...zn.defaultData,geometry:an.defaultData("TextGeometry"),material:Lt.defaultTwoLayerData("phong","layer1","layer2")}))(Ic||(Ic={}));var jn;(o=>{function n(i,a){let s={name:a};return i.type==="Mesh"?(s.geometry={},"material"in i&&(s.material={layers:new Ke}),"materials"in i&&(s.materials=i.materials.map(l=>({layers:new Ke})))):Ir.is(i.type)&&(s.perspective={},s.orthographic={}),s}o.newEmpty=n;function r(i,a){if(a===void 0)return i;let s={...i};return"material"in s&&"material"in a&&a.material&&(s.material=Xo(s.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(a.material.layers)){let p=l.layers.data(c);p&&gt.patch(p,u)}}).data),s.materials&&a.materials&&(s.materials=Xo(s.materials,l=>{for(let c=0;c<s.materials.length;c++){let u=a.materials[c];if(typeof u!="string")for(let[p,d]of Object.entries(u.layers)){let h=l[c]?.layers?.data(p);h&&gt.patch(h,d)}}}).data),s}function e(i,a){let s,l=[],c={orthographic:0,perspective:0,geometry:0};function u(p,d){for(let[h,f]of Object.entries(d.layers)){let{texture:m,...y}=f;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...p,"layers",h,"texture"],props:m,type:0};l.push(g)}if(Object.keys(y).length>0){let g={path:[...p,"layers",h],props:y,type:0};l.push(g)}}}for(let[p,d]of Object.entries(a))if(p!=="name")if(p==="cloner")l.push(...yc.toOps(d,["cloner"]));else if(p==="pathSnapping")l.push({path:[p],props:{slide:d.slide,offset:d.offset},type:0});else if(p==="material")u(["material"],d);else if(p==="materials")for(let[h,f]of Object.entries(d))u(["materials",h],f);else if(c[p]===0){if(p==="geometry"&&d.extrusion!==void 0){let h={path:[p,"extrusion"],props:d.extrusion,type:0};l.push(h),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let h={path:[p],props:d,type:0};l.push(h)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[p]=d;return l}o.toOps=e;function t(i,a){if(a===void 0)return i;let s={...i};if(Object.assign(s,Xi.merge(s,a)),Object.assign(s,{pathSnapping:Object.assign({},s.pathSnapping,{slide:a.pathSnapping?.slide??s.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??s.pathSnapping?.offset??0})}),Ir.is(i.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let l=a;l.orthographic?.zoom!==void 0&&(s.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(s.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(s.targetOffset=l.targetOffset)}else if(i.type==="Mesh")"geometry"in a&&Object.assign(s,{geometry:wc.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=r(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Qr.merge(s.cloner,a.cloner)});else if(i.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Qr.merge(s.cloner,a.cloner)});else if(gc.is(i.type)){let l=a;l.intensity!==void 0&&(s.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?s.color=l.color:s.color=vt.clone(l.color))}return s}o.patch=t})(jn||(jn={}));var Qi;(r=>r.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Qi||(Qi={}));var Nr;(r=>r.defaultData={orbitControls:Qi.defaultData,playPage:rn,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,t)=>{let o=0,i=0;return t<5?i=-30:t<10&&(i=30),t===0||t===10||t===5?o=30:(t===4||t===11||t===9)&&(o=-30),[120,[o,i],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Nr||(Nr={}));var Zd;(r=>r.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Zd||(Zd={}));var Jd;(r=>r.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Jd||(Jd={}));var Oo;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Zd.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Jd.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Oo||(Oo={}));var Fg;(e=>{function n(t){return t.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=n;function r(t,o,i){t.scene.objects.traverseFrom(o,(a,s)=>{if(s.type==="Instance"){let l=Zi.getComponentData(t,s.component)?.data;l&&i(a,s,l.events)}else i(a,s,s.events)})}e.traverseModuleInstances=r})(Fg||(Fg={}));var Co;(l=>{l.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function r(c=!0){let u=[],p=Ic.defaultMeshObject;c&&(u.push({fi:-1,data:Mc.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),u.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:p,children:[]}));let d=new Xe;return d.push({fi:1,id:rn,data:{...Po.defaultData,name:"Scene 1"},children:u}),d}l.defaultData={objects:r(),publish:Nr.defaultData,styles:Oo.defaultData()},l.emptyDataWithoutPage=function(){return{objects:new Xe,publish:Nr.defaultData,styles:Oo.defaultData()}},l.emptyDataWithPage=function(c=!0){return{objects:r(c),publish:Nr.defaultData,styles:Oo.defaultData()}},l.emptyData=function(){return{objects:new Xe,publish:{...Nr.defaultData},styles:Oo.defaultData()}};function a(c){return{...l.defaultData,objects:Ht(c,Xe.prototype)}}l.withObjs=a;function s(c,u){return a([{id:c,data:u,children:[],fi:0}])}l.withObj=s})(Co||(Co={}));var Ji;(r=>r.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Ji||(Ji={}));var Nc;(i=>{function n(a){return a.textValue!==void 0}i.isTextValue=n;function r(a){return typeof a=="number"}i.isNumber=r;function e(a){return typeof a=="boolean"}i.isBoolean=e;function t(a){return n(a)?"string":e(a)?"boolean":"number"}i.typeOfVariable=t;function o(a){return i.isTextValue(a)?Array.isArray(a.textValue)?a.textValue.map(s=>s.toString().padStart(a.padding??2,"0")).join(a.deliminator??":")+(a.suffix!==void 0?" "+a.suffix:""):a.textValue.toString():i.isBoolean(a)?a?"True":"False":i.isNumber(a)?parseFloat(a.toFixed(3)).toString():a.toString()}i.getDisplayedValue=o})(Nc||(Nc={}));var ep;(r=>r.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(ep||(ep={}));var Ug;(r=>r.all=[...ep.all,"components"])(Ug||(Ug={}));var kg;(r=>{function n(){return{images:new xe,videos:new xe,colors:new xe,audios:new xe,particles:new xe,fonts:new xe,materials:new xe,components:new xe,variables:new xe}}r.defaultData=n})(kg||(kg={}));var To;(r=>{function n(){return{images:new xe,videos:new xe,colors:new xe,audios:new xe,particles:new xe,fonts:new xe,materials:new xe,components:new xe,variables:new xe}}r.defaultData=n})(To||(To={}));var xr;(i=>{function n(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ht(a,xe.prototype)}i.defaultColors=n;function r(){return Ht({},xe.prototype)}i.defaultImages=r;function e(){return{catelogs:new xe,materials:new xe,images:new xe,videos:new xe,colors:new xe,audios:new xe,particles:new xe,fonts:new xe,variables:new ve,lib:To.defaultData()}}i.emptyData=e;function t(a){switch(a){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let s=[0,0,0];return{name:"Time",value:{textValue:s,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:s,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",a)}}i.defaultVariables=t;function o(a,s){if(s.format==="HH:mm:ss"){let l=Math.floor(a/3600),c=Math.floor((a-l*3600)/60),u=Math.round(a-l*3600-c*60);return{textValue:[l,c,u]}}else if(s.format==="mm:ss"){let l=Math.floor(a/60),c=Math.round(a-l*60);return{textValue:[l,c]}}else return s.format==="number"?a=Math.round(a):a=Math.round(a*1e3)/1e3,a}i.getFormattedTimerTime=o})(xr||(xr={}));import{MathUtils as _c}from"three";var Dc;(r=>r.list=["idle","move","jump","run"])(Dc||(Dc={}));var Ec;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new ve,move:new ve,jump:new ve,run:new ve},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Ie.fromHexAndA(3728051,1)}}))(Ec||(Ec={}));function Hg(n){n.layers.forEach(r=>{if(r.type==="depth"&&r.colorA!==void 0){let e=r.colorA,t=r.colorB,o=[[e.r,e.g,e.b,e.a],[t.r,t.g,t.b,t.a]],i=[0,1];for(let s=2;s<10;s++)o.push(o[1]),i.push(1);let a={...Mr(ct(r),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,r.near),far:Math.max(0,r.far),colors:o,steps:i,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(r,a)}else if(r.type==="depth"&&r.gradientType===1&&(r.near<0||r.far<0)){let e={...ct(r),near:Math.max(r.near,0),far:Math.max(r.far,0)};Object.assign(r,e)}})}function Ao(n,r){Object.values(n.shared.materials).forEach(e=>r(e))}function Mo(n,r){n.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach((o,i)=>{o===void 0&&(t.materials[i]=Lt.defaultData(),o=t.materials[i]),typeof o!="string"&&r(o)}):"material"in t?typeof t.material!="string"&&(t.material===void 0&&(t.material=Lt.defaultData()),r(t.material)):t.type==="Mesh"&&(t.material===void 0&&(t.material=Lt.defaultData()),r(t.material)),"overrides"in t&&Object.values(t.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&Object.getPrototypeOf(o.material)!==Ke.prototype&&r(o.material)})})}function _T(n){Object.assign(n.scene.publish,{orbitControls:{...Qi.defaultData,...ct(n.scene.publish.orbitControls)}})}function BT(n){Object.assign(n.scene.publish.settings,{video:{...Nr.defaultData.settings.video,...ct(n.scene.publish.settings.video)}})}function LT(n){function r(e){if(e.layers){for(let t of Object.values(e.layers))if(t){for(let[o,i]of Object.entries(t))if((Lg.includes(o)||typeof i=="boolean")&&delete t[o],o==="texture")for(let[a,s]of Object.entries(i))(Rg.includes(a)||typeof s=="boolean")&&delete i[a]}}}n.scene.objects.traverse((e,t)=>{t.states.forEach(o=>{let i=o;i.material?r(i.material):i.materials&&i.materials.forEach(a=>{r(a)})})})}function RT(n){n.scene.publish.withBackground=!0}function VT(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function zT(n){n.scene.objects.traverse((r,e)=>{let t=e.cloner;t&&(t.radial.scale=t.radial.scale.map(o=>o+1),t.linear.scale=t.linear.scale.map(o=>o+1))})}function GT(n){n.scene.objects.traverse((r,e)=>{let t=e.geometry;t&&(t.type==="DodecahedronGeometry"||t.type==="IcosahedronGeometry")&&(t.detail=Math.round(t.detail))})}function jT(n){n.scene.objects.traverse((r,e)=>{let t=n.scene.objects.unproxy().parent(r);if(t){let o=ct(n.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=ct(e).booleanExclude!==!0)}})}function FT(n){n.scene.objects.traverse((r,e)=>{if(e.type==="Mesh"){let t=e;e.geometry.type==="NonParametricGeometry"?t.material!==void 0&&delete t.material:t.materials!==void 0&&delete t.materials}})}function UT(n){function r(t){Object.setPrototypeOf(t,Ke.prototype),t.texture&&Object.setPrototypeOf(t.texture,Ke.prototype)}function e(t){Object.setPrototypeOf(t,Ke.prototype);for(let o in t)r(t[o])}n.scene.objects.traverse((t,o)=>{o.states.forEach(i=>{let a=i;if(a.material){let s=ct(a.material).layers;e(s),a.material.layers=s}if(a.materials)for(let s=0;s<a.materials.length;s++){let l=a.materials[s],c=ct(l).layers;e(c),l.layers=c}})})}function Wg(n){n.layers===void 0&&Object.assign(n,Lt.defaultTwoLayerData("lambert"))}function tp(n){!n.layers||n.layers.forEach(r=>{if(r.type==="depth"&&r.colors.length===10){let e=[...r.colors];e.push(r.colors[9]);let t=[...r.steps];t.push(r.steps[9]);let o={...ct(r),colors:e,steps:t};Object.assign(r,o)}})}function kT(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function qg(n){n.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&tp(t)}):"material"in e&&typeof e.material!="string"&&tp(e.material)}),Object.values(n.shared.materials).forEach(r=>tp(r))}function HT(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((r,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}function WT(n){n.shared.audios=Ht({},xe.prototype)}function qT(n){n.shared.videos=Ht({},xe.prototype)}function $T(n){let r=n.shared.materials;Object.entries(r).forEach(([e,t])=>{if(!t.layers){let o={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(r,{[e]:o})}})}function YT(n){Object.entries(ct(n.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.images[t]}),Object.entries(ct(n.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.audios[t]})}function XT(n){n.scene.publish.settings.web.preload=!1}function $g(n){n.layers&&n.layers.forEach(r=>{r.type==="depth"&&r.num!==void 0&&(r.colors=r.colors.slice(0,r.num),r.steps=r.steps.slice(0,r.num),delete r.num)})}function Yg(n){n.layers&&n.layers.forEach(r=>{Bg(r)&&r.isMask===void 0&&(r.isMask=!1),(r.type==="texture"||r.type==="video")&&r.blending===void 0&&(r.blending=0),(r.type==="noise"||r.type==="displace"&&r.displacementType==="noise")&&(r.voronoiStyle===void 0&&(r.voronoiStyle=0),r.highCut===void 0&&(r.highCut=1),r.lowCut===void 0&&(r.lowCut=0),r.smoothness===void 0&&(r.smoothness=.3),r.seed===void 0&&(r.seed=0),r.quality===void 0&&(r.quality=1))})}function KT(n){n.shared.fonts=Ht({},xe.prototype)}function QT(n){return n.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function ZT(n){let r=[];n.scene.objects.traverse((e,t)=>{let o=t;if(o.type==="TextFrame"){let i=Lt.defaultTwoLayerData("phong"),a=typeof o.color=="string"?n.shared.colors[o.color]:o.color;i.layers[1].data.color={r:a.r,g:a.g,b:a.b},i.layers[1].data.alpha=o.alpha;let s=QT(o.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let l={name:o.name,...St.defaultData,...zn.defaultData,flatShading:!1,wireframe:!1,geometry:{...an.defaultData("TextGeometry"),width:o.width,height:o.height,font:s,depth:0,horizontalAlign:o.horizontalAlign,verticalAlign:o.verticalAlign,fontSize:o.fontSize*1.40625,lineHeight:o.lineHeight/1.40625,letterSpacing:o.letterSpacing-1,text:o.text,textTransform:o.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:i,states:ct(o.states),events:ct(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},c=ct(n.scene.objects).parent(e);n.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),r.push(e)}}),r.forEach(e=>{n.scene.objects.delete(e)})}function JT(n){let r={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};n.scene.objects.traverse((e,t)=>{t.events.forEach(o=>{if(!!r[Number(o.type)])if(Object.assign(o,{type:r[Number(o.type)]}),o.type==="Audio"&&"audioEvent"in o&&(Object.assign(o,{playAudio:o.audioEvent}),delete o.audioEvent),o.type==="GameControl")Object.assign(o,{gameActions:{idle:new ve,move:new ve,jump:new ve}});else{let i=new ve;Object.assign(o,{actions:i}),(o.type==="MouseDown"||o.type==="MouseUp"||o.type==="KeyDown"||o.type==="KeyUp")&&"url"in o&&i.push({fi:0,id:_c.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((a,s,l)=>{let c={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(u,Mr(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(u,{control1:{...a.control1},control2:{...a.control2}});let p={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},d={state:a.state,...p,...u},h={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ve({fi:0,id:_c.generateUUID(),data:c},{fi:1,id:_c.generateUUID(),data:d})};i.push({fi:l,id:s,data:h})}),delete o.targets)}})})}function eA(n){n.scene.objects.traverse((r,e)=>{function t(o,i){let a=new ve,s=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===i){let p;s.push(c),l.interaction==="play"?p={...Mr(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(p={...Mr(l,"interaction","delay","object","playAudio"),type:"Audio"}),p&&a.push({fi:u,id:c,data:p})}}),s.forEach(l=>e.events.delete(l)),a.length){let l=e.events.find(c=>c.type===o)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):e.events.insertBefore(null,[{id:_c.generateUUID(),data:{type:o,actions:a}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function Xg(n){let r=n.layers.find(e=>e.type==="light")?.data;if(r?.category==="basic"){let e=gt.defaultData("light","phong"),t=r;Object.assign(t,e),t.visible=!1}}function Kg(n){Ao(n,Xg),Mo(n,Xg)}function tA(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function rA(n){n.scene.objects.traverse((r,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function oA(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Lt.defaultTwoLayerData("phong"))})}function nA(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((r,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function iA(n){n.scene.objects.traverse((r,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function aA(n){n.scene.publish.mouseEventTarget===void 0&&(n.scene.publish.mouseEventTarget="canvas"),n.scene.publish.settings.web.hint===void 0&&(n.scene.publish.settings.web.hint=!1)}function sA(n){let{video:r}=n.scene.publish.settings;r.format==="gif"&&r.fps>48&&(r.fps=15)}function lA(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.resetYPosition=Math.abs(t.resetYPosition-e.position[1]))})})}function cA(n){let r=n.scene.environment.usePhysics;n.scene.objects.traverse((e,t)=>{r&&t.physics===null?t.collision=!1:t.collision="visibility"})}function uA(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.navmesh=Ec.defaultDataThirdPerson.navmesh)})})}function dA(n){n.scene.styles||(n.scene.styles=Oo.defaultData())}function Qg(n){n.layers.forEach(r=>{r.type==="light"&&r.category!=="toon"&&r.occlusion===void 0&&(r.occlusion=!0)})}function pA(n){n.scene.environment.ambientLight.occlusion===void 0&&(n.scene.environment.ambientLight.occlusion=!1),n.scene.environment.ambientLight.aoFullRes===void 0&&(n.scene.environment.ambientLight.aoFullRes=!1),n.scene.environment.ambientLight.radius===void 0&&(n.scene.environment.ambientLight.radius=256),n.scene.environment.ambientLight.bias===void 0&&(n.scene.environment.ambientLight.bias=.5),n.scene.environment.ambientLight.aoColor===void 0&&(n.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Mo(n,Qg),Ao(n,Qg)}function fA(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&Object.assign(t.gameActions,{run:new ve})})})}function hA(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.keyAssignments=[...t.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function Zg(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.bumpMapIntensity===void 0&&(r.bumpMapIntensity=5)})}function Jg(n,r){if(r<1&&(Mo(n,Hg),Ao(n,Hg),n.schema=1),r<2&&(_T(n),n.schema=2),r<3&&(LT(n),n.schema=3),r<4&&(RT(n),n.schema=4),r<5&&(VT(n),n.schema=5),r<6&&(zT(n),n.schema=6),r<7&&(GT(n),n.schema=7),r<8&&(n.schema=8),r<9&&(qg(n),n.schema=9),r<10&&(kT(n),n.schema=10),r<11&&(HT(n),n.schema=11),r<12&&(qg(n),n.schema=12),r<13&&(WT(n),n.schema=13),r<14&&($T(n),n.schema=14),r<15&&(YT(n),n.schema=15),r<16&&(XT(n),n.schema=16),r<17&&(Mo(n,$g),Ao(n,$g),n.schema=17),r<18&&(Mo(n,Wg),Ao(n,Wg),n.schema=18),r<19&&(BT(n),n.schema=19),r<20&&(KT(n),ZT(n),n.schema=20),r<21&&(JT(n),eA(n),n.schema=21),r<22&&(Kg(n),n.schema=22),r<23&&(tA(n),n.schema=23),r<24&&(rA(n),n.schema=24),(r<25||n.shared.videos===void 0)&&(qT(n),r<25&&(n.schema=25)),r<26&&(jT(n),n.schema=26),r<27&&(FT(n),n.schema=27),r<28&&(Kg(n),n.schema=28),r<29&&(UT(n),n.schema=29),r<30&&(oA(n),n.schema=30),r<31&&(nA(n),n.schema=31),r<33&&(iA(n),n.schema=33),r<34&&(aA(n),n.schema=34),r<35&&(sA(n),n.schema=35),r<36&&(lA(n),n.schema=36),r<37&&(cA(n),n.schema=37),r<38&&(Mo(n,Yg),Ao(n,Yg),n.schema=38),r<39&&(uA(n),n.schema=39),r<40&&(dA(n),n.schema=40),r<41&&(pA(n),n.schema=41),r<42&&(fA(n),n.schema=42),r<43&&(hA(n),n.schema=43),r<99){Mo(n,Zg),Ao(n,Zg),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=tn);let e=ct(n.scene.objects),t=n.scene.objects;n.scene.publish.playPage=rn,t.insertBefore(null,null,[{id:rn,data:{...Po.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:Mr(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:Mr(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Cs.defaultData,...Mr(n.scene.environment,"usePhysics","gravity")},camera:ct(n.scene.ownerCamera)??Po.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==Co.TRASH_CAN_ID&&t.move(rn,a.fi,a.id);let o=0,i=0;n.shared.penumbraSize&&n.scene.objects.traverse((a,s)=>{s.type==="DirectionalLight"?(s.penumbraSize=n.shared.penumbraSize[Math.min(o,2)],o+=1):s.type==="SpotLight"&&(s.penumbraSize=n.shared.penumbraSize[3+Math.min(i,1)],i+=1),(s.physics===void 0||s.physics===null)&&s.type!=="Instance"&&(s.physics={},Object.assign(s.physics,nn.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),n.schema=99}}function e0(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.alphaOverride===void 0&&(r.alphaOverride=1)})}function mA(n){n.scene.objects.traverse((r,e)=>{let t=e.geometry;t&&t.type==="PathGeometry"&&(t.extrusion.capType="flat",t.extrusion.bevel=50,t.extrusion.bevelSides=6,t.extrusion.shape.type==="Custom"&&(t.extrusion.shape.shapeQuality="low"))})}function yA(n){Array.isArray(ct(n.events))&&n.events?.forEach(r=>{"disabled"in r||(r.disabled=!1),(r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress")&&(r.mode=r.mode||"Object")})}var ea=180/Math.PI;function t0(n){n.rotation=n.rotation.slice(0,3).map(r=>r*ea)}function r0(n){t0(n),n.type==="Page"&&t0(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(t=>t*ea))});let r=n.geometry;r&&r.type==="SphereGeometry"&&(r.thetaLength=(r.thetaLength??180)*ea),r&&r.type==="TorusGeometry"&&(r.arc=r.arc*ea),r&&r.type==="PathGeometry"&&(r.extrusion.angle*=ea,r.extrusion.twist*=ea),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(ct(n.events))&&n.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Repeat")})}function gA(n){n.shared.variables=Ht({},xe.prototype)}function xA(n){let r=ct(n.shared.variables);n.shared.variables=Ht(Object.entries(r??{}).map(([e,t],o)=>({fi:o,id:e,data:t})),ve.prototype)}var Jr=111;function o0(n,r){r(n.data);for(let e of n.children)o0(e,r)}function bA(n){let r=n.schema??104;r!==Jr&&r<105&&(o0(n.asset,r0),n.schema=105)}function vA(n){n.shared.particles=Ht({},xe.prototype),n.shared.lib&&(n.shared.lib.particles=To.defaultData().particles)}function SA(n){n.scene.objects.traverse((r,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function Bc(n){let r=n.schema??0;if(r!==Jr){console.warn("updating from ",r,"to ",Jr),Jg(n,r),r<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Nr.defaultData.joystickSizeAndXYOffset),n.schema=100),r<101&&(Mo(n,e0),Ao(n,e0),n.schema=101),r<102&&(mA(n),n.schema=102),r<104&&(n.shared.catelogs=new xe,n.shared.lib=To.defaultData(),n.schema=104),r<105&&(gA(n),n.scene.objects.traverse((e,t)=>{r0(t)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))bA(e);r<106&&(xA(n),n.schema=106),r<107&&(n.shared.lib.variables=To.defaultData().variables,n.schema=107),r<109&&(vA(n),n.schema=109),r<110&&(SA(n),n.schema=110),r<111&&(n.scene.objects.traverse((e,t)=>{yA(t)}),n.schema=111)}}var Zi;(l=>{l.defaultData={schema:Jr,scene:Co.defaultData,frames:new xe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ji.defaultData),shared:{...xr.emptyData(),colors:xr.defaultColors()}},l.emptyDataForImports=function(){let c=Co.emptyDataWithPage();return{schema:Jr,scene:c,frames:new xe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ji.defaultData),shared:{...xr.emptyData(),colors:xr.defaultColors(),images:xr.defaultImages()}}},l.emptyData=function(){return{schema:Jr,scene:Co.emptyDataWithPage(),frames:new xe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ji.defaultData),shared:xr.emptyData()}},l.clipboard2dData=function(){return{schema:Jr,scene:Co.emptyData(),frames:new xe,shared:xr.emptyData()}},l.collabHelper={...bs,updateSchema(c){return(c.schema??0)<Jr?Xo(c,Bc):(c.schema??0)-Jr}};function i(c){let u=l.collabHelper.updateSchema(c);return typeof u=="number"?u===0?c:null:u.data}l.updateSchemaDirectly=i;function a(c){return{...c,shared:{...c.shared,lib:To.defaultData()}}}l.withoutLib=a;function s(c,u){let p=c.scene.objects.get(u);if(p&&p.data.type==="Component")return p;{let d=c.shared.lib.components[u];if(d)return d.asset}}l.getComponentData=s})(Zi||(Zi={}));var Lc;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Lc||(Lc={}));var n0;(r=>{function n(e){return!0}r.is=n})(n0||(n0={}));var Rc;(t=>{t.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function r(o,i){return{position:i?.position??o.position,rotation:i?.rotation??o.rotation,scale:i?.scale??o.scale,shear:i?.shear??o.shear}}t.merge=r;function e(o,i){return Cl({position:Hi.isEqual(o.position,i.position)?void 0:i.position,rotation:o.rotation===i.rotation?void 0:i.rotation,scale:Hi.isEqual(o.scale,i.scale)?void 0:i.scale,shear:o.shear&&i.shear&&Hi.isEqual(o.shear,i.shear)?void 0:i.shear})}t.diff=e})(Rc||(Rc={}));var rp;(r=>r.defaultData={horizontalConstraint:0,verticalConstraint:0})(rp||(rp={}));var Vc;(r=>r.defaultData={opacity:1,fill:{color:Ie.fromHexAndA(ft,1),enabled:!0},stroke:{color:Ie.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Ie.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Ie.from0to1([0,0,0,1]),enabled:!1,spread:0}})(Vc||(Vc={}));var Fn;(i=>{function n(a,s){return{name:s}}i.newEmpty=n;function r(a,s){if(s===void 0)return a;let l={...a},c=["width","height","cornerRadius"];for(let u of c)u in l&&u in s&&s[u]!==void 0&&Object.assign(l,{[u]:s[u]});return l}function e(a,s){if(s===void 0)return a;let l={...a};return"fill"in l&&"fill"in s&&s.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...s.fill}}),"stroke"in l&&"stroke"in s&&s.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...s.stroke}}),"layerBlur"in l&&"layerBlur"in s&&s.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...s.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in s&&s.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...s.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in s&&s.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...s.dropShadow}}),"innerShadow"in l&&"innerShadow"in s&&s.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...s.innerShadow}}),l}function t(a,s){if(s===void 0)return a;let l={...a};return Object.assign(l,Rc.merge(l,s)),l=r(l,s),l=e(l,s),l}i.patch=t;function o(a,s){let l,c=[];for(let[u,p]of Object.entries(s))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[u]=p);return c}i.toOps=o})(Fn||(Fn={}));var Ts;(r=>r.defaultData={...Rc.defaultData,...rp.defaultData,states:new ve,events:new ve,visible:!0,raycastLock:!1})(Ts||(Ts={}));var ta;(r=>r.defaultData={...Ts.defaultData,...Vc.defaultData})(ta||(ta={}));var zc;(r=>r.defaultData={cornerRadius:[0,0,0,0]})(zc||(zc={}));var op;(r=>r.defaultData={...ta.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(op||(op={}));var ra;(r=>r.defaultData={...ta.defaultData,...zc.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(ra||(ra={}));var np;(r=>r.defaultData={...ta.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(np||(np={}));var ip;(r=>r.defaultData={...ta.defaultData,type:"path2d",path:"",name:"Path"})(ip||(ip={}));var i0;(r=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}r.is=n})(i0||(i0={}));var As;(r=>r.defaultData={...Ts.defaultData,name:"Group",type:"group2d"})(As||(As={}));var ap;(r=>r.defaultData=()=>({...Ts.defaultData,...zc.defaultData,...Vc.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Ie.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Ie.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(ap||(ap={}));var Io;(o=>{function n(i){switch(i){case"rectangle2d":return{...ra.defaultData};case"ellipse2d":return{...op.defaultData};case"text2d":return{...np.defaultData};case"vector2d":return{...ra.defaultData};case"path2d":return{...ip.defaultData};case"frame2d":return{...ap.defaultData()};case"group2d":return{...As.defaultData}}}o.defaultData=n;function r(i){return"width"in i&&"height"in i?[typeof i.width=="number"?i.width*.5:0,typeof i.height=="number"?i.height*.5:0]:[0,0]}o.getPivot=r;function e(i){return i.type==="rectangle2d"||i.type==="ellipse2d"||i.type==="text2d"||i.type==="frame2d"}o.isResizeable=e;function t(i){return i.type==="rectangle2d"||i.type==="frame2d"}o.hasCorners=t})(Io||(Io={}));var Gc;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new Xe},e.emptyData=function(){return{type:"scene2d",objects:new Xe}}))(Gc||(Gc={}));var Za=fi(s0());import{Object3D as b3,Vector3 as pr,Euler as kf,MathUtils as Ub,Matrix4 as ni}from"three";var wA=.5*(Math.sqrt(3)-1),Ms=(3-Math.sqrt(3))/6,PA=1/3,eo=1/6,q5=(Math.sqrt(5)-1)/4,$5=(5-Math.sqrt(5))/20,Is=n=>Math.floor(n)|0,l0=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),lp=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function jc(n=Math.random){let r=u0(n),e=new Float64Array(r).map(o=>l0[o%12*2]),t=new Float64Array(r).map(o=>l0[o%12*2+1]);return function(i,a){let s=0,l=0,c=0,u=(i+a)*wA,p=Is(i+u),d=Is(a+u),h=(p+d)*Ms,f=p-h,m=d-h,y=i-f,g=a-m,v,O;y>g?(v=1,O=0):(v=0,O=1);let P=y-v+Ms,S=g-O+Ms,T=y-1+2*Ms,I=g-1+2*Ms,x=p&255,_=d&255,D=.5-y*y-g*g;if(D>=0){let E=x+r[_],B=e[E],V=t[E];D*=D,s=D*D*(B*y+V*g)}let A=.5-P*P-S*S;if(A>=0){let E=x+v+r[_+O],B=e[E],V=t[E];A*=A,l=A*A*(B*P+V*S)}let N=.5-T*T-I*I;if(N>=0){let E=x+1+r[_+1],B=e[E],V=t[E];N*=N,c=N*N*(B*T+V*I)}return 70*(s+l+c)}}function c0(n=Math.random){let r=u0(n),e=new Float64Array(r).map(i=>lp[i%12*3]),t=new Float64Array(r).map(i=>lp[i%12*3+1]),o=new Float64Array(r).map(i=>lp[i%12*3+2]);return function(a,s,l){let c,u,p,d,h=(a+s+l)*PA,f=Is(a+h),m=Is(s+h),y=Is(l+h),g=(f+m+y)*eo,v=f-g,O=m-g,P=y-g,S=a-v,T=s-O,I=l-P,x,_,D,A,N,E;S>=T?T>=I?(x=1,_=0,D=0,A=1,N=1,E=0):S>=I?(x=1,_=0,D=0,A=1,N=0,E=1):(x=0,_=0,D=1,A=1,N=0,E=1):T<I?(x=0,_=0,D=1,A=0,N=1,E=1):S<I?(x=0,_=1,D=0,A=0,N=1,E=1):(x=0,_=1,D=0,A=1,N=1,E=0);let B=S-x+eo,V=T-_+eo,j=I-D+eo,R=S-A+2*eo,W=T-N+2*eo,F=I-E+2*eo,k=S-1+3*eo,H=T-1+3*eo,$=I-1+3*eo,J=f&255,Z=m&255,X=y&255,te=.6-S*S-T*T-I*I;if(te<0)c=0;else{let q=J+r[Z+r[X]];te*=te,c=te*te*(e[q]*S+t[q]*T+o[q]*I)}let Y=.6-B*B-V*V-j*j;if(Y<0)u=0;else{let q=J+x+r[Z+_+r[X+D]];Y*=Y,u=Y*Y*(e[q]*B+t[q]*V+o[q]*j)}let ee=.6-R*R-W*W-F*F;if(ee<0)p=0;else{let q=J+A+r[Z+N+r[X+E]];ee*=ee,p=ee*ee*(e[q]*R+t[q]*W+o[q]*F)}let K=.6-k*k-H*H-$*$;if(K<0)d=0;else{let q=J+1+r[Z+1+r[X+1]];K*=K,d=K*K*(e[q]*k+t[q]*H+o[q]*$)}return 32*(c+u+p+d)}}function u0(n){let e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){let o=t+~~(n()*(256-t)),i=e[t];e[t]=e[o],e[o]=i}for(let t=256;t<512;t++)e[t]=e[t-256];return e}import{Triangle as OA}from"three";var Dr=new OA,Fc=class{constructor(r){this.weightAttribute=null;let e=r.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let r=this.positionAttribute,e=new Float32Array(r.count/3);for(let o=0;o<r.count;o+=3){let i=1;Dr.a.fromBufferAttribute(r,o),Dr.b.fromBufferAttribute(r,o+1),Dr.c.fromBufferAttribute(r,o+2),i*=Dr.getArea(),e[o/3]=i}this.distribution=new Float32Array(r.count/3);let t=0;for(let o=0;o<e.length;o++)t+=e[o],this.distribution[o]=t;return this}setRandomGenerator(r){return this.randomFunction=r,this}sample(r,e){if(this.distribution){let t=this.distribution[this.distribution.length-1],o=this.binarySearch(this.randomFunction()*t);return this.sampleFace(o,r,e)}}binarySearch(r){if(!this.distribution)return 0;let e=this.distribution,t=0,o=e.length-1,i=-1;for(;t<=o;){let a=Math.ceil((t+o)/2);if(a===0||e[a-1]<=r&&e[a]>r){i=a;break}else r<e[a]?o=a-1:t=a+1}return i}sampleFace(r,e,t){let o=this.randomFunction(),i=this.randomFunction();return o+i>1&&(o=1-o,i=1-i),Dr.a.fromBufferAttribute(this.positionAttribute,r*3),Dr.b.fromBufferAttribute(this.positionAttribute,r*3+1),Dr.c.fromBufferAttribute(this.positionAttribute,r*3+2),e.set(0,0,0).addScaledVector(Dr.a,o).addScaledVector(Dr.b,i).addScaledVector(Dr.c,1-(o+i)),Dr.getNormal(t),this}};import{Object3D as IA}from"three";var f0=fi(p0());import{Object3D as CA,Matrix4 as to}from"three";var TA=new to,AA=new to,MA=new to,oa;(r=>{function n(e){return e&&e.__isSPEObject}r.is=n})(oa||(oa={}));var na=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new to;this.copyPreviousMatrix=!0;this.hiddenMatrix=new to;this.matrixWorldRigid=new to;this.shearScale=new to;this.shearScaleInv=new to}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof CA&&(t=t.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===t)return!0;o=o.parent}return!1}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 o of this.children)o.updateMatrixWorld(t)}updateWorldMatrix(t,o){let i=this.parent;if(t&&i!==null&&i.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)),o)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(t,o=0){for(let i of this.children)oa.is(i)&&i.traverseObject(t,o+1)}traverseObject(t,o=0){if(t(this,o)!==!0)for(let a of this.children)oa.is(a)&&a.traverseObject(t,o+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,o=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:i,v:a,q:s}=(0,f0.SVD)(o),l=TA.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),c=AA.set(a[0][0],a[0][1],a[0][2],0,a[1][0],a[1][1],a[1][2],0,a[2][0],a[2][1],a[2][2],0,0,0,0,1),u=MA.copy(c).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(u).premultiply(c),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,u).copyPosition(this.matrixWorld),s.every(p=>Math.abs(s[0]-p)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,o){this.updateWorldMatrix(!0,!1);let i=new to().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof to?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),o!==void 0&&(this.children.pop(),this.children.splice(o,0,t)),this}copy(t,o=!1){return super.copy(t,o),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,o,i,a,s,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var cp=class extends na(IA){},NA=n=>n.type==="Mesh",No=class extends cp{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let o=this.children[e];o?.object!==t&&(o&&this.remove(o),o=new No(t),this.add(o),this.children.splice(e,0,this.children.pop()),o.matrixWorldNeedsUpdate=!0,o.matrixAutoUpdate=!1,o.matrix=t.matrix,o.hiddenMatrix=t.hiddenMatrix),o.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return NA(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};import{Box3 as FI,BufferGeometry as UI,MeshBasicMaterial as kI}from"three";import{Matrix4 as GI,Mesh as jI}from"three";import{Matrix4 as Hc,Vector3 as y0,Euler as RA,MathUtils as Ds}from"three";import{Box3 as DA,Line3 as EA,Matrix4 as up,Vector3 as cr}from"three";var Un=new cr,kn=new cr,ia=new up,m0=[new cr(-1,1,1),new cr(-1,-1,1),new cr(1,-1,1),new cr(1,1,1),new cr(-1,1,-1),new cr(-1,-1,-1),new cr(1,-1,-1),new cr(1,1,-1)],_A=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],BA=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],h0=(n,r,e)=>{n.updateEntityBoxSize(Un,kn),ia.copy(r).multiply(n.matrixWorld),kn.x===0&&kn.y===0&&kn.z===0?e.push(new cr(Un.x,Un.y,Un.z).applyMatrix4(ia)):m0.forEach(t=>{e.push(t.clone().multiply(kn).add(Un).applyMatrix4(ia))})},Ns=class extends DA{constructor(){super(...arguments);this.matrix=new up;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 o=new up().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,t)}expandByObjectSize(e,t,o=!1){let i=[];return o===!0?e.traverseEntity(a=>{if(a.visible||a.cloner&&a.data.visible){if(!("geometry"in a)){i.push(new cr);return}h0(a,t,i)}}):h0(e,t,i),this.setFromPoints(i)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(ia.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(kn).multiplyScalar(.5),this.getCenter(Un),ia.copy(this.matrix).setPosition(Un),this.vertices=m0.map(e=>e.clone().multiply(kn).applyMatrix4(ia))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=_A.map(([e,t])=>new EA(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new cr))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=BA.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var Er={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};import{CurvePath as LA,CubicBezierCurve3 as dp,Vector3 as _r}from"three";var fp=class extends LA{constructor(){super()}getPoints(r=12){let e=[],t,o=this.getCurveLengths(),a=o[o.length-1]/o.length;for(let s=0,l=this.curves;s<l.length;s++){let c=l[s],u=s===0?o[s]:o[s]-o[s-1],p=Math.ceil(r*u/a),d=c.getPoints(p);for(let h=0;h<d.length;h++){let f=d[h];t&&t.equals(f)||(e.push(f),t=f)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var hp=.001;function mp(n,r,e){return r.clone().sub(n).cross(r.clone().sub(e)).length()<=hp}function pp(n,r){let e=new _r(...n.position),t=new _r(...n.controlNext.position),o=new _r(...r.controlPrevious.position),i=new _r(...r.position);return mp(e,t,i)&&mp(e,o,i)}function kc(n){let r=n.points.map(u=>new _r(...u.data.position)),e=[n.points[0]],t=new _r(...e[0].data.position);for(let u=0;u<n.points.length-1;u++)mp(t,r[u],r[u+1])||(e.push(n.points[u]),t=r[u]);e.push(n.points[n.points.length-1]);let o=n.isClosed,i=e.length-(o?0:1),a=e.length,s=[];for(let u=0;u<a;u++){let p=e[u].data,d=new _r(...p.position),h=new _r(...p.controlPrevious.position),f=new _r(...p.controlNext.position),m={position:d,baseRoundness:p.roundness,controlPrevious:h,controlNext:f};if(p.roundness===0||!n.isClosed&&(u===0||u===a-1)){s[u]={...m,removedLength:0};continue}let y=o&&u==0?a-1:u-1,g=o&&u==a-1?0:u+1,v=e[y].data,O=e[g].data,P=new _r(...v.position),S=new _r(...O.position),T=P.clone().sub(d).normalize(),I=S.clone().sub(d).normalize();Object.assign(m,{prevDir:T,nextDir:I});let x=pp(v,p),_=pp(p,O);if(!x||!_)s[u]={...m,removedLength:0};else{let D=T.clone().add(I).normalize(),A=D.clone().cross(T).length()/T.dot(D);s[u]={...m,tan:A,removedLength:p.roundness/A}}}for(let u=0;u<i;u++){let p=u,d=o&&u===a-1?0:u+1,h=s[p],f=s[d];if(h.removedLength!==0||f.removedLength!==0){let m=h.position.distanceTo(f.position);h.removedLength=Math.min(h.removedLength,m/2),f.removedLength=Math.min(f.removedLength,m/2)}}let l=[];for(let u=0;u<i;u++){let p=u,d=o&&u===a-1?0:u+1,h=s[p],f=s[d],m=null;if(!pp(e[p].data,e[d].data))h.position.distanceTo(f.position)>hp&&(m=new dp(h.position,h.controlNext,f.controlPrevious,f.position));else{let y=h.position.clone(),g=f.position.clone();(h.removedLength!==0||f.removedLength!==0)&&(h.nextDir&&y.add(h.nextDir.clone().setLength(h.removedLength)),f.prevDir&&g.add(f.prevDir.clone().setLength(f.removedLength))),y.distanceTo(g)>hp&&(m=new dp(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}l[2*u+1]=m}for(let u=0;u<a;u++){let p=s[u];if(p.removedLength===0){l[2*u]=null;continue}let d=p.position,h=p.prevDir.clone().multiplyScalar(p.removedLength).add(d),f=p.nextDir.clone().multiplyScalar(p.removedLength).add(d),m=p.tan*p.removedLength,y=p.prevDir.clone().add(p.nextDir).normalize(),g=h.clone().lerp(f,.5),v=h.distanceTo(f)/2,O=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(v,2))).add(g),P=y.clone().multiplyScalar(-m).add(O),S=d.distanceTo(P)/d.distanceTo(g),T=p.prevDir.clone().multiplyScalar(S*d.distanceTo(h)).add(d),I=T.clone().lerp(P,2),x=h.clone().lerp(T,4/3),_=f.clone().lerp(I,4/3);l[2*u]=new dp(h,x,_,f)}let c=new fp;return l.forEach(u=>{u&&c.add(u)}),c}var Le;(r=>{function n(e){return e&&e.__isEntity}r.is=n})(Le||(Le={}));var aa=n=>Le.is(n),VA={type:"completeState",isfromEntity:!0},zA=["x","y","z"],yp=new y0,GA=new y0().set(0,1,0),sa=n=>class extends na(n){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.destroyedInAction=!1;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Ns;this._recursiveBBox=new Ns;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let o=this.children[t];if(Le.is(o))return o}entityChildrenCount(){let t=this.children.length;for(;t--;)if(Le.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let o=t.parent;if(Le.is(o))t=o;else return}return t}forInstancesRec(t){this.instances.forEach(o=>{o.disposed||t(o),o.forInstancesRec(t)})}super_Entity(t,o){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=o,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,o,i=!1){if(!(this.data.states.length===0&&!i)){for(let a of this.data.states)jn.toOps(this.data,a.data).forEach(l=>{let c=ji.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(c,this.data,o)});if(t!==null){let a=this.data.states.data(t);a&&(this.dataPatched=jn.patch(this.data,a),jn.toOps(this.data,a).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,o)}))}i&&this.updateTransformState(this.dataPatched,o),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}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}updateEntityBoxSize(t,o){t.setScalar(0),o.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{aa(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let o;return this.traverseEntity(i=>{i.uuid===t&&(o=i)}),o}traverseSortNextHelper(){let t=this.parent;if(t){let o=t.children,i=o.indexOf(this)+1;if(Le.is(o[i]))return o[i];if(Le.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&Le.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let o=this;for(;t>0&&o!==null;)o=o.parent,t-=1;return o}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let o=this.parent;for(;o;){if(t===o)return!0;o=o.parent}return!1}countToAccestor(t){let o=0,i=this;for(;i!==t;){if(i===null)return-1;i=i.parent,o+=1}return o}forEachEntity(t){for(let o of this.children)aa(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{Le.is(o)&&t(o)})}traverseConcreteEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)aa(a)&&a.isConcreteEntity&&a.traverseEntity(t,o+1)}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)aa(a)&&a.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)aa(o)&&o.visible&&o.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,o=!1){return super.copy(t,o),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>aa(t))}isAncestorOf(t){if(this.uuid===t)return!1;let o=!1;return this.traverseEntity(i=>{i.uuid===t&&(o=!0)}),o}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x*Ds.RAD2DEG,this.rotation.y*Ds.RAD2DEG,this.rotation.z*Ds.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Li(o,t)}getTransformValues(t,o,i){return o[t].map((a,s)=>i?.shared.getVariable(a,[this.uuid,t,zA[s]])??a)}updateTransformState(t,o){let i=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,o)),i=!0),t.rotation&&(yp.fromArray(this.getTransformValues("rotation",t,o)).multiplyScalar(Ds.DEG2RAD),this.rotation.setFromVector3(yp),i=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,o)),i=!0),t.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??en.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(a=>{a.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}onVariableUpdate(t=!1){if(t){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)Le.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{Le.is(t)&&t.disposeRecursively()})}toState(t=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return Li(o,t)}updateByObjUpdateOp(t,o){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},o,!1)}updateByOp(t,o,i,a){let s=this.data;this.data=o;let l=t,c=Be(t.path,["states","*"]);if(c!==null){if(t.type===0){let[u]=c;if(this?.stateSelection===u){let p={...t.props};if(delete p.name,Object.values(t.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let h=rt.zoom(d,t.path.slice(2));if(h)for(let f in t.props)t.props[f]===void 0&&f in h&&(p[f]=h[f])}}l={...t,props:p,path:t.path.slice(2)}}}}else if(t.type===0){let u=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(u!==void 0){if(t.props.name!==void 0&&u.name){let{name:d,...h}=u;u=h}if(t.props.material!==void 0&&"material"in u){let{material:d,...h}=u;u=h}let p=rt.removeOverridden(t.path,t.props,u);l={...t,props:p}}}if(this.updateByPatchedOpBase(l,jn.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),Be(t.path,["overrides"])){let u=[],p=[...t.path];for(u.push(p[1]),p.splice(0,2);p.length>0&&p[0]==="descendants";)u.push(p[1]),p.splice(0,2);if(u[u.length-1]===void 0){if(t.type===0)for(let d of Object.keys(t.props)){u[u.length-1]=d;let h=i.scene.findInstance([this.uuid,...u]);h&&(h.overrideData=t.props[d],h.updateState(qr.apply(h.component.data,h.overrideData),i))}}else{let d=i.scene.findInstance([this.uuid,...u]);if(d){let h=rt.zoom(d.component.data,p);if(t={...t,path:p},t.type===0){let f=t.props;if(h)for(let[m,y]of Object.entries(t.props))y===void 0&&(f===t.props&&(f={...t.props}),f[m]=h[m]);t={...t,props:f}}d.overrideData=Ki.resolve(o.overrides,u),d.updateByOp(t,ot.applySimple(d.data,t),i,!1)}}}else if(this.instances.length>0){let u;if(t.path.length===0&&t.type===0){let p;for(let d of Zr.rootOverrideProps)d in t.props&&(p===void 0&&(p={}),p[d]=t.props[d]);p&&(u={...t,props:p})}else for(let p of Zr.rootOverrideProps)if(Be(t.path,[p])){u=t;break}u!==void 0&&this.instances.forEach(p=>{if(p.isInstanceRoot){let d=qr.filterOp(p.overrideData,u);d&&p.updateByOp(d,ot.applySimple(p.data,d),i,!0)}}),this.instances.forEach(p=>{if(!p.isInstanceRoot){let d=qr.filterOp(p.overrideData,t);if(d){let h;s===p.data&&t===d?h=o:h=ot.applySimple(p.data,d),p.updateByOp(d,h,i,!0)}}})}}updateByPatchedOpBase(t,o,i){if(this.dataPatched=o,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Ir.is(t.props.type)&&Er.changeEntityProptotype(this,o,i);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){Er.changeEntityProptotype(this,o,i);for(let a of this.children)Le.is(a)&&a.updateVisible(i.scene)}this.updateByPatchedOp(t,o,i)}updateByPatchedOp(t,o,i){if(t.path.length===0&&t.type===0&&this.updateState(t.props,i),Be(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Be(t.path,["cloner"])!==null){let a=ot.drop(t,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,i):this.cloner?this.cloner.updateState(o.cloner,i.scene):(this.setFromClonerState(o.cloner,i),this.expandCloner(i.scene)),this.updateVisible(i.scene)}}updatePathSnapping(t=this.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let o=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,i=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,a=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(o===null)return;let l=t.find(o);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let c=l.data;if(c.geometry.path.points.length<=1)return;let u=kc(c.geometry.path),p=(i+a)%1;i+a===1&&p===0&&(p=1);let d=u.getPointAt(p);if(d===null)return;let h=this.parent?this.parent?.matrixWorld:new Hc;l.updateMatrixWorld();let f=new Hc().multiplyMatrices(h.clone().invert(),l.matrixWorld);d.applyMatrix4(f);let m={position:d.toArray(),rotation:c.rotation};if(s==="tangential"){let y=new Hc().extractRotation(l.matrixWorld),g=u.getTangentAt(p).applyMatrix4(y).add(d),v=new Hc().lookAt(d,g,GA),O=yp.setFromEuler(new RA().setFromRotationMatrix(v)).multiplyScalar(Ds.RAD2DEG);m={...m,rotation:O.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(VA)})}updateVisible(t){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!t)return;let o=!1;this.traverseEntity(i=>{if(i.data.type==="Splat")return o=!0,!0}),o&&t.reloadSplats()}updateState_Entity(t,o){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(o?.scene),this.resetBBoxNeedsUpdate()),o&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,o),this.updateVisible(o.scene)),this.updateTransformState(t,o)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof Er.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,o){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Er.Cloner(this,t),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,o.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}};import{BufferGeometry as UA,ConeGeometry as kA,Float32BufferAttribute as HA,MathUtils as WA}from"three";import{BufferGeometry as x0,CylinderGeometry as jA,Float32BufferAttribute as qc,MathUtils as FA,Vector2 as Br,Vector3 as Wc}from"three";var b0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);e.thetaLength=FA.clamp(e.thetaLength,0,360);let t=e.width/2,o=e.radiusTop??t,i=e.radiusBottom??t;return o===i?(o=t,i=t):o>i?(o=t,i=i*t/o):(o=o*t/i,i=t),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:o,radiusBottom:i})}}static build(n){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:p,cornerSegments:d,hollow:h}=n.parameters,f;return l===0?(f=new x0,f.setAttribute("position",new qc([],3))):p||h?f=new Es(c,u,t,o,i,a,s,l*Math.PI/180,p,p,d,h):f=new jA(c,u,t,o,i,a,s,l*Math.PI/180),f.scale(1,1,e/r),Object.assign(f,{userData:{...n,type:"CylinderGeometry"}})}};function sn(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function g0(n){return new Br(n.y,-n.x)}var Es=class extends x0{constructor(r,e,t,o,i,a,s,l,c,u,p,d,h=!1){super(),this.type="RoundedCylinderBufferGeometry",r=r!==void 0?r:1,e=e!==void 0?e:1,t=t||1,o=Math.floor(o)||8,i=Math.floor(i)||1,a=a!==void 0?a:!1,s=s!==void 0?s:0,l=l!==void 0?l:Math.PI*2,a&&(c=0,u=0);let f=[],m=[],y=[],g=[],v=0,O=t/2,P=new Wc,S=new Wc;h&&r==0&&(r=c),h&&e==0&&(e=u);let T=new Br(r,O),I=new Br(e,-O),x=null,_=null,D=null,A=null,N=T.clone().sub(I),E=0,B=0,V=0;d>0&&(E=Math.min(r,e)*(1-d),B=r-E,V=e-E);let j=T.clone();j.x-=E;let R=Math.PI-N.angle(),W=N.angle(),F=Math.tan(W/2),k=Math.tan(R/2),H=F+k,$=d?H:k,J=d?H:F;if(c=Math.min(c,(r-B)/$,N.length()/H),u=Math.min(u,(e-V)/J,N.length()/H),c>0){let K=c/F;x=T.clone().sub(new Br(K,c)),d&&(D=x.clone(),D.x-=E-H*c),T.sub(N.clone().setLength(K))}if(u>0){let K=u/k;_=I.clone().sub(new Br(K,-u)),I.add(N.clone().setLength(K)),d&&(A=_.clone(),A.x-=E-H*u,j.sub(N.clone().setLength(K)))}N=T.clone().sub(I);let Z=N.length()<.5,X=[];for(let K=0;K<=o;K++){let q=[],ue=K/o,le=ue*l+s,ne=new Br(Math.sin(le),Math.cos(le));A&&_?(te(q,ue,ne,R,u,A,-1,!0),te(q,ue,ne,W,u,_,-1,!1)):_?(Y(q,ne,_.x,0,-1),te(q,ue,ne,W,u,_,-1,!1)):a||Y(q,ne,e,V,-1);let ce=g0(N).normalize();if(sn(ce,ne,P),!Z)for(let ae=0;ae<=i;ae++){let he=ae/i,pe=N.clone().multiplyScalar(he).add(I);sn(pe,ne,S),m.push(S.x,S.y,S.z),y.push(P.x,P.y,P.z),g.push(ue,.5+S.y/t),q.push(v++)}if(D&&x?(te(q,ue,ne,R,c,x,1,!1),te(q,ue,ne,W,c,D,1,!0)):x?(te(q,ue,ne,R,c,x,1,!1),Y(q,ne,x.x,0,1)):a||Y(q,ne,r,B,1),d&&!Z){let ae=g0(N).multiplyScalar(-1).normalize();sn(ae,ne,P);for(let he=0;he<=i;he++){let pe=he/i,fe=N.clone().multiplyScalar(-pe).add(j);sn(fe,ne,S),m.push(S.x,S.y,S.z),y.push(P.x,P.y,P.z),g.push(ue,.5+S.y/t),q.push(v++)}}d&&!a&&q.push(q[0]),X.push(q)}for(let K=0;K<X.length-1;K++)for(let q=0;q<X[0].length-1;q++){if(a&&d&&q==i)continue;let ue=X[K][q],le=X[K+1][q],ne=X[K+1][q+1],ce=X[K][q+1],ae=m[ne*3+0],he=m[ne*3+2];f.push(ue,le,ce),(ae!=0||he!=0)&&f.push(le,ne,ce)}l<Math.PI*2&&(ee(-1,X[0],s),ee(1,X[X.length-1],s+l)),this.setIndex(f),this.setAttribute("position",new qc(m,3)),this.setAttribute("normal",new qc(y,3)),this.setAttribute("uv",new qc(g,2));function te(K,q,ue,le,ne,ce,ae,he){for(let pe=0;pe<p+1;pe++){let fe=pe/p,ge=ae<0?fe:1-fe;he&&(ge-=1),ge*=le;let me=new Br(Math.sin(ge),Math.cos(ge)*ae),C=me.clone().multiplyScalar(ne).add(ce);sn(C,ue,S),m.push(S.x,S.y,S.z),sn(me,ue,P),y.push(P.x,P.y,P.z),g.push(q,.5+S.y/t),K.push(v++)}}function Y(K,q,ue,le,ne){let ce=new Wc,ae=new Br,he=[ue,le];ne<0&&he.reverse();for(let pe of he)ae.set(pe,O*ne),sn(ae,q,ce),m.push(ce.x,ce.y,ce.z),y.push(0,ne,0),g.push(.5,.5),K.push(v++)}function ee(K,q,ue){let le=new Br(Math.sin(ue),Math.cos(ue)),ne=new Br(-Math.cos(ue),Math.sin(ue)),ce=new Wc,ae=K<0?(fe,ge,me)=>f.push(fe,ge,me):(fe,ge,me)=>f.push(fe,me,ge),he=new Br((r+e+B+V)/4,0);sn(he,le,ce),m.push(ce.x,ce.y,ce.z),y.push(ne.x,0,ne.y),g.push(.5,.5);let pe=v++;for(let fe of q){let ge=m.slice(fe*3,fe*3+3);m.push(...ge),y.push(ne.x,0,ne.y);let me=g.slice(fe*2,fe*2+2);g.push(...me),v++}for(let fe=pe+1;fe<v-1;fe++)ae(pe,fe,fe+1);ae(pe,v-1,pe+1)}}};var v0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},n.parameters);return e.thetaLength=WA.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:u,cornerSegments:p}=n.parameters,d;return l===0?(d=new UA,d.setAttribute("position",new HA([],3))):c>0||u>0||l<360?d=new Es(0,r/2,t,o,i,a,s,l*Math.PI/180,c,u,p,0,!0):d=new kA(r/2,t,o,i,a),d.scale(1,1,e/r),Object.assign(d,{userData:{...n,type:"ConeGeometry"}})}};import{BoxGeometry as qA,BufferGeometry as $A,Float32BufferAttribute as gp,Vector3 as _s}from"three";var S0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,widthSegments:o,heightSegments:i,depthSegments:a,cornerRadius:s,cornerSegments:l}=n.parameters,c;return s==0?c=new qA(r,e,t,o,i,a):c=new bp(r,e,t,o,i,a,s,l),Object.assign(c,{userData:{...n,type:"CubeGeometry"}})}},xp=Math.PI/2,bp=class extends $A{constructor(r=1,e=1,t=1,o=1,i=1,a=1,s=0,l=4){super(),this.type="BoxGeometry";let c=this;o=Math.floor(o),i=Math.floor(i),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,r/2,e/2,t/2);let u=[],p=[],d=[],h=[],f=0,m=0;y("z","y","x",-1,-1,t,e,r,a,i,0),y("z","y","x",1,-1,t,e,-r,a,i,1),y("x","z","y",1,1,r,t,e,o,a,2),y("x","z","y",1,-1,r,t,-e,o,a,3),y("x","y","z",1,-1,r,e,t,o,i,4),y("x","y","z",-1,-1,r,e,-t,o,i,5),s>0&&(g("z","y","x",-1,-1,1,t,e,r,a,0),g("z","y","x",1,-1,-1,t,e,r,a,1),g("z","y","x",-1,1,-1,t,e,r,a,1),g("z","y","x",1,1,1,t,e,r,a,0),g("x","y","z",-1,-1,-1,r,e,t,o,0),g("x","y","z",1,-1,1,r,e,t,o,1),g("x","y","z",-1,1,1,r,e,t,o,0),g("x","y","z",1,1,-1,r,e,t,o,1),g("y","x","z",-1,-1,1,e,r,t,i,0),g("y","x","z",1,-1,-1,e,r,t,i,1),g("y","x","z",1,1,1,e,r,t,i,1),g("y","x","z",-1,1,-1,e,r,t,i,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(u),this.setAttribute("position",new gp(p,3)),this.setAttribute("normal",new gp(d,3)),this.setAttribute("uv",new gp(h,2));function y(O,P,S,T,I,x,_,D,A,N,E){let B=(x-2*s)/A,V=(_-2*s)/N,j=x/2-s,R=_/2-s,W=D/2,F=A+1,k=N+1,H=0,$=0,J=new _s;for(let Z=0;Z<k;Z++){let X=Z*V-R;for(let te=0;te<F;te++){let Y=te*B-j;J[O]=Y*T,J[P]=X*I,J[S]=W,p.push(J.x,J.y,J.z),J[O]=0,J[P]=0,J[S]=D>0?1:-1,d.push(J.x,J.y,J.z),h.push(te/A),h.push(1-Z/N),H+=1}}for(let Z=0;Z<N;Z++)for(let X=0;X<A;X++){let te=f+X+F*Z,Y=f+X+F*(Z+1),ee=f+(X+1)+F*(Z+1),K=f+(X+1)+F*Z;u.push(te,Y,K),u.push(Y,ee,K),$+=6}c.addGroup(m,$,E),m+=$,f+=H}function g(O,P,S,T,I,x,_,D,A,N,E){let B=(_-2*s)/N,V=_/2-s,j=D/2-s,R=A/2,W=N+1,F=0,k=0,H=new _s,$=new _s;for(let J=0;J<l+1;J++){let Z=J/l*xp,X=Math.sin(Z)*s,te=(1-Math.cos(Z))*s,Y=Math.sin(Z),ee=Math.cos(Z);H[P]=(j+X)*I,H[S]=(R-te)*x,$[O]=0,$[P]=Y*Math.sign(H[P]),$[S]=ee*Math.sign(H[S]);for(let K=0;K<W;K++){let q=K*B-V;H[O]=q*T,p.push(H.x,H.y,H.z),d.push($.x,$.y,$.z),h.push(K/N),h.push(0),F+=1}}for(let J=0;J<l;J++)for(let Z=0;Z<N;Z++){let X=f+Z+W*J,te=f+Z+W*(J+1),Y=f+(Z+1)+W*(J+1),ee=f+(Z+1)+W*J;u.push(X,te,ee),u.push(te,Y,ee),k+=6}c.addGroup(m,k,E),m+=k,f+=F}function v(O,P,S){let T=new _s,I=new _s(r/2,e/2,t/2);I.subScalar(s);let x=[],_=O*P*S>0?(A,N,E)=>u.push(A,N,E):(A,N,E)=>u.push(A,E,N);for(let A=0;A<=l;A++){let N=[],E=xp*(1-A/l),B=Math.cos(E),V=Math.sin(E),j=0;for(let R=0;R<=A;R++){let W=Math.cos(j),F=Math.sin(j);T.x=B*W,T.y=V,T.z=B*F;let k=I.clone().addScaledVector(T,s);p.push(O*k.x,P*k.y,S*k.z),d.push(O*T.x,P*T.y,S*T.z),h.push(0,0),N.push(f++),j+=xp/A}x.push(N)}let D=x.length-1;for(let A=0;A<D;A++){let N=x[A],E=x[A+1],B=N.length-1;_(N[0],E[1],E[0]);for(let V=1;V<=B;V++)_(N[V-1],N[V],E[V]),_(N[V],E[V+1],E[V])}}}};import{BufferGeometry as YA,Float32BufferAttribute as vp,Triangle as XA,Vector3 as Do,Vector2 as Sp}from"three";var ln=class extends YA{constructor(r=[],e=[],t="",o=1,i=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],c=[];u(),p(),this.setAttribute("position",new vp(s,3)),this.setAttribute("normal",new vp(c,3)),this.setAttribute("uv",new vp(l,2));return;function u(){i=Math.min(1-1e-5,i),i==0&&(a=0);let h={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[t],f=new Do,m=f.clone(),y=new XA,g=i*o,v=o-g,O=a+1,P=new Do,S=(F,k)=>P.subVectors(F,k).normalize(),T=(F,k)=>Array(F).fill(void 0).map(k),I=T(r.length/3,(F,k)=>new Do().fromArray(r,k*3).setLength(o)),x=[],_=1e6;for(let F=0;F<I.length;F++){let k=I[F],H=[],$,J,Z,X=1e10,te=-1;for(;(te=e.indexOf(F,te+1))!=-1;){let q=te-te%3;$=e[q+(te+1)%3],J=e[q+(te+2)%3],Z=k.distanceToSquared(I[$]),X=Math.min(X,Z),H.push([$,J,Z])}X+=1e-6;let Y=[],ee=0,K=H.length;for(let q=0;q<K;q++){[$,J,Z]=H[ee];let ue=x[$]?.includes(F)==!0;Z<=X&&Y.push($+ +ue*_),ee=H.findIndex(le=>le[0]==J)}x.push(Y)}let D=[];{let F=0,k=0,H,$,J=h==3;for(let Z=0;Z<=a;Z++){H=Z*(Z+1)/2,$=(Z+1)*(Z+2)/2;for(let X=0;X<a-Z;X++)[F,k]=[H+X+Z+2,$+X+Z+3],D.push(H,$,...J?[k,H]:[F,$],k,F),[H,$]=[F,k];D.push(H,$,H+a+2)}}let A=f.clone(),N=f.clone(),E=f.clone(),B=f.clone(),V=f.clone(),j=[],R=T(I.length,()=>T(h,()=>f.clone()));for(let F=0;F<I.length;F++){f.copy(I[F]).normalize(),A.copy(f).multiplyScalar(v);let k=x[F];for(let Y=0;Y<k.length;Y++){let ee=k[Y],K=k[(Y+1)%h];y.setFromPointsAndIndices(I,F,ee%_,K%_),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(A,R[F][Y])}let H=[],$=[],J=[],Z=new Do;a==0&&[...R[F]].reduce((Y,ee)=>Y.add(ee),Z).multiplyScalar(1/h);for(let Y=0;Y<h;Y++){let ee=[],K=(Y-1+h)%h,q=R[F][K],ue=R[F][Y];f.copy(q).sub(A),m.copy(ue).sub(A);let le=A.angleTo(f),ne=f.angleTo(m),ce=Math.cos(le)*g;a==0?N.copy(Z):N.copy(A).setLength(v+ce),$.push(ce);let ae=[N,q,ue];for(let he=0;he<2;he++){let pe=ae[he],fe=ae[he+1];B.subVectors(pe,A),V.subVectors(fe,A),E.crossVectors(B,V).normalize();for(let ge=0;ge<O;ge++){let me=[le,ne][he]*ge/O;f.copy(B).applyAxisAngle(E,me).add(A),H.push(f.clone()),he&&(S(f,A),ee.push([ge==0?pe:f.clone(),P.clone()]))}he&&(S(fe,A),ee.push([fe,P.clone()]))}J.push(ee)}j.push(J);let X=2*O,te=2;for(let Y=0;Y<h;Y++){let ee=X*Y,K=X*((Y+1)%h),q=[H[ee]];for(let le=1;le<O;le++){B=H[ee+le],V=H[K+le],q.push(B);for(let ne=1,ce=le-te+1;ne<=ce;ne++)f.lerpVectors(B,V,ne/(ce+1)),f.sub(A).setLength($[Y]).add(A),q.push(f.clone());q.push(V)}for(let le=0;le<O;le++)q.push(H[le+O+ee]);q.push(H[K+O]);let ue=D.map(le=>q[le]);s.push(...ue.map(le=>[le.x,le.y,le.z]).flat()),c.push(...ue.map(le=>(S(le,A),[P.x,P.y,P.z])).flat())}}let W=[];for(let F=0;F<x.length;F++)for(let k=0;k<h;k++){let H=x[F][k];if(H<_){let $=x[H].findIndex(X=>X%_==F),J=j[F][k],Z=j[H][$];for(let X=0;X<O;X++){let te=J[X],Y=Z[O-X],ee=J[X+1],K=Z[O-(X+1)];[te,Y,ee,ee,Y,K].forEach(q=>{s.push(q[0].x,q[0].y,q[0].z),c.push(q[1].x,q[1].y,q[1].z)})}W.push(J[0][0],Z[O][0],J[O][0],Z[0][0])}}for(;W.length;){let F,k,H,$;[F,k]=W.splice(0,2);let J=[F];for(;F!=k;)J.push(k),H=W.indexOf(k),$=H%2,k=W.splice(H-$,2)[1-$];P.subVectors(J[0],J[1]).cross(f.subVectors(J[0],J[2])).normalize();let Z=P.dot(J[0])<0;Z&&P.negate();for(let X=1;X<=J.length-2;X++)[J[X+ +Z],J[X+1-+Z],J[0]].forEach(te=>{s.push(te.x,te.y,te.z),c.push(P.x,P.y,P.z)})}}function p(){let d=new Do;for(let I=0;I<s.length;I+=3){d.x=s[I+0],d.y=s[I+1],d.z=s[I+2];let x=S(d)/2/Math.PI+.5,_=T(d)/Math.PI+.5;l.push(x,1-_)}let h=new Do,f=new Do,m=new Do,y=new Do,g=new Sp,v=new Sp,O=new Sp,P=(I,x,_,D)=>{D<0&&I.x===1&&(l[x]=I.x-1),_.x===0&&_.z===0&&(l[x]=D/2/Math.PI+.5)};for(let I=0,x=0;I<s.length;I+=9,x+=6){h.set(s[I+0],s[I+1],s[I+2]),f.set(s[I+3],s[I+4],s[I+5]),m.set(s[I+6],s[I+7],s[I+8]),g.set(l[x+0],l[x+1]),v.set(l[x+2],l[x+3]),O.set(l[x+4],l[x+5]),y.copy(h).add(f).add(m).divideScalar(3);let _=S(y);P(g,x+0,h,_),P(v,x+2,f,_),P(O,x+4,m,_)}for(let I=0;I<l.length;I+=6){let x=l[I+0],_=l[I+2],D=l[I+4],A=Math.max(x,_,D),N=Math.min(x,_,D);A>.9&&N<.1&&(x<.2&&(l[I+0]+=1),_<.2&&(l[I+2]+=1),D<.2&&(l[I+4]+=1))}function S(I){return Math.atan2(I.z,-I.x)}function T(I){return Math.atan2(-I.y,Math.sqrt(I.x*I.x+I.z*I.z))}}}static fromJSON(r){return new ln(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};import{DodecahedronGeometry as KA}from"three";var w0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new Bs(r*.5,i,a):new KA(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},Bs=class extends ln{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,i=1/o,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-o,0,-i,o,0,i,-o,0,i,o,-i,-o,0,-i,o,0,i,-o,0,i,o,0,-o,0,-i,o,0,-i,-o,0,i,o,0,i],s=[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(a,s,l,r,e,t),this.type=l}static fromJSON(r){return new Bs(r.radius,r.corner,r.cornerSides)}};import{Plane as sM,Shape as V0,Vector2 as Eo,Vector3 as lM,MathUtils as Mp,LineCurve as Ip,QuadraticBezierCurve as z0,CubicBezierCurve as Kc}from"three";import{CubicBezierCurve as $c,EllipseCurve as QA,LineCurve as Yc,LineCurve3 as ZA,MathUtils as JA,QuadraticBezierCurve as Pp,SplineCurve as eM,Vector2 as Ft,Vector3 as C0}from"three";var Ls=1e-12,la=class{constructor(r){this.position=new Ft;this.startPosition=new Ft;this.uuid=JA.generateUUID();this.position=r.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(r){this.position.copy(this.startPosition).add(r)}copy(r){return this.position.copy(r.position),this.startPosition.copy(r.startPosition),this}clone(){return new la(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},ca=class extends la{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new ca(this.parent).copy(this)}},Lr=class extends la{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new ca(this),new ca(this))}static create(e,t){let o=new Lr(e,new Ft(...t.position));return o.controls[0].position.set(...t.controlPrevious.position),o.controls[1].position.set(...t.controlNext.position),o.roundness=t.roundness,o.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,o}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 o=0,i=this.controls.length;o<i;o++){let a=this.controls[o];this.position.distanceTo(a.position)<=t?a.position.copy(this.position):a.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Lr(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new Ft,t=new Ft){let[o,i]=this.computeTangents();return o&&i&&(P0(o,e),P0(i,t)),[e,t]}computeTangent(e=new Ft){let[t,o]=this.computeTangents();return t&&o&&e.copy(t).add(o).normalize(),e}computeNormal(e=new Ft){let[t,o]=this.computeNormals();return e.copy(t).add(o).normalize(),e}};function P0(n,r=new Ft){let e=n.length();return r.set(-n.y/e,n.x/e)}var Op=n=>n,ua=new Ft,Xc=new Ft,tM=new Ft,rM=new Ft,oM=new Ft,nM=new Ft,T0=new C0,A0=new C0;function M0(n){let r=new Ft;r.addVectors(n.v0,ua.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Ft;return e.addVectors(n.v2,Xc.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new $c(n.v0,r,e,n.v2)}function Rs(n,r,e=Number.EPSILON){return Math.abs(n-r)<e}function iM(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function aM(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function Cp(n,r,e){let t=Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2)),o=Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2)),i=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((o*o+t*t-i*i)/(2*o*t))}function I0(n,r,e){return O0(n,r)&&O0(r,e)&&wp(n.position,r.position,e.position)}function wp(n,r,e){return ua.copy(r).sub(n).cross(Xc.copy(e).sub(n))===0}function N0(n,r,e,t,o){let i=Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2)),a=(n.y+r.y)/2,s=(n.x+r.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(n.y-r.y)/i,c=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(r.x-n.x)/i;return t.set(s+l,a+c),o.set(s-l,a-c),[t,o]}function D0(n,r,e){let t=n.distanceTo(e),o=r.distanceTo(e);return t<o?r:n}function E0(n,r,e,t,o,i){let a=r.x-n.x,s=r.y-n.y,l=e.x-n.x,c=e.y-n.y,u=Math.sqrt((a+l)*(a+l)+(s+c)*(s+c)),p;return Cp(r,n,e)>Math.PI&&(u*=-1),Rs(c,s)?p=(s+c)*(t/u-.5)*8/3/(a-l):p=(a+l)*(t/u-.5)*8/3/(c-s),o.set(r.x-p*s,r.y+p*a),i.set(e.x+p*c,e.y-p*l),[o,i]}function Tp(n,r){return n.position.equals(n.controls[1].position)&&r.position.equals(r.controls[0].position)}function O0(n,r){return wp(n.position,n.controls[1].position,r.position)&&wp(n.position,r.controls[0].position,r.position)}function _0(n,r,e,t,o=.5){let i=ua.subVectors(r,n).multiplyScalar(o).add(n),a=Xc.subVectors(e,r).multiplyScalar(o).add(r),s=tM.subVectors(t,e).multiplyScalar(o).add(e),l=i,c=rM.subVectors(a,i).multiplyScalar(o).add(i),u=oM.subVectors(s,a).multiplyScalar(o).add(a),p=s,d=nM.subVectors(u,c).multiplyScalar(o).add(c);return[n.x,n.y,l.x,l.y,c.x,c.y,d.x,d.y,u.x,u.y,p.x,p.y,t.x,t.y]}function B0(n,r,e=12,t=!0){let o=A0.set(0,0,0),i,a=0,s=[];for(let l=0;l<r.length;l++){let c=Op(r[l]),u=ua,p=cn(c,e);s.push(p);for(let d=0;d<=p;d++)if(c instanceof $c||c instanceof Pp||c instanceof Yc){if(c.getPoint(d/p,u),o.set(u.x,u.y,0),i!==void 0&&aM(i,o))continue;i===void 0&&(i=T0),i.copy(o),n.setXYZ(a,o.x,o.y,o.z),a++}}return t&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),n}function L0(n,r,e,t=12,o=!0){let i=A0.set(0,0,0),a=0,s=[];for(let l=0;l<r.length;l++){if(e[l]===!1)continue;let c,u=Op(r[l]),p=ua,d=cn(u,t);s.push(d);for(let h=0;h<=d;h++)if(u instanceof $c||u instanceof Pp||u instanceof Yc){if(u.getPoint(h/d,p),i.set(p.x,p.y,0),c?.equals(i))continue;c===void 0?c=T0:(n.setXYZ(a,c.x,c.y,c.z),a++,n.setXYZ(a,i.x,i.y,i.z),a++),c.copy(i)}}return o&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),s}function Ap(n,r=12,e=!1){let t=[];for(let o=0,i=n.length;o<i;o++){let a=n[o],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=cn(a.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=cn(a.curveAfter,r)),t.push(s)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(t[n.length-1]+=cn(n[0].roundedCurveCorner,r)*.5),t}function cn(n,r=12){return n&&n instanceof QA?r*2:n&&(n instanceof Yc||n instanceof ZA)?1:n&&n instanceof eM?r*n.points.length:r}function R0(n,r,e=12,t=!0){let o,i=0;for(let a=0;a<r.length;a++){let s=Op(r[a]),l=cn(s,e),c=ua;for(let u=0;u<=l;u++)if(s instanceof $c||s instanceof Pp||s instanceof Yc){if(s.getPoint(u/l,c),o!==void 0&&iM(o,c,Ls))continue;o===void 0&&(o=Xc),o.copy(c),n.push(c.x,c.y),i++}}return Rs(n[0],n[n.length-2],Ls)&&Rs(n[1],n[n.length-1],Ls)&&(n.pop(),n.pop()),t&&i>1&&!(Rs(n[i-1],n[1],Ls)&&Rs(n[i-2],n[0],Ls))&&(n.push(n[0],n[1]),i++),n}var Np=new Eo,cM=new Eo,uM=new Eo,dM=new Eo,pM=new Eo,fM=new Eo,Fe=class extends V0{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new sM(new lM(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this.isText=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Mp.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,o){let i=new Fe;return i.isClosed=e.isClosed,i.points=e.points.map(a=>Lr.create(a.id,a.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(a=>Fe.createFromState(a)),t!==void 0&&o!==void 0&&i.applySize(t,o),i.update(),i}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,o=this.points.length;t<o;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,o=this.points.findIndex(i=>i.uuid===e);if(o<0){let i=t;for(let a=0,s=this.shapeHoles.length;a<s;a++){let l=this.shapeHoles[a],c=l.points.length,u=l.getPointIndexById(e);if(u<0)i+=c;else return u+i}}return o}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let o=0,i=this.shapeHoles.length;o<i;o++){let a=this.shapeHoles[o],s=e-t;if(s<=a.points.length-1)return a.points[s];t+=a.points.length}}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 o=0,i=this.shapeHoles.length;o<i;o++){let a=this.shapeHoles[o],s=a.points.indexOf(e);if(s>=0)return t+s;t+=a.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 o=Np.set(e,t);for(let i=0,a=this.points.length;i<a;i++){let s=this.points[i];s.position.multiply(o),s.controls[0].position.multiply(o),s.controls[1].position.multiply(o)}for(let i=0,a=this.shapeHoles.length;i<a;i++)this.shapeHoles[i].applyScale(e,t);this._update()}createPoint(e,t=0,o=Mp.generateUUID()){let i;e instanceof Eo?i=e:i=new Eo(e,t);let a=new Lr(o,i);return a.roundness=this.roundness,a}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,o=this.points.length;t<o;t++){let i=this.points[t];if(i.uuid===e)return i}for(let t=0,o=this.shapeHoles.length;t<o;t++){let a=this.shapeHoles[t].getPointByUuid(e);if(a)return a}}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(o=>o.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,o=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let i=o?this.roundedCurveDivisions:this.curveDivisions;return B0(e,o?this.roundedCurves:this.curves,t,this.autoClose),i.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Ap(this.points,e,!1),this.roundedCurveDivisions=Ap(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,o=12){return L0(e,this.curves,t,o,this.autoClose).reduce((a,s)=>a+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),R0(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let i=t?this.roundedCurveDivisions:this.curveDivisions,a=0;t&&this.points[0].roundedCurveCorner!==void 0&&(a=cn(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=i.reduce((l,c)=>l+c,0));for(let l=0,c=i.length;l<c;l++){let u=i[l];if(s<o+u)return[l,(s-o+1)/u];o+=u}return[0,1]}getCurveT(e,t,o){let i=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(Tp(i,a)){let p=i.position.distanceTo(a.position);return i.position.distanceTo(Np.set(o.x,o.y))/p}let c=0;for(let p=0;p<e;p++)c+=s[p];return(t-c)/l}dispose(){}_applyCurveForPoint(e,t){Tp(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 o=this.curves[this.curves.length-1];e.curveBefore=o,t.curveAfter=o;let i=o.clone();e.roundedCurveBefore=i,t.roundedCurveAfter=i,e.roundedCurveCorner=void 0,this.roundedCurves.push(i)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,o=this.points.length;t<o;t++){let i=this.points[t];if(t===0)this.moveTo(i.position.x,i.position.y);else{let a=this.points[t-1];this._applyCurveForPoint(i,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],o=this.points[this.points.length-1];this._applyCurveForPoint(t,o)}if(this.points.length>2){let t=0;for(let o=0,i=this.points.length;o<i;o++){let a=this.points[o],s=this.points[o-1]??this.points[this.points.length-1],l=this.points[o+1]??this.points[0],c=a.roundness,u=s&&l&&I0(s,a,l);if(!a.controlsMoved()&&c>0&&!u){let p=a.curveBefore,d=a.curveAfter;if(p===void 0||d===void 0)continue;let h=a.roundedCurveBefore,f=a.roundedCurveAfter,m=p.getLength(),y=d.getLength(),g=Math.min(c,m*.499),v=Math.min(c,y*.499),O=Math.min(g,v),P=1-O/m,S=O/y,T=p.getPointAt(P,Np),I=d.getPointAt(S,cM);this._subSplitCurve(p,h,P,T,void 0),this._subSplitCurve(d,f,S,void 0,I);let x;if(this.useCubicForRoundedCorners){let _=Cp(T,a.position,I)/2,D=Math.tan(_)*T.distanceTo(a.position),[A,N]=N0(T,I,D,uM,dM),E=D0(A,N,a.position),[B,V]=E0(E,T,I,D,pM,fM);x=new Kc(T.clone(),B.clone(),V.clone(),I.clone())}else x=new z0(T.clone(),a.position.clone(),I.clone());a.roundedCurveCorner=x,this.roundedCurves.splice(o+t,0,x),t++}}}}_subSplitCurve(e,t,o,i,a){if(e instanceof Ip)i!==void 0&&t.v2.copy(i),a!==void 0&&t.v1.copy(a);else{let s=e,l=t,c=s.getUtoTmapping(o,0),u=_0(s.v0,s.v1,s.v2,s.v3,c);return i!==void 0&&(l.v0.set(u[0],u[1]),l.v1.set(u[2],u[3]),l.v2.set(u[4],u[5]),l.v3.set(u[6],u[7])),a!==void 0&&(l.v0.set(u[6],u[7]),l.v1.set(u[8],u[9]),l.v2.set(u[10],u[11]),l.v3.set(u[12],u[13])),l}return t}clone(){let e=new Fe(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){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let o=0;o<t;o++){let i=o*7,a=e.points[i+0],s=e.points[i+1],l=e.points[i+2],c=e.points[i+3],u=e.points[i+4],p=e.points[i+5],d=e.points[i+6],h=new Lr(Mp.generateUUID(),new Eo(a,s));h.controls[0].position.set(l,c),h.controls[1].position.set(u,p),h.roundness=d,this.points.push(h)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new Fe;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let o=(a,s)=>{s instanceof Kc&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},i=a=>{let s=[],l,c;for(l=0,c=a.length;l<c;l++)a[l]instanceof z0&&(a[l]=M0(a[l]));for(l=0,c=a.length;l<c;l++){let d=a[l],h=l>0?a[l-1]:null,f;d instanceof Kc?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Ip&&(f=this.createPoint(d.v1)),f!==void 0&&(h!==null&&o(f,h),s.push(f))}let u=a[a.length-1],p=!1;return u instanceof Kc?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),p=!0):u instanceof Ip&&u.v2.equals(s[0].position)&&(p=!0),this.isClosed=p,s};return this.points=i(e.curves),e instanceof V0&&(this.shapeHoles=e.holes.map(a=>{let s=new Fe;return s.fromShape(a),s})),this.update(),this}updatePoint(e,t){let o=this.getPointByUuid(e);o&&(t.position!==void 0&&o.position.fromArray(t.position),t.roundness!==void 0&&(o.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(o.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}};var Ep=Math.PI*2;function Dp({x:n,y:r},e,t,o,i){return{x:n*e+o,y:r*t+i}}function hM(n,r){let e=r===1.5707963267948966?.551915024494:r===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(r/4),t=Math.cos(n),o=Math.sin(n),i=Math.cos(n+r),a=Math.sin(n+r);return[{x:t-o*e,y:o+t*e},{x:i+a*e,y:a-i*e},{x:i,y:a}]}function G0(n,r,e,t){let o=n*t-r*e<0?-1:1,i=Math.min(1,Math.max(-1,n*e+r*t));return o*Math.acos(i)}function mM(n,r,e,t,o,i,a,s,l,c){let u=Math.pow(o,2),p=Math.pow(i,2),d=Math.pow(a,2),h=Math.pow(s,2),f=u*p-u*h-p*d;f<0&&(f=0),f/=u*h+p*d,f=Math.sqrt(f)*(l===c?-1:1);let m=f*o/i*s,y=f*-i/o*a,g=m+(n+e)/2,v=y+(r+t)/2,O=(a-m)/o,P=(s-y)/i,S=(-a-m)/o,T=(-s-y)/i,I=G0(1,0,O,P),x=G0(O,P,S,T);return!c&&x>0&&(x-=Ep),c&&x<0&&(x+=Ep),{centerx:g,centery:v,ang1:I,ang2:x}}function j0({px:n,py:r,cx:e,cy:t,rx:o,ry:i,largeArcFlag:a,sweepFlag:s}){let l=[];if(o===0||i===0)return[];let c=(n-e)/2,u=(r-t)/2;if(c===0&&u===0)return[];o=Math.abs(o),i=Math.abs(i);let p=Math.pow(c,2)/Math.pow(o,2)+Math.pow(u,2)/Math.pow(i,2);p>1&&(o*=Math.sqrt(p),i*=Math.sqrt(p));let d=mM(n,r,e,t,o,i,c,u,a,s),{ang1:h,ang2:f}=d,{centerx:m,centery:y}=d,g=Math.abs(f)/(Ep/4);Math.abs(1-g)<1e-7&&(g=1);let v=Math.max(Math.ceil(g),1);f/=v;for(let O=0;O<v;O++)l.push(hM(h,f)),h+=f;return l.map(O=>{let{x:P,y:S}=Dp(O[0],o,i,m,y),{x:T,y:I}=Dp(O[1],o,i,m,y),{x,y:_}=Dp(O[2],o,i,m,y);return{x1:P,y1:S,x2:T,y2:I,x,y:_}})}import{BufferAttribute as tu,BufferGeometry as AM}from"three";var Ge;(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"})(Ge||(Ge={}));var nt;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(nt||(nt={}));function we(n,r){if(!n)throw r||"Assertion Failed!"}var be=function(){function n(){}return n.vertEq=function(r,e){return r.s===e.s&&r.t===e.t},n.vertLeq=function(r,e){return r.s<e.s||r.s===e.s&&r.t<=e.t},n.transLeq=function(r,e){return r.t<e.t||r.t===e.t&&r.s<=e.s},n.edgeGoesLeft=function(r){return n.vertLeq(r.Dst,r.Org)},n.edgeGoesRight=function(r){return n.vertLeq(r.Org,r.Dst)},n.vertL1dist=function(r,e){return Math.abs(r.s-e.s)+Math.abs(r.t-e.t)},n.edgeEval=function(r,e,t){we(n.vertLeq(r,e)&&n.vertLeq(e,t));var o=e.s-r.s,i=t.s-e.s;return o+i>0?o<i?e.t-r.t+(r.t-t.t)*(o/(o+i)):e.t-t.t+(t.t-r.t)*(i/(o+i)):0},n.edgeSign=function(r,e,t){we(n.vertLeq(r,e)&&n.vertLeq(e,t));var o=e.s-r.s,i=t.s-e.s;return o+i>0?(e.t-t.t)*o+(e.t-r.t)*i:0},n.transEval=function(r,e,t){we(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?o<i?e.s-r.s+(r.s-t.s)*(o/(o+i)):e.s-t.s+(t.s-r.s)*(i/(o+i)):0},n.transSign=function(r,e,t){we(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?(e.s-t.s)*o+(e.s-r.s)*i:0},n.vertCCW=function(r,e,t){return r.s*(e.t-t.t)+e.s*(t.t-r.t)+t.s*(r.t-e.t)>=0},n.interpolate=function(r,e,t,o){return r=r<0?0:r,t=t<0?0:t,r<=t?t===0?(e+o)/2:e+(o-e)*(r/(r+t)):o+(e-o)*(t/(r+t))},n.intersect=function(r,e,t,o,i){var a,s,l;n.vertLeq(r,e)||(l=r,r=e,e=l),n.vertLeq(t,o)||(l=t,t=o,o=l),n.vertLeq(r,t)||(l=r,r=t,t=l,l=e,e=o,o=l),n.vertLeq(t,e)?n.vertLeq(e,o)?(a=n.edgeEval(r,t,e),s=n.edgeEval(t,e,o),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,t.s,s,e.s)):(a=n.edgeSign(r,t,e),s=-n.edgeSign(r,o,e),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,t.s,s,o.s)):i.s=(t.s+e.s)/2,n.transLeq(r,e)||(l=r,r=e,e=l),n.transLeq(t,o)||(l=t,t=o,o=l),n.transLeq(r,t)||(l=r,r=t,t=l,l=e,e=o,o=l),n.transLeq(t,e)?n.transLeq(e,o)?(a=n.transEval(r,t,e),s=n.transEval(t,e,o),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,t.t,s,e.t)):(a=n.transSign(r,t,e),s=-n.transSign(r,o,e),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,t.t,s,o.t)):i.t=(t.t+e.t)/2},n}(),Vs=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}(),Qc=function(){function n(r){this.side=r,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(r){this.Sym.Lface=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(r){this.Sym.Org=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(r){this.Sym.Lnext=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(r){this.Onext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(r){this.Lnext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(r){this.Sym.Onext=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(r){this.Sym.Onext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(r){this.Sym.Lnext.Sym=r},enumerable:!0,configurable:!0}),n}(),da=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}(),F0=function(){function n(){var r=new da,e=new Vs,t=new Qc(0),o=new Qc(1);r.next=r.prev=r,r.anEdge=null,e.next=e.prev=e,t.next=t,t.Sym=o,o.next=o,o.Sym=t,this.vHead=r,this.fHead=e,this.eHead=t,this.eHeadSym=o}return n.prototype.makeEdge_=function(r){var e=new Qc(0),t=new Qc(1);r.Sym.side<r.side&&(r=r.Sym);var o=r.Sym.next;return t.next=o,o.Sym.next=e,e.next=r,r.Sym.next=t,e.Sym=t,e.Onext=e,e.Lnext=t,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,t.Sym=e,t.Onext=t,t.Lnext=e,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,e},n.prototype.splice_=function(r,e){var t=r.Onext,o=e.Onext;t.Sym.Lnext=e,o.Sym.Lnext=r,r.Onext=o,e.Onext=t},n.prototype.makeVertex_=function(r,e,t){var o=r;we(o,"Vertex can't be null!");var i=t.prev;o.prev=i,i.next=o,o.next=t,t.prev=o,o.anEdge=e;var a=e;do a.Org=o,a=a.Onext;while(a!==e)},n.prototype.makeFace_=function(r,e,t){var o=r;we(o,"Face can't be null");var i=t.prev;o.prev=i,i.next=o,o.next=t,t.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=t.inside;var a=e;do a.Lface=o,a=a.Lnext;while(a!==e)},n.prototype.killEdge_=function(r){r.Sym.side<r.side&&(r=r.Sym);var e=r.next,t=r.Sym.next;e.Sym.next=t,t.Sym.next=e},n.prototype.killVertex_=function(r,e){var t=r.anEdge,o=t;do o.Org=e,o=o.Onext;while(o!==t);var i=r.prev,a=r.next;a.prev=i,i.next=a},n.prototype.killFace_=function(r,e){var t=r.anEdge,o=t;do o.Lface=e,o=o.Lnext;while(o!==t);var i=r.prev,a=r.next;a.prev=i,i.next=a},n.prototype.makeEdge=function(){var r=new da,e=new da,t=new Vs,o=this.makeEdge_(this.eHead);return this.makeVertex_(r,o,this.vHead),this.makeVertex_(e,o.Sym,this.vHead),this.makeFace_(t,o,this.fHead),o},n.prototype.splice=function(r,e){var t=!1,o=!1;if(r!==e){if(e.Org!==r.Org&&(o=!0,this.killVertex_(e.Org,r.Org)),e.Lface!==r.Lface&&(t=!0,this.killFace_(e.Lface,r.Lface)),this.splice_(e,r),!o){var i=new da;this.makeVertex_(i,e,r.Org),r.Org.anEdge=r}if(!t){var a=new Vs;this.makeFace_(a,e,r.Lface),r.Lface.anEdge=r}}},n.prototype.delete=function(r){var e=r.Sym,t=!1;if(r.Lface!==r.Rface&&(t=!0,this.killFace_(r.Lface,r.Rface)),r.Onext===r)this.killVertex_(r.Org,null);else if(r.Rface.anEdge=r.Oprev,r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev),!t){var o=new Vs;this.makeFace_(o,r,r.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(r.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(r)},n.prototype.addEdgeVertex=function(r){var e=this.makeEdge_(r),t=e.Sym;this.splice_(e,r.Lnext),e.Org=r.Dst;var o=new da;return this.makeVertex_(o,t,e.Org),e.Lface=t.Lface=r.Lface,e},n.prototype.splitEdge=function(r){var e=this.addEdgeVertex(r),t=e.Sym;return this.splice_(r.Sym,r.Sym.Oprev),this.splice_(r.Sym,t),r.Dst=t.Org,t.Dst.anEdge=t.Sym,t.Rface=r.Rface,t.winding=r.winding,t.Sym.winding=r.Sym.winding,t.idx=r.idx,t.Sym.idx=r.Sym.idx,t},n.prototype.connect=function(r,e){var t=!1,o=this.makeEdge_(r),i=o.Sym;if(e.Lface!==r.Lface&&(t=!0,this.killFace_(e.Lface,r.Lface)),this.splice_(o,r.Lnext),this.splice_(i,e),o.Org=r.Dst,i.Org=e.Org,o.Lface=i.Lface=r.Lface,r.Lface.anEdge=i,!t){var a=new Vs;this.makeFace_(a,o,r.Lface)}return o},n.prototype.zapFace=function(r){var e=r.anEdge,t,o,i,a,s;o=e.Lnext;do t=o,o=t.Lnext,t.Lface=null,t.Rface===null&&(t.Onext===t?this.killVertex_(t.Org,null):(t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),i=t.Sym,i.Onext===i?this.killVertex_(i.Org,null):(i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t));while(t!=e);a=r.prev,s=r.next,s.prev=a,a.next=s},n.prototype.countFaceVerts_=function(r){var e=r.anEdge,t=0;do t++,e=e.Lnext;while(e!==r.anEdge);return t},n.prototype.mergeConvexFaces=function(r){var e,t,o,i,a,s,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(t=e.anEdge,a=t.Org;o=t.Lnext,i=t.Sym,i&&i.Lface&&i.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(i.Lface),s+l-2<=r&&be.vertCCW(t.Lprev.Org,t.Org,i.Lnext.Lnext.Org)&&be.vertCCW(i.Lprev.Org,i.Org,t.Lnext.Lnext.Org)&&(o=i.Lnext,this.delete(i),t=null,i=null)),!(t&&t.Lnext.Org===a);)t=o;return!0},n.prototype.check=function(){var r=this.fHead,e=this.vHead,t=this.eHead,o,i,a,s,l,c;for(i=r,i=r;(o=i.next)!==r;i=o){we(o.prev===i),l=o.anEdge;do we(l.Sym!==l),we(l.Sym.Sym===l),we(l.Lnext.Onext.Sym===l),we(l.Onext.Sym.Lnext===l),we(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(we(o.prev===i&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){we(a.prev===s),l=a.anEdge;do we(l.Sym!==l),we(l.Sym.Sym===l),we(l.Lnext.Onext.Sym===l),we(l.Onext.Sym.Lnext===l),we(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(we(a.prev===s&&a.anEdge===null),c=t,c=t;(l=c.next)!==t;c=l)we(l.Sym.next===c.Sym),we(l.Sym!==l),we(l.Sym.Sym===l),we(l.Org!==null),we(l.Dst!==null),we(l.Lnext.Onext.Sym===l),we(l.Onext.Sym.Lnext===l);we(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}(),U0=function(){function n(){this.handle=null}return n}(),k0=function(){function n(){this.key=null,this.node=0}return n}(),yM=function(){function n(r,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=r,this.nodes=[],this.handles=[];for(var t=0;t<r+1;t++)this.nodes[t]=new U0,this.handles[t]=new k0;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(r){var e=this.nodes,t=this.handles,o,i,a;for(o=e[r].handle;;){if(a=r<<1,a<this.size&&this.leq(t[e[a+1].handle].key,t[e[a].handle].key)&&++a,we(a<=this.max),i=e[a].handle,a>this.size||this.leq(t[o].key,t[i].key)){e[r].handle=o,t[o].node=r;break}e[r].handle=i,t[i].node=r,r=a}},n.prototype.floatUp_=function(r){var e=this.nodes,t=this.handles,o,i,a;for(o=e[r].handle;;){if(a=r>>1,i=e[a].handle,a===0||this.leq(t[i].key,t[o].key)){e[r].handle=o,t[o].node=r;break}e[r].handle=i,t[i].node=r,r=a}},n.prototype.init=function(){for(var r=this.size;r>=1;--r)this.floatDown_(r);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(r){var e,t;if(e=++this.size,e*2>this.max){this.max*=2;var o,i;for(i=this.nodes.length,this.nodes.length=this.max+1,o=i;o<this.nodes.length;o++)this.nodes[o]=new U0;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new k0}return this.freeList===0?t=e:(t=this.freeList,this.freeList=this.handles[t].node),this.nodes[e].handle=t,this.handles[t].node=e,this.handles[t].key=r,this.initialized&&this.floatUp_(e),t},n.prototype.extractMin=function(){var r=this.nodes,e=this.handles,t=r[1].handle,o=e[t].key;return this.size>0&&(r[1].handle=r[this.size].handle,e[r[1].handle].node=1,e[t].key=null,e[t].node=this.freeList,this.freeList=t,--this.size,this.size>0&&this.floatDown_(1)),o},n.prototype.delete=function(r){var e=this.nodes,t=this.handles,o;we(r>=1&&r<=this.max&&t[r].key!==null),o=t[r].node,e[o].handle=e[this.size].handle,t[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(t[e[o>>1].handle].key,t[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),t[r].key=null,t[r].node=this.freeList,this.freeList=r},n}(),_p=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}(),H0=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),gM=function(){function n(r,e){this.frame=r,this.leq=e,this.head=new H0,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(r){return this.insertBefore(this.head,r)},n.prototype.search=function(r){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,r,e.key));return e},n.prototype.insertBefore=function(r,e){do r=r.prev;while(r.key!==null&&!this.leq(this.frame,r.key,e));var t=new H0;return t.key=e,t.next=r.next,r.next.prev=t,t.prev=r,r.next=t,t},n.prototype.delete=function(r){r.next.prev=r.prev,r.prev.next=r.next},n}(),xM=function(){function n(){}return n.regionBelow=function(r){return r.nodeUp.prev.key},n.regionAbove=function(r){return r.nodeUp.next.key},n.debugEvent=function(r){},n.addWinding=function(r,e){r.winding+=e.winding,r.Sym.winding+=e.Sym.winding},n.edgeLeq=function(r,e,t){var o=r.event,i=e.eUp,a=t.eUp;if(i.Dst===o)return a.Dst===o?be.vertLeq(i.Org,a.Org)?be.edgeSign(a.Dst,i.Org,a.Org)<=0:be.edgeSign(i.Dst,a.Org,i.Org)>=0:be.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return be.edgeSign(i.Dst,o,i.Org)>=0;var s=be.edgeEval(i.Dst,o,i.Org),l=be.edgeEval(a.Dst,o,a.Org);return s>=l},n.deleteRegion=function(r,e){e.fixUpperEdge&&we(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},n.fixUpperEdge=function(r,e,t){we(e.fixUpperEdge),r.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=t,t.activeRegion=e},n.topLeftRegion=function(r,e){var t=e.eUp.Org,o;do e=n.regionAbove(e);while(e.eUp.Org===t);if(e.fixUpperEdge){if(o=r.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;n.fixUpperEdge(r,e,o),e=n.regionAbove(e)}return e},n.topRightRegion=function(r){var e=r.eUp.Dst;do r=n.regionAbove(r);while(r.eUp.Dst===e);return r},n.addRegionBelow=function(r,e,t){var o=new _p;return o.eUp=t,o.nodeUp=r.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,t.activeRegion=o,o},n.isWindingInside=function(r,e){switch(r.windingRule){case Ge.ODD:return(e&1)!==0;case Ge.NONZERO:return e!==0;case Ge.POSITIVE:return e>0;case Ge.NEGATIVE:return e<0;case Ge.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(r,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(r,e.windingNumber)},n.finishRegion=function(r,e){var t=e.eUp,o=t.Lface;o.inside=e.inside,o.anEdge=t,n.deleteRegion(r,e)},n.finishLeftRegions=function(r,e,t){for(var o,i=null,a=e,s=e.eUp;a!==t;){if(a.fixUpperEdge=!1,i=n.regionBelow(a),o=i.eUp,o.Org!=s.Org){if(!i.fixUpperEdge){n.finishRegion(r,a);break}o=r.mesh.connect(s.Lprev,o.Sym),n.fixUpperEdge(r,i,o)}s.Onext!==o&&(r.mesh.splice(o.Oprev,o),r.mesh.splice(s,o)),n.finishRegion(r,a),s=i.eUp,a=i}return s},n.addRightEdges=function(r,e,t,o,i,a){var s,l,c,u,p=!0;c=t;do we(be.vertLeq(c.Org,c.Dst)),n.addRegionBelow(r,e,c.Sym),c=c.Onext;while(c!==o);for(i===null&&(i=n.regionBelow(e).eUp.Rprev),l=e,u=i;s=n.regionBelow(l),c=s.eUp.Sym,c.Org===u.Org;)c.Onext!==u&&(r.mesh.splice(c.Oprev,c),r.mesh.splice(u.Oprev,c)),s.windingNumber=l.windingNumber-c.winding,s.inside=n.isWindingInside(r,s.windingNumber),l.dirty=!0,!p&&n.checkForRightSplice(r,l)&&(n.addWinding(c,u),n.deleteRegion(r,l),r.mesh.delete(u)),p=!1,l=s,u=c;l.dirty=!0,we(l.windingNumber-c.winding===s.windingNumber),a&&n.walkDirtyRegions(r,l)},n.spliceMergeVertices=function(r,e,t){r.mesh.splice(e,t)},n.vertexWeights=function(r,e,t){var o=be.vertL1dist(e,r),i=be.vertL1dist(t,r),a=.5*i/(o+i),s=.5*o/(o+i);r.coords[0]+=a*e.coords[0]+s*t.coords[0],r.coords[1]+=a*e.coords[1]+s*t.coords[1],r.coords[2]+=a*e.coords[2]+s*t.coords[2]},n.getIntersectData=function(r,e,t,o,i,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,t,o),n.vertexWeights(e,i,a)},n.checkForRightSplice=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp;if(be.vertLeq(o.Org,i.Org)){if(be.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;be.vertEq(o.Org,i.Org)?o.Org!==i.Org&&(r.pq.delete(o.Org.pqHandle),n.spliceMergeVertices(r,i.Oprev,o)):(r.mesh.splitEdge(i.Sym),r.mesh.splice(o,i.Oprev),e.dirty=t.dirty=!0)}else{if(be.edgeSign(o.Dst,i.Org,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,r.mesh.splitEdge(o.Sym),r.mesh.splice(i.Oprev,o)}return!0},n.checkForLeftSplice=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp,a;if(we(!be.vertEq(o.Dst,i.Dst)),be.vertLeq(o.Dst,i.Dst)){if(be.edgeSign(o.Dst,i.Dst,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,a=r.mesh.splitEdge(o),r.mesh.splice(i.Sym,a),a.Lface.inside=e.inside}else{if(be.edgeSign(i.Dst,o.Dst,i.Org)>0)return!1;e.dirty=t.dirty=!0,a=r.mesh.splitEdge(i),r.mesh.splice(o.Lnext,i.Sym),a.Rface.inside=e.inside}return!0},n.checkForIntersect=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp,a=o.Org,s=i.Org,l=o.Dst,c=i.Dst,u,p,d=new da,h,f;if(we(!be.vertEq(c,l)),we(be.edgeSign(l,r.event,a)<=0),we(be.edgeSign(c,r.event,s)>=0),we(a!==r.event&&s!==r.event),we(!e.fixUpperEdge&&!t.fixUpperEdge),a===s||(u=Math.min(a.t,l.t),p=Math.max(s.t,c.t),u>p))return!1;if(be.vertLeq(a,s)){if(be.edgeSign(c,a,s)>0)return!1}else if(be.edgeSign(l,s,a)<0)return!1;return n.debugEvent(r),be.intersect(l,a,c,s,d),we(Math.min(a.t,l.t)<=d.t),we(d.t<=Math.max(s.t,c.t)),we(Math.min(c.s,l.s)<=d.s),we(d.s<=Math.max(s.s,a.s)),be.vertLeq(d,r.event)&&(d.s=r.event.s,d.t=r.event.t),h=be.vertLeq(a,s)?a:s,be.vertLeq(h,d)&&(d.s=h.s,d.t=h.t),be.vertEq(d,a)||be.vertEq(d,s)?(n.checkForRightSplice(r,e),!1):!be.vertEq(l,r.event)&&be.edgeSign(l,r.event,d)>=0||!be.vertEq(c,r.event)&&be.edgeSign(c,r.event,d)<=0?c===r.event?(r.mesh.splitEdge(o.Sym),r.mesh.splice(i.Sym,o),e=n.topLeftRegion(r,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(r,n.regionBelow(e),t),n.addRightEdges(r,e,o.Oprev,o,o,!0),!0):l===r.event?(r.mesh.splitEdge(i.Sym),r.mesh.splice(o.Lnext,i.Oprev),t=e,e=n.topRightRegion(e),f=n.regionBelow(e).eUp.Rprev,t.eUp=i.Oprev,i=n.finishLeftRegions(r,t,null),n.addRightEdges(r,e,i.Onext,o.Rprev,f,!0),!0):(be.edgeSign(l,r.event,d)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,r.mesh.splitEdge(o.Sym),o.Org.s=r.event.s,o.Org.t=r.event.t),be.edgeSign(c,r.event,d)<=0&&(e.dirty=t.dirty=!0,r.mesh.splitEdge(i.Sym),i.Org.s=r.event.s,i.Org.t=r.event.t),!1):(r.mesh.splitEdge(o.Sym),r.mesh.splitEdge(i.Sym),r.mesh.splice(i.Oprev,o),o.Org.s=d.s,o.Org.t=d.t,o.Org.pqHandle=r.pq.insert(o.Org),n.getIntersectData(r,o.Org,a,l,s,c),n.regionAbove(e).dirty=e.dirty=t.dirty=!0,!1)},n.walkDirtyRegions=function(r,e){for(var t=n.regionBelow(e),o,i;;){for(;t.dirty;)e=t,t=n.regionBelow(t);if(!e.dirty&&(t=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,i=t.eUp,o.Dst!==i.Dst&&n.checkForLeftSplice(r,e)&&(t.fixUpperEdge?(n.deleteRegion(r,t),r.mesh.delete(i),t=n.regionBelow(e),i=t.eUp):e.fixUpperEdge&&(n.deleteRegion(r,e),r.mesh.delete(o),e=n.regionAbove(t),o=e.eUp)),o.Org!==i.Org)if(o.Dst!==i.Dst&&!e.fixUpperEdge&&!t.fixUpperEdge&&(o.Dst===r.event||i.Dst===r.event)){if(n.checkForIntersect(r,e))return}else n.checkForRightSplice(r,e);o.Org===i.Org&&o.Dst===i.Dst&&(n.addWinding(i,o),n.deleteRegion(r,e),r.mesh.delete(o),e=n.regionAbove(t))}},n.connectRightVertex=function(r,e,t){var o,i=t.Onext,a=n.regionBelow(e),s=e.eUp,l=a.eUp,c=!1;if(s.Dst!==l.Dst&&n.checkForIntersect(r,e),be.vertEq(s.Org,r.event)&&(r.mesh.splice(i.Oprev,s),e=n.topLeftRegion(r,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(r,n.regionBelow(e),a),c=!0),be.vertEq(l.Org,r.event)&&(r.mesh.splice(t,l.Oprev),t=n.finishLeftRegions(r,a,null),c=!0),c){n.addRightEdges(r,e,t.Onext,i,i,!0);return}be.vertLeq(l.Org,s.Org)?o=l.Oprev:o=s,o=r.mesh.connect(t.Lprev,o),n.addRightEdges(r,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(r,e)},n.connectLeftDegenerate=function(r,e,t){var o,i,a,s,l;if(o=e.eUp,be.vertEq(o.Org,t)){we(!1),n.spliceMergeVertices(r,o,t.anEdge);return}if(!be.vertEq(o.Dst,t)){r.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(r.mesh.delete(o.Onext),e.fixUpperEdge=!1),r.mesh.splice(t.anEdge,o),n.sweepEvent(r,t);return}we(!1),e=n.topRightRegion(e),l=n.regionBelow(e),a=l.eUp.Sym,i=s=a.Onext,l.fixUpperEdge&&(we(i!==a),n.deleteRegion(r,l),r.mesh.delete(a),a=i.Oprev),r.mesh.splice(t.anEdge,a),be.edgeGoesLeft(i)||(i=null),n.addRightEdges(r,e,a.Onext,s,i,!0)},n.connectLeftVertex=function(r,e){var t,o,i,a,s,l,c=new _p;if(c.eUp=e.anEdge.Sym,t=r.dict.search(c).key,o=n.regionBelow(t),!!o){if(a=t.eUp,s=o.eUp,be.edgeSign(a.Dst,e,a.Org)===0){n.connectLeftDegenerate(r,t,e);return}if(i=be.vertLeq(s.Dst,a.Dst)?t:o,t.inside||i.fixUpperEdge){if(i===t)l=r.mesh.connect(e.anEdge.Sym,a.Lnext);else{var u=r.mesh.connect(s.Dnext,e.anEdge);l=u.Sym}i.fixUpperEdge?n.fixUpperEdge(r,i,l):n.computeWinding(r,n.addRegionBelow(r,t,l)),n.sweepEvent(r,e)}else n.addRightEdges(r,t,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(r,e){r.event=e,n.debugEvent(r);for(var t=e.anEdge;t.activeRegion===null;)if(t=t.Onext,t===e.anEdge){n.connectLeftVertex(r,e);return}var o=n.topLeftRegion(r,t.activeRegion);we(o!==null);var i=n.regionBelow(o),a=i.eUp,s=n.finishLeftRegions(r,i,null);s.Onext===a?n.connectRightVertex(r,o,s):n.addRightEdges(r,o,s.Onext,a,a,!0)},n.addSentinel=function(r,e,t,o){var i=new _p,a=r.mesh.makeEdge();a.Org.s=t,a.Org.t=o,a.Dst.s=e,a.Dst.t=o,r.event=a.Dst,i.eUp=a,i.windingNumber=0,i.inside=!1,i.fixUpperEdge=!1,i.sentinel=!0,i.dirty=!1,i.nodeUp=r.dict.insert(i)},n.initEdgeDict=function(r){r.dict=new gM(r,n.edgeLeq);var e=r.bmax[0]-r.bmin[0],t=r.bmax[1]-r.bmin[1],o=r.bmin[0]-e,i=r.bmax[0]+e,a=r.bmin[1]-t,s=r.bmax[1]+t;n.addSentinel(r,o,i,a),n.addSentinel(r,o,i,s)},n.doneEdgeDict=function(r){for(var e,t=0;(e=r.dict.min().key)!==null;)e.sentinel||(we(e.fixUpperEdge),we(++t===1)),we(e.windingNumber===0),n.deleteRegion(r,e)},n.removeDegenerateEdges=function(r){var e,t,o,i=r.mesh.eHead;for(e=i.next;e!==i;e=t)t=e.next,o=e.Lnext,be.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(r,o,e),r.mesh.delete(e),e=o,o=e.Lnext),o.Lnext===e&&(o!==e&&((o===t||o===t.Sym)&&(t=t.next),r.mesh.delete(o)),(e===t||e===t.Sym)&&(t=t.next),r.mesh.delete(e))},n.initPriorityQ=function(r){var e,t,o,i=0;for(o=r.mesh.vHead,t=o.next;t!==o;t=t.next)i++;for(i+=8,e=r.pq=new yM(i,be.vertLeq),o=r.mesh.vHead,t=o.next;t!==o;t=t.next)t.pqHandle=e.insert(t);return t!==o?!1:(e.init(),!0)},n.donePriorityQ=function(r){r.pq=null},n.removeDegenerateFaces=function(r,e){var t,o,i;for(t=e.fHead.next;t!==e.fHead;t=o)o=t.next,i=t.anEdge,we(i.Lnext!==i),i.Lnext.Lnext===i&&(n.addWinding(i.Onext,i),r.mesh.delete(i));return!0},n.computeInterior=function(r,e){e===void 0&&(e=!0);var t,o;if(n.removeDegenerateEdges(r),!n.initPriorityQ(r))return!1;for(n.initEdgeDict(r);(t=r.pq.extractMin())!==null;){for(;o=r.pq.min(),!(o===null||!be.vertEq(o,t));)o=r.pq.extractMin(),n.spliceMergeVertices(r,t.anEdge,o.anEdge);n.sweepEvent(r,t)}return r.event=r.dict.min().key.eUp.Org,n.debugEvent(r),n.doneEdgeDict(r),n.donePriorityQ(r),n.removeDegenerateFaces(r,r.mesh)?(e&&r.mesh.check(),!0):!1},n}(),bM=function(){function n(){this.mesh=new F0,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=Ge.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(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]},n.prototype.normalize_=function(r){var e=r[0]*r[0]+r[1]*r[1]+r[2]*r[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),r[0]/=e,r[1]/=e,r[2]/=e},n.prototype.longAxis_=function(r){var e=0;return Math.abs(r[1])>Math.abs(r[0])&&(e=1),Math.abs(r[2])>Math.abs(r[e])&&(e=2),e},n.prototype.computeNormal_=function(r){var e,t,o,i,a,s,l=[0,0,0],c=[0,0,0],u=[0,0,0],p=[0,0,0],d=[0,0,0],h=[null,null,null],f=[null,null,null],m=this.mesh.vHead;e=m.next;for(var y=0;y<3;++y)i=e.coords[y],c[y]=i,f[y]=e,l[y]=i,h[y]=e;for(e=m.next;e!==m;e=e.next)for(var g=0;g<3;++g)i=e.coords[g],i<c[g]&&(c[g]=i,f[g]=e),i>l[g]&&(l[g]=i,h[g]=e);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){r[0]=0,r[1]=0,r[2]=1;return}for(s=0,t=f[v],o=h[v],u[0]=t.coords[0]-o.coords[0],u[1]=t.coords[1]-o.coords[1],u[2]=t.coords[2]-o.coords[2],e=m.next;e!==m;e=e.next)p[0]=e.coords[0]-o.coords[0],p[1]=e.coords[1]-o.coords[1],p[2]=e.coords[2]-o.coords[2],d[0]=u[1]*p[2]-u[2]*p[1],d[1]=u[2]*p[0]-u[0]*p[2],d[2]=u[0]*p[1]-u[1]*p[0],a=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],a>s&&(s=a,r[0]=d[0],r[1]=d[1],r[2]=d[2]);s<=0&&(r[0]=r[1]=r[2]=0,r[this.longAxis_(u)]=1)},n.prototype.checkOrientation_=function(){for(var r=this.mesh.fHead,e,t=this.mesh.vHead,o,i=0,a=r.next;a!==r;a=a.next)if(o=a.anEdge,!(o.winding<=0))do i+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==a.anEdge);if(i<0){for(e=t.next;e!==t;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 r=this.mesh.vHead,e=[0,0,0],t,o,i=!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),i=!0),t=this.sUnit,o=this.tUnit;var a=this.longAxis_(e);t[a]=0,t[(a+1)%3]=1,t[(a+2)%3]=0,o[a]=0,o[(a+1)%3]=0,o[(a+2)%3]=e[a]>0?1:-1;for(var s=r.next;s!==r;s=s.next)s.s=this.dot_(s.coords,t),s.t=this.dot_(s.coords,o);i&&this.checkOrientation_();for(var l=!0,c=r.next;c!==r;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(r,e){r.winding+=e.winding,r.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(r,e){var t,o;if(t=e.anEdge,!(t.Lnext!==t&&t.Lnext.Lnext!==t))throw"Mono region invalid";for(;be.vertLeq(t.Dst,t.Org);t=t.Lprev);for(;be.vertLeq(t.Org,t.Dst);t=t.Lnext);o=t.Lprev;for(var i=void 0;t.Lnext!==o;)if(be.vertLeq(t.Dst,o.Org)){for(;o.Lnext!==t&&(be.edgeGoesLeft(o.Lnext)||be.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)i=r.connect(o.Lnext,o),o=i.Sym;o=o.Lprev}else{for(;o.Lnext!==t&&(be.edgeGoesRight(t.Lprev)||be.edgeSign(t.Dst,t.Org,t.Lprev.Org)>=0);)i=r.connect(t,t.Lprev),t=i.Sym;t=t.Lnext}if(o.Lnext===t)throw"Mono region invalid";for(;o.Lnext.Lnext!==t;)i=r.connect(o.Lnext,o),o=i.Sym;return!0},n.prototype.tessellateInterior_=function(r){for(var e,t=r.fHead.next;t!==r.fHead;t=e)if(e=t.next,t.inside&&!this.tessellateMonoRegion_(r,t))return!1;return!0},n.prototype.discardExterior_=function(r){for(var e,t=r.fHead.next;t!==r.fHead;t=e)e=t.next,t.inside||r.zapFace(t)},n.prototype.setWindingNumber_=function(r,e,t){for(var o,i=r.eHead.next;i!==r.eHead;i=o)o=i.next,i.Rface.inside!==i.Lface.inside?i.winding=i.Lface.inside?e:-e:t?r.delete(i):i.winding=0},n.prototype.getNeighbourFace_=function(r){return!r.Rface||!r.Rface.inside?-1:r.Rface.n},n.prototype.outputPolymesh_=function(r,e,t,o){var i,a=0,s=0,l;t>3&&r.mergeConvexFaces(t);for(var c=r.vHead.next;c!==r.vHead;c=c.next)c.n=-1;for(var u=r.fHead.next;u!==r.fHead;u=u.next)if(u.n=-1,!!u.inside){i=u.anEdge,l=0;do{var c=i.Org;c.n===-1&&(c.n=s,s++),l++,i=i.Lnext}while(i!==u.anEdge);if(l>t)throw"Face vertex greater that support polygon";u.n=a,++a}this.elementCount=a,e===nt.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*t,this.vertexCount=s,this.vertices=[],this.vertices.length=s*o,this.vertexIndices=[],this.vertexIndices.length=s;for(var c=r.vHead.next;c!==r.vHead;c=c.next)if(c.n!==-1){var p=c.n*o;this.vertices[p+0]=c.coords[0],this.vertices[p+1]=c.coords[1],o>2&&(this.vertices[p+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var d=0,u=r.fHead.next;u!==r.fHead;u=u.next)if(!!u.inside){i=u.anEdge,l=0;do{var c=i.Org;this.elements[d++]=c.n,l++,i=i.Lnext}while(i!==u.anEdge);for(var h=l;h<t;++h)this.elements[d++]=-1;if(e===nt.CONNECTED_POLYGONS){i=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==u.anEdge);for(var f=l;f<t;++f)this.elements[d++]=-1}}},n.prototype.outputContours_=function(r,e){var t,o,i=0,a=0;this.vertexCount=0,this.elementCount=0;for(var s=r.fHead.next;s!==r.fHead;s=s.next)if(!!s.inside){o=t=s.anEdge;do this.vertexCount++,t=t.Lnext;while(t!==o);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,u=0;i=0;for(var s=r.fHead.next;s!==r.fHead;s=s.next)if(!!s.inside){a=0,o=t=s.anEdge;do this.vertices[l++]=t.Org.coords[0],this.vertices[l++]=t.Org.coords[1],e>2&&(this.vertices[l++]=t.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(t):t.Org.idx,a++,t=t.Lnext;while(t!==o);this.elements[u++]=i,this.elements[u++]=a,i+=a}},n.prototype.addContour=function(r,e){this.mesh===null&&(this.mesh=new F0),r<2&&(r=2),r>3&&(r=3);for(var t=null,o=0;o<e.length;o+=r)t===null?(t=this.mesh.makeEdge(),this.mesh.splice(t,t.Sym)):(this.mesh.splitEdge(t),t=t.Lnext),t.Org.coords[0]=e[o+0],t.Org.coords[1]=e[o+1],r>2?t.Org.coords[2]=e[o+2]:t.Org.coords[2]=0,t.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(t),t.winding=1,t.Sym.winding=-1},n.prototype.tesselate=function(r,e,t,o,i,a){if(r===void 0&&(r=Ge.ODD),e===void 0&&(e=nt.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,i&&(this.normal[0]=i[0],this.normal[1]=i[1],this.normal[2]=i[2]),this.windingRule=r,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),xM.computeInterior(this,a);var s=this.mesh;return e===nt.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===nt.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,t,o),!0},n}();function Rr(n){var r=n.windingRule,e=r===void 0?Ge.ODD:r,t=n.elementType,o=t===void 0?nt.POLYGONS:t,i=n.polySize,a=i===void 0?3:i,s=n.vertexSize,l=s===void 0?2:s,c=n.normal,u=c===void 0?[0,0,1]:c,p=n.contours,d=p===void 0?[]:p,h=n.strict,f=h===void 0?!0:h,m=n.debug,y=m===void 0?!1:m;if(!d&&f)throw new Error("Contours can't be empty");if(!!d){var g=new bM;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var v=0;v<d.length;v++)g.addContour(l||2,d[v]);return g.tesselate(e,o,a,l,u,f),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var SW=Ge.ODD,wW=Ge.NONZERO,PW=Ge.POSITIVE,OW=Ge.NEGATIVE,CW=Ge.ABS_GEQ_TWO,TW=nt.POLYGONS,AW=nt.CONNECTED_POLYGONS,MW=nt.BOUNDARY_CONTOURS;import{Box2 as OM,BufferAttribute as eu,BufferGeometry as CM,Vector2 as TM}from"three";var Zc=class{constructor(r=256,e=!1){this.capacity=r,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${r}`);let t=r*Zc.eSize;this.buffer=new ArrayBuffer(t);let o=Float32Array.BYTES_PER_ELEMENT,i=0;this.positions=new Float32Array(this.buffer,i*o,3*r),i+=3*r,this.normals=new Float32Array(this.buffer,i*o,3*r),i+=3*r,this.uvs=new Float32Array(this.buffer,i*o,2*r)}realloc(r,e=!1){if(r<this.size)throw Error("cannot shrink buffer");if(r<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${r}`);let t=r*Zc.eSize,o=new ArrayBuffer(t),i=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*i,3*r);a+=3*r;let l=new Float32Array(o,a*i,3*r);a+=3*r;let c=new Float32Array(o,a*i,2*r);e?(s.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),c.set(this.uvs.subarray(0,this.size*2))):(s.set(this.positions),l.set(this.normals),c.set(this.uvs)),this.buffer=o,this.positions=s,this.normals=l,this.uvs=c,this.capacity=r}get(r=1){let e=this.size+r;if(e>this.capacity){let o=this.capacity;for(;e>o;)o*=2;this.realloc(o)}let t=this.size;return this.size=e,t}reserve(r){let e=this.size+r;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},zs=Zc;zs.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Y0=fi($0()),Gs={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},zp={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Gp={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},Vp=(n,r)=>([e,t])=>(t<e&&(t+=r),(n>=e?n:n+r)<=t),dn=class extends CM{constructor(e,t,o=0,i=12,a=3,s=Ge.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._curveSegments=i,this._bevelSegmentsInput=a;let c=this._shape.extractShapePointsToFlatArray([],i),u=this._shape.shapeHoles.map(A=>{let N=A.extractShapePointsToFlatArray([],i),E=[];for(let B=N.length-1;B>=1;B-=2){let V=N[B-1],j=N[B-0];E.push(V,j)}return E}),p=[],d=[];for(let A=0;A<c.length;A+=2)d.push([c[A],c[A+1]]);p.push(d);for(let A=0;A<u.length;A++){let N=u[A],E=[];for(let B=0;B<N.length;B+=2)E.push([N[B],N[B+1]]);p.push(E)}let h;e.isText?h=new OM().setFromPoints(e.points.map(N=>N.position)).getSize(new TM).length()*.1:p[0].length===0?h=o:h=(0,Y0.default)(p).distance,o<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(o,h,t/2),this._bevelSegments=Math.floor(a));let f;try{f=Rr({windingRule:s,elementType:nt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{f=Gs}let m;try{m=Rr({windingRule:Ge.ODD,elementType:nt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{m=zp}if(!f)throw new Error("error generating geometry");let y=f.elementCount;if(m){f.elementCount+=m.elementCount;for(let A=0;A<m.elements.length;A++){let N=m.elements[A],E=A%2===0?f.vertexCount:0;f.elements.push(N+E)}for(let A=0;A<m.vertexIndices.length;A++){let N=m.vertexIndices[A],E=f.vertexCount;f.vertexIndices.push(N+E)}for(let A=0;A<m.vertices.length;A++){let N=m.vertices[A];f.vertices.push(N)}}let g=1/0,v=-1/0,O=1/0,P=-1/0;for(let A=0,N=f.vertexCount;A<N;A++){let E=A*2,B=f.vertices[E+0],V=f.vertices[E+1];B<g&&(g=B),B>v&&(v=B),V<O&&(O=V),V>P&&(P=V)}this._minX=g,this._minY=O,this._width=v-g,this._height=P-O,this._buffer=new zs(this._computeBufferEstimatedSize(f));let S=[],T=[];for(let A=f.elementCount-1;A>=0;A--){let N=A>=y,E=A*2,B=f.elements[E+0],V=f.elements[E+1],j=B+V,R={start:B,count:V,normals:[],continuous:[],concave:[]},W=B,F=j-1,k=B+1,H=this._shape.roundedCurves.length;do{let te=W-B,Y=f.vertices[F*2+0],ee=f.vertices[F*2+1],K=f.vertices[W*2+0],q=f.vertices[W*2+1],ue=f.vertices[k*2+0],le=f.vertices[k*2+1],ne=K-Y,ce=q-ee,ae=Math.sqrt(ne*ne+ce*ce);ne/=ae,ce/=ae;let he=K-ue,pe=q-le,fe=Math.sqrt(he*he+pe*pe);he/=fe,pe/=fe,R.normals[te*2+0]=-pe,R.normals[te*2+1]=he,R.concave[te]=ne*pe-ce*he>0;let ge=f.vertexIndices[W];if(Array.isArray(ge))R.continuous[te]=!1;else{let[me,C]=this._shape.getCurveIndexFromVertexId(ge-1,!0);if(C>0&&C<1)R.continuous[te]=!0;else{let ie=C===1?me+1:me-1;ie=(ie+H)%H;let De=C===1?0:1,Re=this._shape.roundedCurves[me].getTangent(C),Ee=this._shape.roundedCurves[ie].getTangent(De);R.continuous[te]=Re.dot(Ee)>.95}}N&&(R.normals[te*2+0]*=-1,R.normals[te*2+1]*=-1),[F,W,k]=[W,k,k+1],k>=j&&(k-=V)}while(k!==B+1);let $=[];$.push({bevelI:0,angle:0,size:0,boundary:{vertices:f.vertices.slice(B*2,j*2),vertexCount:V,vertexIndices:new Array(V).fill(!0).map((te,Y)=>[Y,Y]),elements:[0,V],elementCount:1,mesh:null},reverseMap:[],insetPoints:f.vertices.slice(B*2,j*2)});let J=0;for(let te=1;te<=this._bevelSegments;te++){let Y=te/this._bevelSegments*Math.PI/2,ee=(1-Math.cos(Y))*this._bevel,K=[],q=[],ue=[],le=[],ne=0;for(let ae=0;ae<V;ae++){let he=ae*2,pe=(ae-1+V)%V*2,fe=f.vertices[R.start*2+he+0],ge=f.vertices[R.start*2+he+1],me=-R.normals[pe+0]*ee,C=-R.normals[pe+1]*ee,ie=-R.normals[he+0]*ee,De=-R.normals[he+1]*ee;if(R.concave[ae]||!R.concave[ae]&&N){let Re=Math.atan2(C,me),Ee=Math.atan2(De,ie);Ee>Re&&(Ee-=Math.PI*2);let Pe=Ee-Re;if(R.continuous[ae]||N){let xt=Re+Pe/2,Me=Math.cos(xt)*ee,mt=Math.sin(xt)*ee;K[2*ne+0]=fe+Me*(N?-1:1),K[2*ne+1]=ge+mt*(N?-1:1),le[ne]=ae,ne++}else{let xt=Math.max(1,Math.floor(i/4*Math.abs(Pe)/Math.PI));for(let Me=0;Me<=xt;Me++){let mt=Re+Pe*(Me/xt),bt=Math.cos(mt)*ee,Tn=Math.sin(mt)*ee;K[2*ne+0]=fe+bt,K[2*ne+1]=ge+Tn,le[ne]=ae,ne++}}}else K[2*ne+0]=fe+me,K[2*ne+1]=ge+C,le[ne]=ae,q[ae]=ne,ne++,K[2*ne+0]=fe,K[2*ne+1]=ge,le[ne]=ae,ne++,K[2*ne+0]=fe+ie,K[2*ne+1]=ge+De,le[ne]=ae,ue[ae]=ne,ne++}let ce=Rr({windingRule:Ge.POSITIVE,elementType:nt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[K],edgeCreateCallback:ae=>{let pe=ae.Org.idx,fe=le[pe],ge=le[(pe+1)%le.length];ae.idx=[fe,ge],ae.Sym.idx=[ge,fe]},vertexIdCallback:ae=>{let he=ae.Lprev.idx;return[he?he[1]:0,ae.idx?ae.idx[0]:0]}});if(!ce)throw console.log("Error"),new Error(`error generating bevel geometry for ${te}'th loop`);if(!ce.vertexCount){let ae=(te-1)/this._bevelSegments*Math.PI/2;J=(1-Math.sin(ae))*this._bevel;break}for(let ae=0;ae<ce.vertexIndices.length;ae++){let[he,pe]=ce.vertexIndices[ae];if(he===pe)continue;let fe=pe;pe<he&&(fe+=V);for(let ge=he;ge<fe;ge++){let me=ge%V,C=(ge+1)%V;if(!R.continuous[me]||!R.continuous[C]){ce.vertexIndices[ae]=[he,me],ce.vertexIndices.splice(ae+1,0,[C,pe]),ce.vertices.splice((ae+1)*2,0,ce.vertices[ae*2],ce.vertices[ae*2+1]);break}}}$.push({bevelI:te,angle:Y,size:ee,boundary:ce,reverseMap:le,insetPoints:K})}let Z=(te,Y,ee)=>{let K=0,q=te.boundary.vertexIndices.length;for(;K<q&&ee(te.boundary.vertexIndices[Y]);)Y=(Y+1)%q,K++;return K},X=S.length;for(let te=1;te<$.length;te++){let Y=$[te-1],ee=$[te],K=Y.boundary.vertexIndices.length,q=ee.boundary.vertexIndices.length;if(!K||!q)break;let ue=R.concave.length,le=0,ne=Vp(le,V);for(;!Y.boundary.vertexIndices.filter(ne).length||!ee.boundary.vertexIndices.filter(ne).length;)le++,ne=Vp(le,V);let ce=Y.boundary.vertexIndices.findIndex(ne),ae=ee.boundary.vertexIndices.findIndex(ne);do ce=(ce+1)%K;while(ne(Y.boundary.vertexIndices[ce]));do ae=(ae+1)%q;while(ne(ee.boundary.vertexIndices[ae]));le=(le+1)%V;let he=le,pe=0,fe=this._buildBevelVert(R,Y,(ce-1+K)%K,void 0,pe),ge=this._buildBevelVert(R,ee,(ae-1+q)%q,void 0,pe),me=fe,C=ge,ie,De,Re=!1;do{pe=(le||ue)/ue,ne=Vp(le,V);let Ee=Z(Y,ce,ne),Pe=Z(ee,ae,ne),xt=Re;if(Re=!1,Ee&&!Pe){for(let Me=0;Me<Ee;Me++)ie=this._buildBevelVert(R,Y,(ce+Me)%K,Me/(Ee-1),pe),S.push(me.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,me.bottomN,C.bottomN),me=ie;Re=!0}else if(!Ee&&Pe)for(let Me=0;Me<Pe;Me++)De=this._buildBevelVert(R,ee,(ae+Me)%q,Me/(Pe-1),pe),S.push(C.topN,me.topP,De.topP),l===!1&&S.push(me.bottomP,C.bottomN,De.bottomP),C=De;else if(Ee&&Pe)if(ie=this._buildBevelVert(R,Y,ce,0,pe),De=this._buildBevelVert(R,ee,ae,0,pe),xt?(S.push(me.topN,De.topP,C.topN),S.push(me.topN,ie.topP,De.topP),l===!1&&(S.push(De.bottomP,me.bottomN,C.bottomN),S.push(De.bottomP,ie.bottomP,me.bottomN))):(S.push(C.topN,me.topN,ie.topP),S.push(C.topN,ie.topP,De.topP),l===!1&&(S.push(ie.bottomP,me.bottomN,C.bottomN),S.push(ie.bottomP,C.bottomN,De.bottomP))),me=ie,C=De,Ee===Pe)for(let Me=1;Me<Ee;Me++)ie=this._buildBevelVert(R,Y,(ce+Me)%K,Me/(Ee-1),pe),De=this._buildBevelVert(R,ee,(ae+Me)%q,Me/(Pe-1),pe),S.push(me.topN,ie.topP,C.topN),S.push(C.topN,ie.topP,De.topP),l===!1&&(S.push(ie.bottomP,me.bottomN,C.bottomN),S.push(ie.bottomP,C.bottomN,De.bottomP)),me=ie,C=De;else if(Ee>Pe){let Me=Ee/Pe,mt=0;for(let bt=1;bt<Ee;bt++)ie=this._buildBevelVert(R,Y,(ce+bt)%K,bt/(Ee-1),pe),S.push(me.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,me.bottomN,C.bottomN),me=ie,bt>(mt+1)*Me&&(mt++,De=this._buildBevelVert(R,ee,(ae+mt)%q,mt/(Pe-1),pe),S.push(C.topN,ie.topP,De.topP),l===!1&&S.push(ie.bottomP,C.bottomN,De.bottomP),C=De)}else{let Me=Pe/Ee,mt=0;for(let bt=1;bt<Pe;bt++)De=this._buildBevelVert(R,ee,(ae+bt)%q,bt/(Pe-1),pe),S.push(C.topN,ie.topP,De.topP),l===!1&&S.push(ie.bottomP,C.bottomN,De.bottomP),C=De,bt>(mt+1)*Me&&(mt++,ie=this._buildBevelVert(R,Y,(ce+mt)%K,mt/(Ee-1),pe),S.push(me.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,me.bottomN,C.bottomN),me=ie)}ce=(ce+Ee)%K,ae=(ae+Pe)%q,le=(le+1)%ue}while(le!==he)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall($,R,S),N){let te=[];for(let Y=S.length-1;Y>=X+2;Y-=3){let ee=S[Y-2],K=S[Y-1],q=S[Y-0];te.push(q,K,ee)}S.splice(X,S.length-X,...te)}if(N){let te=[];for(let Y=$[$.length-1].boundary.vertices.length-1;Y>=1;Y-=2){let ee=$[$.length-1].boundary.vertices[Y-1],K=$[$.length-1].boundary.vertices[Y-0];te.push(ee,K)}T.push(te)}if(!N){let te=$[$.length-1],Y;try{Y=Rr({windingRule:$.length>1?Ge.POSITIVE:Ge.ODD,elementType:nt.POLYGONS,vertexSize:2,strict:!0,contours:[te.insetPoints,...T]})}catch{Y=Gp}if(!Y)throw new Error("Error generating geometry for surface");u.length===0&&this._bevel<h&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let ee=0;ee<Y.elementCount*3;ee+=3){let K=this._buildSurfaceVert(Y,Y.elements[ee+0],J),q=this._buildSurfaceVert(Y,Y.elements[ee+1],J),ue=this._buildSurfaceVert(Y,Y.elements[ee+2],J);S.push(K.top,q.top,ue.top),l===!1&&S.push(ue.bottom,q.bottom,K.bottom)}}this.vertexCache={}}this._buffer.shrink();let I=new eu(Uint32Array.from(S),1),x=new eu(this._buffer.positions,3),_=new eu(this._buffer.normals,3),D=new eu(this._buffer.uvs,2);x.needsUpdate=!0,_.needsUpdate=!0,D.needsUpdate=!0,I.needsUpdate=!0,this.setAttribute("position",x),this.setAttribute("normal",_),this.setAttribute("uv",D),this.setIndex(I)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(t,i,a),c=this._buildBevelVert(t,i,(a+1)%s);o.push(c.topP,l.topN,l.bottomN),o.push(c.topP,l.bottomN,c.bottomP)}}_buildSurfaceVert(e,t,o){let i=t.toString();if(i in this.vertexCache)return this.vertexCache[i];let a=e.vertices[t*2+0],s=e.vertices[t*2+1],l=(a-this._minX)/this._width,c=(s-this._minY)/this._height;this.forPathBevel&&(c=1);let u=this._buffer.get(this.forPathBevel?1:2),p=u*3,d=u*2,h={top:u+0,bottom:u+1};return this._buffer.positions[p+0]=a,this._buffer.positions[p+1]=s,this._buffer.positions[p+2]=this.forPathBevel?this._bevel:this._depth-o,this._buffer.normals[p+0]=0,this._buffer.normals[p+1]=0,this._buffer.normals[p+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=c,this.forPathBevel===!1&&(this._buffer.positions[p+3]=a,this._buffer.positions[p+4]=s,this._buffer.positions[p+5]=o,this._buffer.normals[p+3]=0,this._buffer.normals[p+4]=0,this._buffer.normals[p+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=c),this.vertexCache[i]=h,h}_buildBevelVert(e,t,o,i=1,a){let s=`${t.bevelI}:${o}`;if(s in this.vertexCache&&a!==0&&a!==1&&(!a||a===this.vertexCache[s].pathBevelUCoord))return this.vertexCache[s];let[l,c]=t.boundary.vertexIndices[o],u,p,d,h;l!==c?(p=l,u=c,h=!1,d=e.continuous[p]&&e.continuous[u]):(u=l,p=(u-1+e.count)%e.count,h=e.concave[u]&&t.bevelI>0,d=e.continuous[u]||h);let f=Math.cos(t.angle),m=Math.sin(t.angle),y=o*2,g=u*2,v=p*2,O=t.boundary.vertices[y+0],P=t.boundary.vertices[y+1],S=(1-m)*this._bevel,T=(O-this._minX)/this._width,I=(P-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(T=a),I=1);let x=e.normals[g+0],_=e.normals[g+1],D=e.normals[v+0],A=e.normals[v+1];if(h){let j=D-x,R=A-_;x=x+j*(1-i),_=_+R*(1-i);let W=Math.sqrt(x*x+_*_);x/=W,_/=W}let N=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),E=N*3,B=N*2,V={i:o,fi:u,topP:N+0,topN:N+0,bottomP:N+1,bottomN:N+1,pathBevelUCoord:a};return this._buffer.positions[E+0]=O,this._buffer.positions[E+1]=P,this._buffer.positions[E+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[E+0]=x*f,this._buffer.normals[E+1]=_*f,this._buffer.normals[E+2]=m,this._buffer.uvs[B+0]=T,this._buffer.uvs[B+1]=I,this.forPathBevel===!1&&(this._buffer.positions[E+3]=O,this._buffer.positions[E+4]=P,this._buffer.positions[E+5]=S,this._buffer.normals[E+3]=x*f,this._buffer.normals[E+4]=_*f,this._buffer.normals[E+5]=-m,this._buffer.uvs[B+2]=I,this._buffer.uvs[B+3]=T),d||(this.forPathBevel?(N+=1,E+=3,B+=2):(N+=2,E+=6,B+=4),V.topP=N+0,V.bottomP=N+1,this._buffer.positions[E+0]=O,this._buffer.positions[E+1]=P,this._buffer.positions[E+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[E+0]=D*f,this._buffer.normals[E+1]=A*f,this._buffer.normals[E+2]=m,this._buffer.uvs[B+0]=T,this._buffer.uvs[B+1]=I,this.forPathBevel===!1&&(this._buffer.positions[E+3]=O,this._buffer.positions[E+4]=P,this._buffer.positions[E+5]=S,this._buffer.normals[E+3]=D*f,this._buffer.normals[E+4]=A*f,this._buffer.normals[E+5]=-m,this._buffer.uvs[B+2]=I,this._buffer.uvs[B+3]=T)),this.vertexCache[s]=V,V}clone(){let e=new dn(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=So(this.userData),e}};var pa=class extends AM{constructor(e,t=12,o={}){super();this.type="ShapeGeometry";this.windingRule=Ge.ODD;this.elementType=nt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Ge.ODD,elementType:nt.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let i=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(f=>f.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,c=!0,u,p;for(let f=0,m=i.length/2;f<m;f++){let y=f*2,g=i[y+0],v=i[y+1];if(u!==void 0&&g!==u&&(l=!1),p!==void 0&&v!==p&&(c=!1),u=g,p=v,!l&&!c)break}if(!l&&!c)try{s=Rr({contours:[i,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=Gs}let d=s?.vertexCount??1,h=s?.elementCount??1;if(this._positionAttribute=new tu(new Float32Array(d*3),3),this._normalAttribute=new tu(new Float32Array(d*3),3),this._uvAttribute=new tu(new Float32Array(d*2),2),this._indexAttribute=new tu(new Uint32Array(h*3),1),s){let f=1/0,m=-1/0,y=1/0,g=-1/0;for(let P=0,S=d;P<S;P++){let T=P*2,I=s.vertices[T+0],x=s.vertices[T+1];I<f&&(f=I),I>m&&(m=I),x<y&&(y=x),x>g&&(g=x)}let v=m-f,O=g-y;for(let P=0,S=d;P<S;P++){let T=P*2,I=s.vertices[T+0],x=s.vertices[T+1],_=(I-f)/v,D=(x-y)/O;this._positionAttribute.setXYZ(P,I,x,0),this._normalAttribute.setXYZ(P,0,0,1),this._uvAttribute.setXY(P,_,D)}for(let P=0,S=h;P<S;P++){let T=P*3,I=s.elements[T+0],x=s.elements[T+1],_=s.elements[T+2];this._indexAttribute.setX(T+0,I),this._indexAttribute.setX(T+1,x),this._indexAttribute.setX(T+2,_)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(s?.elementCount??1)*3)}clone(){let e=new pa(this._shape,this._curveSegments);return e.userData=So(this.userData),e}};var fa=class extends dn{constructor(e,t,o=0,i=12,a=3,s=Ge.ODD){super(e,t,o,i,a,s);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(t,i,a),c=this._buildBevelVert(t,i,(a+1)%s);o.push(c.topP,l.topN,l.bottomN),o.push(c.topP,l.bottomN,c.bottomP)}}clone(){let e=new fa(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=So(this.userData),e}};var Jt=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Ge.ODD},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=n.shape??r?.shape,s=a?.roundness??e.roundness;a!==void 0&&(a instanceof Fe?(a.width!==t||a.height!==o)&&a.applySize(t,o):a=new Fe(t,o).fromJSON(a),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&a.update());let l=a??new Fe(t,o);return{parameters:Object.assign(e,{width:t,height:o,depth:i,roundness:s}),shape:l}}static build(n){let{depth:r,extrudeBevelSize:e,extrudeBevelSegments:t,subdivisions:o,roundness:i,windingRule:a}=n.parameters;n.shape.roundness=i;let s;return r<=0?s=new pa(n.shape,o,{windingRule:a}):s=new fa(n.shape,r,e,o,t,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};import{BufferGeometry as MM,Float32BufferAttribute as IM,MathUtils as jp,Vector2 as K0}from"three";var Q0=Math.PI*2,ma=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return e.angle=jp.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof Fe?n.shape:new Fe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,spikes:t,angle:o,innerRadius:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,c=n.shape,u=r*.5,p=e*.5,d=NM(c,u,p,o*Math.PI/180,t,i);c.isClosed=!0,c.update();let h;return o===0?(h=new MM,h.setAttribute("position",new IM([],3))):h=Jt.create({shape:c,parameters:{subdivisions:d,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(h,{userData:{...n,type:"EllipseGeometry"}})}};function NM(n,r,e,t,o,i){if(t>=Q0)return o>30||o%4===0?(EM(n,r,e,i),Math.round(o/4)):X0(n,t,o,r,e,i);t=Math.max(t,.001);let a={x:0,y:e},s=t+Math.PI*.5,l={x:Math.cos(s)*r,y:Math.sin(s)*e},c=j0({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:r,ry:e,largeArcFlag:t>Math.PI,sweepFlag:!0});return o>30||o%c.length===0?DM(n,a.x,a.y,c,o,r,e,i):X0(n,t,o,r,e,i)}function DM(n,r,e,t,o,i,a,s){let l=Math.round(o/t.length);n.addPoint(ha(r,e));for(let c=0,u=t.length;c<u;c++){let p=t[c],d=n.points[c],h=ha(p.x,p.y);d.controls[1].position.set(p.x1,p.y1),h.controls[0].position.set(p.x2,p.y2),n.addPoint(h)}return s>0?Z0(n,i,a,s):n.addPoint(ha(0,0)),l}function X0(n,r,e,t,o,i){let a=-r/e;for(let s=0;s<=e;s++){let l=a*s,c=Math.sin(l)*t,u=Math.cos(l)*o;n.addPoint(ha(c,u))}return r<Q0?i>0?Z0(n,t,o,i):n.addPoint(ha(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&J0(n,t,o,i)),1}function EM(n,r,e,t=0,o=0,i=0){let a=.5522847498,s=r*a,l=e*a;n.addPoint(ru(o-r,i,o-r,i-l,o-r,i+l)),n.addPoint(ru(o,i+e,o-s,i+e,o+s,i+e)),n.addPoint(ru(o+r,i,o+r,i+l,o+r,i-l)),n.addPoint(ru(o,i-e,o+s,i-e,o-s,i-e)),t>0&&J0(n,r,e,t)}function ha(n,r){return new Lr(jp.generateUUID(),new K0(n,r))}function ru(n,r,e,t,o,i){let a=ha(n,r);return a.controls[0].position.set(e,t),a.controls[1].position.set(o,i),a}function Z0(n,r,e,t){ex(n,r,e,t).forEach(i=>n.addPoint(i))}function J0(n,r,e,t){let o=ex(n,r,e,t),i=new Fe;o.forEach(a=>i.addPoint(a)),i.isClosed=!0,n.shapeHoles.push(i)}function ex(n,r,e,t){let o=t*r/100,i=o*(Math.abs(e)/Math.abs(r)),a=new K0(o/r,i/e),s=n.points.map(l=>{let c=l.clone();return c.uuid=jp.generateUUID(),c}).reverse();return s.forEach(l=>{l.position.multiply(a);let c=l.controls[0].position.clone().multiply(a),u=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(u),l.controls[1].position.copy(c)}),s}import{BufferGeometry as _M,Float32BufferAttribute as Fp,Uint32BufferAttribute as BM,Vector3 as tx}from"three";var rx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??t),i=Math.abs(e.depth??t),a=Math.abs(Math.min(t,i))/2;return{parameters:Object.assign(e,{width:t,height:o,depth:i,radius:a,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:r,height:e,depth:t,radius:o,revolutions:i,segments:a,pathRadius:s,pathType:l,pathSegments:c,cornerRadius:u,cornerSegments:p}=n.parameters,d=new js(!1,r,e,t,o,i,a,s,l,c,u,p);return Object.assign(d,{userData:{...n,type:"HelixGeometry"}})}},Up=new BM([0,0,0],1),js=class extends _M{constructor(r=!0,e=1,t=1,o=1,i=1,a=1,s=1,l=1,c=1,u=1,p=1,d=1){if(super(),a===0)return;let h=r&&a===1;h&&(d=0),p>100&&(p=100),p===0&&(d=0);let f=()=>new tx,m=new tx,y=f(),g=f(),v=f(),O,P,S,T,I,x,_,D,A=f(),N=f(),E=f(),B=f(),V=f(),j=f(),R=f(),W=f(),F=t-2*l+.001,k=F/a,H=Math.ceil(s*a),$=H+1,J=F/H,Z=-F/2,X=u+1,te=2*Math.PI/u,Y=Math.PI/2/d,ee=.01,K=Math.min((1-p/100)*l,l-ee),q=l-K,ue=0,le=2,ne=d*le+le,ce=X*ne/le,ae=ce+X*$,he=Math.max(0,X*($+ne)),[pe,fe,ge]=[3,3,2].map(tt=>Array(he*tt).fill(0)),me=[],C=i-l;function ie(tt,Ye){let Ar=Math.PI/2;x=Ye*J,D=2*Math.PI*(x%k)/k+Ar,x+=Z,_=Math.sin(D)*C,I=Math.cos(D)*C,r?tt.set(I,_,x):tt.set(I,x,_)}ie(m,-1e-10),ie(y,0),A.copy(m),ie(m,1);let De=m.distanceTo(y),Re=h?0:q+K,Ee=De*H+2*Re,Pe=K,xt=Ee-Re;for(let tt=0;tt<=H;tt++){ie(g,tt),W.subVectors(g,A).normalize(),A.copy(g),j.copy(g).setComponent(+r+1,0).normalize(),R.crossVectors(W,j).normalize();let Ye=tt===0,Ar=tt===H,cd=Ye?3*Math.PI/2:Y,ud=Ye?Pe:xt,bl=Ye?X:ae,An=Ye?0:he-X,st=W.clone().multiplyScalar(Ye?-q:q).add(g),dd=W.clone().multiplyScalar(Ye?-1:1).normalize();for(let hr=0;hr<X;hr++){let ps=hr*te;if(N.addVectors(m.copy(j).multiplyScalar(l*Math.cos(ps)),y.copy(R).multiplyScalar(l*Math.sin(ps))),E.copy(N).normalize(),Ye||Ar){h||(ue=An+hr,[0,1,2].forEach(jt=>{pe[ue*3+jt]=st.getComponent(jt),fe[ue*3+jt]=dd.getComponent(jt)}),ge[ue*2]=+Ar,ge[ue*2+1]=hr/u),y.copy(E).multiplyScalar(K),v.addVectors(g,y);for(let jt=0;jt<d;jt++){let Mn=jt*Y+cd;B.addVectors(m.copy(W).multiplyScalar(q*Math.sin(Mn)),y.copy(E).multiplyScalar(q*Math.cos(Mn))),V.copy(B).normalize(),y.addVectors(v,B),B.normalize(),ue=bl+jt*X+hr,[0,1,2].forEach(ci=>{pe[ue*3+ci]=y.getComponent(ci),fe[ue*3+ci]=V.getComponent(ci)});let vl=+Ye+Math.sin(Mn);ge[ue*2]=(ud+q*vl)/Ee,ge[ue*2+1]=hr/u}}y.addVectors(g,N),ue=ce+tt*X+hr,[0,1,2].forEach(jt=>{pe[ue*3+jt]=y.getComponent(jt),fe[ue*3+jt]=E.getComponent(jt)}),ge[ue*2]=(Re+tt*De)/Ee,ge[ue*2+1]=hr/u}}let Me=$+2*d+le,mt=1,[bt,Tn]=[+h,Me-1];for(let tt=bt;tt<=Tn-1;tt++){let Ye=h&&tt===Tn-1;for(let Ar=0;Ar<X-1;Ar++)O=tt*X+Ar,P=O+1,S=(Ye?Ar:O)+X,T=(Ye?Ar+1:P)+X,tt===0?me.push(P,T,S):tt===Me-2?me.push(O,P,S):me.push(O,P,S,P,T,S)}this.setIndex(me),this.setAttribute("position",new Fp(pe,3)),this.setAttribute("normal",new Fp(fe,3)),this.setAttribute("uv",new Fp(ge,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let r=this.userData.parameters,e=Math.ceil(r.tubularSegments),t=r.radialSegments+1,o=Array.from(this.getIndex().array),i,a,s,l,c=6*(e-1)*r.radialSegments,u=e,p=u===e;for(let d=0;d<r.radialSegments;d++)i=u*t+d,a=i+1,s=(p?d:i)+t,l=(p?d+1:a)+t,o[c++]=i,o[c++]=a,o[c++]=s,o[c++]=a,o[c++]=l,o[c++]=s;return o.length=c,Up.array=o,Up.count=o.length,Up}};import{IcosahedronGeometry as LM}from"three";var ox=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new Fs(r*.5,i,a):new LM(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},Fs=class extends ln{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,i=[-1,o,0,1,o,0,-1,-o,0,1,-o,0,0,-1,o,0,1,o,0,-1,-o,0,1,-o,o,0,-1,o,0,1,-o,0,-1,-o,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],s="IcosahedronGeometry";super(i,a,s,r,e,t),this.type=s}static fromJSON(r){return new Fs(r.radius,r.corner,r.cornerSides)}};import{LatheGeometry as RM,Shape as VM}from"three";var nx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){(n.parameters?.points??[]).forEach(t=>{Array.isArray(t)&&(t.x=t[0],t.y=t[1])});let e=Object.assign({},r?.parameters??{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(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{points:r,segments:e,verticalSegments:t}=n.parameters,o=new VM;o.moveTo(r[0].x,r[0].y),o.bezierCurveTo(r[1].x,r[1].y,r[2].x,r[2].y,r[3].x,r[3].y);let i=new RM(o.extractPoints(t).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};import{BufferGeometry as px,BufferGeometryLoader as XM,Vector3 as KM,BoxGeometry as fx}from"three";import{BufferGeometry as WM,Vector2 as qp,Vector3 as dx}from"three";import{Box3 as zM,BufferAttribute as Us,BufferGeometry as ix,Color as Wp,EventDispatcher as GM,Float32BufferAttribute as ya,Matrix3 as ax,Matrix4 as ux,MathUtils as jM,Object3D as FM,Sphere as UM,Vector2 as ur,Vector3 as Rt,Vector4 as kM}from"three";var ro=new ux,kp=new FM,ou=new Rt,pn=class extends GM{constructor(){super(),this.uuid=jM.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(r){let e=new ax().getNormalMatrix(r);for(let t=0,o=this.vertices.length;t<o;t++)this.vertices[t].applyMatrix4(r);for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t];i.normal.applyMatrix3(e).normalize();for(let a=0,s=i.vertexNormals.length;a<s;a++)i.vertexNormals[a].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(r){return ro.makeRotationX(r),this.applyMatrix4(ro),this}rotateY(r){return ro.makeRotationY(r),this.applyMatrix4(ro),this}rotateZ(r){return ro.makeRotationZ(r),this.applyMatrix4(ro),this}translate(r,e,t){return ro.makeTranslation(r,e,t),this.applyMatrix4(ro),this}scale(r,e,t){return ro.makeScale(r,e,t),this.applyMatrix4(ro),this}lookAt(r){return kp.lookAt(r),kp.updateMatrix(),this.applyMatrix4(kp.matrix),this}fromBufferGeometry(r){let e=this,t=r.index!==null?r.index:void 0,o=r.attributes;if(o.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let i=o.position,a=o.normal,s=o.color,l=o.uv,c=o.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<i.count;d++)e.vertices.push(new Rt().fromBufferAttribute(i,d)),s!==void 0&&e.colors.push(new Wp().fromBufferAttribute(s,d));function u(d,h,f,m){let y=s===void 0?[]:[e.colors[d].clone(),e.colors[h].clone(),e.colors[f].clone()],g=a===void 0?[]:[new Rt().fromBufferAttribute(a,d),new Rt().fromBufferAttribute(a,h),new Rt().fromBufferAttribute(a,f)],v=new ga(d,h,f,g,y,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new ur().fromBufferAttribute(l,d),new ur().fromBufferAttribute(l,h),new ur().fromBufferAttribute(l,f)]),c!==void 0&&e.faceVertexUvs[1].push([new ur().fromBufferAttribute(c,d),new ur().fromBufferAttribute(c,h),new ur().fromBufferAttribute(c,f)])}let p=r.groups;if(p.length>0)for(let d=0;d<p.length;d++){let h=p[d],f=h.start,m=h.count;for(let y=f,g=f+m;y<g;y+=3)t!==void 0?u(t.getX(y),t.getX(y+1),t.getX(y+2),h.materialIndex):u(y,y+1,y+2,h.materialIndex)}else if(t!==void 0)for(let d=0;d<t.count;d+=3)u(t.getX(d),t.getX(d+1),t.getX(d+2));else for(let d=0;d<i.count;d+=3)u(d,d+1,d+2);return this.computeFaceNormals(),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ou).negate(),this.translate(ou.x,ou.y,ou.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new ux;return o.set(t,0,0,-t*r.x,0,t,0,-t*r.y,0,0,t,-t*r.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let r=new Rt,e=new Rt;for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],a=this.vertices[i.a],s=this.vertices[i.b],l=this.vertices[i.c];r.subVectors(l,s),e.subVectors(a,s),r.cross(e),r.normalize(),i.normal.copy(r)}}computeVertexNormals(r=!0){let e=new Array(this.vertices.length);for(let t=0,o=this.vertices.length;t<o;t++)e[t]=new Rt;if(r){let t=new Rt,o=new Rt;for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=this.vertices[s.a],c=this.vertices[s.b],u=this.vertices[s.c];t.subVectors(u,c),o.subVectors(l,c),t.cross(o),e[s.a].add(t),e[s.b].add(t),e[s.c].add(t)}}else{this.computeFaceNormals();for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t];e[i.a].add(i.normal),e[i.b].add(i.normal),e[i.c].add(i.normal)}}for(let t=0,o=this.vertices.length;t<o;t++)e[t].normalize();for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],a=i.vertexNormals;a.length===3?(a[0].copy(e[i.a]),a[1].copy(e[i.b]),a[2].copy(e[i.c])):(a[0]=e[i.a].clone(),a[1]=e[i.b].clone(),a[2]=e[i.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let r=0,e=this.faces.length;r<e;r++){let t=this.faces[r],o=t.vertexNormals;o.length===3?(o[0].copy(t.normal),o[1].copy(t.normal),o[2].copy(t.normal)):(o[0]=t.normal.clone(),o[1]=t.normal.clone(),o[2]=t.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,t=this.faces.length;e<t;e++){let o=this.faces[e];o.__originalFaceNormal?o.__originalFaceNormal.copy(o.normal):o.__originalFaceNormal=o.normal.clone(),o.__originalVertexNormals||(o.__originalVertexNormals=[]);for(let i=0,a=o.vertexNormals.length;i<a;i++)o.__originalVertexNormals[i]?o.__originalVertexNormals[i].copy(o.vertexNormals[i]):o.__originalVertexNormals[i]=o.vertexNormals[i].clone()}let r=new pn;r.faces=this.faces;for(let e=0,t=this.morphTargets.length;e<t;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let i=this.morphNormals[e].faceNormals,a=this.morphNormals[e].vertexNormals;for(let s=0,l=this.faces.length;s<l;s++){let c=new Rt,u={a:new Rt,b:new Rt,c:new Rt};i.push(c),a.push(u)}}let o=this.morphNormals[e];r.vertices=this.morphTargets[e].vertices,r.computeFaceNormals(),r.computeVertexNormals();for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=o.faceNormals[i],c=o.vertexNormals[i];l.copy(s.normal),c.a.copy(s.vertexNormals[0]),c.b.copy(s.vertexNormals[1]),c.c.copy(s.vertexNormals[2])}}for(let e=0,t=this.faces.length;e<t;e++){let o=this.faces[e];o.normal=o.__originalFaceNormal,o.vertexNormals=o.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new zM),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new UM),this.boundingSphere.setFromPoints(this.vertices)}merge(r,e,t=0){if(!(r&&r.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",r);return}let o,i=this.vertices.length,a=this.vertices,s=r.vertices,l=this.faces,c=r.faces,u=this.colors,p=r.colors;e!==void 0&&(o=new ax().getNormalMatrix(e));for(let d=0,h=s.length;d<h;d++){let m=s[d].clone();e!==void 0&&m.applyMatrix4(e),a.push(m)}for(let d=0,h=p.length;d<h;d++)u.push(p[d].clone());for(let d=0,h=c.length;d<h;d++){let f=c[d],m,y,g=f.vertexNormals,v=f.vertexColors,O=new ga(f.a+i,f.b+i,f.c+i);O.normal.copy(f.normal),o!==void 0&&O.normal.applyMatrix3(o).normalize();for(let P=0,S=g.length;P<S;P++)m=g[P].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),O.vertexNormals.push(m);O.color.copy(f.color);for(let P=0,S=v.length;P<S;P++)y=v[P],O.vertexColors.push(y.clone());O.materialIndex=f.materialIndex+t,l.push(O)}for(let d=0,h=r.faceVertexUvs.length;d<h;d++){let f=r.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,y=f.length;m<y;m++){let g=f[m],v=[];for(let O=0,P=g.length;O<P;O++)v.push(g[O].clone());this.faceVertexUvs[d].push(v)}}}mergeMesh(r){if(!(r&&r.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",r);return}r.matrixAutoUpdate&&r.updateMatrix(),this.merge(r.geometry,r.matrix)}mergeVertices(r=4){let e={},t=[],o=[],i=Math.pow(10,r);for(let l=0,c=this.vertices.length;l<c;l++){let u=this.vertices[l],p=Math.round(u.x*i)+"_"+Math.round(u.y*i)+"_"+Math.round(u.z*i);e[p]===void 0?(e[p]=l,t.push(this.vertices[l]),o[l]=t.length-1):o[l]=o[e[p]]}let a=[];for(let l=0,c=this.faces.length;l<c;l++){let u=this.faces[l];u.a=o[u.a],u.b=o[u.b],u.c=o[u.c];let p=[u.a,u.b,u.c];for(let d=0;d<3;d++)if(p[d]===p[(d+1)%3]){a.push(l);break}}for(let l=a.length-1;l>=0;l--){let c=a[l];this.faces.splice(c,1);for(let u=0,p=this.faceVertexUvs.length;u<p;u++)this.faceVertexUvs[u].splice(c,1)}let s=this.vertices.length-t.length;return this.vertices=t,s}setFromPoints(r){this.vertices=[];for(let e=0,t=r.length;e<t;e++){let o=r[e];this.vertices.push(new Rt(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let r=this.faces,e=r.length;for(let l=0;l<e;l++)r[l]._id=l;function t(l,c){return l.materialIndex-c.materialIndex}r.sort(t);let o=this.faceVertexUvs[0],i=this.faceVertexUvs[1],a,s;o&&o.length===e&&(a=[]),i&&i.length===e&&(s=[]);for(let l=0;l<e;l++){let c=r[l]._id;a&&a.push(o[c]),s&&s.push(i[c])}a&&(this.faceVertexUvs[0]=a),s&&(this.faceVertexUvs[1]=s)}toJSON(){let r={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.parameters!==void 0){let f=this.parameters;for(let m in f)f[m]!==void 0&&(r[m]=f[m]);return r}let e=[];for(let f=0;f<this.vertices.length;f++){let m=this.vertices[f];e.push(m.x,m.y,m.z)}let t=[],o=[],i={},a=[],s={},l=[],c={};for(let f=0;f<this.faces.length;f++){let m=this.faces[f],y=!0,g=!1,v=this.faceVertexUvs[0][f]!==void 0,O=m.normal.length()>0,P=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,T=m.vertexColors.length>0,I=0;if(I=u(I,0,0),I=u(I,1,y),I=u(I,2,g),I=u(I,3,v),I=u(I,4,O),I=u(I,5,P),I=u(I,6,S),I=u(I,7,T),t.push(I),t.push(m.a,m.b,m.c),t.push(m.materialIndex),v){let x=this.faceVertexUvs[0][f];t.push(h(x[0]),h(x[1]),h(x[2]))}if(O&&t.push(p(m.normal)),P){let x=m.vertexNormals;t.push(p(x[0]),p(x[1]),p(x[2]))}if(S&&t.push(d(m.color)),T){let x=m.vertexColors;t.push(d(x[0]),d(x[1]),d(x[2]))}}function u(f,m,y){return y?f|1<<m:f&~(1<<m)}function p(f){let m=f.x.toString()+f.y.toString()+f.z.toString();return i[m]!==void 0||(i[m]=o.length/3,o.push(f.x,f.y,f.z)),i[m]}function d(f){let m=f.r.toString()+f.g.toString()+f.b.toString();return s[m]!==void 0||(s[m]=a.length,a.push(f.getHex())),s[m]}function h(f){let m=f.x.toString()+f.y.toString();return c[m]!==void 0||(c[m]=l.length/2,l.push(f.x,f.y)),c[m]}return r.data={},r.data.vertices=e,r.data.normals=o,a.length>0&&(r.data.colors=a),l.length>0&&(r.data.uvs=[l]),r.data.faces=t,r}clone(){return new pn().copy(this)}copy(r){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=r.name;let e=r.vertices;for(let d=0,h=e.length;d<h;d++)this.vertices.push(e[d].clone());let t=r.colors;for(let d=0,h=t.length;d<h;d++)this.colors.push(t[d].clone());let o=r.faces;for(let d=0,h=o.length;d<h;d++)this.faces.push(o[d].clone());for(let d=0,h=r.faceVertexUvs.length;d<h;d++){let f=r.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,y=f.length;m<y;m++){let g=f[m],v=[];for(let O=0,P=g.length;O<P;O++){let S=g[O];v.push(S.clone())}this.faceVertexUvs[d].push(v)}}let i=r.morphTargets;for(let d=0,h=i.length;d<h;d++){let f={};if(f.name=i[d].name,i[d].vertices!==void 0){f.vertices=[];for(let m=0,y=i[d].vertices.length;m<y;m++)f.vertices.push(i[d].vertices[m].clone())}if(i[d].normals!==void 0){f.normals=[];for(let m=0,y=i[d].normals.length;m<y;m++)f.normals.push(i[d].normals[m].clone())}this.morphTargets.push(f)}let a=r.morphNormals;for(let d=0,h=a.length;d<h;d++){let f={};if(a[d].vertexNormals!==void 0){f.vertexNormals=[];for(let m=0,y=a[d].vertexNormals.length;m<y;m++){let g=a[d].vertexNormals[m],v={};v.a=g.a.clone(),v.b=g.b.clone(),v.c=g.c.clone(),f.vertexNormals.push(v)}}if(a[d].faceNormals!==void 0){f.faceNormals=[];for(let m=0,y=a[d].faceNormals.length;m<y;m++)f.faceNormals.push(a[d].faceNormals[m].clone())}this.morphNormals.push(f)}let s=r.skinWeights;for(let d=0,h=s.length;d<h;d++)this.skinWeights.push(s[d].clone());let l=r.skinIndices;for(let d=0,h=l.length;d<h;d++)this.skinIndices.push(l[d].clone());let c=r.lineDistances;for(let d=0,h=c.length;d<h;d++)this.lineDistances.push(c[d]);let u=r.boundingBox;u!==null&&(this.boundingBox=u.clone());let p=r.boundingSphere;return p!==null&&(this.boundingSphere=p.clone()),this.elementsNeedUpdate=r.elementsNeedUpdate,this.verticesNeedUpdate=r.verticesNeedUpdate,this.uvsNeedUpdate=r.uvsNeedUpdate,this.normalsNeedUpdate=r.normalsNeedUpdate,this.colorsNeedUpdate=r.colorsNeedUpdate,this.lineDistancesNeedUpdate=r.lineDistancesNeedUpdate,this.groupsNeedUpdate=r.groupsNeedUpdate,this}toBufferGeometry(){let r=new Hp().fromGeometry(this),e=new ix,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",nu.call(new Us(t,3),r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",nu.call(new Us(o,3),r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",sx.call(new Us(o,3),r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",lx.call(new Us(o,2),r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",lx.call(new Us(o,2),r.uvs2))}e.groups=r.groups;for(let o in r.morphTargets){let i=[],a=r.morphTargets[o];for(let s=0,l=a.length;s<l;s++){let c=a[s],u=new ya(c.data.length*3,3);u.name=c.name,i.push(nu.call(u,c.data))}e.morphAttributes[o]=i}if(r.skinIndices.length>0){let o=new ya(r.skinIndices.length*4,4);e.setAttribute("skinIndex",cx.call(o,r.skinIndices))}if(r.skinWeights.length>0){let o=new ya(r.skinWeights.length*4,4);e.setAttribute("skinWeight",cx.call(o,r.skinWeights))}return r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(r){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(r)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(r){let e=new ix,t=r.geometry;if(r.isPoints||r.isLine){let o=new ya(t.vertices.length*3,3),i=new ya(t.colors.length*3,3);if(e.setAttribute("position",nu.call(o,t.vertices)),e.setAttribute("color",sx.call(i,t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let a=new ya(t.lineDistances.length,1);e.setAttribute("lineDistance",HM.call(a,t.lineDistances))}t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone())}else r.isMesh&&(e=t.toBufferGeometry());return e}};pn.prototype.isGeometry=!0;var Hp=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(r){let e=[],t,o,i,a=r.faces;for(o=0;o<a.length;o++){let s=a[o];s.materialIndex!==i&&(i=s.materialIndex,t!==void 0&&(t.count=o*3-t.start,e.push(t)),t={start:o*3,materialIndex:i})}t!==void 0&&(t.count=o*3-t.start,e.push(t)),this.groups=e}fromGeometry(r){let e=r.faces,t=r.vertices,o=r.faceVertexUvs,i=o[0]&&o[0].length>0,a=o[1]&&o[1].length>0,s=r.morphTargets,l=s.length,c;if(l>0){c=[];for(let g=0;g<l;g++)c[g]={name:s[g].name,data:[]};this.morphTargets.position=c}let u=r.morphNormals,p=u.length,d;if(p>0){d=[];for(let g=0;g<p;g++)d[g]={name:u[g].name,data:[]};this.morphTargets.normal=d}let h=r.skinIndices,f=r.skinWeights,m=h.length===t.length,y=f.length===t.length;t.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<e.length;g++){let v=e[g];this.vertices.push(t[v.a],t[v.b],t[v.c]);let O=v.vertexNormals;if(O.length===3)this.normals.push(O[0],O[1],O[2]);else{let S=v.normal;this.normals.push(S,S,S)}let P=v.vertexColors;if(P.length===3)this.colors.push(P[0],P[1],P[2]);else{let S=v.color;this.colors.push(S,S,S)}if(i===!0){let S=o[0][g];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new ur,new ur,new ur))}if(a===!0){let S=o[1][g];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new ur,new ur,new ur))}for(let S=0;S<l;S++){let T=s[S].vertices;c[S].data.push(T[v.a],T[v.b],T[v.c])}for(let S=0;S<p;S++){let T=u[S].vertexNormals[g];d[S].data.push(T.a,T.b,T.c)}m&&this.skinIndices.push(h[v.a],h[v.b],h[v.c]),y&&this.skinWeights.push(f[v.a],f[v.b],f[v.c])}return this.computeGroups(r),this.verticesNeedUpdate=r.verticesNeedUpdate,this.normalsNeedUpdate=r.normalsNeedUpdate,this.colorsNeedUpdate=r.colorsNeedUpdate,this.uvsNeedUpdate=r.uvsNeedUpdate,this.groupsNeedUpdate=r.groupsNeedUpdate,r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),this}},ga=class{constructor(r,e,t,o,i,a=0){this.a=r,this.b=e,this.c=t,this.normal=o&&o.isVector3?o:new Rt,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new Wp,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=a}clone(){return new this.constructor().copy(this)}copy(r){this.a=r.a,this.b=r.b,this.c=r.c,this.normal.copy(r.normal),this.color.copy(r.color),this.materialIndex=r.materialIndex;for(let e=0,t=r.vertexNormals.length;e<t;e++)this.vertexNormals[e]=r.vertexNormals[e].clone();for(let e=0,t=r.vertexColors.length;e<t;e++)this.vertexColors[e]=r.vertexColors[e].clone();return this}};function HM(n){return this.array.set(n),this}function sx(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",t),i=new Wp),r[e++]=i.r,r[e++]=i.g,r[e++]=i.b}return this}function lx(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",t),i=new ur),r[e++]=i.x,r[e++]=i.y}return this}function nu(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",t),i=new Rt),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z}return this}function cx(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",t),i=new kM),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z,r[e++]=i.w}return this}var qM=["a","b","c"];function $M(n,r){switch(r){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function $p(n,r,e){let t=Math.min(n,r),o=Math.max(n,r),i=t+"_"+o;return e.get(i)}function Yp(n,r,e,t,o,i){let a=Math.min(n,r),s=Math.max(n,r),l=a+"_"+s,c;if(t.has(l))c=t.get(l);else{let u=e[a],p=e[s];c={a:u,b:p,newEdge:null,faces:[]},t.set(l,c)}c.faces.push(o),i[n].edges.push(c),i[r].edges.push(c)}function YM(n,r,e,t){let o,i,a;for(o=0,i=n.length;o<i;o++)e[o]={edges:[]};for(o=0,i=r.length;o<i;o++)a=r[o],Yp(a.a,a.b,n,t,a,e),Yp(a.b,a.c,n,t,a,e),Yp(a.c,a.a,n,t,a,e)}function iu(n,r,e,t,o){n.push(new ga(r,e,t,void 0,void 0,o))}function xa(n,r){return Math.abs(r-n)/2+Math.min(n,r)}function au(n,r,e,t){n.push([r.clone(),e.clone(),t.clone()])}var su=class{constructor(r=1){this.subdivisions=r}modify(r){r instanceof WM?r=new pn().fromBufferGeometry(r):r=r.clone(),r.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(r);return r.computeFaceNormals(),r.computeVertexNormals(),r}_smooth(r){let e=new dx,t,o,i,a,s,l=r.vertices,c=r.faces,u=r.faceVertexUvs[0],p=u!==void 0&&u.length>0,d=[],h=new Map;YM(l,c,d,h);let f=[],m,y,g,v,O,P,S;for(let ee of Array.from(h.keys())){for(y=h.get(ee),g=new dx,O=3/8,P=1/8,S=y.faces.length,S!=2&&(O=.5,P=0,S!=1),g.addVectors(y.a,y.b).multiplyScalar(O),e.set(0,0,0),a=0;a<S;a++){for(v=y.faces[a],s=0;s<3&&(m=l[$M(v,qM[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(P),g.add(e),y.newEdge=f.length,f.push(g)}let T,I,x,_,D,A,N,E=[];for(o=0,i=l.length;o<i;o++){for(A=l[o],D=d[o].edges,t=D.length,t==3?T=3/16:t>3&&(T=3/(8*t)),I=1-t*Number(T),x=T,t<=2&&(t==2?(I=3/4,x=1/8):t==1||t==0),N=A.clone().multiplyScalar(I),e.set(0,0,0),a=0;a<t;a++)_=D[a],m=_.a!==A?_.a:_.b,e.add(m);e.multiplyScalar(Number(x)),N.add(e),E.push(N)}let B=E.concat(f),V=E.length,j,R,W,F=[],k=[],H,$,J,Z,X=new qp,te=new qp,Y=new qp;for(o=0,i=c.length;o<i;o++)v=c[o],j=Number($p(v.a,v.b,h).newEdge)+V,R=Number($p(v.b,v.c,h).newEdge)+V,W=Number($p(v.c,v.a,h).newEdge)+V,iu(F,j,R,W,v.materialIndex),iu(F,v.a,j,W,v.materialIndex),iu(F,v.b,R,j,v.materialIndex),iu(F,v.c,W,R,v.materialIndex),p&&(H=u[o],$=H[0],J=H[1],Z=H[2],X.set(xa($.x,J.x),xa($.y,J.y)),te.set(xa(J.x,Z.x),xa(J.y,Z.y)),Y.set(xa($.x,Z.x),xa($.y,Z.y)),au(k,X,te,Y),au(k,$,X,Y),au(k,J,te,X),au(k,Z,Y,te));r.vertices=B,r.faces=F,p&&(r.faceVertexUvs[0]=k)}};var wt=new KM,hx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=n.geometry??r?.geometry??new px().copy(new fx(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(wt),t={width:wt.x,height:wt.y,depth:wt.z,subdivisions:0}):t=r.parameters;let o={...t,...n.parameters};return{parameters:{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth),subdivisions:Math.abs(o.subdivisions)},geometry:e}}static build(n){let{width:r,height:e,depth:t,subdivisions:o}=n.parameters,i=n.geometry??new px().copy(new fx(100,100,100)),a=i.userData.parameters;a===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(wt)):wt.set(a.width,a.height,a.depth),(r!==wt.x||e!==wt.y||t!==wt.z)&&i.scale(wt.x===0?1:r/wt.x,wt.y===0?1:e/wt.y,wt.z===0?1:t/wt.z);let s=i.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=i),i=new su(o).modify(s).toBufferGeometry()):(s!==void 0&&(i=s),s=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals())}catch{s!==void 0&&(i=s),s=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals()}return s!==void 0&&Object.assign(i,{originalGeometry:s}),delete n.geometry,Object.assign(i,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,r,e){new XM(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(wt);let a=100/wt.x;Object.assign(i.parameters,{width:100,height:wt.y*a,depth:wt.z*a}),r(this.build(i))})}};var lu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof Fe?n.shape:new Fe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,spikes:t,cornerRadius:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}=n.parameters,l=n.shape,c=r*.5,u=e*.5,p=0,d=0,h=2*Math.PI/t;for(let m=0;m<t;m++){let y=h*m,g=p+Math.sin(y)*c,v=d+Math.cos(y)*u;l.addPoint(l.createPoint(g,v))}l.isClosed=!0;for(let m=0,y=l.points.length;m<y;m++)l.points[m].roundness=o;l.roundness=o,l.update();let f=Jt.create({shape:l,parameters:{roundness:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(f,{userData:{...n,type:"PolygonGeometry"}})}};import{BufferGeometry as QM,Float32BufferAttribute as Xp,Vector2 as oo,Vector3 as Mt}from"three";var mx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{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(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,radialSegments:o,heightSegments:i,openEnded:a,cornerRadius:s,cornerSegments:l}=n.parameters,c=new Qp(r*.5,e,o,i,a,s,l);return c.scale(1,1,t/r),Object.assign(c,{userData:{...n,type:"PyramidGeometry"}})}};function ks(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function Kp(n,r,e,t,o,i){let a=r.clone().sub(n),s=e.clone().sub(n),l=a.angleTo(s);if(a.normalize(),s.normalize(),t===o){let c=a.add(s).normalize();i.copy(n).addScaledVector(c,t/Math.sin(l/2))}else{let c=a.angleTo(s);i.copy(n),i.addScaledVector(a,o/Math.sin(c)),i.addScaledVector(s,t/Math.sin(c))}}function ZM(n,r,e){let t=n.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var Qp=class extends QM{constructor(r=.5,e=1,t=4,o=1,i=!1,a=0,s=4){super(),t=Math.floor(Math.max(3,t)),o=Math.floor(o),s=Math.floor(s);let l=[],c=[],u=[],p=[],d=0,h=e/2,f=Math.PI/t,m=r*Math.cos(Math.PI/t),y=2*Math.PI/t,g=(t-2)*Math.PI/t,v=Math.PI-g,O=new Mt(0,-h,0),P=new Mt(0,h,0),S=new oo(r,-h),T=new oo(m,-h),I=new oo(0,P.y).sub(T),x=new oo(0,P.y).sub(S),_=new oo(I.y,-I.x).normalize(),D=new oo(x.y,-x.x).normalize(),N=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-I.angle())/2)-1e-8;a=Math.min(a,N);let E;{let k=new Mt(_.x,_.y,0),H=new Mt(Math.cos(y)*k.x,k.y,Math.sin(y)*k.x);E=k.angleTo(H)}let B=a/Math.tan((Math.PI-I.angle())/2),V=a/Math.tan((Math.PI-E)/2),j=new Mt;if(!i){c.push(O.x,O.y,O.z),u.push(0,-1,0),p.push(0,0);let k=d++,H=[],$=S.clone(),J=B/Math.cos(Math.PI/t);$.x-=J;for(let Z=0;Z<t;Z++){let X=Z/t*Math.PI*2+f,te=new oo(Math.sin(X),Math.cos(X));ks($,te,j),c.push(j.x,j.y,j.z),u.push(0,-1,0),p.push(0,0),H.push(d++)}for(let Z=0;Z<H.length;Z++)l.push(H[Z],k,H[(Z+1)%H.length])}let R=[];{let k=new Mt,H=new Mt,$=new Mt,J=new Mt,Z=new Mt,X=new Mt;for(let te=0;te<t;te++){let Y=te/t*Math.PI*2+f,ee=(te+.5)/t*Math.PI*2+f,K=(te+1)/t*Math.PI*2+f,q=new oo(Math.sin(Y),Math.cos(Y)),ue=new oo(Math.sin(ee),Math.cos(ee)),le=new oo(Math.sin(K),Math.cos(K));ks(S,q,H),ks(S,le,$),ks(_,ue,k),Kp(P,H,$,V,V,J),c.push(J.x,J.y,J.z),Kp(H,P,$,V,B,Z),c.push(Z.x,Z.y,Z.z),Kp($,H,P,B,V,X),c.push(X.x,X.y,X.z),u.push(k.x,k.y,k.z),u.push(k.x,k.y,k.z),u.push(k.x,k.y,k.z),p.push(0,0),p.push(0,0),p.push(0,0);let ne=d++,ce=d++,ae=d++;if(l.push(ne,ce,ae),a>0){{let fe=H.clone().add($).multiplyScalar(.5),ge=P.clone().sub(fe).normalize(),C=O.clone().sub(fe).normalize().add(ge).normalize().multiplyScalar(-1),ie=X.clone().sub(Z);W(fe,ie,C,I.angle())}let he,pe;{let fe=new Mt;ks(D,le,fe);let ge=X.clone().add(J).multiplyScalar(.5);ge=ZM(ge,$,P);let me=X.clone().sub(J);[he,pe]=W(ge,me,fe,E,J.y)}{let fe=he,ge=fe.clone().setY(0).normalize(),me=new Mt(0,-1,0),C=ge.clone().cross(me);F(fe,ge,me,C)}R.concat(pe);{let fe=I.angle(),ge=Math.PI-fe,me=P.clone();me.y-=a/Math.sin(fe-Math.PI/2);let C=new Mt,ie=[];for(let Re=0;Re<s;Re++){let Ee=[],Pe=Math.PI/2-ge*Re/s,xt=Math.cos(Pe),Me=Math.sin(Pe),mt=ee;for(let bt=0;bt<=Re;bt++){let Tn=Math.cos(mt),tt=Math.sin(mt);k.x=xt*tt,k.y=Me,k.z=xt*Tn,C.copy(me).addScaledVector(k,a),c.push(C.x,C.y,C.z),u.push(k.x,k.y,k.z),p.push(0,0),Ee.push(d++),mt+=Math.PI*2/Re/t}ie.push(Ee)}pe.reverse(),ie.push(pe);let De=ie.length-1;for(let Re=0;Re<De;Re++){let Ee=ie[Re],Pe=ie[Re+1],xt=Ee.length-1;l.push(Pe[1],Ee[0],Pe[0]);for(let Me=1;Me<=xt;Me++)l.push(Ee[Me],Ee[Me-1],Pe[Me]),l.push(Pe[Me+1],Ee[Me],Pe[Me])}}}}}this.setIndex(l),this.setAttribute("position",new Xp(c,3)),this.setAttribute("normal",new Xp(u,3)),this.setAttribute("uv",new Xp(p,2));function W(k,H,$,J,Z){let X=-J/2,te=(Math.PI-J)/2,Y=H.clone().normalize().cross($);k.addScaledVector($,-a/Math.sin(te));let ee=new Mt,K=new Mt,q=1,ue=d,le=[];for(let ne=0;ne<=s;ne++){let ce=X+ne/s*J;K.set(0,0,0),K.addScaledVector(Y,Math.sin(ce)),K.addScaledVector($,Math.cos(ce));for(let ae=0;ae<=q;ae++){let he=ae/q-.5;if(ee.copy(k),ee.addScaledVector(H,he),ee.addScaledVector(K,a),Z!=null){let pe=Math.max(0,ee.y-Z);ee.addScaledVector(H,-pe/H.y)}c.push(ee.x,ee.y,ee.z),u.push(K.x,K.y,K.z),p.push(0,0),ae===0&&le.push(d),d++}}for(let ne=0;ne<s;ne++)for(let ce=0;ce<q;ce++){let ae=ue+ce+(q+1)*ne,he=ae+(q+1),pe=he+1,fe=ae+1;l.push(ae,he,fe),l.push(he,pe,fe)}return[k.clone().addScaledVector(H,.5),le]}function F(k,H,$,J){let Z=Math.PI/2,X=x.angle()-Z,te=[],Y=new Mt,ee=new Mt;for(let q=0;q<=s;q++){let ue=[],le=q/s;for(let ne=0;ne<=q;ne++){let ae=((q?ne/q:0)-.5)*v,he=Math.cos(ae),pe=Math.sin(ae),fe=Math.atan(Math.tan(X)*he),ge=(Z+fe)*le,me=Math.cos(ge),C=Math.sin(ge);Y.set(0,0,0),Y.addScaledVector(H,C*he),Y.addScaledVector($,me),Y.addScaledVector(J,C*pe),ee.copy(k).addScaledVector(Y,a),c.push(ee.x,ee.y,ee.z),u.push(Y.x,Y.y,Y.z),p.push(0,0),ue.push(d++)}te.push(ue)}let K=te.length-1;for(let q=0;q<K;q++){let ue=te[q],le=te[q+1],ne=ue.length-1;l.push(ue[0],le[1],le[0]);for(let ce=1;ce<=ne;ce++)l.push(ue[ce-1],ue[ce],le[ce]),l.push(ue[ce],le[ce+1],le[ce])}}}};var ba=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),t=Object.assign(r?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof Fe?n.shape:new Fe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:t}}static build(n){let r=n.shape,{width:e,height:t,cornerRadius:o,cornerType:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,c={x:e*.5,y:t*.5},u={x:-c.x,y:-c.y},p={x:c.x,y:c.y};function d(P,S,T){return S>e&&T>t?Math.min(P*e/S,P*t/T):S>e?P*e/S:T>t?P*t/T:P}let h=[];h[0]=o[0]===0?0:d(o[0],o[0]+o[3],o[0]+o[1]),h[1]=o[1]===0?0:d(o[1],o[1]+o[2],o[1]+o[0]),h[2]=o[2]===0?0:d(o[2],o[2]+o[1],o[2]+o[3]),h[3]=o[3]===0?0:d(o[3],o[3]+o[0],o[3]+o[2]);let f=u.x,m=p.x,y=p.y,g=u.y;r.addPoint(r.createPoint(f,y)),r.addPoint(r.createPoint(m,y)),r.addPoint(r.createPoint(m,g)),r.addPoint(r.createPoint(f,g)),r.isClosed=!0;let v=!0;for(let P=0,S=r.points.length;P<S;P++)r.points[P].roundness=h[P],P>0&&h[P]!==h[P-1]&&(v=!1);v&&(r.roundness=h[0]),r.useCubicForRoundedCorners=i!==1,r.update();let O=Jt.create({shape:r,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(O,{userData:{...n,type:"RectangleGeometry"}})}};import{BufferGeometry as JM,Float32BufferAttribute as eI,MathUtils as yx,SphereGeometry as tI}from"three";var gx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},n.parameters);return e.thetaLength=yx.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r=100,height:e=r,depth:t=r,widthSegments:o=64,heightSegments:i=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:c}=n.parameters,u;return c===0?(u=new JM,u.setAttribute("position",new eI([],3))):u=new tI(.5*r,o,i,a,s,l,c*yx.DEG2RAD),u.scale(1,e/r,t/r),Object.assign(u,{userData:{...n,type:"SphereGeometry"}})}};import{PlaneGeometry as rI}from"three";var xx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(n){let{width:r=100,height:e=r,widthSegments:t=8,heightSegments:o=8}=n.parameters,i=new rI(r,e,t,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};import{BufferGeometry as oI,Float32BufferAttribute as Zp,Vector3 as nI}from"three";var bx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,angle:o,cornerRadius:i,cornerSegments:a}=n.parameters,s=new Jp(r,e,t,o,i,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},Jp=class extends oI{constructor(r=1,e=1,t=1,o=90,i=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],c=[],u=.001;i==0&&(a=1),a=Math.max(1,Math.floor(a)),i=Math.min(i,100),o=Math.min(180-u,o),o*=Math.PI/180;let p=[],d=Math.PI/2,h=(ee=0,K=0,q=0)=>new nI(ee,K,q),f=h(),m=h(),[y,g,v]=[e/2,r/2,t/2],O=-g,P=+g,[S,T,I]=[h(O,-y,+v),h(O,-y,-v),h(O,+y,-v)],x=(ee,K=!1)=>Math.sin(ee-Math.PI/(1+ +K)),_=(ee,K=!1)=>Math.cos(ee-Math.PI/(1+ +K));I.y=Math.sin(o)*e-y;let D=Math.cos(o)*e-v,A=S.z-u;o<=d?(I.z=Math.min(D,A),I.z==A&&(I.y-=(D-A)/Math.tan(d-o))):T.z=Math.min(T.z-D-v,S.z-u),f.subVectors(S,T),m.subVectors(I,T);let N=Math.min(f.length(),m.length())*i/100,E=N*Math.tan(o/2),B=N/Math.cos(o/2),V=f.clone().normalize().add(m.normalize()).setLength(B).add(T);f.set(0,x(o,!0),_(o,!0)),p.push([I,f.clone()]);let j=(Math.PI-o)/a;for(let ee=0;ee<=a;ee++){let K=d+o+ee*j;f.set(0,Math.sin(K)*E,Math.cos(K)*E),f.add(V),m.set(0,x(K),_(K)),p.push([f.clone(),m.clone()])}p.push([S,h(0,1,0)]);let R=Math.sin(j/2)*E*2,W=p.length-1,F=p[0][0].distanceTo(p[1][0]),k=p[W-1][0].distanceTo(p[W][0]),H=F+R*a+k;p[0].push(1);for(let ee=0;ee<=a;ee++)p[ee+1].push(1-(F+ee*R)/H);p[W].push(0);let[$,J,Z]=p[0],X,te,Y;for(let ee=1;ee<p.length;ee++)[X,te,Y]=p[ee],s.push(O,$.y,$.z,O,X.y,X.z,P,$.y,$.z,P,$.y,$.z,O,X.y,X.z,P,X.y,X.z),l.push(0,J.y,J.z,0,te.y,te.z,0,J.y,J.z,0,J.y,J.z,0,te.y,te.z,0,te.y,te.z),c.push(0,Z,0,Y,1,Z,1,Z,0,Y,1,Y),[$,J,Z]=[X,te,Y];this.setAttribute("position",new Zp(s,3)),this.setAttribute("normal",new Zp(l,3)),this.setAttribute("uv",new Zp(c,2))}};var cu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Fe?n.shape:new Fe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,innerRadiusPercent:t,spikes:o,cornerRadius:i,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}=n.parameters,u=n.shape,p=r*.5,d=e*.5,h=0,f=0,m=a*Math.PI/360/o,y=Math.PI/2*3*-1,g=p*t/100,v=d*t/100;if(o===3&&t===50){m=2*Math.PI/o;for(let P=0;P<o;P++){let S=m*P,T=h+Math.sin(S)*p,I=f+Math.cos(S)*d;u.addPoint(u.createPoint(T,I))}}else for(let P=0;P<o;P++){let S=h+Math.cos(y)*p,T=f+Math.sin(y)*d;u.addPoint(u.createPoint(S,T)),y+=m,S=h+Math.cos(y)*g,T=f+Math.sin(y)*v,P<=o,u.addPoint(u.createPoint(S,T)),y+=m}u.isClosed=!0;for(let P=0,S=u.points.length;P<S;P++)u.points[P].roundness=i;u.roundness=i,u.update();let O=Jt.create({shape:u,parameters:{roundness:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(O,{userData:{...n,type:"StarGeometry"}})}};import{PlaneGeometry as iI}from"three";var vx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e}=n.parameters,t=new iI(r,e);return Object.assign(t,{userData:{...n,type:"TextFrameGeometry"}})}};import{BufferGeometry as aI,Float32BufferAttribute as sI,MathUtils as lI}from"three";var Sx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:t,height:o,depth:i})}}static build(n){let{width:r,height:e,depth:t,radialSegments:o,tubularSegments:i,arc:a,cornerRadius:s,cornerSegments:l}=n.parameters,c=cI(r,e,t,r*.5,a,i,0,0,o,s,l);return c.scale(1,e/r,1),Object.assign(c,{userData:{...n,type:"TorusGeometry"}})}};function cI(n,r,e,t,o,i,a,s,l,c,u){[r,e]=[e,r],a=r/2;let p=lI.clamp(o/360,0,1);if(p===0){let d=new aI;return d.setAttribute("position",new sI([],3)),d}return p===1&&(c=0),new js(!0,n,r,e,t,p,i,a,s,l,c,u)}import{TorusKnotGeometry as uI}from"three";var wx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{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(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(n){let{width:r,tube:e,tubularSegments:t,radialSegments:o,p:i,q:a}=n.parameters,s=r*.5;s!==e&&(s-=e);let l=new uI(s,e,t,o,i,a);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var Px=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof Fe?n.shape:new Fe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r=100,height:e,cornerRadius:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a,isRect:s}=n.parameters,l=n.shape,c=r*.5,u=e*.5;s?(l.addPoint(l.createPoint(-c,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))):(l.addPoint(l.createPoint(0,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))),l.isClosed=!0;for(let d=0,h=l.points.length;d<h;d++)l.points[d].roundness=t;l.roundness=t,l.update();let p=Jt.create({shape:l,parameters:{roundness:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...n,type:"TriangleGeometry"}})}};import{Vector2 as Cx,Vector3 as It,Matrix3 as dI,Matrix4 as Hn,BufferGeometry as Tx,BufferAttribute as va,MathUtils as uu}from"three";function Ox(n,r){let e=2*Math.PI;return(n%e+e)%e===(r%e+e)%e}var pI=new Hn,fI=new Hn;function hI(n,r,e){let t=[new It,new It,new It],o=[new It,new It,new It];return n.extractBasis(t[0],t[1],t[2]),r.extractBasis(o[0],o[1],o[2]),t.forEach((i,a)=>{let s=o[a],l=uu.lerp(i.length(),s.length(),e);i.lerp(s,e).setLength(l)}),new Hn().makeBasis(t[0],t[1],t[2])}var Ax=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=r?.shapeData??ma.create({parameters:$d}).userData.shape;return{path:n.path??Yi.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:i,extrusion:{...Sc,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new ef(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new Tx,{userData:{...n,type:"PathGeometry"}})}},ef=class extends Tx{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!Ox(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:o,offset:i}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),i=Math.max(0,Math.min(i,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(i*a),l=this.inputs.path.isClosed?Math.ceil((o+i)*a):Math.ceil(Math.min(1,o+i)*a),c=Math.min(Math.max(2,l-s+1),a+2),u=[],p=[];for(let F=0;F<c;F++){let k=this.inputs.path.isClosed?(F+s)%e.length:Math.min(F+s,e.length-1);u.push(e[k].clone()),p.push(t[k].clone())}let d=(F,k,H)=>{u[F]=u[F].clone().lerp(u[k],H),p[F]=hI(p[F],p[k],H)},h=0,f=i*a%1;(!this.inputs.path.isClosed||o<=1)&&(f||i===0)&&(h=f,d(0,1,h));let m=0,y=(i+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&i+o<1)&&y&&(m=y,d(u.length-1,u.length-2,1-m)),o===0){let F=u.length-1;u[F].copy(u[0]),p[F].copy(p[0])}this._applyPathModifiers(p,h,m);let{bevel:g,bevelSides:v}=this.inputs.parameters.extrusion,O=g>0?this.inputs.parameters.extrusion.capType:"flat",P=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(P=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:I}=this._computeShapePoints(P),x=0,_;O==="round"&&(_=new dn(this.inputs.shapeData,2*g,g,P,v,void 0,!0),x=_.getAttribute("position").count);let D=0,A=0;T.sort((F,k)=>F.start-k.start),T.forEach(F=>{F.verticesStart=D,F.verticesCount=F.continuous.reduce((k,H,$)=>k+($===0||!H?2:1),0),A+=F.verticesCount,D=A});let N=A*c,E,B=0;if(this._isOpenEnded()&&O==="flat"){try{E=Rr({windingRule:Ge.ODD,elementType:nt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{E=Gp}B=E.vertexCount}let V=N+2*B+x*2,j=N+2*B,R={positions:new Float32Array(V*3),normals:new Float32Array(V*3),uvs:new Float32Array(V*2)},W=[];if(T.forEach(F=>{this._extrudeRegion(F,I,p,u,R,W,this._isGeometryClosed()&&!this._isOpenEnded())}),E&&(this._closeEnd(E,N,W,R,p[0],u[0],!1),this._closeEnd(E,N+B,W,R,p[p.length-1],u[u.length-1],!0)),_){R.positions.set(_.getAttribute("position").array,j*3),R.normals.set(_.getAttribute("normal").array,j*3),R.uvs.set(_.getAttribute("uv").array,j*2);for(let $=j;$<j+x;$++)R.uvs[$*2+1]=1e-4;let F=W.length;W.push(..._.getIndex().array.map($=>$+j)),j+=x,R.positions.set(_.getAttribute("position").array,j*3),R.normals.set(_.getAttribute("normal").array,j*3),R.uvs.set(_.getAttribute("uv").array,j*2);let k=W.length;W.push(..._.getIndex().array.map($=>$+j)),this.setAttribute("position",new va(R.positions,3)),this.setAttribute("normal",new va(R.normals,3)),this.setAttribute("uv",new va(R.uvs,2)),this.setIndex(W);let H=pI;H.copy(p[p.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,j,V),H.copy(p[0]).setPosition(u[0]).multiply(fI.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,j-x,j),this.reverseIndicesOnRange(F,k)}else this.setAttribute("position",new va(R.positions,3)),this.setAttribute("normal",new va(R.normals,3)),this.setAttribute("uv",new va(R.uvs,2)),this.setIndex(W)}_extractPathPoints(){let t=kc(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(t.length<2)return[];let o=[t[0]];return t.forEach(a=>{o[o.length-1].distanceToSquared(a)>.001&&o.push(a)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let t=[],o=e.length,i=this.inputs.path.isClosed,a=new It,s=new It,l=new It,c=new It,u=new It(0,1,0);for(let y=0;y<o;y++){let g=e[y],v;y===0?v=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let O;y===o-1?O=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):O=e[y+1];let P=g.clone().sub(v).normalize(),S=O.clone().sub(g).normalize(),T=P.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let I=u.clone().cross(T).normalize(),x=T.clone().cross(I).normalize();u.copy(x),c.copy(I),y===0&&(a.copy(x),s.copy(T));let _=new Hn().makeBasis(I,x,T);t.push(_)}let p=i?s:l,d=i?a:new It(0,1,0),h=p.clone().cross(c).normalize(),f=Math.acos(d.dot(h));if(isNaN(f))return t;let m=d.clone().cross(h);p.dot(m)>0&&(f*=-1);for(let y=1;y<t.length;y++){let g=new Hn().makeRotationZ(f*y/t.length);t[y].multiply(g)}return t}_applyPathModifiers(e,t,o){let i=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new Hn,p=new Hn;return e.forEach((d,h)=>{let f=h===0?0:h===i-1?1:(h-t)/(i-(o===0?0:1)-(t+(1-o)));u.makeRotationZ(uu.lerp(a,a+s,f)*uu.DEG2RAD);let m=uu.lerp(l,c,f);p.makeScale(m,m,m),d.multiply(u).multiply(p)}),e}_computeShapePoints(e=12,t=Ge.ODD){let o=this.inputs.shapeData,i=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let v=y.length-1;v>=1;v-=2){let O=y[v-1],P=y[v-0];g.push(O,P)}return g}),s;try{s=Rr({windingRule:t,elementType:nt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{s=Gs}let l;try{l=Rr({windingRule:Ge.ODD,elementType:nt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=zp}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let u=1/0,p=-1/0,d=1/0,h=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,v=s.vertices[g+0],O=s.vertices[g+1];v<u&&(u=v),v>p&&(p=v),O<d&&(d=O),O>h&&(h=O)}let f=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,v=s.elements[g+0],O=s.elements[g+1],P=v+O,S={start:v,count:O,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};f.push(S);let T=v,I=P-1,x=v+1,_=o.roundedCurves.length;do{let D=T-v,A=s.vertices[I*2+0],N=s.vertices[I*2+1],E=s.vertices[T*2+0],B=s.vertices[T*2+1],V=s.vertices[x*2+0],j=s.vertices[x*2+1],R=E-A,W=B-N,F=Math.sqrt(R*R+W*W);R/=F,W/=F;let k=E-V,H=B-j,$=Math.sqrt(k*k+H*H);k/=$,H/=$,S.normals[D*2+0]=-H,S.normals[D*2+1]=k;let J=s.vertexIndices[T];if(Array.isArray(J))S.continuous[D]=!1;else{let[Z,X]=o.getCurveIndexFromVertexId(J-1,!0);if(X>0&&X<1)S.continuous[D]=!0;else{let te=X===1?Z+1:Z-1;te=(te+_)%_;let Y=X===1?0:1,ee=o.roundedCurves[Z].getTangent(X),K=o.roundedCurves[te].getTangent(Y);S.continuous[D]=ee.dot(K)>.95}}y&&(S.normals[D*2+0]*=-1,S.normals[D*2+1]*=-1),[I,T,x]=[T,x,x+1],x>=P&&(x-=O)}while(x!==v+1)}return{regions:[i,...a],infos:f,vertices:s.vertices}}_insertVertex(e,t,o,i,a){let s=t*2,l=t*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=i.x,e.normals[l+1]=i.y,e.normals[l+2]=i.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,t,o,i,a,s,l){let c=new It,u=new It,p=new It,d=new It,h=new Cx;o.forEach((m,y)=>{let g=i[y],v=e.verticesStart*o.length+e.verticesCount*y;for(let O=0;O<e.count;O++){let P=(e.start+O)*2;if(c.set(t[P+0],t[P+1],0),p.copy(c).applyMatrix4(m).add(g),e.continuous[O])d.set(e.normals[O*2+0],e.normals[O*2+1],0);else{let S=O===0?(e.start+e.count-1)*2:P-2;u.set(t[S+0],t[S+1],0),d.copy(c).sub(u),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(m).normalize(),h.set(O===0?1:O/e.count,y/(o.length-1)),this._insertVertex(a,v,p,d,h),v++,!e.continuous[O]||O===0){if(O===0)d.set(e.normals[O*2+0],e.normals[O*2+1],0),h.set(0,y/(o.length-1));else{let S=O===e.count-1?e.start*2:P+2;u.set(t[S+0],t[S+1],0),d.copy(u).sub(c),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(m).normalize(),this._insertVertex(a,v,p,d,h),v++}}});let f=o.length-1;for(let m=0;m<f;m++){let y=e.verticesStart*o.length+e.verticesCount*m,g=e.verticesStart*o.length+e.verticesCount*(m+1),v=0;for(let O=0;O<e.count;O++){(!e.continuous[O]||O===0)&&v++;let P=O===e.count-1?0:v+1,S=y+v,T=y+P,I=g+P,x=g+v;e.isHole?s.push(S,I,T,S,x,I):s.push(S,T,I,S,I,x),v++}}}_closeEnd(e,t,o,i,a,s,l){let c=e.vertexCount,u=new It(0,0,l?-1:1).applyMatrix4(a),p=new It,d=new Cx;for(let f=0;f<c;f++){let m=2*f;p.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(i,t+f,p,u,d)}let h=e.elements;for(let f=0;f<e.elementCount;f++){let m=3*f,y=h[m+0]+t,g=h[m+(l?1:2)]+t,v=h[m+(l?2:1)]+t;o.push(y,g,v)}}applyMatrix4OnRange(e,t,o){let i=e.elements,a=new dI().getNormalMatrix(e).elements,s,l,c,u,p=this.attributes.position,d=this.attributes.normal;if(!p||!d)return;let h=p.array,f=d.array,m=p.itemSize;for(let y=t*m,g=o*m;y<g;y+=m){if(y===t)debugger;s=h[y+0],l=h[y+1],c=h[y+2],u=1/(i[3]*s+i[7]*l+i[11]*c+i[15]),h[y+0]=(i[0]*s+i[4]*l+i[8]*c+i[12])*u,h[y+1]=(i[1]*s+i[5]*l+i[9]*c+i[13])*u,h[y+2]=(i[2]*s+i[6]*l+i[10]*c+i[14])*u,s=f[y+0],l=f[y+1],c=f[y+2],f[y+0]=a[0]*s+a[3]*l+a[6]*c,f[y+1]=a[1]*s+a[4]*l+a[7]*c,f[y+2]=a[2]*s+a[5]*l+a[8]*c}p.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,t){let o=this.index;if(o){for(let i=e;i<t;i+=3){let a=o.getX(i),s=o.getX(i+1),l=o.getX(i+2);o.setXYZ(i,l,s,a)}o.needsUpdate=!0}}};import{BufferAttribute as Mx,BufferGeometry as tf}from"three";import{mergeBufferGeometries as yI}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Ix(){let n=new tf;return n.setAttribute("position",new Mx(new Float32Array([]),3)),n.setIndex(new Mx(new Uint16Array([]),1)),n}var gI=Ix().attributes,xI=12,bI=1,Sa=class extends tf{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,gI),this.userData={parameters:e,type:"TextGeometry"};let o=t.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let o=t.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l,text:c,textTransform:u}=e,p=Nc.getDisplayedValue(c),d=u===2?p.toUpperCase():u===3?p.toLowerCase():p,h=vI(e,t,d),{shapes:f,charWidths:m,charCoords:y}=t.generateShapes(h,e),g=(typeof o=="number"?o:1)*.5,v=(typeof i=="number"?i:1)*.5,O=f.map(T=>new Fe().fromShape(T,!0));this.vectorShapes=O;let P=O.map(T=>Jt.create({shape:T,parameters:{depth:a,extrudeBevelSegments:l,extrudeBevelSize:s,windingRule:a<=0?Ge.NONZERO:Ge.ODD,subdivisions:this.isLowResolution&&a>0?bI:xI}})),S=P.length?yI(P):Ix();S.translate(-g,v,0),this.dispose(),this.wrappedText=h,this.charCoords=y,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(S.attributes).forEach(([T,I])=>{this.setAttribute(T,I)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=Ht(new tf,Sa.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,o])=>{this.setAttribute(t,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function vI(n,r,e){let t=[""],o="";for(let i of e)o+=i,i===" "||i===`
3
3
  `?(t[t.length-1]+=o,o="",i===`
4
- `&&t.push("")):r.getTextWidth(t[t.length-1]+o,n)>n.width&&(t[t.length-1].length&&t.push(""),r.getTextWidth(t[t.length-1]+o,n)>n.width&&(o.length===1?(t[t.length-1]+=o,o=""):(t[t.length-1]+=o.slice(0,-1),o=o[o.length-1],t.push(""))));return t[t.length-1]+=o,t}import{BufferGeometry as nf,BufferAttribute as E0,Uint32BufferAttribute as af,Float32BufferAttribute as sf,Matrix4 as OI,Vector3 as qs,Sphere as CI,Box3 as TI,BoxGeometry as AI}from"three";var N0,fu=new Promise(n=>{N0=n}),I0=!1;var pu;function D0(){if(I0)return;if(pu)return pu;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.0.70/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(c=>c.arrayBuffer())]),s=i.default,l=await s({wasmBinary:a});N0(l),I0=!0}return pu=n(),pu}import{BufferGeometryLoader as vI}from"three";var SI=["font"];function _o(n,r,e,t){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let c of a){let u=i;for(let p of c)u=u[p];for(o in u){let p=u[o];Wd(p)&&!SI.includes(o)&&(u[o]=r.getVariable(p,[t.uuid,"geometry",...c,o]),Wd(u[o])&&(u[o]=1))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let c=Fe.createFromState(i.shape,i.width,i.height);s.shape=c}else if(i.type==="NonParametricGeometry")i.data.groups&&i.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new vI().parse(i);else if(i.type==="SubdivGeometry"){let c=new mt(i,e);return c.data=n,c}else{if(i.type==="TextGeometry")return new wa(i,r);if(i.type==="UIGeometry")return va.create({parameters:{width:i.width,height:i.height,cornerRadius:i.cornerRadius,cornerType:i.cornerType}})}let l;try{l=of(s)}catch(c){console.error(c)}if(!l){let c=Fe.createFromState(Yi.defaultData(),100,100);s.shape=c,l=of(s)}return l}import{Matrix4 as wI}from"three";var PI=new wI;function Ws(n,r,e,t){let o=n.position.array,i=n.normal.array,a=PI.makeScale(r,e,t).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=r,o[u+1]*=e,o[u+2]*=t,s=i[u],l=i[u+1],c=i[u+2],i[u]=a[0]*s+a[4]*l+a[8]*c,i[u+1]=a[1]*s+a[5]*l+a[9]*c,i[u+2]=a[2]*s+a[6]*l+a[10]*c;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var hu=new TI,Pa=new qs,Se;fu.then(n=>{Se=n});var _0=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),B0=new Uint32Array([0,1,2,3]),L0=new Uint8Array([4]),mt=class extends nf{constructor(e,t){super();this.data=e;this.flatShading=t;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let o=this.data.scaleBaked,i=Jo.div(t,o);this.subdividedGeometry&&Ws(this.subdividedGeometry.attributes,...i),this.originalGeometry&&Ws(this.originalGeometry.attributes,...i),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*i[0],height:a.height*i[1],depth:a.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(Pa.fromArray(i));let s=Pa.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,o;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:o}=mt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new AI(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(mt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new CI,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;hu.setFromBufferAttribute(t),hu.getCenter(o),e.boundingSphere.radius=o.distanceTo(hu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),hu.getSize(Pa);let i={width:Pa.x,height:Pa.y,depth:Pa.z};return this.userData.parameters=i,i}static build(e,t,o,i){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),t&&(Se.free_bvh(t),Se.free_subdivision_surface(t));try{a=mt.allocate(e,i)}catch(u){console.error(u,e),a=mt.allocate({positionWASM:_0,indexWASM:B0,verticesPerFaceWASM:L0},i)}if(Se.set_destination_refinement_level(a,0),s=mt.buildLevel(a,!0,c),e.subdivisions>0)try{Se.set_destination_refinement_level(a,e.subdivisions),l=mt.buildLevel(a,!1,c)}catch{try{Se.set_destination_refinement_level(a,e.subdivisions-1),l=mt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,t,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let i=e.shape!==void 0||e.path!==void 0?t.geometry:_o(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,l,c,u;({positions:s,triIndices:u}=df(i.getAttribute("position"),a));let p;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,h=d+e.radialSegments*3;p=[d,h]}return{indices:l,verticesPerFace:c}=pf(s,u,i,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,t){let o,i,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=_0,i=B0,a=L0);let c=o.length,u=i.length,p=a.length,d=o.length+s.length+l.length,h=i.length+a.length,f=d*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,y=h*Uint32Array.BYTES_PER_ELEMENT,g=Se._malloc(f),v=new Float32Array(Se.HEAPF32.buffer,g,d),O=new Uint32Array(Se.HEAPU32.buffer,g+m,h);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),O.set(i,0),O.set(a,i.length);let P;e?.scaleBaked?.some(T=>T!==1)&&(P=new OI().makeScale(...e.scaleBaked)),t&&(P?P.premultiply(t):P=t);let S=P?Se.alloc_subdivision_surface2(g,c,g+m,u,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p,P.elements):Se.alloc_subdivision_surface(g,c,g+m,u,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p);return Se._free(g),S}static buildLevel(e,t,o,i,a){let s=a?Se.get_mesh_data2(e,t?Se.Level.CONTROL:Se.Level.REFINED,o,a.elements):Se.get_mesh_data(e,t?Se.Level.CONTROL:Se.Level.REFINED,o),l=8,c=Se.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=Se.HEAPU32[c[p]>>2],h=Se.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let f=Se.HEAPU32[c[p]>>2],m=Se.HEAPF32.subarray(f>>2,(f>>2)+u[p]);p++;let y=Se.HEAPU32[c[p]>>2],g=Se.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=Se.HEAPU32[c[p]>>2],O=Se.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,i===void 0){let P=new nf;if(P.setIndex(new af(O,1)),P.setAttribute("position",new sf(h,3)),P.setAttribute("normal",new sf(m,3)),t){P.setAttribute("faceMap",new af(g,1));let S=new Float32Array(m.length/3*4).fill(0);P.setAttribute("color",new E0(S,4))}return Se.free_mesh_data(s),P.userData.type="SubdivGeometry",P}i.getAttribute("position").copyArray(h),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,Se.free_mesh_data(s)}static freeSubdivPointer(e){Se.free_bvh(e),Se.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=Se.get_wireframe_data_for_base_level(e),a=4,s=Se.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),c=0,u=Se.HEAPU32[s[c]>>2],p=Se.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Se.HEAPU32[s[c]>>2],h=Se.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(t===void 0){let f=new nf;f.setAttribute("position",new sf(p,3));let m=new Float32Array(p.length);for(let y=0,g=p.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return f.setAttribute("color",new E0(m,3)),f.setIndex(new af(h,1)),Se.free_wireframe_data_for_base_level(i),f}t.getAttribute("position").copyArray(p),t.attributes.position.needsUpdate=!0,Se.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||Se.set_destination_refinement_level(e,t);let a=o?Se.get_topological_data2(e,i?Se.Level.CONTROL:Se.Level.REFINED,o.elements):Se.get_topological_data(e,i?Se.Level.CONTROL:Se.Level.REFINED),s=6,l=Se.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=Se.HEAPU32[l[u]>>2],d=new Float32Array(Se.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let h=Se.HEAPU32[l[u]>>2],f=new Uint32Array(Se.HEAPU32.subarray(h>>2,(h>>2)+c[u]));u++;let m=Se.HEAPU32[l[u]>>2],y=new Uint8Array(Se.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Se.free_topological_data(a),{positions:d,indices:f,verticesPerFace:y}}};var R0=["getX","getY","getZ"];function df(n,r){let e={},t=r?r.count:n.count,o=0,i=[],a=[],s=1e4;for(let c=0;c<t;c++){let u=r?r.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(n[R0[d]](u)*s)},`;if(p in e)i.push(e[p]);else{for(let d=0;d<3;d++)a.push(n[R0[d]](u));e[p]=o,i.push(o),o++}}let l=[];for(let c=0;c<i.length;c+=3)i[c]===i[c+1]||i[c]===i[c+2]||i[c+1]===i[c+2]||l.push(i[c],i[c+1],i[c+2]);return{positions:a,triIndices:l}}var mu=new qs,lf=new qs,cf=new qs,uf=new qs;function pf(n,r,e,t){let o=[],i=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/c;l=l.filter((h,f)=>Math.floor(f/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);n.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)n.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)n.push(l[d],l[d+1],0),o.push(p++);return i.push(p),{indices:o,verticesPerFace:i}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<r.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[r[s]*3+2]===a||n[r[s]*3+2]===0)&&l++,(n[r[s+1]*3+2]===a||n[r[s+1]*3+2]===0)&&l++,(n[r[s+2]*3+2]===a||n[r[s+2]*3+2]===0)&&l++,l===3)break}if(r[s+1]===r[s+3]&&r[s+2]===r[s+5]||r[s+0]===r[s+3]&&r[s+2]===r[s+4]){mu.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),lf.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),cf.set(n[r[s+4]*3],n[r[s+4]*3+1],n[r[s+4]*3+2]),uf.set(n[r[s+5]*3],n[r[s+5]*3+1],n[r[s+5]*3+2]),lf.sub(mu).normalize(),cf.sub(mu).normalize(),uf.sub(mu).normalize();let l=lf.cross(cf).dot(uf);Math.abs(l)>.005||t&&t.some((c,u)=>u%2===1?!1:s>=t[u]&&s<t[u+1])?(o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3):(o.push(r[s],r[s+1],r[s+4],r[s+5]),i.push(4),s+=6)}else o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<n.length;p+=3,d++)n[p+2]===0&&(l.push(d),u++),n[p+2]===a&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let p=c[0];c[0]=c[1],c[1]=p}l.reverse(),o.push(...l,...c),i.push(u,u)}return{indices:o,verticesPerFace:i}}var br={};r1(br,{calcBoolean:()=>EI,calcBooleanTopological:()=>DI,freeMeshSet:()=>RI,getMeshSet:()=>_I,hasOpenEdges:()=>BI,transformMeshSet:()=>LI});var MI,V0=new Promise(n=>{MI=n});import{Float32BufferAttribute as z0,Sphere as II}from"three";var Ne,Oa;V0.then(n=>Ne=n);function NI(n,r,e){let t,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:a}=df(n.getAttribute("position"),o),s;if(r&&e){let{indices:l,verticesPerFace:c}=pf(i,a,n);s=c.length,t=[];for(let u=0,p=0;u<s;u++){t.push(c[u]);for(let d=0;d<c[u];d++)t.push(l[p++])}}else{let l=a.length;t=Array(l+l/3),s=0;for(let c=0,u=0;u<t.length;)t[u++]=3,s++,t[u++]=a[c++],t[u++]=a[c++],t[u++]=a[c++]}return{positions:i,faceIndices:t,nFaces:s}}function G0(n){let r=n.length,e=r*Uint32Array.BYTES_PER_ELEMENT,t=r*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:t,i=Ne._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Ne.HEAPU32.buffer,i,r):new Float32Array(Ne.HEAPF32.buffer,i,r)).set(n,0),i}function j0(n){switch(n){case 0:return Ne.OP.UNION;case 1:return Ne.OP.INTERSECTION;case 2:return Ne.OP.A_MINUS_B;case 3:return Ne.OP.B_MINUS_A;case 4:return Ne.OP.SYMMETRIC_DIFFERENCE;case 5:return Ne.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function DI(n,r){Oa===void 0&&(Oa=Ne.init_csg());let e=G0(n),t=Ne.csg_calc_topological(Oa,e,n.length,j0(r));Ne._free(e);let o=6,i=Ne.HEAPU32.subarray(t>>2,(t>>2)+o),a=i.subarray(3,3+3),s=0,l=Ne.HEAPU32[i[s]>>2],c=new Float32Array(Ne.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ne.HEAPU32[i[s]>>2],p=new Uint32Array(Ne.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Ne.HEAPU32[i[s]>>2],h=new Uint8Array(Ne.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Ne.free_mesh_data(t),{positions:c,indices:p,verticesPerFace:h}}function EI(n,r,e,t){Oa===void 0&&(Oa=Ne.init_csg());let o=G0(n),i=Ne.csg_calc(Oa,o,n.length,t,j0(r));Ne._free(o);let a=5,s=Ne.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),c=0,u=Ne.HEAPU32[s[c]>>2],p=Ne.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Ne.HEAPU32[s[c]>>2],h=Ne.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let f=l[c];e.setAttribute("position",new z0(p,3)),e.setAttribute("normal",new z0(h,3));let m=Ne.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new II),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Ne.free_mesh_data(i),f}function _I(n,r,e){if(Ne===void 0)return-1;let t,o,i;if(r&&n.userData.positions!==void 0){let g=n.userData;i=g.verticesPerFace.length,t=g.positions,o=Array(g.verticesPerFace.reduce((v,O)=>v+O,0)+i);for(let v=0,O=0,P=0;v<g.verticesPerFace.length;v++){o[P++]=g.verticesPerFace[v];for(let S=0;S<g.verticesPerFace[v];S++)o[P++]=g.indices[O++]}}else({positions:t,faceIndices:o,nFaces:i}=NI(n,r,e));let a=t.length,s=o.length,l=t.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,h=Ne._malloc(u),f=new Float32Array(Ne.HEAPF32.buffer,h,l),m=new Uint32Array(Ne.HEAPU32.buffer,h+p,c);f.set(t,0),m.set(o,0);let y=Ne.get_csg_mesh(h,a,h+p,s,i);return Ne._free(h),y}function BI(n){return Ne.has_open_edges(n)}function LI(n,r){Ne.transform_csg_mesh(n,r.elements)}function RI(n){Ne.free_csg_mesh(n)}var VI={ConeGeometry:bx,CubeGeometry:vx,CylinderGeometry:xx,DodecahedronGeometry:Sx,EllipseGeometry:ya,HelixGeometry:t0,IcosahedronGeometry:r0,LatheGeometry:o0,NonParametricGeometry:f0,PolygonGeometry:cu,PyramidGeometry:h0,RectangleGeometry:va,SphereGeometry:y0,PlaneGeometry:g0,BackdropGeometry:x0,StarGeometry:uu,TextFrameGeometry:b0,TorusGeometry:v0,TorusKnotGeometry:S0,TriangleGeometry:w0,PathGeometry:T0,VectorGeometry:Jt},of=n=>VI[n.type].create(n);function Ca(n){return n!==null&&"booleanOp"in n}var Ta=class extends la(GI){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new zI}updateVisible(e){super.updateVisible(e),this.visible=!Ca(this.parent)&&this.visible,Ca(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(br.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ca(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Ta&&(e.freeBooleanPointer(),Ca(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let o=super.updateTransformState(e,t);return o&&Ca(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ca(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var yu=new jI;function $s(n,r=0,e=n.count,t,o){let i=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=r;p<e;p++){let d=n.getX(p),h=n.getY(p),f=n.getZ(p);d<i&&(i=d),h<a&&(a=h),f<s&&(s=f),d>l&&(l=d),h>c&&(c=h),f>u&&(u=f)}yu.min.set(i,a,s),yu.max.set(l,c,u),yu.getCenter(t),yu.getSize(o).multiplyScalar(.5)}var kI=new FI,HI=new UI,Ot=class extends Ta{constructor(r,e){super(kI,HI),this.super_Entity(r,e)}updateState(r,e){this.updateState_Entity(r,e)}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?$s(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};import{Box3 as a3,Matrix4 as s3,Sphere as Mb,Vector3 as l3}from"three";import{BufferAttribute as o3,Float32BufferAttribute as Ab,MathUtils as zf,Vector3 as Gf}from"three";import{ShaderMaterial as FN}from"three";var Bo=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Bo.uuidContext===null)throw new Error("plz startContext");Bo.uuidContext===Bo.globalContext?this.uuid="_gid"+Bo.uuidContext.nodeContextUuid++:this.uuid="_uid"+Bo.uuidContext.nodeContextUuid++,this.type=r,this.name=""}static startContext(r){if(this.uuidContext===null||this.uuidContext===Bo.globalContext)this.uuidContext=r;else throw new Error}static endContext(r){if(this.uuidContext!==r)throw new Error;this.uuidContext=null}analyze(r,e){e=e??{},r.analyzing=!0,this.build(r.addFlow(e.slot,e.cache,e.context),"v4"),r.clearVertexNodeCode(),r.clearFragmentNodeCode(),r.removeFlow(),r.analyzing=!1}analyzeAndFlow(r,e,t){return t=t??{},this.analyze(r,t),this.flow(r,e,t)}flow(r,e,t){t=t??{},r.addFlow(t.slot,t.cache,t.context);let o={result:this.build(r,e),code:r.clearNodeCode(),extra:r.context.extra};return r.removeFlow(),o}build(r,e,t){e=e??this.getType(r,e);let o=r.getNodeData(t??this);return r.analyzing&&this.appendDepsNode(r,o,e),r.nodes.indexOf(this)===-1&&r.nodes.push(this),this.updateFrame!==void 0&&r.updaters.indexOf(this)===-1&&r.updaters.push(this),this.generate(r,e,t)}updateFrame(r){}generateReadonly(r,e,t,o,i,a){return""}generate(r,e,t,o,i){return""}parse(r,e,t,o){}appendDepsNode(r,e,t){e.deps=(e.deps||0)+1;let o=r.getTypeLength(t);(o>(e.outputMax||0)||this.getType(r,t))&&(e.outputMax=o,e.output=t)}setName(r){this.name=r}getName(){return this.name}getType(r,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},it=Bo;it.globalContext={nodeContextUuid:0},it.uuidContext=Bo.globalContext;import{CubeReflectionMapping as tN,CubeRefractionMapping as rN,CubeUVReflectionMapping as oN,LinearEncoding as K0,sRGBEncoding as nN}from"three";var Ys=class{constructor(r){r=r??{},this.name=r.name,this.type=r.type,this.node=r.node,this.size=r.size,this.needsUpdate=r.needsUpdate}get value(){return this.node.value}set value(r){this.node.value=r}};var ff=class{constructor(){this.nodes={};this.keywords={}}add(r){this.nodes[r.name]=r}addKeyword(r,e,t){t=t!==void 0?t:!0,this.keywords[r]={callback:e,cache:t}}remove(r){delete this.nodes[r.name]}removeKeyword(r){delete this.keywords[r]}get(r){return this.nodes[r]}getKeyword(r,e){return this.keywords[r].callback(e)}getKeywordData(r){return this.keywords[r]}contains(r){return this.nodes[r]!==void 0}containsKeyword(r){return this.keywords[r]!==void 0}},Ct=new ff;import{Vector2 as F0}from"three";import{MathUtils as WI}from"three";var ye=class extends it{constructor(e,t){super(e);this.scope="";t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,o,i){if(t=t??this.getType(e),this.getShared(e,t)){let a=this.getUnique(e,t);a&&this.uuid===void 0&&(this.uuid=WI.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,t),this.generate(e,t,o)):super.build(e,t,o);if(a)return s.name=s.name||super.build(e,t,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,t,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,t);{c=super.generate(e,t,o,s.output,i);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,t)}}return super.build(e,t,o)}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 o=e.getVars()[t];return o?o.name:void 0}generate(e,t,o,i,a){return this.getShared(e,t)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),a,this.getLabel()).name}};var qe=class extends ye{constructor(e,t){t=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}generate(e,t,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,t)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,t))}};var at=class extends qe{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof F0?e:new F0(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,o,i,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}};import{Vector3 as U0}from"three";var Vt=class extends qe{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof U0?e:new U0(e,t,o)}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,o,i,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}};import{Color as qI}from"three";var Tt=class extends qI{constructor(e,t,o,i){super(e,t,o);this.isColorA=!0;this.a=i}setRGBA(e,t,o,i){super.setRGB(e,t,o),this.a=i}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)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let i,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(i[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(i[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}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}};var er=class extends qe{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Tt?e:new Tt(e.r,e.g,e.b,e.a)}generateReadonly(e,t,o,i,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}};var $I=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,k0=/[a-z_0-9]+/gi,re=class extends ye{constructor(e,t,o,i,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,t,o,i)}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,o,i,a){let s,l=0,c=this.src;if(this.includes)for(let p=0;p<this.includes.length;p++)e.include(this.includes[p],this);for(let p in this.extensions)e.extensions[p]=!0;let u=[];for(;s=k0.exec(this.src);)u.push(s);for(let p=0;p<u.length;p++){let d=u[p],h=d[0],f=this.isMethod?!this.getInputByName(h):!0,m=h;if(this.keywords[h]||this.useKeywords&&f&&Ct.containsKeyword(h)){let y=this.keywords[h];if(!y){let g=Ct.getKeywordData(h);g.cache&&(y=e.keywords[h]),y=y||Ct.getKeyword(h,e),g.cache&&(e.keywords[h]=y)}m=y.build(e)}h!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+h.length+l),l+=m.length-h.length),this.getIncludeByName(m)===void 0&&Ct.contains(m)&&e.include(Ct.get(m))}return t==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),t)}parse(e,t,o,i){if(this.src=e||"",this.includes=t??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let a=$I.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(k0);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let p=s[l++];this.inputs.push({name:p,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var YI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,hf=class extends ye{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||hf.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,o,i,a){this.src=e||"";let s,l,c="",u=YI.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}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,o,i,a){return e.format(this.name,this.getType(e),t)}},je=hf;je.PI="PI",je.PI2="PI2",je.RECIPROCAL_PI="RECIPROCAL_PI",je.RECIPROCAL_PI2="RECIPROCAL_PI2",je.LOG2="LOG2",je.EPSILON="EPSILON";var XI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
5
- )*?)}`,"gim"),KI=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Aa=class extends ye{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,o,i,a){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=XI.exec(e);if(t){let o=t[2],i;for(;i=KI.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}};var Ma=class extends ye{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",i=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(i,this.getType(e),t)}};Ct.addKeyword("uv",function(){return new Ma});Ct.addKeyword("uv2",function(){return new Ma(1)});import{LinearEncoding as QI,sRGBEncoding as ZI}from"three";var qn=class extends ye{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??qn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case QI:return["Linear"];case ZI:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),i=this.getType(e),a=qn.Nodes[this.method],s=e.include(a);if(s===qn.LINEAR_TO_LINEAR)return e.format(o,i,t);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",i,t)}else return e.format(s+"( "+o+" )",i,t)}fromEncoding(e){let t=qn.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=qn.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},qt=qn;qt.Nodes={LinearToLinear:new re(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
4
+ `&&t.push("")):r.getTextWidth(t[t.length-1]+o,n)>n.width&&(t[t.length-1].length&&t.push(""),r.getTextWidth(t[t.length-1]+o,n)>n.width&&(o.length===1?(t[t.length-1]+=o,o=""):(t[t.length-1]+=o.slice(0,-1),o=o[o.length-1],t.push(""))));return t[t.length-1]+=o,t}import{BufferGeometry as of,BufferAttribute as _x,Uint32BufferAttribute as nf,Float32BufferAttribute as af,Matrix4 as CI,Vector3 as Ws,Sphere as TI,Box3 as AI,BoxGeometry as MI}from"three";var Dx,pu=new Promise(n=>{Dx=n}),Nx=!1;var du;function Ex(){if(Nx)return;if(du)return du;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.0.71/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(c=>c.arrayBuffer())]),s=i.default,l=await s({wasmBinary:a});Dx(l),Nx=!0}return du=n(),du}import{BufferGeometryLoader as SI}from"three";var wI=["font"];function Bo(n,r,e,t){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let c of a){let u=i;for(let p of c)u=u[p];for(o in u){let p=u[o];Hd(p)&&!wI.includes(o)&&(u[o]=r.getVariable(p,[t.uuid,"geometry",...c,o]),Hd(u[o])&&(u[o]=1))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let c=Fe.createFromState(i.shape,i.width,i.height);s.shape=c}else if(i.type==="NonParametricGeometry")i.data.groups&&i.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new SI().parse(i);else if(i.type==="SubdivGeometry"){let c=new ht(i,e);return c.data=n,c}else{if(i.type==="TextGeometry")return new Sa(i,r);if(i.type==="UIGeometry")return ba.create({parameters:{width:i.width,height:i.height,cornerRadius:i.cornerRadius,cornerType:i.cornerType}})}let l;try{l=rf(s)}catch(c){console.error(c)}if(!l){let c=Fe.createFromState($i.defaultData(),100,100);s.shape=c,l=rf(s)}return l}import{Matrix4 as PI}from"three";var OI=new PI;function Hs(n,r,e,t){let o=n.position.array,i=n.normal.array,a=OI.makeScale(r,e,t).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=r,o[u+1]*=e,o[u+2]*=t,s=i[u],l=i[u+1],c=i[u+2],i[u]=a[0]*s+a[4]*l+a[8]*c,i[u+1]=a[1]*s+a[5]*l+a[9]*c,i[u+2]=a[2]*s+a[6]*l+a[10]*c;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var fu=new AI,wa=new Ws,Se;pu.then(n=>{Se=n});var Bx=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Lx=new Uint32Array([0,1,2,3]),Rx=new Uint8Array([4]),ht=class extends of{constructor(e,t){super();this.data=e;this.flatShading=t;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let o=this.data.scaleBaked,i=Jo.div(t,o);this.subdividedGeometry&&Hs(this.subdividedGeometry.attributes,...i),this.originalGeometry&&Hs(this.originalGeometry.attributes,...i),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*i[0],height:a.height*i[1],depth:a.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(wa.fromArray(i));let s=wa.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,o;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:o}=ht.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new MI(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(ht.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new TI,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;fu.setFromBufferAttribute(t),fu.getCenter(o),e.boundingSphere.radius=o.distanceTo(fu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),fu.getSize(wa);let i={width:wa.x,height:wa.y,depth:wa.z};return this.userData.parameters=i,i}static build(e,t,o,i){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),t&&(Se.free_bvh(t),Se.free_subdivision_surface(t));try{a=ht.allocate(e,i)}catch(u){console.error(u,e),a=ht.allocate({positionWASM:Bx,indexWASM:Lx,verticesPerFaceWASM:Rx},i)}if(Se.set_destination_refinement_level(a,0),s=ht.buildLevel(a,!0,c),e.subdivisions>0)try{Se.set_destination_refinement_level(a,e.subdivisions),l=ht.buildLevel(a,!1,c)}catch{try{Se.set_destination_refinement_level(a,e.subdivisions-1),l=ht.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,t,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let i=e.shape!==void 0||e.path!==void 0?t.geometry:Bo(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,l,c,u;({positions:s,triIndices:u}=uf(i.getAttribute("position"),a));let p;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,h=d+e.radialSegments*3;p=[d,h]}return{indices:l,verticesPerFace:c}=df(s,u,i,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,t){let o,i,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=Bx,i=Lx,a=Rx);let c=o.length,u=i.length,p=a.length,d=o.length+s.length+l.length,h=i.length+a.length,f=d*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,y=h*Uint32Array.BYTES_PER_ELEMENT,g=Se._malloc(f),v=new Float32Array(Se.HEAPF32.buffer,g,d),O=new Uint32Array(Se.HEAPU32.buffer,g+m,h);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),O.set(i,0),O.set(a,i.length);let P;e?.scaleBaked?.some(T=>T!==1)&&(P=new CI().makeScale(...e.scaleBaked)),t&&(P?P.premultiply(t):P=t);let S=P?Se.alloc_subdivision_surface2(g,c,g+m,u,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p,P.elements):Se.alloc_subdivision_surface(g,c,g+m,u,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p);return Se._free(g),S}static buildLevel(e,t,o,i,a){let s=a?Se.get_mesh_data2(e,t?Se.Level.CONTROL:Se.Level.REFINED,o,a.elements):Se.get_mesh_data(e,t?Se.Level.CONTROL:Se.Level.REFINED,o),l=8,c=Se.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=Se.HEAPU32[c[p]>>2],h=Se.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let f=Se.HEAPU32[c[p]>>2],m=Se.HEAPF32.subarray(f>>2,(f>>2)+u[p]);p++;let y=Se.HEAPU32[c[p]>>2],g=Se.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=Se.HEAPU32[c[p]>>2],O=Se.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,i===void 0){let P=new of;if(P.setIndex(new nf(O,1)),P.setAttribute("position",new af(h,3)),P.setAttribute("normal",new af(m,3)),t){P.setAttribute("faceMap",new nf(g,1));let S=new Float32Array(m.length/3*4).fill(0);P.setAttribute("color",new _x(S,4))}return Se.free_mesh_data(s),P.userData.type="SubdivGeometry",P}i.getAttribute("position").copyArray(h),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,Se.free_mesh_data(s)}static freeSubdivPointer(e){Se.free_bvh(e),Se.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=Se.get_wireframe_data_for_base_level(e),a=4,s=Se.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),c=0,u=Se.HEAPU32[s[c]>>2],p=Se.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Se.HEAPU32[s[c]>>2],h=Se.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(t===void 0){let f=new of;f.setAttribute("position",new af(p,3));let m=new Float32Array(p.length);for(let y=0,g=p.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return f.setAttribute("color",new _x(m,3)),f.setIndex(new nf(h,1)),Se.free_wireframe_data_for_base_level(i),f}t.getAttribute("position").copyArray(p),t.attributes.position.needsUpdate=!0,Se.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||Se.set_destination_refinement_level(e,t);let a=o?Se.get_topological_data2(e,i?Se.Level.CONTROL:Se.Level.REFINED,o.elements):Se.get_topological_data(e,i?Se.Level.CONTROL:Se.Level.REFINED),s=6,l=Se.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=Se.HEAPU32[l[u]>>2],d=new Float32Array(Se.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let h=Se.HEAPU32[l[u]>>2],f=new Uint32Array(Se.HEAPU32.subarray(h>>2,(h>>2)+c[u]));u++;let m=Se.HEAPU32[l[u]>>2],y=new Uint8Array(Se.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Se.free_topological_data(a),{positions:d,indices:f,verticesPerFace:y}}};var Vx=["getX","getY","getZ"];function uf(n,r){let e={},t=r?r.count:n.count,o=0,i=[],a=[],s=1e4;for(let c=0;c<t;c++){let u=r?r.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(n[Vx[d]](u)*s)},`;if(p in e)i.push(e[p]);else{for(let d=0;d<3;d++)a.push(n[Vx[d]](u));e[p]=o,i.push(o),o++}}let l=[];for(let c=0;c<i.length;c+=3)i[c]===i[c+1]||i[c]===i[c+2]||i[c+1]===i[c+2]||l.push(i[c],i[c+1],i[c+2]);return{positions:a,triIndices:l}}var hu=new Ws,sf=new Ws,lf=new Ws,cf=new Ws;function df(n,r,e,t){let o=[],i=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/c;l=l.filter((h,f)=>Math.floor(f/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);n.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)n.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)n.push(l[d],l[d+1],0),o.push(p++);return i.push(p),{indices:o,verticesPerFace:i}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<r.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[r[s]*3+2]===a||n[r[s]*3+2]===0)&&l++,(n[r[s+1]*3+2]===a||n[r[s+1]*3+2]===0)&&l++,(n[r[s+2]*3+2]===a||n[r[s+2]*3+2]===0)&&l++,l===3)break}if(r[s+1]===r[s+3]&&r[s+2]===r[s+5]||r[s+0]===r[s+3]&&r[s+2]===r[s+4]){hu.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),sf.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),lf.set(n[r[s+4]*3],n[r[s+4]*3+1],n[r[s+4]*3+2]),cf.set(n[r[s+5]*3],n[r[s+5]*3+1],n[r[s+5]*3+2]),sf.sub(hu).normalize(),lf.sub(hu).normalize(),cf.sub(hu).normalize();let l=sf.cross(lf).dot(cf);Math.abs(l)>.005||t&&t.some((c,u)=>u%2===1?!1:s>=t[u]&&s<t[u+1])?(o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3):(o.push(r[s],r[s+1],r[s+4],r[s+5]),i.push(4),s+=6)}else o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<n.length;p+=3,d++)n[p+2]===0&&(l.push(d),u++),n[p+2]===a&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let p=c[0];c[0]=c[1],c[1]=p}l.reverse(),o.push(...l,...c),i.push(u,u)}return{indices:o,verticesPerFace:i}}var br={};o1(br,{calcBoolean:()=>_I,calcBooleanTopological:()=>EI,freeMeshSet:()=>VI,getMeshSet:()=>BI,hasOpenEdges:()=>LI,transformMeshSet:()=>RI});var II,zx=new Promise(n=>{II=n});import{Float32BufferAttribute as Gx,Sphere as NI}from"three";var Ne,Pa;zx.then(n=>Ne=n);function DI(n,r,e){let t,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:a}=uf(n.getAttribute("position"),o),s;if(r&&e){let{indices:l,verticesPerFace:c}=df(i,a,n);s=c.length,t=[];for(let u=0,p=0;u<s;u++){t.push(c[u]);for(let d=0;d<c[u];d++)t.push(l[p++])}}else{let l=a.length;t=Array(l+l/3),s=0;for(let c=0,u=0;u<t.length;)t[u++]=3,s++,t[u++]=a[c++],t[u++]=a[c++],t[u++]=a[c++]}return{positions:i,faceIndices:t,nFaces:s}}function jx(n){let r=n.length,e=r*Uint32Array.BYTES_PER_ELEMENT,t=r*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:t,i=Ne._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Ne.HEAPU32.buffer,i,r):new Float32Array(Ne.HEAPF32.buffer,i,r)).set(n,0),i}function Fx(n){switch(n){case 0:return Ne.OP.UNION;case 1:return Ne.OP.INTERSECTION;case 2:return Ne.OP.A_MINUS_B;case 3:return Ne.OP.B_MINUS_A;case 4:return Ne.OP.SYMMETRIC_DIFFERENCE;case 5:return Ne.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function EI(n,r){Pa===void 0&&(Pa=Ne.init_csg());let e=jx(n),t=Ne.csg_calc_topological(Pa,e,n.length,Fx(r));Ne._free(e);let o=6,i=Ne.HEAPU32.subarray(t>>2,(t>>2)+o),a=i.subarray(3,3+3),s=0,l=Ne.HEAPU32[i[s]>>2],c=new Float32Array(Ne.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ne.HEAPU32[i[s]>>2],p=new Uint32Array(Ne.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Ne.HEAPU32[i[s]>>2],h=new Uint8Array(Ne.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Ne.free_mesh_data(t),{positions:c,indices:p,verticesPerFace:h}}function _I(n,r,e,t){Pa===void 0&&(Pa=Ne.init_csg());let o=jx(n),i=Ne.csg_calc(Pa,o,n.length,t,Fx(r));Ne._free(o);let a=5,s=Ne.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),c=0,u=Ne.HEAPU32[s[c]>>2],p=Ne.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Ne.HEAPU32[s[c]>>2],h=Ne.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let f=l[c];e.setAttribute("position",new Gx(p,3)),e.setAttribute("normal",new Gx(h,3));let m=Ne.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new NI),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Ne.free_mesh_data(i),f}function BI(n,r,e){if(Ne===void 0)return-1;let t,o,i;if(r&&n.userData.positions!==void 0){let g=n.userData;i=g.verticesPerFace.length,t=g.positions,o=Array(g.verticesPerFace.reduce((v,O)=>v+O,0)+i);for(let v=0,O=0,P=0;v<g.verticesPerFace.length;v++){o[P++]=g.verticesPerFace[v];for(let S=0;S<g.verticesPerFace[v];S++)o[P++]=g.indices[O++]}}else({positions:t,faceIndices:o,nFaces:i}=DI(n,r,e));let a=t.length,s=o.length,l=t.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,h=Ne._malloc(u),f=new Float32Array(Ne.HEAPF32.buffer,h,l),m=new Uint32Array(Ne.HEAPU32.buffer,h+p,c);f.set(t,0),m.set(o,0);let y=Ne.get_csg_mesh(h,a,h+p,s,i);return Ne._free(h),y}function LI(n){return Ne.has_open_edges(n)}function RI(n,r){Ne.transform_csg_mesh(n,r.elements)}function VI(n){Ne.free_csg_mesh(n)}var zI={ConeGeometry:v0,CubeGeometry:S0,CylinderGeometry:b0,DodecahedronGeometry:w0,EllipseGeometry:ma,HelixGeometry:rx,IcosahedronGeometry:ox,LatheGeometry:nx,NonParametricGeometry:hx,PolygonGeometry:lu,PyramidGeometry:mx,RectangleGeometry:ba,SphereGeometry:gx,PlaneGeometry:xx,BackdropGeometry:bx,StarGeometry:cu,TextFrameGeometry:vx,TorusGeometry:Sx,TorusKnotGeometry:wx,TriangleGeometry:Px,PathGeometry:Ax,VectorGeometry:Jt},rf=n=>zI[n.type].create(n);function Oa(n){return n!==null&&"booleanOp"in n}var Ca=class extends sa(jI){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new GI}updateVisible(e){super.updateVisible(e),this.visible=!Oa(this.parent)&&this.visible,Oa(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(br.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Oa(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Ca&&(e.freeBooleanPointer(),Oa(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let o=super.updateTransformState(e,t);return o&&Oa(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Oa(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var mu=new FI;function qs(n,r=0,e=n.count,t,o){let i=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=r;p<e;p++){let d=n.getX(p),h=n.getY(p),f=n.getZ(p);d<i&&(i=d),h<a&&(a=h),f<s&&(s=f),d>l&&(l=d),h>c&&(c=h),f>u&&(u=f)}mu.min.set(i,a,s),mu.max.set(l,c,u),mu.getCenter(t),mu.getSize(o).multiplyScalar(.5)}var HI=new UI,WI=new kI,Pt=class extends Ca{constructor(r,e){super(HI,WI),this.super_Entity(r,e)}updateState(r,e){this.updateState_Entity(r,e)}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?qs(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};import{Box3 as a3,Matrix4 as s3,Sphere as Ib,Vector3 as l3}from"three";import{BufferAttribute as o3,Float32BufferAttribute as Mb,MathUtils as Gf,Vector3 as jf}from"three";import{ShaderMaterial as FN}from"three";import{CubeReflectionMapping as oN,CubeRefractionMapping as nN,CubeUVReflectionMapping as iN,LinearEncoding as Qx,sRGBEncoding as aN}from"three";var $s=class{constructor(r){r=r??{},this.name=r.name,this.type=r.type,this.node=r.node,this.size=r.size,this.needsUpdate=r.needsUpdate}get value(){return this.node.value}set value(r){this.node.value=r}};import{MathUtils as qI}from"three";var Nt=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=qI.generateUUID(),this.type=r,this.name=""}analyze(r,e){e=e??{},r.analyzing=!0,this.build(r.addFlow(e.slot,e.cache,e.context),"v4"),r.clearVertexNodeCode(),r.clearFragmentNodeCode(),r.removeFlow(),r.analyzing=!1}analyzeAndFlow(r,e,t){return t=t??{},this.analyze(r,t),this.flow(r,e,t)}flow(r,e,t){t=t??{},r.addFlow(t.slot,t.cache,t.context);let o={result:this.build(r,e),code:r.clearNodeCode(),extra:r.context.extra};return r.removeFlow(),o}build(r,e,t){e=e??this.getType(r,e);let o=r.getNodeData(t??this);return r.analyzing&&this.appendDepsNode(r,o,e),r.nodes.indexOf(this)===-1&&r.nodes.push(this),this.updateFrame!==void 0&&r.updaters.indexOf(this)===-1&&r.updaters.push(this),this.generate(r,e,t)}updateFrame(r){}generateReadonly(r,e,t,o,i,a){return""}generate(r,e,t,o,i){return""}parse(r,e,t,o){}appendDepsNode(r,e,t){e.deps=(e.deps||0)+1;let o=r.getTypeLength(t);(o>(e.outputMax||0)||this.getType(r,t))&&(e.outputMax=o,e.output=t)}setName(r){this.name=r}getName(){return this.name}getType(r,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let r="{",e,t;for(e in this)t=this[e],t instanceof Nt&&(r+='"'+e+'":'+t.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)e=this.hashProperties[o],t=this[e],r+='"'+e+'":"'+String(t)+'",';return r+='"id":"'+this.uuid+'"}',r}};var pf=class{constructor(){this.nodes={};this.keywords={}}add(r){this.nodes[r.name]=r}addKeyword(r,e,t){t=t!==void 0?t:!0,this.keywords[r]={callback:e,cache:t}}remove(r){delete this.nodes[r.name]}removeKeyword(r){delete this.keywords[r]}get(r){return this.nodes[r]}getKeyword(r,e){return this.keywords[r].callback(e)}getKeywordData(r){return this.keywords[r]}contains(r){return this.nodes[r]!==void 0}containsKeyword(r){return this.keywords[r]!==void 0}},Ot=new pf;import{Vector2 as Ux}from"three";import{MathUtils as $I}from"three";var ye=class extends Nt{constructor(e,t){super(e);this.scope="";t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,o,i){if(t=t??this.getType(e),this.getShared(e,t)){let a=this.getUnique(e,t);a&&this.uuid===void 0&&(this.uuid=$I.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,t),this.generate(e,t,o)):super.build(e,t,o);if(a)return s.name=s.name||super.build(e,t,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,t,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,t);{c=super.generate(e,t,o,s.output,i);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,t)}}return super.build(e,t,o)}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 o=e.getVars()[t];return o?o.name:void 0}generate(e,t,o,i,a){return this.getShared(e,t)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),a,this.getLabel()).name}};var qe=class extends ye{constructor(e,t){t=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}generate(e,t,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,t)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,t))}};var it=class extends qe{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof Ux?e:new Ux(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,o,i,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}};import{Vector3 as kx}from"three";var Vt=class extends qe{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof kx?e:new kx(e,t,o)}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,o,i,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}};import{Color as YI}from"three";var Ct=class extends YI{constructor(e,t,o,i){super(e,t,o);this.isColorA=!0;this.a=i}setRGBA(e,t,o,i){super.setRGB(e,t,o),this.a=i}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)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let i,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(i[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(i[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}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}};var er=class extends qe{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ct?e:new Ct(e.r,e.g,e.b,e.a)}generateReadonly(e,t,o,i,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}};var XI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Hx=/[a-z_0-9]+/gi,re=class extends ye{constructor(e,t,o,i,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,t,o,i)}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,o,i,a){let s,l=0,c=this.src;if(this.includes)for(let p=0;p<this.includes.length;p++)e.include(this.includes[p],this);for(let p in this.extensions)e.extensions[p]=!0;let u=[];for(;s=Hx.exec(this.src);)u.push(s);for(let p=0;p<u.length;p++){let d=u[p],h=d[0],f=this.isMethod?!this.getInputByName(h):!0,m=h;if(this.keywords[h]||this.useKeywords&&f&&Ot.containsKeyword(h)){let y=this.keywords[h];if(!y){let g=Ot.getKeywordData(h);g.cache&&(y=e.keywords[h]),y=y||Ot.getKeyword(h,e),g.cache&&(e.keywords[h]=y)}m=y.build(e)}h!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+h.length+l),l+=m.length-h.length),this.getIncludeByName(m)===void 0&&Ot.contains(m)&&e.include(Ot.get(m))}return t==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),t)}parse(e,t,o,i){if(this.src=e||"",this.includes=t??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let a=XI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Hx);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let p=s[l++];this.inputs.push({name:p,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var KI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,ff=class extends ye{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||ff.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,o,i,a){this.src=e||"";let s,l,c="",u=KI.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}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,o,i,a){return e.format(this.name,this.getType(e),t)}},je=ff;je.PI="PI",je.PI2="PI2",je.RECIPROCAL_PI="RECIPROCAL_PI",je.RECIPROCAL_PI2="RECIPROCAL_PI2",je.LOG2="LOG2",je.EPSILON="EPSILON";var QI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
5
+ )*?)}`,"gim"),ZI=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Ta=class extends ye{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,o,i,a){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=QI.exec(e);if(t){let o=t[2],i;for(;i=ZI.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}};var Aa=class extends ye{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",i=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(i,this.getType(e),t)}};Ot.addKeyword("uv",function(){return new Aa});Ot.addKeyword("uv2",function(){return new Aa(1)});import{LinearEncoding as JI,sRGBEncoding as eN}from"three";var Wn=class extends ye{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??Wn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case JI:return["Linear"];case eN:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),i=this.getType(e),a=Wn.Nodes[this.method],s=e.include(a);if(s===Wn.LINEAR_TO_LINEAR)return e.format(o,i,t);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",i,t)}else return e.format(s+"( "+o+" )",i,t)}fromEncoding(e){let t=Wn.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Wn.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},qt=Wn;qt.Nodes={LinearToLinear:new re(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
6
6
  `)),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(`
7
7
  `)),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(`
8
- `))},qt.LINEAR_TO_LINEAR="LinearToLinear",qt.SRGB_TO_LINEAR="sRGBToLinear",qt.LINEAR_TO_SRGB="LinearTosRGB";var Ue=class extends re{constructor(e="",t,o,i,a){super(e,a,i,o,t);this.nodeType="Expression"}};import{Texture as JI}from"three";var $t=class extends qe{constructor(e=new JI,t,o,i){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t??new Ma,this.bias=o,this.project=i!==void 0?i:!1}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){if(t==="sampler2D")return this.getTexture(e,t);let o=this.getTexture(e,t),i=this.uv.build(e,this.project?"v4":"v2"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s,l;this.project?s="texture2DProj":s=a?"tex2DBias":"tex2D",a?l=s+"( "+o+", "+i+", "+a+" )":l=s+"( "+o+", "+i+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new qt(new Ue("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,u),e.removeContext(),e.format(l,u,t)}};var se=class extends qe{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,t,o,i,a,s){return e.format(this.value+(this.value%1?"":".0"),i,t)}};var Xs=class extends ye{constructor(e,t){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=t??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,o,i,a){i=this.getType(e);let s=this.value,l=s.build(e,t)+"( ",c=[];if(s.inputs){for(let u=0;u<s.inputs.length;u++){let p=s.inputs[u],d=this.inputs[u]||this.inputs[p.name];c.push(d.build(e,e.getTypeByFormat(p.type)))}l+=c.join(", ")+" )"}return e.format(l,i,t)}};var mf=class extends ye{constructor(e,t,o=mf.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=t,this.op=o}getType(e){let t=this.a.getType(e),o=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(o)>e.getTypeLength(t)?o:t}generate(e,t){let o=this.getType(e);this.type=o;let i=this.a.build(e,o),a=this.b.build(e,o);return e.format("( "+i+" "+this.op+" "+a+" )",o,t)}},Dt=mf;Dt.ADD="+",Dt.SUB="-",Dt.MUL="*",Dt.DIV="/";var $e=class extends ye{constructor(e,t=$e.ABS,o,i){super();this.nodeType="Math";this.a=e,typeof t!="string"?this.b=t:i=t,typeof o!="string"?this.c=o:i=o,this.method=i,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case $e.MIX:case $e.CLAMP:case $e.REFRACT:case $e.SMOOTHSTEP:case $e.FACEFORWARD:return 3;case $e.MIN:case $e.MAX:case $e.MOD:case $e.STEP:case $e.REFLECT:case $e.DISTANCE:case $e.DOT:case $e.CROSS:case $e.POW:return 2;default:return 1}}getInputType(e){let t=e.getTypeLength(this.a.getType(e)),o=this.b?e.getTypeLength(this.b.getType(e)):0,i=this.c?e.getTypeLength(this.c.getType(e)):0;return t>o&&t>i?this.a.getType(e):o>i?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case $e.LENGTH:case $e.DISTANCE:case $e.DOT:return"f";case $e.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let o,i,a,s=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,u=this.getInputType(e),p=this.getType(e);switch(this.type=p,this.method){case $e.NEGATE:return e.format("( -"+this.a.build(e,u)+" )",u,t);case $e.INVERT:return e.format("( 1.0 - "+this.a.build(e,u)+" )",u,t);case $e.CROSS:o=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case $e.STEP:o=this.a.build(e,s===1?"f":u),i=this.b.build(e,u);break;case $e.MIN:case $e.MAX:case $e.MOD:o=this.a.build(e,u),i=this.b.build(e,l===1?"f":u);break;case $e.REFRACT:o=this.a.build(e,u),i=this.b.build(e,u),a=this.c.build(e,"f");break;case $e.MIX:o=this.a.build(e,u),i=this.b.build(e,u),a=this.c.build(e,c===1?"f":u);break;default:o=this.a.build(e,u),this.b&&(i=this.b.build(e,u)),this.c&&(a=this.c.build(e,u));break}let d=[];d.push(o),i&&d.push(i),a&&d.push(a);let h=this.getNumInputs(e);if(d.length!==h)throw Error(`Arguments not match used in "${this.method}". Require ${h}, currently ${d.length}.`);return e.format(this.method+"( "+d.join(", ")+" )",p,t)}},Oe=$e;Oe.RAD="radians",Oe.DEG="degrees",Oe.EXP="exp",Oe.EXP2="exp2",Oe.LOG="log",Oe.LOG2="log2",Oe.SQRT="sqrt",Oe.INV_SQRT="inversesqrt",Oe.FLOOR="floor",Oe.CEIL="ceil",Oe.NORMALIZE="normalize",Oe.FRACT="fract",Oe.SATURATE="saturate",Oe.SIN="sin",Oe.COS="cos",Oe.TAN="tan",Oe.ASIN="asin",Oe.ACOS="acos",Oe.ARCTAN="atan",Oe.ABS="abs",Oe.SIGN="sign",Oe.LENGTH="length",Oe.NEGATE="negate",Oe.INVERT="invert",Oe.MIN="min",Oe.MAX="max",Oe.MOD="mod",Oe.STEP="step",Oe.REFLECT="reflect",Oe.DISTANCE="distance",Oe.DOT="dot",Oe.CROSS="cross",Oe.POW="pow",Oe.MIX="mix",Oe.CLAMP="clamp",Oe.REFRACT="refract",Oe.SMOOTHSTEP="smoothstep",Oe.FACEFORWARD="faceforward";var Ia=class extends ye{constructor(e,t,o){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=t,this.bias=o}bilinearCubeUV(e,t,o,i){let a=new Xs(Ia.Nodes.bilinearCubeUV,[t,o,i]);this.colorSpaceTL=this.colorSpaceTL??new qt(new Ue("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new qt(new Ue("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new qt(new Ue("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new qt(new Ue("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(a.build(e)+".br");let s={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(s),this.colorSpaceTLExp=new Ue(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Ue(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Ue(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Ue(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new Ue("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=a,l}generate(e,t){if(e.isShader("fragment")){let o=this.uv,i=this.bias||e.context.roughness,a=new Xs(Ia.Nodes.roughnessToMip,[i]),s=new Oe(a,Ia.Nodes.m0,Ia.Nodes.cubeUV_maxMipLevel,Oe.CLAMP),l=new Oe(s,Oe.FLOOR),c=new Oe(s,Oe.FRACT),u=this.bilinearCubeUV(e,this.value,o,l),p=this.bilinearCubeUV(e,this.value,o,new Dt(l,new se(1).setReadonly(!0),Dt.ADD)),d=new Oe(u,p,c,Oe.MIX);return e.format(d.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)}},Na=Ia;Na.Nodes=function(){let e=new Aa(`struct TextureCubeUVData {
8
+ `))},qt.LINEAR_TO_LINEAR="LinearToLinear",qt.SRGB_TO_LINEAR="sRGBToLinear",qt.LINEAR_TO_SRGB="LinearTosRGB";var Ue=class extends re{constructor(e="",t,o,i,a){super(e,a,i,o,t);this.nodeType="Expression"}};import{Texture as tN}from"three";var $t=class extends qe{constructor(e=new tN,t,o,i){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t??new Aa,this.bias=o,this.project=i!==void 0?i:!1}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){if(t==="sampler2D")return this.getTexture(e,t);let o=this.getTexture(e,t),i=this.uv.build(e,this.project?"v4":"v2"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s,l;this.project?s="texture2DProj":s=a?"tex2DBias":"tex2D",a?l=s+"( "+o+", "+i+", "+a+" )":l=s+"( "+o+", "+i+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new qt(new Ue("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,u),e.removeContext(),e.format(l,u,t)}};var se=class extends qe{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,t,o,i,a,s){return e.format(this.value+(this.value%1?"":".0"),i,t)}};var Ys=class extends ye{constructor(e,t){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=t??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,o,i,a){i=this.getType(e);let s=this.value,l=s.build(e,t)+"( ",c=[];if(s.inputs){for(let u=0;u<s.inputs.length;u++){let p=s.inputs[u],d=this.inputs[u]||this.inputs[p.name];c.push(d.build(e,e.getTypeByFormat(p.type)))}l+=c.join(", ")+" )"}return e.format(l,i,t)}};var hf=class extends ye{constructor(e,t,o=hf.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=t,this.op=o}getType(e){let t=this.a.getType(e),o=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(o)>e.getTypeLength(t)?o:t}generate(e,t){let o=this.getType(e);this.type=o;let i=this.a.build(e,o),a=this.b.build(e,o);return e.format("( "+i+" "+this.op+" "+a+" )",o,t)}},Dt=hf;Dt.ADD="+",Dt.SUB="-",Dt.MUL="*",Dt.DIV="/";var $e=class extends ye{constructor(e,t=$e.ABS,o,i){super();this.nodeType="Math";this.a=e,typeof t!="string"?this.b=t:i=t,typeof o!="string"?this.c=o:i=o,this.method=i,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case $e.MIX:case $e.CLAMP:case $e.REFRACT:case $e.SMOOTHSTEP:case $e.FACEFORWARD:return 3;case $e.MIN:case $e.MAX:case $e.MOD:case $e.STEP:case $e.REFLECT:case $e.DISTANCE:case $e.DOT:case $e.CROSS:case $e.POW:return 2;default:return 1}}getInputType(e){let t=e.getTypeLength(this.a.getType(e)),o=this.b?e.getTypeLength(this.b.getType(e)):0,i=this.c?e.getTypeLength(this.c.getType(e)):0;return t>o&&t>i?this.a.getType(e):o>i?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case $e.LENGTH:case $e.DISTANCE:case $e.DOT:return"f";case $e.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let o,i,a,s=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,u=this.getInputType(e),p=this.getType(e);switch(this.type=p,this.method){case $e.NEGATE:return e.format("( -"+this.a.build(e,u)+" )",u,t);case $e.INVERT:return e.format("( 1.0 - "+this.a.build(e,u)+" )",u,t);case $e.CROSS:o=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case $e.STEP:o=this.a.build(e,s===1?"f":u),i=this.b.build(e,u);break;case $e.MIN:case $e.MAX:case $e.MOD:o=this.a.build(e,u),i=this.b.build(e,l===1?"f":u);break;case $e.REFRACT:o=this.a.build(e,u),i=this.b.build(e,u),a=this.c.build(e,"f");break;case $e.MIX:o=this.a.build(e,u),i=this.b.build(e,u),a=this.c.build(e,c===1?"f":u);break;default:o=this.a.build(e,u),this.b&&(i=this.b.build(e,u)),this.c&&(a=this.c.build(e,u));break}let d=[];d.push(o),i&&d.push(i),a&&d.push(a);let h=this.getNumInputs(e);if(d.length!==h)throw Error(`Arguments not match used in "${this.method}". Require ${h}, currently ${d.length}.`);return e.format(this.method+"( "+d.join(", ")+" )",p,t)}},Oe=$e;Oe.RAD="radians",Oe.DEG="degrees",Oe.EXP="exp",Oe.EXP2="exp2",Oe.LOG="log",Oe.LOG2="log2",Oe.SQRT="sqrt",Oe.INV_SQRT="inversesqrt",Oe.FLOOR="floor",Oe.CEIL="ceil",Oe.NORMALIZE="normalize",Oe.FRACT="fract",Oe.SATURATE="saturate",Oe.SIN="sin",Oe.COS="cos",Oe.TAN="tan",Oe.ASIN="asin",Oe.ACOS="acos",Oe.ARCTAN="atan",Oe.ABS="abs",Oe.SIGN="sign",Oe.LENGTH="length",Oe.NEGATE="negate",Oe.INVERT="invert",Oe.MIN="min",Oe.MAX="max",Oe.MOD="mod",Oe.STEP="step",Oe.REFLECT="reflect",Oe.DISTANCE="distance",Oe.DOT="dot",Oe.CROSS="cross",Oe.POW="pow",Oe.MIX="mix",Oe.CLAMP="clamp",Oe.REFRACT="refract",Oe.SMOOTHSTEP="smoothstep",Oe.FACEFORWARD="faceforward";var Ma=class extends ye{constructor(e,t,o){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=t,this.bias=o}bilinearCubeUV(e,t,o,i){let a=new Ys(Ma.Nodes.bilinearCubeUV,[t,o,i]);this.colorSpaceTL=this.colorSpaceTL??new qt(new Ue("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new qt(new Ue("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new qt(new Ue("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new qt(new Ue("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(a.build(e)+".br");let s={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(s),this.colorSpaceTLExp=new Ue(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Ue(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Ue(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Ue(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new Ue("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=a,l}generate(e,t){if(e.isShader("fragment")){let o=this.uv,i=this.bias||e.context.roughness,a=new Ys(Ma.Nodes.roughnessToMip,[i]),s=new Oe(a,Ma.Nodes.m0,Ma.Nodes.cubeUV_maxMipLevel,Oe.CLAMP),l=new Oe(s,Oe.FLOOR),c=new Oe(s,Oe.FRACT),u=this.bilinearCubeUV(e,this.value,o,l),p=this.bilinearCubeUV(e,this.value,o,new Dt(l,new se(1).setReadonly(!0),Dt.ADD)),d=new Oe(u,p,c,Oe.MIX);return e.format(d.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)}},Ia=Ma;Ia.Nodes=function(){let e=new Ta(`struct TextureCubeUVData {
9
9
  vec4 tl;
10
10
  vec4 tr;
11
11
  vec4 br;
@@ -84,7 +84,7 @@ var KS=Object.create;var Cl=Object.defineProperty;var QS=Object.getOwnPropertyDe
84
84
  mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
85
85
  }
86
86
  return mip;
87
- }`,_);return{bilinearCubeUV:c,roughnessToMip:D,m0:d,cubeUV_maxMipLevel:t}}();var $n=class extends ye{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??$n.VIEW}getShared(){return this.scope===$n.WORLD}build(e,t,o,i){let a=e.context[this.scope+"Normal"];return a?a.build(e,t,o,i):super.build(e,t,o)}generate(e,t,o,i,a){let s;switch(this.scope){case $n.VIEW:e.isShader("vertex")?s="transformedNormal":s="geometryNormal";break;case $n.LOCAL:e.isShader("vertex")?s="objectNormal":(e.requires.normal=!0,s="vObjectNormal");break;case $n.WORLD:e.isShader("vertex")?s="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,s="vWNormal");break}return e.format(s,this.getType(e),t)}},Et=$n;Et.LOCAL="local",Et.WORLD="world",Et.VIEW="view",Et.NORMAL="normal";Ct.addKeyword("viewNormal",function(){return new Et(Et.VIEW)});Ct.addKeyword("localNormal",function(){return new Et(Et.NORMAL)});Ct.addKeyword("worldNormal",function(){return new Et(Et.WORLD)});var no=class extends ye{constructor(e){super("v3");this.nodeType="Position";this.scope=e??no.LOCAL}getType(){switch(this.scope){case no.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case no.LOCAL:case no.WORLD:return!1}return!0}generate(e,t,o,i,a){let s;switch(this.scope){case no.LOCAL:e.isShader("vertex")?s="transformed":(e.requires.position=!0,s="vPosition");break;case no.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,s="vWPosition";break;case no.VIEW:s=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case no.PROJECTION:s=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(s,this.getType(),t)}},tr=no;tr.LOCAL="local",tr.WORLD="world",tr.VIEW="view",tr.PROJECTION="projection";Ct.addKeyword("position",function(){return new tr});Ct.addKeyword("worldPosition",function(){return new tr(tr.WORLD)});Ct.addKeyword("viewPosition",function(){return new tr(tr.VIEW)});var Vr=class extends ye{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??Vr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case Vr.SPHERE:return"v2"}return this.type}generate(e,t){let o=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case Vr.VECTOR:{let a=new Et(Et.VIEW),s=e.context.roughness,l=a.build(e,"v3"),c=new tr(tr.VIEW).build(e,"v3"),u=s?s.build(e,"f"):void 0,p=`reflect( -normalize( ${c} ), ${l} )`;u&&(p=`normalize( mix( ${p}, ${l}, ${u} * ${u} ) )`);let d=`inverseTransformDirection( ${p}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${d};`),i="reflectVec"):i=d;break}case Vr.CUBE:{let a=new Vr(Vr.VECTOR).build(e,"v3"),s="vec3( -"+a+".x, "+a+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${s};`),i="reflectCubeVec"):i=s;break}case Vr.SPHERE:{let s="normalize( ( viewMatrix * vec4( "+new Vr(Vr.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${s};`),i="reflectSphereVec"):i=s;break}}return e.format(i,this.getType(),t)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}},io=Vr;io.CUBE="cube",io.SPHERE="sphere",io.VECTOR="vector";var gu=class extends ye{constructor(e=new $t,t,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Na(this.value,t??new io(io.VECTOR),o),this.irradianceNode=new Na(this.value,new Et(Et.WORLD),new se(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))}};import{CubeTexture as eN}from"three";var xu=class extends qe{constructor(e=new eN,t,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t??new io,this.bias=o}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){if(t==="samplerCube")return this.getTexture(e,t);let o=this.getTexture(e,t),i=this.uv?.build(e,"v3"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s;a?s="texCubeBias( "+o+", "+i+", "+a+" )":s="texCube( "+o+", "+i+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new qt(new Ue("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(s),s=this.colorSpace.build(e,c),e.removeContext(),e.format(s,c,t)}};var H0=`
87
+ }`,_);return{bilinearCubeUV:c,roughnessToMip:D,m0:d,cubeUV_maxMipLevel:t}}();var qn=class extends ye{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??qn.VIEW}getShared(){return this.scope===qn.WORLD}build(e,t,o,i){let a=e.context[this.scope+"Normal"];return a?a.build(e,t,o,i):super.build(e,t,o)}generate(e,t,o,i,a){let s;switch(this.scope){case qn.VIEW:e.isShader("vertex")?s="transformedNormal":s="geometryNormal";break;case qn.LOCAL:e.isShader("vertex")?s="objectNormal":(e.requires.normal=!0,s="vObjectNormal");break;case qn.WORLD:e.isShader("vertex")?s="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,s="vWNormal");break}return e.format(s,this.getType(e),t)}},Et=qn;Et.LOCAL="local",Et.WORLD="world",Et.VIEW="view",Et.NORMAL="normal";Ot.addKeyword("viewNormal",function(){return new Et(Et.VIEW)});Ot.addKeyword("localNormal",function(){return new Et(Et.NORMAL)});Ot.addKeyword("worldNormal",function(){return new Et(Et.WORLD)});var no=class extends ye{constructor(e){super("v3");this.nodeType="Position";this.scope=e??no.LOCAL}getType(){switch(this.scope){case no.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case no.LOCAL:case no.WORLD:return!1}return!0}generate(e,t,o,i,a){let s;switch(this.scope){case no.LOCAL:e.isShader("vertex")?s="transformed":(e.requires.position=!0,s="vPosition");break;case no.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,s="vWPosition";break;case no.VIEW:s=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case no.PROJECTION:s=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(s,this.getType(),t)}},tr=no;tr.LOCAL="local",tr.WORLD="world",tr.VIEW="view",tr.PROJECTION="projection";Ot.addKeyword("position",function(){return new tr});Ot.addKeyword("worldPosition",function(){return new tr(tr.WORLD)});Ot.addKeyword("viewPosition",function(){return new tr(tr.VIEW)});var Vr=class extends ye{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??Vr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case Vr.SPHERE:return"v2"}return this.type}generate(e,t){let o=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case Vr.VECTOR:{let a=new Et(Et.VIEW),s=e.context.roughness,l=a.build(e,"v3"),c=new tr(tr.VIEW).build(e,"v3"),u=s?s.build(e,"f"):void 0,p=`reflect( -normalize( ${c} ), ${l} )`;u&&(p=`normalize( mix( ${p}, ${l}, ${u} * ${u} ) )`);let d=`inverseTransformDirection( ${p}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${d};`),i="reflectVec"):i=d;break}case Vr.CUBE:{let a=new Vr(Vr.VECTOR).build(e,"v3"),s="vec3( -"+a+".x, "+a+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${s};`),i="reflectCubeVec"):i=s;break}case Vr.SPHERE:{let s="normalize( ( viewMatrix * vec4( "+new Vr(Vr.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${s};`),i="reflectSphereVec"):i=s;break}}return e.format(i,this.getType(),t)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}},io=Vr;io.CUBE="cube",io.SPHERE="sphere",io.VECTOR="vector";var yu=class extends ye{constructor(e=new $t,t,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Ia(this.value,t??new io(io.VECTOR),o),this.irradianceNode=new Ia(this.value,new Et(Et.WORLD),new se(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))}};import{CubeTexture as rN}from"three";var gu=class extends qe{constructor(e=new rN,t,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t??new io,this.bias=o}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){if(t==="samplerCube")return this.getTexture(e,t);let o=this.getTexture(e,t),i=this.uv?.build(e,"v3"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s;a?s="texCubeBias( "+o+", "+i+", "+a+" )":s="texCube( "+o+", "+i+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new qt(new Ue("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(s),s=this.colorSpace.build(e,c),e.removeContext(),e.format(s,c,t)}};var Wx=`
88
88
  uniform int frameIndex;
89
89
  uniform vec2 resolution;
90
90
  uniform mat4 previousModelViewMatrix;
@@ -92,7 +92,7 @@ uniform mat4 previousProjectionMatrix;
92
92
 
93
93
  varying vec4 vCurrentPosition;
94
94
  varying vec4 vPreviousPosition;
95
- `,W0=`
95
+ `,qx=`
96
96
  layout(location = 1) out vec4 gVelocity;
97
97
 
98
98
  uniform int frameIndex;
@@ -134,7 +134,7 @@ float getNoiseInterleavedGradient(vec2 screenPos) {
134
134
  return fract(magic.z * fract(dot(screenPos, magic.xy)));
135
135
  }
136
136
 
137
- `,q0=`
137
+ `,$x=`
138
138
  // TODO: This could be generated CPU side and passed to the shader every frame
139
139
  const vec2 haltonSequence[16] = vec2[16](
140
140
  vec2( 0.000000,-0.333334),
@@ -171,7 +171,7 @@ vPreviousPosition.xy += OUTLINE_COMPENSATION;
171
171
  #endif
172
172
  gl_Position = currentPositionJittered;
173
173
 
174
- `,$0=`
174
+ `,Yx=`
175
175
  vec2 oldPos = vPreviousPosition.xy;
176
176
  oldPos /= vPreviousPosition.w;
177
177
  oldPos.xy = (oldPos.xy+1.)/2.0;
@@ -186,14 +186,14 @@ vec2 velocity = (newPos - oldPos);
186
186
  if (gl_FragColor.a <= 0.0) discard;
187
187
 
188
188
  gVelocity = vec4(velocity, 0.0, 1.0);
189
- `,Y0=`
189
+ `,Xx=`
190
190
  layout(location = 1) out vec4 gVelocity;
191
- `,X0=`
191
+ `,Kx=`
192
192
  // Discard fully transparent pixels
193
193
  if (gl_FragColor.a <= 0.0) discard;
194
194
 
195
195
  gVelocity = vec4(0.0, 0.0, 0.0, 1.0);
196
- `;var Q0=["x","y","z","w"],iN=["float","vec2","vec3","vec4"],aN={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},sN={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[]"},Da=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.needsJitter=!0;this.getIncludesCode=function(){function r(e,t){return e.deps.length-t.deps.length}return function(t,o){let i=this.getIncludes(t,o);if(!i)return"";let a="";i=i.sort(r);for(let s=0;s<i.length;s++)i[s].src&&(a+=i[s].src+`
196
+ `;var Zx=["x","y","z","w"],sN=["float","vec2","vec3","vec4"],lN={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},cN={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[]"},Na=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.needsJitter=!0;this.getIncludesCode=function(){function r(e,t){return e.deps.length-t.deps.length}return function(t,o){let i=this.getIncludes(t,o);if(!i)return"";let a="";i=i.sort(r);for(let s=0;s<i.length;s++)i[s].src&&(a+=i[s].src+`
197
197
  `);return a}}();this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.fragmentParsVariables={},this.vertexParsVariables={},this.requires={uv:[],color:[],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",`
198
198
  // NOTE: Include Spline's blending modes. This could be part of BlendNode
199
199
  #define SPE_BLENDING_NORMAL 0
@@ -231,20 +231,20 @@ layout(location = 1) out vec4 gVelocity;
231
231
  `),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
232
232
  accumAlpha += (1.0 - accumAlpha) * alpha;
233
233
  }`,""].join(`
234
- `)},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(r,e){this.addVertexParsCode(H0),this.addFragmentParsCode(W0),this.buildShader("vertex",r),this.buildShader("fragment",e);for(let t=0;t<this.requires.uv.length;t++)if(this.requires.uv[t]){let o=t>0?t+1:"";this.addVaryCode("varying vec2 vUv"+o+";"),t>0&&this.addVertexParsCode("attribute vec2 uv"+o+";"),this.addVertexFinalCode("vUv"+o+" = uv"+o+";")}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.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.needsJitter&&(this.addVertexFinalCode(q0),this.addFragmentFinalCode($0)),this}buildShader(r,e){this.resultCode[r]=e.build(this.setShader(r),"v4")}setMaterial(r,e){return this.defines={},this}addFlow(r,e,t){return this.addSlot(r).addCache(e).addContext(t)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(r){return this.cache=r??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(r){return this.context=Object.assign({},this.context,r),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(r){return this.slot=r||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(r,e){this.fragmentVariables[r]===void 0&&(this.addFragmentCode(`${e} ${r};`),this.fragmentVariables[r]="")}addFragmentParsVariable(r,e){this.fragmentParsVariables[r]===void 0&&(this.addFragmentParsCode(`${e} ${r};`),this.fragmentParsVariables[r]="")}addVertexParsVariable(r,e){this.vertexParsVariables[r]===void 0&&(this.addVertexParsCode(`${e} ${r};`),this.vertexParsVariables[r]="")}addVertexCode(r){this.addCode(r,"vertex")}addFragmentCode(r){this.addCode(r,"fragment")}addCode(r,e){this.code[e??this.shader]+=r+`
234
+ `)},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(r,e){this.addVertexParsCode(Wx),this.addFragmentParsCode(qx),this.buildShader("vertex",r),this.buildShader("fragment",e);for(let t=0;t<this.requires.uv.length;t++)if(this.requires.uv[t]){let o=t>0?t+1:"";this.addVaryCode("varying vec2 vUv"+o+";"),t>0&&this.addVertexParsCode("attribute vec2 uv"+o+";"),this.addVertexFinalCode("vUv"+o+" = uv"+o+";")}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.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.needsJitter&&(this.addVertexFinalCode($x),this.addFragmentFinalCode(Yx)),this}buildShader(r,e){this.resultCode[r]=e.build(this.setShader(r),"v4")}setMaterial(r,e){return this.defines={},this}addFlow(r,e,t){return this.addSlot(r).addCache(e).addContext(t)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(r){return this.cache=r??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(r){return this.context=Object.assign({},this.context,r),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(r){return this.slot=r||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(r,e){this.fragmentVariables[r]===void 0&&(this.addFragmentCode(`${e} ${r};`),this.fragmentVariables[r]="")}addFragmentParsVariable(r,e){this.fragmentParsVariables[r]===void 0&&(this.addFragmentParsCode(`${e} ${r};`),this.fragmentParsVariables[r]="")}addVertexParsVariable(r,e){this.vertexParsVariables[r]===void 0&&(this.addVertexParsCode(`${e} ${r};`),this.vertexParsVariables[r]="")}addVertexCode(r){this.addCode(r,"vertex")}addFragmentCode(r){this.addCode(r,"fragment")}addCode(r,e){this.code[e??this.shader]+=r+`
235
235
  `}addVertexNodeCode(r){this.addNodeCode(r,"vertex")}addFragmentNodeCode(r){this.addNodeCode(r,"fragment")}addNodeCode(r,e){this.nodeCode[e??this.shader]+=r+`
236
236
  `}clearNodeCode(r){r=r??this.shader;let e=this.nodeCode[r];return this.nodeCode[r]="",e}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(r){this.addFinalCode(r,"vertex")}addFragmentFinalCode(r){this.addFinalCode(r,"fragment")}addFinalCode(r,e){this.finalCode[e??this.shader]+=r+`
237
237
  `}addVertexParsCode(r){this.addParsCode(r,"vertex")}addFragmentParsCode(r){this.addParsCode(r,"fragment")}addParsCode(r,e){this.parsCode[e??this.shader]+=r+`
238
238
  `}addVaryCode(r){this.addVertexParsCode(r),this.addFragmentParsCode(r)}isCache(r){return this.caches.indexOf(r)!==-1}isSlot(r){return this.slots.indexOf(r)!==-1}define(r,e){this.defines[r]=e===void 0?1:e}require(r){this.requires[r]=!0}isDefined(r){return this.defines[r]!==void 0}getVar(r,e,t,o="varying",i="V",a=""){let s=this.getVars(o),l=s[r];if(!l){let c=s.length;l={name:t||"node"+i+c+(a?"_"+a:""),type:e},s.push(l),s[r]=l}return l}getTempVar(r,e,t,o){return this.getVar(r,e,t,this.shader,"T",o)}getAttribute(r,e){if(!this.attributes[r]){let t=this.getVar(r,e);this.addVertexParsCode("attribute "+e+" "+r+";"),this.addVertexFinalCode(t.name+" = "+r+";"),this.attributes[r]={varying:t,name:r,type:e}}return this.attributes[r]}getCode(r){return[this.prefixCode,this.parsCode[r],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[r],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[r],"uniform"),this.getIncludesCode("consts",r),this.getIncludesCode("structs",r),this.getIncludesCode("functions",r),"void main() {",this.getVarListCode(this.getVars(r)),this.code[r],this.resultCode[r],this.finalCode[r],"}"].join(`
239
239
  `)}getVarListCode(r,e){e=e??"";let t="";for(let o=0,i=r.length;o<i;++o){let a=r[o],s=a.type,l=a.name,c=a.size,u=this.getFormatByType(s);if(u===void 0)throw new Error("Node pars "+u+" not found.");u.includes("[]")?t+=e+" "+u.substring(0,u.length-2)+" "+l+`[${c}];
240
240
  `:t+=e+" "+u+" "+l+`;
241
- `}return t}getVars(r){return this.inputs.vars[r??this.shader]}getNodeData(r){let e=r instanceof it?r.uuid:r;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(r,e,t,o,i,a){if(e.includes("[]")){let s=this.inputs.arrayUniforms,l=s.list.length,c=new Ys({type:e,size:t.size,name:o||"nodeUA"+l+(a?"_"+a:""),node:t,needsUpdate:i});return s.list.push(c),s[r].push(c),s[r][c.name]=c,this.uniforms[c.name]=c,c}else{let s=this.inputs.uniforms,l=s.list.length,c=new Ys({type:e,name:o||"nodeU"+l+(a?"_"+a:""),node:t,needsUpdate:i});return s.list.push(c),s[r].push(c),s[r][c.name]=c,this.uniforms[c.name]=c,c}}createVertexUniform(r,e,t,o,i){return this.createUniform("vertex",r,e,t,o,i)}createFragmentUniform(r,e,t,o,i){return this.createUniform("fragment",r,e,t,o,i)}include(r,e,t){let o;if(r=typeof r=="string"?Ct.get(r):r,this.context.include===!1)return r.name;r instanceof re?o=this.includes.functions:r instanceof je?o=this.includes.consts:r instanceof Aa&&(o=this.includes.structs);let i=o[this.shader]=o[this.shader]||[];if(r){let a=i[r.name];if(a||(a=i[r.name]={node:r,deps:[]},i.push(a),a.src=r.build(this,"source")),r instanceof re&&e&&i[e.name]&&i[e.name].deps.indexOf(r)===-1&&(i[e.name].deps.push(r),r.includes?.length)){let s=0;do this.include(r.includes[s++],e);while(s<r.includes.length)}return t&&(a.src=t),r.name}else throw new Error("Include not found.")}colorToVectorProperties(r){return r.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(r){return r.replace(/c/g,"v3")}getIncludes(r,e){return this.includes[r][e||this.shader]}getConstructorFromLength(r){return iN[r-1]}isTypeMatrix(r){return/^m/.test(r)}getTypeLength(r){return r==="f"?1:parseInt(this.colorToVector(r).substr(1))}getTypeFromLength(r){return r===1?"f":"v"+r}findNode(...r){for(let e=0;e<arguments.length;e++){let t=r[e];if(t?.isNode)return t}}resolve(...r){for(let e=0;e<arguments.length;e++){let t=r[e];if(t!==void 0){if(t.isNode)return t;if(t.isTexture)switch(t.mapping){case tN:case rN:return new xu(t);case oN:return new gu(new $t(t));default:return new $t(t)}else{if(t.isVector2)return new at(t);if(t.isVector3)return new Vt(t);if(t.isVector4)return new er(t)}}}}format(r,e,t){switch(this.colorToVector(t+" <- "+e)){case"f <- v2":return r+".x";case"f <- v3":return r+".x";case"f <- v4":return r+".x";case"f <- i":case"f <- b":return"float( "+r+" )";case"v2 <- f":return"vec2( "+r+" )";case"v2 <- v3":return r+".xy";case"v2 <- v4":return r+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+r+" ) )";case"v3 <- f":return"vec3( "+r+" )";case"v3 <- v2":return"vec3( "+r+", 0.0 )";case"v3 <- v4":return r+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+r+" ) )";case"v4 <- f":return"vec4( "+r+" )";case"v4 <- v2":return"vec4( "+r+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+r+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+r+" ) )";case"i <- f":case"i <- b":return"int( "+r+" )";case"i <- v2":return"int( "+r+".x )";case"i <- v3":return"int( "+r+".x )";case"i <- v4":return"int( "+r+".x )";case"b <- f":return"( "+r+" != 0.0 )";case"b <- v2":return"( "+r+" != vec2( 0.0 ) )";case"b <- v3":return"( "+r+" != vec3( 0.0 ) )";case"b <- v4":return"( "+r+" != vec4( 0.0 ) )";case"b <- i":return"( "+r+" != 0 )"}return r}getTypeByFormat(r){return aN[r]||r}getFormatByType(r){return sN[r]||r}getUUID(r,e){return e=e!==void 0?e:!0,e&&this.cache&&(r=this.cache+"-"+r),r}getElementByIndex(r){return Q0[r]}getIndexByElement(r){return Q0.indexOf(r)}isShader(r){return this.shader===r}setShader(r){return this.shader=r,this}mergeDefines(r){for(let e in r)this.defines[e]=r[e];return this.defines}mergeUniform(r){for(let e in r)this.uniforms[e]=r[e];return this.uniforms}getTextureEncodingFromMap(r){let e;return r?r.isTexture&&(e=r.encoding):e=K0,e===K0&&this.context.gamma&&(e=nN),e}};import{Vector2 as Fr,Vector3 as lo,Vector4 as Ya}from"three";var He=class extends qe{constructor(e=0,t,o,i){super("c");this.nodeType="Color";this.value=e instanceof Tt?e:new Tt(e||0,t,o,i)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o),c=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let u=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${u};`)}return c?this.generateReadonly(e,t,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,t)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,t))}generateReadonly(e,t,o,i,a,s){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",i,t)}};var _e=class extends qe{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,t,o,i,a,s){return e.format(this.value.toString(),i,t)}};import{UniformsLib as pN,UniformsUtils as fN}from"three";var pt=class extends qe{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,t,o,i){return e.format(this.value?"true":"false",i,t)}};var zr=class extends qe{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)}};import{Vector3 as lN}from"three";var fn=class extends qe{};var bu=class extends fn{constructor(e){super("v3");this.image=e;this._value=new lN}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}};var Yn=class extends fn{constructor(e,t,o=1008){super("t");this.image=e;this.wrap=t;this.minFilter=o}get value(){return this.image.getTexture(this.wrap,this.minFilter)}};import{Matrix3 as cN}from"three";var Ea=class extends qe{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new cN}generateReadonly(e,t,o,i,a,s){return e.format("mat3("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};import{Matrix4 as uN}from"three";var zt=class extends qe{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new uN}generateReadonly(e,t,o,i,a,s){return e.format("mat4("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};import{MathUtils as dN,Matrix3 as J0}from"three";function Z0(n,r,e,t=0){n.setUvTransform(e[0],e[1],r[0],r[1],0,0,0).premultiply(new J0().makeRotation(t*dN.DEG2RAD))}var vu=class extends Ea{constructor(e,t,o=0){super(new J0);this.repeat=e;this.offset=t;this.rotation=o;Z0(this.value,e,t,o)}updateMatrix(){Z0(this.value,this.repeat,this.offset,this.rotation)}};import{Vector4 as eb}from"three";var Gr=class extends qe{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof eb?new Array(e).fill(t):new Array(e).fill(new eb(0))}};var _a=class extends ye{constructor(e,t,o,i){super("v3");this.nodeType="Blend";this.a=e,this.b=t,this.alpha=o,this.mode=i}generate(e,t){if(e.isShader("fragment")){let o=[];return o.push(this.a.build(e,"c")),o.push(this.b.build(e,"c")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),e.format("spe_blend("+o.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)}};var yf=class extends ye{constructor(e,t){super("v3");this.nodeType="CustomColor";this.color=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let o=e.include(yf.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.color.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Xn=yf;Xn.Nodes=function(){return{customColor:new re(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
241
+ `}return t}getVars(r){return this.inputs.vars[r??this.shader]}getNodeData(r){let e=r instanceof Nt?r.uuid:r;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(r,e,t,o,i,a){if(e.includes("[]")){let s=this.inputs.arrayUniforms,l=s.list.length,c=new $s({type:e,size:t.size,name:o||"nodeUA"+l+(a?"_"+a:""),node:t,needsUpdate:i});return s.list.push(c),s[r].push(c),s[r][c.name]=c,this.uniforms[c.name]=c,c}else{let s=this.inputs.uniforms,l=s.list.length,c=new $s({type:e,name:o||"nodeU"+l+(a?"_"+a:""),node:t,needsUpdate:i});return s.list.push(c),s[r].push(c),s[r][c.name]=c,this.uniforms[c.name]=c,c}}createVertexUniform(r,e,t,o,i){return this.createUniform("vertex",r,e,t,o,i)}createFragmentUniform(r,e,t,o,i){return this.createUniform("fragment",r,e,t,o,i)}include(r,e,t){let o;if(r=typeof r=="string"?Ot.get(r):r,this.context.include===!1)return r.name;r instanceof re?o=this.includes.functions:r instanceof je?o=this.includes.consts:r instanceof Ta&&(o=this.includes.structs);let i=o[this.shader]=o[this.shader]||[];if(r){let a=i[r.name];if(a||(a=i[r.name]={node:r,deps:[]},i.push(a),a.src=r.build(this,"source")),r instanceof re&&e&&i[e.name]&&i[e.name].deps.indexOf(r)===-1&&(i[e.name].deps.push(r),r.includes?.length)){let s=0;do this.include(r.includes[s++],e);while(s<r.includes.length)}return t&&(a.src=t),r.name}else throw new Error("Include not found.")}colorToVectorProperties(r){return r.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(r){return r.replace(/c/g,"v3")}getIncludes(r,e){return this.includes[r][e||this.shader]}getConstructorFromLength(r){return sN[r-1]}isTypeMatrix(r){return/^m/.test(r)}getTypeLength(r){return r==="f"?1:parseInt(this.colorToVector(r).substr(1))}getTypeFromLength(r){return r===1?"f":"v"+r}findNode(...r){for(let e=0;e<arguments.length;e++){let t=r[e];if(t?.isNode)return t}}resolve(...r){for(let e=0;e<arguments.length;e++){let t=r[e];if(t!==void 0){if(t.isNode)return t;if(t.isTexture)switch(t.mapping){case oN:case nN:return new gu(t);case iN:return new yu(new $t(t));default:return new $t(t)}else{if(t.isVector2)return new it(t);if(t.isVector3)return new Vt(t);if(t.isVector4)return new er(t)}}}}format(r,e,t){switch(this.colorToVector(t+" <- "+e)){case"f <- v2":return r+".x";case"f <- v3":return r+".x";case"f <- v4":return r+".x";case"f <- i":case"f <- b":return"float( "+r+" )";case"v2 <- f":return"vec2( "+r+" )";case"v2 <- v3":return r+".xy";case"v2 <- v4":return r+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+r+" ) )";case"v3 <- f":return"vec3( "+r+" )";case"v3 <- v2":return"vec3( "+r+", 0.0 )";case"v3 <- v4":return r+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+r+" ) )";case"v4 <- f":return"vec4( "+r+" )";case"v4 <- v2":return"vec4( "+r+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+r+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+r+" ) )";case"i <- f":case"i <- b":return"int( "+r+" )";case"i <- v2":return"int( "+r+".x )";case"i <- v3":return"int( "+r+".x )";case"i <- v4":return"int( "+r+".x )";case"b <- f":return"( "+r+" != 0.0 )";case"b <- v2":return"( "+r+" != vec2( 0.0 ) )";case"b <- v3":return"( "+r+" != vec3( 0.0 ) )";case"b <- v4":return"( "+r+" != vec4( 0.0 ) )";case"b <- i":return"( "+r+" != 0 )"}return r}getTypeByFormat(r){return lN[r]||r}getFormatByType(r){return cN[r]||r}getUUID(r,e){return e=e!==void 0?e:!0,e&&this.cache&&(r=this.cache+"-"+r),r}getElementByIndex(r){return Zx[r]}getIndexByElement(r){return Zx.indexOf(r)}isShader(r){return this.shader===r}setShader(r){return this.shader=r,this}mergeDefines(r){for(let e in r)this.defines[e]=r[e];return this.defines}mergeUniform(r){for(let e in r)this.uniforms[e]=r[e];return this.uniforms}getTextureEncodingFromMap(r){let e;return r?r.isTexture&&(e=r.encoding):e=Qx,e===Qx&&this.context.gamma&&(e=aN),e}};import{Vector2 as Fr,Vector3 as lo,Vector4 as $a}from"three";var He=class extends qe{constructor(e=0,t,o,i){super("c");this.nodeType="Color";this.value=e instanceof Ct?e:new Ct(e||0,t,o,i)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o),c=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let u=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${u};`)}return c?this.generateReadonly(e,t,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,t)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,t))}generateReadonly(e,t,o,i,a,s){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",i,t)}};var _e=class extends qe{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,t,o,i,a,s){return e.format(this.value.toString(),i,t)}};import{UniformsLib as hN,UniformsUtils as mN}from"three";var dt=class extends qe{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,t,o,i){return e.format(this.value?"true":"false",i,t)}};var zr=class extends qe{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)}};import{Vector3 as uN}from"three";var fn=class extends qe{};var xu=class extends fn{constructor(e){super("v3");this.image=e;this._value=new uN}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}};var $n=class extends fn{constructor(e,t,o=1008){super("t");this.image=e;this.wrap=t;this.minFilter=o}get value(){return this.image.getTexture(this.wrap,this.minFilter)}};import{Matrix3 as dN}from"three";var Da=class extends qe{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new dN}generateReadonly(e,t,o,i,a,s){return e.format("mat3("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};import{Matrix4 as pN}from"three";var zt=class extends qe{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new pN}generateReadonly(e,t,o,i,a,s){return e.format("mat4("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};import{MathUtils as fN,Matrix3 as eb}from"three";function Jx(n,r,e,t=0){n.setUvTransform(e[0],e[1],r[0],r[1],0,0,0).premultiply(new eb().makeRotation(t*fN.DEG2RAD))}var bu=class extends Da{constructor(e,t,o=0){super(new eb);this.repeat=e;this.offset=t;this.rotation=o;Jx(this.value,e,t,o)}updateMatrix(){Jx(this.value,this.repeat,this.offset,this.rotation)}};import{Vector4 as tb}from"three";var Gr=class extends qe{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof tb?new Array(e).fill(t):new Array(e).fill(new tb(0))}};var Ea=class extends ye{constructor(e,t,o,i){super("v3");this.nodeType="Blend";this.a=e,this.b=t,this.alpha=o,this.mode=i}generate(e,t){if(e.isShader("fragment")){let o=[];return o.push(this.a.build(e,"c")),o.push(this.b.build(e,"c")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),e.format("spe_blend("+o.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)}};var mf=class extends ye{constructor(e,t){super("v3");this.nodeType="CustomColor";this.color=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let o=e.include(mf.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.color.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Yn=mf;Yn.Nodes=function(){return{customColor:new re(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
242
242
  float lalpha = alpha * mask;
243
243
  calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
244
244
  accumAlpha += (1.0 - accumAlpha) * lalpha;
245
245
 
246
246
  return color;
247
- }`)}}();var gf=class extends ye{constructor(e,t){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let o=e.include(gf.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.cnormal.build(e,"v3")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.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)}},Ba=gf;Ba.Nodes=function(){return{customNormal:new re(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
247
+ }`)}}();var yf=class extends ye{constructor(e,t){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let o=e.include(yf.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.cnormal.build(e,"v3")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.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)}},_a=yf;_a.Nodes=function(){return{customNormal:new re(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
248
248
  vec3 normal = packNormalToRGB( norm ).rgb;
249
249
  normal *= step( vec3(0.5), cnormal );
250
250
 
@@ -253,7 +253,7 @@ layout(location = 1) out vec4 gVelocity;
253
253
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
254
254
 
255
255
  return normal;
256
- }`)}}();var La=class extends ye{constructor(e,t,o,i,a,s,l,c,u,p,d,h){super("v3");this.nodeType="CustomTexture";this.texture=e,this.textureSize=t,this.crop=o,this.projection=i,this.axis=a,this.side=s,this.size=l,this.blending=c,this.mat=u,this.isMask=h,this.alpha=p,this.mode=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){e.require("position"),e.require("normal"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let o=`g${this.uuid.toString().replace(/-/g,"")}`,i;switch(this.projection.value){case 3:i=e.include(La.Nodes.cylindrical);break;case 2:i=e.include(La.Nodes.spherical);break;case 1:let s=["vec3(1.0, 0.0, 0.0)","vec3(0.0, 1.0, 0.0)","vec3(0.0, 0.0, 1.0)"][this.axis.value],l=["zy","xz","xy"][this.axis.value],c=new re(`
256
+ }`)}}();var Ba=class extends ye{constructor(e,t,o,i,a,s,l,c,u,p,d,h){super("v3");this.nodeType="CustomTexture";this.texture=e,this.textureSize=t,this.crop=o,this.projection=i,this.axis=a,this.side=s,this.size=l,this.blending=c,this.mat=u,this.isMask=h,this.alpha=p,this.mode=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){e.require("position"),e.require("normal"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let o=`g${this.uuid.toString().replace(/-/g,"")}`,i;switch(this.projection.value){case 3:i=e.include(Ba.Nodes.cylindrical);break;case 2:i=e.include(Ba.Nodes.spherical);break;case 1:let s=["vec3(1.0, 0.0, 0.0)","vec3(0.0, 1.0, 0.0)","vec3(0.0, 0.0, 1.0)"][this.axis.value],l=["zy","xz","xy"][this.axis.value],c=new re(`
257
257
  vec3 ${o}_planarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
258
258
  vec2 projected = (1. + (position.${l})) / 2.;
259
259
  vec2 uvs = ( mat * vec3( (projected * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
@@ -277,7 +277,7 @@ layout(location = 1) out vec4 gVelocity;
277
277
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
278
278
 
279
279
  return col;
280
- }`);i=e.include(c);break;case 4:i=e.include(La.Nodes.triplanar);break;default:i=e.include(La.Nodes.uv);break}e.addFragmentVariable(this.calpha,"float");let a=[];if(a.push("normal"),a.push(this.texture.generate(e,"t")),a.push(this.textureSize.build(e,"v2")),a.push(this.crop.build(e,"f")),a.push(this.mat.build(e,"mat3")),a.push(this.size.build(e,"v2")),a.push(this.blending.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),this.projection.value===4){let s=`${o}_writeUvs`,l=s+"0",c=s+"1",u=s+"2",p=`${o}_triplanarWeights`;e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(c,"vec2"),e.addFragmentVariable(u,"vec2"),e.addFragmentVariable(p,"vec3"),a.push(l),a.push(c),a.push(u),a.push(p)}else{let s=`${o}_writeUvs`;e.addFragmentVariable(s,"vec2"),a.push(s)}return e.format(i+"("+a.join(",")+")",this.getType(e),t)}},hn=La;hn.Nodes=function(){let e=new re(`
280
+ }`);i=e.include(c);break;case 4:i=e.include(Ba.Nodes.triplanar);break;default:i=e.include(Ba.Nodes.uv);break}e.addFragmentVariable(this.calpha,"float");let a=[];if(a.push("normal"),a.push(this.texture.generate(e,"t")),a.push(this.textureSize.build(e,"v2")),a.push(this.crop.build(e,"f")),a.push(this.mat.build(e,"mat3")),a.push(this.size.build(e,"v2")),a.push(this.blending.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),this.projection.value===4){let s=`${o}_writeUvs`,l=s+"0",c=s+"1",u=s+"2",p=`${o}_triplanarWeights`;e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(c,"vec2"),e.addFragmentVariable(u,"vec2"),e.addFragmentVariable(p,"vec3"),a.push(l),a.push(c),a.push(u),a.push(p)}else{let s=`${o}_writeUvs`;e.addFragmentVariable(s,"vec2"),a.push(s)}return e.format(i+"("+a.join(",")+")",this.getType(e),t)}},hn=Ba;hn.Nodes=function(){let e=new re(`
281
281
  vec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
282
282
  vec3 posN = normalize(position);
283
283
  float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
@@ -432,7 +432,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
432
432
 
433
433
  return col;//n * 0.5 + 0.5;
434
434
  }
435
- `);return{cylindrical:e,spherical:t,uv:o,triplanar:i}}();var Ra=class extends ye{constructor(e,t,o,i,a,s,l,c,u,p,d,h){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=t,this.near=o,this.far=i,this.isVector=a,this.isWorldSpace=s,this.origin=l,this.direction=c,this.colors=u,this.steps=p,this.isMask=h,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let o=`g${this.uuid.toString().replace(/-/g,"")}`,i=new re(`vec3 ${o}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${o}_MAX_COLORS], float steps[${o}_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) {
435
+ `);return{cylindrical:e,spherical:t,uv:o,triplanar:i}}();var La=class extends ye{constructor(e,t,o,i,a,s,l,c,u,p,d,h){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=t,this.near=o,this.far=i,this.isVector=a,this.isWorldSpace=s,this.origin=l,this.direction=c,this.colors=u,this.steps=p,this.isMask=h,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let o=`g${this.uuid.toString().replace(/-/g,"")}`,i=new re(`vec3 ${o}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${o}_MAX_COLORS], float steps[${o}_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) {
436
436
  vec4 color = colors[0];
437
437
  #ifdef ${o}_IS_VECTOR
438
438
  #ifdef ${o}_LINEAR
@@ -472,7 +472,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
472
472
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
473
473
 
474
474
  return color.rgb;
475
- }`,[Ra.Nodes.vectorLinearWorldSpaceDepth,Ra.Nodes.vectorLinearObjectSpaceDepth,Ra.Nodes.vectorSphericalObjectSpaceDepth,Ra.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${o}_MAX_COLORS`,this.colors.value.length),this.smooth.value&&e.define(`${o}_SMOOTH`),this.isVector.value>.5&&e.define(`${o}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${o}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${o}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let a=e.include(i),s=[];return s.push(this.near.build(e,"f")),s.push(this.far.build(e,"f")),s.push(this.origin.build(e,"v3")),s.push(this.direction.build(e,"v3")),s.push(this.colors.build(e,"v4[]")),s.push(this.steps.build(e,"f[]")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(a+"("+s.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)}},Va=Ra;Va.Nodes=function(){let e=new re(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
475
+ }`,[La.Nodes.vectorLinearWorldSpaceDepth,La.Nodes.vectorLinearObjectSpaceDepth,La.Nodes.vectorSphericalObjectSpaceDepth,La.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${o}_MAX_COLORS`,this.colors.value.length),this.smooth.value&&e.define(`${o}_SMOOTH`),this.isVector.value>.5&&e.define(`${o}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${o}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${o}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let a=e.include(i),s=[];return s.push(this.near.build(e,"f")),s.push(this.far.build(e,"f")),s.push(this.origin.build(e,"v3")),s.push(this.direction.build(e,"v3")),s.push(this.colors.build(e,"v4[]")),s.push(this.steps.build(e,"f[]")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(a+"("+s.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)}},Ra=La;Ra.Nodes=function(){let e=new re(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
476
476
  vec3 n = normalize(direction);
477
477
  float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
478
478
  return ( dist - near ) / ( far - near );
@@ -486,7 +486,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
486
486
  }`),i=new re(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
487
487
  float dist = length(position - origin);
488
488
  return ( dist - near ) / ( far - near );
489
- }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:t,vectorSphericalWorldSpaceDepth:o,vectorSphericalObjectSpaceDepth:i}}();var Ks=class extends ye{constructor(e,t,o,i,a,s,l,c){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=t,this.scale=o,this.intensity=i,this.factor=a,this.isMask=c,this.alpha=s,this.mode=l,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 o=new re(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {
489
+ }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:t,vectorSphericalWorldSpaceDepth:o,vectorSphericalObjectSpaceDepth:i}}();var Xs=class extends ye{constructor(e,t,o,i,a,s,l,c){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=t,this.scale=o,this.intensity=i,this.factor=a,this.isMask=c,this.alpha=s,this.mode=l,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 o=new re(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {
490
490
  float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );
491
491
 
492
492
  float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;
@@ -494,7 +494,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
494
494
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
495
495
 
496
496
  return color;
497
- }`),i=e.include(o),a=[];return a.push(this.color.build(e,"c")),a.push(this.bias.build(e,"f")),a.push(this.scale.build(e,"f")),a.push(this.intensity.build(e,"f")),a.push(this.factor.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),e.format(i+"("+a.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)}};var xf=class extends ye{constructor(e,t,o,i,a,s,l,c,u){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=t,this.colors=o,this.steps=i,this.offset=a,this.morph=s,this.angle=l,this.isMask=u,this.alpha=c,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 o=e.include(xf.Nodes.gradient),i=[];return i.push(this.gradientType.build(e,"i")),i.push(this.smooth.build(e,"b")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.offset.build(e,"v2")),i.push(this.morph.build(e,"v2")),i.push(this.angle.build(e,"f")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.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)}},za=xf;za.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, bool isMask, float mask, float alpha, out float calpha) {
497
+ }`),i=e.include(o),a=[];return a.push(this.color.build(e,"c")),a.push(this.bias.build(e,"f")),a.push(this.scale.build(e,"f")),a.push(this.intensity.build(e,"f")),a.push(this.factor.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),e.format(i+"("+a.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)}};var gf=class extends ye{constructor(e,t,o,i,a,s,l,c,u){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=t,this.colors=o,this.steps=i,this.offset=a,this.morph=s,this.angle=l,this.isMask=u,this.alpha=c,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 o=e.include(gf.Nodes.gradient),i=[];return i.push(this.gradientType.build(e,"i")),i.push(this.smooth.build(e,"b")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.offset.build(e,"v2")),i.push(this.morph.build(e,"v2")),i.push(this.angle.build(e,"f")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.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)}},Va=gf;Va.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, bool isMask, float mask, float alpha, out float calpha) {
498
498
  vec4 color = colors[0];
499
499
  vec2 m = morph / vUv.xy;
500
500
  vec2 rot = vec2( 0.5 + m.x, m.y );
@@ -536,7 +536,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
536
536
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
537
537
 
538
538
  return color.xyz;
539
- }`)}}();var bf=class extends ye{constructor(e,t,o,i,a){super("v3");this.nodeType="Matcap";this.texture=e,this.isMask=i,this.alpha=t,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`,this.rotation=a}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(bf.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let i=[];return i.push(this.texture.generate(e,"t")),i.push("normal"),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),i.push(this.rotation.build(e,"f")),e.format(o+"("+i.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)}},Ga=bf;Ga.Nodes=function(){return{matcap:new re(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {
539
+ }`)}}();var xf=class extends ye{constructor(e,t,o,i,a){super("v3");this.nodeType="Matcap";this.texture=e,this.isMask=i,this.alpha=t,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`,this.rotation=a}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(xf.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let i=[];return i.push(this.texture.generate(e,"t")),i.push("normal"),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),i.push(this.rotation.build(e,"f")),e.format(o+"("+i.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)}},za=xf;za.Nodes=function(){return{matcap:new re(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {
540
540
  vec3 viewDir = normalize( vViewPosition );
541
541
  vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
542
542
  vec3 y = cross( viewDir, x );
@@ -550,7 +550,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
550
550
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
551
551
 
552
552
  return matcapColor.rgb;
553
- }`)}}();var Qs=(a=>(a.SIMPLEX="simplex3d",a.SIMPLEX_FRACTAL="simplex3dFractal",a.ASHIMA="simplexAshima",a.FBM="fbm",a.PERLIN="perlin",a.VORONOI="voronoi",a))(Qs||{}),_t=function(){let r=new re(`vec3 random3(vec3 c) {
553
+ }`)}}();var Ks=(a=>(a.SIMPLEX="simplex3d",a.SIMPLEX_FRACTAL="simplex3dFractal",a.ASHIMA="simplexAshima",a.FBM="fbm",a.PERLIN="perlin",a.VORONOI="voronoi",a))(Ks||{}),_t=function(){let r=new re(`vec3 random3(vec3 c) {
554
554
  float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
555
555
  vec3 r;
556
556
  r.z = fract(512.0*j);
@@ -903,7 +903,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
903
903
  return hashwithoutsine13(vec3(p + mb) + seed);
904
904
  }
905
905
  }
906
- `,[h,f,m,y,g,v]);return{simplex:e,simplexFractal:t,simplexAshima:a,fbm:u,perlin:d,voronoi:O}}();var ja=class extends ye{constructor(e,t,o,i,a,s,l,c,u,p,d,h,f,m,y,g,v,O,P){super("v3");this.nodeType="Noise";this.scale=e,this.size=t,this.move=o,this.fA=i,this.fB=a,this.distortion=s,this.colorA=l,this.colorB=c,this.colorC=u,this.colorD=p,this.noiseType=h,this.voronoiStyle=m,this.highCut=y,this.lowCut=g,this.smoothness=v,this.seed=O,this.quality=P,this.isMask=f,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t,o,i,a){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let s=Object.values(Qs)[this.noiseType.value],l=s=="voronoi"?`
906
+ `,[h,f,m,y,g,v]);return{simplex:e,simplexFractal:t,simplexAshima:a,fbm:u,perlin:d,voronoi:O}}();var Ga=class extends ye{constructor(e,t,o,i,a,s,l,c,u,p,d,h,f,m,y,g,v,O,P){super("v3");this.nodeType="Noise";this.scale=e,this.size=t,this.move=o,this.fA=i,this.fB=a,this.distortion=s,this.colorA=l,this.colorB=c,this.colorC=u,this.colorD=p,this.noiseType=h,this.voronoiStyle=m,this.highCut=y,this.lowCut=g,this.smoothness=v,this.seed=O,this.quality=P,this.isMask=f,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t,o,i,a){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let s=Object.values(Ks)[this.noiseType.value],l=s=="voronoi"?`
907
907
  float v = ${s}(st + move, voronoiStyle, smoothness, seed, quality);
908
908
 
909
909
  // Apply clipping to colors
@@ -940,7 +940,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
940
940
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
941
941
 
942
942
  return clamp(color, 0.0, 1.0).rgb;
943
- }`,[_t.simplex,_t.simplexFractal,_t.simplexAshima,_t.fbm,_t.perlin,_t.voronoi]),u=e.include(c),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.voronoiStyle.build(e,"i")),p.push(this.highCut.build(e,"f")),p.push(this.lowCut.build(e,"f")),p.push(this.smoothness.build(e,"f")),p.push(this.seed.build(e,"f")),p.push(this.quality.build(e,"i")),p.push(this.isMask.build(e,"b")),p.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),p.push(this.alpha.build(e,"f")),p.push(this.calpha),e.format(u+"("+p.join(",")+")",this.getType(e),t)}};ja.numOctaves=5;var vf=class extends ye{constructor(e,t,o,i,a,s,l,c,u,p,d,h,f,m,y,g){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=t,this.outlineWidth=o,this.contourWidth=i,this.contourThreshold=a,this.outlineThreshold=s,this.contourFrequency=l,this.outlineSmoothing=c,this.contourDirection=u,this.positionalLines=p,this.compensation=d,this.resolution=h,this.normalMap=f,this.depthMap=m,this.pixelRatio=y,this.alpha=g,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let o=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${o}_offset`),this.firstTime){let i=this.outlineWidth.build(e,"f"),a=this.resolution.build(e,"v2"),s=this.compensation.build(e,"b"),l=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(i,"uniform float"),e.addVertexParsVariable(a,"uniform vec2"),e.addVertexParsVariable(s,"uniform bool"),e.addVertexParsVariable(l,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
943
+ }`,[_t.simplex,_t.simplexFractal,_t.simplexAshima,_t.fbm,_t.perlin,_t.voronoi]),u=e.include(c),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.voronoiStyle.build(e,"i")),p.push(this.highCut.build(e,"f")),p.push(this.lowCut.build(e,"f")),p.push(this.smoothness.build(e,"f")),p.push(this.seed.build(e,"f")),p.push(this.quality.build(e,"i")),p.push(this.isMask.build(e,"b")),p.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),p.push(this.alpha.build(e,"f")),p.push(this.calpha),e.format(u+"("+p.join(",")+")",this.getType(e),t)}};Ga.numOctaves=5;var bf=class extends ye{constructor(e,t,o,i,a,s,l,c,u,p,d,h,f,m,y,g){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=t,this.outlineWidth=o,this.contourWidth=i,this.contourThreshold=a,this.outlineThreshold=s,this.contourFrequency=l,this.outlineSmoothing=c,this.contourDirection=u,this.positionalLines=p,this.compensation=d,this.resolution=h,this.normalMap=f,this.depthMap=m,this.pixelRatio=y,this.alpha=g,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let o=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${o}_offset`),this.firstTime){let i=this.outlineWidth.build(e,"f"),a=this.resolution.build(e,"v2"),s=this.compensation.build(e,"b"),l=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(i,"uniform float"),e.addVertexParsVariable(a,"uniform vec2"),e.addVertexParsVariable(s,"uniform bool"),e.addVertexParsVariable(l,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
944
944
  vID = randomColor.r;
945
945
  vec2 ${o}_offset = vec2(0.0);
946
946
  if (${s}) {
@@ -955,7 +955,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
955
955
  // if this offset is the biggest of all the potential offsets
956
956
  gl_Position = ${o}_clipPosition;
957
957
  }
958
- `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(vf.Nodes.outline),a=[];return a.push(this.outlineColor.build(e,"c")),a.push(this.contourColor.build(e,"c")),a.push(this.outlineWidth.build(e,"f")),a.push(this.contourWidth.build(e,"f")),a.push(this.contourThreshold.build(e,"f")),a.push(this.outlineThreshold.build(e,"f")),a.push(this.contourFrequency.build(e,"f")),a.push(this.outlineSmoothing.build(e,"f")),a.push(this.contourDirection.build(e,"v3")),a.push(this.positionalLines.build(e,"b")),a.push(this.resolution.build(e,"v2")),a.push(this.normalMap.getTexture(e,"t")),a.push(this.depthMap.getTexture(e,"t")),a.push(this.pixelRatio.build(e,"f")),a.push(this.compensation.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),this.firstTime=!this.firstTime,e.format(i+"("+a.join(",")+")",this.getType(e),t)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},Fa=vf;Fa.Nodes=function(){let e=new re(`
958
+ `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(bf.Nodes.outline),a=[];return a.push(this.outlineColor.build(e,"c")),a.push(this.contourColor.build(e,"c")),a.push(this.outlineWidth.build(e,"f")),a.push(this.contourWidth.build(e,"f")),a.push(this.contourThreshold.build(e,"f")),a.push(this.outlineThreshold.build(e,"f")),a.push(this.contourFrequency.build(e,"f")),a.push(this.outlineSmoothing.build(e,"f")),a.push(this.contourDirection.build(e,"v3")),a.push(this.positionalLines.build(e,"b")),a.push(this.resolution.build(e,"v2")),a.push(this.normalMap.getTexture(e,"t")),a.push(this.depthMap.getTexture(e,"t")),a.push(this.pixelRatio.build(e,"f")),a.push(this.compensation.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),this.firstTime=!this.firstTime,e.format(i+"("+a.join(",")+")",this.getType(e),t)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},ja=bf;ja.Nodes=function(){let e=new re(`
959
959
  float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)
960
960
  {
961
961
  vec2 halton = haltonSequence[frameIndex];
@@ -1190,7 +1190,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1190
1190
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
1191
1191
 
1192
1192
  return clamp(color, 0.0, 1.0).rgb;
1193
- }`,[s,a,ao.DrawFunctions.circle,ao.DrawFunctions.ring,ao.DrawFunctions.polygon,ao.DrawFunctions.cross,ao.DrawFunctions.diamond,ao.DrawFunctions.checkerboard,ao.DrawFunctions.line,ao.DrawFunctions.wave]),u=e.include(c),p=[];return p.push("normal"),p.push(this.blending.build(e,"f")),p.push(this.style.build(e,"i")),p.push(this.offset.build(e,"v2")),p.push(this.colorA.build(e,"v4")),p.push(this.colorB.build(e,"v4")),p.push(this.frequency.build(e,"v2")),p.push(this.size.build(e,"f")),p.push(this.variation.build(e,"f")),p.push(this.smoothness.build(e,"f")),p.push(this.zigzag.build(e,"f")),p.push(this.rotation.build(e,"f")),p.push(this.vertical.build(e,"v2")),p.push(this.horizontal.build(e,"v2")),p.push(this.sides.build(e,"i")),p.push(this.isMask.build(e,"b")),p.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),p.push(this.alpha.build(e,"f")),p.push(this.calpha),e.format(u+"("+p.join(",")+")",this.getType(e),t)}else return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),t)}},Ua=ao;Ua.DrawFunctions=function(){let e=new re(`float hashwithoutsine12(vec2 p) {
1193
+ }`,[s,a,ao.DrawFunctions.circle,ao.DrawFunctions.ring,ao.DrawFunctions.polygon,ao.DrawFunctions.cross,ao.DrawFunctions.diamond,ao.DrawFunctions.checkerboard,ao.DrawFunctions.line,ao.DrawFunctions.wave]),u=e.include(c),p=[];return p.push("normal"),p.push(this.blending.build(e,"f")),p.push(this.style.build(e,"i")),p.push(this.offset.build(e,"v2")),p.push(this.colorA.build(e,"v4")),p.push(this.colorB.build(e,"v4")),p.push(this.frequency.build(e,"v2")),p.push(this.size.build(e,"f")),p.push(this.variation.build(e,"f")),p.push(this.smoothness.build(e,"f")),p.push(this.zigzag.build(e,"f")),p.push(this.rotation.build(e,"f")),p.push(this.vertical.build(e,"v2")),p.push(this.horizontal.build(e,"v2")),p.push(this.sides.build(e,"i")),p.push(this.isMask.build(e,"b")),p.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),p.push(this.alpha.build(e,"f")),p.push(this.calpha),e.format(u+"("+p.join(",")+")",this.getType(e),t)}else return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),t)}},Fa=ao;Fa.DrawFunctions=function(){let e=new re(`float hashwithoutsine12(vec2 p) {
1194
1194
  vec3 p3 = fract(vec3(p.xyx) * 0.1031);
1195
1195
  p3 += dot(p3, p3.yzx + 33.33);
1196
1196
  return fract((p3.x + p3.y) * p3.z);
@@ -1355,7 +1355,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1355
1355
  float s = mix(size, size * rand, variation);
1356
1356
 
1357
1357
  return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);
1358
- }`);return{tileAndCenter:t,circle:o,ring:i,polygon:a,cross:s,diamond:l,checkerboard:c,line:u,wave:p}}();var Sf=class extends ye{constructor(e,t,o,i,a,s,l,c){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=t,this.wavelengths=o,this.noiseStrength=i,this.noiseScale=a,this.offset=s,this.isMask=c,this.alpha=l,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 o=e.include(Sf.Nodes.rainbow),i=[];return i.push(this.filmThickness.build(e,"f")),i.push(this.movement.build(e,"f")),i.push(this.wavelengths.build(e,"v3")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.offset.build(e,"v3")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.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)}},ka=Sf;ka.Nodes=function(){let e=new re(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
1358
+ }`);return{tileAndCenter:t,circle:o,ring:i,polygon:a,cross:s,diamond:l,checkerboard:c,line:u,wave:p}}();var vf=class extends ye{constructor(e,t,o,i,a,s,l,c){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=t,this.wavelengths=o,this.noiseStrength=i,this.noiseScale=a,this.offset=s,this.isMask=c,this.alpha=l,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 o=e.include(vf.Nodes.rainbow),i=[];return i.push(this.filmThickness.build(e,"f")),i.push(this.movement.build(e,"f")),i.push(this.wavelengths.build(e,"v3")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.offset.build(e,"v3")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.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)}},Ua=vf;Ua.Nodes=function(){let e=new re(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
1359
1359
  vec3 st = position / noiseScale;
1360
1360
  vec3 q = vec3(simplex3d(st),
1361
1361
  simplex3d(st + vec3(1.0)),
@@ -1378,7 +1378,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1378
1378
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
1379
1379
 
1380
1380
  return res;
1381
- }`,[e])}}();var wf=class extends ye{constructor(e,t,o,i,a,s,l,c,u,p){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=t,this.steps=o,this.source=i,this.isWorldSpace=a,this.noiseStrength=s,this.noiseScale=l,this.shadowColor=c,this.offset=u,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let o=e.include(wf.Nodes.toon),i=[];return i.push(this.positioning.build(e,"i")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.source.build(e,"v3")),i.push(this.isWorldSpace.build(e,"b")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.shadowColor.build(e,"v4")),i.push(this.offset.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ha=wf;Ha.Nodes=function(){let e=new re(`float rand(float n) {
1381
+ }`,[e])}}();var Sf=class extends ye{constructor(e,t,o,i,a,s,l,c,u,p){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=t,this.steps=o,this.source=i,this.isWorldSpace=a,this.noiseStrength=s,this.noiseScale=l,this.shadowColor=c,this.offset=u,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let o=e.include(Sf.Nodes.toon),i=[];return i.push(this.positioning.build(e,"i")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.source.build(e,"v3")),i.push(this.isWorldSpace.build(e,"b")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.shadowColor.build(e,"v4")),i.push(this.offset.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},ka=Sf;ka.Nodes=function(){let e=new re(`float rand(float n) {
1382
1382
  return fract(sin(n) * 43758.5453123);
1383
1383
  }`),t=new re(`float hash1(float p) {
1384
1384
  p = fract(p * 0.011);
@@ -1614,7 +1614,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1614
1614
 
1615
1615
  return color.xyz;
1616
1616
 
1617
- }`,[_t.simplex,e,o,a])}}();import{Vector2 as rb}from"three";var tb=function(){return{textureBicubic:new re(`float w0( float a ) {
1617
+ }`,[_t.simplex,e,o,a])}}();import{Vector2 as ob}from"three";var rb=function(){return{textureBicubic:new re(`float w0( float a ) {
1618
1618
  return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
1619
1619
  }
1620
1620
 
@@ -1678,7 +1678,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1678
1678
  vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
1679
1679
  vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
1680
1680
  return mix( fSample, cSample, fract( lod ) );
1681
- }`)}}();function ob(n,r){return n>=r?new rb(r/n,1):new rb(1,n/r)}var Pf=class extends ye{constructor(e,t,o,i,a,s,l,c){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=t,this.roughness=o,this.transmissionSamplerSize=i,this.transmissionSamplerMap=a,this.transmissionDepthMap=s,this.aspectRatio=l,this.alpha=c,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",6),e.define("BLUR_SLOD",Math.pow(2,Ae.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let o=e.include(Pf.Nodes.transmission),i=[];return i.push(this.thickness.build(e,"f")),i.push(this.ior.build(e,"f")),i.push(this.roughness.build(e,"f")),i.push(this.transmissionSamplerSize.build(e,"v2")),i.push(this.transmissionSamplerMap.getTexture(e,"t")),i.push(this.transmissionDepthMap.getTexture(e,"t")),i.push(this.aspectRatio.build(e,"v2")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.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)}},Wa=Pf;Wa.Nodes=function(){let e=new re(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
1681
+ }`)}}();function nb(n,r){return n>=r?new ob(r/n,1):new ob(1,n/r)}var wf=class extends ye{constructor(e,t,o,i,a,s,l,c){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=t,this.roughness=o,this.transmissionSamplerSize=i,this.transmissionSamplerMap=a,this.transmissionDepthMap=s,this.aspectRatio=l,this.alpha=c,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",6),e.define("BLUR_SLOD",Math.pow(2,Ae.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let o=e.include(wf.Nodes.transmission),i=[];return i.push(this.thickness.build(e,"f")),i.push(this.ior.build(e,"f")),i.push(this.roughness.build(e,"f")),i.push(this.transmissionSamplerSize.build(e,"v2")),i.push(this.transmissionSamplerMap.getTexture(e,"t")),i.push(this.transmissionDepthMap.getTexture(e,"t")),i.push(this.aspectRatio.build(e,"v2")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.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)}},Ha=wf;Ha.Nodes=function(){let e=new re(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
1682
1682
  // Slightly modified version of this:
1683
1683
  // https://www.shadertoy.com/view/ltScRG
1684
1684
 
@@ -1738,7 +1738,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1738
1738
  float lod = applyIorToRoughness(roughness, ior);
1739
1739
  return blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
1740
1740
  #endif
1741
- }`,[tb.textureBicubic,o,e]),a=new re(`vec3 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 ) {
1741
+ }`,[rb.textureBicubic,o,e]),a=new re(`vec3 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 ) {
1742
1742
  vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
1743
1743
  vec3 refractedRayExit = position + transmissionRay;
1744
1744
 
@@ -1769,7 +1769,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1769
1769
  accumAlpha += ( 1.0 - accumAlpha ) * alpha;
1770
1770
 
1771
1771
  return transmission;
1772
- }`,[a])}}();var Of=(e=>(e.NOISE="noise",e.MAP="map",e))(Of||{}),Cf=class extends ye{constructor(e,t,o,i,a,s,l,c,u,p,d){super("v3");this.displacementTypeIndex=new _e(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=t,Object.values(Of)[this.displacementTypeIndex.value]==="map"&&(this.mat=new Ea(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=p,this.noiseFunctionIndex=d,this.voronoiStyle=i,this.smoothness=a,this.seed=s,this.highCut=l,this.lowCut=c,this.quality=u}generate(e,t){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let o,i=[];switch(i.push("displaced_position"),i.push("displaced_normal"),Object.values(Of)[this.displacementTypeIndex.value]){case"map":{o=e.include(Cf.Nodes.map),i.push(this.movementOrTexture.getTexture(e,"t")),i.push("uv"),i.push(this.cropOrOffset.build(e,"f")),this.mat&&i.push(this.mat.build(e,"mat3"));break}case"noise":{let s=Object.values(Qs)[this.noiseFunctionIndex.value],l=new re(`vec3 orthogonal(vec3 v) {
1772
+ }`,[a])}}();var Pf=(e=>(e.NOISE="noise",e.MAP="map",e))(Pf||{}),Of=class extends ye{constructor(e,t,o,i,a,s,l,c,u,p,d){super("v3");this.displacementTypeIndex=new _e(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=t,Object.values(Pf)[this.displacementTypeIndex.value]==="map"&&(this.mat=new Da(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=p,this.noiseFunctionIndex=d,this.voronoiStyle=i,this.smoothness=a,this.seed=s,this.highCut=l,this.lowCut=c,this.quality=u}generate(e,t){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let o,i=[];switch(i.push("displaced_position"),i.push("displaced_normal"),Object.values(Pf)[this.displacementTypeIndex.value]){case"map":{o=e.include(Of.Nodes.map),i.push(this.movementOrTexture.getTexture(e,"t")),i.push("uv"),i.push(this.cropOrOffset.build(e,"f")),this.mat&&i.push(this.mat.build(e,"mat3"));break}case"noise":{let s=Object.values(Ks)[this.noiseFunctionIndex.value],l=new re(`vec3 orthogonal(vec3 v) {
1773
1773
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
1774
1774
  }`),c=s=="voronoi"?`
1775
1775
  float v = ${s}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);
@@ -1798,7 +1798,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1798
1798
  vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
1799
1799
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1800
1800
  return displaced_position;
1801
- }`,[u,l]);o=e.include(p),i.push(this.scale.build(e,"f")),i.push(this.cropOrOffset.build(e,"v3")),i.push(this.movementOrTexture.build(e,"f")),i.push(this.voronoiStyle.build(e,"i")),i.push(this.smoothness.build(e,"f")),i.push(this.seed.build(e,"f")),i.push(this.highCut.build(e,"f")),i.push(this.lowCut.build(e,"f")),i.push(this.quality.build(e,"i"));break}}return i.push(this.intensity.build(e,"f")),i.push("displaced_normal"),e.format(o+"("+i.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)}},qa=Cf;qa.Nodes=function(){let e=new re(`vec3 orthogonal(vec3 v) {
1801
+ }`,[u,l]);o=e.include(p),i.push(this.scale.build(e,"f")),i.push(this.cropOrOffset.build(e,"v3")),i.push(this.movementOrTexture.build(e,"f")),i.push(this.voronoiStyle.build(e,"i")),i.push(this.smoothness.build(e,"f")),i.push(this.seed.build(e,"f")),i.push(this.highCut.build(e,"f")),i.push(this.lowCut.build(e,"f")),i.push(this.quality.build(e,"i"));break}}return i.push(this.intensity.build(e,"f")),i.push("displaced_normal"),e.format(o+"("+i.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)}},Wa=Of;Wa.Nodes=function(){let e=new re(`vec3 orthogonal(vec3 v) {
1802
1802
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
1803
1803
  }`),t=new re(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
1804
1804
  vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
@@ -1820,7 +1820,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1820
1820
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
1821
1821
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1822
1822
  return displaced_position;
1823
- }`,[e,t])}}();var Ae={normalRenderTarget:new $t,normalRenderTargetDepth:new $t,transmissionRenderTarget:new $t,aspectRatio:new at,transmissionSize:new at(2048,2048),transmissionRenderTargetDepth:new $t,aoRenderTarget:new $t,aoEnabled:new pt,pixelRatioNode:new se(1),resolution:new at,penumbraSize:new zr(5,.5),frameIndex:new _e(0),transmissionLod:new _e(2)};for(let n of Object.values(Ae))n.isRenderGlobal=!0;var nb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.0.70/build/ui.wasm"};var Lo=class extends it{constructor(){super("basic");this.nodeType="Basic";this.color=new He(ht),this.shadingAlpha=new se(1),this.shadingBlend=new _e(0),this.previousModelViewMatrix=new zt,this.previouseProjectionMatrix=new zt}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(fN.merge([pN.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
1823
+ }`,[e,t])}}();var Ae={normalRenderTarget:new $t,normalRenderTargetDepth:new $t,transmissionRenderTarget:new $t,aspectRatio:new it,transmissionSize:new it(2048,2048),transmissionRenderTargetDepth:new $t,aoRenderTarget:new $t,aoEnabled:new dt,pixelRatioNode:new se(1),resolution:new it,penumbraSize:new zr(5,.5),frameIndex:new _e(0),transmissionLod:new _e(2)};for(let n of Object.values(Ae))n.isRenderGlobal=!0;var ib={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.0.71/build/ui.wasm"};var Lo=class extends Nt{constructor(){super("basic");this.nodeType="Basic";this.color=new He(ft),this.shadingAlpha=new se(1),this.shadingBlend=new _e(0),this.previousModelViewMatrix=new zt,this.previouseProjectionMatrix=new zt}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(mN.merge([hN.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
1824
1824
  `));let i=["#include <beginnormal_vertex>",`
1825
1825
  #if !defined( USE_LAYER_DISPLACE )
1826
1826
  #include <defaultnormal_vertex>
@@ -1838,9 +1838,9 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1838
1838
  #include <begin_vertex>
1839
1839
  #endif /* !USE_LAYER_DISPLACE */
1840
1840
  `];o&&i.push(o.code,o.result?"displaced_position = "+o.result+";":""),i.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join(`
1841
- `)}else{this.color===void 0&&(this.color=new He(ht)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let o=this.color.flow(e,"c",{slot:"color"}),i=this.alpha?this.alpha.flow(e,"f"):void 0,a=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=i!==void 0,e.addParsCode(["varying vec3 vWPosition;","#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
1841
+ `)}else{this.color===void 0&&(this.color=new He(ft)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let o=this.color.flow(e,"c",{slot:"color"}),i=this.alpha?this.alpha.flow(e,"f"):void 0,a=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=i!==void 0,e.addParsCode(["varying vec3 vWPosition;","#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
1842
1842
  `));let l=["#include <normal_fragment_begin>",o.code];i&&l.push(i.code,"#ifdef ALPHATEST"," if ( "+i.result+" <= ALPHATEST ) discard;","#endif"),s?l.push(s.code,`vec3 outgoingLight = ${o.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):l.push(`vec3 finalColor = ${o.result};`);let c="1.0";this.mask&&(this.mask.analyze(e),c=`luminance(${this.mask.flow(e,"v3").result})`),i?l.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${i.result} * ${c} );`):l.push("gl_FragColor = vec4("+o.result+", 1.0 );"),a&&l.push(`gl_FragColor.a *= ${a.result};`),l.push("#include <fog_fragment>","#include <dithering_fragment>"),t=l.join(`
1843
- `)}return t}};import{UniformsLib as ib,UniformsUtils as hN}from"three";var Zs=class extends it{constructor(){super("lambert");this.nodeType="Lambert";this.color=new He(ht),this.emissive=new He(0),this.emissiveIntensity=new se(1),this.previousModelViewMatrix=new zt,this.previouseProjectionMatrix=new zt,this.shadingAlpha=new se(1),this.shadingBlend=new _e(0),this.occlusion=new pt(!0)}get category(){return"lambert"}build(e){let t;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(hN.merge([ib.fog,ib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","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(`
1843
+ `)}return t}};import{UniformsLib as ab,UniformsUtils as yN}from"three";var Qs=class extends Nt{constructor(){super("lambert");this.nodeType="Lambert";this.color=new He(ft),this.emissive=new He(0),this.emissiveIntensity=new se(1),this.previousModelViewMatrix=new zt,this.previouseProjectionMatrix=new zt,this.shadingAlpha=new se(1),this.shadingBlend=new _e(0),this.occlusion=new dt(!0)}get category(){return"lambert"}build(e){let t;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(yN.merge([ab.fog,ab.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","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(`
1844
1844
  `));let i=["#include <beginnormal_vertex>",`
1845
1845
  #ifndef USE_LAYER_DISPLACE
1846
1846
  #include <defaultnormal_vertex>
@@ -1933,7 +1933,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1933
1933
  #pragma unroll_loop_end
1934
1934
  #endif
1935
1935
  `," #include <shadowmap_vertex>"," #include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join(`
1936
- `)}else{e.mergeUniform({penumbraSize:Ae.penumbraSize}),e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({aoMap:Ae.aoRenderTarget}),e.mergeUniform({aoEnabled:Ae.aoEnabled}),this.color===void 0&&(this.color=new He(ht)),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 o=this.color.flow(e,"c",{slot:"color"}),i=this.emissive.flow(e,"c",{slot:"emissive"}),a=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),s=this.occlusion.flow(e,"b",{slot:"occlusion"}),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=p!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vViewPosition;","varying vec3 vWPosition;","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(`
1936
+ `)}else{e.mergeUniform({penumbraSize:Ae.penumbraSize}),e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({aoMap:Ae.aoRenderTarget}),e.mergeUniform({aoEnabled:Ae.aoEnabled}),this.color===void 0&&(this.color=new He(ft)),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 o=this.color.flow(e,"c",{slot:"color"}),i=this.emissive.flow(e,"c",{slot:"emissive"}),a=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),s=this.occlusion.flow(e,"b",{slot:"occlusion"}),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=p!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vViewPosition;","varying vec3 vWPosition;","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(`
1937
1937
  `));let h=["#include <normal_fragment_begin>",`
1938
1938
  // NOTE: gl_FrontFacing alternative using face normal estimation.
1939
1939
  vec3 viewdx = dFdx(vViewPosition);
@@ -1949,7 +1949,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1949
1949
  outgoingLight *= ao;
1950
1950
  }
1951
1951
  `),u&&h.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),p?h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result} );`):h.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&h.push(`gl_FragColor.a *= ${d.result};`),h.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=h.join(`
1952
- `)}return t}};import{UniformsLib as ab,UniformsUtils as mN}from"three";var Ro=function(){let n=new re(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {
1952
+ `)}return t}};import{UniformsLib as sb,UniformsUtils as gN}from"three";var Ro=function(){let n=new re(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {
1953
1953
 
1954
1954
  // Gradient of UVs w.r.t. X coordinate (in screen-space)
1955
1955
  vec2 dSTdx = dFdx(bumpMapUv);
@@ -1980,7 +1980,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1980
1980
 
1981
1981
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
1982
1982
  return normalize( abs( fDet ) * vN - vGrad );
1983
- }`);return{dHdxy:n,perturbNormalArb:r}}();var Js=class extends it{constructor(){super("phong");this.nodeType="Phong";this.color=new He(ht),this.specular=new He(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new zt,this.previouseProjectionMatrix=new zt,this.shadingAlpha=new se(1),this.shadingBlend=new _e(0),this.occlusion=new pt(!0)}get category(){return"phong"}build(e){let t;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(mN.merge([ab.fog,ab.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1983
+ }`);return{dHdxy:n,perturbNormalArb:r}}();var Zs=class extends Nt{constructor(){super("phong");this.nodeType="Phong";this.color=new He(ft),this.specular=new He(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new zt,this.previouseProjectionMatrix=new zt,this.shadingAlpha=new se(1),this.shadingBlend=new _e(0),this.occlusion=new dt(!0)}get category(){return"phong"}build(e){let t;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(gN.merge([sb.fog,sb.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1984
1984
  `));let i=["#include <beginnormal_vertex>",`
1985
1985
  #include <skinbase_vertex>
1986
1986
  #include <skinnormal_vertex>
@@ -2001,7 +2001,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2001
2001
  #include <begin_vertex>
2002
2002
  #endif
2003
2003
  `];o&&i.push(o.code,o.result?"displaced_position = "+o.result+";":""),i.push("transformed = displaced_position;","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join(`
2004
- `)}else{e.mergeUniform({penumbraSize:Ae.penumbraSize}),e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({aoMap:Ae.aoRenderTarget}),e.mergeUniform({aoEnabled:Ae.aoEnabled}),this.color===void 0&&(this.color=new He(ht)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e);let o=this.occlusion.flow(e,"b",{slot:"occlusion"});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"}),a=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=p!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#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(`
2004
+ `)}else{e.mergeUniform({penumbraSize:Ae.penumbraSize}),e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({aoMap:Ae.aoRenderTarget}),e.mergeUniform({aoEnabled:Ae.aoEnabled}),this.color===void 0&&(this.color=new He(ft)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e);let o=this.occlusion.flow(e,"b",{slot:"occlusion"});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"}),a=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=p!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#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(`
2005
2005
  `));let h=["#include <normal_fragment_begin>",`
2006
2006
  // NOTE: gl_FrontFacing alternative using face normal estimation.
2007
2007
  vec3 viewdx = dFdx(vViewPosition);
@@ -2048,7 +2048,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2048
2048
  outgoingLight *= ao;
2049
2049
  }
2050
2050
  `),u&&h.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),p?h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result});`):h.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&h.push(`gl_FragColor.a *= ${d.result};`),h.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=h.join(`
2051
- `)}return t}};import{UniformsLib as Tf,UniformsUtils as yN}from"three";var el=class extends it{constructor(){super("standard");this.nodeType="Standard";this.color=new He(ht),this.roughness=new se(.3),this.metalness=new se(0),this.reflectivity=new se(.5),this.previousModelViewMatrix=new zt,this.previouseProjectionMatrix=new zt,this.shadingAlpha=new se(1),this.shadingBlend=new _e(0),this.occlusion=new pt(!0)}get category(){return"physical"}build(e){let t;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(yN.merge([Tf.fog,Tf.lights])),Tf.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2051
+ `)}return t}};import{UniformsLib as Cf,UniformsUtils as xN}from"three";var Js=class extends Nt{constructor(){super("standard");this.nodeType="Standard";this.color=new He(ft),this.roughness=new se(.3),this.metalness=new se(0),this.reflectivity=new se(.5),this.previousModelViewMatrix=new zt,this.previouseProjectionMatrix=new zt,this.shadingAlpha=new se(1),this.shadingBlend=new _e(0),this.occlusion=new dt(!0)}get category(){return"physical"}build(e){let t;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(xN.merge([Cf.fog,Cf.lights])),Cf.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2052
2052
  `));let i=["#include <beginnormal_vertex>",`
2053
2053
  #if !defined( USE_LAYER_DISPLACE )
2054
2054
  #include <defaultnormal_vertex>
@@ -2066,7 +2066,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2066
2066
  #include <begin_vertex>
2067
2067
  #endif /* !USE_LAYER_DISPLACE */
2068
2068
  `];o&&i.push(o.code,o.result?"displaced_position = "+o.result+";":""),i.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join(`
2069
- `)}else{e.mergeUniform({penumbraSize:Ae.penumbraSize}),e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({aoMap:Ae.aoRenderTarget}),e.mergeUniform({aoEnabled:Ae.aoEnabled});let o={gamma:!0};this.color===void 0&&(this.color=new He(ht)),this.color.analyze(e,{slot:"color",context:o}),this.roughness.analyze(e),this.metalness.analyze(e);let i=this.occlusion.flow(e,"b",{slot:"occlusion"});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 a=this.color.flow(e,"c",{slot:"color",context:o}),s=this.roughness.flow(e,"f"),l=this.metalness.flow(e,"f"),c=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),p=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,h=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,f=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#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(`
2069
+ `)}else{e.mergeUniform({penumbraSize:Ae.penumbraSize}),e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({aoMap:Ae.aoRenderTarget}),e.mergeUniform({aoEnabled:Ae.aoEnabled});let o={gamma:!0};this.color===void 0&&(this.color=new He(ft)),this.color.analyze(e,{slot:"color",context:o}),this.roughness.analyze(e),this.metalness.analyze(e);let i=this.occlusion.flow(e,"b",{slot:"occlusion"});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 a=this.color.flow(e,"c",{slot:"color",context:o}),s=this.roughness.flow(e,"f"),l=this.metalness.flow(e,"f"),c=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),p=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,h=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,f=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#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(`
2070
2070
  `));let m=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
2071
2071
  // NOTE: gl_FrontFacing alternative using face normal estimation.
2072
2072
  vec3 viewdx = dFdx(vViewPosition);
@@ -2139,7 +2139,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2139
2139
  outgoingLight *= ao;
2140
2140
  }
2141
2141
  `),p&&m.push(p.code,`outgoingLight = spe_blend(outgoingLight, ${p.result}, 1.0, SPE_BLENDING_NORMAL);`),d?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),h&&m.push(`gl_FragColor.a *= ${h.result};`),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=m.join(`
2142
- `)}return t}};import{UniformsLib as sb,UniformsUtils as gN}from"three";var tl=class extends it{constructor(){super("toon");this.nodeType="Toon";this.color=new He(ht),this.specular=new He(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new zt,this.previouseProjectionMatrix=new zt,this.shadingAlpha=new se(1),this.shadingBlend=new _e(0)}get category(){return"toon"}build(e){let t;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(gN.merge([sb.fog,sb.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2142
+ `)}return t}};import{UniformsLib as lb,UniformsUtils as bN}from"three";var el=class extends Nt{constructor(){super("toon");this.nodeType="Toon";this.color=new He(ft),this.specular=new He(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new zt,this.previouseProjectionMatrix=new zt,this.shadingAlpha=new se(1),this.shadingBlend=new _e(0)}get category(){return"toon"}build(e){let t;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(bN.merge([lb.fog,lb.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2143
2143
  `));let i=["#include <beginnormal_vertex>",`
2144
2144
  #ifndef USE_LAYER_DISPLACE
2145
2145
  #include <defaultnormal_vertex>
@@ -2157,7 +2157,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2157
2157
  #include <begin_vertex>
2158
2158
  #endif
2159
2159
  `];o&&i.push(o.code,o.result?"displaced_position = "+o.result+";":""),i.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push(" #include <project_vertex>"," #include <fog_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join(`
2160
- `)}else{e.mergeUniform({penumbraSize:Ae.penumbraSize}),e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({aoMap:Ae.aoRenderTarget}),e.mergeUniform({aoEnabled:Ae.aoEnabled}),this.color===void 0&&(this.color=new He(ht)),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 o=this.color.flow(e,"c",{slot:"color"}),i=this.specular.flow(e,"c"),a=this.shininess.flow(e,"f"),s=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,u=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=u!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vWPosition;","#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
2160
+ `)}else{e.mergeUniform({penumbraSize:Ae.penumbraSize}),e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({aoMap:Ae.aoRenderTarget}),e.mergeUniform({aoEnabled:Ae.aoEnabled}),this.color===void 0&&(this.color=new He(ft)),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 o=this.color.flow(e,"c",{slot:"color"}),i=this.specular.flow(e,"c"),a=this.shininess.flow(e,"f"),s=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,u=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=u!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vWPosition;","#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
2161
2161
  varying vec3 vViewPosition;
2162
2162
  struct ToonMaterial {
2163
2163
  vec3 diffuseColor;
@@ -2222,11 +2222,11 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2222
2222
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result} * ${h}, ${l.result} );
2223
2223
  }
2224
2224
  `),c&&d.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),u?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p&&d.push(`gl_FragColor.a *= ${p.result};`),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
2225
- `)}return t}};import{VideoTexture as xN,Texture as bN,CanvasTexture as vN}from"three";var Su=class{constructor(r=1e3*10){this.timeout=r;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...r){}remove(r){let e=this.cache.get(r);e&&(this.dispose(r,e.data),this.cache.delete(r),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let r=Date.now(),e=this.head.next;for(;e.time<r-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(r){return this.cache.get(r)?.data}load(r){let e=Date.now(),t=this.cache.get(r);return t===void 0?(t={data:this.create(r),src:r,time:e,next:null,prev:null},this.cache.set(r,t)):(t.time=e,t.prev.next=t.next,t.next.prev=t.prev),t.prev=this.tail.prev,t.next=this.tail,this.tail.prev.next=t,this.tail.prev=t,this.scheduleCleanup(),t.data}};var Mf=class extends Su{create(r){return URL.createObjectURL(new Blob([r]))}dispose(r,e){URL.revokeObjectURL(e)}},Af;function lb(n){return typeof n=="string"?n:(Af||(Af=new Mf),Af.load(n))}var wu=class{constructor(r,e){this.data=r;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},Pu=class{constructor(){this.cache=new Map}remove(r){if(this.cache.delete(r.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(r){let e=this.cache.get(r);return e===void 0&&(e=this.create(r),this.cache.set(r,e)),e.refCount+=1,e}};var $a=class extends wu{constructor(e,t){super(e,t.imageHolderCache);this.data=e;this.shared=t;this.loaded=!1;this.isVideo=!1;this.isCanvas=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isCanvas=e.nodeName==="CANVAS",this.updateSrc(this.isCanvas?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;for(let i of Object.values(this._cache))for(let a of Object.values(i))a&&(a.image=this.img,a.needsUpdate=!0);this.shared.requestRender()};if(this.isCanvas)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var o=new FileReader;o.readAsDataURL(new Blob([e],{type:"video/mp4"}));let i;await new Promise(a=>{o.onloadend=s=>{i=s.target?.result,a(null)}}),this.img.src=i}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=lb(e),this.img.onload=t}getTexture(e,t=1008){let o=this._cache[e]?.[t];if(o)return o;{let i;return this.isCanvas&&(i=new vN(this.img,void 0,e,e,void 0,t)),this.isVideo?i=new xN(this.img,void 0,e,e):i=new bN(this.img,void 0,e,e,void 0,t),this.loaded&&(i.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][t]=i,i}}setNeedsUpdate(e){for(let t of Object.values(this._cache))for(let o of Object.values(t))o&&(o.needsUpdate=e)}disposeTextures(){for(let[e,t]of Object.entries(this._cache))for(let[o,i]of Object.entries(t))i?.dispose(),this._cache[e][o]=void 0}dispose(){super.dispose(),this.disposeTextures()}};var dr=class extends $a{};import{Vector2 as Vo,Vector3 as so,Vector4 as Ou}from"three";function Gt(n,r){return r.color(n)}function cb(n,r){switch(n.type){case"fresnel":return PN(n,r);case"gradient":return ON(n,r);case"depth":return CN(n,r);case"normal":return TN(n,r);case"noise":return AN(n,r);case"rainbow":return MN(n,r);case"toon":return IN(n,r);case"outline":return NN(n,r);case"transmission":return DN(n,r);case"color":return wN(n,r);case"pattern":return EN(n,r)}}function SN(n){return{type:n.type}}function jr(n,r){let{alpha:e,mode:t,isMask:o}=n,i=typeof e=="string"?(Number(r.getVariable(e))??100)/100:e;return{...SN(n),alpha:i,mode:t,isMask:o}}function wN(n,r){return{...jr(n,r),color:Gt(n.color,r)}}function PN(n,r){let{bias:e,scale:t,intensity:o,factor:i,color:a}=n;return{...jr(n,r),color:Gt(a,r),bias:e,scale:t,intensity:o,factor:i}}function ON(n,r){let{gradientType:e,smooth:t,colors:o,steps:i,angle:a,offset:s,morph:l}=n;return{...jr(n,r),gradientType:e,smooth:t,colors:o.map(c=>new Ou(c[0],c[1],c[2],c[3])),num:o.length,steps:i,offset:new Vo(...s),morph:new Vo(...l),angle:a}}function CN(n,r){let{gradientType:e,near:t,far:o,isVector:i,isWorldSpace:a,origin:s,direction:l,colors:c,steps:u,smooth:p}=n;return{...jr(n,r),gradientType:e,near:t,far:o,isVector:i,isWorldSpace:a,origin:new so(...s),direction:l?new so(...l):new so(1,0,0),colors:c.map(d=>d!==void 0?new Ou(d[0],d[1],d[2],d[3]):new Ou(0,0,0,0)),steps:u.slice(0,c.length),smooth:p}}function TN(n,r){let{cnormal:e}=n;return{...jr(n,r),cnormal:new so(e[0],e[1],e[2])}}function AN(n,r){return{...jr(n,r),scale:n.scale,move:n.move,fA:new Vo(...n.fA),fB:new Vo(...n.fB),size:new so(...n.size),distortion:new Vo(...n.distortion),colorA:Gt(n.colorA,r),colorB:Gt(n.colorB,r),colorC:Gt(n.colorC,r),colorD:Gt(n.colorD,r),noiseType:n.noiseType,voronoiStyle:n.voronoiStyle,highCut:n.highCut,lowCut:n.lowCut,smoothness:n.smoothness,seed:n.seed,quality:n.quality}}function MN(n,r){return{...jr(n,r),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new so(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new so(...n.offset)}}function IN(n,r){return{...jr(n,r),positioning:n.positioning,colors:n.colors.map(e=>new Ou(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new so(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:Gt(n.shadowColor,r),offset:new so(...n.offset)}}function NN(n,r){return{...jr(n,r),outlineColor:Gt(n.outlineColor,r),contourColor:Gt(n.contourColor,r),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new so(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function DN(n,r){return{...jr(n,r),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function EN(n,r){return{...jr(n,r),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new Vo(...n.offset),colorA:Gt(n.colorA,r),colorB:Gt(n.colorB,r),frequency:new Vo(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new Vo(...n.vertical),horizontal:new Vo(...n.horizontal),sides:n.sides}}var mn=class extends Tt{};import{MathUtils as _N,Vector4 as BN}from"three";var LN={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},RN={depth:["colors"]};function VN(n,r,e){if(r==="isMask")return!0;let t=LN[n.type],o=RN[n.type];if(o!==void 0){let i=n.color;if(o.includes(r)){let a=i[r]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return t!==void 0?t.includes(r):!1}function If(n,r,e){let t=e.uniforms[`f${e.id}_texture`];if(!t)return!1;let o=!1,i=n;if("image"in i){let a=i.image,s=r.image(a),l=t;l.image instanceof dr||l.image.deref(),l.image=s}if("video"in i){let a=i.video,s=r.video(a),l=t;l.image instanceof dr||l.image.deref(),l.image=s}if("wrapping"in i){let a=t;a.wrap=i.wrapping}if("minFilter"in i){let a=t;a.minFilter=i.minFilter}if("rotation"in i&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(i.rotation??0)*_N.DEG2RAD,o;if("repeat"in i||"offset"in i||"rotation"in i){let a="mat",s=e.uniforms[`f${e.id}_${a}`];"repeat"in i&&(s.repeat=i.repeat),"offset"in i&&(s.offset=i.offset),"rotation"in i&&(s.rotation=i.rotation??0),s.updateMatrix()}return o}function ub(n,r,e,t){let o=!1;for(let[i,a]of Object.entries(n)){if(i==="bumpMap"||i==="roughnessMap"){o=!0;continue}if(!i||a===void 0)continue;if(Nf(i,e,t,r)){i==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=t.visible;let s=e.uniforms[`f${e.id}_${i}`];if(!!s&&!(s instanceof fn))switch(o=o||VN(e,i,a),s.constructor){case He:if(typeof a=="string"){let l=r.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof mn?s.value=new Tt(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case er:if(typeof a=="string"){let l=r.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof mn?s.value=new Tt(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case at:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case Vt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case $t:{If(a,r,e);break}case Gr:{s.value=a.map(l=>new BN(...l));break}default:{s.value=a;break}}}return o}var yn=(n,r,e)=>Math.max(0,Math.min(1,Number(r.getVariable(typeof n=="number"?n*100:n,e)??100)/100))??1,gn=class{constructor(r,e,t,o,i){this.id=r;this.uuid=e;this.data=t;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in t)Nf(a,this,t,i)}get type(){return this.data.type}static create(r,e,t,o){if(t.type==="light")return Yt.createLigherLayer(r,e,t,o);if(t.type==="texture"||t.type==="video"){let i=t.type==="texture"?o.canvas(t.texture.image)??o.image(t.texture.image):o.video(t.texture.video),a=new Yn(i,t.texture.wrapping,t.texture.minFilter??1008),s=new bu(i),l=new vu(t.texture.repeat,t.texture.offset,t.texture.rotation??0),c=new se(t.crop?1:0),u=new _e(t.projection??0),p=new _e(["x","y","z"].indexOf(t.axis)??0),d=new _e(t.side??0),h=new at(t.size?new Fr(t.size[0],t.size[1]):new Fr(100,100)),f=new se(t.blending??0),m=new se(yn(t.alpha,o)),y=new _e(t.mode??0),g=new pt(t.isMask??!1),v=new hn(a,s,c,u,p,d,h,f,l,m,y,g),O=new Ue(v.calpha,"f");return new et(r,e,t,{texture:a,textureSize:s,crop:c,projection:u,axis:p,side:d,size:h,blending:f,mat:l,alpha:m,mode:y,isMask:g},v,y,O,g,o)}else if(t.type==="matcap"){let i=o.image(t.texture.image),a=new Yn(i,t.texture.wrapping,t.texture.minFilter??1008),s=new se(yn(t.alpha,o)),l=new _e(t.mode??0),c=new pt(t.isMask??!1),u=new se(t.texture.rotation??0),p=new Ga(a,s,l,c,u),d=new Ue(p.calpha,"f");return new et(r,e,t,{texture:a,alpha:s,mode:l,isMask:c,rotation:u},p,l,d,c,o)}else if(t.type==="displace")if(t.displacementType==="noise"){let i=new Vt(new lo(...t.offset)),a=new se(t.scale??10),s=new se(t.intensity??8),l=new se(t.movement??1),c=new _e(t.noiseType??0),u=new _e(t.voronoiStyle??0),p=new se(t.smoothness??.5),d=new se(t.seed??0),h=new se(t.highCut??1),f=new se(t.lowCut??0),m=new _e(t.quality??1),y=new qa(s,l,i,u,p,d,h,f,m,a,c);return new rl(r,e,t,{offset:i,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:u,smoothness:p,seed:d,highCut:h,lowCut:f,quality:m},y,o)}else throw new Error;else return jN(r,e,t,o)}updateByOp(r,e,t){let o=r;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props?(t.scene.markNeedsUpdateRendererDirty(),!0):ub(o.props,t.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?If(o.props,t.shared,this):!0;return!1}dispose(){if(zN(this)){let r=this.uniforms[`f${this.id}_texture`];if(!r)return!1;let e=r;e.image instanceof dr||e.image.deref()}}hasValueByKey(r){return this.uniforms[r]!==void 0}hasValue(r){return this.hasValueByKey(`f${this.id}_${r}`)}setValue(r,e){let t=`f${this.id}_${r}`;this.hasValueByKey(t)&&e!==void 0&&(this.uniforms[t].value=e)}getNode(r){let e=`f${this.id}_${r}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(r){let e=`f${this.id}_${r}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(r){let t=/f\d+_(.*)/.exec(r);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${r}`)}getNames(){let r=[];for(let e in this.uniforms){let t=this.getName(e);t&&r.push(t)}return r}},et=class extends gn{constructor(e,t,o,i,a,s,l,c,u){super(e,t,o,i,u);this.params=i;this.color=a;this.mode=s;this.alpha=l;this.isMask=c}},rl=class extends gn{constructor(e,t,o,i,a,s){super(e,t,o,i,s);this.position=a}},Yt=class extends gn{constructor(e,t,o,i,a,s){super(e,t,o,a,s);this.node=i}static createLigherLayer(e,t,o,i){let a,s=new se(yn(o.alpha,i)),l=new _e(o.mode),c=new se(o.bumpMapIntensity),u=new se(yn(o.alphaOverride,i)),p;if(!o.visible)a=new Lo,p={};else if(o.category==="lambert"){a=new Zs;let d=new He(i.color(o.emissive)??0),h=new pt(o.occlusion??!0);p={emissive:d,occlusion:h},a.emissive=d,a.occlusion=h}else if(o.category==="toon"){a=new tl;let d=new se(o.shininess??30),h=new He(i.color(o.specular)??1118481);p={shininess:d,specular:h},a.shininess=d,a.specular=h}else if(o.category==="physical"){a=new el;let d=new se(o.roughness??.3),h=new se(o.metalness??0),f=new se(o.reflectivity??.5),m=new pt(o.occlusion??!0);p={roughness:d,metalness:h,reflectivity:f,occlusion:m},a.roughness=d,a.metalness=h,a.reflectivity=f,a.occlusion=m}else{a=new Js;let d=new se(o.shininess??30),h=new He(o.specular!==void 0?i.color(o.specular)??1118481:1118481),f=new pt(o.occlusion??!0);p={shininess:d,specular:h,occlusion:f},a.shininess=d,a.specular=h,a.occlusion=f}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=c,a.alphaOverride=u,p.alpha=a.shadingAlpha,p.mode=a.shadingBlend,p.bumpMapIntensity=a.bumpMapIntensity,p.alphaOverride=a.alphaOverride,new Yt(e,t,o,a,p,i)}get category(){return this.node.category}};function zN(n){let r=n instanceof gn?n.type:n;return r==="texture"||r==="video"||r==="displace_map"||r==="matcap"}function vr(n){return{alpha:new se(n.alpha??1),mode:new _e(n.mode??0),isMask:new pt(n.isMask??!1)}}function GN(n,r,e,t,o){switch(n.type){case"color":{let i=new He(t.color??ht),a=vr(t),s=new Xn(i,a.alpha),l=new Ue(s.calpha,"f");return new et(r,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let i=new He(t.color??16777215),a=new se(t.bias??.1),s=new se(t.scale??1),l=new se(t.intensity??2),c=new se(t.factor??1),u=vr(t),p=new Ks(i,a,s,l,c,u.alpha,u.mode,u.isMask),d=new Ue(p.calpha,"f");return new et(r,e,n,{color:i,bias:a,scale:s,intensity:l,factor:c,...u},p,u.mode,d,u.isMask,o)}case"rainbow":{let i=new se(t.filmThickness??30),a=new se(t.movement??0),s=new Vt(t.wavelengths??new lo(0,0,0)),l=new se(t.noiseStrength??0),c=new se(t.noiseScale??1),u=new Vt(t.offset??new lo(0,0,0)),p=vr(t),d=new ka(i,a,s,l,c,u,p.alpha,p.isMask),h=new Ue(d.calpha,"f");return new et(r,e,n,{filmThickness:i,movement:a,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...p},d,p.mode,h,p.isMask,o)}case"transmission":{let i=new se(t.thickness??10),a=new se(t.ior??1.5),s=new se(t.roughness??.5),l=Ae.transmissionSize,c=Ae.transmissionRenderTarget,u=Ae.transmissionRenderTargetDepth,p=window.innerWidth,d=window.innerHeight,h=p>=d?new at(d/p,1):new at(1,p/d),f=vr(t),m=new Wa(i,a,s,l,c,u,h,f.alpha),y=new Ue(m.calpha,"f");return new et(r,e,n,{thickness:i,ior:a,roughness:s,aspectRatio:h,...f},m,f.mode,y,f.isMask,o)}case"toon":{let i=new _e(t.positioning??0),a;t.colors?a=new Gr(t.colors.length,t.colors):(a=new Gr(10,new Ya(0,0,0,1)),a.value[1]=new Ya(1,1,1,1));let s;t.steps?s=new zr(t.steps.length,t.steps):(s=new zr(10,1),s.value[0]=0);let l=new Vt(t.source??new lo(0,0,0)),c=new pt(t.isWorldSpace??!0),u=new se(t.noiseStrength??0),p=new se(t.noiseScale??1),d=new er(t.shadowColor),h=new Vt(t.offset??new lo(0,0,0)),f=vr(t),m=new Ha(i,a,s,l,c,u,p,d,h,f.alpha),y=new Ue(m.calpha,"f");return new et(r,e,n,{positioning:i,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:p,shadowColor:d,offset:h,...f},m,f.mode,y,f.isMask,o)}case"outline":{let i=new He(t.outlineColor??16777215),a=new He(t.contourColor??16777215),s=new se(t.outlineWidth??.1),l=new se(t.contourWidth??.1),c=new se(t.outlineThreshold??.1),u=new se(t.contourThreshold??.1),p=new se(t.outlineSmoothing??.1),d=new se(t.contourFrequency??.1),h=new Vt(t.contourDirection??new lo(0,1,0)),f=new pt(t.positionalLines??!1),m=new pt(t.compensation??!0),y=Ae.normalRenderTarget,g=Ae.normalRenderTargetDepth,v=Ae.pixelRatioNode,O=Ae.resolution,P=vr(t),S=new Fa(i,a,s,l,c,u,p,d,h,f,m,O,y,g,v,P.alpha),T=new Ue(S.calpha,"f");return new et(r,e,n,{outlineColor:i,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:p,contourFrequency:d,contourDirection:h,positionalLines:f,compensation:m,...P},S,P.mode,T,P.isMask,o)}case"depth":{let i=new _e(t.gradientType??0),a=new pt(t.smooth??!1),s=new se(t.near??50),l=new se(t.far??200),c=new se(t.isVector??1),u=new se(t.isWorldSpace??0),p=new Vt(t.origin??new lo),d=new Vt(t.direction??new lo),h;t.colors?h=new Gr(t.colors.length,t.colors):(h=new Gr(2,new Ya(0,0,0,1)),h.value[1]=new Ya(1,1,1,1));let f;t.steps?f=new zr(t.steps.length,t.steps):(f=new zr(2,1),f.value[0]=0);let m=vr(t),y=new Va(i,a,s,l,c,u,p,d,h,f,m.alpha,m.isMask),g=new Ue(y.calpha,"f");return new et(r,e,n,{gradientType:i,smooth:a,near:s,far:l,isVector:c,isWorldSpace:u,origin:p,direction:d,colors:h,steps:f,...m},y,m.mode,g,m.isMask,o)}case"noise":{let i=new se(t.scale??1),a=new Vt(t.size??new lo(100,100,100)),s=new se(t.move??1),l=new at(t.fA??new Fr(1.7,9.2)),c=new at(t.fB??new Fr(8.3,2.8)),u=new at(t.distortion??new Fr(1,1)),p=new er(t.colorA),d=new er(t.colorB),h=new er(t.colorC),f=new er(t.colorD),m=new _e(t.noiseType??0),y=new _e(t.voronoiStyle??0),g=new se(t.highCut??1),v=new se(t.lowCut??0),O=new se(t.smoothness??.5),P=new se(t.seed??.5),S=new _e(t.quality??1),T=vr(t),I=new ja(i,a,s,l,c,u,p,d,h,f,T.alpha,m,T.isMask,y,g,v,O,P,S),x=new Ue(I.calpha,"f");return new et(r,e,n,{scale:i,size:a,move:s,fA:l,fB:c,distortion:u,colorA:p,colorB:d,colorC:h,colorD:f,noiseType:m,...T,voronoiStyle:y,highCut:g,lowCut:v,smoothness:O,seed:P,quality:S},I,T.mode,x,T.isMask,o)}case"normal":{let i=new Vt(t.cnormal??new lo(1,1,1)),a=vr(t),s=new Ba(i,a.alpha),l=new Ue(s.calpha,"f");return new et(r,e,n,{cnormal:i,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let i=new _e(t.gradientType??0),a=new pt(t.smooth??!1),s;t.colors?s=new Gr(t.colors.length,t.colors):(s=new Gr(10,new Ya(0,0,0,1)),s.value[1]=new Ya(1,1,1,1));let l;t.steps?l=new zr(t.steps.length,t.steps):(l=new zr(10,1),l.value[0]=0);let c=new at(t.offset??new Fr(0,0)),u=new at(t.morph??new Fr(0,0)),p=new se(t.angle??0),d=vr(t),h=new za(i,a,s,l,c,u,p,d.alpha,d.isMask),f=new Ue(h.calpha,"f");return new et(r,e,n,{gradientType:i,smooth:a,colors:s,steps:l,offset:c,morph:u,angle:p,...d},h,d.mode,f,d.isMask,o)}case"pattern":{let i=new _e(t.style??0),a=new _e(t.projection??0),s=new _e(["x","y","z"].indexOf(t.axis)??0),l=new se(t.blending??0),c=new at(t.offset??new Fr(0,0)),u=new er(t.colorA),p=new er(t.colorB),d=new at(t.frequency??new Fr(10,10)),h=new se(t.size??.5),f=new se(t.variation??0),m=new se(t.smoothness??.5),y=new se(t.zigzag??0),g=new se(t.rotation??0),v=new at(t.vertical??new Fr(0,1)),O=new at(t.horizontal??new Fr(0,1)),P=new _e(t.sides??6),S=vr(t),T=new Ua(i,a,s,l,c,u,p,d,h,f,m,y,g,v,O,P,S.alpha,S.isMask),I=new Ue(T.calpha,"f");return new et(r,e,n,{style:i,projection:a,axis:s,blending:l,offset:c,colorA:u,colorB:p,frequency:d,size:h,variation:f,smoothness:m,zigzag:y,rotation:g,vertical:v,horizontal:O,sides:P,...S},T,S.mode,I,S.isMask,o)}default:{let i=new He(1,0,0,1),a=vr(t),s=new Xn(i,a.alpha),l=new Ue(s.calpha,"f");return new et(r,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}}}function jN(n,r,e,t){let o=cb(e,t);return GN(e,n,r,o,t)}function Nf(n,r,e,t){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let o=r.uniforms[`f${r.id}_intensity`];return o?(o.value=e.intensity*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="visible")){let o=r.uniforms[`f${r.id}_alpha`];if(!o)return;if(o.value=yn(e.alpha,t)*(e.visible?1:0),e.type==="outline"&&n==="visible"){let i=r.uniforms[`f${r.id}_compensation`];i&&(i.value=e.compensation&&e.visible)}return o}}function Cu(n,r){let e=0,t=n.layers.find(o=>o.data.type==="light");if(t){let o=t.data,i=Number(r.getVariable(o.alphaOverride));if((typeof o.alphaOverride=="string"?i/100:o.alphaOverride)<1)return!0}for(let o of n.layers){if(o.data.type!=="displace"&&o.data.isMask)return!0;if(o.data.type!=="displace"&&"alpha"in o.data&&o.data.type!=="light"&&o.data.type!=="fresnel"&&o.data.type!=="texture"&&o.data.type!=="matcap"&&o.data.type!=="rainbow"&&o.data.type!=="outline"&&o.data.type!=="pattern"){let i=o.data.visible?o.data.alpha:0;if(typeof i=="string"&&(i=Math.max(0,Math.min(1,Number(r.getVariable(i)??100)/100))),i===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let a of o.data.colors)if(a[3]<1){i=a[3];break}}else if(i===1&&o.data.type==="noise"){let a=r.color(o.data.colorA).a,s=r.color(o.data.colorB).a,l=r.color(o.data.colorC).a,c=r.color(o.data.colorD).a,u=Math.min(a,Math.min(s,Math.min(l,c)));u<1&&(i=u)}e+=(1-e)*i}}return e<1}var rr=class extends FN{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.nodeContextUuid=0;this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return""}},Tu=class extends rr{constructor(e,t,o,i){super();this.flatShading=e;this.side=t;this.wireframe=o;this.root=i}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,o){return this.root.getFlavor(e,t,o)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,t,o){this.root.updateByOp(e,t,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},Qn=class extends rr{constructor(e,t,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],it.startContext(this),this.reset0(e,t),it.endContext(this)}get nodeMaterial(){return this}getFlavor(e,t,o){let i=o?6:(e?3:0)+t;if(i===0)return this;this.flavors===void 0&&(this.flavors=[]),i-=1;let a=this.flavors[i];return a===void 0&&(a=new Tu(e,t,o,this),this.flavors[i]=a,a.flatShading=e,a.side=t,a.updateAfterBuild()),a}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,t,o=!1){(this.data!==e||o)&&this.reset0(e,t)}reset0(e,t){this.data=e;let o=e.layers??Lt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(i=>gn.create(this.layerIdGen++,i.id,i.data,t.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(t.shared),this.transparent=Cu(e,t.shared),this.saveVariableLocations(t)}onVariableUpdate(e,t,o){if(e[0]==="alphaOverride")this.transparent=Cu(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));else if(e[0]==="layer"){let i=e[1],a=e[2];if(i&&a){let s=this.layers.find(l=>l.uuid===i);s?.hasValue(a)&&(a==="alpha"?(this.transparent=Cu(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(t)/100,1)))):s.setValue(a,t))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers.find(o=>o.data.type==="light");t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(o=>{"alpha"in o.data&&typeof o.data.alpha=="string"&&e.shared.getVariable(o.data.alpha,["material",this.uuid,"layer",o.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(t=>t instanceof Yt),this.lightLayer===void 0&&(this.lightLayer=new Yt(0,"",{...xt.defaultData("light","phong"),visible:!1},new Lo,{},e)),this.dispose();for(let t of this.flavors)t&&t.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}applyTextureMaps(){let e=this.layers.find(a=>a instanceof Yt);if(!e)return;let t=e.data,o=t.bumpMap,i=t.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let a=0;a<this.layers.length;++a){let s=this.layers[a];s instanceof et&&s.color instanceof hn&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===i&&(e.node.roughnessMap=s.color))}}updateByOp(e,t,o){if(it.startContext(this),t!==void 0?this.data=t:t=this.data,this.transparent=Cu(t,o.shared),e.path[0]==="layers"){let i=o.shared,a=e.path[1];if(a===void 0)o.scene.markNeedsUpdateRendererDirty(),this.reset0(t,o);else{e.type===0&&e.props.occlusion!==void 0&&o.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(l=>l.uuid===a);if(s){let l=t.layers.data(a),c;e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?c={...e.props,alpha:yn(e.props.alpha,i,["material",this.uuid,"layer",a,"alpha"])}:c={...e.props,alphaOverride:yn(e.props.alphaOverride,i,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...c?{props:c}:{},path:e.path.slice(2)},l,o)&&this.reset0(t,o)}}}else this.reset0(t,o);it.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof et?t.color.mask=void 0:t instanceof Yt&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof et&&t.isMask.value&&t.data.visible&&e>0){let o=e-1,i=this.layers[o];i instanceof Yt?i.node.mask=new Dt(t.color,t.alpha,Dt.MUL):i instanceof et&&(i.isMask.value||(i.color.mask=new Dt(t.color,t.alpha,Dt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof et),t=this.layers.findIndex(o=>o instanceof Yt);if(e!==-1&&e<t){let o=this.layers[e].color;for(let i=e+1;i<t;++i){let a=this.layers[i];if(a instanceof et){if(a.isMask.value)continue;o=new _a(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Ue("outgoingLight","f"),t=this.layers.findIndex(o=>o instanceof Yt);if(this.layers.length>t+1){for(let o=t+1;o<this.layers.length;++o){let i=this.layers[o];if(i instanceof et){if(i.isMask.value)continue;e=new _a(e,i.color,i.alpha,i.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof rl);if(e.length>0){let t=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(t=new Dt(t,e[o].position,Dt.ADD),t=new Dt(t,new se(.5).setReadonly(!0),Dt.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){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}clampUniformsForPreview(e,t){let o=(i,a,s)=>Math.min(Math.max(i,a),s);for(let i of this.layers)if(i.type==="displace"){let a=o(i.uniforms[`f${i.id}_intensity`].value,e,t);i.uniforms[`f${i.id}_intensity`].value=a}}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new Da;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let t of this.flavors)t&&t.updateAfterBuild();return this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof et){let t=e.params.texture;if(t instanceof Yn&&!t.image.loaded)return!1}return!0}};Object.defineProperties(rr.prototype,{properties:{get:function(){return this.fragment.properties}}});var Zn=class extends Qn{constructor(r,e,t){super(r,e,!1),this.uuid=t,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var db=new Map;function pb(n){if(typeof n=="string")return n;let r=db.get(n);return r||(r={url:URL.createObjectURL(new Blob([n]))},db.set(n,r)),r.url}var UN,fb=new Promise(n=>{UN=n});var hb;fb.then(n=>hb=n);var Jn=class{constructor({src:r,volume:e,delay:t,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let i;typeof r=="string"?i={src:r}:i={src:pb(r),format:"wav"},this.sound=new hb.Howl(i),this.sound.on("end",this.onEnd),this.src=r,e!==void 0&&(this.volume=e),t!==void 0&&(this.delay=t),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(r){this._volume=r,this.sound.volume(r)}get loop(){return this._loop}set loop(r){this._loop=r,this.loopsRemaining=r}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(r,e=1e3){r?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},r)):this.sound.fade(this._volume,0,e)}on(r,e,t){this.sound.on(r,e,t)}off(r,e,t){this.sound.off(r,e,t)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(r=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};import{Box2 as kN,Vector2 as ei,Path as mb,Shape as HN,ShapeUtils as WN,Color as qN}from"three";var Au=class{constructor(){this.type="ShapePath";this.color=new qN;this.subPaths=[];this.currentPath=null}moveTo(r,e){return this.currentPath=new mb,this.subPaths.push(this.currentPath),this.currentPath.moveTo(r,e),this}lineTo(r,e){return this.currentPath?.lineTo(r,e),this}quadraticCurveTo(r,e,t,o){return this.currentPath?.quadraticCurveTo(r,e,t,o),this}bezierCurveTo(r,e,t,o,i,a){return this.currentPath?.bezierCurveTo(r,e,t,o,i,a),this}splineThru(r){return this.currentPath?.splineThru(r),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function o(m,y,g,v){let O=m.x,P=y.x,S=g.x,T=v.x,I=m.y,x=y.y,_=g.y,D=v.y,A=(T-S)*(I-_)-(D-_)*(O-S),N=(P-O)*(I-_)-(x-I)*(O-S),E=(D-_)*(P-O)-(T-S)*(x-I),B=A/E,V=N/E;if(E===0&&A!==0||B<=0||B>=1||V<0||V>1)return null;if(A===0&&E===0){for(let j=0;j<2;j++)if(i(j===0?g:v,m,y),t.loc===e.ORIGIN){let R=j===0?g:v;return{x:R.x,y:R.y,t:t.t}}else if(t.loc===e.BETWEEN){let R=+(O+t.t*(P-O)).toPrecision(10),W=+(I+t.t*(x-I)).toPrecision(10);return{x:R,y:W,t:t.t}}return null}else{for(let W=0;W<2;W++)if(i(W===0?g:v,m,y),t.loc===e.ORIGIN){let F=W===0?g:v;return{x:F.x,y:F.y,t:t.t}}let j=+(O+B*(P-O)).toPrecision(10),R=+(I+B*(x-I)).toPrecision(10);return{x:j,y:R,t:B}}}function i(m,y,g){let v=g.x-y.x,O=g.y-y.y,P=m.x-y.x,S=m.y-y.y,T=v*S-P*O;if(m.x===y.x&&m.y===y.y){t.loc=e.ORIGIN,t.t=0;return}if(m.x===g.x&&m.y===g.y){t.loc=e.DESTINATION,t.t=1;return}if(T<-Number.EPSILON){t.loc=e.LEFT;return}if(T>Number.EPSILON){t.loc=e.RIGHT;return}if(v*P<0||O*S<0){t.loc=e.BEHIND;return}if(Math.sqrt(v*v+O*O)<Math.sqrt(P*P+S*S)){t.loc=e.BEYOND;return}let I;v!==0?I=P/v:I=S/O,t.loc=e.BETWEEN,t.t=I}function a(m,y){let g=[],v=[];for(let O=1;O<m.length;O++){let P=m[O-1],S=m[O];for(let T=1;T<y.length;T++){let I=y[T-1],x=y[T],_=o(P,S,I,x);_!==null&&g.find(D=>D.t<=_.t+Number.EPSILON&&D.t>=_.t-Number.EPSILON)===void 0&&(g.push(_),v.push(new ei(_.x,_.y)))}}return v}function s(m,y,g){let v=new ei;y.getCenter(v);let O=[];return g.forEach(P=>{P.boundingBox.containsPoint(v)&&a(m,P.points).forEach(T=>{O.push({identifier:P.identifier,isCW:P.isCW,point:T})})}),O.sort((P,S)=>P.point.x-S.point.x),O}function l(m,y,g,v,O){(O==null||O==="")&&(O="nonzero");let P=new ei;m.boundingBox.getCenter(P);let S=[new ei(g,P.y),new ei(v,P.y)],T=s(S,m.boundingBox,y);T.sort((N,E)=>N.point.x-E.point.x);let I=[],x=[];T.forEach(N=>{N.identifier===m.identifier?I.push(N):x.push(N)});let _=I[0].point.x,D=[],A=0;for(;A<x.length&&x[A].point.x<_;)D.length>0&&D[D.length-1]===x[A].identifier?D.pop():D.push(x[A].identifier),A++;if(D.push(m.identifier),O==="evenodd"){let N=D.length%2===0,E=D[D.length-2];return{identifier:m.identifier,isHole:N,for:E}}else if(O==="nonzero"){let N=!0,E=null,B=null;for(let V=0;V<D.length;V++){let j=D[V];y[j]&&(N?(B=y[j].isCW,N=!1,E=j):B!==y[j].isCW&&(B=y[j].isCW,N=!0))}return{identifier:m.identifier,isHole:N,for:E}}else console.warn('fill-rule: "'+O+'" is currently not implemented.')}let c=0,u=999999999,p=-999999999,d=[];this.subPaths.forEach(m=>{let y=m.getPoints(),g=-999999999,v=999999999,O=-999999999,P=999999999;for(let S=0;S<y.length;S++){let T=y[S];T.y>g&&(g=T.y),T.y<v&&(v=T.y),T.x>O&&(O=T.x),T.x<P&&(P=T.x)}p<=O&&(p=O+1),u>=P&&(u=P-1),y.length&&d.push({curves:m.curves,points:y,isCW:WN.isClockWise(y),identifier:c++,boundingBox:new kN(new ei(P,v),new ei(O,g))})});let h=d.map(m=>l(m,d,u,p,this.userData?.style.fillRule)),f=[];return d.forEach(m=>{let y=h[m.identifier];if(y&&!y.isHole){let g=new HN;g.curves=m.curves,h.filter(O=>O?.isHole&&O.for===m.identifier).forEach(O=>{if(O){let P=d[O.identifier],S=new mb;S.curves=P.curves,g.holes.push(S)}}),f.push(g)}}),f}};var Df=!1,gb,Ef=new Promise(n=>{gb=n}),yb=!1;var Mu;function xb(){if(Df=!0,yb)return;if(Mu)return Mu;async function n(){let e=await import("./opentype.js");gb(e),yb=!0}return Mu=n(),Mu}var ol=class{async load(r,e,t=()=>{}){let{load:o}=await Ef;o(r,(i,a)=>{i||!a?t(i??"Something went wrong"):e(a)})}async parse(r){let{parse:e,Bidi:t}=await Ef;try{let o=e(r),i=new t,a=s=>o.charToGlyphIndex(s.char);return i.registerModifier("glyphIndex",null,a),i.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:i}}catch(o){console.error(o)}}};async function $N(n){return await(await fetch(n)).arrayBuffer()}var YN=new ol;async function _f(n){let r,e,t=!1;if(n.url?(r=await $N(n.url),e=n.url,t=n.url.startsWith("/")):n.data&&(r=n.data.buffer.slice(n.data.byteOffset,n.data.byteOffset+n.data.byteLength)),r)if(Df){let o=await YN.parse(r);if(o)return{font:o.font,url:e,intercepted:t,arr:r,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:t,arr:r,bidi:null}}import{CubicBezierCurve as XN,LineCurve as KN,QuadraticBezierCurve as QN}from"three";function ZN(n,r){return r.state.glyphIndex===n||r.state.fina===n||r.state.medi===n||r.state.init===n}var Iu=class{constructor(r){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=r.isUserFont??!1,this._loadingPromise=_f(r).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(r){this._isLoaded=!1,this._isUserFont=r.isUserFont??!1,this._loadingPromise=_f(r).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(r,e,t){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let i=o.tokenizer.tokens,a=[],s=0,l=t.length===i.length;for(let c=0;c<t.length;c++){let u=t[c].index,p=String.fromCharCode(t[c].unicode),d=i[s];if(ZN(u,d)||l)a.push({char:p,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),s++;else{let h=d.char,f="",m=[d.state.glyphIndex],y=[],g=!1;for(;!g;)s++,f=e.charAt(s),h+=f,m.push(r.charToGlyphIndex(f)),y=r.stringToGlyphs(h),y.length===1&&y[0].index===u&&(g=!0),s>e.length&&(g=!0);a.push({char:p,index:u,replacements:m,replacementChars:Array.from(h)}),s++}}return a}generateShapes(r,e){if(!this._isLoaded)return;let t=this.font,o=e.fontSize/this.unitsPerEm,i=e.fontSize*e.lineHeight,a=r.map(v=>this.getTextWidth(v,e)),s=e.width,l=this.getCharWidth(`
2225
+ `)}return t}};import{VideoTexture as vN,Texture as SN,CanvasTexture as wN}from"three";var vu=class{constructor(r=1e3*10){this.timeout=r;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...r){}remove(r){let e=this.cache.get(r);e&&(this.dispose(r,e.data),this.cache.delete(r),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let r=Date.now(),e=this.head.next;for(;e.time<r-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(r){return this.cache.get(r)?.data}load(r){let e=Date.now(),t=this.cache.get(r);return t===void 0?(t={data:this.create(r),src:r,time:e,next:null,prev:null},this.cache.set(r,t)):(t.time=e,t.prev.next=t.next,t.next.prev=t.prev),t.prev=this.tail.prev,t.next=this.tail,this.tail.prev.next=t,this.tail.prev=t,this.scheduleCleanup(),t.data}};var Af=class extends vu{create(r){return URL.createObjectURL(new Blob([r]))}dispose(r,e){URL.revokeObjectURL(e)}},Tf;function cb(n){return typeof n=="string"?n:(Tf||(Tf=new Af),Tf.load(n))}var Su=class{constructor(r,e){this.data=r;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},wu=class{constructor(){this.cache=new Map}remove(r){if(this.cache.delete(r.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(r){let e=this.cache.get(r);return e===void 0&&(e=this.create(r),this.cache.set(r,e)),e.refCount+=1,e}};var qa=class extends Su{constructor(e,t){super(e,t.imageHolderCache);this.data=e;this.shared=t;this.loaded=!1;this.isVideo=!1;this.isCanvas=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isCanvas=e.nodeName==="CANVAS",this.updateSrc(this.isCanvas?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;for(let i of Object.values(this._cache))for(let a of Object.values(i))a&&(a.image=this.img,a.needsUpdate=!0);this.shared.requestRender()};if(this.isCanvas)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var o=new FileReader;o.readAsDataURL(new Blob([e],{type:"video/mp4"}));let i;await new Promise(a=>{o.onloadend=s=>{i=s.target?.result,a(null)}}),this.img.src=i}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=cb(e),this.img.onload=t}getTexture(e,t=1008){let o=this._cache[e]?.[t];if(o)return o;{let i;return this.isCanvas&&(i=new wN(this.img,void 0,e,e,void 0,t)),this.isVideo?i=new vN(this.img,void 0,e,e):i=new SN(this.img,void 0,e,e,void 0,t),this.loaded&&(i.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][t]=i,i}}setNeedsUpdate(e){for(let t of Object.values(this._cache))for(let o of Object.values(t))o&&(o.needsUpdate=e)}disposeTextures(){for(let[e,t]of Object.entries(this._cache))for(let[o,i]of Object.entries(t))i?.dispose(),this._cache[e][o]=void 0}dispose(){super.dispose(),this.disposeTextures()}};var dr=class extends qa{};import{Vector2 as Vo,Vector3 as so,Vector4 as Pu}from"three";function Gt(n,r){return r.color(n)}function ub(n,r){switch(n.type){case"fresnel":return CN(n,r);case"gradient":return TN(n,r);case"depth":return AN(n,r);case"normal":return MN(n,r);case"noise":return IN(n,r);case"rainbow":return NN(n,r);case"toon":return DN(n,r);case"outline":return EN(n,r);case"transmission":return _N(n,r);case"color":return ON(n,r);case"pattern":return BN(n,r)}}function PN(n){return{type:n.type}}function jr(n,r){let{alpha:e,mode:t,isMask:o}=n,i=typeof e=="string"?(Number(r.getVariable(e))??100)/100:e;return{...PN(n),alpha:i,mode:t,isMask:o}}function ON(n,r){return{...jr(n,r),color:Gt(n.color,r)}}function CN(n,r){let{bias:e,scale:t,intensity:o,factor:i,color:a}=n;return{...jr(n,r),color:Gt(a,r),bias:e,scale:t,intensity:o,factor:i}}function TN(n,r){let{gradientType:e,smooth:t,colors:o,steps:i,angle:a,offset:s,morph:l}=n;return{...jr(n,r),gradientType:e,smooth:t,colors:o.map(c=>new Pu(c[0],c[1],c[2],c[3])),num:o.length,steps:i,offset:new Vo(...s),morph:new Vo(...l),angle:a}}function AN(n,r){let{gradientType:e,near:t,far:o,isVector:i,isWorldSpace:a,origin:s,direction:l,colors:c,steps:u,smooth:p}=n;return{...jr(n,r),gradientType:e,near:t,far:o,isVector:i,isWorldSpace:a,origin:new so(...s),direction:l?new so(...l):new so(1,0,0),colors:c.map(d=>d!==void 0?new Pu(d[0],d[1],d[2],d[3]):new Pu(0,0,0,0)),steps:u.slice(0,c.length),smooth:p}}function MN(n,r){let{cnormal:e}=n;return{...jr(n,r),cnormal:new so(e[0],e[1],e[2])}}function IN(n,r){return{...jr(n,r),scale:n.scale,move:n.move,fA:new Vo(...n.fA),fB:new Vo(...n.fB),size:new so(...n.size),distortion:new Vo(...n.distortion),colorA:Gt(n.colorA,r),colorB:Gt(n.colorB,r),colorC:Gt(n.colorC,r),colorD:Gt(n.colorD,r),noiseType:n.noiseType,voronoiStyle:n.voronoiStyle,highCut:n.highCut,lowCut:n.lowCut,smoothness:n.smoothness,seed:n.seed,quality:n.quality}}function NN(n,r){return{...jr(n,r),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new so(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new so(...n.offset)}}function DN(n,r){return{...jr(n,r),positioning:n.positioning,colors:n.colors.map(e=>new Pu(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new so(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:Gt(n.shadowColor,r),offset:new so(...n.offset)}}function EN(n,r){return{...jr(n,r),outlineColor:Gt(n.outlineColor,r),contourColor:Gt(n.contourColor,r),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new so(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function _N(n,r){return{...jr(n,r),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function BN(n,r){return{...jr(n,r),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new Vo(...n.offset),colorA:Gt(n.colorA,r),colorB:Gt(n.colorB,r),frequency:new Vo(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new Vo(...n.vertical),horizontal:new Vo(...n.horizontal),sides:n.sides}}var mn=class extends Ct{};import{MathUtils as LN,Vector4 as RN}from"three";var Mf={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},If={depth:["colors"]};function VN(n,r,e){if(r==="isMask")return!0;let t=Mf[n.type],o=If[n.type];if(o!==void 0){let i=n.color;if(o.includes(r)){let a=i[r]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return t!==void 0?t.includes(r):!1}function Nf(n,r,e){let t=e.uniforms[`f${e.id}_texture`];if(!t)return!1;let o=!1,i=n;if("image"in i){let a=i.image,s=r.image(a),l=t;l.image instanceof dr||l.image.deref(),l.image=s}if("video"in i){let a=i.video,s=r.video(a),l=t;l.image instanceof dr||l.image.deref(),l.image=s}if("wrapping"in i){let a=t;a.wrap=i.wrapping}if("minFilter"in i){let a=t;a.minFilter=i.minFilter}if("rotation"in i&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(i.rotation??0)*LN.DEG2RAD,o;if("repeat"in i||"offset"in i||"rotation"in i){let a="mat",s=e.uniforms[`f${e.id}_${a}`];"repeat"in i&&(s.repeat=i.repeat),"offset"in i&&(s.offset=i.offset),"rotation"in i&&(s.rotation=i.rotation??0),s.updateMatrix()}return o}function db(n,r,e,t){let o=!1;for(let[i,a]of Object.entries(n)){if(i==="bumpMap"||i==="roughnessMap"){o=!0;continue}if(!i||a===void 0)continue;if(Df(i,e,t,r)){i==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=t.visible;let s=e.uniforms[`f${e.id}_${i}`];if(!!s&&!(s instanceof fn))switch(o=o||VN(e,i,a),s.constructor){case He:if(typeof a=="string"){let l=r.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof mn?s.value=new Ct(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case er:if(typeof a=="string"){let l=r.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof mn?s.value=new Ct(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case it:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case Vt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case $t:{Nf(a,r,e);break}case Gr:{s.value=a.map(l=>new RN(...l));break}default:{s.value=a;break}}}return o}var yn=(n,r,e)=>Math.max(0,Math.min(1,Number(r.getVariable(typeof n=="number"?n*100:n,e)??100)/100))??1,co=class{constructor(r,e,t,o,i){this.id=r;this.uuid=e;this.data=t;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in t)Df(a,this,t,i)}get type(){return this.data.type}static create(r,e,t,o){if(t.type==="light")return Yt.createLigherLayer(r,e,t,o);if(t.type==="texture"||t.type==="video"){let i=t.type==="texture"?o.canvas(t.texture.image)??o.image(t.texture.image):o.video(t.texture.video),a=new $n(i,t.texture.wrapping,t.texture.minFilter??1008),s=new xu(i),l=new bu(t.texture.repeat,t.texture.offset,t.texture.rotation??0),c=new se(t.crop?1:0),u=new _e(t.projection??0),p=new _e(["x","y","z"].indexOf(t.axis)??0),d=new _e(t.side??0),h=new it(t.size?new Fr(t.size[0],t.size[1]):new Fr(100,100)),f=new se(t.blending??0),m=new se(yn(t.alpha,o)),y=new _e(t.mode??0),g=new dt(t.isMask??!1),v=new hn(a,s,c,u,p,d,h,f,l,m,y,g),O=new Ue(v.calpha,"f");return new et(r,e,t,{texture:a,textureSize:s,crop:c,projection:u,axis:p,side:d,size:h,blending:f,mat:l,alpha:m,mode:y,isMask:g},v,y,O,g,o)}else if(t.type==="matcap"){let i=o.image(t.texture.image),a=new $n(i,t.texture.wrapping,t.texture.minFilter??1008),s=new se(yn(t.alpha,o)),l=new _e(t.mode??0),c=new dt(t.isMask??!1),u=new se(t.texture.rotation??0),p=new za(a,s,l,c,u),d=new Ue(p.calpha,"f");return new et(r,e,t,{texture:a,alpha:s,mode:l,isMask:c,rotation:u},p,l,d,c,o)}else if(t.type==="displace")if(t.displacementType==="noise"){let i=new Vt(new lo(...t.offset)),a=new se(t.scale??10),s=new se(t.intensity??8),l=new se(t.movement??1),c=new _e(t.noiseType??0),u=new _e(t.voronoiStyle??0),p=new se(t.smoothness??.5),d=new se(t.seed??0),h=new se(t.highCut??1),f=new se(t.lowCut??0),m=new _e(t.quality??1),y=new Wa(s,l,i,u,p,d,h,f,m,a,c);return new tl(r,e,t,{offset:i,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:u,smoothness:p,seed:d,highCut:h,lowCut:f,quality:m},y,o)}else throw new Error;else return jN(r,e,t,o)}updateByOp(r,e,t){let o=r;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props?(t.scene.markNeedsUpdateRendererDirty(),!0):db(o.props,t.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Nf(o.props,t.shared,this):!0;return!1}dispose(){if(zN(this)){let r=this.uniforms[`f${this.id}_texture`];if(!r)return!1;let e=r;e.image instanceof dr||e.image.deref()}}hasValueByKey(r){return this.uniforms[r]!==void 0}hasValue(r){return this.hasValueByKey(`f${this.id}_${r}`)}setValue(r,e){let t=`f${this.id}_${r}`;this.hasValueByKey(t)&&e!==void 0&&(this.uniforms[t].value=e)}getNode(r){let e=`f${this.id}_${r}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(r){let e=`f${this.id}_${r}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(r){let t=/f\d+_(.*)/.exec(r);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${r}`)}getNames(){let r=[];for(let e in this.uniforms){let t=this.getName(e);t&&r.push(t)}return r}},et=class extends co{constructor(e,t,o,i,a,s,l,c,u){super(e,t,o,i,u);this.params=i;this.color=a;this.mode=s;this.alpha=l;this.isMask=c}},tl=class extends co{constructor(e,t,o,i,a,s){super(e,t,o,i,s);this.position=a}},Yt=class extends co{constructor(e,t,o,i,a,s){super(e,t,o,a,s);this.node=i}static createLigherLayer(e,t,o,i){let a,s=new se(yn(o.alpha,i)),l=new _e(o.mode),c=new se(o.bumpMapIntensity),u=new se(yn(o.alphaOverride,i)),p;if(!o.visible)a=new Lo,p={};else if(o.category==="lambert"){a=new Qs;let d=new He(i.color(o.emissive)??0),h=new dt(o.occlusion??!0);p={emissive:d,occlusion:h},a.emissive=d,a.occlusion=h}else if(o.category==="toon"){a=new el;let d=new se(o.shininess??30),h=new He(i.color(o.specular)??1118481);p={shininess:d,specular:h},a.shininess=d,a.specular=h}else if(o.category==="physical"){a=new Js;let d=new se(o.roughness??.3),h=new se(o.metalness??0),f=new se(o.reflectivity??.5),m=new dt(o.occlusion??!0);p={roughness:d,metalness:h,reflectivity:f,occlusion:m},a.roughness=d,a.metalness=h,a.reflectivity=f,a.occlusion=m}else{a=new Zs;let d=new se(o.shininess??30),h=new He(o.specular!==void 0?i.color(o.specular)??1118481:1118481),f=new dt(o.occlusion??!0);p={shininess:d,specular:h,occlusion:f},a.shininess=d,a.specular=h,a.occlusion=f}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=c,a.alphaOverride=u,p.alpha=a.shadingAlpha,p.mode=a.shadingBlend,p.bumpMapIntensity=a.bumpMapIntensity,p.alphaOverride=a.alphaOverride,new Yt(e,t,o,a,p,i)}get category(){return this.node.category}};function zN(n){let r=n instanceof co?n.type:n;return r==="texture"||r==="video"||r==="displace_map"||r==="matcap"}function vr(n){return{alpha:new se(n.alpha??1),mode:new _e(n.mode??0),isMask:new dt(n.isMask??!1)}}function GN(n,r,e,t,o){switch(n.type){case"color":{let i=new He(t.color??ft),a=vr(t),s=new Yn(i,a.alpha),l=new Ue(s.calpha,"f");return new et(r,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let i=new He(t.color??16777215),a=new se(t.bias??.1),s=new se(t.scale??1),l=new se(t.intensity??2),c=new se(t.factor??1),u=vr(t),p=new Xs(i,a,s,l,c,u.alpha,u.mode,u.isMask),d=new Ue(p.calpha,"f");return new et(r,e,n,{color:i,bias:a,scale:s,intensity:l,factor:c,...u},p,u.mode,d,u.isMask,o)}case"rainbow":{let i=new se(t.filmThickness??30),a=new se(t.movement??0),s=new Vt(t.wavelengths??new lo(0,0,0)),l=new se(t.noiseStrength??0),c=new se(t.noiseScale??1),u=new Vt(t.offset??new lo(0,0,0)),p=vr(t),d=new Ua(i,a,s,l,c,u,p.alpha,p.isMask),h=new Ue(d.calpha,"f");return new et(r,e,n,{filmThickness:i,movement:a,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...p},d,p.mode,h,p.isMask,o)}case"transmission":{let i=new se(t.thickness??10),a=new se(t.ior??1.5),s=new se(t.roughness??.5),l=Ae.transmissionSize,c=Ae.transmissionRenderTarget,u=Ae.transmissionRenderTargetDepth,p=window.innerWidth,d=window.innerHeight,h=p>=d?new it(d/p,1):new it(1,p/d),f=vr(t),m=new Ha(i,a,s,l,c,u,h,f.alpha),y=new Ue(m.calpha,"f");return new et(r,e,n,{thickness:i,ior:a,roughness:s,aspectRatio:h,...f},m,f.mode,y,f.isMask,o)}case"toon":{let i=new _e(t.positioning??0),a;t.colors?a=new Gr(t.colors.length,t.colors):(a=new Gr(10,new $a(0,0,0,1)),a.value[1]=new $a(1,1,1,1));let s;t.steps?s=new zr(t.steps.length,t.steps):(s=new zr(10,1),s.value[0]=0);let l=new Vt(t.source??new lo(0,0,0)),c=new dt(t.isWorldSpace??!0),u=new se(t.noiseStrength??0),p=new se(t.noiseScale??1),d=new er(t.shadowColor),h=new Vt(t.offset??new lo(0,0,0)),f=vr(t),m=new ka(i,a,s,l,c,u,p,d,h,f.alpha),y=new Ue(m.calpha,"f");return new et(r,e,n,{positioning:i,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:p,shadowColor:d,offset:h,...f},m,f.mode,y,f.isMask,o)}case"outline":{let i=new He(t.outlineColor??16777215),a=new He(t.contourColor??16777215),s=new se(t.outlineWidth??.1),l=new se(t.contourWidth??.1),c=new se(t.outlineThreshold??.1),u=new se(t.contourThreshold??.1),p=new se(t.outlineSmoothing??.1),d=new se(t.contourFrequency??.1),h=new Vt(t.contourDirection??new lo(0,1,0)),f=new dt(t.positionalLines??!1),m=new dt(t.compensation??!0),y=Ae.normalRenderTarget,g=Ae.normalRenderTargetDepth,v=Ae.pixelRatioNode,O=Ae.resolution,P=vr(t),S=new ja(i,a,s,l,c,u,p,d,h,f,m,O,y,g,v,P.alpha),T=new Ue(S.calpha,"f");return new et(r,e,n,{outlineColor:i,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:p,contourFrequency:d,contourDirection:h,positionalLines:f,compensation:m,...P},S,P.mode,T,P.isMask,o)}case"depth":{let i=new _e(t.gradientType??0),a=new dt(t.smooth??!1),s=new se(t.near??50),l=new se(t.far??200),c=new se(t.isVector??1),u=new se(t.isWorldSpace??0),p=new Vt(t.origin??new lo),d=new Vt(t.direction??new lo),h;t.colors?h=new Gr(t.colors.length,t.colors):(h=new Gr(2,new $a(0,0,0,1)),h.value[1]=new $a(1,1,1,1));let f;t.steps?f=new zr(t.steps.length,t.steps):(f=new zr(2,1),f.value[0]=0);let m=vr(t),y=new Ra(i,a,s,l,c,u,p,d,h,f,m.alpha,m.isMask),g=new Ue(y.calpha,"f");return new et(r,e,n,{gradientType:i,smooth:a,near:s,far:l,isVector:c,isWorldSpace:u,origin:p,direction:d,colors:h,steps:f,...m},y,m.mode,g,m.isMask,o)}case"noise":{let i=new se(t.scale??1),a=new Vt(t.size??new lo(100,100,100)),s=new se(t.move??1),l=new it(t.fA??new Fr(1.7,9.2)),c=new it(t.fB??new Fr(8.3,2.8)),u=new it(t.distortion??new Fr(1,1)),p=new er(t.colorA),d=new er(t.colorB),h=new er(t.colorC),f=new er(t.colorD),m=new _e(t.noiseType??0),y=new _e(t.voronoiStyle??0),g=new se(t.highCut??1),v=new se(t.lowCut??0),O=new se(t.smoothness??.5),P=new se(t.seed??.5),S=new _e(t.quality??1),T=vr(t),I=new Ga(i,a,s,l,c,u,p,d,h,f,T.alpha,m,T.isMask,y,g,v,O,P,S),x=new Ue(I.calpha,"f");return new et(r,e,n,{scale:i,size:a,move:s,fA:l,fB:c,distortion:u,colorA:p,colorB:d,colorC:h,colorD:f,noiseType:m,...T,voronoiStyle:y,highCut:g,lowCut:v,smoothness:O,seed:P,quality:S},I,T.mode,x,T.isMask,o)}case"normal":{let i=new Vt(t.cnormal??new lo(1,1,1)),a=vr(t),s=new _a(i,a.alpha),l=new Ue(s.calpha,"f");return new et(r,e,n,{cnormal:i,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let i=new _e(t.gradientType??0),a=new dt(t.smooth??!1),s;t.colors?s=new Gr(t.colors.length,t.colors):(s=new Gr(10,new $a(0,0,0,1)),s.value[1]=new $a(1,1,1,1));let l;t.steps?l=new zr(t.steps.length,t.steps):(l=new zr(10,1),l.value[0]=0);let c=new it(t.offset??new Fr(0,0)),u=new it(t.morph??new Fr(0,0)),p=new se(t.angle??0),d=vr(t),h=new Va(i,a,s,l,c,u,p,d.alpha,d.isMask),f=new Ue(h.calpha,"f");return new et(r,e,n,{gradientType:i,smooth:a,colors:s,steps:l,offset:c,morph:u,angle:p,...d},h,d.mode,f,d.isMask,o)}case"pattern":{let i=new _e(t.style??0),a=new _e(t.projection??0),s=new _e(["x","y","z"].indexOf(t.axis)??0),l=new se(t.blending??0),c=new it(t.offset??new Fr(0,0)),u=new er(t.colorA),p=new er(t.colorB),d=new it(t.frequency??new Fr(10,10)),h=new se(t.size??.5),f=new se(t.variation??0),m=new se(t.smoothness??.5),y=new se(t.zigzag??0),g=new se(t.rotation??0),v=new it(t.vertical??new Fr(0,1)),O=new it(t.horizontal??new Fr(0,1)),P=new _e(t.sides??6),S=vr(t),T=new Fa(i,a,s,l,c,u,p,d,h,f,m,y,g,v,O,P,S.alpha,S.isMask),I=new Ue(T.calpha,"f");return new et(r,e,n,{style:i,projection:a,axis:s,blending:l,offset:c,colorA:u,colorB:p,frequency:d,size:h,variation:f,smoothness:m,zigzag:y,rotation:g,vertical:v,horizontal:O,sides:P,...S},T,S.mode,I,S.isMask,o)}default:{let i=new He(1,0,0,1),a=vr(t),s=new Yn(i,a.alpha),l=new Ue(s.calpha,"f");return new et(r,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}}}function jN(n,r,e,t){let o=ub(e,t);return GN(e,n,r,o,t)}function Df(n,r,e,t){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let o=r.uniforms[`f${r.id}_intensity`];return o?(o.value=e.intensity*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="visible")){let o=r.uniforms[`f${r.id}_alpha`];if(!o)return;if(o.value=yn(e.alpha,t)*(e.visible?1:0),e.type==="outline"&&n==="visible"){let i=r.uniforms[`f${r.id}_compensation`];i&&(i.value=e.compensation&&e.visible)}return o}}function Ou(n,r){let e=0,t=n.layers.find(o=>o.data.type==="light");if(t){let o=t.data,i=Number(r.getVariable(o.alphaOverride));if((typeof o.alphaOverride=="string"?i/100:o.alphaOverride)<1)return!0}for(let o of n.layers){if(o.data.type!=="displace"&&o.data.isMask)return!0;if(o.data.type!=="displace"&&"alpha"in o.data&&o.data.type!=="light"&&o.data.type!=="fresnel"&&o.data.type!=="texture"&&o.data.type!=="matcap"&&o.data.type!=="rainbow"&&o.data.type!=="outline"&&o.data.type!=="pattern"){let i=o.data.visible?o.data.alpha:0;if(typeof i=="string"&&(i=Math.max(0,Math.min(1,Number(r.getVariable(i)??100)/100))),i===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let a of o.data.colors)if(a[3]<1){i=a[3];break}}else if(i===1&&o.data.type==="noise"){let a=r.color(o.data.colorA).a,s=r.color(o.data.colorB).a,l=r.color(o.data.colorC).a,c=r.color(o.data.colorD).a,u=Math.min(a,Math.min(s,Math.min(l,c)));u<1&&(i=u)}e+=(1-e)*i}}return e<1}var rr=class extends FN{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},Cu=class extends rr{constructor(e,t,o,i){super();this.flatShading=e;this.side=t;this.wireframe=o;this.root=i}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,o){return this.root.getFlavor(e,t,o)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,t,o){this.root.updateByOp(e,t,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},Kn=class extends rr{constructor(e,t,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.reset0(e,t)}get nodeMaterial(){return this}getFlavor(e,t,o){let i=o?6:(e?3:0)+t;if(i===0)return this;this.flavors===void 0&&(this.flavors=[]),i-=1;let a=this.flavors[i];return a===void 0&&(a=new Cu(e,t,o,this),this.flavors[i]=a,a.flatShading=e,a.side=t,a.updateAfterBuild()),a}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,t,o=!1){(this.data!==e||o)&&this.reset0(e,t)}reset0(e,t){this.data=e;let o=e.layers??Lt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(i=>co.create(this.layerIdGen++,i.id,i.data,t.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(t.shared),this.transparent=Ou(e,t.shared),this.saveVariableLocations(t)}onVariableUpdate(e,t,o){if(e[0]==="alphaOverride")this.transparent=Ou(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));else if(e[0]==="layer"){let i=e[1],a=e[2];if(i&&a){let s=this.layers.find(l=>l.uuid===i);s?.hasValue(a)&&(a==="alpha"?(this.transparent=Ou(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(t)/100,1)))):s.setValue(a,t))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers.find(o=>o.data.type==="light");t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(o=>{"alpha"in o.data&&typeof o.data.alpha=="string"&&e.shared.getVariable(o.data.alpha,["material",this.uuid,"layer",o.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(e){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(t=>t instanceof Yt),this.lightLayer===void 0&&(this.lightLayer=new Yt(0,"",{...gt.defaultData("light","phong"),visible:!1},new Lo,{},e)),this.dispose();for(let t of this.flavors)t&&t.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(a=>a instanceof Yt);if(!e)return;let t=e.data,o=t.bumpMap,i=t.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let a=0;a<this.layers.length;++a){let s=this.layers[a];s instanceof et&&s.color instanceof hn&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===i&&(e.node.roughnessMap=s.color))}}updateByOp(e,t,o){if(t!==void 0?this.data=t:t=this.data,this.transparent=Ou(t,o.shared),e.path[0]==="layers"){this.data=t;let i=o.shared,a=e.path[1];if(a===void 0){if(this.layers.reverse(),e.type===4){let s=co.create(this.layerIdGen++,e.id,e.data,o.shared);this.layers.splice(e.localIndex,0,s),o.scene.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),o.scene.markNeedsUpdateRendererDirty();else if(e.type===6){let s=this.layers.findIndex(c=>c.uuid===e.id),l=this.layers[s];this.layers.splice(s,1),this.layers.splice(e.localIndex,0,l),o.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate(o.shared)}else{e.type===0&&e.props.occlusion!==void 0&&o.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(l=>l.uuid===a);if(s){let l=t.layers.data(a),c;if(e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?c={...e.props,alpha:yn(e.props.alpha,i,["material",this.uuid,"layer",a,"alpha"])}:c={...e.props,alphaOverride:yn(e.props.alphaOverride,i,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...c?{props:c}:{},path:e.path.slice(2)},l,o)){let p=co.create(this.layerIdGen++,a,l,i);this.layers.splice(this.layers.findIndex(d=>d.uuid===a),1,p),this.onUpdate(o.shared)}}}}else this.reset(t,o)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof et?t.color.mask=void 0:t instanceof Yt&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof et&&t.isMask.value&&t.data.visible&&e>0){let o=e-1,i=this.layers[o];i instanceof Yt?i.node.mask=new Dt(t.color,t.alpha,Dt.MUL):i instanceof et&&(i.isMask.value||(i.color.mask=new Dt(t.color,t.alpha,Dt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof et),t=this.layers.findIndex(o=>o instanceof Yt);if(e!==-1&&e<t){let o=this.layers[e].color;for(let i=e+1;i<t;++i){let a=this.layers[i];if(a instanceof et){if(a.isMask.value)continue;o=new Ea(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Ue("outgoingLight","f"),t=this.layers.findIndex(o=>o instanceof Yt);if(this.layers.length>t+1){for(let o=t+1;o<this.layers.length;++o){let i=this.layers[o];if(i instanceof et){if(i.isMask.value)continue;e=new Ea(e,i.color,i.alpha,i.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof tl);if(e.length>0){let t=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(t=new Dt(t,e[o].position,Dt.ADD),t=new Dt(t,new se(.5).setReadonly(!0),Dt.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.build(),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}clampUniformsForPreview(e,t){let o=(i,a,s)=>Math.min(Math.max(i,a),s);for(let i of this.layers)if(i.type==="displace"){let a=o(i.uniforms[`f${i.id}_intensity`].value,e,t);i.uniforms[`f${i.id}_intensity`].value=a}}computeCacheKey(){let e="[";for(let{data:t}of this.data.layers)if(t.type==="light")e+=`"${t.visible?t.category.toUpperCase():"Basic"}"`;else{let o=(Mf[t.type]??[]).map(c=>t[c]),i=(If[t.type]??[]).map(c=>t[c]?.length??0),a=[...o,...i],s="isMask"in t&&t.isMask,l=`"${t.type}-${t.visible}-${s}"`;a.length?e+=`[${l}, "${a.join('","')}"],`:e+=l}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new Na;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let t of this.flavors)t&&t.updateAfterBuild();return this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof et){let t=e.params.texture;if(t instanceof $n&&!t.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(rr.prototype,{properties:{get:function(){return this.fragment.properties}}});var Qn=class extends Kn{constructor(r,e,t){super(r,e,!1),this.uuid=t,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var pb=new Map;function fb(n){if(typeof n=="string")return n;let r=pb.get(n);return r||(r={url:URL.createObjectURL(new Blob([n]))},pb.set(n,r)),r.url}var UN,hb=new Promise(n=>{UN=n});var mb;hb.then(n=>mb=n);var Zn=class{constructor({src:r,volume:e,delay:t,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let i;typeof r=="string"?i={src:r}:i={src:fb(r),format:"wav"},this.sound=new mb.Howl(i),this.sound.on("end",this.onEnd),this.src=r,e!==void 0&&(this.volume=e),t!==void 0&&(this.delay=t),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(r){this._volume=r,this.sound.volume(r)}get loop(){return this._loop}set loop(r){this._loop=r,this.loopsRemaining=r}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(r,e=1e3){r?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},r)):this.sound.fade(this._volume,0,e)}on(r,e,t){this.sound.on(r,e,t)}off(r,e,t){this.sound.off(r,e,t)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(r=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};import{Box2 as kN,Vector2 as Jn,Path as yb,Shape as HN,ShapeUtils as WN,Color as qN}from"three";var Tu=class{constructor(){this.type="ShapePath";this.color=new qN;this.subPaths=[];this.currentPath=null}moveTo(r,e){return this.currentPath=new yb,this.subPaths.push(this.currentPath),this.currentPath.moveTo(r,e),this}lineTo(r,e){return this.currentPath?.lineTo(r,e),this}quadraticCurveTo(r,e,t,o){return this.currentPath?.quadraticCurveTo(r,e,t,o),this}bezierCurveTo(r,e,t,o,i,a){return this.currentPath?.bezierCurveTo(r,e,t,o,i,a),this}splineThru(r){return this.currentPath?.splineThru(r),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function o(m,y,g,v){let O=m.x,P=y.x,S=g.x,T=v.x,I=m.y,x=y.y,_=g.y,D=v.y,A=(T-S)*(I-_)-(D-_)*(O-S),N=(P-O)*(I-_)-(x-I)*(O-S),E=(D-_)*(P-O)-(T-S)*(x-I),B=A/E,V=N/E;if(E===0&&A!==0||B<=0||B>=1||V<0||V>1)return null;if(A===0&&E===0){for(let j=0;j<2;j++)if(i(j===0?g:v,m,y),t.loc===e.ORIGIN){let R=j===0?g:v;return{x:R.x,y:R.y,t:t.t}}else if(t.loc===e.BETWEEN){let R=+(O+t.t*(P-O)).toPrecision(10),W=+(I+t.t*(x-I)).toPrecision(10);return{x:R,y:W,t:t.t}}return null}else{for(let W=0;W<2;W++)if(i(W===0?g:v,m,y),t.loc===e.ORIGIN){let F=W===0?g:v;return{x:F.x,y:F.y,t:t.t}}let j=+(O+B*(P-O)).toPrecision(10),R=+(I+B*(x-I)).toPrecision(10);return{x:j,y:R,t:B}}}function i(m,y,g){let v=g.x-y.x,O=g.y-y.y,P=m.x-y.x,S=m.y-y.y,T=v*S-P*O;if(m.x===y.x&&m.y===y.y){t.loc=e.ORIGIN,t.t=0;return}if(m.x===g.x&&m.y===g.y){t.loc=e.DESTINATION,t.t=1;return}if(T<-Number.EPSILON){t.loc=e.LEFT;return}if(T>Number.EPSILON){t.loc=e.RIGHT;return}if(v*P<0||O*S<0){t.loc=e.BEHIND;return}if(Math.sqrt(v*v+O*O)<Math.sqrt(P*P+S*S)){t.loc=e.BEYOND;return}let I;v!==0?I=P/v:I=S/O,t.loc=e.BETWEEN,t.t=I}function a(m,y){let g=[],v=[];for(let O=1;O<m.length;O++){let P=m[O-1],S=m[O];for(let T=1;T<y.length;T++){let I=y[T-1],x=y[T],_=o(P,S,I,x);_!==null&&g.find(D=>D.t<=_.t+Number.EPSILON&&D.t>=_.t-Number.EPSILON)===void 0&&(g.push(_),v.push(new Jn(_.x,_.y)))}}return v}function s(m,y,g){let v=new Jn;y.getCenter(v);let O=[];return g.forEach(P=>{P.boundingBox.containsPoint(v)&&a(m,P.points).forEach(T=>{O.push({identifier:P.identifier,isCW:P.isCW,point:T})})}),O.sort((P,S)=>P.point.x-S.point.x),O}function l(m,y,g,v,O){(O==null||O==="")&&(O="nonzero");let P=new Jn;m.boundingBox.getCenter(P);let S=[new Jn(g,P.y),new Jn(v,P.y)],T=s(S,m.boundingBox,y);T.sort((N,E)=>N.point.x-E.point.x);let I=[],x=[];T.forEach(N=>{N.identifier===m.identifier?I.push(N):x.push(N)});let _=I[0].point.x,D=[],A=0;for(;A<x.length&&x[A].point.x<_;)D.length>0&&D[D.length-1]===x[A].identifier?D.pop():D.push(x[A].identifier),A++;if(D.push(m.identifier),O==="evenodd"){let N=D.length%2===0,E=D[D.length-2];return{identifier:m.identifier,isHole:N,for:E}}else if(O==="nonzero"){let N=!0,E=null,B=null;for(let V=0;V<D.length;V++){let j=D[V];y[j]&&(N?(B=y[j].isCW,N=!1,E=j):B!==y[j].isCW&&(B=y[j].isCW,N=!0))}return{identifier:m.identifier,isHole:N,for:E}}else console.warn('fill-rule: "'+O+'" is currently not implemented.')}let c=0,u=999999999,p=-999999999,d=[];this.subPaths.forEach(m=>{let y=m.getPoints(),g=-999999999,v=999999999,O=-999999999,P=999999999;for(let S=0;S<y.length;S++){let T=y[S];T.y>g&&(g=T.y),T.y<v&&(v=T.y),T.x>O&&(O=T.x),T.x<P&&(P=T.x)}p<=O&&(p=O+1),u>=P&&(u=P-1),y.length&&d.push({curves:m.curves,points:y,isCW:WN.isClockWise(y),identifier:c++,boundingBox:new kN(new Jn(P,v),new Jn(O,g))})});let h=d.map(m=>l(m,d,u,p,this.userData?.style.fillRule)),f=[];return d.forEach(m=>{let y=h[m.identifier];if(y&&!y.isHole){let g=new HN;g.curves=m.curves,h.filter(O=>O?.isHole&&O.for===m.identifier).forEach(O=>{if(O){let P=d[O.identifier],S=new yb;S.curves=P.curves,g.holes.push(S)}}),f.push(g)}}),f}};var Ef=!1,xb,_f=new Promise(n=>{xb=n}),gb=!1;var Au;function bb(){if(Ef=!0,gb)return;if(Au)return Au;async function n(){let e=await import("./opentype.js");xb(e),gb=!0}return Au=n(),Au}var rl=class{async load(r,e,t=()=>{}){let{load:o}=await _f;o(r,(i,a)=>{i||!a?t(i??"Something went wrong"):e(a)})}async parse(r){let{parse:e,Bidi:t}=await _f;try{let o=e(r),i=new t,a=s=>o.charToGlyphIndex(s.char);return i.registerModifier("glyphIndex",null,a),i.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:i}}catch(o){console.error(o)}}};async function $N(n){return await(await fetch(n)).arrayBuffer()}var YN=new rl;async function Bf(n){let r,e,t=!1;if(n.url?(r=await $N(n.url),e=n.url,t=n.url.startsWith("/")):n.data&&(r=n.data.buffer.slice(n.data.byteOffset,n.data.byteOffset+n.data.byteLength)),r)if(Ef){let o=await YN.parse(r);if(o)return{font:o.font,url:e,intercepted:t,arr:r,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:t,arr:r,bidi:null}}import{CubicBezierCurve as XN,LineCurve as KN,QuadraticBezierCurve as QN}from"three";function ZN(n,r){return r.state.glyphIndex===n||r.state.fina===n||r.state.medi===n||r.state.init===n}var Mu=class{constructor(r){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=r.isUserFont??!1,this._loadingPromise=Bf(r).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(r){this._isLoaded=!1,this._isUserFont=r.isUserFont??!1,this._loadingPromise=Bf(r).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(r,e,t){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let i=o.tokenizer.tokens,a=[],s=0,l=t.length===i.length;for(let c=0;c<t.length;c++){let u=t[c].index,p=String.fromCharCode(t[c].unicode),d=i[s];if(ZN(u,d)||l)a.push({char:p,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),s++;else{let h=d.char,f="",m=[d.state.glyphIndex],y=[],g=!1;for(;!g;)s++,f=e.charAt(s),h+=f,m.push(r.charToGlyphIndex(f)),y=r.stringToGlyphs(h),y.length===1&&y[0].index===u&&(g=!0),s>e.length&&(g=!0);a.push({char:p,index:u,replacements:m,replacementChars:Array.from(h)}),s++}}return a}generateShapes(r,e){if(!this._isLoaded)return;let t=this.font,o=e.fontSize/this.unitsPerEm,i=e.fontSize*e.lineHeight,a=r.map(v=>this.getTextWidth(v,e)),s=e.width,l=this.getCharWidth(`
2226
2226
  `,e),c=e.horizontalAlign===1?l:0,u=this.computeSpaceWidthForLine(r,0,e),p=this.getLineInitialOffsetX(a[0],s,e.horizontalAlign,r[0],l),d=this.getLineInitialOffsetY(i,r.length,e.height,o,e.verticalAlign),h=[],f=r.map(v=>[]),m=r.map(v=>[]),y;for(let v=0;v<r.length;v++){let O=r[v],P={features:{liga:!0}},S=[];try{S=t.stringToGlyphs(O,P)}catch(I){console.warn(I)}p=this.getLineInitialOffsetX(a[v],s,e.horizontalAlign,O,l);let T=[];try{T=this.reverseLigaturesTable(t,O,S)}catch(I){console.warn(I)}u=this.computeSpaceWidthForLine(r,v,e);for(let I=0;I<S.length;I++){let x=S[I],_=x.index===0?`
2227
2227
  `:x.unicode?String.fromCharCode(x.unicode):void 0,D=T[I],A=0,N=0;I===0&&e.horizontalAlign===2&&x.leftSideBearing!==void 0&&(N=-x.leftSideBearing*o),y&&(A=t.getKerningValue(x,y)*o),p+=N+A;let E=0;if(_===`
2228
2228
  `)E=c;else if(_===" ")E=u;else{let B=this.createPath(x,o,p,d,e);B&&(E=B.offsetX-(A+N),h.push(B.path))}if(D.replacements.length===1)m[v].push([p,d]),f[v].push(E);else{let B=D.replacements.map(W=>(t.glyphs.get(W).advanceWidth??0)*o),V=B.reduce((W,F)=>W+=F,0),j=B.map(W=>W/V),R=p;for(let W=0;W<j.length;W++){let F=E*j[W];m[v].push([R,d]),f[v].push(F),R+=F}}p+=E,y=x}d-=i}let g=[];for(let v=0,O=h.length;v<O;v++)g.push(...h[v].toShapes());return{shapes:g,charWidths:f,lineWidths:a,charCoords:m}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(r,e,t,o,i){return(t===3||t===2)&&o.indexOf(`
2229
- `)>=0&&(r-=i),t===3?e*.5-r*.5:t===2?e-r:0}getLineInitialOffsetY(r,e,t,o,i){let a=e*r,s=Math.abs(this.ascender-this.descender)*o,l=r-s,c=-this.ascender*o-l/2;return i===3?-(t-a-c):i===2?-(t*.5-a*.5-c):c}createPath(r,e,t,o,i){let a=r.getPath(t,-o,i.fontSize,{kerning:!1,letterSpacing:i.letterSpacing});if(!a){console.error('THREE.Font: character "'+r+'" does not exists in font family '+this.familyName+".");return}let s=new Au,l=(r.advanceWidth??1)*e;if(r)for(let c of a.commands){let u=s.currentPath?.currentPoint;if(!(u&&c.type!=="Z"&&u.x===c.x&&-u.y===c.y))switch(c.type){case"M":s.moveTo(c.x,-c.y);break;case"L":s.lineTo(c.x,-c.y);break;case"Q":s.quadraticCurveTo(c.x1,-c.y1,c.x,-c.y);break;case"C":s.bezierCurveTo(c.x1,-c.y1,c.x2,-c.y2,c.x,-c.y);break}}return s.subPaths.forEach(c=>{let u=JN(c.curves);u!==void 0&&c.currentPoint.distanceTo(u)>0&&c.lineTo(u.x,u.y)}),{offsetX:l+i.fontSize*i.letterSpacing,path:s}}getCharWidth(r,e){return this.font?.getAdvanceWidth(r,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(r,e){return this.font?.getAdvanceWidth(r,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(r,e,t){let o=this.getCharWidth(" ",t),i=r[e];if(i){let a=this.countSpaces(i.trimEnd());if(t.horizontalAlign===4&&e<r.length-1&&a){let s=t.width,l=this.getTextWidth(i,t);return(s-(l-a*o))/a}}return o}countSpaces(r){return(r.match(/ /g)||[]).length}};function JN(n){if(n.length){let r=n[0];if(r instanceof KN)return r.v1;if(r instanceof XN||r instanceof QN)return r.v0}}var Bf=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(r){return this.objects.get(r)}get size(){return this.objects.size}get(r,e,t){let o=this.objects.get(r);return o===void 0?(o=this.createObject(r,e,t),this.objects.set(r,o)):o.isShared=!0,o}forceDelete(r){let e=this.objects.get(r);e&&(this.disposeObject(e),this.objects.delete(r))}mutateIfUnique(r,e){let t=this.objects.get(r);if(t&&t.isShared!==!0)return this.objects.delete(r),this.objects.set(e,t),t}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(r,e){let t=this.objects.get(r);e===t?this.unreachable.delete(r):!1&&console.warn("Reachable but deleted",r)}endGc(){this.unreachable.forEach(r=>{this.disposeObject(this.objects.get(r)),this.objects.delete(r)}),this.unreachable.clear()}dispose(){this.objects.forEach(r=>{this.disposeObject(r)}),this.objects.clear()}},nl=class extends Bf{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t,o){let i=_o(e,t,this.flatShading,o);return i.computeBoundingSphere(),i}};var bb={markNeedsUpdateRendererDirty:()=>{}};import{MathUtils as vb}from"three";var Lf=class extends Pu{constructor(e){super();this.shared=e}create(e){return new $a(e,this.shared)}},ti=class{constructor(r,e={}){this.data=r;this.geometryCache=new nl(!0);this.geometryCache2=new nl(!1);this.imageHolderCache=new Lf(this);this.thisContext={scene:bb,shared:this};this.deletedMaterial=new Zn(Lt.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new dr(Rc.emptyImage,this);this.deletedVideo=new dr($i.defaultVideo,this);this.materials={};this.images={};this.canvases={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.variables={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[t,o]of Object.entries(e.images))this.addImage(t,o);if(e.videos)for(let[t,o]of Object.entries(e.videos))this.addVideo(t,o);if(e.audios)for(let[t,o]of Object.entries(e.audios))this.addAudio(t,o);if(e.particles)for(let[t,o]of Object.entries(e.particles))this.addParticle(t,o);this.reset(r)}setRequestRender(r){this._requestRender=r}setEntityOpContext(r){this.entityOpContext=r}reset(r,e=!1){this.resetLib(r.lib);for(let{id:t,data:o}of r.variables)this.addVariableHolder(t,o),e&&this.updateVariableHolder(t,o);for(let[t,o]of Object.entries(r.images))this.addImage(t,o);for(let[t,o]of Object.entries(r.videos))this.addVideo(t,o);for(let[t,o]of Object.entries(r.colors))this.addColor(t,o);for(let[t,o]of Object.entries(r.materials))this.addMaterial(t,o);for(let[t,o]of Object.entries(r.audios))this.addAudio(t,o);for(let[t,o]of Object.entries(r.particles))this.addParticle(t,o);for(let[t,o]of Object.entries(r.fonts))this.addFont(t,o)}addMaterial(r,e){if(this.materials[r]){let t=this.materials[r];t.reset(e,this.thisContext),t.dispose()}else{let t=new Zn(e,this.thisContext,r);this.materials[r]=t}}deleteMaterial(r){this.materials[r]&&(this.materials[r].nodeMaterialDispose(),delete this.materials[r])}getMaterial(r){let e=this.materials[r];return e}getMaterialOrDeletedPlaceholder(r){return this.materials[r]??this.deletedMaterial}material(r){return typeof r=="string"?this.getMaterialOrDeletedPlaceholder(r):r==null?(console.error("material is undefined or null"),this.deletedMaterial):new Qn(r,this.thisContext)}getMaterials(){return this.materials}addImage(r,e){return this.images[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[r].updateSrc(e.data),!0):(this.images[r]=new dr(e,this),!1)}deleteImage(r){let e=this.images[r];e&&(e.dispose(),delete this.images[r])}getDefaultImage(){return this.images.image_0}getImage(r){return this.images[r]??this.deletedImage}image(r){return typeof r=="string"?this.getImage(r):this.imageHolderCache.load(r)}addCanvas(r,e){return this.canvases[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.canvases[r].updateSrc(e),!0):(this.canvases[r]=new dr(e,this),!1)}canvas(r){return this.canvases[r]}addVideo(r,e){return this.videos[r]?(this.videos[r].updateSrc(e.data),!0):(this.videos[r]=new dr(e,this),!1)}deleteVideo(r){let e=this.videos[r];e&&(e.dispose(),delete this.videos[r])}getVideo(r){return this.videos[r]??this.deletedVideo}video(r){return typeof r=="string"?this.getVideo(r):this.imageHolderCache.load(r)}addColor(r,e){return this.colors[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[r].setRGBA(e.r,e.g,e.b,e.a):this.colors[r].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[r]=new mn(e.r,e.g,e.b,e.a):this.colors[r]=new mn(e.r,e.g,e.b,1),!1)}updateColor(r,e){if(this.colors[r]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let t=this.colors[r];return this.colors[r].r=e.r??t.r,this.colors[r].g=e.g??t.g,this.colors[r].b=e.b??t.b,this.colors[r].a=e.a??t.a,!0}return!1}deleteColor(r){this.colors[r]&&delete this.colors[r]}getColor(r){return this.colors[r]}color(r){let e;if(typeof r=="string"){let t=this.getColor(r);t?e=t:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Tt(0,0,0,0))}else return"a"in r?new Tt(r.r,r.g,r.b,r.a):new Tt(r.r,r.g,r.b,1);return e}addAudio(r,e){this.audios[r]=e}getAudio(r){let e=this.audios[r];if(e instanceof Jn)return e;{let t=new Jn({src:e.data});return this.audios[r]=t,t}}addParticle(r,e){this.particles[r]=e}getParticle(r){return this.particles[r]}deleteParticle(r){this.particles[r]&&delete this.particles[r]}deleteAudio(r){let e=this.audios[r];e&&(e instanceof Jn&&e.dispose(),delete this.audios[r])}addFont(r,e){this.fonts[r]=new Iu(e),this.fonts[r].loadingPromise.then(()=>this.requestRender())}getFont(r){return this.fonts[r]}deleteFont(r){this.fonts[r]&&delete this.fonts[r]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Jn&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(r,e){return this.variables[r]===void 0?(this.variables[r]={value:e.value,locations:[]},"dynamicVariableType"in e&&(this.variables[r].dynamicVariablePlayState="Playing",this.variables[r].dynamicVariableToggleIsForward=void 0),!0):(this.variables[r].value=e.value,!1)}resetDynamicVariablePlayState(){for(let r in this.variables)this.variables[r].dynamicVariablePlayState!==void 0&&(this.variables[r].dynamicVariablePlayState="Playing",this.variables[r].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(r,e){this.updateVariable(r,e.value)}updateVariable(r,e){if(this.variables[r]===void 0)return!1;this.variables[r].value=e;let t=e;for(;typeof t=="string";)t=this.variables[t].value;let o=this.entityOpContext.scene;for(let i=this.variables[r].locations.length-1;i>=0;i--){let a=this.variables[r].locations[i];if(a[0]==="material"){let s=a[1],l=t,c={scene:o,shared:this},u=a.slice(2);o.traverseMaterial(d=>{let h=d.root??d;h.uuid===s&&h.onVariableUpdate(u,l,c)});let p=this.materials[s];p&&p.onVariableUpdate(u,l,c)}else{let s=o.find(a[0]);if(s===void 0){this.variables[r].locations.splice(i,1);continue}if(a[1]!=="geometry"&&a[1]!=="particles"){for(let l=1;l<a.length-1;l++)s=s[a[l]];a[1]==="rotation"?s[a[a.length-1]]=t*vb.DEG2RAD:s[a[a.length-1]]=t}if(s=o.find(a[0]),s.type==="ParticleEmitter"&&s.updateVariableState(t,a),Le.is(s)){if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")s.onVariableUpdate();else if(a[1]==="geometry"){let l=s;s.component&&(l=s.component);let c=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(c.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.instances.forEach(u=>{let p=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(p.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0)})}}}}return this.requestRender(),!0}deleteVariable(r){this.variables[r]&&delete this.variables[r]}getVariable(r,e){if(Array.isArray(r)){if(r[0]==="mouse")return this.mouseProperty?.[r[1]]??0;if(r[0]==="raycast")return this.raycastProperty?.[r[1]]??0;let t=this.entityOpContext.scene.find(r[0]);if(r[1]==="width"||r[1]==="height"||r[1]==="depth")return t.geometry.userData.parameters[r[1]];for(let o=1;o<r.length;o++)t=t[r[o]];return r[1]==="rotation"&&(t*=vb.RAD2DEG),t}for(let t in this.variables){if(e===void 0)break;let o=this.variables[t],i=o.locations?.findIndex(a=>rt.equal(a,e));i!==void 0&&i!==-1&&o.locations.splice(i,1)}if(typeof r=="string"){let t=r,o=r;do{if(o=t,this.variables[t]===void 0)break;t=this.variables[t].value}while(typeof t=="string");return e&&this.variables[o]!==void 0&&this.variables[o].locations.push(e),t}else return r}getVariables(){return this.variables}getDynamicVariablePlayState(r){return this.variables[r]?.dynamicVariablePlayState}setDynamicVariablePlayState(r,e){this.variables[r]!==void 0&&(this.variables[r].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(r){return this.variables[r]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(r,e){this.variables[r]!==void 0&&(this.variables[r].dynamicVariableToggleIsForward=e)}resetLib(r){for(let[e,t]of Object.entries(r.images))this.addImage(e,t.asset);for(let[e,t]of Object.entries(r.audios))this.addAudio(e,t.asset);for(let[e,t]of Object.entries(r.particles))this.addParticle(e,t.asset);for(let[e,t]of Object.entries(r.colors))this.addColor(e,t.asset);for(let[e,t]of Object.entries(r.fonts))this.addFont(e,t.asset);for(let[e,t]of Object.entries(r.materials))this.addMaterial(e,t.asset);for(let[e,t]of Object.entries(r.videos))this.addVideo(e,t.asset);for(let[e,t]of Object.entries(r.variables))this.addVariableHolder(e,t.asset)}updateLibByOp(r,e){r.path[0]==="images"?r.path.length===1&&r.type===1?this.addImage(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteImage(r.id):r.path[0]==="videos"?r.path.length===1&&r.type===1?this.addVideo(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteVideo(r.id):r.path[0]==="audios"?r.path.length===1&&r.type===1?this.addAudio(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteAudio(r.id):r.path[0]==="particles"?r.path.length===1&&r.type===1?this.addParticle(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteParticle(r.id):r.path[0]==="colors"?r.path.length===1&&r.type===1?this.addColor(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteColor(r.id):r.path[0]==="materials"?r.path.length===1&&r.type===1?this.addMaterial(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteMaterial(r.id):r.path[0]==="fonts"?r.path.length===1&&r.type===1?this.addFont(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteFont(r.id):r.path[0]==="variables"?r.path.length===1&&r.type===1?this.addVariableHolder(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteVariable(r.id):r.path[0]==="components"&&e.updateByLibOp(r,this)}updateByOp(r,e,t){this.data=e,r.path[0]==="images"?r.path.length===2&&r.type===0?r.props.data&&this.getImage(r.path[1]).updateSrc(r.props.data):r.path.length===1&&r.type===1?this.addImage(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteImage(r.id):r.path[0]==="videos"?r.path.length===2&&r.type===0?r.props.data&&this.getVideo(r.path[1]).updateSrc(r.props.data):r.path.length===1&&r.type===1?this.addVideo(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteVideo(r.id):r.path[0]==="audios"?r.path.length===2&&r.type===0?r.props.data&&this.addAudio(r.path[1],e.audios[r.path[1]]):r.path.length===1&&r.type===1?this.addAudio(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteAudio(r.id):r.path[0]==="particles"?r.path.length===2&&r.type===0?r.props.data&&this.addParticle(r.path[1],e.particles[r.path[1]]):r.path.length===1&&r.type===1?this.addParticle(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteParticle(r.id):r.path[0]==="colors"?r.path.length===2&&r.type===0?this.updateColor(r.path[1],r.props):r.path.length===1&&r.type===1?this.addColor(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteColor(r.id):r.path[0]==="materials"?r.path.length===1&&r.type===1?this.addMaterial(r.id,r.data):r.path.length===1&&r.type===2?this.deleteMaterial(r.id):r.path.length>1&&this.getMaterial(r.path[1]).updateByOp(ot.drop(r,2),e.materials[r.path[1]],{shared:this,scene:t}):r.path[0]==="fonts"?r.path.length===2&&r.type===0?this.updateFont(r.path[1],r,t):r.path.length===1&&r.type===1?this.addFont(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteFont(r.id):r.path[0]==="variables"?r.path.length===2&&r.type===0&&"value"in r.props?this.updateVariable(r.path[1],r.props.value):r.path.length===1&&r.type===4?this.addVariableHolder(r.id,r.data):r.path.length===1&&r.type===5&&this.deleteVariable(r.id):r.path[0]==="lib"&&this.updateLibByOp(ot.drop(r,1),t)}updateFont(r,e,t){if(e.props.url){let o=this.getFont(r),i={...this.data.fonts[r],url:e.props.url};o.update(i),o.loadingPromise.then(()=>this.requestRender()),t.updateFont(r,this)}}},Sb=new ti(xr.emptyData());var or=class extends Ot{updateByPatchedOp(e,t,o){if(super.updateByPatchedOp(e,t,o),og(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[i,a]of Object.entries(e.props)){let s=o.shared.material(a);this.material[Number(i)]=s}else if(Be(e.path,["material"])&&this.material instanceof rr)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(ot.drop(e,1),t.material,o);else if(Be(e.path,["materials","*"])&&Array.isArray(this.material)){let i=e.path[1];if("materials"in t&&i<this.material.length){let a=t.materials[i];typeof a!="string"&&this.material[i].updateByOp(ot.drop(e,2),a,o)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}updateState(e,t){super.updateState(e,t),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let o=this.dataPatched;if(e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=t.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe),t.scene.markNeedsUpdateRendererDirty()),(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(i=>t.shared.material(i).getFlavor(o.flatShading,o.side,o.wireframe)),t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[t.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe)],t.scene.markNeedsUpdateRendererDirty())),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let i=0;i<this.material.length;i++)this.material[i]=this.material[i].getFlavor(o.flatShading,o.side,o.wireframe);else this.material=this.material.getFlavor(o.flatShading,o.side,o.wireframe)}disposeMaterial(){this.material&&Al(this.material).forEach(e=>{e instanceof rr&&(e instanceof Zn||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};import{BufferGeometry as t3,Matrix4 as Rf,Vector3 as Tb,Vector4 as Vf}from"three";var wb=new Tb,Pb=new Vf,Ob=new Vf,r3=new Tb,Cb=new Rf,st=class extends or{constructor(e,t,o){super(e,t);this.data=t;this.isSkinnedMesh=!1;this.localGeometry=void 0,t.bindMode&&t.bindMatrix&&(this.bindMode=t.bindMode,this.bindMatrix=new Rf().fromArray(t.bindMatrix),this.bindMatrixInverse=new Rf)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof t3&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof ti){let e=this.geometryCreateDeleyed,t=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=t.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return Cs.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return Cs.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),Be(e.path,["geometry"])&&this.updateByPatchedOpGeometry(ot.drop(e,1),t.geometry,o)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,t){this.invalidateDownstreamBooleanData();let o=this.data.geometry.type;if(o==="NonParametricGeometry"||o==="SubdivGeometry"){let i=e;if(this.localGeometry===void 0){let u={...this.data.geometry,...i};this.localGeometry=_o(u,t,this.data.flatShading,this)}let a,s,l;i.scaleBaked?[a,s,l]=i.scaleBaked:{width:a,height:s,depth:l}=i;let c=this.localGeometry.userData;c.sxPrev!==void 0&&Ws(this.localGeometry.attributes,a/c.sxPrev,s/c.syPrev,l/c.szPrev),c.sxPrev=a,c.syPrev=s,c.szPrev=l}else{let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=_o(i,t,this.data.flatShading,this)}}refreshAttachedCloners(e){for(let t of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(t.object)}refreshAttachedPaths(e){for(let t of this.attachedPaths)e.scene.addPendingCommand(()=>t.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,t,o){let i=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof mt&&this.chooseGeoemtryCache(o.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(i=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(t,e.props.scaleBaked),this.refreshAttachedCloners(o),this.refreshAttachedPaths(o)),i||(o.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(o)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,t){this.createGeometryDelayed(t)}updateState(e,t){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,t),super.updateState(e,t)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,t){let o=this.geometry.userData.parameters;this.is2DType?e.set(0,0,o.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)):e.setScalar(0),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,t){this.skeleton=e,this.isSkinnedMesh=!0,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let t=new Vf,o=this.geometry.attributes.skinWeight;for(let i=0,a=o.count;i<a;i++){t.fromBufferAttribute(o,i);let s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),o.setXYZW(i,t.x,t.y,t.z,t.w)}}boneTransform(e,t){let o=this.skeleton;if(o===void 0)return;let i=this.geometry;Pb.fromBufferAttribute(i.attributes.skinIndex,e),Ob.fromBufferAttribute(i.attributes.skinWeight,e),wb.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let a=0;a<4;a++){let s=Ob.getComponent(a);if(s!==0){let l=Pb.getComponent(a);Cb.multiplyMatrices(o.bones[l].matrixWorld,o.boneInverses[l]),t.addScaledVector(r3.copy(wb).applyMatrix4(Cb),s)}}return t.applyMatrix4(this.bindMatrixInverse)}};function n3(n){if(n.geometry.attributes.extrudeNormal||!n.geometry.attributes.position||!n.geometry.attributes.normal)return;let r=new Map,e=n.geometry.attributes,t=e.position.array,o=e.normal.array,i=new Float32Array(t.length);for(let a=0;a<t.length;a+=3){let s=`${t[a]}_${t[a+1]}_${t[a+2]}`,l=new Gf(o[a],o[a+1],o[a+2]);r.has(s)?r.get(s)?.normals.push(l):r.set(s,{normals:[l],result:new Gf})}r.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<t.length;a+=3){let s=`${t[a]}_${t[a+1]}_${t[a+2]}`,l=r.get(s)?.result;l&&(i[a]=l.x,i[a+1]=l.y,i[a+2]=l.z)}n.geometry.setAttribute("extrudeNormal",new Ab(i,3))}function i3(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,t=new Float32Array(e.length),o=new Gf;for(let i=0;i<e.length;i+=3)o.set(e[i],e[i+1],e[i+2]).normalize(),t[i]=o.x,t[i+1]=o.y,t[i+2]=o.z;n.geometry.setAttribute("extrudeNormal",new Ab(t,3))}function Xa(n){if(Array.isArray(n.material)){for(let r of n.material)if(r.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof rr)||n.material.getLayersOfType("outline").length===0)return;n instanceof st&&n.is2DAndNoDepth?i3(n):n3(n)}function Ka(n){if(!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,t=new Float32Array(e.length),o=parseInt(n.uuid.replace(/\D/g,"")),i=[zf.seededRandom(o),zf.seededRandom(o+1e4),zf.seededRandom(o+2e4)];for(let a=0;a<e.length;a++)t[a]=i[a%3];n.geometry.setAttribute("randomColor",new o3(t,3))}var co=new a3,il=new l3;function Ib(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="SubdivGeometry"&&(r=!0)}),r}var ri=class extends st{constructor(e,t,o){super(e,t,o);this.data=t;this.hiddenMatrixOld=new s3;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,t){let o=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let t=this.localGeometry?.uuid,{originalGeometry:o,subdividedGeometry:i,subdivPointer:a}=mt.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,o!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=o),i!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Xa(this),Ka(this),this.calcBoundingBox(),t&&(this.localGeometry.uuid=t)}updateState(e,t){if(super.updateState(e,t),e.flatShading!==void 0){let o=this.material;this.material=Array.isArray(o)?o.map(i=>i.getFlavor(!1,i.side,i.wireframe)):o.getFlavor(!1,o.side,o.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(t)}}updateMesh(e=!1){mt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&mt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=mt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=mt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,t){let o=this.localGeometry;this.localGeometry=this.originalGeometryNew,Ot.prototype.raycast.call(this,e,t),this.localGeometry=o}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Mb,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;co.setFromBufferAttribute(t),co.getCenter(o),e.boundingSphere.radius=o.distanceTo(co.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),co.getSize(il),this.hasNonUniformScale&&il.divide(this.scale);let i={width:il.x,height:il.y,depth:il.z};return this.geometry.userData.parameters=i,i}updateBoundingSphere(e){let t=this.originalGeometry;co.min.set(e[0],e[2],e[4]),co.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(co.min.applyMatrix4(this.shearScaleInv),co.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new Mb);let o=t.boundingSphere.center;co.getCenter(o),t.boundingSphere.radius=o.distanceTo(co.max)}freeSubdivPointer(){this.subdivPointer&&(mt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,t,o){super.updateByPatchedOpGeometry(e,t,o),this.localGeometry&&this.createGeometryByControls(t)}};import{Triangle as c3,Vector3 as ni}from"three";var Nb=-1,u3=1,Db={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},Eb={polygon_center:0,edge:1,vertex:2},al=(n,r)=>(e,t)=>!r||e===0||n===0?0:n*t/100,Te=(n,r)=>{let e=Math.abs(r),t=e*-1;return(n-Nb)*(e-t)/(u3-Nb)+t};function _b(n){let r=[],e={};for(var t=0,o=n.length;t<o;t++){var i=JSON.stringify(n[t].pos.map(a=>Math.round(a*1e4)/1e4));e[i]||(r.push(n[t]),e[i]=!0)}return r}var d3=new ni,Nu=new ni,p3=new ni,f3=new ni;function Qa(n,r){let e=p3.fromArray(n),t=f3.fromArray(r);Nu.copy(t).sub(e);let o=Nu.length();return Nu.normalize().multiplyScalar(o*.5),d3.copy(e).add(Nu).toArray()}var Sr=new c3,Du=new ni,Eu=new ni,oi=new ni;function Bb(n){let r=[];for(let e=0;e<=n.index.count;e++)if(Du.fromArray(n.index.array,e*3),Sr.setFromAttributeAndIndices(n.attributes.position,Du.x,Du.y,Du.z),Sr.getNormal(Eu),Sr.getMidpoint(oi),!(isNaN(oi.x)||isNaN(oi.y)||isNaN(oi.z))){let{a:t,b:o,c:i}=Sr,a=t.toArray(),s=o.toArray(),l=i.toArray(),c=t.distanceTo(o),u=o.distanceTo(i),p=i.distanceTo(t),d=Qa(a,s),h=Qa(s,l),f=Qa(l,a),m=[c,u,p],y=Math.max(...m),g=m.filter(P=>Math.round(P)===Math.round(y)).length>1,v=[],O=Sr.getMidpoint(oi).toArray();y===c&&!g&&(v=[h,f,f],O=d),y===u&&!g&&(v=[d,f,f],O=h),y===p&&!g&&(v=[d,h,h],O=f),g&&(v=[d,h,f]),r.push({vertices:[a,s,l],faceCenters:v,midpoint:O,norm:Sr.getNormal(Eu).toArray()})}return r}function Lb(n){let r=[],{position:e}=n.attributes;for(let t=0;t<e.count;t++){Sr.setFromAttributeAndIndices(e,t*3,t*3+1,t*3+2),Sr.getNormal(Eu),Sr.getMidpoint(oi);let o=Sr.a.toArray(),i=Sr.b.toArray(),a=Sr.c.toArray();r.push({vertices:[o,i,a],faceCenters:[Qa(o,i),Qa(i,a),Qa(a,o)],midpoint:oi.toArray(),norm:Eu.toArray()})}return r}var h3=4,m3=.5,jf=n=>.5*(1-Math.cos(n*Math.PI)),Ff=class{constructor(){this.perlin=new Array(4095+1)}noise(r,e=0,t=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}r<0&&(r=-r),e<0&&(e=-e),t<0&&(t=-t);let o=Math.floor(r),i=Math.floor(e),a=Math.floor(t),s=r-o,l=e-i,c=t-a,u,p,d=0,h=.5,f,m,y;for(let g=0;g<h3;g++){let v=o+(i<<4)+(a<<8);u=jf(s),p=jf(l),f=this.perlin[v&4095],f+=u*(this.perlin[v+1&4095]-f),m=this.perlin[v+16&4095],m+=u*(this.perlin[v+16+1&4095]-m),f+=p*(m-f),v+=256,m=this.perlin[v&4095],m+=u*(this.perlin[v+1&4095]-m),y=this.perlin[v+16&4095],y+=u*(this.perlin[v+16+1&4095]-y),m+=p*(y-m),f+=jf(c)*(m-f),d+=f*h,h*=m3,o<<=1,s*=2,i<<=1,l*=2,a<<=1,c*=2,s>=1&&(o++,s--),l>=1&&(i++,l--),c>=1&&(a++,c--)}return d}noiseSeed(r){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(r),this.perlin=new Array(4095+1);for(let t=0;t<4095+1;t++)this.perlin[t]=e.rand()}},Rb=Ff;import{Vector3 as y3,Matrix4 as g3,Ray as x3}from"three";var Vb=new y3,zb=new g3,Gb=new x3;function jb(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(r=!0)}),r}var Za=class extends st{constructor(e,t,o){super(e,t,o);this.data=t}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,e.geometry.height,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,t){let{matrixWorld:o}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(zb.copy(o).invert(),Gb.copy(e.ray).applyMatrix4(zb),Gb.intersectBox(this.singleBBox,Vb))){let i=Vb.applyMatrix4(o),a=e.ray.origin.distanceTo(i);t.push({distance:a,point:i.clone(),object:this})}}};var Xt=1e-4,uo,Hb,Wb,qb,Ub=new pr,kb=new pr;fu.then(n=>{uo=n,Hb=[uo.get_face_center,uo.get_edge_midpoint,uo.get_vertex_position],Wb=[uo.get_face_normal,uo.get_edge_normal,uo.get_vertex_normal],qb=[uo.face_count,uo.edge_count,uo.vertex_count]});var v3=new ii,S3=new ii,xn=new pr,_u=new pr,sl=new pr,kf=new pr,w3=new pr,P3=new pr;var zo=new Rb,es=class extends ia(b3){constructor(e,t){super();this.parameters=t;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let t of this.children)t instanceof Io&&t.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(t=>{t instanceof Io&&t.object===e&&(t.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}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);break;case"toObject":this._updateToObject(this.parameters)}for(let e of this.children)e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD())}_updateCount(e){let t;if(e!==void 0?t=e:t=this.parameters.type==="grid"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(t=0),this.parameters.type==="toObject"&&this.objectForSample){for(let i=0,a=this.children.length;i<a;++i)this.remove(this.children[0]);let o=this.children;if(o.length===t)return;if(o.length<t)for(let i=0,a=t-o.length;i<a;++i){let s=new Io(this.object);s.expand(),this.add(s)}else for(let i=0,a=o.length-t;i<a;++i)this.remove(o[i])}else{if(this.children.length===t)return;if(this.children.length<t)for(let o=0,i=t-this.children.length;o<i;++o){let a=new Io(this.object);a.expand(),this.add(a)}else for(let o=0,i=this.children.length-t;o<i;++o)this.remove(this.children[0])}}_updateRadial(e){let t=e.radial,o=t.start*Fb.DEG2RAD,i=t.end*Fb.DEG2RAD,a=o-i,s=new Uf(t.rotation[0],t.rotation[1],t.rotation[2]),l;switch(t.axis){case"z":l=new pr(0,0,1);break;case"y":l=new pr(0,1,0);break;default:case"x":l=new pr(1,0,0);break}let c=e.randomnessObject??Qr.defaultData([1,1,1]).randomnessObject,u=c.noiseType==="perlin";zo.noiseSeed(c.seed);let p=Fc((0,Ja.default)(c.seed)),d=al(c.strength,this.parameters.randomness);for(let[h,f]of this.children.entries()){let m=h*(c.freqScale/10)+c.movement,y=u?zo.noise(m):p(m,m),g=h+1;f.scale.x=t.scale[0]+d(g,Te(y,c.scale[0]))||Xt,f.scale.y=t.scale[1]+d(g,Te(y,c.scale[1]))||Xt,f.scale.z=t.scale[2]+d(g,Te(y,c.scale[2]))||Xt,f.position.setScalar(0);let v=a/e.count*h-o;switch(t.axis){case"x":f.rotation.set(0,v,0);break;case"y":f.rotation.set(0,0,v);break;case"z":f.rotation.set(v,0,0);break}f.translateOnAxis(l,t.radius),f.position.x+=t.position[0]+d(g,Te(y,c.position[0])),f.position.y+=t.position[1]+d(g,Te(y,c.position[1])),f.position.z+=t.position[2]+d(g,Te(y,c.position[2]));let O=d(g,Te(y,c.rotation[0])),P=d(g,Te(y,c.rotation[1])),S=d(g,Te(y,c.rotation[2]));t.alignment===!0?(f.rotation.x+=s.x+O,f.rotation.y+=s.y+P,f.rotation.z+=s.z+S):f.rotation.set(s.x+O,s.y+P,s.z+S)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,o=new Uf(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Qr.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";zo.noiseSeed(i.seed);let s=Fc((0,Ja.default)(i.seed)),l=al(i.strength,this.parameters.randomness);for(let[c,u]of this.children.entries()){let p=c*(i.freqScale/10)+i.movement,d=a?zo.noise(p):s(p,p),h=c+1,f=l(h,Te(d,i.rotation[0])),m=l(h,Te(d,i.rotation[1])),y=l(h,Te(d,i.rotation[2]));u.scale.x=1+(t.scale[0]-1)*c+l(h,Te(d,i.scale[0]))||Xt,u.scale.y=1+(t.scale[1]-1)*c+l(h,Te(d,i.scale[1]))||Xt,u.scale.z=1+(t.scale[2]-1)*c+l(h,Te(d,i.scale[2]))||Xt,u.rotation.x=o.x*c+f,u.rotation.y=o.y*c+m,u.rotation.z=o.z*c+y,u.position.x=t.position[0]*c+l(h,Te(d,i.position[0])),u.position.y=t.position[1]*c+l(h,Te(d,i.position[1])),u.position.z=t.position[2]*c+l(h,Te(d,i.position[2]))}}_updateGrid(e){let t=0,o=e.grid,i=e.randomnessObject??Qr.defaultData([1,1,1]).randomnessObject,a=al(i.strength,this.parameters.randomness),s=i.noiseType==="perlin";zo.noiseSeed(i.seed);let l=lx((0,Ja.default)(i.seed));if(o.useCenter===!0){let c={x:o.count[0]%2===0?2:1,y:o.count[1]%2===0?2:1,z:o.count[2]%2===0?2:1},u=new pr(o.size[0]*(o.count[0]-c.x)*.5,o.size[1]*(o.count[1]-c.y)*.5,o.size[2]*(o.count[2]-c.z)*.5);for(let p=0;p<o.count[0];p++)for(let d=0;d<o.count[1];d++)for(let h=0;h<o.count[2];h++){let f=[(p+1)*(i.freqScale/10)+i.movement,(d+1)*(i.freqScale/10)+i.movement,(h+1)*(i.freqScale/10)+i.movement],m=s?zo.noise(...f):l(...f),y=this.children[t++];y.scale.x=1+a(t,Te(m,i.scale[0]))||Xt,y.scale.y=1+a(t,Te(m,i.scale[1]))||Xt,y.scale.z=1+a(t,Te(m,i.scale[2]))||Xt;let g=a(t,Te(m,i.rotation[0])),v=a(t,Te(m,i.rotation[1])),O=a(t,Te(m,i.rotation[2]));y.rotation.set(g,v,O),y.position.x=o.size[0]*p-u.x+a(t,Te(m,i.position[0])),y.position.y=o.size[1]*d-u.y+a(t,Te(m,i.position[1])),y.position.z=o.size[2]*h-u.z+a(t,Te(m,i.position[2]))}}else for(let c=0;c<o.count[0];c++)for(let u=0;u<o.count[1];u++)for(let p=0;p<o.count[2];p++){let d=[(c+1)*(i.freqScale/10)+i.movement,(u+1)*(i.freqScale/10)+i.movement,(p+1)*(i.freqScale/10)+i.movement],h=s?zo.noise(...d):l(...d),f=this.children[t++];f.scale.x=1+a(t,Te(h,i.scale[0]))||Xt,f.scale.y=1+a(t,Te(h,i.scale[1]))||Xt,f.scale.z=1+a(t,Te(h,i.scale[2]))||Xt;let m=a(t,Te(h,i.rotation[0])),y=a(t,Te(h,i.rotation[1])),g=a(t,Te(h,i.rotation[2]));f.rotation.set(m,y,g),f.position.x=o.size[0]*c+a(t,Te(h,i.position[0])),f.position.y=-o.size[1]*u+a(t,Te(h,i.position[1])),f.position.z=-o.size[2]*p+a(t,Te(h,i.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:t}=e,o=new Uf(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Qr.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";zo.noiseSeed(i.seed);let s=Fc((0,Ja.default)(i.seed)),l=al(i.strength,this.parameters.randomness);if(!t.object){for(let[,g]of this.children.entries())g.position.set(0,0,0),g.scale.setScalar(1),g.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof Za)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let c=this.getSubdivData(),u=[],p=g=>{let v=g.length,O=g.map(T=>T[0]).reduce((T,I)=>T+I,0),P=g.map(T=>T[1]).reduce((T,I)=>T+I,0),S=g.map(T=>T[2]).reduce((T,I)=>T+I,0);return[O/v,P/v,S/v]},d=g=>Math.round(g*1e6)/1e6;c.forEach(g=>{let v=c.filter(O=>d(g.pos[0])===d(O.pos[0])&&d(g.pos[1])===d(O.pos[1])&&d(g.pos[2])===d(O.pos[2]));v.length>1?u.push({pos:g.pos,norm:p(v.map(O=>O.norm))}):u.push(g)});let h=_b(u);if(h.length>0){let g=Math.round(h.length*t.count/100);this._updateCount(g)}else{let g=this.objectForSample.geometry.getAttribute("position");if(!g||isNaN(g.count)||g.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let f=new Uc(this.objectForSample).build(),m=Db[t.axis],y=this.children;f.setRandomGenerator((0,Ja.default)(this.object.uuid+t.seed));for(let[g,v]of y.entries()){let O=g*(i.freqScale/10)+i.movement,P=a?zo.noise(O):s(O,O),S=g+1,T=l(S,Te(P,i.rotation[0])),I=l(S,Te(P,i.rotation[1])),x=l(S,Te(P,i.rotation[2]));t.spreadType==="random"?f.sample(sl,kf):(h.length&&(sl.fromArray(h[g].pos),kf.fromArray(h[g].norm)),this.objectForSample instanceof ri&&sl.applyMatrix4(v3.copy(this.objectForSample.matrixWorld).invert())),sl.applyMatrix4(this.object.hiddenMatrix.clone().invert()),v.position.copy(sl),xn.fromArray(m);let _=t.align==="normal"?kf:this.object.getWorldDirection(P3),D=_u.fromArray(t.position);_u.x+=l(S,Te(P,i.position[0])),_u.y+=l(S,Te(P,i.position[1])),_u.z+=l(S,Te(P,i.position[2]));let A=Math.acos(_.dot(xn)),N=w3.crossVectors(xn,_).normalize(),E=S3.makeRotationAxis(N,A),B=_.clone().cross(this.object.up).normalize(),V=B.clone().cross(_).normalize(),j=new ii().makeBasis(B,_,V),R=new pr(xn.y,xn.z,xn.x).normalize(),W=R.clone().cross(xn).normalize(),F=new ii().makeBasis(R,xn,W).invert(),k=new ii().multiplyMatrices(j,F);v.rotation.setFromRotationMatrix(k),D.applyMatrix4(E),v.position.add(D),v.rotation.x=v.rotation.x+o.x+T,v.rotation.y=v.rotation.y+o.y+I,v.rotation.z=v.rotation.z+o.z+x,v.scale.setScalar(1),v.scale.x=v.scale.x+t.scale[0]+l(S,Te(P,i.scale[0]))||Xt,v.scale.y=v.scale.y+t.scale[1]+l(S,Te(P,i.scale[1]))||Xt,v.scale.z=v.scale.z+t.scale[2]+l(S,Te(P,i.scale[2]))||Xt,v.scale.multiply(this.object.scale),v.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof ri){let t=this.objectForSample,o=Eb[e],i=qb[o],a=Hb[o],s=Wb[o],l=[],c=i(t.subdivPointerNew);for(let u=0;u<=c-1;u++){let p=a(t.subdivPointerNew,u),d=s(t.subdivPointerNew,u);Ub.fromArray(p).applyMatrix4(t.matrixWorld),kb.fromArray(d),l.push({pos:Ub.toArray(),norm:kb.toArray()})}return l}else return(this.objectForSample.geometry.index?Bb(this.objectForSample.geometry):Lb(this.objectForSample.geometry)).map((o,i)=>e==="polygon_center"?{pos:o.midpoint,norm:o.norm}:e==="vertex"?[{pos:o.vertices[0],norm:o.norm},{pos:o.vertices[1],norm:o.norm},{pos:o.vertices[2],norm:o.norm}]:e==="edge"?[{pos:o.faceCenters[0],norm:o.norm},{pos:o.faceCenters[1],norm:o.norm},{pos:o.faceCenters[2],norm:o.norm}]:[]).flat()}updateState(e,t){if(this.parameters=vo(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let o=t.find(this.parameters.toObject.object);o instanceof Ot?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new ii,this.hiddenMatrix=new ii,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};import{Scene as wE,Vector3 as PE,Matrix4 as OE,Box3 as CE,MeshBasicMaterial as TE,Skeleton as AE}from"three";import{Camera as L3,OrthographicCamera as R3,PerspectiveCamera as V3,Vector3 as kr,Object3D as Kb,Quaternion as z3,Matrix4 as G3}from"three";import{Camera as I3,LineSegments as N3,BufferGeometry as D3,LineBasicMaterial as E3,Color as Wf,Vector3 as _3,Float32BufferAttribute as Yb}from"three";import{BoxGeometry as O3}from"three";var po=n=>{var r;return r=class extends n{},r.geometryHelper=new O3(30,30,30),r};import{Ray as C3,Sphere as T3,Matrix4 as A3,Vector3 as Go}from"three";var Bu=new C3,Hf=new T3,$b=new A3,fo=(n,r,e,t,o=!1)=>{let i=r,a=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),Hf.copy(i.boundingSphere),Hf.applyMatrix4(a),e.ray.intersectsSphere(Hf)===!1||($b.copy(a).invert(),Bu.copy(e.ray).applyMatrix4($b),i.boundingBox!==null&&Bu.intersectsBox(i.boundingBox)===!1))return;let s,l,c,u,p=i.index,d=i.attributes.position,h=i.drawRange,f,m;if(o===!1){let g=Math.max(0,h.start),v=Math.min(p.count,h.start+h.count);for(f=g,m=v;f<m;f+=3)if(l=p.getX(f),c=p.getX(f+1),u=p.getX(f+2),s=y(n,e,Bu,d,l,c,u),s){s.faceIndex=Math.floor(f/3),t.push(s);return}}else{let v=i.attributes.position,O=new Go,P=new Go,S=new Go,T=new Go,I=2,_=1/((n.scale.x+n.scale.y+n.scale.z)/3),D=_*_,A=Math.max(0,h.start),N=Math.min(v.count,h.start+h.count);for(let E=A,B=N-1;E<B;E+=I){if(O.fromBufferAttribute(v,E),P.fromBufferAttribute(v,E+1),Bu.distanceSqToSegment(O,P,T,S)>D)continue;T.applyMatrix4(n.matrixWorld);let j=e.ray.origin.distanceTo(T);j<e.near||j>e.far||t.push({distance:j,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(g,v,O,P,S,T,I){let x=new Go,_=new Go,D=new Go,A=new Go,N=new Go;if(x.fromBufferAttribute(P,S),_.fromBufferAttribute(P,T),D.fromBufferAttribute(P,I),O.intersectTriangle(x,_,D,!1,A)===null)return null;N.copy(A),N.applyMatrix4(g.matrixWorld);let B=v.ray.origin.distanceTo(N);return B<v.near||B>v.far?null:{faceIndex:1,distance:B,point:N.clone(),object:g}}};var Lu=new _3,wr=new I3,qf=class extends N3{constructor(e){let t=new D3,o=new E3({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],a=[],s={},l=new Wf(15711266),c=new Wf(15711266),u=new Wf(2857471);p("n1","n2",l),p("n2","n4",l),p("n4","n3",l),p("n3","n1",l),p("f1","f2",l),p("f2","f4",l),p("f4","f3",l),p("f3","f1",l),p("n1","f1",l),p("n2","f2",l),p("n3","f3",l),p("n4","f4",l),p("p","n1",c),p("p","n2",c),p("p","n3",c),p("p","n4",c),p("u1","u2",u),p("u2","u3",u),p("u3","u1",u);function p(h,f,m){d(h,m),d(f,m)}function d(h,f){i.push(0,0,0),a.push(f.r,f.g,f.b),s[h]===void 0&&(s[h]=[]),s[h].push(i.length/3-1)}t.setAttribute("position",new Yb(i,3)),t.setAttribute("color",new Yb(a,3));super(t,o);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,t=this.pointMap,o=!0;wr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=1,a=1,s=o?.8:1e-4;Ur("n1",t,e,wr,-i,-a,s),Ur("n2",t,e,wr,i,-a,s),Ur("n3",t,e,wr,-i,a,s),Ur("n4",t,e,wr,i,a,s);let l=s;Ur("f1",t,e,wr,-i,-a,l),Ur("f2",t,e,wr,i,-a,l),Ur("f3",t,e,wr,-i,a,l),Ur("f4",t,e,wr,i,a,l);let c=l,u=.5;Ur("u1",t,e,wr,i*.7*u,a*1.1,c),Ur("u2",t,e,wr,-i*.7*u,a*1.1,c),Ur("u3",t,e,wr,0,a*(1.1+.9*u),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Ur(n,r,e,t,o,i,a){Lu.set(o,i,a).unproject(t);let s=r[n];if(s!==void 0){let l=e.getAttribute("position");for(let c=0,u=s.length;c<u;c++)l.setXYZ(s[c],Lu.x,Lu.y,Lu.z)}}var Ru=class extends po(qf){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){fo(this.object,this.geometry,e,t,!0)}};import{Box3Helper as Xb,BoxGeometry as B3}from"three";var Vu;(r=>r.is=e=>"objectHelper"in e)(Vu||(Vu={}));var Pr=(n,r)=>class extends la(n){constructor(){super(...arguments);this.objectHelper=new r(this);this.gizmos={}}get geometryHelper(){return r.geometryHelper}raycast(o,i){this.objectHelper.raycast(o,i)}showGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof Xb&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof B3?(o.setScalar(0),i.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(o,i)}hideGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof Xb&&(i.visible=!1)}}};var zu=790,ts=new kr,$f=new kr,Yf=new z3,Xf=new kr,ll=new kr,Kf=new kr,jo=class extends Pr(L3,Ru){constructor(e="",t={...jn.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=on.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,t),this.previousProjectionMatrix=new G3,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,i=this.height;this.orthoCamera=new R3(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4),this.perspCamera=new V3(45,o/i,50,1e4),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.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}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,t,o){typeof e=="number"&&(e=new kr(e,t,o)),super.lookAt(e),this.getWorldPosition(ts),this.targetOffset=ts.distanceTo(e)}getTarget(e=new kr){return this.getWorldDirection($f),this.getWorldPosition(ts),$f.multiplyScalar(this.targetOffset),e.copy(ts).add($f),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(ts),ts.distanceTo(e)}updateUp(){this.getWorldQuaternion(Yf),Xf.set(0,0,1).applyQuaternion(Yf),ll.copy(Kb.DEFAULT_UP),this.isUpVectorFlipped&&ll.negate(),ll.applyQuaternion(Yf),Kf.copy(Kb.DEFAULT_UP).projectOnPlane(Xf),this.angleOffsetFromUp=Kf.angleTo(ll),this.angleOffsetFromUp*=Kf.cross(ll).dot(Xf)>=0?1:-1}updateTransformState(e,t){let o=super.updateTransformState(e,t);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),o}getViewFrontToObject(e){let t=e.getWorldPosition(new kr),i=e.getWorldDirection(new kr).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToTarget(e){let o=this.getWorldDirection(new kr).multiplyScalar(this.targetOffset);return{position:e.clone().sub(o),target:e}}getViewToObject(e){let t=new kr,o=e.getWorldPosition(t);return this.getViewToTarget(t)}setViewplaneSize(e,t,o=!1){if(this.aspect=e/t,o){let i=e>t?this.aspect:1,a=e>t?1:this.aspect;this.left=-zu*.5*i,this.right=zu*.5*i,this.top=zu*.5*(1/a),this.bottom=-zu*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){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.objectHelper&&this.objectHelper.update()}toPerspective(){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.objectHelper&&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,o,i,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,o,i,a,s):this.orthoCamera.setViewOffset(e,t,o,i,a,s)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}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.parent=e.parent,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}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 Ri(t,e)}updateCameraSubtype(e,t){let o=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";t.zoom!==void 0&&this.setZoom(o,t.zoom),t.near!==void 0&&this.setNear(o,t.near),t.fov!==void 0&&o==="PerspectiveCamera"&&(this.fov=t.fov)}updateState(e,t){this.updateCameraState(e,t)}updateCameraState(e,t){this.updateState_Entity(e,t),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),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()}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}};import{MathUtils as Ore}from"three";import{BufferGeometry as Qb,Matrix4 as Zb,Float32BufferAttribute as j3}from"three";var rs=new Zb,F3=new Zb;var nr=class extends or{constructor(e,t,o){super(e,t);this.data=t;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new Qb;this.onAfterRender=(e,t,o,i,a,s)=>{super.onAfterRender(e,t,o,i,a,s),this.recomputeBoolean()};this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,t=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let i=0;i<this.children.length;i++){let a=this.children[i];a instanceof nr&&a.dataPatched.visible===!0&&a.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let a=this.children[i];if(a instanceof Ot&&a.dataPatched.visible===!0&&a.geometry.attributes.position?.count>0&&a.geometry.drawRange.count>0&&a.booleanMeshSetAddress!==0){rs.multiplyMatrices(a.hiddenMatrix,a.matrix);try{if(a.booleanMeshSetAddress===-1){if((a.geometry.index??a.geometry.getAttribute("position")).count/3<15e5&&(a.booleanMeshSetAddress=br.getMeshSet(a.geometry,e===!0,t)),a.booleanMeshSetAddress===-1)return;br.transformMeshSet(a.booleanMeshSetAddress,rs),a.booleanMatrixInvOld.copy(rs).invert(),a.booleanWasTransformed=!1}else a instanceof nr&&a.needsTransformForDownstream===!0?(br.transformMeshSet(a.booleanMeshSetAddress,rs),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(br.transformMeshSet(a.booleanMeshSetAddress,F3.multiplyMatrices(rs,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(rs).invert(),a.booleanWasTransformed=!1)}catch(s){console.error(s),a.booleanMeshSetAddress=0,a.geometry.userData.booleanOperationDidFail=!0;continue}br.hasOpenEdges(a.booleanMeshSetAddress)===!1||i===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(a.booleanMeshSetAddress),a.geometry.userData.booleanOperationDidFail=!1):a.geometry.userData.booleanOperationDidFail="openEdges"}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new j3([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return br.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new Qb,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=br.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,Xa(this),Ka(this)}dispose(){super.dispose(),this.geometry.dispose()}};import{Light as U3}from"three";var Jb;(r=>{function n(e){return Le.is(e)&&e instanceof U3}r.is=n})(Jb||(Jb={}));var os=(n,r)=>class extends Pr(n,r){updateState_Light(t,o){this.updateState_Entity(t,o),t.color!==void 0&&(this.color=o.shared.color(t.color)),t.intensity!==void 0&&(this.intensity=t.intensity),t.depth!==void 0&&(this.shadow.camera.far=t.depth,this.shadow.needsUpdate=!0),t.shadows!==void 0&&(this.castShadow=t.shadows)}};var bn=n=>n instanceof Ot,cl=n=>n!==null&&n instanceof nr;var ul=n=>Vu.is(n);import{Group as H3}from"three";import{AxesHelper as k3}from"three";var Or=class extends po(k3){constructor(e,t=15){super(t);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,t){fo(this.object,Or.geometryHelper,e,t)}update(){}};var vn=class extends Pr(H3,Or){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update()}updateState(r,e){this.updateState_Entity(r,e),"buffer"in r&&Object.keys(r).length===1&&e.scene.reloadSplats()}};import{Group as W3}from"three";var Gu=class extends Pr(W3,Or){constructor(e,t,o){super();this.super_Entity(e,t),this.context=o,this.objectHelper.update()}updateState(e,t){this.updateState_Entity(e,t)}};import{Color as xD,Fog as bD,HemisphereLight as vD}from"three";import{ShaderChunk as dl}from"three";var q3=n=>`
2229
+ `)>=0&&(r-=i),t===3?e*.5-r*.5:t===2?e-r:0}getLineInitialOffsetY(r,e,t,o,i){let a=e*r,s=Math.abs(this.ascender-this.descender)*o,l=r-s,c=-this.ascender*o-l/2;return i===3?-(t-a-c):i===2?-(t*.5-a*.5-c):c}createPath(r,e,t,o,i){let a=r.getPath(t,-o,i.fontSize,{kerning:!1,letterSpacing:i.letterSpacing});if(!a){console.error('THREE.Font: character "'+r+'" does not exists in font family '+this.familyName+".");return}let s=new Tu,l=(r.advanceWidth??1)*e;if(r)for(let c of a.commands){let u=s.currentPath?.currentPoint;if(!(u&&c.type!=="Z"&&u.x===c.x&&-u.y===c.y))switch(c.type){case"M":s.moveTo(c.x,-c.y);break;case"L":s.lineTo(c.x,-c.y);break;case"Q":s.quadraticCurveTo(c.x1,-c.y1,c.x,-c.y);break;case"C":s.bezierCurveTo(c.x1,-c.y1,c.x2,-c.y2,c.x,-c.y);break}}return s.subPaths.forEach(c=>{let u=JN(c.curves);u!==void 0&&c.currentPoint.distanceTo(u)>0&&c.lineTo(u.x,u.y)}),{offsetX:l+i.fontSize*i.letterSpacing,path:s}}getCharWidth(r,e){return this.font?.getAdvanceWidth(r,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(r,e){return this.font?.getAdvanceWidth(r,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(r,e,t){let o=this.getCharWidth(" ",t),i=r[e];if(i){let a=this.countSpaces(i.trimEnd());if(t.horizontalAlign===4&&e<r.length-1&&a){let s=t.width,l=this.getTextWidth(i,t);return(s-(l-a*o))/a}}return o}countSpaces(r){return(r.match(/ /g)||[]).length}};function JN(n){if(n.length){let r=n[0];if(r instanceof KN)return r.v1;if(r instanceof XN||r instanceof QN)return r.v0}}var Lf=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(r){return this.objects.get(r)}get size(){return this.objects.size}get(r,e,t){let o=this.objects.get(r);return o===void 0?(o=this.createObject(r,e,t),this.objects.set(r,o)):o.isShared=!0,o}forceDelete(r){let e=this.objects.get(r);e&&(this.disposeObject(e),this.objects.delete(r))}mutateIfUnique(r,e){let t=this.objects.get(r);if(t&&t.isShared!==!0)return this.objects.delete(r),this.objects.set(e,t),t}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(r,e){let t=this.objects.get(r);e===t?this.unreachable.delete(r):!1&&console.warn("Reachable but deleted",r)}endGc(){this.unreachable.forEach(r=>{this.disposeObject(this.objects.get(r)),this.objects.delete(r)}),this.unreachable.clear()}dispose(){this.objects.forEach(r=>{this.disposeObject(r)}),this.objects.clear()}},ol=class extends Lf{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t,o){let i=Bo(e,t,this.flatShading,o);return i.computeBoundingSphere(),i}};var vb={markNeedsUpdateRendererDirty:()=>{}};import{MathUtils as Sb}from"three";var Rf=class extends wu{constructor(e){super();this.shared=e}create(e){return new qa(e,this.shared)}},ei=class{constructor(r,e={}){this.data=r;this.geometryCache=new ol(!0);this.geometryCache2=new ol(!1);this.imageHolderCache=new Rf(this);this.thisContext={scene:vb,shared:this};this.deletedMaterial=new Qn(Lt.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new dr(Lc.emptyImage,this);this.deletedVideo=new dr(qi.defaultVideo,this);this.materials={};this.images={};this.canvases={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.variables={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[t,o]of Object.entries(e.images))this.addImage(t,o);if(e.videos)for(let[t,o]of Object.entries(e.videos))this.addVideo(t,o);if(e.audios)for(let[t,o]of Object.entries(e.audios))this.addAudio(t,o);if(e.particles)for(let[t,o]of Object.entries(e.particles))this.addParticle(t,o);this.reset(r)}setRequestRender(r){this._requestRender=r}setEntityOpContext(r){this.entityOpContext=r}reset(r,e=!1){this.resetLib(r.lib);for(let{id:t,data:o}of r.variables)this.addVariableHolder(t,o),e&&this.updateVariableHolder(t,o);for(let[t,o]of Object.entries(r.images))this.addImage(t,o);for(let[t,o]of Object.entries(r.videos))this.addVideo(t,o);for(let[t,o]of Object.entries(r.colors))this.addColor(t,o);for(let[t,o]of Object.entries(r.materials))this.addMaterial(t,o);for(let[t,o]of Object.entries(r.audios))this.addAudio(t,o);for(let[t,o]of Object.entries(r.particles))this.addParticle(t,o);for(let[t,o]of Object.entries(r.fonts))this.addFont(t,o)}addMaterial(r,e){if(this.materials[r]){let t=this.materials[r];t.reset(e,this.thisContext),t.dispose()}else{let t=new Qn(e,this.thisContext,r);this.materials[r]=t}}deleteMaterial(r){this.materials[r]&&(this.materials[r].nodeMaterialDispose(),delete this.materials[r])}getMaterial(r){let e=this.materials[r];return e}getMaterialOrDeletedPlaceholder(r){return this.materials[r]??this.deletedMaterial}material(r){return typeof r=="string"?this.getMaterialOrDeletedPlaceholder(r):r==null?(console.error("material is undefined or null"),this.deletedMaterial):new Kn(r,this.thisContext)}getMaterials(){return this.materials}addImage(r,e){return this.images[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[r].updateSrc(e.data),!0):(this.images[r]=new dr(e,this),!1)}deleteImage(r){let e=this.images[r];e&&(e.dispose(),delete this.images[r])}getDefaultImage(){return this.images.image_0}getImage(r){return this.images[r]??this.deletedImage}image(r){return typeof r=="string"?this.getImage(r):this.imageHolderCache.load(r)}addCanvas(r,e){return this.canvases[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.canvases[r].updateSrc(e),!0):(this.canvases[r]=new dr(e,this),!1)}canvas(r){return this.canvases[r]}addVideo(r,e){return this.videos[r]?(this.videos[r].updateSrc(e.data),!0):(this.videos[r]=new dr(e,this),!1)}deleteVideo(r){let e=this.videos[r];e&&(e.dispose(),delete this.videos[r])}getVideo(r){return this.videos[r]??this.deletedVideo}video(r){return typeof r=="string"?this.getVideo(r):this.imageHolderCache.load(r)}addColor(r,e){return this.colors[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[r].setRGBA(e.r,e.g,e.b,e.a):this.colors[r].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[r]=new mn(e.r,e.g,e.b,e.a):this.colors[r]=new mn(e.r,e.g,e.b,1),!1)}updateColor(r,e){if(this.colors[r]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let t=this.colors[r];return this.colors[r].r=e.r??t.r,this.colors[r].g=e.g??t.g,this.colors[r].b=e.b??t.b,this.colors[r].a=e.a??t.a,!0}return!1}deleteColor(r){this.colors[r]&&delete this.colors[r]}getColor(r){return this.colors[r]}color(r){let e;if(typeof r=="string"){let t=this.getColor(r);t?e=t:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Ct(0,0,0,0))}else return"a"in r?new Ct(r.r,r.g,r.b,r.a):new Ct(r.r,r.g,r.b,1);return e}addAudio(r,e){this.audios[r]=e}getAudio(r){let e=this.audios[r];if(e instanceof Zn)return e;{let t=new Zn({src:e.data});return this.audios[r]=t,t}}addParticle(r,e){this.particles[r]=e}getParticle(r){return this.particles[r]}deleteParticle(r){this.particles[r]&&delete this.particles[r]}deleteAudio(r){let e=this.audios[r];e&&(e instanceof Zn&&e.dispose(),delete this.audios[r])}addFont(r,e){this.fonts[r]=new Mu(e),this.fonts[r].loadingPromise.then(()=>this.requestRender())}getFont(r){return this.fonts[r]}deleteFont(r){this.fonts[r]&&delete this.fonts[r]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Zn&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(r,e){return this.variables[r]===void 0?(this.variables[r]={value:e.value,locations:[]},"dynamicVariableType"in e&&(this.variables[r].dynamicVariablePlayState="Playing",this.variables[r].dynamicVariableToggleIsForward=void 0),!0):(this.variables[r].value=e.value,!1)}resetDynamicVariablePlayState(){for(let r in this.variables)this.variables[r].dynamicVariablePlayState!==void 0&&(this.variables[r].dynamicVariablePlayState="Playing",this.variables[r].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(r,e){this.updateVariable(r,e.value)}updateVariable(r,e){if(this.variables[r]===void 0)return!1;this.variables[r].value=e;let t=e;for(;typeof t=="string";)t=this.variables[t].value;let o=this.entityOpContext.scene;for(let i=this.variables[r].locations.length-1;i>=0;i--){let a=this.variables[r].locations[i];if(a[0]==="material"){let s=a[1],l=t,c={scene:o,shared:this},u=a.slice(2);o.traverseMaterial(d=>{let h=d.root??d;h.uuid===s&&h.onVariableUpdate(u,l,c)});let p=this.materials[s];p&&p.onVariableUpdate(u,l,c)}else{let s=o.find(a[0]);if(s===void 0){this.variables[r].locations.splice(i,1);continue}if(a[1]!=="geometry"&&a[1]!=="particles"){for(let l=1;l<a.length-1;l++)s=s[a[l]];a[1]==="rotation"?s[a[a.length-1]]=t*Sb.DEG2RAD:s[a[a.length-1]]=t}if(s=o.find(a[0]),s.type==="ParticleEmitter"&&s.updateVariableState(t,a),Le.is(s)){if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")s.onVariableUpdate();else if(a[1]==="geometry"){let l=s;s.component&&(l=s.component);let c=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(c.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.instances.forEach(u=>{let p=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(p.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0)})}}}}return this.requestRender(),!0}deleteVariable(r){this.variables[r]&&delete this.variables[r]}getVariable(r,e){if(Array.isArray(r)){if(r[0]==="mouse")return this.mouseProperty?.[r[1]]??0;if(r[0]==="raycast")return this.raycastProperty?.[r[1]]??0;let t=this.entityOpContext.scene.find(r[0]);if(r[1]==="width"||r[1]==="height"||r[1]==="depth")return t.geometry.userData.parameters[r[1]];for(let o=1;o<r.length;o++)t=t[r[o]];return r[1]==="rotation"&&(t*=Sb.RAD2DEG),t}for(let t in this.variables){if(e===void 0)break;let o=this.variables[t],i=o.locations?.findIndex(a=>rt.equal(a,e));i!==void 0&&i!==-1&&o.locations.splice(i,1)}if(typeof r=="string"){let t=r,o=r;do{if(o=t,this.variables[t]===void 0)break;t=this.variables[t].value}while(typeof t=="string");return e&&this.variables[o]!==void 0&&this.variables[o].locations.push(e),t}else return r}getVariables(){return this.variables}getDynamicVariablePlayState(r){return this.variables[r]?.dynamicVariablePlayState}setDynamicVariablePlayState(r,e){this.variables[r]!==void 0&&(this.variables[r].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(r){return this.variables[r]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(r,e){this.variables[r]!==void 0&&(this.variables[r].dynamicVariableToggleIsForward=e)}resetLib(r){for(let[e,t]of Object.entries(r.images))this.addImage(e,t.asset);for(let[e,t]of Object.entries(r.audios))this.addAudio(e,t.asset);for(let[e,t]of Object.entries(r.particles))this.addParticle(e,t.asset);for(let[e,t]of Object.entries(r.colors))this.addColor(e,t.asset);for(let[e,t]of Object.entries(r.fonts))this.addFont(e,t.asset);for(let[e,t]of Object.entries(r.materials))this.addMaterial(e,t.asset);for(let[e,t]of Object.entries(r.videos))this.addVideo(e,t.asset);for(let[e,t]of Object.entries(r.variables))this.addVariableHolder(e,t.asset)}updateLibByOp(r,e){r.path[0]==="images"?r.path.length===1&&r.type===1?this.addImage(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteImage(r.id):r.path[0]==="videos"?r.path.length===1&&r.type===1?this.addVideo(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteVideo(r.id):r.path[0]==="audios"?r.path.length===1&&r.type===1?this.addAudio(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteAudio(r.id):r.path[0]==="particles"?r.path.length===1&&r.type===1?this.addParticle(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteParticle(r.id):r.path[0]==="colors"?r.path.length===1&&r.type===1?this.addColor(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteColor(r.id):r.path[0]==="materials"?r.path.length===1&&r.type===1?this.addMaterial(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteMaterial(r.id):r.path[0]==="fonts"?r.path.length===1&&r.type===1?this.addFont(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteFont(r.id):r.path[0]==="variables"?r.path.length===1&&r.type===1?this.addVariableHolder(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteVariable(r.id):r.path[0]==="components"&&e.updateByLibOp(r,this)}updateByOp(r,e,t){this.data=e,r.path[0]==="images"?r.path.length===2&&r.type===0?r.props.data&&this.getImage(r.path[1]).updateSrc(r.props.data):r.path.length===1&&r.type===1?this.addImage(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteImage(r.id):r.path[0]==="videos"?r.path.length===2&&r.type===0?r.props.data&&this.getVideo(r.path[1]).updateSrc(r.props.data):r.path.length===1&&r.type===1?this.addVideo(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteVideo(r.id):r.path[0]==="audios"?r.path.length===2&&r.type===0?r.props.data&&this.addAudio(r.path[1],e.audios[r.path[1]]):r.path.length===1&&r.type===1?this.addAudio(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteAudio(r.id):r.path[0]==="particles"?r.path.length===2&&r.type===0?r.props.data&&this.addParticle(r.path[1],e.particles[r.path[1]]):r.path.length===1&&r.type===1?this.addParticle(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteParticle(r.id):r.path[0]==="colors"?r.path.length===2&&r.type===0?this.updateColor(r.path[1],r.props):r.path.length===1&&r.type===1?this.addColor(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteColor(r.id):r.path[0]==="materials"?r.path.length===1&&r.type===1?this.addMaterial(r.id,r.data):r.path.length===1&&r.type===2?this.deleteMaterial(r.id):r.path.length>1&&this.getMaterial(r.path[1]).updateByOp(ot.drop(r,2),e.materials[r.path[1]],{shared:this,scene:t}):r.path[0]==="fonts"?r.path.length===2&&r.type===0?this.updateFont(r.path[1],r,t):r.path.length===1&&r.type===1?this.addFont(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteFont(r.id):r.path[0]==="variables"?r.path.length===2&&r.type===0&&"value"in r.props?this.updateVariable(r.path[1],r.props.value):r.path.length===1&&r.type===4?this.addVariableHolder(r.id,r.data):r.path.length===1&&r.type===5&&this.deleteVariable(r.id):r.path[0]==="lib"&&this.updateLibByOp(ot.drop(r,1),t)}updateFont(r,e,t){if(e.props.url){let o=this.getFont(r),i={...this.data.fonts[r],url:e.props.url};o.update(i),o.loadingPromise.then(()=>this.requestRender()),t.updateFont(r,this)}}},wb=new ei(xr.emptyData());var or=class extends Pt{updateByPatchedOp(e,t,o){if(super.updateByPatchedOp(e,t,o),ng(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[i,a]of Object.entries(e.props)){let s=o.shared.material(a);this.material[Number(i)]=s}else if(Be(e.path,["material"])&&this.material instanceof rr)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(ot.drop(e,1),t.material,o);else if(Be(e.path,["materials","*"])&&Array.isArray(this.material)){let i=e.path[1];if("materials"in t&&i<this.material.length){let a=t.materials[i];typeof a!="string"&&this.material[i].updateByOp(ot.drop(e,2),a,o)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}updateState(e,t){super.updateState(e,t),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let o=this.dataPatched;if(e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=t.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe),t.scene.markNeedsUpdateRendererDirty()),(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(i=>t.shared.material(i).getFlavor(o.flatShading,o.side,o.wireframe)),t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[t.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe)],t.scene.markNeedsUpdateRendererDirty())),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let i=0;i<this.material.length;i++)this.material[i]=this.material[i].getFlavor(o.flatShading,o.side,o.wireframe);else this.material=this.material.getFlavor(o.flatShading,o.side,o.wireframe)}disposeMaterial(){this.material&&Tl(this.material).forEach(e=>{e instanceof rr&&(e instanceof Qn||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};import{BufferGeometry as t3,Matrix4 as Vf,Vector3 as Ab,Vector4 as zf}from"three";var Pb=new Ab,Ob=new zf,Cb=new zf,r3=new Ab,Tb=new Vf,at=class extends or{constructor(e,t,o){super(e,t);this.data=t;this.isSkinnedMesh=!1;this.localGeometry=void 0,t.bindMode&&t.bindMatrix&&(this.bindMode=t.bindMode,this.bindMatrix=new Vf().fromArray(t.bindMatrix),this.bindMatrixInverse=new Vf)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof t3&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof ei){let e=this.geometryCreateDeleyed,t=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=t.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return Os.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return Os.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),Be(e.path,["geometry"])&&this.updateByPatchedOpGeometry(ot.drop(e,1),t.geometry,o)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,t){this.invalidateDownstreamBooleanData();let o=this.data.geometry.type;if(o==="NonParametricGeometry"||o==="SubdivGeometry"){let i=e;if(this.localGeometry===void 0){let u={...this.data.geometry,...i};this.localGeometry=Bo(u,t,this.data.flatShading,this)}let a,s,l;i.scaleBaked?[a,s,l]=i.scaleBaked:{width:a,height:s,depth:l}=i;let c=this.localGeometry.userData;c.sxPrev!==void 0&&Hs(this.localGeometry.attributes,a/c.sxPrev,s/c.syPrev,l/c.szPrev),c.sxPrev=a,c.syPrev=s,c.szPrev=l}else{let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=Bo(i,t,this.data.flatShading,this)}}refreshAttachedCloners(e){for(let t of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(t.object)}refreshAttachedPaths(e){for(let t of this.attachedPaths)e.scene.addPendingCommand(()=>t.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,t,o){let i=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof ht&&this.chooseGeoemtryCache(o.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(i=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(t,e.props.scaleBaked),this.refreshAttachedCloners(o),this.refreshAttachedPaths(o)),i||(o.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(o)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,t){this.createGeometryDelayed(t)}updateState(e,t){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,t),super.updateState(e,t)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,t){let o=this.geometry.userData.parameters;this.is2DType?e.set(0,0,o.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)):e.setScalar(0),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,t){this.skeleton=e,this.isSkinnedMesh=!0,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let t=new zf,o=this.geometry.attributes.skinWeight;for(let i=0,a=o.count;i<a;i++){t.fromBufferAttribute(o,i);let s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),o.setXYZW(i,t.x,t.y,t.z,t.w)}}boneTransform(e,t){let o=this.skeleton;if(o===void 0)return;let i=this.geometry;Ob.fromBufferAttribute(i.attributes.skinIndex,e),Cb.fromBufferAttribute(i.attributes.skinWeight,e),Pb.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let a=0;a<4;a++){let s=Cb.getComponent(a);if(s!==0){let l=Ob.getComponent(a);Tb.multiplyMatrices(o.bones[l].matrixWorld,o.boneInverses[l]),t.addScaledVector(r3.copy(Pb).applyMatrix4(Tb),s)}}return t.applyMatrix4(this.bindMatrixInverse)}};function n3(n){if(n.geometry.attributes.extrudeNormal||!n.geometry.attributes.position||!n.geometry.attributes.normal)return;let r=new Map,e=n.geometry.attributes,t=e.position.array,o=e.normal.array,i=new Float32Array(t.length);for(let a=0;a<t.length;a+=3){let s=`${t[a]}_${t[a+1]}_${t[a+2]}`,l=new jf(o[a],o[a+1],o[a+2]);r.has(s)?r.get(s)?.normals.push(l):r.set(s,{normals:[l],result:new jf})}r.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<t.length;a+=3){let s=`${t[a]}_${t[a+1]}_${t[a+2]}`,l=r.get(s)?.result;l&&(i[a]=l.x,i[a+1]=l.y,i[a+2]=l.z)}n.geometry.setAttribute("extrudeNormal",new Mb(i,3))}function i3(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,t=new Float32Array(e.length),o=new jf;for(let i=0;i<e.length;i+=3)o.set(e[i],e[i+1],e[i+2]).normalize(),t[i]=o.x,t[i+1]=o.y,t[i+2]=o.z;n.geometry.setAttribute("extrudeNormal",new Mb(t,3))}function Ya(n){if(Array.isArray(n.material)){for(let r of n.material)if(r.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof rr)||n.material.getLayersOfType("outline").length===0)return;n instanceof at&&n.is2DAndNoDepth?i3(n):n3(n)}function Xa(n){if(!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,t=new Float32Array(e.length),o=parseInt(n.uuid.replace(/\D/g,"")),i=[Gf.seededRandom(o),Gf.seededRandom(o+1e4),Gf.seededRandom(o+2e4)];for(let a=0;a<e.length;a++)t[a]=i[a%3];n.geometry.setAttribute("randomColor",new o3(t,3))}var uo=new a3,nl=new l3;function Nb(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="SubdivGeometry"&&(r=!0)}),r}var ti=class extends at{constructor(e,t,o){super(e,t,o);this.data=t;this.hiddenMatrixOld=new s3;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,t){let o=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let t=this.localGeometry?.uuid,{originalGeometry:o,subdividedGeometry:i,subdivPointer:a}=ht.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,o!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=o),i!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Ya(this),Xa(this),this.calcBoundingBox(),t&&(this.localGeometry.uuid=t)}updateState(e,t){if(super.updateState(e,t),e.flatShading!==void 0){let o=this.material;this.material=Array.isArray(o)?o.map(i=>i.getFlavor(!1,i.side,i.wireframe)):o.getFlavor(!1,o.side,o.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(t)}}updateMesh(e=!1){ht.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&ht.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=ht.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=ht.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,t){let o=this.localGeometry;this.localGeometry=this.originalGeometryNew,Pt.prototype.raycast.call(this,e,t),this.localGeometry=o}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Ib,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;uo.setFromBufferAttribute(t),uo.getCenter(o),e.boundingSphere.radius=o.distanceTo(uo.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),uo.getSize(nl),this.hasNonUniformScale&&nl.divide(this.scale);let i={width:nl.x,height:nl.y,depth:nl.z};return this.geometry.userData.parameters=i,i}updateBoundingSphere(e){let t=this.originalGeometry;uo.min.set(e[0],e[2],e[4]),uo.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(uo.min.applyMatrix4(this.shearScaleInv),uo.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new Ib);let o=t.boundingSphere.center;uo.getCenter(o),t.boundingSphere.radius=o.distanceTo(uo.max)}freeSubdivPointer(){this.subdivPointer&&(ht.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,t,o){super.updateByPatchedOpGeometry(e,t,o),this.localGeometry&&this.createGeometryByControls(t)}};import{Triangle as c3,Vector3 as oi}from"three";var Db=-1,u3=1,Eb={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},_b={polygon_center:0,edge:1,vertex:2},il=(n,r)=>(e,t)=>!r||e===0||n===0?0:n*t/100,Te=(n,r)=>{let e=Math.abs(r),t=e*-1;return(n-Db)*(e-t)/(u3-Db)+t};function Bb(n){let r=[],e={};for(var t=0,o=n.length;t<o;t++){var i=JSON.stringify(n[t].pos.map(a=>Math.round(a*1e4)/1e4));e[i]||(r.push(n[t]),e[i]=!0)}return r}var d3=new oi,Iu=new oi,p3=new oi,f3=new oi;function Ka(n,r){let e=p3.fromArray(n),t=f3.fromArray(r);Iu.copy(t).sub(e);let o=Iu.length();return Iu.normalize().multiplyScalar(o*.5),d3.copy(e).add(Iu).toArray()}var Sr=new c3,Nu=new oi,Du=new oi,ri=new oi;function Lb(n){let r=[];for(let e=0;e<=n.index.count;e++)if(Nu.fromArray(n.index.array,e*3),Sr.setFromAttributeAndIndices(n.attributes.position,Nu.x,Nu.y,Nu.z),Sr.getNormal(Du),Sr.getMidpoint(ri),!(isNaN(ri.x)||isNaN(ri.y)||isNaN(ri.z))){let{a:t,b:o,c:i}=Sr,a=t.toArray(),s=o.toArray(),l=i.toArray(),c=t.distanceTo(o),u=o.distanceTo(i),p=i.distanceTo(t),d=Ka(a,s),h=Ka(s,l),f=Ka(l,a),m=[c,u,p],y=Math.max(...m),g=m.filter(P=>Math.round(P)===Math.round(y)).length>1,v=[],O=Sr.getMidpoint(ri).toArray();y===c&&!g&&(v=[h,f,f],O=d),y===u&&!g&&(v=[d,f,f],O=h),y===p&&!g&&(v=[d,h,h],O=f),g&&(v=[d,h,f]),r.push({vertices:[a,s,l],faceCenters:v,midpoint:O,norm:Sr.getNormal(Du).toArray()})}return r}function Rb(n){let r=[],{position:e}=n.attributes;for(let t=0;t<e.count;t++){Sr.setFromAttributeAndIndices(e,t*3,t*3+1,t*3+2),Sr.getNormal(Du),Sr.getMidpoint(ri);let o=Sr.a.toArray(),i=Sr.b.toArray(),a=Sr.c.toArray();r.push({vertices:[o,i,a],faceCenters:[Ka(o,i),Ka(i,a),Ka(a,o)],midpoint:ri.toArray(),norm:Du.toArray()})}return r}var h3=4,m3=.5,Ff=n=>.5*(1-Math.cos(n*Math.PI)),Uf=class{constructor(){this.perlin=new Array(4095+1)}noise(r,e=0,t=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}r<0&&(r=-r),e<0&&(e=-e),t<0&&(t=-t);let o=Math.floor(r),i=Math.floor(e),a=Math.floor(t),s=r-o,l=e-i,c=t-a,u,p,d=0,h=.5,f,m,y;for(let g=0;g<h3;g++){let v=o+(i<<4)+(a<<8);u=Ff(s),p=Ff(l),f=this.perlin[v&4095],f+=u*(this.perlin[v+1&4095]-f),m=this.perlin[v+16&4095],m+=u*(this.perlin[v+16+1&4095]-m),f+=p*(m-f),v+=256,m=this.perlin[v&4095],m+=u*(this.perlin[v+1&4095]-m),y=this.perlin[v+16&4095],y+=u*(this.perlin[v+16+1&4095]-y),m+=p*(y-m),f+=Ff(c)*(m-f),d+=f*h,h*=m3,o<<=1,s*=2,i<<=1,l*=2,a<<=1,c*=2,s>=1&&(o++,s--),l>=1&&(i++,l--),c>=1&&(a++,c--)}return d}noiseSeed(r){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(r),this.perlin=new Array(4095+1);for(let t=0;t<4095+1;t++)this.perlin[t]=e.rand()}},Vb=Uf;import{Vector3 as y3,Matrix4 as g3,Ray as x3}from"three";var zb=new y3,Gb=new g3,jb=new x3;function Fb(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(r=!0)}),r}var Qa=class extends at{constructor(e,t,o){super(e,t,o);this.data=t}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,e.geometry.height,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,t){let{matrixWorld:o}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(Gb.copy(o).invert(),jb.copy(e.ray).applyMatrix4(Gb),jb.intersectBox(this.singleBBox,zb))){let i=zb.applyMatrix4(o),a=e.ray.origin.distanceTo(i);t.push({distance:a,point:i.clone(),object:this})}}};var Xt=1e-4,po,Wb,qb,$b,kb=new pr,Hb=new pr;pu.then(n=>{po=n,Wb=[po.get_face_center,po.get_edge_midpoint,po.get_vertex_position],qb=[po.get_face_normal,po.get_edge_normal,po.get_vertex_normal],$b=[po.face_count,po.edge_count,po.vertex_count]});var v3=new ni,S3=new ni,gn=new pr,Eu=new pr,al=new pr,Hf=new pr,w3=new pr,P3=new pr;var zo=new Vb,Ja=class extends na(b3){constructor(e,t){super();this.parameters=t;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let t of this.children)t instanceof No&&t.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(t=>{t instanceof No&&t.object===e&&(t.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}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);break;case"toObject":this._updateToObject(this.parameters)}for(let e of this.children)e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD())}_updateCount(e){let t;if(e!==void 0?t=e:t=this.parameters.type==="grid"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(t=0),this.parameters.type==="toObject"&&this.objectForSample){for(let i=0,a=this.children.length;i<a;++i)this.remove(this.children[0]);let o=this.children;if(o.length===t)return;if(o.length<t)for(let i=0,a=t-o.length;i<a;++i){let s=new No(this.object);s.expand(),this.add(s)}else for(let i=0,a=o.length-t;i<a;++i)this.remove(o[i])}else{if(this.children.length===t)return;if(this.children.length<t)for(let o=0,i=t-this.children.length;o<i;++o){let a=new No(this.object);a.expand(),this.add(a)}else for(let o=0,i=this.children.length-t;o<i;++o)this.remove(this.children[0])}}_updateRadial(e){let t=e.radial,o=t.start*Ub.DEG2RAD,i=t.end*Ub.DEG2RAD,a=o-i,s=new kf(t.rotation[0],t.rotation[1],t.rotation[2]),l;switch(t.axis){case"z":l=new pr(0,0,1);break;case"y":l=new pr(0,1,0);break;default:case"x":l=new pr(1,0,0);break}let c=e.randomnessObject??Qr.defaultData([1,1,1]).randomnessObject,u=c.noiseType==="perlin";zo.noiseSeed(c.seed);let p=jc((0,Za.default)(c.seed)),d=il(c.strength,this.parameters.randomness);for(let[h,f]of this.children.entries()){let m=h*(c.freqScale/10)+c.movement,y=u?zo.noise(m):p(m,m),g=h+1;f.scale.x=t.scale[0]+d(g,Te(y,c.scale[0]))||Xt,f.scale.y=t.scale[1]+d(g,Te(y,c.scale[1]))||Xt,f.scale.z=t.scale[2]+d(g,Te(y,c.scale[2]))||Xt,f.position.setScalar(0);let v=a/e.count*h-o;switch(t.axis){case"x":f.rotation.set(0,v,0);break;case"y":f.rotation.set(0,0,v);break;case"z":f.rotation.set(v,0,0);break}f.translateOnAxis(l,t.radius),f.position.x+=t.position[0]+d(g,Te(y,c.position[0])),f.position.y+=t.position[1]+d(g,Te(y,c.position[1])),f.position.z+=t.position[2]+d(g,Te(y,c.position[2]));let O=d(g,Te(y,c.rotation[0])),P=d(g,Te(y,c.rotation[1])),S=d(g,Te(y,c.rotation[2]));t.alignment===!0?(f.rotation.x+=s.x+O,f.rotation.y+=s.y+P,f.rotation.z+=s.z+S):f.rotation.set(s.x+O,s.y+P,s.z+S)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,o=new kf(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Qr.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";zo.noiseSeed(i.seed);let s=jc((0,Za.default)(i.seed)),l=il(i.strength,this.parameters.randomness);for(let[c,u]of this.children.entries()){let p=c*(i.freqScale/10)+i.movement,d=a?zo.noise(p):s(p,p),h=c+1,f=l(h,Te(d,i.rotation[0])),m=l(h,Te(d,i.rotation[1])),y=l(h,Te(d,i.rotation[2]));u.scale.x=1+(t.scale[0]-1)*c+l(h,Te(d,i.scale[0]))||Xt,u.scale.y=1+(t.scale[1]-1)*c+l(h,Te(d,i.scale[1]))||Xt,u.scale.z=1+(t.scale[2]-1)*c+l(h,Te(d,i.scale[2]))||Xt,u.rotation.x=o.x*c+f,u.rotation.y=o.y*c+m,u.rotation.z=o.z*c+y,u.position.x=t.position[0]*c+l(h,Te(d,i.position[0])),u.position.y=t.position[1]*c+l(h,Te(d,i.position[1])),u.position.z=t.position[2]*c+l(h,Te(d,i.position[2]))}}_updateGrid(e){let t=0,o=e.grid,i=e.randomnessObject??Qr.defaultData([1,1,1]).randomnessObject,a=il(i.strength,this.parameters.randomness),s=i.noiseType==="perlin";zo.noiseSeed(i.seed);let l=c0((0,Za.default)(i.seed));if(o.useCenter===!0){let c={x:o.count[0]%2===0?2:1,y:o.count[1]%2===0?2:1,z:o.count[2]%2===0?2:1},u=new pr(o.size[0]*(o.count[0]-c.x)*.5,o.size[1]*(o.count[1]-c.y)*.5,o.size[2]*(o.count[2]-c.z)*.5);for(let p=0;p<o.count[0];p++)for(let d=0;d<o.count[1];d++)for(let h=0;h<o.count[2];h++){let f=[(p+1)*(i.freqScale/10)+i.movement,(d+1)*(i.freqScale/10)+i.movement,(h+1)*(i.freqScale/10)+i.movement],m=s?zo.noise(...f):l(...f),y=this.children[t++];y.scale.x=1+a(t,Te(m,i.scale[0]))||Xt,y.scale.y=1+a(t,Te(m,i.scale[1]))||Xt,y.scale.z=1+a(t,Te(m,i.scale[2]))||Xt;let g=a(t,Te(m,i.rotation[0])),v=a(t,Te(m,i.rotation[1])),O=a(t,Te(m,i.rotation[2]));y.rotation.set(g,v,O),y.position.x=o.size[0]*p-u.x+a(t,Te(m,i.position[0])),y.position.y=o.size[1]*d-u.y+a(t,Te(m,i.position[1])),y.position.z=o.size[2]*h-u.z+a(t,Te(m,i.position[2]))}}else for(let c=0;c<o.count[0];c++)for(let u=0;u<o.count[1];u++)for(let p=0;p<o.count[2];p++){let d=[(c+1)*(i.freqScale/10)+i.movement,(u+1)*(i.freqScale/10)+i.movement,(p+1)*(i.freqScale/10)+i.movement],h=s?zo.noise(...d):l(...d),f=this.children[t++];f.scale.x=1+a(t,Te(h,i.scale[0]))||Xt,f.scale.y=1+a(t,Te(h,i.scale[1]))||Xt,f.scale.z=1+a(t,Te(h,i.scale[2]))||Xt;let m=a(t,Te(h,i.rotation[0])),y=a(t,Te(h,i.rotation[1])),g=a(t,Te(h,i.rotation[2]));f.rotation.set(m,y,g),f.position.x=o.size[0]*c+a(t,Te(h,i.position[0])),f.position.y=-o.size[1]*u+a(t,Te(h,i.position[1])),f.position.z=-o.size[2]*p+a(t,Te(h,i.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:t}=e,o=new kf(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Qr.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";zo.noiseSeed(i.seed);let s=jc((0,Za.default)(i.seed)),l=il(i.strength,this.parameters.randomness);if(!t.object){for(let[,g]of this.children.entries())g.position.set(0,0,0),g.scale.setScalar(1),g.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof Qa)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let c=this.getSubdivData(),u=[],p=g=>{let v=g.length,O=g.map(T=>T[0]).reduce((T,I)=>T+I,0),P=g.map(T=>T[1]).reduce((T,I)=>T+I,0),S=g.map(T=>T[2]).reduce((T,I)=>T+I,0);return[O/v,P/v,S/v]},d=g=>Math.round(g*1e6)/1e6;c.forEach(g=>{let v=c.filter(O=>d(g.pos[0])===d(O.pos[0])&&d(g.pos[1])===d(O.pos[1])&&d(g.pos[2])===d(O.pos[2]));v.length>1?u.push({pos:g.pos,norm:p(v.map(O=>O.norm))}):u.push(g)});let h=Bb(u);if(h.length>0){let g=Math.round(h.length*t.count/100);this._updateCount(g)}else{let g=this.objectForSample.geometry.getAttribute("position");if(!g||isNaN(g.count)||g.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let f=new Fc(this.objectForSample).build(),m=Eb[t.axis],y=this.children;f.setRandomGenerator((0,Za.default)(this.object.uuid+t.seed));for(let[g,v]of y.entries()){let O=g*(i.freqScale/10)+i.movement,P=a?zo.noise(O):s(O,O),S=g+1,T=l(S,Te(P,i.rotation[0])),I=l(S,Te(P,i.rotation[1])),x=l(S,Te(P,i.rotation[2]));t.spreadType==="random"?f.sample(al,Hf):(h.length&&(al.fromArray(h[g].pos),Hf.fromArray(h[g].norm)),this.objectForSample instanceof ti&&al.applyMatrix4(v3.copy(this.objectForSample.matrixWorld).invert())),al.applyMatrix4(this.object.hiddenMatrix.clone().invert()),v.position.copy(al),gn.fromArray(m);let _=t.align==="normal"?Hf:this.object.getWorldDirection(P3),D=Eu.fromArray(t.position);Eu.x+=l(S,Te(P,i.position[0])),Eu.y+=l(S,Te(P,i.position[1])),Eu.z+=l(S,Te(P,i.position[2]));let A=Math.acos(_.dot(gn)),N=w3.crossVectors(gn,_).normalize(),E=S3.makeRotationAxis(N,A),B=_.clone().cross(this.object.up).normalize(),V=B.clone().cross(_).normalize(),j=new ni().makeBasis(B,_,V),R=new pr(gn.y,gn.z,gn.x).normalize(),W=R.clone().cross(gn).normalize(),F=new ni().makeBasis(R,gn,W).invert(),k=new ni().multiplyMatrices(j,F);v.rotation.setFromRotationMatrix(k),D.applyMatrix4(E),v.position.add(D),v.rotation.x=v.rotation.x+o.x+T,v.rotation.y=v.rotation.y+o.y+I,v.rotation.z=v.rotation.z+o.z+x,v.scale.setScalar(1),v.scale.x=v.scale.x+t.scale[0]+l(S,Te(P,i.scale[0]))||Xt,v.scale.y=v.scale.y+t.scale[1]+l(S,Te(P,i.scale[1]))||Xt,v.scale.z=v.scale.z+t.scale[2]+l(S,Te(P,i.scale[2]))||Xt,v.scale.multiply(this.object.scale),v.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof ti){let t=this.objectForSample,o=_b[e],i=$b[o],a=Wb[o],s=qb[o],l=[],c=i(t.subdivPointerNew);for(let u=0;u<=c-1;u++){let p=a(t.subdivPointerNew,u),d=s(t.subdivPointerNew,u);kb.fromArray(p).applyMatrix4(t.matrixWorld),Hb.fromArray(d),l.push({pos:kb.toArray(),norm:Hb.toArray()})}return l}else return(this.objectForSample.geometry.index?Lb(this.objectForSample.geometry):Rb(this.objectForSample.geometry)).map((o,i)=>e==="polygon_center"?{pos:o.midpoint,norm:o.norm}:e==="vertex"?[{pos:o.vertices[0],norm:o.norm},{pos:o.vertices[1],norm:o.norm},{pos:o.vertices[2],norm:o.norm}]:e==="edge"?[{pos:o.faceCenters[0],norm:o.norm},{pos:o.faceCenters[1],norm:o.norm},{pos:o.faceCenters[2],norm:o.norm}]:[]).flat()}updateState(e,t){if(this.parameters=So(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let o=t.find(this.parameters.toObject.object);o instanceof Pt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new ni,this.hiddenMatrix=new ni,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};import{Scene as wE,Vector3 as PE,Matrix4 as OE,Box3 as CE,MeshBasicMaterial as TE,Skeleton as AE}from"three";import{Camera as L3,OrthographicCamera as R3,PerspectiveCamera as V3,Vector3 as kr,Object3D as Qb,Quaternion as z3,Matrix4 as G3}from"three";import{Camera as I3,LineSegments as N3,BufferGeometry as D3,LineBasicMaterial as E3,Color as qf,Vector3 as _3,Float32BufferAttribute as Xb}from"three";import{BoxGeometry as O3}from"three";var fo=n=>{var r;return r=class extends n{},r.geometryHelper=new O3(30,30,30),r};import{Ray as C3,Sphere as T3,Matrix4 as A3,Vector3 as Go}from"three";var _u=new C3,Wf=new T3,Yb=new A3,ho=(n,r,e,t,o=!1)=>{let i=r,a=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),Wf.copy(i.boundingSphere),Wf.applyMatrix4(a),e.ray.intersectsSphere(Wf)===!1||(Yb.copy(a).invert(),_u.copy(e.ray).applyMatrix4(Yb),i.boundingBox!==null&&_u.intersectsBox(i.boundingBox)===!1))return;let s,l,c,u,p=i.index,d=i.attributes.position,h=i.drawRange,f,m;if(o===!1){let g=Math.max(0,h.start),v=Math.min(p.count,h.start+h.count);for(f=g,m=v;f<m;f+=3)if(l=p.getX(f),c=p.getX(f+1),u=p.getX(f+2),s=y(n,e,_u,d,l,c,u),s){s.faceIndex=Math.floor(f/3),t.push(s);return}}else{let v=i.attributes.position,O=new Go,P=new Go,S=new Go,T=new Go,I=2,_=1/((n.scale.x+n.scale.y+n.scale.z)/3),D=_*_,A=Math.max(0,h.start),N=Math.min(v.count,h.start+h.count);for(let E=A,B=N-1;E<B;E+=I){if(O.fromBufferAttribute(v,E),P.fromBufferAttribute(v,E+1),_u.distanceSqToSegment(O,P,T,S)>D)continue;T.applyMatrix4(n.matrixWorld);let j=e.ray.origin.distanceTo(T);j<e.near||j>e.far||t.push({distance:j,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(g,v,O,P,S,T,I){let x=new Go,_=new Go,D=new Go,A=new Go,N=new Go;if(x.fromBufferAttribute(P,S),_.fromBufferAttribute(P,T),D.fromBufferAttribute(P,I),O.intersectTriangle(x,_,D,!1,A)===null)return null;N.copy(A),N.applyMatrix4(g.matrixWorld);let B=v.ray.origin.distanceTo(N);return B<v.near||B>v.far?null:{faceIndex:1,distance:B,point:N.clone(),object:g}}};var Bu=new _3,wr=new I3,$f=class extends N3{constructor(e){let t=new D3,o=new E3({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],a=[],s={},l=new qf(15711266),c=new qf(15711266),u=new qf(2857471);p("n1","n2",l),p("n2","n4",l),p("n4","n3",l),p("n3","n1",l),p("f1","f2",l),p("f2","f4",l),p("f4","f3",l),p("f3","f1",l),p("n1","f1",l),p("n2","f2",l),p("n3","f3",l),p("n4","f4",l),p("p","n1",c),p("p","n2",c),p("p","n3",c),p("p","n4",c),p("u1","u2",u),p("u2","u3",u),p("u3","u1",u);function p(h,f,m){d(h,m),d(f,m)}function d(h,f){i.push(0,0,0),a.push(f.r,f.g,f.b),s[h]===void 0&&(s[h]=[]),s[h].push(i.length/3-1)}t.setAttribute("position",new Xb(i,3)),t.setAttribute("color",new Xb(a,3));super(t,o);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,t=this.pointMap,o=!0;wr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=1,a=1,s=o?.8:1e-4;Ur("n1",t,e,wr,-i,-a,s),Ur("n2",t,e,wr,i,-a,s),Ur("n3",t,e,wr,-i,a,s),Ur("n4",t,e,wr,i,a,s);let l=s;Ur("f1",t,e,wr,-i,-a,l),Ur("f2",t,e,wr,i,-a,l),Ur("f3",t,e,wr,-i,a,l),Ur("f4",t,e,wr,i,a,l);let c=l,u=.5;Ur("u1",t,e,wr,i*.7*u,a*1.1,c),Ur("u2",t,e,wr,-i*.7*u,a*1.1,c),Ur("u3",t,e,wr,0,a*(1.1+.9*u),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Ur(n,r,e,t,o,i,a){Bu.set(o,i,a).unproject(t);let s=r[n];if(s!==void 0){let l=e.getAttribute("position");for(let c=0,u=s.length;c<u;c++)l.setXYZ(s[c],Bu.x,Bu.y,Bu.z)}}var Lu=class extends fo($f){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){ho(this.object,this.geometry,e,t,!0)}};import{Box3Helper as Kb,BoxGeometry as B3}from"three";var Ru;(r=>r.is=e=>"objectHelper"in e)(Ru||(Ru={}));var Pr=(n,r)=>class extends sa(n){constructor(){super(...arguments);this.objectHelper=new r(this);this.gizmos={}}get geometryHelper(){return r.geometryHelper}raycast(o,i){this.objectHelper.raycast(o,i)}showGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof Kb&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof B3?(o.setScalar(0),i.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(o,i)}hideGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof Kb&&(i.visible=!1)}}};var Vu=790,es=new kr,Yf=new kr,Xf=new z3,Kf=new kr,sl=new kr,Qf=new kr,jo=class extends Pr(L3,Lu){constructor(e="",t={...Gn.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=on.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,t),this.previousProjectionMatrix=new G3,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,i=this.height;this.orthoCamera=new R3(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4),this.perspCamera=new V3(45,o/i,50,1e4),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.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}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,t,o){typeof e=="number"&&(e=new kr(e,t,o)),super.lookAt(e),this.getWorldPosition(es),this.targetOffset=es.distanceTo(e)}getTarget(e=new kr){return this.getWorldDirection(Yf),this.getWorldPosition(es),Yf.multiplyScalar(this.targetOffset),e.copy(es).add(Yf),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(es),es.distanceTo(e)}updateUp(){this.getWorldQuaternion(Xf),Kf.set(0,0,1).applyQuaternion(Xf),sl.copy(Qb.DEFAULT_UP),this.isUpVectorFlipped&&sl.negate(),sl.applyQuaternion(Xf),Qf.copy(Qb.DEFAULT_UP).projectOnPlane(Kf),this.angleOffsetFromUp=Qf.angleTo(sl),this.angleOffsetFromUp*=Qf.cross(sl).dot(Kf)>=0?1:-1}updateTransformState(e,t){let o=super.updateTransformState(e,t);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),o}getViewFrontToObject(e){let t=e.getWorldPosition(new kr),i=e.getWorldDirection(new kr).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToTarget(e){let o=this.getWorldDirection(new kr).multiplyScalar(this.targetOffset);return{position:e.clone().sub(o),target:e}}getViewToObject(e){let t=new kr,o=e.getWorldPosition(t);return this.getViewToTarget(t)}setViewplaneSize(e,t,o=!1){if(this.aspect=e/t,o){let i=e>t?this.aspect:1,a=e>t?1:this.aspect;this.left=-Vu*.5*i,this.right=Vu*.5*i,this.top=Vu*.5*(1/a),this.bottom=-Vu*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){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.objectHelper&&this.objectHelper.update()}toPerspective(){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.objectHelper&&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,o,i,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,o,i,a,s):this.orthoCamera.setViewOffset(e,t,o,i,a,s)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}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.parent=e.parent,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}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 Li(t,e)}updateCameraSubtype(e,t){let o=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";t.zoom!==void 0&&this.setZoom(o,t.zoom),t.near!==void 0&&this.setNear(o,t.near),t.fov!==void 0&&o==="PerspectiveCamera"&&(this.fov=t.fov)}updateState(e,t){this.updateCameraState(e,t)}updateCameraState(e,t){this.updateState_Entity(e,t),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),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()}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}};import{MathUtils as Ore}from"three";import{BufferGeometry as Zb,Matrix4 as Jb,Float32BufferAttribute as j3}from"three";var ts=new Jb,F3=new Jb;var nr=class extends or{constructor(e,t,o){super(e,t);this.data=t;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new Zb;this.onAfterRender=(e,t,o,i,a,s)=>{super.onAfterRender(e,t,o,i,a,s),this.recomputeBoolean()};this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,t=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let i=0;i<this.children.length;i++){let a=this.children[i];a instanceof nr&&a.dataPatched.visible===!0&&a.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let a=this.children[i];if(a instanceof Pt&&a.dataPatched.visible===!0&&a.geometry.attributes.position?.count>0&&a.geometry.drawRange.count>0&&a.booleanMeshSetAddress!==0){ts.multiplyMatrices(a.hiddenMatrix,a.matrix);try{if(a.booleanMeshSetAddress===-1){if((a.geometry.index??a.geometry.getAttribute("position")).count/3<15e5&&(a.booleanMeshSetAddress=br.getMeshSet(a.geometry,e===!0,t)),a.booleanMeshSetAddress===-1)return;br.transformMeshSet(a.booleanMeshSetAddress,ts),a.booleanMatrixInvOld.copy(ts).invert(),a.booleanWasTransformed=!1}else a instanceof nr&&a.needsTransformForDownstream===!0?(br.transformMeshSet(a.booleanMeshSetAddress,ts),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(br.transformMeshSet(a.booleanMeshSetAddress,F3.multiplyMatrices(ts,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(ts).invert(),a.booleanWasTransformed=!1)}catch(s){console.error(s),a.booleanMeshSetAddress=0,a.geometry.userData.booleanOperationDidFail=!0;continue}br.hasOpenEdges(a.booleanMeshSetAddress)===!1||i===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(a.booleanMeshSetAddress),a.geometry.userData.booleanOperationDidFail=!1):a.geometry.userData.booleanOperationDidFail="openEdges"}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new j3([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return br.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new Zb,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=br.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,Ya(this),Xa(this)}dispose(){super.dispose(),this.geometry.dispose()}};import{Light as U3}from"three";var ev;(r=>{function n(e){return Le.is(e)&&e instanceof U3}r.is=n})(ev||(ev={}));var rs=(n,r)=>class extends Pr(n,r){updateState_Light(t,o){this.updateState_Entity(t,o),t.color!==void 0&&(this.color=o.shared.color(t.color)),t.intensity!==void 0&&(this.intensity=t.intensity),t.depth!==void 0&&(this.shadow.camera.far=t.depth,this.shadow.needsUpdate=!0),t.shadows!==void 0&&(this.castShadow=t.shadows)}};var xn=n=>n instanceof Pt,ll=n=>n!==null&&n instanceof nr;var cl=n=>Ru.is(n);import{Group as H3}from"three";import{AxesHelper as k3}from"three";var Or=class extends fo(k3){constructor(e,t=15){super(t);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,t){ho(this.object,Or.geometryHelper,e,t)}update(){}};var bn=class extends Pr(H3,Or){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update()}updateState(r,e){this.updateState_Entity(r,e),"buffer"in r&&Object.keys(r).length===1&&e.scene.reloadSplats()}};import{Group as W3}from"three";var zu=class extends Pr(W3,Or){constructor(e,t,o){super();this.super_Entity(e,t),this.context=o,this.objectHelper.update()}updateState(e,t){this.updateState_Entity(e,t)}};import{Color as xD,Fog as bD,HemisphereLight as vD}from"three";import{ShaderChunk as ul}from"three";var q3=n=>`
2230
2230
 
2231
2231
  // PCSS implementation based on:
2232
2232
  // https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
@@ -2600,7 +2600,7 @@ float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, floa
2600
2600
  }
2601
2601
 
2602
2602
  #endif
2603
- `,$3=dl.lights_fragment_begin,Y3=dl.shadowmask_pars_fragment,ev=null,X3=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},tv=(n="medium")=>{if(ev===n)return!1;ev=n;let r=X3(n);dl.shadowmap_pars_fragment=q3(r);let e=$3.slice();e=e.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),e=e.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),dl.lights_fragment_begin=e;let t=Y3.slice();return t=t.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),dl.shadowmask_pars_fragment=t,!0};import{DirectionalLight as eD,CameraHelper as rv}from"three";import{DirectionalLightHelper as K3}from"three";var ns=class extends po(K3){constructor(e,t=15,o=10066329){super(e,t,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){fo(this.object,ns.geometryHelper,e,t)}};import{PointLightHelper as Q3}from"three";var is=class extends po(Q3){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){fo(this.object,is.geometryHelper,e,t)}};import{SpotLightHelper as Z3,Vector3 as J3}from"three";var ju=class extends po(Z3){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){fo(this.object,ju.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=ju._vector,t=this.object.distance?this.object.distance:1e3,o=t*Math.tan(this.object.angle);this.cone.scale.set(o,o,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let i=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let a=0,s=this.cone.material.length;a<s;a++)this.cone.material[a].color.set(i);else this.cone.material.color.set(i)}}},pl=ju;pl._vector=new J3;function tD(n,r){n.shadow.camera.right=r/2,n.shadow.camera.left=-r/2,n.shadow.camera.top=r/2,n.shadow.camera.bottom=-r/2,n.shadow.needsUpdate=!0}var as=class extends os(eD,ns){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let a=new rv(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof rv&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e);let t=r.depth!==void 0&&r.depth!==this.shadow.camera.far||r.size!==void 0&&r.size/2!==this.shadow.camera.right;r.size!==void 0&&tD(this,r.size),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),r.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t&&this.update()}};import{Scene as SD}from"three";import{SpotLight as rD,CameraHelper as ov,MathUtils as oD,Vector3 as sv,Quaternion as nD}from"three";var nv=new sv,iv=new sv,av=new nD,ss=class extends os(rD,pl){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=oD.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let a=new ov(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof ov&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),iv.setFromMatrixPosition(this.matrixWorld),av.setFromRotationMatrix(this.matrixWorld),nv.copy(this.up).applyQuaternion(av).negate().multiplyScalar(this.distance),this.target.position.copy(iv).add(nv),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.angle!==void 0&&(this.angle=r.angle),r.penumbra!==void 0&&(this.penumbra=r.penumbra),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};function iD(n){let r=(n[0][0]+n[1][1])/2,e=(n[0][0]-n[1][1])/2,t=(n[1][0]+n[0][1])/2,o=(n[1][0]-n[0][1])/2,i=Math.sqrt(r*r+o*o),a=Math.sqrt(e*e+t*t),s=i+a,l=i-a,c=Math.atan2(t,e),u=Math.atan2(o,r),p=(u-c)/2,d=(u+c)/2,h=[[Math.cos(d),Math.sin(d)],[-Math.sin(d),Math.cos(d)]],f=[[s,0],[0,l]],m=[[Math.cos(p),Math.sin(p)],[-Math.sin(p),Math.cos(p)]];return h[0][0]*=-1,h[0][1]*=-1,m[0][0]*=-1,m[1][0]*=-1,[h,f,m]}function Fu(n,r){return[[n[0][0]*r[0][0]+n[0][1]*r[1][0],n[0][0]*r[0][1]+n[0][1]*r[1][1]],[n[1][0]*r[0][0]+n[1][1]*r[1][0],n[1][0]*r[0][1]+n[1][1]*r[1][1]]]}function lv(n){return[[n[0][0],n[1][0]],[n[0][1],n[1][1]]]}function cv(n){let[r,e,t]=iD(n),o=Fu(r,lv(t)),i=Fu(Fu(t,e),lv(t)),a=Math.atan2(o[1][0],o[0][0]),s=[i[0][0],i[1][1]],l=[i[0][1]/i[1][1],i[1][0]/i[0][0]];return{rotation:a,scale:s,shear:l}}function uv({rotation:n,scale:r,shear:e}){let t=Math.cos(n),o=Math.sin(n),i=[[t,-o],[o,t]],a=[[r[0],e[0]*r[1]],[e[1]*r[0],r[1]]],s=Fu(i,a);return[s[0][0],s[1][0],s[0][1],s[1][1]]}var ze;(S=>{function n(){return[1,0,0,0,1,0,0,0,1]}S.identity=n;function r(T,I=S.identity()){for(let x=0,_=T.length;x<_;x++)I[x]=T[x];return I}S.copy=r;function e(T,I,x,_,D,A){return S.setAbcdef(S.identity(),T,I,x,_,D,A)}S.create=e;function t(T,I,x,_,D,A,N){return T[0]=I,T[1]=_,T[2]=A,T[3]=x,T[4]=D,T[5]=N,T}S.setAbcdef=t;function o(T,I){let[x,_,D,A,N,E]=a(T),[B,V,j,R,W,F]=a(I),k=B*x+V*D,H=B*_+V*A,$=j*x+R*D,J=j*_+R*A,Z=W*x+F*D+N,X=W*_+F*A+E;return S.create(k,H,$,J,Z,X)}S.append=o;function i(T,I){let[x,_,D,A,N,E]=a(T),[B,V,j,R,W,F]=a(I),k=x,H=_,$=D,J=A;(B!==1||V!==0||j!==0||R!==1)&&(k=x*B+_*j,H=x*V+_*R,$=D*B+A*j,J=D*V+A*R);let Z=N*B+E*j+W,X=N*V+E*R+F;return S.create(k,H,$,J,Z,X)}S.prepend=i;function a(T){return[T[0],T[3],T[1],T[4],T[2],T[5]]}S.getAbcdef=a;function s(T){let[I,x,_,D,A,N]=S.getAbcdef(T),E=I*D-x*_,B=D/E,V=-x/E,j=-_/E,R=I/E,W=(_*N-D*A)/E,F=-(I*N-x*A)/E;return S.create(B,V,j,R,W,F)}S.invert=s;function l([T,I],x){let[_,D,A,N,E,B]=S.getAbcdef(x);return[_*T+A*I+E,D*T+N*I+B]}S.apply=l;function c(T,I){let[x,_,D,A,N,E]=S.getAbcdef(I),B=1/(x*A+D*-_),[V,j]=T;return[A*B*V+-D*B*j+(E*D-N*A)*B,x*B*j+-_*B*V+(-E*x+N*_)*B]}S.applyInverse=c;function u(T,I,x=I){let[_,D,A,N,E,B]=S.getAbcdef(T);return S.setAbcdef(T,_*I,D*x,A*I,N*x,E*I,B*x),T}S.scale=u;function p(T,I){let x=Math.cos(I),_=Math.sin(I),[D,A,N,E,B,V]=S.getAbcdef(T);return S.setAbcdef(T,D*x-A*_,D*_+A*x,N*x-E*_,N*_+E*x,B*x-V*_,B*_+V*x),T}S.rotate=p;function d(T,I,x){let[_,D]=x,A=S.translate(T,-_,-D);return A=S.rotate(A,I),A=S.translate(A,_,D),A}S.rotateAround=d;function h(T,I,x){let[_,D,A,N,E,B]=S.getAbcdef(T);return S.setAbcdef(T,_,D,A,N,E+I,B+x),T}S.translate=h;function f(T,I,x){let[_,D,A,N]=S.getAbcdef(T);return S.setAbcdef(T,_,D,A,N,I,x),T}S.setTranslate=f;function m(T,I,x){let[_,D,A,N]=S.getAbcdef(T);return S.setAbcdef(T,_,D,A,N,I,x),T}S.setPosition=m;function y(T){let[I,x,_,D]=S.getAbcdef(T),A=Math.sqrt(I*I+x*x),N=Math.sqrt(_*_+D*D);return[A,N]}S.getScale=y;function g(T){let[,,,,I,x]=S.getAbcdef(T);return[I,x]}S.getPosition=g;function v(T,I){return S.decompose(T,I).rotation}S.getRotation=v;function O(T,I){let[x,_,D,A,N,E]=S.getAbcdef(T),{rotation:B,scale:V,shear:j}=cv([[x,D],[_,A]]);return{position:[N+(I[0]*x+I[1]*D)-I[0],E+(I[0]*_+I[1]*A)-I[1]],scale:V,rotation:B,shear:j,pivot:I}}S.decompose=O;function P(T,I,x,_,D=[0,0]){let[A,N]=T,[E,B]=_,[V,j,R,W]=uv({rotation:x,scale:I,shear:D}),F=A-(E*V+B*R)+E,k=N-(E*j+B*W)+B;return S.create(V,j,R,W,F,k)}S.compose=P})(ze||(ze={}));var aD=Math.PI/180,Loe=180/Math.PI;function dv(n,r,e,t,o,i){let a=n-e,s=r-t;return a*a/(o*o)+s*s/(i*i)<=1}function pv(n){return n*aD}function Zf(n){return{all:n=n||new Map,on:function(r,e){var t=n.get(r);t?t.push(e):n.set(r,[e])},off:function(r,e){var t=n.get(r);t&&(e?t.splice(t.indexOf(e)>>>0,1):n.set(r,[]))},emit:function(r,e){var t=n.get(r);t&&t.slice().map(function(o){o(e)}),(t=n.get("*"))&&t.slice().map(function(o){o(r,e)})}}}var Fo=class{constructor(r,e,t){this.uuid=r;this.data=e;this.localMatrix=ze.identity();this.worldMatrix=ze.identity();this.ignoreCameraZoom=!1;this.visible=!0;this._singleBBox=new Sn;this._recursiveBBox=new Sn;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.stateSelection=null;this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this.name="";this.position=[0,0];this.scale=[1,1];this.rotation=0;this.shear=[0,0];this.emitter=Zf();this.dpr=t.dpr??1,this.dataPatched=e}project(r,e){let t=this.worldMatrix;return e&&(t=ze.append(e.worldMatrix,t)),ze.applyInverse(r,t)}intersects(r,e,t,o=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([r,e],t),o)}intersectsInLocalSpace(r,e,t=!1){let{min:o,max:i}=t?this.recursiveBBox:this.singleBBox;return r>=o[0]&&r<=i[0]&&e>=o[1]&&e<=i[1]}applyTransforms(r){r.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=ze.compose(this.position,this.scale,pv(this.rotation),Mo.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(r,e,t){let o=this.parent;e&&o!==null&&o!==void 0&&o.updateWorldMatrix(r,!0,!1),r&&this.updateLocalMatrix(),this.parent?this.worldMatrix=ze.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=ze.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return Mo.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{r.resetBBoxNeedsUpdateSelf()})}updateTransformState(r){let e=!1;r.position!==void 0&&(e=!0,this.position=r.position),r.rotation!==void 0&&(e=!0,this.rotation=r.rotation),r.scale!==void 0&&(e=!0,this.scale=r.scale),r.shear!==void 0&&(e=!0,this.shear=r.shear),e&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(r,e,t){r.type===0&&r.props.visible!==void 0&&(this.visible=r.props.visible),this.data=e,this.data=e;let o=r,i=Be(r.path,["states","*"]);if(i!==null){if(r.type===0){let[a]=i;if(this?.stateSelection===a){let s={...r.props};if(delete s.name,Object.values(r.props).some(l=>l===void 0)){let l=this.data;if(l!==void 0){let c=rt.zoom(l,r.path.slice(2));if(c)for(let u in r.props)r.props[u]===void 0&&u in c&&(s[u]=c[u])}}o={...r,props:s,path:r.path.slice(2)}}}}else if(r.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(r.props.name!==void 0&&a.name){let{name:l,...c}=a;a=c}let s=rt.removeOverridden(r.path,r.props,a);o={...r,props:s}}}this.updateByPatchedOpBase(o,Un.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),t)}changeSelectedState(r,e,t=!1){if(!(this.data.states.length===0&&!t)){for(let o of this.data.states)Un.toOps(this.data,o.data).forEach(a=>{let s=Fi.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,e)});if(r!==null){let o=this.data.states.data(r);o&&(this.dataPatched=Un.patch(this.data,o),Un.toOps(this.data,o).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,e)}))}t&&this.updateTransformState(this.dataPatched),this.stateSelection=r}}updateState(r,e){r.name!==void 0&&(this.name=r.name),r.visible!==void 0&&(this.visible=r.visible),this.updateTransformState(r)}updateByPatchedOpBase(r,e,t){this.dataPatched=e,this.updateByPatchedOp(r,e,t)}updateByPatchedOp(r,e,t){r.path.length===0&&r.type===0&&this.updateState(r.props,t),this.requestRender()}traverseFrameAncestors(r){this.traverseAncestors(e=>{e.data.type==="frame2d"&&r(e)})}traverseAncestors(r){let e=this.parent;for(;e;)r(e),e=e.parent}requestRender(){this.traverseFrameAncestors(r=>{r.requestRender()})}clone(r){let e=new Fo(this.uuid,this.data,r);return e.parent=void 0,e}addEventListener(r,e){this.emitter.on(r,e)}removeEventListener(r,e){this.emitter.off(r,e)}dispatchEvent(r){this.emitter.emit(r.type,{...r,target:r.target??this})}traverseSortNextHelper(){let r=this.parent;if(r){let e=r.children;if(e){let t=e.indexOf(this)+1;return e[t]?e[t]:r.traverseSortNextHelper()}}}sortNext(){let r=this.children;return r&&r.length>0&&r[0]?r[0]:this.traverseSortNextHelper()}isDescendantOf(r){r instanceof Fo&&(r=r.uuid);let e=this;for(;e.parent;){if(e.parent.uuid===r)return!0;e=e.parent}return!1}};var Ut=class extends Fo{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.context=o;this.children=[]}add(e){e.parent&&e.parent instanceof Ut&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let t=this.children.indexOf(e);t>=0&&(this.children.splice(t,1),e.parent=void 0)}traverse(e){let t=e(this);if(t!==!0)for(let o of this.children)o instanceof Ut?o.traverse(e):t=e(o)}intersectsChildren(e,t,o,i=!1,a=[],s=!1){for(let l of this.children){let c=l instanceof Kt;if(l instanceof Ut&&!c&&s&&l.intersectsChildren(e,t,o,i,a,!1),l.intersects(e,t,o,c)&&(a.push(l),i))break}return a}updateWorldMatrix(e,t,o){if(super.updateWorldMatrix(e,t,o),o&&this.children)for(let i of this.children)i.updateWorldMatrix(e,!1,!0)}find(e){let t;return this.traverse(o=>{o.uuid===e&&(t=o)}),t}innerDrawChildren(e){for(let t=this.children.length-1;t>=0;t--)this.children[t].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let t=new Ut(this.uuid,this.data,e);t.parent=void 0;for(let o of this.children)t.add(o.clone(e));return t}},Kt=class extends Ut{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.updateState(t,o)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let t=new Kt(this.uuid,this.data,e);t.parent=void 0;for(let o of this.children)t.add(o.clone(e));return t}};function sD(n,r){let[[e,t],[o,i]]=n,[[a,s],[l,c]]=r,u=(e-o)*(s-c)-(t-i)*(a-l);if(u===0)return!1;let p=((e-a)*(s-c)-(t-s)*(a-l))/u,d=-((e-o)*(t-s)-(t-i)*(e-a))/u;return p>=0&&p<=1&&d>=0&&d<=1}var hv=[[-1,1],[-1,-1],[1,-1],[1,1]],fv=(n,r,e)=>{let t=n.getCenter(),o=n.getHalfSize(),i=ze.append(r,n.worldMatrix);o[0]===0&&o[1]===0?e.push(ze.apply(t,i)):hv.forEach(a=>{let s=[a[0]*o[0]+t[0],a[1]*o[1]+t[1]];e.push(ze.apply(s,i))})},Sn=class{constructor(){this.matrix=ze.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(r,e=!1){r.updateWorldMatrix(),this.makeEmpty(),ze.copy(r.worldMatrix,this.matrix);let t=ze.invert(r.worldMatrix);this.expandByObjectSize(r,t,e)}expandByObjectSize(r,e,t=!1){let o=[];t===!0&&r instanceof Ut?r.traverse(i=>{i.visible&&fv(i,e,o)}):fv(r,e,o),this.setFromPoints(o)}getCenter(){let[r,e]=this.min,[t,o]=this.getHalfSize();return ze.apply([r+t,e+o],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(r){this.makeEmpty();for(let e of r)this.expandByPoint(e)}expandByPoint(r){this.min=[Math.min(this.min[0],r[0]),Math.min(this.min[1],r[1])],this.max=[Math.max(this.max[0],r[0]),Math.max(this.max[1],r[1])]}computeVertices(){let[r,e]=this.getHalfSize(),t=this.getCenter(),[o,i,a,s]=ze.getAbcdef(this.matrix),l=ze.create(o,i,a,s,t[0],t[1]);this.vertices=hv.map(([c,u])=>ze.apply([c*r,u*e],l))}computeEdges(){this.edges=[];for(let r=0,e=this.vertices.length;r<e;++r)this.edges.push([this.vertices[r],this.vertices[(r+1)%e]])}project(r,e){let t=this.matrix;return e&&(t=ze.append(e.worldMatrix,t)),ze.applyInverse(r,t)}intersects(r,e,t){return this.intersectsInLocalSpace(...this.project([r,e],t))}intersectsInLocalSpace(r,e){let{min:t,max:o}=this;return r>=t[0]&&r<=o[0]&&e>=t[1]&&e<=o[1]}containsPoint(r){let[e,t]=r,[o,i]=this.min,[a,s]=this.max;return e>=o&&e<=a&&t>=i&&t<=s}intersectsBBox2D(r){for(let e=0,t=this.edges.length;e<t;e++){let o=this.edges[e];for(let i=0,a=r.edges.length;i<a;i++){let s=r.edges[i];if(sD(o,s))return!0}}for(let e=0,t=r.vertices.length;e<t;e++){let o=r.vertices[e];if(this.containsPoint(o))return!0}return!1}ensureMinMax(){let r=this.min,e=this.max;this.min=[Math.min(r[0],e[0]),Math.min(r[1],e[1])],this.max=[Math.max(r[0],e[0]),Math.max(r[1],e[1])]}copy(r){this.min=[...r.min],this.max=[...r.max],ze.copy(r.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let r=new Sn;return r.copy(this),r}};var yv,gv=new Promise(n=>{yv=n}),mv=!1;var Uu;function xv(){if(mv)return;if(Uu)return Uu;async function n(){let e=await import("./ui.js");yv(e.default??e),mv=!0}return Uu=n(),Uu}function Sv(n){let r=!1;return n.scene.objects.traverse((e,t)=>{(t.type==="Mesh"&&t.geometry.type==="UIGeometry"||t.type==="Page"&&t.uiFrame!==void 0)&&(r=!0)}),r}var Ce,Jf;async function lD(n){let r=await gv;Ce||(Jf||(Jf=r({locateFile:()=>n})),Ce=await Jf)}var bv=ze.identity(),hl=class{constructor(r,e=1){this.canvas=r;this.dpr=e;this._width=0;this._height=0;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=Ie.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=Ie.transparent;this._fonts=new Map;try{let t=r.getBoundingClientRect();r.width=t.width*e,r.height=t.height*e}catch{console.log(r.width,e)}this._currentM3Transform=bv,this._currentTransform=new Float32Array(bv)}async init(){if(!this.wasmURL)throw Error("Your must set the wasm binary url with renderer.wasmURL = ... before you can call renderer.init");await lD(this.wasmURL),this._surface=Ce.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas(),this._paint=new Ce.Paint,this._paint.setAntiAlias(!0),this._paintFill=this._paint.copy(),this._paintFill.setStyle(Ce.PaintStyle.Fill),this._paintStroke=this._paint.copy(),this._paintStroke.setStyle(Ce.PaintStyle.Stroke),this.ctx?.scale(this.dpr,this.dpr)}get currentTransform(){return this._currentM3Transform}get currentTransformBuffer(){return this._currentTransform}set currentTransform(r){this._currentM3Transform=r,this._currentTransform.set(r)}async loadFont(r,e){let t=await(await fetch(r)).arrayBuffer();this.registerFont(t,e)}registerFont(r,e){if(this._fonts.has(e))return;let t=Ce.FontMgr.FromData(r);if(t)this._fonts.set(e,t);else throw new Error("Invalid font data for "+e)}get width(){return this._width}get height(){return this._height}set strokeColor(r){this._paintStroke&&this._paintStroke.setColor(ku(r),Ce.ColorSpace.DISPLAY_P3)}set fillColor(r){this._paintFill&&this._paintFill.setColor(ku(r),Ce.ColorSpace.DISPLAY_P3)}set lineWidth(r){this._paintStroke&&this._paintStroke.setStrokeWidth(this._strokeMode==="center"?r:r*2)}set strokeMode(r){this._strokeMode=r}set dropShadowBlur(r){this._dropShadowBlur=r}set dropShadowColor(r){this._dropShadowColor=r}set dropShadowOffsetX(r){this._dropShadowOffsetX=r}set dropShadowOffsetY(r){this._dropShadowOffsetY=r}set innerShadowBlur(r){this._innerShadowBlur=r}set innerShadowColor(r){this._innerShadowColor=r}set innerShadowOffsetX(r){this._innerShadowOffsetX=r}set innerShadowOffsetY(r){this._innerShadowOffsetY=r}set innerShadowSpread(r){this._innerShadowSpread=r}set layerBlur(r){this._layerBlur=r}set backgroundBlur(r){this._backgroundBlur=r}clear(){this.ctx?.clear(Ce.TRANSPARENT)}save(){this.ctx?.save()}restore(){this.ctx?.restore()}beginPath(){this._currentPath?.delete(),this._currentPath=new Ce.Path}closePath(){let r=this._currentPath;if(r){if(r.isEmpty())return;let e=r.getBounds();(e[3]-e[1]||e[2]-e[0])&&r.close()}}fill(){this._paintInner(this._paintFill,!0)}stroke(){this._paintInner(this._paintStroke,!1)}clipRect(r,e,t,o,i=0,a=0,s=0,l=0){let c=Ce.XYWHRect(r,e,t,o);if(i===0&&a===0&&l===0&&s===0)this.ctx?.clipRect(c,Ce.ClipOp.Intersect,!0);else{let u=Ce.RRectXY(c,i,i);u[4]=u[5]=i,u[6]=u[7]=a,u[8]=u[9]=s,u[10]=u[11]=l,this.ctx?.clipRRect(u,Ce.ClipOp.Intersect,!0)}}_applyShadowOffsetMatrix(){if(this.ctx){let r=ze.invert(this.currentTransform);this.ctx.concat(r);let e=ze.translate(ze.identity(),this._dropShadowOffsetX,this._dropShadowOffsetY);this.ctx.concat(e),this.ctx.concat(this._currentTransform)}}_applyEffectsToPaint(r,e,t=!0){if(this.ctx&&this._currentPath){let o,i=!1;if(t&&this._hasDropShadow()){let a=r.copy();a.setColor(ku(this._dropShadowColor));let s;this._dropShadowBlur>0&&(s=Ce.MaskFilter.MakeBlur(Ce.BlurStyle.Normal,this._dropShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s)),this.ctx.save(),this.ctx.clipPath(this._currentPath,Ce.ClipOp.Difference,!0),this._applyShadowOffsetMatrix(),e(a),this.ctx.restore(),a.delete(),s?.delete()}if(this._backgroundBlur>0&&t){this.ctx.save(),this.ctx.clipPath(this._currentPath,Ce.ClipOp.Intersect,!0);let a=Ce.ImageFilter.MakeBlur(this._backgroundBlur,this._backgroundBlur,Ce.TileMode.Clamp,null),s=r.copy();s.setImageFilter(a),s.setAlphaf(1);let l=this._currentPath.computeTightBounds();this.ctx.saveLayer(s,l,null,Ce.SaveLayerInitWithPrevious),this.ctx.drawColor(r.getColor()),this.ctx.restore(),this.ctx.restore(),s.delete(),a.delete(),i=!0}if(this._layerBlur>0){let a=r.copy();o=Ce.MaskFilter.MakeBlur(Ce.BlurStyle.Normal,this._layerBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(o),e(a),a.delete(),o.delete(),i=!0}if(i||e(r),t&&this._hasInnerShadow()){let a=new Ce.Paint;a.setAntiAlias(!0),a.setStyle(Ce.PaintStyle.Fill),a.setColor(ku(this._innerShadowColor));let s;this._innerShadowBlur>0&&(s=Ce.MaskFilter.MakeBlur(Ce.BlurStyle.Normal,this._innerShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s));let l=this._currentPath.computeTightBounds(),[c,u,p,d]=l,h=p-c,f=d-u;this.ctx.save(),this.ctx.clipPath(this._currentPath,Ce.ClipOp.Intersect,!0),this.ctx.saveLayer(a,l,null,Ce.SaveLayerInitWithPrevious),this.ctx?.translate(this._innerShadowOffsetX,this._innerShadowOffsetY),this.ctx.drawRect(Ce.XYWHRect(-1e3-this._innerShadowOffsetX,-1e3-this._innerShadowOffsetY,2e3+h+Math.abs(this._innerShadowOffsetX*2),2e3+f+Math.abs(this._innerShadowOffsetY*2)),a),a.setBlendMode(Ce.BlendMode.Clear),this.ctx.drawPath(this._currentPath,a),this.ctx.restore(),this.ctx.restore(),a.delete(),s?.delete()}}}_paintInner(r,e=!0){if(this.ctx&&this._currentPath&&r){let t=this.ctx,o=this._currentPath;this._applyEffectsToPaint(r,i=>{let a=!1;!e&&this._strokeMode!=="center"&&(t.save(),t.clipPath(o,this._strokeMode==="outside"?Ce.ClipOp.Difference:Ce.ClipOp.Intersect,!0),a=!0),t.drawPath(o,i),a&&t.restore()},e)}}_hasDropShadow(){return this._dropShadowColor?.a>0}_hasInnerShadow(){return this._innerShadowColor?.a>0}path(r){this._currentPath?.addPath(Ce.Path.MakeFromSVGString(r))}ellipse(r,e,t,o,i,a,s,l){if(!vv([r,e,t,o])||!this._currentPath)return;if(t<0||o<0)throw Error("radii cannot be negative");let c=Ce.XYWHRect(r-t,e-o,t*2,o*2);this._currentPath?.addOval(c)}rect(r,e,t,o,i=0,a=0,s=0,l=0){let c=Ce.XYWHRect(r,e,t,o);if(!!vv(c))if(i===0&&a===0&&l===0&&s===0)this._currentPath?.addRect(c);else{let u=Ce.RRectXY(c,i,i);u[4]=u[5]=i,u[6]=u[7]=a,u[8]=u[9]=s,u[10]=u[11]=l,this._currentPath?.addRRect(u)}}getHorizontalAlign(r){switch(r){case 2:return Ce.TextAlign.Right;case 3:return Ce.TextAlign.Center;case 4:return Ce.TextAlign.Justify;case 1:default:return Ce.TextAlign.Left}}drawTextInner(r,e,t,[o,i,a,s],l,c,u=!0){let p=0,{ctx:d}=this;if(!d)return p;let h=c.copy(),f=c.copy();return f.setAlphaf(0),this._applyEffectsToPaint(h,m=>{e.pushPaintStyle(t,m,f),e.addText(r);let y=e.build();y.layout(a);let g=i;l===2?g+=(s-y.getHeight())/2:l===3&&(g+=s-y.getHeight()),d.drawParagraph(y,o,g),p=y.getHeight(),e.reset(),y.delete()},u),h.delete(),f.delete(),p}drawText(r,e){let t=0,o=this._fonts.get(e.font),{ctx:i,_paintFill:a,_paintStroke:s}=this;if(o&&i){let l=new Ce.TextStyle({fontFamilies:[e.font],fontSize:e.fontSize,heightMultiplier:e.lineHeight,letterSpacing:e.letterSpacing}),c=new Ce.ParagraphStyle({textStyle:l,textAlign:this.getHorizontalAlign(e.horizontalAlign)}),u=Ce.XYWHRect(e.x,e.y,e.width,e.height),p=Ce.ParagraphBuilder.Make(c,o);a&&(t=this.drawTextInner(r,p,l,u,e.verticalAlign,a,!0)),s&&(t=this.drawTextInner(r,p,l,u,e.verticalAlign,s,!1)),p.delete()}return{height:t}}render(){this._surface?.flush()}moveTo(r,e){this._currentPath?.moveTo(r,e)}lineTo(r,e){this._currentPath?.lineTo(r,e)}bezierCurveTo(r,e,t,o,i,a){this._currentPath?.cubicTo(r,e,t,o,i,a)}quadraticCurveTo(r,e,t,o){this._currentPath?.quadTo(r,e,t,o)}setTransform(r,e=!1){if(!this.ctx)return;let t=this.ctx.getTotalMatrix(),o=ze.invert(t);if(o&&this.ctx.concat(o),this.ctx?.scale(this.dpr,this.dpr),this.camera?.enabled&&(this.ctx?.concat(this.camera.worldMatrix),e)){let i=ze.getScale(this.camera.worldMatrix);this.ctx?.scale(1/i[0],1/i[1])}this.ctx?.concat(r),this.currentTransform=r}transform(r){this.ctx?.concat(r)}setSize(r,e){r===this._width&&e===this._height||(this._width=r,this._height=e,this.canvas.style.width=r+"px",this.canvas.style.height=e+"px",this.canvas.width=r*this.dpr,this.canvas.height=e*this.dpr,this._surface&&(this._surface=Ce.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas()))}};function vv(n){for(let r=0;r<n.length;r++)if(n[r]!==void 0&&!Number.isFinite(n[r]))return!1;return!0}function ku({r:n,g:r,b:e,a:t}){return Ce.Color4f(n,r,e,t)}var ml=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.blurRadius=0;this.offset=[0,0];this.spread=0;this.update(e)}update(r){r.color!==void 0&&(this.color=r.color),r.enabled!==void 0&&(this.enabled=r.enabled),r.blurRadius!==void 0&&(this.blurRadius=r.blurRadius),r.offset!==void 0&&(this.offset=r.offset),r.spread!==void 0&&(this.spread=r.spread)}};var yl=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.radius=0;this.update(e)}update(r){r.enabled!==void 0&&(this.enabled=r.enabled),r.radius!==void 0&&(this.radius=r.radius)}};var Hu=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.update(e)}update(r){r.enabled!==void 0&&(this.enabled=r.enabled),r.color!==void 0&&(this.color=r.color)}};var Wu=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.thickness=0;this.mode="inside";this.update(e)}update(r){r.enabled!==void 0&&(this.enabled=r.enabled),r.color!==void 0&&(this.color=r.color),r.thickness!==void 0&&(this.thickness=r.thickness),r.mode!==void 0&&(this.mode=r.mode)}};var ir=class extends Fo{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.autoClose=!0;this.fill=new Hu(e+"-fill",t.fill,o),this.stroke=new Wu(e+"-stroke",t.stroke,o),this.dropShadow=new ml(e+"-dropShadow",t.dropShadow,o),this.innerShadow=new ml(e+"-innerShadow",t.innerShadow,o),this.backgroundBlur=new yl(e+"-backgroundBlur",t.backgroundBlur,o),this.layerBlur=new yl(e+"-layerBlur",t.layerBlur,o)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ie.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ie.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=Ie.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=Ie.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.type===0&&(Be(e.path,["fill"])?this.fill.update(e.props):Be(e.path,["stroke"])?this.stroke.update(e.props):Be(e.path,["dropShadow"])?this.dropShadow.update(e.props):Be(e.path,["innerShadow"])?this.innerShadow.update(e.props):Be(e.path,["layerBlur"])?this.layerBlur.update(e.props):Be(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,t){super.updateState(e,t),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let t=new ir(this.uuid,this.data,e);return t.parent=void 0,t}};var wn=class extends ir{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.width=0;this.height=0;this.updateState(t,o)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,t){return dv(e,t,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e)}clone(e){let t=new wn(this.uuid,this.data,e);return t.parent=void 0,t}};var ho=class extends ir{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.width=0;this.height=0;this.cornerRadius=[0,0,0,0];this.updateState(t,o)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let t=new ho(this.uuid,this.data,e);return t.parent=void 0,t}};var Pn=class extends ir{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this._textHeight=0;this._textHeightDirty=!0;this.width=0;this.height=0;this.updateState(t,o)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ie.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ie.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){this._fontHolder?.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let t=this.data.textTransform,o=this.data.text.textValue.toString(),i=t===2?o.toUpperCase():t===3?o.toLowerCase():o,{height:a}=e.drawText(i,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=a}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:t}){e.font!==void 0&&(this._fontHolder=t.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateFontState(e,t)}clone(e){let t=new Pn(this.uuid,this.data,e);return t.parent=void 0,t}};var ls=class extends ir{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.curves=[];this.extremasBBox={min:[0,0],max:[0,0]};this.updateState(t,o)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(i=>qu.extremas(i)),t=[1/0,1/0],o=[-1/0,-1/0];for(let i=0,a=e.length;i<a;i++){let s=e[i];s[0][0]<t[0]&&(t[0]=s[0][0]),s[0][1]<t[1]&&(t[1]=s[0][1]),s[1][0]>o[0]&&(o[0]=s[1][0]),s[1][1]>o[1]&&(o[1]=s[1][1])}return this.extremasBBox.min=[t[0],t[1]],this.extremasBBox.max=[o[0],o[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let o=1,i=this.data.points.length;o<i;o++){let a=this.data.points[o].data,s=this.data.points[o-1].data,l={start:s.position,cp1:s.controlNext.position,cp2:a.controlPrevious.position,end:a.position};this.curves.push(l)}let e=this.data.points[0].data,t=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let o={start:t.position,cp1:t.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(o)}}getCenter(){let[e,t]=this.extremasBBox.min,[o,i]=this.getHalfSize();return[e+o,t+i]}getHalfSize(){let{min:e,max:t}=this.extremasBBox;return[(t[0]-e[0])*.5,(t[1]-e[1])*.5]}innerDraw(e){for(let i=0,a=this.data.points.length;i<a;i++){let s=this.data.points[i].data;if(i===0){let[l,c]=s.position;e.moveTo(l,c)}else{let l=this.data.points[i-1].data,[c,u]=l.controlNext.position,[p,d]=s.controlPrevious.position,[h,f]=s.position,m={start:l.position,cp1:l.controlNext.position,cp2:s.controlPrevious.position,end:s.position};qu.derive(m),e.bezierCurveTo(c,u,p,d,h,f)}}let t=this.data.points[0].data,o=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[i,a]=o.controlNext.position,[s,l]=t.controlPrevious.position,[c,u]=t.position;e.bezierCurveTo(i,a,s,l,c,u)}}updateState(e,t){super.updateState(e,t),this.computeExtremas()}clone(e){let t=new ls(this.uuid,this.data,e);return t.parent=void 0,t}},qu;(i=>{function n(a){let s=a.start,l=a.cp1,c=a.cp2,u=a.end,p=[3*(l[0]-s[0]),3*(l[1]-s[1])],d=[3*(c[0]-l[0]),3*(c[1]-l[1])],h=[3*(u[0]-c[0]),3*(u[1]-c[1])],f={start:p,cp:d,end:h};return a.derivative=f,f.derivative=eh.derive(f),f}i.derive=n;function r(a,s,l,c=!1){let u=a-2*s+l;if(u!==0){let p=-Math.sqrt(Math.abs(s*s-a*l)),d=-a+s,h=-(p+d)/u,f=-(-p+d)/u;return[h,f]}else if(s!==l&&u===0)return[(2*s-l)/(2*(s-l))];return[]}function e(a){let s=a.derivative??i.derive(a),l=s.start,c=s.cp,u=s.end;return[r(l[0],c[0],u[0]),r(l[1],c[1],u[1])]}i.droot=e;function t(a){let[s,l]=i.droot(a),c=[a.start[0],a.end[0]],u=[a.start[1],a.end[1]];for(let p of s)c.push(i.compute(a,Math.min(1,Math.max(0,p)))[0]);for(let p of l)u.push(i.compute(a,Math.min(1,Math.max(0,p)))[1]);return c.sort((p,d)=>p-d),u.sort((p,d)=>p-d),[[c[0],u[0]],[c[c.length-1],u[u.length-1]]]}i.extremas=t;function o(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let l=1-s,c=l*l,u=s*s,p=c*l,d=c*s*3,h=l*u*3,f=s*u;return[p*a.start[0]+d*a.cp1[0]+h*a.cp2[0]+f*a.end[0],p*a.start[1]+d*a.cp1[1]+h*a.cp2[1]+f*a.end[1]]}i.compute=o})(qu||(qu={}));var eh;(t=>{function n(o){let i=o.start,a=o.cp,s=o.end,l=[2*(a[0]-i[0]),2*(a[1]-i[1])],c=[2*(s[0]-a[0]),2*(s[1]-a[1])],u={start:l,end:c};return u.derivative=th.derive(u),o.derivative=u,u}t.derive=n;function r(o){let i=o.derivative??t.derive(o),a=i.start,s=i.end;return[a[0]!==s[0]?a[0]/(a[0]-s[0]):0,a[1]!==s[1]?a[1]/(a[1]-s[1]):0]}t.droot=r;function e(o,i){if(i===0)return[...o.start];if(i===1)return[...o.end];let a=1-i,s=a*a,l=i*i,c=s,u=a*i*2,p=l;return[c*o.start[0]+u*o.cp[0]+p*o.end[0],c*o.start[1]+u*o.cp[1]+p*o.end[1]]}t.compute=e})(eh||(eh={}));var th;(e=>{function n(t){let o=t.start,i=t.end,a=[i[0]-o[0],i[1]-o[1]];return t.derivative=a,t.derivative}e.derive=n;function r(t,o){if(o===0)return[...t.start];if(o===1)return[...t.end];let i=t.start,a=t.end;return[i[0]+(a[0]-i[0])*o,i[1]+(a[1]-i[1])*o]}e.compute=r})(th||(th={}));var fr=class extends Ut{constructor(e,t,o){super(e,t,o);this.uuid=e;this.width=0;this.height=0;this.clipped=!0;this.background=new ho(e+"-background",oa.defaultData,o),this.background.parent=this,this.updateState(t,o)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){super.updateLocalMatrix(),this.background?.updateLocalMatrix()}updateWorldMatrix(e,t,o){super.updateWorldMatrix(e,t,o),this.background?.updateWorldMatrix(e,t,o)}draw(e){if(!this.visible)return;e.save();let t=this.width,o=this.height;this.applyTransforms(e),this.background.width=t,this.background.height=o,this.background.draw(e),this.clipped&&e.clipRect(0,0,t,o,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.type===0&&(Be(e.path,["fill"])?this.fill.update(e.props):Be(e.path,["stroke"])?this.stroke.update(e.props):Be(e.path,["dropShadow"])?this.dropShadow.update(e.props):Be(e.path,["innerShadow"])?this.innerShadow.update(e.props):Be(e.path,["layerBlur"])?this.layerBlur.update(e.props):Be(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let t=new fr(this.uuid,this.data,e);t.parent=void 0;for(let o of this.children)t.add(o.clone(e));return t}};var Cv=hi(rh(),1),Uo=class extends ir{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this._pathBBox=new DOMRect;this.path="";this.updateState(t,o),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg"),t=document.createElementNS("http://www.w3.org/2000/svg","path");document.body.appendChild(e),t.setAttribute("d",this.path),e.appendChild(t),this._pathBBox=t.getBBox(),e.remove()}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,t){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&t>=this._pathBBox.y&&t<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,t){super.updateState(e,t),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let t=new Uo(this.uuid,this.data,e);return t.parent=void 0,t}};function Tv(n,r=1,e=1){if(r<=0||e<=0)return n;let o=(0,Cv.parseSVG)(n).map(i=>{let a={...i};return"x"in a&&(a.x=a.x*r),"y"in a&&(a.y=a.y*e),"x1"in a&&(a.x1=a.x1*r),"x2"in a&&(a.x2=a.x2*r),"y1"in a&&(a.y1=a.y1*e),"y2"in a&&(a.y2=a.y2*e),"rx"in a&&(a.rx=a.rx*r),"ry"in a&&(a.ry=a.ry*e),a});return Av(o)}function Av(n){let r=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],e;return n.map(t=>{let o=[];r.forEach(a=>{if(a in t){let s=t[a]*1;o.length&&s>=0&&o.push(","),o.push(s)}});let i=(e===t.code?o[0]<0?"":",":t.code)+o.join("");return e=t.code,i}).join("")}function Mv(n,r,e){switch(r.type){case"ellipse2d":return new wn(n,r,e);case"rectangle2d":return new ho(n,r,e);case"text2d":return new Pn(n,r,e);case"vector2d":return new ls(n,r,e);case"path2d":return new Uo(n,r,e);case"frame2d":return new fr(n,r,e);case"group2d":default:return new Kt(n,r,e)}}var oh=class{constructor(r,e,t){this.uuid=r;this.data=e;this.group=new Kt(oh.GROUP_ID,{...Ms.defaultData},t),this.createChildrenObjects(e.objects,this.group,t)}createObject(r,e,t,o,i,a){let s=Mv(r,e,a);s&&(o.add(s),o.children.splice(i,0,o.children.pop()),s.updateWorldMatrix(),t.length>0&&(s instanceof Kt||s instanceof fr)&&this.createChildrenObjects(t,s,a))}createChildrenObjects(r,e,t){let o=0;for(let i of r)this.createObject(i.id,i.data,i.children,e,o,t),o+=1}draw(r){this.group.draw(r)}updateEntityByOp(r,e,t,o){let i=this.find(r);if(i)try{i.updateByOp(e,t,{shared:o})}catch(a){console.error(a)}}updateTreeByOp(r,e){if(r.path.length===0&&r.type===7){let t=r.parent===null?this.group:this.find(r.parent);t!==void 0&&t instanceof Ut&&(this.createObject(r.id,r.data,r.children,t,r.localIndex,e),t.requestRender())}else if(r.path.length===0&&r.type===8){let t=this.find(r.id);if(t!==void 0&&t.parent!==void 0&&t.parent instanceof Ut){let o=t.parent;t.resetBBoxNeedsUpdate(),o?.remove(t),o?.requestRender()}}else if(r.path.length===0&&r.type===9){let t=this.find(r.id);if(t!==void 0){let o=t.parent,i=r.parent===null?this:this.find(r.parent);if(i===void 0&&!1&&console.error("unexpected",i,r),i instanceof Ut||i===this){i.add(t);let a=r.localIndex;i.children.splice(a,0,i.children.pop()),t.updateWorldMatrix(!0,!1,!0),o?.requestRender(),t.requestRender()}t.resetBBoxNeedsUpdate()}}}add(r){this.group.add(r)}remove(r){this.group.remove(r)}traverse(r){this.group.traverse(e=>{e!==this.group&&r(e)})}intersectsChildren(r,e,t,o=!1,i=[]){return this.group.intersectsChildren(r,e,t,o,i,!0)}find(r){return this.group.find(r)}get children(){return this.group.children}project(r,e){return this.group.project(r,e)}getWithSortKey(r){let e=this.find(r);if(e===void 0)return;let t=[],o=e;for(;o!==this.group;){let i=o;o=o.parent;let a=o.children.indexOf(i);t.splice(0,0,a)}return{entity:e,sortKey:t}}getAllSorted(r){let e=[];for(let t of r){let o=this.getWithSortKey(t.id);o!==void 0&&e.push(o)}return e.sort((t,o)=>Ml(t.sortKey,o.sortKey)),e.map(t=>t.entity)}},si=oh;si.GROUP_ID="scene2d";function nh({constraints:n,newParentWidth:r,newParentHeight:e,initialParentWidth:t,initialParentHeight:o,objectInitialWidth:i,objectInitialHeight:a,objectInitialPosition:s}){let{horizontalConstraint:l,verticalConstraint:c}=n,u=r-t,p=e-o,d=i,h=a,f=s[0],m=s[1];if(l!==0){if(l===1)f+=u;else if(l===3)f+=u/2;else if(l===2)d=Math.max(1,d+u);else if(l===4){let y=r/t;d*=y,f*=y}}if(c!==0){if(c===1)m+=p;else if(c===3)m+=p/2;else if(c===2)h=Math.max(1,h+p);else if(c===4){let y=e/o;h*=y,m*=y}}return{width:d,height:h,position:[f,m]}}var pD=hi(rh(),1);var dae={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{mm:1,px:1,cm:1,in:1,pt:1,pc:1}};import{MathUtils as fD}from"three";var hD=ze.identity(),cs=class{constructor(r,e,t,o){this.uuid=r;this.width=e;this.height=t;this.context=o;this.enabled=!0;this.isScreenSpace=!1;this.isFrameDirty=!1;this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.context.shared.requestRender()};this.onFrameOverrideObjectEvent=r=>{if(r.target?.uuid!==void 0){let e=this.frameRoot?.find(r.target.uuid);e&&e.dispatchEvent({...r,target:e})}};this.scene2d=new si(fD.generateUUID(),jc.defaultData,{dpr:window.devicePixelRatio,shared:o.shared}),this.canvas=document.createElement("canvas"),this.renderer=new hl(this.canvas),o.shared.addCanvas(this.uuid,this.canvas),this.textureHolder=o.shared.canvas(this.uuid),this.promise=this.init()}async init(){this.renderer instanceof hl&&(this.renderer.wasmURL=nb.skiaWasmUrl),await this.renderer.init()}render(){this.isFrameDirty&&(this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.textureHolder?.setNeedsUpdate(!0),this.isFrameDirty=!1)}updateEntity2DByOp(r,e,t,o){this.scene2d.updateEntityByOp(r,e,t,o),this.applySize()}updateTreeByOp(r,e){this.scene2d.updateTreeByOp(r,e),this.applySize()}applyOverrides(r){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=r?.width??this.width,t=r?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=t,this.frameOverride.localMatrix=hD,this.isScreenSpace&&(this.frameOverride.fill.color=Ie.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:t},Iv({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(r){let e=r?.width??this.width,t=r?.height??this.height;this.width=e,this.height=t,this.renderer.dpr=this.isScreenSpace?window.devicePixelRatio:Math.floor(2048/Math.max(e,t)),this.renderer.setSize(e,t),this.textureHolder?.dispose(),this.applyOverrides(r),this.frameOverride?.requestRender()}applyFrame(r){let e=this.context.scene.find2D(r);if(!(!e||!(e instanceof fr)))return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.textureHolder?.dispose(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(t=>{t.addEventListener("beginState",this.onFrameOverrideObjectEvent)}),this.frameOverride.traverse(t=>{t.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(r){return this.scene2d.find(r)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(r=>{r.removeEventListener("beginStateChange",this.onFrameOverrideObjectEvent)}),this.frameOverride?.traverse(r=>{r.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function Iv({objectOverride:n,objectRoot:r,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:i}){if(n instanceof fr&&r instanceof fr||n instanceof Kt&&r instanceof Kt)for(let a=0,s=n.children.length;a<s;a++){let l=n.children[a],c=r.children[a];l&&c&&l.uuid===c.uuid&&yD({objectOverride:l,objectRoot:c,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:i})}}function mD(n){if(ih(n))return[n.width,n.height];if(n instanceof Uo){let[r,e]=n.getHalfSize();return[r*2,e*2]}else if(n instanceof Kt){let[r,e]=n.recursiveBBox.getHalfSize();return[r*2,e*2]}return[0,0]}function yD({objectOverride:n,objectRoot:r,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:i}){let[a,s]=mD(r),{width:l,height:c,position:u}=nh({constraints:n.data,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:i,objectInitialWidth:a,objectInitialHeight:s,objectInitialPosition:r.position});if(n.position=u,n.data={...n.data,position:u},n.states)for(let p in n.states)gD({stateId:p,objectOverride:n,objectRoot:r,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:i});if(ih(n)||n instanceof Kt)ih(n)&&(n.width=l,n.height=c,n.data={...n.data,width:l,height:c}),Iv({objectOverride:n,objectRoot:r,newParentWidth:l,newParentHeight:c,initialParentWidth:a,initialParentHeight:s});else if(n instanceof Uo){let p=r,d=a!==0?l/a:1,h=s!==0?c/s:1;n.path=Tv(p.path,d,h),n.data={...n.data,path:n.path}}}function gD({stateId:n,objectOverride:r,objectRoot:e,newParentWidth:t,newParentHeight:o,initialParentWidth:i,initialParentHeight:a}){let s=r.states?.[n],l=e.states?.[n];if(s&&l){let{width:c,height:u,position:p}=nh({constraints:r.data,newParentWidth:t,newParentHeight:o,initialParentWidth:i,initialParentHeight:a,objectInitialWidth:Mo.isResizeable(l)?l.width:0,objectInitialHeight:Mo.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(r.states[n],{position:p}),Mo.isResizeable(s)&&Object.assign(r.states[n],{width:c,height:u})}}function ih(n){return n instanceof ho||n instanceof fr||n instanceof wn||n instanceof Pn}var Cr=class extends la(SD){constructor(e,t,o){super();this.data=t;this.bgColor=new Tt(1,1,1,1);this.fog=null;this.backupFog=new bD(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new xD;this.penumbraSizeArrayCache=null;this.super_Entity(e,t),this.personalCamera=new jo(tn,{...jn.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new vD(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),t.uiScene?this.uiScene=new si((Array.isArray(e)?e[0]:e)+"-ui",t.uiScene,{dpr:window.devicePixelRatio,shared:o.shared}):t.uiFrame&&this.createUICanvas(t.uiFrame,o)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(e,t){this.uiCanvas=new cs(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,t),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=Gt(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(t=>{t instanceof nr&&t.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof or)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&tv(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,t){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let o=this.scene;o.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Gt(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=Gt(e.aoColor,t))}updateByOp(e,t,o,i){let a=this.data.uiFrame;super.updateByOp(e,t,o,i);let s=t;Be(e.path,["fog"])?this.updateFog(s.fog,o.shared):Be(e.path,["ao"])?this.updateAo(s.ao,o.shared):Be(e.path,["ambient"])?this.updateAmbientLight(s.ambient,o.shared):Be(e.path,["shadow"])?this.updateShadow(s.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||a!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,o)}updateUIFrame(e,t){e?(this.uiCanvas||this.createUICanvas(e,t),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(Gt(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,t){}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,t=0;this.traverseEntity(o=>{if(!o.visible)return!0;o instanceof as&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize,e+=1),o instanceof ss&&o.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+t]=o.data.penumbraSize,t+=1)})}raycastWithClones(e){let t=[],o=i=>{for(let a of i.children){let s=a.cloner;Le.is(a)&&(a.visible||s?.object.data.visible)&&((bn(a)||ul(a)&&this.scene.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),gl(a,e,t,!0)),o(a))}};return o(this),t}updateEntity2DByOp(e,t,o,i){this.uiCanvas?.updateEntity2DByOp(e,t,o,i)}};import{PointLight as wD,Vector3 as Yu,Box3 as PD,Box3Helper as Nv,Color as OD}from"three";var Xu=class extends os(wD,is){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let a=new Yu(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new Yu(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),l=new PD(a,s),c=new Nv(l,new OD(16755200));c.visible=!1,this.gizmos.shadowmap=c,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let r in this.gizmos){let e=this.gizmos[r];if(e instanceof Nv){let t=this.shadow.camera,o=new Yu(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),i=new Yu(t.far+this.position.x,t.far+this.position.y,t.far+this.position.z);e.box.set(o,i),e.updateMatrixWorld(!0)}}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Ku=class extends st{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?$s(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var us=class extends st{constructor(e,t,o){super(e,t,o);this._shapeId=null;this._context=o}updateState(e,t){super.updateState(e,t),this.updateShape()}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let i in e)typeof e[i]=="string"&&(e[i]=this._context.shared.getVariable(e[i],[this.uuid,"geometry","extrusion","shape",i]));let t;if(e.type==="Custom"){let i=e.shapeId;if(i!==this._shapeId&&this.detachShape(),i){this._shapeId=i;let a=this._context.scene.find(i);a?.data&&(a.attachedPaths.add(this),t=a.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let i;switch(e.type){case"Rectangle":i=va;break;case"Ellipse":i=ya;break;case"Polygon":i=cu;break;case"Star":i=uu;break;default:throw new Error(`Unknown shape type: ${e.type}`)}t=i.create({parameters:e}).userData.shape}let o=this.geometry;t&&o.inputs&&(o.inputs.shapeData=t,o.build(),this.attachedSurfaceCloners.forEach(i=>i.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,t){return super.updateTransformState(e,t)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let o=this.geometry.getAttribute("position");o!==void 0?$s(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,t):super.updateEntityBoxSize(e,t)}};import{Group as CD,Matrix4 as TD,Skeleton as AD}from"three";var ko=class extends Pr(CD,Or){constructor(e,t,o){super();t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,o)),this.super_Entity(e,t),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,t){let o=Ji.getComponentData({scene:t.scene.data,shared:t.shared.data},e.component);if(o){let i,a;for(let s of Zr.rootOverrideProps)e[s]===void 0?(i===void 0&&(i={...e}),i[s]=o.data[s]):(a===void 0&&(a={}),a[s]=e[s],i===void 0&&(i={...e}),i[s]=qr.apply(o.data[s],e[s]));return this.overrideData=a,i}else return{...wt.defaultData,...e,...Mr(wt.defaultData,Zr.rootOverrideProps)}}updateByOp(e,t,o,i){let a;if(this.isInstanceRoot&&!i){if(t=this.transformAssignData(t,o),e.type===0&&e.path.length===0&&this.component)for(let s of Zr.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&Zr.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:t[s]}})}}super.updateByOp(a??e,t,o,i)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){let o=e.scene.find(t.component)??null,i=!1;if(o!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(Le.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Qu(s),a+=1;else break;this.children.splice(0,a)}i=!0}if(o){let a={};Ev(e,[this.uuid],t.overrides,this,o,o,0,i,a);for(let s of this.children)if(Le.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(c=>{if(c instanceof st&&c.isSkinnedMesh){let u=c.dataPatched;if(u.bones&&u.boneInverses){let p=u.bones.map(f=>e.scene.find(a[f])),d=u.boneInverses.map(f=>new TD().fromArray(f)),h=new AD(p,d);c.bind(h,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function Qu(n){if(n.component){let r=n.component.instances.indexOf(n);r>=0&&n.component.instances.splice(r,1);for(let e of n.children)Le.is(e)&&Qu(e)}}function Dv(n,r,e,t){return n.component===r&&Td(n.identity,t)?n.overrideData===e?2:1:0}function Ev(n,r,e,t,o,i,a,s,l){if(a>50)return!1;if(t.component!==o){if(t.component){let u=t.component.instances.indexOf(t);u>=0&&t.component.instances.splice(u,1)}o.instances.find(u=>u===t)||o.instances.push(t),t.component=o}o instanceof ko&&o.isInstanceRoot&&o.expandInstanceChildren(n);let c=0;for(let u of o.children)if(Le.is(u)){let p=[...r,...typeof u.identity=="string"?[u.identity]:u.identity],d=Qi.resolve(e,p,1);if(d!=null&&!(d instanceof Ke)){if(!1)debugger;Object.setPrototypeOf(d,Ke.prototype),console.error("wrong prototype")}let h=null,f;if(!s){let m=t.children[c];if(h=Le.is(m)?m:null,h!==null){let y=Dv(h,u,d,p);f=y>=1?h.stateSelection:void 0,y!==2&&(h=null)}if(h===null&&(h=n.scene.findInstance(p)??null,h!==null)){let y=Dv(h,u,d,p);if(f=y>=1?h.stateSelection:void 0,y!==2)h=null;else{let g=h.parent.children.indexOf(h);h.parent.children.splice(g,1),t.children.splice(c,0,h),h.parent===t?(g<=c&&console.error("not possible"),void 0):(h.parent=t,h.matrixWorldNeedsUpdate=!0,h.resetBBoxNeedsUpdate(),h.updateVisible(),n.pendingDeletes.delete(h),void 0)}}}if(h===null){let m=d?qr.apply(u.data,d):u.data;Ir.is(m.type)&&(m={...m,type:"Empty"}),h=Er.createEntity(p,m,n),h.overrideData=d,t.add(h),t.children.splice(t.children.length-1,1),t.children.splice(c,0,h),h.updateState(h.data,n),f&&h.changeSelectedState(f,n),n.scene.registerInstanceAndSetUuid(h)}if(h.isBone){let m=h.identity[h.identity.length-1];l[m]=h.uuid}c+=1,Ev(n,r,e,h,u,i,a+1,s,l)}if(!s){let u=c;for(;;){let p=t.children[c];if(Le.is(p))n.pendingDeletes.add(p);else break;c+=1}t.children.splice(u,c-u)}return!0}import{Bone as MD}from"three";var Zu=class extends Pr(MD,Or){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(r,e){this.updateState_Entity(r,e)}};var li=class extends st{constructor(e,t,o){super(e,t,o);this.onBeforeRender=()=>{this.uiCanvas.render()};this.uiCanvas=new cs(e+"-canvas",t.geometry.width,t.geometry.height,o),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,o.shared)})}updateByPatchedOpGeometry(e,t,o){super.updateByPatchedOpGeometry(e,t,o),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,o.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,o.shared))}applySize(e,t){let o=e?.width??this.dataPatched.geometry.width,i=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:o,height:i}),this.applyGeometryParametersFromFrame(t)}applyFrame(e,t){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(t),this.applyMaterialParametersFromFrame({shared:t})}applyGeometryParametersFromFrame(e){let t=this.frame;t&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=_o(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let t=this.frame;if(t){let o=t.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),this.material.reset(this.dataPatched.material,e,!0)}}updateEntity2DByOp(e,t,o,i){this.uiCanvas.updateEntity2DByOp(e,t,o,i),e===this.frameId&&t.type===0&&(t.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(i):Be(t.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:i}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.applySize({width:e.width,height:e.height},t)}};import{Object3D as GD,Vector3 as Tr,InstancedMesh as jD,InstancedBufferAttribute as FD,PlaneGeometry as UD,Vector4 as xl,Quaternion as Jv,TextureLoader as kD,Texture as eS,Euler as HD,MathUtils as ph}from"three";import{GPUComputationRenderer as WD}from"three/examples/jsm/misc/GPUComputationRenderer.js";import{Vector3 as _v,FloatType as ah,DataTexture as sh,RGBAFormat as lh,Mesh as ID,Euler as Jse,Matrix4 as ele}from"three";import{MeshSurfaceSampler as ND}from"three/examples/jsm/math/MeshSurfaceSampler.js";function Bv(n){let r=new Float32Array(n*n*2);for(let e=0;e<n;e++)for(let t=0;t<n;t++){let o=e*n+t;r[o*2+0]=e/(n-1),r[o*2+1]=t/(n-1)}return r}function Lv(n){let r=Math.ceil(Math.sqrt(n));return Math.max(r,1)}function Rv(n,r){let e=new ID(n.geometry,n.material),t=[],o=[],i=new _v,a=new _v;e.geometry.index!==null&&(e.geometry=e.geometry.toNonIndexed());let s=new ND(e).build();for(let u=0;u<r;u++)s.sample(i,a),t.push(i.x,i.y,i.z),o.push(a.x,a.y,a.z);let l=new Float32Array(t),c=new Float32Array(o);return{positions:l,normals:c}}function ch(n,r){let e=n,t=new Float32Array(4*r*r);for(let i=0;i<r*r;i++)t[4*i]=e[3*i],t[4*i+1]=e[3*i+1],t[4*i+2]=e[3*i+2],t[4*i+3]=0;let o=new sh(t,r,r,lh,ah);return o.needsUpdate=!0,o}function Vv({size:n}){let r=new Float32Array(4*n*n);for(let t=0;t<n*n;t++)r[4*t]=t,r[4*t+1]=0,r[4*t+2]=0,r[4*t+3]=0;let e=new sh(r,n,n,lh,ah);return e.needsUpdate=!0,e}function zv(n){let r=new Float32Array(4*n*n);for(let t=0;t<n*n;t++)r[4*t]=0,r[4*t+1]=0,r[4*t+2]=0,r[4*t+3]=0;let e=new sh(r,n,n,lh,ah);return e.needsUpdate=!0,e}var Gv=`
2603
+ `,$3=ul.lights_fragment_begin,Y3=ul.shadowmask_pars_fragment,tv=null,X3=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},rv=(n="medium")=>{if(tv===n)return!1;tv=n;let r=X3(n);ul.shadowmap_pars_fragment=q3(r);let e=$3.slice();e=e.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),e=e.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),ul.lights_fragment_begin=e;let t=Y3.slice();return t=t.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),ul.shadowmask_pars_fragment=t,!0};import{DirectionalLight as eD,CameraHelper as ov}from"three";import{DirectionalLightHelper as K3}from"three";var os=class extends fo(K3){constructor(e,t=15,o=10066329){super(e,t,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){ho(this.object,os.geometryHelper,e,t)}};import{PointLightHelper as Q3}from"three";var ns=class extends fo(Q3){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){ho(this.object,ns.geometryHelper,e,t)}};import{SpotLightHelper as Z3,Vector3 as J3}from"three";var Gu=class extends fo(Z3){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){ho(this.object,Gu.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=Gu._vector,t=this.object.distance?this.object.distance:1e3,o=t*Math.tan(this.object.angle);this.cone.scale.set(o,o,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let i=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let a=0,s=this.cone.material.length;a<s;a++)this.cone.material[a].color.set(i);else this.cone.material.color.set(i)}}},dl=Gu;dl._vector=new J3;function tD(n,r){n.shadow.camera.right=r/2,n.shadow.camera.left=-r/2,n.shadow.camera.top=r/2,n.shadow.camera.bottom=-r/2,n.shadow.needsUpdate=!0}var is=class extends rs(eD,os){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let a=new ov(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof ov&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e);let t=r.depth!==void 0&&r.depth!==this.shadow.camera.far||r.size!==void 0&&r.size/2!==this.shadow.camera.right;r.size!==void 0&&tD(this,r.size),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),r.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t&&this.update()}};import{Scene as SD}from"three";import{SpotLight as rD,CameraHelper as nv,MathUtils as oD,Vector3 as lv,Quaternion as nD}from"three";var iv=new lv,av=new lv,sv=new nD,as=class extends rs(rD,dl){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=oD.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let a=new nv(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof nv&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),av.setFromMatrixPosition(this.matrixWorld),sv.setFromRotationMatrix(this.matrixWorld),iv.copy(this.up).applyQuaternion(sv).negate().multiplyScalar(this.distance),this.target.position.copy(av).add(iv),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.angle!==void 0&&(this.angle=r.angle),r.penumbra!==void 0&&(this.penumbra=r.penumbra),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};function iD(n){let r=(n[0][0]+n[1][1])/2,e=(n[0][0]-n[1][1])/2,t=(n[1][0]+n[0][1])/2,o=(n[1][0]-n[0][1])/2,i=Math.sqrt(r*r+o*o),a=Math.sqrt(e*e+t*t),s=i+a,l=i-a,c=Math.atan2(t,e),u=Math.atan2(o,r),p=(u-c)/2,d=(u+c)/2,h=[[Math.cos(d),Math.sin(d)],[-Math.sin(d),Math.cos(d)]],f=[[s,0],[0,l]],m=[[Math.cos(p),Math.sin(p)],[-Math.sin(p),Math.cos(p)]];return h[0][0]*=-1,h[0][1]*=-1,m[0][0]*=-1,m[1][0]*=-1,[h,f,m]}function ju(n,r){return[[n[0][0]*r[0][0]+n[0][1]*r[1][0],n[0][0]*r[0][1]+n[0][1]*r[1][1]],[n[1][0]*r[0][0]+n[1][1]*r[1][0],n[1][0]*r[0][1]+n[1][1]*r[1][1]]]}function cv(n){return[[n[0][0],n[1][0]],[n[0][1],n[1][1]]]}function uv(n){let[r,e,t]=iD(n),o=ju(r,cv(t)),i=ju(ju(t,e),cv(t)),a=Math.atan2(o[1][0],o[0][0]),s=[i[0][0],i[1][1]],l=[i[0][1]/i[1][1],i[1][0]/i[0][0]];return{rotation:a,scale:s,shear:l}}function dv({rotation:n,scale:r,shear:e}){let t=Math.cos(n),o=Math.sin(n),i=[[t,-o],[o,t]],a=[[r[0],e[0]*r[1]],[e[1]*r[0],r[1]]],s=ju(i,a);return[s[0][0],s[1][0],s[0][1],s[1][1]]}var ze;(S=>{function n(){return[1,0,0,0,1,0,0,0,1]}S.identity=n;function r(T,I=S.identity()){for(let x=0,_=T.length;x<_;x++)I[x]=T[x];return I}S.copy=r;function e(T,I,x,_,D,A){return S.setAbcdef(S.identity(),T,I,x,_,D,A)}S.create=e;function t(T,I,x,_,D,A,N){return T[0]=I,T[1]=_,T[2]=A,T[3]=x,T[4]=D,T[5]=N,T}S.setAbcdef=t;function o(T,I){let[x,_,D,A,N,E]=a(T),[B,V,j,R,W,F]=a(I),k=B*x+V*D,H=B*_+V*A,$=j*x+R*D,J=j*_+R*A,Z=W*x+F*D+N,X=W*_+F*A+E;return S.create(k,H,$,J,Z,X)}S.append=o;function i(T,I){let[x,_,D,A,N,E]=a(T),[B,V,j,R,W,F]=a(I),k=x,H=_,$=D,J=A;(B!==1||V!==0||j!==0||R!==1)&&(k=x*B+_*j,H=x*V+_*R,$=D*B+A*j,J=D*V+A*R);let Z=N*B+E*j+W,X=N*V+E*R+F;return S.create(k,H,$,J,Z,X)}S.prepend=i;function a(T){return[T[0],T[3],T[1],T[4],T[2],T[5]]}S.getAbcdef=a;function s(T){let[I,x,_,D,A,N]=S.getAbcdef(T),E=I*D-x*_,B=D/E,V=-x/E,j=-_/E,R=I/E,W=(_*N-D*A)/E,F=-(I*N-x*A)/E;return S.create(B,V,j,R,W,F)}S.invert=s;function l([T,I],x){let[_,D,A,N,E,B]=S.getAbcdef(x);return[_*T+A*I+E,D*T+N*I+B]}S.apply=l;function c(T,I){let[x,_,D,A,N,E]=S.getAbcdef(I),B=1/(x*A+D*-_),[V,j]=T;return[A*B*V+-D*B*j+(E*D-N*A)*B,x*B*j+-_*B*V+(-E*x+N*_)*B]}S.applyInverse=c;function u(T,I,x=I){let[_,D,A,N,E,B]=S.getAbcdef(T);return S.setAbcdef(T,_*I,D*x,A*I,N*x,E*I,B*x),T}S.scale=u;function p(T,I){let x=Math.cos(I),_=Math.sin(I),[D,A,N,E,B,V]=S.getAbcdef(T);return S.setAbcdef(T,D*x-A*_,D*_+A*x,N*x-E*_,N*_+E*x,B*x-V*_,B*_+V*x),T}S.rotate=p;function d(T,I,x){let[_,D]=x,A=S.translate(T,-_,-D);return A=S.rotate(A,I),A=S.translate(A,_,D),A}S.rotateAround=d;function h(T,I,x){let[_,D,A,N,E,B]=S.getAbcdef(T);return S.setAbcdef(T,_,D,A,N,E+I,B+x),T}S.translate=h;function f(T,I,x){let[_,D,A,N]=S.getAbcdef(T);return S.setAbcdef(T,_,D,A,N,I,x),T}S.setTranslate=f;function m(T,I,x){let[_,D,A,N]=S.getAbcdef(T);return S.setAbcdef(T,_,D,A,N,I,x),T}S.setPosition=m;function y(T){let[I,x,_,D]=S.getAbcdef(T),A=Math.sqrt(I*I+x*x),N=Math.sqrt(_*_+D*D);return[A,N]}S.getScale=y;function g(T){let[,,,,I,x]=S.getAbcdef(T);return[I,x]}S.getPosition=g;function v(T,I){return S.decompose(T,I).rotation}S.getRotation=v;function O(T,I){let[x,_,D,A,N,E]=S.getAbcdef(T),{rotation:B,scale:V,shear:j}=uv([[x,D],[_,A]]);return{position:[N+(I[0]*x+I[1]*D)-I[0],E+(I[0]*_+I[1]*A)-I[1]],scale:V,rotation:B,shear:j,pivot:I}}S.decompose=O;function P(T,I,x,_,D=[0,0]){let[A,N]=T,[E,B]=_,[V,j,R,W]=dv({rotation:x,scale:I,shear:D}),F=A-(E*V+B*R)+E,k=N-(E*j+B*W)+B;return S.create(V,j,R,W,F,k)}S.compose=P})(ze||(ze={}));var aD=Math.PI/180,Loe=180/Math.PI;function pv(n,r,e,t,o,i){let a=n-e,s=r-t;return a*a/(o*o)+s*s/(i*i)<=1}function fv(n){return n*aD}function Jf(n){return{all:n=n||new Map,on:function(r,e){var t=n.get(r);t?t.push(e):n.set(r,[e])},off:function(r,e){var t=n.get(r);t&&(e?t.splice(t.indexOf(e)>>>0,1):n.set(r,[]))},emit:function(r,e){var t=n.get(r);t&&t.slice().map(function(o){o(e)}),(t=n.get("*"))&&t.slice().map(function(o){o(r,e)})}}}var Fo=class{constructor(r,e,t){this.uuid=r;this.data=e;this.localMatrix=ze.identity();this.worldMatrix=ze.identity();this.ignoreCameraZoom=!1;this.visible=!0;this._singleBBox=new vn;this._recursiveBBox=new vn;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.stateSelection=null;this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this.name="";this.position=[0,0];this.scale=[1,1];this.rotation=0;this.shear=[0,0];this.emitter=Jf();this.dpr=t.dpr??1,this.dataPatched=e}project(r,e){let t=this.worldMatrix;return e&&(t=ze.append(e.worldMatrix,t)),ze.applyInverse(r,t)}intersects(r,e,t,o=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([r,e],t),o)}intersectsInLocalSpace(r,e,t=!1){let{min:o,max:i}=t?this.recursiveBBox:this.singleBBox;return r>=o[0]&&r<=i[0]&&e>=o[1]&&e<=i[1]}applyTransforms(r){r.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=ze.compose(this.position,this.scale,fv(this.rotation),Io.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(r,e,t){let o=this.parent;e&&o!==null&&o!==void 0&&o.updateWorldMatrix(r,!0,!1),r&&this.updateLocalMatrix(),this.parent?this.worldMatrix=ze.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=ze.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return Io.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{r.resetBBoxNeedsUpdateSelf()})}updateTransformState(r){let e=!1;r.position!==void 0&&(e=!0,this.position=r.position),r.rotation!==void 0&&(e=!0,this.rotation=r.rotation),r.scale!==void 0&&(e=!0,this.scale=r.scale),r.shear!==void 0&&(e=!0,this.shear=r.shear),e&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(r,e,t){r.type===0&&r.props.visible!==void 0&&(this.visible=r.props.visible),this.data=e,this.data=e;let o=r,i=Be(r.path,["states","*"]);if(i!==null){if(r.type===0){let[a]=i;if(this?.stateSelection===a){let s={...r.props};if(delete s.name,Object.values(r.props).some(l=>l===void 0)){let l=this.data;if(l!==void 0){let c=rt.zoom(l,r.path.slice(2));if(c)for(let u in r.props)r.props[u]===void 0&&u in c&&(s[u]=c[u])}}o={...r,props:s,path:r.path.slice(2)}}}}else if(r.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(r.props.name!==void 0&&a.name){let{name:l,...c}=a;a=c}let s=rt.removeOverridden(r.path,r.props,a);o={...r,props:s}}}this.updateByPatchedOpBase(o,Fn.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),t)}changeSelectedState(r,e,t=!1){if(!(this.data.states.length===0&&!t)){for(let o of this.data.states)Fn.toOps(this.data,o.data).forEach(a=>{let s=ji.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,e)});if(r!==null){let o=this.data.states.data(r);o&&(this.dataPatched=Fn.patch(this.data,o),Fn.toOps(this.data,o).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,e)}))}t&&this.updateTransformState(this.dataPatched),this.stateSelection=r}}updateState(r,e){r.name!==void 0&&(this.name=r.name),r.visible!==void 0&&(this.visible=r.visible),this.updateTransformState(r)}updateByPatchedOpBase(r,e,t){this.dataPatched=e,this.updateByPatchedOp(r,e,t)}updateByPatchedOp(r,e,t){r.path.length===0&&r.type===0&&this.updateState(r.props,t),this.requestRender()}traverseFrameAncestors(r){this.traverseAncestors(e=>{e.data.type==="frame2d"&&r(e)})}traverseAncestors(r){let e=this.parent;for(;e;)r(e),e=e.parent}requestRender(){this.traverseFrameAncestors(r=>{r.requestRender()})}clone(r){let e=new Fo(this.uuid,this.data,r);return e.parent=void 0,e}addEventListener(r,e){this.emitter.on(r,e)}removeEventListener(r,e){this.emitter.off(r,e)}dispatchEvent(r){this.emitter.emit(r.type,{...r,target:r.target??this})}traverseSortNextHelper(){let r=this.parent;if(r){let e=r.children;if(e){let t=e.indexOf(this)+1;return e[t]?e[t]:r.traverseSortNextHelper()}}}sortNext(){let r=this.children;return r&&r.length>0&&r[0]?r[0]:this.traverseSortNextHelper()}isDescendantOf(r){r instanceof Fo&&(r=r.uuid);let e=this;for(;e.parent;){if(e.parent.uuid===r)return!0;e=e.parent}return!1}};var Ut=class extends Fo{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.context=o;this.children=[]}add(e){e.parent&&e.parent instanceof Ut&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let t=this.children.indexOf(e);t>=0&&(this.children.splice(t,1),e.parent=void 0)}traverse(e){let t=e(this);if(t!==!0)for(let o of this.children)o instanceof Ut?o.traverse(e):t=e(o)}intersectsChildren(e,t,o,i=!1,a=[],s=!1){for(let l of this.children){let c=l instanceof Kt;if(l instanceof Ut&&!c&&s&&l.intersectsChildren(e,t,o,i,a,!1),l.intersects(e,t,o,c)&&(a.push(l),i))break}return a}updateWorldMatrix(e,t,o){if(super.updateWorldMatrix(e,t,o),o&&this.children)for(let i of this.children)i.updateWorldMatrix(e,!1,!0)}find(e){let t;return this.traverse(o=>{o.uuid===e&&(t=o)}),t}innerDrawChildren(e){for(let t=this.children.length-1;t>=0;t--)this.children[t].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let t=new Ut(this.uuid,this.data,e);t.parent=void 0;for(let o of this.children)t.add(o.clone(e));return t}},Kt=class extends Ut{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.updateState(t,o)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let t=new Kt(this.uuid,this.data,e);t.parent=void 0;for(let o of this.children)t.add(o.clone(e));return t}};function sD(n,r){let[[e,t],[o,i]]=n,[[a,s],[l,c]]=r,u=(e-o)*(s-c)-(t-i)*(a-l);if(u===0)return!1;let p=((e-a)*(s-c)-(t-s)*(a-l))/u,d=-((e-o)*(t-s)-(t-i)*(e-a))/u;return p>=0&&p<=1&&d>=0&&d<=1}var mv=[[-1,1],[-1,-1],[1,-1],[1,1]],hv=(n,r,e)=>{let t=n.getCenter(),o=n.getHalfSize(),i=ze.append(r,n.worldMatrix);o[0]===0&&o[1]===0?e.push(ze.apply(t,i)):mv.forEach(a=>{let s=[a[0]*o[0]+t[0],a[1]*o[1]+t[1]];e.push(ze.apply(s,i))})},vn=class{constructor(){this.matrix=ze.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(r,e=!1){r.updateWorldMatrix(),this.makeEmpty(),ze.copy(r.worldMatrix,this.matrix);let t=ze.invert(r.worldMatrix);this.expandByObjectSize(r,t,e)}expandByObjectSize(r,e,t=!1){let o=[];t===!0&&r instanceof Ut?r.traverse(i=>{i.visible&&hv(i,e,o)}):hv(r,e,o),this.setFromPoints(o)}getCenter(){let[r,e]=this.min,[t,o]=this.getHalfSize();return ze.apply([r+t,e+o],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(r){this.makeEmpty();for(let e of r)this.expandByPoint(e)}expandByPoint(r){this.min=[Math.min(this.min[0],r[0]),Math.min(this.min[1],r[1])],this.max=[Math.max(this.max[0],r[0]),Math.max(this.max[1],r[1])]}computeVertices(){let[r,e]=this.getHalfSize(),t=this.getCenter(),[o,i,a,s]=ze.getAbcdef(this.matrix),l=ze.create(o,i,a,s,t[0],t[1]);this.vertices=mv.map(([c,u])=>ze.apply([c*r,u*e],l))}computeEdges(){this.edges=[];for(let r=0,e=this.vertices.length;r<e;++r)this.edges.push([this.vertices[r],this.vertices[(r+1)%e]])}project(r,e){let t=this.matrix;return e&&(t=ze.append(e.worldMatrix,t)),ze.applyInverse(r,t)}intersects(r,e,t){return this.intersectsInLocalSpace(...this.project([r,e],t))}intersectsInLocalSpace(r,e){let{min:t,max:o}=this;return r>=t[0]&&r<=o[0]&&e>=t[1]&&e<=o[1]}containsPoint(r){let[e,t]=r,[o,i]=this.min,[a,s]=this.max;return e>=o&&e<=a&&t>=i&&t<=s}intersectsBBox2D(r){for(let e=0,t=this.edges.length;e<t;e++){let o=this.edges[e];for(let i=0,a=r.edges.length;i<a;i++){let s=r.edges[i];if(sD(o,s))return!0}}for(let e=0,t=r.vertices.length;e<t;e++){let o=r.vertices[e];if(this.containsPoint(o))return!0}return!1}ensureMinMax(){let r=this.min,e=this.max;this.min=[Math.min(r[0],e[0]),Math.min(r[1],e[1])],this.max=[Math.max(r[0],e[0]),Math.max(r[1],e[1])]}copy(r){this.min=[...r.min],this.max=[...r.max],ze.copy(r.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let r=new vn;return r.copy(this),r}};var gv,xv=new Promise(n=>{gv=n}),yv=!1;var Fu;function bv(){if(yv)return;if(Fu)return Fu;async function n(){let e=await import("./ui.js");gv(e.default??e),yv=!0}return Fu=n(),Fu}function wv(n){let r=!1;return n.scene.objects.traverse((e,t)=>{(t.type==="Mesh"&&t.geometry.type==="UIGeometry"||t.type==="Page"&&t.uiFrame!==void 0)&&(r=!0)}),r}var Ce,eh;async function lD(n){let r=await xv;Ce||(eh||(eh=r({locateFile:()=>n})),Ce=await eh)}var vv=ze.identity(),fl=class{constructor(r,e=1){this.canvas=r;this.dpr=e;this._width=0;this._height=0;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=Ie.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=Ie.transparent;this._fonts=new Map;try{let t=r.getBoundingClientRect();r.width=t.width*e,r.height=t.height*e}catch{console.log(r.width,e)}this._currentM3Transform=vv,this._currentTransform=new Float32Array(vv)}async init(){if(!this.wasmURL)throw Error("Your must set the wasm binary url with renderer.wasmURL = ... before you can call renderer.init");await lD(this.wasmURL),this._surface=Ce.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas(),this._paint=new Ce.Paint,this._paint.setAntiAlias(!0),this._paintFill=this._paint.copy(),this._paintFill.setStyle(Ce.PaintStyle.Fill),this._paintStroke=this._paint.copy(),this._paintStroke.setStyle(Ce.PaintStyle.Stroke),this.ctx?.scale(this.dpr,this.dpr)}get currentTransform(){return this._currentM3Transform}get currentTransformBuffer(){return this._currentTransform}set currentTransform(r){this._currentM3Transform=r,this._currentTransform.set(r)}async loadFont(r,e){let t=await(await fetch(r)).arrayBuffer();this.registerFont(t,e)}registerFont(r,e){if(this._fonts.has(e))return;let t=Ce.FontMgr.FromData(r);if(t)this._fonts.set(e,t);else throw new Error("Invalid font data for "+e)}get width(){return this._width}get height(){return this._height}set strokeColor(r){this._paintStroke&&this._paintStroke.setColor(Uu(r),Ce.ColorSpace.DISPLAY_P3)}set fillColor(r){this._paintFill&&this._paintFill.setColor(Uu(r),Ce.ColorSpace.DISPLAY_P3)}set lineWidth(r){this._paintStroke&&this._paintStroke.setStrokeWidth(this._strokeMode==="center"?r:r*2)}set strokeMode(r){this._strokeMode=r}set dropShadowBlur(r){this._dropShadowBlur=r}set dropShadowColor(r){this._dropShadowColor=r}set dropShadowOffsetX(r){this._dropShadowOffsetX=r}set dropShadowOffsetY(r){this._dropShadowOffsetY=r}set innerShadowBlur(r){this._innerShadowBlur=r}set innerShadowColor(r){this._innerShadowColor=r}set innerShadowOffsetX(r){this._innerShadowOffsetX=r}set innerShadowOffsetY(r){this._innerShadowOffsetY=r}set innerShadowSpread(r){this._innerShadowSpread=r}set layerBlur(r){this._layerBlur=r}set backgroundBlur(r){this._backgroundBlur=r}clear(){this.ctx?.clear(Ce.TRANSPARENT)}save(){this.ctx?.save()}restore(){this.ctx?.restore()}beginPath(){this._currentPath?.delete(),this._currentPath=new Ce.Path}closePath(){let r=this._currentPath;if(r){if(r.isEmpty())return;let e=r.getBounds();(e[3]-e[1]||e[2]-e[0])&&r.close()}}fill(){this._paintInner(this._paintFill,!0)}stroke(){this._paintInner(this._paintStroke,!1)}clipRect(r,e,t,o,i=0,a=0,s=0,l=0){let c=Ce.XYWHRect(r,e,t,o);if(i===0&&a===0&&l===0&&s===0)this.ctx?.clipRect(c,Ce.ClipOp.Intersect,!0);else{let u=Ce.RRectXY(c,i,i);u[4]=u[5]=i,u[6]=u[7]=a,u[8]=u[9]=s,u[10]=u[11]=l,this.ctx?.clipRRect(u,Ce.ClipOp.Intersect,!0)}}_applyShadowOffsetMatrix(){if(this.ctx){let r=ze.invert(this.currentTransform);this.ctx.concat(r);let e=ze.translate(ze.identity(),this._dropShadowOffsetX,this._dropShadowOffsetY);this.ctx.concat(e),this.ctx.concat(this._currentTransform)}}_applyEffectsToPaint(r,e,t=!0){if(this.ctx&&this._currentPath){let o,i=!1;if(t&&this._hasDropShadow()){let a=r.copy();a.setColor(Uu(this._dropShadowColor));let s;this._dropShadowBlur>0&&(s=Ce.MaskFilter.MakeBlur(Ce.BlurStyle.Normal,this._dropShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s)),this.ctx.save(),this.ctx.clipPath(this._currentPath,Ce.ClipOp.Difference,!0),this._applyShadowOffsetMatrix(),e(a),this.ctx.restore(),a.delete(),s?.delete()}if(this._backgroundBlur>0&&t){this.ctx.save(),this.ctx.clipPath(this._currentPath,Ce.ClipOp.Intersect,!0);let a=Ce.ImageFilter.MakeBlur(this._backgroundBlur,this._backgroundBlur,Ce.TileMode.Clamp,null),s=r.copy();s.setImageFilter(a),s.setAlphaf(1);let l=this._currentPath.computeTightBounds();this.ctx.saveLayer(s,l,null,Ce.SaveLayerInitWithPrevious),this.ctx.drawColor(r.getColor()),this.ctx.restore(),this.ctx.restore(),s.delete(),a.delete(),i=!0}if(this._layerBlur>0){let a=r.copy();o=Ce.MaskFilter.MakeBlur(Ce.BlurStyle.Normal,this._layerBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(o),e(a),a.delete(),o.delete(),i=!0}if(i||e(r),t&&this._hasInnerShadow()){let a=new Ce.Paint;a.setAntiAlias(!0),a.setStyle(Ce.PaintStyle.Fill),a.setColor(Uu(this._innerShadowColor));let s;this._innerShadowBlur>0&&(s=Ce.MaskFilter.MakeBlur(Ce.BlurStyle.Normal,this._innerShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s));let l=this._currentPath.computeTightBounds(),[c,u,p,d]=l,h=p-c,f=d-u;this.ctx.save(),this.ctx.clipPath(this._currentPath,Ce.ClipOp.Intersect,!0),this.ctx.saveLayer(a,l,null,Ce.SaveLayerInitWithPrevious),this.ctx?.translate(this._innerShadowOffsetX,this._innerShadowOffsetY),this.ctx.drawRect(Ce.XYWHRect(-1e3-this._innerShadowOffsetX,-1e3-this._innerShadowOffsetY,2e3+h+Math.abs(this._innerShadowOffsetX*2),2e3+f+Math.abs(this._innerShadowOffsetY*2)),a),a.setBlendMode(Ce.BlendMode.Clear),this.ctx.drawPath(this._currentPath,a),this.ctx.restore(),this.ctx.restore(),a.delete(),s?.delete()}}}_paintInner(r,e=!0){if(this.ctx&&this._currentPath&&r){let t=this.ctx,o=this._currentPath;this._applyEffectsToPaint(r,i=>{let a=!1;!e&&this._strokeMode!=="center"&&(t.save(),t.clipPath(o,this._strokeMode==="outside"?Ce.ClipOp.Difference:Ce.ClipOp.Intersect,!0),a=!0),t.drawPath(o,i),a&&t.restore()},e)}}_hasDropShadow(){return this._dropShadowColor?.a>0}_hasInnerShadow(){return this._innerShadowColor?.a>0}path(r){this._currentPath?.addPath(Ce.Path.MakeFromSVGString(r))}ellipse(r,e,t,o,i,a,s,l){if(!Sv([r,e,t,o])||!this._currentPath)return;if(t<0||o<0)throw Error("radii cannot be negative");let c=Ce.XYWHRect(r-t,e-o,t*2,o*2);this._currentPath?.addOval(c)}rect(r,e,t,o,i=0,a=0,s=0,l=0){let c=Ce.XYWHRect(r,e,t,o);if(!!Sv(c))if(i===0&&a===0&&l===0&&s===0)this._currentPath?.addRect(c);else{let u=Ce.RRectXY(c,i,i);u[4]=u[5]=i,u[6]=u[7]=a,u[8]=u[9]=s,u[10]=u[11]=l,this._currentPath?.addRRect(u)}}getHorizontalAlign(r){switch(r){case 2:return Ce.TextAlign.Right;case 3:return Ce.TextAlign.Center;case 4:return Ce.TextAlign.Justify;case 1:default:return Ce.TextAlign.Left}}drawTextInner(r,e,t,[o,i,a,s],l,c,u=!0){let p=0,{ctx:d}=this;if(!d)return p;let h=c.copy(),f=c.copy();return f.setAlphaf(0),this._applyEffectsToPaint(h,m=>{e.pushPaintStyle(t,m,f),e.addText(r);let y=e.build();y.layout(a);let g=i;l===2?g+=(s-y.getHeight())/2:l===3&&(g+=s-y.getHeight()),d.drawParagraph(y,o,g),p=y.getHeight(),e.reset(),y.delete()},u),h.delete(),f.delete(),p}drawText(r,e){let t=0,o=this._fonts.get(e.font),{ctx:i,_paintFill:a,_paintStroke:s}=this;if(o&&i){let l=new Ce.TextStyle({fontFamilies:[e.font],fontSize:e.fontSize,heightMultiplier:e.lineHeight,letterSpacing:e.letterSpacing}),c=new Ce.ParagraphStyle({textStyle:l,textAlign:this.getHorizontalAlign(e.horizontalAlign)}),u=Ce.XYWHRect(e.x,e.y,e.width,e.height),p=Ce.ParagraphBuilder.Make(c,o);a&&(t=this.drawTextInner(r,p,l,u,e.verticalAlign,a,!0)),s&&(t=this.drawTextInner(r,p,l,u,e.verticalAlign,s,!1)),p.delete()}return{height:t}}render(){this._surface?.flush()}moveTo(r,e){this._currentPath?.moveTo(r,e)}lineTo(r,e){this._currentPath?.lineTo(r,e)}bezierCurveTo(r,e,t,o,i,a){this._currentPath?.cubicTo(r,e,t,o,i,a)}quadraticCurveTo(r,e,t,o){this._currentPath?.quadTo(r,e,t,o)}setTransform(r,e=!1){if(!this.ctx)return;let t=this.ctx.getTotalMatrix(),o=ze.invert(t);if(o&&this.ctx.concat(o),this.ctx?.scale(this.dpr,this.dpr),this.camera?.enabled&&(this.ctx?.concat(this.camera.worldMatrix),e)){let i=ze.getScale(this.camera.worldMatrix);this.ctx?.scale(1/i[0],1/i[1])}this.ctx?.concat(r),this.currentTransform=r}transform(r){this.ctx?.concat(r)}setSize(r,e){r===this._width&&e===this._height||(this._width=r,this._height=e,this.canvas.style.width=r+"px",this.canvas.style.height=e+"px",this.canvas.width=r*this.dpr,this.canvas.height=e*this.dpr,this._surface&&(this._surface=Ce.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas()))}};function Sv(n){for(let r=0;r<n.length;r++)if(n[r]!==void 0&&!Number.isFinite(n[r]))return!1;return!0}function Uu({r:n,g:r,b:e,a:t}){return Ce.Color4f(n,r,e,t)}var hl=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.blurRadius=0;this.offset=[0,0];this.spread=0;this.update(e)}update(r){r.color!==void 0&&(this.color=r.color),r.enabled!==void 0&&(this.enabled=r.enabled),r.blurRadius!==void 0&&(this.blurRadius=r.blurRadius),r.offset!==void 0&&(this.offset=r.offset),r.spread!==void 0&&(this.spread=r.spread)}};var ml=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.radius=0;this.update(e)}update(r){r.enabled!==void 0&&(this.enabled=r.enabled),r.radius!==void 0&&(this.radius=r.radius)}};var ku=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.update(e)}update(r){r.enabled!==void 0&&(this.enabled=r.enabled),r.color!==void 0&&(this.color=r.color)}};var Hu=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.thickness=0;this.mode="inside";this.update(e)}update(r){r.enabled!==void 0&&(this.enabled=r.enabled),r.color!==void 0&&(this.color=r.color),r.thickness!==void 0&&(this.thickness=r.thickness),r.mode!==void 0&&(this.mode=r.mode)}};var ir=class extends Fo{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.autoClose=!0;this.fill=new ku(e+"-fill",t.fill,o),this.stroke=new Hu(e+"-stroke",t.stroke,o),this.dropShadow=new hl(e+"-dropShadow",t.dropShadow,o),this.innerShadow=new hl(e+"-innerShadow",t.innerShadow,o),this.backgroundBlur=new ml(e+"-backgroundBlur",t.backgroundBlur,o),this.layerBlur=new ml(e+"-layerBlur",t.layerBlur,o)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ie.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ie.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=Ie.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=Ie.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.type===0&&(Be(e.path,["fill"])?this.fill.update(e.props):Be(e.path,["stroke"])?this.stroke.update(e.props):Be(e.path,["dropShadow"])?this.dropShadow.update(e.props):Be(e.path,["innerShadow"])?this.innerShadow.update(e.props):Be(e.path,["layerBlur"])?this.layerBlur.update(e.props):Be(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,t){super.updateState(e,t),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let t=new ir(this.uuid,this.data,e);return t.parent=void 0,t}};var Sn=class extends ir{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.width=0;this.height=0;this.updateState(t,o)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,t){return pv(e,t,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e)}clone(e){let t=new Sn(this.uuid,this.data,e);return t.parent=void 0,t}};var mo=class extends ir{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.width=0;this.height=0;this.cornerRadius=[0,0,0,0];this.updateState(t,o)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let t=new mo(this.uuid,this.data,e);return t.parent=void 0,t}};var wn=class extends ir{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this._textHeight=0;this._textHeightDirty=!0;this.width=0;this.height=0;this.updateState(t,o)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ie.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ie.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){this._fontHolder?.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let t=this.data.textTransform,o=this.data.text.textValue.toString(),i=t===2?o.toUpperCase():t===3?o.toLowerCase():o,{height:a}=e.drawText(i,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=a}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:t}){e.font!==void 0&&(this._fontHolder=t.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateFontState(e,t)}clone(e){let t=new wn(this.uuid,this.data,e);return t.parent=void 0,t}};var ss=class extends ir{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.curves=[];this.extremasBBox={min:[0,0],max:[0,0]};this.updateState(t,o)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(i=>Wu.extremas(i)),t=[1/0,1/0],o=[-1/0,-1/0];for(let i=0,a=e.length;i<a;i++){let s=e[i];s[0][0]<t[0]&&(t[0]=s[0][0]),s[0][1]<t[1]&&(t[1]=s[0][1]),s[1][0]>o[0]&&(o[0]=s[1][0]),s[1][1]>o[1]&&(o[1]=s[1][1])}return this.extremasBBox.min=[t[0],t[1]],this.extremasBBox.max=[o[0],o[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let o=1,i=this.data.points.length;o<i;o++){let a=this.data.points[o].data,s=this.data.points[o-1].data,l={start:s.position,cp1:s.controlNext.position,cp2:a.controlPrevious.position,end:a.position};this.curves.push(l)}let e=this.data.points[0].data,t=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let o={start:t.position,cp1:t.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(o)}}getCenter(){let[e,t]=this.extremasBBox.min,[o,i]=this.getHalfSize();return[e+o,t+i]}getHalfSize(){let{min:e,max:t}=this.extremasBBox;return[(t[0]-e[0])*.5,(t[1]-e[1])*.5]}innerDraw(e){for(let i=0,a=this.data.points.length;i<a;i++){let s=this.data.points[i].data;if(i===0){let[l,c]=s.position;e.moveTo(l,c)}else{let l=this.data.points[i-1].data,[c,u]=l.controlNext.position,[p,d]=s.controlPrevious.position,[h,f]=s.position,m={start:l.position,cp1:l.controlNext.position,cp2:s.controlPrevious.position,end:s.position};Wu.derive(m),e.bezierCurveTo(c,u,p,d,h,f)}}let t=this.data.points[0].data,o=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[i,a]=o.controlNext.position,[s,l]=t.controlPrevious.position,[c,u]=t.position;e.bezierCurveTo(i,a,s,l,c,u)}}updateState(e,t){super.updateState(e,t),this.computeExtremas()}clone(e){let t=new ss(this.uuid,this.data,e);return t.parent=void 0,t}},Wu;(i=>{function n(a){let s=a.start,l=a.cp1,c=a.cp2,u=a.end,p=[3*(l[0]-s[0]),3*(l[1]-s[1])],d=[3*(c[0]-l[0]),3*(c[1]-l[1])],h=[3*(u[0]-c[0]),3*(u[1]-c[1])],f={start:p,cp:d,end:h};return a.derivative=f,f.derivative=th.derive(f),f}i.derive=n;function r(a,s,l,c=!1){let u=a-2*s+l;if(u!==0){let p=-Math.sqrt(Math.abs(s*s-a*l)),d=-a+s,h=-(p+d)/u,f=-(-p+d)/u;return[h,f]}else if(s!==l&&u===0)return[(2*s-l)/(2*(s-l))];return[]}function e(a){let s=a.derivative??i.derive(a),l=s.start,c=s.cp,u=s.end;return[r(l[0],c[0],u[0]),r(l[1],c[1],u[1])]}i.droot=e;function t(a){let[s,l]=i.droot(a),c=[a.start[0],a.end[0]],u=[a.start[1],a.end[1]];for(let p of s)c.push(i.compute(a,Math.min(1,Math.max(0,p)))[0]);for(let p of l)u.push(i.compute(a,Math.min(1,Math.max(0,p)))[1]);return c.sort((p,d)=>p-d),u.sort((p,d)=>p-d),[[c[0],u[0]],[c[c.length-1],u[u.length-1]]]}i.extremas=t;function o(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let l=1-s,c=l*l,u=s*s,p=c*l,d=c*s*3,h=l*u*3,f=s*u;return[p*a.start[0]+d*a.cp1[0]+h*a.cp2[0]+f*a.end[0],p*a.start[1]+d*a.cp1[1]+h*a.cp2[1]+f*a.end[1]]}i.compute=o})(Wu||(Wu={}));var th;(t=>{function n(o){let i=o.start,a=o.cp,s=o.end,l=[2*(a[0]-i[0]),2*(a[1]-i[1])],c=[2*(s[0]-a[0]),2*(s[1]-a[1])],u={start:l,end:c};return u.derivative=rh.derive(u),o.derivative=u,u}t.derive=n;function r(o){let i=o.derivative??t.derive(o),a=i.start,s=i.end;return[a[0]!==s[0]?a[0]/(a[0]-s[0]):0,a[1]!==s[1]?a[1]/(a[1]-s[1]):0]}t.droot=r;function e(o,i){if(i===0)return[...o.start];if(i===1)return[...o.end];let a=1-i,s=a*a,l=i*i,c=s,u=a*i*2,p=l;return[c*o.start[0]+u*o.cp[0]+p*o.end[0],c*o.start[1]+u*o.cp[1]+p*o.end[1]]}t.compute=e})(th||(th={}));var rh;(e=>{function n(t){let o=t.start,i=t.end,a=[i[0]-o[0],i[1]-o[1]];return t.derivative=a,t.derivative}e.derive=n;function r(t,o){if(o===0)return[...t.start];if(o===1)return[...t.end];let i=t.start,a=t.end;return[i[0]+(a[0]-i[0])*o,i[1]+(a[1]-i[1])*o]}e.compute=r})(rh||(rh={}));var fr=class extends Ut{constructor(e,t,o){super(e,t,o);this.uuid=e;this.width=0;this.height=0;this.clipped=!0;this.background=new mo(e+"-background",ra.defaultData,o),this.background.parent=this,this.updateState(t,o)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){super.updateLocalMatrix(),this.background?.updateLocalMatrix()}updateWorldMatrix(e,t,o){super.updateWorldMatrix(e,t,o),this.background?.updateWorldMatrix(e,t,o)}draw(e){if(!this.visible)return;e.save();let t=this.width,o=this.height;this.applyTransforms(e),this.background.width=t,this.background.height=o,this.background.draw(e),this.clipped&&e.clipRect(0,0,t,o,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.type===0&&(Be(e.path,["fill"])?this.fill.update(e.props):Be(e.path,["stroke"])?this.stroke.update(e.props):Be(e.path,["dropShadow"])?this.dropShadow.update(e.props):Be(e.path,["innerShadow"])?this.innerShadow.update(e.props):Be(e.path,["layerBlur"])?this.layerBlur.update(e.props):Be(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let t=new fr(this.uuid,this.data,e);t.parent=void 0;for(let o of this.children)t.add(o.clone(e));return t}};var Tv=fi(oh(),1),Uo=class extends ir{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this._pathBBox=new DOMRect;this.path="";this.updateState(t,o),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg"),t=document.createElementNS("http://www.w3.org/2000/svg","path");document.body.appendChild(e),t.setAttribute("d",this.path),e.appendChild(t),this._pathBBox=t.getBBox(),e.remove()}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,t){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&t>=this._pathBBox.y&&t<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,t){super.updateState(e,t),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let t=new Uo(this.uuid,this.data,e);return t.parent=void 0,t}};function Av(n,r=1,e=1){if(r<=0||e<=0)return n;let o=(0,Tv.parseSVG)(n).map(i=>{let a={...i};return"x"in a&&(a.x=a.x*r),"y"in a&&(a.y=a.y*e),"x1"in a&&(a.x1=a.x1*r),"x2"in a&&(a.x2=a.x2*r),"y1"in a&&(a.y1=a.y1*e),"y2"in a&&(a.y2=a.y2*e),"rx"in a&&(a.rx=a.rx*r),"ry"in a&&(a.ry=a.ry*e),a});return Mv(o)}function Mv(n){let r=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],e;return n.map(t=>{let o=[];r.forEach(a=>{if(a in t){let s=t[a]*1;o.length&&s>=0&&o.push(","),o.push(s)}});let i=(e===t.code?o[0]<0?"":",":t.code)+o.join("");return e=t.code,i}).join("")}function Iv(n,r,e){switch(r.type){case"ellipse2d":return new Sn(n,r,e);case"rectangle2d":return new mo(n,r,e);case"text2d":return new wn(n,r,e);case"vector2d":return new ss(n,r,e);case"path2d":return new Uo(n,r,e);case"frame2d":return new fr(n,r,e);case"group2d":default:return new Kt(n,r,e)}}var nh=class{constructor(r,e,t){this.uuid=r;this.data=e;this.group=new Kt(nh.GROUP_ID,{...As.defaultData},t),this.createChildrenObjects(e.objects,this.group,t)}createObject(r,e,t,o,i,a){let s=Iv(r,e,a);s&&(o.add(s),o.children.splice(i,0,o.children.pop()),s.updateWorldMatrix(),t.length>0&&(s instanceof Kt||s instanceof fr)&&this.createChildrenObjects(t,s,a))}createChildrenObjects(r,e,t){let o=0;for(let i of r)this.createObject(i.id,i.data,i.children,e,o,t),o+=1}draw(r){this.group.draw(r)}updateEntityByOp(r,e,t,o){let i=this.find(r);if(i)try{i.updateByOp(e,t,{shared:o})}catch(a){console.error(a)}}updateTreeByOp(r,e){if(r.path.length===0&&r.type===7){let t=r.parent===null?this.group:this.find(r.parent);t!==void 0&&t instanceof Ut&&(this.createObject(r.id,r.data,r.children,t,r.localIndex,e),t.requestRender())}else if(r.path.length===0&&r.type===8){let t=this.find(r.id);if(t!==void 0&&t.parent!==void 0&&t.parent instanceof Ut){let o=t.parent;t.resetBBoxNeedsUpdate(),o?.remove(t),o?.requestRender()}}else if(r.path.length===0&&r.type===9){let t=this.find(r.id);if(t!==void 0){let o=t.parent,i=r.parent===null?this:this.find(r.parent);if(i===void 0&&!1&&console.error("unexpected",i,r),i instanceof Ut||i===this){i.add(t);let a=r.localIndex;i.children.splice(a,0,i.children.pop()),t.updateWorldMatrix(!0,!1,!0),o?.requestRender(),t.requestRender()}t.resetBBoxNeedsUpdate()}}}add(r){this.group.add(r)}remove(r){this.group.remove(r)}traverse(r){this.group.traverse(e=>{e!==this.group&&r(e)})}intersectsChildren(r,e,t,o=!1,i=[]){return this.group.intersectsChildren(r,e,t,o,i,!0)}find(r){return this.group.find(r)}get children(){return this.group.children}project(r,e){return this.group.project(r,e)}getWithSortKey(r){let e=this.find(r);if(e===void 0)return;let t=[],o=e;for(;o!==this.group;){let i=o;o=o.parent;let a=o.children.indexOf(i);t.splice(0,0,a)}return{entity:e,sortKey:t}}getAllSorted(r){let e=[];for(let t of r){let o=this.getWithSortKey(t.id);o!==void 0&&e.push(o)}return e.sort((t,o)=>Al(t.sortKey,o.sortKey)),e.map(t=>t.entity)}},ai=nh;ai.GROUP_ID="scene2d";function ih({constraints:n,newParentWidth:r,newParentHeight:e,initialParentWidth:t,initialParentHeight:o,objectInitialWidth:i,objectInitialHeight:a,objectInitialPosition:s}){let{horizontalConstraint:l,verticalConstraint:c}=n,u=r-t,p=e-o,d=i,h=a,f=s[0],m=s[1];if(l!==0){if(l===1)f+=u;else if(l===3)f+=u/2;else if(l===2)d=Math.max(1,d+u);else if(l===4){let y=r/t;d*=y,f*=y}}if(c!==0){if(c===1)m+=p;else if(c===3)m+=p/2;else if(c===2)h=Math.max(1,h+p);else if(c===4){let y=e/o;h*=y,m*=y}}return{width:d,height:h,position:[f,m]}}var pD=fi(oh(),1);var dae={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{mm:1,px:1,cm:1,in:1,pt:1,pc:1}};import{MathUtils as fD}from"three";var hD=ze.identity(),ls=class{constructor(r,e,t,o){this.uuid=r;this.width=e;this.height=t;this.context=o;this.enabled=!0;this.isScreenSpace=!1;this.isFrameDirty=!1;this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.context.shared.requestRender()};this.onFrameOverrideObjectEvent=r=>{if(r.target?.uuid!==void 0){let e=this.frameRoot?.find(r.target.uuid);e&&e.dispatchEvent({...r,target:e})}};this.scene2d=new ai(fD.generateUUID(),Gc.defaultData,{dpr:window.devicePixelRatio,shared:o.shared}),this.canvas=document.createElement("canvas"),this.renderer=new fl(this.canvas),o.shared.addCanvas(this.uuid,this.canvas),this.textureHolder=o.shared.canvas(this.uuid),this.promise=this.init()}async init(){this.renderer instanceof fl&&(this.renderer.wasmURL=ib.skiaWasmUrl),await this.renderer.init()}render(){this.isFrameDirty&&(this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.textureHolder?.setNeedsUpdate(!0),this.isFrameDirty=!1)}updateEntity2DByOp(r,e,t,o){this.scene2d.updateEntityByOp(r,e,t,o),this.applySize()}updateTreeByOp(r,e){this.scene2d.updateTreeByOp(r,e),this.applySize()}applyOverrides(r){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=r?.width??this.width,t=r?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=t,this.frameOverride.localMatrix=hD,this.isScreenSpace&&(this.frameOverride.fill.color=Ie.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:t},Nv({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(r){let e=r?.width??this.width,t=r?.height??this.height;this.width=e,this.height=t,this.renderer.dpr=this.isScreenSpace?window.devicePixelRatio:Math.floor(2048/Math.max(e,t)),this.renderer.setSize(e,t),this.textureHolder?.dispose(),this.applyOverrides(r),this.frameOverride?.requestRender()}applyFrame(r){let e=this.context.scene.find2D(r);if(!(!e||!(e instanceof fr)))return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.textureHolder?.dispose(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(t=>{t.addEventListener("beginState",this.onFrameOverrideObjectEvent)}),this.frameOverride.traverse(t=>{t.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(r){return this.scene2d.find(r)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(r=>{r.removeEventListener("beginStateChange",this.onFrameOverrideObjectEvent)}),this.frameOverride?.traverse(r=>{r.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function Nv({objectOverride:n,objectRoot:r,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:i}){if(n instanceof fr&&r instanceof fr||n instanceof Kt&&r instanceof Kt)for(let a=0,s=n.children.length;a<s;a++){let l=n.children[a],c=r.children[a];l&&c&&l.uuid===c.uuid&&yD({objectOverride:l,objectRoot:c,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:i})}}function mD(n){if(ah(n))return[n.width,n.height];if(n instanceof Uo){let[r,e]=n.getHalfSize();return[r*2,e*2]}else if(n instanceof Kt){let[r,e]=n.recursiveBBox.getHalfSize();return[r*2,e*2]}return[0,0]}function yD({objectOverride:n,objectRoot:r,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:i}){let[a,s]=mD(r),{width:l,height:c,position:u}=ih({constraints:n.data,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:i,objectInitialWidth:a,objectInitialHeight:s,objectInitialPosition:r.position});if(n.position=u,n.data={...n.data,position:u},n.states)for(let p in n.states)gD({stateId:p,objectOverride:n,objectRoot:r,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:i});if(ah(n)||n instanceof Kt)ah(n)&&(n.width=l,n.height=c,n.data={...n.data,width:l,height:c}),Nv({objectOverride:n,objectRoot:r,newParentWidth:l,newParentHeight:c,initialParentWidth:a,initialParentHeight:s});else if(n instanceof Uo){let p=r,d=a!==0?l/a:1,h=s!==0?c/s:1;n.path=Av(p.path,d,h),n.data={...n.data,path:n.path}}}function gD({stateId:n,objectOverride:r,objectRoot:e,newParentWidth:t,newParentHeight:o,initialParentWidth:i,initialParentHeight:a}){let s=r.states?.[n],l=e.states?.[n];if(s&&l){let{width:c,height:u,position:p}=ih({constraints:r.data,newParentWidth:t,newParentHeight:o,initialParentWidth:i,initialParentHeight:a,objectInitialWidth:Io.isResizeable(l)?l.width:0,objectInitialHeight:Io.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(r.states[n],{position:p}),Io.isResizeable(s)&&Object.assign(r.states[n],{width:c,height:u})}}function ah(n){return n instanceof mo||n instanceof fr||n instanceof Sn||n instanceof wn}var Cr=class extends sa(SD){constructor(e,t,o){super();this.data=t;this.bgColor=new Ct(1,1,1,1);this.fog=null;this.backupFog=new bD(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new xD;this.penumbraSizeArrayCache=null;this.super_Entity(e,t),this.personalCamera=new jo(tn,{...Gn.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new vD(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),t.uiScene?this.uiScene=new ai((Array.isArray(e)?e[0]:e)+"-ui",t.uiScene,{dpr:window.devicePixelRatio,shared:o.shared}):t.uiFrame&&this.createUICanvas(t.uiFrame,o)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(e,t){this.uiCanvas=new ls(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,t),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=Gt(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(t=>{t instanceof nr&&t.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof or)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&rv(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,t){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let o=this.scene;o.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Gt(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=Gt(e.aoColor,t))}updateByOp(e,t,o,i){let a=this.data.uiFrame;super.updateByOp(e,t,o,i);let s=t;Be(e.path,["fog"])?this.updateFog(s.fog,o.shared):Be(e.path,["ao"])?this.updateAo(s.ao,o.shared):Be(e.path,["ambient"])?this.updateAmbientLight(s.ambient,o.shared):Be(e.path,["shadow"])?this.updateShadow(s.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||a!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,o)}updateUIFrame(e,t){e?(this.uiCanvas||this.createUICanvas(e,t),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(Gt(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,t){}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,t=0;this.traverseEntity(o=>{if(!o.visible)return!0;o instanceof is&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize,e+=1),o instanceof as&&o.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+t]=o.data.penumbraSize,t+=1)})}raycastWithClones(e){let t=[],o=i=>{for(let a of i.children){let s=a.cloner;Le.is(a)&&(a.visible||s?.object.data.visible)&&((xn(a)||cl(a)&&this.scene.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),yl(a,e,t,!0)),o(a))}};return o(this),t}updateEntity2DByOp(e,t,o,i){this.uiCanvas?.updateEntity2DByOp(e,t,o,i)}};import{PointLight as wD,Vector3 as $u,Box3 as PD,Box3Helper as Dv,Color as OD}from"three";var Yu=class extends rs(wD,ns){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let a=new $u(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new $u(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),l=new PD(a,s),c=new Dv(l,new OD(16755200));c.visible=!1,this.gizmos.shadowmap=c,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let r in this.gizmos){let e=this.gizmos[r];if(e instanceof Dv){let t=this.shadow.camera,o=new $u(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),i=new $u(t.far+this.position.x,t.far+this.position.y,t.far+this.position.z);e.box.set(o,i),e.updateMatrixWorld(!0)}}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Xu=class extends at{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?qs(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var cs=class extends at{constructor(e,t,o){super(e,t,o);this._shapeId=null;this._context=o}updateState(e,t){super.updateState(e,t),this.updateShape()}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let i in e)typeof e[i]=="string"&&(e[i]=this._context.shared.getVariable(e[i],[this.uuid,"geometry","extrusion","shape",i]));let t;if(e.type==="Custom"){let i=e.shapeId;if(i!==this._shapeId&&this.detachShape(),i){this._shapeId=i;let a=this._context.scene.find(i);a?.data&&(a.attachedPaths.add(this),t=a.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let i;switch(e.type){case"Rectangle":i=ba;break;case"Ellipse":i=ma;break;case"Polygon":i=lu;break;case"Star":i=cu;break;default:throw new Error(`Unknown shape type: ${e.type}`)}t=i.create({parameters:e}).userData.shape}let o=this.geometry;t&&o.inputs&&(o.inputs.shapeData=t,o.build(),this.attachedSurfaceCloners.forEach(i=>i.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,t){return super.updateTransformState(e,t)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let o=this.geometry.getAttribute("position");o!==void 0?qs(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,t):super.updateEntityBoxSize(e,t)}};import{Group as CD,Matrix4 as TD,Skeleton as AD}from"three";var ko=class extends Pr(CD,Or){constructor(e,t,o){super();t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,o)),this.super_Entity(e,t),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,t){let o=Zi.getComponentData({scene:t.scene.data,shared:t.shared.data},e.component);if(o){let i,a;for(let s of Zr.rootOverrideProps)e[s]===void 0?(i===void 0&&(i={...e}),i[s]=o.data[s]):(a===void 0&&(a={}),a[s]=e[s],i===void 0&&(i={...e}),i[s]=qr.apply(o.data[s],e[s]));return this.overrideData=a,i}else return{...St.defaultData,...e,...Mr(St.defaultData,Zr.rootOverrideProps)}}updateByOp(e,t,o,i){let a;if(this.isInstanceRoot&&!i){if(t=this.transformAssignData(t,o),e.type===0&&e.path.length===0&&this.component)for(let s of Zr.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&Zr.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:t[s]}})}}super.updateByOp(a??e,t,o,i)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){let o=e.scene.find(t.component)??null,i=!1;if(o!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(Le.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Ku(s),a+=1;else break;this.children.splice(0,a)}i=!0}if(o){let a={};_v(e,[this.uuid],t.overrides,this,o,o,0,i,a);for(let s of this.children)if(Le.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(c=>{if(c instanceof at&&c.isSkinnedMesh){let u=c.dataPatched;if(u.bones&&u.boneInverses){let p=u.bones.map(f=>e.scene.find(a[f])),d=u.boneInverses.map(f=>new TD().fromArray(f)),h=new AD(p,d);c.bind(h,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function Ku(n){if(n.component){let r=n.component.instances.indexOf(n);r>=0&&n.component.instances.splice(r,1);for(let e of n.children)Le.is(e)&&Ku(e)}}function Ev(n,r,e,t){return n.component===r&&Cd(n.identity,t)?n.overrideData===e?2:1:0}function _v(n,r,e,t,o,i,a,s,l){if(a>50)return!1;if(t.component!==o){if(t.component){let u=t.component.instances.indexOf(t);u>=0&&t.component.instances.splice(u,1)}o.instances.find(u=>u===t)||o.instances.push(t),t.component=o}o instanceof ko&&o.isInstanceRoot&&o.expandInstanceChildren(n);let c=0;for(let u of o.children)if(Le.is(u)){let p=[...r,...typeof u.identity=="string"?[u.identity]:u.identity],d=Ki.resolve(e,p,1);if(d!=null&&!(d instanceof Ke)){if(!1)debugger;Object.setPrototypeOf(d,Ke.prototype),console.error("wrong prototype")}let h=null,f;if(!s){let m=t.children[c];if(h=Le.is(m)?m:null,h!==null){let y=Ev(h,u,d,p);f=y>=1?h.stateSelection:void 0,y!==2&&(h=null)}if(h===null&&(h=n.scene.findInstance(p)??null,h!==null)){let y=Ev(h,u,d,p);if(f=y>=1?h.stateSelection:void 0,y!==2)h=null;else{let g=h.parent.children.indexOf(h);h.parent.children.splice(g,1),t.children.splice(c,0,h),h.parent===t?(g<=c&&console.error("not possible"),void 0):(h.parent=t,h.matrixWorldNeedsUpdate=!0,h.resetBBoxNeedsUpdate(),h.updateVisible(),n.pendingDeletes.delete(h),void 0)}}}if(h===null){let m=d?qr.apply(u.data,d):u.data;Ir.is(m.type)&&(m={...m,type:"Empty"}),h=Er.createEntity(p,m,n),h.overrideData=d,t.add(h),t.children.splice(t.children.length-1,1),t.children.splice(c,0,h),h.updateState(h.data,n),f&&h.changeSelectedState(f,n),n.scene.registerInstanceAndSetUuid(h)}if(h.isBone){let m=h.identity[h.identity.length-1];l[m]=h.uuid}c+=1,_v(n,r,e,h,u,i,a+1,s,l)}if(!s){let u=c;for(;;){let p=t.children[c];if(Le.is(p))n.pendingDeletes.add(p);else break;c+=1}t.children.splice(u,c-u)}return!0}import{Bone as MD}from"three";var Qu=class extends Pr(MD,Or){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(r,e){this.updateState_Entity(r,e)}};var si=class extends at{constructor(e,t,o){super(e,t,o);this.onBeforeRender=()=>{this.uiCanvas.render()};this.uiCanvas=new ls(e+"-canvas",t.geometry.width,t.geometry.height,o),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,o.shared)})}updateByPatchedOpGeometry(e,t,o){super.updateByPatchedOpGeometry(e,t,o),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,o.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,o.shared))}applySize(e,t){let o=e?.width??this.dataPatched.geometry.width,i=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:o,height:i}),this.applyGeometryParametersFromFrame(t)}applyFrame(e,t){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(t),this.applyMaterialParametersFromFrame({shared:t})}applyGeometryParametersFromFrame(e){let t=this.frame;t&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=Bo(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let t=this.frame;if(t){let o=t.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),this.material.reset(this.dataPatched.material,e,!0)}}updateEntity2DByOp(e,t,o,i){this.uiCanvas.updateEntity2DByOp(e,t,o,i),e===this.frameId&&t.type===0&&(t.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(i):Be(t.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:i}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.applySize({width:e.width,height:e.height},t)}};import{Object3D as GD,Vector3 as Tr,InstancedMesh as jD,InstancedBufferAttribute as FD,PlaneGeometry as UD,Vector4 as gl,Quaternion as eS,TextureLoader as kD,Texture as tS,Euler as HD,MathUtils as fh}from"three";import{GPUComputationRenderer as WD}from"three/examples/jsm/misc/GPUComputationRenderer.js";import{Vector3 as Bv,FloatType as sh,DataTexture as lh,RGBAFormat as ch,Mesh as ID,Euler as Jse,Matrix4 as ele}from"three";import{MeshSurfaceSampler as ND}from"three/examples/jsm/math/MeshSurfaceSampler.js";function Lv(n){let r=new Float32Array(n*n*2);for(let e=0;e<n;e++)for(let t=0;t<n;t++){let o=e*n+t;r[o*2+0]=e/(n-1),r[o*2+1]=t/(n-1)}return r}function Rv(n){let r=Math.ceil(Math.sqrt(n));return Math.max(r,1)}function Vv(n,r){let e=new ID(n.geometry,n.material),t=[],o=[],i=new Bv,a=new Bv;e.geometry.index!==null&&(e.geometry=e.geometry.toNonIndexed());let s=new ND(e).build();for(let u=0;u<r;u++)s.sample(i,a),t.push(i.x,i.y,i.z),o.push(a.x,a.y,a.z);let l=new Float32Array(t),c=new Float32Array(o);return{positions:l,normals:c}}function uh(n,r){let e=n,t=new Float32Array(4*r*r);for(let i=0;i<r*r;i++)t[4*i]=e[3*i],t[4*i+1]=e[3*i+1],t[4*i+2]=e[3*i+2],t[4*i+3]=0;let o=new lh(t,r,r,ch,sh);return o.needsUpdate=!0,o}function zv({size:n}){let r=new Float32Array(4*n*n);for(let t=0;t<n*n;t++)r[4*t]=t,r[4*t+1]=0,r[4*t+2]=0,r[4*t+3]=0;let e=new lh(r,n,n,ch,sh);return e.needsUpdate=!0,e}function Gv(n){let r=new Float32Array(4*n*n);for(let t=0;t<n*n;t++)r[4*t]=0,r[4*t+1]=0,r[4*t+2]=0,r[4*t+3]=0;let e=new lh(r,n,n,ch,sh);return e.needsUpdate=!0,e}var jv=`
2604
2604
  // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
2605
2605
  // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
2606
2606
  // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
@@ -2669,7 +2669,7 @@ void main() {
2669
2669
  gl_FragColor = mix(vec4(0.0), activeColor, isActive);
2670
2670
 
2671
2671
  }
2672
- `;var jv=`
2672
+ `;var Fv=`
2673
2673
 
2674
2674
  vec3 mod289(vec3 x) {
2675
2675
  return x - floor(x * (1.0 / 289.0)) * 289.0;
@@ -2871,7 +2871,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
2871
2871
  );
2872
2872
  }
2873
2873
 
2874
- `;var Fv=`
2874
+ `;var Uv=`
2875
2875
  #ifdef USE_COLLIDER
2876
2876
  float restitution = max(uBounce * 2., .01); // Energy Loss
2877
2877
  // SPHERE COLLIDER
@@ -2939,7 +2939,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
2939
2939
  #endif
2940
2940
  #endif
2941
2941
  // END COLLIDER
2942
- `;var Uv=`
2942
+ `;var kv=`
2943
2943
  #ifdef USE_ATTRACTOR
2944
2944
 
2945
2945
  #ifdef USE_SPHERE_COLLIDER
@@ -3013,7 +3013,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
3013
3013
  velocity *= uForceDamping;
3014
3014
  #endif
3015
3015
  #endif
3016
- `;var kv=`
3016
+ `;var Hv=`
3017
3017
  #ifdef USE_VORTEX
3018
3018
  // Box dimensions
3019
3019
  vec3 boxHalfSize = uColliderSize / 2.0;
@@ -3052,7 +3052,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
3052
3052
  velocity += applyForce( originDirection * uSpeed * (1. - uForceDamping) , mass * .5);
3053
3053
  }
3054
3054
  #endif
3055
- `;var Hv=`
3055
+ `;var Wv=`
3056
3056
  // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
3057
3057
  // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
3058
3058
  // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
@@ -3078,7 +3078,7 @@ uniform float uForceDamping;
3078
3078
  uniform float uForceIntensity;
3079
3079
 
3080
3080
 
3081
- `+jv+`
3081
+ `+Fv+`
3082
3082
  float rand(vec2 co){
3083
3083
  return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
3084
3084
  }
@@ -3156,11 +3156,11 @@ void main() {
3156
3156
  #endif
3157
3157
 
3158
3158
  // COLLIDER
3159
- ${Fv}
3159
+ ${Uv}
3160
3160
  // ATTRACTION
3161
- ${Uv}
3161
+ ${kv}
3162
3162
  // VORTEX
3163
- ${kv}
3163
+ ${Hv}
3164
3164
  }
3165
3165
  // End isActive
3166
3166
 
@@ -3178,7 +3178,7 @@ void main() {
3178
3178
 
3179
3179
  gl_FragColor = vec4(velocity, collisionFlag);
3180
3180
  }
3181
- `;import{ShaderMaterial as DD}from"three";var uh=`
3181
+ `;import{ShaderMaterial as DD}from"three";var dh=`
3182
3182
 
3183
3183
  // Linear Fade In
3184
3184
  float linearFadeIn(float t) {
@@ -3211,7 +3211,7 @@ void main() {
3211
3211
  float constant(float t) {
3212
3212
  return 1.0;
3213
3213
  }
3214
- `;var Wv=`
3214
+ `;var qv=`
3215
3215
 
3216
3216
  float rand(vec3 co){
3217
3217
  return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
@@ -3226,7 +3226,7 @@ vec3 applyForce(vec3 force, float mass) {
3226
3226
 
3227
3227
  return acceleration;
3228
3228
  }
3229
- `;var qv=`
3229
+ `;var $v=`
3230
3230
  vec3 rgb2xyz (in vec3 rgb) {
3231
3231
  float r = rgb.r;
3232
3232
  float g = rgb.g;
@@ -3317,7 +3317,7 @@ vec3 lab2rgb (in vec3 lab) {
3317
3317
  return(rgb);
3318
3318
  }
3319
3319
 
3320
- `;var $v=`
3320
+ `;var Yv=`
3321
3321
  uniform sampler2D uPosition;
3322
3322
  uniform float uSize;
3323
3323
  uniform float uSizeEnd;
@@ -3338,9 +3338,9 @@ vec3 lab2rgb (in vec3 lab) {
3338
3338
  varying vec2 vUv;
3339
3339
  varying vec2 vRef;
3340
3340
 
3341
- ${Wv}
3342
- ${uh}
3343
- `,Yv=({easeSize:n="linearFadeOut"})=>`
3341
+ ${qv}
3342
+ ${dh}
3343
+ `,Xv=({easeSize:n="linearFadeOut"})=>`
3344
3344
  vUv = uv;
3345
3345
  vRef = ref;
3346
3346
  // Normalized LifeTime 1 to 0
@@ -3392,7 +3392,7 @@ vec3 lab2rgb (in vec3 lab) {
3392
3392
  mvPosition = modelViewMatrix * instanceMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
3393
3393
  mvPosition.xy += rotatedPosition;
3394
3394
  gl_Position = projectionMatrix * mvPosition;
3395
- `,Xv=`
3395
+ `,Kv=`
3396
3396
  uniform vec4 uColor; // start color
3397
3397
  uniform vec4 uColor2; // end color
3398
3398
  uniform sampler2D uTexture; // texture
@@ -3403,10 +3403,10 @@ vec3 lab2rgb (in vec3 lab) {
3403
3403
  float random(vec2 co) {
3404
3404
  return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
3405
3405
  }
3406
- `+uh+`
3407
- ${qv}
3406
+ `+dh+`
3407
+ ${$v}
3408
3408
 
3409
- `,Kv=({easeOpacity:n="linearFadeOut"})=>`
3409
+ `,Qv=({easeOpacity:n="linearFadeOut"})=>`
3410
3410
  // if Particle is dead, hide it
3411
3411
  if (v_LifeLeft <= 0.005 ) {
3412
3412
  discard;
@@ -3427,7 +3427,7 @@ vec3 lab2rgb (in vec3 lab) {
3427
3427
 
3428
3428
  gl_FragColor = vec4(finalColor, finalAlpha);
3429
3429
 
3430
- `;var Ju=class extends DD{constructor(e,t){super();this.needsJitter=!0;this.type="ParticleMaterial";this.easeOpacity="linearFadeIn";this.easeSize="linearFadeIn";this.useSizeEnd=!1;this.isColoringRandom=!1;this.init(e,t),this.context=t}reset(){}init(e,t){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],this.lightLayer=new Yt(0,"",{...xt.defaultData("light","phong"),visible:!1},new Lo,{},t.shared),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new Da;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(Y0),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(X0),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode($v),e.addFragmentParsCode(Xv),e.addVertexFinalCode(Yv({easeSize:this.easeSize})),e.addFragmentFinalCode(Kv({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.extensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}};import{BoxGeometry as ED,ConeGeometry as _D,MeshBasicMaterial as BD,SphereGeometry as dh,Vector3 as LD}from"three";import{Mesh as RD}from"three";import{TorusGeometry as VD}from"three";import{PlaneGeometry as zD}from"three";var ds=class{constructor(r,e,t,o){this.type="SphereEmitterShape";this.targetMesh=void 0;this.size=r,this.type=t,this.textureSize=Lv(e);let i=1;this.targetMesh=o?.type==="Mesh"&&o?o:this.getMesh(t,i);let{positions:a,dataTexture:s,dataTextureNormals:l}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(t,i));this.positionsTexture=s,this.positionsAttribute=a,this.directionsTexture=l}createPositions(r,e){let{positions:t,normals:o}=Rv(e,r*r),i=ch(t,r),a=ch(o,r);return{dataTexture:i,positions:t,dataTextureNormals:a}}getMesh(r,e){let t=null;switch(r){case"SphereEmitterShape":{t=new dh(e*.5,32,32);break}case"TorusEmitterShape":{t=new VD(e*.5,.3,15,40);break}case"ConeEmitterShape":{t=new _D(e,e,15);break}case"BoxEmitterShape":{t=new ED(e,e,e);break}case"PlaneEmitterShape":{t=new zD(e,e),t.rotateX(-Math.PI/2);break}case"MeshEmitterShape":{t=new dh(e,32,32);break}default:{t=new dh(e,32,32);break}}return new RD(t,new BD({color:16711680}))}applyToShader(r,e){this.size=new LD().fromArray(e.size),r.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function ci(n){let r={...n},e=qi.defaultData;r.forceFieldObjectId&&(r.colliderEntityId=r.forceFieldObjectId);let t={...e.shape,...r.shape},o={...e.renderMaterial,...r.renderMaterial};return{...e,...r,shape:t,renderMaterial:o}}var Qv=`
3430
+ `;var Zu=class extends DD{constructor(e,t){super();this.needsJitter=!0;this.type="ParticleMaterial";this.easeOpacity="linearFadeIn";this.easeSize="linearFadeIn";this.useSizeEnd=!1;this.isColoringRandom=!1;this.init(e,t),this.context=t}reset(){}init(e,t){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],this.lightLayer=new Yt(0,"",{...gt.defaultData("light","phong"),visible:!1},new Lo,{},t.shared),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new Na;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(Xx),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(Kx),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(Yv),e.addFragmentParsCode(Kv),e.addVertexFinalCode(Xv({easeSize:this.easeSize})),e.addFragmentFinalCode(Qv({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.extensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}};import{BoxGeometry as ED,ConeGeometry as _D,MeshBasicMaterial as BD,SphereGeometry as ph,Vector3 as LD}from"three";import{Mesh as RD}from"three";import{TorusGeometry as VD}from"three";import{PlaneGeometry as zD}from"three";var us=class{constructor(r,e,t,o){this.type="SphereEmitterShape";this.targetMesh=void 0;this.size=r,this.type=t,this.textureSize=Rv(e);let i=1;this.targetMesh=o?.type==="Mesh"&&o?o:this.getMesh(t,i);let{positions:a,dataTexture:s,dataTextureNormals:l}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(t,i));this.positionsTexture=s,this.positionsAttribute=a,this.directionsTexture=l}createPositions(r,e){let{positions:t,normals:o}=Vv(e,r*r),i=uh(t,r),a=uh(o,r);return{dataTexture:i,positions:t,dataTextureNormals:a}}getMesh(r,e){let t=null;switch(r){case"SphereEmitterShape":{t=new ph(e*.5,32,32);break}case"TorusEmitterShape":{t=new VD(e*.5,.3,15,40);break}case"ConeEmitterShape":{t=new _D(e,e,15);break}case"BoxEmitterShape":{t=new ED(e,e,e);break}case"PlaneEmitterShape":{t=new zD(e,e),t.rotateX(-Math.PI/2);break}case"MeshEmitterShape":{t=new ph(e,32,32);break}default:{t=new ph(e,32,32);break}}return new RD(t,new BD({color:16711680}))}applyToShader(r,e){this.size=new LD().fromArray(e.size),r.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function li(n){let r={...n},e=Wi.defaultData;r.forceFieldObjectId&&(r.colliderEntityId=r.forceFieldObjectId);let t={...e.shape,...r.shape},o={...e.renderMaterial,...r.renderMaterial};return{...e,...r,shape:t,renderMaterial:o}}var Zv=`
3431
3431
  // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
3432
3432
  // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
3433
3433
  // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
@@ -3474,8 +3474,8 @@ void main() {
3474
3474
 
3475
3475
 
3476
3476
  }
3477
- `;var fh=10,ed=class extends GD{constructor(e,t){super();this.type="ParticleEmitter";this.debugMode=!1;this.worldSpace=!0;this.rootObject=null;this.gpuCompute=null;this.positionSimRT=null;this.velocitySimRT=null;this.emissionRateSimRT=null;this.emitterShape=void 0;this.isEmitting=!1;this.hasBeenReset=!1;this.emittedParticlesAmount=0;this.lastEmitTime=0;this.globalTime=0;this.targetFPS=60;this.previousRatio=1;this.lerpFactor=.4;this.particlesAmount=0;this.noiseStrength=0;this.noiseScale=0;this.isBillboardBased=!0;this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1};this.textureLoader=new kD;this.currentWorldPosition=new Tr;this.systemQuaternion=new Jv;this.worldGravity=new Tr(0,0,0);this.directionAxis=new Tr(0,0,0);this.colliderV3=new Tr(0,0,0);this.colliderQuaternion=new Jv(0,0,0,1);this.matrixAutoUpdate=!0,this.renderer=e,this.system=t,this.shared=t.context.shared;let o=t.data;this.material=new Ju(o.renderMaterial,t.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:o.renderMaterial.color},uColor2:{value:o.renderMaterial.color2},uPosition:{value:new Tr(0,0,0)},uEmissionData:{value:new Tr(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new Tr(0,0,0)},uWorldQuaternion:{value:new xl(0,0,0,1)},uRandScaleFactor:{value:o.randomScale??0},uRandRotationFactor:{value:o.randomRotation??0},uRotation:{value:o.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:o.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,o.renderMaterial.texture),this.init(o)}setTexture(e,t){let o=t.data;if(typeof t=="string"){let i=this.shared.image(t),a=new eS(i.img);a.needsUpdate=!0,e.uTexture.value=a;return}if(typeof o!="string"){let i=new Image;i.onload=()=>{let l=new eS(i);l.needsUpdate=!0,e.uTexture.value=l};let a=new Blob([o],{type:"image/*"}),s=URL.createObjectURL(a);i.src=s}}updateGeometryAttributes(e,t){let o=Bv(t);!this.emitterShape?.positionsAttribute||e.geometry.setAttribute("ref",new FD(o,2))}applyWorldSpace(){if(!this.system.started||!this.worldSpace||!this.positionSimRT||!this.velocitySimRT)return;let e=this.system;e.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),e.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(e,t){if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset){this.reset();return}this.applyWorldSpace(),this.globalTime=e,this.positionSimRT.material.uniforms.uTime.value=e,this.emissionRateSimRT.material.uniforms.uTime.value=e;let o=1e3/t,i=this.targetFPS/o,a=this.previousRatio+(i-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=a,this.previousRatio=a;let s=this.isEmitting?this.GoEmitSomeParticles(e,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=s,this.material.uniforms.uPosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT)?.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let e=this.system.colliderEntities[0];if(!e)return;e.getWorldPosition(this.colliderV3),this.colliderV3.y===0&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let t=e.data.size;this.colliderV3.fromArray(t),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),e.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(e){!this.velocitySimRT||!this.positionSimRT||(e.renderMaterial&&this.updateMaterialState(e.renderMaterial),this.updateParticleState(e))}updateVariableState(e,t){if(!this.velocitySimRT||!this.positionSimRT)return;t[2]==="size"&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),t[2]==="sizeEnd"&&this.material.updateState({size:[this.material.uniforms.uSize.value,e]});let o=(i,a)=>{let s=[...this.system.data.shape.size];s[i]=a,this.updateParticleState({shape:{...this.system.data.shape,size:s}})};t[2]==="shape_size_0"&&o(0,e),t[2]==="shape_size_1"&&o(1,e),t[2]==="shape_size_2"&&o(2,e),t[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/fh),t[2]==="gravity"&&this.worldGravity.set(0,e/100,0),t[2]==="noiseStrength"&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),t[2]==="noiseScale"&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),t[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),t[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),t[2]==="direction_z"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(e)]))}updateMaterialState(e){this.material.updateState({...e,size:e.size?[Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),e.texture&&(this.setTexture(this.material.uniforms,e.texture),this.material.needsUpdate=!0)}updateParticleState(e){if(!(!this.positionSimRT||!this.velocitySimRT)){if(this.shouldReInitGPUCompute(e)&&this.init(ci(this.system.data)),e.life!==void 0&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=e.life),e.speed!==void 0&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/fh),e.collisionBounce!==void 0&&(this.velocitySimRT.material.uniforms.uBounce.value=e.collisionBounce),e.noiseStrength!==void 0&&(this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),e.noiseScale!==void 0&&(this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),e.noiseSeed!==void 0&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=e.noiseSeed),e.randomMass!==void 0&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=e.randomMass),e.renderMaterial?.size!==void 0){let t=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(t)}if(e.renderMaterial?.spriteRotation!==void 0&&(this.material.uniforms.uRotation.value=e.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=e.renderMaterial.spriteRotation[1]),e.shape!==void 0){let t=e.shape.size??this.system.data.shape.size,o=[Number(this.shared.getVariable(t[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(t[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(t[2],[this.uuid,"particles","shape_size_2"]))],i={...ci(this.system.data).shape,size:o};this.emitterShape?.applyToShader(this.positionSimRT.material.uniforms,i)}if(e.gravity!==void 0&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),e.direction!==void 0){let t=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(t),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}e.randomRotation!==void 0&&(this.material.uniforms.uRandRotationFactor.value=e.randomRotation),e.randomScale!==void 0&&(this.material.uniforms.uRandScaleFactor.value=e.randomScale)}}updateForceFieldParameters(e){!this.velocitySimRT||(e.forceIntensity!==void 0&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=e.forceIntensity),e.forceDambing!==void 0&&(this.velocitySimRT.material.uniforms.uForceDamping.value=e.forceDambing))}getDirectionAxis(e){let t=[Number(e[0])*ph.DEG2RAD,Number(e[1])*ph.DEG2RAD,Number(e[2])*ph.DEG2RAD],o=new HD(t[0],t[1],t[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(o).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(e){let{birthRatePerSec:t,rootObjectType:o,colliderEntityId:i,shape:a,emitTimeDuration:s,emitTimeCycle:l,life:c,directionMode:u,noiseType:p}=e;return t!==void 0||o!==void 0||(i||i===null)||l!==void 0||a!==void 0||c!==void 0||s!==void 0||u!==void 0||p!==void 0}init(e){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:e.birthRatePerSec,particleMaxLifeTime:e.life,loopDuration:e.emitTimeCycle==="infinity"?0:e.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn(`The maximum number of particles is limited to ${1e5}.`),this.particlesAmount=1e5),this.emitterShape=this.createShape(e.shape,this.particlesAmount);let t=setInterval(()=>{if(!!this.emitterShape)if(isNaN(this.emitterShape.positionsTexture.source.data.data[0])){this.init(e);return}else clearInterval(t)},100);if(!this.emitterShape)return;let o=new WD(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),i=this.updateSimulationDefinition(e),a=o.addVariable("uCurrentPosition",i+Gv,this.emitterShape.positionsTexture),s=o.addVariable("uCurrentVelocity",i+Hv,this.emitterShape.directionsTexture),l=o.addVariable("uCurrentEmissionRate",Qv,zv(this.emitterShape.textureSize));o.setVariableDependencies(a,[a,s,l]),o.setVariableDependencies(s,[a,s,l]),o.setVariableDependencies(l,[a,s,l]);let c=Vv({size:this.emitterShape.textureSize}),u={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new Tr(0,0,0)},uWorldQuaternion:{value:new xl(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:e.life},uEmitterSize:{value:new Tr(Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"])))},particleSize:{value:0}};a.material.uniforms=u;let p=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(p),this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"]));let d=e.colliderEntityId&&this.system.getColliderData(e.colliderEntityId),h={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new xl(0,0,0,1)},uColliderPos:{value:new Tr(0,0,0)},uColliderSize:{value:new Tr(0,0,0)},uForceIntensity:{value:d?d.forceIntensity:0},uForceDamping:{value:d?d.forceDambing:0},uColliderQuaternion:{value:new xl(0,0,0,1)},uColliderQuaternionInvert:{value:new xl(0,0,0,1)},particleSize:{value:0},uGravity:{value:this.worldGravity},uNoiseStrength:{value:this.noiseStrength},uNoiseScale:{value:this.noiseScale},uNoiseSeed:{value:e.noiseSeed},uRandomMassFactor:{value:e.randomMass},uBounce:{value:e.collisionBounce},uSpeed:{value:Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/fh}};s.material.uniforms=h;let f={uIndex:{value:c},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};l.material.uniforms=f;let m=[Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"]))],y={...ci(this.system.data).shape,size:m};this.emitterShape.applyToShader(a.material.uniforms,y),o.init(),this.gpuCompute=o,this.positionSimRT=a,this.velocitySimRT=s,this.emissionRateSimRT=l,this.rootObject=this.createPrimaryEmitter(this.emitterShape.textureSize),this.add(this.rootObject),this.material.needsUpdate=!0}getDirectionFromVariable(e){let t=Number(this.shared.getVariable(e[0],[this.uuid,"particles","direction_x"])),o=Number(this.shared.getVariable(e[1],[this.uuid,"particles","direction_y"])),i=Number(this.shared.getVariable(e[2],[this.uuid,"particles","direction_z"]));return[t,o,i]}updateSimulationDefinition(e){if(this.simFeaturesDefinition.USE_COLLIDER=!1,this.simFeaturesDefinition.USE_ATTRACTOR=!1,this.simFeaturesDefinition.USE_VORTEX=!1,this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!1,this.simFeaturesDefinition.USE_BOX_COLLIDER=!1,this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!1,this.simFeaturesDefinition.USE_NORMALS=!1,this.simFeaturesDefinition.USE_CURL_NOISE=!1,this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!1,this.simFeaturesDefinition.USE_FBM_NOISE=!1,e.colliderEntityId&&this.system.colliderEntities.length>0){let o=this.system.getColliderData(e.colliderEntityId);switch(o?.forceType){case"attractor":this.simFeaturesDefinition.USE_ATTRACTOR=!0;break;case"collider":this.simFeaturesDefinition.USE_COLLIDER=!0;break;case"vortex":this.simFeaturesDefinition.USE_VORTEX=!0;break}let i=o?.colliderType;i==="sphere"&&(this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!0),i==="box"&&(this.simFeaturesDefinition.USE_BOX_COLLIDER=!0),o?.forceRange==="helper"&&(this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!0)}e.directionMode==="normals"&&(this.simFeaturesDefinition.USE_NORMALS=!0),e.noiseType==="curl"&&(this.simFeaturesDefinition.USE_CURL_NOISE=!0),e.noiseType==="simplex"&&(this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!0),e.noiseType==="fbm"&&(this.simFeaturesDefinition.USE_FBM_NOISE=!0);let t="";for(let[o,i]of Object.entries(this.simFeaturesDefinition))i&&(t+=`#define ${o}
3478
- `);return t}createShape(e,t){this.emitterShape&&this.emitterShape.dispose();let o=new Tr(Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.size[2],[this.uuid,"particles","shape_size_2"])));if(e.type==="MeshEmitterShape"){let i=null;return this.system.context.scene.traverseEntity(a=>{a.uuid===e.fromMeshId&&(i=a)}),i?new ds(o,t,e.type,i):new ds(o,t,"SphereEmitterShape")}else return new ds(o,t,e.type)}createPrimaryEmitter(e){let t,o=e*e;return t=new jD(new UD(1,1,1),this.material,o),this.updateGeometryAttributes(t,e),this.material.needsUpdate=!0,t.onBeforeRender=()=>{this.applyWorldSpace()},t}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:t,loopDuration:o=0}){return Math.ceil(e*(t+o))}dispose(){!this.gpuCompute||(this.rootObject?.parent?.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),this.emitterShape?.dispose())}GoEmitSomeParticles(e,t){let o=e-this.lastEmitTime,i=1/t;if(o>=i){let a=Math.max(1,Math.floor(o/i));return this.lastEmitTime=e,this.emittedParticlesAmount+a>this.particlesAmount&&(this.emittedParticlesAmount=0),this.emittedParticlesAmount+=a,a}return 0}checkIfAllParticlesAreDead(){return this.lastEmitTime+this.system.data.life+1<this.globalTime}reset(){this.hasBeenReset=!0,this.lastEmitTime=0,this.emittedParticlesAmount=0,this.gpuCompute&&this.init(ci(this.system.data))}startEmitting(e){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=e}stopEmitting(){this.isEmitting=!1}};import{BufferGeometry as qD,Float32BufferAttribute as $D,MeshBasicMaterial as YD}from"three";var td=class extends Ot{constructor(e,t,o){super(e,t);this.type="ParticleSystem";this.geometry=new qD;this.actualTime=0;this.currentLoopTime=0;this.started=!1;this.stopped=!1;this.isFrozen=!1;this.isIdle=!0;this.emitter=null;this.colliderEntities=[];this.renderer=null;this.isPreWarm=!1;this._hasOnAfterRenderBeenCalled=!1;this.onAfterRender=e=>{this._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(e))};this.context=o,this.data={...t,...ci(t)},this.geometry.setAttribute("position",new $D([],3)),this.material=new YD({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new ed(e,this),this.add(this.emitter),this.updateParticleState(this.data)}update(e){if(!this.isReady||!this.started||this.isFrozen||this.isIdle)return;this.actualTime+=e,this.stopped||(this.currentLoopTime+=e);let t=this.data.emitTimeCycle==="one_time";if((this.data.emitTimeCycle==="loop"||t)&&this.currentLoopTime>this.data.emitTimeDuration*1e3&&(this.stopped||(this.stop(),t||this.start(this.data.emitTimeLoopDelayStart==="start"?0:this.data.emitTimeDelay*1e3))),this.emitter&&this.started){let i=this.actualTime/1e3;this.emitter.update(i,e)}this.scale.set(1,1,1),this.updateMatrix()}isReady(){return!!this.emitter}hasCollider(e){return this.colliderEntities.some(t=>t.identity===e)}getColliderData(e){let t=this.colliderEntities.find(o=>o.identity===e);return t?t.data:null}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),Be(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...ot.drop(e,1).props}}),Be(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...ot.drop(e,1).props}})}updateState(e,t){super.updateState(e,t),this.updateParticleState(e)}updateParticleState(e){if(!!this.emitter){if(e.colliderEntityId!==void 0&&e.colliderEntityId!==null){let t=this.context.scene.find(e.colliderEntityId);this.colliderEntities=t?[t]:[]}e.colliderEntityId===null&&(this.colliderEntities=[]),this.emitter.updateState(e),e.emitTimeCycle&&this.started&&this.start()}}updateFromColliderEntity(e){!this.emitter||(this.emitter.updateForceFieldParameters(e),this.stop(),this.start())}start(e=0){if(this.currentLoopTime=0,e){setTimeout(()=>{this.start(0)},e);return}this.started=!0,this.stopped=!1,this.isFrozen=!1,this.emitter?.startEmitting(this.actualTime/1e3)}froze(){this.isFrozen=!0}unFroze(){this.isFrozen=!1}stop(){this.stopped=!0,this.currentLoopTime=0,this.emitter?.stopEmitting()}reset(){this.started=!1,this.stopped=!1,this.emitter?.reset()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}};function XD(n,r,e){let t;return r.geometry.type==="TextGeometry"?new Za(n,r,e):(r.geometry.type==="SubdivGeometry"?t=new ri(n,r,e):r.geometry.type==="PathGeometry"?t=new us(n,r,e):r.geometry.type==="VectorGeometry"?t=new Ku(n,r,e):r.geometry.type==="BooleanGeometry"?t=new nr(n,r,e):r.geometry.type==="UIGeometry"?t=new li(n,r,e):t=new st(n,r,e),t)}function rd(n,r,e){return console.assert(r.type!==void 0),r.type==="Mesh"?XD(n,r,e):r.type==="Empty"?new vn(n,r):r.type==="Particle"?new td(n,r,e):r.type==="ParticleCollider"?new Gu(n,r,e):r.type==="Splat"?new vn(n,r):r.type==="Bone"?new Zu(n,r):r.type==="Page"?new Cr(n,r,e):r.type==="PointLight"?new Xu(n,r,e):r.type==="SpotLight"?new ss(n,r,e):r.type==="DirectionalLight"?new as(n,r,e):r.type==="Component"||r.type==="Instance"?new ko(n,r,e):Ir.is(r.type)?new jo(n,r):(console.error(r),new vn(n,r))}Er.createEntity=rd;function KD(n,r,e){let t=rd(n.identity,r,e),o=n.children,i=n.attachedPaths,a=n.parent,s=n.component,l=n.instances,c=n.overrideData,u=n.uuid,p=n.stateSelection;n.dispose();for(let d of Object.keys(n))delete n[d];Object.setPrototypeOf(n,Object.getPrototypeOf(t));for(let d of Object.keys(t))n[d]=t[d];n.children=[...n.children,...o],n.attachedPaths=i,n.parent=a,n.component=s,n.instances=l,n.uuid=u,n.overrideData=c,n.updateState(n.data,e),p&&n.changeSelectedState(p,e),n.resetBBoxNeedsUpdate()}Er.changeEntityProptotype=KD;Er.Cloner=es;function tS(n,r,e,t){n.updateByOp(r,e,t,!1)}import{Matrix4 as JD,Ray as eE,Raycaster as tE}from"three";function rS(n,r){let e=!1,t=r.getLayersOfType("transmission"),o=r.getLayersOfType("outline");return o.length>0&&(n.layers.set(8),t.length>0&&n.layers.enable(3),e=!0,Ka(n),Xa(n)),t.length===0&&o.length===0&&n.layers.set(0),n instanceof or&&n.needsAO&&n.layers.enable(5),e}function oS(n,r){if(!r.layers)return!1;let e=!1,t=r.getLayersOfType("transmission").filter(i=>i.data.visible),o=r.getLayersOfType("outline").filter(i=>i.data.visible);return t.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),t.length===0&&o.length===0&&n.layers.set(0),n.needsAO&&n.layers.enable(5),e}function nS(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof or)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)rS(e,e.material[t])&&(r=!0);else rS(e,e.material)&&(r=!0)}),r}function iS(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof or)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)oS(e,e.material[t])&&(r=!0);else oS(e,e.material)&&(r=!0)}),r}var rE=new tE,oE=new JD,nE=new eE;function gl(n,r,e,t=!1){let o=n.cloner;if(o)for(let i of o.children){let a=oE.copy(i.matrixWorld).invert(),s=nE.copy(r.ray).applyMatrix4(a),l=n.matrixWorld;s.applyMatrix4(l);let c=rE;c.set(s.origin,s.direction),c.near=r.near,c.far=r.far;let u=c.intersectObject(n,!1);u.length>0&&e.push({...u[0],object:t?i:n})}}var od=class{constructor(){this._constraints=new Map}setConstraint(r,e){e===null?this._constraints.delete(r):this._constraints.set(r,e)}removeDependencies(r){this._constraints.delete(r)}applyConstraints(r){let e=new Set;this._constraints.forEach((t,o)=>{let i=[o,t],a=t;for(;this._constraints.has(a);)a=this._constraints.get(a),e.has(a)||i.push(a);for(let s=i.length-2;s>=0;s--)if(!e.has(i[s])){let l=r.find(i[s]);l?l.applyPathSnapping(r):console.warn(`missing entity ${i[s]}`),e.add(i[s])}})}findDependency(r,e){let t=r;for(;this._constraints.has(t);)if(t=this._constraints.get(t),t===e)return!0;return!1}};var aS="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL";var mo=class{};En(mo,"DepthMapRange",1<<16),En(mo,"MemoryPageSize",65536),En(mo,"BytesPerFloat",4),En(mo,"BytesPerInt",4);function iE(n){let r,e,t,o,i,a,s,l,c,u,p,d,h,f,m,y;function g(A){let N=new Float64Array(u,a,16);for(let B=0;B<16;B++)N[B]=A[B];let E;if(t>1){r.exports.sortIndexes(o,i,c,a,s,l,d.DepthMapRange,t);let B=new Uint32Array(t);E=B.buffer,B.set(new Uint32Array(u,l,t))}else if(t===1){let B=new Uint32Array(t);B[0]=new Uint32Array(u,o,e)[0],E=B.buffer}else E=new ArrayBuffer(0);n.postMessage({sortDone:!0,indexesBuffer:E},[E])}function v(A,N,E){let B=new Float32Array(u,i,e*3);t=0;let V=new Uint32Array(u,o,e);for(let j=0;j<E.length-1;j++){let R=N[j],W=A[j].elements,F=R.filter(H=>H.enabled&&H.mode==="Include").map(H=>H.type==="Box"?T(H):_(H)),k=R.filter(H=>H.enabled&&H.mode==="Exclude").map(H=>H.type==="Box"?T(H):_(H));for(let H=E[j];H<E[j+1];H++){let $=h[H*3],J=h[H*3+1],Z=h[H*3+2];if((F.length===0||P($,J,Z,F))&&(k.length===0||!P($,J,Z,k))){let X=1/(W[3]*$+W[7]*J+W[11]*Z+W[15]);B[t*3]=(W[0]*$+W[4]*J+W[8]*Z+W[12])*X,B[t*3+1]=(W[1]*$+W[5]*J+W[9]*Z+W[13])*X,B[t*3+2]=(W[2]*$+W[6]*J+W[10]*Z+W[14])*X,V[t]=H,t++}}}}function O(A,N){let E=[],B=N.filter(R=>R.enabled&&R.mode==="Include").map(R=>R.type==="Box"?T(R):_(R)),V=N.filter(R=>R.enabled&&R.mode==="Exclude").map(R=>R.type==="Box"?T(R):_(R)),j=A.length;for(let R=0;R<j;R+=3){let W=A[R],F=A[R+1],k=A[R+2];(B.length===0||P(W,F,k,B))&&(V.length===0||!P(W,F,k,V))||E.push(R/3)}return E}function P(A,N,E,B,V){return B[V==="Intersect"?"every":"some"](j=>{let R=S(A,N,E,j.invRotationMatrix,j.cropCenter);return Array.isArray(j)?x(R.x,R.y,R.z,j):D(R.x,R.y,R.z,j)})}function S(A,N,E,B,V){let j=A-V[0],R=N-V[1],W=E-V[2],F=1/(B[3]*j+B[7]*R+B[11]*W+B[15]);return{x:(B[0]*j+B[4]*R+B[8]*W+B[12])*F+V[0],y:(B[1]*j+B[5]*R+B[9]*W+B[13])*F+V[1],z:(B[2]*j+B[6]*R+B[10]*W+B[14])*F+V[2]}}function T(A){let N=A.cropSize[0]/2,E=A.cropSize[1]/2,B=A.cropSize[2]/2,V=[A.cropCenter[0]-N,A.cropCenter[1]-E,A.cropCenter[2]-B,A.cropCenter[0]+N,A.cropCenter[1]+E,A.cropCenter[2]+B],j=I(A.cropRotation);return Object.assign(V,{invRotationMatrix:j,cropCenter:A.cropCenter})}function I(A){let N=[],E=A[0]*Math.PI/180,B=A[1]*Math.PI/180,V=A[2]*Math.PI/180,j=Math.cos(E),R=Math.sin(E),W=Math.cos(B),F=Math.sin(B),k=Math.cos(V),H=Math.sin(V),$=j*k,J=j*H,Z=R*k,X=R*H;return N[0]=W*k,N[1]=-W*H,N[2]=F,N[4]=J+Z*F,N[5]=$-X*F,N[6]=-R*W,N[8]=X-$*F,N[9]=Z+J*F,N[10]=j*W,N[12]=0,N[13]=0,N[14]=0,N[3]=0,N[7]=0,N[11]=0,N[15]=1,N}function x(A,N,E,B){return A>=B[0]&&A<=B[3]&&N>=B[1]&&N<=B[4]&&E>=B[2]&&E<=B[5]}function _(A){let N=2/A.cropSize[0],E=2/A.cropSize[1],B=2/A.cropSize[2],V=I(A.cropRotation);return{invRadiusX:N,invRadiusY:E,invRadiusZ:B,cropCenter:A.cropCenter,invRotationMatrix:V}}function D(A,N,E,B){let V=(A-B.cropCenter[0])*B.invRadiusX,j=(N-B.cropCenter[1])*B.invRadiusY,R=(E-B.cropCenter[2])*B.invRadiusZ;return V*V+j*j+R*R<=1}n.onmessage=A=>{if(A.data.getCroppedIndexes){let N=new Uint32Array(O(new Float32Array(A.data.positions),A.data.crops)).buffer;n.postMessage({outOfBoundsIndexes:N},[N])}else if(A.data.positions)p=A.data.positions,h=new Float32Array(p),m=A.data.meshMatrixWorlds,y=A.data.cropsArray,f=A.data.meshIndexIntervals,v(m,y,f),n.postMessage({sortSetupComplete:!0});else if(A.data.sort||A.data.newMatrixWorlds||A.data.newCropsArray)(A.data.newMatrixWorlds||A.data.newCropsArray)&&(y=A.data.newCropsArray||y,m=A.data.newMatrixWorlds||m,v(m,y,f)),g(A.data.sort.view,A.data.sort.cameraPosition);else if(A.data.init){d=A.data.init.Constants,e=A.data.init.splatCount;let N=d.BytesPerInt,E=d.BytesPerFloat*3,B=new Uint8Array(A.data.init.sorterWasmBytes),V=N+E,j=e*V,R=e*d.BytesPerInt*2+d.DepthMapRange*d.BytesPerInt*2,W=d.MemoryPageSize*32,F=j+R+W,k=Math.floor(F/d.MemoryPageSize)+1,H={module:{},env:{memory:new WebAssembly.Memory({initial:k*2,maximum:k*3,shared:!0})}};WebAssembly.compile(B).then($=>WebAssembly.instantiate($,H)).then($=>{r=$,o=0,i=e*N,a=i+e*E,c=a+16*d.BytesPerFloat*2,s=c+e*d.BytesPerInt,l=s+d.DepthMapRange*d.BytesPerInt,u=H.env.memory.buffer,n.postMessage({sortSetupPhase1Complete:!0})})}}}function sS(n){let r=new Worker(URL.createObjectURL(new Blob(["(",iE.toString(),")(self)"],{type:"application/javascript"}))),e=atob(aS),t=new Uint8Array(e.length);for(let o=0;o<e.length;o++)t[o]=e.charCodeAt(o);return r.postMessage({init:{sorterWasmBytes:t.buffer,splatCount:n,Constants:{BytesPerFloat:mo.BytesPerFloat,BytesPerInt:mo.BytesPerInt,DepthMapRange:mo.DepthMapRange,MemoryPageSize:mo.MemoryPageSize}}}),r}import{Matrix4 as fS,Quaternion as hS,Vector2 as SE,Vector3 as ps}from"three";import{BufferAttribute as aE,BufferGeometry as sE,Color as lE,DataTexture as id,DataUtils as cE,DoubleSide as uE,DynamicDrawUsage as dE,FloatType as cS,HalfFloatType as pE,InstancedBufferAttribute as fE,InstancedBufferGeometry as hE,Mesh as mE,NormalBlending as yE,RGBAFormat as gE,RGBAIntegerFormat as xE,RGFormat as uS,ShaderMaterial as bE,UnsignedIntType as vE,Vector2 as On}from"three";var nd=function(){let n=new Float32Array(1),r=new Int32Array(n.buffer);return function(e){return n[0]=e,r[0]}}(),lS=function(n,r,e,t){return n+(r<<8)+(e<<16)+(t<<24)};var ad=new On;function sd(n){let r=!1;return n.scene.objects.traverse((e,t)=>{if(t.visible===!1)return!0;t.type==="Splat"&&(r=!0)}),r}var Cn=class extends mE{constructor(e,t,o,i,a=!1,s=1,l,c){super(o,i);this.splatCount=t,this.meshIndexIntervals=l,this.meshMatrixWorlds=c,this.splatBuffers=e,this.geometry=o,this.material=i,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=a,this.devicePixelRatio=s,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,t,o=!1,i=1,a,s){let l=Cn.buildGeomtery(t),c=Cn.buildMaterial(a);return new Cn(e,t,l,c,o,i,a,s)}static buildMaterial(e){let t=`
3477
+ `;var hh=10,Ju=class extends GD{constructor(e,t){super();this.type="ParticleEmitter";this.debugMode=!1;this.worldSpace=!0;this.rootObject=null;this.gpuCompute=null;this.positionSimRT=null;this.velocitySimRT=null;this.emissionRateSimRT=null;this.emitterShape=void 0;this.isEmitting=!1;this.hasBeenReset=!1;this.emittedParticlesAmount=0;this.lastEmitTime=0;this.globalTime=0;this.targetFPS=60;this.previousRatio=1;this.lerpFactor=.4;this.particlesAmount=0;this.noiseStrength=0;this.noiseScale=0;this.isBillboardBased=!0;this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1};this.textureLoader=new kD;this.currentWorldPosition=new Tr;this.systemQuaternion=new eS;this.worldGravity=new Tr(0,0,0);this.directionAxis=new Tr(0,0,0);this.colliderV3=new Tr(0,0,0);this.colliderQuaternion=new eS(0,0,0,1);this.matrixAutoUpdate=!0,this.renderer=e,this.system=t,this.shared=t.context.shared;let o=t.data;this.material=new Zu(o.renderMaterial,t.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:o.renderMaterial.color},uColor2:{value:o.renderMaterial.color2},uPosition:{value:new Tr(0,0,0)},uEmissionData:{value:new Tr(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new Tr(0,0,0)},uWorldQuaternion:{value:new gl(0,0,0,1)},uRandScaleFactor:{value:o.randomScale??0},uRandRotationFactor:{value:o.randomRotation??0},uRotation:{value:o.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:o.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,o.renderMaterial.texture),this.init(o)}setTexture(e,t){let o=t.data;if(typeof t=="string"){let i=this.shared.image(t),a=new tS(i.img);a.needsUpdate=!0,e.uTexture.value=a;return}if(typeof o!="string"){let i=new Image;i.onload=()=>{let l=new tS(i);l.needsUpdate=!0,e.uTexture.value=l};let a=new Blob([o],{type:"image/*"}),s=URL.createObjectURL(a);i.src=s}}updateGeometryAttributes(e,t){let o=Lv(t);!this.emitterShape?.positionsAttribute||e.geometry.setAttribute("ref",new FD(o,2))}applyWorldSpace(){if(!this.system.started||!this.worldSpace||!this.positionSimRT||!this.velocitySimRT)return;let e=this.system;e.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),e.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(e,t){if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset){this.reset();return}this.applyWorldSpace(),this.globalTime=e,this.positionSimRT.material.uniforms.uTime.value=e,this.emissionRateSimRT.material.uniforms.uTime.value=e;let o=1e3/t,i=this.targetFPS/o,a=this.previousRatio+(i-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=a,this.previousRatio=a;let s=this.isEmitting?this.GoEmitSomeParticles(e,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=s,this.material.uniforms.uPosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT)?.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let e=this.system.colliderEntities[0];if(!e)return;e.getWorldPosition(this.colliderV3),this.colliderV3.y===0&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let t=e.data.size;this.colliderV3.fromArray(t),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),e.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(e){!this.velocitySimRT||!this.positionSimRT||(e.renderMaterial&&this.updateMaterialState(e.renderMaterial),this.updateParticleState(e))}updateVariableState(e,t){if(!this.velocitySimRT||!this.positionSimRT)return;t[2]==="size"&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),t[2]==="sizeEnd"&&this.material.updateState({size:[this.material.uniforms.uSize.value,e]});let o=(i,a)=>{let s=[...this.system.data.shape.size];s[i]=a,this.updateParticleState({shape:{...this.system.data.shape,size:s}})};t[2]==="shape_size_0"&&o(0,e),t[2]==="shape_size_1"&&o(1,e),t[2]==="shape_size_2"&&o(2,e),t[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/hh),t[2]==="gravity"&&this.worldGravity.set(0,e/100,0),t[2]==="noiseStrength"&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),t[2]==="noiseScale"&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),t[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),t[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),t[2]==="direction_z"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(e)]))}updateMaterialState(e){this.material.updateState({...e,size:e.size?[Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),e.texture&&(this.setTexture(this.material.uniforms,e.texture),this.material.needsUpdate=!0)}updateParticleState(e){if(!(!this.positionSimRT||!this.velocitySimRT)){if(this.shouldReInitGPUCompute(e)&&this.init(li(this.system.data)),e.life!==void 0&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=e.life),e.speed!==void 0&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/hh),e.collisionBounce!==void 0&&(this.velocitySimRT.material.uniforms.uBounce.value=e.collisionBounce),e.noiseStrength!==void 0&&(this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),e.noiseScale!==void 0&&(this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),e.noiseSeed!==void 0&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=e.noiseSeed),e.randomMass!==void 0&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=e.randomMass),e.renderMaterial?.size!==void 0){let t=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(t)}if(e.renderMaterial?.spriteRotation!==void 0&&(this.material.uniforms.uRotation.value=e.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=e.renderMaterial.spriteRotation[1]),e.shape!==void 0){let t=e.shape.size??this.system.data.shape.size,o=[Number(this.shared.getVariable(t[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(t[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(t[2],[this.uuid,"particles","shape_size_2"]))],i={...li(this.system.data).shape,size:o};this.emitterShape?.applyToShader(this.positionSimRT.material.uniforms,i)}if(e.gravity!==void 0&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),e.direction!==void 0){let t=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(t),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}e.randomRotation!==void 0&&(this.material.uniforms.uRandRotationFactor.value=e.randomRotation),e.randomScale!==void 0&&(this.material.uniforms.uRandScaleFactor.value=e.randomScale)}}updateForceFieldParameters(e){!this.velocitySimRT||(e.forceIntensity!==void 0&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=e.forceIntensity),e.forceDambing!==void 0&&(this.velocitySimRT.material.uniforms.uForceDamping.value=e.forceDambing))}getDirectionAxis(e){let t=[Number(e[0])*fh.DEG2RAD,Number(e[1])*fh.DEG2RAD,Number(e[2])*fh.DEG2RAD],o=new HD(t[0],t[1],t[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(o).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(e){let{birthRatePerSec:t,rootObjectType:o,colliderEntityId:i,shape:a,emitTimeDuration:s,emitTimeCycle:l,life:c,directionMode:u,noiseType:p}=e;return t!==void 0||o!==void 0||(i||i===null)||l!==void 0||a!==void 0||c!==void 0||s!==void 0||u!==void 0||p!==void 0}init(e){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:e.birthRatePerSec,particleMaxLifeTime:e.life,loopDuration:e.emitTimeCycle==="infinity"?0:e.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn(`The maximum number of particles is limited to ${1e5}.`),this.particlesAmount=1e5),this.emitterShape=this.createShape(e.shape,this.particlesAmount);let t=setInterval(()=>{if(!!this.emitterShape)if(isNaN(this.emitterShape.positionsTexture.source.data.data[0])){this.init(e);return}else clearInterval(t)},100);if(!this.emitterShape)return;let o=new WD(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),i=this.updateSimulationDefinition(e),a=o.addVariable("uCurrentPosition",i+jv,this.emitterShape.positionsTexture),s=o.addVariable("uCurrentVelocity",i+Wv,this.emitterShape.directionsTexture),l=o.addVariable("uCurrentEmissionRate",Zv,Gv(this.emitterShape.textureSize));o.setVariableDependencies(a,[a,s,l]),o.setVariableDependencies(s,[a,s,l]),o.setVariableDependencies(l,[a,s,l]);let c=zv({size:this.emitterShape.textureSize}),u={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new Tr(0,0,0)},uWorldQuaternion:{value:new gl(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:e.life},uEmitterSize:{value:new Tr(Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"])))},particleSize:{value:0}};a.material.uniforms=u;let p=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(p),this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"]));let d=e.colliderEntityId&&this.system.getColliderData(e.colliderEntityId),h={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new gl(0,0,0,1)},uColliderPos:{value:new Tr(0,0,0)},uColliderSize:{value:new Tr(0,0,0)},uForceIntensity:{value:d?d.forceIntensity:0},uForceDamping:{value:d?d.forceDambing:0},uColliderQuaternion:{value:new gl(0,0,0,1)},uColliderQuaternionInvert:{value:new gl(0,0,0,1)},particleSize:{value:0},uGravity:{value:this.worldGravity},uNoiseStrength:{value:this.noiseStrength},uNoiseScale:{value:this.noiseScale},uNoiseSeed:{value:e.noiseSeed},uRandomMassFactor:{value:e.randomMass},uBounce:{value:e.collisionBounce},uSpeed:{value:Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/hh}};s.material.uniforms=h;let f={uIndex:{value:c},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};l.material.uniforms=f;let m=[Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"]))],y={...li(this.system.data).shape,size:m};this.emitterShape.applyToShader(a.material.uniforms,y),o.init(),this.gpuCompute=o,this.positionSimRT=a,this.velocitySimRT=s,this.emissionRateSimRT=l,this.rootObject=this.createPrimaryEmitter(this.emitterShape.textureSize),this.add(this.rootObject),this.material.needsUpdate=!0}getDirectionFromVariable(e){let t=Number(this.shared.getVariable(e[0],[this.uuid,"particles","direction_x"])),o=Number(this.shared.getVariable(e[1],[this.uuid,"particles","direction_y"])),i=Number(this.shared.getVariable(e[2],[this.uuid,"particles","direction_z"]));return[t,o,i]}updateSimulationDefinition(e){if(this.simFeaturesDefinition.USE_COLLIDER=!1,this.simFeaturesDefinition.USE_ATTRACTOR=!1,this.simFeaturesDefinition.USE_VORTEX=!1,this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!1,this.simFeaturesDefinition.USE_BOX_COLLIDER=!1,this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!1,this.simFeaturesDefinition.USE_NORMALS=!1,this.simFeaturesDefinition.USE_CURL_NOISE=!1,this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!1,this.simFeaturesDefinition.USE_FBM_NOISE=!1,e.colliderEntityId&&this.system.colliderEntities.length>0){let o=this.system.getColliderData(e.colliderEntityId);switch(o?.forceType){case"attractor":this.simFeaturesDefinition.USE_ATTRACTOR=!0;break;case"collider":this.simFeaturesDefinition.USE_COLLIDER=!0;break;case"vortex":this.simFeaturesDefinition.USE_VORTEX=!0;break}let i=o?.colliderType;i==="sphere"&&(this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!0),i==="box"&&(this.simFeaturesDefinition.USE_BOX_COLLIDER=!0),o?.forceRange==="helper"&&(this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!0)}e.directionMode==="normals"&&(this.simFeaturesDefinition.USE_NORMALS=!0),e.noiseType==="curl"&&(this.simFeaturesDefinition.USE_CURL_NOISE=!0),e.noiseType==="simplex"&&(this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!0),e.noiseType==="fbm"&&(this.simFeaturesDefinition.USE_FBM_NOISE=!0);let t="";for(let[o,i]of Object.entries(this.simFeaturesDefinition))i&&(t+=`#define ${o}
3478
+ `);return t}createShape(e,t){this.emitterShape&&this.emitterShape.dispose();let o=new Tr(Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.size[2],[this.uuid,"particles","shape_size_2"])));if(e.type==="MeshEmitterShape"){let i=null;return this.system.context.scene.traverseEntity(a=>{a.uuid===e.fromMeshId&&(i=a)}),i?new us(o,t,e.type,i):new us(o,t,"SphereEmitterShape")}else return new us(o,t,e.type)}createPrimaryEmitter(e){let t,o=e*e;return t=new jD(new UD(1,1,1),this.material,o),this.updateGeometryAttributes(t,e),this.material.needsUpdate=!0,t.onBeforeRender=()=>{this.applyWorldSpace()},t}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:t,loopDuration:o=0}){return Math.ceil(e*(t+o))}dispose(){!this.gpuCompute||(this.rootObject?.parent?.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),this.emitterShape?.dispose())}GoEmitSomeParticles(e,t){let o=e-this.lastEmitTime,i=1/t;if(o>=i){let a=Math.max(1,Math.floor(o/i));return this.lastEmitTime=e,this.emittedParticlesAmount+a>this.particlesAmount&&(this.emittedParticlesAmount=0),this.emittedParticlesAmount+=a,a}return 0}checkIfAllParticlesAreDead(){return this.lastEmitTime+this.system.data.life+1<this.globalTime}reset(){this.hasBeenReset=!0,this.lastEmitTime=0,this.emittedParticlesAmount=0,this.gpuCompute&&this.init(li(this.system.data))}startEmitting(e){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=e}stopEmitting(){this.isEmitting=!1}};import{BufferGeometry as qD,Float32BufferAttribute as $D,MeshBasicMaterial as YD}from"three";var ed=class extends Pt{constructor(e,t,o){super(e,t);this.type="ParticleSystem";this.geometry=new qD;this.actualTime=0;this.currentLoopTime=0;this.started=!1;this.stopped=!1;this.isFrozen=!1;this.isIdle=!0;this.emitter=null;this.colliderEntities=[];this.renderer=null;this.isPreWarm=!1;this._hasOnAfterRenderBeenCalled=!1;this.onAfterRender=e=>{this._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(e))};this.context=o,this.data={...t,...li(t)},this.geometry.setAttribute("position",new $D([],3)),this.material=new YD({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new Ju(e,this),this.add(this.emitter),this.updateParticleState(this.data)}update(e){if(!this.isReady||!this.started||this.isFrozen||this.isIdle)return;this.actualTime+=e,this.stopped||(this.currentLoopTime+=e);let t=this.data.emitTimeCycle==="one_time";if((this.data.emitTimeCycle==="loop"||t)&&this.currentLoopTime>this.data.emitTimeDuration*1e3&&(this.stopped||(this.stop(),t||this.start(this.data.emitTimeLoopDelayStart==="start"?0:this.data.emitTimeDelay*1e3))),this.emitter&&this.started){let i=this.actualTime/1e3;this.emitter.update(i,e)}this.scale.set(1,1,1),this.updateMatrix()}isReady(){return!!this.emitter}hasCollider(e){return this.colliderEntities.some(t=>t.identity===e)}getColliderData(e){let t=this.colliderEntities.find(o=>o.identity===e);return t?t.data:null}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),Be(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...ot.drop(e,1).props}}),Be(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...ot.drop(e,1).props}})}updateState(e,t){super.updateState(e,t),this.updateParticleState(e)}updateParticleState(e){if(!!this.emitter){if(e.colliderEntityId!==void 0&&e.colliderEntityId!==null){let t=this.context.scene.find(e.colliderEntityId);this.colliderEntities=t?[t]:[]}e.colliderEntityId===null&&(this.colliderEntities=[]),this.emitter.updateState(e),e.emitTimeCycle&&this.started&&this.start()}}updateFromColliderEntity(e){!this.emitter||(this.emitter.updateForceFieldParameters(e),this.stop(),this.start())}start(e=0){if(this.currentLoopTime=0,e){setTimeout(()=>{this.start(0)},e);return}this.started=!0,this.stopped=!1,this.isFrozen=!1,this.emitter?.startEmitting(this.actualTime/1e3)}froze(){this.isFrozen=!0}unFroze(){this.isFrozen=!1}stop(){this.stopped=!0,this.currentLoopTime=0,this.emitter?.stopEmitting()}reset(){this.started=!1,this.stopped=!1,this.emitter?.reset()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}};function XD(n,r,e){let t;return r.geometry.type==="TextGeometry"?new Qa(n,r,e):(r.geometry.type==="SubdivGeometry"?t=new ti(n,r,e):r.geometry.type==="PathGeometry"?t=new cs(n,r,e):r.geometry.type==="VectorGeometry"?t=new Xu(n,r,e):r.geometry.type==="BooleanGeometry"?t=new nr(n,r,e):r.geometry.type==="UIGeometry"?t=new si(n,r,e):t=new at(n,r,e),t)}function td(n,r,e){return console.assert(r.type!==void 0),r.type==="Mesh"?XD(n,r,e):r.type==="Empty"?new bn(n,r):r.type==="Particle"?new ed(n,r,e):r.type==="ParticleCollider"?new zu(n,r,e):r.type==="Splat"?new bn(n,r):r.type==="Bone"?new Qu(n,r):r.type==="Page"?new Cr(n,r,e):r.type==="PointLight"?new Yu(n,r,e):r.type==="SpotLight"?new as(n,r,e):r.type==="DirectionalLight"?new is(n,r,e):r.type==="Component"||r.type==="Instance"?new ko(n,r,e):Ir.is(r.type)?new jo(n,r):(console.error(r),new bn(n,r))}Er.createEntity=td;function KD(n,r,e){let t=td(n.identity,r,e),o=n.children,i=n.attachedPaths,a=n.parent,s=n.component,l=n.instances,c=n.overrideData,u=n.uuid,p=n.stateSelection;n.dispose();for(let d of Object.keys(n))delete n[d];Object.setPrototypeOf(n,Object.getPrototypeOf(t));for(let d of Object.keys(t))n[d]=t[d];n.children=[...n.children,...o],n.attachedPaths=i,n.parent=a,n.component=s,n.instances=l,n.uuid=u,n.overrideData=c,n.updateState(n.data,e),p&&n.changeSelectedState(p,e),n.resetBBoxNeedsUpdate()}Er.changeEntityProptotype=KD;Er.Cloner=Ja;function rS(n,r,e,t){n.updateByOp(r,e,t,!1)}import{Matrix4 as JD,Ray as eE,Raycaster as tE}from"three";function oS(n,r){let e=!1,t=r.getLayersOfType("transmission"),o=r.getLayersOfType("outline");return o.length>0&&(n.layers.set(8),t.length>0&&n.layers.enable(3),e=!0,Xa(n),Ya(n)),t.length===0&&o.length===0&&n.layers.set(0),n instanceof or&&n.needsAO&&n.layers.enable(5),e}function nS(n,r){if(!r.layers)return!1;let e=!1,t=r.getLayersOfType("transmission").filter(i=>i.data.visible),o=r.getLayersOfType("outline").filter(i=>i.data.visible);return t.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),t.length===0&&o.length===0&&n.layers.set(0),n.needsAO&&n.layers.enable(5),e}function iS(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof or)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)oS(e,e.material[t])&&(r=!0);else oS(e,e.material)&&(r=!0)}),r}function aS(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof or)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)nS(e,e.material[t])&&(r=!0);else nS(e,e.material)&&(r=!0)}),r}var rE=new tE,oE=new JD,nE=new eE;function yl(n,r,e,t=!1){let o=n.cloner;if(o)for(let i of o.children){let a=oE.copy(i.matrixWorld).invert(),s=nE.copy(r.ray).applyMatrix4(a),l=n.matrixWorld;s.applyMatrix4(l);let c=rE;c.set(s.origin,s.direction),c.near=r.near,c.far=r.far;let u=c.intersectObject(n,!1);u.length>0&&e.push({...u[0],object:t?i:n})}}var rd=class{constructor(){this._constraints=new Map}setConstraint(r,e){e===null?this._constraints.delete(r):this._constraints.set(r,e)}removeDependencies(r){this._constraints.delete(r)}applyConstraints(r){let e=new Set;this._constraints.forEach((t,o)=>{let i=[o,t],a=t;for(;this._constraints.has(a);)a=this._constraints.get(a),e.has(a)||i.push(a);for(let s=i.length-2;s>=0;s--)if(!e.has(i[s])){let l=r.find(i[s]);l?l.applyPathSnapping(r):console.warn(`missing entity ${i[s]}`),e.add(i[s])}})}findDependency(r,e){let t=r;for(;this._constraints.has(t);)if(t=this._constraints.get(t),t===e)return!0;return!1}};var sS="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL";var yo=class{};Dn(yo,"DepthMapRange",1<<16),Dn(yo,"MemoryPageSize",65536),Dn(yo,"BytesPerFloat",4),Dn(yo,"BytesPerInt",4);function iE(n){let r,e,t,o,i,a,s,l,c,u,p,d,h,f,m,y;function g(A){let N=new Float64Array(u,a,16);for(let B=0;B<16;B++)N[B]=A[B];let E;if(t>1){r.exports.sortIndexes(o,i,c,a,s,l,d.DepthMapRange,t);let B=new Uint32Array(t);E=B.buffer,B.set(new Uint32Array(u,l,t))}else if(t===1){let B=new Uint32Array(t);B[0]=new Uint32Array(u,o,e)[0],E=B.buffer}else E=new ArrayBuffer(0);n.postMessage({sortDone:!0,indexesBuffer:E},[E])}function v(A,N,E){let B=new Float32Array(u,i,e*3);t=0;let V=new Uint32Array(u,o,e);for(let j=0;j<E.length-1;j++){let R=N[j],W=A[j].elements,F=R.filter(H=>H.enabled&&H.mode==="Include").map(H=>H.type==="Box"?T(H):_(H)),k=R.filter(H=>H.enabled&&H.mode==="Exclude").map(H=>H.type==="Box"?T(H):_(H));for(let H=E[j];H<E[j+1];H++){let $=h[H*3],J=h[H*3+1],Z=h[H*3+2];if((F.length===0||P($,J,Z,F))&&(k.length===0||!P($,J,Z,k))){let X=1/(W[3]*$+W[7]*J+W[11]*Z+W[15]);B[t*3]=(W[0]*$+W[4]*J+W[8]*Z+W[12])*X,B[t*3+1]=(W[1]*$+W[5]*J+W[9]*Z+W[13])*X,B[t*3+2]=(W[2]*$+W[6]*J+W[10]*Z+W[14])*X,V[t]=H,t++}}}}function O(A,N){let E=[],B=N.filter(R=>R.enabled&&R.mode==="Include").map(R=>R.type==="Box"?T(R):_(R)),V=N.filter(R=>R.enabled&&R.mode==="Exclude").map(R=>R.type==="Box"?T(R):_(R)),j=A.length;for(let R=0;R<j;R+=3){let W=A[R],F=A[R+1],k=A[R+2];(B.length===0||P(W,F,k,B))&&(V.length===0||!P(W,F,k,V))||E.push(R/3)}return E}function P(A,N,E,B,V){return B[V==="Intersect"?"every":"some"](j=>{let R=S(A,N,E,j.invRotationMatrix,j.cropCenter);return Array.isArray(j)?x(R.x,R.y,R.z,j):D(R.x,R.y,R.z,j)})}function S(A,N,E,B,V){let j=A-V[0],R=N-V[1],W=E-V[2],F=1/(B[3]*j+B[7]*R+B[11]*W+B[15]);return{x:(B[0]*j+B[4]*R+B[8]*W+B[12])*F+V[0],y:(B[1]*j+B[5]*R+B[9]*W+B[13])*F+V[1],z:(B[2]*j+B[6]*R+B[10]*W+B[14])*F+V[2]}}function T(A){let N=A.cropSize[0]/2,E=A.cropSize[1]/2,B=A.cropSize[2]/2,V=[A.cropCenter[0]-N,A.cropCenter[1]-E,A.cropCenter[2]-B,A.cropCenter[0]+N,A.cropCenter[1]+E,A.cropCenter[2]+B],j=I(A.cropRotation);return Object.assign(V,{invRotationMatrix:j,cropCenter:A.cropCenter})}function I(A){let N=[],E=A[0]*Math.PI/180,B=A[1]*Math.PI/180,V=A[2]*Math.PI/180,j=Math.cos(E),R=Math.sin(E),W=Math.cos(B),F=Math.sin(B),k=Math.cos(V),H=Math.sin(V),$=j*k,J=j*H,Z=R*k,X=R*H;return N[0]=W*k,N[1]=-W*H,N[2]=F,N[4]=J+Z*F,N[5]=$-X*F,N[6]=-R*W,N[8]=X-$*F,N[9]=Z+J*F,N[10]=j*W,N[12]=0,N[13]=0,N[14]=0,N[3]=0,N[7]=0,N[11]=0,N[15]=1,N}function x(A,N,E,B){return A>=B[0]&&A<=B[3]&&N>=B[1]&&N<=B[4]&&E>=B[2]&&E<=B[5]}function _(A){let N=2/A.cropSize[0],E=2/A.cropSize[1],B=2/A.cropSize[2],V=I(A.cropRotation);return{invRadiusX:N,invRadiusY:E,invRadiusZ:B,cropCenter:A.cropCenter,invRotationMatrix:V}}function D(A,N,E,B){let V=(A-B.cropCenter[0])*B.invRadiusX,j=(N-B.cropCenter[1])*B.invRadiusY,R=(E-B.cropCenter[2])*B.invRadiusZ;return V*V+j*j+R*R<=1}n.onmessage=A=>{if(A.data.getCroppedIndexes){let N=new Uint32Array(O(new Float32Array(A.data.positions),A.data.crops)).buffer;n.postMessage({outOfBoundsIndexes:N},[N])}else if(A.data.positions)p=A.data.positions,h=new Float32Array(p),m=A.data.meshMatrixWorlds,y=A.data.cropsArray,f=A.data.meshIndexIntervals,v(m,y,f),n.postMessage({sortSetupComplete:!0});else if(A.data.sort||A.data.newMatrixWorlds||A.data.newCropsArray)(A.data.newMatrixWorlds||A.data.newCropsArray)&&(y=A.data.newCropsArray||y,m=A.data.newMatrixWorlds||m,v(m,y,f)),g(A.data.sort.view,A.data.sort.cameraPosition);else if(A.data.init){d=A.data.init.Constants,e=A.data.init.splatCount;let N=d.BytesPerInt,E=d.BytesPerFloat*3,B=new Uint8Array(A.data.init.sorterWasmBytes),V=N+E,j=e*V,R=e*d.BytesPerInt*2+d.DepthMapRange*d.BytesPerInt*2,W=d.MemoryPageSize*32,F=j+R+W,k=Math.floor(F/d.MemoryPageSize)+1,H={module:{},env:{memory:new WebAssembly.Memory({initial:k*2,maximum:k*3,shared:!0})}};WebAssembly.compile(B).then($=>WebAssembly.instantiate($,H)).then($=>{r=$,o=0,i=e*N,a=i+e*E,c=a+16*d.BytesPerFloat*2,s=c+e*d.BytesPerInt,l=s+d.DepthMapRange*d.BytesPerInt,u=H.env.memory.buffer,n.postMessage({sortSetupPhase1Complete:!0})})}}}function lS(n){let r=new Worker(URL.createObjectURL(new Blob(["(",iE.toString(),")(self)"],{type:"application/javascript"}))),e=atob(sS),t=new Uint8Array(e.length);for(let o=0;o<e.length;o++)t[o]=e.charCodeAt(o);return r.postMessage({init:{sorterWasmBytes:t.buffer,splatCount:n,Constants:{BytesPerFloat:yo.BytesPerFloat,BytesPerInt:yo.BytesPerInt,DepthMapRange:yo.DepthMapRange,MemoryPageSize:yo.MemoryPageSize}}}),r}import{Matrix4 as hS,Quaternion as mS,Vector2 as SE,Vector3 as ds}from"three";import{BufferAttribute as aE,BufferGeometry as sE,Color as lE,DataTexture as nd,DataUtils as cE,DoubleSide as uE,DynamicDrawUsage as dE,FloatType as uS,HalfFloatType as pE,InstancedBufferAttribute as fE,InstancedBufferGeometry as hE,Mesh as mE,NormalBlending as yE,RGBAFormat as gE,RGBAIntegerFormat as xE,RGFormat as dS,ShaderMaterial as bE,UnsignedIntType as vE,Vector2 as Pn}from"three";var od=function(){let n=new Float32Array(1),r=new Int32Array(n.buffer);return function(e){return n[0]=e,r[0]}}(),cS=function(n,r,e,t){return n+(r<<8)+(e<<16)+(t<<24)};var id=new Pn;function ad(n){let r=!1;return n.scene.objects.traverse((e,t)=>{if(t.visible===!1)return!0;t.type==="Splat"&&(r=!0)}),r}var On=class extends mE{constructor(e,t,o,i,a=!1,s=1,l,c){super(o,i);this.splatCount=t,this.meshIndexIntervals=l,this.meshMatrixWorlds=c,this.splatBuffers=e,this.geometry=o,this.material=i,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=a,this.devicePixelRatio=s,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,t,o=!1,i=1,a,s){let l=On.buildGeomtery(t),c=On.buildMaterial(a);return new On(e,t,l,c,o,i,a,s)}static buildMaterial(e){let t=`
3479
3479
  precision highp float;
3480
3480
  #include <common>
3481
3481
 
@@ -3629,4 +3629,4 @@ void main() {
3629
3629
  A = exp(A) * vColor.a;
3630
3630
  gl_FragColor = vec4(color.rgb, A);
3631
3631
  gVelocity = vec4(0.0); // so it is ignored by TAA
3632
- }`,i={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new On},viewport:{type:"v2",value:new On},basisViewport:{type:"v2",value:new On},debugColor:{type:"v3",value:new lE},covariancesTextureSize:{type:"v2",value:new On(1024,1024)},centersColorsTextureSize:{type:"v2",value:new On(1024,1024)},orthoZoom:{type:"f",value:-1}};return new bE({uniforms:i,vertexShader:t,fragmentShader:o,transparent:!0,alphaTest:1,blending:yE,depthTest:!0,depthWrite:!1,side:uE})}static buildGeomtery(e){let t=new sE;t.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new aE(o,3);t.setAttribute("position",i),i.setXYZ(0,-1,-1,0),i.setXYZ(1,-1,1,0),i.setXYZ(2,1,1,0),i.setXYZ(3,1,-1,0),i.needsUpdate=!0;let a=new hE().copy(t),s=new Uint32Array(e),l=new fE(s,1,!1);return l.setUsage(dE),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(i=>i.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,t=0,o=0;for(let i of this.splatBuffers){let a=i.nsplats;this.colors.subarray(e,e+a*4).set(i.colorsA),e+=a*4,this.centers.subarray(t,t+a*3).set(i.decoded.xyz.denormDequant().data),t+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(i.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,i=new On(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new On(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(i.x*i.y*2);for(let f=0;f<this.covariances.length;f++)l[f]=cE.toHalfFloat(this.covariances[f]);s=new id(l,i.x,i.y,uS,pE)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new id(l,i.x,i.y,uS,cS);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(i);let c=new Uint32Array(a.x*a.y*4);for(let f=0;f<o;f++){let m=f*4,y=f*3,g=f*4;c[g]=lS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=nd(this.centers[y]),c[g+2]=nd(this.centers[y+1]),c[g+3]=nd(this.centers[y+2])}let u=new id(c,a.x,a.y,xE,vE);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let p=256*4,d=new Float32Array(256*16);for(let f=0;f<this.meshMatrixWorlds.length;f++)d.set(this.meshMatrixWorlds[f].elements,f*16);let h=new id(d,p,1,gE,cS);h.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=h,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:i},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:h}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,o,i){this.splatCount>0&&(ad.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(ad),this.material.uniforms.basisViewport.value.set(2/ad.x,2/ad.y),this.material.uniforms.focal.value.set(t,o),this.material.uniforms.orthoZoom.value=i,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var pS,hh=new Promise(n=>{pS=n}),dS=!1;var ld;function mh(){if(dS)return;if(ld)return ld;async function n(){let e=await import("./gaussian-splat-compression.js");pS(e),dS=!0}return ld=n(),ld}var mS;hh.then(n=>mS=n);var bl=class{constructor(r={}){En(this,"updateView",function(){let r=new fS,e=[],t=new ps(0,0,-1),o=new ps(0,0,-1),i=new ps,a=new ps;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,h=!1;if(o.dot(t)<=.95&&(d=!0),a.copy(l.position).sub(i).length()>=1&&(h=!0),!d&&!h&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,i.copy(l.position),t.copy(o),r.copy(l.matrixWorld).invert(),r.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:r.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=p:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(p))}}());this.scene=r.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new fS().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(r,e){let t=new SE;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(r.getSize(t),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(r={}){this.activePage=this.scene.activePage,r.position&&(r.position=new ps().fromArray(r.position)),r.orientation&&(r.orientation=new hS().fromArray(r.orientation)),r.halfPrecisionCovariances=!!r.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let t=e.map(a=>new mS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,i=[0];for(let a of t)o+=a.getSplatCount(),i.push(o);return this.setupSplatMesh(t,o,r.position,r.orientation,r.halfPrecisionCovariances,this.devicePixelRatio,i,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let r=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)r.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,t)=>e.equals(this.meshMatrixWorldsOld[t]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let r=!1;return this.splatEntries.forEach((e,t)=>{e.data.crops.forEach((o,i)=>{this.cropsArray[t][i]===void 0?(r=!0,this.cropsArray[t][i]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[t][i][a][c])?(r=!0,this.cropsArray[t][i][a]=s):s!==this.cropsArray[t][i]?.[a]&&(r=!0,this.cropsArray[t][i][a]=s)})}),e.data.crops.length!==this.cropsArray[t]?.length&&(this.cropsArray[t].length=e.data.crops.length,r=!0)}),r}setupSplatMesh(r,e,t=new ps,o=new hS,i=!1,a=1,s,l){this.splatMesh=Cn.buildMesh(r,e,i,a,s,l),this.splatMesh.position.copy(t),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,p)=>this.update(c,p)}setupSortWorker(r){this.sortWorker=sS(r),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(r,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(r,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var ME=new TE;ME.wireframe=!0;var yS=new PE,cd=class extends wE{constructor(e,t){super();this.data=e;this.sharedAssets=t;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new od;this.invisibleObjects=new vn("jflkdsafjasdifjaslk",{...Mc.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new Cr("fdasfa",{...wo.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=iS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=nS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),o=this.entityIdentityToEntity[t];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Cr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let o=[],i=t;for(;i!==this;){let a=i;i=i.parent;let s=i.children.indexOf(a);o.splice(0,0,s)}return{entity:t,sortKey:o}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push(i)}return t.sort((o,i)=>Ml(o.sortKey,i.sortKey)),t.map(o=>o.entity)}nonExistOrDescendantOf(e,t){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===t)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===tn)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}find2D(e){for(let t of this.children)if(t instanceof Cr&&t.uiScene){let o=t.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof Cr&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(o=>{t===void 0&&o instanceof li&&(t=o.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof Cr&&t.uiScene&&t.uiScene.traverse(e)}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let i=this.createObject(e.id,e.data,e.children,o,e.localIndex,t);i.updateVisible(this),i.resetBBoxNeedsUpdate(),bn(i)&&cl(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty(),i.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),cl(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),bn(o)&&(o.freeBooleanPointer(),i instanceof nr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof us&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),bn(o)&&(o.invalidateUpstreamBooleanData(),cl(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof nr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let t of this.children)t instanceof Cr&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,t,o,i){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:s}=t.props;t={...t,props:s},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let a=this.find(e);if(a)try{tS(a,t,o,{scene:this,shared:i}),a instanceof st&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,t,o,i,a,s=[]){e.updateEntityByOp(t,o,i,a),this.traverseEntity(l=>{(l instanceof li||l instanceof Cr)&&(s.includes(l.frameId??"")||l.frameId===t)&&l.updateEntity2DByOp(t,o,i,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,t){let o=Object.entries(t.data.lib.components).map((i,a)=>({data:i[1].asset.data,children:i[1].asset.children,id:i[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(i=>{i instanceof jo&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Le.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Le.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,i,a,s,l){if(e){let c=i.find(e);c&&c!==i&&a.forInstancesRec(u=>{u.data=Xo(u.data,p=>{let d=p.events.data(l.id),h=u.goUp(s);if(h){let f=[...Al(h.identity),e].join("-"),m=this.entityIdentityToEntity[f];if(m){let y=m.uuid,g=rt.zoom(d,t);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,t,o,i,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...t,l.id],"object",o,i,a,s):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...t,l.id],"object",o,i,a,s)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof ko&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(i=>{if(i.data.type==="GameControl"){let a=!1;if(t.forInstancesRec(s=>{s.data=Xo(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of Ec.list)this.rewriteActions(i.data.gameActions[s],["gameActions",s],e,t,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,t,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,t,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,t,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,t,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,t,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,t,o,i)})}),!0})}expandInstances(e,t,o){let i=new Set;this.traverseEntity(a=>{if(a instanceof ko&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),t||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Qu(a)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof ko&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let o=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[o]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[o]),t.dispose()})}clearScene(){for(let e of this.children)Le.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let o=[],i=a=>{for(let s of a.children){let l=s.cloner;if(Le.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(t===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let p=s.matrixWorld.clone().invert();u.point.applyMatrix4(p),o.push(u)}}else(bn(s)||ul(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),gl(s,e,o)),i(s)}};return i(this.activePage),o}raycastWithClones(e){let t=[],o=i=>{for(let a of i.children){let s=a.cloner;Le.is(a)&&(a.visible||s?.object.data.visible)&&((bn(a)||ul(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),gl(a,e,t,!0)),o(a))}};return o(this),t}forEachEntity(e){for(let t of this.children)Le.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)Le.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)Le.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(o=>{if(o instanceof st&&o.data.type==="Mesh"&&o.data.geometry.type==="TextGeometry"&&o.data.geometry.font===e){let i=o.geometry,a=o.data.geometry;i.updateFont(e,t).then(()=>{i.update(a);let s=o.invalidateDownstreamBooleanData();cl(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)na.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Le.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,o){let i=0;for(let a of e)this.createObject(a.id,a.data,a.children,t,i,o),i+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,o,i,a,s){let l={scene:this,shared:s},c=rd(e,t,l);return c&&(this.entityByUuid[e]=c,i.add(c),i.children.splice(a,0,i.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(t,l),c instanceof st&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof st&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),h=p.boneInverses.map(m=>new OE().fromArray(m)),f=new AE(d,h);u.bind(f,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let t=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:l}=e[i],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;t.push(...u.vertices)}let o=new CE;return o.setFromPoints(t),o.getCenter(yS),yS}copyMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e);o?t.copy(o.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e)?.parent;o?t.copy(o.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Ot)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof rr&&e(t.material[o]);else t.material instanceof rr&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(i=>{i instanceof jo&&i.setViewplaneSize(e,t,o)})}initializeSplatViewer(){this.splatViewer=new bl({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as IE}from"three/examples/jsm/loaders/DRACOLoader.js";var Tn;function gS(){return Tn||(Tn=new IE,Tn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Tn.decoderPending}async function NE(n){if(Tn){let r={attributeIDs:Tn.defaultAttributeIDs,attributeTypes:Tn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Tn.decodeGeometry(new Int8Array(n).buffer,r)}catch(t){console.error(t)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([t,o])=>({name:t,itemSize:o.itemSize,array:o.array}))}}return null}async function xS(n,r){let[e,t]=Ed(mc.deserialize(new Uint8Array(n)));return Lc(e),r&&r(e),t.result().data}function bS(n){let r=[];return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="NonParametricGeometry"&&t.geometry.data.draco!==void 0&&r.push(t)}),r}async function vS(n){for(let r of n){let e=await NE(r.geometry.data.draco);if(e){let t=r.geometry.data;e.index&&(t.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:i,array:a,itemSize:s})=>{o[i]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),t.attributes=o,t.draco=void 0}}}import{Mesh as dde}from"three";import{mergeBufferGeometries as hde}from"three/examples/jsm/utils/BufferGeometryUtils.js";function SS(n){let r;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)r=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=r}import{Color as wS,ShaderLib as DE}from"three";function PS(n){let r=new Set;return n.traverse(e=>{if(e instanceof or)if(ct(e.material))e.material.forEach(t=>{let o=t;r.has(o)||r.add(o)});else{let t=e.material;r.has(t)||r.add(t)}}),r.forEach(e=>{if(e instanceof Array)return;let t=e.onBeforeCompile.bind(e);if(EE(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new wS,specularColor:new wS});let o=0;e.onBeforeCompile=(i,a)=>{t&&t(i,a),i.uniforms=Object.assign({},DE.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(i.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=ob(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else _E(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function EE(n){return n.getLayersOfType("transmission").length>0}function _E(n){let r=0;for(let e of n.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(r+=(1-r)*o.value)}}return r<1}function OS(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function CS(n){let r=[],e=(t,o=0)=>{let i=o>0?t+o:t;return r.includes(i)?e(t,o+1):i};return n.traverse(t=>{if(r.includes(t.name)){let o=t.name,i=e(t.name);if(t.name=i,t.isMesh){let a=t;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,i)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,i))}}r.push(t.name)}),n}import{mergeBufferGeometries as BE}from"three/examples/jsm/utils/BufferGeometryUtils.js";function TS(n){let r=[];return n.traverse(e=>{e instanceof es&&r.push(e)}),r.forEach(e=>{let t=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&SS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&t instanceof Ot&&a.unshift(t.geometry),a.length){let s=BE(a);t instanceof Ot&&(t.geometry=s)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:Sb})}),n}function AS(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function MS(n){Object.values(n.shared.materials).forEach(r=>{yh(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?yh(e.material):"materials"in e&&e.materials.forEach(t=>{yh(t)})})}function yh(n){if(typeof n=="string")return;let r=[];n.layers.forEach((e,t)=>{e.type==="outline"&&r.push(t)}),r.reverse().forEach(e=>{n.layers.delete(e)}),r.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var _S=hi(NS(),1);function DS(n){return n.traverseMaterial(r=>{r.needsJitter=!1}),n}var ES="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",gh=class extends RE{load(r,e,t,o=console.error){let i=new LE(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(ES+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(ES),i.load(r,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},t,o)}async parse(r){let e=await xS(r,MS),t=bS(e);e.version&&(0,_S.default)(e.version,"1.0.70")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([t.length&&gS(),Ib(e)&&D0(),jb(e)&&xb(),Sv(e)&&xv(),sd(e)&&mh()].filter(Boolean)),t.length&&await vS(t);let o=new ti(e.shared);Object.values(o.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let i=new cd(e.scene,o);sd(e)&&i.initializeSplatViewer();let a=i.activeCamera;return a&&Object.assign(a,{makeDefault:!0}),i=TS(i),i=PS(i),i=OS(i),i=CS(i),i=AS(i),i=DS(i),i}};export{gh as default};
3632
+ }`,i={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Pn},viewport:{type:"v2",value:new Pn},basisViewport:{type:"v2",value:new Pn},debugColor:{type:"v3",value:new lE},covariancesTextureSize:{type:"v2",value:new Pn(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Pn(1024,1024)},orthoZoom:{type:"f",value:-1}};return new bE({uniforms:i,vertexShader:t,fragmentShader:o,transparent:!0,alphaTest:1,blending:yE,depthTest:!0,depthWrite:!1,side:uE})}static buildGeomtery(e){let t=new sE;t.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new aE(o,3);t.setAttribute("position",i),i.setXYZ(0,-1,-1,0),i.setXYZ(1,-1,1,0),i.setXYZ(2,1,1,0),i.setXYZ(3,1,-1,0),i.needsUpdate=!0;let a=new hE().copy(t),s=new Uint32Array(e),l=new fE(s,1,!1);return l.setUsage(dE),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(i=>i.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,t=0,o=0;for(let i of this.splatBuffers){let a=i.nsplats;this.colors.subarray(e,e+a*4).set(i.colorsA),e+=a*4,this.centers.subarray(t,t+a*3).set(i.decoded.xyz.denormDequant().data),t+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(i.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,i=new Pn(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new Pn(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(i.x*i.y*2);for(let f=0;f<this.covariances.length;f++)l[f]=cE.toHalfFloat(this.covariances[f]);s=new nd(l,i.x,i.y,dS,pE)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new nd(l,i.x,i.y,dS,uS);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(i);let c=new Uint32Array(a.x*a.y*4);for(let f=0;f<o;f++){let m=f*4,y=f*3,g=f*4;c[g]=cS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=od(this.centers[y]),c[g+2]=od(this.centers[y+1]),c[g+3]=od(this.centers[y+2])}let u=new nd(c,a.x,a.y,xE,vE);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let p=256*4,d=new Float32Array(256*16);for(let f=0;f<this.meshMatrixWorlds.length;f++)d.set(this.meshMatrixWorlds[f].elements,f*16);let h=new nd(d,p,1,gE,uS);h.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=h,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:i},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:h}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,o,i){this.splatCount>0&&(id.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(id),this.material.uniforms.basisViewport.value.set(2/id.x,2/id.y),this.material.uniforms.focal.value.set(t,o),this.material.uniforms.orthoZoom.value=i,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var fS,mh=new Promise(n=>{fS=n}),pS=!1;var sd;function yh(){if(pS)return;if(sd)return sd;async function n(){let e=await import("./gaussian-splat-compression.js");fS(e),pS=!0}return sd=n(),sd}var yS;mh.then(n=>yS=n);var xl=class{constructor(r={}){Dn(this,"updateView",function(){let r=new hS,e=[],t=new ds(0,0,-1),o=new ds(0,0,-1),i=new ds,a=new ds;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,h=!1;if(o.dot(t)<=.95&&(d=!0),a.copy(l.position).sub(i).length()>=1&&(h=!0),!d&&!h&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,i.copy(l.position),t.copy(o),r.copy(l.matrixWorld).invert(),r.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:r.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=p:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(p))}}());this.scene=r.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new hS().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(r,e){let t=new SE;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(r.getSize(t),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(r={}){this.activePage=this.scene.activePage,r.position&&(r.position=new ds().fromArray(r.position)),r.orientation&&(r.orientation=new mS().fromArray(r.orientation)),r.halfPrecisionCovariances=!!r.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let t=e.map(a=>new yS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,i=[0];for(let a of t)o+=a.getSplatCount(),i.push(o);return this.setupSplatMesh(t,o,r.position,r.orientation,r.halfPrecisionCovariances,this.devicePixelRatio,i,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let r=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)r.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,t)=>e.equals(this.meshMatrixWorldsOld[t]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let r=!1;return this.splatEntries.forEach((e,t)=>{e.data.crops.forEach((o,i)=>{this.cropsArray[t][i]===void 0?(r=!0,this.cropsArray[t][i]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[t][i][a][c])?(r=!0,this.cropsArray[t][i][a]=s):s!==this.cropsArray[t][i]?.[a]&&(r=!0,this.cropsArray[t][i][a]=s)})}),e.data.crops.length!==this.cropsArray[t]?.length&&(this.cropsArray[t].length=e.data.crops.length,r=!0)}),r}setupSplatMesh(r,e,t=new ds,o=new mS,i=!1,a=1,s,l){this.splatMesh=On.buildMesh(r,e,i,a,s,l),this.splatMesh.position.copy(t),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,p)=>this.update(c,p)}setupSortWorker(r){this.sortWorker=lS(r),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(r,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(r,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var ME=new TE;ME.wireframe=!0;var gS=new PE,ld=class extends wE{constructor(e,t){super();this.data=e;this.sharedAssets=t;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new rd;this.invisibleObjects=new bn("jflkdsafjasdifjaslk",{...Ac.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new Cr("fdasfa",{...Po.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=aS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=iS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),o=this.entityIdentityToEntity[t];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Cr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let o=[],i=t;for(;i!==this;){let a=i;i=i.parent;let s=i.children.indexOf(a);o.splice(0,0,s)}return{entity:t,sortKey:o}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push(i)}return t.sort((o,i)=>Al(o.sortKey,i.sortKey)),t.map(o=>o.entity)}nonExistOrDescendantOf(e,t){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===t)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===tn)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}find2D(e){for(let t of this.children)if(t instanceof Cr&&t.uiScene){let o=t.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof Cr&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(o=>{t===void 0&&o instanceof si&&(t=o.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof Cr&&t.uiScene&&t.uiScene.traverse(e)}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let i=this.createObject(e.id,e.data,e.children,o,e.localIndex,t);i.updateVisible(this),i.resetBBoxNeedsUpdate(),xn(i)&&ll(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty(),i.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),ll(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),xn(o)&&(o.freeBooleanPointer(),i instanceof nr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof cs&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),xn(o)&&(o.invalidateUpstreamBooleanData(),ll(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof nr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let t of this.children)t instanceof Cr&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,t,o,i){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:s}=t.props;t={...t,props:s},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let a=this.find(e);if(a)try{rS(a,t,o,{scene:this,shared:i}),a instanceof at&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,t,o,i,a,s=[]){e.updateEntityByOp(t,o,i,a),this.traverseEntity(l=>{(l instanceof si||l instanceof Cr)&&(s.includes(l.frameId??"")||l.frameId===t)&&l.updateEntity2DByOp(t,o,i,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,t){let o=Object.entries(t.data.lib.components).map((i,a)=>({data:i[1].asset.data,children:i[1].asset.children,id:i[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(i=>{i instanceof jo&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Le.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Le.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,i,a,s,l){if(e){let c=i.find(e);c&&c!==i&&a.forInstancesRec(u=>{u.data=Xo(u.data,p=>{let d=p.events.data(l.id),h=u.goUp(s);if(h){let f=[...Tl(h.identity),e].join("-"),m=this.entityIdentityToEntity[f];if(m){let y=m.uuid,g=rt.zoom(d,t);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,t,o,i,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...t,l.id],"object",o,i,a,s):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...t,l.id],"object",o,i,a,s)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof ko&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(i=>{if(i.data.type==="GameControl"){let a=!1;if(t.forInstancesRec(s=>{s.data=Xo(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of Dc.list)this.rewriteActions(i.data.gameActions[s],["gameActions",s],e,t,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,t,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,t,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,t,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,t,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,t,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,t,o,i)})}),!0})}expandInstances(e,t,o){let i=new Set;this.traverseEntity(a=>{if(a instanceof ko&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),t||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Ku(a)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof ko&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let o=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[o]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[o]),t.dispose()})}clearScene(){for(let e of this.children)Le.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let o=[],i=a=>{for(let s of a.children){let l=s.cloner;if(Le.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(t===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let p=s.matrixWorld.clone().invert();u.point.applyMatrix4(p),o.push(u)}}else(xn(s)||cl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),yl(s,e,o)),i(s)}};return i(this.activePage),o}raycastWithClones(e){let t=[],o=i=>{for(let a of i.children){let s=a.cloner;Le.is(a)&&(a.visible||s?.object.data.visible)&&((xn(a)||cl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),yl(a,e,t,!0)),o(a))}};return o(this),t}forEachEntity(e){for(let t of this.children)Le.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)Le.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)Le.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(o=>{if(o instanceof at&&o.data.type==="Mesh"&&o.data.geometry.type==="TextGeometry"&&o.data.geometry.font===e){let i=o.geometry,a=o.data.geometry;i.updateFont(e,t).then(()=>{i.update(a);let s=o.invalidateDownstreamBooleanData();ll(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)oa.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Le.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,o){let i=0;for(let a of e)this.createObject(a.id,a.data,a.children,t,i,o),i+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,o,i,a,s){let l={scene:this,shared:s},c=td(e,t,l);return c&&(this.entityByUuid[e]=c,i.add(c),i.children.splice(a,0,i.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(t,l),c instanceof at&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof at&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),h=p.boneInverses.map(m=>new OE().fromArray(m)),f=new AE(d,h);u.bind(f,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let t=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:l}=e[i],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;t.push(...u.vertices)}let o=new CE;return o.setFromPoints(t),o.getCenter(gS),gS}copyMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e);o?t.copy(o.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e)?.parent;o?t.copy(o.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Pt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof rr&&e(t.material[o]);else t.material instanceof rr&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(i=>{i instanceof jo&&i.setViewplaneSize(e,t,o)})}initializeSplatViewer(){this.splatViewer=new xl({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as IE}from"three/examples/jsm/loaders/DRACOLoader.js";var Cn;function xS(){return Cn||(Cn=new IE,Cn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Cn.decoderPending}async function NE(n){if(Cn){let r={attributeIDs:Cn.defaultAttributeIDs,attributeTypes:Cn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Cn.decodeGeometry(new Int8Array(n).buffer,r)}catch(t){console.error(t)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([t,o])=>({name:t,itemSize:o.itemSize,array:o.array}))}}return null}async function bS(n,r){let[e,t]=Dd(hc.deserialize(new Uint8Array(n)));return Bc(e),r&&r(e),t.result().data}function vS(n){let r=[];return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="NonParametricGeometry"&&t.geometry.data.draco!==void 0&&r.push(t)}),r}async function SS(n){for(let r of n){let e=await NE(r.geometry.data.draco);if(e){let t=r.geometry.data;e.index&&(t.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:i,array:a,itemSize:s})=>{o[i]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),t.attributes=o,t.draco=void 0}}}import{Mesh as dde}from"three";import{mergeBufferGeometries as hde}from"three/examples/jsm/utils/BufferGeometryUtils.js";function wS(n){let r;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)r=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=r}import{Color as PS,ShaderLib as DE}from"three";function OS(n){let r=new Set;return n.traverse(e=>{if(e instanceof or)if(lt(e.material))e.material.forEach(t=>{let o=t;r.has(o)||r.add(o)});else{let t=e.material;r.has(t)||r.add(t)}}),r.forEach(e=>{if(e instanceof Array)return;let t=e.onBeforeCompile.bind(e);if(EE(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new PS,specularColor:new PS});let o=0;e.onBeforeCompile=(i,a)=>{t&&t(i,a),i.uniforms=Object.assign({},DE.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(i.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=nb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else _E(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function EE(n){return n.getLayersOfType("transmission").length>0}function _E(n){let r=0;for(let e of n.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(r+=(1-r)*o.value)}}return r<1}function CS(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function TS(n){let r=[],e=(t,o=0)=>{let i=o>0?t+o:t;return r.includes(i)?e(t,o+1):i};return n.traverse(t=>{if(r.includes(t.name)){let o=t.name,i=e(t.name);if(t.name=i,t.isMesh){let a=t;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,i)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,i))}}r.push(t.name)}),n}import{mergeBufferGeometries as BE}from"three/examples/jsm/utils/BufferGeometryUtils.js";function AS(n){let r=[];return n.traverse(e=>{e instanceof Ja&&r.push(e)}),r.forEach(e=>{let t=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&wS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&t instanceof Pt&&a.unshift(t.geometry),a.length){let s=BE(a);t instanceof Pt&&(t.geometry=s)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:wb})}),n}function MS(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function IS(n){Object.values(n.shared.materials).forEach(r=>{gh(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?gh(e.material):"materials"in e&&e.materials.forEach(t=>{gh(t)})})}function gh(n){if(typeof n=="string")return;let r=[];n.layers.forEach((e,t)=>{e.type==="outline"&&r.push(t)}),r.reverse().forEach(e=>{n.layers.delete(e)}),r.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var BS=fi(DS(),1);function ES(n){return n.traverseMaterial(r=>{r.needsJitter=!1}),n}var _S="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",xh=class extends RE{load(r,e,t,o=console.error){let i=new LE(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(_S+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(_S),i.load(r,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},t,o)}async parse(r){let e=await bS(r,IS),t=vS(e);e.version&&(0,BS.default)(e.version,"1.0.71")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([t.length&&xS(),Nb(e)&&Ex(),Fb(e)&&bb(),wv(e)&&bv(),ad(e)&&yh()].filter(Boolean)),t.length&&await SS(t);let o=new ei(e.shared);Object.values(o.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let i=new ld(e.scene,o);ad(e)&&i.initializeSplatViewer();let a=i.activeCamera;return a&&Object.assign(a,{makeDefault:!0}),i=AS(i),i=OS(i),i=CS(i),i=TS(i),i=MS(i),i=ES(i),i}};export{xh as default};