@splinetool/loader 1.9.24 → 1.9.25
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.
- package/build/SplineLoader.cjs +3 -3
- package/build/SplineLoader.js +3 -3
- package/package.json +1 -1
package/build/SplineLoader.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";var t1=Object.create;var ks=Object.defineProperty;var r1=Object.getOwnPropertyDescriptor;var o1=Object.getOwnPropertyNames;var n1=Object.getPrototypeOf,i1=Object.prototype.hasOwnProperty;var a1=(n,r,e)=>r in n?ks(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e;var ni=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),Vh=(n,r)=>{for(var e in r)ks(n,e,{get:r[e],enumerable:!0})},Gh=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of o1(r))!i1.call(n,o)&&o!==e&&ks(n,o,{get:()=>r[o],enumerable:!(t=r1(r,o))||t.enumerable});return n};var zi=(n,r,e)=>(e=n!=null?t1(n1(n)):{},Gh(r||!n||!n.__esModule?ks(e,"default",{value:n,enumerable:!0}):e,n)),s1=n=>Gh(ks({},"__esModule",{value:!0}),n);var ii=(n,r,e)=>(a1(n,typeof r!="symbol"?r+"":r,e),e);var wx=ni((Fp,Sx)=>{(function(n,r){typeof Fp=="object"?Sx.exports=r():typeof define=="function"&&define.amd?define(r):n.Alea=r()})(Fp,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 Mx=ni((vu,Ax)=>{(function(n,r){typeof vu=="object"&&typeof Ax<"u"?r(vu):typeof define=="function"&&define.amd?define(["exports"],r):r((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(vu,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,P=r.length;if(P<v)throw new TypeError("Invalid matrix: m < n");for(var O=[],S=[],T=[],A=e==="f"?P:v,x=m=d=0;x<P;x++)S[x]=new Array(A).fill(0);for(x=0;x<v;x++)T[x]=new Array(v).fill(0);var D,N=new Array(v).fill(0);for(x=0;x<P;x++)for(a=0;a<v;a++)S[x][a]=r[x][a];for(x=0;x<v;x++){for(O[x]=d,f=0,l=x+1,a=x;a<P;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<P;s++)f+=S[s][x]*S[s][a];for(p=f/h,s=x;s<P;s++)S[s][a]=S[s][a]+p*S[s][x]}for(N[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++)O[a]=S[x][a]/h;for(a=l;a<P;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*O[s]}}m<(y=Math.abs(N[x])+Math.abs(O[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=O[x],l=x}if(e){if(e==="f")for(x=v;x<P;x++){for(a=v;a<P;a++)S[x][a]=0;S[x][x]=1}for(x=v-1;0<=x;x--){for(l=x+1,d=N[x],a=l;a<A;a++)S[x][a]=0;if(d!==0){for(h=S[x][x]*d,a=l;a<A;a++){for(f=0,s=l;s<P;s++)f+=S[s][x]*S[s][a];for(p=f/h,s=x;s<P;s++)S[s][a]=S[s][a]+p*S[s][x]}for(a=x;a<P;a++)S[a][x]=S[a][x]/d}else for(a=x;a<P;a++)S[a][x]=0;S[x][x]=S[x][x]+1}}for(o*=m,s=v-1;0<=s;s--)for(var I=0;I<50;I++){for(D=!1,l=s;0<=l;l--){if(Math.abs(O[l])<=o){D=!0;break}if(Math.abs(N[l-1])<=o)break}if(!D){for(u=0,c=l-(f=1),x=l;x<s+1&&(p=f*O[x],O[x]=u*O[x],!(Math.abs(p)<=o));x++)if(d=N[x],N[x]=Math.sqrt(p*p+d*d),u=d/(h=N[x]),f=-p/h,e)for(a=0;a<P;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=N[s],l===s){if(g<0&&(N[s]=-g,t))for(a=0;a<v;a++)T[a][s]=-T[a][s];break}for(m=N[l],p=(((y=N[s-1])-g)*(y+g)+((d=O[s-1])-(h=O[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=O[x],y=N[x],h=f*d,d*=u,g=Math.sqrt(p*p+h*h),p=m*(u=p/(O[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/(N[x-1]=g))*d+(f=h/g)*y,m=-f*d+u*y,e)for(a=0;a<P;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}O[l]=0,O[s]=p,N[s]=m}for(x=0;x<v;x++)N[x]<o&&(N[x]=0);return{u:S,q:N,v:T}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var n0=ni((sf,lf)=>{(function(n,r){typeof sf=="object"&&typeof lf<"u"?lf.exports=r():typeof define=="function"&&define.amd?define(r):(n=n||self,n.TinyQueue=r())})(sf,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 a0=ni((e4,cf)=>{"use strict";var Cu=n0();Cu.default&&(Cu=Cu.default);cf.exports=i0;cf.exports.default=i0;function i0(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 Cu(void 0,rM),m=t;m<i;m+=p)for(var y=o;y<a;y+=p)f.push(new Bn(m+d,y+d,d,n));var g=nM(n),v=new Bn(t+c/2,o+u/2,0,n);v.d>g.d&&(g=v);for(var P=f.length;f.length;){var O=f.pop();O.d>g.d&&(g=O,e&&console.log("found best %d after %d probes",Math.round(1e4*O.d)/1e4,P)),!(O.max-g.d<=r)&&(d=O.h/2,f.push(new Bn(O.x-d,O.y-d,d,n)),f.push(new Bn(O.x+d,O.y-d,d,n)),f.push(new Bn(O.x-d,O.y+d,d,n)),f.push(new Bn(O.x+d,O.y+d,d,n)),P+=4)}e&&(console.log("num probes: "+P),console.log("best distance: "+g.d));var S=[g.x,g.y];return S.distance=g.d,S}function rM(n,r){return r.max-n.max}function Bn(n,r,e,t){this.x=n,this.y=r,this.h=e,this.d=oM(n,r,t),this.max=this.d+this.h*Math.SQRT2}function oM(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,iM(n,r,u,p))}return o===0?0:(t?1:-1)*Math.sqrt(o)}function nM(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 Bn(o[0][0],o[0][1],0,n):new Bn(e/r,t/r,0,n)}function iM(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 Av=ni((jee,Tv)=>{"use strict";function $I(n,r){function e(){this.constructor=n}e.prototype=r.prototype,n.prototype=new e}function Di(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,Di)}$I(Di,Error);Di.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 YI(n,r){r=r!==void 0?r:{};var e={},t={svg_path:Us},o=Us,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 e1(b,w)},s=/^[Mm]/,l=nt(["M","m"],!1,!1),c=function(b,w,L){var M=Vi(b,[w]);return L&&(M=M.concat(Vi(b=="M"?"L":"l",L[1]))),M},u=/^[Zz]/,p=nt(["Z","z"],!1,!1),d=function(){return Vi("Z")},h=/^[Ll]/,f=nt(["L","l"],!1,!1),m=function(b,w){return Vi(b,w)},y=/^[Hh]/,g=nt(["H","h"],!1,!1),v=function(b,w){return Vi(b,w.map(function(L){return{x:L}}))},P=/^[Vv]/,O=nt(["V","v"],!1,!1),S=function(b,w){return Vi(b,w.map(function(L){return{y:L}}))},T=/^[Cc]/,A=nt(["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}},D=/^[Ss]/,N=nt(["S","s"],!1,!1),I=function(b,w){return{x2:b.x,y2:b.y,x:w.x,y:w.y}},E=/^[Qq]/,_=nt(["Q","q"],!1,!1),B=function(b,w){return{x1:b.x,y1:b.y,x:w.x,y:w.y}},V=/^[Tt]/,U=nt(["T","t"],!1,!1),R=/^[Aa]/,W=nt(["A","a"],!1,!1),j=function(b,w,L,M,G,oe){return{rx:b,ry:w,xAxisRotation:L,largeArc:M,sweep:G,x:oe.x,y:oe.y}},F=function(b,w){return{x:b,y:w}},H=function(b){return b*1},q=function(b){return b.join("")*1},re=/^[01]/,ee=nt(["0","1"],!1,!1),X=function(b){return b=="1"},te=function(){return""},K=",",Z=yt(",",!1),Q=function(b){return b.join("")},$=".",ue=yt(".",!1),le=/^[eE]/,ne=nt(["e","E"],!1,!1),ce=/^[+\-]/,ae=nt(["+","-"],!1,!1),ye=/^[0-9]/,fe=nt([["0","9"]],!1,!1),me=function(b){return b.join("")},be=/^[ \t\n\r]/,ge=nt([" "," ",`
|
|
2
2
|
`,"\r"],!1,!1),C=0,ie=0,Ve=[{line:1,column:1}],Ue=0,Ge=[],Ce=0,Rt;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 De(){return n.substring(ie,C)}function Dt(){return ti(ie,C)}function Vt(b,w){throw w=w!==void 0?w:ti(ie,C),Lr([Hd(b)],n.substring(ie,C),w)}function ei(b,w){throw w=w!==void 0?w:ti(ie,C),Wd(b,w)}function yt(b,w){return{type:"literal",text:b,ignoreCase:w}}function nt(b,w,L){return{type:"class",parts:b,inverted:w,ignoreCase:L}}function Kr(){return{type:"any"}}function kd(){return{type:"end"}}function Hd(b){return{type:"other",description:b}}function Jl(b){var w=Ve[b],L;if(w)return w;for(L=b-1;!Ve[L];)L--;for(w=Ve[L],w={line:w.line,column:w.column};L<b;)n.charCodeAt(L)===10?(w.line++,w.column=1):w.column++,L++;return Ve[b]=w,w}function ti(b,w){var L=Jl(b),M=Jl(w);return{start:{offset:b,line:L.line,column:L.column},end:{offset:w,line:M.line,column:M.column}}}function wt(b){C<Ue||(C>Ue&&(Ue=C,Ge=[]),Ge.push(b))}function Wd(b,w){return new Di(b,null,null,w)}function Lr(b,w,L){return new Di(Di.buildMessage(b,w),b,w,L)}function Us(){var b,w,L,M,G;for(b=C,w=[],L=ke();L!==e;)w.push(L),L=ke();if(w!==e)if(L=ir(),L===e&&(L=null),L!==e){for(M=[],G=ke();G!==e;)M.push(G),G=ke();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 ir(){var b,w,L,M,G,oe;if(b=C,w=ri(),w!==e){for(L=[],M=C,G=[],oe=ke();oe!==e;)G.push(oe),oe=ke();for(G!==e?(oe=ri(),oe!==e?(G=[G,oe],M=G):(C=M,M=e)):(C=M,M=e);M!==e;){for(L.push(M),M=C,G=[],oe=ke();oe!==e;)G.push(oe),oe=ke();G!==e?(oe=ri(),oe!==e?(G=[G,oe],M=G):(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 ri(){var b,w,L,M,G,oe;if(b=C,w=Li(),w!==e){for(L=[],M=C,G=[],oe=ke();oe!==e;)G.push(oe),oe=ke();for(G!==e?(oe=ec(),oe!==e?(G=[G,oe],M=G):(C=M,M=e)):(C=M,M=e);M!==e;){for(L.push(M),M=C,G=[],oe=ke();oe!==e;)G.push(oe),oe=ke();G!==e?(oe=ec(),oe!==e?(G=[G,oe],M=G):(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 ec(){var b;return b=zS(),b===e&&(b=jS(),b===e&&(b=FS(),b===e&&(b=US(),b===e&&(b=kS(),b===e&&(b=WS(),b===e&&(b=$S(),b===e&&(b=XS(),b===e&&(b=QS())))))))),b}function Li(){var b,w,L,M,G,oe,Gi;if(b=C,s.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&wt(l)),w!==e){for(L=[],M=ke();M!==e;)L.push(M),M=ke();L!==e?(M=lr(),M!==e?(G=C,oe=pt(),oe===e&&(oe=null),oe!==e?(Gi=Ih(),Gi!==e?(oe=[oe,Gi],G=oe):(C=G,G=e)):(C=G,G=e),G===e&&(G=null),G!==e?(ie=b,w=c(w,M,G),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function zS(){var b,w;return b=C,u.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&wt(p)),w!==e&&(ie=b,w=d()),b=w,b}function jS(){var b,w,L,M;if(b=C,h.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&wt(f)),w!==e){for(L=[],M=ke();M!==e;)L.push(M),M=ke();L!==e?(M=Ih(),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 Ih(){var b,w,L,M,G,oe;if(b=C,w=lr(),w!==e){for(L=[],M=C,G=pt(),G===e&&(G=null),G!==e?(oe=lr(),oe!==e?(G=[G,oe],M=G):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,G=pt(),G===e&&(G=null),G!==e?(oe=lr(),oe!==e?(G=[G,oe],M=G):(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 FS(){var b,w,L,M;if(b=C,y.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&wt(g)),w!==e){for(L=[],M=ke();M!==e;)L.push(M),M=ke();L!==e?(M=Nh(),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 Nh(){var b,w,L,M,G,oe;if(b=C,w=Ri(),w!==e){for(L=[],M=C,G=pt(),G===e&&(G=null),G!==e?(oe=Ri(),oe!==e?(G=[G,oe],M=G):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,G=pt(),G===e&&(G=null),G!==e?(oe=Ri(),oe!==e?(G=[G,oe],M=G):(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 US(){var b,w,L,M;if(b=C,P.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&wt(O)),w!==e){for(L=[],M=ke();M!==e;)L.push(M),M=ke();L!==e?(M=Nh(),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 kS(){var b,w,L,M;if(b=C,T.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&wt(A)),w!==e){for(L=[],M=ke();M!==e;)L.push(M),M=ke();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,G,oe;if(b=C,w=qd(),w!==e){for(L=[],M=C,G=pt(),G===e&&(G=null),G!==e?(oe=qd(),oe!==e?(G=[G,oe],M=G):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,G=pt(),G===e&&(G=null),G!==e?(oe=qd(),oe!==e?(G=[G,oe],M=G):(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 qd(){var b,w,L,M,G,oe;return b=C,w=lr(),w!==e?(L=pt(),L===e&&(L=null),L!==e?(M=lr(),M!==e?(G=pt(),G===e&&(G=null),G!==e?(oe=lr(),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 WS(){var b,w,L,M;if(b=C,D.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&wt(N)),w!==e){for(L=[],M=ke();M!==e;)L.push(M),M=ke();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,G,oe;if(b=C,w=$d(),w!==e){for(L=[],M=C,G=pt(),G===e&&(G=null),G!==e?(oe=$d(),oe!==e?(G=[G,oe],M=G):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,G=pt(),G===e&&(G=null),G!==e?(oe=$d(),oe!==e?(G=[G,oe],M=G):(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 $d(){var b,w,L,M;return b=C,w=lr(),w!==e?(L=pt(),L===e&&(L=null),L!==e?(M=lr(),M!==e?(ie=b,w=I(w,M),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function $S(){var b,w,L,M;if(b=C,E.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&wt(_)),w!==e){for(L=[],M=ke();M!==e;)L.push(M),M=ke();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,G,oe;if(b=C,w=Yd(),w!==e){for(L=[],M=C,G=pt(),G===e&&(G=null),G!==e?(oe=Yd(),oe!==e?(G=[G,oe],M=G):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,G=pt(),G===e&&(G=null),G!==e?(oe=Yd(),oe!==e?(G=[G,oe],M=G):(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;return b=C,w=lr(),w!==e?(L=pt(),L===e&&(L=null),L!==e?(M=lr(),M!==e?(ie=b,w=B(w,M),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function XS(){var b,w,L,M;if(b=C,V.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&wt(U)),w!==e){for(L=[],M=ke();M!==e;)L.push(M),M=ke();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,G,oe;if(b=C,w=lr(),w!==e){for(L=[],M=C,G=pt(),G===e&&(G=null),G!==e?(oe=lr(),oe!==e?(G=[G,oe],M=G):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,G=pt(),G===e&&(G=null),G!==e?(oe=lr(),oe!==e?(G=[G,oe],M=G):(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,Ce===0&&wt(W)),w!==e){for(L=[],M=ke();M!==e;)L.push(M),M=ke();L!==e?(M=ZS(),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 ZS(){var b,w,L,M,G,oe;if(b=C,w=Xd(),w!==e){for(L=[],M=C,G=pt(),G===e&&(G=null),G!==e?(oe=Xd(),oe!==e?(G=[G,oe],M=G):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,G=pt(),G===e&&(G=null),G!==e?(oe=Xd(),oe!==e?(G=[G,oe],M=G):(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 Xd(){var b,w,L,M,G,oe,Gi,Qd,rc,Zd,oc,Jd;return b=C,w=Eh(),w!==e?(L=pt(),L===e&&(L=null),L!==e?(M=Eh(),M!==e?(G=pt(),G===e&&(G=null),G!==e?(oe=Ri(),oe!==e?(Gi=pt(),Gi!==e?(Qd=Dh(),Qd!==e?(rc=pt(),rc===e&&(rc=null),rc!==e?(Zd=Dh(),Zd!==e?(oc=pt(),oc===e&&(oc=null),oc!==e?(Jd=lr(),Jd!==e?(ie=b,w=j(w,M,oe,Qd,Zd,Jd),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 lr(){var b,w,L,M;return b=C,w=Ri(),w!==e?(L=pt(),L===e&&(L=null),L!==e?(M=Ri(),M!==e?(ie=b,w=F(w,M),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function Eh(){var b,w;return b=C,w=Bh(),w===e&&(w=oi()),w!==e&&(ie=b,w=H(w)),b=w,b}function Ri(){var b,w,L,M;return b=C,w=C,L=Kd(),L===e&&(L=null),L!==e?(M=Bh(),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e),w===e&&(w=C,L=Kd(),L===e&&(L=null),L!==e?(M=oi(),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e)),w!==e&&(ie=b,w=q(w)),b=w,b}function Dh(){var b,w;return b=C,re.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&wt(ee)),w!==e&&(ie=b,w=X(w)),b=w,b}function pt(){var b,w,L,M,G;if(b=C,w=[],L=ke(),L!==e)for(;L!==e;)w.push(L),L=ke();else w=e;if(w!==e)if(L=_h(),L===e&&(L=null),L!==e){for(M=[],G=ke();G!==e;)M.push(G),G=ke();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=_h(),L!==e){for(M=[],G=ke();G!==e;)M.push(G),G=ke();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 _h(){var b;return n.charCodeAt(C)===44?(b=K,C++):(b=e,Ce===0&&wt(Z)),b}function Bh(){var b,w,L,M;return b=C,w=C,L=JS(),L!==e?(M=Lh(),M===e&&(M=null),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e),w===e&&(w=C,L=oi(),L!==e?(M=Lh(),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e)),w!==e&&(ie=b,w=Q(w)),b=w,b}function JS(){var b,w,L,M,G;return b=C,w=C,L=oi(),L===e&&(L=null),L!==e?(n.charCodeAt(C)===46?(M=$,C++):(M=e,Ce===0&&wt(ue)),M!==e?(G=oi(),G!==e?(L=[L,M,G],w=L):(C=w,w=e)):(C=w,w=e)):(C=w,w=e),w===e&&(w=C,L=oi(),L!==e?(n.charCodeAt(C)===46?(M=$,C++):(M=e,Ce===0&&wt(ue)),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e)),w!==e&&(ie=b,w=Q(w)),b=w,b}function Lh(){var b,w,L,M,G;return b=C,w=C,le.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Ce===0&&wt(ne)),L!==e?(M=Kd(),M===e&&(M=null),M!==e?(G=oi(),G!==e?(L=[L,M,G],w=L):(C=w,w=e)):(C=w,w=e)):(C=w,w=e),w!==e&&(ie=b,w=Q(w)),b=w,b}function Kd(){var b;return ce.test(n.charAt(C))?(b=n.charAt(C),C++):(b=e,Ce===0&&wt(ae)),b}function oi(){var b,w,L;if(b=C,w=[],ye.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Ce===0&&wt(fe)),L!==e)for(;L!==e;)w.push(L),ye.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Ce===0&&wt(fe));else w=e;return w!==e&&(ie=b,w=me(w)),b=w,b}function ke(){var b,w;return b=C,be.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&wt(ge)),w!==e&&(ie=b,w=te()),b=w,b}function e1(b,w){if(!w)return[b];for(var L=[b],M=0,G=w.length;M<G;M++)L[M+1]=w[M][1];return L}var tc={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 Rh in tc)tc[Rh.toUpperCase()]=tc[Rh];function Vi(b,w){w||(w=[{}]);for(var L=w.length;L--;){var M={code:b,command:tc[b]};b==b.toLowerCase()&&(M.relative=!0);for(var G in w[L])M[G]=w[L][G];w[L]=M}return w}if(Rt=o(),Rt!==e&&C===n.length)return Rt;throw Rt!==e&&C<n.length&&wt(kd()),Lr(Ge,Ue<n.length?n.charAt(Ue):null,Ue<n.length?ti(Ue,Ue+1):ti(Ue,Ue))}Tv.exports={SyntaxError:Di,parse:YI}});var hh=ni((Fee,Mv)=>{var Cd=Av().parse;Cd.parseSVG=Cd;Cd.makeAbsolute=XI;Mv.exports=Cd;function XI(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 RS=ni((use,LS)=>{LS.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}});var PN={};Vh(PN,{default:()=>Fd});module.exports=s1(PN);var Ud=require("three");function nc(n){for(let r of Object.keys(n))n[r]===void 0&&delete n[r];return n}function Zt(n,r){return Object.setPrototypeOf(n,r),n}function ic(n){return Array.isArray(n)?n:[n]}function ac(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 l1=typeof global=="object"&&global&&global.Object===Object&&global,sc=l1;var c1=typeof self=="object"&&self&&self.Object===Object&&self,u1=sc||c1||Function("return this")(),_t=u1;var d1=_t.Symbol,Wt=d1;var zh=Object.prototype,p1=zh.hasOwnProperty,f1=zh.toString,Hs=Wt?Wt.toStringTag:void 0;function h1(n){var r=p1.call(n,Hs),e=n[Hs];try{n[Hs]=void 0;var t=!0}catch{}var o=f1.call(n);return t&&(r?n[Hs]=e:delete n[Hs]),o}var jh=h1;var m1=Object.prototype,y1=m1.toString;function g1(n){return y1.call(n)}var Fh=g1;var x1="[object Null]",b1="[object Undefined]",Uh=Wt?Wt.toStringTag:void 0;function v1(n){return n==null?n===void 0?b1:x1:Uh&&Uh in Object(n)?jh(n):Fh(n)}var Ar=v1;function S1(n){return n!=null&&typeof n=="object"}var Jt=S1;var w1="[object Symbol]";function P1(n){return typeof n=="symbol"||Jt(n)&&Ar(n)==w1}var ji=P1;function O1(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 lc=O1;var C1=Array.isArray,Pt=C1;var T1=1/0,kh=Wt?Wt.prototype:void 0,Hh=kh?kh.toString:void 0;function Wh(n){if(typeof n=="string")return n;if(Pt(n))return lc(n,Wh)+"";if(ji(n))return Hh?Hh.call(n):"";var r=n+"";return r=="0"&&1/n==-T1?"-0":r}var qh=Wh;function A1(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}var Mr=A1;function M1(n){return n}var $h=M1;var I1="[object AsyncFunction]",N1="[object Function]",E1="[object GeneratorFunction]",D1="[object Proxy]";function _1(n){if(!Mr(n))return!1;var r=Ar(n);return r==N1||r==E1||r==I1||r==D1}var cc=_1;var B1=_t["__core-js_shared__"],uc=B1;var Yh=function(){var n=/[^.]+$/.exec(uc&&uc.keys&&uc.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function L1(n){return!!Yh&&Yh in n}var Xh=L1;var R1=Function.prototype,V1=R1.toString;function G1(n){if(n!=null){try{return V1.call(n)}catch{}try{return n+""}catch{}}return""}var zo=G1;var z1=/[\\^$.*+?()[\]{}|]/g,j1=/^\[object .+?Constructor\]$/,F1=Function.prototype,U1=Object.prototype,k1=F1.toString,H1=U1.hasOwnProperty,W1=RegExp("^"+k1.call(H1).replace(z1,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function q1(n){if(!Mr(n)||Xh(n))return!1;var r=cc(n)?W1:j1;return r.test(zo(n))}var Kh=q1;function $1(n,r){return n?.[r]}var Qh=$1;function Y1(n,r){var e=Qh(n,r);return Kh(e)?e:void 0}var mr=Y1;var X1=mr(_t,"WeakMap"),dc=X1;var Zh=Object.create,K1=function(){function n(){}return function(r){if(!Mr(r))return{};if(Zh)return Zh(r);n.prototype=r;var e=new n;return n.prototype=void 0,e}}(),Jh=K1;function Q1(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 em=Q1;function Z1(n,r){var e=-1,t=n.length;for(r||(r=Array(t));++e<t;)r[e]=n[e];return r}var tm=Z1;var J1=800,ew=16,tw=Date.now;function rw(n){var r=0,e=0;return function(){var t=tw(),o=ew-(t-e);if(e=t,o>0){if(++r>=J1)return arguments[0]}else r=0;return n.apply(void 0,arguments)}}var rm=rw;function ow(n){return function(){return n}}var om=ow;var nw=function(){try{var n=mr(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Fi=nw;var iw=Fi?function(n,r){return Fi(n,"toString",{configurable:!0,enumerable:!1,value:om(r),writable:!0})}:$h,nm=iw;var aw=rm(nm),im=aw;function sw(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}var am=sw;var lw=9007199254740991,cw=/^(?:0|[1-9]\d*)$/;function uw(n,r){var e=typeof n;return r=r??lw,!!r&&(e=="number"||e!="symbol"&&cw.test(n))&&n>-1&&n%1==0&&n<r}var Ui=uw;function dw(n,r,e){r=="__proto__"&&Fi?Fi(n,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[r]=e}var pc=dw;function pw(n,r){return n===r||n!==n&&r!==r}var ki=pw;var fw=Object.prototype,hw=fw.hasOwnProperty;function mw(n,r,e){var t=n[r];(!(hw.call(n,r)&&ki(t,e))||e===void 0&&!(r in n))&&pc(n,r,e)}var Hi=mw;function yw(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?pc(e,s,l):Hi(e,s,l)}return e}var mo=yw;var sm=Math.max;function gw(n,r,e){return r=sm(r===void 0?n.length-1:r,0),function(){for(var t=arguments,o=-1,i=sm(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),em(n,this,s)}}var lm=gw;var xw=9007199254740991;function bw(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=xw}var Wi=bw;function vw(n){return n!=null&&Wi(n.length)&&!cc(n)}var fc=vw;var Sw=Object.prototype;function ww(n){var r=n&&n.constructor,e=typeof r=="function"&&r.prototype||Sw;return n===e}var qi=ww;function Pw(n,r){for(var e=-1,t=Array(n);++e<n;)t[e]=r(e);return t}var cm=Pw;var Ow="[object Arguments]";function Cw(n){return Jt(n)&&Ar(n)==Ow}var ep=Cw;var um=Object.prototype,Tw=um.hasOwnProperty,Aw=um.propertyIsEnumerable,Mw=ep(function(){return arguments}())?ep:function(n){return Jt(n)&&Tw.call(n,"callee")&&!Aw.call(n,"callee")},$i=Mw;function Iw(){return!1}var dm=Iw;var hm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pm=hm&&typeof module=="object"&&module&&!module.nodeType&&module,Nw=pm&&pm.exports===hm,fm=Nw?_t.Buffer:void 0,Ew=fm?fm.isBuffer:void 0,Dw=Ew||dm,ai=Dw;var _w="[object Arguments]",Bw="[object Array]",Lw="[object Boolean]",Rw="[object Date]",Vw="[object Error]",Gw="[object Function]",zw="[object Map]",jw="[object Number]",Fw="[object Object]",Uw="[object RegExp]",kw="[object Set]",Hw="[object String]",Ww="[object WeakMap]",qw="[object ArrayBuffer]",$w="[object DataView]",Yw="[object Float32Array]",Xw="[object Float64Array]",Kw="[object Int8Array]",Qw="[object Int16Array]",Zw="[object Int32Array]",Jw="[object Uint8Array]",e2="[object Uint8ClampedArray]",t2="[object Uint16Array]",r2="[object Uint32Array]",ft={};ft[Yw]=ft[Xw]=ft[Kw]=ft[Qw]=ft[Zw]=ft[Jw]=ft[e2]=ft[t2]=ft[r2]=!0;ft[_w]=ft[Bw]=ft[qw]=ft[Lw]=ft[$w]=ft[Rw]=ft[Vw]=ft[Gw]=ft[zw]=ft[jw]=ft[Fw]=ft[Uw]=ft[kw]=ft[Hw]=ft[Ww]=!1;function o2(n){return Jt(n)&&Wi(n.length)&&!!ft[Ar(n)]}var mm=o2;function n2(n){return function(r){return n(r)}}var Yi=n2;var ym=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ws=ym&&typeof module=="object"&&module&&!module.nodeType&&module,i2=Ws&&Ws.exports===ym,tp=i2&&sc.process,a2=function(){try{var n=Ws&&Ws.require&&Ws.require("util").types;return n||tp&&tp.binding&&tp.binding("util")}catch{}}(),jo=a2;var gm=jo&&jo.isTypedArray,s2=gm?Yi(gm):mm,hc=s2;var l2=Object.prototype,c2=l2.hasOwnProperty;function u2(n,r){var e=Pt(n),t=!e&&$i(n),o=!e&&!t&&ai(n),i=!e&&!t&&!o&&hc(n),a=e||t||o||i,s=a?cm(n.length,String):[],l=s.length;for(var c in n)(r||c2.call(n,c))&&!(a&&(c=="length"||o&&(c=="offset"||c=="parent")||i&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Ui(c,l)))&&s.push(c);return s}var mc=u2;function d2(n,r){return function(e){return n(r(e))}}var yc=d2;var p2=yc(Object.keys,Object),xm=p2;var f2=Object.prototype,h2=f2.hasOwnProperty;function m2(n){if(!qi(n))return xm(n);var r=[];for(var e in Object(n))h2.call(n,e)&&e!="constructor"&&r.push(e);return r}var bm=m2;function y2(n){return fc(n)?mc(n):bm(n)}var Xi=y2;function g2(n){var r=[];if(n!=null)for(var e in Object(n))r.push(e);return r}var vm=g2;var x2=Object.prototype,b2=x2.hasOwnProperty;function v2(n){if(!Mr(n))return vm(n);var r=qi(n),e=[];for(var t in n)t=="constructor"&&(r||!b2.call(n,t))||e.push(t);return e}var Sm=v2;function S2(n){return fc(n)?mc(n,!0):Sm(n)}var Ki=S2;var w2=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,P2=/^\w*$/;function O2(n,r){if(Pt(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||ji(n)?!0:P2.test(n)||!w2.test(n)||r!=null&&n in Object(r)}var wm=O2;var C2=mr(Object,"create"),Fo=C2;function T2(){this.__data__=Fo?Fo(null):{},this.size=0}var Pm=T2;function A2(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}var Om=A2;var M2="__lodash_hash_undefined__",I2=Object.prototype,N2=I2.hasOwnProperty;function E2(n){var r=this.__data__;if(Fo){var e=r[n];return e===M2?void 0:e}return N2.call(r,n)?r[n]:void 0}var Cm=E2;var D2=Object.prototype,_2=D2.hasOwnProperty;function B2(n){var r=this.__data__;return Fo?r[n]!==void 0:_2.call(r,n)}var Tm=B2;var L2="__lodash_hash_undefined__";function R2(n,r){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Fo&&r===void 0?L2:r,this}var Am=R2;function Qi(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])}}Qi.prototype.clear=Pm;Qi.prototype.delete=Om;Qi.prototype.get=Cm;Qi.prototype.has=Tm;Qi.prototype.set=Am;var rp=Qi;function V2(){this.__data__=[],this.size=0}var Mm=V2;function G2(n,r){for(var e=n.length;e--;)if(ki(n[e][0],r))return e;return-1}var fn=G2;var z2=Array.prototype,j2=z2.splice;function F2(n){var r=this.__data__,e=fn(r,n);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():j2.call(r,e,1),--this.size,!0}var Im=F2;function U2(n){var r=this.__data__,e=fn(r,n);return e<0?void 0:r[e][1]}var Nm=U2;function k2(n){return fn(this.__data__,n)>-1}var Em=k2;function H2(n,r){var e=this.__data__,t=fn(e,n);return t<0?(++this.size,e.push([n,r])):e[t][1]=r,this}var Dm=H2;function Zi(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])}}Zi.prototype.clear=Mm;Zi.prototype.delete=Im;Zi.prototype.get=Nm;Zi.prototype.has=Em;Zi.prototype.set=Dm;var hn=Zi;var W2=mr(_t,"Map"),mn=W2;function q2(){this.size=0,this.__data__={hash:new rp,map:new(mn||hn),string:new rp}}var _m=q2;function $2(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}var Bm=$2;function Y2(n,r){var e=n.__data__;return Bm(r)?e[typeof r=="string"?"string":"hash"]:e.map}var yn=Y2;function X2(n){var r=yn(this,n).delete(n);return this.size-=r?1:0,r}var Lm=X2;function K2(n){return yn(this,n).get(n)}var Rm=K2;function Q2(n){return yn(this,n).has(n)}var Vm=Q2;function Z2(n,r){var e=yn(this,n),t=e.size;return e.set(n,r),this.size+=e.size==t?0:1,this}var Gm=Z2;function Ji(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])}}Ji.prototype.clear=_m;Ji.prototype.delete=Lm;Ji.prototype.get=Rm;Ji.prototype.has=Vm;Ji.prototype.set=Gm;var si=Ji;var J2="Expected a function";function op(n,r){if(typeof n!="function"||r!=null&&typeof r!="function")throw new TypeError(J2);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(op.Cache||si),e}op.Cache=si;var zm=op;var eP=500;function tP(n){var r=zm(n,function(t){return e.size===eP&&e.clear(),t}),e=r.cache;return r}var jm=tP;var rP=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,oP=/\\(\\)?/g,nP=jm(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(rP,function(e,t,o,i){r.push(o?i.replace(oP,"$1"):t||e)}),r}),Fm=nP;function iP(n){return n==null?"":qh(n)}var Um=iP;function aP(n,r){return Pt(n)?n:wm(n,r)?[n]:Fm(Um(n))}var Rr=aP;var sP=1/0;function lP(n){if(typeof n=="string"||ji(n))return n;var r=n+"";return r=="0"&&1/n==-sP?"-0":r}var gn=lP;function cP(n,r){r=Rr(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[gn(r[e++])];return e&&e==t?n:void 0}var gc=cP;function uP(n,r){for(var e=-1,t=r.length,o=n.length;++e<t;)n[o+e]=r[e];return n}var ea=uP;var km=Wt?Wt.isConcatSpreadable:void 0;function dP(n){return Pt(n)||$i(n)||!!(km&&n&&n[km])}var Hm=dP;function Wm(n,r,e,t,o){var i=-1,a=n.length;for(e||(e=Hm),o||(o=[]);++i<a;){var s=n[i];r>0&&e(s)?r>1?Wm(s,r-1,e,t,o):ea(o,s):t||(o[o.length]=s)}return o}var qm=Wm;function pP(n){var r=n==null?0:n.length;return r?qm(n,1):[]}var $m=pP;function fP(n){return im(lm(n,void 0,$m),n+"")}var xc=fP;var hP=yc(Object.getPrototypeOf,Object),ta=hP;var mP="[object Object]",yP=Function.prototype,gP=Object.prototype,Ym=yP.toString,xP=gP.hasOwnProperty,bP=Ym.call(Object);function vP(n){if(!Jt(n)||Ar(n)!=mP)return!1;var r=ta(n);if(r===null)return!0;var e=xP.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&Ym.call(e)==bP}var Xm=vP;function SP(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 Km=SP;function wP(){this.__data__=new hn,this.size=0}var Qm=wP;function PP(n){var r=this.__data__,e=r.delete(n);return this.size=r.size,e}var Zm=PP;function OP(n){return this.__data__.get(n)}var Jm=OP;function CP(n){return this.__data__.has(n)}var ey=CP;var TP=200;function AP(n,r){var e=this.__data__;if(e instanceof hn){var t=e.__data__;if(!mn||t.length<TP-1)return t.push([n,r]),this.size=++e.size,this;e=this.__data__=new si(t)}return e.set(n,r),this.size=e.size,this}var ty=AP;function ra(n){var r=this.__data__=new hn(n);this.size=r.size}ra.prototype.clear=Qm;ra.prototype.delete=Zm;ra.prototype.get=Jm;ra.prototype.has=ey;ra.prototype.set=ty;var oa=ra;function MP(n,r){return n&&mo(r,Xi(r),n)}var ry=MP;function IP(n,r){return n&&mo(r,Ki(r),n)}var oy=IP;var sy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ny=sy&&typeof module=="object"&&module&&!module.nodeType&&module,NP=ny&&ny.exports===sy,iy=NP?_t.Buffer:void 0,ay=iy?iy.allocUnsafe:void 0;function EP(n,r){if(r)return n.slice();var e=n.length,t=ay?ay(e):new n.constructor(e);return n.copy(t),t}var ly=EP;function DP(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 cy=DP;function _P(){return[]}var bc=_P;var BP=Object.prototype,LP=BP.propertyIsEnumerable,uy=Object.getOwnPropertySymbols,RP=uy?function(n){return n==null?[]:(n=Object(n),cy(uy(n),function(r){return LP.call(n,r)}))}:bc,na=RP;function VP(n,r){return mo(n,na(n),r)}var dy=VP;var GP=Object.getOwnPropertySymbols,zP=GP?function(n){for(var r=[];n;)ea(r,na(n)),n=ta(n);return r}:bc,vc=zP;function jP(n,r){return mo(n,vc(n),r)}var py=jP;function FP(n,r,e){var t=r(n);return Pt(n)?t:ea(t,e(n))}var Sc=FP;function UP(n){return Sc(n,Xi,na)}var qs=UP;function kP(n){return Sc(n,Ki,vc)}var wc=kP;var HP=mr(_t,"DataView"),Pc=HP;var WP=mr(_t,"Promise"),Oc=WP;var qP=mr(_t,"Set"),Cc=qP;var fy="[object Map]",$P="[object Object]",hy="[object Promise]",my="[object Set]",yy="[object WeakMap]",gy="[object DataView]",YP=zo(Pc),XP=zo(mn),KP=zo(Oc),QP=zo(Cc),ZP=zo(dc),li=Ar;(Pc&&li(new Pc(new ArrayBuffer(1)))!=gy||mn&&li(new mn)!=fy||Oc&&li(Oc.resolve())!=hy||Cc&&li(new Cc)!=my||dc&&li(new dc)!=yy)&&(li=function(n){var r=Ar(n),e=r==$P?n.constructor:void 0,t=e?zo(e):"";if(t)switch(t){case YP:return gy;case XP:return fy;case KP:return hy;case QP:return my;case ZP:return yy}return r});var Uo=li;var JP=Object.prototype,eO=JP.hasOwnProperty;function tO(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&eO.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var xy=tO;var rO=_t.Uint8Array,ia=rO;function oO(n){var r=new n.constructor(n.byteLength);return new ia(r).set(new ia(n)),r}var aa=oO;function nO(n,r){var e=r?aa(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var by=nO;var iO=/\w*$/;function aO(n){var r=new n.constructor(n.source,iO.exec(n));return r.lastIndex=n.lastIndex,r}var vy=aO;var Sy=Wt?Wt.prototype:void 0,wy=Sy?Sy.valueOf:void 0;function sO(n){return wy?Object(wy.call(n)):{}}var Py=sO;function lO(n,r){var e=r?aa(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var Oy=lO;var cO="[object Boolean]",uO="[object Date]",dO="[object Map]",pO="[object Number]",fO="[object RegExp]",hO="[object Set]",mO="[object String]",yO="[object Symbol]",gO="[object ArrayBuffer]",xO="[object DataView]",bO="[object Float32Array]",vO="[object Float64Array]",SO="[object Int8Array]",wO="[object Int16Array]",PO="[object Int32Array]",OO="[object Uint8Array]",CO="[object Uint8ClampedArray]",TO="[object Uint16Array]",AO="[object Uint32Array]";function MO(n,r,e){var t=n.constructor;switch(r){case gO:return aa(n);case cO:case uO:return new t(+n);case xO:return by(n,e);case bO:case vO:case SO:case wO:case PO:case OO:case CO:case TO:case AO:return Oy(n,e);case dO:return new t;case pO:case mO:return new t(n);case fO:return vy(n);case hO:return new t;case yO:return Py(n)}}var Cy=MO;function IO(n){return typeof n.constructor=="function"&&!qi(n)?Jh(ta(n)):{}}var Ty=IO;var NO="[object Map]";function EO(n){return Jt(n)&&Uo(n)==NO}var Ay=EO;var My=jo&&jo.isMap,DO=My?Yi(My):Ay,Iy=DO;var _O="[object Set]";function BO(n){return Jt(n)&&Uo(n)==_O}var Ny=BO;var Ey=jo&&jo.isSet,LO=Ey?Yi(Ey):Ny,Dy=LO;var RO=1,VO=2,GO=4,_y="[object Arguments]",zO="[object Array]",jO="[object Boolean]",FO="[object Date]",UO="[object Error]",By="[object Function]",kO="[object GeneratorFunction]",HO="[object Map]",WO="[object Number]",Ly="[object Object]",qO="[object RegExp]",$O="[object Set]",YO="[object String]",XO="[object Symbol]",KO="[object WeakMap]",QO="[object ArrayBuffer]",ZO="[object DataView]",JO="[object Float32Array]",eC="[object Float64Array]",tC="[object Int8Array]",rC="[object Int16Array]",oC="[object Int32Array]",nC="[object Uint8Array]",iC="[object Uint8ClampedArray]",aC="[object Uint16Array]",sC="[object Uint32Array]",ut={};ut[_y]=ut[zO]=ut[QO]=ut[ZO]=ut[jO]=ut[FO]=ut[JO]=ut[eC]=ut[tC]=ut[rC]=ut[oC]=ut[HO]=ut[WO]=ut[Ly]=ut[qO]=ut[$O]=ut[YO]=ut[XO]=ut[nC]=ut[iC]=ut[aC]=ut[sC]=!0;ut[UO]=ut[By]=ut[KO]=!1;function Tc(n,r,e,t,o,i){var a,s=r&RO,l=r&VO,c=r&GO;if(e&&(a=o?e(n,t,o,i):e(n)),a!==void 0)return a;if(!Mr(n))return n;var u=Pt(n);if(u){if(a=xy(n),!s)return tm(n,a)}else{var p=Uo(n),d=p==By||p==kO;if(ai(n))return ly(n,s);if(p==Ly||p==_y||d&&!o){if(a=l||d?{}:Ty(n),!s)return l?py(n,oy(a,n)):dy(n,ry(a,n))}else{if(!ut[p])return o?n:{};a=Cy(n,p,s)}}i||(i=new oa);var h=i.get(n);if(h)return h;i.set(n,a),Dy(n)?n.forEach(function(y){a.add(Tc(y,r,e,y,n,i))}):Iy(n)&&n.forEach(function(y,g){a.set(g,Tc(y,r,e,g,n,i))});var f=c?l?wc:qs:l?Ki:Xi,m=u?void 0:f(n);return am(m||n,function(y,g){m&&(g=y,y=n[g]),Hi(a,g,Tc(y,r,e,g,n,i))}),a}var Ac=Tc;var lC=1,cC=4;function uC(n){return Ac(n,lC|cC)}var ko=uC;var dC="__lodash_hash_undefined__";function pC(n){return this.__data__.set(n,dC),this}var Ry=pC;function fC(n){return this.__data__.has(n)}var Vy=fC;function Mc(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new si;++r<e;)this.add(n[r])}Mc.prototype.add=Mc.prototype.push=Ry;Mc.prototype.has=Vy;var Gy=Mc;function hC(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 zy=hC;function mC(n,r){return n.has(r)}var jy=mC;var yC=1,gC=2;function xC(n,r,e,t,o,i){var a=e&yC,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&gC?new Gy: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(!zy(r,function(g,v){if(!jy(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 Ic=xC;function bC(n){var r=-1,e=Array(n.size);return n.forEach(function(t,o){e[++r]=[o,t]}),e}var Fy=bC;function vC(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Uy=vC;var SC=1,wC=2,PC="[object Boolean]",OC="[object Date]",CC="[object Error]",TC="[object Map]",AC="[object Number]",MC="[object RegExp]",IC="[object Set]",NC="[object String]",EC="[object Symbol]",DC="[object ArrayBuffer]",_C="[object DataView]",ky=Wt?Wt.prototype:void 0,np=ky?ky.valueOf:void 0;function BC(n,r,e,t,o,i,a){switch(e){case _C:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case DC:return!(n.byteLength!=r.byteLength||!i(new ia(n),new ia(r)));case PC:case OC:case AC:return ki(+n,+r);case CC:return n.name==r.name&&n.message==r.message;case MC:case NC:return n==r+"";case TC:var s=Fy;case IC:var l=t&SC;if(s||(s=Uy),n.size!=r.size&&!l)return!1;var c=a.get(n);if(c)return c==r;t|=wC,a.set(n,r);var u=Ic(s(n),s(r),t,o,i,a);return a.delete(n),u;case EC:if(np)return np.call(n)==np.call(r)}return!1}var Hy=BC;var LC=1,RC=Object.prototype,VC=RC.hasOwnProperty;function GC(n,r,e,t,o,i){var a=e&LC,s=qs(n),l=s.length,c=qs(r),u=c.length;if(l!=u&&!a)return!1;for(var p=l;p--;){var d=s[p];if(!(a?d in r:VC.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 P=a?t(v,g,d,r,n,i):t(g,v,d,n,r,i);if(!(P===void 0?g===v||o(g,v,e,t,i):P)){m=!1;break}y||(y=d=="constructor")}if(m&&!y){var O=n.constructor,S=r.constructor;O!=S&&"constructor"in n&&"constructor"in r&&!(typeof O=="function"&&O instanceof O&&typeof S=="function"&&S instanceof S)&&(m=!1)}return i.delete(n),i.delete(r),m}var Wy=GC;var zC=1,qy="[object Arguments]",$y="[object Array]",Nc="[object Object]",jC=Object.prototype,Yy=jC.hasOwnProperty;function FC(n,r,e,t,o,i){var a=Pt(n),s=Pt(r),l=a?$y:Uo(n),c=s?$y:Uo(r);l=l==qy?Nc:l,c=c==qy?Nc:c;var u=l==Nc,p=c==Nc,d=l==c;if(d&&ai(n)){if(!ai(r))return!1;a=!0,u=!1}if(d&&!u)return i||(i=new oa),a||hc(n)?Ic(n,r,e,t,o,i):Hy(n,r,l,e,t,o,i);if(!(e&zC)){var h=u&&Yy.call(n,"__wrapped__"),f=p&&Yy.call(r,"__wrapped__");if(h||f){var m=h?n.value():n,y=f?r.value():r;return i||(i=new oa),o(m,y,e,t,i)}}return d?(i||(i=new oa),Wy(n,r,e,t,o,i)):!1}var Xy=FC;function Ky(n,r,e,t,o){return n===r?!0:n==null||r==null||!Jt(n)&&!Jt(r)?n!==n&&r!==r:Xy(n,r,e,t,Ky,o)}var Qy=Ky;function UC(n,r){return n!=null&&r in Object(n)}var Zy=UC;function kC(n,r,e){r=Rr(r,n);for(var t=-1,o=r.length,i=!1;++t<o;){var a=gn(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&&Wi(o)&&Ui(a,o)&&(Pt(n)||$i(n)))}var Jy=kC;function HC(n,r){return n!=null&&Jy(n,r,Zy)}var eg=HC;function WC(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}var tg=WC;function qC(n,r){return r.length<2?n:gc(n,Km(r,0,-1))}var rg=qC;function $C(n,r){return Qy(n,r)}var ip=$C;function YC(n,r){return r=Rr(r,n),n=rg(n,r),n==null||delete n[gn(tg(r))]}var og=YC;function XC(n){return Xm(n)?void 0:n}var ng=XC;var KC=1,QC=2,ZC=4,JC=xc(function(n,r){var e={};if(n==null)return e;var t=!1;r=lc(r,function(i){return i=Rr(i,n),t||(t=i.length>1),i}),mo(n,wc(n),e),t&&(e=Ac(e,KC|QC|ZC,ng));for(var o=r.length;o--;)og(e,r[o]);return e}),sa=JC;function eT(n,r,e,t){if(!Mr(n))return n;r=Rr(r,n);for(var o=-1,i=r.length,a=i-1,s=n;s!=null&&++o<i;){var l=gn(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=Mr(u)?u:Ui(r[o+1])?[]:{})}Hi(s,l,c),s=s[l]}return n}var ig=eT;function tT(n,r,e){for(var t=-1,o=r.length,i={};++t<o;){var a=r[t],s=gc(n,a);e(s,a)&&ig(i,Rr(a,n),s)}return i}var ag=tT;function rT(n,r){return ag(n,r,function(e,t){return eg(n,t)})}var sg=rT;var oT=xc(function(n,r){return n==null?{}:sg(n,r)}),Qr=oT;var he=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,he.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,he.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,he.prototype),delete i[t],{data:i,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function $s(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"&&$s(t)}return Object.freeze(n)}function lg(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 la=class extends Error{};function Ec(n){let r={...n};return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function yo(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 ca(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 cg(){return typeof process<"u"}function ug(n,r){for(let e of n)r(e.id,e.data)!==!0&&ug(e.children,r)}function dg(n,r){if(r(n.id,n.data)!==!0)for(let e of n.children)dg(e,r)}var st=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,st.prototype)}deepFreeze(){let e=0;for(;e<this.length;)$s(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&&dg(o,t)}}traverse(e){ug(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,st.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 la("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)=>lg(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 yo(0,o,o);{let a=i[0].fi;return yo(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 yo(l,l+o,o)}else return yo(a.fi,s.fi,o)}}};var ua;(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})(ua||(ua={}));var ve=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ve.prototype)}deepFreeze(){let e=0;for(;e<this.length;)$s(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 cg()||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 yo(0,t,t);{let i=o[0].fi;return yo(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 yo(s,s+t,t)}else return yo(i.fi,a.fi,t)}}};function da(n){return n&&typeof n=="object"&&n instanceof lt}var lt=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&&!da(t))return null;o+=1}t=t?Ec(t):new lt;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=Ec(l),delete t[r.path[o-1]])}else{let l=e[o-1];if(l){let c=Ec(l);c[r.path[o-1]]=t,t=c}else{let c=new lt;c[r.path[o-1]]=t,t=c}}o-=1}let a=Object.setPrototypeOf(t,lt.prototype),s={...r,props:i};return{data:a,actual:r,reverse:s}}},go;(t=>{function n(o,i){return Ys(o,i)??o}t.apply=n;function r(o,i){return sp(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=ct.zoomOnce(l,s[a]),l===void 0)return i;if(!da(l))return;a+=1}if(l===void 0)return i;if(!!da(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=ap([i],l);return c?(console.log(c),c):i}else return i}t.filterOp=e})(go||(go={}));function ap(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,a=Ys(o.data,r[i]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=ap(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 nT(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,a=Ys(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 Ys(n,r){if(!da(r))return r;if(n instanceof st){let e=ap(n,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof ve)return nT(n,r);if(Array.isArray(n)){let e=!1,t=n.map((o,i)=>{let a=Ys(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 lt)return sp(n,r);if(n&&typeof n=="object"){let e={},t=!1;for(let[o,i]of Object.entries(n)){let a=Ys(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 sp(n,r){if(n===void 0)return r;if(r===void 0)return n;if(!da(r))return r;if(!da(n))return go.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 lt;for(let o of e){let i=sp(n===void 0?void 0:n[o],r===void 0?void 0:r[o]);t[o]=i}return t}function pg(n,r){let e={cur:[],result:[],len:0};return n=Xs(n,r,e)??n,[n,e.result]}function Dc(n,r){return n===null?null:(n.cur[n.len]=r,n.len+=1,n)}function _c(n){n&&(n.len-=1)}function iT(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function fg(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,Dc(e,a));_c(e),t=t||l!==void 0,l===void 0&&(l=i.data);let c=fg(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 aT(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,Dc(e,a));return _c(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 st){let t=fg(n,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else{if(n instanceof ve)return aT(n,r,e);if(Array.isArray(n)){let t=!1,o=n.map((i,a)=>{let s=Xs(i,r,Dc(e,a));return _c(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"&&!ca(n)){let t={},o=!1;for(let[i,a]of Object.entries(n))if(i!=="name"&&i!=="variableId"){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,Dc(e,i));_c(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&&iT(e),t}else return}}var pa;(r=>{function n(e,t){let o=ct.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})(pa||(pa={}));var gt;(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 lt&&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 st||l instanceof ve||l instanceof he?d=l.runOp(c):d=ua.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 st){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 he){if(typeof g=="number")throw new Error("illegal arg");m=v.modifyById(g,m)}else if(v instanceof lt){let P={...v,[g]:m};m=Object.setPrototypeOf(P,lt.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 P=m;m=[...v],m[g]=P}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 st){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})(gt||(gt={}));var Ks;(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=>gt.subsumed(d,h))),...u]}l.compress=o;function i(c,u){return c.every(p=>u.every(d=>gt.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=ct.zoom(p,[...f.path,f.id]),g=gt.apply(p,{...f,type:2})):(m=ct.zoom(p,[...f.path,f.id,"value"]),g=gt.apply(p,f)),g!==null){p=g.data;let[v,P]=pg(p,{[f.id]:m});p=v;for(let O=0;O<P.length;O++){let S=P[O],T=S.pop();if(typeof T=="number"){let A=[T];for(let D=O+1;D<P.length;D++){let N=P[D],I=N[N.length-1];if(typeof I=="number"&&ct.equal(S,N.slice(0,N.length-1)))A.push(I),P.splice(D,1);else break}let x=ct.zoom(p,S);y=x.map((D,N)=>A.includes(N)?f.id:D),m=x,T=S.pop()}else{if(T==="alphaOverride"||T==="alpha"){m/=100;let A=m,x=ct.zoom(p,S.slice(0,S.length-2)),D=x.layers.map(N=>N.id===S[S.length-1]?{...N,data:{...N.data,[T]:A}}:N);Object.setPrototypeOf(D,Object.getPrototypeOf(x.layers)),x.layers=D}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=gt.apply(p,f);m!==null&&(d.push(m.actual),p=m.data,h.push(m.reverse))}}catch(m){if(m instanceof la)return null;throw m}return{data:p,actual:d,reverse:h.reverse()}}l.apply=s})(Ks||(Ks={}));var hg=Symbol(),sT=Symbol(),Lc=Symbol(),ci=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let i=t;for(;!(o instanceof Bc);){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[Lc];t&&t(),delete this._children[r]}}}},cp=class extends ci{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,ua.runOp(this._current,r),r.path)}},up=class extends ci{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,he.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},mg={get(n,r){if(r===Lc)return()=>{n._parent=null};if(r===hg)return n._current;if(r===sT)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=Rc(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]}}},lT={...mg,set(n,r,e){let t={type:0,props:{[r]:xt(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}},cT={...mg,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}},fa=class extends ci{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Lc]=()=>{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=Rc(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)}},ha=class extends ci{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Lc]=()=>{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=Rc(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 lp(n,r,e){if(n.length>0){let t=n[n.length-1];if(t.type===0&&r.type===0&&ct.equal(t.path,e)){Object.assign(t.props,r.props);return}}n.push({...r,path:e})}var Bc=class extends ci{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){lp(this.ts,e,r),lp(this.actual,t,r),lp(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Rc(n,r,e){return e instanceof st?new fa(n,r,e):e instanceof ve?new ha(n,r,e):e instanceof he?new Proxy(new up(n,r,e),cT):e!==null&&typeof e=="object"?ca(e)?e:new Proxy(new cp(n,r,e),lT):e}function dp(n){let r=new Bc(n);return[Rc(r,"",n),r]}function xn(n,r){let[e,t]=dp(n);return r(e),t.result()}function xt(n){return n instanceof fa||n instanceof ha?n._current:n!==null&&typeof n=="object"?n[hg]:n}var ct;(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 st||i instanceof fa)&&typeof a=="string")return i.data(a);if((i instanceof ve||i instanceof ha)&&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})(ct||(ct={}));function yg(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 je(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 Vc=class{},Qs=class extends Vc{constructor(e){super();this.id=e}},Zs=class extends Vc{constructor(e){super();this.data=e}};var fp;try{fp=new TextDecoder}catch{}var de,vn,z=0;var Og=[],hp=Og,mp=0,yr={},Ke,bn,Vr=0,xo=0,Ir,Ho,cr=[],et,gg={useRecords:!1,mapsAsObjects:!0},Js=class{},gp=new Js;gp.name="MessagePack 0xC1";var ma=!1,bo=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 Ig(()=>(zc(),this?this.unpack(r,e):bo.prototype.unpack.call(gg,r,e)));vn=e>-1?e:r.length,z=0,mp=0,xo=0,bn=null,hp=Og,Ir=null,de=r;try{et=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 bo){if(yr=this,this.structures)return Ke=this.structures,Gc();(!Ke||Ke.length>0)&&(Ke=[])}else yr=gg,(!Ke||Ke.length>0)&&(Ke=[]);return Gc()}unpackMultiple(r,e){let t,o=0;try{ma=!0;let i=r.length,a=this?this.unpack(r,i):Uc.unpack(r,i);if(e){for(e(a);z<i;)if(o=z,e(Gc())===!1)return}else{for(t=[a];z<i;)o=z,t.push(Gc());return t}}catch(i){throw i.lastPosition=o,i.values=t,i}finally{ma=!1,zc()}}_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 Gc(){try{if(!yr.trusted&&!ma){let r=Ke.sharedLength||0;r<Ke.length&&(Ke.length=r)}let n=Ot();if(z==vn)Ke.restoreStructures&&xg(),Ke=null,de=null,Ho&&(Ho=null);else if(z>vn){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}else if(!ma)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Ke.restoreStructures&&xg(),zc(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function xg(){for(let n in Ke.restoreStructures)Ke[n]=Ke.restoreStructures[n];Ke.restoreStructures=null}function Ot(){let n=de[z++];if(n<160)if(n<128){if(n<64)return n;{let r=Ke[n&63]||yr.getStructures&&Cg()[n&63];return r?(r.read||(r.read=xp(r,n&63)),r.read()):n}}else if(n<144)if(n-=128,yr.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[Ag()]=Ot();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(Ot(),Ot());return r}else{n-=144;let r=new Array(n);for(let e=0;e<n;e++)r[e]=Ot();return r}else if(n<192){let r=n-160;if(xo>=z)return bn.slice(z-Vr,(z+=r)-Vr);if(xo==0&&vn<140){let e=r<16?bp(r):Tg(r);if(e!=null)return e}return yp(r)}else{let r;switch(n){case 192:return null;case 193:return Ir?(r=Ot(),r>0?Ir[1].slice(Ir.position1,Ir.position1+=r):Ir[0].slice(Ir.position0,Ir.position0-=r)):gp;case 194:return!1;case 195:return!0;case 196:return pp(de[z++]);case 197:return r=et.getUint16(z),z+=2,pp(r);case 198:return r=et.getUint32(z),z+=4,pp(r);case 199:return ui(de[z++]);case 200:return r=et.getUint16(z),z+=2,ui(r);case 201:return r=et.getUint32(z),z+=4,ui(r);case 202:if(r=et.getFloat32(z),yr.useFloat32>2){let e=Fc[(de[z]&127)<<1|de[z+1]>>7];return z+=4,(e*r+(r>0?.5:-.5)>>0)/e}return z+=4,r;case 203:return r=et.getFloat64(z),z+=8,r;case 204:return de[z++];case 205:return r=et.getUint16(z),z+=2,r;case 206:return r=et.getUint32(z),z+=4,r;case 207:return yr.int64AsNumber?(r=et.getUint32(z)*4294967296,r+=et.getUint32(z+4)):r=et.getBigUint64(z),z+=8,r;case 208:return et.getInt8(z++);case 209:return r=et.getInt16(z),z+=2,r;case 210:return r=et.getInt32(z),z+=4,r;case 211:return yr.int64AsNumber?(r=et.getInt32(z)*4294967296,r+=et.getUint32(z+4)):r=et.getBigInt64(z),z+=8,r;case 212:if(r=de[z++],r==114)return Pg(de[z++]&63);{let e=cr[r];if(e)return e.read?(z++,e.read(Ot())):e.noBuffer?(z++,e()):e(de.subarray(z,++z));throw new Error("Unknown extension "+r)}case 213:return r=de[z],r==114?(z++,Pg(de[z++]&63,de[z++])):ui(2);case 214:return ui(4);case 215:return ui(8);case 216:return ui(16);case 217:return r=de[z++],xo>=z?bn.slice(z-Vr,(z+=r)-Vr):dT(r);case 218:return r=et.getUint16(z),z+=2,xo>=z?bn.slice(z-Vr,(z+=r)-Vr):pT(r);case 219:return r=et.getUint32(z),z+=4,xo>=z?bn.slice(z-Vr,(z+=r)-Vr):fT(r);case 220:return r=et.getUint16(z),z+=2,vg(r);case 221:return r=et.getUint32(z),z+=4,vg(r);case 222:return r=et.getUint16(z),z+=2,Sg(r);case 223:return r=et.getUint32(z),z+=4,Sg(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 uT=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function xp(n,r){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>uT.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(Ot);return n.highByte===0&&(n.read=bg(r,n.read)),o()}let t={};for(let o=0,i=n.length;o<i;o++){let a=n[o];t[a]=Ot()}return t}return e.count=0,n.highByte===0?bg(r,e):e}var bg=(n,r)=>function(){let e=de[z++];if(e===0)return r();let t=n<32?-(n+(e<<5)):n+(e<<5),o=Ke[t]||Cg()[t];if(!o)throw new Error("Record id is not defined for "+t);return o.read||(o.read=xp(o,n)),o.read()};function Cg(){let n=Ig(()=>(de=null,yr.getStructures()));return Ke=yr._mergeStructures(n,Ke)}var yp=jc,dT=jc,pT=jc,fT=jc;function jc(n){let r;if(n<16&&(r=bp(n)))return r;if(n>64&&fp)return fp.decode(de.subarray(z,z+=n));let e=z+n,t=[];for(r="";z<e;){let o=de[z++];if((o&128)===0)t.push(o);else if((o&224)===192){let i=de[z++]&63;t.push((o&31)<<6|i)}else if((o&240)===224){let i=de[z++]&63,a=de[z++]&63;t.push((o&31)<<12|i<<6|a)}else if((o&248)===240){let i=de[z++]&63,a=de[z++]&63,s=de[z++]&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+=qt.apply(String,t),t.length=0)}return t.length>0&&(r+=qt.apply(String,t)),r}function vg(n){let r=new Array(n);for(let e=0;e<n;e++)r[e]=Ot();return r}function Sg(n){if(yr.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[Ag()]=Ot();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(Ot(),Ot());return r}}var qt=String.fromCharCode;function Tg(n){let r=z,e=new Array(n);for(let t=0;t<n;t++){let o=de[z++];if((o&128)>0){z=r;return}e[t]=o}return qt.apply(String,e)}function bp(n){if(n<4)if(n<2){if(n===0)return"";{let r=de[z++];if((r&128)>1){z-=1;return}return qt(r)}}else{let r=de[z++],e=de[z++];if((r&128)>0||(e&128)>0){z-=2;return}if(n<3)return qt(r,e);let t=de[z++];if((t&128)>0){z-=3;return}return qt(r,e,t)}else{let r=de[z++],e=de[z++],t=de[z++],o=de[z++];if((r&128)>0||(e&128)>0||(t&128)>0||(o&128)>0){z-=4;return}if(n<6){if(n===4)return qt(r,e,t,o);{let i=de[z++];if((i&128)>0){z-=5;return}return qt(r,e,t,o,i)}}else if(n<8){let i=de[z++],a=de[z++];if((i&128)>0||(a&128)>0){z-=6;return}if(n<7)return qt(r,e,t,o,i,a);let s=de[z++];if((s&128)>0){z-=7;return}return qt(r,e,t,o,i,a,s)}else{let i=de[z++],a=de[z++],s=de[z++],l=de[z++];if((i&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){z-=8;return}if(n<10){if(n===8)return qt(r,e,t,o,i,a,s,l);{let c=de[z++];if((c&128)>0){z-=9;return}return qt(r,e,t,o,i,a,s,l,c)}}else if(n<12){let c=de[z++],u=de[z++];if((c&128)>0||(u&128)>0){z-=10;return}if(n<11)return qt(r,e,t,o,i,a,s,l,c,u);let p=de[z++];if((p&128)>0){z-=11;return}return qt(r,e,t,o,i,a,s,l,c,u,p)}else{let c=de[z++],u=de[z++],p=de[z++],d=de[z++];if((c&128)>0||(u&128)>0||(p&128)>0||(d&128)>0){z-=12;return}if(n<14){if(n===12)return qt(r,e,t,o,i,a,s,l,c,u,p,d);{let h=de[z++];if((h&128)>0){z-=13;return}return qt(r,e,t,o,i,a,s,l,c,u,p,d,h)}}else{let h=de[z++],f=de[z++];if((h&128)>0||(f&128)>0){z-=14;return}if(n<15)return qt(r,e,t,o,i,a,s,l,c,u,p,d,h,f);let m=de[z++];if((m&128)>0){z-=15;return}return qt(r,e,t,o,i,a,s,l,c,u,p,d,h,f,m)}}}}}function pp(n){return yr.copyBuffers?Uint8Array.prototype.slice.call(de,z,z+=n):de.subarray(z,z+=n)}function ui(n){let r=de[z++];if(cr[r])return cr[r](de.subarray(z,z+=n));throw new Error("Unknown extension type "+r)}var wg=new Array(4096);function Ag(){let n=de[z++];if(n>=160&&n<192){if(n=n-160,xo>=z)return bn.slice(z-Vr,(z+=n)-Vr);if(!(xo==0&&vn<180))return yp(n)}else return z--,Ot();let r=(n<<5^(n>1?et.getUint16(z):n>0?de[z]:0))&4095,e=wg[r],t=z,o=z+n-3,i,a=0;if(e&&e.bytes==n){for(;t<o;){if(i=et.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 z=t,e.string;o-=3,t=z}for(e=[],wg[r]=e,e.bytes=n;t<o;)i=et.getUint32(t),e.push(i),t+=4;for(o+=3;t<o;)i=de[t++],e.push(i);let s=n<16?bp(n):Tg(n);return s!=null?e.string=s:e.string=yp(n)}var Pg=(n,r)=>{var e=Ot();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=xp(e,t),e.read()},Mg=typeof self=="object"?self:global;cr[0]=()=>{};cr[0].noBuffer=!0;cr[101]=()=>{let n=Ot();return(Mg[n[0]]||Error)(n[1])};cr[105]=n=>{let r=et.getUint32(z-4);Ho||(Ho=new Map);let e=de[z],t;e>=144&&e<160||e==220||e==221?t=[]:t={};let o={target:t};Ho.set(r,o);let i=Ot();return o.used?Object.assign(t,i):(o.target=i,i)};cr[112]=n=>{let r=et.getUint32(z-4),e=Ho.get(r);return e.used=!0,e.target};cr[115]=()=>new Set(Ot());var vp=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");cr[116]=n=>{let r=n[0],e=vp[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)};cr[120]=()=>{let n=Ot();return new RegExp(n[0],n[1])};cr[98]=n=>{let r=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=z;z+=r-4,Ir=[Ot(),Ot()],Ir.position0=0,Ir.position1=0;let t=z;z=e;try{return Ot()}finally{z=t}};cr[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 Ig(n){let r=vn,e=z,t=mp,o=Vr,i=xo,a=bn,s=hp,l=Ho,c=Ir,u=new Uint8Array(de.slice(0,vn)),p=Ke,d=Ke.slice(0,Ke.length),h=yr,f=ma,m=n();return vn=r,z=e,mp=t,Vr=o,xo=i,bn=a,hp=s,Ho=l,Ir=c,de=u,ma=f,Ke=p,Ke.splice(0,Ke.length,...d),yr=h,et=new DataView(de.buffer,de.byteOffset,de.byteLength),m}function zc(){de=null,Ho=null,Ke=null}function Ng(n){n.unpack?cr[n.type]=n.unpack:cr[n.type]=n}var Fc=new Array(147);for(let n=0;n<256;n++)Fc[n]=+("1e"+Math.floor(45.15-n*.30103));var Uc=new bo({useRecords:!1}),hT=Uc.unpack,mT=Uc.unpackMultiple,yT=Uc.unpack,kc={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},gT=new Float32Array(1),UG=new Uint8Array(gT.buffer,0,4);var Hc;try{Hc=new TextEncoder}catch{}var Wc,wp,qc=typeof Buffer<"u",Sp=qc?Buffer.allocUnsafeSlow:Uint8Array,Bg=qc?Buffer:Uint8Array,Eg=qc?4294967296:2144337920,Y,Mt,k=0,vo,So=null,xT=/[\u0080-\uFFFF]/,el=Symbol("record-id"),di=class extends bo{constructor(r){super(r),this.offset=0;let e,t,o,i,a,s,l=0,c=Bg.prototype.utf8Write?function(x,D,N){return Y.utf8Write(x,D,N)}:Hc&&Hc.encodeInto?function(x,D){return Hc.encodeInto(x,Y.subarray(D)).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=[],P=0,O=0;this.pack=this.encode=function(x,D){if(Y||(Y=new Sp(8192),Mt=new DataView(Y.buffer,0,8192),k=0),vo=Y.length-10,vo-k<2048?(Y=new Sp(Y.length),Mt=new DataView(Y.buffer,0,Y.length),vo=Y.length-10,k=0):k=k+7&2147483640,t=k,s=u.structuredClone?new Map:null,u.bundleStrings?(So=["",""],Y[k++]=214,Y[k++]=98,So.position=k-t,k+=4):So=null,o=u.structures,o){o.uninitialized&&(o=u._mergeStructures(u.getStructures()));let N=o.sharedLength||0;if(N>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 I=0;I<N;I++){let E=o[I];if(!E)continue;let _,B=o.transitions;for(let V=0,U=E.length;V<U;V++){let R=E[V];_=B[R],_||(_=B[R]=Object.create(null)),B=_}B[el]=I+64}l=N}p||(o.nextId=N+64)}i&&(i=!1),a=o||[];try{if(S(x),So){Mt.setUint32(So.position+t,k-So.position-t);let N=So;So=null,S(N[0]),S(N[1])}if(u.offset=k,s&&s.idsToInsert){k+=s.idsToInsert.length*6,k>vo&&A(k),u.offset=k;let N=vT(Y.subarray(t,k),s.idsToInsert);return s=null,N}return D&Rg?(Y.start=t,Y.end=k,Y):Y.subarray(t,k)}finally{if(o){if(O<10&&O++,P>1e4)o.transitions=null,O=0,P=0,v.length>0&&(v=[]);else if(v.length>0&&!p){for(let N=0,I=v.length;N<I;N++)v[N][el]=0;v=[]}if(i&&u.saveStructures){let N=o.sharedLength||h;o.length>N&&(o=o.slice(0,N));let I=Y.subarray(t,k);return u.saveStructures(o,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(x)):(l=N,I)}}D&AT&&(k=t)}};let S=x=>{k>vo&&(Y=A(k));var D=typeof x,N;if(D==="string"){let I=x.length;if(So&&I>=8&&I<4096){let B=xT.test(x);So[B?0:1]+=x,Y[k++]=193,S(B?-I:I);return}let E;I<32?E=1:I<256?E=2:I<65536?E=3:E=5;let _=I*3;if(k+_>vo&&(Y=A(k+_)),I<64||!c){let B,V,U,R=k+E;for(B=0;B<I;B++)V=x.charCodeAt(B),V<128?Y[R++]=V:V<2048?(Y[R++]=V>>6|192,Y[R++]=V&63|128):(V&64512)===55296&&((U=x.charCodeAt(B+1))&64512)===56320?(V=65536+((V&1023)<<10)+(U&1023),B++,Y[R++]=V>>18|240,Y[R++]=V>>12&63|128,Y[R++]=V>>6&63|128,Y[R++]=V&63|128):(Y[R++]=V>>12|224,Y[R++]=V>>6&63|128,Y[R++]=V&63|128);N=R-k-E}else N=c(x,k+E,_);N<32?Y[k++]=160|N:N<256?(E<2&&Y.copyWithin(k+2,k+1,k+1+N),Y[k++]=217,Y[k++]=N):N<65536?(E<3&&Y.copyWithin(k+3,k+2,k+2+N),Y[k++]=218,Y[k++]=N>>8,Y[k++]=N&255):(E<5&&Y.copyWithin(k+5,k+3,k+3+N),Y[k++]=219,Mt.setUint32(k,N),k+=4),k+=N}else if(D==="number")if(x>>>0===x)x<64?Y[k++]=x:x<256?(Y[k++]=204,Y[k++]=x):x<65536?(Y[k++]=205,Y[k++]=x>>8,Y[k++]=x&255):(Y[k++]=206,Mt.setUint32(k,x),k+=4);else if(x>>0===x)x>=-32?Y[k++]=256+x:x>=-128?(Y[k++]=208,Y[k++]=x+256):x>=-32768?(Y[k++]=209,Mt.setInt16(k,x),k+=2):(Y[k++]=210,Mt.setInt32(k,x),k+=4);else{let I;if((I=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){Y[k++]=202,Mt.setFloat32(k,x);let E;if(I<4||(E=x*Fc[(Y[k]&127)<<1|Y[k+1]>>7])>>0===E){k+=4;return}else k--}Y[k++]=203,Mt.setFloat64(k,x),k+=8}else if(D==="object")if(!x)Y[k++]=192;else{if(s){let E=s.get(x);if(E){if(!E.id){let _=s.idsToInsert||(s.idsToInsert=[]);E.id=_.push(E)}Y[k++]=214,Y[k++]=112,Mt.setUint32(k,E.id),k+=4;return}else s.set(x,{offset:k-t})}let I=x.constructor;if(I===Object)T(x,!0);else if(I===Array){N=x.length,N<16?Y[k++]=144|N:N<65536?(Y[k++]=220,Y[k++]=N>>8,Y[k++]=N&255):(Y[k++]=221,Mt.setUint32(k,N),k+=4);for(let E=0;E<N;E++)S(x[E])}else if(I===Map){N=x.size,N<16?Y[k++]=128|N:N<65536?(Y[k++]=222,Y[k++]=N>>8,Y[k++]=N&255):(Y[k++]=223,Mt.setUint32(k,N),k+=4);for(let[E,_]of x)S(E),S(_)}else{for(let E=0,_=Wc.length;E<_;E++){let B=wp[E];if(x instanceof B){let V=Wc[E];if(V.write){V.type&&(Y[k++]=212,Y[k++]=V.type,Y[k++]=0),S(V.write.call(this,x));return}let U=Y,R=Mt,W=k;Y=null;let j;try{j=V.pack.call(this,x,F=>(Y=U,U=null,k+=F,k>vo&&A(k),{target:Y,targetView:Mt,position:k-F}),S)}finally{U&&(Y=U,Mt=R,k=W,vo=Y.length-10)}j&&(j.length+k>vo&&A(j.length+k),k=bT(j,Y,k,V.type));return}}T(x,!x.hasOwnProperty)}}else if(D==="boolean")Y[k++]=x?195:194;else if(D==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))Y[k++]=211,Mt.setBigInt64(k,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)Y[k++]=207,Mt.setBigUint64(k,x);else if(this.largeBigIntToFloat)Y[k++]=203,Mt.setFloat64(k,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");k+=8}else if(D==="undefined")this.encodeUndefinedAsNil?Y[k++]=192:(Y[k++]=212,Y[k++]=0,Y[k++]=0);else if(D==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+D)},T=this.useRecords===!1?this.variableMapSize?x=>{let D=Object.keys(x),N=D.length;N<16?Y[k++]=128|N:N<65536?(Y[k++]=222,Y[k++]=N>>8,Y[k++]=N&255):(Y[k++]=223,Mt.setUint32(k,N),k+=4);let I;for(let E=0;E<N;E++)S(I=D[E]),S(x[I])}:(x,D)=>{Y[k++]=222;let N=k-t;k+=2;let I=0;for(let E in x)(D||x.hasOwnProperty(E))&&(S(E),S(x[E]),I++);Y[N+++t]=I>>8,Y[N+t]=I&255}:x=>{let D=Object.keys(x),N,I=a.transitions||(a.transitions=Object.create(null)),E=0;for(let B=0,V=D.length;B<V;B++){let U=D[B];N=I[U],N||(N=I[U]=Object.create(null),E++),I=N}let _=I[el];if(_)_>=96&&m?(Y[k++]=((_-=96)&31)+96,Y[k++]=_>>5):Y[k++]=_;else{_=a.nextId,_||(_=64),_<y&&this.shouldShareStructure&&!this.shouldShareStructure(D)?(_=a.nextOwnId,_<g||(_=y),a.nextOwnId=_+1):(_>=g&&(_=y),a.nextId=_+1);let B=D.highByte=_>=96&&m?_-96>>5:-1;I[el]=_,a[_-64]=D,_<y?(D.isShared=!0,a.sharedLength=_-63,i=!0,B>=0?(Y[k++]=(_&31)+96,Y[k++]=B):Y[k++]=_):(B>=0?(Y[k++]=213,Y[k++]=114,Y[k++]=(_&31)+96,Y[k++]=B):(Y[k++]=212,Y[k++]=114,Y[k++]=_),E&&(P+=O*E),v.length>=f&&(v.shift()[el]=0),v.push(I),S(D))}for(let B=0,V=D.length;B<V;B++)S(x[D[B]])},A=x=>{let D;if(x>16777216){if(x-t>Eg)throw new Error("Packed buffer would be larger than maximum buffer size");D=Math.min(Eg,Math.round(Math.max((x-t)*(x>67108864?1.25:2),4194304)/4096)*4096)}else D=(Math.max(x-t<<2,Y.length-1)>>12)+1<<12;let N=new Sp(D);return Mt=new DataView(N.buffer,0,D),Y.copy?Y.copy(N,0,t,x):N.set(Y.slice(t,x)),k-=t,t=0,vo=N.length-10,Y=N}}useBuffer(r){Y=r,Mt=new DataView(Y.buffer,Y.byteOffset,Y.byteLength),k=0}};wp=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Js];Wc=[{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?Dg(n,16,r):_g(qc?Buffer.from(n):new Uint8Array(n),r)}},{pack(n,r){let e=n.constructor;e!==Bg&&this.structuredClone?Dg(n,vp.indexOf(e.name),r):_g(n,r)}},{pack(n,r){let{target:e,position:t}=r(1);e[t]=193}}];function Dg(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 _g(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 bT(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 vT(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 Sn(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)");wp.unshift(n.Class),Wc.unshift(n)}Ng(n)}var Lg=new di({useRecords:!1}),ST=Lg.pack,wT=Lg.pack;var{NEVER:PT,ALWAYS:OT,DECIMAL_ROUND:CT,DECIMAL_FIT:TT}=kc,Rg=512,AT=1024;var Vg=new di({structuredClone:!0});Sn({Class:he.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,he.prototype),n}});Sn({Class:ve.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,ve.prototype),n}});Sn({Class:st.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,st.prototype),n}});Sn({Class:Qs.prototype.constructor,type:4,write(n){return n.id},read(n){return new Qs(n)}});Sn({Class:Zs.prototype.constructor,type:5,write(n){return n.data},read(n){return new Zs(n)}});Sn({Class:lt.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,lt.prototype),n}});function MT(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 Pp(n){if(ca(n))return n;if(Array.isArray(n))return n.map(Pp);if(typeof n=="object"&&n!==null){let r={};for(let e of Object.keys(n).sort())r[e]=Pp(n[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else return n}var $c;(t=>{function n(o){return Vg.pack(o)}t.serialize=n;function r(o){return Vg.unpack(o)}t.deserialize=r;function e(o){return MT(n(Pp(o))).toString()}t.checksum=e})($c||($c={}));var On="personal camera",Cn="a218fcc3-276b-49b9-b485-49037fd14f5f",kg=2960946,It=5526619;var ya;(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),P=h.dot(g,v)/h.dot(g,g),O=h.scalarMultiply(g,P);return h.add(f,O)}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})(ya||(ya={}));var wn;(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})(wn||(wn={}));var Gg;(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})(Gg||(Gg={}));var zg;(a=>{let n=180/Math.PI,r=Math.PI/180;function e(s){return typeof s=="number"?s*n:s}function t(s){return typeof s=="number"?s*r:s}function o(s){return[e(s[0]),e(s[1]),e(s[2])]}a.radToDeg=o;function i(s){return[t(s[0]),t(s[1]),t(s[2])]}a.degToRad=i})(zg||(zg={}));var Pn;(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})(Pn||(Pn={}));var Gt;(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})(Gt||(Gt={}));var _e;(c=>{c.white={...Gt.white,a:1},c.transparent={...Gt.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{...Gt.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 Gt.equals(u,p)&&u.a===p.a}c.equals=i;function a(u,p){return Gt.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})(_e||(_e={}));var Yc;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Yc||(Yc={}));var jg;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(jg||(jg={}));var Fg;(r=>r.defaultData={control1:[.5,0],control2:[.5,1]})(Fg||(Fg={}));var Ug;(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]))(Ug||(Ug={}));function Op(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 Zr;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(Zr||(Zr={}));var Tn;(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})(Tn||(Tn={}));var wo;(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(IT.forEach(a=>{Object.assign(i,{[a]:o[a]??t[a]})}),i.radial={...t.radial},o.radial){let a=t.radial,s=o.radial;NT.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;ET.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;DT.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;_T.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;BT.forEach(l=>{Object.assign(i.randomnessObject,{[l]:s[l]??a[l]})})}return i}e.merge=r})(wo||(wo={}));var Xc;(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})(Xc||(Xc={}));var IT=["count"],NT=["radius","start","end","position","scale","rotation"],ET=["position","scale","rotation"],DT=["count","size"],_T=["count","position","scale","rotation"],BT=["strength","scale","rotation","position","movement","seed","freqScale"];var Kc;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function r(t){return e.all.includes(t)}e.is=r})(Kc||(Kc={}));var Qc;(e=>{function n(t){return r(t)}e.defaultData=n;function r(t){if(t==="PointLight")return{type:t,color:_e.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(t==="SpotLight")return{type:t,color:_e.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:_e.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Qc||(Qc={}));var ga;(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",emitTimeDuration:1,...t.defaultCollisionData}))(ga||(ga={}));var An;(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]})(An||(An={}));var Cp;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function r(t,o){return t.castShadow===o.castShadow&&t.receiveShadow===o.receiveShadow}e.equals=r})(Cp||(Cp={}));var Tp;(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})(Tp||(Tp={}));var Zc;(r=>r.defaultData={...Tp.defaultData,...Cp.defaultData})(Zc||(Zc={}));var Hg;(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})(Hg||(Hg={}));var xa;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(xa||(xa={}));var Wg;(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})(Wg||(Wg={}));function $g(n){return n.type!=="displace"}var qg;(r=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}r.is=n})(qg||(qg={}));var Yg=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],Xg=["wrapping","image","video","name","minFilter","magFilter"],Bt;(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,magFilter:1006},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:xa.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...a,type:"color",color:Gt.fromHex(It)};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:{...Gt.fromHex(6710886),a:1},colorB:{...Gt.fromHex(6710886),a:1},colorC:{...Gt.fromHex(16777215),a:1},colorD:{...Gt.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:_e.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:_e.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:_e.fromHexAndA(0,1),contourColor:_e.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,magFilter:1006}};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:{...Gt.fromHex(0),a:1},colorB:{...Gt.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}}}})(Bt||(Bt={}));var $t;(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:Bt.defaultData("light",u),id:p}),h.push({fi:1,data:Bt.defaultData("color"),id:d}),{layers:h}}c.defaultTwoLayerData=i;function a(u){let p=Bt.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:{...Bt.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...Bt.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}c.defaultUIObjectMaterial=a;function s(u,p="phong",d="layer1",h="layer2"){let f=Bt.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:Bt.defaultData("light",p),id:h}),{layers:m}}c.defaultTwoLayerTextureData=s;function l(u,p="phong",d="layer1",h="layer2"){let f=Bt.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:Bt.defaultData("light",p),id:h}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})($t||($t={}));var ba;(r=>{function n(){return{points:new ve,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n})(ba||(ba={}));var va;(r=>{function n(){return{points:new ve,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}r.defaultData=n})(va||(va={}));var Ap={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Jc;(r=>{function n(e,t){let o={...e};return LT.forEach(i=>{Object.assign(o,{[i]:t[i]??e[i]})}),o}r.merge=n})(Jc||(Jc={}));var eu={shape:Ap,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},LT=["depth","offset","angle","twist","startScale","endScale"];var tl;(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"||t==="InputGeometry"}e.isParametricMesh=r})(tl||(tl={}));var tu;(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,Jc.merge(o.extrusion,t.extrusion))),o}r.merge=n})(tu||(tu={}));var Wo;(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:va.defaultData(),extrusion:eu};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:ba.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",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="InputGeometry")return{...r.defaultData("TextGeometry"),type:e,editable:!0};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})(Wo||(Wo={}));var ru;(r=>r.defaultData={enabled:!1,useBackgroundColor:!1,color:Gt.white,near:.1,far:2e3})(ru||(ru={}));var ou;(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,focusDistance:100,focalLength:20,bokehScale:5},noise:{...n,blendFunction:16}}})(ou||(ou={}));var Mp;(r=>r.defaultData={softShadowQuality:"low"})(Mp||(Mp={}));var Ip;(r=>r.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Ip||(Ip={}));var Np;(r=>r.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Np||(Np={}));var rl;(r=>r.defaultData={usePhysics:!1,gravity:-10})(rl||(rl={}));var Ep;(r=>r.defaultData={playCamera:On,gameControlObject:null})(Ep||(Ep={}));var nu;(r=>r.defaultData={backgroundColor:_e.fromHexAndA(kg,1),postprocessing:ou.defaultData,fog:ru.defaultData,globalPhysics:rl.defaultData,ambient:Ip.defaultData,ao:Np.defaultData,shadow:Mp.defaultData,publish:Ep.defaultData})(nu||(nu={}));var iu;(r=>r.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(iu||(iu={}));var Kg;(e=>{function n(t){return t==="Component"||t==="Instance"}e.isComponentRelated=n;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(Kg||(Kg={}));var Sa;(o=>{o.identity={...Yc.identity,hiddenMatrix:Pn.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 nc({position:wn.isEqual(i.position,a.position)?void 0:a.position,rotation:wn.isEqual(i.rotation,a.rotation)?void 0:a.rotation,scale:wn.isEqual(i.scale,a.scale)?null:a.scale,hiddenMatrix:Pn.isEqual(i.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=t})(Sa||(Sa={}));var Lt;(r=>r.defaultData={states:new ve,events:new ve,visible:!0,raycastLock:!1,physics:An.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Sa.identity,cloner:null})(Lt||(Lt={}));var au;(r=>r.defaultData={type:"Empty",...Lt.defaultData})(au||(au={}));var Qg;(r=>r.defaultData={type:"ParticleCollider",...iu.defaultData,...Lt.defaultData})(Qg||(Qg={}));var Zg;(r=>r.defaultData={type:"Component",...Lt.defaultData})(Zg||(Zg={}));var Jg;(r=>r.defaultData={type:"Particle",...Lt.defaultData,...ga.defaultData})(Jg||(Jg={}));var Mn;(r=>r.defaultData={type:"Mesh",...Lt.defaultData,...Zc.defaultData})(Mn||(Mn={}));var pi;(r=>r.defaultData={...Lt.defaultData,...Sa.identity,position:[0,0,Tn.DefaultTargetOffset],...Tn.defaultData})(pi||(pi={}));var su;(e=>{function n(t){return{...Lt.defaultData,...Qc.defaultData(t)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(su||(su={}));var wa;(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})(wa||(wa={}));var Po;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function t(a,s){return{...Lt.defaultData,...s,component:a,overrides:new lt,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=t;function o(a){let s=Sa.fromObject(a.data);return t(a.id,s)}i.fromComponentData=o})(Po||(Po={}));var qo;(e=>{e.defaultData={type:"Page",...Lt.defaultData,physics:{...An.defaultData,fusedBody:!1},...nu.defaultData,camera:pi.defaultData};function r(t){return t.uiScene!==void 0}e.isUIPage=r})(qo||(qo={}));var lu;(a=>(a.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Pn.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:An.defaultData,states:new ve,events:new ve,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Tn.defaultData},a.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"]},a.defaultMeshObject={name:"Rectangle",...Lt.defaultData,...Mn.defaultData,geometry:Wo.defaultData("RectangleGeometry"),material:$t.defaultTwoLayerData("phong","layer1","layer2")},a.defaultBooleanObject={name:"Boolean",...Lt.defaultData,...Mn.defaultData,geometry:Wo.defaultData("BooleanGeometry"),material:$t.defaultTwoLayerData("phong","layer1","layer2")},a.defaultTextObject={name:"Text",...Lt.defaultData,...Mn.defaultData,geometry:Wo.defaultData("TextGeometry"),material:$t.defaultTwoLayerData("phong","layer1","layer2")},a.defaultInputObject={name:"Input",...Lt.defaultData,...Mn.defaultData,geometry:Wo.defaultData("InputGeometry"),material:$t.defaultTwoLayerData("phong","layer1","layer2")}))(lu||(lu={}));var fi;(o=>{function n(i,a){let s={name:a};return i.type==="Mesh"?(s.geometry={},"material"in i&&(s.material={layers:new lt}),"materials"in i&&(s.materials=i.materials.map(l=>({layers:new lt})))):Zr.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=xn(s.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(a.material.layers)){let p=l.layers.data(c);p&&Bt.patch(p,u)}}).data),s.materials&&a.materials&&(s.materials=xn(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&&Bt.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(...Xc.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,Sa.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})}),Zr.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:tu.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=r(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:wo.merge(s.cloner,a.cloner)});else if(i.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:wo.merge(s.cloner,a.cloner)});else if(Kc.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=Gt.clone(l.color))}return s}o.patch=t})(fi||(fi={}));var Pa;(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})(Pa||(Pa={}));var Jr;(r=>r.defaultData={orbitControls:Pa.defaultData,playPage:Cn,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,imageQuality:70}},stopRaycast:!0,hdTransmission:!1})(Jr||(Jr={}));var Dp;(r=>r.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Dp||(Dp={}));var _p;(r=>r.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(_p||(_p={}));var $o;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Dp.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:_p.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))($o||($o={}));var ex;(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=Oa.getComponentData(t,s.component)?.data;l&&i(a,s,l.events)}else i(a,s,s.events)})}e.traverseModuleInstances=r})(ex||(ex={}));var Yo;(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:su.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(u=!0,p=[]){let d=[],h=lu.defaultMeshObject;u&&(d.push({...c.defaultLight}),d.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:h,children:[]})),d.push(...p);let f=new st;return f.push({fi:1,id:Cn,data:{...qo.defaultData,name:"Scene 1"},children:d}),f}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:Jr.defaultData,styles:$o.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new st,publish:Jr.defaultData,styles:$o.defaultData()}},c.emptyDataWithPage=function(u=!0){return{objects:e(u),publish:Jr.defaultData,styles:$o.defaultData()}},c.emptyData=function(){return{objects:new st,publish:{...Jr.defaultData},styles:$o.defaultData()}};function s(u){return{...c.defaultData,objects:Zt(u,st.prototype)}}c.withObjs=s;function l(u,p){return s([{id:u,data:p,children:[],fi:0}])}c.withObj=l})(Yo||(Yo={}));var Ca;(r=>r.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Ca||(Ca={}));var cu;(e=>(e.defaultData=t=>({url:t,name:"New Webhook",parametersSchemas:new ve}),e.defaultParameterValueByType=t=>t==="number"?0:t==="boolean"?!1:""))(cu||(cu={}));var tx;(r=>r.defaultData=(e,t="GET")=>({url:e,method:t,name:"New API",headers:new ve,queries:new ve,autoStart:!0}))(tx||(tx={}));var In;(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})(In||(In={}));var Bp;(r=>r.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(Bp||(Bp={}));var rx;(r=>r.all=[...Bp.all,"components"])(rx||(rx={}));var ox;(r=>{function n(){return{images:new he,videos:new he,colors:new he,audios:new he,particles:new he,fonts:new he,materials:new he,components:new he,variables:new he,userAPIs:new he,userWebhooks:new he}}r.defaultData=n})(ox||(ox={}));var eo;(r=>{function n(){return{images:new he,videos:new he,colors:new he,audios:new he,particles:new he,fonts:new he,materials:new he,components:new he,variables:new he,userAPIs:new he,userWebhooks:new he}}r.defaultData=n})(eo||(eo={}));var zr;(i=>{function n(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Zt(a,he.prototype)}i.defaultColors=n;function r(){return Zt({},he.prototype)}i.defaultImages=r;function e(){return{catelogs:new he,materials:new he,images:new he,videos:new he,colors:new he,audios:new he,particles:new he,fonts:new he,variables:new ve,userAPIs:new he,userWebhooks:new he,lib:eo.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})(zr||(zr={}));var ol=require("three");var uu;(r=>r.list=["idle","move","jump","run"])(uu||(uu={}));var du;(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:_e.fromHexAndA(3728051,1)}}))(du||(du={}));function nx(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={...Qr(xt(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={...xt(r),near:Math.max(r.near,0),far:Math.max(r.far,0)};Object.assign(r,e)}})}function Xo(n,r){Object.values(n.shared.materials).forEach(e=>r(e))}function Ko(n,r){n.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach((o,i)=>{o===void 0&&(t.materials[i]=$t.defaultData(),o=t.materials[i]),typeof o!="string"&&r(o)}):"material"in t?typeof t.material!="string"&&(t.material===void 0&&(t.material=$t.defaultData()),r(t.material)):t.type==="Mesh"&&(t.material===void 0&&(t.material=$t.defaultData()),r(t.material)),"overrides"in t&&Object.values(t.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&Object.getPrototypeOf(o.material)!==lt.prototype&&r(o.material)})})}function RT(n){Object.assign(n.scene.publish,{orbitControls:{...Pa.defaultData,...xt(n.scene.publish.orbitControls)}})}function VT(n){Object.assign(n.scene.publish.settings,{video:{...Jr.defaultData.settings.video,...xt(n.scene.publish.settings.video)}})}function GT(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((Yg.includes(o)||typeof i=="boolean")&&delete t[o],o==="texture")for(let[a,s]of Object.entries(i))(Xg.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 zT(n){n.scene.publish.withBackground=!0}function jT(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function FT(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 UT(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 kT(n){n.scene.objects.traverse((r,e)=>{let t=n.scene.objects.unproxy().parent(r);if(t){let o=xt(n.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=xt(e).booleanExclude!==!0)}})}function HT(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 WT(n){function r(t){Object.setPrototypeOf(t,lt.prototype),t.texture&&Object.setPrototypeOf(t.texture,lt.prototype)}function e(t){Object.setPrototypeOf(t,lt.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=xt(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=xt(l).layers;e(c),l.layers=c}})})}function ix(n){n.layers===void 0&&Object.assign(n,$t.defaultTwoLayerData("lambert"))}function Lp(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={...xt(r),colors:e,steps:t};Object.assign(r,o)}})}function qT(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function ax(n){n.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&Lp(t)}):"material"in e&&typeof e.material!="string"&&Lp(e.material)}),Object.values(n.shared.materials).forEach(r=>Lp(r))}function $T(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 YT(n){n.shared.audios=Zt({},he.prototype)}function XT(n){n.shared.videos=Zt({},he.prototype)}function KT(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 QT(n){Object.entries(xt(n.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.images[t]}),Object.entries(xt(n.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.audios[t]})}function ZT(n){n.scene.publish.settings.web.preload=!1}function sx(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 lx(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 JT(n){n.shared.fonts=Zt({},he.prototype)}function eA(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 tA(n){let r=[];n.scene.objects.traverse((e,t)=>{let o=t;if(o.type==="TextFrame"){let i=$t.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=eA(o.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let l={name:o.name,...Lt.defaultData,...Mn.defaultData,flatShading:!1,wireframe:!1,geometry:{...Wo.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:xt(o.states),events:xt(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},c=xt(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 rA(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:ol.MathUtils.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,Qr(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:ol.MathUtils.generateUUID(),data:c},{fi:1,id:ol.MathUtils.generateUUID(),data:d})};i.push({fi:l,id:s,data:h})}),delete o.targets)}})})}function oA(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={...Qr(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={...Qr(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:ol.MathUtils.generateUUID(),data:{type:o,actions:a}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function cx(n){let r=n.layers.find(e=>e.type==="light")?.data;if(r?.category==="basic"){let e=Bt.defaultData("light","phong"),t=r;Object.assign(t,e),t.visible=!1}}function ux(n){Xo(n,cx),Ko(n,cx)}function nA(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function iA(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 aA(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=$t.defaultTwoLayerData("phong"))})}function sA(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 lA(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 cA(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 uA(n){let{video:r}=n.scene.publish.settings;r.format==="gif"&&r.fps>48&&(r.fps=15)}function dA(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.resetYPosition=Math.abs(t.resetYPosition-e.position[1]))})})}function pA(n){let r=n.scene.environment.usePhysics;n.scene.objects.traverse((e,t)=>{r&&t.physics===null?t.collision=!1:t.collision="visibility"})}function fA(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.navmesh=du.defaultDataThirdPerson.navmesh)})})}function hA(n){n.scene.styles||(n.scene.styles=$o.defaultData())}function dx(n){n.layers.forEach(r=>{r.type==="light"&&r.category!=="toon"&&r.occlusion===void 0&&(r.occlusion=!0)})}function mA(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}),Ko(n,dx),Xo(n,dx)}function yA(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&Object.assign(t.gameActions,{run:new ve})})})}function gA(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.keyAssignments=[...t.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function px(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.bumpMapIntensity===void 0&&(r.bumpMapIntensity=5)})}function fx(n,r){if(r<1&&(Ko(n,nx),Xo(n,nx),n.schema=1),r<2&&(RT(n),n.schema=2),r<3&&(GT(n),n.schema=3),r<4&&(zT(n),n.schema=4),r<5&&(jT(n),n.schema=5),r<6&&(FT(n),n.schema=6),r<7&&(UT(n),n.schema=7),r<8&&(n.schema=8),r<9&&(ax(n),n.schema=9),r<10&&(qT(n),n.schema=10),r<11&&($T(n),n.schema=11),r<12&&(ax(n),n.schema=12),r<13&&(YT(n),n.schema=13),r<14&&(KT(n),n.schema=14),r<15&&(QT(n),n.schema=15),r<16&&(ZT(n),n.schema=16),r<17&&(Ko(n,sx),Xo(n,sx),n.schema=17),r<18&&(Ko(n,ix),Xo(n,ix),n.schema=18),r<19&&(VT(n),n.schema=19),r<20&&(JT(n),tA(n),n.schema=20),r<21&&(rA(n),oA(n),n.schema=21),r<22&&(ux(n),n.schema=22),r<23&&(nA(n),n.schema=23),r<24&&(iA(n),n.schema=24),(r<25||n.shared.videos===void 0)&&(XT(n),r<25&&(n.schema=25)),r<26&&(kT(n),n.schema=26),r<27&&(HT(n),n.schema=27),r<28&&(ux(n),n.schema=28),r<29&&(WT(n),n.schema=29),r<30&&(aA(n),n.schema=30),r<31&&(sA(n),n.schema=31),r<33&&(lA(n),n.schema=33),r<34&&(cA(n),n.schema=34),r<35&&(uA(n),n.schema=35),r<36&&(dA(n),n.schema=36),r<37&&(pA(n),n.schema=37),r<38&&(Ko(n,lx),Xo(n,lx),n.schema=38),r<39&&(fA(n),n.schema=39),r<40&&(hA(n),n.schema=40),r<41&&(mA(n),n.schema=41),r<42&&(yA(n),n.schema=42),r<43&&(gA(n),n.schema=43),r<99){Ko(n,px),Xo(n,px),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=On);let e=xt(n.scene.objects),t=n.scene.objects;n.scene.publish.playPage=Cn,t.insertBefore(null,null,[{id:Cn,data:{...qo.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:Qr(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:Qr(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...rl.defaultData,...Qr(n.scene.environment,"usePhysics","gravity")},camera:xt(n.scene.ownerCamera)??qo.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==Yo.TRASH_CAN_ID&&t.move(Cn,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,An.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),n.schema=99}}function hx(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.alphaOverride===void 0&&(r.alphaOverride=1)})}function xA(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 bA(n){Array.isArray(xt(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 mx(n){n.rotation=n.rotation.slice(0,3).map(r=>r*Ta)}function yx(n){mx(n),n.type==="Page"&&mx(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(xt(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 vA(n){n.shared.variables=Zt({},he.prototype)}function SA(n){let r=xt(n.shared.variables);n.shared.variables=Zt(Object.entries(r??{}).map(([e,t],o)=>({fi:o,id:e,data:t})),ve.prototype)}var Oo=115;function gx(n,r){r(n.data);for(let e of n.children)gx(e,r)}function wA(n){let r=n.schema??104;r!==Oo&&r<105&&(gx(n.asset,yx),n.schema=105)}function PA(n){n.shared.particles=Zt({},he.prototype),n.shared.lib&&(n.shared.lib.particles=eo.defaultData().particles)}function OA(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 CA(n){n.scene.objects.traverse((r,e)=>{e.type==="Page"&&(e.postprocessing.depthOfField.focusDistance=100,e.postprocessing.depthOfField.focalLength=20,e.postprocessing.depthOfField.bokehScale=5)})}function TA(n){n.scene.objects.traverse((r,e)=>{Array.isArray(xt(e.events))!==!1&&e.events?.forEach(t=>{let o=t.runMode;t.type==="MouseDown"||t.type==="MouseUp"||t.type==="KeyDown"||t.type==="KeyUp"||t.type==="Collision"||t.type==="Trigger"?t.actions?.forEach(i=>{i.type==="Transition"&&(i.runMode=o??"Repeat"),(i.type==="Animation"||i.type==="SwitchCamera")&&(i.runMode=o==="Toggle"?"Toggle":"Normal")}):t.type==="MouseHover"||t.type==="MousePress"||t.type==="KeyPress"?t.actions?.forEach(i=>{(i.type==="Transition"||i.type==="Animation"||i.type==="SwitchCamera")&&(i.runMode="Toggle")}):t.type==="GameControl"?(delete t.actions,Object.keys(t.gameActions).forEach(a=>{t.gameActions[a]?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),s.type==="Animation"&&(s.runMode="Normal")})})):t.type==="DragDrop"?(delete t.actions,t.dragDropActions?.drag?.forEach(i=>{(i.type==="Transition"||i.type==="Animation"||i.type==="SwitchCamera")&&(i.runMode="Toggle")}),t.dragDropActions?.drop?.forEach(i=>{(i.type==="Transition"||i.type==="Animation"||i.type==="SwitchCamera")&&(i.runMode="Toggle")})):t.type==="Resize"?(delete t.actions,t.breakpoints?.forEach(i=>{i.actions?.forEach(a=>{(a.type==="Transition"||a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Toggle")})})):t.type==="Start"?t.actions?.forEach(i=>{i.type==="Transition"&&(i.runMode="Once"),(i.type==="Animation"||i.type==="SwitchCamera")&&(i.runMode="Normal")}):t.type==="VariableChange"||t.type==="Scroll"?t.actions?.forEach(i=>{i.type==="Transition"&&(i.runMode="Repeat"),(i.type==="Animation"||i.type==="SwitchCamera")&&(i.runMode="Normal")}):t.type==="Conditional"&&(delete t.actions,t.inActions?.forEach(i=>{i.type==="Transition"&&(i.runMode="Repeat"),(i.type==="Animation"||i.type==="SwitchCamera")&&(i.runMode="Normal")}),t.outActions?.forEach(i=>{i.type==="Transition"&&(i.runMode="Repeat"),(i.type==="Animation"||i.type==="SwitchCamera")&&(i.runMode="Normal")}))})})}function AA(n){n.shared.userAPIs=Zt({},he.prototype),n.shared.userWebhooks=Zt({},he.prototype),n.shared.lib&&(n.shared.lib.userAPIs=eo.defaultData().userAPIs,n.shared.lib.userWebhooks=eo.defaultData().userWebhooks)}function pu(n){let r=n.schema??0;if(r!==Oo){console.warn("updating from ",r,"to ",Oo),fx(n,r),r<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Jr.defaultData.joystickSizeAndXYOffset),n.schema=100),r<101&&(Ko(n,hx),Xo(n,hx),n.schema=101),r<102&&(xA(n),n.schema=102),r<104&&(n.shared.catelogs=new he,n.shared.lib=eo.defaultData(),n.schema=104),r<105&&(vA(n),n.scene.objects.traverse((e,t)=>{yx(t)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))wA(e);r<106&&(SA(n),n.schema=106),r<107&&(n.shared.lib.variables=eo.defaultData().variables,n.schema=107),r<109&&(PA(n),n.schema=109),r<110&&(OA(n),n.schema=110),r<111&&(n.scene.objects.traverse((e,t)=>{bA(t)}),n.schema=111),r<112&&(CA(n),n.schema=112),r<113&&(TA(n),n.schema=113),r<114&&(n.scene.publish.settings.web.imageQuality===void 0&&(n.scene.publish.settings.web.imageQuality=70),n.schema=114),r<115&&(AA(n),n.schema=115)}}var Oa;(c=>{c.defaultData={schema:Oo,scene:Yo.defaultData,frames:new he().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ca.defaultData),shared:{...zr.emptyData(),colors:zr.defaultColors()}},c.emptyDataForImports=function(){let u=Yo.emptyDataWithPage();return{schema:Oo,scene:u,frames:new he().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ca.defaultData),shared:{...zr.emptyData(),colors:zr.defaultColors(),images:zr.defaultImages()}}},c.emptyData=function(){return{schema:Oo,scene:Yo.emptyDataWithPage(),frames:new he().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ca.defaultData),shared:zr.emptyData()}},c.clipboard2dData=function(){return{schema:Oo,scene:Yo.emptyData(),frames:new he,shared:zr.emptyData()}},c.collabHelper={...Ks,updateSchema(u){return(u.schema??0)<Oo?xn(u,pu):(u.schema??0)-Oo}};function i(u){let p=c.collabHelper.updateSchema(u);return typeof p=="number"?p===0?u:null:p.data}c.updateSchemaDirectly=i;function a(u){return{...u,shared:{...u.shared,lib:eo.defaultData()}}}c.withoutLib=a;function s(u,p){let d=u.scene.objects.get(p);if(d&&d.data.type==="Component")return d;{let h=u.shared.lib.components[p];if(h)return h.asset}}c.getComponentData=s;function l(u){let p=Object.values(u.shared.userAPIs);for(let d of p){let h=d.headers;for(let f of h)if(f.data.key.toLowerCase()==="authorization"&&f.data.value!=="")return!0}return!1}c.hasSensitiveData=l})(Oa||(Oa={}));var fu;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(fu||(fu={}));var xx;(r=>{function n(e){return!0}r.is=n})(xx||(xx={}));var hu;(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 nc({position:ya.isEqual(o.position,i.position)?void 0:i.position,rotation:o.rotation===i.rotation?void 0:i.rotation,scale:ya.isEqual(o.scale,i.scale)?void 0:i.scale,shear:o.shear&&i.shear&&ya.isEqual(o.shear,i.shear)?void 0:i.shear})}t.diff=e})(hu||(hu={}));var Rp;(r=>r.defaultData={horizontalConstraint:0,verticalConstraint:0})(Rp||(Rp={}));var bx;(r=>r.defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8})(bx||(bx={}));var mu;(r=>r.defaultData={opacity:1,fill:{color:_e.fromHexAndA(It,1),enabled:!0},stroke:{color:_e.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:_e.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:_e.from0to1([0,0,0,1]),enabled:!1,spread:0}})(mu||(mu={}));var hi;(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,hu.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})(hi||(hi={}));var nl;(r=>r.defaultData={...hu.defaultData,...Rp.defaultData,states:new ve,events:new ve,visible:!0,raycastLock:!1})(nl||(nl={}));var Aa;(r=>r.defaultData={...nl.defaultData,...mu.defaultData})(Aa||(Aa={}));var yu;(r=>r.defaultData={cornerRadius:[0,0,0,0]})(yu||(yu={}));var Vp;(r=>r.defaultData={...Aa.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(Vp||(Vp={}));var Ma;(r=>r.defaultData={...Aa.defaultData,...yu.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Ma||(Ma={}));var Gp;(r=>r.defaultData={...Aa.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"})(Gp||(Gp={}));var zp;(r=>r.defaultData={...Aa.defaultData,type:"path2d",path:"",name:"Path"})(zp||(zp={}));var vx;(r=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}r.is=n})(vx||(vx={}));var il;(r=>r.defaultData={...nl.defaultData,name:"Group",type:"group2d"})(il||(il={}));var jp;(r=>r.defaultData=()=>({...nl.defaultData,...yu.defaultData,...mu.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:_e.fromHexAndA(4737101,1),enabled:!0},stroke:{color:_e.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(jp||(jp={}));var Qo;(i=>{function n(a){switch(a){case"rectangle2d":return{...Ma.defaultData};case"ellipse2d":return{...Vp.defaultData};case"text2d":return{...Gp.defaultData};case"vector2d":return{...Ma.defaultData};case"path2d":return{...zp.defaultData};case"frame2d":return{...jp.defaultData()};case"group2d":return{...il.defaultData}}}i.defaultData=n;function r(a){return"width"in a&&"height"in a?[typeof a.width=="number"?a.width*.5:0,typeof a.height=="number"?a.height*.5:0]:[0,0]}i.getPivot=r;function e(a){return a.type==="rectangle2d"||a.type==="ellipse2d"||a.type==="text2d"||a.type==="frame2d"}i.isResizeable=e;function t(a){return a.type==="frame2d"&&a.autoLayout!==void 0}i.isAutoLayoutable=t;function o(a){return a.type==="rectangle2d"||a.type==="frame2d"}i.hasCorners=o})(Qo||(Qo={}));var gu;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new st},e.emptyData=function(){return{type:"scene2d",objects:new st}}))(gu||(gu={}));var Je=require("three"),Os=zi(wx());var MA=.5*(Math.sqrt(3)-1),al=(3-Math.sqrt(3))/6,IA=1/3,Co=1/6,MU=(Math.sqrt(5)-1)/4,IU=(5-Math.sqrt(5))/20,sl=n=>Math.floor(n)|0,Px=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]),Up=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 xu(n=Math.random){let r=Cx(n),e=new Float64Array(r).map(o=>Px[o%12*2]),t=new Float64Array(r).map(o=>Px[o%12*2+1]);return function(i,a){let s=0,l=0,c=0,u=(i+a)*MA,p=sl(i+u),d=sl(a+u),h=(p+d)*al,f=p-h,m=d-h,y=i-f,g=a-m,v,P;y>g?(v=1,P=0):(v=0,P=1);let O=y-v+al,S=g-P+al,T=y-1+2*al,A=g-1+2*al,x=p&255,D=d&255,N=.5-y*y-g*g;if(N>=0){let _=x+r[D],B=e[_],V=t[_];N*=N,s=N*N*(B*y+V*g)}let I=.5-O*O-S*S;if(I>=0){let _=x+v+r[D+P],B=e[_],V=t[_];I*=I,l=I*I*(B*O+V*S)}let E=.5-T*T-A*A;if(E>=0){let _=x+1+r[D+1],B=e[_],V=t[_];E*=E,c=E*E*(B*T+V*A)}return 70*(s+l+c)}}function Ox(n=Math.random){let r=Cx(n),e=new Float64Array(r).map(i=>Up[i%12*3]),t=new Float64Array(r).map(i=>Up[i%12*3+1]),o=new Float64Array(r).map(i=>Up[i%12*3+2]);return function(a,s,l){let c,u,p,d,h=(a+s+l)*IA,f=sl(a+h),m=sl(s+h),y=sl(l+h),g=(f+m+y)*Co,v=f-g,P=m-g,O=y-g,S=a-v,T=s-P,A=l-O,x,D,N,I,E,_;S>=T?T>=A?(x=1,D=0,N=0,I=1,E=1,_=0):S>=A?(x=1,D=0,N=0,I=1,E=0,_=1):(x=0,D=0,N=1,I=1,E=0,_=1):T<A?(x=0,D=0,N=1,I=0,E=1,_=1):S<A?(x=0,D=1,N=0,I=0,E=1,_=1):(x=0,D=1,N=0,I=1,E=1,_=0);let B=S-x+Co,V=T-D+Co,U=A-N+Co,R=S-I+2*Co,W=T-E+2*Co,j=A-_+2*Co,F=S-1+3*Co,H=T-1+3*Co,q=A-1+3*Co,re=f&255,ee=m&255,X=y&255,te=.6-S*S-T*T-A*A;if(te<0)c=0;else{let $=re+r[ee+r[X]];te*=te,c=te*te*(e[$]*S+t[$]*T+o[$]*A)}let K=.6-B*B-V*V-U*U;if(K<0)u=0;else{let $=re+x+r[ee+D+r[X+N]];K*=K,u=K*K*(e[$]*B+t[$]*V+o[$]*U)}let Z=.6-R*R-W*W-j*j;if(Z<0)p=0;else{let $=re+I+r[ee+E+r[X+_]];Z*=Z,p=Z*Z*(e[$]*R+t[$]*W+o[$]*j)}let Q=.6-F*F-H*H-q*q;if(Q<0)d=0;else{let $=re+1+r[ee+1+r[X+1]];Q*=Q,d=Q*Q*(e[$]*F+t[$]*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}var Tx=require("three"),to=new Tx.Triangle,bu=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;to.a.fromBufferAttribute(r,o),to.b.fromBufferAttribute(r,o+1),to.c.fromBufferAttribute(r,o+2),i*=to.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),to.a.fromBufferAttribute(this.positionAttribute,r*3),to.b.fromBufferAttribute(this.positionAttribute,r*3+1),to.c.fromBufferAttribute(this.positionAttribute,r*3+2),e.set(0,0,0).addScaledVector(to.a,o).addScaledVector(to.b,i).addScaledVector(to.c,1-(o+i)),to.getNormal(t),this}};var Nx=require("three");var Nr=require("three"),Ix=zi(Mx()),NA=new Nr.Matrix4,EA=new Nr.Matrix4,DA=new Nr.Matrix4,Ia;(r=>{function n(e){return e&&e.__isSPEObject}r.is=n})(Ia||(Ia={}));var Na=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new Nr.Matrix4;this.copyPreviousMatrix=!0;this.hiddenMatrix=new Nr.Matrix4;this.matrixWorldRigid=new Nr.Matrix4;this.shearScale=new Nr.Matrix4;this.shearScaleInv=new Nr.Matrix4}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Nr.Object3D&&(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)Ia.is(i)&&i.traverseObject(t,o+1)}traverseObject(t,o=0){if(t(this,o)!==!0)for(let a of this.children)Ia.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,Ix.SVD)(o),l=NA.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=EA.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=DA.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 Nr.Matrix4().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof Nr.Matrix4?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 kp=class extends Na(Nx.Object3D){},_A=n=>n.type==="Mesh",Zo=class extends kp{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 Zo(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 _A(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}};var Ka=require("three");var zu=require("three");var ar=require("three");var Ct=require("three"),mi=new Ct.Vector3,yi=new Ct.Vector3,Ea=new Ct.Matrix4,Dx=[new Ct.Vector3(-1,1,1),new Ct.Vector3(-1,-1,1),new Ct.Vector3(1,-1,1),new Ct.Vector3(1,1,1),new Ct.Vector3(-1,1,-1),new Ct.Vector3(-1,-1,-1),new Ct.Vector3(1,-1,-1),new Ct.Vector3(1,1,-1)],BA=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],LA=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Ex=(n,r,e)=>{n.updateEntityBoxSize(mi,yi),Ea.copy(r).multiply(n.matrixWorld),yi.x===0&&yi.y===0&&yi.z===0?e.push(new Ct.Vector3(mi.x,mi.y,mi.z).applyMatrix4(Ea)):Dx.forEach(t=>{e.push(t.clone().multiply(yi).add(mi).applyMatrix4(Ea))})},ll=class extends Ct.Box3{constructor(){super(...arguments);this.matrix=new Ct.Matrix4;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 Ct.Matrix4().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 Ct.Vector3);return}Ex(a,t,i)}}):Ex(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(Ea.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(yi).multiplyScalar(.5),this.getCenter(mi),Ea.copy(this.matrix).setPosition(mi),this.vertices=Dx.map(e=>e.clone().multiply(yi).applyMatrix4(Ea))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=BA.map(([e,t])=>new Ct.Line3(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new Ct.Vector3))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=LA.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var ro={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var Yt=require("three"),Wp=class extends Yt.CurvePath{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 qp=.001;function $p(n,r,e){return r.clone().sub(n).cross(r.clone().sub(e)).length()<=qp}function Hp(n,r){let e=new Yt.Vector3(...n.position),t=new Yt.Vector3(...n.controlNext.position),o=new Yt.Vector3(...r.controlPrevious.position),i=new Yt.Vector3(...r.position);return $p(e,t,i)&&$p(e,o,i)}function Su(n){let r=n.points.map(u=>new Yt.Vector3(...u.data.position)),e=[n.points[0]],t=new Yt.Vector3(...e[0].data.position);for(let u=0;u<n.points.length-1;u++)$p(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 Yt.Vector3(...p.position),h=new Yt.Vector3(...p.controlPrevious.position),f=new Yt.Vector3(...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,P=e[g].data,O=new Yt.Vector3(...v.position),S=new Yt.Vector3(...P.position),T=O.clone().sub(d).normalize(),A=S.clone().sub(d).normalize();Object.assign(m,{prevDir:T,nextDir:A});let x=Hp(v,p),D=Hp(p,P);if(!x||!D)s[u]={...m,removedLength:0};else{let N=T.clone().add(A).normalize(),I=N.clone().cross(T).length()/T.dot(N);s[u]={...m,tan:I,removedLength:p.roundness/I}}}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(!Hp(e[p].data,e[d].data))h.position.distanceTo(f.position)>qp&&(m=new Yt.CubicBezierCurve3(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)>qp&&(m=new Yt.CubicBezierCurve3(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,P=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(v,2))).add(g),O=y.clone().multiplyScalar(-m).add(P),S=d.distanceTo(O)/d.distanceTo(g),T=p.prevDir.clone().multiplyScalar(S*d.distanceTo(h)).add(d),A=T.clone().lerp(O,2),x=h.clone().lerp(T,4/3),D=f.clone().lerp(A,4/3);l[2*u]=new Yt.CubicBezierCurve3(h,x,D,f)}let c=new Wp;return l.forEach(u=>{u&&c.add(u)}),c}var Fe;(r=>{function n(e){return e&&e.__isEntity}r.is=n})(Fe||(Fe={}));var Da=n=>Fe.is(n),RA={type:"completeState",isfromEntity:!0},VA=["x","y","z"],Yp=new ar.Vector3,GA=new ar.Vector3().set(0,1,0),_a=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 ll;this._recursiveBBox=new ll;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(Fe.is(o))return o}entityChildrenCount(){let t=this.children.length;for(;t--;)if(Fe.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(Fe.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)fi.toOps(this.data,a.data).forEach(l=>{let c=pa.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=fi.patch(this.data,a),fi.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=>{Da(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(Fe.is(o[i]))return o[i];if(Fe.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&Fe.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)Da(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{Fe.is(o)&&t(o)})}traverseConcreteEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)Da(a)&&a.isConcreteEntity&&a.traverseEntity(t,o+1)}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)Da(a)&&a.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)Da(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=>Da(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*ar.MathUtils.RAD2DEG,this.rotation.y*ar.MathUtils.RAD2DEG,this.rotation.z*ar.MathUtils.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return sa(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&&(Yp.fromArray(this.getTransformValues("rotation",t,o)).multiplyScalar(ar.MathUtils.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??Pn.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)Fe.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{Fe.is(t)&&t.disposeRecursively()})}toState(t=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return sa(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=je(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=ct.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=ct.removeOverridden(t.path,t.props,u);l={...t,props:p}}}if(this.updateByPatchedOpBase(l,fi.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),je(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(go.apply(h.component.data,h.overrideData),i))}}else{let d=i.scene.findInstance([this.uuid,...u]);if(d){let h=ct.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=wa.resolve(o.overrides,u),d.updateByOp(t,gt.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 Po.rootOverrideProps)d in t.props&&(p===void 0&&(p={}),p[d]=t.props[d]);p&&(u={...t,props:p})}else for(let p of Po.rootOverrideProps)if(je(t.path,[p])){u=t;break}u!==void 0&&this.instances.forEach(p=>{if(p.isInstanceRoot){let d=go.filterOp(p.overrideData,u);d&&p.updateByOp(d,gt.applySimple(p.data,d),i,!0)}}),this.instances.forEach(p=>{if(!p.isInstanceRoot){let d=go.filterOp(p.overrideData,t);if(d){let h;s===p.data&&t===d?h=o:h=gt.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&&!Zr.is(t.props.type)&&ro.changeEntityProptotype(this,o,i);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){ro.changeEntityProptotype(this,o,i);for(let a of this.children)Fe.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),je(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),je(t.path,["cloner"])!==null){let a=gt.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=Su(c.geometry.path),p=(i+a)%1;i+a===1&&p===0&&(p=1);let d=u.curves.length?u.getPointAt(p):null;if(d===null)return;let h=this.parent?this.parent?.matrixWorld:new ar.Matrix4;l.updateMatrixWorld();let f=new ar.Matrix4().multiplyMatrices(h.clone().invert(),l.matrixWorld);d.applyMatrix4(f);let m={position:d.toArray(),rotation:c.rotation};if(s==="tangential"){let y=new ar.Matrix4().extractRotation(l.matrixWorld),g=u.getTangentAt(p).applyMatrix4(y).add(d),v=new ar.Matrix4().lookAt(d,g,GA),P=Yp.setFromEuler(new ar.Euler().setFromRotationMatrix(v)).multiplyScalar(ar.MathUtils.RAD2DEG);m={...m,rotation:P.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 ro.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 ro.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"})}};var En=require("three");var it=require("three"),Bx=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=it.MathUtils.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 it.BufferGeometry,f.setAttribute("position",new it.Float32BufferAttribute([],3))):p||h?f=new cl(c,u,t,o,i,a,s,l*Math.PI/180,p,p,d,h):f=new it.CylinderGeometry(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 Nn(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function _x(n){return new it.Vector2(n.y,-n.x)}var cl=class extends it.BufferGeometry{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,P=t/2,O=new it.Vector3,S=new it.Vector3;h&&r==0&&(r=c),h&&e==0&&(e=u);let T=new it.Vector2(r,P),A=new it.Vector2(e,-P),x=null,D=null,N=null,I=null,E=T.clone().sub(A),_=0,B=0,V=0;d>0&&(_=Math.min(r,e)*(1-d),B=r-_,V=e-_);let U=T.clone();U.x-=_;let R=Math.PI-E.angle(),W=E.angle(),j=Math.tan(W/2),F=Math.tan(R/2),H=j+F,q=d?H:F,re=d?H:j;if(c=Math.min(c,(r-B)/q,E.length()/H),u=Math.min(u,(e-V)/re,E.length()/H),c>0){let Q=c/j;x=T.clone().sub(new it.Vector2(Q,c)),d&&(N=x.clone(),N.x-=_-H*c),T.sub(E.clone().setLength(Q))}if(u>0){let Q=u/F;D=A.clone().sub(new it.Vector2(Q,-u)),A.add(E.clone().setLength(Q)),d&&(I=D.clone(),I.x-=_-H*u,U.sub(E.clone().setLength(Q)))}E=T.clone().sub(A);let ee=E.length()<.5,X=[];for(let Q=0;Q<=o;Q++){let $=[],ue=Q/o,le=ue*l+s,ne=new it.Vector2(Math.sin(le),Math.cos(le));I&&D?(te($,ue,ne,R,u,I,-1,!0),te($,ue,ne,W,u,D,-1,!1)):D?(K($,ne,D.x,0,-1),te($,ue,ne,W,u,D,-1,!1)):a||K($,ne,e,V,-1);let ce=_x(E).normalize();if(Nn(ce,ne,O),!ee)for(let ae=0;ae<=i;ae++){let ye=ae/i,fe=E.clone().multiplyScalar(ye).add(A);Nn(fe,ne,S),m.push(S.x,S.y,S.z),y.push(O.x,O.y,O.z),g.push(ue,.5+S.y/t),$.push(v++)}if(N&&x?(te($,ue,ne,R,c,x,1,!1),te($,ue,ne,W,c,N,1,!0)):x?(te($,ue,ne,R,c,x,1,!1),K($,ne,x.x,0,1)):a||K($,ne,r,B,1),d&&!ee){let ae=_x(E).multiplyScalar(-1).normalize();Nn(ae,ne,O);for(let ye=0;ye<=i;ye++){let fe=ye/i,me=E.clone().multiplyScalar(-fe).add(U);Nn(me,ne,S),m.push(S.x,S.y,S.z),y.push(O.x,O.y,O.z),g.push(ue,.5+S.y/t),$.push(v++)}}d&&!a&&$.push($[0]),X.push($)}for(let Q=0;Q<X.length-1;Q++)for(let $=0;$<X[0].length-1;$++){if(a&&d&&$==i)continue;let ue=X[Q][$],le=X[Q+1][$],ne=X[Q+1][$+1],ce=X[Q][$+1],ae=m[ne*3+0],ye=m[ne*3+2];f.push(ue,le,ce),(ae!=0||ye!=0)&&f.push(le,ne,ce)}l<Math.PI*2&&(Z(-1,X[0],s),Z(1,X[X.length-1],s+l)),this.setIndex(f),this.setAttribute("position",new it.Float32BufferAttribute(m,3)),this.setAttribute("normal",new it.Float32BufferAttribute(y,3)),this.setAttribute("uv",new it.Float32BufferAttribute(g,2));function te(Q,$,ue,le,ne,ce,ae,ye){for(let fe=0;fe<p+1;fe++){let me=fe/p,be=ae<0?me:1-me;ye&&(be-=1),be*=le;let ge=new it.Vector2(Math.sin(be),Math.cos(be)*ae),C=ge.clone().multiplyScalar(ne).add(ce);Nn(C,ue,S),m.push(S.x,S.y,S.z),Nn(ge,ue,O),y.push(O.x,O.y,O.z),g.push($,.5+S.y/t),Q.push(v++)}}function K(Q,$,ue,le,ne){let ce=new it.Vector3,ae=new it.Vector2,ye=[ue,le];ne<0&&ye.reverse();for(let fe of ye)ae.set(fe,P*ne),Nn(ae,$,ce),m.push(ce.x,ce.y,ce.z),y.push(0,ne,0),g.push(.5,.5),Q.push(v++)}function Z(Q,$,ue){let le=new it.Vector2(Math.sin(ue),Math.cos(ue)),ne=new it.Vector2(-Math.cos(ue),Math.sin(ue)),ce=new it.Vector3,ae=Q<0?(me,be,ge)=>f.push(me,be,ge):(me,be,ge)=>f.push(me,ge,be),ye=new it.Vector2((r+e+B+V)/4,0);Nn(ye,le,ce),m.push(ce.x,ce.y,ce.z),y.push(ne.x,0,ne.y),g.push(.5,.5);let fe=v++;for(let me of $){let be=m.slice(me*3,me*3+3);m.push(...be),y.push(ne.x,0,ne.y);let ge=g.slice(me*2,me*2+2);g.push(...ge),v++}for(let me=fe+1;me<v-1;me++)ae(fe,me,me+1);ae(fe,v-1,fe+1)}}};var Lx=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=En.MathUtils.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 En.BufferGeometry,d.setAttribute("position",new En.Float32BufferAttribute([],3))):c>0||u>0||l<360?d=new cl(0,r/2,t,o,i,a,s,l*Math.PI/180,c,u,p,0,!0):d=new En.ConeGeometry(r/2,t,o,i,a),d.scale(1,1,e/r),Object.assign(d,{userData:{...n,type:"ConeGeometry"}})}};var gr=require("three"),Rx=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 gr.BoxGeometry(r,e,t,o,i,a):c=new Kp(r,e,t,o,i,a,s,l),Object.assign(c,{userData:{...n,type:"CubeGeometry"}})}},Xp=Math.PI/2,Kp=class extends gr.BufferGeometry{constructor(r=1,e=1,t=1,o=1,i=1,a=1,s=0,l=4){super(),this.type="BoxGeometry",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 c=[],u=[],p=[],d=[],h=0;f("z","y","x",-1,-1,t,e,r,a,i),f("z","y","x",1,-1,t,e,-r,a,i),f("x","z","y",1,1,r,t,e,o,a),f("x","z","y",1,-1,r,t,-e,o,a),f("x","y","z",1,-1,r,e,t,o,i),f("x","y","z",-1,-1,r,e,-t,o,i),s>0&&(m("z","y","x",-1,-1,1,t,e,r,a),m("z","y","x",1,-1,-1,t,e,r,a),m("z","y","x",-1,1,-1,t,e,r,a),m("z","y","x",1,1,1,t,e,r,a),m("x","y","z",-1,-1,-1,r,e,t,o),m("x","y","z",1,-1,1,r,e,t,o),m("x","y","z",-1,1,1,r,e,t,o),m("x","y","z",1,1,-1,r,e,t,o),m("y","x","z",-1,-1,1,e,r,t,i),m("y","x","z",1,-1,-1,e,r,t,i),m("y","x","z",1,1,1,e,r,t,i),m("y","x","z",-1,1,-1,e,r,t,i),y(1,1,1),y(-1,1,1),y(1,-1,1),y(-1,-1,1),y(1,1,-1),y(-1,1,-1),y(1,-1,-1),y(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new gr.Float32BufferAttribute(u,3)),this.setAttribute("normal",new gr.Float32BufferAttribute(p,3)),this.setAttribute("uv",new gr.Float32BufferAttribute(d,2));function f(g,v,P,O,S,T,A,x,D,N){let I=(T-2*s)/D,E=(A-2*s)/N,_=T/2-s,B=A/2-s,V=x/2,U=D+1,R=N+1,W=0,j=new gr.Vector3;for(let F=0;F<R;F++){let H=F*E-B;for(let q=0;q<U;q++){let re=q*I-_;j[g]=re*O,j[v]=H*S,j[P]=V,u.push(j.x,j.y,j.z),j[g]=0,j[v]=0,j[P]=x>0?1:-1,p.push(j.x,j.y,j.z),d.push(q/D),d.push(1-F/N),W+=1}}for(let F=0;F<N;F++)for(let H=0;H<D;H++){let q=h+H+U*F,re=h+H+U*(F+1),ee=h+(H+1)+U*(F+1),X=h+(H+1)+U*F;c.push(q,re,X),c.push(re,ee,X)}h+=W}function m(g,v,P,O,S,T,A,x,D,N){let I=(A-2*s)/N,E=A/2-s,_=x/2-s,B=D/2,V=N+1,U=0,R=new gr.Vector3,W=new gr.Vector3;for(let j=0;j<l+1;j++){let F=j/l*Xp,H=Math.sin(F)*s,q=(1-Math.cos(F))*s,re=Math.sin(F),ee=Math.cos(F);R[v]=(_+H)*S,R[P]=(B-q)*T,W[g]=0,W[v]=re*Math.sign(R[v]),W[P]=ee*Math.sign(R[P]);for(let X=0;X<V;X++){let te=X*I-E;R[g]=te*O,u.push(R.x,R.y,R.z),p.push(W.x,W.y,W.z),d.push(X/N),d.push(0),U+=1}}for(let j=0;j<l;j++)for(let F=0;F<N;F++){let H=h+F+V*j,q=h+F+V*(j+1),re=h+(F+1)+V*(j+1),ee=h+(F+1)+V*j;c.push(H,q,ee),c.push(q,re,ee)}h+=U}function y(g,v,P){let O=new gr.Vector3,S=new gr.Vector3(r/2,e/2,t/2);S.subScalar(s);let T=[],A=g*v*P>0?(D,N,I)=>c.push(D,N,I):(D,N,I)=>c.push(D,I,N);for(let D=0;D<=l;D++){let N=[],I=Xp*(1-D/l),E=Math.cos(I),_=Math.sin(I),B=0;for(let V=0;V<=D;V++){let U=Math.cos(B),R=Math.sin(B);O.x=E*U,O.y=_,O.z=E*R;let W=S.clone().addScaledVector(O,s);u.push(g*W.x,v*W.y,P*W.z),p.push(g*O.x,v*O.y,P*O.z),d.push(0,0),N.push(h++),B+=Xp/D}T.push(N)}let x=T.length-1;for(let D=0;D<x;D++){let N=T[D],I=T[D+1],E=N.length-1;A(N[0],I[1],I[0]);for(let _=1;_<=E;_++)A(N[_-1],N[_],I[_]),A(N[_],I[_+1],I[_])}}}};var Tt=require("three"),Dn=class extends Tt.BufferGeometry{constructor(r=[],e=[],t="",o=1,i=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],c=[];u(),p(),this.setAttribute("position",new Tt.Float32BufferAttribute(s,3)),this.setAttribute("normal",new Tt.Float32BufferAttribute(c,3)),this.setAttribute("uv",new Tt.Float32BufferAttribute(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 Tt.Vector3,m=f.clone(),y=new Tt.Triangle,g=i*o,v=o-g,P=a+1,O=new Tt.Vector3,S=(j,F)=>O.subVectors(j,F).normalize(),T=(j,F)=>Array(j).fill(void 0).map(F),A=T(r.length/3,(j,F)=>new Tt.Vector3().fromArray(r,F*3).setLength(o)),x=[],D=1e6;for(let j=0;j<A.length;j++){let F=A[j],H=[],q,re,ee,X=1e10,te=-1;for(;(te=e.indexOf(j,te+1))!=-1;){let $=te-te%3;q=e[$+(te+1)%3],re=e[$+(te+2)%3],ee=F.distanceToSquared(A[q]),X=Math.min(X,ee),H.push([q,re,ee])}X+=1e-6;let K=[],Z=0,Q=H.length;for(let $=0;$<Q;$++){[q,re,ee]=H[Z];let ue=x[q]?.includes(j)==!0;ee<=X&&K.push(q+ +ue*D),Z=H.findIndex(le=>le[0]==re)}x.push(K)}let N=[];{let j=0,F=0,H,q,re=h==3;for(let ee=0;ee<=a;ee++){H=ee*(ee+1)/2,q=(ee+1)*(ee+2)/2;for(let X=0;X<a-ee;X++)[j,F]=[H+X+ee+2,q+X+ee+3],N.push(H,q,...re?[F,H]:[j,q],F,j),[H,q]=[j,F];N.push(H,q,H+a+2)}}let I=f.clone(),E=f.clone(),_=f.clone(),B=f.clone(),V=f.clone(),U=[],R=T(A.length,()=>T(h,()=>f.clone()));for(let j=0;j<A.length;j++){f.copy(A[j]).normalize(),I.copy(f).multiplyScalar(v);let F=x[j];for(let K=0;K<F.length;K++){let Z=F[K],Q=F[(K+1)%h];y.setFromPointsAndIndices(A,j,Z%D,Q%D),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(I,R[j][K])}let H=[],q=[],re=[],ee=new Tt.Vector3;a==0&&[...R[j]].reduce((K,Z)=>K.add(Z),ee).multiplyScalar(1/h);for(let K=0;K<h;K++){let Z=[],Q=(K-1+h)%h,$=R[j][Q],ue=R[j][K];f.copy($).sub(I),m.copy(ue).sub(I);let le=I.angleTo(f),ne=f.angleTo(m),ce=Math.cos(le)*g;a==0?E.copy(ee):E.copy(I).setLength(v+ce),q.push(ce);let ae=[E,$,ue];for(let ye=0;ye<2;ye++){let fe=ae[ye],me=ae[ye+1];B.subVectors(fe,I),V.subVectors(me,I),_.crossVectors(B,V).normalize();for(let be=0;be<P;be++){let ge=[le,ne][ye]*be/P;f.copy(B).applyAxisAngle(_,ge).add(I),H.push(f.clone()),ye&&(S(f,I),Z.push([be==0?fe:f.clone(),O.clone()]))}ye&&(S(me,I),Z.push([me,O.clone()]))}re.push(Z)}U.push(re);let X=2*P,te=2;for(let K=0;K<h;K++){let Z=X*K,Q=X*((K+1)%h),$=[H[Z]];for(let le=1;le<P;le++){B=H[Z+le],V=H[Q+le],$.push(B);for(let ne=1,ce=le-te+1;ne<=ce;ne++)f.lerpVectors(B,V,ne/(ce+1)),f.sub(I).setLength(q[K]).add(I),$.push(f.clone());$.push(V)}for(let le=0;le<P;le++)$.push(H[le+P+Z]);$.push(H[Q+P]);let ue=N.map(le=>$[le]);s.push(...ue.map(le=>[le.x,le.y,le.z]).flat()),c.push(...ue.map(le=>(S(le,I),[O.x,O.y,O.z])).flat())}}let W=[];for(let j=0;j<x.length;j++)for(let F=0;F<h;F++){let H=x[j][F];if(H<D){let q=x[H].findIndex(X=>X%D==j),re=U[j][F],ee=U[H][q];for(let X=0;X<P;X++){let te=re[X],K=ee[P-X],Z=re[X+1],Q=ee[P-(X+1)];[te,K,Z,Z,K,Q].forEach($=>{s.push($[0].x,$[0].y,$[0].z),c.push($[1].x,$[1].y,$[1].z)})}W.push(re[0][0],ee[P][0],re[P][0],ee[0][0])}}for(;W.length;){let j,F,H,q;[j,F]=W.splice(0,2);let re=[j];for(;j!=F;)re.push(F),H=W.indexOf(F),q=H%2,F=W.splice(H-q,2)[1-q];O.subVectors(re[0],re[1]).cross(f.subVectors(re[0],re[2])).normalize();let ee=O.dot(re[0])<0;ee&&O.negate();for(let X=1;X<=re.length-2;X++)[re[X+ +ee],re[X+1-+ee],re[0]].forEach(te=>{s.push(te.x,te.y,te.z),c.push(O.x,O.y,O.z)})}}function p(){let d=new Tt.Vector3;for(let A=0;A<s.length;A+=3){d.x=s[A+0],d.y=s[A+1],d.z=s[A+2];let x=S(d)/2/Math.PI+.5,D=T(d)/Math.PI+.5;l.push(x,1-D)}let h=new Tt.Vector3,f=new Tt.Vector3,m=new Tt.Vector3,y=new Tt.Vector3,g=new Tt.Vector2,v=new Tt.Vector2,P=new Tt.Vector2,O=(A,x,D,N)=>{N<0&&A.x===1&&(l[x]=A.x-1),D.x===0&&D.z===0&&(l[x]=N/2/Math.PI+.5)};for(let A=0,x=0;A<s.length;A+=9,x+=6){h.set(s[A+0],s[A+1],s[A+2]),f.set(s[A+3],s[A+4],s[A+5]),m.set(s[A+6],s[A+7],s[A+8]),g.set(l[x+0],l[x+1]),v.set(l[x+2],l[x+3]),P.set(l[x+4],l[x+5]),y.copy(h).add(f).add(m).divideScalar(3);let D=S(y);O(g,x+0,h,D),O(v,x+2,f,D),O(P,x+4,m,D)}for(let A=0;A<l.length;A+=6){let x=l[A+0],D=l[A+2],N=l[A+4],I=Math.max(x,D,N),E=Math.min(x,D,N);I>.9&&E<.1&&(x<.2&&(l[A+0]+=1),D<.2&&(l[A+2]+=1),N<.2&&(l[A+4]+=1))}function S(A){return Math.atan2(A.z,-A.x)}function T(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(r){return new Dn(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};var Vx=require("three"),Gx=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 ul(r*.5,i,a):new Vx.DodecahedronGeometry(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},ul=class extends Dn{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 ul(r.radius,r.corner,r.cornerSides)}};var Ye=require("three");var Ne=require("three"),dl=1e-12,Ba=class{constructor(r){this.position=new Ne.Vector2;this.startPosition=new Ne.Vector2;this.uuid=Ne.MathUtils.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 Ba(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},La=class extends Ba{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new La(this.parent).copy(this)}},oo=class extends Ba{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new La(this),new La(this))}static create(e,t){let o=new oo(e,new Ne.Vector2(...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 oo(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 Ne.Vector2,t=new Ne.Vector2){let[o,i]=this.computeTangents();return o&&i&&(zx(o,e),zx(i,t)),[e,t]}computeTangent(e=new Ne.Vector2){let[t,o]=this.computeTangents();return t&&o&&e.copy(t).add(o).normalize(),e}computeNormal(e=new Ne.Vector2){let[t,o]=this.computeNormals();return e.copy(t).add(o).normalize(),e}};function zx(n,r=new Ne.Vector2){let e=n.length();return r.set(-n.y/e,n.x/e)}var Zp=n=>n,Ra=new Ne.Vector2,wu=new Ne.Vector2,zA=new Ne.Vector2,jA=new Ne.Vector2,FA=new Ne.Vector2,UA=new Ne.Vector2,Fx=new Ne.Vector3,Ux=new Ne.Vector3;function kx(n){let r=new Ne.Vector2;r.addVectors(n.v0,Ra.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Ne.Vector2;return e.addVectors(n.v2,wu.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new Ne.CubicBezierCurve(n.v0,r,e,n.v2)}function pl(n,r,e=Number.EPSILON){return Math.abs(n-r)<e}function kA(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function HA(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function Jp(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 Hx(n,r,e){return jx(n,r)&&jx(r,e)&&Qp(n.position,r.position,e.position)}function Qp(n,r,e){return Ra.copy(r).sub(n).cross(wu.copy(e).sub(n))===0}function Wx(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 qx(n,r,e){let t=n.distanceTo(e),o=r.distanceTo(e);return t<o?r:n}function $x(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 Jp(r,n,e)>Math.PI&&(u*=-1),pl(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 ef(n,r){return n.position.equals(n.controls[1].position)&&r.position.equals(r.controls[0].position)}function jx(n,r){return Qp(n.position,n.controls[1].position,r.position)&&Qp(n.position,r.controls[0].position,r.position)}function Yx(n,r,e,t,o=.5){let i=Ra.subVectors(r,n).multiplyScalar(o).add(n),a=wu.subVectors(e,r).multiplyScalar(o).add(r),s=zA.subVectors(t,e).multiplyScalar(o).add(e),l=i,c=jA.subVectors(a,i).multiplyScalar(o).add(i),u=FA.subVectors(s,a).multiplyScalar(o).add(a),p=s,d=UA.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 Xx(n,r,e=12,t=!0){let o=Ux.set(0,0,0),i,a=0,s=[];for(let l=0;l<r.length;l++){let c=Zp(r[l]),u=Ra,p=_n(c,e);s.push(p);for(let d=0;d<=p;d++)if(c instanceof Ne.CubicBezierCurve||c instanceof Ne.QuadraticBezierCurve||c instanceof Ne.LineCurve){if(c.getPoint(d/p,u),o.set(u.x,u.y,0),i!==void 0&&HA(i,o))continue;i===void 0&&(i=Fx),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 Kx(n,r,e,t=12,o=!0){let i=Ux.set(0,0,0),a=0,s=[];for(let l=0;l<r.length;l++){if(e[l]===!1)continue;let c,u=Zp(r[l]),p=Ra,d=_n(u,t);s.push(d);for(let h=0;h<=d;h++)if(u instanceof Ne.CubicBezierCurve||u instanceof Ne.QuadraticBezierCurve||u instanceof Ne.LineCurve){if(u.getPoint(h/d,p),i.set(p.x,p.y,0),c?.equals(i))continue;c===void 0?c=Fx:(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 tf(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=_n(a.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=_n(a.curveAfter,r)),t.push(s)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(t[n.length-1]+=_n(n[0].roundedCurveCorner,r)*.5),t}function _n(n,r=12){return n&&n instanceof Ne.EllipseCurve?r*2:n&&(n instanceof Ne.LineCurve||n instanceof Ne.LineCurve3)?1:n&&n instanceof Ne.SplineCurve?r*n.points.length:r}function Qx(n,r,e=12,t=!0){let o,i=0;for(let a=0;a<r.length;a++){let s=Zp(r[a]),l=_n(s,e),c=Ra;for(let u=0;u<=l;u++)if(s instanceof Ne.CubicBezierCurve||s instanceof Ne.QuadraticBezierCurve||s instanceof Ne.LineCurve){if(s.getPoint(u/l,c),o!==void 0&&kA(o,c,dl))continue;o===void 0&&(o=wu),o.copy(c),n.push(c.x,c.y),i++}}return pl(n[0],n[n.length-2],dl)&&pl(n[1],n[n.length-1],dl)&&(n.pop(),n.pop()),t&&i>1&&!(pl(n[i-1],n[1],dl)&&pl(n[i-2],n[0],dl))&&(n.push(n[0],n[1]),i++),n}var rf=new Ye.Vector2,WA=new Ye.Vector2,qA=new Ye.Vector2,$A=new Ye.Vector2,YA=new Ye.Vector2,XA=new Ye.Vector2,$e=class extends Ye.Shape{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new Ye.Plane(new Ye.Vector3(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=Ye.MathUtils.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,o){let i=new $e;return i.isClosed=e.isClosed,i.points=e.points.map(a=>oo.create(a.id,a.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(a=>$e.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=rf.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=Ye.MathUtils.generateUUID()){let i;e instanceof Ye.Vector2?i=e:i=new Ye.Vector2(e,t);let a=new oo(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 Xx(e,o?this.roundedCurves:this.curves,t,this.autoClose),i.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=tf(this.points,e,!1),this.roundedCurveDivisions=tf(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,o=12){return Kx(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),Qx(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=_n(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(ef(i,a)){let p=i.position.distanceTo(a.position);return i.position.distanceTo(rf.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){ef(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&&Hx(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),P=Math.min(g,v),O=1-P/m,S=P/y,T=p.getPointAt(O,rf),A=d.getPointAt(S,WA);this._subSplitCurve(p,h,O,T,void 0),this._subSplitCurve(d,f,S,void 0,A);let x;if(this.useCubicForRoundedCorners){let D=Jp(T,a.position,A)/2,N=Math.tan(D)*T.distanceTo(a.position),[I,E]=Wx(T,A,N,qA,$A),_=qx(I,E,a.position),[B,V]=$x(_,T,A,N,YA,XA);x=new Ye.CubicBezierCurve(T.clone(),B.clone(),V.clone(),A.clone())}else x=new Ye.QuadraticBezierCurve(T.clone(),a.position.clone(),A.clone());a.roundedCurveCorner=x,this.roundedCurves.splice(o+t,0,x),t++}}}}_subSplitCurve(e,t,o,i,a){if(e instanceof Ye.LineCurve)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=Yx(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 $e(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 oo(Ye.MathUtils.generateUUID(),new Ye.Vector2(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 $e;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 Ye.CubicBezierCurve&&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 Ye.QuadraticBezierCurve&&(a[l]=kx(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 Ye.CubicBezierCurve?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Ye.LineCurve&&(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 Ye.CubicBezierCurve?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),p=!0):u instanceof Ye.LineCurve&&u.v2.equals(s[0].position)&&(p=!0),this.isClosed=p,s};return this.points=i(e.curves),e instanceof Ye.Shape&&(this.shapeHoles=e.holes.map(a=>{let s=new $e;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 nf=Math.PI*2;function of({x:n,y:r},e,t,o,i){return{x:n*e+o,y:r*t+i}}function KA(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 QA(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,P=(a-m)/o,O=(s-y)/i,S=(-a-m)/o,T=(-s-y)/i,A=Zx(1,0,P,O),x=Zx(P,O,S,T);return!c&&x>0&&(x-=nf),c&&x<0&&(x+=nf),{centerx:g,centery:v,ang1:A,ang2:x}}function Jx({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=QA(n,r,e,t,o,i,c,u,a,s),{ang1:h,ang2:f}=d,{centerx:m,centery:y}=d,g=Math.abs(f)/(nf/4);Math.abs(1-g)<1e-7&&(g=1);let v=Math.max(Math.ceil(g),1);f/=v;for(let P=0;P<v;P++)l.push(KA(h,f)),h+=f;return l.map(P=>{let{x:O,y:S}=of(P[0],o,i,m,y),{x:T,y:A}=of(P[1],o,i,m,y),{x,y:D}=of(P[2],o,i,m,y);return{x1:O,y1:S,x2:T,y2:A,x,y:D}})}var gi=require("three");var We;(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"})(We||(We={}));var bt;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(bt||(bt={}));function Pe(n,r){if(!n)throw r||"Assertion Failed!"}var Se=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){Pe(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){Pe(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){Pe(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){Pe(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}(),fl=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}(),Pu=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}(),Va=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}(),e0=function(){function n(){var r=new Va,e=new fl,t=new Pu(0),o=new Pu(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 Pu(0),t=new Pu(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;Pe(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;Pe(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 Va,e=new Va,t=new fl,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 Va;this.makeVertex_(i,e,r.Org),r.Org.anEdge=r}if(!t){var a=new fl;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 fl;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 Va;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 fl;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&&Se.vertCCW(t.Lprev.Org,t.Org,i.Lnext.Lnext.Org)&&Se.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){Pe(o.prev===i),l=o.anEdge;do Pe(l.Sym!==l),Pe(l.Sym.Sym===l),Pe(l.Lnext.Onext.Sym===l),Pe(l.Onext.Sym.Lnext===l),Pe(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(Pe(o.prev===i&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){Pe(a.prev===s),l=a.anEdge;do Pe(l.Sym!==l),Pe(l.Sym.Sym===l),Pe(l.Lnext.Onext.Sym===l),Pe(l.Onext.Sym.Lnext===l),Pe(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(Pe(a.prev===s&&a.anEdge===null),c=t,c=t;(l=c.next)!==t;c=l)Pe(l.Sym.next===c.Sym),Pe(l.Sym!==l),Pe(l.Sym.Sym===l),Pe(l.Org!==null),Pe(l.Dst!==null),Pe(l.Lnext.Onext.Sym===l),Pe(l.Onext.Sym.Lnext===l);Pe(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}(),t0=function(){function n(){this.handle=null}return n}(),r0=function(){function n(){this.key=null,this.node=0}return n}(),ZA=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 t0,this.handles[t]=new r0;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,Pe(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 t0;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new r0}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;Pe(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}(),af=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}(),o0=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),JA=function(){function n(r,e){this.frame=r,this.leq=e,this.head=new o0,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 o0;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}(),eM=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?Se.vertLeq(i.Org,a.Org)?Se.edgeSign(a.Dst,i.Org,a.Org)<=0:Se.edgeSign(i.Dst,a.Org,i.Org)>=0:Se.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return Se.edgeSign(i.Dst,o,i.Org)>=0;var s=Se.edgeEval(i.Dst,o,i.Org),l=Se.edgeEval(a.Dst,o,a.Org);return s>=l},n.deleteRegion=function(r,e){e.fixUpperEdge&&Pe(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},n.fixUpperEdge=function(r,e,t){Pe(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 af;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 We.ODD:return(e&1)!==0;case We.NONZERO:return e!==0;case We.POSITIVE:return e>0;case We.NEGATIVE:return e<0;case We.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 Pe(Se.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,Pe(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=Se.vertL1dist(e,r),i=Se.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(Se.vertLeq(o.Org,i.Org)){if(Se.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;Se.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(Se.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(Pe(!Se.vertEq(o.Dst,i.Dst)),Se.vertLeq(o.Dst,i.Dst)){if(Se.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(Se.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 Va,h,f;if(Pe(!Se.vertEq(c,l)),Pe(Se.edgeSign(l,r.event,a)<=0),Pe(Se.edgeSign(c,r.event,s)>=0),Pe(a!==r.event&&s!==r.event),Pe(!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(Se.vertLeq(a,s)){if(Se.edgeSign(c,a,s)>0)return!1}else if(Se.edgeSign(l,s,a)<0)return!1;return n.debugEvent(r),Se.intersect(l,a,c,s,d),Pe(Math.min(a.t,l.t)<=d.t),Pe(d.t<=Math.max(s.t,c.t)),Pe(Math.min(c.s,l.s)<=d.s),Pe(d.s<=Math.max(s.s,a.s)),Se.vertLeq(d,r.event)&&(d.s=r.event.s,d.t=r.event.t),h=Se.vertLeq(a,s)?a:s,Se.vertLeq(h,d)&&(d.s=h.s,d.t=h.t),Se.vertEq(d,a)||Se.vertEq(d,s)?(n.checkForRightSplice(r,e),!1):!Se.vertEq(l,r.event)&&Se.edgeSign(l,r.event,d)>=0||!Se.vertEq(c,r.event)&&Se.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):(Se.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),Se.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),Se.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),Se.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}Se.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,Se.vertEq(o.Org,t)){Pe(!1),n.spliceMergeVertices(r,o,t.anEdge);return}if(!Se.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}Pe(!1),e=n.topRightRegion(e),l=n.regionBelow(e),a=l.eUp.Sym,i=s=a.Onext,l.fixUpperEdge&&(Pe(i!==a),n.deleteRegion(r,l),r.mesh.delete(a),a=i.Oprev),r.mesh.splice(t.anEdge,a),Se.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 af;if(c.eUp=e.anEdge.Sym,t=r.dict.search(c).key,o=n.regionBelow(t),!!o){if(a=t.eUp,s=o.eUp,Se.edgeSign(a.Dst,e,a.Org)===0){n.connectLeftDegenerate(r,t,e);return}if(i=Se.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);Pe(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 af,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 JA(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||(Pe(e.fixUpperEdge),Pe(++t===1)),Pe(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,Se.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 ZA(i,Se.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,Pe(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||!Se.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}(),tM=function(){function n(){this.mesh=new e0,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=We.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(;Se.vertLeq(t.Dst,t.Org);t=t.Lprev);for(;Se.vertLeq(t.Org,t.Dst);t=t.Lnext);o=t.Lprev;for(var i=void 0;t.Lnext!==o;)if(Se.vertLeq(t.Dst,o.Org)){for(;o.Lnext!==t&&(Se.edgeGoesLeft(o.Lnext)||Se.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&&(Se.edgeGoesRight(t.Lprev)||Se.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===bt.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===bt.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 e0),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=We.ODD),e===void 0&&(e=bt.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_(),eM.computeInterior(this,a);var s=this.mesh;return e===bt.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===bt.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,t,o),!0},n}();function no(n){var r=n.windingRule,e=r===void 0?We.ODD:r,t=n.elementType,o=t===void 0?bt.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 tM;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 Hk=We.ODD,Wk=We.NONZERO,qk=We.POSITIVE,$k=We.NEGATIVE,Yk=We.ABS_GEQ_TWO,Xk=bt.POLYGONS,Kk=bt.CONNECTED_POLYGONS,Qk=bt.BOUNDARY_CONTOURS;var io=require("three");var Ou=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*Ou.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*Ou.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)}},hl=Ou;hl.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var s0=zi(a0()),ml={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},df={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},pf={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},uf=(n,r)=>([e,t])=>(t<e&&(t+=r),(n>=e?n:n+r)<=t),Ln=class extends io.BufferGeometry{constructor(e,t,o=0,i=12,a=3,s=We.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(I=>{let E=I.extractShapePointsToFlatArray([],i),_=[];for(let B=E.length-1;B>=1;B-=2){let V=E[B-1],U=E[B-0];_.push(V,U)}return _}),p=[],d=[];for(let I=0;I<c.length;I+=2)d.push([c[I],c[I+1]]);p.push(d);for(let I=0;I<u.length;I++){let E=u[I],_=[];for(let B=0;B<E.length;B+=2)_.push([E[B],E[B+1]]);p.push(_)}let h;e.isText?h=new io.Box2().setFromPoints(e.points.map(E=>E.position)).getSize(new io.Vector2).length()*.1:p[0].length===0?h=o:h=(0,s0.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=no({windingRule:s,elementType:bt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{f=ml}let m;try{m=no({windingRule:We.ODD,elementType:bt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{m=df}if(!f)throw new Error("error generating geometry");let y=f.elementCount;if(m){f.elementCount+=m.elementCount;for(let I=0;I<m.elements.length;I++){let E=m.elements[I],_=I%2===0?f.vertexCount:0;f.elements.push(E+_)}for(let I=0;I<m.vertexIndices.length;I++){let E=m.vertexIndices[I],_=f.vertexCount;f.vertexIndices.push(E+_)}for(let I=0;I<m.vertices.length;I++){let E=m.vertices[I];f.vertices.push(E)}}let g=1/0,v=-1/0,P=1/0,O=-1/0;for(let I=0,E=f.vertexCount;I<E;I++){let _=I*2,B=f.vertices[_+0],V=f.vertices[_+1];B<g&&(g=B),B>v&&(v=B),V<P&&(P=V),V>O&&(O=V)}this._minX=g,this._minY=P,this._width=v-g,this._height=O-P,this._buffer=new hl(this._computeBufferEstimatedSize(f));let S=[],T=[];for(let I=f.elementCount-1;I>=0;I--){let E=I>=y,_=I*2,B=f.elements[_+0],V=f.elements[_+1],U=B+V,R={start:B,count:V,normals:[],continuous:[],concave:[]},W=B,j=U-1,F=B+1,H=this._shape.roundedCurves.length;do{let te=W-B,K=f.vertices[j*2+0],Z=f.vertices[j*2+1],Q=f.vertices[W*2+0],$=f.vertices[W*2+1],ue=f.vertices[F*2+0],le=f.vertices[F*2+1],ne=Q-K,ce=$-Z,ae=Math.sqrt(ne*ne+ce*ce);ne/=ae,ce/=ae;let ye=Q-ue,fe=$-le,me=Math.sqrt(ye*ye+fe*fe);ye/=me,fe/=me,R.normals[te*2+0]=-fe,R.normals[te*2+1]=ye,R.concave[te]=ne*fe-ce*ye>0;let be=f.vertexIndices[W];if(Array.isArray(be))R.continuous[te]=!1;else{let[ge,C]=this._shape.getCurveIndexFromVertexId(be-1,!0);if(C>0&&C<1)R.continuous[te]=!0;else{let ie=C===1?ge+1:ge-1;ie=(ie+H)%H;let Ve=C===1?0:1,Ue=this._shape.roundedCurves[ge].getTangent(C),Ge=this._shape.roundedCurves[ie].getTangent(Ve);R.continuous[te]=Ue.dot(Ge)>.95}}E&&(R.normals[te*2+0]*=-1,R.normals[te*2+1]*=-1),[j,W,F]=[W,F,F+1],F>=U&&(F-=V)}while(F!==B+1);let q=[];q.push({bevelI:0,angle:0,size:0,boundary:{vertices:f.vertices.slice(B*2,U*2),vertexCount:V,vertexIndices:new Array(V).fill(!0).map((te,K)=>[K,K]),elements:[0,V],elementCount:1,mesh:null},reverseMap:[],insetPoints:f.vertices.slice(B*2,U*2)});let re=0;for(let te=1;te<=this._bevelSegments;te++){let K=te/this._bevelSegments*Math.PI/2,Z=(1-Math.cos(K))*this._bevel,Q=[],$=[],ue=[],le=[],ne=0;for(let ae=0;ae<V;ae++){let ye=ae*2,fe=(ae-1+V)%V*2,me=f.vertices[R.start*2+ye+0],be=f.vertices[R.start*2+ye+1],ge=-R.normals[fe+0]*Z,C=-R.normals[fe+1]*Z,ie=-R.normals[ye+0]*Z,Ve=-R.normals[ye+1]*Z;if(R.concave[ae]||!R.concave[ae]&&E){let Ue=Math.atan2(C,ge),Ge=Math.atan2(Ve,ie);Ge>Ue&&(Ge-=Math.PI*2);let Ce=Ge-Ue;if(R.continuous[ae]||E){let Rt=Ue+Ce/2,De=Math.cos(Rt)*Z,Dt=Math.sin(Rt)*Z;Q[2*ne+0]=me+De*(E?-1:1),Q[2*ne+1]=be+Dt*(E?-1:1),le[ne]=ae,ne++}else{let Rt=Math.max(1,Math.floor(i/4*Math.abs(Ce)/Math.PI));for(let De=0;De<=Rt;De++){let Dt=Ue+Ce*(De/Rt),Vt=Math.cos(Dt)*Z,ei=Math.sin(Dt)*Z;Q[2*ne+0]=me+Vt,Q[2*ne+1]=be+ei,le[ne]=ae,ne++}}}else Q[2*ne+0]=me+ge,Q[2*ne+1]=be+C,le[ne]=ae,$[ae]=ne,ne++,Q[2*ne+0]=me,Q[2*ne+1]=be,le[ne]=ae,ne++,Q[2*ne+0]=me+ie,Q[2*ne+1]=be+Ve,le[ne]=ae,ue[ae]=ne,ne++}let ce=no({windingRule:We.POSITIVE,elementType:bt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Q],edgeCreateCallback:ae=>{let fe=ae.Org.idx,me=le[fe],be=le[(fe+1)%le.length];ae.idx=[me,be],ae.Sym.idx=[be,me]},vertexIdCallback:ae=>{let ye=ae.Lprev.idx;return[ye?ye[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;re=(1-Math.sin(ae))*this._bevel;break}for(let ae=0;ae<ce.vertexIndices.length;ae++){let[ye,fe]=ce.vertexIndices[ae];if(ye===fe)continue;let me=fe;fe<ye&&(me+=V);for(let be=ye;be<me;be++){let ge=be%V,C=(be+1)%V;if(!R.continuous[ge]||!R.continuous[C]){ce.vertexIndices[ae]=[ye,ge],ce.vertexIndices.splice(ae+1,0,[C,fe]),ce.vertices.splice((ae+1)*2,0,ce.vertices[ae*2],ce.vertices[ae*2+1]);break}}}q.push({bevelI:te,angle:K,size:Z,boundary:ce,reverseMap:le,insetPoints:Q})}let ee=(te,K,Z)=>{let Q=0,$=te.boundary.vertexIndices.length;for(;Q<$&&Z(te.boundary.vertexIndices[K]);)K=(K+1)%$,Q++;return Q},X=S.length;for(let te=1;te<q.length;te++){let K=q[te-1],Z=q[te],Q=K.boundary.vertexIndices.length,$=Z.boundary.vertexIndices.length;if(!Q||!$)break;let ue=R.concave.length,le=0,ne=uf(le,V);for(;!K.boundary.vertexIndices.filter(ne).length||!Z.boundary.vertexIndices.filter(ne).length;)le++,ne=uf(le,V);let ce=K.boundary.vertexIndices.findIndex(ne),ae=Z.boundary.vertexIndices.findIndex(ne);do ce=(ce+1)%Q;while(ne(K.boundary.vertexIndices[ce]));do ae=(ae+1)%$;while(ne(Z.boundary.vertexIndices[ae]));le=(le+1)%V;let ye=le,fe=0,me=this._buildBevelVert(R,K,(ce-1+Q)%Q,void 0,fe),be=this._buildBevelVert(R,Z,(ae-1+$)%$,void 0,fe),ge=me,C=be,ie,Ve,Ue=!1;do{fe=(le||ue)/ue,ne=uf(le,V);let Ge=ee(K,ce,ne),Ce=ee(Z,ae,ne),Rt=Ue;if(Ue=!1,Ge&&!Ce){for(let De=0;De<Ge;De++)ie=this._buildBevelVert(R,K,(ce+De)%Q,De/(Ge-1),fe),S.push(ge.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,ge.bottomN,C.bottomN),ge=ie;Ue=!0}else if(!Ge&&Ce)for(let De=0;De<Ce;De++)Ve=this._buildBevelVert(R,Z,(ae+De)%$,De/(Ce-1),fe),S.push(C.topN,ge.topP,Ve.topP),l===!1&&S.push(ge.bottomP,C.bottomN,Ve.bottomP),C=Ve;else if(Ge&&Ce)if(ie=this._buildBevelVert(R,K,ce,0,fe),Ve=this._buildBevelVert(R,Z,ae,0,fe),Rt?(S.push(ge.topN,Ve.topP,C.topN),S.push(ge.topN,ie.topP,Ve.topP),l===!1&&(S.push(Ve.bottomP,ge.bottomN,C.bottomN),S.push(Ve.bottomP,ie.bottomP,ge.bottomN))):(S.push(C.topN,ge.topN,ie.topP),S.push(C.topN,ie.topP,Ve.topP),l===!1&&(S.push(ie.bottomP,ge.bottomN,C.bottomN),S.push(ie.bottomP,C.bottomN,Ve.bottomP))),ge=ie,C=Ve,Ge===Ce)for(let De=1;De<Ge;De++)ie=this._buildBevelVert(R,K,(ce+De)%Q,De/(Ge-1),fe),Ve=this._buildBevelVert(R,Z,(ae+De)%$,De/(Ce-1),fe),S.push(ge.topN,ie.topP,C.topN),S.push(C.topN,ie.topP,Ve.topP),l===!1&&(S.push(ie.bottomP,ge.bottomN,C.bottomN),S.push(ie.bottomP,C.bottomN,Ve.bottomP)),ge=ie,C=Ve;else if(Ge>Ce){let De=Ge/Ce,Dt=0;for(let Vt=1;Vt<Ge;Vt++)ie=this._buildBevelVert(R,K,(ce+Vt)%Q,Vt/(Ge-1),fe),S.push(ge.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,ge.bottomN,C.bottomN),ge=ie,Vt>(Dt+1)*De&&(Dt++,Ve=this._buildBevelVert(R,Z,(ae+Dt)%$,Dt/(Ce-1),fe),S.push(C.topN,ie.topP,Ve.topP),l===!1&&S.push(ie.bottomP,C.bottomN,Ve.bottomP),C=Ve)}else{let De=Ce/Ge,Dt=0;for(let Vt=1;Vt<Ce;Vt++)Ve=this._buildBevelVert(R,Z,(ae+Vt)%$,Vt/(Ce-1),fe),S.push(C.topN,ie.topP,Ve.topP),l===!1&&S.push(ie.bottomP,C.bottomN,Ve.bottomP),C=Ve,Vt>(Dt+1)*De&&(Dt++,ie=this._buildBevelVert(R,K,(ce+Dt)%Q,Dt/(Ge-1),fe),S.push(ge.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,ge.bottomN,C.bottomN),ge=ie)}ce=(ce+Ge)%Q,ae=(ae+Ce)%$,le=(le+1)%ue}while(le!==ye)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(q,R,S),E){let te=[];for(let K=S.length-1;K>=X+2;K-=3){let Z=S[K-2],Q=S[K-1],$=S[K-0];te.push($,Q,Z)}S.splice(X,S.length-X,...te)}if(E){let te=[];for(let K=q[q.length-1].boundary.vertices.length-1;K>=1;K-=2){let Z=q[q.length-1].boundary.vertices[K-1],Q=q[q.length-1].boundary.vertices[K-0];te.push(Z,Q)}T.push(te)}if(!E){let te=q[q.length-1],K;try{K=no({windingRule:q.length>1?We.POSITIVE:We.ODD,elementType:bt.POLYGONS,vertexSize:2,strict:!0,contours:[te.insetPoints,...T]})}catch{K=pf}if(!K)throw new Error("Error generating geometry for surface");u.length===0&&this._bevel<h&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let Z=0;Z<K.elementCount*3;Z+=3){let Q=this._buildSurfaceVert(K,K.elements[Z+0],re),$=this._buildSurfaceVert(K,K.elements[Z+1],re),ue=this._buildSurfaceVert(K,K.elements[Z+2],re);S.push(Q.top,$.top,ue.top),l===!1&&S.push(ue.bottom,$.bottom,Q.bottom)}}this.vertexCache={}}this._buffer.shrink();let A=new io.BufferAttribute(Uint32Array.from(S),1),x=new io.BufferAttribute(this._buffer.positions,3),D=new io.BufferAttribute(this._buffer.normals,3),N=new io.BufferAttribute(this._buffer.uvs,2);x.needsUpdate=!0,D.needsUpdate=!0,N.needsUpdate=!0,A.needsUpdate=!0,this.setAttribute("position",x),this.setAttribute("normal",D),this.setAttribute("uv",N),this.setIndex(A)}_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,P=t.boundary.vertices[y+0],O=t.boundary.vertices[y+1],S=(1-m)*this._bevel,T=(P-this._minX)/this._width,A=(O-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(T=a),A=1);let x=e.normals[g+0],D=e.normals[g+1],N=e.normals[v+0],I=e.normals[v+1];if(h){let U=N-x,R=I-D;x=x+U*(1-i),D=D+R*(1-i);let W=Math.sqrt(x*x+D*D);x/=W,D/=W}let E=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),_=E*3,B=E*2,V={i:o,fi:u,topP:E+0,topN:E+0,bottomP:E+1,bottomN:E+1,pathBevelUCoord:a};return this._buffer.positions[_+0]=P,this._buffer.positions[_+1]=O,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[_+0]=x*f,this._buffer.normals[_+1]=D*f,this._buffer.normals[_+2]=m,this._buffer.uvs[B+0]=T,this._buffer.uvs[B+1]=A,this.forPathBevel===!1&&(this._buffer.positions[_+3]=P,this._buffer.positions[_+4]=O,this._buffer.positions[_+5]=S,this._buffer.normals[_+3]=x*f,this._buffer.normals[_+4]=D*f,this._buffer.normals[_+5]=-m,this._buffer.uvs[B+2]=A,this._buffer.uvs[B+3]=T),d||(this.forPathBevel?(E+=1,_+=3,B+=2):(E+=2,_+=6,B+=4),V.topP=E+0,V.bottomP=E+1,this._buffer.positions[_+0]=P,this._buffer.positions[_+1]=O,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[_+0]=N*f,this._buffer.normals[_+1]=I*f,this._buffer.normals[_+2]=m,this._buffer.uvs[B+0]=T,this._buffer.uvs[B+1]=A,this.forPathBevel===!1&&(this._buffer.positions[_+3]=P,this._buffer.positions[_+4]=O,this._buffer.positions[_+5]=S,this._buffer.normals[_+3]=N*f,this._buffer.normals[_+4]=I*f,this._buffer.normals[_+5]=-m,this._buffer.uvs[B+2]=A,this._buffer.uvs[B+3]=T)),this.vertexCache[s]=V,V}clone(){let e=new Ln(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=ko(this.userData),e}};var Ga=class extends gi.BufferGeometry{constructor(e,t=12,o={}){super();this.type="ShapeGeometry";this.windingRule=We.ODD;this.elementType=bt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:We.ODD,elementType:bt.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=no({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=ml}let d=s?.vertexCount??1,h=s?.elementCount??1;if(this._positionAttribute=new gi.BufferAttribute(new Float32Array(d*3),3),this._normalAttribute=new gi.BufferAttribute(new Float32Array(d*3),3),this._uvAttribute=new gi.BufferAttribute(new Float32Array(d*2),2),this._indexAttribute=new gi.BufferAttribute(new Uint32Array(h*3),1),s){let f=1/0,m=-1/0,y=1/0,g=-1/0;for(let O=0,S=d;O<S;O++){let T=O*2,A=s.vertices[T+0],x=s.vertices[T+1];A<f&&(f=A),A>m&&(m=A),x<y&&(y=x),x>g&&(g=x)}let v=m-f,P=g-y;for(let O=0,S=d;O<S;O++){let T=O*2,A=s.vertices[T+0],x=s.vertices[T+1],D=(A-f)/v,N=(x-y)/P;this._positionAttribute.setXYZ(O,A,x,0),this._normalAttribute.setXYZ(O,0,0,1),this._uvAttribute.setXY(O,D,N)}for(let O=0,S=h;O<S;O++){let T=O*3,A=s.elements[T+0],x=s.elements[T+1],D=s.elements[T+2];this._indexAttribute.setX(T+0,A),this._indexAttribute.setX(T+1,x),this._indexAttribute.setX(T+2,D)}}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 Ga(this._shape,this._curveSegments);return e.userData=ko(this.userData),e}};var za=class extends Ln{constructor(e,t,o=0,i=12,a=3,s=We.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 za(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=ko(this.userData),e}};var xr=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:We.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 $e?(a.width!==t||a.height!==o)&&a.applySize(t,o):a=new $e(t,o).fromJSON(a),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&a.update());let l=a??new $e(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 Ga(n.shape,o,{windingRule:a}):s=new za(n.shape,r,e,o,t,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};var ao=require("three"),c0=Math.PI*2,Fa=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=ao.MathUtils.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof $e?n.shape:new $e,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=aM(c,u,p,o*Math.PI/180,t,i);c.isClosed=!0,c.update();let h;return o===0?(h=new ao.BufferGeometry,h.setAttribute("position",new ao.Float32BufferAttribute([],3))):h=xr.create({shape:c,parameters:{subdivisions:d,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(h,{userData:{...n,type:"EllipseGeometry"}})}};function aM(n,r,e,t,o,i){if(t>=c0)return o>30||o%4===0?(lM(n,r,e,i),Math.round(o/4)):l0(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=Jx({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?sM(n,a.x,a.y,c,o,r,e,i):l0(n,t,o,r,e,i)}function sM(n,r,e,t,o,i,a,s){let l=Math.round(o/t.length);n.addPoint(ja(r,e));for(let c=0,u=t.length;c<u;c++){let p=t[c],d=n.points[c],h=ja(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?u0(n,i,a,s):n.addPoint(ja(0,0)),l}function l0(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(ja(c,u))}return r<c0?i>0?u0(n,t,o,i):n.addPoint(ja(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&d0(n,t,o,i)),1}function lM(n,r,e,t=0,o=0,i=0){let a=.5522847498,s=r*a,l=e*a;n.addPoint(Tu(o-r,i,o-r,i-l,o-r,i+l)),n.addPoint(Tu(o,i+e,o-s,i+e,o+s,i+e)),n.addPoint(Tu(o+r,i,o+r,i+l,o+r,i-l)),n.addPoint(Tu(o,i-e,o+s,i-e,o-s,i-e)),t>0&&d0(n,r,e,t)}function ja(n,r){return new oo(ao.MathUtils.generateUUID(),new ao.Vector2(n,r))}function Tu(n,r,e,t,o,i){let a=ja(n,r);return a.controls[0].position.set(e,t),a.controls[1].position.set(o,i),a}function u0(n,r,e,t){p0(n,r,e,t).forEach(i=>n.addPoint(i))}function d0(n,r,e,t){let o=p0(n,r,e,t),i=new $e;o.forEach(a=>i.addPoint(a)),i.isClosed=!0,n.shapeHoles.push(i)}function p0(n,r,e,t){let o=t*r/100,i=o*(Math.abs(e)/Math.abs(r)),a=new ao.Vector2(o/r,i/e),s=n.points.map(l=>{let c=l.clone();return c.uuid=ao.MathUtils.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}var so=require("three"),f0=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 yl(!1,r,e,t,o,i,a,s,l,c,u,p);return Object.assign(d,{userData:{...n,type:"HelixGeometry"}})}},ff=new so.Uint32BufferAttribute([0,0,0],1),yl=class extends so.BufferGeometry{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 so.Vector3,m=new so.Vector3,y=f(),g=f(),v=f(),P,O,S,T,A,x,D,N,I=f(),E=f(),_=f(),B=f(),V=f(),U=f(),R=f(),W=f(),j=t-2*l+.001,F=j/a,H=Math.ceil(s*a),q=H+1,re=j/H,ee=-j/2,X=u+1,te=2*Math.PI/u,K=Math.PI/2/d,Z=.01,Q=Math.min((1-p/100)*l,l-Z),$=l-Q,ue=0,le=2,ne=d*le+le,ce=X*ne/le,ae=ce+X*q,ye=Math.max(0,X*(q+ne)),[fe,me,be]=[3,3,2].map(yt=>Array(ye*yt).fill(0)),ge=[],C=i-l;function ie(yt,nt){let Kr=Math.PI/2;x=nt*re,N=2*Math.PI*(x%F)/F+Kr,x+=ee,D=Math.sin(N)*C,A=Math.cos(N)*C,r?yt.set(A,D,x):yt.set(A,x,D)}ie(m,-1e-10),ie(y,0),I.copy(m),ie(m,1);let Ve=m.distanceTo(y),Ue=h?0:$+Q,Ge=Ve*H+2*Ue,Ce=Q,Rt=Ge-Ue;for(let yt=0;yt<=H;yt++){ie(g,yt),W.subVectors(g,I).normalize(),I.copy(g),U.copy(g).setComponent(+r+1,0).normalize(),R.crossVectors(W,U).normalize();let nt=yt===0,Kr=yt===H,kd=nt?3*Math.PI/2:K,Hd=nt?Ce:Rt,Jl=nt?X:ae,ti=nt?0:ye-X,wt=W.clone().multiplyScalar(nt?-$:$).add(g),Wd=W.clone().multiplyScalar(nt?-1:1).normalize();for(let Lr=0;Lr<X;Lr++){let Us=Lr*te;if(E.addVectors(m.copy(U).multiplyScalar(l*Math.cos(Us)),y.copy(R).multiplyScalar(l*Math.sin(Us))),_.copy(E).normalize(),nt||Kr){h||(ue=ti+Lr,[0,1,2].forEach(ir=>{fe[ue*3+ir]=wt.getComponent(ir),me[ue*3+ir]=Wd.getComponent(ir)}),be[ue*2]=+Kr,be[ue*2+1]=Lr/u),y.copy(_).multiplyScalar(Q),v.addVectors(g,y);for(let ir=0;ir<d;ir++){let ri=ir*K+kd;B.addVectors(m.copy(W).multiplyScalar($*Math.sin(ri)),y.copy(_).multiplyScalar($*Math.cos(ri))),V.copy(B).normalize(),y.addVectors(v,B),B.normalize(),ue=Jl+ir*X+Lr,[0,1,2].forEach(Li=>{fe[ue*3+Li]=y.getComponent(Li),me[ue*3+Li]=V.getComponent(Li)});let ec=+nt+Math.sin(ri);be[ue*2]=(Hd+$*ec)/Ge,be[ue*2+1]=Lr/u}}y.addVectors(g,E),ue=ce+yt*X+Lr,[0,1,2].forEach(ir=>{fe[ue*3+ir]=y.getComponent(ir),me[ue*3+ir]=_.getComponent(ir)}),be[ue*2]=(Ue+yt*Ve)/Ge,be[ue*2+1]=Lr/u}}let De=q+2*d+le,Dt=1,[Vt,ei]=[+h,De-1];for(let yt=Vt;yt<=ei-1;yt++){let nt=h&&yt===ei-1;for(let Kr=0;Kr<X-1;Kr++)P=yt*X+Kr,O=P+1,S=(nt?Kr:P)+X,T=(nt?Kr+1:O)+X,yt===0?ge.push(O,T,S):yt===De-2?ge.push(P,O,S):ge.push(P,O,S,O,T,S)}this.setIndex(ge),this.setAttribute("position",new so.Float32BufferAttribute(fe,3)),this.setAttribute("normal",new so.Float32BufferAttribute(me,3)),this.setAttribute("uv",new so.Float32BufferAttribute(be,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,ff.array=o,ff.count=o.length,ff}};var h0=require("three");var m0=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 gl(r*.5,i,a):new h0.IcosahedronGeometry(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},gl=class extends Dn{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 gl(r.radius,r.corner,r.cornerSides)}};var Au=require("three"),y0=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 Au.Shape;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 Au.LatheGeometry(o.extractPoints(t).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};var Ao=require("three");var Jo=require("three");var pe=require("three"),To=new pe.Matrix4,hf=new pe.Object3D,Mu=new pe.Vector3,Rn=class extends pe.EventDispatcher{constructor(){super(),this.uuid=pe.MathUtils.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 pe.Matrix3().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 To.makeRotationX(r),this.applyMatrix4(To),this}rotateY(r){return To.makeRotationY(r),this.applyMatrix4(To),this}rotateZ(r){return To.makeRotationZ(r),this.applyMatrix4(To),this}translate(r,e,t){return To.makeTranslation(r,e,t),this.applyMatrix4(To),this}scale(r,e,t){return To.makeScale(r,e,t),this.applyMatrix4(To),this}lookAt(r){return hf.lookAt(r),hf.updateMatrix(),this.applyMatrix4(hf.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 pe.Vector3().fromBufferAttribute(i,d)),s!==void 0&&e.colors.push(new pe.Color().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 pe.Vector3().fromBufferAttribute(a,d),new pe.Vector3().fromBufferAttribute(a,h),new pe.Vector3().fromBufferAttribute(a,f)],v=new Ua(d,h,f,g,y,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new pe.Vector2().fromBufferAttribute(l,d),new pe.Vector2().fromBufferAttribute(l,h),new pe.Vector2().fromBufferAttribute(l,f)]),c!==void 0&&e.faceVertexUvs[1].push([new pe.Vector2().fromBufferAttribute(c,d),new pe.Vector2().fromBufferAttribute(c,h),new pe.Vector2().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(Mu).negate(),this.translate(Mu.x,Mu.y,Mu.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new pe.Matrix4;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 pe.Vector3,e=new pe.Vector3;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 pe.Vector3;if(r){let t=new pe.Vector3,o=new pe.Vector3;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 Rn;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 pe.Vector3,u={a:new pe.Vector3,b:new pe.Vector3,c:new pe.Vector3};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 pe.Box3),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new pe.Sphere),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 pe.Matrix3().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,P=new Ua(f.a+i,f.b+i,f.c+i);P.normal.copy(f.normal),o!==void 0&&P.normal.applyMatrix3(o).normalize();for(let O=0,S=g.length;O<S;O++)m=g[O].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),P.vertexNormals.push(m);P.color.copy(f.color);for(let O=0,S=v.length;O<S;O++)y=v[O],P.vertexColors.push(y.clone());P.materialIndex=f.materialIndex+t,l.push(P)}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 P=0,O=g.length;P<O;P++)v.push(g[P].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 pe.Vector3(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,P=m.normal.length()>0,O=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,T=m.vertexColors.length>0,A=0;if(A=u(A,0,0),A=u(A,1,y),A=u(A,2,g),A=u(A,3,v),A=u(A,4,P),A=u(A,5,O),A=u(A,6,S),A=u(A,7,T),t.push(A),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(P&&t.push(p(m.normal)),O){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 Rn().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 P=0,O=g.length;P<O;P++){let S=g[P];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 mf().fromGeometry(this),e=new pe.BufferGeometry,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",Iu.call(new pe.BufferAttribute(t,3),r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",Iu.call(new pe.BufferAttribute(o,3),r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",g0.call(new pe.BufferAttribute(o,3),r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",x0.call(new pe.BufferAttribute(o,2),r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",x0.call(new pe.BufferAttribute(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 pe.Float32BufferAttribute(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 pe.Float32BufferAttribute(r.skinIndices.length*4,4);e.setAttribute("skinIndex",b0.call(o,r.skinIndices))}if(r.skinWeights.length>0){let o=new pe.Float32BufferAttribute(r.skinWeights.length*4,4);e.setAttribute("skinWeight",b0.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 pe.BufferGeometry,t=r.geometry;if(r.isPoints||r.isLine){let o=new pe.Float32BufferAttribute(t.vertices.length*3,3),i=new pe.Float32BufferAttribute(t.colors.length*3,3);if(e.setAttribute("position",Iu.call(o,t.vertices)),e.setAttribute("color",g0.call(i,t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let a=new pe.Float32BufferAttribute(t.lineDistances.length,1);e.setAttribute("lineDistance",cM.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}};Rn.prototype.isGeometry=!0;var mf=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 P=v.vertexNormals;if(P.length===3)this.normals.push(P[0],P[1],P[2]);else{let S=v.normal;this.normals.push(S,S,S)}let O=v.vertexColors;if(O.length===3)this.colors.push(O[0],O[1],O[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 pe.Vector2,new pe.Vector2,new pe.Vector2))}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 pe.Vector2,new pe.Vector2,new pe.Vector2))}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}},Ua=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 pe.Vector3,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new pe.Color,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 cM(n){return this.array.set(n),this}function g0(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 pe.Color),r[e++]=i.r,r[e++]=i.g,r[e++]=i.b}return this}function x0(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 pe.Vector2),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 pe.Vector3),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z}return this}function b0(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 pe.Vector4),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z,r[e++]=i.w}return this}var uM=["a","b","c"];function dM(n,r){switch(r){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function yf(n,r,e){let t=Math.min(n,r),o=Math.max(n,r),i=t+"_"+o;return e.get(i)}function gf(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 pM(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],gf(a.a,a.b,n,t,a,e),gf(a.b,a.c,n,t,a,e),gf(a.c,a.a,n,t,a,e)}function Nu(n,r,e,t,o){n.push(new Ua(r,e,t,void 0,void 0,o))}function ka(n,r){return Math.abs(r-n)/2+Math.min(n,r)}function Eu(n,r,e,t){n.push([r.clone(),e.clone(),t.clone()])}var Du=class{constructor(r=1){this.subdivisions=r}modify(r){r instanceof Jo.BufferGeometry?r=new Rn().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 Jo.Vector3,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;pM(l,c,d,h);let f=[],m,y,g,v,P,O,S;for(let Z of Array.from(h.keys())){for(y=h.get(Z),g=new Jo.Vector3,P=3/8,O=1/8,S=y.faces.length,S!=2&&(P=.5,O=0,S!=1),g.addVectors(y.a,y.b).multiplyScalar(P),e.set(0,0,0),a=0;a<S;a++){for(v=y.faces[a],s=0;s<3&&(m=l[dM(v,uM[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(O),g.add(e),y.newEdge=f.length,f.push(g)}let T,A,x,D,N,I,E,_=[];for(o=0,i=l.length;o<i;o++){for(I=l[o],N=d[o].edges,t=N.length,t==3?T=3/16:t>3&&(T=3/(8*t)),A=1-t*Number(T),x=T,t<=2&&(t==2?(A=3/4,x=1/8):t==1||t==0),E=I.clone().multiplyScalar(A),e.set(0,0,0),a=0;a<t;a++)D=N[a],m=D.a!==I?D.a:D.b,e.add(m);e.multiplyScalar(Number(x)),E.add(e),_.push(E)}let B=_.concat(f),V=_.length,U,R,W,j=[],F=[],H,q,re,ee,X=new Jo.Vector2,te=new Jo.Vector2,K=new Jo.Vector2;for(o=0,i=c.length;o<i;o++)v=c[o],U=Number(yf(v.a,v.b,h).newEdge)+V,R=Number(yf(v.b,v.c,h).newEdge)+V,W=Number(yf(v.c,v.a,h).newEdge)+V,Nu(j,U,R,W,v.materialIndex),Nu(j,v.a,U,W,v.materialIndex),Nu(j,v.b,R,U,v.materialIndex),Nu(j,v.c,W,R,v.materialIndex),p&&(H=u[o],q=H[0],re=H[1],ee=H[2],X.set(ka(q.x,re.x),ka(q.y,re.y)),te.set(ka(re.x,ee.x),ka(re.y,ee.y)),K.set(ka(q.x,ee.x),ka(q.y,ee.y)),Eu(F,X,te,K),Eu(F,q,X,K),Eu(F,re,te,X),Eu(F,ee,K,te));r.vertices=B,r.faces=j,p&&(r.faceVertexUvs[0]=F)}};var zt=new Ao.Vector3,v0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=n.geometry??r?.geometry??new Ao.BufferGeometry().copy(new Ao.BoxGeometry(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(zt),t={width:zt.x,height:zt.y,depth:zt.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 Ao.BufferGeometry().copy(new Ao.BoxGeometry(100,100,100)),a=i.userData.parameters;a===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(zt)):zt.set(a.width,a.height,a.depth),(r!==zt.x||e!==zt.y||t!==zt.z)&&i.scale(zt.x===0?1:r/zt.x,zt.y===0?1:e/zt.y,zt.z===0?1:t/zt.z);let s=i.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=i),i=new Du(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 Ao.BufferGeometryLoader(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(zt);let a=100/zt.x;Object.assign(i.parameters,{width:100,height:zt.y*a,depth:zt.z*a}),r(this.build(i))})}};var _u=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 $e?n.shape:new $e,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=xr.create({shape:l,parameters:{roundness:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(f,{userData:{...n,type:"PolygonGeometry"}})}};var He=require("three"),S0=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 bf(r*.5,e,o,i,a,s,l);return c.scale(1,1,t/r),Object.assign(c,{userData:{...n,type:"PyramidGeometry"}})}};function xl(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function xf(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 fM(n,r,e){let t=n.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var bf=class extends He.BufferGeometry{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,P=new He.Vector3(0,-h,0),O=new He.Vector3(0,h,0),S=new He.Vector2(r,-h),T=new He.Vector2(m,-h),A=new He.Vector2(0,O.y).sub(T),x=new He.Vector2(0,O.y).sub(S),D=new He.Vector2(A.y,-A.x).normalize(),N=new He.Vector2(x.y,-x.x).normalize(),E=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-A.angle())/2)-1e-8;a=Math.min(a,E);let _;{let F=new He.Vector3(D.x,D.y,0),H=new He.Vector3(Math.cos(y)*F.x,F.y,Math.sin(y)*F.x);_=F.angleTo(H)}let B=a/Math.tan((Math.PI-A.angle())/2),V=a/Math.tan((Math.PI-_)/2),U=new He.Vector3;if(!i){c.push(P.x,P.y,P.z),u.push(0,-1,0),p.push(0,0);let F=d++,H=[],q=S.clone(),re=B/Math.cos(Math.PI/t);q.x-=re;for(let ee=0;ee<t;ee++){let X=ee/t*Math.PI*2+f,te=new He.Vector2(Math.sin(X),Math.cos(X));xl(q,te,U),c.push(U.x,U.y,U.z),u.push(0,-1,0),p.push(0,0),H.push(d++)}for(let ee=0;ee<H.length;ee++)l.push(H[ee],F,H[(ee+1)%H.length])}let R=[];{let F=new He.Vector3,H=new He.Vector3,q=new He.Vector3,re=new He.Vector3,ee=new He.Vector3,X=new He.Vector3;for(let te=0;te<t;te++){let K=te/t*Math.PI*2+f,Z=(te+.5)/t*Math.PI*2+f,Q=(te+1)/t*Math.PI*2+f,$=new He.Vector2(Math.sin(K),Math.cos(K)),ue=new He.Vector2(Math.sin(Z),Math.cos(Z)),le=new He.Vector2(Math.sin(Q),Math.cos(Q));xl(S,$,H),xl(S,le,q),xl(D,ue,F),xf(O,H,q,V,V,re),c.push(re.x,re.y,re.z),xf(H,O,q,V,B,ee),c.push(ee.x,ee.y,ee.z),xf(q,H,O,B,V,X),c.push(X.x,X.y,X.z),u.push(F.x,F.y,F.z),u.push(F.x,F.y,F.z),u.push(F.x,F.y,F.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 me=H.clone().add(q).multiplyScalar(.5),be=O.clone().sub(me).normalize(),C=P.clone().sub(me).normalize().add(be).normalize().multiplyScalar(-1),ie=X.clone().sub(ee);W(me,ie,C,A.angle())}let ye,fe;{let me=new He.Vector3;xl(N,le,me);let be=X.clone().add(re).multiplyScalar(.5);be=fM(be,q,O);let ge=X.clone().sub(re);[ye,fe]=W(be,ge,me,_,re.y)}{let me=ye,be=me.clone().setY(0).normalize(),ge=new He.Vector3(0,-1,0),C=be.clone().cross(ge);j(me,be,ge,C)}R.concat(fe);{let me=A.angle(),be=Math.PI-me,ge=O.clone();ge.y-=a/Math.sin(me-Math.PI/2);let C=new He.Vector3,ie=[];for(let Ue=0;Ue<s;Ue++){let Ge=[],Ce=Math.PI/2-be*Ue/s,Rt=Math.cos(Ce),De=Math.sin(Ce),Dt=Z;for(let Vt=0;Vt<=Ue;Vt++){let ei=Math.cos(Dt),yt=Math.sin(Dt);F.x=Rt*yt,F.y=De,F.z=Rt*ei,C.copy(ge).addScaledVector(F,a),c.push(C.x,C.y,C.z),u.push(F.x,F.y,F.z),p.push(0,0),Ge.push(d++),Dt+=Math.PI*2/Ue/t}ie.push(Ge)}fe.reverse(),ie.push(fe);let Ve=ie.length-1;for(let Ue=0;Ue<Ve;Ue++){let Ge=ie[Ue],Ce=ie[Ue+1],Rt=Ge.length-1;l.push(Ce[1],Ge[0],Ce[0]);for(let De=1;De<=Rt;De++)l.push(Ge[De],Ge[De-1],Ce[De]),l.push(Ce[De+1],Ge[De],Ce[De])}}}}}this.setIndex(l),this.setAttribute("position",new He.Float32BufferAttribute(c,3)),this.setAttribute("normal",new He.Float32BufferAttribute(u,3)),this.setAttribute("uv",new He.Float32BufferAttribute(p,2));function W(F,H,q,re,ee){let X=-re/2,te=(Math.PI-re)/2,K=H.clone().normalize().cross(q);F.addScaledVector(q,-a/Math.sin(te));let Z=new He.Vector3,Q=new He.Vector3,$=1,ue=d,le=[];for(let ne=0;ne<=s;ne++){let ce=X+ne/s*re;Q.set(0,0,0),Q.addScaledVector(K,Math.sin(ce)),Q.addScaledVector(q,Math.cos(ce));for(let ae=0;ae<=$;ae++){let ye=ae/$-.5;if(Z.copy(F),Z.addScaledVector(H,ye),Z.addScaledVector(Q,a),ee!=null){let fe=Math.max(0,Z.y-ee);Z.addScaledVector(H,-fe/H.y)}c.push(Z.x,Z.y,Z.z),u.push(Q.x,Q.y,Q.z),p.push(0,0),ae===0&&le.push(d),d++}}for(let ne=0;ne<s;ne++)for(let ce=0;ce<$;ce++){let ae=ue+ce+($+1)*ne,ye=ae+($+1),fe=ye+1,me=ae+1;l.push(ae,ye,me),l.push(ye,fe,me)}return[F.clone().addScaledVector(H,.5),le]}function j(F,H,q,re){let ee=Math.PI/2,X=x.angle()-ee,te=[],K=new He.Vector3,Z=new He.Vector3;for(let $=0;$<=s;$++){let ue=[],le=$/s;for(let ne=0;ne<=$;ne++){let ae=(($?ne/$:0)-.5)*v,ye=Math.cos(ae),fe=Math.sin(ae),me=Math.atan(Math.tan(X)*ye),be=(ee+me)*le,ge=Math.cos(be),C=Math.sin(be);K.set(0,0,0),K.addScaledVector(H,C*ye),K.addScaledVector(q,ge),K.addScaledVector(re,C*fe),Z.copy(F).addScaledVector(K,a),c.push(Z.x,Z.y,Z.z),u.push(K.x,K.y,K.z),p.push(0,0),ue.push(d++)}te.push(ue)}let Q=te.length-1;for(let $=0;$<Q;$++){let ue=te[$],le=te[$+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 Ha=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 $e?n.shape:new $e,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(O,S,T){return S>e&&T>t?Math.min(O*e/S,O*t/T):S>e?O*e/S:T>t?O*t/T:O}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 O=0,S=r.points.length;O<S;O++)r.points[O].roundness=h[O],O>0&&h[O]!==h[O-1]&&(v=!1);v&&(r.roundness=h[0]),r.useCubicForRoundedCorners=i!==1,r.update();let P=xr.create({shape:r,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(P,{userData:{...n,type:"RectangleGeometry"}})}};var en=require("three"),w0=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=en.MathUtils.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 en.BufferGeometry,u.setAttribute("position",new en.Float32BufferAttribute([],3))):u=new en.SphereGeometry(.5*r,o,i,a,s,l,c*en.MathUtils.DEG2RAD),u.scale(1,e/r,t/r),Object.assign(u,{userData:{...n,type:"SphereGeometry"}})}};var P0=require("three"),O0=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 P0.PlaneGeometry(r,e,t,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};var Vn=require("three"),C0=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 vf(r,e,t,o,i,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},vf=class extends Vn.BufferGeometry{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=(Z=0,Q=0,$=0)=>new Vn.Vector3(Z,Q,$),f=h(),m=h(),[y,g,v]=[e/2,r/2,t/2],P=-g,O=+g,[S,T,A]=[h(P,-y,+v),h(P,-y,-v),h(P,+y,-v)],x=(Z,Q=!1)=>Math.sin(Z-Math.PI/(1+ +Q)),D=(Z,Q=!1)=>Math.cos(Z-Math.PI/(1+ +Q));A.y=Math.sin(o)*e-y;let N=Math.cos(o)*e-v,I=S.z-u;o<=d?(A.z=Math.min(N,I),A.z==I&&(A.y-=(N-I)/Math.tan(d-o))):T.z=Math.min(T.z-N-v,S.z-u),f.subVectors(S,T),m.subVectors(A,T);let E=Math.min(f.length(),m.length())*i/100,_=E*Math.tan(o/2),B=E/Math.cos(o/2),V=f.clone().normalize().add(m.normalize()).setLength(B).add(T);f.set(0,x(o,!0),D(o,!0)),p.push([A,f.clone()]);let U=(Math.PI-o)/a;for(let Z=0;Z<=a;Z++){let Q=d+o+Z*U;f.set(0,Math.sin(Q)*_,Math.cos(Q)*_),f.add(V),m.set(0,x(Q),D(Q)),p.push([f.clone(),m.clone()])}p.push([S,h(0,1,0)]);let R=Math.sin(U/2)*_*2,W=p.length-1,j=p[0][0].distanceTo(p[1][0]),F=p[W-1][0].distanceTo(p[W][0]),H=j+R*a+F;p[0].push(1);for(let Z=0;Z<=a;Z++)p[Z+1].push(1-(j+Z*R)/H);p[W].push(0);let[q,re,ee]=p[0],X,te,K;for(let Z=1;Z<p.length;Z++)[X,te,K]=p[Z],s.push(P,q.y,q.z,P,X.y,X.z,O,q.y,q.z,O,q.y,q.z,P,X.y,X.z,O,X.y,X.z),l.push(0,re.y,re.z,0,te.y,te.z,0,re.y,re.z,0,re.y,re.z,0,te.y,te.z,0,te.y,te.z),c.push(0,ee,0,K,1,ee,1,ee,0,K,1,K),[q,re,ee]=[X,te,K];this.setAttribute("position",new Vn.Float32BufferAttribute(s,3)),this.setAttribute("normal",new Vn.Float32BufferAttribute(l,3)),this.setAttribute("uv",new Vn.Float32BufferAttribute(c,2))}};var Bu=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 $e?n.shape:new $e,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 O=0;O<o;O++){let S=m*O,T=h+Math.sin(S)*p,A=f+Math.cos(S)*d;u.addPoint(u.createPoint(T,A))}}else for(let O=0;O<o;O++){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,O<=o,u.addPoint(u.createPoint(S,T)),y+=m}u.isClosed=!0;for(let O=0,S=u.points.length;O<S;O++)u.points[O].roundness=i;u.roundness=i,u.update();let P=xr.create({shape:u,parameters:{roundness:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(P,{userData:{...n,type:"StarGeometry"}})}};var T0=require("three"),A0=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 T0.PlaneGeometry(r,e);return Object.assign(t,{userData:{...n,type:"TextFrameGeometry"}})}};var Wa=require("three");var M0=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=hM(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 hM(n,r,e,t,o,i,a,s,l,c,u){[r,e]=[e,r],a=r/2;let p=Wa.MathUtils.clamp(o/360,0,1);if(p===0){let d=new Wa.BufferGeometry;return d.setAttribute("position",new Wa.Float32BufferAttribute([],3)),d}return p===1&&(c=0),new yl(!0,n,r,e,t,p,i,a,s,l,c,u)}var I0=require("three"),N0=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 I0.TorusKnotGeometry(s,e,t,o,i,a);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var E0=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 $e?n.shape:new $e,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=xr.create({shape:l,parameters:{roundness:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...n,type:"TriangleGeometry"}})}};var Me=require("three");function D0(n,r){let e=2*Math.PI;return(n%e+e)%e===(r%e+e)%e}var mM=new Me.Matrix4,yM=new Me.Matrix4;function gM(n,r,e){let t=[new Me.Vector3,new Me.Vector3,new Me.Vector3],o=[new Me.Vector3,new Me.Vector3,new Me.Vector3];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=Me.MathUtils.lerp(i.length(),s.length(),e);i.lerp(s,e).setLength(l)}),new Me.Matrix4().makeBasis(t[0],t[1],t[2])}var _0=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??Fa.create({parameters:Ap}).userData.shape;return{path:n.path??va.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:i,extrusion:{...eu,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new Sf(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new Me.BufferGeometry,{userData:{...n,type:"PathGeometry"}})}},Sf=class extends Me.BufferGeometry{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)||!D0(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 j=0;j<c;j++){let F=this.inputs.path.isClosed?(j+s)%e.length:Math.min(j+s,e.length-1);u.push(e[F].clone()),p.push(t[F].clone())}let d=(j,F,H)=>{u[j]=u[j].clone().lerp(u[F],H),p[j]=gM(p[j],p[F],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 j=u.length-1;u[j].copy(u[0]),p[j].copy(p[0])}this._applyPathModifiers(p,h,m);let{bevel:g,bevelSides:v}=this.inputs.parameters.extrusion,P=g>0?this.inputs.parameters.extrusion.capType:"flat",O=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(O=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:A}=this._computeShapePoints(O),x=0,D;P==="round"&&(D=new Ln(this.inputs.shapeData,2*g,g,O,v,void 0,!0),x=D.getAttribute("position").count);let N=0,I=0;T.sort((j,F)=>j.start-F.start),T.forEach(j=>{j.verticesStart=N,j.verticesCount=j.continuous.reduce((F,H,q)=>F+(q===0||!H?2:1),0),I+=j.verticesCount,N=I});let E=I*c,_,B=0;if(this._isOpenEnded()&&P==="flat"){try{_=no({windingRule:We.ODD,elementType:bt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=pf}B=_.vertexCount}let V=E+2*B+x*2,U=E+2*B,R={positions:new Float32Array(V*3),normals:new Float32Array(V*3),uvs:new Float32Array(V*2)},W=[];if(T.forEach(j=>{this._extrudeRegion(j,A,p,u,R,W,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,E,W,R,p[0],u[0],!1),this._closeEnd(_,E+B,W,R,p[p.length-1],u[u.length-1],!0)),D){R.positions.set(D.getAttribute("position").array,U*3),R.normals.set(D.getAttribute("normal").array,U*3),R.uvs.set(D.getAttribute("uv").array,U*2);for(let q=U;q<U+x;q++)R.uvs[q*2+1]=1e-4;let j=W.length;W.push(...D.getIndex().array.map(q=>q+U)),U+=x,R.positions.set(D.getAttribute("position").array,U*3),R.normals.set(D.getAttribute("normal").array,U*3),R.uvs.set(D.getAttribute("uv").array,U*2);let F=W.length;W.push(...D.getIndex().array.map(q=>q+U)),this.setAttribute("position",new Me.BufferAttribute(R.positions,3)),this.setAttribute("normal",new Me.BufferAttribute(R.normals,3)),this.setAttribute("uv",new Me.BufferAttribute(R.uvs,2)),this.setIndex(W);let H=mM;H.copy(p[p.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(p[0]).setPosition(u[0]).multiply(yM.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-x,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new Me.BufferAttribute(R.positions,3)),this.setAttribute("normal",new Me.BufferAttribute(R.normals,3)),this.setAttribute("uv",new Me.BufferAttribute(R.uvs,2)),this.setIndex(W)}_extractPathPoints(){let t=Su(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 Me.Vector3,s=new Me.Vector3,l=new Me.Vector3,c=new Me.Vector3,u=new Me.Vector3(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 P;y===o-1?P=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):P=e[y+1];let O=g.clone().sub(v).normalize(),S=P.clone().sub(g).normalize(),T=O.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let A=u.clone().cross(T).normalize(),x=T.clone().cross(A).normalize();u.copy(x),c.copy(A),y===0&&(a.copy(x),s.copy(T));let D=new Me.Matrix4().makeBasis(A,x,T);t.push(D)}let p=i?s:l,d=i?a:new Me.Vector3(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 Me.Matrix4().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 Me.Matrix4,p=new Me.Matrix4;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(Me.MathUtils.lerp(a,a+s,f)*Me.MathUtils.DEG2RAD);let m=Me.MathUtils.lerp(l,c,f);p.makeScale(m,m,m),d.multiply(u).multiply(p)}),e}_computeShapePoints(e=12,t=We.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 P=y[v-1],O=y[v-0];g.push(P,O)}return g}),s;try{s=no({windingRule:t,elementType:bt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{s=ml}let l;try{l=no({windingRule:We.ODD,elementType:bt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=df}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],P=s.vertices[g+1];v<u&&(u=v),v>p&&(p=v),P<d&&(d=P),P>h&&(h=P)}let f=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,v=s.elements[g+0],P=s.elements[g+1],O=v+P,S={start:v,count:P,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};f.push(S);let T=v,A=O-1,x=v+1,D=o.roundedCurves.length;do{let N=T-v,I=s.vertices[A*2+0],E=s.vertices[A*2+1],_=s.vertices[T*2+0],B=s.vertices[T*2+1],V=s.vertices[x*2+0],U=s.vertices[x*2+1],R=_-I,W=B-E,j=Math.sqrt(R*R+W*W);R/=j,W/=j;let F=_-V,H=B-U,q=Math.sqrt(F*F+H*H);F/=q,H/=q,S.normals[N*2+0]=-H,S.normals[N*2+1]=F;let re=s.vertexIndices[T];if(Array.isArray(re))S.continuous[N]=!1;else{let[ee,X]=o.getCurveIndexFromVertexId(re-1,!0);if(X>0&&X<1)S.continuous[N]=!0;else{let te=X===1?ee+1:ee-1;te=(te+D)%D;let K=X===1?0:1,Z=o.roundedCurves[ee].getTangent(X),Q=o.roundedCurves[te].getTangent(K);S.continuous[N]=Z.dot(Q)>.95}}y&&(S.normals[N*2+0]*=-1,S.normals[N*2+1]*=-1),[A,T,x]=[T,x,x+1],x>=O&&(x-=P)}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 Me.Vector3,u=new Me.Vector3,p=new Me.Vector3,d=new Me.Vector3,h=new Me.Vector2;o.forEach((m,y)=>{let g=i[y],v=e.verticesStart*o.length+e.verticesCount*y;for(let P=0;P<e.count;P++){let O=(e.start+P)*2;if(c.set(t[O+0],t[O+1],0),p.copy(c).applyMatrix4(m).add(g),e.continuous[P])d.set(e.normals[P*2+0],e.normals[P*2+1],0);else{let S=P===0?(e.start+e.count-1)*2:O-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(P===0?1:P/e.count,y/(o.length-1)),this._insertVertex(a,v,p,d,h),v++,!e.continuous[P]||P===0){if(P===0)d.set(e.normals[P*2+0],e.normals[P*2+1],0),h.set(0,y/(o.length-1));else{let S=P===e.count-1?e.start*2:O+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 P=0;P<e.count;P++){(!e.continuous[P]||P===0)&&v++;let O=P===e.count-1?0:v+1,S=y+v,T=y+O,A=g+O,x=g+v;e.isHole?s.push(S,A,T,S,x,A):s.push(S,T,A,S,A,x),v++}}}_closeEnd(e,t,o,i,a,s,l){let c=e.vertexCount,u=new Me.Vector3(0,0,l?-1:1).applyMatrix4(a),p=new Me.Vector3,d=new Me.Vector2;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 Me.Matrix3().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}}};var xi=require("three"),B0=require("three/examples/jsm/utils/BufferGeometryUtils.js");function L0(){let n=new xi.BufferGeometry;return n.setAttribute("position",new xi.BufferAttribute(new Float32Array([]),3)),n.setIndex(new xi.BufferAttribute(new Uint16Array([]),1)),n}var bM=L0().attributes,vM=12,SM=1,bi=class extends xi.BufferGeometry{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,bM),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=In.getDisplayedValue(c),d=u===2?p.toUpperCase():u===3?p.toLowerCase():p,h=wM(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,P=f.map(T=>new $e().fromShape(T,!0));this.vectorShapes=P;let O=P.map(T=>xr.create({shape:T,parameters:{depth:a,extrudeBevelSegments:l,extrudeBevelSize:s,windingRule:a<=0?We.NONZERO:We.ODD,subdivisions:this.isLowResolution&&a>0?SM:vM}})),S=O.length?(0,B0.mergeBufferGeometries)(O):L0();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,A])=>{this.setAttribute(T,A)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=Zt(new xi.BufferGeometry,bi.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:{textValue:e}})}get text(){return this.userData.parameters.text??""}};function wM(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}var at=require("three");var V0,Ru=new Promise(n=>{V0=n}),R0=!1;var Lu;function G0(){if(R0)return;if(Lu)return Lu;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.9.24/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});V0(l),R0=!0}return Lu=n(),Lu}var z0=require("three");var PM=["font"];function rn(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];Op(p)&&!PM.includes(o)&&(u[o]=r.getVariable(p,[t.uuid,"geometry",...c,o]),Op(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=$e.createFromState(i.shape,i.width,i.height);s.shape=c}else if(i.type==="NonParametricGeometry"){if(i.data.groups&&i.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new z0.BufferGeometryLoader().parse(i),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(i.type==="SubdivGeometry"){let c=new Nt(i,e);return c.data=n,c}else{if(i.type==="TextGeometry")return new bi(i,r);if(i.type==="InputGeometry")return new bi(i,r);if(i.type==="UIGeometry")return Ha.create({parameters:{width:i.width,height:i.height,cornerRadius:i.cornerRadius,cornerType:i.cornerType}})}let l;try{l=wf(s)}catch(c){console.error(c)}if(!l){let c=$e.createFromState(ba.defaultData(),100,100);s.shape=c,l=wf(s)}return l}var j0=require("three"),OM=new j0.Matrix4;function bl(n,r,e,t){let o=n.position.array,i=n.normal.array,a=OM.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 Vu=new at.Box3,qa=new at.Vector3,we;Ru.then(n=>{we=n});var F0=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),U0=new Uint32Array([0,1,2,3]),k0=new Uint8Array([4]),Nt=class extends at.BufferGeometry{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=wn.div(t,o);this.subdividedGeometry&&bl(this.subdividedGeometry.attributes,...i),this.originalGeometry&&bl(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(qa.fromArray(i));let s=qa.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}=Nt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new at.BoxGeometry(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&&(Nt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new at.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Vu.setFromBufferAttribute(t),Vu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Vu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Vu.getSize(qa);let i={width:qa.x,height:qa.y,depth:qa.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&&(we.free_bvh(t),we.free_subdivision_surface(t));try{a=Nt.allocate(e,i)}catch(u){console.error(u,e),a=Nt.allocate({positionWASM:F0,indexWASM:U0,verticesPerFaceWASM:k0},i)}if(we.set_destination_refinement_level(a,0),s=Nt.buildLevel(a,!0,c),e.subdivisions>0)try{we.set_destination_refinement_level(a,e.subdivisions),l=Nt.buildLevel(a,!1,c)}catch{try{we.set_destination_refinement_level(a,e.subdivisions-1),l=Nt.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:rn(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}=Tf(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}=Af(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=F0,i=U0,a=k0);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=we._malloc(f),v=new Float32Array(we.HEAPF32.buffer,g,d),P=new Uint32Array(we.HEAPU32.buffer,g+m,h);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),P.set(i,0),P.set(a,i.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new at.Matrix4().makeScale(...e.scaleBaked)),t&&(O?O.premultiply(t):O=t);let S=O?we.alloc_subdivision_surface2(g,c,g+m,u,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):we.alloc_subdivision_surface(g,c,g+m,u,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p);return we._free(g),S}static buildLevel(e,t,o,i,a){let s=a?we.get_mesh_data2(e,t?we.Level.CONTROL:we.Level.REFINED,o,a.elements):we.get_mesh_data(e,t?we.Level.CONTROL:we.Level.REFINED,o),l=8,c=we.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=we.HEAPU32[c[p]>>2],h=we.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let f=we.HEAPU32[c[p]>>2],m=we.HEAPF32.subarray(f>>2,(f>>2)+u[p]);p++;let y=we.HEAPU32[c[p]>>2],g=we.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=we.HEAPU32[c[p]>>2],P=we.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,i===void 0){let O=new at.BufferGeometry;if(O.setIndex(new at.Uint32BufferAttribute(P,1)),O.setAttribute("position",new at.Float32BufferAttribute(h,3)),O.setAttribute("normal",new at.Float32BufferAttribute(m,3)),t){O.setAttribute("faceMap",new at.Uint32BufferAttribute(g,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new at.BufferAttribute(S,4))}return we.free_mesh_data(s),O.userData.type="SubdivGeometry",O}i.getAttribute("position").copyArray(h),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,we.free_mesh_data(s)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),c=0,u=we.HEAPU32[s[c]>>2],p=we.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=we.HEAPU32[s[c]>>2],h=we.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(t===void 0){let f=new at.BufferGeometry;f.setAttribute("position",new at.Float32BufferAttribute(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 at.BufferAttribute(m,3)),f.setIndex(new at.Uint32BufferAttribute(h,1)),we.free_wireframe_data_for_base_level(i),f}t.getAttribute("position").copyArray(p),t.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||we.set_destination_refinement_level(e,t);let a=o?we.get_topological_data2(e,i?we.Level.CONTROL:we.Level.REFINED,o.elements):we.get_topological_data(e,i?we.Level.CONTROL:we.Level.REFINED),s=6,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=we.HEAPU32[l[u]>>2],d=new Float32Array(we.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let h=we.HEAPU32[l[u]>>2],f=new Uint32Array(we.HEAPU32.subarray(h>>2,(h>>2)+c[u]));u++;let m=we.HEAPU32[l[u]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return we.free_topological_data(a),{positions:d,indices:f,verticesPerFace:y}}};var H0=["getX","getY","getZ"];function Tf(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[H0[d]](u)*s)},`;if(p in e)i.push(e[p]);else{for(let d=0;d<3;d++)a.push(n[H0[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 Gu=new at.Vector3,Pf=new at.Vector3,Of=new at.Vector3,Cf=new at.Vector3;function Af(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]){Gu.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),Pf.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),Of.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]),Pf.sub(Gu).normalize(),Of.sub(Gu).normalize(),Cf.sub(Gu).normalize();let l=Pf.cross(Of).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 jr={};Vh(jr,{calcBoolean:()=>MM,calcBooleanTopological:()=>AM,freeMeshSet:()=>DM,getMeshSet:()=>IM,hasOpenEdges:()=>NM,transformMeshSet:()=>EM});var CM,W0=new Promise(n=>{CM=n});var vl=require("three");var Re,$a;W0.then(n=>Re=n);function TM(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}=Tf(n.getAttribute("position"),o),s;if(r&&e){let{indices:l,verticesPerFace:c}=Af(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 q0(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=Re._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Re.HEAPU32.buffer,i,r):new Float32Array(Re.HEAPF32.buffer,i,r)).set(n,0),i}function $0(n){switch(n){case 0:return Re.OP.UNION;case 1:return Re.OP.INTERSECTION;case 2:return Re.OP.A_MINUS_B;case 3:return Re.OP.B_MINUS_A;case 4:return Re.OP.SYMMETRIC_DIFFERENCE;case 5:return Re.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function AM(n,r){$a===void 0&&($a=Re.init_csg());let e=q0(n),t=Re.csg_calc_topological($a,e,n.length,$0(r));Re._free(e);let o=6,i=Re.HEAPU32.subarray(t>>2,(t>>2)+o),a=i.subarray(3,3+3),s=0,l=Re.HEAPU32[i[s]>>2],c=new Float32Array(Re.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Re.HEAPU32[i[s]>>2],p=new Uint32Array(Re.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Re.HEAPU32[i[s]>>2],h=new Uint8Array(Re.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Re.free_mesh_data(t),{positions:c,indices:p,verticesPerFace:h}}function MM(n,r,e,t){$a===void 0&&($a=Re.init_csg());let o=q0(n),i=Re.csg_calc($a,o,n.length,t,$0(r));Re._free(o);let a=5,s=Re.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),c=0,u=Re.HEAPU32[s[c]>>2],p=Re.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Re.HEAPU32[s[c]>>2],h=Re.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let f=l[c];e.setAttribute("position",new vl.Float32BufferAttribute(p,3)),e.setAttribute("normal",new vl.Float32BufferAttribute(h,3));let m=Re.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new vl.Sphere),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},Re.free_mesh_data(i),f}function IM(n,r,e){if(Re===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,P)=>v+P,0)+i);for(let v=0,P=0,O=0;v<g.verticesPerFace.length;v++){o[O++]=g.verticesPerFace[v];for(let S=0;S<g.verticesPerFace[v];S++)o[O++]=g.indices[P++]}}else({positions:t,faceIndices:o,nFaces:i}=TM(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=Re._malloc(u),f=new Float32Array(Re.HEAPF32.buffer,h,l),m=new Uint32Array(Re.HEAPU32.buffer,h+p,c);f.set(t,0),m.set(o,0);let y=Re.get_csg_mesh(h,a,h+p,s,i);return Re._free(h),y}function NM(n){return Re.has_open_edges(n)}function EM(n,r){Re.transform_csg_mesh(n,r.elements)}function DM(n){Re.free_csg_mesh(n)}var _M={ConeGeometry:Lx,CubeGeometry:Rx,CylinderGeometry:Bx,DodecahedronGeometry:Gx,EllipseGeometry:Fa,HelixGeometry:f0,IcosahedronGeometry:m0,LatheGeometry:y0,NonParametricGeometry:v0,PolygonGeometry:_u,PyramidGeometry:S0,RectangleGeometry:Ha,SphereGeometry:w0,PlaneGeometry:O0,BackdropGeometry:C0,StarGeometry:Bu,TextFrameGeometry:A0,TorusGeometry:M0,TorusKnotGeometry:N0,TriangleGeometry:E0,PathGeometry:_0,VectorGeometry:xr},wf=n=>_M[n.type].create(n);function Ya(n){return n!==null&&"booleanOp"in n}var Xa=class extends _a(zu.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new zu.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!Ya(this.parent)&&this.visible,Ya(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(jr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ya(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Xa&&(e.freeBooleanPointer(),Ya(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let o=super.updateTransformState(e,t);return o&&Ya(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ya(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var ju=new Ka.Box3;function Sl(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)}ju.min.set(i,a,s),ju.max.set(l,c,u),ju.getCenter(t),ju.getSize(o).multiplyScalar(.5)}var BM=new Ka.BufferGeometry,LM=new Ka.MeshBasicMaterial,jt=class extends Xa{constructor(r,e){super(BM,LM),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?Sl(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var sn=require("three");var _r=require("three");var yb=require("three");var on=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(on.uuidContext===null)throw new Error("plz startContext");on.uuidContext===on.globalContext?this.uuid="_gid"+on.uuidContext.nodeContextUuid++:this.uuid="_uid"+on.uuidContext.nodeContextUuid++,this.type=r,this.name=""}static startContext(r){this.uuidContext===null||this.uuidContext===on.globalContext?this.uuidContext=r:console.error("Can't start context twice")}static endContext(r){this.uuidContext!==r&&console.error("Can't end context twice"),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}},tt=on;tt.globalContext={nodeContextUuid:0},tt.uuidContext=on.globalContext;var co=require("three");var wl=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 Mf=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}},Ft=new Mf;var If=require("three");var Y0=require("three"),xe=class extends tt{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=Y0.MathUtils.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 rt=class extends xe{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 vt=class extends rt{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof If.Vector2?e:new If.Vector2(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)}};var Nf=require("three");var er=class extends rt{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Nf.Vector3?e:new Nf.Vector3(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)}};var X0=require("three"),Ut=class extends X0.Color{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 br=class extends rt{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ut?e:new Ut(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 RM=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,K0=/[a-z_0-9]+/gi,J=class extends xe{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&&Ft.containsKeyword(h)){let y=this.keywords[h];if(!y){let g=Ft.getKeywordData(h);g.cache&&(y=e.keywords[h]),y=y||Ft.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&&Ft.contains(m)&&e.include(Ft.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=RM.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 VM=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Ef=class extends xe{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Ef.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=VM.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)}},qe=Ef;qe.PI="PI",qe.PI2="PI2",qe.RECIPROCAL_PI="RECIPROCAL_PI",qe.RECIPROCAL_PI2="RECIPROCAL_PI2",qe.LOG2="LOG2",qe.EPSILON="EPSILON";var GM=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
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}var at=require("three");var V0,Ru=new Promise(n=>{V0=n}),R0=!1;var Lu;function G0(){if(R0)return;if(Lu)return Lu;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.9.25/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});V0(l),R0=!0}return Lu=n(),Lu}var z0=require("three");var PM=["font"];function rn(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];Op(p)&&!PM.includes(o)&&(u[o]=r.getVariable(p,[t.uuid,"geometry",...c,o]),Op(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=$e.createFromState(i.shape,i.width,i.height);s.shape=c}else if(i.type==="NonParametricGeometry"){if(i.data.groups&&i.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new z0.BufferGeometryLoader().parse(i),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(i.type==="SubdivGeometry"){let c=new Nt(i,e);return c.data=n,c}else{if(i.type==="TextGeometry")return new bi(i,r);if(i.type==="InputGeometry")return new bi(i,r);if(i.type==="UIGeometry")return Ha.create({parameters:{width:i.width,height:i.height,cornerRadius:i.cornerRadius,cornerType:i.cornerType}})}let l;try{l=wf(s)}catch(c){console.error(c)}if(!l){let c=$e.createFromState(ba.defaultData(),100,100);s.shape=c,l=wf(s)}return l}var j0=require("three"),OM=new j0.Matrix4;function bl(n,r,e,t){let o=n.position.array,i=n.normal.array,a=OM.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 Vu=new at.Box3,qa=new at.Vector3,we;Ru.then(n=>{we=n});var F0=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),U0=new Uint32Array([0,1,2,3]),k0=new Uint8Array([4]),Nt=class extends at.BufferGeometry{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=wn.div(t,o);this.subdividedGeometry&&bl(this.subdividedGeometry.attributes,...i),this.originalGeometry&&bl(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(qa.fromArray(i));let s=qa.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}=Nt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new at.BoxGeometry(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&&(Nt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new at.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Vu.setFromBufferAttribute(t),Vu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Vu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Vu.getSize(qa);let i={width:qa.x,height:qa.y,depth:qa.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&&(we.free_bvh(t),we.free_subdivision_surface(t));try{a=Nt.allocate(e,i)}catch(u){console.error(u,e),a=Nt.allocate({positionWASM:F0,indexWASM:U0,verticesPerFaceWASM:k0},i)}if(we.set_destination_refinement_level(a,0),s=Nt.buildLevel(a,!0,c),e.subdivisions>0)try{we.set_destination_refinement_level(a,e.subdivisions),l=Nt.buildLevel(a,!1,c)}catch{try{we.set_destination_refinement_level(a,e.subdivisions-1),l=Nt.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:rn(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}=Tf(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}=Af(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=F0,i=U0,a=k0);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=we._malloc(f),v=new Float32Array(we.HEAPF32.buffer,g,d),P=new Uint32Array(we.HEAPU32.buffer,g+m,h);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),P.set(i,0),P.set(a,i.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new at.Matrix4().makeScale(...e.scaleBaked)),t&&(O?O.premultiply(t):O=t);let S=O?we.alloc_subdivision_surface2(g,c,g+m,u,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):we.alloc_subdivision_surface(g,c,g+m,u,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p);return we._free(g),S}static buildLevel(e,t,o,i,a){let s=a?we.get_mesh_data2(e,t?we.Level.CONTROL:we.Level.REFINED,o,a.elements):we.get_mesh_data(e,t?we.Level.CONTROL:we.Level.REFINED,o),l=8,c=we.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=we.HEAPU32[c[p]>>2],h=we.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let f=we.HEAPU32[c[p]>>2],m=we.HEAPF32.subarray(f>>2,(f>>2)+u[p]);p++;let y=we.HEAPU32[c[p]>>2],g=we.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=we.HEAPU32[c[p]>>2],P=we.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,i===void 0){let O=new at.BufferGeometry;if(O.setIndex(new at.Uint32BufferAttribute(P,1)),O.setAttribute("position",new at.Float32BufferAttribute(h,3)),O.setAttribute("normal",new at.Float32BufferAttribute(m,3)),t){O.setAttribute("faceMap",new at.Uint32BufferAttribute(g,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new at.BufferAttribute(S,4))}return we.free_mesh_data(s),O.userData.type="SubdivGeometry",O}i.getAttribute("position").copyArray(h),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,we.free_mesh_data(s)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),c=0,u=we.HEAPU32[s[c]>>2],p=we.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=we.HEAPU32[s[c]>>2],h=we.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(t===void 0){let f=new at.BufferGeometry;f.setAttribute("position",new at.Float32BufferAttribute(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 at.BufferAttribute(m,3)),f.setIndex(new at.Uint32BufferAttribute(h,1)),we.free_wireframe_data_for_base_level(i),f}t.getAttribute("position").copyArray(p),t.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||we.set_destination_refinement_level(e,t);let a=o?we.get_topological_data2(e,i?we.Level.CONTROL:we.Level.REFINED,o.elements):we.get_topological_data(e,i?we.Level.CONTROL:we.Level.REFINED),s=6,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=we.HEAPU32[l[u]>>2],d=new Float32Array(we.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let h=we.HEAPU32[l[u]>>2],f=new Uint32Array(we.HEAPU32.subarray(h>>2,(h>>2)+c[u]));u++;let m=we.HEAPU32[l[u]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return we.free_topological_data(a),{positions:d,indices:f,verticesPerFace:y}}};var H0=["getX","getY","getZ"];function Tf(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[H0[d]](u)*s)},`;if(p in e)i.push(e[p]);else{for(let d=0;d<3;d++)a.push(n[H0[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 Gu=new at.Vector3,Pf=new at.Vector3,Of=new at.Vector3,Cf=new at.Vector3;function Af(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]){Gu.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),Pf.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),Of.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]),Pf.sub(Gu).normalize(),Of.sub(Gu).normalize(),Cf.sub(Gu).normalize();let l=Pf.cross(Of).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 jr={};Vh(jr,{calcBoolean:()=>MM,calcBooleanTopological:()=>AM,freeMeshSet:()=>DM,getMeshSet:()=>IM,hasOpenEdges:()=>NM,transformMeshSet:()=>EM});var CM,W0=new Promise(n=>{CM=n});var vl=require("three");var Re,$a;W0.then(n=>Re=n);function TM(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}=Tf(n.getAttribute("position"),o),s;if(r&&e){let{indices:l,verticesPerFace:c}=Af(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 q0(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=Re._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Re.HEAPU32.buffer,i,r):new Float32Array(Re.HEAPF32.buffer,i,r)).set(n,0),i}function $0(n){switch(n){case 0:return Re.OP.UNION;case 1:return Re.OP.INTERSECTION;case 2:return Re.OP.A_MINUS_B;case 3:return Re.OP.B_MINUS_A;case 4:return Re.OP.SYMMETRIC_DIFFERENCE;case 5:return Re.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function AM(n,r){$a===void 0&&($a=Re.init_csg());let e=q0(n),t=Re.csg_calc_topological($a,e,n.length,$0(r));Re._free(e);let o=6,i=Re.HEAPU32.subarray(t>>2,(t>>2)+o),a=i.subarray(3,3+3),s=0,l=Re.HEAPU32[i[s]>>2],c=new Float32Array(Re.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Re.HEAPU32[i[s]>>2],p=new Uint32Array(Re.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Re.HEAPU32[i[s]>>2],h=new Uint8Array(Re.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Re.free_mesh_data(t),{positions:c,indices:p,verticesPerFace:h}}function MM(n,r,e,t){$a===void 0&&($a=Re.init_csg());let o=q0(n),i=Re.csg_calc($a,o,n.length,t,$0(r));Re._free(o);let a=5,s=Re.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),c=0,u=Re.HEAPU32[s[c]>>2],p=Re.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Re.HEAPU32[s[c]>>2],h=Re.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let f=l[c];e.setAttribute("position",new vl.Float32BufferAttribute(p,3)),e.setAttribute("normal",new vl.Float32BufferAttribute(h,3));let m=Re.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new vl.Sphere),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},Re.free_mesh_data(i),f}function IM(n,r,e){if(Re===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,P)=>v+P,0)+i);for(let v=0,P=0,O=0;v<g.verticesPerFace.length;v++){o[O++]=g.verticesPerFace[v];for(let S=0;S<g.verticesPerFace[v];S++)o[O++]=g.indices[P++]}}else({positions:t,faceIndices:o,nFaces:i}=TM(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=Re._malloc(u),f=new Float32Array(Re.HEAPF32.buffer,h,l),m=new Uint32Array(Re.HEAPU32.buffer,h+p,c);f.set(t,0),m.set(o,0);let y=Re.get_csg_mesh(h,a,h+p,s,i);return Re._free(h),y}function NM(n){return Re.has_open_edges(n)}function EM(n,r){Re.transform_csg_mesh(n,r.elements)}function DM(n){Re.free_csg_mesh(n)}var _M={ConeGeometry:Lx,CubeGeometry:Rx,CylinderGeometry:Bx,DodecahedronGeometry:Gx,EllipseGeometry:Fa,HelixGeometry:f0,IcosahedronGeometry:m0,LatheGeometry:y0,NonParametricGeometry:v0,PolygonGeometry:_u,PyramidGeometry:S0,RectangleGeometry:Ha,SphereGeometry:w0,PlaneGeometry:O0,BackdropGeometry:C0,StarGeometry:Bu,TextFrameGeometry:A0,TorusGeometry:M0,TorusKnotGeometry:N0,TriangleGeometry:E0,PathGeometry:_0,VectorGeometry:xr},wf=n=>_M[n.type].create(n);function Ya(n){return n!==null&&"booleanOp"in n}var Xa=class extends _a(zu.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new zu.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!Ya(this.parent)&&this.visible,Ya(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(jr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ya(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Xa&&(e.freeBooleanPointer(),Ya(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let o=super.updateTransformState(e,t);return o&&Ya(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ya(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var ju=new Ka.Box3;function Sl(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)}ju.min.set(i,a,s),ju.max.set(l,c,u),ju.getCenter(t),ju.getSize(o).multiplyScalar(.5)}var BM=new Ka.BufferGeometry,LM=new Ka.MeshBasicMaterial,jt=class extends Xa{constructor(r,e){super(BM,LM),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?Sl(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var sn=require("three");var _r=require("three");var yb=require("three");var on=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(on.uuidContext===null)throw new Error("plz startContext");on.uuidContext===on.globalContext?this.uuid="_gid"+on.uuidContext.nodeContextUuid++:this.uuid="_uid"+on.uuidContext.nodeContextUuid++,this.type=r,this.name=""}static startContext(r){this.uuidContext===null||this.uuidContext===on.globalContext?this.uuidContext=r:console.error("Can't start context twice")}static endContext(r){this.uuidContext!==r&&console.error("Can't end context twice"),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}},tt=on;tt.globalContext={nodeContextUuid:0},tt.uuidContext=on.globalContext;var co=require("three");var wl=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 Mf=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}},Ft=new Mf;var If=require("three");var Y0=require("three"),xe=class extends tt{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=Y0.MathUtils.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 rt=class extends xe{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 vt=class extends rt{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof If.Vector2?e:new If.Vector2(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)}};var Nf=require("three");var er=class extends rt{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Nf.Vector3?e:new Nf.Vector3(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)}};var X0=require("three"),Ut=class extends X0.Color{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 br=class extends rt{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ut?e:new Ut(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 RM=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,K0=/[a-z_0-9]+/gi,J=class extends xe{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&&Ft.containsKeyword(h)){let y=this.keywords[h];if(!y){let g=Ft.getKeywordData(h);g.cache&&(y=e.keywords[h]),y=y||Ft.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&&Ft.contains(m)&&e.include(Ft.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=RM.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 VM=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Ef=class extends xe{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Ef.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=VM.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)}},qe=Ef;qe.PI="PI",qe.PI2="PI2",qe.RECIPROCAL_PI="RECIPROCAL_PI",qe.RECIPROCAL_PI2="RECIPROCAL_PI2",qe.LOG2="LOG2",qe.EPSILON="EPSILON";var GM=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
5
5
|
)*?)}`,"gim"),zM=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Qa=class extends xe{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=GM.exec(e);if(t){let o=t[2],i;for(;i=zM.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}};var Za=class extends xe{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)}};Ft.addKeyword("uv",function(){return new Za});Ft.addKeyword("uv2",function(){return new Za(1)});var Fu=require("three");var vi=class extends xe{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??vi.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Fu.LinearEncoding:return["Linear"];case Fu.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),i=this.getType(e),a=vi.Nodes[this.method],s=e.include(a);if(s===vi.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=vi.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=vi.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},ur=vi;ur.Nodes={LinearToLinear:new J(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
6
6
|
`)),sRGBToLinear:new J(["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 J(["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(`
|
|
@@ -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 Ee={normalRenderTarget:new dr,normalRenderTargetDepth:new dr,transmissionRenderTarget:new dr,aspectRatio:new vt,transmissionSize:new vt(2048,2048),transmissionRenderTargetDepth:new dr,aoRenderTarget:new dr,aoEnabled:new At,pixelRatioNode:new se(1),resolution:new vt,penumbraSize:new uo(5,.5),frameIndex:new ze(0),transmissionLod:new ze(2)};for(let n of Object.values(Ee))n.isRenderGlobal=!0;var pb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.9.
|
|
1823
|
+
}`,[e,t])}}();var Ee={normalRenderTarget:new dr,normalRenderTargetDepth:new dr,transmissionRenderTarget:new dr,aspectRatio:new vt,transmissionSize:new vt(2048,2048),transmissionRenderTargetDepth:new dr,aoRenderTarget:new dr,aoEnabled:new At,pixelRatioNode:new se(1),resolution:new vt,penumbraSize:new uo(5,.5),frameIndex:new ze(0),transmissionLod:new ze(2)};for(let n of Object.values(Ee))n.isRenderGlobal=!0;var pb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.9.25/build/ui.wasm"};var nn=class extends tt{constructor(){super("basic");this.nodeType="Basic";this.color=new Ze(It),this.shadingAlpha=new se(1),this.shadingBlend=new ze(0),this.previousModelViewMatrix=new tr,this.previouseProjectionMatrix=new tr}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:Ee.frameIndex}),e.mergeUniform({resolution:Ee.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(qu.UniformsUtils.merge([qu.UniformsLib.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>
|
|
@@ -3656,4 +3656,4 @@ void main() {
|
|
|
3656
3656
|
A = exp(A) * vColor.a;
|
|
3657
3657
|
gl_FragColor = vec4(color.rgb, A);
|
|
3658
3658
|
gVelocity = vec4(0.0); // so it is ignored by TAA
|
|
3659
|
-
}`,i={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Oe.Vector2},viewport:{type:"v2",value:new Oe.Vector2},basisViewport:{type:"v2",value:new Oe.Vector2},debugColor:{type:"v3",value:new Oe.Color},covariancesTextureSize:{type:"v2",value:new Oe.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Oe.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Oe.ShaderMaterial({uniforms:i,vertexShader:t,fragmentShader:o,transparent:!0,alphaTest:1,blending:Oe.NormalBlending,depthTest:!0,depthWrite:!1,side:Oe.DoubleSide})}static buildGeomtery(e){let t=new Oe.BufferGeometry;t.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new Oe.BufferAttribute(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 Oe.InstancedBufferGeometry().copy(t),s=new Uint32Array(e),l=new Oe.InstancedBufferAttribute(s,1,!1);return l.setUsage(Oe.DynamicDrawUsage),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 Oe.Vector2(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new Oe.Vector2(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]=Oe.DataUtils.toHalfFloat(this.covariances[f]);s=new Oe.DataTexture(l,i.x,i.y,Oe.RGFormat,Oe.HalfFloatType)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new Oe.DataTexture(l,i.x,i.y,Oe.RGFormat,Oe.FloatType);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]=gS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=Rd(this.centers[y]),c[g+2]=Rd(this.centers[y+1]),c[g+3]=Rd(this.centers[y+2])}let u=new Oe.DataTexture(c,a.x,a.y,Oe.RGBAIntegerFormat,Oe.UnsignedIntType);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 Oe.DataTexture(d,p,1,Oe.RGBAFormat,Oe.FloatType);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&&(Vd.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Vd),this.material.uniforms.basisViewport.value.set(2/Vd.x,2/Vd.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 bS,Th=new Promise(n=>{bS=n}),xS=!1;var zd;function Ah(){if(xS)return;if(zd)return zd;async function n(){let e=await import("./gaussian-splat-compression.js");bS(e),xS=!0}return zd=n(),zd}var vS;Th.then(n=>vS=n);var Ql=class{constructor(r={}){ii(this,"updateView",function(){let r=new hr.Matrix4,e=[],t=new hr.Vector3(0,0,-1),o=new hr.Vector3(0,0,-1),i=new hr.Vector3,a=new hr.Vector3;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 hr.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(r,e){let t=new hr.Vector2;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 hr.Vector3().fromArray(r.position)),r.orientation&&(r.orientation=new hr.Quaternion().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 vS.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 hr.Vector3,o=new hr.Quaternion,i=!1,a=1,s,l){this.splatMesh=Zn.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=yS(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 gN=new Xr.MeshBasicMaterial;gN.wireframe=!0;var SS=new Xr.Vector3,jd=class extends Xr.Scene{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 Ld;this.invisibleObjects=new $n("jflkdsafjasdifjaslk",{...au.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new $r("fdasfa",{...qo.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=hS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=fS(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 $r&&(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)=>ac(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===On)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 $r&&t.uiScene){let o=t.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof $r&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(o=>{t===void 0&&o instanceof Bi&&(t=o.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof $r&&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(),qn(i)&&Ul(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),Ul(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),qn(o)&&(o.freeBooleanPointer(),i instanceof Pr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Vs&&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()),qn(o)&&(o.invalidateUpstreamBooleanData(),Ul(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof Pr&&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 $r&&(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{uS(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 Bi||l instanceof $r)&&(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 cn&&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){Fe.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Fe.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=xn(u.data,p=>{let d=p.events.data(l.id),h=u.goUp(s);if(h){let f=[...ic(h.identity),e].join("-"),m=this.entityIdentityToEntity[f];if(m){let y=m.uuid,g=ct.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):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...t,l.id,"ifActions"],o,i,a,s),this.rewriteActions(l.data.elseActions,[...t,l.id,"elseActions"],o,i,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof pn&&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=xn(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of uu.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 pn&&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),Id(a)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof pn&&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)Fe.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(Fe.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(qn(s)||kl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Kl(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;Fe.is(a)&&(a.visible||s?.object.data.visible)&&((qn(a)||kl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),Kl(a,e,t,!0)),o(a))}};return o(this),t}forEachEntity(e){for(let t of this.children)Fe.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)Fe.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)Fe.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.type==="InputGeometry")&&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();Ul(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)Ia.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Fe.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=Bd(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 Xr.Matrix4().fromArray(m)),f=new Xr.Skeleton(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 Xr.Box3;return o.setFromPoints(t),o.getCenter(SS),SS}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 jt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof Sr&&e(t.material[o]);else t.material instanceof Sr&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(i=>{i instanceof cn&&i.setViewplaneSize(e,t,o)})}initializeSplatViewer(){this.splatViewer=new Ql({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var wS=require("three/examples/jsm/loaders/DRACOLoader.js");var Jn;function PS(){return Jn||(Jn=new wS.DRACOLoader,Jn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Jn.decoderPending}async function xN(n){if(Jn){let r={attributeIDs:Jn.defaultAttributeIDs,attributeTypes:Jn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Jn.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 OS(n,r){let[e,t]=dp($c.deserialize(new Uint8Array(n)));return pu(e),r&&r(e),t.result().data}function CS(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 TS(n){for(let r of n){let e=await xN(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}}}var bN=require("three"),vN=require("three/examples/jsm/utils/BufferGeometryUtils.js");function AS(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}var Zl=require("three");function MS(n){let r=new Set;return n.traverse(e=>{if(e instanceof wr)if(Pt(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(SN(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Zl.Color,specularColor:new Zl.Color});let o=0;e.onBeforeCompile=(i,a)=>{t&&t(i,a),i.uniforms=Object.assign({},Zl.ShaderLib.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=db(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else wN(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function SN(n){return n.getLayersOfType("transmission").length>0}function wN(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 IS(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function NS(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}var ES=require("three/examples/jsm/utils/BufferGeometryUtils.js");function DS(n){let r=[];return n.traverse(e=>{e instanceof Cs&&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&&AS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&t instanceof jt&&a.unshift(t.geometry),a.length){let s=(0,ES.mergeBufferGeometries)(a);t instanceof jt&&(t.geometry=s)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:Ib})}),n}function _S(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function BS(n){Object.values(n.shared.materials).forEach(r=>{Mh(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?Mh(e.material):"materials"in e&&e.materials.forEach(t=>{Mh(t)})})}function Mh(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 GS=zi(RS(),1);var VS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Fd=class extends Ud.Loader{load(r,e,t,o=console.error){let i=new Ud.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(VS+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(VS),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 OS(r,BS),t=CS(e);e.version&&(0,GS.default)(e.version,"1.9.24")>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&&PS(),Bb(e)&&G0(),Wb(e)&&Pb(),Cv(e)&&wv(),Gd(e)&&Ah()].filter(Boolean)),t.length&&await TS(t);let o=!1,i=new Ii(e.shared,{},o);Object.values(i.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new jd(e.scene,i);Gd(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=DS(a),a=MS(a),a=IS(a),a=NS(a),a=_S(a),a}};
|
|
3659
|
+
}`,i={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Oe.Vector2},viewport:{type:"v2",value:new Oe.Vector2},basisViewport:{type:"v2",value:new Oe.Vector2},debugColor:{type:"v3",value:new Oe.Color},covariancesTextureSize:{type:"v2",value:new Oe.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Oe.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Oe.ShaderMaterial({uniforms:i,vertexShader:t,fragmentShader:o,transparent:!0,alphaTest:1,blending:Oe.NormalBlending,depthTest:!0,depthWrite:!1,side:Oe.DoubleSide})}static buildGeomtery(e){let t=new Oe.BufferGeometry;t.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new Oe.BufferAttribute(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 Oe.InstancedBufferGeometry().copy(t),s=new Uint32Array(e),l=new Oe.InstancedBufferAttribute(s,1,!1);return l.setUsage(Oe.DynamicDrawUsage),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 Oe.Vector2(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new Oe.Vector2(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]=Oe.DataUtils.toHalfFloat(this.covariances[f]);s=new Oe.DataTexture(l,i.x,i.y,Oe.RGFormat,Oe.HalfFloatType)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new Oe.DataTexture(l,i.x,i.y,Oe.RGFormat,Oe.FloatType);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]=gS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=Rd(this.centers[y]),c[g+2]=Rd(this.centers[y+1]),c[g+3]=Rd(this.centers[y+2])}let u=new Oe.DataTexture(c,a.x,a.y,Oe.RGBAIntegerFormat,Oe.UnsignedIntType);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 Oe.DataTexture(d,p,1,Oe.RGBAFormat,Oe.FloatType);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&&(Vd.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Vd),this.material.uniforms.basisViewport.value.set(2/Vd.x,2/Vd.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 bS,Th=new Promise(n=>{bS=n}),xS=!1;var zd;function Ah(){if(xS)return;if(zd)return zd;async function n(){let e=await import("./gaussian-splat-compression.js");bS(e),xS=!0}return zd=n(),zd}var vS;Th.then(n=>vS=n);var Ql=class{constructor(r={}){ii(this,"updateView",function(){let r=new hr.Matrix4,e=[],t=new hr.Vector3(0,0,-1),o=new hr.Vector3(0,0,-1),i=new hr.Vector3,a=new hr.Vector3;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 hr.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(r,e){let t=new hr.Vector2;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 hr.Vector3().fromArray(r.position)),r.orientation&&(r.orientation=new hr.Quaternion().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 vS.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 hr.Vector3,o=new hr.Quaternion,i=!1,a=1,s,l){this.splatMesh=Zn.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=yS(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 gN=new Xr.MeshBasicMaterial;gN.wireframe=!0;var SS=new Xr.Vector3,jd=class extends Xr.Scene{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 Ld;this.invisibleObjects=new $n("jflkdsafjasdifjaslk",{...au.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new $r("fdasfa",{...qo.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=hS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=fS(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 $r&&(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)=>ac(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===On)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 $r&&t.uiScene){let o=t.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof $r&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(o=>{t===void 0&&o instanceof Bi&&(t=o.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof $r&&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(),qn(i)&&Ul(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),Ul(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),qn(o)&&(o.freeBooleanPointer(),i instanceof Pr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Vs&&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()),qn(o)&&(o.invalidateUpstreamBooleanData(),Ul(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof Pr&&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 $r&&(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{uS(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 Bi||l instanceof $r)&&(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 cn&&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){Fe.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Fe.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=xn(u.data,p=>{let d=p.events.data(l.id),h=u.goUp(s);if(h){let f=[...ic(h.identity),e].join("-"),m=this.entityIdentityToEntity[f];if(m){let y=m.uuid,g=ct.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):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...t,l.id,"ifActions"],o,i,a,s),this.rewriteActions(l.data.elseActions,[...t,l.id,"elseActions"],o,i,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof pn&&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=xn(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of uu.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 pn&&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),Id(a)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof pn&&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)Fe.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(Fe.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(qn(s)||kl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Kl(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;Fe.is(a)&&(a.visible||s?.object.data.visible)&&((qn(a)||kl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),Kl(a,e,t,!0)),o(a))}};return o(this),t}forEachEntity(e){for(let t of this.children)Fe.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)Fe.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)Fe.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.type==="InputGeometry")&&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();Ul(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)Ia.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Fe.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=Bd(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 Xr.Matrix4().fromArray(m)),f=new Xr.Skeleton(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 Xr.Box3;return o.setFromPoints(t),o.getCenter(SS),SS}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 jt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof Sr&&e(t.material[o]);else t.material instanceof Sr&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(i=>{i instanceof cn&&i.setViewplaneSize(e,t,o)})}initializeSplatViewer(){this.splatViewer=new Ql({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var wS=require("three/examples/jsm/loaders/DRACOLoader.js");var Jn;function PS(){return Jn||(Jn=new wS.DRACOLoader,Jn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Jn.decoderPending}async function xN(n){if(Jn){let r={attributeIDs:Jn.defaultAttributeIDs,attributeTypes:Jn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Jn.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 OS(n,r){let[e,t]=dp($c.deserialize(new Uint8Array(n)));return pu(e),r&&r(e),t.result().data}function CS(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 TS(n){for(let r of n){let e=await xN(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}}}var bN=require("three"),vN=require("three/examples/jsm/utils/BufferGeometryUtils.js");function AS(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}var Zl=require("three");function MS(n){let r=new Set;return n.traverse(e=>{if(e instanceof wr)if(Pt(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(SN(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Zl.Color,specularColor:new Zl.Color});let o=0;e.onBeforeCompile=(i,a)=>{t&&t(i,a),i.uniforms=Object.assign({},Zl.ShaderLib.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=db(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else wN(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function SN(n){return n.getLayersOfType("transmission").length>0}function wN(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 IS(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function NS(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}var ES=require("three/examples/jsm/utils/BufferGeometryUtils.js");function DS(n){let r=[];return n.traverse(e=>{e instanceof Cs&&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&&AS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&t instanceof jt&&a.unshift(t.geometry),a.length){let s=(0,ES.mergeBufferGeometries)(a);t instanceof jt&&(t.geometry=s)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:Ib})}),n}function _S(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function BS(n){Object.values(n.shared.materials).forEach(r=>{Mh(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?Mh(e.material):"materials"in e&&e.materials.forEach(t=>{Mh(t)})})}function Mh(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 GS=zi(RS(),1);var VS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Fd=class extends Ud.Loader{load(r,e,t,o=console.error){let i=new Ud.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(VS+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(VS),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 OS(r,BS),t=CS(e);e.version&&(0,GS.default)(e.version,"1.9.25")>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&&PS(),Bb(e)&&G0(),Wb(e)&&Pb(),Cv(e)&&wv(),Gd(e)&&Ah()].filter(Boolean)),t.length&&await TS(t);let o=!1,i=new Ii(e.shared,{},o);Object.values(i.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new jd(e.scene,i);Gd(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=DS(a),a=MS(a),a=IS(a),a=NS(a),a=_S(a),a}};
|