@splinetool/loader 1.10.27 → 1.10.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- var nw=Object.create;var kl=Object.defineProperty;var aw=Object.getOwnPropertyDescriptor;var sw=Object.getOwnPropertyNames;var lw=Object.getPrototypeOf,cw=Object.prototype.hasOwnProperty;var uw=(i,r,e)=>r in i?kl(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e;var As=(i,r)=>()=>(r||i((r={exports:{}}).exports,r),r.exports),dw=(i,r)=>{for(var e in r)kl(i,e,{get:r[e],enumerable:!0})},pw=(i,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of sw(r))!cw.call(i,o)&&o!==e&&kl(i,o,{get:()=>r[o],enumerable:!(t=aw(r,o))||t.enumerable});return i};var Ms=(i,r,e)=>(e=i!=null?nw(lw(i)):{},pw(r||!i||!i.__esModule?kl(e,"default",{value:i,enumerable:!0}):e,i));var qi=(i,r,e)=>(uw(i,typeof r!="symbol"?r+"":r,e),e);var tx=As((zp,ex)=>{(function(i,r){typeof zp=="object"?ex.exports=r():typeof define=="function"&&define.amd?define(r):i.Alea=r()})(zp,function(){"use strict";return i.importState=function(e){var t=new i;return t.importState(e),t},i;function i(){return function(e){var t=0,o=0,n=0,a=1;e.length==0&&(e=[+new Date]);var s=r();t=s(" "),o=s(" "),n=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),n-=s(e[l]),n<0&&(n+=1);s=null;var c=function(){var u=2091639*t+a*23283064365386963e-26;return t=o,o=n,n=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,n,a]},c.importState=function(u){t=+u[0]||0,o=+u[1]||0,n=+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 n=0;n<o.length;n++){e+=o.charCodeAt(n);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 sx=As((lu,ax)=>{(function(i,r){typeof lu=="object"&&typeof ax<"u"?r(lu):typeof define=="function"&&define.amd?define(["exports"],r):r((i=typeof globalThis<"u"?globalThis:i||self).SVDJS={})})(lu,function(i){"use strict";i.SVD=function(r,e,t,o,n){if(e=e===void 0||e,t=t===void 0||t,n=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,f,h,m,y,b,v=r[0].length,w=r.length;if(w<v)throw new TypeError("Invalid matrix: m < n");for(var O=[],S=[],T=[],M=e==="f"?w:v,g=m=d=0;g<w;g++)S[g]=new Array(M).fill(0);for(g=0;g<v;g++)T[g]=new Array(v).fill(0);var D,E=new Array(v).fill(0);for(g=0;g<w;g++)for(a=0;a<v;a++)S[g][a]=r[g][a];for(g=0;g<v;g++){for(O[g]=d,h=0,l=g+1,a=g;a<w;a++)h+=Math.pow(S[a][g],2);if(h<n)d=0;else for(f=(p=S[g][g])*(d=p<0?Math.sqrt(h):-Math.sqrt(h))-h,S[g][g]=p-d,a=l;a<v;a++){for(h=0,s=g;s<w;s++)h+=S[s][g]*S[s][a];for(p=h/f,s=g;s<w;s++)S[s][a]=S[s][a]+p*S[s][g]}for(E[g]=d,h=0,a=l;a<v;a++)h+=Math.pow(S[g][a],2);if(h<n)d=0;else{for(f=(p=S[g][g+1])*(d=p<0?Math.sqrt(h):-Math.sqrt(h))-h,S[g][g+1]=p-d,a=l;a<v;a++)O[a]=S[g][a]/f;for(a=l;a<w;a++){for(h=0,s=l;s<v;s++)h+=S[a][s]*S[g][s];for(s=l;s<v;s++)S[a][s]=S[a][s]+h*O[s]}}m<(y=Math.abs(E[g])+Math.abs(O[g]))&&(m=y)}if(t)for(g=v-1;0<=g;g--){if(d!==0){for(f=S[g][g+1]*d,a=l;a<v;a++)T[a][g]=S[g][a]/f;for(a=l;a<v;a++){for(h=0,s=l;s<v;s++)h+=S[g][s]*T[s][a];for(s=l;s<v;s++)T[s][a]=T[s][a]+h*T[s][g]}}for(a=l;a<v;a++)T[g][a]=0,T[a][g]=0;T[g][g]=1,d=O[g],l=g}if(e){if(e==="f")for(g=v;g<w;g++){for(a=v;a<w;a++)S[g][a]=0;S[g][g]=1}for(g=v-1;0<=g;g--){for(l=g+1,d=E[g],a=l;a<M;a++)S[g][a]=0;if(d!==0){for(f=S[g][g]*d,a=l;a<M;a++){for(h=0,s=l;s<w;s++)h+=S[s][g]*S[s][a];for(p=h/f,s=g;s<w;s++)S[s][a]=S[s][a]+p*S[s][g]}for(a=g;a<w;a++)S[a][g]=S[a][g]/d}else for(a=g;a<w;a++)S[a][g]=0;S[g][g]=S[g][g]+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(E[l-1])<=o)break}if(!D){for(u=0,c=l-(h=1),g=l;g<s+1&&(p=h*O[g],O[g]=u*O[g],!(Math.abs(p)<=o));g++)if(d=E[g],E[g]=Math.sqrt(p*p+d*d),u=d/(f=E[g]),h=-p/f,e)for(a=0;a<w;a++)y=S[a][c],b=S[a][g],S[a][c]=y*u+b*h,S[a][g]=-y*h+b*u}if(b=E[s],l===s){if(b<0&&(E[s]=-b,t))for(a=0;a<v;a++)T[a][s]=-T[a][s];break}for(m=E[l],p=(((y=E[s-1])-b)*(y+b)+((d=O[s-1])-(f=O[s]))*(d+f))/(2*f*y),d=Math.sqrt(p*p+1),p=((m-b)*(m+b)+f*(y/(p<0?p-d:p+d)-f))/m,g=l+(h=u=1);g<s+1;g++){if(d=O[g],y=E[g],f=h*d,d*=u,b=Math.sqrt(p*p+f*f),p=m*(u=p/(O[g-1]=b))+d*(h=f/b),d=-m*h+d*u,f=y*h,y*=u,t)for(a=0;a<v;a++)m=T[a][g-1],b=T[a][g],T[a][g-1]=m*u+b*h,T[a][g]=-m*h+b*u;if(b=Math.sqrt(p*p+f*f),p=(u=p/(E[g-1]=b))*d+(h=f/b)*y,m=-h*d+u*y,e)for(a=0;a<w;a++)y=S[a][g-1],b=S[a][g],S[a][g-1]=y*u+b*h,S[a][g]=-y*h+b*u}O[l]=0,O[s]=p,E[s]=m}for(g=0;g<v;g++)E[g]<o&&(E[g]=0);return{u:S,q:E,v:T}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})});var P1=As((Fle,w1)=>{"use strict";function i_(i,r){function e(){this.constructor=i}e.prototype=r.prototype,i.prototype=new e}function Sn(i,r,e,t){this.message=i,this.expected=r,this.found=e,this.location=t,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Sn)}i_(Sn,Error);Sn.buildMessage=function(i,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?n(c.parts[p][0])+"-"+n(c.parts[p][1]):n(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 n(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(i)+" but "+l(r)+" found."};function n_(i,r){r=r!==void 0?r:{};var e={},t={svg_path:Cs},o=Cs,n=function(x){if(!x)return[];for(var P=[],L=0;L<x.length;L++)P=P.concat.apply(P,x[L]);var A=P[0];return A&&A.code=="m"&&(delete A.relative,A.code="M"),P},a=function(x,P){return iw(x,P)},s=/^[Mm]/,l=Ye(["M","m"],!1,!1),c=function(x,P,L){var A=An(x,[P]);return L&&(A=A.concat(An(x=="M"?"L":"l",L[1]))),A},u=/^[Zz]/,p=Ye(["Z","z"],!1,!1),d=function(){return An("Z")},f=/^[Ll]/,h=Ye(["L","l"],!1,!1),m=function(x,P){return An(x,P)},y=/^[Hh]/,b=Ye(["H","h"],!1,!1),v=function(x,P){return An(x,P.map(function(L){return{x:L}}))},w=/^[Vv]/,O=Ye(["V","v"],!1,!1),S=function(x,P){return An(x,P.map(function(L){return{y:L}}))},T=/^[Cc]/,M=Ye(["C","c"],!1,!1),g=function(x,P,L){return{x1:x.x,y1:x.y,x2:P.x,y2:P.y,x:L.x,y:L.y}},D=/^[Ss]/,E=Ye(["S","s"],!1,!1),I=function(x,P){return{x2:x.x,y2:x.y,x:P.x,y:P.y}},N=/^[Qq]/,_=Ye(["Q","q"],!1,!1),R=function(x,P){return{x1:x.x,y1:x.y,x:P.x,y:P.y}},V=/^[Tt]/,U=Ye(["T","t"],!1,!1),B=/^[Aa]/,q=Ye(["A","a"],!1,!1),j=function(x,P,L,A,z,oe){return{rx:x,ry:P,xAxisRotation:L,largeArc:A,sweep:z,x:oe.x,y:oe.y}},F=function(x,P){return{x,y:P}},H=function(x){return x*1},W=function(x){return x.join("")*1},ee=/^[01]/,te=Ye(["0","1"],!1,!1),Y=function(x){return x=="1"},re=function(){return""},K=",",Z=it(",",!1),Q=function(x){return x.join("")},$=".",ue=it(".",!1),le=/^[eE]/,ie=Ye(["e","E"],!1,!1),ce=/^[+\-]/,ae=Ye(["+","-"],!1,!1),me=/^[0-9]/,pe=Ye([["0","9"]],!1,!1),he=function(x){return x.join("")},xe=/^[ \t\n\r]/,ye=Ye([" "," ",`
2
- `,"\r"],!1,!1),C=0,ne=0,Ne=[{line:1,column:1}],Ve=0,_e=[],Pe=0,vt;if("startRule"in r){if(!(r.startRule in t))throw new Error(`Can't start parsing from rule "`+r.startRule+'".');o=t[r.startRule]}function Me(){return i.substring(ne,C)}function xt(){return ki(ne,C)}function St(x,P){throw P=P!==void 0?P:ki(ne,C),mr([Fd(x)],i.substring(ne,C),P)}function Ui(x,P){throw P=P!==void 0?P:ki(ne,C),jd(x,P)}function it(x,P){return{type:"literal",text:x,ignoreCase:P}}function Ye(x,P,L){return{type:"class",parts:x,inverted:P,ignoreCase:L}}function Er(){return{type:"any"}}function Gd(){return{type:"end"}}function Fd(x){return{type:"other",description:x}}function zl(x){var P=Ne[x],L;if(P)return P;for(L=x-1;!Ne[L];)L--;for(P=Ne[L],P={line:P.line,column:P.column};L<x;)i.charCodeAt(L)===10?(P.line++,P.column=1):P.column++,L++;return Ne[x]=P,P}function ki(x,P){var L=zl(x),A=zl(P);return{start:{offset:x,line:L.line,column:L.column},end:{offset:P,line:A.line,column:A.column}}}function ct(x){C<Ve||(C>Ve&&(Ve=C,_e=[]),_e.push(x))}function jd(x,P){return new Sn(x,null,null,P)}function mr(x,P,L){return new Sn(Sn.buildMessage(x,P),x,P,L)}function Cs(){var x,P,L,A,z;for(x=C,P=[],L=ze();L!==e;)P.push(L),L=ze();if(P!==e)if(L=Ht(),L===e&&(L=null),L!==e){for(A=[],z=ze();z!==e;)A.push(z),z=ze();A!==e?(ne=x,P=n(L),x=P):(C=x,x=e)}else C=x,x=e;else C=x,x=e;return x}function Ht(){var x,P,L,A,z,oe;if(x=C,P=Hi(),P!==e){for(L=[],A=C,z=[],oe=ze();oe!==e;)z.push(oe),oe=ze();for(z!==e?(oe=Hi(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;){for(L.push(A),A=C,z=[],oe=ze();oe!==e;)z.push(oe),oe=ze();z!==e?(oe=Hi(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e)}L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function Hi(){var x,P,L,A,z,oe;if(x=C,P=Tn(),P!==e){for(L=[],A=C,z=[],oe=ze();oe!==e;)z.push(oe),oe=ze();for(z!==e?(oe=Gl(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;){for(L.push(A),A=C,z=[],oe=ze();oe!==e;)z.push(oe),oe=ze();z!==e?(oe=Gl(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e)}L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function Gl(){var x;return x=kS(),x===e&&(x=HS(),x===e&&(x=WS(),x===e&&(x=qS(),x===e&&(x=$S(),x===e&&(x=YS(),x===e&&(x=QS(),x===e&&(x=JS(),x===e&&(x=tw())))))))),x}function Tn(){var x,P,L,A,z,oe,Mn;if(x=C,s.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(l)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=qt(),A!==e?(z=C,oe=tt(),oe===e&&(oe=null),oe!==e?(Mn=sm(),Mn!==e?(oe=[oe,Mn],z=oe):(C=z,z=e)):(C=z,z=e),z===e&&(z=null),z!==e?(ne=x,P=c(P,A,z),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function kS(){var x,P;return x=C,u.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(p)),P!==e&&(ne=x,P=d()),x=P,x}function HS(){var x,P,L,A;if(x=C,f.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(h)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=sm(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function sm(){var x,P,L,A,z,oe;if(x=C,P=qt(),P!==e){for(L=[],A=C,z=tt(),z===e&&(z=null),z!==e?(oe=qt(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=tt(),z===e&&(z=null),z!==e?(oe=qt(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function WS(){var x,P,L,A;if(x=C,y.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(b)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=lm(),A!==e?(ne=x,P=v(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function lm(){var x,P,L,A,z,oe;if(x=C,P=Cn(),P!==e){for(L=[],A=C,z=tt(),z===e&&(z=null),z!==e?(oe=Cn(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=tt(),z===e&&(z=null),z!==e?(oe=Cn(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function qS(){var x,P,L,A;if(x=C,w.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(O)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=lm(),A!==e?(ne=x,P=S(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function $S(){var x,P,L,A;if(x=C,T.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(M)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=XS(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function XS(){var x,P,L,A,z,oe;if(x=C,P=Ud(),P!==e){for(L=[],A=C,z=tt(),z===e&&(z=null),z!==e?(oe=Ud(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=tt(),z===e&&(z=null),z!==e?(oe=Ud(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function Ud(){var x,P,L,A,z,oe;return x=C,P=qt(),P!==e?(L=tt(),L===e&&(L=null),L!==e?(A=qt(),A!==e?(z=tt(),z===e&&(z=null),z!==e?(oe=qt(),oe!==e?(ne=x,P=g(P,A,oe),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function YS(){var x,P,L,A;if(x=C,D.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(E)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=KS(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function KS(){var x,P,L,A,z,oe;if(x=C,P=kd(),P!==e){for(L=[],A=C,z=tt(),z===e&&(z=null),z!==e?(oe=kd(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=tt(),z===e&&(z=null),z!==e?(oe=kd(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function kd(){var x,P,L,A;return x=C,P=qt(),P!==e?(L=tt(),L===e&&(L=null),L!==e?(A=qt(),A!==e?(ne=x,P=I(P,A),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function QS(){var x,P,L,A;if(x=C,N.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(_)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=ZS(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function ZS(){var x,P,L,A,z,oe;if(x=C,P=Hd(),P!==e){for(L=[],A=C,z=tt(),z===e&&(z=null),z!==e?(oe=Hd(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=tt(),z===e&&(z=null),z!==e?(oe=Hd(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function Hd(){var x,P,L,A;return x=C,P=qt(),P!==e?(L=tt(),L===e&&(L=null),L!==e?(A=qt(),A!==e?(ne=x,P=R(P,A),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function JS(){var x,P,L,A;if(x=C,V.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(U)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=ew(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function ew(){var x,P,L,A,z,oe;if(x=C,P=qt(),P!==e){for(L=[],A=C,z=tt(),z===e&&(z=null),z!==e?(oe=qt(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=tt(),z===e&&(z=null),z!==e?(oe=qt(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function tw(){var x,P,L,A;if(x=C,B.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(q)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=rw(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function rw(){var x,P,L,A,z,oe;if(x=C,P=Wd(),P!==e){for(L=[],A=C,z=tt(),z===e&&(z=null),z!==e?(oe=Wd(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=tt(),z===e&&(z=null),z!==e?(oe=Wd(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function Wd(){var x,P,L,A,z,oe,Mn,$d,jl,Xd,Ul,Yd;return x=C,P=cm(),P!==e?(L=tt(),L===e&&(L=null),L!==e?(A=cm(),A!==e?(z=tt(),z===e&&(z=null),z!==e?(oe=Cn(),oe!==e?(Mn=tt(),Mn!==e?($d=um(),$d!==e?(jl=tt(),jl===e&&(jl=null),jl!==e?(Xd=um(),Xd!==e?(Ul=tt(),Ul===e&&(Ul=null),Ul!==e?(Yd=qt(),Yd!==e?(ne=x,P=j(P,A,oe,$d,Xd,Yd),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function qt(){var x,P,L,A;return x=C,P=Cn(),P!==e?(L=tt(),L===e&&(L=null),L!==e?(A=Cn(),A!==e?(ne=x,P=F(P,A),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function cm(){var x,P;return x=C,P=pm(),P===e&&(P=Wi()),P!==e&&(ne=x,P=H(P)),x=P,x}function Cn(){var x,P,L,A;return x=C,P=C,L=qd(),L===e&&(L=null),L!==e?(A=pm(),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e),P===e&&(P=C,L=qd(),L===e&&(L=null),L!==e?(A=Wi(),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e)),P!==e&&(ne=x,P=W(P)),x=P,x}function um(){var x,P;return x=C,ee.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(te)),P!==e&&(ne=x,P=Y(P)),x=P,x}function tt(){var x,P,L,A,z;if(x=C,P=[],L=ze(),L!==e)for(;L!==e;)P.push(L),L=ze();else P=e;if(P!==e)if(L=dm(),L===e&&(L=null),L!==e){for(A=[],z=ze();z!==e;)A.push(z),z=ze();A!==e?(P=[P,L,A],x=P):(C=x,x=e)}else C=x,x=e;else C=x,x=e;if(x===e){if(x=C,P=C,L=dm(),L!==e){for(A=[],z=ze();z!==e;)A.push(z),z=ze();A!==e?(L=[L,A],P=L):(C=P,P=e)}else C=P,P=e;P!==e&&(ne=x,P=re()),x=P}return x}function dm(){var x;return i.charCodeAt(C)===44?(x=K,C++):(x=e,Pe===0&&ct(Z)),x}function pm(){var x,P,L,A;return x=C,P=C,L=ow(),L!==e?(A=fm(),A===e&&(A=null),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e),P===e&&(P=C,L=Wi(),L!==e?(A=fm(),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e)),P!==e&&(ne=x,P=Q(P)),x=P,x}function ow(){var x,P,L,A,z;return x=C,P=C,L=Wi(),L===e&&(L=null),L!==e?(i.charCodeAt(C)===46?(A=$,C++):(A=e,Pe===0&&ct(ue)),A!==e?(z=Wi(),z!==e?(L=[L,A,z],P=L):(C=P,P=e)):(C=P,P=e)):(C=P,P=e),P===e&&(P=C,L=Wi(),L!==e?(i.charCodeAt(C)===46?(A=$,C++):(A=e,Pe===0&&ct(ue)),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e)),P!==e&&(ne=x,P=Q(P)),x=P,x}function fm(){var x,P,L,A,z;return x=C,P=C,le.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Pe===0&&ct(ie)),L!==e?(A=qd(),A===e&&(A=null),A!==e?(z=Wi(),z!==e?(L=[L,A,z],P=L):(C=P,P=e)):(C=P,P=e)):(C=P,P=e),P!==e&&(ne=x,P=Q(P)),x=P,x}function qd(){var x;return ce.test(i.charAt(C))?(x=i.charAt(C),C++):(x=e,Pe===0&&ct(ae)),x}function Wi(){var x,P,L;if(x=C,P=[],me.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Pe===0&&ct(pe)),L!==e)for(;L!==e;)P.push(L),me.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Pe===0&&ct(pe));else P=e;return P!==e&&(ne=x,P=he(P)),x=P,x}function ze(){var x,P;return x=C,xe.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(ye)),P!==e&&(ne=x,P=re()),x=P,x}function iw(x,P){if(!P)return[x];for(var L=[x],A=0,z=P.length;A<z;A++)L[A+1]=P[A][1];return L}var Fl={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 hm in Fl)Fl[hm.toUpperCase()]=Fl[hm];function An(x,P){P||(P=[{}]);for(var L=P.length;L--;){var A={code:x,command:Fl[x]};x==x.toLowerCase()&&(A.relative=!0);for(var z in P[L])A[z]=P[L][z];P[L]=A}return P}if(vt=o(),vt!==e&&C===i.length)return vt;throw vt!==e&&C<i.length&&ct(Gd()),mr(_e,Ve<i.length?i.charAt(Ve):null,Ve<i.length?ki(Ve,Ve+1):ki(Ve,Ve))}w1.exports={SyntaxError:Sn,parse:n_}});var Rh=As((jle,O1)=>{var xd=P1().parse;xd.parseSVG=xd;xd.makeAbsolute=a_;O1.exports=xd;function a_(i){var r,e={x:0,y:0},t={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return i.forEach(function(o){o.command==="moveto"&&(r=o),o.x0=e.x,o.y0=e.y;for(var n in t)n in o&&(o[n]+=o.relative?o[t[n]]: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}),i}});var FS=As((lye,GS)=>{GS.exports=function(r,e){for(var t=r.split("."),o=e.split("."),n=0;n<3;n++){var a=Number(t[n]),s=Number(o[n]);if(a>s)return 1;if(s>a)return-1;if(!isNaN(a)&&isNaN(s))return 1;if(isNaN(a)&&!isNaN(s))return-1}return 0}});import{FileLoader as lL,Loader as cL}from"three";function Hl(i){for(let r of Object.keys(i))i[r]===void 0&&delete i[r];return i}function Bt(i,r){return Object.setPrototypeOf(i,r),i}function Wl(i){return Array.isArray(i)?i:[i]}function ql(i,r){let e=0;for(;e<i.length&&e<r.length;){if(i[e]<r[e])return-1;if(i[e]>r[e])return 1;e+=1}return e!==r.length?-1:e!==i.length?1:0}var fw=typeof global=="object"&&global&&global.Object===Object&&global,$l=fw;var hw=typeof self=="object"&&self&&self.Object===Object&&self,mw=$l||hw||Function("return this")(),ut=mw;var yw=ut.Symbol,Mt=yw;var mm=Object.prototype,gw=mm.hasOwnProperty,xw=mm.toString,Is=Mt?Mt.toStringTag:void 0;function bw(i){var r=gw.call(i,Is),e=i[Is];try{i[Is]=void 0;var t=!0}catch{}var o=xw.call(i);return t&&(r?i[Is]=e:delete i[Is]),o}var ym=bw;var vw=Object.prototype,Sw=vw.toString;function ww(i){return Sw.call(i)}var gm=ww;var Pw="[object Null]",Ow="[object Undefined]",xm=Mt?Mt.toStringTag:void 0;function Tw(i){return i==null?i===void 0?Ow:Pw:xm&&xm in Object(i)?ym(i):gm(i)}var lr=Tw;function Cw(i){return i!=null&&typeof i=="object"}var Vt=Cw;var Aw="[object Symbol]";function Mw(i){return typeof i=="symbol"||Vt(i)&&lr(i)==Aw}var ei=Mw;function Iw(i,r){for(var e=-1,t=i==null?0:i.length,o=Array(t);++e<t;)o[e]=r(i[e],e,i);return o}var Xl=Iw;var Ew=Array.isArray,dt=Ew;var Nw=1/0,bm=Mt?Mt.prototype:void 0,vm=bm?bm.toString:void 0;function Sm(i){if(typeof i=="string")return i;if(dt(i))return Xl(i,Sm)+"";if(ei(i))return vm?vm.call(i):"";var r=i+"";return r=="0"&&1/i==-Nw?"-0":r}var wm=Sm;var Dw=/\s/;function _w(i){for(var r=i.length;r--&&Dw.test(i.charAt(r)););return r}var Pm=_w;var Rw=/^\s+/;function Lw(i){return i&&i.slice(0,Pm(i)+1).replace(Rw,"")}var Om=Lw;function Bw(i){var r=typeof i;return i!=null&&(r=="object"||r=="function")}var It=Bw;var Tm=0/0,Vw=/^[-+]0x[0-9a-f]+$/i,zw=/^0b[01]+$/i,Gw=/^0o[0-7]+$/i,Fw=parseInt;function jw(i){if(typeof i=="number")return i;if(ei(i))return Tm;if(It(i)){var r=typeof i.valueOf=="function"?i.valueOf():i;i=It(r)?r+"":r}if(typeof i!="string")return i===0?i:+i;i=Om(i);var e=zw.test(i);return e||Gw.test(i)?Fw(i.slice(2),e?2:8):Vw.test(i)?Tm:+i}var Kd=jw;function Uw(i){return i}var Cm=Uw;var kw="[object AsyncFunction]",Hw="[object Function]",Ww="[object GeneratorFunction]",qw="[object Proxy]";function $w(i){if(!It(i))return!1;var r=lr(i);return r==Hw||r==Ww||r==kw||r==qw}var Yl=$w;var Xw=ut["__core-js_shared__"],Kl=Xw;var Am=function(){var i=/[^.]+$/.exec(Kl&&Kl.keys&&Kl.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function Yw(i){return!!Am&&Am in i}var Mm=Yw;var Kw=Function.prototype,Qw=Kw.toString;function Zw(i){if(i!=null){try{return Qw.call(i)}catch{}try{return i+""}catch{}}return""}var Oo=Zw;var Jw=/[\\^$.*+?()[\]{}|]/g,e2=/^\[object .+?Constructor\]$/,t2=Function.prototype,r2=Object.prototype,o2=t2.toString,i2=r2.hasOwnProperty,n2=RegExp("^"+o2.call(i2).replace(Jw,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function a2(i){if(!It(i)||Mm(i))return!1;var r=Yl(i)?n2:e2;return r.test(Oo(i))}var Im=a2;function s2(i,r){return i?.[r]}var Em=s2;function l2(i,r){var e=Em(i,r);return Im(e)?e:void 0}var Zt=l2;var c2=Zt(ut,"WeakMap"),Ql=c2;var Nm=Object.create,u2=function(){function i(){}return function(r){if(!It(r))return{};if(Nm)return Nm(r);i.prototype=r;var e=new i;return i.prototype=void 0,e}}(),Dm=u2;function d2(i,r,e){switch(e.length){case 0:return i.call(r);case 1:return i.call(r,e[0]);case 2:return i.call(r,e[0],e[1]);case 3:return i.call(r,e[0],e[1],e[2])}return i.apply(r,e)}var _m=d2;function p2(i,r){var e=-1,t=i.length;for(r||(r=Array(t));++e<t;)r[e]=i[e];return r}var Rm=p2;var f2=800,h2=16,m2=Date.now;function y2(i){var r=0,e=0;return function(){var t=m2(),o=h2-(t-e);if(e=t,o>0){if(++r>=f2)return arguments[0]}else r=0;return i.apply(void 0,arguments)}}var Lm=y2;function g2(i){return function(){return i}}var Bm=g2;var x2=function(){try{var i=Zt(Object,"defineProperty");return i({},"",{}),i}catch{}}(),In=x2;var b2=In?function(i,r){return In(i,"toString",{configurable:!0,enumerable:!1,value:Bm(r),writable:!0})}:Cm,Vm=b2;var v2=Lm(Vm),zm=v2;function S2(i,r){for(var e=-1,t=i==null?0:i.length;++e<t&&r(i[e],e,i)!==!1;);return i}var Gm=S2;var w2=9007199254740991,P2=/^(?:0|[1-9]\d*)$/;function O2(i,r){var e=typeof i;return r=r??w2,!!r&&(e=="number"||e!="symbol"&&P2.test(i))&&i>-1&&i%1==0&&i<r}var En=O2;function T2(i,r,e){r=="__proto__"&&In?In(i,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[r]=e}var Zl=T2;function C2(i,r){return i===r||i!==i&&r!==r}var Nn=C2;var A2=Object.prototype,M2=A2.hasOwnProperty;function I2(i,r,e){var t=i[r];(!(M2.call(i,r)&&Nn(t,e))||e===void 0&&!(r in i))&&Zl(i,r,e)}var Dn=I2;function E2(i,r,e,t){var o=!e;e||(e={});for(var n=-1,a=r.length;++n<a;){var s=r[n],l=t?t(e[s],i[s],s,e,i):void 0;l===void 0&&(l=i[s]),o?Zl(e,s,l):Dn(e,s,l)}return e}var Yr=E2;var Fm=Math.max;function N2(i,r,e){return r=Fm(r===void 0?i.length-1:r,0),function(){for(var t=arguments,o=-1,n=Fm(t.length-r,0),a=Array(n);++o<n;)a[o]=t[r+o];o=-1;for(var s=Array(r+1);++o<r;)s[o]=t[o];return s[r]=e(a),_m(i,this,s)}}var jm=N2;var D2=9007199254740991;function _2(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=D2}var _n=_2;function R2(i){return i!=null&&_n(i.length)&&!Yl(i)}var Jl=R2;var L2=Object.prototype;function B2(i){var r=i&&i.constructor,e=typeof r=="function"&&r.prototype||L2;return i===e}var Rn=B2;function V2(i,r){for(var e=-1,t=Array(i);++e<i;)t[e]=r(e);return t}var Um=V2;var z2="[object Arguments]";function G2(i){return Vt(i)&&lr(i)==z2}var Qd=G2;var km=Object.prototype,F2=km.hasOwnProperty,j2=km.propertyIsEnumerable,U2=Qd(function(){return arguments}())?Qd:function(i){return Vt(i)&&F2.call(i,"callee")&&!j2.call(i,"callee")},Ln=U2;function k2(){return!1}var Hm=k2;var $m=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Wm=$m&&typeof module=="object"&&module&&!module.nodeType&&module,H2=Wm&&Wm.exports===$m,qm=H2?ut.Buffer:void 0,W2=qm?qm.isBuffer:void 0,q2=W2||Hm,$i=q2;var $2="[object Arguments]",X2="[object Array]",Y2="[object Boolean]",K2="[object Date]",Q2="[object Error]",Z2="[object Function]",J2="[object Map]",eP="[object Number]",tP="[object Object]",rP="[object RegExp]",oP="[object Set]",iP="[object String]",nP="[object WeakMap]",aP="[object ArrayBuffer]",sP="[object DataView]",lP="[object Float32Array]",cP="[object Float64Array]",uP="[object Int8Array]",dP="[object Int16Array]",pP="[object Int32Array]",fP="[object Uint8Array]",hP="[object Uint8ClampedArray]",mP="[object Uint16Array]",yP="[object Uint32Array]",rt={};rt[lP]=rt[cP]=rt[uP]=rt[dP]=rt[pP]=rt[fP]=rt[hP]=rt[mP]=rt[yP]=!0;rt[$2]=rt[X2]=rt[aP]=rt[Y2]=rt[sP]=rt[K2]=rt[Q2]=rt[Z2]=rt[J2]=rt[eP]=rt[tP]=rt[rP]=rt[oP]=rt[iP]=rt[nP]=!1;function gP(i){return Vt(i)&&_n(i.length)&&!!rt[lr(i)]}var Xm=gP;function xP(i){return function(r){return i(r)}}var Bn=xP;var Ym=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Es=Ym&&typeof module=="object"&&module&&!module.nodeType&&module,bP=Es&&Es.exports===Ym,Zd=bP&&$l.process,vP=function(){try{var i=Es&&Es.require&&Es.require("util").types;return i||Zd&&Zd.binding&&Zd.binding("util")}catch{}}(),To=vP;var Km=To&&To.isTypedArray,SP=Km?Bn(Km):Xm,ec=SP;var wP=Object.prototype,PP=wP.hasOwnProperty;function OP(i,r){var e=dt(i),t=!e&&Ln(i),o=!e&&!t&&$i(i),n=!e&&!t&&!o&&ec(i),a=e||t||o||n,s=a?Um(i.length,String):[],l=s.length;for(var c in i)(r||PP.call(i,c))&&!(a&&(c=="length"||o&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||En(c,l)))&&s.push(c);return s}var tc=OP;function TP(i,r){return function(e){return i(r(e))}}var rc=TP;var CP=rc(Object.keys,Object),Qm=CP;var AP=Object.prototype,MP=AP.hasOwnProperty;function IP(i){if(!Rn(i))return Qm(i);var r=[];for(var e in Object(i))MP.call(i,e)&&e!="constructor"&&r.push(e);return r}var Zm=IP;function EP(i){return Jl(i)?tc(i):Zm(i)}var Vn=EP;function NP(i){var r=[];if(i!=null)for(var e in Object(i))r.push(e);return r}var Jm=NP;var DP=Object.prototype,_P=DP.hasOwnProperty;function RP(i){if(!It(i))return Jm(i);var r=Rn(i),e=[];for(var t in i)t=="constructor"&&(r||!_P.call(i,t))||e.push(t);return e}var ey=RP;function LP(i){return Jl(i)?tc(i,!0):ey(i)}var zn=LP;var BP=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,VP=/^\w*$/;function zP(i,r){if(dt(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||ei(i)?!0:VP.test(i)||!BP.test(i)||r!=null&&i in Object(r)}var ty=zP;var GP=Zt(Object,"create"),Co=GP;function FP(){this.__data__=Co?Co(null):{},this.size=0}var ry=FP;function jP(i){var r=this.has(i)&&delete this.__data__[i];return this.size-=r?1:0,r}var oy=jP;var UP="__lodash_hash_undefined__",kP=Object.prototype,HP=kP.hasOwnProperty;function WP(i){var r=this.__data__;if(Co){var e=r[i];return e===UP?void 0:e}return HP.call(r,i)?r[i]:void 0}var iy=WP;var qP=Object.prototype,$P=qP.hasOwnProperty;function XP(i){var r=this.__data__;return Co?r[i]!==void 0:$P.call(r,i)}var ny=XP;var YP="__lodash_hash_undefined__";function KP(i,r){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=Co&&r===void 0?YP:r,this}var ay=KP;function Gn(i){var r=-1,e=i==null?0:i.length;for(this.clear();++r<e;){var t=i[r];this.set(t[0],t[1])}}Gn.prototype.clear=ry;Gn.prototype.delete=oy;Gn.prototype.get=iy;Gn.prototype.has=ny;Gn.prototype.set=ay;var Jd=Gn;function QP(){this.__data__=[],this.size=0}var sy=QP;function ZP(i,r){for(var e=i.length;e--;)if(Nn(i[e][0],r))return e;return-1}var ti=ZP;var JP=Array.prototype,eO=JP.splice;function tO(i){var r=this.__data__,e=ti(r,i);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():eO.call(r,e,1),--this.size,!0}var ly=tO;function rO(i){var r=this.__data__,e=ti(r,i);return e<0?void 0:r[e][1]}var cy=rO;function oO(i){return ti(this.__data__,i)>-1}var uy=oO;function iO(i,r){var e=this.__data__,t=ti(e,i);return t<0?(++this.size,e.push([i,r])):e[t][1]=r,this}var dy=iO;function Fn(i){var r=-1,e=i==null?0:i.length;for(this.clear();++r<e;){var t=i[r];this.set(t[0],t[1])}}Fn.prototype.clear=sy;Fn.prototype.delete=ly;Fn.prototype.get=cy;Fn.prototype.has=uy;Fn.prototype.set=dy;var ri=Fn;var nO=Zt(ut,"Map"),oi=nO;function aO(){this.size=0,this.__data__={hash:new Jd,map:new(oi||ri),string:new Jd}}var py=aO;function sO(i){var r=typeof i;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?i!=="__proto__":i===null}var fy=sO;function lO(i,r){var e=i.__data__;return fy(r)?e[typeof r=="string"?"string":"hash"]:e.map}var ii=lO;function cO(i){var r=ii(this,i).delete(i);return this.size-=r?1:0,r}var hy=cO;function uO(i){return ii(this,i).get(i)}var my=uO;function dO(i){return ii(this,i).has(i)}var yy=dO;function pO(i,r){var e=ii(this,i),t=e.size;return e.set(i,r),this.size+=e.size==t?0:1,this}var gy=pO;function jn(i){var r=-1,e=i==null?0:i.length;for(this.clear();++r<e;){var t=i[r];this.set(t[0],t[1])}}jn.prototype.clear=py;jn.prototype.delete=hy;jn.prototype.get=my;jn.prototype.has=yy;jn.prototype.set=gy;var Xi=jn;var fO="Expected a function";function ep(i,r){if(typeof i!="function"||r!=null&&typeof r!="function")throw new TypeError(fO);var e=function(){var t=arguments,o=r?r.apply(this,t):t[0],n=e.cache;if(n.has(o))return n.get(o);var a=i.apply(this,t);return e.cache=n.set(o,a)||n,a};return e.cache=new(ep.Cache||Xi),e}ep.Cache=Xi;var xy=ep;var hO=500;function mO(i){var r=xy(i,function(t){return e.size===hO&&e.clear(),t}),e=r.cache;return r}var by=mO;var yO=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,gO=/\\(\\)?/g,xO=by(function(i){var r=[];return i.charCodeAt(0)===46&&r.push(""),i.replace(yO,function(e,t,o,n){r.push(o?n.replace(gO,"$1"):t||e)}),r}),vy=xO;function bO(i){return i==null?"":wm(i)}var Sy=bO;function vO(i,r){return dt(i)?i:ty(i,r)?[i]:vy(Sy(i))}var yr=vO;var SO=1/0;function wO(i){if(typeof i=="string"||ei(i))return i;var r=i+"";return r=="0"&&1/i==-SO?"-0":r}var ni=wO;function PO(i,r){r=yr(r,i);for(var e=0,t=r.length;i!=null&&e<t;)i=i[ni(r[e++])];return e&&e==t?i:void 0}var oc=PO;function OO(i,r){for(var e=-1,t=r.length,o=i.length;++e<t;)i[o+e]=r[e];return i}var Un=OO;var wy=Mt?Mt.isConcatSpreadable:void 0;function TO(i){return dt(i)||Ln(i)||!!(wy&&i&&i[wy])}var Py=TO;function Oy(i,r,e,t,o){var n=-1,a=i.length;for(e||(e=Py),o||(o=[]);++n<a;){var s=i[n];r>0&&e(s)?r>1?Oy(s,r-1,e,t,o):Un(o,s):t||(o[o.length]=s)}return o}var Ty=Oy;function CO(i){var r=i==null?0:i.length;return r?Ty(i,1):[]}var Cy=CO;function AO(i){return zm(jm(i,void 0,Cy),i+"")}var ic=AO;var MO=rc(Object.getPrototypeOf,Object),kn=MO;var IO="[object Object]",EO=Function.prototype,NO=Object.prototype,Ay=EO.toString,DO=NO.hasOwnProperty,_O=Ay.call(Object);function RO(i){if(!Vt(i)||lr(i)!=IO)return!1;var r=kn(i);if(r===null)return!0;var e=DO.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&Ay.call(e)==_O}var My=RO;function LO(i,r,e){var t=-1,o=i.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 n=Array(o);++t<o;)n[t]=i[t+r];return n}var Iy=LO;function BO(){this.__data__=new ri,this.size=0}var Ey=BO;function VO(i){var r=this.__data__,e=r.delete(i);return this.size=r.size,e}var Ny=VO;function zO(i){return this.__data__.get(i)}var Dy=zO;function GO(i){return this.__data__.has(i)}var _y=GO;var FO=200;function jO(i,r){var e=this.__data__;if(e instanceof ri){var t=e.__data__;if(!oi||t.length<FO-1)return t.push([i,r]),this.size=++e.size,this;e=this.__data__=new Xi(t)}return e.set(i,r),this.size=e.size,this}var Ry=jO;function Hn(i){var r=this.__data__=new ri(i);this.size=r.size}Hn.prototype.clear=Ey;Hn.prototype.delete=Ny;Hn.prototype.get=Dy;Hn.prototype.has=_y;Hn.prototype.set=Ry;var Wn=Hn;function UO(i,r){return i&&Yr(r,Vn(r),i)}var Ly=UO;function kO(i,r){return i&&Yr(r,zn(r),i)}var By=kO;var Fy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vy=Fy&&typeof module=="object"&&module&&!module.nodeType&&module,HO=Vy&&Vy.exports===Fy,zy=HO?ut.Buffer:void 0,Gy=zy?zy.allocUnsafe:void 0;function WO(i,r){if(r)return i.slice();var e=i.length,t=Gy?Gy(e):new i.constructor(e);return i.copy(t),t}var jy=WO;function qO(i,r){for(var e=-1,t=i==null?0:i.length,o=0,n=[];++e<t;){var a=i[e];r(a,e,i)&&(n[o++]=a)}return n}var Uy=qO;function $O(){return[]}var nc=$O;var XO=Object.prototype,YO=XO.propertyIsEnumerable,ky=Object.getOwnPropertySymbols,KO=ky?function(i){return i==null?[]:(i=Object(i),Uy(ky(i),function(r){return YO.call(i,r)}))}:nc,qn=KO;function QO(i,r){return Yr(i,qn(i),r)}var Hy=QO;var ZO=Object.getOwnPropertySymbols,JO=ZO?function(i){for(var r=[];i;)Un(r,qn(i)),i=kn(i);return r}:nc,ac=JO;function eT(i,r){return Yr(i,ac(i),r)}var Wy=eT;function tT(i,r,e){var t=r(i);return dt(i)?t:Un(t,e(i))}var sc=tT;function rT(i){return sc(i,Vn,qn)}var Ns=rT;function oT(i){return sc(i,zn,ac)}var lc=oT;var iT=Zt(ut,"DataView"),cc=iT;var nT=Zt(ut,"Promise"),uc=nT;var aT=Zt(ut,"Set"),dc=aT;var qy="[object Map]",sT="[object Object]",$y="[object Promise]",Xy="[object Set]",Yy="[object WeakMap]",Ky="[object DataView]",lT=Oo(cc),cT=Oo(oi),uT=Oo(uc),dT=Oo(dc),pT=Oo(Ql),Yi=lr;(cc&&Yi(new cc(new ArrayBuffer(1)))!=Ky||oi&&Yi(new oi)!=qy||uc&&Yi(uc.resolve())!=$y||dc&&Yi(new dc)!=Xy||Ql&&Yi(new Ql)!=Yy)&&(Yi=function(i){var r=lr(i),e=r==sT?i.constructor:void 0,t=e?Oo(e):"";if(t)switch(t){case lT:return Ky;case cT:return qy;case uT:return $y;case dT:return Xy;case pT:return Yy}return r});var Ao=Yi;var fT=Object.prototype,hT=fT.hasOwnProperty;function mT(i){var r=i.length,e=new i.constructor(r);return r&&typeof i[0]=="string"&&hT.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var Qy=mT;var yT=ut.Uint8Array,$n=yT;function gT(i){var r=new i.constructor(i.byteLength);return new $n(r).set(new $n(i)),r}var Xn=gT;function xT(i,r){var e=r?Xn(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var Zy=xT;var bT=/\w*$/;function vT(i){var r=new i.constructor(i.source,bT.exec(i));return r.lastIndex=i.lastIndex,r}var Jy=vT;var eg=Mt?Mt.prototype:void 0,tg=eg?eg.valueOf:void 0;function ST(i){return tg?Object(tg.call(i)):{}}var rg=ST;function wT(i,r){var e=r?Xn(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var og=wT;var PT="[object Boolean]",OT="[object Date]",TT="[object Map]",CT="[object Number]",AT="[object RegExp]",MT="[object Set]",IT="[object String]",ET="[object Symbol]",NT="[object ArrayBuffer]",DT="[object DataView]",_T="[object Float32Array]",RT="[object Float64Array]",LT="[object Int8Array]",BT="[object Int16Array]",VT="[object Int32Array]",zT="[object Uint8Array]",GT="[object Uint8ClampedArray]",FT="[object Uint16Array]",jT="[object Uint32Array]";function UT(i,r,e){var t=i.constructor;switch(r){case NT:return Xn(i);case PT:case OT:return new t(+i);case DT:return Zy(i,e);case _T:case RT:case LT:case BT:case VT:case zT:case GT:case FT:case jT:return og(i,e);case TT:return new t;case CT:case IT:return new t(i);case AT:return Jy(i);case MT:return new t;case ET:return rg(i)}}var ig=UT;function kT(i){return typeof i.constructor=="function"&&!Rn(i)?Dm(kn(i)):{}}var ng=kT;var HT="[object Map]";function WT(i){return Vt(i)&&Ao(i)==HT}var ag=WT;var sg=To&&To.isMap,qT=sg?Bn(sg):ag,lg=qT;var $T="[object Set]";function XT(i){return Vt(i)&&Ao(i)==$T}var cg=XT;var ug=To&&To.isSet,YT=ug?Bn(ug):cg,dg=YT;var KT=1,QT=2,ZT=4,pg="[object Arguments]",JT="[object Array]",eC="[object Boolean]",tC="[object Date]",rC="[object Error]",fg="[object Function]",oC="[object GeneratorFunction]",iC="[object Map]",nC="[object Number]",hg="[object Object]",aC="[object RegExp]",sC="[object Set]",lC="[object String]",cC="[object Symbol]",uC="[object WeakMap]",dC="[object ArrayBuffer]",pC="[object DataView]",fC="[object Float32Array]",hC="[object Float64Array]",mC="[object Int8Array]",yC="[object Int16Array]",gC="[object Int32Array]",xC="[object Uint8Array]",bC="[object Uint8ClampedArray]",vC="[object Uint16Array]",SC="[object Uint32Array]",Je={};Je[pg]=Je[JT]=Je[dC]=Je[pC]=Je[eC]=Je[tC]=Je[fC]=Je[hC]=Je[mC]=Je[yC]=Je[gC]=Je[iC]=Je[nC]=Je[hg]=Je[aC]=Je[sC]=Je[lC]=Je[cC]=Je[xC]=Je[bC]=Je[vC]=Je[SC]=!0;Je[rC]=Je[fg]=Je[uC]=!1;function pc(i,r,e,t,o,n){var a,s=r&KT,l=r&QT,c=r&ZT;if(e&&(a=o?e(i,t,o,n):e(i)),a!==void 0)return a;if(!It(i))return i;var u=dt(i);if(u){if(a=Qy(i),!s)return Rm(i,a)}else{var p=Ao(i),d=p==fg||p==oC;if($i(i))return jy(i,s);if(p==hg||p==pg||d&&!o){if(a=l||d?{}:ng(i),!s)return l?Wy(i,By(a,i)):Hy(i,Ly(a,i))}else{if(!Je[p])return o?i:{};a=ig(i,p,s)}}n||(n=new Wn);var f=n.get(i);if(f)return f;n.set(i,a),dg(i)?i.forEach(function(y){a.add(pc(y,r,e,y,i,n))}):lg(i)&&i.forEach(function(y,b){a.set(b,pc(y,r,e,b,i,n))});var h=c?l?lc:Ns:l?zn:Vn,m=u?void 0:h(i);return Gm(m||i,function(y,b){m&&(b=y,y=i[b]),Dn(a,b,pc(y,r,e,b,i,n))}),a}var fc=pc;var wC=1,PC=4;function OC(i){return fc(i,wC|PC)}var Mo=OC;var TC="__lodash_hash_undefined__";function CC(i){return this.__data__.set(i,TC),this}var mg=CC;function AC(i){return this.__data__.has(i)}var yg=AC;function hc(i){var r=-1,e=i==null?0:i.length;for(this.__data__=new Xi;++r<e;)this.add(i[r])}hc.prototype.add=hc.prototype.push=mg;hc.prototype.has=yg;var gg=hc;function MC(i,r){for(var e=-1,t=i==null?0:i.length;++e<t;)if(r(i[e],e,i))return!0;return!1}var xg=MC;function IC(i,r){return i.has(r)}var bg=IC;var EC=1,NC=2;function DC(i,r,e,t,o,n){var a=e&EC,s=i.length,l=r.length;if(s!=l&&!(a&&l>s))return!1;var c=n.get(i),u=n.get(r);if(c&&u)return c==r&&u==i;var p=-1,d=!0,f=e&NC?new gg:void 0;for(n.set(i,r),n.set(r,i);++p<s;){var h=i[p],m=r[p];if(t)var y=a?t(m,h,p,r,i,n):t(h,m,p,i,r,n);if(y!==void 0){if(y)continue;d=!1;break}if(f){if(!xg(r,function(b,v){if(!bg(f,v)&&(h===b||o(h,b,e,t,n)))return f.push(v)})){d=!1;break}}else if(!(h===m||o(h,m,e,t,n))){d=!1;break}}return n.delete(i),n.delete(r),d}var mc=DC;function _C(i){var r=-1,e=Array(i.size);return i.forEach(function(t,o){e[++r]=[o,t]}),e}var vg=_C;function RC(i){var r=-1,e=Array(i.size);return i.forEach(function(t){e[++r]=t}),e}var Sg=RC;var LC=1,BC=2,VC="[object Boolean]",zC="[object Date]",GC="[object Error]",FC="[object Map]",jC="[object Number]",UC="[object RegExp]",kC="[object Set]",HC="[object String]",WC="[object Symbol]",qC="[object ArrayBuffer]",$C="[object DataView]",wg=Mt?Mt.prototype:void 0,tp=wg?wg.valueOf:void 0;function XC(i,r,e,t,o,n,a){switch(e){case $C:if(i.byteLength!=r.byteLength||i.byteOffset!=r.byteOffset)return!1;i=i.buffer,r=r.buffer;case qC:return!(i.byteLength!=r.byteLength||!n(new $n(i),new $n(r)));case VC:case zC:case jC:return Nn(+i,+r);case GC:return i.name==r.name&&i.message==r.message;case UC:case HC:return i==r+"";case FC:var s=vg;case kC:var l=t&LC;if(s||(s=Sg),i.size!=r.size&&!l)return!1;var c=a.get(i);if(c)return c==r;t|=BC,a.set(i,r);var u=mc(s(i),s(r),t,o,n,a);return a.delete(i),u;case WC:if(tp)return tp.call(i)==tp.call(r)}return!1}var Pg=XC;var YC=1,KC=Object.prototype,QC=KC.hasOwnProperty;function ZC(i,r,e,t,o,n){var a=e&YC,s=Ns(i),l=s.length,c=Ns(r),u=c.length;if(l!=u&&!a)return!1;for(var p=l;p--;){var d=s[p];if(!(a?d in r:QC.call(r,d)))return!1}var f=n.get(i),h=n.get(r);if(f&&h)return f==r&&h==i;var m=!0;n.set(i,r),n.set(r,i);for(var y=a;++p<l;){d=s[p];var b=i[d],v=r[d];if(t)var w=a?t(v,b,d,r,i,n):t(b,v,d,i,r,n);if(!(w===void 0?b===v||o(b,v,e,t,n):w)){m=!1;break}y||(y=d=="constructor")}if(m&&!y){var O=i.constructor,S=r.constructor;O!=S&&"constructor"in i&&"constructor"in r&&!(typeof O=="function"&&O instanceof O&&typeof S=="function"&&S instanceof S)&&(m=!1)}return n.delete(i),n.delete(r),m}var Og=ZC;var JC=1,Tg="[object Arguments]",Cg="[object Array]",yc="[object Object]",eA=Object.prototype,Ag=eA.hasOwnProperty;function tA(i,r,e,t,o,n){var a=dt(i),s=dt(r),l=a?Cg:Ao(i),c=s?Cg:Ao(r);l=l==Tg?yc:l,c=c==Tg?yc:c;var u=l==yc,p=c==yc,d=l==c;if(d&&$i(i)){if(!$i(r))return!1;a=!0,u=!1}if(d&&!u)return n||(n=new Wn),a||ec(i)?mc(i,r,e,t,o,n):Pg(i,r,l,e,t,o,n);if(!(e&JC)){var f=u&&Ag.call(i,"__wrapped__"),h=p&&Ag.call(r,"__wrapped__");if(f||h){var m=f?i.value():i,y=h?r.value():r;return n||(n=new Wn),o(m,y,e,t,n)}}return d?(n||(n=new Wn),Og(i,r,e,t,o,n)):!1}var Mg=tA;function Ig(i,r,e,t,o){return i===r?!0:i==null||r==null||!Vt(i)&&!Vt(r)?i!==i&&r!==r:Mg(i,r,e,t,Ig,o)}var Eg=Ig;function rA(i,r){return i!=null&&r in Object(i)}var Ng=rA;function oA(i,r,e){r=yr(r,i);for(var t=-1,o=r.length,n=!1;++t<o;){var a=ni(r[t]);if(!(n=i!=null&&e(i,a)))break;i=i[a]}return n||++t!=o?n:(o=i==null?0:i.length,!!o&&_n(o)&&En(a,o)&&(dt(i)||Ln(i)))}var Dg=oA;function iA(i,r){return i!=null&&Dg(i,r,Ng)}var _g=iA;var nA=function(){return ut.Date.now()},gc=nA;var aA="Expected a function",sA=Math.max,lA=Math.min;function cA(i,r,e){var t,o,n,a,s,l,c=0,u=!1,p=!1,d=!0;if(typeof i!="function")throw new TypeError(aA);r=Kd(r)||0,It(e)&&(u=!!e.leading,p="maxWait"in e,n=p?sA(Kd(e.maxWait)||0,r):n,d="trailing"in e?!!e.trailing:d);function f(T){var M=t,g=o;return t=o=void 0,c=T,a=i.apply(g,M),a}function h(T){return c=T,s=setTimeout(b,r),u?f(T):a}function m(T){var M=T-l,g=T-c,D=r-M;return p?lA(D,n-g):D}function y(T){var M=T-l,g=T-c;return l===void 0||M>=r||M<0||p&&g>=n}function b(){var T=gc();if(y(T))return v(T);s=setTimeout(b,m(T))}function v(T){return s=void 0,d&&t?f(T):(t=o=void 0,a)}function w(){s!==void 0&&clearTimeout(s),c=0,t=l=o=s=void 0}function O(){return s===void 0?a:v(gc())}function S(){var T=gc(),M=y(T);if(t=arguments,o=this,l=T,M){if(s===void 0)return h(l);if(p)return clearTimeout(s),s=setTimeout(b,r),f(l)}return s===void 0&&(s=setTimeout(b,r)),a}return S.cancel=w,S.flush=O,S}var xc=cA;function uA(i){var r=i==null?0:i.length;return r?i[r-1]:void 0}var Rg=uA;function dA(i,r){return r.length<2?i:oc(i,Iy(r,0,-1))}var Lg=dA;function pA(i,r){return Eg(i,r)}var rp=pA;function fA(i,r){return r=yr(r,i),i=Lg(i,r),i==null||delete i[ni(Rg(r))]}var Bg=fA;function hA(i){return My(i)?void 0:i}var Vg=hA;var mA=1,yA=2,gA=4,xA=ic(function(i,r){var e={};if(i==null)return e;var t=!1;r=Xl(r,function(n){return n=yr(n,i),t||(t=n.length>1),n}),Yr(i,lc(i),e),t&&(e=fc(e,mA|yA|gA,Vg));for(var o=r.length;o--;)Bg(e,r[o]);return e}),Yn=xA;function bA(i,r,e,t){if(!It(i))return i;r=yr(r,i);for(var o=-1,n=r.length,a=n-1,s=i;s!=null&&++o<n;){var l=ni(r[o]),c=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(o!=a){var u=s[l];c=t?t(u,l,s):void 0,c===void 0&&(c=It(u)?u:En(r[o+1])?[]:{})}Dn(s,l,c),s=s[l]}return i}var zg=bA;function vA(i,r,e){for(var t=-1,o=r.length,n={};++t<o;){var a=r[t],s=oc(i,a);e(s,a)&&zg(n,yr(a,i),s)}return n}var Gg=vA;function SA(i,r){return Gg(i,r,function(e,t){return _g(i,t)})}var Fg=SA;var wA=ic(function(i,r){return i==null?{}:Fg(i,r)}),Nr=wA;var fe=class{modifyById(r,e){let t=this;if(t[r]===void 0)throw new Error("not expected");{let n={...t,[r]:e};return Object.setPrototypeOf(n,fe.prototype),n}}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:n,data:a}=r,s={...e,[n]:a};return Object.setPrototypeOf(s,fe.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 n={...e};return Object.setPrototypeOf(n,fe.prototype),delete n[t],{data:n,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function Ds(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let r=Object.getOwnPropertyNames(i);for(let e of r){let t=i[e];t&&typeof t=="object"&&Ds(t)}return Object.freeze(i)}function jg(i,r){let e=0;for(;e<i.length&&e<r.length;){if(i[e]<r[e])return-1;if(i[e]>r[e])return 1;e+=1}return e!==r.length?-1:e!==i.length?1:0}var Kn=class extends Error{};function bc(i){let r={...i};return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function Kr(i,r,e){if(i===void 0?r===void 0?(i=0,r=10):i=r-10:r===void 0&&(r=i+10),i>r){let n=i;i=r,r=n}let t=[],o=1/(e+1);for(let n=0;n<e;n++){let a=i+(r-i)*(n+.75+Math.random()*.5)*o;t.push(a)}return t}function Qn(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function Ug(){return typeof process<"u"}function kg(i,r){for(let e of i)r(e.id,e.data)!==!0&&kg(e.children,r)}function Hg(i,r){if(r(i.id,i.data)!==!0)for(let e of i.children)Hg(e,r)}var Ke=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Ke.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Ds(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&&Hg(o,t)}}traverse(e){kg(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let n=this.parent(e),a=this.childrenArray(n),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(n,a)}}modifyArrayBy(e,t){let o=e,n=t;for(;o!==null;){let s=n,l=o;if(o=this.parent(o),o===void 0)throw new Error;n=this.childrenArray(o);let c=n.findIndex(u=>u.id===l);if(c<0)throw new Error;n=[...n],n[c]={...n[c],children:s}}Object.setPrototypeOf(n,Ke.prototype);let a=n;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:n,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:n,data:a,children:s};return c=[...c,u],c.sort((d,f)=>d.fi-f.fi),e.localIndex=c.indexOf(u),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:n}}}}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 n=this.childrenArray(o),a=n.findIndex(c=>c.id===t);e.localIndex=a,n=[...n];let s=n.splice(a,1)[0];return{data:this.modifyArrayBy(o,n),actual:e,reverse:{type:7,...s,parent:o}}}}moveOp(e){let{parent:t,fi:o,id:n}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:n});if(t!==null){let f=t;for(;f!==null;){if(f===void 0)throw new Error;if(f===n)throw new Kn("cyclic tree");f=this.parent(f)}}let a=this.parent(n);if(a===void 0)return null;let s=a,l=this.childrenArray(a),c=l.findIndex(f=>f.id===n);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((f,h)=>f.fi-h.fi),e.localIndex=l.indexOf(u),p=p.modifyArrayBy(a,l),{data:p,actual:e,reverse:{type:9,parent:s,fi:d,id:n}}}previous(e,t){if(t===null){let n=this.childrenArray(e);return n.length===0?null:n[n.length-1].id}let o=null;for(let n of this.childrenArray(e)){if(n.id===t)return o;o=n.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let o=this.childrenArray(t),n=o.findIndex(a=>a.id===e)+1;if(n<o.length)return o[n].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let o=this.childrenArray(t),n=o.findIndex(a=>a.id===e)-1;return n>=0?this.traverseSortPrevious(o[n].id):t}}getAllSorted(e){let t=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&t.push({...o,...n})}t.sort((o,n)=>jg(o.sortKey,n.sortKey));for(let o of t)delete o.sortKey;return t}getWithSortKey(e){var t=e;let o=[],n=this.get(t),a=n;if(n!==void 0){for(;t;)o.splice(0,0,n.fi),t=this.parent(t),t!==null&&(n=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 n=this.childrenArray(e);if(t===null){if(n.length===0)return Kr(0,o,o);{let a=n[0].fi;return Kr(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=n.find(l=>l.fi>a.fi);if(s===void 0){let l=n[n.length-1].fi;return Kr(l,l+o,o)}else return Kr(a.fi,s.fi,o)}}};var Zn;(r=>{function i(e,t){if(t.type!==0)return null;if(Array.isArray(e)){let o=t.props,n={},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");n[l]=a[c],a[c]=o[l],s=!0}return s?{data:a,actual:t,reverse:{type:0,props:n}}:null}else{let o=t.props,n={},a={...e},s=!1;if(o)for(let l of Object.keys(o)){n[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:n}}:null}}r.runOp=i})(Zn||(Zn={}));var be=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,be.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Ds(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 n=this,a=n.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let s=n[a];return n=[...n],n[a]={...s,data:t},this.modifyArrayBy(n)}}modifyArrayBy(e){Object.setPrototypeOf(e,be.prototype);let t=e;return Ug()||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:n}=e,a=this,s={fi:t,id:o,data:n};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,n=o.findIndex(l=>l.id===t);if(n===-1)return null;e.localIndex=n,o=[...o];let a=o.splice(n,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:t,id:o}=e,n=this;n=[...n];let a=n.findIndex(u=>u.id===o);if(a===-1)return null;let s=n[a].fi,l={...n[a],fi:t};return n[a]=l,n.sort((u,p)=>u.fi-p.fi),e.localIndex=n.indexOf(l),{data:this.modifyArrayBy(n),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 Kr(0,t,t);{let n=o[0].fi;return Kr(n-t,n,t)}}else{let n=this.get(e);if(n===void 0)throw new Error("illegal args");let a=o.find(s=>s.fi>n.fi);if(a===void 0){let s=o[o.length-1].fi;return Kr(s,s+t,t)}else return Kr(n.fi,a.fi,t)}}};function Jn(i){return i&&typeof i=="object"&&i instanceof Qe}var Qe=class{unusedFunOverridesTable(r){}runOp(r){let e=[],t=this,o=0,n={};for(;o<r.path.length;){if(e.push(t),t=t===void 0?void 0:t[r.path[o]],t!==void 0&&!Jn(t))return null;o+=1}t=t?bc(t):new Qe;for(let[l,c]of Object.entries(r.props)){let u=t[l];n[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=bc(l),delete t[r.path[o-1]])}else{let l=e[o-1];if(l){let c=bc(l);c[r.path[o-1]]=t,t=c}else{let c=new Qe;c[r.path[o-1]]=t,t=c}}o-=1}let a=Object.setPrototypeOf(t,Qe.prototype),s={...r,props:n};return{data:a,actual:r,reverse:s}}},Qr;(t=>{function i(o,n){return _s(o,n)??o}t.apply=i;function r(o,n){return ip(o,n)}t.merge=r;function e(o,n){let a=0,s=n.path,l=o;for(;a<s.length&&l!==void 0;){if(l=Ze.zoomOnce(l,s[a]),l===void 0)return n;if(!Jn(l))return;a+=1}if(l===void 0)return n;if(!!Jn(l))if(n.type===0){let c={...n.props};for(let u of Object.keys(l))delete c[u];return{...n,props:c}}else if(n.type===1||n.type===4||n.type===7){let c=op([n],l);return c?(console.log(c),c):n}else return n}t.filterOp=e})(Qr||(Qr={}));function op(i,r){if(r===void 0)return;let e=!1,t=i.map(o=>{let n=o.id,a=_s(o.data,r[n]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=op(o.children,r);return s!==void 0?e=!0:s=o.children,{...o,id:n,data:a,children:s}}else return{...o,id:n,data:a}});if(e)return t}function PA(i,r){if(r===void 0)return;let e=!1,t=i.map(o=>{let n=o.id,a=_s(o.data,r[n]);return e=e||a!==void 0,a===void 0&&(a=o.data),{...o,id:n,data:a}});if(e)return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function _s(i,r){if(!Jn(r))return r;if(i instanceof Ke){let e=op(i,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof be)return PA(i,r);if(Array.isArray(i)){let e=!1,t=i.map((o,n)=>{let a=_s(o,r[n]);return e=e||a!==void 0,a===void 0&&(a=o),a});return e?(Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t):void 0}else{if(i instanceof Qe)return ip(i,r);if(i&&typeof i=="object"){let e={},t=!1;for(let[o,n]of Object.entries(i)){let a=_s(n,r[o]);t=t||a!==void 0,a===void 0&&(a=n),e[o]=a}return t?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function ip(i,r){if(i===void 0)return r;if(r===void 0)return i;if(!Jn(r))return r;if(!Jn(i))return Qr.apply(i,r);let e=new Set;for(let o of Object.keys(i))e.add(o);for(let o of Object.keys(r))e.add(o);let t=new Qe;for(let o of e){let n=ip(i===void 0?void 0:i[o],r===void 0?void 0:r[o]);t[o]=n}return t}function Wg(i,r){let e={cur:[],result:[],len:0};return i=Rs(i,r,e)??i,[i,e.result]}function vc(i,r){return i===null?null:(i.cur[i.len]=r,i.len+=1,i)}function Sc(i){i&&(i.len-=1)}function OA(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function qg(i,r,e){let t=!1,o=i.map(n=>{let a=n.id,s=r[a];if(s!==void 0&&typeof s=="string"&&(t=!0,a=s,e!==null))throw new Error("not supported");let l=Rs(n.data,r,vc(e,a));Sc(e),t=t||l!==void 0,l===void 0&&(l=n.data);let c=qg(n.children,r,e);return c!==void 0?t=!0:c=n.children,{...n,id:a,data:l,children:c}});if(t)return o}function TA(i,r,e){let t=!1,o=i.map(n=>{let a=n.id,s=r[a];if(s!==void 0&&typeof s=="string"&&(t=!0,a=s,e!==null))throw new Error("not supported");let l=Rs(n.data,r,vc(e,a));return Sc(e),t=t||l!==void 0,l===void 0&&(l=n.data),{...n,id:a,data:l}});if(t)return Object.setPrototypeOf(o,Object.getPrototypeOf(i)),o}function Rs(i,r,e){if(i instanceof Ke){let t=qg(i,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else{if(i instanceof be)return TA(i,r,e);if(Array.isArray(i)){let t=!1,o=i.map((n,a)=>{let s=Rs(n,r,vc(e,a));return Sc(e),t=t||s!==void 0,s===void 0&&(s=n),s});return t?(Object.setPrototypeOf(o,Object.getPrototypeOf(i)),o):void 0}else if(i&&typeof i=="object"&&!Qn(i)){let t={},o=!1;for(let[n,a]of Object.entries(i))if(n!=="name"&&n!=="variableId"){let s=r[n];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,n=s}let l=Rs(a,r,vc(e,n));Sc(e),o=o||l!==void 0,l===void 0&&(l=a),t[n]=l}else t[n]=a;return o?(Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t):void 0}else if(typeof i=="string"){let t=r[i];return t!==void 0&&OA(e),t}else return}}var ea;(r=>{function i(e,t){let o=Ze.zoom(t,e.path);if(typeof o=="object"){let n={};for(let a of Object.keys(e.props))n[a]=o[a];return{...e,props:n}}else return{...e,props:{}}}r.replaceProps=i})(ea||(ea={}));var nt;(s=>{function i(l,c){return{...l,path:l.path.slice(c)}}s.drop=i;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 Qe&&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 Ke||l instanceof be||l instanceof fe?d=l.runOp(c):d=Zn.runOp(l,c)),d!==void 0)if(d!==null){let m=d.data;for(let y=p.length-1;y>=0;y--){let b=u[y],v=p[y];if(v instanceof Ke){if(typeof b=="number")throw new Error("illegal arg");m=v.modifyById(b,m)}else if(v instanceof be){if(typeof b=="number")throw new Error("illegal arg");m=v.modifyById(b,m)}else if(v instanceof fe){if(typeof b=="number")throw new Error("illegal arg");m=v.modifyById(b,m)}else if(v instanceof Qe){let w={...v,[b]:m};m=Object.setPrototypeOf(w,Qe.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof b=="string"&&(b=parseInt(b),isNaN(b)))throw new Error("Invalid path");let w=m;m=[...v],m[b]=w}else m={...v,[b]:m};else return null}return{data:m,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let f=u[p.length],h;if(l instanceof Ke){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else if(l instanceof be){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else l!==null&&(h=l[f]);if(h!==void 0)p.push(l),l=h;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 n(l,c){return t(l.path,c.path)}s.commutative=n;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})(nt||(nt={}));var Ls;(l=>{function i(){return[]}l.empty=i;function r(c,u){let p=[];for(let d of c){let[f,...h]=d.path;f===u&&p.push({...d,path:h})}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(f=>nt.subsumed(d,f))),...u]}l.compress=o;function n(c,u){return c.every(p=>u.every(d=>nt.commutative(p,d)))}l.commutative=n;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=[],f=[];for(let h of u)try{if(h.type===3||h.type===5&&h.path[h.path.length-1]==="variables"){let m,y,b;if(h.type===3?(m=Ze.zoom(p,[...h.path,h.id]),b=nt.apply(p,{...h,type:2})):(m=Ze.zoom(p,[...h.path,h.id,"value"]),b=nt.apply(p,h)),b!==null){p=b.data;let[v,w]=Wg(p,{[h.id]:m});p=v;for(let O=0;O<w.length;O++){let S=w[O],T=S.pop();if(typeof T=="number"){let M=[T];for(let D=O+1;D<w.length;D++){let E=w[D],I=E[E.length-1];if(typeof I=="number"&&Ze.equal(S,E.slice(0,E.length-1)))M.push(I),w.splice(D,1);else break}let g=Ze.zoom(p,S);y=g.map((D,E)=>M.includes(E)?h.id:D),m=g,T=S.pop()}else{if(T==="alphaOverride"||T==="alpha"){m/=100;let M=m,g=Ze.zoom(p,S.slice(0,S.length-2)),D=g.layers.map(E=>E.id===S[S.length-1]?{...E,data:{...E.data,[T]:M}}:E);Object.setPrototypeOf(D,Object.getPrototypeOf(g.layers)),g.layers=D}y=h.id}d.push({type:0,path:S,props:{[T]:m}}),f.push({type:0,path:S,props:{[T]:y}})}f.push(b.reverse),d.push(b.actual)}}else{let m=nt.apply(p,h);m!==null&&(d.push(m.actual),p=m.data,f.push(m.reverse))}}catch(m){if(m instanceof Kn)return null;throw m}return{data:p,actual:d,reverse:f.reverse()}}l.apply=s})(Ls||(Ls={}));var $g=Symbol(),CA=Symbol(),Pc=Symbol(),Ki=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let n=t;for(;!(o instanceof wc);){let a=o._path,s=o._current;if(a!==""&&n.splice(0,0,a),o=o._parent,o===null)return;o.update(a,s)}o.push(n,r,e.actual,e.reverse)}deleteChildren(r){if(this._children){let e=this._children[r];if(e){let t=e[Pc];t&&t(),delete this._children[r]}}}},ap=class extends Ki{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,Zn.runOp(this._current,r),r.path)}},sp=class extends Ki{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,fe.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},Xg={get(i,r){if(r===Pc)return()=>{i._parent=null};if(r===$g)return i._current;if(r===CA)return i;let{_current:e,_children:t}=i;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 n=e[r],a=Oc(i,r,n);return a!==n?(t===void 0&&(t={},i._children=t),t[r]=a,a):n},has(i,r){return r in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,r){let e=i._current,t=Reflect.getOwnPropertyDescriptor(e,r);return t&&{writable:!0,configurable:!0,enumerable:t.enumerable,value:e[r]}}},AA={...Xg,set(i,r,e){let t={type:0,props:{[r]:at(e)??e}};return i.deleteChildren(r),i.runOp(t),!0},deleteProperty(i,r){let e={type:0,props:{[r]:void 0}};return i.deleteChildren(r),i.runOp(e),!0}},MA={...Xg,set(i,r,e){return e===void 0?this.deleteProperty(i,r):(i.deleteChildren(r),i.runOp({type:1,id:r,data:e})),!0},deleteProperty(i,r){return i.runOp({type:2,id:r}),!0}},ta=class extends Ki{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Pc]=()=>{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 n=e.get(r)?.data,a=Oc(this,r,n);return a!==n?(t===void 0&&(t={},this._children=t),t[r]=a,a):n}add(r,e,t,o,n){this.runOp({type:7,parent:r,fi:e,id:t,data:o,children:n})}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 n=0;n<t.length;n++){let a=t[n];this.add(r,o[n],a.id,a.data,a.children)}}insertBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let n=0;n<t.length;n++){let a=t[n];this.add(r,o[n],a.id,a.data,a.children)}}moveAfter(r,e,t){let o=this._current.insertAfterHelper(r,e,t.length);for(let n=0;n<t.length;n++){let a=t[n];this.move(r,o[n],a)}}moveBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let n=0;n<t.length;n++){let a=t[n];this.move(r,o[n],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)}},ra=class extends Ki{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Pc]=()=>{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,n=this._current[t].fi;r(this.data(this._current[t].id),o,n)}}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 n=e.get(r)?.data,a=Oc(this,r,n);return a!==n?(t===void 0&&(t={},this._children=t),t[r]=a,a):n}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 n=e[o];this.add(t[o],n.id,n.data)}}insertBefore(r,e){let t=this._current.insertBeforeHelper(r,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.add(t[o],n.id,n.data)}}moveAfter(r,e){let t=this._current.insertAfterHelper(r,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.move(t[o],n)}}moveBefore(r,e){let t=this._current.insertBeforeHelper(r,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.move(t[o],n)}}delete(r){this.deleteChildren(r),this.runOp({type:5,id:r})}};function np(i,r,e){if(i.length>0){let t=i[i.length-1];if(t.type===0&&r.type===0&&Ze.equal(t.path,e)){Object.assign(t.props,r.props);return}}i.push({...r,path:e})}var wc=class extends Ki{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){np(this.ts,e,r),np(this.actual,t,r),np(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Oc(i,r,e){return e instanceof Ke?new ta(i,r,e):e instanceof be?new ra(i,r,e):e instanceof fe?new Proxy(new sp(i,r,e),MA):e!==null&&typeof e=="object"?Qn(e)?e:new Proxy(new ap(i,r,e),AA):e}function lp(i){let r=new wc(i);return[Oc(r,"",i),r]}function ai(i,r){let[e,t]=lp(i);return r(e),t.result()}function at(i){return i instanceof ta||i instanceof ra?i._current:i!==null&&typeof i=="object"?i[$g]:i}var Ze;(o=>{function i(n,a){if(a.length===n.length)for(var s=0;s<n.length;){if(n[s]!==a[s])return!1;s+=1}else return!1;return!0}o.equal=i;function r(n,a,s){let l=t(s,n);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(n,a){if((n instanceof Ke||n instanceof ta)&&typeof a=="string")return n.data(a);if((n instanceof be||n instanceof ra)&&typeof a=="string")return n.data(a);if(typeof a=="number"&&Array.isArray(n))return n[a];if(typeof a=="string"&&typeof n=="object"&&n!==null)return n[a]}o.zoomOnce=e;function t(n,a,s=0){for(;s<a.length&&n!==void 0;)n=e(n,a[s]),s+=1;return n}o.zoom=t})(Ze||(Ze={}));function Yg(i,r){let e=[];if(r.length===i.length)for(var t=0;t<i.length;){if(r[t]==="*")e.push(i[t]);else if(i[t]!==r[t])return null;t+=1}else return null;return e}function Le(i,r){let e=[];if(r.length<=i.length)for(var t=0;t<r.length;){if(r[t]==="*")e.push(i[t]);else if(i[t]!==r[t])return null;t+=1}else return null;return e}var Tc=class{},Bs=class extends Tc{constructor(e){super();this.id=e}},Vs=class extends Tc{constructor(e){super();this.data=e}};var up;try{up=new TextDecoder}catch{}var de,li,G=0;var o0=[],dp=o0,pp=0,Jt={},ke,si,gr=0,Zr=0,cr,Io,$t=[],We,Kg={useRecords:!1,mapsAsObjects:!0},zs=class{},hp=new zs;hp.name="MessagePack 0xC1";var oa=!1,Jr=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 l0(()=>(Ac(),this?this.unpack(r,e):Jr.prototype.unpack.call(Kg,r,e)));li=e>-1?e:r.length,G=0,pp=0,Zr=0,si=null,dp=o0,cr=null,de=r;try{We=r.dataView||(r.dataView=new DataView(r.buffer,r.byteOffset,r.byteLength))}catch(t){throw de=null,r instanceof Uint8Array?t:new Error("Source must be a Uint8Array or Buffer but was a "+(r&&typeof r=="object"?r.constructor.name:typeof r))}if(this instanceof Jr){if(Jt=this,this.structures)return ke=this.structures,Cc();(!ke||ke.length>0)&&(ke=[])}else Jt=Kg,(!ke||ke.length>0)&&(ke=[]);return Cc()}unpackMultiple(r,e){let t,o=0;try{oa=!0;let n=r.length,a=this?this.unpack(r,n):Ec.unpack(r,n);if(e){for(e(a);G<n;)if(o=G,e(Cc())===!1)return}else{for(t=[a];G<n;)o=G,t.push(Cc());return t}}catch(n){throw n.lastPosition=o,n.values=t,n}finally{oa=!1,Ac()}}_mergeStructures(r,e){r=r||[];for(let t=0,o=r.length;t<o;t++){let n=r[t];n&&(n.isShared=!0,t>=32&&(n.highByte=t-32>>5))}r.sharedLength=r.length;for(let t in e||[])if(t>=0){let o=r[t],n=e[t];n&&(o&&((r.restoreStructures||(r.restoreStructures=[]))[t]=o),r[t]=n)}return this.structures=r}decode(r,e){return this.unpack(r,e)}};function Cc(){try{if(!Jt.trusted&&!oa){let r=ke.sharedLength||0;r<ke.length&&(ke.length=r)}let i=pt();if(G==li)ke.restoreStructures&&Qg(),ke=null,de=null,Io&&(Io=null);else if(G>li){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}else if(!oa)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw ke.restoreStructures&&Qg(),Ac(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function Qg(){for(let i in ke.restoreStructures)ke[i]=ke.restoreStructures[i];ke.restoreStructures=null}function pt(){let i=de[G++];if(i<160)if(i<128){if(i<64)return i;{let r=ke[i&63]||Jt.getStructures&&i0()[i&63];return r?(r.read||(r.read=mp(r,i&63)),r.read()):i}}else if(i<144)if(i-=128,Jt.mapsAsObjects){let r={};for(let e=0;e<i;e++)r[a0()]=pt();return r}else{let r=new Map;for(let e=0;e<i;e++)r.set(pt(),pt());return r}else{i-=144;let r=new Array(i);for(let e=0;e<i;e++)r[e]=pt();return r}else if(i<192){let r=i-160;if(Zr>=G)return si.slice(G-gr,(G+=r)-gr);if(Zr==0&&li<140){let e=r<16?yp(r):n0(r);if(e!=null)return e}return fp(r)}else{let r;switch(i){case 192:return null;case 193:return cr?(r=pt(),r>0?cr[1].slice(cr.position1,cr.position1+=r):cr[0].slice(cr.position0,cr.position0-=r)):hp;case 194:return!1;case 195:return!0;case 196:return cp(de[G++]);case 197:return r=We.getUint16(G),G+=2,cp(r);case 198:return r=We.getUint32(G),G+=4,cp(r);case 199:return Qi(de[G++]);case 200:return r=We.getUint16(G),G+=2,Qi(r);case 201:return r=We.getUint32(G),G+=4,Qi(r);case 202:if(r=We.getFloat32(G),Jt.useFloat32>2){let e=Ic[(de[G]&127)<<1|de[G+1]>>7];return G+=4,(e*r+(r>0?.5:-.5)>>0)/e}return G+=4,r;case 203:return r=We.getFloat64(G),G+=8,r;case 204:return de[G++];case 205:return r=We.getUint16(G),G+=2,r;case 206:return r=We.getUint32(G),G+=4,r;case 207:return Jt.int64AsNumber?(r=We.getUint32(G)*4294967296,r+=We.getUint32(G+4)):r=We.getBigUint64(G),G+=8,r;case 208:return We.getInt8(G++);case 209:return r=We.getInt16(G),G+=2,r;case 210:return r=We.getInt32(G),G+=4,r;case 211:return Jt.int64AsNumber?(r=We.getInt32(G)*4294967296,r+=We.getUint32(G+4)):r=We.getBigInt64(G),G+=8,r;case 212:if(r=de[G++],r==114)return r0(de[G++]&63);{let e=$t[r];if(e)return e.read?(G++,e.read(pt())):e.noBuffer?(G++,e()):e(de.subarray(G,++G));throw new Error("Unknown extension "+r)}case 213:return r=de[G],r==114?(G++,r0(de[G++]&63,de[G++])):Qi(2);case 214:return Qi(4);case 215:return Qi(8);case 216:return Qi(16);case 217:return r=de[G++],Zr>=G?si.slice(G-gr,(G+=r)-gr):EA(r);case 218:return r=We.getUint16(G),G+=2,Zr>=G?si.slice(G-gr,(G+=r)-gr):NA(r);case 219:return r=We.getUint32(G),G+=4,Zr>=G?si.slice(G-gr,(G+=r)-gr):DA(r);case 220:return r=We.getUint16(G),G+=2,Jg(r);case 221:return r=We.getUint32(G),G+=4,Jg(r);case 222:return r=We.getUint16(G),G+=2,e0(r);case 223:return r=We.getUint32(G),G+=4,e0(r);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var IA=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function mp(i,r){function e(){if(e.count++>2){let o=i.read=new Function("r","return function(){return {"+i.map(n=>IA.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(pt);return i.highByte===0&&(i.read=Zg(r,i.read)),o()}let t={};for(let o=0,n=i.length;o<n;o++){let a=i[o];t[a]=pt()}return t}return e.count=0,i.highByte===0?Zg(r,e):e}var Zg=(i,r)=>function(){let e=de[G++];if(e===0)return r();let t=i<32?-(i+(e<<5)):i+(e<<5),o=ke[t]||i0()[t];if(!o)throw new Error("Record id is not defined for "+t);return o.read||(o.read=mp(o,i)),o.read()};function i0(){let i=l0(()=>(de=null,Jt.getStructures()));return ke=Jt._mergeStructures(i,ke)}var fp=Mc,EA=Mc,NA=Mc,DA=Mc;function Mc(i){let r;if(i<16&&(r=yp(i)))return r;if(i>64&&up)return up.decode(de.subarray(G,G+=i));let e=G+i,t=[];for(r="";G<e;){let o=de[G++];if((o&128)===0)t.push(o);else if((o&224)===192){let n=de[G++]&63;t.push((o&31)<<6|n)}else if((o&240)===224){let n=de[G++]&63,a=de[G++]&63;t.push((o&31)<<12|n<<6|a)}else if((o&248)===240){let n=de[G++]&63,a=de[G++]&63,s=de[G++]&63,l=(o&7)<<18|n<<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+=Et.apply(String,t),t.length=0)}return t.length>0&&(r+=Et.apply(String,t)),r}function Jg(i){let r=new Array(i);for(let e=0;e<i;e++)r[e]=pt();return r}function e0(i){if(Jt.mapsAsObjects){let r={};for(let e=0;e<i;e++)r[a0()]=pt();return r}else{let r=new Map;for(let e=0;e<i;e++)r.set(pt(),pt());return r}}var Et=String.fromCharCode;function n0(i){let r=G,e=new Array(i);for(let t=0;t<i;t++){let o=de[G++];if((o&128)>0){G=r;return}e[t]=o}return Et.apply(String,e)}function yp(i){if(i<4)if(i<2){if(i===0)return"";{let r=de[G++];if((r&128)>1){G-=1;return}return Et(r)}}else{let r=de[G++],e=de[G++];if((r&128)>0||(e&128)>0){G-=2;return}if(i<3)return Et(r,e);let t=de[G++];if((t&128)>0){G-=3;return}return Et(r,e,t)}else{let r=de[G++],e=de[G++],t=de[G++],o=de[G++];if((r&128)>0||(e&128)>0||(t&128)>0||(o&128)>0){G-=4;return}if(i<6){if(i===4)return Et(r,e,t,o);{let n=de[G++];if((n&128)>0){G-=5;return}return Et(r,e,t,o,n)}}else if(i<8){let n=de[G++],a=de[G++];if((n&128)>0||(a&128)>0){G-=6;return}if(i<7)return Et(r,e,t,o,n,a);let s=de[G++];if((s&128)>0){G-=7;return}return Et(r,e,t,o,n,a,s)}else{let n=de[G++],a=de[G++],s=de[G++],l=de[G++];if((n&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){G-=8;return}if(i<10){if(i===8)return Et(r,e,t,o,n,a,s,l);{let c=de[G++];if((c&128)>0){G-=9;return}return Et(r,e,t,o,n,a,s,l,c)}}else if(i<12){let c=de[G++],u=de[G++];if((c&128)>0||(u&128)>0){G-=10;return}if(i<11)return Et(r,e,t,o,n,a,s,l,c,u);let p=de[G++];if((p&128)>0){G-=11;return}return Et(r,e,t,o,n,a,s,l,c,u,p)}else{let c=de[G++],u=de[G++],p=de[G++],d=de[G++];if((c&128)>0||(u&128)>0||(p&128)>0||(d&128)>0){G-=12;return}if(i<14){if(i===12)return Et(r,e,t,o,n,a,s,l,c,u,p,d);{let f=de[G++];if((f&128)>0){G-=13;return}return Et(r,e,t,o,n,a,s,l,c,u,p,d,f)}}else{let f=de[G++],h=de[G++];if((f&128)>0||(h&128)>0){G-=14;return}if(i<15)return Et(r,e,t,o,n,a,s,l,c,u,p,d,f,h);let m=de[G++];if((m&128)>0){G-=15;return}return Et(r,e,t,o,n,a,s,l,c,u,p,d,f,h,m)}}}}}function cp(i){return Jt.copyBuffers?Uint8Array.prototype.slice.call(de,G,G+=i):de.subarray(G,G+=i)}function Qi(i){let r=de[G++];if($t[r])return $t[r](de.subarray(G,G+=i));throw new Error("Unknown extension type "+r)}var t0=new Array(4096);function a0(){let i=de[G++];if(i>=160&&i<192){if(i=i-160,Zr>=G)return si.slice(G-gr,(G+=i)-gr);if(!(Zr==0&&li<180))return fp(i)}else return G--,pt();let r=(i<<5^(i>1?We.getUint16(G):i>0?de[G]:0))&4095,e=t0[r],t=G,o=G+i-3,n,a=0;if(e&&e.bytes==i){for(;t<o;){if(n=We.getUint32(t),n!=e[a++]){t=1879048192;break}t+=4}for(o+=3;t<o;)if(n=de[t++],n!=e[a++]){t=1879048192;break}if(t===o)return G=t,e.string;o-=3,t=G}for(e=[],t0[r]=e,e.bytes=i;t<o;)n=We.getUint32(t),e.push(n),t+=4;for(o+=3;t<o;)n=de[t++],e.push(n);let s=i<16?yp(i):n0(i);return s!=null?e.string=s:e.string=fp(i)}var r0=(i,r)=>{var e=pt();let t=i;r!==void 0&&(i=i<32?-((r<<5)+i):(r<<5)+i,e.highByte=r);let o=ke[i];return o&&o.isShared&&((ke.restoreStructures||(ke.restoreStructures=[]))[i]=o),ke[i]=e,e.read=mp(e,t),e.read()},s0=typeof self=="object"?self:global;$t[0]=()=>{};$t[0].noBuffer=!0;$t[101]=()=>{let i=pt();return(s0[i[0]]||Error)(i[1])};$t[105]=i=>{let r=We.getUint32(G-4);Io||(Io=new Map);let e=de[G],t;e>=144&&e<160||e==220||e==221?t=[]:t={};let o={target:t};Io.set(r,o);let n=pt();return o.used?Object.assign(t,n):(o.target=n,n)};$t[112]=i=>{let r=We.getUint32(G-4),e=Io.get(r);return e.used=!0,e.target};$t[115]=()=>new Set(pt());var gp=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");$t[116]=i=>{let r=i[0],e=gp[r];if(!e)throw new Error("Could not find typed array for code "+r);return new s0[e](Uint8Array.prototype.slice.call(i,1).buffer)};$t[120]=()=>{let i=pt();return new RegExp(i[0],i[1])};$t[98]=i=>{let r=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=G;G+=r-4,cr=[pt(),pt()],cr.position0=0,cr.position1=0;let t=G;G=e;try{return pt()}finally{G=t}};$t[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function l0(i){let r=li,e=G,t=pp,o=gr,n=Zr,a=si,s=dp,l=Io,c=cr,u=new Uint8Array(de.slice(0,li)),p=ke,d=ke.slice(0,ke.length),f=Jt,h=oa,m=i();return li=r,G=e,pp=t,gr=o,Zr=n,si=a,dp=s,Io=l,cr=c,de=u,oa=h,ke=p,ke.splice(0,ke.length,...d),Jt=f,We=new DataView(de.buffer,de.byteOffset,de.byteLength),m}function Ac(){de=null,Io=null,ke=null}function c0(i){i.unpack?$t[i.type]=i.unpack:$t[i.type]=i}var Ic=new Array(147);for(let i=0;i<256;i++)Ic[i]=+("1e"+Math.floor(45.15-i*.30103));var Ec=new Jr({useRecords:!1}),_A=Ec.unpack,RA=Ec.unpackMultiple,LA=Ec.unpack,Nc={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},BA=new Float32Array(1),U4=new Uint8Array(BA.buffer,0,4);var Dc;try{Dc=new TextEncoder}catch{}var _c,bp,Rc=typeof Buffer<"u",xp=Rc?Buffer.allocUnsafeSlow:Uint8Array,f0=Rc?Buffer:Uint8Array,u0=Rc?4294967296:2144337920,X,ht,k=0,eo,to=null,VA=/[\u0080-\uFFFF]/,Gs=Symbol("record-id"),Zi=class extends Jr{constructor(r){super(r),this.offset=0;let e,t,o,n,a,s,l=0,c=f0.prototype.utf8Write?function(g,D,E){return X.utf8Write(g,D,E)}:Dc&&Dc.encodeInto?function(g,D){return Dc.encodeInto(g,X.subarray(D)).written}:!1,u=this;r||(r={});let p=r&&r.sequential,d=r.structures||r.saveStructures,f=r.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let h=r.maxOwnStructures;h==null&&(h=d?32:64),p&&!r.saveStructures&&(this.structures=[]);let m=f>32||h+f>64,y=f+64,b=f+h+64;if(b>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],w=0,O=0;this.pack=this.encode=function(g,D){if(X||(X=new xp(8192),ht=new DataView(X.buffer,0,8192),k=0),eo=X.length-10,eo-k<2048?(X=new xp(X.length),ht=new DataView(X.buffer,0,X.length),eo=X.length-10,k=0):k=k+7&2147483640,t=k,s=u.structuredClone?new Map:null,u.bundleStrings?(to=["",""],X[k++]=214,X[k++]=98,to.position=k-t,k+=4):to=null,o=u.structures,o){o.uninitialized&&(o=u._mergeStructures(u.getStructures()));let E=o.sharedLength||0;if(E>f)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<E;I++){let N=o[I];if(!N)continue;let _,R=o.transitions;for(let V=0,U=N.length;V<U;V++){let B=N[V];_=R[B],_||(_=R[B]=Object.create(null)),R=_}R[Gs]=I+64}l=E}p||(o.nextId=E+64)}n&&(n=!1),a=o||[];try{if(S(g),to){ht.setUint32(to.position+t,k-to.position-t);let E=to;to=null,S(E[0]),S(E[1])}if(u.offset=k,s&&s.idsToInsert){k+=s.idsToInsert.length*6,k>eo&&M(k),u.offset=k;let E=GA(X.subarray(t,k),s.idsToInsert);return s=null,E}return D&m0?(X.start=t,X.end=k,X):X.subarray(t,k)}finally{if(o){if(O<10&&O++,w>1e4)o.transitions=null,O=0,w=0,v.length>0&&(v=[]);else if(v.length>0&&!p){for(let E=0,I=v.length;E<I;E++)v[E][Gs]=0;v=[]}if(n&&u.saveStructures){let E=o.sharedLength||f;o.length>E&&(o=o.slice(0,E));let I=X.subarray(t,k);return u.saveStructures(o,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(g)):(l=E,I)}}D&qA&&(k=t)}};let S=g=>{k>eo&&(X=M(k));var D=typeof g,E;if(D==="string"){let I=g.length;if(to&&I>=8&&I<4096){let R=VA.test(g);to[R?0:1]+=g,X[k++]=193,S(R?-I:I);return}let N;I<32?N=1:I<256?N=2:I<65536?N=3:N=5;let _=I*3;if(k+_>eo&&(X=M(k+_)),I<64||!c){let R,V,U,B=k+N;for(R=0;R<I;R++)V=g.charCodeAt(R),V<128?X[B++]=V:V<2048?(X[B++]=V>>6|192,X[B++]=V&63|128):(V&64512)===55296&&((U=g.charCodeAt(R+1))&64512)===56320?(V=65536+((V&1023)<<10)+(U&1023),R++,X[B++]=V>>18|240,X[B++]=V>>12&63|128,X[B++]=V>>6&63|128,X[B++]=V&63|128):(X[B++]=V>>12|224,X[B++]=V>>6&63|128,X[B++]=V&63|128);E=B-k-N}else E=c(g,k+N,_);E<32?X[k++]=160|E:E<256?(N<2&&X.copyWithin(k+2,k+1,k+1+E),X[k++]=217,X[k++]=E):E<65536?(N<3&&X.copyWithin(k+3,k+2,k+2+E),X[k++]=218,X[k++]=E>>8,X[k++]=E&255):(N<5&&X.copyWithin(k+5,k+3,k+3+E),X[k++]=219,ht.setUint32(k,E),k+=4),k+=E}else if(D==="number")if(g>>>0===g)g<64?X[k++]=g:g<256?(X[k++]=204,X[k++]=g):g<65536?(X[k++]=205,X[k++]=g>>8,X[k++]=g&255):(X[k++]=206,ht.setUint32(k,g),k+=4);else if(g>>0===g)g>=-32?X[k++]=256+g:g>=-128?(X[k++]=208,X[k++]=g+256):g>=-32768?(X[k++]=209,ht.setInt16(k,g),k+=2):(X[k++]=210,ht.setInt32(k,g),k+=4);else{let I;if((I=this.useFloat32)>0&&g<4294967296&&g>=-2147483648){X[k++]=202,ht.setFloat32(k,g);let N;if(I<4||(N=g*Ic[(X[k]&127)<<1|X[k+1]>>7])>>0===N){k+=4;return}else k--}X[k++]=203,ht.setFloat64(k,g),k+=8}else if(D==="object")if(!g)X[k++]=192;else{if(s){let N=s.get(g);if(N){if(!N.id){let _=s.idsToInsert||(s.idsToInsert=[]);N.id=_.push(N)}X[k++]=214,X[k++]=112,ht.setUint32(k,N.id),k+=4;return}else s.set(g,{offset:k-t})}let I=g.constructor;if(I===Object)T(g,!0);else if(I===Array){E=g.length,E<16?X[k++]=144|E:E<65536?(X[k++]=220,X[k++]=E>>8,X[k++]=E&255):(X[k++]=221,ht.setUint32(k,E),k+=4);for(let N=0;N<E;N++)S(g[N])}else if(I===Map){E=g.size,E<16?X[k++]=128|E:E<65536?(X[k++]=222,X[k++]=E>>8,X[k++]=E&255):(X[k++]=223,ht.setUint32(k,E),k+=4);for(let[N,_]of g)S(N),S(_)}else{for(let N=0,_=_c.length;N<_;N++){let R=bp[N];if(g instanceof R){let V=_c[N];if(V.write){V.type&&(X[k++]=212,X[k++]=V.type,X[k++]=0),S(V.write.call(this,g));return}let U=X,B=ht,q=k;X=null;let j;try{j=V.pack.call(this,g,F=>(X=U,U=null,k+=F,k>eo&&M(k),{target:X,targetView:ht,position:k-F}),S)}finally{U&&(X=U,ht=B,k=q,eo=X.length-10)}j&&(j.length+k>eo&&M(j.length+k),k=zA(j,X,k,V.type));return}}T(g,!g.hasOwnProperty)}}else if(D==="boolean")X[k++]=g?195:194;else if(D==="bigint"){if(g<BigInt(1)<<BigInt(63)&&g>=-(BigInt(1)<<BigInt(63)))X[k++]=211,ht.setBigInt64(k,g);else if(g<BigInt(1)<<BigInt(64)&&g>0)X[k++]=207,ht.setBigUint64(k,g);else if(this.largeBigIntToFloat)X[k++]=203,ht.setFloat64(k,Number(g));else throw new RangeError(g+" 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?X[k++]=192:(X[k++]=212,X[k++]=0,X[k++]=0);else if(D==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+D)},T=this.useRecords===!1?this.variableMapSize?g=>{let D=Object.keys(g),E=D.length;E<16?X[k++]=128|E:E<65536?(X[k++]=222,X[k++]=E>>8,X[k++]=E&255):(X[k++]=223,ht.setUint32(k,E),k+=4);let I;for(let N=0;N<E;N++)S(I=D[N]),S(g[I])}:(g,D)=>{X[k++]=222;let E=k-t;k+=2;let I=0;for(let N in g)(D||g.hasOwnProperty(N))&&(S(N),S(g[N]),I++);X[E+++t]=I>>8,X[E+t]=I&255}:g=>{let D=Object.keys(g),E,I=a.transitions||(a.transitions=Object.create(null)),N=0;for(let R=0,V=D.length;R<V;R++){let U=D[R];E=I[U],E||(E=I[U]=Object.create(null),N++),I=E}let _=I[Gs];if(_)_>=96&&m?(X[k++]=((_-=96)&31)+96,X[k++]=_>>5):X[k++]=_;else{_=a.nextId,_||(_=64),_<y&&this.shouldShareStructure&&!this.shouldShareStructure(D)?(_=a.nextOwnId,_<b||(_=y),a.nextOwnId=_+1):(_>=b&&(_=y),a.nextId=_+1);let R=D.highByte=_>=96&&m?_-96>>5:-1;I[Gs]=_,a[_-64]=D,_<y?(D.isShared=!0,a.sharedLength=_-63,n=!0,R>=0?(X[k++]=(_&31)+96,X[k++]=R):X[k++]=_):(R>=0?(X[k++]=213,X[k++]=114,X[k++]=(_&31)+96,X[k++]=R):(X[k++]=212,X[k++]=114,X[k++]=_),N&&(w+=O*N),v.length>=h&&(v.shift()[Gs]=0),v.push(I),S(D))}for(let R=0,V=D.length;R<V;R++)S(g[D[R]])},M=g=>{let D;if(g>16777216){if(g-t>u0)throw new Error("Packed buffer would be larger than maximum buffer size");D=Math.min(u0,Math.round(Math.max((g-t)*(g>67108864?1.25:2),4194304)/4096)*4096)}else D=(Math.max(g-t<<2,X.length-1)>>12)+1<<12;let E=new xp(D);return ht=new DataView(E.buffer,0,D),X.copy?X.copy(E,0,t,g):E.set(X.slice(t,g)),k-=t,t=0,eo=E.length-10,X=E}}useBuffer(r){X=r,ht=new DataView(X.buffer,X.byteOffset,X.byteLength),k=0}};bp=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,zs];_c=[{pack(i,r,e){let t=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&t>=0&&t<4294967296){let{target:o,targetView:n,position:a}=r(6);o[a++]=214,o[a++]=255,n.setUint32(a,t)}else if(t>0&&t<17179869184){let{target:o,targetView:n,position:a}=r(10);o[a++]=215,o[a++]=255,n.setUint32(a,i.getMilliseconds()*4e6+(t/1e3/4294967296>>0)),n.setUint32(a+4,t)}else if(isNaN(t)){if(this.onInvalidDate)return r(0),e(this.onInvalidDate());let{target:o,targetView:n,position:a}=r(3);o[a++]=212,o[a++]=255,o[a++]=255}else{let{target:o,targetView:n,position:a}=r(15);o[a++]=199,o[a++]=12,o[a++]=255,n.setUint32(a,i.getMilliseconds()*1e6),n.setBigInt64(a+4,BigInt(Math.floor(t)))}}},{pack(i,r,e){let t=Array.from(i),{target:o,position:n}=r(this.structuredClone?3:0);this.structuredClone&&(o[n++]=212,o[n++]=115,o[n++]=0),e(t)}},{pack(i,r,e){let{target:t,position:o}=r(this.structuredClone?3:0);this.structuredClone&&(t[o++]=212,t[o++]=101,t[o++]=0),e([i.name,i.message])}},{pack(i,r,e){let{target:t,position:o}=r(this.structuredClone?3:0);this.structuredClone&&(t[o++]=212,t[o++]=120,t[o++]=0),e([i.source,i.flags])}},{pack(i,r){this.structuredClone?d0(i,16,r):p0(Rc?Buffer.from(i):new Uint8Array(i),r)}},{pack(i,r){let e=i.constructor;e!==f0&&this.structuredClone?d0(i,gp.indexOf(e.name),r):p0(i,r)}},{pack(i,r){let{target:e,position:t}=r(1);e[t]=193}}];function d0(i,r,e,t){let o=i.byteLength;if(o+1<256){var{target:n,position:a}=e(4+o);n[a++]=199,n[a++]=o+1}else if(o+1<65536){var{target:n,position:a}=e(5+o);n[a++]=200,n[a++]=o+1>>8,n[a++]=o+1&255}else{var{target:n,position:a,targetView:s}=e(7+o);n[a++]=201,s.setUint32(a,o+1),a+=4}n[a++]=116,n[a++]=r,n.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),a)}function p0(i,r){let e=i.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:n}=r(e+5);t[o++]=198,n.setUint32(o,e),o+=4}t.set(i,o)}function zA(i,r,e,t){let o=i.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(i,e),e+=o,e}function GA(i,r){let e,t=r.length*6,o=i.length-t;for(r.sort((n,a)=>n.offset>a.offset?1:-1);e=r.pop();){let n=e.offset,a=e.id;i.copyWithin(n+t,n,o),t-=6;let s=n+t;i[s++]=214,i[s++]=105,i[s++]=a>>24,i[s++]=a>>16&255,i[s++]=a>>8&255,i[s++]=a&255,o=n}return i}function ci(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");bp.unshift(i.Class),_c.unshift(i)}c0(i)}var h0=new Zi({useRecords:!1}),FA=h0.pack,jA=h0.pack;var{NEVER:UA,ALWAYS:kA,DECIMAL_ROUND:HA,DECIMAL_FIT:WA}=Nc,m0=512,qA=1024;var y0=new Zi({structuredClone:!0});ci({Class:fe.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,fe.prototype),i}});ci({Class:be.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,be.prototype),i}});ci({Class:Ke.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Ke.prototype),i}});ci({Class:Bs.prototype.constructor,type:4,write(i){return i.id},read(i){return new Bs(i)}});ci({Class:Vs.prototype.constructor,type:5,write(i){return i.data},read(i){return new Vs(i)}});ci({Class:Qe.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,Qe.prototype),i}});function $A(i){var r=0;if(i.length===0)return r;for(let e=0;e<i.length;e++){let t=i[e];r=(r<<5)-r+t,r=r&r}return r}function vp(i){if(Qn(i))return i;if(Array.isArray(i))return i.map(vp);if(typeof i=="object"&&i!==null){let r={};for(let e of Object.keys(i).sort())r[e]=vp(i[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}else return i}var Lc;(t=>{function i(o){return y0.pack(o)}t.serialize=i;function r(o){return y0.unpack(o)}t.deserialize=r;function e(o){return $A(i(vp(o))).toString()}t.checksum=e})(Lc||(Lc={}));var pi="personal camera",fi="a218fcc3-276b-49b9-b485-49037fd14f5f",w0=2960946,mt=5526619;var ia;(f=>{function i(h,m){return h[0]===m[0]&&h[1]===m[1]}f.isEqual=i;function r(h,m,y){return[h[0]+(m[0]-h[0])*y,h[1]+(m[1]-h[1])*y]}f.lerp=r;function e(h,m){return[h[0]+m[0],h[1]+m[1]]}f.add=e;function t(h,m){return[h[0]-m[0],h[1]-m[1]]}f.sub=t;function o(h,m){return[h[0]*m[0],h[1]*m[1]]}f.multiply=o;function n(h,m){return[h[0]/m[0],h[1]/m[1]]}f.divide=n;function a(h,m){return Math.pow(m[0]-h[0],2)+Math.pow(m[1]-h[1],2)}f.distanceSquared=a;function s(h,m){return Math.sqrt(a(h,m))}f.distance=s;function l(h,m){return h[0]*m[0]+h[1]*m[1]}f.dot=l;function c(h,m){return[h[0]*m,h[1]*m]}f.scalarMultiply=c;function u(h,m,y){let b=f.sub(m,h),v=f.sub(y,h),w=f.dot(b,v)/f.dot(b,b),O=f.scalarMultiply(b,w);return f.add(h,O)}f.projectionOnto=u;function p(h,m,y){return s(h,u(h,m,y))}f.projectionOntoDistance=p;function d(h,m){return[(h[0]+m[0])*.5,(h[1]+m[1])*.5]}f.center=d})(ia||(ia={}));var ui;(s=>{function i(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}s.isEqual=i;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 n(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])}s.dist=n;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})(ui||(ui={}));var g0;(e=>{function i(t,o){return t[0]===o[0]&&t[1]===o[1]&&t[2]===o[2]&&t[3]===o[3]}e.isEqual=i;function r(t,o,n){return[t[0]+(o[0]-t[0])*n,t[1]+(o[1]-t[1])*n,t[2]+(o[2]-t[2])*n,t[3]+(o[3]-t[3])*n]}e.lerp=r})(g0||(g0={}));var x0;(a=>{let i=180/Math.PI,r=Math.PI/180;function e(s){return typeof s=="number"?s*i: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 n(s){return[t(s[0]),t(s[1]),t(s[2])]}a.degToRad=n})(x0||(x0={}));var di;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function r(n,a){for(let s=0;s<16;s++)if(n[s]!==a[s])return!1;return!0}o.isEqual=r;function e(n){return n??o.identity}o.simplify=e;function t(n,a){let s=a.slice(0);for(var l=0,c=a.length;l<c;l+=3){let u=n[3]*a[l]+n[7]*a[l+1]+n[11]*a[l+2]+n[15];s[l]=(n[0]*a[l]+n[4]*a[l+1]+n[8]*a[l+2]+n[12])/u,s[l+1]=(n[1]*a[l]+n[5]*a[l+1]+n[9]*a[l+2]+n[13])/u,s[l+2]=(n[2]*a[l]+n[6]*a[l+1]+n[10]*a[l+2]+n[14])/u}return s}o.applyMatrix4=t})(di||(di={}));var wt;(p=>{function i(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}p.isRGB=i,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 n(d){return{r:d.r,g:d.g,b:d.b}}p.clone=n;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,f){return d.r===f.r&&d.g===f.g&&d.b===f.b}p.equals=l;function c(d,f){return d.r.toFixed(2)===f.r.toFixed(2)&&d.g.toFixed(2)===f.g.toFixed(2)&&d.b.toFixed(2)===f.b.toFixed(2)}p.equalsFixed=c;function u(d,f,h){return{r:d.r+(f.r-d.r)*h,g:d.g+(f.g-d.g)*h,b:d.b+(f.b-d.b)*h}}p.lerp=u})(wt||(wt={}));var Ie;(c=>{c.white={...wt.white,a:1},c.transparent={...wt.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{...wt.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 n(u,p){return wt.equals(u,p)&&u.a===p.a}c.equals=n;function a(u,p){return wt.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:f}=c.white){return`rgba(${u*255}, ${p*255}, ${d*255}, ${f})`}c.toStyle=l})(Ie||(Ie={}));var Bc;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Bc||(Bc={}));var b0;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(b0||(b0={}));var v0;(r=>r.defaultData={control1:[.5,0],control2:[.5,1]})(v0||(v0={}));var S0;(n=>(n.linear=[0,0,1,1],n.ease=[.25,.1,.25,1],n.easeIn=[.42,0,1,1],n.easeOut=[0,0,.58,1],n.easeInOut=[.42,0,.58,1]))(S0||(S0={}));function Sp(i){return typeof i=="string"&&i.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i):!1}var Dr;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(Dr||(Dr={}));var hi;(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(n){return n.type==="PerspectiveCamera"?n.perspective?.zoom??1:n.orthographic?.zoom??1}o.getZoom=t})(hi||(hi={}));var ro;(e=>{function i(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(n=>n*(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=i;function r(t,o){let n={...t};if(XA.forEach(a=>{Object.assign(n,{[a]:o[a]??t[a]})}),n.radial={...t.radial},o.radial){let a=t.radial,s=o.radial;YA.forEach(l=>{Object.assign(n.radial,{[l]:s[l]??a[l]})})}if(n.linear={...t.linear},o.linear){let a=t.linear,s=o.linear;KA.forEach(l=>{Object.assign(n.linear,{[l]:s[l]??a[l]})})}if(n.grid={...t.grid},o.grid){let a=t.grid,s=o.grid;QA.forEach(l=>{Object.assign(n.grid,{[l]:s[l]??a[l]})})}if(n.toObject={...t.toObject},o.toObject){let a=t.toObject,s=o.toObject;ZA.forEach(l=>{Object.assign(n.toObject,{[l]:s[l]??a[l]})})}if(n.randomnessObject={...t.randomnessObject},o.randomnessObject){let a=t.randomnessObject,s=o.randomnessObject;JA.forEach(l=>{Object.assign(n.randomnessObject,{[l]:s[l]??a[l]})})}return n}e.merge=r})(ro||(ro={}));var Vc;(t=>{t.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let r=["radial","linear","grid","toObject","randomnessObject"];function e(o,n){let a=[];o.count!==void 0&&a.push({type:0,path:n,props:{count:o.count}});for(let s of r){let l=o[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...n,s],props:l})}return a}t.toOps=e})(Vc||(Vc={}));var XA=["count"],YA=["radius","start","end","position","scale","rotation"],KA=["position","scale","rotation"],QA=["count","size"],ZA=["count","position","scale","rotation"],JA=["strength","scale","rotation","position","movement","seed","freqScale"];var zc;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function r(t){return e.all.includes(t)}e.is=r})(zc||(zc={}));var Gc;(e=>{function i(t){return r(t)}e.defaultData=i;function r(t){if(t==="PointLight")return{type:t,color:Ie.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(t==="SpotLight")return{type:t,color:Ie.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(t==="DirectionalLight")return{type:t,color:Ie.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Gc||(Gc={}));var na;(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}))(na||(na={}));var mi;(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]})(mi||(mi={}));var wp;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function r(t,o){return t.castShadow===o.castShadow&&t.receiveShadow===o.receiveShadow}e.equals=r})(wp||(wp={}));var Pp;(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})(Pp||(Pp={}));var Fc;(r=>r.defaultData={...Pp.defaultData,...wp.defaultData})(Fc||(Fc={}));var P0;(r=>{function i(e,t){let o=[];if("material"in e){let n=typeof e.material=="string"?t.materials[e.material]??t.lib.materials[e.material]?.asset:e.material;n&&o.push(n)}else if("materials"in e)for(let n of e.materials){let a=typeof n=="string"?t.materials[n]??t.lib.materials[n]?.asset:n;a&&o.push(a)}return o}r.getMaterialData=i})(P0||(P0={}));var aa;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(aa||(aa={}));var O0;(r=>{function i(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=i})(O0||(O0={}));function C0(i){return i.type!=="displace"}var T0;(r=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}r.is=i})(T0||(T0={}));var A0=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],M0=["wrapping","image","video","name","minFilter","magFilter"],bt;(o=>{function i(n,a){let{texture:s,...l}=a;if(Object.assign(n,l),s){let c=n.texture;c&&Object.assign(c,s)}}o.patch=i;function r(n,a){return n==="light"&&a?e(a):t(n)}o.defaultData=r;function e(n){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(n){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(n){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(n){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:aa.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...a,type:"color",color:wt.fromHex(mt)};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:{...wt.fromHex(6710886),a:1},colorB:{...wt.fromHex(6710886),a:1},colorC:{...wt.fromHex(16777215),a:1},colorD:{...wt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:Ie.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Ie.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:Ie.fromHexAndA(0,1),contourColor:Ie.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,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:{...wt.fromHex(0),a:1},colorB:{...wt.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 Pt;(c=>{function i(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=i;function r(u){let p="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([f,h])=>{p+=`${f}${h}`,Array.isArray(h)?h.forEach(m=>p+=`${m}`):typeof h=="object"?Object.values(h).forEach(m=>{typeof m=="number"?p+=`${m.toFixed(4)}`:p+=`${m}`}):p+=`${h}`})}),p}c.getHash=r;function e(){return{layers:new be}}c.defaultEmptyData=e;function t(u="layer1",p="layer2"){return n("phong",u,p)}c.defaultData=t;function o(u,p){return{...u,name:p}}c.withName=o;function n(u,p="layer1",d="layer2"){let f=new be;return f.push({fi:0,data:bt.defaultData("light",u),id:p}),f.push({fi:1,data:bt.defaultData("color"),id:d}),{layers:f}}c.defaultTwoLayerData=n;function a(u){let p=bt.defaultData("texture");u&&Object.assign(p.texture,{image:u});let d=new be;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",f="layer2"){let h=bt.defaultData("texture");Object.assign(h.texture,{image:u});let m=new be;return m.push({fi:0,data:h,id:d}),m.push({fi:1,data:bt.defaultData("light",p),id:f}),{layers:m}}c.defaultTwoLayerTextureData=s;function l(u,p="phong",d="layer1",f="layer2"){let h=bt.defaultData("video");Object.assign(h.texture,{video:u});let m=new be;return m.push({fi:0,data:h,id:d}),m.push({fi:1,data:bt.defaultData("light",p),id:f}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})(Pt||(Pt={}));var sa;(r=>{function i(){return{points:new be,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=i})(sa||(sa={}));var la;(r=>{function i(){return{points:new be,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}r.defaultData=i})(la||(la={}));var Op={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var jc;(r=>{function i(e,t){let o={...e};return eM.forEach(n=>{Object.assign(o,{[n]:t[n]??e[n]})}),o}r.merge=i})(jc||(jc={}));var Uc={shape:Op,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},eM=["depth","offset","angle","twist","startScale","endScale"];var Fs;(e=>{function i(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"||t==="UIGeometry"}e.is2DParametricMesh=i;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})(Fs||(Fs={}));var kc;(r=>{function i(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=i})(kc||(kc={}));var oo;(r=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};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:la.defaultData(),extrusion:Uc};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:sa.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==="ShapeBlendGeometry")return{type:e,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};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=i})(oo||(oo={}));var Hc;(r=>r.defaultData={enabled:!1,useBackgroundColor:!1,color:wt.white,near:.1,far:2e3})(Hc||(Hc={}));var Wc;(e=>{let i={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...i,blendFunction:16,granularity:15},bloom:{...i,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...i,offset:[2,2]},vignette:{...i,darkness:1,offset:0},hueSaturation:{...i,hue:3,saturation:0},brightnessContrast:{...i,brightness:.25,contrast:0},depthOfField:{...i,focusDistance:100,focalLength:20,bokehScale:5},noise:{...i,blendFunction:16}}})(Wc||(Wc={}));var Tp;(r=>r.defaultData={softShadowQuality:"low"})(Tp||(Tp={}));var Cp;(r=>r.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Cp||(Cp={}));var Ap;(r=>r.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Ap||(Ap={}));var js;(r=>r.defaultData={usePhysics:!1,gravity:-10})(js||(js={}));var Mp;(r=>r.defaultData={playCamera:pi,gameControlObject:null})(Mp||(Mp={}));var qc;(r=>r.defaultData={backgroundColor:Ie.fromHexAndA(w0,1),postprocessing:Wc.defaultData,fog:Hc.defaultData,globalPhysics:js.defaultData,ambient:Cp.defaultData,ao:Ap.defaultData,shadow:Tp.defaultData,publish:Mp.defaultData})(qc||(qc={}));var $c;(r=>r.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})($c||($c={}));var I0;(e=>{function i(t){return t==="Component"||t==="Instance"}e.isComponentRelated=i;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(I0||(I0={}));var ca;(o=>{o.identity={...Bc.identity,hiddenMatrix:di.identity};function r(n){return{position:n.position,rotation:n.rotation,scale:n.scale,hiddenMatrix:n.hiddenMatrix}}o.fromObject=r;function e(n,a){return{position:a?.position||n.position,rotation:a?.rotation||n.rotation,scale:a?.scale||n.scale,hiddenMatrix:a?.hiddenMatrix||n.hiddenMatrix}}o.merge=e;function t(n,a){return Hl({position:ui.isEqual(n.position,a.position)?void 0:a.position,rotation:ui.isEqual(n.rotation,a.rotation)?void 0:a.rotation,scale:ui.isEqual(n.scale,a.scale)?null:a.scale,hiddenMatrix:di.isEqual(n.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=t})(ca||(ca={}));var yt;(r=>r.defaultData={states:new be,events:new be,visible:!0,raycastLock:!1,physics:mi.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...ca.identity,cloner:null})(yt||(yt={}));var Xc;(r=>r.defaultData={type:"Empty",...yt.defaultData})(Xc||(Xc={}));var E0;(r=>r.defaultData={type:"ParticleCollider",...$c.defaultData,...yt.defaultData})(E0||(E0={}));var N0;(r=>r.defaultData={type:"Component",...yt.defaultData})(N0||(N0={}));var D0;(r=>r.defaultData={type:"Particle",...yt.defaultData,...na.defaultData})(D0||(D0={}));var Eo;(r=>r.defaultData={type:"Mesh",...yt.defaultData,...Fc.defaultData})(Eo||(Eo={}));var Ji;(r=>r.defaultData={...yt.defaultData,...ca.identity,position:[0,0,hi.DefaultTargetOffset],...hi.defaultData})(Ji||(Ji={}));var Yc;(e=>{function i(t){return{...yt.defaultData,...Gc.defaultData(t)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Yc||(Yc={}));var ua;(e=>{function i(t,o,n=0){for(;n<o.length;){let a=t?t[o[n]]:void 0;if(o.length===n+1)return a;if(a)t=a.descendants,n+=1;else return}}e.resolveWithDes=i;function r(t,o,n=0){let a=i(t,o,n);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=r})(ua||(ua={}));var io;(n=>{n.rootOverrideProps=["physics","events"],n.compositeNonOptionalOverrideProps=["geometry"],n.compositeEntireOverrideOverrideProps=["material"];function t(a,s){return{...yt.defaultData,...s,component:a,overrides:new Qe,physics:void 0,events:void 0,type:"Instance"}}n.ofComponent=t;function o(a){let s=ca.fromObject(a.data);return t(a.id,s)}n.fromComponentData=o})(io||(io={}));var No;(e=>{e.defaultData={type:"Page",...yt.defaultData,physics:{...mi.defaultData,fusedBody:!1},...qc.defaultData,camera:Ji.defaultData};function r(t){return t.uiScene!==void 0}e.isUIPage=r})(No||(No={}));var Kc;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:di.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:mi.defaultData,states:new be,events:new be,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...hi.defaultData},s.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"]},s.defaultMeshObject={name:"Rectangle",...yt.defaultData,...Eo.defaultData,geometry:oo.defaultData("RectangleGeometry"),material:Pt.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...yt.defaultData,...Eo.defaultData,geometry:oo.defaultData("BooleanGeometry"),material:Pt.defaultTwoLayerData("phong","layer1","layer2")},s.defaultShapeBlendObject={name:"Shape Blend",...yt.defaultData,...Eo.defaultData,geometry:oo.defaultData("ShapeBlendGeometry"),material:Pt.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...yt.defaultData,...Eo.defaultData,geometry:oo.defaultData("TextGeometry"),material:Pt.defaultTwoLayerData("phong","layer1","layer2")},s.defaultInputObject={name:"Input",...yt.defaultData,...Eo.defaultData,geometry:oo.defaultData("InputGeometry"),material:Pt.defaultTwoLayerData("phong","layer1","layer2")}))(Kc||(Kc={}));var en;(o=>{function i(n,a){let s={name:a};return n.type==="Mesh"?(s.geometry={},"material"in n&&(s.material={layers:new Qe}),"materials"in n&&(s.materials=n.materials.map(l=>({layers:new Qe})))):Dr.is(n.type)&&(s.perspective={},s.orthographic={}),s}o.newEmpty=i;function r(n,a){if(a===void 0)return n;let s={...n};return"material"in s&&"material"in a&&a.material&&(s.material=ai(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=ai(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 f=l[c]?.layers?.data(p);f&&bt.patch(f,d)}}}).data),s}function e(n,a){let s,l=[],c={orthographic:0,perspective:0,geometry:0};function u(p,d){for(let[f,h]of Object.entries(d.layers)){let{texture:m,...y}=h;if(m!==void 0&&Object.keys(m).length>0){let b={path:[...p,"layers",f,"texture"],props:m,type:0};l.push(b)}if(Object.keys(y).length>0){let b={path:[...p,"layers",f],props:y,type:0};l.push(b)}}}for(let[p,d]of Object.entries(a))if(p!=="name")if(p==="cloner")l.push(...Vc.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[f,h]of Object.entries(d))u(["materials",f],h);else if(c[p]===0){if(p==="geometry"&&d.extrusion!==void 0){let f={path:[p,"extrusion"],props:d.extrusion,type:0};l.push(f),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let f={path:[p],props:d,type:0};l.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[p]=d;return l}o.toOps=e;function t(n,a){if(a===void 0)return n;let s={...n};if(Object.assign(s,ca.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})}),Dr.is(n.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(n.type==="Mesh")"geometry"in a&&Object.assign(s,{geometry:kc.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=r(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:ro.merge(s.cloner,a.cloner)});else if(n.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:ro.merge(s.cloner,a.cloner)});else if(zc.is(n.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=wt.clone(l.color))}return s}o.patch=t})(en||(en={}));var da;(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})(da||(da={}));var br;(r=>r.defaultData={orbitControls:da.defaultData,playPage:fi,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,t)=>{let o=0,n=0;return t<5?n=-30:t<10&&(n=30),t===0||t===10||t===5?o=30:(t===4||t===11||t===9)&&(o=-30),[120,[o,n],"show"]}),settings:{image:{format:"jpg",ratio:1},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3},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})(br||(br={}));var Ip;(r=>r.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Ip||(Ip={}));var Ep;(r=>r.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Ep||(Ep={}));var Do;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Ip.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Ep.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Do||(Do={}));var _0;(e=>{function i(t){return t.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function r(t,o,n){t.scene.objects.traverseFrom(o,(a,s)=>{if(s.type==="Instance"){let l=pa.getComponentData(t,s.component)?.data;l&&n(a,s,l.events)}else n(a,s,s.events)})}e.traverseModuleInstances=r})(_0||(_0={}));var _o;(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:Yc.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(u=!0,p=[]){let d=[],f=Kc.defaultMeshObject;u&&(d.push({...c.defaultLight}),d.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:f,children:[]})),d.push(...p);let h=new Ke;return h.push({fi:1,id:fi,data:{...No.defaultData,name:"Scene 1"},children:d}),h}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:br.defaultData,styles:Do.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new Ke,publish:br.defaultData,styles:Do.defaultData()}},c.emptyDataWithPage=function(u=!0){return{objects:e(u),publish:br.defaultData,styles:Do.defaultData()}},c.emptyData=function(){return{objects:new Ke,publish:{...br.defaultData},styles:Do.defaultData()}};function s(u){return{...c.defaultData,objects:Bt(u,Ke.prototype)}}c.withObjs=s;function l(u,p){return s([{id:u,data:p,children:[],fi:0}])}c.withObj=l})(_o||(_o={}));var fa;(r=>r.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(fa||(fa={}));var Qc;(e=>(e.defaultData=t=>({url:t,name:"New Webhook",parametersSchemas:new be}),e.defaultParameterValueByType=t=>t==="number"?0:t==="boolean"?!1:""))(Qc||(Qc={}));var R0;(r=>r.defaultData=(e,t="GET")=>({url:e,method:t,name:"New API",headers:new be,queries:new be,autoStart:!0}))(R0||(R0={}));var yi;(n=>{function i(a){return a.textValue!==void 0}n.isTextValue=i;function r(a){return typeof a=="number"}n.isNumber=r;function e(a){return typeof a=="boolean"}n.isBoolean=e;function t(a){return i(a)?"string":e(a)?"boolean":"number"}n.typeOfVariable=t;function o(a){return n.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():n.isBoolean(a)?a?"True":"False":n.isNumber(a)?parseFloat(a.toFixed(3)).toString():a.toString()}n.getDisplayedValue=o})(yi||(yi={}));var Np;(r=>r.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(Np||(Np={}));var L0;(r=>r.all=[...Np.all,"components"])(L0||(L0={}));var B0;(r=>{function i(){return{images:new fe,videos:new fe,colors:new fe,audios:new fe,particles:new fe,fonts:new fe,materials:new fe,components:new fe,variables:new fe,userAPIs:new fe,userWebhooks:new fe}}r.defaultData=i})(B0||(B0={}));var _r;(r=>{function i(){return{images:new fe,videos:new fe,colors:new fe,audios:new fe,particles:new fe,fonts:new fe,materials:new fe,components:new fe,variables:new fe,userAPIs:new fe,userWebhooks:new fe}}r.defaultData=i})(_r||(_r={}));var vr;(n=>{function i(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Bt(a,fe.prototype)}n.defaultColors=i;function r(){return Bt({},fe.prototype)}n.defaultImages=r;function e(){return{catelogs:new fe,materials:new fe,images:new fe,videos:new fe,colors:new fe,audios:new fe,particles:new fe,fonts:new fe,variables:new be,userAPIs:new fe,userWebhooks:new fe,lib:_r.defaultData()}}n.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)}}n.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}n.getFormattedTimerTime=o})(vr||(vr={}));import{MathUtils as eu}from"three";var Zc;(r=>r.list=["idle","move","jump","run"])(Zc||(Zc={}));var Jc;(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 be,move:new be,jump:new be,run:new be},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Ie.fromHexAndA(3728051,1)}}))(Jc||(Jc={}));function V0(i){i.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]],n=[0,1];for(let s=2;s<10;s++)o.push(o[1]),n.push(1);let a={...Nr(at(r),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,r.near),far:Math.max(0,r.far),colors:o,steps:n,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={...at(r),near:Math.max(r.near,0),far:Math.max(r.far,0)};Object.assign(r,e)}})}function Ro(i,r){Object.values(i.shared.materials).forEach(e=>r(e))}function Lo(i,r){i.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach((o,n)=>{o===void 0&&(t.materials[n]=Pt.defaultData(),o=t.materials[n]),typeof o!="string"&&r(o)}):"material"in t?typeof t.material!="string"&&(t.material===void 0&&(t.material=Pt.defaultData()),r(t.material)):t.type==="Mesh"&&(t.material===void 0&&(t.material=Pt.defaultData()),r(t.material)),"overrides"in t&&Object.values(t.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&Object.getPrototypeOf(o.material)!==Qe.prototype&&r(o.material)})})}function tM(i){Object.assign(i.scene.publish,{orbitControls:{...da.defaultData,...at(i.scene.publish.orbitControls)}})}function rM(i){Object.assign(i.scene.publish.settings,{video:{...br.defaultData.settings.video,...at(i.scene.publish.settings.video)}})}function oM(i){function r(e){if(e.layers){for(let t of Object.values(e.layers))if(t){for(let[o,n]of Object.entries(t))if((A0.includes(o)||typeof n=="boolean")&&delete t[o],o==="texture")for(let[a,s]of Object.entries(n))(M0.includes(a)||typeof s=="boolean")&&delete n[a]}}}i.scene.objects.traverse((e,t)=>{t.states.forEach(o=>{let n=o;n.material?r(n.material):n.materials&&n.materials.forEach(a=>{r(a)})})})}function iM(i){i.scene.publish.withBackground=!0}function nM(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function aM(i){i.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 sM(i){i.scene.objects.traverse((r,e)=>{let t=e.geometry;t&&(t.type==="DodecahedronGeometry"||t.type==="IcosahedronGeometry")&&(t.detail=Math.round(t.detail))})}function lM(i){i.scene.objects.traverse((r,e)=>{let t=i.scene.objects.unproxy().parent(r);if(t){let o=at(i.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=at(e).booleanExclude!==!0)}})}function cM(i){i.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 uM(i){function r(t){Object.setPrototypeOf(t,Qe.prototype),t.texture&&Object.setPrototypeOf(t.texture,Qe.prototype)}function e(t){Object.setPrototypeOf(t,Qe.prototype);for(let o in t)r(t[o])}i.scene.objects.traverse((t,o)=>{o.states.forEach(n=>{let a=n;if(a.material){let s=at(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=at(l).layers;e(c),l.layers=c}})})}function z0(i){i.layers===void 0&&Object.assign(i,Pt.defaultTwoLayerData("lambert"))}function Dp(i){!i.layers||i.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={...at(r),colors:e,steps:t};Object.assign(r,o)}})}function dM(i){i.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function G0(i){i.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&Dp(t)}):"material"in e&&typeof e.material!="string"&&Dp(e.material)}),Object.values(i.shared.materials).forEach(r=>Dp(r))}function pM(i){i.scene.environment.ambientLight.softShadows=!1,i.scene.environment.ambientLight.softShadowQuality="low",i.scene.objects.traverse((r,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),i.shared.penumbraSize=new Array(5).fill(.5)}function fM(i){i.shared.audios=Bt({},fe.prototype)}function hM(i){i.shared.videos=Bt({},fe.prototype)}function mM(i){let r=i.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 yM(i){Object.entries(at(i.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete i.shared.images[t]}),Object.entries(at(i.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete i.shared.audios[t]})}function gM(i){i.scene.publish.settings.web.preload=!1}function F0(i){i.layers&&i.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 j0(i){i.layers&&i.layers.forEach(r=>{C0(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 xM(i){i.shared.fonts=Bt({},fe.prototype)}function bM(i){return i.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 vM(i){let r=[];i.scene.objects.traverse((e,t)=>{let o=t;if(o.type==="TextFrame"){let n=Pt.defaultTwoLayerData("phong"),a=typeof o.color=="string"?i.shared.colors[o.color]:o.color;n.layers[1].data.color={r:a.r,g:a.g,b:a.b},n.layers[1].data.alpha=o.alpha;let s=bM(o.font);i.shared.fonts[s]===void 0&&(i.shared.fonts[s]={name:s});let l={name:o.name,...yt.defaultData,...Eo.defaultData,flatShading:!1,wireframe:!1,geometry:{...oo.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:n,states:at(o.states),events:at(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},c=at(i.scene.objects).parent(e);i.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),r.push(e)}}),r.forEach(e=>{i.scene.objects.delete(e)})}function SM(i){let r={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};i.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 be,move:new be,jump:new be}});else{let n=new be;Object.assign(o,{actions:n}),(o.type==="MouseDown"||o.type==="MouseUp"||o.type==="KeyDown"||o.type==="KeyUp")&&"url"in o&&n.push({fi:0,id:eu.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,Nr(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},f={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new be({fi:0,id:eu.generateUUID(),data:c},{fi:1,id:eu.generateUUID(),data:d})};n.push({fi:l,id:s,data:f})}),delete o.targets)}})})}function wM(i){i.scene.objects.traverse((r,e)=>{function t(o,n){let a=new be,s=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===n){let p;s.push(c),l.interaction==="play"?p={...Nr(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={...Nr(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:eu.generateUUID(),data:{type:o,actions:a}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function U0(i){let r=i.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 k0(i){Ro(i,U0),Lo(i,U0)}function PM(i){i.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function OM(i){i.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 TM(i){i.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Pt.defaultTwoLayerData("phong"))})}function CM(i){i.scene.publish.orbitControls.autoZoom===void 0&&(i.scene.publish.orbitControls.autoZoom=!1),i.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 AM(i){i.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 MM(i){i.scene.publish.mouseEventTarget===void 0&&(i.scene.publish.mouseEventTarget="canvas"),i.scene.publish.settings.web.hint===void 0&&(i.scene.publish.settings.web.hint=!1)}function IM(i){let{video:r}=i.scene.publish.settings;r.format==="gif"&&r.fps>48&&(r.fps=15)}function EM(i){i.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.resetYPosition=Math.abs(t.resetYPosition-e.position[1]))})})}function NM(i){let r=i.scene.environment.usePhysics;i.scene.objects.traverse((e,t)=>{r&&t.physics===null?t.collision=!1:t.collision="visibility"})}function DM(i){i.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.navmesh=Jc.defaultDataThirdPerson.navmesh)})})}function _M(i){i.scene.styles||(i.scene.styles=Do.defaultData())}function H0(i){i.layers.forEach(r=>{r.type==="light"&&r.category!=="toon"&&r.occlusion===void 0&&(r.occlusion=!0)})}function RM(i){i.scene.environment.ambientLight.occlusion===void 0&&(i.scene.environment.ambientLight.occlusion=!1),i.scene.environment.ambientLight.aoFullRes===void 0&&(i.scene.environment.ambientLight.aoFullRes=!1),i.scene.environment.ambientLight.radius===void 0&&(i.scene.environment.ambientLight.radius=256),i.scene.environment.ambientLight.bias===void 0&&(i.scene.environment.ambientLight.bias=.5),i.scene.environment.ambientLight.aoColor===void 0&&(i.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Lo(i,H0),Ro(i,H0)}function LM(i){i.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&Object.assign(t.gameActions,{run:new be})})})}function BM(i){i.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.keyAssignments=[...t.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function W0(i){i.layers&&i.layers.forEach(r=>{r.type==="light"&&r.bumpMapIntensity===void 0&&(r.bumpMapIntensity=5)})}function q0(i,r){if(r<1&&(Lo(i,V0),Ro(i,V0),i.schema=1),r<2&&(tM(i),i.schema=2),r<3&&(oM(i),i.schema=3),r<4&&(iM(i),i.schema=4),r<5&&(nM(i),i.schema=5),r<6&&(aM(i),i.schema=6),r<7&&(sM(i),i.schema=7),r<8&&(i.schema=8),r<9&&(G0(i),i.schema=9),r<10&&(dM(i),i.schema=10),r<11&&(pM(i),i.schema=11),r<12&&(G0(i),i.schema=12),r<13&&(fM(i),i.schema=13),r<14&&(mM(i),i.schema=14),r<15&&(yM(i),i.schema=15),r<16&&(gM(i),i.schema=16),r<17&&(Lo(i,F0),Ro(i,F0),i.schema=17),r<18&&(Lo(i,z0),Ro(i,z0),i.schema=18),r<19&&(rM(i),i.schema=19),r<20&&(xM(i),vM(i),i.schema=20),r<21&&(SM(i),wM(i),i.schema=21),r<22&&(k0(i),i.schema=22),r<23&&(PM(i),i.schema=23),r<24&&(OM(i),i.schema=24),(r<25||i.shared.videos===void 0)&&(hM(i),r<25&&(i.schema=25)),r<26&&(lM(i),i.schema=26),r<27&&(cM(i),i.schema=27),r<28&&(k0(i),i.schema=28),r<29&&(uM(i),i.schema=29),r<30&&(TM(i),i.schema=30),r<31&&(CM(i),i.schema=31),r<33&&(AM(i),i.schema=33),r<34&&(MM(i),i.schema=34),r<35&&(IM(i),i.schema=35),r<36&&(EM(i),i.schema=36),r<37&&(NM(i),i.schema=37),r<38&&(Lo(i,j0),Ro(i,j0),i.schema=38),r<39&&(DM(i),i.schema=39),r<40&&(_M(i),i.schema=40),r<41&&(RM(i),i.schema=41),r<42&&(LM(i),i.schema=42),r<43&&(BM(i),i.schema=43),r<99){Lo(i,W0),Ro(i,W0),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=pi);let e=at(i.scene.objects),t=i.scene.objects;i.scene.publish.playPage=fi,t.insertBefore(null,null,[{id:fi,data:{...No.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Nr(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Nr(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...js.defaultData,...Nr(i.scene.environment,"usePhysics","gravity")},camera:at(i.scene.ownerCamera)??No.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==_o.TRASH_CAN_ID&&t.move(fi,a.fi,a.id);let o=0,n=0;i.shared.penumbraSize&&i.scene.objects.traverse((a,s)=>{s.type==="DirectionalLight"?(s.penumbraSize=i.shared.penumbraSize[Math.min(o,2)],o+=1):s.type==="SpotLight"&&(s.penumbraSize=i.shared.penumbraSize[3+Math.min(n,1)],n+=1),(s.physics===void 0||s.physics===null)&&s.type!=="Instance"&&(s.physics={},Object.assign(s.physics,mi.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),i.schema=99}}function $0(i){i.layers&&i.layers.forEach(r=>{r.type==="light"&&r.alphaOverride===void 0&&(r.alphaOverride=1)})}function VM(i){i.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 zM(i){Array.isArray(at(i.events))&&i.events?.forEach(r=>{"disabled"in r||(r.disabled=!1),(r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress")&&(r.mode=r.mode||"Object")})}var ha=180/Math.PI;function X0(i){i.rotation=i.rotation.slice(0,3).map(r=>r*ha)}function Y0(i){X0(i),i.type==="Page"&&X0(i.camera),i.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(t=>t*ha))});let r=i.geometry;r&&r.type==="SphereGeometry"&&(r.thetaLength=(r.thetaLength??180)*ha),r&&r.type==="TorusGeometry"&&(r.arc=r.arc*ha),r&&r.type==="PathGeometry"&&(r.extrusion.angle*=ha,r.extrusion.twist*=ha),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(at(i.events))&&i.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 GM(i){i.shared.variables=Bt({},fe.prototype)}function FM(i){let r=at(i.shared.variables);i.shared.variables=Bt(Object.entries(r??{}).map(([e,t],o)=>({fi:o,id:e,data:t})),be.prototype)}var no=116;function K0(i,r){r(i.data);for(let e of i.children)K0(e,r)}function jM(i){let r=i.schema??104;r!==no&&r<105&&(K0(i.asset,Y0),i.schema=105)}function UM(i){i.shared.particles=Bt({},fe.prototype),i.shared.lib&&(i.shared.lib.particles=_r.defaultData().particles)}function kM(i){i.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 HM(i){i.scene.objects.traverse((r,e)=>{e.type==="Page"&&(e.postprocessing.depthOfField.focusDistance=100,e.postprocessing.depthOfField.focalLength=20,e.postprocessing.depthOfField.bokehScale=5)})}function WM(i){i.scene.objects.traverse((r,e)=>{Array.isArray(at(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(n=>{n.type==="Transition"&&(n.runMode=o??"Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode=o==="Toggle"?"Toggle":"Normal")}):t.type==="MouseHover"||t.type==="MousePress"||t.type==="KeyPress"?t.actions?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.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(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")}),t.dragDropActions?.drop?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")})):t.type==="Resize"?(delete t.actions,t.breakpoints?.forEach(n=>{n.actions?.forEach(a=>{(a.type==="Transition"||a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Toggle")})})):t.type==="Start"?t.actions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Once"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}):t.type==="VariableChange"||t.type==="Scroll"?t.actions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}):t.type==="Conditional"&&(delete t.actions,t.inActions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}),t.outActions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}))})})}function qM(i){i.shared.userAPIs=Bt({},fe.prototype),i.shared.userWebhooks=Bt({},fe.prototype),i.shared.lib&&(i.shared.lib.userAPIs=_r.defaultData().userAPIs,i.shared.lib.userWebhooks=_r.defaultData().userWebhooks)}function $M(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=br.defaultData.settings.videoStatic)}function tu(i){let r=i.schema??0;if(r!==no){console.warn("updating from ",r,"to ",no),q0(i,r),r<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=br.defaultData.joystickSizeAndXYOffset),i.schema=100),r<101&&(Lo(i,$0),Ro(i,$0),i.schema=101),r<102&&(VM(i),i.schema=102),r<104&&(i.shared.catelogs=new fe,i.shared.lib=_r.defaultData(),i.schema=104),r<105&&(GM(i),i.scene.objects.traverse((e,t)=>{Y0(t)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))jM(e);r<106&&(FM(i),i.schema=106),r<107&&(i.shared.lib.variables=_r.defaultData().variables,i.schema=107),r<109&&(UM(i),i.schema=109),r<110&&(kM(i),i.schema=110),r<111&&(i.scene.objects.traverse((e,t)=>{zM(t)}),i.schema=111),r<112&&(HM(i),i.schema=112),r<113&&(WM(i),i.schema=113),r<114&&(i.scene.publish.settings.web.imageQuality===void 0&&(i.scene.publish.settings.web.imageQuality=70),i.schema=114),r<115&&(qM(i),i.schema=115),r<116&&($M(i),i.schema=116)}}var pa;(c=>{c.defaultData={schema:no,scene:_o.defaultData,frames:new fe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",fa.defaultData),shared:{...vr.emptyData(),colors:vr.defaultColors()}},c.emptyDataForImports=function(){let u=_o.emptyDataWithPage();return{schema:no,scene:u,frames:new fe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",fa.defaultData),shared:{...vr.emptyData(),colors:vr.defaultColors(),images:vr.defaultImages()}}},c.emptyData=function(){return{schema:no,scene:_o.emptyDataWithPage(),frames:new fe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",fa.defaultData),shared:vr.emptyData()}},c.clipboard2dData=function(){return{schema:no,scene:_o.emptyData(),frames:new fe,shared:vr.emptyData()}},c.collabHelper={...Ls,updateSchema(u){return(u.schema??0)<no?ai(u,tu):(u.schema??0)-no}};function n(u){let p=c.collabHelper.updateSchema(u);return typeof p=="number"?p===0?u:null:p.data}c.updateSchemaDirectly=n;function a(u){return{...u,shared:{...u.shared,lib:_r.defaultData()}}}c.withoutLib=a;function s(u,p){let d=u.scene.objects.get(p);if(d&&d.data.type==="Component")return d;{let f=u.shared.lib.components[p];if(f)return f.asset}}c.getComponentData=s;function l(u){let p=Object.values(u.shared.userAPIs);for(let d of p){let f=d.headers;for(let h of f)if(h.data.key.toLowerCase()==="authorization"&&h.data.value!=="")return!0}return!1}c.hasSensitiveData=l})(pa||(pa={}));var ru;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(ru||(ru={}));var Q0;(r=>{function i(e){return!0}r.is=i})(Q0||(Q0={}));var ou;(t=>{t.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function r(o,n){return{position:n?.position??o.position,rotation:n?.rotation??o.rotation,scale:n?.scale??o.scale,shear:n?.shear??o.shear}}t.merge=r;function e(o,n){return Hl({position:ia.isEqual(o.position,n.position)?void 0:n.position,rotation:o.rotation===n.rotation?void 0:n.rotation,scale:ia.isEqual(o.scale,n.scale)?void 0:n.scale,shear:o.shear&&n.shear&&ia.isEqual(o.shear,n.shear)?void 0:n.shear})}t.diff=e})(ou||(ou={}));var _p;(r=>r.defaultData={horizontalConstraint:0,verticalConstraint:0})(_p||(_p={}));var Z0;(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})(Z0||(Z0={}));var iu;(r=>r.defaultData={opacity:1,fill:{color:Ie.fromHexAndA(mt,1),enabled:!0},stroke:{color:Ie.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Ie.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Ie.from0to1([0,0,0,1]),enabled:!1,spread:0}})(iu||(iu={}));var tn;(n=>{function i(a,s){return{name:s}}n.newEmpty=i;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,ou.merge(l,s)),l=r(l,s),l=e(l,s),l}n.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}n.toOps=o})(tn||(tn={}));var Us;(r=>r.defaultData={...ou.defaultData,..._p.defaultData,states:new be,events:new be,visible:!0,raycastLock:!1})(Us||(Us={}));var ma;(r=>r.defaultData={...Us.defaultData,...iu.defaultData})(ma||(ma={}));var nu;(r=>r.defaultData={cornerRadius:[0,0,0,0]})(nu||(nu={}));var Rp;(r=>r.defaultData={...ma.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(Rp||(Rp={}));var ya;(r=>r.defaultData={...ma.defaultData,...nu.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(ya||(ya={}));var Lp;(r=>r.defaultData={...ma.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"})(Lp||(Lp={}));var Bp;(r=>r.defaultData={...ma.defaultData,type:"path2d",path:"",name:"Path"})(Bp||(Bp={}));var J0;(r=>{function i(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}r.is=i})(J0||(J0={}));var ks;(r=>r.defaultData={...Us.defaultData,name:"Group",type:"group2d"})(ks||(ks={}));var Vp;(r=>r.defaultData=()=>({...Us.defaultData,...nu.defaultData,...iu.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Ie.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Ie.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(Vp||(Vp={}));var Bo;(n=>{function i(a){switch(a){case"rectangle2d":return{...ya.defaultData};case"ellipse2d":return{...Rp.defaultData};case"text2d":return{...Lp.defaultData};case"vector2d":return{...ya.defaultData};case"path2d":return{...Bp.defaultData};case"frame2d":return{...Vp.defaultData()};case"group2d":return{...ks.defaultData}}}n.defaultData=i;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]}n.getPivot=r;function e(a){return a.type==="rectangle2d"||a.type==="ellipse2d"||a.type==="text2d"||a.type==="frame2d"}n.isResizeable=e;function t(a){return a.type==="frame2d"&&a.autoLayout!==void 0}n.isAutoLayoutable=t;function o(a){return a.type==="rectangle2d"||a.type==="frame2d"}n.hasCorners=o})(Bo||(Bo={}));var au;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new Ke},e.emptyData=function(){return{type:"scene2d",objects:new Ke}}))(au||(au={}));var nd=Ms(tx());import{Object3D as uD,Vector3 as fr,Euler as bh,MathUtils as Gv,Matrix4 as vn}from"three";var XM=.5*(Math.sqrt(3)-1),Hs=(3-Math.sqrt(3))/6,YM=1/3,ao=1/6,I6=(Math.sqrt(5)-1)/4,E6=(5-Math.sqrt(5))/20,Ws=i=>Math.floor(i)|0,rx=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]),Gp=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 ox(i=Math.random){let r=nx(i),e=new Float64Array(r).map(o=>rx[o%12*2]),t=new Float64Array(r).map(o=>rx[o%12*2+1]);return function(n,a){let s=0,l=0,c=0,u=(n+a)*XM,p=Ws(n+u),d=Ws(a+u),f=(p+d)*Hs,h=p-f,m=d-f,y=n-h,b=a-m,v,w;y>b?(v=1,w=0):(v=0,w=1);let O=y-v+Hs,S=b-w+Hs,T=y-1+2*Hs,M=b-1+2*Hs,g=p&255,D=d&255,E=.5-y*y-b*b;if(E>=0){let _=g+r[D],R=e[_],V=t[_];E*=E,s=E*E*(R*y+V*b)}let I=.5-O*O-S*S;if(I>=0){let _=g+v+r[D+w],R=e[_],V=t[_];I*=I,l=I*I*(R*O+V*S)}let N=.5-T*T-M*M;if(N>=0){let _=g+1+r[D+1],R=e[_],V=t[_];N*=N,c=N*N*(R*T+V*M)}return 70*(s+l+c)}}function ix(i=Math.random){let r=nx(i),e=new Float64Array(r).map(n=>Gp[n%12*3]),t=new Float64Array(r).map(n=>Gp[n%12*3+1]),o=new Float64Array(r).map(n=>Gp[n%12*3+2]);return function(a,s,l){let c,u,p,d,f=(a+s+l)*YM,h=Ws(a+f),m=Ws(s+f),y=Ws(l+f),b=(h+m+y)*ao,v=h-b,w=m-b,O=y-b,S=a-v,T=s-w,M=l-O,g,D,E,I,N,_;S>=T?T>=M?(g=1,D=0,E=0,I=1,N=1,_=0):S>=M?(g=1,D=0,E=0,I=1,N=0,_=1):(g=0,D=0,E=1,I=1,N=0,_=1):T<M?(g=0,D=0,E=1,I=0,N=1,_=1):S<M?(g=0,D=1,E=0,I=0,N=1,_=1):(g=0,D=1,E=0,I=1,N=1,_=0);let R=S-g+ao,V=T-D+ao,U=M-E+ao,B=S-I+2*ao,q=T-N+2*ao,j=M-_+2*ao,F=S-1+3*ao,H=T-1+3*ao,W=M-1+3*ao,ee=h&255,te=m&255,Y=y&255,re=.6-S*S-T*T-M*M;if(re<0)c=0;else{let $=ee+r[te+r[Y]];re*=re,c=re*re*(e[$]*S+t[$]*T+o[$]*M)}let K=.6-R*R-V*V-U*U;if(K<0)u=0;else{let $=ee+g+r[te+D+r[Y+E]];K*=K,u=K*K*(e[$]*R+t[$]*V+o[$]*U)}let Z=.6-B*B-q*q-j*j;if(Z<0)p=0;else{let $=ee+I+r[te+N+r[Y+_]];Z*=Z,p=Z*Z*(e[$]*B+t[$]*q+o[$]*j)}let Q=.6-F*F-H*H-W*W;if(Q<0)d=0;else{let $=ee+1+r[te+1+r[Y+1]];Q*=Q,d=Q*Q*(e[$]*F+t[$]*H+o[$]*W)}return 32*(c+u+p+d)}}function nx(i){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+~~(i()*(256-t)),n=e[t];e[t]=e[o],e[o]=n}for(let t=256;t<512;t++)e[t]=e[t-256];return e}import{Triangle as KM}from"three";var Rr=new KM,su=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 n=1;Rr.a.fromBufferAttribute(r,o),Rr.b.fromBufferAttribute(r,o+1),Rr.c.fromBufferAttribute(r,o+2),n*=Rr.getArea(),e[o/3]=n}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,n=-1;for(;t<=o;){let a=Math.ceil((t+o)/2);if(a===0||e[a-1]<=r&&e[a]>r){n=a;break}else r<e[a]?o=a-1:t=a+1}return n}sampleFace(r,e,t){let o=this.randomFunction(),n=this.randomFunction();return o+n>1&&(o=1-o,n=1-n),Rr.a.fromBufferAttribute(this.positionAttribute,r*3),Rr.b.fromBufferAttribute(this.positionAttribute,r*3+1),Rr.c.fromBufferAttribute(this.positionAttribute,r*3+2),e.set(0,0,0).addScaledVector(Rr.a,o).addScaledVector(Rr.b,n).addScaledVector(Rr.c,1-(o+n)),Rr.getNormal(t),this}};import{Object3D as tI}from"three";var lx=Ms(sx());import{Object3D as QM,Matrix4 as so}from"three";var ZM=new so,JM=new so,eI=new so,Vo;(r=>{function i(e){return e&&e.__isSPEObject}r.is=i})(Vo||(Vo={}));var ga=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new so;this.copyPreviousMatrix=!0;this.hiddenMatrix=new so;this.matrixWorldRigid=new so;this.shearScale=new so;this.shearScaleInv=new so}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof QM&&(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 n=this.parent;if(t&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),o)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(t,o=0){for(let n of this.children)Vo.is(n)&&n.traverseObject(t,o+1)}traverseObject(t,o=0){if(t(this,o)!==!0)for(let a of this.children)Vo.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:n,v:a,q:s}=(0,lx.SVD)(o),l=ZM.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1),c=JM.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=eI.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 n=new so().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),n.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof so?t.hiddenMatrix.premultiply(n):t.applyMatrix4(n),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,n,a,s,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var Fp=class extends ga(tI){},rI=i=>i.type==="Mesh",Lr=class extends Fp{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 Lr(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 rI(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};import{Box3 as OE,BufferGeometry as TE,MeshBasicMaterial as CE}from"three";import{Matrix4 as wE,Mesh as PE}from"three";import{Matrix4 as uu,Vector3 as dx,Euler as lI,MathUtils as $s}from"three";import{Box3 as oI,Line3 as iI,Matrix4 as jp,Vector3 as ur}from"three";var rn=new ur,on=new ur,xa=new jp,ux=[new ur(-1,1,1),new ur(-1,-1,1),new ur(1,-1,1),new ur(1,1,1),new ur(-1,1,-1),new ur(-1,-1,-1),new ur(1,-1,-1),new ur(1,1,-1)],nI=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],aI=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],cx=(i,r,e)=>{i.updateEntityBoxSize(rn,on),xa.copy(r).multiply(i.matrixWorld),on.x===0&&on.y===0&&on.z===0?e.push(new ur(rn.x,rn.y,rn.z).applyMatrix4(xa)):ux.forEach(t=>{e.push(t.clone().multiply(on).add(rn).applyMatrix4(xa))})},qs=class extends oI{constructor(){super(...arguments);this.matrix=new jp;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 jp().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,t)}expandByObjectSize(e,t,o=!1){let n=[];return o===!0?e.traverseEntity(a=>{if(a.visible||a.cloner&&a.data.visible){if(!("geometry"in a)){n.push(new ur);return}cx(a,t,n)}}):cx(e,t,n),this.setFromPoints(n)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(xa.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(on).multiplyScalar(.5),this.getCenter(rn),xa.copy(this.matrix).setPosition(rn),this.vertices=ux.map(e=>e.clone().multiply(on).applyMatrix4(xa))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=nI.map(([e,t])=>new iI(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new ur))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=aI.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var Br={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};import{CurvePath as sI,CubicBezierCurve3 as Up,Vector3 as Vr}from"three";var Hp=class extends sI{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 f=0;f<d.length;f++){let h=d[f];t&&t.equals(h)||(e.push(h),t=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var Wp=.001;function qp(i,r,e){return r.clone().sub(i).cross(r.clone().sub(e)).length()<=Wp}function kp(i,r){let e=new Vr(...i.position),t=new Vr(...i.controlNext.position),o=new Vr(...r.controlPrevious.position),n=new Vr(...r.position);return qp(e,t,n)&&qp(e,o,n)}function cu(i){let r=i.points.map(u=>new Vr(...u.data.position)),e=[i.points[0]],t=new Vr(...e[0].data.position);for(let u=0;u<i.points.length-1;u++)qp(t,r[u],r[u+1])||(e.push(i.points[u]),t=r[u]);e.push(i.points[i.points.length-1]);let o=i.isClosed,n=e.length-(o?0:1),a=e.length,s=[];for(let u=0;u<a;u++){let p=e[u].data,d=new Vr(...p.position),f=new Vr(...p.controlPrevious.position),h=new Vr(...p.controlNext.position),m={position:d,baseRoundness:p.roundness,controlPrevious:f,controlNext:h};if(p.roundness===0||!i.isClosed&&(u===0||u===a-1)){s[u]={...m,removedLength:0};continue}let y=o&&u==0?a-1:u-1,b=o&&u==a-1?0:u+1,v=e[y].data,w=e[b].data,O=new Vr(...v.position),S=new Vr(...w.position),T=O.clone().sub(d).normalize(),M=S.clone().sub(d).normalize();Object.assign(m,{prevDir:T,nextDir:M});let g=kp(v,p),D=kp(p,w);if(!g||!D)s[u]={...m,removedLength:0};else{let E=T.clone().add(M).normalize(),I=E.clone().cross(T).length()/T.dot(E);s[u]={...m,tan:I,removedLength:p.roundness/I}}}for(let u=0;u<n;u++){let p=u,d=o&&u===a-1?0:u+1,f=s[p],h=s[d];if(f.removedLength!==0||h.removedLength!==0){let m=f.position.distanceTo(h.position);f.removedLength=Math.min(f.removedLength,m/2),h.removedLength=Math.min(h.removedLength,m/2)}}let l=[];for(let u=0;u<n;u++){let p=u,d=o&&u===a-1?0:u+1,f=s[p],h=s[d],m=null;if(!kp(e[p].data,e[d].data))f.position.distanceTo(h.position)>Wp&&(m=new Up(f.position,f.controlNext,h.controlPrevious,h.position));else{let y=f.position.clone(),b=h.position.clone();(f.removedLength!==0||h.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),h.prevDir&&b.add(h.prevDir.clone().setLength(h.removedLength))),y.distanceTo(b)>Wp&&(m=new Up(y,y.clone().lerp(b,.3),b.clone().lerp(y,.3),b))}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,f=p.prevDir.clone().multiplyScalar(p.removedLength).add(d),h=p.nextDir.clone().multiplyScalar(p.removedLength).add(d),m=p.tan*p.removedLength,y=p.prevDir.clone().add(p.nextDir).normalize(),b=f.clone().lerp(h,.5),v=f.distanceTo(h)/2,w=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(v,2))).add(b),O=y.clone().multiplyScalar(-m).add(w),S=d.distanceTo(O)/d.distanceTo(b),T=p.prevDir.clone().multiplyScalar(S*d.distanceTo(f)).add(d),M=T.clone().lerp(O,2),g=f.clone().lerp(T,4/3),D=h.clone().lerp(M,4/3);l[2*u]=new Up(f,g,D,h)}let c=new Hp;return l.forEach(u=>{u&&c.add(u)}),c}var De;(r=>{function i(e){return e&&e.__isEntity}r.is=i})(De||(De={}));var ba=i=>De.is(i),cI={type:"completeState",isfromEntity:!0},uI=["x","y","z"],$p=new dx,dI=new dx().set(0,1,0),va=i=>class extends ga(i){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 qs;this._recursiveBBox=new qs;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(De.is(o))return o}entityChildrenCount(){let t=this.children.length;for(;t--;)if(De.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(De.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,n=!1){if(!(this.data.states.length===0&&!n)){for(let a of this.data.states)en.toOps(this.data,a.data).forEach(l=>{let c=ea.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=en.patch(this.data,a),en.toOps(this.data,a).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,o)}))}n&&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=>{ba(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let o;return this.traverseEntity(n=>{n.uuid===t&&(o=n)}),o}traverseSortNextHelper(){let t=this.parent;if(t){let o=t.children,n=o.indexOf(this)+1;if(De.is(o[n]))return o[n];if(De.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&De.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,n=this;for(;n!==t;){if(n===null)return-1;n=n.parent,o+=1}return o}forEachEntity(t){for(let o of this.children)ba(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{De.is(o)&&t(o)})}traverseConcreteEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)ba(a)&&a.isConcreteEntity&&a.traverseEntity(t,o+1)}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)ba(a)&&a.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)ba(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=>ba(t))}isAncestorOf(t){if(this.uuid===t)return!1;let o=!1;return this.traverseEntity(n=>{n.uuid===t&&(o=!0)}),o}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x*$s.RAD2DEG,this.rotation.y*$s.RAD2DEG,this.rotation.z*$s.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Yn(o,t)}getTransformValues(t,o,n){return o[t].map((a,s)=>n?.shared.getVariable(a,[this.uuid,t,uI[s]])??a)}updateTransformState(t,o){let n=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,o)),n=!0),t.rotation&&($p.fromArray(this.getTransformValues("rotation",t,o)).multiplyScalar($s.DEG2RAD),this.rotation.setFromVector3($p),n=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,o)),n=!0),t.hiddenMatrix!==void 0&&(n=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??di.identity)),n&&(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),n}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)De.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{De.is(t)&&t.disposeRecursively()})}toState(t=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return Yn(o,t)}updateByObjUpdateOp(t,o){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},o,!1)}updateByOp(t,o,n,a){let s=this.data;this.data=o;let l=t,c=Le(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 f=Ze.zoom(d,t.path.slice(2));if(f)for(let h in t.props)t.props[h]===void 0&&h in f&&(p[h]=f[h])}}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,...f}=u;u=f}if(t.props.material!==void 0&&"material"in u){let{material:d,...f}=u;u=f}let p=Ze.removeOverridden(t.path,t.props,u);l={...t,props:p}}}if(this.updateByPatchedOpBase(l,en.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),n),Le(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 f=n.scene.findInstance([this.uuid,...u]);f&&(f.overrideData=t.props[d],f.updateState(Qr.apply(f.component.data,f.overrideData),n))}}else{let d=n.scene.findInstance([this.uuid,...u]);if(d){let f=Ze.zoom(d.component.data,p);if(t={...t,path:p},t.type===0){let h=t.props;if(f)for(let[m,y]of Object.entries(t.props))y===void 0&&(h===t.props&&(h={...t.props}),h[m]=f[m]);t={...t,props:h}}d.overrideData=ua.resolve(o.overrides,u),d.updateByOp(t,nt.applySimple(d.data,t),n,!1)}}}else if(this.instances.length>0){let u;if(t.path.length===0&&t.type===0){let p;for(let d of io.rootOverrideProps)d in t.props&&(p===void 0&&(p={}),p[d]=t.props[d]);p&&(u={...t,props:p})}else for(let p of io.rootOverrideProps)if(Le(t.path,[p])){u=t;break}u!==void 0&&this.instances.forEach(p=>{if(p.isInstanceRoot){let d=Qr.filterOp(p.overrideData,u);d&&p.updateByOp(d,nt.applySimple(p.data,d),n,!0)}}),this.instances.forEach(p=>{if(!p.isInstanceRoot){let d=Qr.filterOp(p.overrideData,t);if(d){let f;s===p.data&&t===d?f=o:f=nt.applySimple(p.data,d),p.updateByOp(d,f,n,!0)}}})}}updateByPatchedOpBase(t,o,n){if(this.dataPatched=o,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Dr.is(t.props.type)&&Br.changeEntityProptotype(this,o,n);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){Br.changeEntityProptotype(this,o,n);for(let a of this.children)De.is(a)&&a.updateVisible(n.scene)}this.updateByPatchedOp(t,o,n)}updateByPatchedOp(t,o,n){if(t.path.length===0&&t.type===0?this.updateState(t.props,n):t.type===0&&("resolutionLevel"in t.props||"useChildrenColors"in t.props)&&this.updateState(o,n),t.path[0]==="morphTargetInfluences"&&t.type===0){let s=o.morphTargetInfluences.get(t.path[1])?.data.name;s&&this.updateMorphInfluences(s,n.shared.getVariable(t.props.value,[this.uuid,"morphTargetInfluences",s]))}if(Le(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Le(t.path,["cloner"])!==null){let a=nt.drop(t,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,n):this.cloner?this.cloner.updateState(o.cloner,n.scene):(this.setFromClonerState(o.cloner,n),this.expandCloner(n.scene)),this.updateVisible(n.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,n=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=cu(c.geometry.path),p=(n+a)%1;n+a===1&&p===0&&(p=1);let d=null;try{d=u.curves.length?u.getPointAt(p):null}catch(y){!1&&(console.warn(`The aligned path on ${this.name} is invalid. (${l.name})`),console.error(y))}if(d===null)return;let f=this.parent?this.parent?.matrixWorld:new uu;l.updateMatrixWorld();let h=new uu().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(h);let m={position:d.toArray(),rotation:c.rotation};if(s==="tangential"){let y=new uu().extractRotation(l.matrixWorld),b=u.getTangentAt(p).applyMatrix4(y).add(d),v=new uu().lookAt(d,b,dI),w=$p.setFromEuler(new lI().setFromRotationMatrix(v)).multiplyScalar($s.RAD2DEG);m={...m,rotation:w.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(cI)})}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(n=>{if(n.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 Br.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 Br.Cloner(this,t),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,o.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}};import{BufferGeometry as hI,ConeGeometry as mI,Float32BufferAttribute as yI,MathUtils as gI}from"three";import{BufferGeometry as fx,CylinderGeometry as pI,Float32BufferAttribute as pu,MathUtils as fI,Vector2 as zr,Vector3 as du}from"three";var hx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=i.parameters?.radiusTop,t=i.parameters?.radiusBottom,o=Object.assign({},r?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters);o.thetaLength=fI.clamp(o.thetaLength,0,360);let n=o.width/2,a=o.radiusTop??n,s=o.radiusBottom??n;if(a===s?(a=n,s=n):a>s?(a=n,s=s*n/a):(a=a*n/s,s=n),o.shapeBlendNode){a=e??n,s=t??n;let l=Math.max(a,s)*2;o.width=l,o.depth=l}return{parameters:Object.assign(o,{width:Math.abs(o.width),height:Math.abs(o.height??o.width),depth:Math.abs(o.depth??o.width),radiusTop:a,radiusBottom:s})}}static build(i){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:n,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:p,cornerSegments:d,hollow:f}=i.parameters,h;return l===0?(h=new fx,h.setAttribute("position",new pu([],3))):p||f?h=new Xs(c,u,t,o,n,a,s,l*Math.PI/180,p,p,d,f):h=new pI(c,u,t,o,n,a,s,l*Math.PI/180),h.scale(1,1,e/r),Object.assign(h,{userData:{...i,type:"CylinderGeometry"}})}};function gi(i,r,e){e.x=i.x*r.x,e.y=i.y,e.z=i.x*r.y}function px(i){return new zr(i.y,-i.x)}var Xs=class extends fx{constructor(r,e,t,o,n,a,s,l,c,u,p,d,f=!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,n=Math.floor(n)||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 h=[],m=[],y=[],b=[],v=0,w=t/2,O=new du,S=new du;f&&r==0&&(r=c),f&&e==0&&(e=u);let T=new zr(r,w),M=new zr(e,-w),g=null,D=null,E=null,I=null,N=T.clone().sub(M),_=0,R=0,V=0;d>0&&(_=Math.min(r,e)*(1-d),R=r-_,V=e-_);let U=T.clone();U.x-=_;let B=Math.PI-N.angle(),q=N.angle(),j=Math.tan(q/2),F=Math.tan(B/2),H=j+F,W=d?H:F,ee=d?H:j;if(c=Math.min(c,(r-R)/W,N.length()/H),u=Math.min(u,(e-V)/ee,N.length()/H),c>0){let Q=c/j;g=T.clone().sub(new zr(Q,c)),d&&(E=g.clone(),E.x-=_-H*c),T.sub(N.clone().setLength(Q))}if(u>0){let Q=u/F;D=M.clone().sub(new zr(Q,-u)),M.add(N.clone().setLength(Q)),d&&(I=D.clone(),I.x-=_-H*u,U.sub(N.clone().setLength(Q)))}N=T.clone().sub(M);let te=N.length()<.5,Y=[];for(let Q=0;Q<=o;Q++){let $=[],ue=Q/o,le=ue*l+s,ie=new zr(Math.sin(le),Math.cos(le));I&&D?(re($,ue,ie,B,u,I,-1,!0),re($,ue,ie,q,u,D,-1,!1)):D?(K($,ie,D.x,0,-1),re($,ue,ie,q,u,D,-1,!1)):a||K($,ie,e,V,-1);let ce=px(N).normalize();if(gi(ce,ie,O),!te)for(let ae=0;ae<=n;ae++){let me=ae/n,pe=N.clone().multiplyScalar(me).add(M);gi(pe,ie,S),m.push(S.x,S.y,S.z),y.push(O.x,O.y,O.z),b.push(ue,.5+S.y/t),$.push(v++)}if(E&&g?(re($,ue,ie,B,c,g,1,!1),re($,ue,ie,q,c,E,1,!0)):g?(re($,ue,ie,B,c,g,1,!1),K($,ie,g.x,0,1)):a||K($,ie,r,R,1),d&&!te){let ae=px(N).multiplyScalar(-1).normalize();gi(ae,ie,O);for(let me=0;me<=n;me++){let pe=me/n,he=N.clone().multiplyScalar(-pe).add(U);gi(he,ie,S),m.push(S.x,S.y,S.z),y.push(O.x,O.y,O.z),b.push(ue,.5+S.y/t),$.push(v++)}}d&&!a&&$.push($[0]),Y.push($)}for(let Q=0;Q<Y.length-1;Q++)for(let $=0;$<Y[0].length-1;$++){if(a&&d&&$==n)continue;let ue=Y[Q][$],le=Y[Q+1][$],ie=Y[Q+1][$+1],ce=Y[Q][$+1],ae=m[ie*3+0],me=m[ie*3+2];h.push(ue,le,ce),(ae!=0||me!=0)&&h.push(le,ie,ce)}l<Math.PI*2&&(Z(-1,Y[0],s),Z(1,Y[Y.length-1],s+l)),this.setIndex(h),this.setAttribute("position",new pu(m,3)),this.setAttribute("normal",new pu(y,3)),this.setAttribute("uv",new pu(b,2));function re(Q,$,ue,le,ie,ce,ae,me){for(let pe=0;pe<p+1;pe++){let he=pe/p,xe=ae<0?he:1-he;me&&(xe-=1),xe*=le;let ye=new zr(Math.sin(xe),Math.cos(xe)*ae),C=ye.clone().multiplyScalar(ie).add(ce);gi(C,ue,S),m.push(S.x,S.y,S.z),gi(ye,ue,O),y.push(O.x,O.y,O.z),b.push($,.5+S.y/t),Q.push(v++)}}function K(Q,$,ue,le,ie){let ce=new du,ae=new zr,me=[ue,le];ie<0&&me.reverse();for(let pe of me)ae.set(pe,w*ie),gi(ae,$,ce),m.push(ce.x,ce.y,ce.z),y.push(0,ie,0),b.push(.5,.5),Q.push(v++)}function Z(Q,$,ue){let le=new zr(Math.sin(ue),Math.cos(ue)),ie=new zr(-Math.cos(ue),Math.sin(ue)),ce=new du,ae=Q<0?(he,xe,ye)=>h.push(he,xe,ye):(he,xe,ye)=>h.push(he,ye,xe),me=new zr((r+e+R+V)/4,0);gi(me,le,ce),m.push(ce.x,ce.y,ce.z),y.push(ie.x,0,ie.y),b.push(.5,.5);let pe=v++;for(let he of $){let xe=m.slice(he*3,he*3+3);m.push(...xe),y.push(ie.x,0,ie.y);let ye=b.slice(he*2,he*2+2);b.push(...ye),v++}for(let he=pe+1;he<v-1;he++)ae(pe,he,he+1);ae(pe,v-1,pe+1)}}};var mx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,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},i.parameters);return e.thetaLength=gI.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(i){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:n,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:u,cornerSegments:p}=i.parameters,d;return l===0?(d=new hI,d.setAttribute("position",new yI([],3))):c>0||u>0||l<360?d=new Xs(0,r/2,t,o,n,a,s,l*Math.PI/180,c,u,p,0,!0):d=new mI(r/2,t,o,n,a),d.scale(1,1,e/r),Object.assign(d,{userData:{...i,type:"ConeGeometry"}})}};import{BoxGeometry as xI,BufferGeometry as bI,Float32BufferAttribute as Xp,Vector3 as Ys}from"three";var yx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},i.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(i){let{width:r,height:e,depth:t,widthSegments:o,heightSegments:n,depthSegments:a,cornerRadius:s,cornerSegments:l}=i.parameters,c;return s===0?c=new xI(r,e,t,o,n,a):c=new Kp(r,e,t,o,n,a,s,l),Object.assign(c,{userData:{...i,type:"CubeGeometry"}})}},Yp=Math.PI/2,Kp=class extends bI{constructor(r=1,e=1,t=1,o=1,n=1,a=1,s=0,l=4){super(),this.type="BoxGeometry",o=Math.floor(o),n=Math.floor(n),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,r/2,e/2,t/2);let c=[],u=[],p=[],d=[],f=0;h("z","y","x",-1,-1,t,e,r,a,n),h("z","y","x",1,-1,t,e,-r,a,n),h("x","z","y",1,1,r,t,e,o,a),h("x","z","y",1,-1,r,t,-e,o,a),h("x","y","z",1,-1,r,e,t,o,n),h("x","y","z",-1,-1,r,e,-t,o,n),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,n),m("y","x","z",1,-1,-1,e,r,t,n),m("y","x","z",1,1,1,e,r,t,n),m("y","x","z",-1,1,-1,e,r,t,n),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 Xp(u,3)),this.setAttribute("normal",new Xp(p,3)),this.setAttribute("uv",new Xp(d,2));function h(b,v,w,O,S,T,M,g,D,E){let I=(T-2*s)/D,N=(M-2*s)/E,_=T/2-s,R=M/2-s,V=g/2,U=D+1,B=E+1,q=0,j=new Ys;for(let F=0;F<B;F++){let H=F*N-R;for(let W=0;W<U;W++){let ee=W*I-_;j[b]=ee*O,j[v]=H*S,j[w]=V,u.push(j.x,j.y,j.z),j[b]=0,j[v]=0,j[w]=g>0?1:-1,p.push(j.x,j.y,j.z),d.push(W/D),d.push(1-F/E),q+=1}}for(let F=0;F<E;F++)for(let H=0;H<D;H++){let W=f+H+U*F,ee=f+H+U*(F+1),te=f+(H+1)+U*(F+1),Y=f+(H+1)+U*F;c.push(W,ee,Y),c.push(ee,te,Y)}f+=q}function m(b,v,w,O,S,T,M,g,D,E){let I=(M-2*s)/E,N=M/2-s,_=g/2-s,R=D/2,V=E+1,U=0,B=new Ys,q=new Ys;for(let j=0;j<l+1;j++){let F=j/l*Yp,H=Math.sin(F)*s,W=(1-Math.cos(F))*s,ee=Math.sin(F),te=Math.cos(F);B[v]=(_+H)*S,B[w]=(R-W)*T,q[b]=0,q[v]=ee*Math.sign(B[v]),q[w]=te*Math.sign(B[w]);for(let Y=0;Y<V;Y++){let re=Y*I-N;B[b]=re*O,u.push(B.x,B.y,B.z),p.push(q.x,q.y,q.z),d.push(Y/E),d.push(0),U+=1}}for(let j=0;j<l;j++)for(let F=0;F<E;F++){let H=f+F+V*j,W=f+F+V*(j+1),ee=f+(F+1)+V*(j+1),te=f+(F+1)+V*j;c.push(H,W,te),c.push(W,ee,te)}f+=U}function y(b,v,w){let O=new Ys,S=new Ys(r/2,e/2,t/2);S.subScalar(s);let T=[],M=b*v*w>0?(D,E,I)=>c.push(D,E,I):(D,E,I)=>c.push(D,I,E);for(let D=0;D<=l;D++){let E=[],I=Yp*(1-D/l),N=Math.cos(I),_=Math.sin(I),R=0;for(let V=0;V<=D;V++){let U=Math.cos(R),B=Math.sin(R);O.x=N*U,O.y=_,O.z=N*B;let q=S.clone().addScaledVector(O,s);u.push(b*q.x,v*q.y,w*q.z),p.push(b*O.x,v*O.y,w*O.z),d.push(0,0),E.push(f++),R+=Yp/D}T.push(E)}let g=T.length-1;for(let D=0;D<g;D++){let E=T[D],I=T[D+1],N=E.length-1;M(E[0],I[1],I[0]);for(let _=1;_<=N;_++)M(E[_-1],E[_],I[_]),M(E[_],I[_+1],I[_])}}}};import{BufferGeometry as vI,Float32BufferAttribute as Qp,Triangle as SI,Vector3 as zo,Vector2 as Zp}from"three";var xi=class extends vI{constructor(r=[],e=[],t="",o=1,n=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],c=[];u(),p(),this.setAttribute("position",new Qp(s,3)),this.setAttribute("normal",new Qp(c,3)),this.setAttribute("uv",new Qp(l,2));return;function u(){n=Math.min(1-1e-5,n),n==0&&(a=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[t],h=new zo,m=h.clone(),y=new SI,b=n*o,v=o-b,w=a+1,O=new zo,S=(j,F)=>O.subVectors(j,F).normalize(),T=(j,F)=>Array(j).fill(void 0).map(F),M=T(r.length/3,(j,F)=>new zo().fromArray(r,F*3).setLength(o)),g=[],D=1e6;for(let j=0;j<M.length;j++){let F=M[j],H=[],W,ee,te,Y=1e10,re=-1;for(;(re=e.indexOf(j,re+1))!=-1;){let $=re-re%3;W=e[$+(re+1)%3],ee=e[$+(re+2)%3],te=F.distanceToSquared(M[W]),Y=Math.min(Y,te),H.push([W,ee,te])}Y+=1e-6;let K=[],Z=0,Q=H.length;for(let $=0;$<Q;$++){[W,ee,te]=H[Z];let ue=g[W]?.includes(j)==!0;te<=Y&&K.push(W+ +ue*D),Z=H.findIndex(le=>le[0]==ee)}g.push(K)}let E=[];{let j=0,F=0,H,W,ee=f==3;for(let te=0;te<=a;te++){H=te*(te+1)/2,W=(te+1)*(te+2)/2;for(let Y=0;Y<a-te;Y++)[j,F]=[H+Y+te+2,W+Y+te+3],E.push(H,W,...ee?[F,H]:[j,W],F,j),[H,W]=[j,F];E.push(H,W,H+a+2)}}let I=h.clone(),N=h.clone(),_=h.clone(),R=h.clone(),V=h.clone(),U=[],B=T(M.length,()=>T(f,()=>h.clone()));for(let j=0;j<M.length;j++){h.copy(M[j]).normalize(),I.copy(h).multiplyScalar(v);let F=g[j];for(let K=0;K<F.length;K++){let Z=F[K],Q=F[(K+1)%f];y.setFromPointsAndIndices(M,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,B[j][K])}let H=[],W=[],ee=[],te=new zo;a==0&&[...B[j]].reduce((K,Z)=>K.add(Z),te).multiplyScalar(1/f);for(let K=0;K<f;K++){let Z=[],Q=(K-1+f)%f,$=B[j][Q],ue=B[j][K];h.copy($).sub(I),m.copy(ue).sub(I);let le=I.angleTo(h),ie=h.angleTo(m),ce=Math.cos(le)*b;a==0?N.copy(te):N.copy(I).setLength(v+ce),W.push(ce);let ae=[N,$,ue];for(let me=0;me<2;me++){let pe=ae[me],he=ae[me+1];R.subVectors(pe,I),V.subVectors(he,I),_.crossVectors(R,V).normalize();for(let xe=0;xe<w;xe++){let ye=[le,ie][me]*xe/w;h.copy(R).applyAxisAngle(_,ye).add(I),H.push(h.clone()),me&&(S(h,I),Z.push([xe==0?pe:h.clone(),O.clone()]))}me&&(S(he,I),Z.push([he,O.clone()]))}ee.push(Z)}U.push(ee);let Y=2*w,re=2;for(let K=0;K<f;K++){let Z=Y*K,Q=Y*((K+1)%f),$=[H[Z]];for(let le=1;le<w;le++){R=H[Z+le],V=H[Q+le],$.push(R);for(let ie=1,ce=le-re+1;ie<=ce;ie++)h.lerpVectors(R,V,ie/(ce+1)),h.sub(I).setLength(W[K]).add(I),$.push(h.clone());$.push(V)}for(let le=0;le<w;le++)$.push(H[le+w+Z]);$.push(H[Q+w]);let ue=E.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 q=[];for(let j=0;j<g.length;j++)for(let F=0;F<f;F++){let H=g[j][F];if(H<D){let W=g[H].findIndex(Y=>Y%D==j),ee=U[j][F],te=U[H][W];for(let Y=0;Y<w;Y++){let re=ee[Y],K=te[w-Y],Z=ee[Y+1],Q=te[w-(Y+1)];[re,K,Z,Z,K,Q].forEach($=>{s.push($[0].x,$[0].y,$[0].z),c.push($[1].x,$[1].y,$[1].z)})}q.push(ee[0][0],te[w][0],ee[w][0],te[0][0])}}for(;q.length;){let j,F,H,W;[j,F]=q.splice(0,2);let ee=[j];for(;j!=F;)ee.push(F),H=q.indexOf(F),W=H%2,F=q.splice(H-W,2)[1-W];O.subVectors(ee[0],ee[1]).cross(h.subVectors(ee[0],ee[2])).normalize();let te=O.dot(ee[0])<0;te&&O.negate();for(let Y=1;Y<=ee.length-2;Y++)[ee[Y+ +te],ee[Y+1-+te],ee[0]].forEach(re=>{s.push(re.x,re.y,re.z),c.push(O.x,O.y,O.z)})}}function p(){let d=new zo;for(let M=0;M<s.length;M+=3){d.x=s[M+0],d.y=s[M+1],d.z=s[M+2];let g=S(d)/2/Math.PI+.5,D=T(d)/Math.PI+.5;l.push(g,1-D)}let f=new zo,h=new zo,m=new zo,y=new zo,b=new Zp,v=new Zp,w=new Zp,O=(M,g,D,E)=>{E<0&&M.x===1&&(l[g]=M.x-1),D.x===0&&D.z===0&&(l[g]=E/2/Math.PI+.5)};for(let M=0,g=0;M<s.length;M+=9,g+=6){f.set(s[M+0],s[M+1],s[M+2]),h.set(s[M+3],s[M+4],s[M+5]),m.set(s[M+6],s[M+7],s[M+8]),b.set(l[g+0],l[g+1]),v.set(l[g+2],l[g+3]),w.set(l[g+4],l[g+5]),y.copy(f).add(h).add(m).divideScalar(3);let D=S(y);O(b,g+0,f,D),O(v,g+2,h,D),O(w,g+4,m,D)}for(let M=0;M<l.length;M+=6){let g=l[M+0],D=l[M+2],E=l[M+4],I=Math.max(g,D,E),N=Math.min(g,D,E);I>.9&&N<.1&&(g<.2&&(l[M+0]+=1),D<.2&&(l[M+2]+=1),E<.2&&(l[M+4]+=1))}function S(M){return Math.atan2(M.z,-M.x)}function T(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(r){return new xi(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};import{DodecahedronGeometry as wI}from"three";var gx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.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(i){let{width:r,height:e,depth:t,detail:o,corner:n,cornerSides:a}=i.parameters,s=o===0&&n!==0?new Ks(r*.5,n,a):new wI(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...i,type:"DodecahedronGeometry"}})}},Ks=class extends xi{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,n=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,-n,-o,0,-n,o,0,n,-o,0,n,o,-n,-o,0,-n,o,0,n,-o,0,n,o,0,-o,0,-n,o,0,-n,-o,0,n,o,0,n],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 Ks(r.radius,r.corner,r.cornerSides)}};import{Plane as _I,Shape as Dx,Vector2 as Go,Vector3 as RI,MathUtils as af,LineCurve as sf,QuadraticBezierCurve as _x,CubicBezierCurve as yu}from"three";import{CubicBezierCurve as fu,EllipseCurve as PI,LineCurve as hu,LineCurve3 as OI,MathUtils as TI,QuadraticBezierCurve as ef,SplineCurve as CI,Vector2 as Wt,Vector3 as vx}from"three";var Qs=1e-12,Sa=class{constructor(r){this.position=new Wt;this.startPosition=new Wt;this.uuid=TI.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 Sa(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},wa=class extends Sa{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new wa(this.parent).copy(this)}},Gr=class extends Sa{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new wa(this),new wa(this))}static create(e,t){let o=new Gr(e,new Wt(...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,n=this.controls.length;o<n;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 Gr(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 Wt,t=new Wt){let[o,n]=this.computeTangents();return o&&n&&(xx(o,e),xx(n,t)),[e,t]}computeTangent(e=new Wt){let[t,o]=this.computeTangents();return t&&o&&e.copy(t).add(o).normalize(),e}computeNormal(e=new Wt){let[t,o]=this.computeNormals();return e.copy(t).add(o).normalize(),e}};function xx(i,r=new Wt){let e=i.length();return r.set(-i.y/e,i.x/e)}var tf=i=>i,Pa=new Wt,mu=new Wt,AI=new Wt,MI=new Wt,II=new Wt,EI=new Wt,Sx=new vx,wx=new vx;function Px(i){let r=new Wt;r.addVectors(i.v0,Pa.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new Wt;return e.addVectors(i.v2,mu.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new fu(i.v0,r,e,i.v2)}function Zs(i,r,e=Number.EPSILON){return Math.abs(i-r)<e}function NI(i,r,e=Number.EPSILON){return i.distanceTo(r)<e}function DI(i,r,e=Number.EPSILON){return i.distanceTo(r)<e}function rf(i,r,e){let t=Math.sqrt(Math.pow(r.x-i.x,2)+Math.pow(r.y-i.y,2)),o=Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2)),n=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((o*o+t*t-n*n)/(2*o*t))}function Ox(i,r,e){return bx(i,r)&&bx(r,e)&&Jp(i.position,r.position,e.position)}function Jp(i,r,e){return Pa.copy(r).sub(i).cross(mu.copy(e).sub(i))===0}function Tx(i,r,e,t,o){let n=Math.sqrt(Math.pow(r.x-i.x,2)+Math.pow(r.y-i.y,2)),a=(i.y+r.y)/2,s=(i.x+r.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(n/2,2))*(i.y-r.y)/n,c=Math.sqrt(Math.pow(e,2)-Math.pow(n/2,2))*(r.x-i.x)/n;return t.set(s+l,a+c),o.set(s-l,a-c),[t,o]}function Cx(i,r,e){let t=i.distanceTo(e),o=r.distanceTo(e);return t<o?r:i}function Ax(i,r,e,t,o,n){let a=r.x-i.x,s=r.y-i.y,l=e.x-i.x,c=e.y-i.y,u=Math.sqrt((a+l)*(a+l)+(s+c)*(s+c)),p;return rf(r,i,e)>Math.PI&&(u*=-1),Zs(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),n.set(e.x+p*c,e.y-p*l),[o,n]}function of(i,r){return i.position.equals(i.controls[1].position)&&r.position.equals(r.controls[0].position)}function bx(i,r){return Jp(i.position,i.controls[1].position,r.position)&&Jp(i.position,r.controls[0].position,r.position)}function Mx(i,r,e,t,o=.5){let n=Pa.subVectors(r,i).multiplyScalar(o).add(i),a=mu.subVectors(e,r).multiplyScalar(o).add(r),s=AI.subVectors(t,e).multiplyScalar(o).add(e),l=n,c=MI.subVectors(a,n).multiplyScalar(o).add(n),u=II.subVectors(s,a).multiplyScalar(o).add(a),p=s,d=EI.subVectors(u,c).multiplyScalar(o).add(c);return[i.x,i.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 Ix(i,r,e=12,t=!0){let o=wx.set(0,0,0),n,a=0,s=[];for(let l=0;l<r.length;l++){let c=tf(r[l]),u=Pa,p=bi(c,e);s.push(p);for(let d=0;d<=p;d++)if(c instanceof fu||c instanceof ef||c instanceof hu){if(c.getPoint(d/p,u),o.set(u.x,u.y,0),n!==void 0&&DI(n,o))continue;n===void 0&&(n=Sx),n.copy(o),i.setXYZ(a,o.x,o.y,o.z),a++}}return t&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),i}function Ex(i,r,e,t=12,o=!0){let n=wx.set(0,0,0),a=0,s=[];for(let l=0;l<r.length;l++){if(e[l]===!1)continue;let c,u=tf(r[l]),p=Pa,d=bi(u,t);s.push(d);for(let f=0;f<=d;f++)if(u instanceof fu||u instanceof ef||u instanceof hu){if(u.getPoint(f/d,p),n.set(p.x,p.y,0),c?.equals(n))continue;c===void 0?c=Sx:(i.setXYZ(a,c.x,c.y,c.z),a++,i.setXYZ(a,n.x,n.y,n.z),a++),c.copy(n)}}return o&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),s}function nf(i,r=12,e=!1){let t=[];for(let o=0,n=i.length;o<n;o++){let a=i[o],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=bi(a.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=bi(a.curveAfter,r)),t.push(s)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(t[i.length-1]+=bi(i[0].roundedCurveCorner,r)*.5),t}function bi(i,r=12){return i&&i instanceof PI?r*2:i&&(i instanceof hu||i instanceof OI)?1:i&&i instanceof CI?r*i.points.length:r}function Nx(i,r,e=12,t=!0){let o,n=0;for(let a=0;a<r.length;a++){let s=tf(r[a]),l=bi(s,e),c=Pa;for(let u=0;u<=l;u++)if(s instanceof fu||s instanceof ef||s instanceof hu){if(s.getPoint(u/l,c),o!==void 0&&NI(o,c,Qs))continue;o===void 0&&(o=mu),o.copy(c),i.push(c.x,c.y),n++}}return Zs(i[0],i[i.length-2],Qs)&&Zs(i[1],i[i.length-1],Qs)&&(i.pop(),i.pop()),t&&n>1&&!(Zs(i[n-1],i[1],Qs)&&Zs(i[n-2],i[0],Qs))&&(i.push(i[0],i[1]),n++),i}var lf=new Go,LI=new Go,BI=new Go,VI=new Go,zI=new Go,GI=new Go,je=class extends Dx{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new _I(new RI(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=af.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,o){let n=new je;return n.isClosed=e.isClosed,n.points=e.points.map(a=>Gr.create(a.id,a.data)),typeof e.roundness=="number"&&(n.roundness=e.roundness),n.shapeHoles=e.shapeHoles.map(a=>je.createFromState(a)),t!==void 0&&o!==void 0&&n.applySize(t,o),n.update(),n}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,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(n=>n.uuid===e);if(o<0){let n=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)n+=c;else return u+n}}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,n=this.shapeHoles.length;o<n;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,n=this.shapeHoles.length;o<n;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=lf.set(e,t);for(let n=0,a=this.points.length;n<a;n++){let s=this.points[n];s.position.multiply(o),s.controls[0].position.multiply(o),s.controls[1].position.multiply(o)}for(let n=0,a=this.shapeHoles.length;n<a;n++)this.shapeHoles[n].applyScale(e,t);this._update()}createPoint(e,t=0,o=af.generateUUID()){let n;e instanceof Go?n=e:n=new Go(e,t);let a=new Gr(o,n);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 n=this.points[t];if(n.uuid===e)return n}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 n=o?this.roundedCurveDivisions:this.curveDivisions;return Ix(e,o?this.roundedCurves:this.curves,t,this.autoClose),n.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=nf(this.points,e,!1),this.roundedCurveDivisions=nf(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,o=12){return Ex(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),Nx(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let n=t?this.roundedCurveDivisions:this.curveDivisions,a=0;t&&this.points[0].roundedCurveCorner!==void 0&&(a=bi(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=n.reduce((l,c)=>l+c,0));for(let l=0,c=n.length;l<c;l++){let u=n[l];if(s<o+u)return[l,(s-o+1)/u];o+=u}return[0,1]}getCurveT(e,t,o){let n=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(of(n,a)){let p=n.position.distanceTo(a.position);return n.position.distanceTo(lf.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){of(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 n=o.clone();e.roundedCurveBefore=n,t.roundedCurveAfter=n,e.roundedCurveCorner=void 0,this.roundedCurves.push(n)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,o=this.points.length;t<o;t++){let n=this.points[t];if(t===0)this.moveTo(n.position.x,n.position.y);else{let a=this.points[t-1];this._applyCurveForPoint(n,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,n=this.points.length;o<n;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&&Ox(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 f=a.roundedCurveBefore,h=a.roundedCurveAfter,m=p.getLength(),y=d.getLength(),b=Math.min(c,m*.499),v=Math.min(c,y*.499),w=Math.min(b,v),O=1-w/m,S=w/y,T=p.getPointAt(O,lf),M=d.getPointAt(S,LI);this._subSplitCurve(p,f,O,T,void 0),this._subSplitCurve(d,h,S,void 0,M);let g;if(this.useCubicForRoundedCorners){let D=rf(T,a.position,M)/2,E=Math.tan(D)*T.distanceTo(a.position),[I,N]=Tx(T,M,E,BI,VI),_=Cx(I,N,a.position),[R,V]=Ax(_,T,M,E,zI,GI);g=new yu(T.clone(),R.clone(),V.clone(),M.clone())}else g=new _x(T.clone(),a.position.clone(),M.clone());a.roundedCurveCorner=g,this.roundedCurves.splice(o+t,0,g),t++}}}}_subSplitCurve(e,t,o,n,a){if(e instanceof sf)n!==void 0&&t.v2.copy(n),a!==void 0&&t.v1.copy(a);else{let s=e,l=t,c=s.getUtoTmapping(o,0),u=Mx(s.v0,s.v1,s.v2,s.v3,c);return n!==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 je(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 n=o*7,a=e.points[n+0],s=e.points[n+1],l=e.points[n+2],c=e.points[n+3],u=e.points[n+4],p=e.points[n+5],d=e.points[n+6],f=new Gr(af.generateUUID(),new Go(a,s));f.controls[0].position.set(l,c),f.controls[1].position.set(u,p),f.roundness=d,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let n=new je;return n.fromJSON(o),n}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let o=(a,s)=>{s instanceof yu&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},n=a=>{let s=[],l,c;for(l=0,c=a.length;l<c;l++)a[l]instanceof _x&&(a[l]=Px(a[l]));for(l=0,c=a.length;l<c;l++){let d=a[l],f=l>0?a[l-1]:null,h;d instanceof yu?(h=this.createPoint(d.v0),h.controls[1].position.copy(d.v1)):d instanceof sf&&(h=this.createPoint(d.v1)),h!==void 0&&(f!==null&&o(h,f),s.push(h))}let u=a[a.length-1],p=!1;return u instanceof yu?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),p=!0):u instanceof sf&&u.v2.equals(s[0].position)&&(p=!0),this.isClosed=p,s};return this.points=n(e.curves),e instanceof Dx&&(this.shapeHoles=e.holes.map(a=>{let s=new je;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 n=this.getPointByUuid(e)?.controls[0];n&&(t.position&&n.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let n=this.getPointByUuid(e)?.controls[1];n&&(t.position&&n.position.fromArray(t.position),this.needsUpdate=!0)}};var uf=Math.PI*2;function cf({x:i,y:r},e,t,o,n){return{x:i*e+o,y:r*t+n}}function FI(i,r){let e=r===1.5707963267948966?.551915024494:r===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(r/4),t=Math.cos(i),o=Math.sin(i),n=Math.cos(i+r),a=Math.sin(i+r);return[{x:t-o*e,y:o+t*e},{x:n+a*e,y:a-n*e},{x:n,y:a}]}function Rx(i,r,e,t){let o=i*t-r*e<0?-1:1,n=Math.min(1,Math.max(-1,i*e+r*t));return o*Math.acos(n)}function jI(i,r,e,t,o,n,a,s,l,c){let u=Math.pow(o,2),p=Math.pow(n,2),d=Math.pow(a,2),f=Math.pow(s,2),h=u*p-u*f-p*d;h<0&&(h=0),h/=u*f+p*d,h=Math.sqrt(h)*(l===c?-1:1);let m=h*o/n*s,y=h*-n/o*a,b=m+(i+e)/2,v=y+(r+t)/2,w=(a-m)/o,O=(s-y)/n,S=(-a-m)/o,T=(-s-y)/n,M=Rx(1,0,w,O),g=Rx(w,O,S,T);return!c&&g>0&&(g-=uf),c&&g<0&&(g+=uf),{centerx:b,centery:v,ang1:M,ang2:g}}function Lx({px:i,py:r,cx:e,cy:t,rx:o,ry:n,largeArcFlag:a,sweepFlag:s}){let l=[];if(o===0||n===0)return[];let c=(i-e)/2,u=(r-t)/2;if(c===0&&u===0)return[];o=Math.abs(o),n=Math.abs(n);let p=Math.pow(c,2)/Math.pow(o,2)+Math.pow(u,2)/Math.pow(n,2);p>1&&(o*=Math.sqrt(p),n*=Math.sqrt(p));let d=jI(i,r,e,t,o,n,c,u,a,s),{ang1:f,ang2:h}=d,{centerx:m,centery:y}=d,b=Math.abs(h)/(uf/4);Math.abs(1-b)<1e-7&&(b=1);let v=Math.max(Math.ceil(b),1);h/=v;for(let w=0;w<v;w++)l.push(FI(f,h)),f+=h;return l.map(w=>{let{x:O,y:S}=cf(w[0],o,n,m,y),{x:T,y:M}=cf(w[1],o,n,m,y),{x:g,y:D}=cf(w[2],o,n,m,y);return{x1:O,y1:S,x2:T,y2:M,x:g,y:D}})}import{BufferAttribute as Su,BufferGeometry as ZI}from"three";var Fe;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Fe||(Fe={}));var st;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(st||(st={}));function we(i,r){if(!i)throw r||"Assertion Failed!"}var ve=function(){function i(){}return i.vertEq=function(r,e){return r.s===e.s&&r.t===e.t},i.vertLeq=function(r,e){return r.s<e.s||r.s===e.s&&r.t<=e.t},i.transLeq=function(r,e){return r.t<e.t||r.t===e.t&&r.s<=e.s},i.edgeGoesLeft=function(r){return i.vertLeq(r.Dst,r.Org)},i.edgeGoesRight=function(r){return i.vertLeq(r.Org,r.Dst)},i.vertL1dist=function(r,e){return Math.abs(r.s-e.s)+Math.abs(r.t-e.t)},i.edgeEval=function(r,e,t){we(i.vertLeq(r,e)&&i.vertLeq(e,t));var o=e.s-r.s,n=t.s-e.s;return o+n>0?o<n?e.t-r.t+(r.t-t.t)*(o/(o+n)):e.t-t.t+(t.t-r.t)*(n/(o+n)):0},i.edgeSign=function(r,e,t){we(i.vertLeq(r,e)&&i.vertLeq(e,t));var o=e.s-r.s,n=t.s-e.s;return o+n>0?(e.t-t.t)*o+(e.t-r.t)*n:0},i.transEval=function(r,e,t){we(i.transLeq(r,e)&&i.transLeq(e,t));var o=e.t-r.t,n=t.t-e.t;return o+n>0?o<n?e.s-r.s+(r.s-t.s)*(o/(o+n)):e.s-t.s+(t.s-r.s)*(n/(o+n)):0},i.transSign=function(r,e,t){we(i.transLeq(r,e)&&i.transLeq(e,t));var o=e.t-r.t,n=t.t-e.t;return o+n>0?(e.s-t.s)*o+(e.s-r.s)*n:0},i.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},i.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))},i.intersect=function(r,e,t,o,n){var a,s,l;i.vertLeq(r,e)||(l=r,r=e,e=l),i.vertLeq(t,o)||(l=t,t=o,o=l),i.vertLeq(r,t)||(l=r,r=t,t=l,l=e,e=o,o=l),i.vertLeq(t,e)?i.vertLeq(e,o)?(a=i.edgeEval(r,t,e),s=i.edgeEval(t,e,o),a+s<0&&(a=-a,s=-s),n.s=i.interpolate(a,t.s,s,e.s)):(a=i.edgeSign(r,t,e),s=-i.edgeSign(r,o,e),a+s<0&&(a=-a,s=-s),n.s=i.interpolate(a,t.s,s,o.s)):n.s=(t.s+e.s)/2,i.transLeq(r,e)||(l=r,r=e,e=l),i.transLeq(t,o)||(l=t,t=o,o=l),i.transLeq(r,t)||(l=r,r=t,t=l,l=e,e=o,o=l),i.transLeq(t,e)?i.transLeq(e,o)?(a=i.transEval(r,t,e),s=i.transEval(t,e,o),a+s<0&&(a=-a,s=-s),n.t=i.interpolate(a,t.t,s,e.t)):(a=i.transSign(r,t,e),s=-i.transSign(r,o,e),a+s<0&&(a=-a,s=-s),n.t=i.interpolate(a,t.t,s,o.t)):n.t=(t.t+e.t)/2},i}(),Js=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),gu=function(){function i(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(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(r){this.Sym.Lface=r},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(r){this.Sym.Org=r},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(r){this.Sym.Lnext=r},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(r){this.Onext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(r){this.Lnext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(r){this.Sym.Onext=r},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(r){this.Sym.Onext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(r){this.Sym.Lnext.Sym=r},enumerable:!0,configurable:!0}),i}(),Oa=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return i}(),Bx=function(){function i(){var r=new Oa,e=new Js,t=new gu(0),o=new gu(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 i.prototype.makeEdge_=function(r){var e=new gu(0),t=new gu(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},i.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},i.prototype.makeVertex_=function(r,e,t){var o=r;we(o,"Vertex can't be null!");var n=t.prev;o.prev=n,n.next=o,o.next=t,t.prev=o,o.anEdge=e;var a=e;do a.Org=o,a=a.Onext;while(a!==e)},i.prototype.makeFace_=function(r,e,t){var o=r;we(o,"Face can't be null");var n=t.prev;o.prev=n,n.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)},i.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},i.prototype.killVertex_=function(r,e){var t=r.anEdge,o=t;do o.Org=e,o=o.Onext;while(o!==t);var n=r.prev,a=r.next;a.prev=n,n.next=a},i.prototype.killFace_=function(r,e){var t=r.anEdge,o=t;do o.Lface=e,o=o.Lnext;while(o!==t);var n=r.prev,a=r.next;a.prev=n,n.next=a},i.prototype.makeEdge=function(){var r=new Oa,e=new Oa,t=new Js,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},i.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 n=new Oa;this.makeVertex_(n,e,r.Org),r.Org.anEdge=r}if(!t){var a=new Js;this.makeFace_(a,e,r.Lface),r.Lface.anEdge=r}}},i.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 Js;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)},i.prototype.addEdgeVertex=function(r){var e=this.makeEdge_(r),t=e.Sym;this.splice_(e,r.Lnext),e.Org=r.Dst;var o=new Oa;return this.makeVertex_(o,t,e.Org),e.Lface=t.Lface=r.Lface,e},i.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},i.prototype.connect=function(r,e){var t=!1,o=this.makeEdge_(r),n=o.Sym;if(e.Lface!==r.Lface&&(t=!0,this.killFace_(e.Lface,r.Lface)),this.splice_(o,r.Lnext),this.splice_(n,e),o.Org=r.Dst,n.Org=e.Org,o.Lface=n.Lface=r.Lface,r.Lface.anEdge=n,!t){var a=new Js;this.makeFace_(a,o,r.Lface)}return o},i.prototype.zapFace=function(r){var e=r.anEdge,t,o,n,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)),n=t.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(t));while(t!=e);a=r.prev,s=r.next,s.prev=a,a.next=s},i.prototype.countFaceVerts_=function(r){var e=r.anEdge,t=0;do t++,e=e.Lnext;while(e!==r.anEdge);return t},i.prototype.mergeConvexFaces=function(r){var e,t,o,n,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,n=t.Sym,n&&n.Lface&&n.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(n.Lface),s+l-2<=r&&ve.vertCCW(t.Lprev.Org,t.Org,n.Lnext.Lnext.Org)&&ve.vertCCW(n.Lprev.Org,n.Org,t.Lnext.Lnext.Org)&&(o=n.Lnext,this.delete(n),t=null,n=null)),!(t&&t.Lnext.Org===a);)t=o;return!0},i.prototype.check=function(){var r=this.fHead,e=this.vHead,t=this.eHead,o,n,a,s,l,c;for(n=r,n=r;(o=n.next)!==r;n=o){we(o.prev===n),l=o.anEdge;do we(l.Sym!==l),we(l.Sym.Sym===l),we(l.Lnext.Onext.Sym===l),we(l.Onext.Sym.Lnext===l),we(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(we(o.prev===n&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){we(a.prev===s),l=a.anEdge;do we(l.Sym!==l),we(l.Sym.Sym===l),we(l.Lnext.Onext.Sym===l),we(l.Onext.Sym.Lnext===l),we(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(we(a.prev===s&&a.anEdge===null),c=t,c=t;(l=c.next)!==t;c=l)we(l.Sym.next===c.Sym),we(l.Sym!==l),we(l.Sym.Sym===l),we(l.Org!==null),we(l.Dst!==null),we(l.Lnext.Onext.Sym===l),we(l.Onext.Sym.Lnext===l);we(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),Vx=function(){function i(){this.handle=null}return i}(),zx=function(){function i(){this.key=null,this.node=0}return i}(),UI=function(){function i(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 Vx,this.handles[t]=new zx;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(r){var e=this.nodes,t=this.handles,o,n,a;for(o=e[r].handle;;){if(a=r<<1,a<this.size&&this.leq(t[e[a+1].handle].key,t[e[a].handle].key)&&++a,we(a<=this.max),n=e[a].handle,a>this.size||this.leq(t[o].key,t[n].key)){e[r].handle=o,t[o].node=r;break}e[r].handle=n,t[n].node=r,r=a}},i.prototype.floatUp_=function(r){var e=this.nodes,t=this.handles,o,n,a;for(o=e[r].handle;;){if(a=r>>1,n=e[a].handle,a===0||this.leq(t[n].key,t[o].key)){e[r].handle=o,t[o].node=r;break}e[r].handle=n,t[n].node=r,r=a}},i.prototype.init=function(){for(var r=this.size;r>=1;--r)this.floatDown_(r);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(r){var e,t;if(e=++this.size,e*2>this.max){this.max*=2;var o,n;for(n=this.nodes.length,this.nodes.length=this.max+1,o=n;o<this.nodes.length;o++)this.nodes[o]=new Vx;for(n=this.handles.length,this.handles.length=this.max+1,o=n;o<this.handles.length;o++)this.handles[o]=new zx}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},i.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},i.prototype.delete=function(r){var e=this.nodes,t=this.handles,o;we(r>=1&&r<=this.max&&t[r].key!==null),o=t[r].node,e[o].handle=e[this.size].handle,t[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(t[e[o>>1].handle].key,t[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),t[r].key=null,t[r].node=this.freeList,this.freeList=r},i}(),df=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),Gx=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),kI=function(){function i(r,e){this.frame=r,this.leq=e,this.head=new Gx,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(r){return this.insertBefore(this.head,r)},i.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},i.prototype.insertBefore=function(r,e){do r=r.prev;while(r.key!==null&&!this.leq(this.frame,r.key,e));var t=new Gx;return t.key=e,t.next=r.next,r.next.prev=t,t.prev=r,r.next=t,t},i.prototype.delete=function(r){r.next.prev=r.prev,r.prev.next=r.next},i}(),HI=function(){function i(){}return i.regionBelow=function(r){return r.nodeUp.prev.key},i.regionAbove=function(r){return r.nodeUp.next.key},i.debugEvent=function(r){},i.addWinding=function(r,e){r.winding+=e.winding,r.Sym.winding+=e.Sym.winding},i.edgeLeq=function(r,e,t){var o=r.event,n=e.eUp,a=t.eUp;if(n.Dst===o)return a.Dst===o?ve.vertLeq(n.Org,a.Org)?ve.edgeSign(a.Dst,n.Org,a.Org)<=0:ve.edgeSign(n.Dst,a.Org,n.Org)>=0:ve.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return ve.edgeSign(n.Dst,o,n.Org)>=0;var s=ve.edgeEval(n.Dst,o,n.Org),l=ve.edgeEval(a.Dst,o,a.Org);return s>=l},i.deleteRegion=function(r,e){e.fixUpperEdge&&we(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},i.fixUpperEdge=function(r,e,t){we(e.fixUpperEdge),r.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=t,t.activeRegion=e},i.topLeftRegion=function(r,e){var t=e.eUp.Org,o;do e=i.regionAbove(e);while(e.eUp.Org===t);if(e.fixUpperEdge){if(o=r.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;i.fixUpperEdge(r,e,o),e=i.regionAbove(e)}return e},i.topRightRegion=function(r){var e=r.eUp.Dst;do r=i.regionAbove(r);while(r.eUp.Dst===e);return r},i.addRegionBelow=function(r,e,t){var o=new df;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},i.isWindingInside=function(r,e){switch(r.windingRule){case Fe.ODD:return(e&1)!==0;case Fe.NONZERO:return e!==0;case Fe.POSITIVE:return e>0;case Fe.NEGATIVE:return e<0;case Fe.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(r,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(r,e.windingNumber)},i.finishRegion=function(r,e){var t=e.eUp,o=t.Lface;o.inside=e.inside,o.anEdge=t,i.deleteRegion(r,e)},i.finishLeftRegions=function(r,e,t){for(var o,n=null,a=e,s=e.eUp;a!==t;){if(a.fixUpperEdge=!1,n=i.regionBelow(a),o=n.eUp,o.Org!=s.Org){if(!n.fixUpperEdge){i.finishRegion(r,a);break}o=r.mesh.connect(s.Lprev,o.Sym),i.fixUpperEdge(r,n,o)}s.Onext!==o&&(r.mesh.splice(o.Oprev,o),r.mesh.splice(s,o)),i.finishRegion(r,a),s=n.eUp,a=n}return s},i.addRightEdges=function(r,e,t,o,n,a){var s,l,c,u,p=!0;c=t;do we(ve.vertLeq(c.Org,c.Dst)),i.addRegionBelow(r,e,c.Sym),c=c.Onext;while(c!==o);for(n===null&&(n=i.regionBelow(e).eUp.Rprev),l=e,u=n;s=i.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=i.isWindingInside(r,s.windingNumber),l.dirty=!0,!p&&i.checkForRightSplice(r,l)&&(i.addWinding(c,u),i.deleteRegion(r,l),r.mesh.delete(u)),p=!1,l=s,u=c;l.dirty=!0,we(l.windingNumber-c.winding===s.windingNumber),a&&i.walkDirtyRegions(r,l)},i.spliceMergeVertices=function(r,e,t){r.mesh.splice(e,t)},i.vertexWeights=function(r,e,t){var o=ve.vertL1dist(e,r),n=ve.vertL1dist(t,r),a=.5*n/(o+n),s=.5*o/(o+n);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]},i.getIntersectData=function(r,e,t,o,n,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,t,o),i.vertexWeights(e,n,a)},i.checkForRightSplice=function(r,e){var t=i.regionBelow(e),o=e.eUp,n=t.eUp;if(ve.vertLeq(o.Org,n.Org)){if(ve.edgeSign(n.Dst,o.Org,n.Org)>0)return!1;ve.vertEq(o.Org,n.Org)?o.Org!==n.Org&&(r.pq.delete(o.Org.pqHandle),i.spliceMergeVertices(r,n.Oprev,o)):(r.mesh.splitEdge(n.Sym),r.mesh.splice(o,n.Oprev),e.dirty=t.dirty=!0)}else{if(ve.edgeSign(o.Dst,n.Org,o.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,r.mesh.splitEdge(o.Sym),r.mesh.splice(n.Oprev,o)}return!0},i.checkForLeftSplice=function(r,e){var t=i.regionBelow(e),o=e.eUp,n=t.eUp,a;if(we(!ve.vertEq(o.Dst,n.Dst)),ve.vertLeq(o.Dst,n.Dst)){if(ve.edgeSign(o.Dst,n.Dst,o.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,a=r.mesh.splitEdge(o),r.mesh.splice(n.Sym,a),a.Lface.inside=e.inside}else{if(ve.edgeSign(n.Dst,o.Dst,n.Org)>0)return!1;e.dirty=t.dirty=!0,a=r.mesh.splitEdge(n),r.mesh.splice(o.Lnext,n.Sym),a.Rface.inside=e.inside}return!0},i.checkForIntersect=function(r,e){var t=i.regionBelow(e),o=e.eUp,n=t.eUp,a=o.Org,s=n.Org,l=o.Dst,c=n.Dst,u,p,d=new Oa,f,h;if(we(!ve.vertEq(c,l)),we(ve.edgeSign(l,r.event,a)<=0),we(ve.edgeSign(c,r.event,s)>=0),we(a!==r.event&&s!==r.event),we(!e.fixUpperEdge&&!t.fixUpperEdge),a===s||(u=Math.min(a.t,l.t),p=Math.max(s.t,c.t),u>p))return!1;if(ve.vertLeq(a,s)){if(ve.edgeSign(c,a,s)>0)return!1}else if(ve.edgeSign(l,s,a)<0)return!1;return i.debugEvent(r),ve.intersect(l,a,c,s,d),we(Math.min(a.t,l.t)<=d.t),we(d.t<=Math.max(s.t,c.t)),we(Math.min(c.s,l.s)<=d.s),we(d.s<=Math.max(s.s,a.s)),ve.vertLeq(d,r.event)&&(d.s=r.event.s,d.t=r.event.t),f=ve.vertLeq(a,s)?a:s,ve.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),ve.vertEq(d,a)||ve.vertEq(d,s)?(i.checkForRightSplice(r,e),!1):!ve.vertEq(l,r.event)&&ve.edgeSign(l,r.event,d)>=0||!ve.vertEq(c,r.event)&&ve.edgeSign(c,r.event,d)<=0?c===r.event?(r.mesh.splitEdge(o.Sym),r.mesh.splice(n.Sym,o),e=i.topLeftRegion(r,e),o=i.regionBelow(e).eUp,i.finishLeftRegions(r,i.regionBelow(e),t),i.addRightEdges(r,e,o.Oprev,o,o,!0),!0):l===r.event?(r.mesh.splitEdge(n.Sym),r.mesh.splice(o.Lnext,n.Oprev),t=e,e=i.topRightRegion(e),h=i.regionBelow(e).eUp.Rprev,t.eUp=n.Oprev,n=i.finishLeftRegions(r,t,null),i.addRightEdges(r,e,n.Onext,o.Rprev,h,!0),!0):(ve.edgeSign(l,r.event,d)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,r.mesh.splitEdge(o.Sym),o.Org.s=r.event.s,o.Org.t=r.event.t),ve.edgeSign(c,r.event,d)<=0&&(e.dirty=t.dirty=!0,r.mesh.splitEdge(n.Sym),n.Org.s=r.event.s,n.Org.t=r.event.t),!1):(r.mesh.splitEdge(o.Sym),r.mesh.splitEdge(n.Sym),r.mesh.splice(n.Oprev,o),o.Org.s=d.s,o.Org.t=d.t,o.Org.pqHandle=r.pq.insert(o.Org),i.getIntersectData(r,o.Org,a,l,s,c),i.regionAbove(e).dirty=e.dirty=t.dirty=!0,!1)},i.walkDirtyRegions=function(r,e){for(var t=i.regionBelow(e),o,n;;){for(;t.dirty;)e=t,t=i.regionBelow(t);if(!e.dirty&&(t=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,n=t.eUp,o.Dst!==n.Dst&&i.checkForLeftSplice(r,e)&&(t.fixUpperEdge?(i.deleteRegion(r,t),r.mesh.delete(n),t=i.regionBelow(e),n=t.eUp):e.fixUpperEdge&&(i.deleteRegion(r,e),r.mesh.delete(o),e=i.regionAbove(t),o=e.eUp)),o.Org!==n.Org)if(o.Dst!==n.Dst&&!e.fixUpperEdge&&!t.fixUpperEdge&&(o.Dst===r.event||n.Dst===r.event)){if(i.checkForIntersect(r,e))return}else i.checkForRightSplice(r,e);o.Org===n.Org&&o.Dst===n.Dst&&(i.addWinding(n,o),i.deleteRegion(r,e),r.mesh.delete(o),e=i.regionAbove(t))}},i.connectRightVertex=function(r,e,t){var o,n=t.Onext,a=i.regionBelow(e),s=e.eUp,l=a.eUp,c=!1;if(s.Dst!==l.Dst&&i.checkForIntersect(r,e),ve.vertEq(s.Org,r.event)&&(r.mesh.splice(n.Oprev,s),e=i.topLeftRegion(r,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(r,i.regionBelow(e),a),c=!0),ve.vertEq(l.Org,r.event)&&(r.mesh.splice(t,l.Oprev),t=i.finishLeftRegions(r,a,null),c=!0),c){i.addRightEdges(r,e,t.Onext,n,n,!0);return}ve.vertLeq(l.Org,s.Org)?o=l.Oprev:o=s,o=r.mesh.connect(t.Lprev,o),i.addRightEdges(r,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(r,e)},i.connectLeftDegenerate=function(r,e,t){var o,n,a,s,l;if(o=e.eUp,ve.vertEq(o.Org,t)){we(!1),i.spliceMergeVertices(r,o,t.anEdge);return}if(!ve.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),i.sweepEvent(r,t);return}we(!1),e=i.topRightRegion(e),l=i.regionBelow(e),a=l.eUp.Sym,n=s=a.Onext,l.fixUpperEdge&&(we(n!==a),i.deleteRegion(r,l),r.mesh.delete(a),a=n.Oprev),r.mesh.splice(t.anEdge,a),ve.edgeGoesLeft(n)||(n=null),i.addRightEdges(r,e,a.Onext,s,n,!0)},i.connectLeftVertex=function(r,e){var t,o,n,a,s,l,c=new df;if(c.eUp=e.anEdge.Sym,t=r.dict.search(c).key,o=i.regionBelow(t),!!o){if(a=t.eUp,s=o.eUp,ve.edgeSign(a.Dst,e,a.Org)===0){i.connectLeftDegenerate(r,t,e);return}if(n=ve.vertLeq(s.Dst,a.Dst)?t:o,t.inside||n.fixUpperEdge){if(n===t)l=r.mesh.connect(e.anEdge.Sym,a.Lnext);else{var u=r.mesh.connect(s.Dnext,e.anEdge);l=u.Sym}n.fixUpperEdge?i.fixUpperEdge(r,n,l):i.computeWinding(r,i.addRegionBelow(r,t,l)),i.sweepEvent(r,e)}else i.addRightEdges(r,t,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(r,e){r.event=e,i.debugEvent(r);for(var t=e.anEdge;t.activeRegion===null;)if(t=t.Onext,t===e.anEdge){i.connectLeftVertex(r,e);return}var o=i.topLeftRegion(r,t.activeRegion);we(o!==null);var n=i.regionBelow(o),a=n.eUp,s=i.finishLeftRegions(r,n,null);s.Onext===a?i.connectRightVertex(r,o,s):i.addRightEdges(r,o,s.Onext,a,a,!0)},i.addSentinel=function(r,e,t,o){var n=new df,a=r.mesh.makeEdge();a.Org.s=t,a.Org.t=o,a.Dst.s=e,a.Dst.t=o,r.event=a.Dst,n.eUp=a,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=r.dict.insert(n)},i.initEdgeDict=function(r){r.dict=new kI(r,i.edgeLeq);var e=r.bmax[0]-r.bmin[0],t=r.bmax[1]-r.bmin[1],o=r.bmin[0]-e,n=r.bmax[0]+e,a=r.bmin[1]-t,s=r.bmax[1]+t;i.addSentinel(r,o,n,a),i.addSentinel(r,o,n,s)},i.doneEdgeDict=function(r){for(var e,t=0;(e=r.dict.min().key)!==null;)e.sentinel||(we(e.fixUpperEdge),we(++t===1)),we(e.windingNumber===0),i.deleteRegion(r,e)},i.removeDegenerateEdges=function(r){var e,t,o,n=r.mesh.eHead;for(e=n.next;e!==n;e=t)t=e.next,o=e.Lnext,ve.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.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))},i.initPriorityQ=function(r){var e,t,o,n=0;for(o=r.mesh.vHead,t=o.next;t!==o;t=t.next)n++;for(n+=8,e=r.pq=new UI(n,ve.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)},i.donePriorityQ=function(r){r.pq=null},i.removeDegenerateFaces=function(r,e){var t,o,n;for(t=e.fHead.next;t!==e.fHead;t=o)o=t.next,n=t.anEdge,we(n.Lnext!==n),n.Lnext.Lnext===n&&(i.addWinding(n.Onext,n),r.mesh.delete(n));return!0},i.computeInterior=function(r,e){e===void 0&&(e=!0);var t,o;if(i.removeDegenerateEdges(r),!i.initPriorityQ(r))return!1;for(i.initEdgeDict(r);(t=r.pq.extractMin())!==null;){for(;o=r.pq.min(),!(o===null||!ve.vertEq(o,t));)o=r.pq.extractMin(),i.spliceMergeVertices(r,t.anEdge,o.anEdge);i.sweepEvent(r,t)}return r.event=r.dict.min().key.eUp.Org,i.debugEvent(r),i.doneEdgeDict(r),i.donePriorityQ(r),i.removeDegenerateFaces(r,r.mesh)?(e&&r.mesh.check(),!0):!1},i}(),WI=function(){function i(){this.mesh=new Bx,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=Fe.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]},i.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},i.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},i.prototype.computeNormal_=function(r){var e,t,o,n,a,s,l=[0,0,0],c=[0,0,0],u=[0,0,0],p=[0,0,0],d=[0,0,0],f=[null,null,null],h=[null,null,null],m=this.mesh.vHead;e=m.next;for(var y=0;y<3;++y)n=e.coords[y],c[y]=n,h[y]=e,l[y]=n,f[y]=e;for(e=m.next;e!==m;e=e.next)for(var b=0;b<3;++b)n=e.coords[b],n<c[b]&&(c[b]=n,h[b]=e),n>l[b]&&(l[b]=n,f[b]=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=h[v],o=f[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)},i.prototype.checkOrientation_=function(){for(var r=this.mesh.fHead,e,t=this.mesh.vHead,o,n=0,a=r.next;a!==r;a=a.next)if(o=a.anEdge,!(o.winding<=0))do n+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==a.anEdge);if(n<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]}},i.prototype.projectPolygon_=function(){var r=this.mesh.vHead,e=[0,0,0],t,o,n=!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),n=!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);n&&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))},i.prototype.addWinding_=function(r,e){r.winding+=e.winding,r.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(r,e){var t,o;if(t=e.anEdge,!(t.Lnext!==t&&t.Lnext.Lnext!==t))throw"Mono region invalid";for(;ve.vertLeq(t.Dst,t.Org);t=t.Lprev);for(;ve.vertLeq(t.Org,t.Dst);t=t.Lnext);o=t.Lprev;for(var n=void 0;t.Lnext!==o;)if(ve.vertLeq(t.Dst,o.Org)){for(;o.Lnext!==t&&(ve.edgeGoesLeft(o.Lnext)||ve.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)n=r.connect(o.Lnext,o),o=n.Sym;o=o.Lprev}else{for(;o.Lnext!==t&&(ve.edgeGoesRight(t.Lprev)||ve.edgeSign(t.Dst,t.Org,t.Lprev.Org)>=0);)n=r.connect(t,t.Lprev),t=n.Sym;t=t.Lnext}if(o.Lnext===t)throw"Mono region invalid";for(;o.Lnext.Lnext!==t;)n=r.connect(o.Lnext,o),o=n.Sym;return!0},i.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},i.prototype.discardExterior_=function(r){for(var e,t=r.fHead.next;t!==r.fHead;t=e)e=t.next,t.inside||r.zapFace(t)},i.prototype.setWindingNumber_=function(r,e,t){for(var o,n=r.eHead.next;n!==r.eHead;n=o)o=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?e:-e:t?r.delete(n):n.winding=0},i.prototype.getNeighbourFace_=function(r){return!r.Rface||!r.Rface.inside?-1:r.Rface.n},i.prototype.outputPolymesh_=function(r,e,t,o){var n,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){n=u.anEdge,l=0;do{var c=n.Org;c.n===-1&&(c.n=s,s++),l++,n=n.Lnext}while(n!==u.anEdge);if(l>t)throw"Face vertex greater that support polygon";u.n=a,++a}this.elementCount=a,e===st.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){n=u.anEdge,l=0;do{var c=n.Org;this.elements[d++]=c.n,l++,n=n.Lnext}while(n!==u.anEdge);for(var f=l;f<t;++f)this.elements[d++]=-1;if(e===st.CONNECTED_POLYGONS){n=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==u.anEdge);for(var h=l;h<t;++h)this.elements[d++]=-1}}},i.prototype.outputContours_=function(r,e){var t,o,n=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;n=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++]=n,this.elements[u++]=a,n+=a}},i.prototype.addContour=function(r,e){this.mesh===null&&(this.mesh=new Bx),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},i.prototype.tesselate=function(r,e,t,o,n,a){if(r===void 0&&(r=Fe.ODD),e===void 0&&(e=st.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=r,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),HI.computeInterior(this,a);var s=this.mesh;return e===st.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===st.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,t,o),!0},i}();function Fr(i){var r=i.windingRule,e=r===void 0?Fe.ODD:r,t=i.elementType,o=t===void 0?st.POLYGONS:t,n=i.polySize,a=n===void 0?3:n,s=i.vertexSize,l=s===void 0?2:s,c=i.normal,u=c===void 0?[0,0,1]:c,p=i.contours,d=p===void 0?[]:p,f=i.strict,h=f===void 0?!0:f,m=i.debug,y=m===void 0?!1:m;if(!d&&h)throw new Error("Contours can't be empty");if(!!d){var b=new WI;i.edgeCreateCallback&&(b.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(b.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<d.length;v++)b.addContour(l||2,d[v]);return b.tesselate(e,o,a,l,u,h),{vertices:b.vertices,vertexIndices:b.vertexIndices,vertexCount:b.vertexCount,elements:b.elements,elementCount:b.elementCount,mesh:y?b.mesh:void 0}}}var aq=Fe.ODD,sq=Fe.NONZERO,lq=Fe.POSITIVE,cq=Fe.NEGATIVE,uq=Fe.ABS_GEQ_TWO,dq=st.POLYGONS,pq=st.CONNECTED_POLYGONS,fq=st.BOUNDARY_CONTOURS;import{Box2 as YI,BufferAttribute as vu,BufferGeometry as KI,Vector2 as QI}from"three";var xu=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*xu.eSize;this.buffer=new ArrayBuffer(t);let o=Float32Array.BYTES_PER_ELEMENT,n=0;this.positions=new Float32Array(this.buffer,n*o,3*r),n+=3*r,this.normals=new Float32Array(this.buffer,n*o,3*r),n+=3*r,this.uvs=new Float32Array(this.buffer,n*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*xu.eSize,o=new ArrayBuffer(t),n=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*n,3*r);a+=3*r;let l=new Float32Array(o,a*n,3*r);a+=3*r;let c=new Float32Array(o,a*n,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)}},el=xu;el.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var tl=class{constructor(r=[],e=(t,o)=>t<o?-1:t>o?1:0){if(this.data=r,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(r){this.data.push(r),this._up(this.length++)}pop(){if(this.length===0)return;let r=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),r}peek(){return this.data[0]}_up(r){let{data:e,compare:t}=this,o=e[r];for(;r>0;){let n=r-1>>1,a=e[n];if(t(o,a)>=0)break;e[r]=a,r=n}e[r]=o}_down(r){let{data:e,compare:t}=this,o=this.length>>1,n=e[r];for(;r<o;){let a=(r<<1)+1,s=a+1;if(s<this.length&&t(e[s],e[a])<0&&(a=s),t(e[a],n)>=0)break;e[r]=e[a],r=a}e[r]=n}};function pf(i,r,e=1,t=!1){let o=1/0,n=1/0,a=-1/0,s=-1/0;for(let[v,w]of i[0])v<o&&(o=v),w<n&&(n=w),v>a&&(a=v),w>s&&(s=w);let l=a-o,c=s-n,u=Math.max(e,Math.min(l,c));if(u===e){let v=[o,n];return v.distance=0,v.distance}let p=new tl([],(v,w)=>w.max-v.max),d=$I(i),f=new bu(o+l/2,n+c/2,0,i);f.d>d.d&&(d=f);let h=2;function m(v,w,O){let S=new bu(v,w,O,i);if(h++,S.max>d.d+e&&p.push(S),S.d>d.d&&(d=S,t&&console.log(`found best ${Math.round(1e4*S.d)/1e4} after ${h} probes`),d.d>r))return r}let y=u/2;for(let v=o;v<a;v+=u)for(let w=n;w<s;w+=u)m(v+y,w+y,y);for(;p.length;){let{max:v,x:w,y:O,h:S}=p.pop();if(v-d.d<=e)break;y=S/2,m(w-y,O-y,y),m(w+y,O-y,y),m(w-y,O+y,y),m(w+y,O+y,y)}t&&console.log(`num probes: ${h}
3
- best distance: ${d.d}`);let b=[d.x,d.y];return b.distance=d.d,b.distance}function bu(i,r,e,t){this.x=i,this.y=r,this.h=e,this.d=qI(i,r,t),this.max=this.d+this.h*Math.SQRT2}function qI(i,r,e){let t=!1,o=1/0;for(let n of e)for(let a=0,s=n.length,l=s-1;a<s;l=a++){let c=n[a],u=n[l];c[1]>r!=u[1]>r&&i<(u[0]-c[0])*(r-c[1])/(u[1]-c[1])+c[0]&&(t=!t),o=Math.min(o,XI(i,r,c,u))}return o===0?0:(t?1:-1)*Math.sqrt(o)}function $I(i){let r=0,e=0,t=0,o=i[0];for(let a=0,s=o.length,l=s-1;a<s;l=a++){let c=o[a],u=o[l],p=c[0]*u[1]-u[0]*c[1];e+=(c[0]+u[0])*p,t+=(c[1]+u[1])*p,r+=p*3}let n=new bu(e/r,t/r,0,i);return r===0||n.d<0?new bu(o[0][0],o[0][1],0,i):n}function XI(i,r,e,t){let o=e[0],n=e[1],a=t[0]-o,s=t[1]-n;if(a!==0||s!==0){let l=((i-o)*a+(r-n)*s)/(a*a+s*s);l>1?(o=t[0],n=t[1]):l>0&&(o+=a*l,n+=s*l)}return a=i-o,s=r-n,a*a+s*s}var rl={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},hf={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},mf={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},ff=(i,r)=>([e,t])=>(t<e&&(t+=r),(i>=e?i:i+r)<=t),vi=class extends KI{constructor(e,t,o=0,n=12,a=3,s=Fe.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._curveSegments=n,this._bevelSegmentsInput=a;let c=this._shape.extractShapePointsToFlatArray([],n),u=this._shape.shapeHoles.map(I=>{let N=I.extractShapePointsToFlatArray([],n),_=[];for(let R=N.length-1;R>=1;R-=2){let V=N[R-1],U=N[R-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 N=u[I],_=[];for(let R=0;R<N.length;R+=2)_.push([N[R],N[R+1]]);p.push(_)}let f;e.isText?f=new YI().setFromPoints(e.points.map(N=>N.position)).getSize(new QI).length()*.1:p[0].length===0?f=o:o>0?f=pf(p,o):f=1e-5,o<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(o,f,t/2),this._bevelSegments=Math.floor(a));let h;try{h=Fr({windingRule:s,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{h=rl}let m;try{m=Fr({windingRule:Fe.ODD,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{m=hf}if(!h)throw new Error("error generating geometry");let y=h.elementCount;if(m){h.elementCount+=m.elementCount;for(let I=0;I<m.elements.length;I++){let N=m.elements[I],_=I%2===0?h.vertexCount:0;h.elements.push(N+_)}for(let I=0;I<m.vertexIndices.length;I++){let N=m.vertexIndices[I],_=h.vertexCount;h.vertexIndices.push(N+_)}for(let I=0;I<m.vertices.length;I++){let N=m.vertices[I];h.vertices.push(N)}}let b=1/0,v=-1/0,w=1/0,O=-1/0;for(let I=0,N=h.vertexCount;I<N;I++){let _=I*2,R=h.vertices[_+0],V=h.vertices[_+1];R<b&&(b=R),R>v&&(v=R),V<w&&(w=V),V>O&&(O=V)}this._minX=b,this._minY=w,this._width=v-b,this._height=O-w,this._buffer=new el(this._computeBufferEstimatedSize(h));let S=[],T=[];for(let I=h.elementCount-1;I>=0;I--){let N=I>=y,_=I*2,R=h.elements[_+0],V=h.elements[_+1],U=R+V,B={start:R,count:V,normals:[],continuous:[],concave:[]},q=R,j=U-1,F=R+1,H=this._shape.roundedCurves.length;do{let re=q-R,K=h.vertices[j*2+0],Z=h.vertices[j*2+1],Q=h.vertices[q*2+0],$=h.vertices[q*2+1],ue=h.vertices[F*2+0],le=h.vertices[F*2+1],ie=Q-K,ce=$-Z,ae=Math.sqrt(ie*ie+ce*ce);ie/=ae,ce/=ae;let me=Q-ue,pe=$-le,he=Math.sqrt(me*me+pe*pe);me/=he,pe/=he,B.normals[re*2+0]=-pe,B.normals[re*2+1]=me,B.concave[re]=ie*pe-ce*me>0;let xe=h.vertexIndices[q];if(Array.isArray(xe))B.continuous[re]=!1;else{let[ye,C]=this._shape.getCurveIndexFromVertexId(xe-1,!0);if(C>0&&C<1)B.continuous[re]=!0;else{let ne=C===1?ye+1:ye-1;ne=(ne+H)%H;let Ne=C===1?0:1,Ve=this._shape.roundedCurves[ye].getTangent(C),_e=this._shape.roundedCurves[ne].getTangent(Ne);B.continuous[re]=Ve.dot(_e)>.95}}N&&(B.normals[re*2+0]*=-1,B.normals[re*2+1]*=-1),[j,q,F]=[q,F,F+1],F>=U&&(F-=V)}while(F!==R+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:h.vertices.slice(R*2,U*2),vertexCount:V,vertexIndices:new Array(V).fill(!0).map((re,K)=>[K,K]),elements:[0,V],elementCount:1,mesh:null},reverseMap:[],insetPoints:h.vertices.slice(R*2,U*2)});let ee=0;for(let re=1;re<=this._bevelSegments;re++){let K=re/this._bevelSegments*Math.PI/2,Z=(1-Math.cos(K))*this._bevel,Q=[],$=[],ue=[],le=[],ie=0;for(let ae=0;ae<V;ae++){let me=ae*2,pe=(ae-1+V)%V*2,he=h.vertices[B.start*2+me+0],xe=h.vertices[B.start*2+me+1],ye=-B.normals[pe+0]*Z,C=-B.normals[pe+1]*Z,ne=-B.normals[me+0]*Z,Ne=-B.normals[me+1]*Z;if(B.concave[ae]||!B.concave[ae]&&N){let Ve=Math.atan2(C,ye),_e=Math.atan2(Ne,ne);_e>Ve&&(_e-=Math.PI*2);let Pe=_e-Ve;if(B.continuous[ae]||N){let vt=Ve+Pe/2,Me=Math.cos(vt)*Z,xt=Math.sin(vt)*Z;Q[2*ie+0]=he+Me*(N?-1:1),Q[2*ie+1]=xe+xt*(N?-1:1),le[ie]=ae,ie++}else{let vt=Math.max(1,Math.floor(n/4*Math.abs(Pe)/Math.PI));for(let Me=0;Me<=vt;Me++){let xt=Ve+Pe*(Me/vt),St=Math.cos(xt)*Z,Ui=Math.sin(xt)*Z;Q[2*ie+0]=he+St,Q[2*ie+1]=xe+Ui,le[ie]=ae,ie++}}}else Q[2*ie+0]=he+ye,Q[2*ie+1]=xe+C,le[ie]=ae,$[ae]=ie,ie++,Q[2*ie+0]=he,Q[2*ie+1]=xe,le[ie]=ae,ie++,Q[2*ie+0]=he+ne,Q[2*ie+1]=xe+Ne,le[ie]=ae,ue[ae]=ie,ie++}let ce=Fr({windingRule:Fe.POSITIVE,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Q],edgeCreateCallback:ae=>{let pe=ae.Org.idx,he=le[pe],xe=le[(pe+1)%le.length];ae.idx=[he,xe],ae.Sym.idx=[xe,he]},vertexIdCallback:ae=>{let me=ae.Lprev.idx;return[me?me[1]:0,ae.idx?ae.idx[0]:0]}});if(!ce)throw console.log("Error"),new Error(`error generating bevel geometry for ${re}'th loop`);if(!ce.vertexCount){let ae=(re-1)/this._bevelSegments*Math.PI/2;ee=(1-Math.sin(ae))*this._bevel;break}for(let ae=0;ae<ce.vertexIndices.length;ae++){let[me,pe]=ce.vertexIndices[ae];if(me===pe)continue;let he=pe;pe<me&&(he+=V);for(let xe=me;xe<he;xe++){let ye=xe%V,C=(xe+1)%V;if(!B.continuous[ye]||!B.continuous[C]){ce.vertexIndices[ae]=[me,ye],ce.vertexIndices.splice(ae+1,0,[C,pe]),ce.vertices.splice((ae+1)*2,0,ce.vertices[ae*2],ce.vertices[ae*2+1]);break}}}W.push({bevelI:re,angle:K,size:Z,boundary:ce,reverseMap:le,insetPoints:Q})}let te=(re,K,Z)=>{let Q=0,$=re.boundary.vertexIndices.length;for(;Q<$&&Z(re.boundary.vertexIndices[K]);)K=(K+1)%$,Q++;return Q},Y=S.length;for(let re=1;re<W.length;re++){let K=W[re-1],Z=W[re],Q=K.boundary.vertexIndices.length,$=Z.boundary.vertexIndices.length;if(!Q||!$)break;let ue=B.concave.length,le=0,ie=ff(le,V);for(;!K.boundary.vertexIndices.filter(ie).length||!Z.boundary.vertexIndices.filter(ie).length;)le++,ie=ff(le,V);let ce=K.boundary.vertexIndices.findIndex(ie),ae=Z.boundary.vertexIndices.findIndex(ie);do ce=(ce+1)%Q;while(ie(K.boundary.vertexIndices[ce]));do ae=(ae+1)%$;while(ie(Z.boundary.vertexIndices[ae]));le=(le+1)%V;let me=le,pe=0,he=this._buildBevelVert(B,K,(ce-1+Q)%Q,void 0,pe),xe=this._buildBevelVert(B,Z,(ae-1+$)%$,void 0,pe),ye=he,C=xe,ne,Ne,Ve=!1;do{pe=(le||ue)/ue,ie=ff(le,V);let _e=te(K,ce,ie),Pe=te(Z,ae,ie),vt=Ve;if(Ve=!1,_e&&!Pe){for(let Me=0;Me<_e;Me++)ne=this._buildBevelVert(B,K,(ce+Me)%Q,Me/(_e-1),pe),S.push(ye.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,ye.bottomN,C.bottomN),ye=ne;Ve=!0}else if(!_e&&Pe)for(let Me=0;Me<Pe;Me++)Ne=this._buildBevelVert(B,Z,(ae+Me)%$,Me/(Pe-1),pe),S.push(C.topN,ye.topP,Ne.topP),l===!1&&S.push(ye.bottomP,C.bottomN,Ne.bottomP),C=Ne;else if(_e&&Pe)if(ne=this._buildBevelVert(B,K,ce,0,pe),Ne=this._buildBevelVert(B,Z,ae,0,pe),vt?(S.push(ye.topN,Ne.topP,C.topN),S.push(ye.topN,ne.topP,Ne.topP),l===!1&&(S.push(Ne.bottomP,ye.bottomN,C.bottomN),S.push(Ne.bottomP,ne.bottomP,ye.bottomN))):(S.push(C.topN,ye.topN,ne.topP),S.push(C.topN,ne.topP,Ne.topP),l===!1&&(S.push(ne.bottomP,ye.bottomN,C.bottomN),S.push(ne.bottomP,C.bottomN,Ne.bottomP))),ye=ne,C=Ne,_e===Pe)for(let Me=1;Me<_e;Me++)ne=this._buildBevelVert(B,K,(ce+Me)%Q,Me/(_e-1),pe),Ne=this._buildBevelVert(B,Z,(ae+Me)%$,Me/(Pe-1),pe),S.push(ye.topN,ne.topP,C.topN),S.push(C.topN,ne.topP,Ne.topP),l===!1&&(S.push(ne.bottomP,ye.bottomN,C.bottomN),S.push(ne.bottomP,C.bottomN,Ne.bottomP)),ye=ne,C=Ne;else if(_e>Pe){let Me=_e/Pe,xt=0;for(let St=1;St<_e;St++)ne=this._buildBevelVert(B,K,(ce+St)%Q,St/(_e-1),pe),S.push(ye.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,ye.bottomN,C.bottomN),ye=ne,St>(xt+1)*Me&&(xt++,Ne=this._buildBevelVert(B,Z,(ae+xt)%$,xt/(Pe-1),pe),S.push(C.topN,ne.topP,Ne.topP),l===!1&&S.push(ne.bottomP,C.bottomN,Ne.bottomP),C=Ne)}else{let Me=Pe/_e,xt=0;for(let St=1;St<Pe;St++)Ne=this._buildBevelVert(B,Z,(ae+St)%$,St/(Pe-1),pe),S.push(C.topN,ne.topP,Ne.topP),l===!1&&S.push(ne.bottomP,C.bottomN,Ne.bottomP),C=Ne,St>(xt+1)*Me&&(xt++,ne=this._buildBevelVert(B,K,(ce+xt)%Q,xt/(_e-1),pe),S.push(ye.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,ye.bottomN,C.bottomN),ye=ne)}ce=(ce+_e)%Q,ae=(ae+Pe)%$,le=(le+1)%ue}while(le!==me)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(W,B,S),N){let re=[];for(let K=S.length-1;K>=Y+2;K-=3){let Z=S[K-2],Q=S[K-1],$=S[K-0];re.push($,Q,Z)}S.splice(Y,S.length-Y,...re)}if(N){let re=[];for(let K=W[W.length-1].boundary.vertices.length-1;K>=1;K-=2){let Z=W[W.length-1].boundary.vertices[K-1],Q=W[W.length-1].boundary.vertices[K-0];re.push(Z,Q)}T.push(re)}if(!N){let re=W[W.length-1],K;try{K=Fr({windingRule:W.length>1?Fe.POSITIVE:Fe.ODD,elementType:st.POLYGONS,vertexSize:2,strict:!0,contours:[re.insetPoints,...T]})}catch{K=mf}if(!K)throw new Error("Error generating geometry for surface");u.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let Z=0;Z<K.elementCount*3;Z+=3){let Q=this._buildSurfaceVert(K,K.elements[Z+0],ee),$=this._buildSurfaceVert(K,K.elements[Z+1],ee),ue=this._buildSurfaceVert(K,K.elements[Z+2],ee);S.push(Q.top,$.top,ue.top),l===!1&&S.push(ue.bottom,$.bottom,Q.bottom)}}this.vertexCache={}}this._buffer.shrink();let M=new vu(Uint32Array.from(S),1),g=new vu(this._buffer.positions,3),D=new vu(this._buffer.normals,3),E=new vu(this._buffer.uvs,2);g.needsUpdate=!0,D.needsUpdate=!0,E.needsUpdate=!0,M.needsUpdate=!0,this.setAttribute("position",g),this.setAttribute("normal",D),this.setAttribute("uv",E),this.setIndex(M)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let n=e[0];for(let a=0,s=n.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(t,n,a),c=this._buildBevelVert(t,n,(a+1)%s);o.push(c.topP,l.topN,l.bottomN),o.push(c.topP,l.bottomN,c.bottomP)}}_buildSurfaceVert(e,t,o){let n=t.toString();if(n in this.vertexCache)return this.vertexCache[n];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,f={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[n]=f,f}_buildBevelVert(e,t,o,n=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,f;l!==c?(p=l,u=c,f=!1,d=e.continuous[p]&&e.continuous[u]):(u=l,p=(u-1+e.count)%e.count,f=e.concave[u]&&t.bevelI>0,d=e.continuous[u]||f);let h=Math.cos(t.angle),m=Math.sin(t.angle),y=o*2,b=u*2,v=p*2,w=t.boundary.vertices[y+0],O=t.boundary.vertices[y+1],S=(1-m)*this._bevel,T=(w-this._minX)/this._width,M=(O-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(T=a),M=1);let g=e.normals[b+0],D=e.normals[b+1],E=e.normals[v+0],I=e.normals[v+1];if(f){let U=E-g,B=I-D;g=g+U*(1-n),D=D+B*(1-n);let q=Math.sqrt(g*g+D*D);g/=q,D/=q}let N=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),_=N*3,R=N*2,V={i:o,fi:u,topP:N+0,topN:N+0,bottomP:N+1,bottomN:N+1,pathBevelUCoord:a};return this._buffer.positions[_+0]=w,this._buffer.positions[_+1]=O,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[_+0]=g*h,this._buffer.normals[_+1]=D*h,this._buffer.normals[_+2]=m,this._buffer.uvs[R+0]=T,this._buffer.uvs[R+1]=M,this.forPathBevel===!1&&(this._buffer.positions[_+3]=w,this._buffer.positions[_+4]=O,this._buffer.positions[_+5]=S,this._buffer.normals[_+3]=g*h,this._buffer.normals[_+4]=D*h,this._buffer.normals[_+5]=-m,this._buffer.uvs[R+2]=M,this._buffer.uvs[R+3]=T),d||(this.forPathBevel?(N+=1,_+=3,R+=2):(N+=2,_+=6,R+=4),V.topP=N+0,V.bottomP=N+1,this._buffer.positions[_+0]=w,this._buffer.positions[_+1]=O,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[_+0]=E*h,this._buffer.normals[_+1]=I*h,this._buffer.normals[_+2]=m,this._buffer.uvs[R+0]=T,this._buffer.uvs[R+1]=M,this.forPathBevel===!1&&(this._buffer.positions[_+3]=w,this._buffer.positions[_+4]=O,this._buffer.positions[_+5]=S,this._buffer.normals[_+3]=E*h,this._buffer.normals[_+4]=I*h,this._buffer.normals[_+5]=-m,this._buffer.uvs[R+2]=M,this._buffer.uvs[R+3]=T)),this.vertexCache[s]=V,V}clone(){let e=new vi(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Mo(this.userData),e}};var Ta=class extends ZI{constructor(e,t=12,o={}){super();this.type="ShapeGeometry";this.windingRule=Fe.ODD;this.elementType=st.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Fe.ODD,elementType:st.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let n=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(h=>h.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,c=!0,u,p;for(let h=0,m=n.length/2;h<m;h++){let y=h*2,b=n[y+0],v=n[y+1];if(u!==void 0&&b!==u&&(l=!1),p!==void 0&&v!==p&&(c=!1),u=b,p=v,!l&&!c)break}if(!l&&!c)try{s=Fr({contours:[n,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=rl}let d=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new Su(new Float32Array(d*3),3),this._normalAttribute=new Su(new Float32Array(d*3),3),this._uvAttribute=new Su(new Float32Array(d*2),2),this._indexAttribute=new Su(new Uint32Array(f*3),1),s){let h=1/0,m=-1/0,y=1/0,b=-1/0;for(let O=0,S=d;O<S;O++){let T=O*2,M=s.vertices[T+0],g=s.vertices[T+1];M<h&&(h=M),M>m&&(m=M),g<y&&(y=g),g>b&&(b=g)}let v=m-h,w=b-y;for(let O=0,S=d;O<S;O++){let T=O*2,M=s.vertices[T+0],g=s.vertices[T+1],D=(M-h)/v,E=(g-y)/w;this._positionAttribute.setXYZ(O,M,g,0),this._normalAttribute.setXYZ(O,0,0,1),this._uvAttribute.setXY(O,D,E)}for(let O=0,S=f;O<S;O++){let T=O*3,M=s.elements[T+0],g=s.elements[T+1],D=s.elements[T+2];this._indexAttribute.setX(T+0,M),this._indexAttribute.setX(T+1,g),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 Ta(this._shape,this._curveSegments);return e.userData=Mo(this.userData),e}};var Ca=class extends vi{constructor(e,t,o=0,n=12,a=3,s=Fe.ODD){super(e,t,o,n,a,s);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let n=e[0];for(let a=0,s=n.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(t,n,a),c=this._buildBevelVert(t,n,(a+1)%s);o.push(c.topP,l.topN,l.bottomN),o.push(c.topP,l.bottomN,c.bottomP)}}clone(){let e=new Ca(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Mo(this.userData),e}};var er=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Fe.ODD},i.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),a=i.shape??r?.shape,s=a?.roundness??e.roundness;a!==void 0&&(a instanceof je?(a.width!==t||a.height!==o)&&a.applySize(t,o):a=new je(t,o).fromJSON(a),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&a.update());let l=a??new je(t,o);return{parameters:Object.assign(e,{width:t,height:o,depth:n,roundness:s}),shape:l}}static build(i){let{depth:r,extrudeBevelSize:e,extrudeBevelSegments:t,subdivisions:o,roundness:n,windingRule:a}=i.parameters;i.shape.roundness=n;let s;return r<=0?s=new Ta(i.shape,o,{windingRule:a}):s=new Ca(i.shape,r,e,o,t,a),Object.assign(s,{userData:{...i,type:"VectorGeometry"}})}};import{BufferGeometry as JI,Float32BufferAttribute as e3,MathUtils as yf,Vector2 as jx}from"three";var Ux=Math.PI*2,Ma=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return e.angle=yf.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof je?i.shape:new je,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:r,height:e,spikes:t,angle:o,innerRadius:n,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=i.parameters,c=i.shape,u=r*.5,p=e*.5,d=t3(c,u,p,o*Math.PI/180,t,n);c.isClosed=!0,c.update();let f;return o===0?(f=new JI,f.setAttribute("position",new e3([],3))):f=er.create({shape:c,parameters:{subdivisions:d,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function t3(i,r,e,t,o,n){if(t>=Ux)return o>30||o%4===0?(o3(i,r,e,n),Math.round(o/4)):Fx(i,t,o,r,e,n);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=Lx({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?r3(i,a.x,a.y,c,o,r,e,n):Fx(i,t,o,r,e,n)}function r3(i,r,e,t,o,n,a,s){let l=Math.round(o/t.length);i.addPoint(Aa(r,e));for(let c=0,u=t.length;c<u;c++){let p=t[c],d=i.points[c],f=Aa(p.x,p.y);d.controls[1].position.set(p.x1,p.y1),f.controls[0].position.set(p.x2,p.y2),i.addPoint(f)}return s>0?kx(i,n,a,s):i.addPoint(Aa(0,0)),l}function Fx(i,r,e,t,o,n){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;i.addPoint(Aa(c,u))}return r<Ux?n>0?kx(i,t,o,n):i.addPoint(Aa(0,0)):(i.removePoint(i.points[i.points.length-1]),n>0&&Hx(i,t,o,n)),1}function o3(i,r,e,t=0,o=0,n=0){let a=.5522847498,s=r*a,l=e*a;i.addPoint(wu(o-r,n,o-r,n-l,o-r,n+l)),i.addPoint(wu(o,n+e,o-s,n+e,o+s,n+e)),i.addPoint(wu(o+r,n,o+r,n+l,o+r,n-l)),i.addPoint(wu(o,n-e,o+s,n-e,o-s,n-e)),t>0&&Hx(i,r,e,t)}function Aa(i,r){return new Gr(yf.generateUUID(),new jx(i,r))}function wu(i,r,e,t,o,n){let a=Aa(i,r);return a.controls[0].position.set(e,t),a.controls[1].position.set(o,n),a}function kx(i,r,e,t){Wx(i,r,e,t).forEach(n=>i.addPoint(n))}function Hx(i,r,e,t){let o=Wx(i,r,e,t),n=new je;o.forEach(a=>n.addPoint(a)),n.isClosed=!0,i.shapeHoles.push(n)}function Wx(i,r,e,t){let o=t*r/100,n=o*(Math.abs(e)/Math.abs(r)),a=new jx(o/r,n/e),s=i.points.map(l=>{let c=l.clone();return c.uuid=yf.generateUUID(),c}).reverse();return s.forEach(l=>{l.position.multiply(a);let c=l.controls[0].position.clone().multiply(a),u=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(u),l.controls[1].position.copy(c)}),s}import{BufferGeometry as i3,Float32BufferAttribute as gf,Uint32BufferAttribute as n3,Vector3 as qx}from"three";var $x=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),t=Math.abs(e.width),o=Math.abs(e.height??t),n=Math.abs(e.depth??t),a=Math.abs(Math.min(t,n))/2;return{parameters:Object.assign(e,{width:t,height:o,depth:n,radius:a,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:r,height:e,depth:t,radius:o,revolutions:n,segments:a,pathRadius:s,pathType:l,pathSegments:c,cornerRadius:u,cornerSegments:p}=i.parameters,d=new ol(!1,r,e,t,o,n,a,s,l,c,u,p);return Object.assign(d,{userData:{...i,type:"HelixGeometry"}})}},xf=new n3([0,0,0],1),ol=class extends i3{constructor(r=!0,e=1,t=1,o=1,n=1,a=1,s=1,l=1,c=1,u=1,p=1,d=1){if(super(),a===0)return;let f=r&&a===1;f&&(d=0),p>100&&(p=100),p===0&&(d=0);let h=()=>new qx,m=new qx,y=h(),b=h(),v=h(),w,O,S,T,M,g,D,E,I=h(),N=h(),_=h(),R=h(),V=h(),U=h(),B=h(),q=h(),j=t-2*l+.001,F=j/a,H=Math.ceil(s*a),W=H+1,ee=j/H,te=-j/2,Y=u+1,re=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,ie=d*le+le,ce=Y*ie/le,ae=ce+Y*W,me=Math.max(0,Y*(W+ie)),[pe,he,xe]=[3,3,2].map(it=>Array(me*it).fill(0)),ye=[],C=n-l;function ne(it,Ye){let Er=Math.PI/2;g=Ye*ee,E=2*Math.PI*(g%F)/F+Er,g+=te,D=Math.sin(E)*C,M=Math.cos(E)*C,r?it.set(M,D,g):it.set(M,g,D)}ne(m,-1e-10),ne(y,0),I.copy(m),ne(m,1);let Ne=m.distanceTo(y),Ve=f?0:$+Q,_e=Ne*H+2*Ve,Pe=Q,vt=_e-Ve;for(let it=0;it<=H;it++){ne(b,it),q.subVectors(b,I).normalize(),I.copy(b),U.copy(b).setComponent(+r+1,0).normalize(),B.crossVectors(q,U).normalize();let Ye=it===0,Er=it===H,Gd=Ye?3*Math.PI/2:K,Fd=Ye?Pe:vt,zl=Ye?Y:ae,ki=Ye?0:me-Y,ct=q.clone().multiplyScalar(Ye?-$:$).add(b),jd=q.clone().multiplyScalar(Ye?-1:1).normalize();for(let mr=0;mr<Y;mr++){let Cs=mr*re;if(N.addVectors(m.copy(U).multiplyScalar(l*Math.cos(Cs)),y.copy(B).multiplyScalar(l*Math.sin(Cs))),_.copy(N).normalize(),Ye||Er){f||(ue=ki+mr,[0,1,2].forEach(Ht=>{pe[ue*3+Ht]=ct.getComponent(Ht),he[ue*3+Ht]=jd.getComponent(Ht)}),xe[ue*2]=+Er,xe[ue*2+1]=mr/u),y.copy(_).multiplyScalar(Q),v.addVectors(b,y);for(let Ht=0;Ht<d;Ht++){let Hi=Ht*K+Gd;R.addVectors(m.copy(q).multiplyScalar($*Math.sin(Hi)),y.copy(_).multiplyScalar($*Math.cos(Hi))),V.copy(R).normalize(),y.addVectors(v,R),R.normalize(),ue=zl+Ht*Y+mr,[0,1,2].forEach(Tn=>{pe[ue*3+Tn]=y.getComponent(Tn),he[ue*3+Tn]=V.getComponent(Tn)});let Gl=+Ye+Math.sin(Hi);xe[ue*2]=(Fd+$*Gl)/_e,xe[ue*2+1]=mr/u}}y.addVectors(b,N),ue=ce+it*Y+mr,[0,1,2].forEach(Ht=>{pe[ue*3+Ht]=y.getComponent(Ht),he[ue*3+Ht]=_.getComponent(Ht)}),xe[ue*2]=(Ve+it*Ne)/_e,xe[ue*2+1]=mr/u}}let Me=W+2*d+le,xt=1,[St,Ui]=[+f,Me-1];for(let it=St;it<=Ui-1;it++){let Ye=f&&it===Ui-1;for(let Er=0;Er<Y-1;Er++)w=it*Y+Er,O=w+1,S=(Ye?Er:w)+Y,T=(Ye?Er+1:O)+Y,it===0?ye.push(O,T,S):it===Me-2?ye.push(w,O,S):ye.push(w,O,S,O,T,S)}this.setIndex(ye),this.setAttribute("position",new gf(pe,3)),this.setAttribute("normal",new gf(he,3)),this.setAttribute("uv",new gf(xe,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let r=this.userData.parameters,e=Math.ceil(r.tubularSegments),t=r.radialSegments+1,o=Array.from(this.getIndex().array),n,a,s,l,c=6*(e-1)*r.radialSegments,u=e,p=u===e;for(let d=0;d<r.radialSegments;d++)n=u*t+d,a=n+1,s=(p?d:n)+t,l=(p?d+1:a)+t,o[c++]=n,o[c++]=a,o[c++]=s,o[c++]=a,o[c++]=l,o[c++]=s;return o.length=c,xf.array=o,xf.count=o.length,xf}};import{IcosahedronGeometry as a3}from"three";var Xx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.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(i){let{width:r,height:e,depth:t,detail:o,corner:n,cornerSides:a}=i.parameters,s=o===0&&n!==0?new il(r*.5,n,a):new a3(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...i,type:"IcosahedronGeometry"}})}},il=class extends xi{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,n=[-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(n,a,s,r,e,t),this.type=s}static fromJSON(r){return new il(r.radius,r.corner,r.cornerSides)}};import{LatheGeometry as s3,Shape as l3}from"three";var Yx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){(i.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}]},i.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(i){let{points:r,segments:e,verticalSegments:t}=i.parameters,o=new l3;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 n=new s3(o.extractPoints(t).shape,e);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...i,type:"LatheGeometry"}})}};import{BufferGeometry as ob,BufferGeometryLoader as v3,Vector3 as S3,BoxGeometry as ib}from"three";import{BufferGeometry as y3,Vector2 as wf,Vector3 as rb}from"three";import{Box3 as c3,BufferAttribute as nl,BufferGeometry as Kx,Color as Sf,EventDispatcher as u3,Float32BufferAttribute as Ia,Matrix3 as Qx,Matrix4 as tb,MathUtils as d3,Object3D as p3,Sphere as f3,Vector2 as dr,Vector3 as zt,Vector4 as h3}from"three";var lo=new tb,bf=new p3,Pu=new zt,Si=class extends u3{constructor(){super(),this.uuid=d3.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 Qx().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 n=this.faces[t];n.normal.applyMatrix3(e).normalize();for(let a=0,s=n.vertexNormals.length;a<s;a++)n.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 lo.makeRotationX(r),this.applyMatrix4(lo),this}rotateY(r){return lo.makeRotationY(r),this.applyMatrix4(lo),this}rotateZ(r){return lo.makeRotationZ(r),this.applyMatrix4(lo),this}translate(r,e,t){return lo.makeTranslation(r,e,t),this.applyMatrix4(lo),this}scale(r,e,t){return lo.makeScale(r,e,t),this.applyMatrix4(lo),this}lookAt(r){return bf.lookAt(r),bf.updateMatrix(),this.applyMatrix4(bf.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 n=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<n.count;d++)e.vertices.push(new zt().fromBufferAttribute(n,d)),s!==void 0&&e.colors.push(new Sf().fromBufferAttribute(s,d));function u(d,f,h,m){let y=s===void 0?[]:[e.colors[d].clone(),e.colors[f].clone(),e.colors[h].clone()],b=a===void 0?[]:[new zt().fromBufferAttribute(a,d),new zt().fromBufferAttribute(a,f),new zt().fromBufferAttribute(a,h)],v=new Ea(d,f,h,b,y,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new dr().fromBufferAttribute(l,d),new dr().fromBufferAttribute(l,f),new dr().fromBufferAttribute(l,h)]),c!==void 0&&e.faceVertexUvs[1].push([new dr().fromBufferAttribute(c,d),new dr().fromBufferAttribute(c,f),new dr().fromBufferAttribute(c,h)])}let p=r.groups;if(p.length>0)for(let d=0;d<p.length;d++){let f=p[d],h=f.start,m=f.count;for(let y=h,b=h+m;y<b;y+=3)t!==void 0?u(t.getX(y),t.getX(y+1),t.getX(y+2),f.materialIndex):u(y,y+1,y+2,f.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<n.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(Pu).negate(),this.translate(Pu.x,Pu.y,Pu.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new tb;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 zt,e=new zt;for(let t=0,o=this.faces.length;t<o;t++){let n=this.faces[t],a=this.vertices[n.a],s=this.vertices[n.b],l=this.vertices[n.c];r.subVectors(l,s),e.subVectors(a,s),r.cross(e),r.normalize(),n.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 zt;if(r){let t=new zt,o=new zt;for(let n=0,a=this.faces.length;n<a;n++){let s=this.faces[n],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 n=this.faces[t];e[n.a].add(n.normal),e[n.b].add(n.normal),e[n.c].add(n.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 n=this.faces[t],a=n.vertexNormals;a.length===3?(a[0].copy(e[n.a]),a[1].copy(e[n.b]),a[2].copy(e[n.c])):(a[0]=e[n.a].clone(),a[1]=e[n.b].clone(),a[2]=e[n.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 n=0,a=o.vertexNormals.length;n<a;n++)o.__originalVertexNormals[n]?o.__originalVertexNormals[n].copy(o.vertexNormals[n]):o.__originalVertexNormals[n]=o.vertexNormals[n].clone()}let r=new Si;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 n=this.morphNormals[e].faceNormals,a=this.morphNormals[e].vertexNormals;for(let s=0,l=this.faces.length;s<l;s++){let c=new zt,u={a:new zt,b:new zt,c:new zt};n.push(c),a.push(u)}}let o=this.morphNormals[e];r.vertices=this.morphTargets[e].vertices,r.computeFaceNormals(),r.computeVertexNormals();for(let n=0,a=this.faces.length;n<a;n++){let s=this.faces[n],l=o.faceNormals[n],c=o.vertexNormals[n];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 c3),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new f3),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,n=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 Qx().getNormalMatrix(e));for(let d=0,f=s.length;d<f;d++){let m=s[d].clone();e!==void 0&&m.applyMatrix4(e),a.push(m)}for(let d=0,f=p.length;d<f;d++)u.push(p[d].clone());for(let d=0,f=c.length;d<f;d++){let h=c[d],m,y,b=h.vertexNormals,v=h.vertexColors,w=new Ea(h.a+n,h.b+n,h.c+n);w.normal.copy(h.normal),o!==void 0&&w.normal.applyMatrix3(o).normalize();for(let O=0,S=b.length;O<S;O++)m=b[O].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),w.vertexNormals.push(m);w.color.copy(h.color);for(let O=0,S=v.length;O<S;O++)y=v[O],w.vertexColors.push(y.clone());w.materialIndex=h.materialIndex+t,l.push(w)}for(let d=0,f=r.faceVertexUvs.length;d<f;d++){let h=r.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,y=h.length;m<y;m++){let b=h[m],v=[];for(let w=0,O=b.length;w<O;w++)v.push(b[w].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=[],n=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*n)+"_"+Math.round(u.y*n)+"_"+Math.round(u.z*n);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 zt(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],n=this.faceVertexUvs[1],a,s;o&&o.length===e&&(a=[]),n&&n.length===e&&(s=[]);for(let l=0;l<e;l++){let c=r[l]._id;a&&a.push(o[c]),s&&s.push(n[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 h=this.parameters;for(let m in h)h[m]!==void 0&&(r[m]=h[m]);return r}let e=[];for(let h=0;h<this.vertices.length;h++){let m=this.vertices[h];e.push(m.x,m.y,m.z)}let t=[],o=[],n={},a=[],s={},l=[],c={};for(let h=0;h<this.faces.length;h++){let m=this.faces[h],y=!0,b=!1,v=this.faceVertexUvs[0][h]!==void 0,w=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,M=0;if(M=u(M,0,0),M=u(M,1,y),M=u(M,2,b),M=u(M,3,v),M=u(M,4,w),M=u(M,5,O),M=u(M,6,S),M=u(M,7,T),t.push(M),t.push(m.a,m.b,m.c),t.push(m.materialIndex),v){let g=this.faceVertexUvs[0][h];t.push(f(g[0]),f(g[1]),f(g[2]))}if(w&&t.push(p(m.normal)),O){let g=m.vertexNormals;t.push(p(g[0]),p(g[1]),p(g[2]))}if(S&&t.push(d(m.color)),T){let g=m.vertexColors;t.push(d(g[0]),d(g[1]),d(g[2]))}}function u(h,m,y){return y?h|1<<m:h&~(1<<m)}function p(h){let m=h.x.toString()+h.y.toString()+h.z.toString();return n[m]!==void 0||(n[m]=o.length/3,o.push(h.x,h.y,h.z)),n[m]}function d(h){let m=h.r.toString()+h.g.toString()+h.b.toString();return s[m]!==void 0||(s[m]=a.length,a.push(h.getHex())),s[m]}function f(h){let m=h.x.toString()+h.y.toString();return c[m]!==void 0||(c[m]=l.length/2,l.push(h.x,h.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 Si().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,f=e.length;d<f;d++)this.vertices.push(e[d].clone());let t=r.colors;for(let d=0,f=t.length;d<f;d++)this.colors.push(t[d].clone());let o=r.faces;for(let d=0,f=o.length;d<f;d++)this.faces.push(o[d].clone());for(let d=0,f=r.faceVertexUvs.length;d<f;d++){let h=r.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,y=h.length;m<y;m++){let b=h[m],v=[];for(let w=0,O=b.length;w<O;w++){let S=b[w];v.push(S.clone())}this.faceVertexUvs[d].push(v)}}let n=r.morphTargets;for(let d=0,f=n.length;d<f;d++){let h={};if(h.name=n[d].name,n[d].vertices!==void 0){h.vertices=[];for(let m=0,y=n[d].vertices.length;m<y;m++)h.vertices.push(n[d].vertices[m].clone())}if(n[d].normals!==void 0){h.normals=[];for(let m=0,y=n[d].normals.length;m<y;m++)h.normals.push(n[d].normals[m].clone())}this.morphTargets.push(h)}let a=r.morphNormals;for(let d=0,f=a.length;d<f;d++){let h={};if(a[d].vertexNormals!==void 0){h.vertexNormals=[];for(let m=0,y=a[d].vertexNormals.length;m<y;m++){let b=a[d].vertexNormals[m],v={};v.a=b.a.clone(),v.b=b.b.clone(),v.c=b.c.clone(),h.vertexNormals.push(v)}}if(a[d].faceNormals!==void 0){h.faceNormals=[];for(let m=0,y=a[d].faceNormals.length;m<y;m++)h.faceNormals.push(a[d].faceNormals[m].clone())}this.morphNormals.push(h)}let s=r.skinWeights;for(let d=0,f=s.length;d<f;d++)this.skinWeights.push(s[d].clone());let l=r.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let c=r.lineDistances;for(let d=0,f=c.length;d<f;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 vf().fromGeometry(this),e=new Kx,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",Ou.call(new nl(t,3),r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",Ou.call(new nl(o,3),r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",Zx.call(new nl(o,3),r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",Jx.call(new nl(o,2),r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",Jx.call(new nl(o,2),r.uvs2))}e.groups=r.groups;for(let o in r.morphTargets){let n=[],a=r.morphTargets[o];for(let s=0,l=a.length;s<l;s++){let c=a[s],u=new Ia(c.data.length*3,3);u.name=c.name,n.push(Ou.call(u,c.data))}e.morphAttributes[o]=n}if(r.skinIndices.length>0){let o=new Ia(r.skinIndices.length*4,4);e.setAttribute("skinIndex",eb.call(o,r.skinIndices))}if(r.skinWeights.length>0){let o=new Ia(r.skinWeights.length*4,4);e.setAttribute("skinWeight",eb.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 Kx,t=r.geometry;if(r.isPoints||r.isLine){let o=new Ia(t.vertices.length*3,3),n=new Ia(t.colors.length*3,3);if(e.setAttribute("position",Ou.call(o,t.vertices)),e.setAttribute("color",Zx.call(n,t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let a=new Ia(t.lineDistances.length,1);e.setAttribute("lineDistance",m3.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}};Si.prototype.isGeometry=!0;var vf=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,n,a=r.faces;for(o=0;o<a.length;o++){let s=a[o];s.materialIndex!==n&&(n=s.materialIndex,t!==void 0&&(t.count=o*3-t.start,e.push(t)),t={start:o*3,materialIndex:n})}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,n=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 b=0;b<l;b++)c[b]={name:s[b].name,data:[]};this.morphTargets.position=c}let u=r.morphNormals,p=u.length,d;if(p>0){d=[];for(let b=0;b<p;b++)d[b]={name:u[b].name,data:[]};this.morphTargets.normal=d}let f=r.skinIndices,h=r.skinWeights,m=f.length===t.length,y=h.length===t.length;t.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let b=0;b<e.length;b++){let v=e[b];this.vertices.push(t[v.a],t[v.b],t[v.c]);let w=v.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[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(n===!0){let S=o[0][b];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",b),this.uvs.push(new dr,new dr,new dr))}if(a===!0){let S=o[1][b];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",b),this.uvs2.push(new dr,new dr,new dr))}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[b];d[S].data.push(T.a,T.b,T.c)}m&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),y&&this.skinWeights.push(h[v.a],h[v.b],h[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}},Ea=class{constructor(r,e,t,o,n,a=0){this.a=r,this.b=e,this.c=t,this.normal=o&&o.isVector3?o:new zt,this.vertexNormals=Array.isArray(o)?o:[],this.color=n&&n.isColor?n:new Sf,this.vertexColors=Array.isArray(n)?n:[],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 m3(i){return this.array.set(i),this}function Zx(i){let r=this.array,e=0;for(let t=0,o=i.length;t<o;t++){let n=i[t];n===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",t),n=new Sf),r[e++]=n.r,r[e++]=n.g,r[e++]=n.b}return this}function Jx(i){let r=this.array,e=0;for(let t=0,o=i.length;t<o;t++){let n=i[t];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",t),n=new dr),r[e++]=n.x,r[e++]=n.y}return this}function Ou(i){let r=this.array,e=0;for(let t=0,o=i.length;t<o;t++){let n=i[t];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",t),n=new zt),r[e++]=n.x,r[e++]=n.y,r[e++]=n.z}return this}function eb(i){let r=this.array,e=0;for(let t=0,o=i.length;t<o;t++){let n=i[t];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",t),n=new h3),r[e++]=n.x,r[e++]=n.y,r[e++]=n.z,r[e++]=n.w}return this}var g3=["a","b","c"];function x3(i,r){switch(r){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function Pf(i,r,e){let t=Math.min(i,r),o=Math.max(i,r),n=t+"_"+o;return e.get(n)}function Of(i,r,e,t,o,n){let a=Math.min(i,r),s=Math.max(i,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),n[i].edges.push(c),n[r].edges.push(c)}function b3(i,r,e,t){let o,n,a;for(o=0,n=i.length;o<n;o++)e[o]={edges:[]};for(o=0,n=r.length;o<n;o++)a=r[o],Of(a.a,a.b,i,t,a,e),Of(a.b,a.c,i,t,a,e),Of(a.c,a.a,i,t,a,e)}function Tu(i,r,e,t,o){i.push(new Ea(r,e,t,void 0,void 0,o))}function Na(i,r){return Math.abs(r-i)/2+Math.min(i,r)}function Cu(i,r,e,t){i.push([r.clone(),e.clone(),t.clone()])}var Au=class{constructor(r=1){this.subdivisions=r}modify(r){r instanceof y3?r=new Si().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 rb,t,o,n,a,s,l=r.vertices,c=r.faces,u=r.faceVertexUvs[0],p=u!==void 0&&u.length>0,d=[],f=new Map;b3(l,c,d,f);let h=[],m,y,b,v,w,O,S;for(let Z of Array.from(f.keys())){for(y=f.get(Z),b=new rb,w=3/8,O=1/8,S=y.faces.length,S!=2&&(w=.5,O=0,S!=1),b.addVectors(y.a,y.b).multiplyScalar(w),e.set(0,0,0),a=0;a<S;a++){for(v=y.faces[a],s=0;s<3&&(m=l[x3(v,g3[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(O),b.add(e),y.newEdge=h.length,h.push(b)}let T,M,g,D,E,I,N,_=[];for(o=0,n=l.length;o<n;o++){for(I=l[o],E=d[o].edges,t=E.length,t==3?T=3/16:t>3&&(T=3/(8*t)),M=1-t*Number(T),g=T,t<=2&&(t==2?(M=3/4,g=1/8):t==1||t==0),N=I.clone().multiplyScalar(M),e.set(0,0,0),a=0;a<t;a++)D=E[a],m=D.a!==I?D.a:D.b,e.add(m);e.multiplyScalar(Number(g)),N.add(e),_.push(N)}let R=_.concat(h),V=_.length,U,B,q,j=[],F=[],H,W,ee,te,Y=new wf,re=new wf,K=new wf;for(o=0,n=c.length;o<n;o++)v=c[o],U=Number(Pf(v.a,v.b,f).newEdge)+V,B=Number(Pf(v.b,v.c,f).newEdge)+V,q=Number(Pf(v.c,v.a,f).newEdge)+V,Tu(j,U,B,q,v.materialIndex),Tu(j,v.a,U,q,v.materialIndex),Tu(j,v.b,B,U,v.materialIndex),Tu(j,v.c,q,B,v.materialIndex),p&&(H=u[o],W=H[0],ee=H[1],te=H[2],Y.set(Na(W.x,ee.x),Na(W.y,ee.y)),re.set(Na(ee.x,te.x),Na(ee.y,te.y)),K.set(Na(W.x,te.x),Na(W.y,te.y)),Cu(F,Y,re,K),Cu(F,W,Y,K),Cu(F,ee,re,Y),Cu(F,te,K,re));r.vertices=R,r.faces=j,p&&(r.faceVertexUvs[0]=F)}};var Ot=new S3,nb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=i.geometry??r?.geometry??new ob().copy(new ib(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Ot),t={width:Ot.x,height:Ot.y,depth:Ot.z,subdivisions:0}):t=r.parameters;let o={...t,...i.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(i){let{width:r,height:e,depth:t,subdivisions:o}=i.parameters,n=i.geometry??new ob().copy(new ib(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(Ot)):Ot.set(a.width,a.height,a.depth),(r!==Ot.x||e!==Ot.y||t!==Ot.z)&&n.scale(Ot.x===0?1:r/Ot.x,Ot.y===0?1:e/Ot.y,Ot.z===0?1:t/Ot.z);let s=n.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=n),n=new Au(o).modify(s).toBufferGeometry()):(s!==void 0&&(n=s),s=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals())}catch{s!==void 0&&(n=s),s=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()}return s!==void 0&&Object.assign(n,{originalGeometry:s}),delete i.geometry,Object.assign(n,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,r,e){new v3(e).load(i,o=>{let n=this.normalizeInputs({geometry:o});o.boundingBox.getSize(Ot);let a=100/Ot.x;Object.assign(n.parameters,{width:100,height:Ot.y*a,depth:Ot.z*a}),r(this.build(n))})}};var Mu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof je?i.shape:new je,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:r,height:e,spikes:t,cornerRadius:o,depth:n,extrudeBevelSize:a,extrudeBevelSegments:s}=i.parameters,l=i.shape,c=r*.5,u=e*.5,p=0,d=0,f=2*Math.PI/t;for(let m=0;m<t;m++){let y=f*m,b=p+Math.sin(y)*c,v=d+Math.cos(y)*u;l.addPoint(l.createPoint(b,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 h=er.create({shape:l,parameters:{roundness:o,depth:n,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(h,{userData:{...i,type:"PolygonGeometry"}})}};import{BufferGeometry as w3,Float32BufferAttribute as Tf,Vector2 as co,Vector3 as Nt}from"three";var ab=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:r,height:e,depth:t,radialSegments:o,heightSegments:n,openEnded:a,cornerRadius:s,cornerSegments:l}=i.parameters,c=new Af(r*.5,e,o,n,a,s,l);return c.scale(1,1,t/r),Object.assign(c,{userData:{...i,type:"PyramidGeometry"}})}};function al(i,r,e){e.x=i.x*r.x,e.y=i.y,e.z=i.x*r.y}function Cf(i,r,e,t,o,n){let a=r.clone().sub(i),s=e.clone().sub(i),l=a.angleTo(s);if(a.normalize(),s.normalize(),t===o){let c=a.add(s).normalize();n.copy(i).addScaledVector(c,t/Math.sin(l/2))}else{let c=a.angleTo(s);n.copy(i),n.addScaledVector(a,o/Math.sin(c)),n.addScaledVector(s,t/Math.sin(c))}}function P3(i,r,e){let t=i.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var Af=class extends w3{constructor(r=.5,e=1,t=4,o=1,n=!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,f=e/2,h=Math.PI/t,m=r*Math.cos(Math.PI/t),y=2*Math.PI/t,b=(t-2)*Math.PI/t,v=Math.PI-b,w=new Nt(0,-f,0),O=new Nt(0,f,0),S=new co(r,-f),T=new co(m,-f),M=new co(0,O.y).sub(T),g=new co(0,O.y).sub(S),D=new co(M.y,-M.x).normalize(),E=new co(g.y,-g.x).normalize(),N=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-M.angle())/2)-1e-8;a=Math.min(a,N);let _;{let F=new Nt(D.x,D.y,0),H=new Nt(Math.cos(y)*F.x,F.y,Math.sin(y)*F.x);_=F.angleTo(H)}let R=a/Math.tan((Math.PI-M.angle())/2),V=a/Math.tan((Math.PI-_)/2),U=new Nt;if(!n){c.push(w.x,w.y,w.z),u.push(0,-1,0),p.push(0,0);let F=d++,H=[],W=S.clone(),ee=R/Math.cos(Math.PI/t);W.x-=ee;for(let te=0;te<t;te++){let Y=te/t*Math.PI*2+h,re=new co(Math.sin(Y),Math.cos(Y));al(W,re,U),c.push(U.x,U.y,U.z),u.push(0,-1,0),p.push(0,0),H.push(d++)}for(let te=0;te<H.length;te++)l.push(H[te],F,H[(te+1)%H.length])}let B=[];{let F=new Nt,H=new Nt,W=new Nt,ee=new Nt,te=new Nt,Y=new Nt;for(let re=0;re<t;re++){let K=re/t*Math.PI*2+h,Z=(re+.5)/t*Math.PI*2+h,Q=(re+1)/t*Math.PI*2+h,$=new co(Math.sin(K),Math.cos(K)),ue=new co(Math.sin(Z),Math.cos(Z)),le=new co(Math.sin(Q),Math.cos(Q));al(S,$,H),al(S,le,W),al(D,ue,F),Cf(O,H,W,V,V,ee),c.push(ee.x,ee.y,ee.z),Cf(H,O,W,V,R,te),c.push(te.x,te.y,te.z),Cf(W,H,O,R,V,Y),c.push(Y.x,Y.y,Y.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 ie=d++,ce=d++,ae=d++;if(l.push(ie,ce,ae),a>0){{let he=H.clone().add(W).multiplyScalar(.5),xe=O.clone().sub(he).normalize(),C=w.clone().sub(he).normalize().add(xe).normalize().multiplyScalar(-1),ne=Y.clone().sub(te);q(he,ne,C,M.angle())}let me,pe;{let he=new Nt;al(E,le,he);let xe=Y.clone().add(ee).multiplyScalar(.5);xe=P3(xe,W,O);let ye=Y.clone().sub(ee);[me,pe]=q(xe,ye,he,_,ee.y)}{let he=me,xe=he.clone().setY(0).normalize(),ye=new Nt(0,-1,0),C=xe.clone().cross(ye);j(he,xe,ye,C)}B.concat(pe);{let he=M.angle(),xe=Math.PI-he,ye=O.clone();ye.y-=a/Math.sin(he-Math.PI/2);let C=new Nt,ne=[];for(let Ve=0;Ve<s;Ve++){let _e=[],Pe=Math.PI/2-xe*Ve/s,vt=Math.cos(Pe),Me=Math.sin(Pe),xt=Z;for(let St=0;St<=Ve;St++){let Ui=Math.cos(xt),it=Math.sin(xt);F.x=vt*it,F.y=Me,F.z=vt*Ui,C.copy(ye).addScaledVector(F,a),c.push(C.x,C.y,C.z),u.push(F.x,F.y,F.z),p.push(0,0),_e.push(d++),xt+=Math.PI*2/Ve/t}ne.push(_e)}pe.reverse(),ne.push(pe);let Ne=ne.length-1;for(let Ve=0;Ve<Ne;Ve++){let _e=ne[Ve],Pe=ne[Ve+1],vt=_e.length-1;l.push(Pe[1],_e[0],Pe[0]);for(let Me=1;Me<=vt;Me++)l.push(_e[Me],_e[Me-1],Pe[Me]),l.push(Pe[Me+1],_e[Me],Pe[Me])}}}}}this.setIndex(l),this.setAttribute("position",new Tf(c,3)),this.setAttribute("normal",new Tf(u,3)),this.setAttribute("uv",new Tf(p,2));function q(F,H,W,ee,te){let Y=-ee/2,re=(Math.PI-ee)/2,K=H.clone().normalize().cross(W);F.addScaledVector(W,-a/Math.sin(re));let Z=new Nt,Q=new Nt,$=1,ue=d,le=[];for(let ie=0;ie<=s;ie++){let ce=Y+ie/s*ee;Q.set(0,0,0),Q.addScaledVector(K,Math.sin(ce)),Q.addScaledVector(W,Math.cos(ce));for(let ae=0;ae<=$;ae++){let me=ae/$-.5;if(Z.copy(F),Z.addScaledVector(H,me),Z.addScaledVector(Q,a),te!=null){let pe=Math.max(0,Z.y-te);Z.addScaledVector(H,-pe/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 ie=0;ie<s;ie++)for(let ce=0;ce<$;ce++){let ae=ue+ce+($+1)*ie,me=ae+($+1),pe=me+1,he=ae+1;l.push(ae,me,he),l.push(me,pe,he)}return[F.clone().addScaledVector(H,.5),le]}function j(F,H,W,ee){let te=Math.PI/2,Y=g.angle()-te,re=[],K=new Nt,Z=new Nt;for(let $=0;$<=s;$++){let ue=[],le=$/s;for(let ie=0;ie<=$;ie++){let ae=(($?ie/$:0)-.5)*v,me=Math.cos(ae),pe=Math.sin(ae),he=Math.atan(Math.tan(Y)*me),xe=(te+he)*le,ye=Math.cos(xe),C=Math.sin(xe);K.set(0,0,0),K.addScaledVector(H,C*me),K.addScaledVector(W,ye),K.addScaledVector(ee,C*pe),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++)}re.push(ue)}let Q=re.length-1;for(let $=0;$<Q;$++){let ue=re[$],le=re[$+1],ie=ue.length-1;l.push(ue[0],le[1],le[0]);for(let ce=1;ce<=ie;ce++)l.push(ue[ce-1],ue[ce],le[ce]),l.push(ue[ce],le[ce+1],le[ce])}}}};var Da=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),t=Object.assign(r?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof je?i.shape:new je,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(i){let r=i.shape,{width:e,height:t,cornerRadius:o,cornerType:n,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=i.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 f=[];f[0]=o[0]===0?0:d(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:d(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:d(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:d(o[3],o[3]+o[0],o[3]+o[2]);let h=u.x,m=p.x,y=p.y,b=u.y;r.addPoint(r.createPoint(h,y)),r.addPoint(r.createPoint(m,y)),r.addPoint(r.createPoint(m,b)),r.addPoint(r.createPoint(h,b)),r.isClosed=!0;let v=!0;for(let O=0,S=r.points.length;O<S;O++)r.points[O].roundness=f[O],O>0&&f[O]!==f[O-1]&&(v=!1);v&&(r.roundness=f[0]),r.useCubicForRoundedCorners=n!==1,r.update();let w=er.create({shape:r,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...i,type:"RectangleGeometry"}})}};import{BufferGeometry as O3,Float32BufferAttribute as T3,MathUtils as sb,SphereGeometry as C3}from"three";var lb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},i.parameters);return e.thetaLength=sb.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(i){let{width:r=100,height:e=r,depth:t=r,widthSegments:o=64,heightSegments:n=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:c}=i.parameters,u;return c===0?(u=new O3,u.setAttribute("position",new T3([],3))):u=new C3(.5*r,o,n,a,s,l,c*sb.DEG2RAD),u.scale(1,e/r,t/r),Object.assign(u,{userData:{...i,type:"SphereGeometry"}})}};import{PlaneGeometry as A3}from"three";var cb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:r=100,height:e=r,widthSegments:t=8,heightSegments:o=8}=i.parameters,n=new A3(r,e,t,o);return n.scale(1,1,1),Object.assign(n,{userData:{...i,type:"PlaneGeometry"}})}};import{BufferGeometry as M3,Float32BufferAttribute as Mf,Vector3 as I3}from"three";var ub=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.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(i){let{width:r,height:e,depth:t,angle:o,cornerRadius:n,cornerSegments:a}=i.parameters,s=new If(r,e,t,o,n,a);return Object.assign(s,{userData:{...i,type:"BackdropGeometry"}})}},If=class extends M3{constructor(r=1,e=1,t=1,o=90,n=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],c=[],u=.001;n==0&&(a=1),a=Math.max(1,Math.floor(a)),n=Math.min(n,100),o=Math.min(180-u,o),o*=Math.PI/180;let p=[],d=Math.PI/2,f=(Z=0,Q=0,$=0)=>new I3(Z,Q,$),h=f(),m=f(),[y,b,v]=[e/2,r/2,t/2],w=-b,O=+b,[S,T,M]=[f(w,-y,+v),f(w,-y,-v),f(w,+y,-v)],g=(Z,Q=!1)=>Math.sin(Z-Math.PI/(1+ +Q)),D=(Z,Q=!1)=>Math.cos(Z-Math.PI/(1+ +Q));M.y=Math.sin(o)*e-y;let E=Math.cos(o)*e-v,I=S.z-u;o<=d?(M.z=Math.min(E,I),M.z==I&&(M.y-=(E-I)/Math.tan(d-o))):T.z=Math.min(T.z-E-v,S.z-u),h.subVectors(S,T),m.subVectors(M,T);let N=Math.min(h.length(),m.length())*n/100,_=N*Math.tan(o/2),R=N/Math.cos(o/2),V=h.clone().normalize().add(m.normalize()).setLength(R).add(T);h.set(0,g(o,!0),D(o,!0)),p.push([M,h.clone()]);let U=(Math.PI-o)/a;for(let Z=0;Z<=a;Z++){let Q=d+o+Z*U;h.set(0,Math.sin(Q)*_,Math.cos(Q)*_),h.add(V),m.set(0,g(Q),D(Q)),p.push([h.clone(),m.clone()])}p.push([S,f(0,1,0)]);let B=Math.sin(U/2)*_*2,q=p.length-1,j=p[0][0].distanceTo(p[1][0]),F=p[q-1][0].distanceTo(p[q][0]),H=j+B*a+F;p[0].push(1);for(let Z=0;Z<=a;Z++)p[Z+1].push(1-(j+Z*B)/H);p[q].push(0);let[W,ee,te]=p[0],Y,re,K;for(let Z=1;Z<p.length;Z++)[Y,re,K]=p[Z],s.push(w,W.y,W.z,w,Y.y,Y.z,O,W.y,W.z,O,W.y,W.z,w,Y.y,Y.z,O,Y.y,Y.z),l.push(0,ee.y,ee.z,0,re.y,re.z,0,ee.y,ee.z,0,ee.y,ee.z,0,re.y,re.z,0,re.y,re.z),c.push(0,te,0,K,1,te,1,te,0,K,1,K),[W,ee,te]=[Y,re,K];this.setAttribute("position",new Mf(s,3)),this.setAttribute("normal",new Mf(l,3)),this.setAttribute("uv",new Mf(c,2))}};var Iu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof je?i.shape:new je,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:r,height:e,innerRadiusPercent:t,spikes:o,cornerRadius:n,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}=i.parameters,u=i.shape,p=r*.5,d=e*.5,f=0,h=0,m=a*Math.PI/360/o,y=Math.PI/2*3*-1,b=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=f+Math.sin(S)*p,M=h+Math.cos(S)*d;u.addPoint(u.createPoint(T,M))}}else for(let O=0;O<o;O++){let S=f+Math.cos(y)*p,T=h+Math.sin(y)*d;u.addPoint(u.createPoint(S,T)),y+=m,S=f+Math.cos(y)*b,T=h+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=n;u.roundness=n,u.update();let w=er.create({shape:u,parameters:{roundness:n,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(w,{userData:{...i,type:"StarGeometry"}})}};import{PlaneGeometry as E3}from"three";var db=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,depth:0},i.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(i){let{width:r,height:e}=i.parameters,t=new E3(r,e);return Object.assign(t,{userData:{...i,type:"TextFrameGeometry"}})}};import{BufferGeometry as N3,Float32BufferAttribute as D3,MathUtils as _3}from"three";var pb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},i.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width);e.shapeBlendNode&&(o=t);let n=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:t,height:o,depth:n})}}static build(i){let{width:r,height:e,depth:t,radialSegments:o,tubularSegments:n,arc:a,cornerRadius:s,cornerSegments:l}=i.parameters,c=R3(r,e,t,r*.5,a,n,0,0,o,s,l);return c.scale(1,e/r,1),Object.assign(c,{userData:{...i,type:"TorusGeometry"}})}};function R3(i,r,e,t,o,n,a,s,l,c,u){[r,e]=[e,r],a=r/2;let p=_3.clamp(o/360,0,1);if(p===0){let d=new N3;return d.setAttribute("position",new D3([],3)),d}return p===1&&(c=0),new ol(!0,i,r,e,t,p,n,a,s,l,c,u)}import{TorusKnotGeometry as L3}from"three";var fb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:r,tube:e,tubularSegments:t,radialSegments:o,p:n,q:a}=i.parameters,s=r*.5;s!==e&&(s-=e);let l=new L3(s,e,t,o,n,a);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var hb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof je?i.shape:new je,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(i){let{width:r=100,height:e,cornerRadius:t,depth:o,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:s}=i.parameters,l=i.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,f=l.points.length;d<f;d++)l.points[d].roundness=t;l.roundness=t,l.update();let p=er.create({shape:l,parameters:{roundness:t,depth:o,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...i,type:"TriangleGeometry"}})}};import{Vector2 as xb,Vector3 as Dt,Matrix3 as X3,Matrix4 as nn,BufferGeometry as bb,BufferAttribute as _a,MathUtils as Nu}from"three";function mb(i,r){let e=2*Math.PI;return(i%e+e)%e===(r%e+e)%e}function B3(i){return/^(rgba)?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(i.toLowerCase())}function V3(i,r,e){let t,o,n,a=Math.floor(i*6),s=i*6-a,l=e*(1-r),c=e*(1-s*r),u=e*(1-(1-s)*r);switch(a%6){case 0:t=e,o=u,n=l;break;case 1:t=c,o=e,n=l;break;case 2:t=l,o=e,n=u;break;case 3:t=l,o=c,n=e;break;case 4:t=u,o=l,n=e;break;case 5:default:t=e,o=l,n=c;break}return{r:t*255,g:o*255,b:n*255}}function z3(i,r,e){i/=255,r/=255,e/=255;let t=Math.max(i,r,e),o=Math.min(i,r,e),n=t,a=t-o,s=t==0?0:a/t,l;if(t==o)l=0;else{switch(t){case i:l=(r-e)/a+(r<e?6:0);break;case r:l=(e-i)/a+2;break;case e:default:l=(i-r)/a+4;break}l/=6}return{h:l,s,v:n}}function G3(i){return i=Math.floor(i),{r:i>>16&255,g:i>>8&255,b:i&255}}function F3(i,r,e){return(i<<16)+(r<<8)+e}function j3(i,r,e){return i=Math.round(i),r=Math.round(r),e=Math.round(e),"#"+[i,r,e].map(t=>t.toString(16).padStart(2,"0")).join("").toUpperCase()}function U3(i){let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;i=i.replace(r,(t,o,n,a)=>String(o+o+n+n+a+a));let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}var yb={parseRgba:B3,hsvToRgb:V3,rgbToHsv:z3,hexToRgb:G3,rgbToHex:F3,rgbToHexString:j3,hexStringToRgb:U3};function Fo(i){return{all:i=i||new Map,on:function(r,e){var t=i.get(r);t?t.push(e):i.set(r,[e])},off:function(r,e){var t=i.get(r);t&&(e?t.splice(t.indexOf(e)>>>0,1):i.set(r,[]))},emit:function(r,e){var t=i.get(r);t&&t.slice().map(function(o){o(e)}),(t=i.get("*"))&&t.slice().map(function(o){o(r,e)})}}}var Eu=class{constructor(r,e,t){this.id=r;this.userAPI=e;this.result=void 0;this.error="null";this.isPrefetched=!1;this.isLoading=!1;this.isLoaded=!1;this.prefetchPromise=new Promise(r=>r());this.emitter=Fo();this._innerCallUserAPI=async r=>{this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await $3(this.userAPI,r),this.error="null",this.emitter.emit("success",{userAPIId:this.id})}catch(e){let t=e.message?.split("_:_")?.[0]?.replace("status:","")??"null";this.error=t,this.result=null,this.emitter.emit("error",{userAPIId:this.id})}this.isLoading=!1,this.isPrefetched=!0,this.isLoaded=!0};e?.integration?.type==="OpenAI"?this.result={content:""}:e.method==="GET"&&e.url!==""&&(this.prefetchPromise=this.prefetch(t)),this._debouncedCallUserAPI=this._innerCallUserAPI,this._updateDebouncedCallUserAPI(),this._debouncedPrefetch=xc(this.prefetch,1e3,{trailing:!0})}_updateDebouncedCallUserAPI(){this._debouncedCallUserAPI=this.userAPI.debounce!==void 0&&this.userAPI.debounce>0?xc(this._innerCallUserAPI,this.userAPI.debounce,{leading:!0,trailing:!0}):this._innerCallUserAPI}async prefetch(r){await this.callUserAPI(r)}async callUserAPI(r){await this._debouncedCallUserAPI(r)}update(r,e,t=!0){this.userAPI=r,this._updateDebouncedCallUserAPI(),this.userAPI.url!==""&&this.userAPI.method==="GET"&&t&&this._debouncedPrefetch(e)}retrieveValue(r){if(this.result)try{return Ze.zoom(this.result,r)}catch(e){console.error(e)}}retrieveZoomedKeyValues(r){if(this.result){let e=r&&r.length?Ze.zoom(this.result,r):this.result;if(q3(e))return Object.entries(e);if(W3(e))return e.map((t,o)=>[o.toString(),t]);throw H3(e)?new Error("This path points to a value, use retrieveValue() instead. "+r?.join(".")):new Error("Path error"+r?.join("."))}}dispose(){}on(r,e){this.emitter.on(r,e)}off(r,e){this.emitter.off(r,e)}get autostart(){return this.userAPI.autoStart}};function k3(i){let r=new Headers;return i.headers.forEach(e=>{e.data.key!==""&&r.append(e.data.key,e.data.value)}),r}function H3(i){return typeof i=="string"||typeof i=="number"||typeof i=="boolean"||i===null}function W3(i){return Array.isArray(i)}function q3(i){return typeof i=="object"&&i!==null}async function $3(i,r,e=new AbortController){let t,o=i.url,n=i.proxy?.enabled??!1,a;if(i.integration?.type==="OpenAI"){let l=sl(i.integration.prompt===""?[]:JSON.parse(i.integration.prompt),r),c=i.integration.behavior===""?[]:sl(JSON.parse(i.integration.behavior),r);a=`{
1
+ var Ow=Object.create;var kl=Object.defineProperty;var Tw=Object.getOwnPropertyDescriptor;var Cw=Object.getOwnPropertyNames;var Aw=Object.getPrototypeOf,Mw=Object.prototype.hasOwnProperty;var Iw=(i,r,e)=>r in i?kl(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e;var As=(i,r)=>()=>(r||i((r={exports:{}}).exports,r),r.exports),Ew=(i,r)=>{for(var e in r)kl(i,e,{get:r[e],enumerable:!0})},Nw=(i,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Cw(r))!Mw.call(i,o)&&o!==e&&kl(i,o,{get:()=>r[o],enumerable:!(t=Tw(r,o))||t.enumerable});return i};var Ms=(i,r,e)=>(e=i!=null?Ow(Aw(i)):{},Nw(r||!i||!i.__esModule?kl(e,"default",{value:i,enumerable:!0}):e,i));var qi=(i,r,e)=>(Iw(i,typeof r!="symbol"?r+"":r,e),e);var vx=As((qp,bx)=>{(function(i,r){typeof qp=="object"?bx.exports=r():typeof define=="function"&&define.amd?define(r):i.Alea=r()})(qp,function(){"use strict";return i.importState=function(e){var t=new i;return t.importState(e),t},i;function i(){return function(e){var t=0,o=0,n=0,a=1;e.length==0&&(e=[+new Date]);var s=r();t=s(" "),o=s(" "),n=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),n-=s(e[l]),n<0&&(n+=1);s=null;var c=function(){var u=2091639*t+a*23283064365386963e-26;return t=o,o=n,n=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,n,a]},c.importState=function(u){t=+u[0]||0,o=+u[1]||0,n=+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 n=0;n<o.length;n++){e+=o.charCodeAt(n);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 Cx=As((pu,Tx)=>{(function(i,r){typeof pu=="object"&&typeof Tx<"u"?r(pu):typeof define=="function"&&define.amd?define(["exports"],r):r((i=typeof globalThis<"u"?globalThis:i||self).SVDJS={})})(pu,function(i){"use strict";i.SVD=function(r,e,t,o,n){if(e=e===void 0||e,t=t===void 0||t,n=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,f,h,m,y,b,v=r[0].length,w=r.length;if(w<v)throw new TypeError("Invalid matrix: m < n");for(var O=[],S=[],T=[],M=e==="f"?w:v,g=m=d=0;g<w;g++)S[g]=new Array(M).fill(0);for(g=0;g<v;g++)T[g]=new Array(v).fill(0);var D,E=new Array(v).fill(0);for(g=0;g<w;g++)for(a=0;a<v;a++)S[g][a]=r[g][a];for(g=0;g<v;g++){for(O[g]=d,h=0,l=g+1,a=g;a<w;a++)h+=Math.pow(S[a][g],2);if(h<n)d=0;else for(f=(p=S[g][g])*(d=p<0?Math.sqrt(h):-Math.sqrt(h))-h,S[g][g]=p-d,a=l;a<v;a++){for(h=0,s=g;s<w;s++)h+=S[s][g]*S[s][a];for(p=h/f,s=g;s<w;s++)S[s][a]=S[s][a]+p*S[s][g]}for(E[g]=d,h=0,a=l;a<v;a++)h+=Math.pow(S[g][a],2);if(h<n)d=0;else{for(f=(p=S[g][g+1])*(d=p<0?Math.sqrt(h):-Math.sqrt(h))-h,S[g][g+1]=p-d,a=l;a<v;a++)O[a]=S[g][a]/f;for(a=l;a<w;a++){for(h=0,s=l;s<v;s++)h+=S[a][s]*S[g][s];for(s=l;s<v;s++)S[a][s]=S[a][s]+h*O[s]}}m<(y=Math.abs(E[g])+Math.abs(O[g]))&&(m=y)}if(t)for(g=v-1;0<=g;g--){if(d!==0){for(f=S[g][g+1]*d,a=l;a<v;a++)T[a][g]=S[g][a]/f;for(a=l;a<v;a++){for(h=0,s=l;s<v;s++)h+=S[g][s]*T[s][a];for(s=l;s<v;s++)T[s][a]=T[s][a]+h*T[s][g]}}for(a=l;a<v;a++)T[g][a]=0,T[a][g]=0;T[g][g]=1,d=O[g],l=g}if(e){if(e==="f")for(g=v;g<w;g++){for(a=v;a<w;a++)S[g][a]=0;S[g][g]=1}for(g=v-1;0<=g;g--){for(l=g+1,d=E[g],a=l;a<M;a++)S[g][a]=0;if(d!==0){for(f=S[g][g]*d,a=l;a<M;a++){for(h=0,s=l;s<w;s++)h+=S[s][g]*S[s][a];for(p=h/f,s=g;s<w;s++)S[s][a]=S[s][a]+p*S[s][g]}for(a=g;a<w;a++)S[a][g]=S[a][g]/d}else for(a=g;a<w;a++)S[a][g]=0;S[g][g]=S[g][g]+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(E[l-1])<=o)break}if(!D){for(u=0,c=l-(h=1),g=l;g<s+1&&(p=h*O[g],O[g]=u*O[g],!(Math.abs(p)<=o));g++)if(d=E[g],E[g]=Math.sqrt(p*p+d*d),u=d/(f=E[g]),h=-p/f,e)for(a=0;a<w;a++)y=S[a][c],b=S[a][g],S[a][c]=y*u+b*h,S[a][g]=-y*h+b*u}if(b=E[s],l===s){if(b<0&&(E[s]=-b,t))for(a=0;a<v;a++)T[a][s]=-T[a][s];break}for(m=E[l],p=(((y=E[s-1])-b)*(y+b)+((d=O[s-1])-(f=O[s]))*(d+f))/(2*f*y),d=Math.sqrt(p*p+1),p=((m-b)*(m+b)+f*(y/(p<0?p-d:p+d)-f))/m,g=l+(h=u=1);g<s+1;g++){if(d=O[g],y=E[g],f=h*d,d*=u,b=Math.sqrt(p*p+f*f),p=m*(u=p/(O[g-1]=b))+d*(h=f/b),d=-m*h+d*u,f=y*h,y*=u,t)for(a=0;a<v;a++)m=T[a][g-1],b=T[a][g],T[a][g-1]=m*u+b*h,T[a][g]=-m*h+b*u;if(b=Math.sqrt(p*p+f*f),p=(u=p/(E[g-1]=b))*d+(h=f/b)*y,m=-h*d+u*y,e)for(a=0;a<w;a++)y=S[a][g-1],b=S[a][g],S[a][g-1]=y*u+b*h,S[a][g]=-y*h+b*u}O[l]=0,O[s]=p,E[s]=m}for(g=0;g<v;g++)E[g]<o&&(E[g]=0);return{u:S,q:E,v:T}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})});var U1=As((cue,j1)=>{"use strict";function eR(i,r){function e(){this.constructor=i}e.prototype=r.prototype,i.prototype=new e}function Sn(i,r,e,t){this.message=i,this.expected=r,this.found=e,this.location=t,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Sn)}eR(Sn,Error);Sn.buildMessage=function(i,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?n(c.parts[p][0])+"-"+n(c.parts[p][1]):n(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 n(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(i)+" but "+l(r)+" found."};function tR(i,r){r=r!==void 0?r:{};var e={},t={svg_path:Cs},o=Cs,n=function(x){if(!x)return[];for(var P=[],L=0;L<x.length;L++)P=P.concat.apply(P,x[L]);var A=P[0];return A&&A.code=="m"&&(delete A.relative,A.code="M"),P},a=function(x,P){return Pw(x,P)},s=/^[Mm]/,l=Ye(["M","m"],!1,!1),c=function(x,P,L){var A=An(x,[P]);return L&&(A=A.concat(An(x=="M"?"L":"l",L[1]))),A},u=/^[Zz]/,p=Ye(["Z","z"],!1,!1),d=function(){return An("Z")},f=/^[Ll]/,h=Ye(["L","l"],!1,!1),m=function(x,P){return An(x,P)},y=/^[Hh]/,b=Ye(["H","h"],!1,!1),v=function(x,P){return An(x,P.map(function(L){return{x:L}}))},w=/^[Vv]/,O=Ye(["V","v"],!1,!1),S=function(x,P){return An(x,P.map(function(L){return{y:L}}))},T=/^[Cc]/,M=Ye(["C","c"],!1,!1),g=function(x,P,L){return{x1:x.x,y1:x.y,x2:P.x,y2:P.y,x:L.x,y:L.y}},D=/^[Ss]/,E=Ye(["S","s"],!1,!1),I=function(x,P){return{x2:x.x,y2:x.y,x:P.x,y:P.y}},N=/^[Qq]/,_=Ye(["Q","q"],!1,!1),R=function(x,P){return{x1:x.x,y1:x.y,x:P.x,y:P.y}},V=/^[Tt]/,U=Ye(["T","t"],!1,!1),B=/^[Aa]/,q=Ye(["A","a"],!1,!1),j=function(x,P,L,A,z,oe){return{rx:x,ry:P,xAxisRotation:L,largeArc:A,sweep:z,x:oe.x,y:oe.y}},F=function(x,P){return{x,y:P}},H=function(x){return x*1},W=function(x){return x.join("")*1},ee=/^[01]/,te=Ye(["0","1"],!1,!1),Y=function(x){return x=="1"},re=function(){return""},K=",",Z=it(",",!1),Q=function(x){return x.join("")},$=".",ue=it(".",!1),le=/^[eE]/,ie=Ye(["e","E"],!1,!1),ce=/^[+\-]/,ae=Ye(["+","-"],!1,!1),me=/^[0-9]/,pe=Ye([["0","9"]],!1,!1),he=function(x){return x.join("")},xe=/^[ \t\n\r]/,ye=Ye([" "," ",`
2
+ `,"\r"],!1,!1),C=0,ne=0,Ne=[{line:1,column:1}],Ve=0,_e=[],Pe=0,vt;if("startRule"in r){if(!(r.startRule in t))throw new Error(`Can't start parsing from rule "`+r.startRule+'".');o=t[r.startRule]}function Me(){return i.substring(ne,C)}function xt(){return ki(ne,C)}function St(x,P){throw P=P!==void 0?P:ki(ne,C),mr([Hd(x)],i.substring(ne,C),P)}function Ui(x,P){throw P=P!==void 0?P:ki(ne,C),Wd(x,P)}function it(x,P){return{type:"literal",text:x,ignoreCase:P}}function Ye(x,P,L){return{type:"class",parts:x,inverted:P,ignoreCase:L}}function Er(){return{type:"any"}}function kd(){return{type:"end"}}function Hd(x){return{type:"other",description:x}}function zl(x){var P=Ne[x],L;if(P)return P;for(L=x-1;!Ne[L];)L--;for(P=Ne[L],P={line:P.line,column:P.column};L<x;)i.charCodeAt(L)===10?(P.line++,P.column=1):P.column++,L++;return Ne[x]=P,P}function ki(x,P){var L=zl(x),A=zl(P);return{start:{offset:x,line:L.line,column:L.column},end:{offset:P,line:A.line,column:A.column}}}function ct(x){C<Ve||(C>Ve&&(Ve=C,_e=[]),_e.push(x))}function Wd(x,P){return new Sn(x,null,null,P)}function mr(x,P,L){return new Sn(Sn.buildMessage(x,P),x,P,L)}function Cs(){var x,P,L,A,z;for(x=C,P=[],L=ze();L!==e;)P.push(L),L=ze();if(P!==e)if(L=Ht(),L===e&&(L=null),L!==e){for(A=[],z=ze();z!==e;)A.push(z),z=ze();A!==e?(ne=x,P=n(L),x=P):(C=x,x=e)}else C=x,x=e;else C=x,x=e;return x}function Ht(){var x,P,L,A,z,oe;if(x=C,P=Hi(),P!==e){for(L=[],A=C,z=[],oe=ze();oe!==e;)z.push(oe),oe=ze();for(z!==e?(oe=Hi(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;){for(L.push(A),A=C,z=[],oe=ze();oe!==e;)z.push(oe),oe=ze();z!==e?(oe=Hi(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e)}L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function Hi(){var x,P,L,A,z,oe;if(x=C,P=Tn(),P!==e){for(L=[],A=C,z=[],oe=ze();oe!==e;)z.push(oe),oe=ze();for(z!==e?(oe=Gl(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;){for(L.push(A),A=C,z=[],oe=ze();oe!==e;)z.push(oe),oe=ze();z!==e?(oe=Gl(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e)}L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function Gl(){var x;return x=lw(),x===e&&(x=cw(),x===e&&(x=uw(),x===e&&(x=dw(),x===e&&(x=pw(),x===e&&(x=hw(),x===e&&(x=yw(),x===e&&(x=xw(),x===e&&(x=vw())))))))),x}function Tn(){var x,P,L,A,z,oe,Mn;if(x=C,s.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(l)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=qt(),A!==e?(z=C,oe=tt(),oe===e&&(oe=null),oe!==e?(Mn=mm(),Mn!==e?(oe=[oe,Mn],z=oe):(C=z,z=e)):(C=z,z=e),z===e&&(z=null),z!==e?(ne=x,P=c(P,A,z),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function lw(){var x,P;return x=C,u.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(p)),P!==e&&(ne=x,P=d()),x=P,x}function cw(){var x,P,L,A;if(x=C,f.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(h)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=mm(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function mm(){var x,P,L,A,z,oe;if(x=C,P=qt(),P!==e){for(L=[],A=C,z=tt(),z===e&&(z=null),z!==e?(oe=qt(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=tt(),z===e&&(z=null),z!==e?(oe=qt(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function uw(){var x,P,L,A;if(x=C,y.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(b)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=ym(),A!==e?(ne=x,P=v(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function ym(){var x,P,L,A,z,oe;if(x=C,P=Cn(),P!==e){for(L=[],A=C,z=tt(),z===e&&(z=null),z!==e?(oe=Cn(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=tt(),z===e&&(z=null),z!==e?(oe=Cn(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function dw(){var x,P,L,A;if(x=C,w.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(O)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=ym(),A!==e?(ne=x,P=S(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function pw(){var x,P,L,A;if(x=C,T.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(M)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=fw(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function fw(){var x,P,L,A,z,oe;if(x=C,P=qd(),P!==e){for(L=[],A=C,z=tt(),z===e&&(z=null),z!==e?(oe=qd(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=tt(),z===e&&(z=null),z!==e?(oe=qd(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function qd(){var x,P,L,A,z,oe;return x=C,P=qt(),P!==e?(L=tt(),L===e&&(L=null),L!==e?(A=qt(),A!==e?(z=tt(),z===e&&(z=null),z!==e?(oe=qt(),oe!==e?(ne=x,P=g(P,A,oe),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function hw(){var x,P,L,A;if(x=C,D.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(E)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=mw(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function mw(){var x,P,L,A,z,oe;if(x=C,P=$d(),P!==e){for(L=[],A=C,z=tt(),z===e&&(z=null),z!==e?(oe=$d(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=tt(),z===e&&(z=null),z!==e?(oe=$d(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function $d(){var x,P,L,A;return x=C,P=qt(),P!==e?(L=tt(),L===e&&(L=null),L!==e?(A=qt(),A!==e?(ne=x,P=I(P,A),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function yw(){var x,P,L,A;if(x=C,N.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(_)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=gw(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function gw(){var x,P,L,A,z,oe;if(x=C,P=Xd(),P!==e){for(L=[],A=C,z=tt(),z===e&&(z=null),z!==e?(oe=Xd(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=tt(),z===e&&(z=null),z!==e?(oe=Xd(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function Xd(){var x,P,L,A;return x=C,P=qt(),P!==e?(L=tt(),L===e&&(L=null),L!==e?(A=qt(),A!==e?(ne=x,P=R(P,A),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function xw(){var x,P,L,A;if(x=C,V.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(U)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=bw(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function bw(){var x,P,L,A,z,oe;if(x=C,P=qt(),P!==e){for(L=[],A=C,z=tt(),z===e&&(z=null),z!==e?(oe=qt(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=tt(),z===e&&(z=null),z!==e?(oe=qt(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function vw(){var x,P,L,A;if(x=C,B.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(q)),P!==e){for(L=[],A=ze();A!==e;)L.push(A),A=ze();L!==e?(A=Sw(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function Sw(){var x,P,L,A,z,oe;if(x=C,P=Yd(),P!==e){for(L=[],A=C,z=tt(),z===e&&(z=null),z!==e?(oe=Yd(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=tt(),z===e&&(z=null),z!==e?(oe=Yd(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function Yd(){var x,P,L,A,z,oe,Mn,Qd,jl,Zd,Ul,Jd;return x=C,P=gm(),P!==e?(L=tt(),L===e&&(L=null),L!==e?(A=gm(),A!==e?(z=tt(),z===e&&(z=null),z!==e?(oe=Cn(),oe!==e?(Mn=tt(),Mn!==e?(Qd=xm(),Qd!==e?(jl=tt(),jl===e&&(jl=null),jl!==e?(Zd=xm(),Zd!==e?(Ul=tt(),Ul===e&&(Ul=null),Ul!==e?(Jd=qt(),Jd!==e?(ne=x,P=j(P,A,oe,Qd,Zd,Jd),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function qt(){var x,P,L,A;return x=C,P=Cn(),P!==e?(L=tt(),L===e&&(L=null),L!==e?(A=Cn(),A!==e?(ne=x,P=F(P,A),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function gm(){var x,P;return x=C,P=vm(),P===e&&(P=Wi()),P!==e&&(ne=x,P=H(P)),x=P,x}function Cn(){var x,P,L,A;return x=C,P=C,L=Kd(),L===e&&(L=null),L!==e?(A=vm(),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e),P===e&&(P=C,L=Kd(),L===e&&(L=null),L!==e?(A=Wi(),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e)),P!==e&&(ne=x,P=W(P)),x=P,x}function xm(){var x,P;return x=C,ee.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(te)),P!==e&&(ne=x,P=Y(P)),x=P,x}function tt(){var x,P,L,A,z;if(x=C,P=[],L=ze(),L!==e)for(;L!==e;)P.push(L),L=ze();else P=e;if(P!==e)if(L=bm(),L===e&&(L=null),L!==e){for(A=[],z=ze();z!==e;)A.push(z),z=ze();A!==e?(P=[P,L,A],x=P):(C=x,x=e)}else C=x,x=e;else C=x,x=e;if(x===e){if(x=C,P=C,L=bm(),L!==e){for(A=[],z=ze();z!==e;)A.push(z),z=ze();A!==e?(L=[L,A],P=L):(C=P,P=e)}else C=P,P=e;P!==e&&(ne=x,P=re()),x=P}return x}function bm(){var x;return i.charCodeAt(C)===44?(x=K,C++):(x=e,Pe===0&&ct(Z)),x}function vm(){var x,P,L,A;return x=C,P=C,L=ww(),L!==e?(A=Sm(),A===e&&(A=null),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e),P===e&&(P=C,L=Wi(),L!==e?(A=Sm(),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e)),P!==e&&(ne=x,P=Q(P)),x=P,x}function ww(){var x,P,L,A,z;return x=C,P=C,L=Wi(),L===e&&(L=null),L!==e?(i.charCodeAt(C)===46?(A=$,C++):(A=e,Pe===0&&ct(ue)),A!==e?(z=Wi(),z!==e?(L=[L,A,z],P=L):(C=P,P=e)):(C=P,P=e)):(C=P,P=e),P===e&&(P=C,L=Wi(),L!==e?(i.charCodeAt(C)===46?(A=$,C++):(A=e,Pe===0&&ct(ue)),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e)),P!==e&&(ne=x,P=Q(P)),x=P,x}function Sm(){var x,P,L,A,z;return x=C,P=C,le.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Pe===0&&ct(ie)),L!==e?(A=Kd(),A===e&&(A=null),A!==e?(z=Wi(),z!==e?(L=[L,A,z],P=L):(C=P,P=e)):(C=P,P=e)):(C=P,P=e),P!==e&&(ne=x,P=Q(P)),x=P,x}function Kd(){var x;return ce.test(i.charAt(C))?(x=i.charAt(C),C++):(x=e,Pe===0&&ct(ae)),x}function Wi(){var x,P,L;if(x=C,P=[],me.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Pe===0&&ct(pe)),L!==e)for(;L!==e;)P.push(L),me.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Pe===0&&ct(pe));else P=e;return P!==e&&(ne=x,P=he(P)),x=P,x}function ze(){var x,P;return x=C,xe.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Pe===0&&ct(ye)),P!==e&&(ne=x,P=re()),x=P,x}function Pw(x,P){if(!P)return[x];for(var L=[x],A=0,z=P.length;A<z;A++)L[A+1]=P[A][1];return L}var Fl={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 wm in Fl)Fl[wm.toUpperCase()]=Fl[wm];function An(x,P){P||(P=[{}]);for(var L=P.length;L--;){var A={code:x,command:Fl[x]};x==x.toLowerCase()&&(A.relative=!0);for(var z in P[L])A[z]=P[L][z];P[L]=A}return P}if(vt=o(),vt!==e&&C===i.length)return vt;throw vt!==e&&C<i.length&&ct(kd()),mr(_e,Ve<i.length?i.charAt(Ve):null,Ve<i.length?ki(Ve,Ve+1):ki(Ve,Ve))}j1.exports={SyntaxError:Sn,parse:tR}});var Uh=As((uue,k1)=>{var wd=U1().parse;wd.parseSVG=wd;wd.makeAbsolute=rR;k1.exports=wd;function rR(i){var r,e={x:0,y:0},t={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return i.forEach(function(o){o.command==="moveto"&&(r=o),o.x0=e.x,o.y0=e.y;for(var n in t)n in o&&(o[n]+=o.relative?o[t[n]]: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}),i}});var nw=As((Nge,iw)=>{iw.exports=function(r,e){for(var t=r.split("."),o=e.split("."),n=0;n<3;n++){var a=Number(t[n]),s=Number(o[n]);if(a>s)return 1;if(s>a)return-1;if(!isNaN(a)&&isNaN(s))return 1;if(isNaN(a)&&!isNaN(s))return-1}return 0}});import{FileLoader as iB,Loader as nB}from"three";function Hl(i){for(let r of Object.keys(i))i[r]===void 0&&delete i[r];return i}function Bt(i,r){return Object.setPrototypeOf(i,r),i}function Wl(i){return Array.isArray(i)?i:[i]}function ql(i,r){let e=0;for(;e<i.length&&e<r.length;){if(i[e]<r[e])return-1;if(i[e]>r[e])return 1;e+=1}return e!==r.length?-1:e!==i.length?1:0}var Dw=typeof global=="object"&&global&&global.Object===Object&&global,$l=Dw;var _w=typeof self=="object"&&self&&self.Object===Object&&self,Rw=$l||_w||Function("return this")(),ut=Rw;var Lw=ut.Symbol,Mt=Lw;var Pm=Object.prototype,Bw=Pm.hasOwnProperty,Vw=Pm.toString,Is=Mt?Mt.toStringTag:void 0;function zw(i){var r=Bw.call(i,Is),e=i[Is];try{i[Is]=void 0;var t=!0}catch{}var o=Vw.call(i);return t&&(r?i[Is]=e:delete i[Is]),o}var Om=zw;var Gw=Object.prototype,Fw=Gw.toString;function jw(i){return Fw.call(i)}var Tm=jw;var Uw="[object Null]",kw="[object Undefined]",Cm=Mt?Mt.toStringTag:void 0;function Hw(i){return i==null?i===void 0?kw:Uw:Cm&&Cm in Object(i)?Om(i):Tm(i)}var lr=Hw;function Ww(i){return i!=null&&typeof i=="object"}var Vt=Ww;var qw="[object Symbol]";function $w(i){return typeof i=="symbol"||Vt(i)&&lr(i)==qw}var ei=$w;function Xw(i,r){for(var e=-1,t=i==null?0:i.length,o=Array(t);++e<t;)o[e]=r(i[e],e,i);return o}var Xl=Xw;var Yw=Array.isArray,dt=Yw;var Kw=1/0,Am=Mt?Mt.prototype:void 0,Mm=Am?Am.toString:void 0;function Im(i){if(typeof i=="string")return i;if(dt(i))return Xl(i,Im)+"";if(ei(i))return Mm?Mm.call(i):"";var r=i+"";return r=="0"&&1/i==-Kw?"-0":r}var Yl=Im;var Qw=/\s/;function Zw(i){for(var r=i.length;r--&&Qw.test(i.charAt(r)););return r}var Kl=Zw;var Jw=/^\s+/;function e2(i){return i&&i.slice(0,Kl(i)+1).replace(Jw,"")}var Em=e2;function t2(i){var r=typeof i;return i!=null&&(r=="object"||r=="function")}var It=t2;var Nm=0/0,r2=/^[-+]0x[0-9a-f]+$/i,o2=/^0b[01]+$/i,i2=/^0o[0-7]+$/i,n2=parseInt;function a2(i){if(typeof i=="number")return i;if(ei(i))return Nm;if(It(i)){var r=typeof i.valueOf=="function"?i.valueOf():i;i=It(r)?r+"":r}if(typeof i!="string")return i===0?i:+i;i=Em(i);var e=o2.test(i);return e||i2.test(i)?n2(i.slice(2),e?2:8):r2.test(i)?Nm:+i}var ep=a2;function s2(i){return i}var Dm=s2;var l2="[object AsyncFunction]",c2="[object Function]",u2="[object GeneratorFunction]",d2="[object Proxy]";function p2(i){if(!It(i))return!1;var r=lr(i);return r==c2||r==u2||r==l2||r==d2}var Ql=p2;var f2=ut["__core-js_shared__"],Zl=f2;var _m=function(){var i=/[^.]+$/.exec(Zl&&Zl.keys&&Zl.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function h2(i){return!!_m&&_m in i}var Rm=h2;var m2=Function.prototype,y2=m2.toString;function g2(i){if(i!=null){try{return y2.call(i)}catch{}try{return i+""}catch{}}return""}var Oo=g2;var x2=/[\\^$.*+?()[\]{}|]/g,b2=/^\[object .+?Constructor\]$/,v2=Function.prototype,S2=Object.prototype,w2=v2.toString,P2=S2.hasOwnProperty,O2=RegExp("^"+w2.call(P2).replace(x2,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function T2(i){if(!It(i)||Rm(i))return!1;var r=Ql(i)?O2:b2;return r.test(Oo(i))}var Lm=T2;function C2(i,r){return i?.[r]}var Bm=C2;function A2(i,r){var e=Bm(i,r);return Lm(e)?e:void 0}var Zt=A2;var M2=Zt(ut,"WeakMap"),Jl=M2;var Vm=Object.create,I2=function(){function i(){}return function(r){if(!It(r))return{};if(Vm)return Vm(r);i.prototype=r;var e=new i;return i.prototype=void 0,e}}(),zm=I2;function E2(i,r,e){switch(e.length){case 0:return i.call(r);case 1:return i.call(r,e[0]);case 2:return i.call(r,e[0],e[1]);case 3:return i.call(r,e[0],e[1],e[2])}return i.apply(r,e)}var Gm=E2;function N2(i,r){var e=-1,t=i.length;for(r||(r=Array(t));++e<t;)r[e]=i[e];return r}var Fm=N2;var D2=800,_2=16,R2=Date.now;function L2(i){var r=0,e=0;return function(){var t=R2(),o=_2-(t-e);if(e=t,o>0){if(++r>=D2)return arguments[0]}else r=0;return i.apply(void 0,arguments)}}var jm=L2;function B2(i){return function(){return i}}var Um=B2;var V2=function(){try{var i=Zt(Object,"defineProperty");return i({},"",{}),i}catch{}}(),In=V2;var z2=In?function(i,r){return In(i,"toString",{configurable:!0,enumerable:!1,value:Um(r),writable:!0})}:Dm,km=z2;var G2=jm(km),Hm=G2;function F2(i,r){for(var e=-1,t=i==null?0:i.length;++e<t&&r(i[e],e,i)!==!1;);return i}var Wm=F2;function j2(i,r,e,t){for(var o=i.length,n=e+(t?1:-1);t?n--:++n<o;)if(r(i[n],n,i))return n;return-1}var qm=j2;function U2(i){return i!==i}var $m=U2;function k2(i,r,e){for(var t=e-1,o=i.length;++t<o;)if(i[t]===r)return t;return-1}var Xm=k2;function H2(i,r,e){return r===r?Xm(i,r,e):qm(i,$m,e)}var Ym=H2;var W2=9007199254740991,q2=/^(?:0|[1-9]\d*)$/;function $2(i,r){var e=typeof i;return r=r??W2,!!r&&(e=="number"||e!="symbol"&&q2.test(i))&&i>-1&&i%1==0&&i<r}var En=$2;function X2(i,r,e){r=="__proto__"&&In?In(i,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[r]=e}var ec=X2;function Y2(i,r){return i===r||i!==i&&r!==r}var Nn=Y2;var K2=Object.prototype,Q2=K2.hasOwnProperty;function Z2(i,r,e){var t=i[r];(!(Q2.call(i,r)&&Nn(t,e))||e===void 0&&!(r in i))&&ec(i,r,e)}var Dn=Z2;function J2(i,r,e,t){var o=!e;e||(e={});for(var n=-1,a=r.length;++n<a;){var s=r[n],l=t?t(e[s],i[s],s,e,i):void 0;l===void 0&&(l=i[s]),o?ec(e,s,l):Dn(e,s,l)}return e}var Yr=J2;var Km=Math.max;function eP(i,r,e){return r=Km(r===void 0?i.length-1:r,0),function(){for(var t=arguments,o=-1,n=Km(t.length-r,0),a=Array(n);++o<n;)a[o]=t[r+o];o=-1;for(var s=Array(r+1);++o<r;)s[o]=t[o];return s[r]=e(a),Gm(i,this,s)}}var Qm=eP;var tP=9007199254740991;function rP(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=tP}var _n=rP;function oP(i){return i!=null&&_n(i.length)&&!Ql(i)}var tc=oP;var iP=Object.prototype;function nP(i){var r=i&&i.constructor,e=typeof r=="function"&&r.prototype||iP;return i===e}var Rn=nP;function aP(i,r){for(var e=-1,t=Array(i);++e<i;)t[e]=r(e);return t}var Zm=aP;var sP="[object Arguments]";function lP(i){return Vt(i)&&lr(i)==sP}var tp=lP;var Jm=Object.prototype,cP=Jm.hasOwnProperty,uP=Jm.propertyIsEnumerable,dP=tp(function(){return arguments}())?tp:function(i){return Vt(i)&&cP.call(i,"callee")&&!uP.call(i,"callee")},Ln=dP;function pP(){return!1}var ey=pP;var oy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ty=oy&&typeof module=="object"&&module&&!module.nodeType&&module,fP=ty&&ty.exports===oy,ry=fP?ut.Buffer:void 0,hP=ry?ry.isBuffer:void 0,mP=hP||ey,$i=mP;var yP="[object Arguments]",gP="[object Array]",xP="[object Boolean]",bP="[object Date]",vP="[object Error]",SP="[object Function]",wP="[object Map]",PP="[object Number]",OP="[object Object]",TP="[object RegExp]",CP="[object Set]",AP="[object String]",MP="[object WeakMap]",IP="[object ArrayBuffer]",EP="[object DataView]",NP="[object Float32Array]",DP="[object Float64Array]",_P="[object Int8Array]",RP="[object Int16Array]",LP="[object Int32Array]",BP="[object Uint8Array]",VP="[object Uint8ClampedArray]",zP="[object Uint16Array]",GP="[object Uint32Array]",rt={};rt[NP]=rt[DP]=rt[_P]=rt[RP]=rt[LP]=rt[BP]=rt[VP]=rt[zP]=rt[GP]=!0;rt[yP]=rt[gP]=rt[IP]=rt[xP]=rt[EP]=rt[bP]=rt[vP]=rt[SP]=rt[wP]=rt[PP]=rt[OP]=rt[TP]=rt[CP]=rt[AP]=rt[MP]=!1;function FP(i){return Vt(i)&&_n(i.length)&&!!rt[lr(i)]}var iy=FP;function jP(i){return function(r){return i(r)}}var Bn=jP;var ny=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Es=ny&&typeof module=="object"&&module&&!module.nodeType&&module,UP=Es&&Es.exports===ny,rp=UP&&$l.process,kP=function(){try{var i=Es&&Es.require&&Es.require("util").types;return i||rp&&rp.binding&&rp.binding("util")}catch{}}(),To=kP;var ay=To&&To.isTypedArray,HP=ay?Bn(ay):iy,rc=HP;var WP=Object.prototype,qP=WP.hasOwnProperty;function $P(i,r){var e=dt(i),t=!e&&Ln(i),o=!e&&!t&&$i(i),n=!e&&!t&&!o&&rc(i),a=e||t||o||n,s=a?Zm(i.length,String):[],l=s.length;for(var c in i)(r||qP.call(i,c))&&!(a&&(c=="length"||o&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||En(c,l)))&&s.push(c);return s}var oc=$P;function XP(i,r){return function(e){return i(r(e))}}var ic=XP;var YP=ic(Object.keys,Object),sy=YP;var KP=Object.prototype,QP=KP.hasOwnProperty;function ZP(i){if(!Rn(i))return sy(i);var r=[];for(var e in Object(i))QP.call(i,e)&&e!="constructor"&&r.push(e);return r}var ly=ZP;function JP(i){return tc(i)?oc(i):ly(i)}var Vn=JP;function eO(i){var r=[];if(i!=null)for(var e in Object(i))r.push(e);return r}var cy=eO;var tO=Object.prototype,rO=tO.hasOwnProperty;function oO(i){if(!It(i))return cy(i);var r=Rn(i),e=[];for(var t in i)t=="constructor"&&(r||!rO.call(i,t))||e.push(t);return e}var uy=oO;function iO(i){return tc(i)?oc(i,!0):uy(i)}var zn=iO;var nO=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,aO=/^\w*$/;function sO(i,r){if(dt(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||ei(i)?!0:aO.test(i)||!nO.test(i)||r!=null&&i in Object(r)}var dy=sO;var lO=Zt(Object,"create"),Co=lO;function cO(){this.__data__=Co?Co(null):{},this.size=0}var py=cO;function uO(i){var r=this.has(i)&&delete this.__data__[i];return this.size-=r?1:0,r}var fy=uO;var dO="__lodash_hash_undefined__",pO=Object.prototype,fO=pO.hasOwnProperty;function hO(i){var r=this.__data__;if(Co){var e=r[i];return e===dO?void 0:e}return fO.call(r,i)?r[i]:void 0}var hy=hO;var mO=Object.prototype,yO=mO.hasOwnProperty;function gO(i){var r=this.__data__;return Co?r[i]!==void 0:yO.call(r,i)}var my=gO;var xO="__lodash_hash_undefined__";function bO(i,r){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=Co&&r===void 0?xO:r,this}var yy=bO;function Gn(i){var r=-1,e=i==null?0:i.length;for(this.clear();++r<e;){var t=i[r];this.set(t[0],t[1])}}Gn.prototype.clear=py;Gn.prototype.delete=fy;Gn.prototype.get=hy;Gn.prototype.has=my;Gn.prototype.set=yy;var op=Gn;function vO(){this.__data__=[],this.size=0}var gy=vO;function SO(i,r){for(var e=i.length;e--;)if(Nn(i[e][0],r))return e;return-1}var ti=SO;var wO=Array.prototype,PO=wO.splice;function OO(i){var r=this.__data__,e=ti(r,i);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():PO.call(r,e,1),--this.size,!0}var xy=OO;function TO(i){var r=this.__data__,e=ti(r,i);return e<0?void 0:r[e][1]}var by=TO;function CO(i){return ti(this.__data__,i)>-1}var vy=CO;function AO(i,r){var e=this.__data__,t=ti(e,i);return t<0?(++this.size,e.push([i,r])):e[t][1]=r,this}var Sy=AO;function Fn(i){var r=-1,e=i==null?0:i.length;for(this.clear();++r<e;){var t=i[r];this.set(t[0],t[1])}}Fn.prototype.clear=gy;Fn.prototype.delete=xy;Fn.prototype.get=by;Fn.prototype.has=vy;Fn.prototype.set=Sy;var ri=Fn;var MO=Zt(ut,"Map"),oi=MO;function IO(){this.size=0,this.__data__={hash:new op,map:new(oi||ri),string:new op}}var wy=IO;function EO(i){var r=typeof i;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?i!=="__proto__":i===null}var Py=EO;function NO(i,r){var e=i.__data__;return Py(r)?e[typeof r=="string"?"string":"hash"]:e.map}var ii=NO;function DO(i){var r=ii(this,i).delete(i);return this.size-=r?1:0,r}var Oy=DO;function _O(i){return ii(this,i).get(i)}var Ty=_O;function RO(i){return ii(this,i).has(i)}var Cy=RO;function LO(i,r){var e=ii(this,i),t=e.size;return e.set(i,r),this.size+=e.size==t?0:1,this}var Ay=LO;function jn(i){var r=-1,e=i==null?0:i.length;for(this.clear();++r<e;){var t=i[r];this.set(t[0],t[1])}}jn.prototype.clear=wy;jn.prototype.delete=Oy;jn.prototype.get=Ty;jn.prototype.has=Cy;jn.prototype.set=Ay;var Xi=jn;var BO="Expected a function";function ip(i,r){if(typeof i!="function"||r!=null&&typeof r!="function")throw new TypeError(BO);var e=function(){var t=arguments,o=r?r.apply(this,t):t[0],n=e.cache;if(n.has(o))return n.get(o);var a=i.apply(this,t);return e.cache=n.set(o,a)||n,a};return e.cache=new(ip.Cache||Xi),e}ip.Cache=Xi;var My=ip;var VO=500;function zO(i){var r=My(i,function(t){return e.size===VO&&e.clear(),t}),e=r.cache;return r}var Iy=zO;var GO=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,FO=/\\(\\)?/g,jO=Iy(function(i){var r=[];return i.charCodeAt(0)===46&&r.push(""),i.replace(GO,function(e,t,o,n){r.push(o?n.replace(FO,"$1"):t||e)}),r}),Ey=jO;function UO(i){return i==null?"":Yl(i)}var nc=UO;function kO(i,r){return dt(i)?i:dy(i,r)?[i]:Ey(nc(i))}var yr=kO;var HO=1/0;function WO(i){if(typeof i=="string"||ei(i))return i;var r=i+"";return r=="0"&&1/i==-HO?"-0":r}var ni=WO;function qO(i,r){r=yr(r,i);for(var e=0,t=r.length;i!=null&&e<t;)i=i[ni(r[e++])];return e&&e==t?i:void 0}var ac=qO;function $O(i,r){for(var e=-1,t=r.length,o=i.length;++e<t;)i[o+e]=r[e];return i}var Un=$O;var Ny=Mt?Mt.isConcatSpreadable:void 0;function XO(i){return dt(i)||Ln(i)||!!(Ny&&i&&i[Ny])}var Dy=XO;function _y(i,r,e,t,o){var n=-1,a=i.length;for(e||(e=Dy),o||(o=[]);++n<a;){var s=i[n];r>0&&e(s)?r>1?_y(s,r-1,e,t,o):Un(o,s):t||(o[o.length]=s)}return o}var Ry=_y;function YO(i){var r=i==null?0:i.length;return r?Ry(i,1):[]}var Ly=YO;function KO(i){return Hm(Qm(i,void 0,Ly),i+"")}var sc=KO;var QO=ic(Object.getPrototypeOf,Object),kn=QO;var ZO="[object Object]",JO=Function.prototype,eT=Object.prototype,By=JO.toString,tT=eT.hasOwnProperty,rT=By.call(Object);function oT(i){if(!Vt(i)||lr(i)!=ZO)return!1;var r=kn(i);if(r===null)return!0;var e=tT.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&By.call(e)==rT}var Vy=oT;function iT(i,r,e){var t=-1,o=i.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 n=Array(o);++t<o;)n[t]=i[t+r];return n}var lc=iT;function nT(i,r,e){var t=i.length;return e=e===void 0?t:e,!r&&e>=t?i:lc(i,r,e)}var zy=nT;var aT="\\ud800-\\udfff",sT="\\u0300-\\u036f",lT="\\ufe20-\\ufe2f",cT="\\u20d0-\\u20ff",uT=sT+lT+cT,dT="\\ufe0e\\ufe0f",pT="\\u200d",fT=RegExp("["+pT+aT+uT+dT+"]");function hT(i){return fT.test(i)}var Gy=hT;function mT(i){return i.split("")}var Fy=mT;var jy="\\ud800-\\udfff",yT="\\u0300-\\u036f",gT="\\ufe20-\\ufe2f",xT="\\u20d0-\\u20ff",bT=yT+gT+xT,vT="\\ufe0e\\ufe0f",ST="["+jy+"]",np="["+bT+"]",ap="\\ud83c[\\udffb-\\udfff]",wT="(?:"+np+"|"+ap+")",Uy="[^"+jy+"]",ky="(?:\\ud83c[\\udde6-\\uddff]){2}",Hy="[\\ud800-\\udbff][\\udc00-\\udfff]",PT="\\u200d",Wy=wT+"?",qy="["+vT+"]?",OT="(?:"+PT+"(?:"+[Uy,ky,Hy].join("|")+")"+qy+Wy+")*",TT=qy+Wy+OT,CT="(?:"+[Uy+np+"?",np,ky,Hy,ST].join("|")+")",AT=RegExp(ap+"(?="+ap+")|"+CT+TT,"g");function MT(i){return i.match(AT)||[]}var $y=MT;function IT(i){return Gy(i)?$y(i):Fy(i)}var sp=IT;function ET(){this.__data__=new ri,this.size=0}var Xy=ET;function NT(i){var r=this.__data__,e=r.delete(i);return this.size=r.size,e}var Yy=NT;function DT(i){return this.__data__.get(i)}var Ky=DT;function _T(i){return this.__data__.has(i)}var Qy=_T;var RT=200;function LT(i,r){var e=this.__data__;if(e instanceof ri){var t=e.__data__;if(!oi||t.length<RT-1)return t.push([i,r]),this.size=++e.size,this;e=this.__data__=new Xi(t)}return e.set(i,r),this.size=e.size,this}var Zy=LT;function Hn(i){var r=this.__data__=new ri(i);this.size=r.size}Hn.prototype.clear=Xy;Hn.prototype.delete=Yy;Hn.prototype.get=Ky;Hn.prototype.has=Qy;Hn.prototype.set=Zy;var Wn=Hn;function BT(i,r){return i&&Yr(r,Vn(r),i)}var Jy=BT;function VT(i,r){return i&&Yr(r,zn(r),i)}var eg=VT;var ig=typeof exports=="object"&&exports&&!exports.nodeType&&exports,tg=ig&&typeof module=="object"&&module&&!module.nodeType&&module,zT=tg&&tg.exports===ig,rg=zT?ut.Buffer:void 0,og=rg?rg.allocUnsafe:void 0;function GT(i,r){if(r)return i.slice();var e=i.length,t=og?og(e):new i.constructor(e);return i.copy(t),t}var ng=GT;function FT(i,r){for(var e=-1,t=i==null?0:i.length,o=0,n=[];++e<t;){var a=i[e];r(a,e,i)&&(n[o++]=a)}return n}var ag=FT;function jT(){return[]}var cc=jT;var UT=Object.prototype,kT=UT.propertyIsEnumerable,sg=Object.getOwnPropertySymbols,HT=sg?function(i){return i==null?[]:(i=Object(i),ag(sg(i),function(r){return kT.call(i,r)}))}:cc,qn=HT;function WT(i,r){return Yr(i,qn(i),r)}var lg=WT;var qT=Object.getOwnPropertySymbols,$T=qT?function(i){for(var r=[];i;)Un(r,qn(i)),i=kn(i);return r}:cc,uc=$T;function XT(i,r){return Yr(i,uc(i),r)}var cg=XT;function YT(i,r,e){var t=r(i);return dt(i)?t:Un(t,e(i))}var dc=YT;function KT(i){return dc(i,Vn,qn)}var Ns=KT;function QT(i){return dc(i,zn,uc)}var pc=QT;var ZT=Zt(ut,"DataView"),fc=ZT;var JT=Zt(ut,"Promise"),hc=JT;var eC=Zt(ut,"Set"),mc=eC;var ug="[object Map]",tC="[object Object]",dg="[object Promise]",pg="[object Set]",fg="[object WeakMap]",hg="[object DataView]",rC=Oo(fc),oC=Oo(oi),iC=Oo(hc),nC=Oo(mc),aC=Oo(Jl),Yi=lr;(fc&&Yi(new fc(new ArrayBuffer(1)))!=hg||oi&&Yi(new oi)!=ug||hc&&Yi(hc.resolve())!=dg||mc&&Yi(new mc)!=pg||Jl&&Yi(new Jl)!=fg)&&(Yi=function(i){var r=lr(i),e=r==tC?i.constructor:void 0,t=e?Oo(e):"";if(t)switch(t){case rC:return hg;case oC:return ug;case iC:return dg;case nC:return pg;case aC:return fg}return r});var Ao=Yi;var sC=Object.prototype,lC=sC.hasOwnProperty;function cC(i){var r=i.length,e=new i.constructor(r);return r&&typeof i[0]=="string"&&lC.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var mg=cC;var uC=ut.Uint8Array,$n=uC;function dC(i){var r=new i.constructor(i.byteLength);return new $n(r).set(new $n(i)),r}var Xn=dC;function pC(i,r){var e=r?Xn(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var yg=pC;var fC=/\w*$/;function hC(i){var r=new i.constructor(i.source,fC.exec(i));return r.lastIndex=i.lastIndex,r}var gg=hC;var xg=Mt?Mt.prototype:void 0,bg=xg?xg.valueOf:void 0;function mC(i){return bg?Object(bg.call(i)):{}}var vg=mC;function yC(i,r){var e=r?Xn(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var Sg=yC;var gC="[object Boolean]",xC="[object Date]",bC="[object Map]",vC="[object Number]",SC="[object RegExp]",wC="[object Set]",PC="[object String]",OC="[object Symbol]",TC="[object ArrayBuffer]",CC="[object DataView]",AC="[object Float32Array]",MC="[object Float64Array]",IC="[object Int8Array]",EC="[object Int16Array]",NC="[object Int32Array]",DC="[object Uint8Array]",_C="[object Uint8ClampedArray]",RC="[object Uint16Array]",LC="[object Uint32Array]";function BC(i,r,e){var t=i.constructor;switch(r){case TC:return Xn(i);case gC:case xC:return new t(+i);case CC:return yg(i,e);case AC:case MC:case IC:case EC:case NC:case DC:case _C:case RC:case LC:return Sg(i,e);case bC:return new t;case vC:case PC:return new t(i);case SC:return gg(i);case wC:return new t;case OC:return vg(i)}}var wg=BC;function VC(i){return typeof i.constructor=="function"&&!Rn(i)?zm(kn(i)):{}}var Pg=VC;var zC="[object Map]";function GC(i){return Vt(i)&&Ao(i)==zC}var Og=GC;var Tg=To&&To.isMap,FC=Tg?Bn(Tg):Og,Cg=FC;var jC="[object Set]";function UC(i){return Vt(i)&&Ao(i)==jC}var Ag=UC;var Mg=To&&To.isSet,kC=Mg?Bn(Mg):Ag,Ig=kC;var HC=1,WC=2,qC=4,Eg="[object Arguments]",$C="[object Array]",XC="[object Boolean]",YC="[object Date]",KC="[object Error]",Ng="[object Function]",QC="[object GeneratorFunction]",ZC="[object Map]",JC="[object Number]",Dg="[object Object]",eA="[object RegExp]",tA="[object Set]",rA="[object String]",oA="[object Symbol]",iA="[object WeakMap]",nA="[object ArrayBuffer]",aA="[object DataView]",sA="[object Float32Array]",lA="[object Float64Array]",cA="[object Int8Array]",uA="[object Int16Array]",dA="[object Int32Array]",pA="[object Uint8Array]",fA="[object Uint8ClampedArray]",hA="[object Uint16Array]",mA="[object Uint32Array]",Je={};Je[Eg]=Je[$C]=Je[nA]=Je[aA]=Je[XC]=Je[YC]=Je[sA]=Je[lA]=Je[cA]=Je[uA]=Je[dA]=Je[ZC]=Je[JC]=Je[Dg]=Je[eA]=Je[tA]=Je[rA]=Je[oA]=Je[pA]=Je[fA]=Je[hA]=Je[mA]=!0;Je[KC]=Je[Ng]=Je[iA]=!1;function yc(i,r,e,t,o,n){var a,s=r&HC,l=r&WC,c=r&qC;if(e&&(a=o?e(i,t,o,n):e(i)),a!==void 0)return a;if(!It(i))return i;var u=dt(i);if(u){if(a=mg(i),!s)return Fm(i,a)}else{var p=Ao(i),d=p==Ng||p==QC;if($i(i))return ng(i,s);if(p==Dg||p==Eg||d&&!o){if(a=l||d?{}:Pg(i),!s)return l?cg(i,eg(a,i)):lg(i,Jy(a,i))}else{if(!Je[p])return o?i:{};a=wg(i,p,s)}}n||(n=new Wn);var f=n.get(i);if(f)return f;n.set(i,a),Ig(i)?i.forEach(function(y){a.add(yc(y,r,e,y,i,n))}):Cg(i)&&i.forEach(function(y,b){a.set(b,yc(y,r,e,b,i,n))});var h=c?l?pc:Ns:l?zn:Vn,m=u?void 0:h(i);return Wm(m||i,function(y,b){m&&(b=y,y=i[b]),Dn(a,b,yc(y,r,e,b,i,n))}),a}var gc=yc;var yA=1,gA=4;function xA(i){return gc(i,yA|gA)}var Mo=xA;var bA="__lodash_hash_undefined__";function vA(i){return this.__data__.set(i,bA),this}var _g=vA;function SA(i){return this.__data__.has(i)}var Rg=SA;function xc(i){var r=-1,e=i==null?0:i.length;for(this.__data__=new Xi;++r<e;)this.add(i[r])}xc.prototype.add=xc.prototype.push=_g;xc.prototype.has=Rg;var Lg=xc;function wA(i,r){for(var e=-1,t=i==null?0:i.length;++e<t;)if(r(i[e],e,i))return!0;return!1}var Bg=wA;function PA(i,r){return i.has(r)}var Vg=PA;var OA=1,TA=2;function CA(i,r,e,t,o,n){var a=e&OA,s=i.length,l=r.length;if(s!=l&&!(a&&l>s))return!1;var c=n.get(i),u=n.get(r);if(c&&u)return c==r&&u==i;var p=-1,d=!0,f=e&TA?new Lg:void 0;for(n.set(i,r),n.set(r,i);++p<s;){var h=i[p],m=r[p];if(t)var y=a?t(m,h,p,r,i,n):t(h,m,p,i,r,n);if(y!==void 0){if(y)continue;d=!1;break}if(f){if(!Bg(r,function(b,v){if(!Vg(f,v)&&(h===b||o(h,b,e,t,n)))return f.push(v)})){d=!1;break}}else if(!(h===m||o(h,m,e,t,n))){d=!1;break}}return n.delete(i),n.delete(r),d}var bc=CA;function AA(i){var r=-1,e=Array(i.size);return i.forEach(function(t,o){e[++r]=[o,t]}),e}var zg=AA;function MA(i){var r=-1,e=Array(i.size);return i.forEach(function(t){e[++r]=t}),e}var Gg=MA;var IA=1,EA=2,NA="[object Boolean]",DA="[object Date]",_A="[object Error]",RA="[object Map]",LA="[object Number]",BA="[object RegExp]",VA="[object Set]",zA="[object String]",GA="[object Symbol]",FA="[object ArrayBuffer]",jA="[object DataView]",Fg=Mt?Mt.prototype:void 0,lp=Fg?Fg.valueOf:void 0;function UA(i,r,e,t,o,n,a){switch(e){case jA:if(i.byteLength!=r.byteLength||i.byteOffset!=r.byteOffset)return!1;i=i.buffer,r=r.buffer;case FA:return!(i.byteLength!=r.byteLength||!n(new $n(i),new $n(r)));case NA:case DA:case LA:return Nn(+i,+r);case _A:return i.name==r.name&&i.message==r.message;case BA:case zA:return i==r+"";case RA:var s=zg;case VA:var l=t&IA;if(s||(s=Gg),i.size!=r.size&&!l)return!1;var c=a.get(i);if(c)return c==r;t|=EA,a.set(i,r);var u=bc(s(i),s(r),t,o,n,a);return a.delete(i),u;case GA:if(lp)return lp.call(i)==lp.call(r)}return!1}var jg=UA;var kA=1,HA=Object.prototype,WA=HA.hasOwnProperty;function qA(i,r,e,t,o,n){var a=e&kA,s=Ns(i),l=s.length,c=Ns(r),u=c.length;if(l!=u&&!a)return!1;for(var p=l;p--;){var d=s[p];if(!(a?d in r:WA.call(r,d)))return!1}var f=n.get(i),h=n.get(r);if(f&&h)return f==r&&h==i;var m=!0;n.set(i,r),n.set(r,i);for(var y=a;++p<l;){d=s[p];var b=i[d],v=r[d];if(t)var w=a?t(v,b,d,r,i,n):t(b,v,d,i,r,n);if(!(w===void 0?b===v||o(b,v,e,t,n):w)){m=!1;break}y||(y=d=="constructor")}if(m&&!y){var O=i.constructor,S=r.constructor;O!=S&&"constructor"in i&&"constructor"in r&&!(typeof O=="function"&&O instanceof O&&typeof S=="function"&&S instanceof S)&&(m=!1)}return n.delete(i),n.delete(r),m}var Ug=qA;var $A=1,kg="[object Arguments]",Hg="[object Array]",vc="[object Object]",XA=Object.prototype,Wg=XA.hasOwnProperty;function YA(i,r,e,t,o,n){var a=dt(i),s=dt(r),l=a?Hg:Ao(i),c=s?Hg:Ao(r);l=l==kg?vc:l,c=c==kg?vc:c;var u=l==vc,p=c==vc,d=l==c;if(d&&$i(i)){if(!$i(r))return!1;a=!0,u=!1}if(d&&!u)return n||(n=new Wn),a||rc(i)?bc(i,r,e,t,o,n):jg(i,r,l,e,t,o,n);if(!(e&$A)){var f=u&&Wg.call(i,"__wrapped__"),h=p&&Wg.call(r,"__wrapped__");if(f||h){var m=f?i.value():i,y=h?r.value():r;return n||(n=new Wn),o(m,y,e,t,n)}}return d?(n||(n=new Wn),Ug(i,r,e,t,o,n)):!1}var qg=YA;function $g(i,r,e,t,o){return i===r?!0:i==null||r==null||!Vt(i)&&!Vt(r)?i!==i&&r!==r:qg(i,r,e,t,$g,o)}var Xg=$g;function KA(i,r){return i!=null&&r in Object(i)}var Yg=KA;function QA(i,r,e){r=yr(r,i);for(var t=-1,o=r.length,n=!1;++t<o;){var a=ni(r[t]);if(!(n=i!=null&&e(i,a)))break;i=i[a]}return n||++t!=o?n:(o=i==null?0:i.length,!!o&&_n(o)&&En(a,o)&&(dt(i)||Ln(i)))}var Kg=QA;function ZA(i,r){return i!=null&&Kg(i,r,Yg)}var Qg=ZA;var JA=function(){return ut.Date.now()},Sc=JA;var eM="Expected a function",tM=Math.max,rM=Math.min;function oM(i,r,e){var t,o,n,a,s,l,c=0,u=!1,p=!1,d=!0;if(typeof i!="function")throw new TypeError(eM);r=ep(r)||0,It(e)&&(u=!!e.leading,p="maxWait"in e,n=p?tM(ep(e.maxWait)||0,r):n,d="trailing"in e?!!e.trailing:d);function f(T){var M=t,g=o;return t=o=void 0,c=T,a=i.apply(g,M),a}function h(T){return c=T,s=setTimeout(b,r),u?f(T):a}function m(T){var M=T-l,g=T-c,D=r-M;return p?rM(D,n-g):D}function y(T){var M=T-l,g=T-c;return l===void 0||M>=r||M<0||p&&g>=n}function b(){var T=Sc();if(y(T))return v(T);s=setTimeout(b,m(T))}function v(T){return s=void 0,d&&t?f(T):(t=o=void 0,a)}function w(){s!==void 0&&clearTimeout(s),c=0,t=l=o=s=void 0}function O(){return s===void 0?a:v(Sc())}function S(){var T=Sc(),M=y(T);if(t=arguments,o=this,l=T,M){if(s===void 0)return h(l);if(p)return clearTimeout(s),s=setTimeout(b,r),f(l)}return s===void 0&&(s=setTimeout(b,r)),a}return S.cancel=w,S.flush=O,S}var wc=oM;function iM(i){var r=i==null?0:i.length;return r?i[r-1]:void 0}var Zg=iM;function nM(i,r){return r.length<2?i:ac(i,lc(r,0,-1))}var Jg=nM;function aM(i,r){return Xg(i,r)}var cp=aM;function sM(i,r){return r=yr(r,i),i=Jg(i,r),i==null||delete i[ni(Zg(r))]}var e0=sM;function lM(i){return Vy(i)?void 0:i}var t0=lM;var cM=1,uM=2,dM=4,pM=sc(function(i,r){var e={};if(i==null)return e;var t=!1;r=Xl(r,function(n){return n=yr(n,i),t||(t=n.length>1),n}),Yr(i,pc(i),e),t&&(e=gc(e,cM|uM|dM,t0));for(var o=r.length;o--;)e0(e,r[o]);return e}),Yn=pM;function fM(i,r,e,t){if(!It(i))return i;r=yr(r,i);for(var o=-1,n=r.length,a=n-1,s=i;s!=null&&++o<n;){var l=ni(r[o]),c=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(o!=a){var u=s[l];c=t?t(u,l,s):void 0,c===void 0&&(c=It(u)?u:En(r[o+1])?[]:{})}Dn(s,l,c),s=s[l]}return i}var r0=fM;function hM(i,r,e){for(var t=-1,o=r.length,n={};++t<o;){var a=r[t],s=ac(i,a);e(s,a)&&r0(n,yr(a,i),s)}return n}var o0=hM;function mM(i,r){return o0(i,r,function(e,t){return Qg(i,t)})}var i0=mM;var yM=sc(function(i,r){return i==null?{}:i0(i,r)}),Nr=yM;function gM(i,r){for(var e=i.length;e--&&Ym(r,i[e],0)>-1;);return e}var n0=gM;function xM(i,r,e){if(i=nc(i),i&&(e||r===void 0))return i.slice(0,Kl(i)+1);if(!i||!(r=Yl(r)))return i;var t=sp(i),o=n0(t,sp(r))+1;return zy(t,0,o).join("")}var up=xM;var fe=class{modifyById(r,e){let t=this;if(t[r]===void 0)throw new Error("not expected");{let n={...t,[r]:e};return Object.setPrototypeOf(n,fe.prototype),n}}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:n,data:a}=r,s={...e,[n]:a};return Object.setPrototypeOf(s,fe.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 n={...e};return Object.setPrototypeOf(n,fe.prototype),delete n[t],{data:n,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function Ds(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let r=Object.getOwnPropertyNames(i);for(let e of r){let t=i[e];t&&typeof t=="object"&&Ds(t)}return Object.freeze(i)}function a0(i,r){let e=0;for(;e<i.length&&e<r.length;){if(i[e]<r[e])return-1;if(i[e]>r[e])return 1;e+=1}return e!==r.length?-1:e!==i.length?1:0}var Kn=class extends Error{};function Pc(i){let r={...i};return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function Kr(i,r,e){if(i===void 0?r===void 0?(i=0,r=10):i=r-10:r===void 0&&(r=i+10),i>r){let n=i;i=r,r=n}let t=[],o=1/(e+1);for(let n=0;n<e;n++){let a=i+(r-i)*(n+.75+Math.random()*.5)*o;t.push(a)}return t}function Qn(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function s0(){return typeof process<"u"}function l0(i,r){for(let e of i)r(e.id,e.data)!==!0&&l0(e.children,r)}function c0(i,r){if(r(i.id,i.data)!==!0)for(let e of i.children)c0(e,r)}var Ke=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Ke.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Ds(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&&c0(o,t)}}traverse(e){l0(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let n=this.parent(e),a=this.childrenArray(n),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(n,a)}}modifyArrayBy(e,t){let o=e,n=t;for(;o!==null;){let s=n,l=o;if(o=this.parent(o),o===void 0)throw new Error;n=this.childrenArray(o);let c=n.findIndex(u=>u.id===l);if(c<0)throw new Error;n=[...n],n[c]={...n[c],children:s}}Object.setPrototypeOf(n,Ke.prototype);let a=n;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:n,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:n,data:a,children:s};return c=[...c,u],c.sort((d,f)=>d.fi-f.fi),e.localIndex=c.indexOf(u),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:n}}}}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 n=this.childrenArray(o),a=n.findIndex(c=>c.id===t);e.localIndex=a,n=[...n];let s=n.splice(a,1)[0];return{data:this.modifyArrayBy(o,n),actual:e,reverse:{type:7,...s,parent:o}}}}moveOp(e){let{parent:t,fi:o,id:n}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:n});if(t!==null){let f=t;for(;f!==null;){if(f===void 0)throw new Error;if(f===n)throw new Kn("cyclic tree");f=this.parent(f)}}let a=this.parent(n);if(a===void 0)return null;let s=a,l=this.childrenArray(a),c=l.findIndex(f=>f.id===n);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((f,h)=>f.fi-h.fi),e.localIndex=l.indexOf(u),p=p.modifyArrayBy(a,l),{data:p,actual:e,reverse:{type:9,parent:s,fi:d,id:n}}}previous(e,t){if(t===null){let n=this.childrenArray(e);return n.length===0?null:n[n.length-1].id}let o=null;for(let n of this.childrenArray(e)){if(n.id===t)return o;o=n.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let o=this.childrenArray(t),n=o.findIndex(a=>a.id===e)+1;if(n<o.length)return o[n].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let o=this.childrenArray(t),n=o.findIndex(a=>a.id===e)-1;return n>=0?this.traverseSortPrevious(o[n].id):t}}getAllSorted(e){let t=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&t.push({...o,...n})}t.sort((o,n)=>a0(o.sortKey,n.sortKey));for(let o of t)delete o.sortKey;return t}getWithSortKey(e){var t=e;let o=[],n=this.get(t),a=n;if(n!==void 0){for(;t;)o.splice(0,0,n.fi),t=this.parent(t),t!==null&&(n=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 n=this.childrenArray(e);if(t===null){if(n.length===0)return Kr(0,o,o);{let a=n[0].fi;return Kr(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=n.find(l=>l.fi>a.fi);if(s===void 0){let l=n[n.length-1].fi;return Kr(l,l+o,o)}else return Kr(a.fi,s.fi,o)}}};var Zn;(r=>{function i(e,t){if(t.type!==0)return null;if(Array.isArray(e)){let o=t.props,n={},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");n[l]=a[c],a[c]=o[l],s=!0}return s?{data:a,actual:t,reverse:{type:0,props:n}}:null}else{let o=t.props,n={},a={...e},s=!1;if(o)for(let l of Object.keys(o)){n[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:n}}:null}}r.runOp=i})(Zn||(Zn={}));var be=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,be.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Ds(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 n=this,a=n.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let s=n[a];return n=[...n],n[a]={...s,data:t},this.modifyArrayBy(n)}}modifyArrayBy(e){Object.setPrototypeOf(e,be.prototype);let t=e;return s0()||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:n}=e,a=this,s={fi:t,id:o,data:n};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,n=o.findIndex(l=>l.id===t);if(n===-1)return null;e.localIndex=n,o=[...o];let a=o.splice(n,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:t,id:o}=e,n=this;n=[...n];let a=n.findIndex(u=>u.id===o);if(a===-1)return null;let s=n[a].fi,l={...n[a],fi:t};return n[a]=l,n.sort((u,p)=>u.fi-p.fi),e.localIndex=n.indexOf(l),{data:this.modifyArrayBy(n),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 Kr(0,t,t);{let n=o[0].fi;return Kr(n-t,n,t)}}else{let n=this.get(e);if(n===void 0)throw new Error("illegal args");let a=o.find(s=>s.fi>n.fi);if(a===void 0){let s=o[o.length-1].fi;return Kr(s,s+t,t)}else return Kr(n.fi,a.fi,t)}}};function Jn(i){return i&&typeof i=="object"&&i instanceof Qe}var Qe=class{unusedFunOverridesTable(r){}runOp(r){let e=[],t=this,o=0,n={};for(;o<r.path.length;){if(e.push(t),t=t===void 0?void 0:t[r.path[o]],t!==void 0&&!Jn(t))return null;o+=1}t=t?Pc(t):new Qe;for(let[l,c]of Object.entries(r.props)){let u=t[l];n[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=Pc(l),delete t[r.path[o-1]])}else{let l=e[o-1];if(l){let c=Pc(l);c[r.path[o-1]]=t,t=c}else{let c=new Qe;c[r.path[o-1]]=t,t=c}}o-=1}let a=Object.setPrototypeOf(t,Qe.prototype),s={...r,props:n};return{data:a,actual:r,reverse:s}}},Qr;(t=>{function i(o,n){return _s(o,n)??o}t.apply=i;function r(o,n){return pp(o,n)}t.merge=r;function e(o,n){let a=0,s=n.path,l=o;for(;a<s.length&&l!==void 0;){if(l=Ze.zoomOnce(l,s[a]),l===void 0)return n;if(!Jn(l))return;a+=1}if(l===void 0)return n;if(!!Jn(l))if(n.type===0){let c={...n.props};for(let u of Object.keys(l))delete c[u];return{...n,props:c}}else if(n.type===1||n.type===4||n.type===7){let c=dp([n],l);return c?(console.log(c),c):n}else return n}t.filterOp=e})(Qr||(Qr={}));function dp(i,r){if(r===void 0)return;let e=!1,t=i.map(o=>{let n=o.id,a=_s(o.data,r[n]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=dp(o.children,r);return s!==void 0?e=!0:s=o.children,{...o,id:n,data:a,children:s}}else return{...o,id:n,data:a}});if(e)return t}function bM(i,r){if(r===void 0)return;let e=!1,t=i.map(o=>{let n=o.id,a=_s(o.data,r[n]);return e=e||a!==void 0,a===void 0&&(a=o.data),{...o,id:n,data:a}});if(e)return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function _s(i,r){if(!Jn(r))return r;if(i instanceof Ke){let e=dp(i,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof be)return bM(i,r);if(Array.isArray(i)){let e=!1,t=i.map((o,n)=>{let a=_s(o,r[n]);return e=e||a!==void 0,a===void 0&&(a=o),a});return e?(Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t):void 0}else{if(i instanceof Qe)return pp(i,r);if(i&&typeof i=="object"){let e={},t=!1;for(let[o,n]of Object.entries(i)){let a=_s(n,r[o]);t=t||a!==void 0,a===void 0&&(a=n),e[o]=a}return t?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function pp(i,r){if(i===void 0)return r;if(r===void 0)return i;if(!Jn(r))return r;if(!Jn(i))return Qr.apply(i,r);let e=new Set;for(let o of Object.keys(i))e.add(o);for(let o of Object.keys(r))e.add(o);let t=new Qe;for(let o of e){let n=pp(i===void 0?void 0:i[o],r===void 0?void 0:r[o]);t[o]=n}return t}function u0(i,r){let e={cur:[],result:[],len:0};return i=Rs(i,r,e)??i,[i,e.result]}function Oc(i,r){return i===null?null:(i.cur[i.len]=r,i.len+=1,i)}function Tc(i){i&&(i.len-=1)}function vM(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function d0(i,r,e){let t=!1,o=i.map(n=>{let a=n.id,s=r[a];if(s!==void 0&&typeof s=="string"&&(t=!0,a=s,e!==null))throw new Error("not supported");let l=Rs(n.data,r,Oc(e,a));Tc(e),t=t||l!==void 0,l===void 0&&(l=n.data);let c=d0(n.children,r,e);return c!==void 0?t=!0:c=n.children,{...n,id:a,data:l,children:c}});if(t)return o}function SM(i,r,e){let t=!1,o=i.map(n=>{let a=n.id,s=r[a];if(s!==void 0&&typeof s=="string"&&(t=!0,a=s,e!==null))throw new Error("not supported");let l=Rs(n.data,r,Oc(e,a));return Tc(e),t=t||l!==void 0,l===void 0&&(l=n.data),{...n,id:a,data:l}});if(t)return Object.setPrototypeOf(o,Object.getPrototypeOf(i)),o}function Rs(i,r,e){if(i instanceof Ke){let t=d0(i,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else{if(i instanceof be)return SM(i,r,e);if(Array.isArray(i)){let t=!1,o=i.map((n,a)=>{let s=Rs(n,r,Oc(e,a));return Tc(e),t=t||s!==void 0,s===void 0&&(s=n),s});return t?(Object.setPrototypeOf(o,Object.getPrototypeOf(i)),o):void 0}else if(i&&typeof i=="object"&&!Qn(i)){let t={},o=!1;for(let[n,a]of Object.entries(i))if(n!=="name"&&n!=="variableId"){let s=r[n];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,n=s}let l=Rs(a,r,Oc(e,n));Tc(e),o=o||l!==void 0,l===void 0&&(l=a),t[n]=l}else t[n]=a;return o?(Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t):void 0}else if(typeof i=="string"){let t=r[i];return t!==void 0&&vM(e),t}else return}}var ea;(r=>{function i(e,t){let o=Ze.zoom(t,e.path);if(typeof o=="object"){let n={};for(let a of Object.keys(e.props))n[a]=o[a];return{...e,props:n}}else return{...e,props:{}}}r.replaceProps=i})(ea||(ea={}));var nt;(s=>{function i(l,c){return{...l,path:l.path.slice(c)}}s.drop=i;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 Qe&&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 Ke||l instanceof be||l instanceof fe?d=l.runOp(c):d=Zn.runOp(l,c)),d!==void 0)if(d!==null){let m=d.data;for(let y=p.length-1;y>=0;y--){let b=u[y],v=p[y];if(v instanceof Ke){if(typeof b=="number")throw new Error("illegal arg");m=v.modifyById(b,m)}else if(v instanceof be){if(typeof b=="number")throw new Error("illegal arg");m=v.modifyById(b,m)}else if(v instanceof fe){if(typeof b=="number")throw new Error("illegal arg");m=v.modifyById(b,m)}else if(v instanceof Qe){let w={...v,[b]:m};m=Object.setPrototypeOf(w,Qe.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof b=="string"&&(b=parseInt(b),isNaN(b)))throw new Error("Invalid path");let w=m;m=[...v],m[b]=w}else m={...v,[b]:m};else return null}return{data:m,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let f=u[p.length],h;if(l instanceof Ke){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else if(l instanceof be){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else l!==null&&(h=l[f]);if(h!==void 0)p.push(l),l=h;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 n(l,c){return t(l.path,c.path)}s.commutative=n;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})(nt||(nt={}));var Ls;(l=>{function i(){return[]}l.empty=i;function r(c,u){let p=[];for(let d of c){let[f,...h]=d.path;f===u&&p.push({...d,path:h})}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(f=>nt.subsumed(d,f))),...u]}l.compress=o;function n(c,u){return c.every(p=>u.every(d=>nt.commutative(p,d)))}l.commutative=n;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=[],f=[];for(let h of u)try{if(h.type===3||h.type===5&&h.path[h.path.length-1]==="variables"){let m,y,b;if(h.type===3?(m=Ze.zoom(p,[...h.path,h.id]),b=nt.apply(p,{...h,type:2})):(m=Ze.zoom(p,[...h.path,h.id,"value"]),b=nt.apply(p,h)),b!==null){p=b.data;let[v,w]=u0(p,{[h.id]:m});p=v;for(let O=0;O<w.length;O++){let S=w[O],T=S.pop();if(typeof T=="number"){let M=[T];for(let D=O+1;D<w.length;D++){let E=w[D],I=E[E.length-1];if(typeof I=="number"&&Ze.equal(S,E.slice(0,E.length-1)))M.push(I),w.splice(D,1);else break}let g=Ze.zoom(p,S);y=g.map((D,E)=>M.includes(E)?h.id:D),m=g,T=S.pop()}else{if(T==="alphaOverride"||T==="alpha"){m/=100;let M=m,g=Ze.zoom(p,S.slice(0,S.length-2)),D=g.layers.map(E=>E.id===S[S.length-1]?{...E,data:{...E.data,[T]:M}}:E);Object.setPrototypeOf(D,Object.getPrototypeOf(g.layers)),g.layers=D}y=h.id}d.push({type:0,path:S,props:{[T]:m}}),f.push({type:0,path:S,props:{[T]:y}})}f.push(b.reverse),d.push(b.actual)}}else{let m=nt.apply(p,h);m!==null&&(d.push(m.actual),p=m.data,f.push(m.reverse))}}catch(m){if(m instanceof Kn)return null;throw m}return{data:p,actual:d,reverse:f.reverse()}}l.apply=s})(Ls||(Ls={}));var p0=Symbol(),wM=Symbol(),Ac=Symbol(),Ki=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let n=t;for(;!(o instanceof Cc);){let a=o._path,s=o._current;if(a!==""&&n.splice(0,0,a),o=o._parent,o===null)return;o.update(a,s)}o.push(n,r,e.actual,e.reverse)}deleteChildren(r){if(this._children){let e=this._children[r];if(e){let t=e[Ac];t&&t(),delete this._children[r]}}}},hp=class extends Ki{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,Zn.runOp(this._current,r),r.path)}},mp=class extends Ki{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,fe.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},f0={get(i,r){if(r===Ac)return()=>{i._parent=null};if(r===p0)return i._current;if(r===wM)return i;let{_current:e,_children:t}=i;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 n=e[r],a=Mc(i,r,n);return a!==n?(t===void 0&&(t={},i._children=t),t[r]=a,a):n},has(i,r){return r in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,r){let e=i._current,t=Reflect.getOwnPropertyDescriptor(e,r);return t&&{writable:!0,configurable:!0,enumerable:t.enumerable,value:e[r]}}},PM={...f0,set(i,r,e){let t={type:0,props:{[r]:at(e)??e}};return i.deleteChildren(r),i.runOp(t),!0},deleteProperty(i,r){let e={type:0,props:{[r]:void 0}};return i.deleteChildren(r),i.runOp(e),!0}},OM={...f0,set(i,r,e){return e===void 0?this.deleteProperty(i,r):(i.deleteChildren(r),i.runOp({type:1,id:r,data:e})),!0},deleteProperty(i,r){return i.runOp({type:2,id:r}),!0}},ta=class extends Ki{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Ac]=()=>{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 n=e.get(r)?.data,a=Mc(this,r,n);return a!==n?(t===void 0&&(t={},this._children=t),t[r]=a,a):n}add(r,e,t,o,n){this.runOp({type:7,parent:r,fi:e,id:t,data:o,children:n})}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 n=0;n<t.length;n++){let a=t[n];this.add(r,o[n],a.id,a.data,a.children)}}insertBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let n=0;n<t.length;n++){let a=t[n];this.add(r,o[n],a.id,a.data,a.children)}}moveAfter(r,e,t){let o=this._current.insertAfterHelper(r,e,t.length);for(let n=0;n<t.length;n++){let a=t[n];this.move(r,o[n],a)}}moveBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let n=0;n<t.length;n++){let a=t[n];this.move(r,o[n],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)}},ra=class extends Ki{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Ac]=()=>{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,n=this._current[t].fi;r(this.data(this._current[t].id),o,n)}}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 n=e.get(r)?.data,a=Mc(this,r,n);return a!==n?(t===void 0&&(t={},this._children=t),t[r]=a,a):n}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 n=e[o];this.add(t[o],n.id,n.data)}}insertBefore(r,e){let t=this._current.insertBeforeHelper(r,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.add(t[o],n.id,n.data)}}moveAfter(r,e){let t=this._current.insertAfterHelper(r,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.move(t[o],n)}}moveBefore(r,e){let t=this._current.insertBeforeHelper(r,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.move(t[o],n)}}delete(r){this.deleteChildren(r),this.runOp({type:5,id:r})}};function fp(i,r,e){if(i.length>0){let t=i[i.length-1];if(t.type===0&&r.type===0&&Ze.equal(t.path,e)){Object.assign(t.props,r.props);return}}i.push({...r,path:e})}var Cc=class extends Ki{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){fp(this.ts,e,r),fp(this.actual,t,r),fp(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Mc(i,r,e){return e instanceof Ke?new ta(i,r,e):e instanceof be?new ra(i,r,e):e instanceof fe?new Proxy(new mp(i,r,e),OM):e!==null&&typeof e=="object"?Qn(e)?e:new Proxy(new hp(i,r,e),PM):e}function yp(i){let r=new Cc(i);return[Mc(r,"",i),r]}function ai(i,r){let[e,t]=yp(i);return r(e),t.result()}function at(i){return i instanceof ta||i instanceof ra?i._current:i!==null&&typeof i=="object"?i[p0]:i}var Ze;(o=>{function i(n,a){if(a.length===n.length)for(var s=0;s<n.length;){if(n[s]!==a[s])return!1;s+=1}else return!1;return!0}o.equal=i;function r(n,a,s){let l=t(s,n);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(n,a){if((n instanceof Ke||n instanceof ta)&&typeof a=="string")return n.data(a);if((n instanceof be||n instanceof ra)&&typeof a=="string")return n.data(a);if(typeof a=="number"&&Array.isArray(n))return n[a];if(typeof a=="string"&&typeof n=="object"&&n!==null)return n[a]}o.zoomOnce=e;function t(n,a,s=0){for(;s<a.length&&n!==void 0;)n=e(n,a[s]),s+=1;return n}o.zoom=t})(Ze||(Ze={}));function h0(i,r){let e=[];if(r.length===i.length)for(var t=0;t<i.length;){if(r[t]==="*")e.push(i[t]);else if(i[t]!==r[t])return null;t+=1}else return null;return e}function Le(i,r){let e=[];if(r.length<=i.length)for(var t=0;t<r.length;){if(r[t]==="*")e.push(i[t]);else if(i[t]!==r[t])return null;t+=1}else return null;return e}var Ic=class{},Bs=class extends Ic{constructor(e){super();this.id=e}},Vs=class extends Ic{constructor(e){super();this.data=e}};var xp;try{xp=new TextDecoder}catch{}var de,li,G=0;var w0=[],bp=w0,vp=0,Jt={},ke,si,gr=0,Zr=0,cr,Io,$t=[],We,m0={useRecords:!1,mapsAsObjects:!0},zs=class{},wp=new zs;wp.name="MessagePack 0xC1";var oa=!1,Jr=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 A0(()=>(Nc(),this?this.unpack(r,e):Jr.prototype.unpack.call(m0,r,e)));li=e>-1?e:r.length,G=0,vp=0,Zr=0,si=null,bp=w0,cr=null,de=r;try{We=r.dataView||(r.dataView=new DataView(r.buffer,r.byteOffset,r.byteLength))}catch(t){throw de=null,r instanceof Uint8Array?t:new Error("Source must be a Uint8Array or Buffer but was a "+(r&&typeof r=="object"?r.constructor.name:typeof r))}if(this instanceof Jr){if(Jt=this,this.structures)return ke=this.structures,Ec();(!ke||ke.length>0)&&(ke=[])}else Jt=m0,(!ke||ke.length>0)&&(ke=[]);return Ec()}unpackMultiple(r,e){let t,o=0;try{oa=!0;let n=r.length,a=this?this.unpack(r,n):Rc.unpack(r,n);if(e){for(e(a);G<n;)if(o=G,e(Ec())===!1)return}else{for(t=[a];G<n;)o=G,t.push(Ec());return t}}catch(n){throw n.lastPosition=o,n.values=t,n}finally{oa=!1,Nc()}}_mergeStructures(r,e){r=r||[];for(let t=0,o=r.length;t<o;t++){let n=r[t];n&&(n.isShared=!0,t>=32&&(n.highByte=t-32>>5))}r.sharedLength=r.length;for(let t in e||[])if(t>=0){let o=r[t],n=e[t];n&&(o&&((r.restoreStructures||(r.restoreStructures=[]))[t]=o),r[t]=n)}return this.structures=r}decode(r,e){return this.unpack(r,e)}};function Ec(){try{if(!Jt.trusted&&!oa){let r=ke.sharedLength||0;r<ke.length&&(ke.length=r)}let i=pt();if(G==li)ke.restoreStructures&&y0(),ke=null,de=null,Io&&(Io=null);else if(G>li){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}else if(!oa)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw ke.restoreStructures&&y0(),Nc(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function y0(){for(let i in ke.restoreStructures)ke[i]=ke.restoreStructures[i];ke.restoreStructures=null}function pt(){let i=de[G++];if(i<160)if(i<128){if(i<64)return i;{let r=ke[i&63]||Jt.getStructures&&P0()[i&63];return r?(r.read||(r.read=Pp(r,i&63)),r.read()):i}}else if(i<144)if(i-=128,Jt.mapsAsObjects){let r={};for(let e=0;e<i;e++)r[T0()]=pt();return r}else{let r=new Map;for(let e=0;e<i;e++)r.set(pt(),pt());return r}else{i-=144;let r=new Array(i);for(let e=0;e<i;e++)r[e]=pt();return r}else if(i<192){let r=i-160;if(Zr>=G)return si.slice(G-gr,(G+=r)-gr);if(Zr==0&&li<140){let e=r<16?Op(r):O0(r);if(e!=null)return e}return Sp(r)}else{let r;switch(i){case 192:return null;case 193:return cr?(r=pt(),r>0?cr[1].slice(cr.position1,cr.position1+=r):cr[0].slice(cr.position0,cr.position0-=r)):wp;case 194:return!1;case 195:return!0;case 196:return gp(de[G++]);case 197:return r=We.getUint16(G),G+=2,gp(r);case 198:return r=We.getUint32(G),G+=4,gp(r);case 199:return Qi(de[G++]);case 200:return r=We.getUint16(G),G+=2,Qi(r);case 201:return r=We.getUint32(G),G+=4,Qi(r);case 202:if(r=We.getFloat32(G),Jt.useFloat32>2){let e=_c[(de[G]&127)<<1|de[G+1]>>7];return G+=4,(e*r+(r>0?.5:-.5)>>0)/e}return G+=4,r;case 203:return r=We.getFloat64(G),G+=8,r;case 204:return de[G++];case 205:return r=We.getUint16(G),G+=2,r;case 206:return r=We.getUint32(G),G+=4,r;case 207:return Jt.int64AsNumber?(r=We.getUint32(G)*4294967296,r+=We.getUint32(G+4)):r=We.getBigUint64(G),G+=8,r;case 208:return We.getInt8(G++);case 209:return r=We.getInt16(G),G+=2,r;case 210:return r=We.getInt32(G),G+=4,r;case 211:return Jt.int64AsNumber?(r=We.getInt32(G)*4294967296,r+=We.getUint32(G+4)):r=We.getBigInt64(G),G+=8,r;case 212:if(r=de[G++],r==114)return S0(de[G++]&63);{let e=$t[r];if(e)return e.read?(G++,e.read(pt())):e.noBuffer?(G++,e()):e(de.subarray(G,++G));throw new Error("Unknown extension "+r)}case 213:return r=de[G],r==114?(G++,S0(de[G++]&63,de[G++])):Qi(2);case 214:return Qi(4);case 215:return Qi(8);case 216:return Qi(16);case 217:return r=de[G++],Zr>=G?si.slice(G-gr,(G+=r)-gr):CM(r);case 218:return r=We.getUint16(G),G+=2,Zr>=G?si.slice(G-gr,(G+=r)-gr):AM(r);case 219:return r=We.getUint32(G),G+=4,Zr>=G?si.slice(G-gr,(G+=r)-gr):MM(r);case 220:return r=We.getUint16(G),G+=2,x0(r);case 221:return r=We.getUint32(G),G+=4,x0(r);case 222:return r=We.getUint16(G),G+=2,b0(r);case 223:return r=We.getUint32(G),G+=4,b0(r);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var TM=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Pp(i,r){function e(){if(e.count++>2){let o=i.read=new Function("r","return function(){return {"+i.map(n=>TM.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(pt);return i.highByte===0&&(i.read=g0(r,i.read)),o()}let t={};for(let o=0,n=i.length;o<n;o++){let a=i[o];t[a]=pt()}return t}return e.count=0,i.highByte===0?g0(r,e):e}var g0=(i,r)=>function(){let e=de[G++];if(e===0)return r();let t=i<32?-(i+(e<<5)):i+(e<<5),o=ke[t]||P0()[t];if(!o)throw new Error("Record id is not defined for "+t);return o.read||(o.read=Pp(o,i)),o.read()};function P0(){let i=A0(()=>(de=null,Jt.getStructures()));return ke=Jt._mergeStructures(i,ke)}var Sp=Dc,CM=Dc,AM=Dc,MM=Dc;function Dc(i){let r;if(i<16&&(r=Op(i)))return r;if(i>64&&xp)return xp.decode(de.subarray(G,G+=i));let e=G+i,t=[];for(r="";G<e;){let o=de[G++];if((o&128)===0)t.push(o);else if((o&224)===192){let n=de[G++]&63;t.push((o&31)<<6|n)}else if((o&240)===224){let n=de[G++]&63,a=de[G++]&63;t.push((o&31)<<12|n<<6|a)}else if((o&248)===240){let n=de[G++]&63,a=de[G++]&63,s=de[G++]&63,l=(o&7)<<18|n<<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+=Et.apply(String,t),t.length=0)}return t.length>0&&(r+=Et.apply(String,t)),r}function x0(i){let r=new Array(i);for(let e=0;e<i;e++)r[e]=pt();return r}function b0(i){if(Jt.mapsAsObjects){let r={};for(let e=0;e<i;e++)r[T0()]=pt();return r}else{let r=new Map;for(let e=0;e<i;e++)r.set(pt(),pt());return r}}var Et=String.fromCharCode;function O0(i){let r=G,e=new Array(i);for(let t=0;t<i;t++){let o=de[G++];if((o&128)>0){G=r;return}e[t]=o}return Et.apply(String,e)}function Op(i){if(i<4)if(i<2){if(i===0)return"";{let r=de[G++];if((r&128)>1){G-=1;return}return Et(r)}}else{let r=de[G++],e=de[G++];if((r&128)>0||(e&128)>0){G-=2;return}if(i<3)return Et(r,e);let t=de[G++];if((t&128)>0){G-=3;return}return Et(r,e,t)}else{let r=de[G++],e=de[G++],t=de[G++],o=de[G++];if((r&128)>0||(e&128)>0||(t&128)>0||(o&128)>0){G-=4;return}if(i<6){if(i===4)return Et(r,e,t,o);{let n=de[G++];if((n&128)>0){G-=5;return}return Et(r,e,t,o,n)}}else if(i<8){let n=de[G++],a=de[G++];if((n&128)>0||(a&128)>0){G-=6;return}if(i<7)return Et(r,e,t,o,n,a);let s=de[G++];if((s&128)>0){G-=7;return}return Et(r,e,t,o,n,a,s)}else{let n=de[G++],a=de[G++],s=de[G++],l=de[G++];if((n&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){G-=8;return}if(i<10){if(i===8)return Et(r,e,t,o,n,a,s,l);{let c=de[G++];if((c&128)>0){G-=9;return}return Et(r,e,t,o,n,a,s,l,c)}}else if(i<12){let c=de[G++],u=de[G++];if((c&128)>0||(u&128)>0){G-=10;return}if(i<11)return Et(r,e,t,o,n,a,s,l,c,u);let p=de[G++];if((p&128)>0){G-=11;return}return Et(r,e,t,o,n,a,s,l,c,u,p)}else{let c=de[G++],u=de[G++],p=de[G++],d=de[G++];if((c&128)>0||(u&128)>0||(p&128)>0||(d&128)>0){G-=12;return}if(i<14){if(i===12)return Et(r,e,t,o,n,a,s,l,c,u,p,d);{let f=de[G++];if((f&128)>0){G-=13;return}return Et(r,e,t,o,n,a,s,l,c,u,p,d,f)}}else{let f=de[G++],h=de[G++];if((f&128)>0||(h&128)>0){G-=14;return}if(i<15)return Et(r,e,t,o,n,a,s,l,c,u,p,d,f,h);let m=de[G++];if((m&128)>0){G-=15;return}return Et(r,e,t,o,n,a,s,l,c,u,p,d,f,h,m)}}}}}function gp(i){return Jt.copyBuffers?Uint8Array.prototype.slice.call(de,G,G+=i):de.subarray(G,G+=i)}function Qi(i){let r=de[G++];if($t[r])return $t[r](de.subarray(G,G+=i));throw new Error("Unknown extension type "+r)}var v0=new Array(4096);function T0(){let i=de[G++];if(i>=160&&i<192){if(i=i-160,Zr>=G)return si.slice(G-gr,(G+=i)-gr);if(!(Zr==0&&li<180))return Sp(i)}else return G--,pt();let r=(i<<5^(i>1?We.getUint16(G):i>0?de[G]:0))&4095,e=v0[r],t=G,o=G+i-3,n,a=0;if(e&&e.bytes==i){for(;t<o;){if(n=We.getUint32(t),n!=e[a++]){t=1879048192;break}t+=4}for(o+=3;t<o;)if(n=de[t++],n!=e[a++]){t=1879048192;break}if(t===o)return G=t,e.string;o-=3,t=G}for(e=[],v0[r]=e,e.bytes=i;t<o;)n=We.getUint32(t),e.push(n),t+=4;for(o+=3;t<o;)n=de[t++],e.push(n);let s=i<16?Op(i):O0(i);return s!=null?e.string=s:e.string=Sp(i)}var S0=(i,r)=>{var e=pt();let t=i;r!==void 0&&(i=i<32?-((r<<5)+i):(r<<5)+i,e.highByte=r);let o=ke[i];return o&&o.isShared&&((ke.restoreStructures||(ke.restoreStructures=[]))[i]=o),ke[i]=e,e.read=Pp(e,t),e.read()},C0=typeof self=="object"?self:global;$t[0]=()=>{};$t[0].noBuffer=!0;$t[101]=()=>{let i=pt();return(C0[i[0]]||Error)(i[1])};$t[105]=i=>{let r=We.getUint32(G-4);Io||(Io=new Map);let e=de[G],t;e>=144&&e<160||e==220||e==221?t=[]:t={};let o={target:t};Io.set(r,o);let n=pt();return o.used?Object.assign(t,n):(o.target=n,n)};$t[112]=i=>{let r=We.getUint32(G-4),e=Io.get(r);return e.used=!0,e.target};$t[115]=()=>new Set(pt());var Tp=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");$t[116]=i=>{let r=i[0],e=Tp[r];if(!e)throw new Error("Could not find typed array for code "+r);return new C0[e](Uint8Array.prototype.slice.call(i,1).buffer)};$t[120]=()=>{let i=pt();return new RegExp(i[0],i[1])};$t[98]=i=>{let r=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=G;G+=r-4,cr=[pt(),pt()],cr.position0=0,cr.position1=0;let t=G;G=e;try{return pt()}finally{G=t}};$t[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function A0(i){let r=li,e=G,t=vp,o=gr,n=Zr,a=si,s=bp,l=Io,c=cr,u=new Uint8Array(de.slice(0,li)),p=ke,d=ke.slice(0,ke.length),f=Jt,h=oa,m=i();return li=r,G=e,vp=t,gr=o,Zr=n,si=a,bp=s,Io=l,cr=c,de=u,oa=h,ke=p,ke.splice(0,ke.length,...d),Jt=f,We=new DataView(de.buffer,de.byteOffset,de.byteLength),m}function Nc(){de=null,Io=null,ke=null}function M0(i){i.unpack?$t[i.type]=i.unpack:$t[i.type]=i}var _c=new Array(147);for(let i=0;i<256;i++)_c[i]=+("1e"+Math.floor(45.15-i*.30103));var Rc=new Jr({useRecords:!1}),IM=Rc.unpack,EM=Rc.unpackMultiple,NM=Rc.unpack,Lc={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},DM=new Float32Array(1),uH=new Uint8Array(DM.buffer,0,4);var Bc;try{Bc=new TextEncoder}catch{}var Vc,Ap,zc=typeof Buffer<"u",Cp=zc?Buffer.allocUnsafeSlow:Uint8Array,D0=zc?Buffer:Uint8Array,I0=zc?4294967296:2144337920,X,ht,k=0,eo,to=null,_M=/[\u0080-\uFFFF]/,Gs=Symbol("record-id"),Zi=class extends Jr{constructor(r){super(r),this.offset=0;let e,t,o,n,a,s,l=0,c=D0.prototype.utf8Write?function(g,D,E){return X.utf8Write(g,D,E)}:Bc&&Bc.encodeInto?function(g,D){return Bc.encodeInto(g,X.subarray(D)).written}:!1,u=this;r||(r={});let p=r&&r.sequential,d=r.structures||r.saveStructures,f=r.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let h=r.maxOwnStructures;h==null&&(h=d?32:64),p&&!r.saveStructures&&(this.structures=[]);let m=f>32||h+f>64,y=f+64,b=f+h+64;if(b>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],w=0,O=0;this.pack=this.encode=function(g,D){if(X||(X=new Cp(8192),ht=new DataView(X.buffer,0,8192),k=0),eo=X.length-10,eo-k<2048?(X=new Cp(X.length),ht=new DataView(X.buffer,0,X.length),eo=X.length-10,k=0):k=k+7&2147483640,t=k,s=u.structuredClone?new Map:null,u.bundleStrings?(to=["",""],X[k++]=214,X[k++]=98,to.position=k-t,k+=4):to=null,o=u.structures,o){o.uninitialized&&(o=u._mergeStructures(u.getStructures()));let E=o.sharedLength||0;if(E>f)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<E;I++){let N=o[I];if(!N)continue;let _,R=o.transitions;for(let V=0,U=N.length;V<U;V++){let B=N[V];_=R[B],_||(_=R[B]=Object.create(null)),R=_}R[Gs]=I+64}l=E}p||(o.nextId=E+64)}n&&(n=!1),a=o||[];try{if(S(g),to){ht.setUint32(to.position+t,k-to.position-t);let E=to;to=null,S(E[0]),S(E[1])}if(u.offset=k,s&&s.idsToInsert){k+=s.idsToInsert.length*6,k>eo&&M(k),u.offset=k;let E=LM(X.subarray(t,k),s.idsToInsert);return s=null,E}return D&R0?(X.start=t,X.end=k,X):X.subarray(t,k)}finally{if(o){if(O<10&&O++,w>1e4)o.transitions=null,O=0,w=0,v.length>0&&(v=[]);else if(v.length>0&&!p){for(let E=0,I=v.length;E<I;E++)v[E][Gs]=0;v=[]}if(n&&u.saveStructures){let E=o.sharedLength||f;o.length>E&&(o=o.slice(0,E));let I=X.subarray(t,k);return u.saveStructures(o,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(g)):(l=E,I)}}D&UM&&(k=t)}};let S=g=>{k>eo&&(X=M(k));var D=typeof g,E;if(D==="string"){let I=g.length;if(to&&I>=8&&I<4096){let R=_M.test(g);to[R?0:1]+=g,X[k++]=193,S(R?-I:I);return}let N;I<32?N=1:I<256?N=2:I<65536?N=3:N=5;let _=I*3;if(k+_>eo&&(X=M(k+_)),I<64||!c){let R,V,U,B=k+N;for(R=0;R<I;R++)V=g.charCodeAt(R),V<128?X[B++]=V:V<2048?(X[B++]=V>>6|192,X[B++]=V&63|128):(V&64512)===55296&&((U=g.charCodeAt(R+1))&64512)===56320?(V=65536+((V&1023)<<10)+(U&1023),R++,X[B++]=V>>18|240,X[B++]=V>>12&63|128,X[B++]=V>>6&63|128,X[B++]=V&63|128):(X[B++]=V>>12|224,X[B++]=V>>6&63|128,X[B++]=V&63|128);E=B-k-N}else E=c(g,k+N,_);E<32?X[k++]=160|E:E<256?(N<2&&X.copyWithin(k+2,k+1,k+1+E),X[k++]=217,X[k++]=E):E<65536?(N<3&&X.copyWithin(k+3,k+2,k+2+E),X[k++]=218,X[k++]=E>>8,X[k++]=E&255):(N<5&&X.copyWithin(k+5,k+3,k+3+E),X[k++]=219,ht.setUint32(k,E),k+=4),k+=E}else if(D==="number")if(g>>>0===g)g<64?X[k++]=g:g<256?(X[k++]=204,X[k++]=g):g<65536?(X[k++]=205,X[k++]=g>>8,X[k++]=g&255):(X[k++]=206,ht.setUint32(k,g),k+=4);else if(g>>0===g)g>=-32?X[k++]=256+g:g>=-128?(X[k++]=208,X[k++]=g+256):g>=-32768?(X[k++]=209,ht.setInt16(k,g),k+=2):(X[k++]=210,ht.setInt32(k,g),k+=4);else{let I;if((I=this.useFloat32)>0&&g<4294967296&&g>=-2147483648){X[k++]=202,ht.setFloat32(k,g);let N;if(I<4||(N=g*_c[(X[k]&127)<<1|X[k+1]>>7])>>0===N){k+=4;return}else k--}X[k++]=203,ht.setFloat64(k,g),k+=8}else if(D==="object")if(!g)X[k++]=192;else{if(s){let N=s.get(g);if(N){if(!N.id){let _=s.idsToInsert||(s.idsToInsert=[]);N.id=_.push(N)}X[k++]=214,X[k++]=112,ht.setUint32(k,N.id),k+=4;return}else s.set(g,{offset:k-t})}let I=g.constructor;if(I===Object)T(g,!0);else if(I===Array){E=g.length,E<16?X[k++]=144|E:E<65536?(X[k++]=220,X[k++]=E>>8,X[k++]=E&255):(X[k++]=221,ht.setUint32(k,E),k+=4);for(let N=0;N<E;N++)S(g[N])}else if(I===Map){E=g.size,E<16?X[k++]=128|E:E<65536?(X[k++]=222,X[k++]=E>>8,X[k++]=E&255):(X[k++]=223,ht.setUint32(k,E),k+=4);for(let[N,_]of g)S(N),S(_)}else{for(let N=0,_=Vc.length;N<_;N++){let R=Ap[N];if(g instanceof R){let V=Vc[N];if(V.write){V.type&&(X[k++]=212,X[k++]=V.type,X[k++]=0),S(V.write.call(this,g));return}let U=X,B=ht,q=k;X=null;let j;try{j=V.pack.call(this,g,F=>(X=U,U=null,k+=F,k>eo&&M(k),{target:X,targetView:ht,position:k-F}),S)}finally{U&&(X=U,ht=B,k=q,eo=X.length-10)}j&&(j.length+k>eo&&M(j.length+k),k=RM(j,X,k,V.type));return}}T(g,!g.hasOwnProperty)}}else if(D==="boolean")X[k++]=g?195:194;else if(D==="bigint"){if(g<BigInt(1)<<BigInt(63)&&g>=-(BigInt(1)<<BigInt(63)))X[k++]=211,ht.setBigInt64(k,g);else if(g<BigInt(1)<<BigInt(64)&&g>0)X[k++]=207,ht.setBigUint64(k,g);else if(this.largeBigIntToFloat)X[k++]=203,ht.setFloat64(k,Number(g));else throw new RangeError(g+" 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?X[k++]=192:(X[k++]=212,X[k++]=0,X[k++]=0);else if(D==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+D)},T=this.useRecords===!1?this.variableMapSize?g=>{let D=Object.keys(g),E=D.length;E<16?X[k++]=128|E:E<65536?(X[k++]=222,X[k++]=E>>8,X[k++]=E&255):(X[k++]=223,ht.setUint32(k,E),k+=4);let I;for(let N=0;N<E;N++)S(I=D[N]),S(g[I])}:(g,D)=>{X[k++]=222;let E=k-t;k+=2;let I=0;for(let N in g)(D||g.hasOwnProperty(N))&&(S(N),S(g[N]),I++);X[E+++t]=I>>8,X[E+t]=I&255}:g=>{let D=Object.keys(g),E,I=a.transitions||(a.transitions=Object.create(null)),N=0;for(let R=0,V=D.length;R<V;R++){let U=D[R];E=I[U],E||(E=I[U]=Object.create(null),N++),I=E}let _=I[Gs];if(_)_>=96&&m?(X[k++]=((_-=96)&31)+96,X[k++]=_>>5):X[k++]=_;else{_=a.nextId,_||(_=64),_<y&&this.shouldShareStructure&&!this.shouldShareStructure(D)?(_=a.nextOwnId,_<b||(_=y),a.nextOwnId=_+1):(_>=b&&(_=y),a.nextId=_+1);let R=D.highByte=_>=96&&m?_-96>>5:-1;I[Gs]=_,a[_-64]=D,_<y?(D.isShared=!0,a.sharedLength=_-63,n=!0,R>=0?(X[k++]=(_&31)+96,X[k++]=R):X[k++]=_):(R>=0?(X[k++]=213,X[k++]=114,X[k++]=(_&31)+96,X[k++]=R):(X[k++]=212,X[k++]=114,X[k++]=_),N&&(w+=O*N),v.length>=h&&(v.shift()[Gs]=0),v.push(I),S(D))}for(let R=0,V=D.length;R<V;R++)S(g[D[R]])},M=g=>{let D;if(g>16777216){if(g-t>I0)throw new Error("Packed buffer would be larger than maximum buffer size");D=Math.min(I0,Math.round(Math.max((g-t)*(g>67108864?1.25:2),4194304)/4096)*4096)}else D=(Math.max(g-t<<2,X.length-1)>>12)+1<<12;let E=new Cp(D);return ht=new DataView(E.buffer,0,D),X.copy?X.copy(E,0,t,g):E.set(X.slice(t,g)),k-=t,t=0,eo=E.length-10,X=E}}useBuffer(r){X=r,ht=new DataView(X.buffer,X.byteOffset,X.byteLength),k=0}};Ap=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,zs];Vc=[{pack(i,r,e){let t=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&t>=0&&t<4294967296){let{target:o,targetView:n,position:a}=r(6);o[a++]=214,o[a++]=255,n.setUint32(a,t)}else if(t>0&&t<17179869184){let{target:o,targetView:n,position:a}=r(10);o[a++]=215,o[a++]=255,n.setUint32(a,i.getMilliseconds()*4e6+(t/1e3/4294967296>>0)),n.setUint32(a+4,t)}else if(isNaN(t)){if(this.onInvalidDate)return r(0),e(this.onInvalidDate());let{target:o,targetView:n,position:a}=r(3);o[a++]=212,o[a++]=255,o[a++]=255}else{let{target:o,targetView:n,position:a}=r(15);o[a++]=199,o[a++]=12,o[a++]=255,n.setUint32(a,i.getMilliseconds()*1e6),n.setBigInt64(a+4,BigInt(Math.floor(t)))}}},{pack(i,r,e){let t=Array.from(i),{target:o,position:n}=r(this.structuredClone?3:0);this.structuredClone&&(o[n++]=212,o[n++]=115,o[n++]=0),e(t)}},{pack(i,r,e){let{target:t,position:o}=r(this.structuredClone?3:0);this.structuredClone&&(t[o++]=212,t[o++]=101,t[o++]=0),e([i.name,i.message])}},{pack(i,r,e){let{target:t,position:o}=r(this.structuredClone?3:0);this.structuredClone&&(t[o++]=212,t[o++]=120,t[o++]=0),e([i.source,i.flags])}},{pack(i,r){this.structuredClone?E0(i,16,r):N0(zc?Buffer.from(i):new Uint8Array(i),r)}},{pack(i,r){let e=i.constructor;e!==D0&&this.structuredClone?E0(i,Tp.indexOf(e.name),r):N0(i,r)}},{pack(i,r){let{target:e,position:t}=r(1);e[t]=193}}];function E0(i,r,e,t){let o=i.byteLength;if(o+1<256){var{target:n,position:a}=e(4+o);n[a++]=199,n[a++]=o+1}else if(o+1<65536){var{target:n,position:a}=e(5+o);n[a++]=200,n[a++]=o+1>>8,n[a++]=o+1&255}else{var{target:n,position:a,targetView:s}=e(7+o);n[a++]=201,s.setUint32(a,o+1),a+=4}n[a++]=116,n[a++]=r,n.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),a)}function N0(i,r){let e=i.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:n}=r(e+5);t[o++]=198,n.setUint32(o,e),o+=4}t.set(i,o)}function RM(i,r,e,t){let o=i.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(i,e),e+=o,e}function LM(i,r){let e,t=r.length*6,o=i.length-t;for(r.sort((n,a)=>n.offset>a.offset?1:-1);e=r.pop();){let n=e.offset,a=e.id;i.copyWithin(n+t,n,o),t-=6;let s=n+t;i[s++]=214,i[s++]=105,i[s++]=a>>24,i[s++]=a>>16&255,i[s++]=a>>8&255,i[s++]=a&255,o=n}return i}function ci(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");Ap.unshift(i.Class),Vc.unshift(i)}M0(i)}var _0=new Zi({useRecords:!1}),BM=_0.pack,VM=_0.pack;var{NEVER:zM,ALWAYS:GM,DECIMAL_ROUND:FM,DECIMAL_FIT:jM}=Lc,R0=512,UM=1024;var L0=new Zi({structuredClone:!0});ci({Class:fe.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,fe.prototype),i}});ci({Class:be.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,be.prototype),i}});ci({Class:Ke.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Ke.prototype),i}});ci({Class:Bs.prototype.constructor,type:4,write(i){return i.id},read(i){return new Bs(i)}});ci({Class:Vs.prototype.constructor,type:5,write(i){return i.data},read(i){return new Vs(i)}});ci({Class:Qe.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,Qe.prototype),i}});function kM(i){var r=0;if(i.length===0)return r;for(let e=0;e<i.length;e++){let t=i[e];r=(r<<5)-r+t,r=r&r}return r}function Mp(i){if(Qn(i))return i;if(Array.isArray(i))return i.map(Mp);if(typeof i=="object"&&i!==null){let r={};for(let e of Object.keys(i).sort())r[e]=Mp(i[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}else return i}var Gc;(t=>{function i(o){return L0.pack(o)}t.serialize=i;function r(o){return L0.unpack(o)}t.deserialize=r;function e(o){return kM(i(Mp(o))).toString()}t.checksum=e})(Gc||(Gc={}));var pi="personal camera",fi="a218fcc3-276b-49b9-b485-49037fd14f5f",j0=2960946,mt=5526619;var ia;(f=>{function i(h,m){return h[0]===m[0]&&h[1]===m[1]}f.isEqual=i;function r(h,m,y){return[h[0]+(m[0]-h[0])*y,h[1]+(m[1]-h[1])*y]}f.lerp=r;function e(h,m){return[h[0]+m[0],h[1]+m[1]]}f.add=e;function t(h,m){return[h[0]-m[0],h[1]-m[1]]}f.sub=t;function o(h,m){return[h[0]*m[0],h[1]*m[1]]}f.multiply=o;function n(h,m){return[h[0]/m[0],h[1]/m[1]]}f.divide=n;function a(h,m){return Math.pow(m[0]-h[0],2)+Math.pow(m[1]-h[1],2)}f.distanceSquared=a;function s(h,m){return Math.sqrt(a(h,m))}f.distance=s;function l(h,m){return h[0]*m[0]+h[1]*m[1]}f.dot=l;function c(h,m){return[h[0]*m,h[1]*m]}f.scalarMultiply=c;function u(h,m,y){let b=f.sub(m,h),v=f.sub(y,h),w=f.dot(b,v)/f.dot(b,b),O=f.scalarMultiply(b,w);return f.add(h,O)}f.projectionOnto=u;function p(h,m,y){return s(h,u(h,m,y))}f.projectionOntoDistance=p;function d(h,m){return[(h[0]+m[0])*.5,(h[1]+m[1])*.5]}f.center=d})(ia||(ia={}));var ui;(s=>{function i(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}s.isEqual=i;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 n(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])}s.dist=n;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})(ui||(ui={}));var B0;(e=>{function i(t,o){return t[0]===o[0]&&t[1]===o[1]&&t[2]===o[2]&&t[3]===o[3]}e.isEqual=i;function r(t,o,n){return[t[0]+(o[0]-t[0])*n,t[1]+(o[1]-t[1])*n,t[2]+(o[2]-t[2])*n,t[3]+(o[3]-t[3])*n]}e.lerp=r})(B0||(B0={}));var V0;(a=>{let i=180/Math.PI,r=Math.PI/180;function e(s){return typeof s=="number"?s*i: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 n(s){return[t(s[0]),t(s[1]),t(s[2])]}a.degToRad=n})(V0||(V0={}));var di;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function r(n,a){for(let s=0;s<16;s++)if(n[s]!==a[s])return!1;return!0}o.isEqual=r;function e(n){return n??o.identity}o.simplify=e;function t(n,a){let s=a.slice(0);for(var l=0,c=a.length;l<c;l+=3){let u=n[3]*a[l]+n[7]*a[l+1]+n[11]*a[l+2]+n[15];s[l]=(n[0]*a[l]+n[4]*a[l+1]+n[8]*a[l+2]+n[12])/u,s[l+1]=(n[1]*a[l]+n[5]*a[l+1]+n[9]*a[l+2]+n[13])/u,s[l+2]=(n[2]*a[l]+n[6]*a[l+1]+n[10]*a[l+2]+n[14])/u}return s}o.applyMatrix4=t})(di||(di={}));var wt;(p=>{function i(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}p.isRGB=i,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 n(d){return{r:d.r,g:d.g,b:d.b}}p.clone=n;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,f){return d.r===f.r&&d.g===f.g&&d.b===f.b}p.equals=l;function c(d,f){return d.r.toFixed(2)===f.r.toFixed(2)&&d.g.toFixed(2)===f.g.toFixed(2)&&d.b.toFixed(2)===f.b.toFixed(2)}p.equalsFixed=c;function u(d,f,h){return{r:d.r+(f.r-d.r)*h,g:d.g+(f.g-d.g)*h,b:d.b+(f.b-d.b)*h}}p.lerp=u})(wt||(wt={}));var Ie;(c=>{c.white={...wt.white,a:1},c.transparent={...wt.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{...wt.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 n(u,p){return wt.equals(u,p)&&u.a===p.a}c.equals=n;function a(u,p){return wt.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:f}=c.white){return`rgba(${u*255}, ${p*255}, ${d*255}, ${f})`}c.toStyle=l})(Ie||(Ie={}));var Fc;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Fc||(Fc={}));var z0;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(z0||(z0={}));var G0;(r=>r.defaultData={control1:[.5,0],control2:[.5,1]})(G0||(G0={}));var F0;(n=>(n.linear=[0,0,1,1],n.ease=[.25,.1,.25,1],n.easeIn=[.42,0,1,1],n.easeOut=[0,0,.58,1],n.easeInOut=[.42,0,.58,1]))(F0||(F0={}));function Ip(i){return typeof i=="string"&&i.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i):!1}var Dr;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(Dr||(Dr={}));var hi;(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(n){return n.type==="PerspectiveCamera"?n.perspective?.zoom??1:n.orthographic?.zoom??1}o.getZoom=t})(hi||(hi={}));var ro;(e=>{function i(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(n=>n*(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=i;function r(t,o){let n={...t};if(HM.forEach(a=>{Object.assign(n,{[a]:o[a]??t[a]})}),n.radial={...t.radial},o.radial){let a=t.radial,s=o.radial;WM.forEach(l=>{Object.assign(n.radial,{[l]:s[l]??a[l]})})}if(n.linear={...t.linear},o.linear){let a=t.linear,s=o.linear;qM.forEach(l=>{Object.assign(n.linear,{[l]:s[l]??a[l]})})}if(n.grid={...t.grid},o.grid){let a=t.grid,s=o.grid;$M.forEach(l=>{Object.assign(n.grid,{[l]:s[l]??a[l]})})}if(n.toObject={...t.toObject},o.toObject){let a=t.toObject,s=o.toObject;XM.forEach(l=>{Object.assign(n.toObject,{[l]:s[l]??a[l]})})}if(n.randomnessObject={...t.randomnessObject},o.randomnessObject){let a=t.randomnessObject,s=o.randomnessObject;YM.forEach(l=>{Object.assign(n.randomnessObject,{[l]:s[l]??a[l]})})}return n}e.merge=r})(ro||(ro={}));var jc;(t=>{t.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let r=["radial","linear","grid","toObject","randomnessObject"];function e(o,n){let a=[];o.count!==void 0&&a.push({type:0,path:n,props:{count:o.count}});for(let s of r){let l=o[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...n,s],props:l})}return a}t.toOps=e})(jc||(jc={}));var HM=["count"],WM=["radius","start","end","position","scale","rotation"],qM=["position","scale","rotation"],$M=["count","size"],XM=["count","position","scale","rotation"],YM=["strength","scale","rotation","position","movement","seed","freqScale"];var Uc;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function r(t){return e.all.includes(t)}e.is=r})(Uc||(Uc={}));var kc;(e=>{function i(t){return r(t)}e.defaultData=i;function r(t){if(t==="PointLight")return{type:t,color:Ie.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(t==="SpotLight")return{type:t,color:Ie.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(t==="DirectionalLight")return{type:t,color:Ie.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(kc||(kc={}));var na;(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}))(na||(na={}));var mi;(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]})(mi||(mi={}));var Ep;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function r(t,o){return t.castShadow===o.castShadow&&t.receiveShadow===o.receiveShadow}e.equals=r})(Ep||(Ep={}));var Np;(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})(Np||(Np={}));var Hc;(r=>r.defaultData={...Np.defaultData,...Ep.defaultData})(Hc||(Hc={}));var U0;(r=>{function i(e,t){let o=[];if("material"in e){let n=typeof e.material=="string"?t.materials[e.material]??t.lib.materials[e.material]?.asset:e.material;n&&o.push(n)}else if("materials"in e)for(let n of e.materials){let a=typeof n=="string"?t.materials[n]??t.lib.materials[n]?.asset:n;a&&o.push(a)}return o}r.getMaterialData=i})(U0||(U0={}));var aa;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(aa||(aa={}));var k0;(r=>{function i(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=i})(k0||(k0={}));function W0(i){return i.type!=="displace"}var H0;(r=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}r.is=i})(H0||(H0={}));var q0=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],$0=["wrapping","image","video","name","minFilter","magFilter"],bt;(o=>{function i(n,a){let{texture:s,...l}=a;if(Object.assign(n,l),s){let c=n.texture;c&&Object.assign(c,s)}}o.patch=i;function r(n,a){return n==="light"&&a?e(a):t(n)}o.defaultData=r;function e(n){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(n){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(n){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(n){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:aa.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...a,type:"color",color:wt.fromHex(mt)};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:{...wt.fromHex(6710886),a:1},colorB:{...wt.fromHex(6710886),a:1},colorC:{...wt.fromHex(16777215),a:1},colorD:{...wt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:Ie.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Ie.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:Ie.fromHexAndA(0,1),contourColor:Ie.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,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:{...wt.fromHex(0),a:1},colorB:{...wt.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 Pt;(c=>{function i(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=i;function r(u){let p="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([f,h])=>{p+=`${f}${h}`,Array.isArray(h)?h.forEach(m=>p+=`${m}`):typeof h=="object"?Object.values(h).forEach(m=>{typeof m=="number"?p+=`${m.toFixed(4)}`:p+=`${m}`}):p+=`${h}`})}),p}c.getHash=r;function e(){return{layers:new be}}c.defaultEmptyData=e;function t(u="layer1",p="layer2"){return n("phong",u,p)}c.defaultData=t;function o(u,p){return{...u,name:p}}c.withName=o;function n(u,p="layer1",d="layer2"){let f=new be;return f.push({fi:0,data:bt.defaultData("light",u),id:p}),f.push({fi:1,data:bt.defaultData("color"),id:d}),{layers:f}}c.defaultTwoLayerData=n;function a(u){let p=bt.defaultData("texture");u&&Object.assign(p.texture,{image:u});let d=new be;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",f="layer2"){let h=bt.defaultData("texture");Object.assign(h.texture,{image:u});let m=new be;return m.push({fi:0,data:h,id:d}),m.push({fi:1,data:bt.defaultData("light",p),id:f}),{layers:m}}c.defaultTwoLayerTextureData=s;function l(u,p="phong",d="layer1",f="layer2"){let h=bt.defaultData("video");Object.assign(h.texture,{video:u});let m=new be;return m.push({fi:0,data:h,id:d}),m.push({fi:1,data:bt.defaultData("light",p),id:f}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})(Pt||(Pt={}));var sa;(r=>{function i(){return{points:new be,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=i})(sa||(sa={}));var la;(r=>{function i(){return{points:new be,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}r.defaultData=i})(la||(la={}));var Dp={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Wc;(r=>{function i(e,t){let o={...e};return KM.forEach(n=>{Object.assign(o,{[n]:t[n]??e[n]})}),o}r.merge=i})(Wc||(Wc={}));var qc={shape:Dp,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},KM=["depth","offset","angle","twist","startScale","endScale"];var Fs;(e=>{function i(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"||t==="UIGeometry"}e.is2DParametricMesh=i;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})(Fs||(Fs={}));var $c;(r=>{function i(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,Wc.merge(o.extrusion,t.extrusion))),o}r.merge=i})($c||($c={}));var oo;(r=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};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:la.defaultData(),extrusion:qc};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:sa.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==="ShapeBlendGeometry")return{type:e,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};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=i})(oo||(oo={}));var Xc;(r=>r.defaultData={enabled:!1,useBackgroundColor:!1,color:wt.white,near:.1,far:2e3})(Xc||(Xc={}));var Yc;(e=>{let i={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...i,blendFunction:16,granularity:15},bloom:{...i,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...i,offset:[2,2]},vignette:{...i,darkness:1,offset:0},hueSaturation:{...i,hue:3,saturation:0},brightnessContrast:{...i,brightness:.25,contrast:0},depthOfField:{...i,focusDistance:100,focalLength:20,bokehScale:5},noise:{...i,blendFunction:16}}})(Yc||(Yc={}));var _p;(r=>r.defaultData={softShadowQuality:"low"})(_p||(_p={}));var Rp;(r=>r.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Rp||(Rp={}));var Lp;(r=>r.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Lp||(Lp={}));var js;(r=>r.defaultData={usePhysics:!1,gravity:-10})(js||(js={}));var Bp;(r=>r.defaultData={playCamera:pi,gameControlObject:null})(Bp||(Bp={}));var Kc;(r=>r.defaultData={backgroundColor:Ie.fromHexAndA(j0,1),postprocessing:Yc.defaultData,fog:Xc.defaultData,globalPhysics:js.defaultData,ambient:Rp.defaultData,ao:Lp.defaultData,shadow:_p.defaultData,publish:Bp.defaultData})(Kc||(Kc={}));var Qc;(r=>r.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(Qc||(Qc={}));var X0;(e=>{function i(t){return t==="Component"||t==="Instance"}e.isComponentRelated=i;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(X0||(X0={}));var ca;(o=>{o.identity={...Fc.identity,hiddenMatrix:di.identity};function r(n){return{position:n.position,rotation:n.rotation,scale:n.scale,hiddenMatrix:n.hiddenMatrix}}o.fromObject=r;function e(n,a){return{position:a?.position||n.position,rotation:a?.rotation||n.rotation,scale:a?.scale||n.scale,hiddenMatrix:a?.hiddenMatrix||n.hiddenMatrix}}o.merge=e;function t(n,a){return Hl({position:ui.isEqual(n.position,a.position)?void 0:a.position,rotation:ui.isEqual(n.rotation,a.rotation)?void 0:a.rotation,scale:ui.isEqual(n.scale,a.scale)?null:a.scale,hiddenMatrix:di.isEqual(n.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=t})(ca||(ca={}));var yt;(r=>r.defaultData={states:new be,events:new be,visible:!0,raycastLock:!1,physics:mi.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...ca.identity,cloner:null})(yt||(yt={}));var Zc;(r=>r.defaultData={type:"Empty",...yt.defaultData})(Zc||(Zc={}));var Y0;(r=>r.defaultData={type:"ParticleCollider",...Qc.defaultData,...yt.defaultData})(Y0||(Y0={}));var K0;(r=>r.defaultData={type:"Component",...yt.defaultData})(K0||(K0={}));var Q0;(r=>r.defaultData={type:"Particle",...yt.defaultData,...na.defaultData})(Q0||(Q0={}));var Eo;(r=>r.defaultData={type:"Mesh",...yt.defaultData,...Hc.defaultData})(Eo||(Eo={}));var Ji;(r=>r.defaultData={...yt.defaultData,...ca.identity,position:[0,0,hi.DefaultTargetOffset],...hi.defaultData})(Ji||(Ji={}));var Jc;(e=>{function i(t){return{...yt.defaultData,...kc.defaultData(t)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Jc||(Jc={}));var ua;(e=>{function i(t,o,n=0){for(;n<o.length;){let a=t?t[o[n]]:void 0;if(o.length===n+1)return a;if(a)t=a.descendants,n+=1;else return}}e.resolveWithDes=i;function r(t,o,n=0){let a=i(t,o,n);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=r})(ua||(ua={}));var io;(n=>{n.rootOverrideProps=["physics","events"],n.compositeNonOptionalOverrideProps=["geometry"],n.compositeEntireOverrideOverrideProps=["material"];function t(a,s){return{...yt.defaultData,...s,component:a,overrides:new Qe,physics:void 0,events:void 0,type:"Instance"}}n.ofComponent=t;function o(a){let s=ca.fromObject(a.data);return t(a.id,s)}n.fromComponentData=o})(io||(io={}));var No;(e=>{e.defaultData={type:"Page",...yt.defaultData,physics:{...mi.defaultData,fusedBody:!1},...Kc.defaultData,camera:Ji.defaultData};function r(t){return t.uiScene!==void 0}e.isUIPage=r})(No||(No={}));var eu;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:di.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:mi.defaultData,states:new be,events:new be,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...hi.defaultData},s.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"]},s.defaultMeshObject={name:"Rectangle",...yt.defaultData,...Eo.defaultData,geometry:oo.defaultData("RectangleGeometry"),material:Pt.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...yt.defaultData,...Eo.defaultData,geometry:oo.defaultData("BooleanGeometry"),material:Pt.defaultTwoLayerData("phong","layer1","layer2")},s.defaultShapeBlendObject={name:"Shape Blend",...yt.defaultData,...Eo.defaultData,geometry:oo.defaultData("ShapeBlendGeometry"),material:Pt.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...yt.defaultData,...Eo.defaultData,geometry:oo.defaultData("TextGeometry"),material:Pt.defaultTwoLayerData("phong","layer1","layer2")},s.defaultInputObject={name:"Input",...yt.defaultData,...Eo.defaultData,geometry:oo.defaultData("InputGeometry"),material:Pt.defaultTwoLayerData("phong","layer1","layer2")}))(eu||(eu={}));var en;(o=>{function i(n,a){let s={name:a};return n.type==="Mesh"?(s.geometry={},"material"in n&&(s.material={layers:new Qe}),"materials"in n&&(s.materials=n.materials.map(l=>({layers:new Qe})))):Dr.is(n.type)&&(s.perspective={},s.orthographic={}),s}o.newEmpty=i;function r(n,a){if(a===void 0)return n;let s={...n};return"material"in s&&"material"in a&&a.material&&(s.material=ai(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=ai(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 f=l[c]?.layers?.data(p);f&&bt.patch(f,d)}}}).data),s}function e(n,a){let s,l=[],c={orthographic:0,perspective:0,geometry:0};function u(p,d){for(let[f,h]of Object.entries(d.layers)){let{texture:m,...y}=h;if(m!==void 0&&Object.keys(m).length>0){let b={path:[...p,"layers",f,"texture"],props:m,type:0};l.push(b)}if(Object.keys(y).length>0){let b={path:[...p,"layers",f],props:y,type:0};l.push(b)}}}for(let[p,d]of Object.entries(a))if(p!=="name")if(p==="cloner")l.push(...jc.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[f,h]of Object.entries(d))u(["materials",f],h);else if(c[p]===0){if(p==="geometry"&&d.extrusion!==void 0){let f={path:[p,"extrusion"],props:d.extrusion,type:0};l.push(f),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let f={path:[p],props:d,type:0};l.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[p]=d;return l}o.toOps=e;function t(n,a){if(a===void 0)return n;let s={...n};if(Object.assign(s,ca.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})}),Dr.is(n.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(n.type==="Mesh")"geometry"in a&&Object.assign(s,{geometry:$c.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=r(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:ro.merge(s.cloner,a.cloner)});else if(n.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:ro.merge(s.cloner,a.cloner)});else if(Uc.is(n.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=wt.clone(l.color))}return s}o.patch=t})(en||(en={}));var da;(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})(da||(da={}));var br;(r=>r.defaultData={orbitControls:da.defaultData,playPage:fi,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,t)=>{let o=0,n=0;return t<5?n=-30:t<10&&(n=30),t===0||t===10||t===5?o=30:(t===4||t===11||t===9)&&(o=-30),[120,[o,n],"show"]}),settings:{image:{format:"jpg",ratio:1},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3},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})(br||(br={}));var Vp;(r=>r.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Vp||(Vp={}));var zp;(r=>r.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(zp||(zp={}));var Do;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Vp.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:zp.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Do||(Do={}));var Z0;(e=>{function i(t){return t.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function r(t,o,n){t.scene.objects.traverseFrom(o,(a,s)=>{if(s.type==="Instance"){let l=pa.getComponentData(t,s.component)?.data;l&&n(a,s,l.events)}else n(a,s,s.events)})}e.traverseModuleInstances=r})(Z0||(Z0={}));var _o;(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:Jc.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(u=!0,p=[]){let d=[],f=eu.defaultMeshObject;u&&(d.push({...c.defaultLight}),d.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:f,children:[]})),d.push(...p);let h=new Ke;return h.push({fi:1,id:fi,data:{...No.defaultData,name:"Scene 1"},children:d}),h}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:br.defaultData,styles:Do.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new Ke,publish:br.defaultData,styles:Do.defaultData()}},c.emptyDataWithPage=function(u=!0){return{objects:e(u),publish:br.defaultData,styles:Do.defaultData()}},c.emptyData=function(){return{objects:new Ke,publish:{...br.defaultData},styles:Do.defaultData()}};function s(u){return{...c.defaultData,objects:Bt(u,Ke.prototype)}}c.withObjs=s;function l(u,p){return s([{id:u,data:p,children:[],fi:0}])}c.withObj=l})(_o||(_o={}));var fa;(r=>r.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(fa||(fa={}));var tu;(e=>(e.defaultData=t=>({url:t,name:"New Webhook",parametersSchemas:new be}),e.defaultParameterValueByType=t=>t==="number"?0:t==="boolean"?!1:""))(tu||(tu={}));var J0;(r=>r.defaultData=(e,t="GET")=>({url:e,method:t,name:"New API",headers:new be,queries:new be,autoStart:!0}))(J0||(J0={}));var yi;(n=>{function i(a){return a.textValue!==void 0}n.isTextValue=i;function r(a){return typeof a=="number"}n.isNumber=r;function e(a){return typeof a=="boolean"}n.isBoolean=e;function t(a){return i(a)?"string":e(a)?"boolean":"number"}n.typeOfVariable=t;function o(a){return n.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():n.isBoolean(a)?a?"True":"False":n.isNumber(a)?parseFloat(a.toFixed(3)).toString():a.toString()}n.getDisplayedValue=o})(yi||(yi={}));var Gp;(r=>r.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(Gp||(Gp={}));var ex;(r=>r.all=[...Gp.all,"components"])(ex||(ex={}));var tx;(r=>{function i(){return{images:new fe,videos:new fe,colors:new fe,audios:new fe,particles:new fe,fonts:new fe,materials:new fe,components:new fe,variables:new fe,userAPIs:new fe,userWebhooks:new fe}}r.defaultData=i})(tx||(tx={}));var _r;(r=>{function i(){return{images:new fe,videos:new fe,colors:new fe,audios:new fe,particles:new fe,fonts:new fe,materials:new fe,components:new fe,variables:new fe,userAPIs:new fe,userWebhooks:new fe}}r.defaultData=i})(_r||(_r={}));var vr;(n=>{function i(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Bt(a,fe.prototype)}n.defaultColors=i;function r(){return Bt({},fe.prototype)}n.defaultImages=r;function e(){return{catelogs:new fe,materials:new fe,images:new fe,videos:new fe,colors:new fe,audios:new fe,particles:new fe,fonts:new fe,variables:new be,userAPIs:new fe,userWebhooks:new fe,lib:_r.defaultData()}}n.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)}}n.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}n.getFormattedTimerTime=o})(vr||(vr={}));import{MathUtils as iu}from"three";var ru;(r=>r.list=["idle","move","jump","run"])(ru||(ru={}));var ou;(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 be,move:new be,jump:new be,run:new be},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Ie.fromHexAndA(3728051,1)}}))(ou||(ou={}));function rx(i){i.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]],n=[0,1];for(let s=2;s<10;s++)o.push(o[1]),n.push(1);let a={...Nr(at(r),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,r.near),far:Math.max(0,r.far),colors:o,steps:n,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={...at(r),near:Math.max(r.near,0),far:Math.max(r.far,0)};Object.assign(r,e)}})}function Ro(i,r){Object.values(i.shared.materials).forEach(e=>r(e))}function Lo(i,r){i.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach((o,n)=>{o===void 0&&(t.materials[n]=Pt.defaultData(),o=t.materials[n]),typeof o!="string"&&r(o)}):"material"in t?typeof t.material!="string"&&(t.material===void 0&&(t.material=Pt.defaultData()),r(t.material)):t.type==="Mesh"&&(t.material===void 0&&(t.material=Pt.defaultData()),r(t.material)),"overrides"in t&&Object.values(t.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&Object.getPrototypeOf(o.material)!==Qe.prototype&&r(o.material)})})}function QM(i){Object.assign(i.scene.publish,{orbitControls:{...da.defaultData,...at(i.scene.publish.orbitControls)}})}function ZM(i){Object.assign(i.scene.publish.settings,{video:{...br.defaultData.settings.video,...at(i.scene.publish.settings.video)}})}function JM(i){function r(e){if(e.layers){for(let t of Object.values(e.layers))if(t){for(let[o,n]of Object.entries(t))if((q0.includes(o)||typeof n=="boolean")&&delete t[o],o==="texture")for(let[a,s]of Object.entries(n))($0.includes(a)||typeof s=="boolean")&&delete n[a]}}}i.scene.objects.traverse((e,t)=>{t.states.forEach(o=>{let n=o;n.material?r(n.material):n.materials&&n.materials.forEach(a=>{r(a)})})})}function eI(i){i.scene.publish.withBackground=!0}function tI(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function rI(i){i.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 oI(i){i.scene.objects.traverse((r,e)=>{let t=e.geometry;t&&(t.type==="DodecahedronGeometry"||t.type==="IcosahedronGeometry")&&(t.detail=Math.round(t.detail))})}function iI(i){i.scene.objects.traverse((r,e)=>{let t=i.scene.objects.unproxy().parent(r);if(t){let o=at(i.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=at(e).booleanExclude!==!0)}})}function nI(i){i.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 aI(i){function r(t){Object.setPrototypeOf(t,Qe.prototype),t.texture&&Object.setPrototypeOf(t.texture,Qe.prototype)}function e(t){Object.setPrototypeOf(t,Qe.prototype);for(let o in t)r(t[o])}i.scene.objects.traverse((t,o)=>{o.states.forEach(n=>{let a=n;if(a.material){let s=at(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=at(l).layers;e(c),l.layers=c}})})}function ox(i){i.layers===void 0&&Object.assign(i,Pt.defaultTwoLayerData("lambert"))}function Fp(i){!i.layers||i.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={...at(r),colors:e,steps:t};Object.assign(r,o)}})}function sI(i){i.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function ix(i){i.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&Fp(t)}):"material"in e&&typeof e.material!="string"&&Fp(e.material)}),Object.values(i.shared.materials).forEach(r=>Fp(r))}function lI(i){i.scene.environment.ambientLight.softShadows=!1,i.scene.environment.ambientLight.softShadowQuality="low",i.scene.objects.traverse((r,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),i.shared.penumbraSize=new Array(5).fill(.5)}function cI(i){i.shared.audios=Bt({},fe.prototype)}function uI(i){i.shared.videos=Bt({},fe.prototype)}function dI(i){let r=i.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 pI(i){Object.entries(at(i.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete i.shared.images[t]}),Object.entries(at(i.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete i.shared.audios[t]})}function fI(i){i.scene.publish.settings.web.preload=!1}function nx(i){i.layers&&i.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 ax(i){i.layers&&i.layers.forEach(r=>{W0(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 hI(i){i.shared.fonts=Bt({},fe.prototype)}function mI(i){return i.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 yI(i){let r=[];i.scene.objects.traverse((e,t)=>{let o=t;if(o.type==="TextFrame"){let n=Pt.defaultTwoLayerData("phong"),a=typeof o.color=="string"?i.shared.colors[o.color]:o.color;n.layers[1].data.color={r:a.r,g:a.g,b:a.b},n.layers[1].data.alpha=o.alpha;let s=mI(o.font);i.shared.fonts[s]===void 0&&(i.shared.fonts[s]={name:s});let l={name:o.name,...yt.defaultData,...Eo.defaultData,flatShading:!1,wireframe:!1,geometry:{...oo.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:n,states:at(o.states),events:at(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},c=at(i.scene.objects).parent(e);i.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),r.push(e)}}),r.forEach(e=>{i.scene.objects.delete(e)})}function gI(i){let r={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};i.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 be,move:new be,jump:new be}});else{let n=new be;Object.assign(o,{actions:n}),(o.type==="MouseDown"||o.type==="MouseUp"||o.type==="KeyDown"||o.type==="KeyUp")&&"url"in o&&n.push({fi:0,id:iu.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,Nr(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},f={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new be({fi:0,id:iu.generateUUID(),data:c},{fi:1,id:iu.generateUUID(),data:d})};n.push({fi:l,id:s,data:f})}),delete o.targets)}})})}function xI(i){i.scene.objects.traverse((r,e)=>{function t(o,n){let a=new be,s=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===n){let p;s.push(c),l.interaction==="play"?p={...Nr(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={...Nr(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:iu.generateUUID(),data:{type:o,actions:a}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function sx(i){let r=i.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 lx(i){Ro(i,sx),Lo(i,sx)}function bI(i){i.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function vI(i){i.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 SI(i){i.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Pt.defaultTwoLayerData("phong"))})}function wI(i){i.scene.publish.orbitControls.autoZoom===void 0&&(i.scene.publish.orbitControls.autoZoom=!1),i.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 PI(i){i.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 OI(i){i.scene.publish.mouseEventTarget===void 0&&(i.scene.publish.mouseEventTarget="canvas"),i.scene.publish.settings.web.hint===void 0&&(i.scene.publish.settings.web.hint=!1)}function TI(i){let{video:r}=i.scene.publish.settings;r.format==="gif"&&r.fps>48&&(r.fps=15)}function CI(i){i.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.resetYPosition=Math.abs(t.resetYPosition-e.position[1]))})})}function AI(i){let r=i.scene.environment.usePhysics;i.scene.objects.traverse((e,t)=>{r&&t.physics===null?t.collision=!1:t.collision="visibility"})}function MI(i){i.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.navmesh=ou.defaultDataThirdPerson.navmesh)})})}function II(i){i.scene.styles||(i.scene.styles=Do.defaultData())}function cx(i){i.layers.forEach(r=>{r.type==="light"&&r.category!=="toon"&&r.occlusion===void 0&&(r.occlusion=!0)})}function EI(i){i.scene.environment.ambientLight.occlusion===void 0&&(i.scene.environment.ambientLight.occlusion=!1),i.scene.environment.ambientLight.aoFullRes===void 0&&(i.scene.environment.ambientLight.aoFullRes=!1),i.scene.environment.ambientLight.radius===void 0&&(i.scene.environment.ambientLight.radius=256),i.scene.environment.ambientLight.bias===void 0&&(i.scene.environment.ambientLight.bias=.5),i.scene.environment.ambientLight.aoColor===void 0&&(i.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Lo(i,cx),Ro(i,cx)}function NI(i){i.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&Object.assign(t.gameActions,{run:new be})})})}function DI(i){i.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.keyAssignments=[...t.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function ux(i){i.layers&&i.layers.forEach(r=>{r.type==="light"&&r.bumpMapIntensity===void 0&&(r.bumpMapIntensity=5)})}function dx(i,r){if(r<1&&(Lo(i,rx),Ro(i,rx),i.schema=1),r<2&&(QM(i),i.schema=2),r<3&&(JM(i),i.schema=3),r<4&&(eI(i),i.schema=4),r<5&&(tI(i),i.schema=5),r<6&&(rI(i),i.schema=6),r<7&&(oI(i),i.schema=7),r<8&&(i.schema=8),r<9&&(ix(i),i.schema=9),r<10&&(sI(i),i.schema=10),r<11&&(lI(i),i.schema=11),r<12&&(ix(i),i.schema=12),r<13&&(cI(i),i.schema=13),r<14&&(dI(i),i.schema=14),r<15&&(pI(i),i.schema=15),r<16&&(fI(i),i.schema=16),r<17&&(Lo(i,nx),Ro(i,nx),i.schema=17),r<18&&(Lo(i,ox),Ro(i,ox),i.schema=18),r<19&&(ZM(i),i.schema=19),r<20&&(hI(i),yI(i),i.schema=20),r<21&&(gI(i),xI(i),i.schema=21),r<22&&(lx(i),i.schema=22),r<23&&(bI(i),i.schema=23),r<24&&(vI(i),i.schema=24),(r<25||i.shared.videos===void 0)&&(uI(i),r<25&&(i.schema=25)),r<26&&(iI(i),i.schema=26),r<27&&(nI(i),i.schema=27),r<28&&(lx(i),i.schema=28),r<29&&(aI(i),i.schema=29),r<30&&(SI(i),i.schema=30),r<31&&(wI(i),i.schema=31),r<33&&(PI(i),i.schema=33),r<34&&(OI(i),i.schema=34),r<35&&(TI(i),i.schema=35),r<36&&(CI(i),i.schema=36),r<37&&(AI(i),i.schema=37),r<38&&(Lo(i,ax),Ro(i,ax),i.schema=38),r<39&&(MI(i),i.schema=39),r<40&&(II(i),i.schema=40),r<41&&(EI(i),i.schema=41),r<42&&(NI(i),i.schema=42),r<43&&(DI(i),i.schema=43),r<99){Lo(i,ux),Ro(i,ux),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=pi);let e=at(i.scene.objects),t=i.scene.objects;i.scene.publish.playPage=fi,t.insertBefore(null,null,[{id:fi,data:{...No.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Nr(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Nr(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...js.defaultData,...Nr(i.scene.environment,"usePhysics","gravity")},camera:at(i.scene.ownerCamera)??No.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==_o.TRASH_CAN_ID&&t.move(fi,a.fi,a.id);let o=0,n=0;i.shared.penumbraSize&&i.scene.objects.traverse((a,s)=>{s.type==="DirectionalLight"?(s.penumbraSize=i.shared.penumbraSize[Math.min(o,2)],o+=1):s.type==="SpotLight"&&(s.penumbraSize=i.shared.penumbraSize[3+Math.min(n,1)],n+=1),(s.physics===void 0||s.physics===null)&&s.type!=="Instance"&&(s.physics={},Object.assign(s.physics,mi.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),i.schema=99}}function px(i){i.layers&&i.layers.forEach(r=>{r.type==="light"&&r.alphaOverride===void 0&&(r.alphaOverride=1)})}function _I(i){i.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 RI(i){Array.isArray(at(i.events))&&i.events?.forEach(r=>{"disabled"in r||(r.disabled=!1),(r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress")&&(r.mode=r.mode||"Object")})}var ha=180/Math.PI;function fx(i){i.rotation=i.rotation.slice(0,3).map(r=>r*ha)}function hx(i){fx(i),i.type==="Page"&&fx(i.camera),i.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(t=>t*ha))});let r=i.geometry;r&&r.type==="SphereGeometry"&&(r.thetaLength=(r.thetaLength??180)*ha),r&&r.type==="TorusGeometry"&&(r.arc=r.arc*ha),r&&r.type==="PathGeometry"&&(r.extrusion.angle*=ha,r.extrusion.twist*=ha),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(at(i.events))&&i.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 LI(i){i.shared.variables=Bt({},fe.prototype)}function BI(i){let r=at(i.shared.variables);i.shared.variables=Bt(Object.entries(r??{}).map(([e,t],o)=>({fi:o,id:e,data:t})),be.prototype)}var no=116;function mx(i,r){r(i.data);for(let e of i.children)mx(e,r)}function VI(i){let r=i.schema??104;r!==no&&r<105&&(mx(i.asset,hx),i.schema=105)}function zI(i){i.shared.particles=Bt({},fe.prototype),i.shared.lib&&(i.shared.lib.particles=_r.defaultData().particles)}function GI(i){i.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 FI(i){i.scene.objects.traverse((r,e)=>{e.type==="Page"&&(e.postprocessing.depthOfField.focusDistance=100,e.postprocessing.depthOfField.focalLength=20,e.postprocessing.depthOfField.bokehScale=5)})}function jI(i){i.scene.objects.traverse((r,e)=>{Array.isArray(at(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(n=>{n.type==="Transition"&&(n.runMode=o??"Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode=o==="Toggle"?"Toggle":"Normal")}):t.type==="MouseHover"||t.type==="MousePress"||t.type==="KeyPress"?t.actions?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.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(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")}),t.dragDropActions?.drop?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")})):t.type==="Resize"?(delete t.actions,t.breakpoints?.forEach(n=>{n.actions?.forEach(a=>{(a.type==="Transition"||a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Toggle")})})):t.type==="Start"?t.actions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Once"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}):t.type==="VariableChange"||t.type==="Scroll"?t.actions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}):t.type==="Conditional"&&(delete t.actions,t.inActions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}),t.outActions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}))})})}function UI(i){i.shared.userAPIs=Bt({},fe.prototype),i.shared.userWebhooks=Bt({},fe.prototype),i.shared.lib&&(i.shared.lib.userAPIs=_r.defaultData().userAPIs,i.shared.lib.userWebhooks=_r.defaultData().userWebhooks)}function kI(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=br.defaultData.settings.videoStatic)}function nu(i){let r=i.schema??0;if(r!==no){console.warn("updating from ",r,"to ",no),dx(i,r),r<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=br.defaultData.joystickSizeAndXYOffset),i.schema=100),r<101&&(Lo(i,px),Ro(i,px),i.schema=101),r<102&&(_I(i),i.schema=102),r<104&&(i.shared.catelogs=new fe,i.shared.lib=_r.defaultData(),i.schema=104),r<105&&(LI(i),i.scene.objects.traverse((e,t)=>{hx(t)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))VI(e);r<106&&(BI(i),i.schema=106),r<107&&(i.shared.lib.variables=_r.defaultData().variables,i.schema=107),r<109&&(zI(i),i.schema=109),r<110&&(GI(i),i.schema=110),r<111&&(i.scene.objects.traverse((e,t)=>{RI(t)}),i.schema=111),r<112&&(FI(i),i.schema=112),r<113&&(jI(i),i.schema=113),r<114&&(i.scene.publish.settings.web.imageQuality===void 0&&(i.scene.publish.settings.web.imageQuality=70),i.schema=114),r<115&&(UI(i),i.schema=115),r<116&&(kI(i),i.schema=116)}}var pa;(c=>{c.defaultData={schema:no,scene:_o.defaultData,frames:new fe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",fa.defaultData),shared:{...vr.emptyData(),colors:vr.defaultColors()}},c.emptyDataForImports=function(){let u=_o.emptyDataWithPage();return{schema:no,scene:u,frames:new fe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",fa.defaultData),shared:{...vr.emptyData(),colors:vr.defaultColors(),images:vr.defaultImages()}}},c.emptyData=function(){return{schema:no,scene:_o.emptyDataWithPage(),frames:new fe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",fa.defaultData),shared:vr.emptyData()}},c.clipboard2dData=function(){return{schema:no,scene:_o.emptyData(),frames:new fe,shared:vr.emptyData()}},c.collabHelper={...Ls,updateSchema(u){return(u.schema??0)<no?ai(u,nu):(u.schema??0)-no}};function n(u){let p=c.collabHelper.updateSchema(u);return typeof p=="number"?p===0?u:null:p.data}c.updateSchemaDirectly=n;function a(u){return{...u,shared:{...u.shared,lib:_r.defaultData()}}}c.withoutLib=a;function s(u,p){let d=u.scene.objects.get(p);if(d&&d.data.type==="Component")return d;{let f=u.shared.lib.components[p];if(f)return f.asset}}c.getComponentData=s;function l(u){let p=Object.values(u.shared.userAPIs);for(let d of p){let f=d.headers;for(let h of f)if(h.data.key.toLowerCase()==="authorization"&&h.data.value!=="")return!0}return!1}c.hasSensitiveData=l})(pa||(pa={}));var au;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(au||(au={}));var yx;(r=>{function i(e){return!0}r.is=i})(yx||(yx={}));var su;(t=>{t.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function r(o,n){return{position:n?.position??o.position,rotation:n?.rotation??o.rotation,scale:n?.scale??o.scale,shear:n?.shear??o.shear}}t.merge=r;function e(o,n){return Hl({position:ia.isEqual(o.position,n.position)?void 0:n.position,rotation:o.rotation===n.rotation?void 0:n.rotation,scale:ia.isEqual(o.scale,n.scale)?void 0:n.scale,shear:o.shear&&n.shear&&ia.isEqual(o.shear,n.shear)?void 0:n.shear})}t.diff=e})(su||(su={}));var jp;(r=>r.defaultData={horizontalConstraint:0,verticalConstraint:0})(jp||(jp={}));var gx;(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})(gx||(gx={}));var lu;(r=>r.defaultData={opacity:1,fill:{color:Ie.fromHexAndA(mt,1),enabled:!0},stroke:{color:Ie.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Ie.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Ie.from0to1([0,0,0,1]),enabled:!1,spread:0}})(lu||(lu={}));var tn;(n=>{function i(a,s){return{name:s}}n.newEmpty=i;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,su.merge(l,s)),l=r(l,s),l=e(l,s),l}n.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}n.toOps=o})(tn||(tn={}));var Us;(r=>r.defaultData={...su.defaultData,...jp.defaultData,states:new be,events:new be,visible:!0,raycastLock:!1})(Us||(Us={}));var ma;(r=>r.defaultData={...Us.defaultData,...lu.defaultData})(ma||(ma={}));var cu;(r=>r.defaultData={cornerRadius:[0,0,0,0]})(cu||(cu={}));var Up;(r=>r.defaultData={...ma.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(Up||(Up={}));var ya;(r=>r.defaultData={...ma.defaultData,...cu.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(ya||(ya={}));var kp;(r=>r.defaultData={...ma.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"})(kp||(kp={}));var Hp;(r=>r.defaultData={...ma.defaultData,type:"path2d",path:"",name:"Path"})(Hp||(Hp={}));var xx;(r=>{function i(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}r.is=i})(xx||(xx={}));var ks;(r=>r.defaultData={...Us.defaultData,name:"Group",type:"group2d"})(ks||(ks={}));var Wp;(r=>r.defaultData=()=>({...Us.defaultData,...cu.defaultData,...lu.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Ie.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Ie.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(Wp||(Wp={}));var Bo;(n=>{function i(a){switch(a){case"rectangle2d":return{...ya.defaultData};case"ellipse2d":return{...Up.defaultData};case"text2d":return{...kp.defaultData};case"vector2d":return{...ya.defaultData};case"path2d":return{...Hp.defaultData};case"frame2d":return{...Wp.defaultData()};case"group2d":return{...ks.defaultData}}}n.defaultData=i;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]}n.getPivot=r;function e(a){return a.type==="rectangle2d"||a.type==="ellipse2d"||a.type==="text2d"||a.type==="frame2d"}n.isResizeable=e;function t(a){return a.type==="frame2d"&&a.autoLayout!==void 0}n.isAutoLayoutable=t;function o(a){return a.type==="rectangle2d"||a.type==="frame2d"}n.hasCorners=o})(Bo||(Bo={}));var uu;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new Ke},e.emptyData=function(){return{type:"scene2d",objects:new Ke}}))(uu||(uu={}));var cd=Ms(vx());import{Object3D as a_,Vector3 as fr,Euler as Ah,MathUtils as i1,Matrix4 as vn}from"three";var HI=.5*(Math.sqrt(3)-1),Hs=(3-Math.sqrt(3))/6,WI=1/3,ao=1/6,Q8=(Math.sqrt(5)-1)/4,Z8=(5-Math.sqrt(5))/20,Ws=i=>Math.floor(i)|0,Sx=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),$p=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 wx(i=Math.random){let r=Ox(i),e=new Float64Array(r).map(o=>Sx[o%12*2]),t=new Float64Array(r).map(o=>Sx[o%12*2+1]);return function(n,a){let s=0,l=0,c=0,u=(n+a)*HI,p=Ws(n+u),d=Ws(a+u),f=(p+d)*Hs,h=p-f,m=d-f,y=n-h,b=a-m,v,w;y>b?(v=1,w=0):(v=0,w=1);let O=y-v+Hs,S=b-w+Hs,T=y-1+2*Hs,M=b-1+2*Hs,g=p&255,D=d&255,E=.5-y*y-b*b;if(E>=0){let _=g+r[D],R=e[_],V=t[_];E*=E,s=E*E*(R*y+V*b)}let I=.5-O*O-S*S;if(I>=0){let _=g+v+r[D+w],R=e[_],V=t[_];I*=I,l=I*I*(R*O+V*S)}let N=.5-T*T-M*M;if(N>=0){let _=g+1+r[D+1],R=e[_],V=t[_];N*=N,c=N*N*(R*T+V*M)}return 70*(s+l+c)}}function Px(i=Math.random){let r=Ox(i),e=new Float64Array(r).map(n=>$p[n%12*3]),t=new Float64Array(r).map(n=>$p[n%12*3+1]),o=new Float64Array(r).map(n=>$p[n%12*3+2]);return function(a,s,l){let c,u,p,d,f=(a+s+l)*WI,h=Ws(a+f),m=Ws(s+f),y=Ws(l+f),b=(h+m+y)*ao,v=h-b,w=m-b,O=y-b,S=a-v,T=s-w,M=l-O,g,D,E,I,N,_;S>=T?T>=M?(g=1,D=0,E=0,I=1,N=1,_=0):S>=M?(g=1,D=0,E=0,I=1,N=0,_=1):(g=0,D=0,E=1,I=1,N=0,_=1):T<M?(g=0,D=0,E=1,I=0,N=1,_=1):S<M?(g=0,D=1,E=0,I=0,N=1,_=1):(g=0,D=1,E=0,I=1,N=1,_=0);let R=S-g+ao,V=T-D+ao,U=M-E+ao,B=S-I+2*ao,q=T-N+2*ao,j=M-_+2*ao,F=S-1+3*ao,H=T-1+3*ao,W=M-1+3*ao,ee=h&255,te=m&255,Y=y&255,re=.6-S*S-T*T-M*M;if(re<0)c=0;else{let $=ee+r[te+r[Y]];re*=re,c=re*re*(e[$]*S+t[$]*T+o[$]*M)}let K=.6-R*R-V*V-U*U;if(K<0)u=0;else{let $=ee+g+r[te+D+r[Y+E]];K*=K,u=K*K*(e[$]*R+t[$]*V+o[$]*U)}let Z=.6-B*B-q*q-j*j;if(Z<0)p=0;else{let $=ee+I+r[te+N+r[Y+_]];Z*=Z,p=Z*Z*(e[$]*B+t[$]*q+o[$]*j)}let Q=.6-F*F-H*H-W*W;if(Q<0)d=0;else{let $=ee+1+r[te+1+r[Y+1]];Q*=Q,d=Q*Q*(e[$]*F+t[$]*H+o[$]*W)}return 32*(c+u+p+d)}}function Ox(i){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+~~(i()*(256-t)),n=e[t];e[t]=e[o],e[o]=n}for(let t=256;t<512;t++)e[t]=e[t-256];return e}import{Triangle as qI}from"three";var Rr=new qI,du=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 n=1;Rr.a.fromBufferAttribute(r,o),Rr.b.fromBufferAttribute(r,o+1),Rr.c.fromBufferAttribute(r,o+2),n*=Rr.getArea(),e[o/3]=n}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,n=-1;for(;t<=o;){let a=Math.ceil((t+o)/2);if(a===0||e[a-1]<=r&&e[a]>r){n=a;break}else r<e[a]?o=a-1:t=a+1}return n}sampleFace(r,e,t){let o=this.randomFunction(),n=this.randomFunction();return o+n>1&&(o=1-o,n=1-n),Rr.a.fromBufferAttribute(this.positionAttribute,r*3),Rr.b.fromBufferAttribute(this.positionAttribute,r*3+1),Rr.c.fromBufferAttribute(this.positionAttribute,r*3+2),e.set(0,0,0).addScaledVector(Rr.a,o).addScaledVector(Rr.b,n).addScaledVector(Rr.c,1-(o+n)),Rr.getNormal(t),this}};import{Object3D as QI}from"three";var Ax=Ms(Cx());import{Object3D as $I,Matrix4 as so}from"three";var XI=new so,YI=new so,KI=new so,Vo;(r=>{function i(e){return e&&e.__isSPEObject}r.is=i})(Vo||(Vo={}));var ga=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new so;this.copyPreviousMatrix=!0;this.hiddenMatrix=new so;this.matrixWorldRigid=new so;this.shearScale=new so;this.shearScaleInv=new so}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof $I&&(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 n=this.parent;if(t&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),o)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(t,o=0){for(let n of this.children)Vo.is(n)&&n.traverseObject(t,o+1)}traverseObject(t,o=0){if(t(this,o)!==!0)for(let a of this.children)Vo.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:n,v:a,q:s}=(0,Ax.SVD)(o),l=XI.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1),c=YI.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=KI.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 n=new so().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),n.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof so?t.hiddenMatrix.premultiply(n):t.applyMatrix4(n),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,n,a,s,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var Xp=class extends ga(QI){},ZI=i=>i.type==="Mesh",Lr=class extends Xp{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 Lr(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 ZI(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};import{Box3 as vN,BufferGeometry as SN,MeshBasicMaterial as wN}from"three";import{Matrix4 as xN,Mesh as bN}from"three";import{Matrix4 as hu,Vector3 as Ex,Euler as i3,MathUtils as $s}from"three";import{Box3 as JI,Line3 as e3,Matrix4 as Yp,Vector3 as ur}from"three";var rn=new ur,on=new ur,xa=new Yp,Ix=[new ur(-1,1,1),new ur(-1,-1,1),new ur(1,-1,1),new ur(1,1,1),new ur(-1,1,-1),new ur(-1,-1,-1),new ur(1,-1,-1),new ur(1,1,-1)],t3=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],r3=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Mx=(i,r,e)=>{i.updateEntityBoxSize(rn,on),xa.copy(r).multiply(i.matrixWorld),on.x===0&&on.y===0&&on.z===0?e.push(new ur(rn.x,rn.y,rn.z).applyMatrix4(xa)):Ix.forEach(t=>{e.push(t.clone().multiply(on).add(rn).applyMatrix4(xa))})},qs=class extends JI{constructor(){super(...arguments);this.matrix=new Yp;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 Yp().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,t)}expandByObjectSize(e,t,o=!1){let n=[];return o===!0?e.traverseEntity(a=>{if(a.visible||a.cloner&&a.data.visible){if(!("geometry"in a)){n.push(new ur);return}Mx(a,t,n)}}):Mx(e,t,n),this.setFromPoints(n)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(xa.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(on).multiplyScalar(.5),this.getCenter(rn),xa.copy(this.matrix).setPosition(rn),this.vertices=Ix.map(e=>e.clone().multiply(on).applyMatrix4(xa))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=t3.map(([e,t])=>new e3(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new ur))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=r3.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var Br={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};import{CurvePath as o3,CubicBezierCurve3 as Kp,Vector3 as Vr}from"three";var Zp=class extends o3{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 f=0;f<d.length;f++){let h=d[f];t&&t.equals(h)||(e.push(h),t=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var Jp=.001;function ef(i,r,e){return r.clone().sub(i).cross(r.clone().sub(e)).length()<=Jp}function Qp(i,r){let e=new Vr(...i.position),t=new Vr(...i.controlNext.position),o=new Vr(...r.controlPrevious.position),n=new Vr(...r.position);return ef(e,t,n)&&ef(e,o,n)}function fu(i){let r=i.points.map(u=>new Vr(...u.data.position)),e=[i.points[0]],t=new Vr(...e[0].data.position);for(let u=0;u<i.points.length-1;u++)ef(t,r[u],r[u+1])||(e.push(i.points[u]),t=r[u]);e.push(i.points[i.points.length-1]);let o=i.isClosed,n=e.length-(o?0:1),a=e.length,s=[];for(let u=0;u<a;u++){let p=e[u].data,d=new Vr(...p.position),f=new Vr(...p.controlPrevious.position),h=new Vr(...p.controlNext.position),m={position:d,baseRoundness:p.roundness,controlPrevious:f,controlNext:h};if(p.roundness===0||!i.isClosed&&(u===0||u===a-1)){s[u]={...m,removedLength:0};continue}let y=o&&u==0?a-1:u-1,b=o&&u==a-1?0:u+1,v=e[y].data,w=e[b].data,O=new Vr(...v.position),S=new Vr(...w.position),T=O.clone().sub(d).normalize(),M=S.clone().sub(d).normalize();Object.assign(m,{prevDir:T,nextDir:M});let g=Qp(v,p),D=Qp(p,w);if(!g||!D)s[u]={...m,removedLength:0};else{let E=T.clone().add(M).normalize(),I=E.clone().cross(T).length()/T.dot(E);s[u]={...m,tan:I,removedLength:p.roundness/I}}}for(let u=0;u<n;u++){let p=u,d=o&&u===a-1?0:u+1,f=s[p],h=s[d];if(f.removedLength!==0||h.removedLength!==0){let m=f.position.distanceTo(h.position);f.removedLength=Math.min(f.removedLength,m/2),h.removedLength=Math.min(h.removedLength,m/2)}}let l=[];for(let u=0;u<n;u++){let p=u,d=o&&u===a-1?0:u+1,f=s[p],h=s[d],m=null;if(!Qp(e[p].data,e[d].data))f.position.distanceTo(h.position)>Jp&&(m=new Kp(f.position,f.controlNext,h.controlPrevious,h.position));else{let y=f.position.clone(),b=h.position.clone();(f.removedLength!==0||h.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),h.prevDir&&b.add(h.prevDir.clone().setLength(h.removedLength))),y.distanceTo(b)>Jp&&(m=new Kp(y,y.clone().lerp(b,.3),b.clone().lerp(y,.3),b))}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,f=p.prevDir.clone().multiplyScalar(p.removedLength).add(d),h=p.nextDir.clone().multiplyScalar(p.removedLength).add(d),m=p.tan*p.removedLength,y=p.prevDir.clone().add(p.nextDir).normalize(),b=f.clone().lerp(h,.5),v=f.distanceTo(h)/2,w=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(v,2))).add(b),O=y.clone().multiplyScalar(-m).add(w),S=d.distanceTo(O)/d.distanceTo(b),T=p.prevDir.clone().multiplyScalar(S*d.distanceTo(f)).add(d),M=T.clone().lerp(O,2),g=f.clone().lerp(T,4/3),D=h.clone().lerp(M,4/3);l[2*u]=new Kp(f,g,D,h)}let c=new Zp;return l.forEach(u=>{u&&c.add(u)}),c}var De;(r=>{function i(e){return e&&e.__isEntity}r.is=i})(De||(De={}));var ba=i=>De.is(i),n3={type:"completeState",isfromEntity:!0},a3=["x","y","z"],tf=new Ex,s3=new Ex().set(0,1,0),va=i=>class extends ga(i){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 qs;this._recursiveBBox=new qs;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(De.is(o))return o}entityChildrenCount(){let t=this.children.length;for(;t--;)if(De.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(De.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,n=!1){if(!(this.data.states.length===0&&!n)){for(let a of this.data.states)en.toOps(this.data,a.data).forEach(l=>{let c=ea.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=en.patch(this.data,a),en.toOps(this.data,a).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,o)}))}n&&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=>{ba(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let o;return this.traverseEntity(n=>{n.uuid===t&&(o=n)}),o}traverseSortNextHelper(){let t=this.parent;if(t){let o=t.children,n=o.indexOf(this)+1;if(De.is(o[n]))return o[n];if(De.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&De.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,n=this;for(;n!==t;){if(n===null)return-1;n=n.parent,o+=1}return o}forEachEntity(t){for(let o of this.children)ba(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{De.is(o)&&t(o)})}traverseConcreteEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)ba(a)&&a.isConcreteEntity&&a.traverseEntity(t,o+1)}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)ba(a)&&a.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)ba(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=>ba(t))}isAncestorOf(t){if(this.uuid===t)return!1;let o=!1;return this.traverseEntity(n=>{n.uuid===t&&(o=!0)}),o}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x*$s.RAD2DEG,this.rotation.y*$s.RAD2DEG,this.rotation.z*$s.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Yn(o,t)}getTransformValues(t,o,n){return o[t].map((a,s)=>n?.shared.getVariable(a,[this.uuid,t,a3[s]])??a)}updateTransformState(t,o){let n=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,o)),n=!0),t.rotation&&(tf.fromArray(this.getTransformValues("rotation",t,o)).multiplyScalar($s.DEG2RAD),this.rotation.setFromVector3(tf),n=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,o)),n=!0),t.hiddenMatrix!==void 0&&(n=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??di.identity)),n&&(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),n}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)De.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{De.is(t)&&t.disposeRecursively()})}toState(t=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return Yn(o,t)}updateByObjUpdateOp(t,o){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},o,!1)}updateByOp(t,o,n,a){let s=this.data;this.data=o;let l=t,c=Le(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 f=Ze.zoom(d,t.path.slice(2));if(f)for(let h in t.props)t.props[h]===void 0&&h in f&&(p[h]=f[h])}}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,...f}=u;u=f}if(t.props.material!==void 0&&"material"in u){let{material:d,...f}=u;u=f}let p=Ze.removeOverridden(t.path,t.props,u);l={...t,props:p}}}if(this.updateByPatchedOpBase(l,en.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),n),Le(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 f=n.scene.findInstance([this.uuid,...u]);f&&(f.overrideData=t.props[d],f.updateState(Qr.apply(f.component.data,f.overrideData),n))}}else{let d=n.scene.findInstance([this.uuid,...u]);if(d){let f=Ze.zoom(d.component.data,p);if(t={...t,path:p},t.type===0){let h=t.props;if(f)for(let[m,y]of Object.entries(t.props))y===void 0&&(h===t.props&&(h={...t.props}),h[m]=f[m]);t={...t,props:h}}d.overrideData=ua.resolve(o.overrides,u),d.updateByOp(t,nt.applySimple(d.data,t),n,!1)}}}else if(this.instances.length>0){let u;if(t.path.length===0&&t.type===0){let p;for(let d of io.rootOverrideProps)d in t.props&&(p===void 0&&(p={}),p[d]=t.props[d]);p&&(u={...t,props:p})}else for(let p of io.rootOverrideProps)if(Le(t.path,[p])){u=t;break}u!==void 0&&this.instances.forEach(p=>{if(p.isInstanceRoot){let d=Qr.filterOp(p.overrideData,u);d&&p.updateByOp(d,nt.applySimple(p.data,d),n,!0)}}),this.instances.forEach(p=>{if(!p.isInstanceRoot){let d=Qr.filterOp(p.overrideData,t);if(d){let f;s===p.data&&t===d?f=o:f=nt.applySimple(p.data,d),p.updateByOp(d,f,n,!0)}}})}}updateByPatchedOpBase(t,o,n){if(this.dataPatched=o,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Dr.is(t.props.type)&&Br.changeEntityProptotype(this,o,n);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){Br.changeEntityProptotype(this,o,n);for(let a of this.children)De.is(a)&&a.updateVisible(n.scene)}this.updateByPatchedOp(t,o,n)}updateByPatchedOp(t,o,n){if(t.path.length===0&&t.type===0?this.updateState(t.props,n):t.type===0&&("resolutionLevel"in t.props||"useChildrenColors"in t.props)&&this.updateState(o,n),t.path[0]==="morphTargetInfluences"&&t.type===0){let s=o.morphTargetInfluences.get(t.path[1])?.data.name;s&&this.updateMorphInfluences(s,n.shared.getVariable(t.props.value,[this.uuid,"morphTargetInfluences",s]))}if(Le(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Le(t.path,["cloner"])!==null){let a=nt.drop(t,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,n):this.cloner?this.cloner.updateState(o.cloner,n.scene):(this.setFromClonerState(o.cloner,n),this.expandCloner(n.scene)),this.updateVisible(n.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,n=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=fu(c.geometry.path),p=(n+a)%1;n+a===1&&p===0&&(p=1);let d=null;try{d=u.curves.length?u.getPointAt(p):null}catch(y){!1&&(console.warn(`The aligned path on ${this.name} is invalid. (${l.name})`),console.error(y))}if(d===null)return;let f=this.parent?this.parent?.matrixWorld:new hu;l.updateMatrixWorld();let h=new hu().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(h);let m={position:d.toArray(),rotation:c.rotation};if(s==="tangential"){let y=new hu().extractRotation(l.matrixWorld),b=u.getTangentAt(p).applyMatrix4(y).add(d),v=new hu().lookAt(d,b,s3),w=tf.setFromEuler(new i3().setFromRotationMatrix(v)).multiplyScalar($s.RAD2DEG);m={...m,rotation:w.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(n3)})}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(n=>{if(n.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 Br.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 Br.Cloner(this,t),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,o.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}};import{BufferGeometry as u3,ConeGeometry as d3,Float32BufferAttribute as p3,MathUtils as f3}from"three";import{BufferGeometry as Dx,CylinderGeometry as l3,Float32BufferAttribute as yu,MathUtils as c3,Vector2 as zr,Vector3 as mu}from"three";var _x=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=i.parameters?.radiusTop,t=i.parameters?.radiusBottom,o=Object.assign({},r?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters);o.thetaLength=c3.clamp(o.thetaLength,0,360);let n=o.width/2,a=o.radiusTop??n,s=o.radiusBottom??n;if(a===s?(a=n,s=n):a>s?(a=n,s=s*n/a):(a=a*n/s,s=n),o.shapeBlendNode){a=e??n,s=t??n;let l=Math.max(a,s)*2;o.width=l,o.depth=l}return{parameters:Object.assign(o,{width:Math.abs(o.width),height:Math.abs(o.height??o.width),depth:Math.abs(o.depth??o.width),radiusTop:a,radiusBottom:s})}}static build(i){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:n,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:p,cornerSegments:d,hollow:f}=i.parameters,h;return l===0?(h=new Dx,h.setAttribute("position",new yu([],3))):p||f?h=new Xs(c,u,t,o,n,a,s,l*Math.PI/180,p,p,d,f):h=new l3(c,u,t,o,n,a,s,l*Math.PI/180),h.scale(1,1,e/r),Object.assign(h,{userData:{...i,type:"CylinderGeometry"}})}};function gi(i,r,e){e.x=i.x*r.x,e.y=i.y,e.z=i.x*r.y}function Nx(i){return new zr(i.y,-i.x)}var Xs=class extends Dx{constructor(r,e,t,o,n,a,s,l,c,u,p,d,f=!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,n=Math.floor(n)||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 h=[],m=[],y=[],b=[],v=0,w=t/2,O=new mu,S=new mu;f&&r==0&&(r=c),f&&e==0&&(e=u);let T=new zr(r,w),M=new zr(e,-w),g=null,D=null,E=null,I=null,N=T.clone().sub(M),_=0,R=0,V=0;d>0&&(_=Math.min(r,e)*(1-d),R=r-_,V=e-_);let U=T.clone();U.x-=_;let B=Math.PI-N.angle(),q=N.angle(),j=Math.tan(q/2),F=Math.tan(B/2),H=j+F,W=d?H:F,ee=d?H:j;if(c=Math.min(c,(r-R)/W,N.length()/H),u=Math.min(u,(e-V)/ee,N.length()/H),c>0){let Q=c/j;g=T.clone().sub(new zr(Q,c)),d&&(E=g.clone(),E.x-=_-H*c),T.sub(N.clone().setLength(Q))}if(u>0){let Q=u/F;D=M.clone().sub(new zr(Q,-u)),M.add(N.clone().setLength(Q)),d&&(I=D.clone(),I.x-=_-H*u,U.sub(N.clone().setLength(Q)))}N=T.clone().sub(M);let te=N.length()<.5,Y=[];for(let Q=0;Q<=o;Q++){let $=[],ue=Q/o,le=ue*l+s,ie=new zr(Math.sin(le),Math.cos(le));I&&D?(re($,ue,ie,B,u,I,-1,!0),re($,ue,ie,q,u,D,-1,!1)):D?(K($,ie,D.x,0,-1),re($,ue,ie,q,u,D,-1,!1)):a||K($,ie,e,V,-1);let ce=Nx(N).normalize();if(gi(ce,ie,O),!te)for(let ae=0;ae<=n;ae++){let me=ae/n,pe=N.clone().multiplyScalar(me).add(M);gi(pe,ie,S),m.push(S.x,S.y,S.z),y.push(O.x,O.y,O.z),b.push(ue,.5+S.y/t),$.push(v++)}if(E&&g?(re($,ue,ie,B,c,g,1,!1),re($,ue,ie,q,c,E,1,!0)):g?(re($,ue,ie,B,c,g,1,!1),K($,ie,g.x,0,1)):a||K($,ie,r,R,1),d&&!te){let ae=Nx(N).multiplyScalar(-1).normalize();gi(ae,ie,O);for(let me=0;me<=n;me++){let pe=me/n,he=N.clone().multiplyScalar(-pe).add(U);gi(he,ie,S),m.push(S.x,S.y,S.z),y.push(O.x,O.y,O.z),b.push(ue,.5+S.y/t),$.push(v++)}}d&&!a&&$.push($[0]),Y.push($)}for(let Q=0;Q<Y.length-1;Q++)for(let $=0;$<Y[0].length-1;$++){if(a&&d&&$==n)continue;let ue=Y[Q][$],le=Y[Q+1][$],ie=Y[Q+1][$+1],ce=Y[Q][$+1],ae=m[ie*3+0],me=m[ie*3+2];h.push(ue,le,ce),(ae!=0||me!=0)&&h.push(le,ie,ce)}l<Math.PI*2&&(Z(-1,Y[0],s),Z(1,Y[Y.length-1],s+l)),this.setIndex(h),this.setAttribute("position",new yu(m,3)),this.setAttribute("normal",new yu(y,3)),this.setAttribute("uv",new yu(b,2));function re(Q,$,ue,le,ie,ce,ae,me){for(let pe=0;pe<p+1;pe++){let he=pe/p,xe=ae<0?he:1-he;me&&(xe-=1),xe*=le;let ye=new zr(Math.sin(xe),Math.cos(xe)*ae),C=ye.clone().multiplyScalar(ie).add(ce);gi(C,ue,S),m.push(S.x,S.y,S.z),gi(ye,ue,O),y.push(O.x,O.y,O.z),b.push($,.5+S.y/t),Q.push(v++)}}function K(Q,$,ue,le,ie){let ce=new mu,ae=new zr,me=[ue,le];ie<0&&me.reverse();for(let pe of me)ae.set(pe,w*ie),gi(ae,$,ce),m.push(ce.x,ce.y,ce.z),y.push(0,ie,0),b.push(.5,.5),Q.push(v++)}function Z(Q,$,ue){let le=new zr(Math.sin(ue),Math.cos(ue)),ie=new zr(-Math.cos(ue),Math.sin(ue)),ce=new mu,ae=Q<0?(he,xe,ye)=>h.push(he,xe,ye):(he,xe,ye)=>h.push(he,ye,xe),me=new zr((r+e+R+V)/4,0);gi(me,le,ce),m.push(ce.x,ce.y,ce.z),y.push(ie.x,0,ie.y),b.push(.5,.5);let pe=v++;for(let he of $){let xe=m.slice(he*3,he*3+3);m.push(...xe),y.push(ie.x,0,ie.y);let ye=b.slice(he*2,he*2+2);b.push(...ye),v++}for(let he=pe+1;he<v-1;he++)ae(pe,he,he+1);ae(pe,v-1,pe+1)}}};var Rx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,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},i.parameters);return e.thetaLength=f3.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(i){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:n,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:u,cornerSegments:p}=i.parameters,d;return l===0?(d=new u3,d.setAttribute("position",new p3([],3))):c>0||u>0||l<360?d=new Xs(0,r/2,t,o,n,a,s,l*Math.PI/180,c,u,p,0,!0):d=new d3(r/2,t,o,n,a),d.scale(1,1,e/r),Object.assign(d,{userData:{...i,type:"ConeGeometry"}})}};import{BoxGeometry as h3,BufferGeometry as m3,Float32BufferAttribute as rf,Vector3 as Ys}from"three";var Lx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},i.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(i){let{width:r,height:e,depth:t,widthSegments:o,heightSegments:n,depthSegments:a,cornerRadius:s,cornerSegments:l}=i.parameters,c;return s===0?c=new h3(r,e,t,o,n,a):c=new nf(r,e,t,o,n,a,s,l),Object.assign(c,{userData:{...i,type:"CubeGeometry"}})}},of=Math.PI/2,nf=class extends m3{constructor(r=1,e=1,t=1,o=1,n=1,a=1,s=0,l=4){super(),this.type="BoxGeometry",o=Math.floor(o),n=Math.floor(n),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,r/2,e/2,t/2);let c=[],u=[],p=[],d=[],f=0;h("z","y","x",-1,-1,t,e,r,a,n),h("z","y","x",1,-1,t,e,-r,a,n),h("x","z","y",1,1,r,t,e,o,a),h("x","z","y",1,-1,r,t,-e,o,a),h("x","y","z",1,-1,r,e,t,o,n),h("x","y","z",-1,-1,r,e,-t,o,n),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,n),m("y","x","z",1,-1,-1,e,r,t,n),m("y","x","z",1,1,1,e,r,t,n),m("y","x","z",-1,1,-1,e,r,t,n),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 rf(u,3)),this.setAttribute("normal",new rf(p,3)),this.setAttribute("uv",new rf(d,2));function h(b,v,w,O,S,T,M,g,D,E){let I=(T-2*s)/D,N=(M-2*s)/E,_=T/2-s,R=M/2-s,V=g/2,U=D+1,B=E+1,q=0,j=new Ys;for(let F=0;F<B;F++){let H=F*N-R;for(let W=0;W<U;W++){let ee=W*I-_;j[b]=ee*O,j[v]=H*S,j[w]=V,u.push(j.x,j.y,j.z),j[b]=0,j[v]=0,j[w]=g>0?1:-1,p.push(j.x,j.y,j.z),d.push(W/D),d.push(1-F/E),q+=1}}for(let F=0;F<E;F++)for(let H=0;H<D;H++){let W=f+H+U*F,ee=f+H+U*(F+1),te=f+(H+1)+U*(F+1),Y=f+(H+1)+U*F;c.push(W,ee,Y),c.push(ee,te,Y)}f+=q}function m(b,v,w,O,S,T,M,g,D,E){let I=(M-2*s)/E,N=M/2-s,_=g/2-s,R=D/2,V=E+1,U=0,B=new Ys,q=new Ys;for(let j=0;j<l+1;j++){let F=j/l*of,H=Math.sin(F)*s,W=(1-Math.cos(F))*s,ee=Math.sin(F),te=Math.cos(F);B[v]=(_+H)*S,B[w]=(R-W)*T,q[b]=0,q[v]=ee*Math.sign(B[v]),q[w]=te*Math.sign(B[w]);for(let Y=0;Y<V;Y++){let re=Y*I-N;B[b]=re*O,u.push(B.x,B.y,B.z),p.push(q.x,q.y,q.z),d.push(Y/E),d.push(0),U+=1}}for(let j=0;j<l;j++)for(let F=0;F<E;F++){let H=f+F+V*j,W=f+F+V*(j+1),ee=f+(F+1)+V*(j+1),te=f+(F+1)+V*j;c.push(H,W,te),c.push(W,ee,te)}f+=U}function y(b,v,w){let O=new Ys,S=new Ys(r/2,e/2,t/2);S.subScalar(s);let T=[],M=b*v*w>0?(D,E,I)=>c.push(D,E,I):(D,E,I)=>c.push(D,I,E);for(let D=0;D<=l;D++){let E=[],I=of*(1-D/l),N=Math.cos(I),_=Math.sin(I),R=0;for(let V=0;V<=D;V++){let U=Math.cos(R),B=Math.sin(R);O.x=N*U,O.y=_,O.z=N*B;let q=S.clone().addScaledVector(O,s);u.push(b*q.x,v*q.y,w*q.z),p.push(b*O.x,v*O.y,w*O.z),d.push(0,0),E.push(f++),R+=of/D}T.push(E)}let g=T.length-1;for(let D=0;D<g;D++){let E=T[D],I=T[D+1],N=E.length-1;M(E[0],I[1],I[0]);for(let _=1;_<=N;_++)M(E[_-1],E[_],I[_]),M(E[_],I[_+1],I[_])}}}};import{BufferGeometry as y3,Float32BufferAttribute as af,Triangle as g3,Vector3 as zo,Vector2 as sf}from"three";var xi=class extends y3{constructor(r=[],e=[],t="",o=1,n=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],c=[];u(),p(),this.setAttribute("position",new af(s,3)),this.setAttribute("normal",new af(c,3)),this.setAttribute("uv",new af(l,2));return;function u(){n=Math.min(1-1e-5,n),n==0&&(a=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[t],h=new zo,m=h.clone(),y=new g3,b=n*o,v=o-b,w=a+1,O=new zo,S=(j,F)=>O.subVectors(j,F).normalize(),T=(j,F)=>Array(j).fill(void 0).map(F),M=T(r.length/3,(j,F)=>new zo().fromArray(r,F*3).setLength(o)),g=[],D=1e6;for(let j=0;j<M.length;j++){let F=M[j],H=[],W,ee,te,Y=1e10,re=-1;for(;(re=e.indexOf(j,re+1))!=-1;){let $=re-re%3;W=e[$+(re+1)%3],ee=e[$+(re+2)%3],te=F.distanceToSquared(M[W]),Y=Math.min(Y,te),H.push([W,ee,te])}Y+=1e-6;let K=[],Z=0,Q=H.length;for(let $=0;$<Q;$++){[W,ee,te]=H[Z];let ue=g[W]?.includes(j)==!0;te<=Y&&K.push(W+ +ue*D),Z=H.findIndex(le=>le[0]==ee)}g.push(K)}let E=[];{let j=0,F=0,H,W,ee=f==3;for(let te=0;te<=a;te++){H=te*(te+1)/2,W=(te+1)*(te+2)/2;for(let Y=0;Y<a-te;Y++)[j,F]=[H+Y+te+2,W+Y+te+3],E.push(H,W,...ee?[F,H]:[j,W],F,j),[H,W]=[j,F];E.push(H,W,H+a+2)}}let I=h.clone(),N=h.clone(),_=h.clone(),R=h.clone(),V=h.clone(),U=[],B=T(M.length,()=>T(f,()=>h.clone()));for(let j=0;j<M.length;j++){h.copy(M[j]).normalize(),I.copy(h).multiplyScalar(v);let F=g[j];for(let K=0;K<F.length;K++){let Z=F[K],Q=F[(K+1)%f];y.setFromPointsAndIndices(M,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,B[j][K])}let H=[],W=[],ee=[],te=new zo;a==0&&[...B[j]].reduce((K,Z)=>K.add(Z),te).multiplyScalar(1/f);for(let K=0;K<f;K++){let Z=[],Q=(K-1+f)%f,$=B[j][Q],ue=B[j][K];h.copy($).sub(I),m.copy(ue).sub(I);let le=I.angleTo(h),ie=h.angleTo(m),ce=Math.cos(le)*b;a==0?N.copy(te):N.copy(I).setLength(v+ce),W.push(ce);let ae=[N,$,ue];for(let me=0;me<2;me++){let pe=ae[me],he=ae[me+1];R.subVectors(pe,I),V.subVectors(he,I),_.crossVectors(R,V).normalize();for(let xe=0;xe<w;xe++){let ye=[le,ie][me]*xe/w;h.copy(R).applyAxisAngle(_,ye).add(I),H.push(h.clone()),me&&(S(h,I),Z.push([xe==0?pe:h.clone(),O.clone()]))}me&&(S(he,I),Z.push([he,O.clone()]))}ee.push(Z)}U.push(ee);let Y=2*w,re=2;for(let K=0;K<f;K++){let Z=Y*K,Q=Y*((K+1)%f),$=[H[Z]];for(let le=1;le<w;le++){R=H[Z+le],V=H[Q+le],$.push(R);for(let ie=1,ce=le-re+1;ie<=ce;ie++)h.lerpVectors(R,V,ie/(ce+1)),h.sub(I).setLength(W[K]).add(I),$.push(h.clone());$.push(V)}for(let le=0;le<w;le++)$.push(H[le+w+Z]);$.push(H[Q+w]);let ue=E.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 q=[];for(let j=0;j<g.length;j++)for(let F=0;F<f;F++){let H=g[j][F];if(H<D){let W=g[H].findIndex(Y=>Y%D==j),ee=U[j][F],te=U[H][W];for(let Y=0;Y<w;Y++){let re=ee[Y],K=te[w-Y],Z=ee[Y+1],Q=te[w-(Y+1)];[re,K,Z,Z,K,Q].forEach($=>{s.push($[0].x,$[0].y,$[0].z),c.push($[1].x,$[1].y,$[1].z)})}q.push(ee[0][0],te[w][0],ee[w][0],te[0][0])}}for(;q.length;){let j,F,H,W;[j,F]=q.splice(0,2);let ee=[j];for(;j!=F;)ee.push(F),H=q.indexOf(F),W=H%2,F=q.splice(H-W,2)[1-W];O.subVectors(ee[0],ee[1]).cross(h.subVectors(ee[0],ee[2])).normalize();let te=O.dot(ee[0])<0;te&&O.negate();for(let Y=1;Y<=ee.length-2;Y++)[ee[Y+ +te],ee[Y+1-+te],ee[0]].forEach(re=>{s.push(re.x,re.y,re.z),c.push(O.x,O.y,O.z)})}}function p(){let d=new zo;for(let M=0;M<s.length;M+=3){d.x=s[M+0],d.y=s[M+1],d.z=s[M+2];let g=S(d)/2/Math.PI+.5,D=T(d)/Math.PI+.5;l.push(g,1-D)}let f=new zo,h=new zo,m=new zo,y=new zo,b=new sf,v=new sf,w=new sf,O=(M,g,D,E)=>{E<0&&M.x===1&&(l[g]=M.x-1),D.x===0&&D.z===0&&(l[g]=E/2/Math.PI+.5)};for(let M=0,g=0;M<s.length;M+=9,g+=6){f.set(s[M+0],s[M+1],s[M+2]),h.set(s[M+3],s[M+4],s[M+5]),m.set(s[M+6],s[M+7],s[M+8]),b.set(l[g+0],l[g+1]),v.set(l[g+2],l[g+3]),w.set(l[g+4],l[g+5]),y.copy(f).add(h).add(m).divideScalar(3);let D=S(y);O(b,g+0,f,D),O(v,g+2,h,D),O(w,g+4,m,D)}for(let M=0;M<l.length;M+=6){let g=l[M+0],D=l[M+2],E=l[M+4],I=Math.max(g,D,E),N=Math.min(g,D,E);I>.9&&N<.1&&(g<.2&&(l[M+0]+=1),D<.2&&(l[M+2]+=1),E<.2&&(l[M+4]+=1))}function S(M){return Math.atan2(M.z,-M.x)}function T(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(r){return new xi(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};import{DodecahedronGeometry as x3}from"three";var Bx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.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(i){let{width:r,height:e,depth:t,detail:o,corner:n,cornerSides:a}=i.parameters,s=o===0&&n!==0?new Ks(r*.5,n,a):new x3(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...i,type:"DodecahedronGeometry"}})}},Ks=class extends xi{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,n=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,-n,-o,0,-n,o,0,n,-o,0,n,o,-n,-o,0,-n,o,0,n,-o,0,n,o,0,-o,0,-n,o,0,-n,-o,0,n,o,0,n],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 Ks(r.radius,r.corner,r.cornerSides)}};import{Plane as I3,Shape as Qx,Vector2 as Go,Vector3 as E3,MathUtils as hf,LineCurve as mf,QuadraticBezierCurve as Zx,CubicBezierCurve as vu}from"three";import{CubicBezierCurve as gu,EllipseCurve as b3,LineCurve as xu,LineCurve3 as v3,MathUtils as S3,QuadraticBezierCurve as cf,SplineCurve as w3,Vector2 as Wt,Vector3 as Gx}from"three";var Qs=1e-12,Sa=class{constructor(r){this.position=new Wt;this.startPosition=new Wt;this.uuid=S3.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 Sa(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},wa=class extends Sa{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new wa(this.parent).copy(this)}},Gr=class extends Sa{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new wa(this),new wa(this))}static create(e,t){let o=new Gr(e,new Wt(...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,n=this.controls.length;o<n;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 Gr(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 Wt,t=new Wt){let[o,n]=this.computeTangents();return o&&n&&(Vx(o,e),Vx(n,t)),[e,t]}computeTangent(e=new Wt){let[t,o]=this.computeTangents();return t&&o&&e.copy(t).add(o).normalize(),e}computeNormal(e=new Wt){let[t,o]=this.computeNormals();return e.copy(t).add(o).normalize(),e}};function Vx(i,r=new Wt){let e=i.length();return r.set(-i.y/e,i.x/e)}var uf=i=>i,Pa=new Wt,bu=new Wt,P3=new Wt,O3=new Wt,T3=new Wt,C3=new Wt,Fx=new Gx,jx=new Gx;function Ux(i){let r=new Wt;r.addVectors(i.v0,Pa.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new Wt;return e.addVectors(i.v2,bu.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new gu(i.v0,r,e,i.v2)}function Zs(i,r,e=Number.EPSILON){return Math.abs(i-r)<e}function A3(i,r,e=Number.EPSILON){return i.distanceTo(r)<e}function M3(i,r,e=Number.EPSILON){return i.distanceTo(r)<e}function df(i,r,e){let t=Math.sqrt(Math.pow(r.x-i.x,2)+Math.pow(r.y-i.y,2)),o=Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2)),n=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((o*o+t*t-n*n)/(2*o*t))}function kx(i,r,e){return zx(i,r)&&zx(r,e)&&lf(i.position,r.position,e.position)}function lf(i,r,e){return Pa.copy(r).sub(i).cross(bu.copy(e).sub(i))===0}function Hx(i,r,e,t,o){let n=Math.sqrt(Math.pow(r.x-i.x,2)+Math.pow(r.y-i.y,2)),a=(i.y+r.y)/2,s=(i.x+r.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(n/2,2))*(i.y-r.y)/n,c=Math.sqrt(Math.pow(e,2)-Math.pow(n/2,2))*(r.x-i.x)/n;return t.set(s+l,a+c),o.set(s-l,a-c),[t,o]}function Wx(i,r,e){let t=i.distanceTo(e),o=r.distanceTo(e);return t<o?r:i}function qx(i,r,e,t,o,n){let a=r.x-i.x,s=r.y-i.y,l=e.x-i.x,c=e.y-i.y,u=Math.sqrt((a+l)*(a+l)+(s+c)*(s+c)),p;return df(r,i,e)>Math.PI&&(u*=-1),Zs(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),n.set(e.x+p*c,e.y-p*l),[o,n]}function pf(i,r){return i.position.equals(i.controls[1].position)&&r.position.equals(r.controls[0].position)}function zx(i,r){return lf(i.position,i.controls[1].position,r.position)&&lf(i.position,r.controls[0].position,r.position)}function $x(i,r,e,t,o=.5){let n=Pa.subVectors(r,i).multiplyScalar(o).add(i),a=bu.subVectors(e,r).multiplyScalar(o).add(r),s=P3.subVectors(t,e).multiplyScalar(o).add(e),l=n,c=O3.subVectors(a,n).multiplyScalar(o).add(n),u=T3.subVectors(s,a).multiplyScalar(o).add(a),p=s,d=C3.subVectors(u,c).multiplyScalar(o).add(c);return[i.x,i.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(i,r,e=12,t=!0){let o=jx.set(0,0,0),n,a=0,s=[];for(let l=0;l<r.length;l++){let c=uf(r[l]),u=Pa,p=bi(c,e);s.push(p);for(let d=0;d<=p;d++)if(c instanceof gu||c instanceof cf||c instanceof xu){if(c.getPoint(d/p,u),o.set(u.x,u.y,0),n!==void 0&&M3(n,o))continue;n===void 0&&(n=Fx),n.copy(o),i.setXYZ(a,o.x,o.y,o.z),a++}}return t&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),i}function Yx(i,r,e,t=12,o=!0){let n=jx.set(0,0,0),a=0,s=[];for(let l=0;l<r.length;l++){if(e[l]===!1)continue;let c,u=uf(r[l]),p=Pa,d=bi(u,t);s.push(d);for(let f=0;f<=d;f++)if(u instanceof gu||u instanceof cf||u instanceof xu){if(u.getPoint(f/d,p),n.set(p.x,p.y,0),c?.equals(n))continue;c===void 0?c=Fx:(i.setXYZ(a,c.x,c.y,c.z),a++,i.setXYZ(a,n.x,n.y,n.z),a++),c.copy(n)}}return o&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),s}function ff(i,r=12,e=!1){let t=[];for(let o=0,n=i.length;o<n;o++){let a=i[o],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=bi(a.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=bi(a.curveAfter,r)),t.push(s)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(t[i.length-1]+=bi(i[0].roundedCurveCorner,r)*.5),t}function bi(i,r=12){return i&&i instanceof b3?r*2:i&&(i instanceof xu||i instanceof v3)?1:i&&i instanceof w3?r*i.points.length:r}function Kx(i,r,e=12,t=!0){let o,n=0;for(let a=0;a<r.length;a++){let s=uf(r[a]),l=bi(s,e),c=Pa;for(let u=0;u<=l;u++)if(s instanceof gu||s instanceof cf||s instanceof xu){if(s.getPoint(u/l,c),o!==void 0&&A3(o,c,Qs))continue;o===void 0&&(o=bu),o.copy(c),i.push(c.x,c.y),n++}}return Zs(i[0],i[i.length-2],Qs)&&Zs(i[1],i[i.length-1],Qs)&&(i.pop(),i.pop()),t&&n>1&&!(Zs(i[n-1],i[1],Qs)&&Zs(i[n-2],i[0],Qs))&&(i.push(i[0],i[1]),n++),i}var yf=new Go,N3=new Go,D3=new Go,_3=new Go,R3=new Go,L3=new Go,je=class extends Qx{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new I3(new E3(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=hf.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,o){let n=new je;return n.isClosed=e.isClosed,n.points=e.points.map(a=>Gr.create(a.id,a.data)),typeof e.roundness=="number"&&(n.roundness=e.roundness),n.shapeHoles=e.shapeHoles.map(a=>je.createFromState(a)),t!==void 0&&o!==void 0&&n.applySize(t,o),n.update(),n}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,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(n=>n.uuid===e);if(o<0){let n=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)n+=c;else return u+n}}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,n=this.shapeHoles.length;o<n;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,n=this.shapeHoles.length;o<n;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=yf.set(e,t);for(let n=0,a=this.points.length;n<a;n++){let s=this.points[n];s.position.multiply(o),s.controls[0].position.multiply(o),s.controls[1].position.multiply(o)}for(let n=0,a=this.shapeHoles.length;n<a;n++)this.shapeHoles[n].applyScale(e,t);this._update()}createPoint(e,t=0,o=hf.generateUUID()){let n;e instanceof Go?n=e:n=new Go(e,t);let a=new Gr(o,n);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 n=this.points[t];if(n.uuid===e)return n}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 n=o?this.roundedCurveDivisions:this.curveDivisions;return Xx(e,o?this.roundedCurves:this.curves,t,this.autoClose),n.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=ff(this.points,e,!1),this.roundedCurveDivisions=ff(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,o=12){return Yx(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),Kx(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let n=t?this.roundedCurveDivisions:this.curveDivisions,a=0;t&&this.points[0].roundedCurveCorner!==void 0&&(a=bi(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=n.reduce((l,c)=>l+c,0));for(let l=0,c=n.length;l<c;l++){let u=n[l];if(s<o+u)return[l,(s-o+1)/u];o+=u}return[0,1]}getCurveT(e,t,o){let n=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(pf(n,a)){let p=n.position.distanceTo(a.position);return n.position.distanceTo(yf.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){pf(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 n=o.clone();e.roundedCurveBefore=n,t.roundedCurveAfter=n,e.roundedCurveCorner=void 0,this.roundedCurves.push(n)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,o=this.points.length;t<o;t++){let n=this.points[t];if(t===0)this.moveTo(n.position.x,n.position.y);else{let a=this.points[t-1];this._applyCurveForPoint(n,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,n=this.points.length;o<n;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&&kx(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 f=a.roundedCurveBefore,h=a.roundedCurveAfter,m=p.getLength(),y=d.getLength(),b=Math.min(c,m*.499),v=Math.min(c,y*.499),w=Math.min(b,v),O=1-w/m,S=w/y,T=p.getPointAt(O,yf),M=d.getPointAt(S,N3);this._subSplitCurve(p,f,O,T,void 0),this._subSplitCurve(d,h,S,void 0,M);let g;if(this.useCubicForRoundedCorners){let D=df(T,a.position,M)/2,E=Math.tan(D)*T.distanceTo(a.position),[I,N]=Hx(T,M,E,D3,_3),_=Wx(I,N,a.position),[R,V]=qx(_,T,M,E,R3,L3);g=new vu(T.clone(),R.clone(),V.clone(),M.clone())}else g=new Zx(T.clone(),a.position.clone(),M.clone());a.roundedCurveCorner=g,this.roundedCurves.splice(o+t,0,g),t++}}}}_subSplitCurve(e,t,o,n,a){if(e instanceof mf)n!==void 0&&t.v2.copy(n),a!==void 0&&t.v1.copy(a);else{let s=e,l=t,c=s.getUtoTmapping(o,0),u=$x(s.v0,s.v1,s.v2,s.v3,c);return n!==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 je(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 n=o*7,a=e.points[n+0],s=e.points[n+1],l=e.points[n+2],c=e.points[n+3],u=e.points[n+4],p=e.points[n+5],d=e.points[n+6],f=new Gr(hf.generateUUID(),new Go(a,s));f.controls[0].position.set(l,c),f.controls[1].position.set(u,p),f.roundness=d,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let n=new je;return n.fromJSON(o),n}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let o=(a,s)=>{s instanceof vu&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},n=a=>{let s=[],l,c;for(l=0,c=a.length;l<c;l++)a[l]instanceof Zx&&(a[l]=Ux(a[l]));for(l=0,c=a.length;l<c;l++){let d=a[l],f=l>0?a[l-1]:null,h;d instanceof vu?(h=this.createPoint(d.v0),h.controls[1].position.copy(d.v1)):d instanceof mf&&(h=this.createPoint(d.v1)),h!==void 0&&(f!==null&&o(h,f),s.push(h))}let u=a[a.length-1],p=!1;return u instanceof vu?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),p=!0):u instanceof mf&&u.v2.equals(s[0].position)&&(p=!0),this.isClosed=p,s};return this.points=n(e.curves),e instanceof Qx&&(this.shapeHoles=e.holes.map(a=>{let s=new je;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 n=this.getPointByUuid(e)?.controls[0];n&&(t.position&&n.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let n=this.getPointByUuid(e)?.controls[1];n&&(t.position&&n.position.fromArray(t.position),this.needsUpdate=!0)}};var xf=Math.PI*2;function gf({x:i,y:r},e,t,o,n){return{x:i*e+o,y:r*t+n}}function B3(i,r){let e=r===1.5707963267948966?.551915024494:r===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(r/4),t=Math.cos(i),o=Math.sin(i),n=Math.cos(i+r),a=Math.sin(i+r);return[{x:t-o*e,y:o+t*e},{x:n+a*e,y:a-n*e},{x:n,y:a}]}function Jx(i,r,e,t){let o=i*t-r*e<0?-1:1,n=Math.min(1,Math.max(-1,i*e+r*t));return o*Math.acos(n)}function V3(i,r,e,t,o,n,a,s,l,c){let u=Math.pow(o,2),p=Math.pow(n,2),d=Math.pow(a,2),f=Math.pow(s,2),h=u*p-u*f-p*d;h<0&&(h=0),h/=u*f+p*d,h=Math.sqrt(h)*(l===c?-1:1);let m=h*o/n*s,y=h*-n/o*a,b=m+(i+e)/2,v=y+(r+t)/2,w=(a-m)/o,O=(s-y)/n,S=(-a-m)/o,T=(-s-y)/n,M=Jx(1,0,w,O),g=Jx(w,O,S,T);return!c&&g>0&&(g-=xf),c&&g<0&&(g+=xf),{centerx:b,centery:v,ang1:M,ang2:g}}function eb({px:i,py:r,cx:e,cy:t,rx:o,ry:n,largeArcFlag:a,sweepFlag:s}){let l=[];if(o===0||n===0)return[];let c=(i-e)/2,u=(r-t)/2;if(c===0&&u===0)return[];o=Math.abs(o),n=Math.abs(n);let p=Math.pow(c,2)/Math.pow(o,2)+Math.pow(u,2)/Math.pow(n,2);p>1&&(o*=Math.sqrt(p),n*=Math.sqrt(p));let d=V3(i,r,e,t,o,n,c,u,a,s),{ang1:f,ang2:h}=d,{centerx:m,centery:y}=d,b=Math.abs(h)/(xf/4);Math.abs(1-b)<1e-7&&(b=1);let v=Math.max(Math.ceil(b),1);h/=v;for(let w=0;w<v;w++)l.push(B3(f,h)),f+=h;return l.map(w=>{let{x:O,y:S}=gf(w[0],o,n,m,y),{x:T,y:M}=gf(w[1],o,n,m,y),{x:g,y:D}=gf(w[2],o,n,m,y);return{x1:O,y1:S,x2:T,y2:M,x:g,y:D}})}import{BufferAttribute as Tu,BufferGeometry as X3}from"three";var Fe;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Fe||(Fe={}));var st;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(st||(st={}));function we(i,r){if(!i)throw r||"Assertion Failed!"}var ve=function(){function i(){}return i.vertEq=function(r,e){return r.s===e.s&&r.t===e.t},i.vertLeq=function(r,e){return r.s<e.s||r.s===e.s&&r.t<=e.t},i.transLeq=function(r,e){return r.t<e.t||r.t===e.t&&r.s<=e.s},i.edgeGoesLeft=function(r){return i.vertLeq(r.Dst,r.Org)},i.edgeGoesRight=function(r){return i.vertLeq(r.Org,r.Dst)},i.vertL1dist=function(r,e){return Math.abs(r.s-e.s)+Math.abs(r.t-e.t)},i.edgeEval=function(r,e,t){we(i.vertLeq(r,e)&&i.vertLeq(e,t));var o=e.s-r.s,n=t.s-e.s;return o+n>0?o<n?e.t-r.t+(r.t-t.t)*(o/(o+n)):e.t-t.t+(t.t-r.t)*(n/(o+n)):0},i.edgeSign=function(r,e,t){we(i.vertLeq(r,e)&&i.vertLeq(e,t));var o=e.s-r.s,n=t.s-e.s;return o+n>0?(e.t-t.t)*o+(e.t-r.t)*n:0},i.transEval=function(r,e,t){we(i.transLeq(r,e)&&i.transLeq(e,t));var o=e.t-r.t,n=t.t-e.t;return o+n>0?o<n?e.s-r.s+(r.s-t.s)*(o/(o+n)):e.s-t.s+(t.s-r.s)*(n/(o+n)):0},i.transSign=function(r,e,t){we(i.transLeq(r,e)&&i.transLeq(e,t));var o=e.t-r.t,n=t.t-e.t;return o+n>0?(e.s-t.s)*o+(e.s-r.s)*n:0},i.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},i.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))},i.intersect=function(r,e,t,o,n){var a,s,l;i.vertLeq(r,e)||(l=r,r=e,e=l),i.vertLeq(t,o)||(l=t,t=o,o=l),i.vertLeq(r,t)||(l=r,r=t,t=l,l=e,e=o,o=l),i.vertLeq(t,e)?i.vertLeq(e,o)?(a=i.edgeEval(r,t,e),s=i.edgeEval(t,e,o),a+s<0&&(a=-a,s=-s),n.s=i.interpolate(a,t.s,s,e.s)):(a=i.edgeSign(r,t,e),s=-i.edgeSign(r,o,e),a+s<0&&(a=-a,s=-s),n.s=i.interpolate(a,t.s,s,o.s)):n.s=(t.s+e.s)/2,i.transLeq(r,e)||(l=r,r=e,e=l),i.transLeq(t,o)||(l=t,t=o,o=l),i.transLeq(r,t)||(l=r,r=t,t=l,l=e,e=o,o=l),i.transLeq(t,e)?i.transLeq(e,o)?(a=i.transEval(r,t,e),s=i.transEval(t,e,o),a+s<0&&(a=-a,s=-s),n.t=i.interpolate(a,t.t,s,e.t)):(a=i.transSign(r,t,e),s=-i.transSign(r,o,e),a+s<0&&(a=-a,s=-s),n.t=i.interpolate(a,t.t,s,o.t)):n.t=(t.t+e.t)/2},i}(),Js=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),Su=function(){function i(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(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(r){this.Sym.Lface=r},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(r){this.Sym.Org=r},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(r){this.Sym.Lnext=r},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(r){this.Onext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(r){this.Lnext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(r){this.Sym.Onext=r},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(r){this.Sym.Onext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(r){this.Sym.Lnext.Sym=r},enumerable:!0,configurable:!0}),i}(),Oa=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return i}(),tb=function(){function i(){var r=new Oa,e=new Js,t=new Su(0),o=new Su(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 i.prototype.makeEdge_=function(r){var e=new Su(0),t=new Su(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},i.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},i.prototype.makeVertex_=function(r,e,t){var o=r;we(o,"Vertex can't be null!");var n=t.prev;o.prev=n,n.next=o,o.next=t,t.prev=o,o.anEdge=e;var a=e;do a.Org=o,a=a.Onext;while(a!==e)},i.prototype.makeFace_=function(r,e,t){var o=r;we(o,"Face can't be null");var n=t.prev;o.prev=n,n.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)},i.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},i.prototype.killVertex_=function(r,e){var t=r.anEdge,o=t;do o.Org=e,o=o.Onext;while(o!==t);var n=r.prev,a=r.next;a.prev=n,n.next=a},i.prototype.killFace_=function(r,e){var t=r.anEdge,o=t;do o.Lface=e,o=o.Lnext;while(o!==t);var n=r.prev,a=r.next;a.prev=n,n.next=a},i.prototype.makeEdge=function(){var r=new Oa,e=new Oa,t=new Js,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},i.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 n=new Oa;this.makeVertex_(n,e,r.Org),r.Org.anEdge=r}if(!t){var a=new Js;this.makeFace_(a,e,r.Lface),r.Lface.anEdge=r}}},i.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 Js;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)},i.prototype.addEdgeVertex=function(r){var e=this.makeEdge_(r),t=e.Sym;this.splice_(e,r.Lnext),e.Org=r.Dst;var o=new Oa;return this.makeVertex_(o,t,e.Org),e.Lface=t.Lface=r.Lface,e},i.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},i.prototype.connect=function(r,e){var t=!1,o=this.makeEdge_(r),n=o.Sym;if(e.Lface!==r.Lface&&(t=!0,this.killFace_(e.Lface,r.Lface)),this.splice_(o,r.Lnext),this.splice_(n,e),o.Org=r.Dst,n.Org=e.Org,o.Lface=n.Lface=r.Lface,r.Lface.anEdge=n,!t){var a=new Js;this.makeFace_(a,o,r.Lface)}return o},i.prototype.zapFace=function(r){var e=r.anEdge,t,o,n,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)),n=t.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(t));while(t!=e);a=r.prev,s=r.next,s.prev=a,a.next=s},i.prototype.countFaceVerts_=function(r){var e=r.anEdge,t=0;do t++,e=e.Lnext;while(e!==r.anEdge);return t},i.prototype.mergeConvexFaces=function(r){var e,t,o,n,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,n=t.Sym,n&&n.Lface&&n.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(n.Lface),s+l-2<=r&&ve.vertCCW(t.Lprev.Org,t.Org,n.Lnext.Lnext.Org)&&ve.vertCCW(n.Lprev.Org,n.Org,t.Lnext.Lnext.Org)&&(o=n.Lnext,this.delete(n),t=null,n=null)),!(t&&t.Lnext.Org===a);)t=o;return!0},i.prototype.check=function(){var r=this.fHead,e=this.vHead,t=this.eHead,o,n,a,s,l,c;for(n=r,n=r;(o=n.next)!==r;n=o){we(o.prev===n),l=o.anEdge;do we(l.Sym!==l),we(l.Sym.Sym===l),we(l.Lnext.Onext.Sym===l),we(l.Onext.Sym.Lnext===l),we(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(we(o.prev===n&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){we(a.prev===s),l=a.anEdge;do we(l.Sym!==l),we(l.Sym.Sym===l),we(l.Lnext.Onext.Sym===l),we(l.Onext.Sym.Lnext===l),we(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(we(a.prev===s&&a.anEdge===null),c=t,c=t;(l=c.next)!==t;c=l)we(l.Sym.next===c.Sym),we(l.Sym!==l),we(l.Sym.Sym===l),we(l.Org!==null),we(l.Dst!==null),we(l.Lnext.Onext.Sym===l),we(l.Onext.Sym.Lnext===l);we(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),rb=function(){function i(){this.handle=null}return i}(),ob=function(){function i(){this.key=null,this.node=0}return i}(),z3=function(){function i(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 rb,this.handles[t]=new ob;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(r){var e=this.nodes,t=this.handles,o,n,a;for(o=e[r].handle;;){if(a=r<<1,a<this.size&&this.leq(t[e[a+1].handle].key,t[e[a].handle].key)&&++a,we(a<=this.max),n=e[a].handle,a>this.size||this.leq(t[o].key,t[n].key)){e[r].handle=o,t[o].node=r;break}e[r].handle=n,t[n].node=r,r=a}},i.prototype.floatUp_=function(r){var e=this.nodes,t=this.handles,o,n,a;for(o=e[r].handle;;){if(a=r>>1,n=e[a].handle,a===0||this.leq(t[n].key,t[o].key)){e[r].handle=o,t[o].node=r;break}e[r].handle=n,t[n].node=r,r=a}},i.prototype.init=function(){for(var r=this.size;r>=1;--r)this.floatDown_(r);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(r){var e,t;if(e=++this.size,e*2>this.max){this.max*=2;var o,n;for(n=this.nodes.length,this.nodes.length=this.max+1,o=n;o<this.nodes.length;o++)this.nodes[o]=new rb;for(n=this.handles.length,this.handles.length=this.max+1,o=n;o<this.handles.length;o++)this.handles[o]=new ob}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},i.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},i.prototype.delete=function(r){var e=this.nodes,t=this.handles,o;we(r>=1&&r<=this.max&&t[r].key!==null),o=t[r].node,e[o].handle=e[this.size].handle,t[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(t[e[o>>1].handle].key,t[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),t[r].key=null,t[r].node=this.freeList,this.freeList=r},i}(),bf=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),ib=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),G3=function(){function i(r,e){this.frame=r,this.leq=e,this.head=new ib,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(r){return this.insertBefore(this.head,r)},i.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},i.prototype.insertBefore=function(r,e){do r=r.prev;while(r.key!==null&&!this.leq(this.frame,r.key,e));var t=new ib;return t.key=e,t.next=r.next,r.next.prev=t,t.prev=r,r.next=t,t},i.prototype.delete=function(r){r.next.prev=r.prev,r.prev.next=r.next},i}(),F3=function(){function i(){}return i.regionBelow=function(r){return r.nodeUp.prev.key},i.regionAbove=function(r){return r.nodeUp.next.key},i.debugEvent=function(r){},i.addWinding=function(r,e){r.winding+=e.winding,r.Sym.winding+=e.Sym.winding},i.edgeLeq=function(r,e,t){var o=r.event,n=e.eUp,a=t.eUp;if(n.Dst===o)return a.Dst===o?ve.vertLeq(n.Org,a.Org)?ve.edgeSign(a.Dst,n.Org,a.Org)<=0:ve.edgeSign(n.Dst,a.Org,n.Org)>=0:ve.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return ve.edgeSign(n.Dst,o,n.Org)>=0;var s=ve.edgeEval(n.Dst,o,n.Org),l=ve.edgeEval(a.Dst,o,a.Org);return s>=l},i.deleteRegion=function(r,e){e.fixUpperEdge&&we(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},i.fixUpperEdge=function(r,e,t){we(e.fixUpperEdge),r.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=t,t.activeRegion=e},i.topLeftRegion=function(r,e){var t=e.eUp.Org,o;do e=i.regionAbove(e);while(e.eUp.Org===t);if(e.fixUpperEdge){if(o=r.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;i.fixUpperEdge(r,e,o),e=i.regionAbove(e)}return e},i.topRightRegion=function(r){var e=r.eUp.Dst;do r=i.regionAbove(r);while(r.eUp.Dst===e);return r},i.addRegionBelow=function(r,e,t){var o=new bf;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},i.isWindingInside=function(r,e){switch(r.windingRule){case Fe.ODD:return(e&1)!==0;case Fe.NONZERO:return e!==0;case Fe.POSITIVE:return e>0;case Fe.NEGATIVE:return e<0;case Fe.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(r,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(r,e.windingNumber)},i.finishRegion=function(r,e){var t=e.eUp,o=t.Lface;o.inside=e.inside,o.anEdge=t,i.deleteRegion(r,e)},i.finishLeftRegions=function(r,e,t){for(var o,n=null,a=e,s=e.eUp;a!==t;){if(a.fixUpperEdge=!1,n=i.regionBelow(a),o=n.eUp,o.Org!=s.Org){if(!n.fixUpperEdge){i.finishRegion(r,a);break}o=r.mesh.connect(s.Lprev,o.Sym),i.fixUpperEdge(r,n,o)}s.Onext!==o&&(r.mesh.splice(o.Oprev,o),r.mesh.splice(s,o)),i.finishRegion(r,a),s=n.eUp,a=n}return s},i.addRightEdges=function(r,e,t,o,n,a){var s,l,c,u,p=!0;c=t;do we(ve.vertLeq(c.Org,c.Dst)),i.addRegionBelow(r,e,c.Sym),c=c.Onext;while(c!==o);for(n===null&&(n=i.regionBelow(e).eUp.Rprev),l=e,u=n;s=i.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=i.isWindingInside(r,s.windingNumber),l.dirty=!0,!p&&i.checkForRightSplice(r,l)&&(i.addWinding(c,u),i.deleteRegion(r,l),r.mesh.delete(u)),p=!1,l=s,u=c;l.dirty=!0,we(l.windingNumber-c.winding===s.windingNumber),a&&i.walkDirtyRegions(r,l)},i.spliceMergeVertices=function(r,e,t){r.mesh.splice(e,t)},i.vertexWeights=function(r,e,t){var o=ve.vertL1dist(e,r),n=ve.vertL1dist(t,r),a=.5*n/(o+n),s=.5*o/(o+n);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]},i.getIntersectData=function(r,e,t,o,n,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,t,o),i.vertexWeights(e,n,a)},i.checkForRightSplice=function(r,e){var t=i.regionBelow(e),o=e.eUp,n=t.eUp;if(ve.vertLeq(o.Org,n.Org)){if(ve.edgeSign(n.Dst,o.Org,n.Org)>0)return!1;ve.vertEq(o.Org,n.Org)?o.Org!==n.Org&&(r.pq.delete(o.Org.pqHandle),i.spliceMergeVertices(r,n.Oprev,o)):(r.mesh.splitEdge(n.Sym),r.mesh.splice(o,n.Oprev),e.dirty=t.dirty=!0)}else{if(ve.edgeSign(o.Dst,n.Org,o.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,r.mesh.splitEdge(o.Sym),r.mesh.splice(n.Oprev,o)}return!0},i.checkForLeftSplice=function(r,e){var t=i.regionBelow(e),o=e.eUp,n=t.eUp,a;if(we(!ve.vertEq(o.Dst,n.Dst)),ve.vertLeq(o.Dst,n.Dst)){if(ve.edgeSign(o.Dst,n.Dst,o.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,a=r.mesh.splitEdge(o),r.mesh.splice(n.Sym,a),a.Lface.inside=e.inside}else{if(ve.edgeSign(n.Dst,o.Dst,n.Org)>0)return!1;e.dirty=t.dirty=!0,a=r.mesh.splitEdge(n),r.mesh.splice(o.Lnext,n.Sym),a.Rface.inside=e.inside}return!0},i.checkForIntersect=function(r,e){var t=i.regionBelow(e),o=e.eUp,n=t.eUp,a=o.Org,s=n.Org,l=o.Dst,c=n.Dst,u,p,d=new Oa,f,h;if(we(!ve.vertEq(c,l)),we(ve.edgeSign(l,r.event,a)<=0),we(ve.edgeSign(c,r.event,s)>=0),we(a!==r.event&&s!==r.event),we(!e.fixUpperEdge&&!t.fixUpperEdge),a===s||(u=Math.min(a.t,l.t),p=Math.max(s.t,c.t),u>p))return!1;if(ve.vertLeq(a,s)){if(ve.edgeSign(c,a,s)>0)return!1}else if(ve.edgeSign(l,s,a)<0)return!1;return i.debugEvent(r),ve.intersect(l,a,c,s,d),we(Math.min(a.t,l.t)<=d.t),we(d.t<=Math.max(s.t,c.t)),we(Math.min(c.s,l.s)<=d.s),we(d.s<=Math.max(s.s,a.s)),ve.vertLeq(d,r.event)&&(d.s=r.event.s,d.t=r.event.t),f=ve.vertLeq(a,s)?a:s,ve.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),ve.vertEq(d,a)||ve.vertEq(d,s)?(i.checkForRightSplice(r,e),!1):!ve.vertEq(l,r.event)&&ve.edgeSign(l,r.event,d)>=0||!ve.vertEq(c,r.event)&&ve.edgeSign(c,r.event,d)<=0?c===r.event?(r.mesh.splitEdge(o.Sym),r.mesh.splice(n.Sym,o),e=i.topLeftRegion(r,e),o=i.regionBelow(e).eUp,i.finishLeftRegions(r,i.regionBelow(e),t),i.addRightEdges(r,e,o.Oprev,o,o,!0),!0):l===r.event?(r.mesh.splitEdge(n.Sym),r.mesh.splice(o.Lnext,n.Oprev),t=e,e=i.topRightRegion(e),h=i.regionBelow(e).eUp.Rprev,t.eUp=n.Oprev,n=i.finishLeftRegions(r,t,null),i.addRightEdges(r,e,n.Onext,o.Rprev,h,!0),!0):(ve.edgeSign(l,r.event,d)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,r.mesh.splitEdge(o.Sym),o.Org.s=r.event.s,o.Org.t=r.event.t),ve.edgeSign(c,r.event,d)<=0&&(e.dirty=t.dirty=!0,r.mesh.splitEdge(n.Sym),n.Org.s=r.event.s,n.Org.t=r.event.t),!1):(r.mesh.splitEdge(o.Sym),r.mesh.splitEdge(n.Sym),r.mesh.splice(n.Oprev,o),o.Org.s=d.s,o.Org.t=d.t,o.Org.pqHandle=r.pq.insert(o.Org),i.getIntersectData(r,o.Org,a,l,s,c),i.regionAbove(e).dirty=e.dirty=t.dirty=!0,!1)},i.walkDirtyRegions=function(r,e){for(var t=i.regionBelow(e),o,n;;){for(;t.dirty;)e=t,t=i.regionBelow(t);if(!e.dirty&&(t=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,n=t.eUp,o.Dst!==n.Dst&&i.checkForLeftSplice(r,e)&&(t.fixUpperEdge?(i.deleteRegion(r,t),r.mesh.delete(n),t=i.regionBelow(e),n=t.eUp):e.fixUpperEdge&&(i.deleteRegion(r,e),r.mesh.delete(o),e=i.regionAbove(t),o=e.eUp)),o.Org!==n.Org)if(o.Dst!==n.Dst&&!e.fixUpperEdge&&!t.fixUpperEdge&&(o.Dst===r.event||n.Dst===r.event)){if(i.checkForIntersect(r,e))return}else i.checkForRightSplice(r,e);o.Org===n.Org&&o.Dst===n.Dst&&(i.addWinding(n,o),i.deleteRegion(r,e),r.mesh.delete(o),e=i.regionAbove(t))}},i.connectRightVertex=function(r,e,t){var o,n=t.Onext,a=i.regionBelow(e),s=e.eUp,l=a.eUp,c=!1;if(s.Dst!==l.Dst&&i.checkForIntersect(r,e),ve.vertEq(s.Org,r.event)&&(r.mesh.splice(n.Oprev,s),e=i.topLeftRegion(r,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(r,i.regionBelow(e),a),c=!0),ve.vertEq(l.Org,r.event)&&(r.mesh.splice(t,l.Oprev),t=i.finishLeftRegions(r,a,null),c=!0),c){i.addRightEdges(r,e,t.Onext,n,n,!0);return}ve.vertLeq(l.Org,s.Org)?o=l.Oprev:o=s,o=r.mesh.connect(t.Lprev,o),i.addRightEdges(r,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(r,e)},i.connectLeftDegenerate=function(r,e,t){var o,n,a,s,l;if(o=e.eUp,ve.vertEq(o.Org,t)){we(!1),i.spliceMergeVertices(r,o,t.anEdge);return}if(!ve.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),i.sweepEvent(r,t);return}we(!1),e=i.topRightRegion(e),l=i.regionBelow(e),a=l.eUp.Sym,n=s=a.Onext,l.fixUpperEdge&&(we(n!==a),i.deleteRegion(r,l),r.mesh.delete(a),a=n.Oprev),r.mesh.splice(t.anEdge,a),ve.edgeGoesLeft(n)||(n=null),i.addRightEdges(r,e,a.Onext,s,n,!0)},i.connectLeftVertex=function(r,e){var t,o,n,a,s,l,c=new bf;if(c.eUp=e.anEdge.Sym,t=r.dict.search(c).key,o=i.regionBelow(t),!!o){if(a=t.eUp,s=o.eUp,ve.edgeSign(a.Dst,e,a.Org)===0){i.connectLeftDegenerate(r,t,e);return}if(n=ve.vertLeq(s.Dst,a.Dst)?t:o,t.inside||n.fixUpperEdge){if(n===t)l=r.mesh.connect(e.anEdge.Sym,a.Lnext);else{var u=r.mesh.connect(s.Dnext,e.anEdge);l=u.Sym}n.fixUpperEdge?i.fixUpperEdge(r,n,l):i.computeWinding(r,i.addRegionBelow(r,t,l)),i.sweepEvent(r,e)}else i.addRightEdges(r,t,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(r,e){r.event=e,i.debugEvent(r);for(var t=e.anEdge;t.activeRegion===null;)if(t=t.Onext,t===e.anEdge){i.connectLeftVertex(r,e);return}var o=i.topLeftRegion(r,t.activeRegion);we(o!==null);var n=i.regionBelow(o),a=n.eUp,s=i.finishLeftRegions(r,n,null);s.Onext===a?i.connectRightVertex(r,o,s):i.addRightEdges(r,o,s.Onext,a,a,!0)},i.addSentinel=function(r,e,t,o){var n=new bf,a=r.mesh.makeEdge();a.Org.s=t,a.Org.t=o,a.Dst.s=e,a.Dst.t=o,r.event=a.Dst,n.eUp=a,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=r.dict.insert(n)},i.initEdgeDict=function(r){r.dict=new G3(r,i.edgeLeq);var e=r.bmax[0]-r.bmin[0],t=r.bmax[1]-r.bmin[1],o=r.bmin[0]-e,n=r.bmax[0]+e,a=r.bmin[1]-t,s=r.bmax[1]+t;i.addSentinel(r,o,n,a),i.addSentinel(r,o,n,s)},i.doneEdgeDict=function(r){for(var e,t=0;(e=r.dict.min().key)!==null;)e.sentinel||(we(e.fixUpperEdge),we(++t===1)),we(e.windingNumber===0),i.deleteRegion(r,e)},i.removeDegenerateEdges=function(r){var e,t,o,n=r.mesh.eHead;for(e=n.next;e!==n;e=t)t=e.next,o=e.Lnext,ve.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.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))},i.initPriorityQ=function(r){var e,t,o,n=0;for(o=r.mesh.vHead,t=o.next;t!==o;t=t.next)n++;for(n+=8,e=r.pq=new z3(n,ve.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)},i.donePriorityQ=function(r){r.pq=null},i.removeDegenerateFaces=function(r,e){var t,o,n;for(t=e.fHead.next;t!==e.fHead;t=o)o=t.next,n=t.anEdge,we(n.Lnext!==n),n.Lnext.Lnext===n&&(i.addWinding(n.Onext,n),r.mesh.delete(n));return!0},i.computeInterior=function(r,e){e===void 0&&(e=!0);var t,o;if(i.removeDegenerateEdges(r),!i.initPriorityQ(r))return!1;for(i.initEdgeDict(r);(t=r.pq.extractMin())!==null;){for(;o=r.pq.min(),!(o===null||!ve.vertEq(o,t));)o=r.pq.extractMin(),i.spliceMergeVertices(r,t.anEdge,o.anEdge);i.sweepEvent(r,t)}return r.event=r.dict.min().key.eUp.Org,i.debugEvent(r),i.doneEdgeDict(r),i.donePriorityQ(r),i.removeDegenerateFaces(r,r.mesh)?(e&&r.mesh.check(),!0):!1},i}(),j3=function(){function i(){this.mesh=new tb,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=Fe.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]},i.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},i.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},i.prototype.computeNormal_=function(r){var e,t,o,n,a,s,l=[0,0,0],c=[0,0,0],u=[0,0,0],p=[0,0,0],d=[0,0,0],f=[null,null,null],h=[null,null,null],m=this.mesh.vHead;e=m.next;for(var y=0;y<3;++y)n=e.coords[y],c[y]=n,h[y]=e,l[y]=n,f[y]=e;for(e=m.next;e!==m;e=e.next)for(var b=0;b<3;++b)n=e.coords[b],n<c[b]&&(c[b]=n,h[b]=e),n>l[b]&&(l[b]=n,f[b]=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=h[v],o=f[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)},i.prototype.checkOrientation_=function(){for(var r=this.mesh.fHead,e,t=this.mesh.vHead,o,n=0,a=r.next;a!==r;a=a.next)if(o=a.anEdge,!(o.winding<=0))do n+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==a.anEdge);if(n<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]}},i.prototype.projectPolygon_=function(){var r=this.mesh.vHead,e=[0,0,0],t,o,n=!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),n=!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);n&&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))},i.prototype.addWinding_=function(r,e){r.winding+=e.winding,r.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(r,e){var t,o;if(t=e.anEdge,!(t.Lnext!==t&&t.Lnext.Lnext!==t))throw"Mono region invalid";for(;ve.vertLeq(t.Dst,t.Org);t=t.Lprev);for(;ve.vertLeq(t.Org,t.Dst);t=t.Lnext);o=t.Lprev;for(var n=void 0;t.Lnext!==o;)if(ve.vertLeq(t.Dst,o.Org)){for(;o.Lnext!==t&&(ve.edgeGoesLeft(o.Lnext)||ve.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)n=r.connect(o.Lnext,o),o=n.Sym;o=o.Lprev}else{for(;o.Lnext!==t&&(ve.edgeGoesRight(t.Lprev)||ve.edgeSign(t.Dst,t.Org,t.Lprev.Org)>=0);)n=r.connect(t,t.Lprev),t=n.Sym;t=t.Lnext}if(o.Lnext===t)throw"Mono region invalid";for(;o.Lnext.Lnext!==t;)n=r.connect(o.Lnext,o),o=n.Sym;return!0},i.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},i.prototype.discardExterior_=function(r){for(var e,t=r.fHead.next;t!==r.fHead;t=e)e=t.next,t.inside||r.zapFace(t)},i.prototype.setWindingNumber_=function(r,e,t){for(var o,n=r.eHead.next;n!==r.eHead;n=o)o=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?e:-e:t?r.delete(n):n.winding=0},i.prototype.getNeighbourFace_=function(r){return!r.Rface||!r.Rface.inside?-1:r.Rface.n},i.prototype.outputPolymesh_=function(r,e,t,o){var n,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){n=u.anEdge,l=0;do{var c=n.Org;c.n===-1&&(c.n=s,s++),l++,n=n.Lnext}while(n!==u.anEdge);if(l>t)throw"Face vertex greater that support polygon";u.n=a,++a}this.elementCount=a,e===st.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){n=u.anEdge,l=0;do{var c=n.Org;this.elements[d++]=c.n,l++,n=n.Lnext}while(n!==u.anEdge);for(var f=l;f<t;++f)this.elements[d++]=-1;if(e===st.CONNECTED_POLYGONS){n=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==u.anEdge);for(var h=l;h<t;++h)this.elements[d++]=-1}}},i.prototype.outputContours_=function(r,e){var t,o,n=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;n=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++]=n,this.elements[u++]=a,n+=a}},i.prototype.addContour=function(r,e){this.mesh===null&&(this.mesh=new tb),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},i.prototype.tesselate=function(r,e,t,o,n,a){if(r===void 0&&(r=Fe.ODD),e===void 0&&(e=st.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=r,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),F3.computeInterior(this,a);var s=this.mesh;return e===st.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===st.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,t,o),!0},i}();function Fr(i){var r=i.windingRule,e=r===void 0?Fe.ODD:r,t=i.elementType,o=t===void 0?st.POLYGONS:t,n=i.polySize,a=n===void 0?3:n,s=i.vertexSize,l=s===void 0?2:s,c=i.normal,u=c===void 0?[0,0,1]:c,p=i.contours,d=p===void 0?[]:p,f=i.strict,h=f===void 0?!0:f,m=i.debug,y=m===void 0?!1:m;if(!d&&h)throw new Error("Contours can't be empty");if(!!d){var b=new j3;i.edgeCreateCallback&&(b.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(b.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<d.length;v++)b.addContour(l||2,d[v]);return b.tesselate(e,o,a,l,u,h),{vertices:b.vertices,vertexIndices:b.vertexIndices,vertexCount:b.vertexCount,elements:b.elements,elementCount:b.elementCount,mesh:y?b.mesh:void 0}}}var M9=Fe.ODD,I9=Fe.NONZERO,E9=Fe.POSITIVE,N9=Fe.NEGATIVE,D9=Fe.ABS_GEQ_TWO,_9=st.POLYGONS,R9=st.CONNECTED_POLYGONS,L9=st.BOUNDARY_CONTOURS;import{Box2 as W3,BufferAttribute as Ou,BufferGeometry as q3,Vector2 as $3}from"three";var wu=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*wu.eSize;this.buffer=new ArrayBuffer(t);let o=Float32Array.BYTES_PER_ELEMENT,n=0;this.positions=new Float32Array(this.buffer,n*o,3*r),n+=3*r,this.normals=new Float32Array(this.buffer,n*o,3*r),n+=3*r,this.uvs=new Float32Array(this.buffer,n*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*wu.eSize,o=new ArrayBuffer(t),n=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*n,3*r);a+=3*r;let l=new Float32Array(o,a*n,3*r);a+=3*r;let c=new Float32Array(o,a*n,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)}},el=wu;el.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var tl=class{constructor(r=[],e=(t,o)=>t<o?-1:t>o?1:0){if(this.data=r,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(r){this.data.push(r),this._up(this.length++)}pop(){if(this.length===0)return;let r=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),r}peek(){return this.data[0]}_up(r){let{data:e,compare:t}=this,o=e[r];for(;r>0;){let n=r-1>>1,a=e[n];if(t(o,a)>=0)break;e[r]=a,r=n}e[r]=o}_down(r){let{data:e,compare:t}=this,o=this.length>>1,n=e[r];for(;r<o;){let a=(r<<1)+1,s=a+1;if(s<this.length&&t(e[s],e[a])<0&&(a=s),t(e[a],n)>=0)break;e[r]=e[a],r=a}e[r]=n}};function vf(i,r,e=1,t=!1){let o=1/0,n=1/0,a=-1/0,s=-1/0;for(let[v,w]of i[0])v<o&&(o=v),w<n&&(n=w),v>a&&(a=v),w>s&&(s=w);let l=a-o,c=s-n,u=Math.max(e,Math.min(l,c));if(u===e){let v=[o,n];return v.distance=0,v.distance}let p=new tl([],(v,w)=>w.max-v.max),d=k3(i),f=new Pu(o+l/2,n+c/2,0,i);f.d>d.d&&(d=f);let h=2;function m(v,w,O){let S=new Pu(v,w,O,i);if(h++,S.max>d.d+e&&p.push(S),S.d>d.d&&(d=S,t&&console.log(`found best ${Math.round(1e4*S.d)/1e4} after ${h} probes`),d.d>r))return r}let y=u/2;for(let v=o;v<a;v+=u)for(let w=n;w<s;w+=u)m(v+y,w+y,y);for(;p.length;){let{max:v,x:w,y:O,h:S}=p.pop();if(v-d.d<=e)break;y=S/2,m(w-y,O-y,y),m(w+y,O-y,y),m(w-y,O+y,y),m(w+y,O+y,y)}t&&console.log(`num probes: ${h}
3
+ best distance: ${d.d}`);let b=[d.x,d.y];return b.distance=d.d,b.distance}function Pu(i,r,e,t){this.x=i,this.y=r,this.h=e,this.d=U3(i,r,t),this.max=this.d+this.h*Math.SQRT2}function U3(i,r,e){let t=!1,o=1/0;for(let n of e)for(let a=0,s=n.length,l=s-1;a<s;l=a++){let c=n[a],u=n[l];c[1]>r!=u[1]>r&&i<(u[0]-c[0])*(r-c[1])/(u[1]-c[1])+c[0]&&(t=!t),o=Math.min(o,H3(i,r,c,u))}return o===0?0:(t?1:-1)*Math.sqrt(o)}function k3(i){let r=0,e=0,t=0,o=i[0];for(let a=0,s=o.length,l=s-1;a<s;l=a++){let c=o[a],u=o[l],p=c[0]*u[1]-u[0]*c[1];e+=(c[0]+u[0])*p,t+=(c[1]+u[1])*p,r+=p*3}let n=new Pu(e/r,t/r,0,i);return r===0||n.d<0?new Pu(o[0][0],o[0][1],0,i):n}function H3(i,r,e,t){let o=e[0],n=e[1],a=t[0]-o,s=t[1]-n;if(a!==0||s!==0){let l=((i-o)*a+(r-n)*s)/(a*a+s*s);l>1?(o=t[0],n=t[1]):l>0&&(o+=a*l,n+=s*l)}return a=i-o,s=r-n,a*a+s*s}var rl={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},wf={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},Sf=(i,r)=>([e,t])=>(t<e&&(t+=r),(i>=e?i:i+r)<=t),vi=class extends q3{constructor(e,t,o=0,n=12,a=3,s=Fe.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._curveSegments=n,this._bevelSegmentsInput=a;let c=this._shape.extractShapePointsToFlatArray([],n),u=this._shape.shapeHoles.map(I=>{let N=I.extractShapePointsToFlatArray([],n),_=[];for(let R=N.length-1;R>=1;R-=2){let V=N[R-1],U=N[R-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 N=u[I],_=[];for(let R=0;R<N.length;R+=2)_.push([N[R],N[R+1]]);p.push(_)}let f;e.isText?f=new W3().setFromPoints(e.points.map(N=>N.position)).getSize(new $3).length()*.1:p[0].length===0?f=o:o>0?f=vf(p,o):f=1e-5,o<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(o,f,t/2),this._bevelSegments=Math.floor(a));let h;try{h=Fr({windingRule:s,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{h=rl}let m;try{m=Fr({windingRule:Fe.ODD,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{m=wf}if(!h)throw new Error("error generating geometry");let y=h.elementCount;if(m){h.elementCount+=m.elementCount;for(let I=0;I<m.elements.length;I++){let N=m.elements[I],_=I%2===0?h.vertexCount:0;h.elements.push(N+_)}for(let I=0;I<m.vertexIndices.length;I++){let N=m.vertexIndices[I],_=h.vertexCount;h.vertexIndices.push(N+_)}for(let I=0;I<m.vertices.length;I++){let N=m.vertices[I];h.vertices.push(N)}}let b=1/0,v=-1/0,w=1/0,O=-1/0;for(let I=0,N=h.vertexCount;I<N;I++){let _=I*2,R=h.vertices[_+0],V=h.vertices[_+1];R<b&&(b=R),R>v&&(v=R),V<w&&(w=V),V>O&&(O=V)}this._minX=b,this._minY=w,this._width=v-b,this._height=O-w,this._buffer=new el(this._computeBufferEstimatedSize(h));let S=[],T=[];for(let I=h.elementCount-1;I>=0;I--){let N=I>=y,_=I*2,R=h.elements[_+0],V=h.elements[_+1],U=R+V,B={start:R,count:V,normals:[],continuous:[],concave:[]},q=R,j=U-1,F=R+1,H=this._shape.roundedCurves.length;do{let re=q-R,K=h.vertices[j*2+0],Z=h.vertices[j*2+1],Q=h.vertices[q*2+0],$=h.vertices[q*2+1],ue=h.vertices[F*2+0],le=h.vertices[F*2+1],ie=Q-K,ce=$-Z,ae=Math.sqrt(ie*ie+ce*ce);ie/=ae,ce/=ae;let me=Q-ue,pe=$-le,he=Math.sqrt(me*me+pe*pe);me/=he,pe/=he,B.normals[re*2+0]=-pe,B.normals[re*2+1]=me,B.concave[re]=ie*pe-ce*me>0;let xe=h.vertexIndices[q];if(Array.isArray(xe))B.continuous[re]=!1;else{let[ye,C]=this._shape.getCurveIndexFromVertexId(xe-1,!0);if(C>0&&C<1)B.continuous[re]=!0;else{let ne=C===1?ye+1:ye-1;ne=(ne+H)%H;let Ne=C===1?0:1,Ve=this._shape.roundedCurves[ye].getTangent(C),_e=this._shape.roundedCurves[ne].getTangent(Ne);B.continuous[re]=Ve.dot(_e)>.95}}N&&(B.normals[re*2+0]*=-1,B.normals[re*2+1]*=-1),[j,q,F]=[q,F,F+1],F>=U&&(F-=V)}while(F!==R+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:h.vertices.slice(R*2,U*2),vertexCount:V,vertexIndices:new Array(V).fill(!0).map((re,K)=>[K,K]),elements:[0,V],elementCount:1,mesh:null},reverseMap:[],insetPoints:h.vertices.slice(R*2,U*2)});let ee=0;for(let re=1;re<=this._bevelSegments;re++){let K=re/this._bevelSegments*Math.PI/2,Z=(1-Math.cos(K))*this._bevel,Q=[],$=[],ue=[],le=[],ie=0;for(let ae=0;ae<V;ae++){let me=ae*2,pe=(ae-1+V)%V*2,he=h.vertices[B.start*2+me+0],xe=h.vertices[B.start*2+me+1],ye=-B.normals[pe+0]*Z,C=-B.normals[pe+1]*Z,ne=-B.normals[me+0]*Z,Ne=-B.normals[me+1]*Z;if(B.concave[ae]||!B.concave[ae]&&N){let Ve=Math.atan2(C,ye),_e=Math.atan2(Ne,ne);_e>Ve&&(_e-=Math.PI*2);let Pe=_e-Ve;if(B.continuous[ae]||N){let vt=Ve+Pe/2,Me=Math.cos(vt)*Z,xt=Math.sin(vt)*Z;Q[2*ie+0]=he+Me*(N?-1:1),Q[2*ie+1]=xe+xt*(N?-1:1),le[ie]=ae,ie++}else{let vt=Math.max(1,Math.floor(n/4*Math.abs(Pe)/Math.PI));for(let Me=0;Me<=vt;Me++){let xt=Ve+Pe*(Me/vt),St=Math.cos(xt)*Z,Ui=Math.sin(xt)*Z;Q[2*ie+0]=he+St,Q[2*ie+1]=xe+Ui,le[ie]=ae,ie++}}}else Q[2*ie+0]=he+ye,Q[2*ie+1]=xe+C,le[ie]=ae,$[ae]=ie,ie++,Q[2*ie+0]=he,Q[2*ie+1]=xe,le[ie]=ae,ie++,Q[2*ie+0]=he+ne,Q[2*ie+1]=xe+Ne,le[ie]=ae,ue[ae]=ie,ie++}let ce=Fr({windingRule:Fe.POSITIVE,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Q],edgeCreateCallback:ae=>{let pe=ae.Org.idx,he=le[pe],xe=le[(pe+1)%le.length];ae.idx=[he,xe],ae.Sym.idx=[xe,he]},vertexIdCallback:ae=>{let me=ae.Lprev.idx;return[me?me[1]:0,ae.idx?ae.idx[0]:0]}});if(!ce)throw console.log("Error"),new Error(`error generating bevel geometry for ${re}'th loop`);if(!ce.vertexCount){let ae=(re-1)/this._bevelSegments*Math.PI/2;ee=(1-Math.sin(ae))*this._bevel;break}for(let ae=0;ae<ce.vertexIndices.length;ae++){let[me,pe]=ce.vertexIndices[ae];if(me===pe)continue;let he=pe;pe<me&&(he+=V);for(let xe=me;xe<he;xe++){let ye=xe%V,C=(xe+1)%V;if(!B.continuous[ye]||!B.continuous[C]){ce.vertexIndices[ae]=[me,ye],ce.vertexIndices.splice(ae+1,0,[C,pe]),ce.vertices.splice((ae+1)*2,0,ce.vertices[ae*2],ce.vertices[ae*2+1]);break}}}W.push({bevelI:re,angle:K,size:Z,boundary:ce,reverseMap:le,insetPoints:Q})}let te=(re,K,Z)=>{let Q=0,$=re.boundary.vertexIndices.length;for(;Q<$&&Z(re.boundary.vertexIndices[K]);)K=(K+1)%$,Q++;return Q},Y=S.length;for(let re=1;re<W.length;re++){let K=W[re-1],Z=W[re],Q=K.boundary.vertexIndices.length,$=Z.boundary.vertexIndices.length;if(!Q||!$)break;let ue=B.concave.length,le=0,ie=Sf(le,V);for(;!K.boundary.vertexIndices.filter(ie).length||!Z.boundary.vertexIndices.filter(ie).length;)le++,ie=Sf(le,V);let ce=K.boundary.vertexIndices.findIndex(ie),ae=Z.boundary.vertexIndices.findIndex(ie);do ce=(ce+1)%Q;while(ie(K.boundary.vertexIndices[ce]));do ae=(ae+1)%$;while(ie(Z.boundary.vertexIndices[ae]));le=(le+1)%V;let me=le,pe=0,he=this._buildBevelVert(B,K,(ce-1+Q)%Q,void 0,pe),xe=this._buildBevelVert(B,Z,(ae-1+$)%$,void 0,pe),ye=he,C=xe,ne,Ne,Ve=!1;do{pe=(le||ue)/ue,ie=Sf(le,V);let _e=te(K,ce,ie),Pe=te(Z,ae,ie),vt=Ve;if(Ve=!1,_e&&!Pe){for(let Me=0;Me<_e;Me++)ne=this._buildBevelVert(B,K,(ce+Me)%Q,Me/(_e-1),pe),S.push(ye.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,ye.bottomN,C.bottomN),ye=ne;Ve=!0}else if(!_e&&Pe)for(let Me=0;Me<Pe;Me++)Ne=this._buildBevelVert(B,Z,(ae+Me)%$,Me/(Pe-1),pe),S.push(C.topN,ye.topP,Ne.topP),l===!1&&S.push(ye.bottomP,C.bottomN,Ne.bottomP),C=Ne;else if(_e&&Pe)if(ne=this._buildBevelVert(B,K,ce,0,pe),Ne=this._buildBevelVert(B,Z,ae,0,pe),vt?(S.push(ye.topN,Ne.topP,C.topN),S.push(ye.topN,ne.topP,Ne.topP),l===!1&&(S.push(Ne.bottomP,ye.bottomN,C.bottomN),S.push(Ne.bottomP,ne.bottomP,ye.bottomN))):(S.push(C.topN,ye.topN,ne.topP),S.push(C.topN,ne.topP,Ne.topP),l===!1&&(S.push(ne.bottomP,ye.bottomN,C.bottomN),S.push(ne.bottomP,C.bottomN,Ne.bottomP))),ye=ne,C=Ne,_e===Pe)for(let Me=1;Me<_e;Me++)ne=this._buildBevelVert(B,K,(ce+Me)%Q,Me/(_e-1),pe),Ne=this._buildBevelVert(B,Z,(ae+Me)%$,Me/(Pe-1),pe),S.push(ye.topN,ne.topP,C.topN),S.push(C.topN,ne.topP,Ne.topP),l===!1&&(S.push(ne.bottomP,ye.bottomN,C.bottomN),S.push(ne.bottomP,C.bottomN,Ne.bottomP)),ye=ne,C=Ne;else if(_e>Pe){let Me=_e/Pe,xt=0;for(let St=1;St<_e;St++)ne=this._buildBevelVert(B,K,(ce+St)%Q,St/(_e-1),pe),S.push(ye.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,ye.bottomN,C.bottomN),ye=ne,St>(xt+1)*Me&&(xt++,Ne=this._buildBevelVert(B,Z,(ae+xt)%$,xt/(Pe-1),pe),S.push(C.topN,ne.topP,Ne.topP),l===!1&&S.push(ne.bottomP,C.bottomN,Ne.bottomP),C=Ne)}else{let Me=Pe/_e,xt=0;for(let St=1;St<Pe;St++)Ne=this._buildBevelVert(B,Z,(ae+St)%$,St/(Pe-1),pe),S.push(C.topN,ne.topP,Ne.topP),l===!1&&S.push(ne.bottomP,C.bottomN,Ne.bottomP),C=Ne,St>(xt+1)*Me&&(xt++,ne=this._buildBevelVert(B,K,(ce+xt)%Q,xt/(_e-1),pe),S.push(ye.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,ye.bottomN,C.bottomN),ye=ne)}ce=(ce+_e)%Q,ae=(ae+Pe)%$,le=(le+1)%ue}while(le!==me)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(W,B,S),N){let re=[];for(let K=S.length-1;K>=Y+2;K-=3){let Z=S[K-2],Q=S[K-1],$=S[K-0];re.push($,Q,Z)}S.splice(Y,S.length-Y,...re)}if(N){let re=[];for(let K=W[W.length-1].boundary.vertices.length-1;K>=1;K-=2){let Z=W[W.length-1].boundary.vertices[K-1],Q=W[W.length-1].boundary.vertices[K-0];re.push(Z,Q)}T.push(re)}if(!N){let re=W[W.length-1],K;try{K=Fr({windingRule:W.length>1?Fe.POSITIVE:Fe.ODD,elementType:st.POLYGONS,vertexSize:2,strict:!0,contours:[re.insetPoints,...T]})}catch{K=Pf}if(!K)throw new Error("Error generating geometry for surface");u.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let Z=0;Z<K.elementCount*3;Z+=3){let Q=this._buildSurfaceVert(K,K.elements[Z+0],ee),$=this._buildSurfaceVert(K,K.elements[Z+1],ee),ue=this._buildSurfaceVert(K,K.elements[Z+2],ee);S.push(Q.top,$.top,ue.top),l===!1&&S.push(ue.bottom,$.bottom,Q.bottom)}}this.vertexCache={}}this._buffer.shrink();let M=new Ou(Uint32Array.from(S),1),g=new Ou(this._buffer.positions,3),D=new Ou(this._buffer.normals,3),E=new Ou(this._buffer.uvs,2);g.needsUpdate=!0,D.needsUpdate=!0,E.needsUpdate=!0,M.needsUpdate=!0,this.setAttribute("position",g),this.setAttribute("normal",D),this.setAttribute("uv",E),this.setIndex(M)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let n=e[0];for(let a=0,s=n.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(t,n,a),c=this._buildBevelVert(t,n,(a+1)%s);o.push(c.topP,l.topN,l.bottomN),o.push(c.topP,l.bottomN,c.bottomP)}}_buildSurfaceVert(e,t,o){let n=t.toString();if(n in this.vertexCache)return this.vertexCache[n];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,f={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[n]=f,f}_buildBevelVert(e,t,o,n=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,f;l!==c?(p=l,u=c,f=!1,d=e.continuous[p]&&e.continuous[u]):(u=l,p=(u-1+e.count)%e.count,f=e.concave[u]&&t.bevelI>0,d=e.continuous[u]||f);let h=Math.cos(t.angle),m=Math.sin(t.angle),y=o*2,b=u*2,v=p*2,w=t.boundary.vertices[y+0],O=t.boundary.vertices[y+1],S=(1-m)*this._bevel,T=(w-this._minX)/this._width,M=(O-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(T=a),M=1);let g=e.normals[b+0],D=e.normals[b+1],E=e.normals[v+0],I=e.normals[v+1];if(f){let U=E-g,B=I-D;g=g+U*(1-n),D=D+B*(1-n);let q=Math.sqrt(g*g+D*D);g/=q,D/=q}let N=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),_=N*3,R=N*2,V={i:o,fi:u,topP:N+0,topN:N+0,bottomP:N+1,bottomN:N+1,pathBevelUCoord:a};return this._buffer.positions[_+0]=w,this._buffer.positions[_+1]=O,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[_+0]=g*h,this._buffer.normals[_+1]=D*h,this._buffer.normals[_+2]=m,this._buffer.uvs[R+0]=T,this._buffer.uvs[R+1]=M,this.forPathBevel===!1&&(this._buffer.positions[_+3]=w,this._buffer.positions[_+4]=O,this._buffer.positions[_+5]=S,this._buffer.normals[_+3]=g*h,this._buffer.normals[_+4]=D*h,this._buffer.normals[_+5]=-m,this._buffer.uvs[R+2]=M,this._buffer.uvs[R+3]=T),d||(this.forPathBevel?(N+=1,_+=3,R+=2):(N+=2,_+=6,R+=4),V.topP=N+0,V.bottomP=N+1,this._buffer.positions[_+0]=w,this._buffer.positions[_+1]=O,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[_+0]=E*h,this._buffer.normals[_+1]=I*h,this._buffer.normals[_+2]=m,this._buffer.uvs[R+0]=T,this._buffer.uvs[R+1]=M,this.forPathBevel===!1&&(this._buffer.positions[_+3]=w,this._buffer.positions[_+4]=O,this._buffer.positions[_+5]=S,this._buffer.normals[_+3]=E*h,this._buffer.normals[_+4]=I*h,this._buffer.normals[_+5]=-m,this._buffer.uvs[R+2]=M,this._buffer.uvs[R+3]=T)),this.vertexCache[s]=V,V}clone(){let e=new vi(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Mo(this.userData),e}};var Ta=class extends X3{constructor(e,t=12,o={}){super();this.type="ShapeGeometry";this.windingRule=Fe.ODD;this.elementType=st.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Fe.ODD,elementType:st.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let n=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(h=>h.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,c=!0,u,p;for(let h=0,m=n.length/2;h<m;h++){let y=h*2,b=n[y+0],v=n[y+1];if(u!==void 0&&b!==u&&(l=!1),p!==void 0&&v!==p&&(c=!1),u=b,p=v,!l&&!c)break}if(!l&&!c)try{s=Fr({contours:[n,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=rl}let d=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new Tu(new Float32Array(d*3),3),this._normalAttribute=new Tu(new Float32Array(d*3),3),this._uvAttribute=new Tu(new Float32Array(d*2),2),this._indexAttribute=new Tu(new Uint32Array(f*3),1),s){let h=1/0,m=-1/0,y=1/0,b=-1/0;for(let O=0,S=d;O<S;O++){let T=O*2,M=s.vertices[T+0],g=s.vertices[T+1];M<h&&(h=M),M>m&&(m=M),g<y&&(y=g),g>b&&(b=g)}let v=m-h,w=b-y;for(let O=0,S=d;O<S;O++){let T=O*2,M=s.vertices[T+0],g=s.vertices[T+1],D=(M-h)/v,E=(g-y)/w;this._positionAttribute.setXYZ(O,M,g,0),this._normalAttribute.setXYZ(O,0,0,1),this._uvAttribute.setXY(O,D,E)}for(let O=0,S=f;O<S;O++){let T=O*3,M=s.elements[T+0],g=s.elements[T+1],D=s.elements[T+2];this._indexAttribute.setX(T+0,M),this._indexAttribute.setX(T+1,g),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 Ta(this._shape,this._curveSegments);return e.userData=Mo(this.userData),e}};var Ca=class extends vi{constructor(e,t,o=0,n=12,a=3,s=Fe.ODD){super(e,t,o,n,a,s);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let n=e[0];for(let a=0,s=n.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(t,n,a),c=this._buildBevelVert(t,n,(a+1)%s);o.push(c.topP,l.topN,l.bottomN),o.push(c.topP,l.bottomN,c.bottomP)}}clone(){let e=new Ca(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Mo(this.userData),e}};var er=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Fe.ODD},i.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),a=i.shape??r?.shape,s=a?.roundness??e.roundness;a!==void 0&&(a instanceof je?(a.width!==t||a.height!==o)&&a.applySize(t,o):a=new je(t,o).fromJSON(a),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&a.update());let l=a??new je(t,o);return{parameters:Object.assign(e,{width:t,height:o,depth:n,roundness:s}),shape:l}}static build(i){let{depth:r,extrudeBevelSize:e,extrudeBevelSegments:t,subdivisions:o,roundness:n,windingRule:a}=i.parameters;i.shape.roundness=n;let s;return r<=0?s=new Ta(i.shape,o,{windingRule:a}):s=new Ca(i.shape,r,e,o,t,a),Object.assign(s,{userData:{...i,type:"VectorGeometry"}})}};import{BufferGeometry as Y3,Float32BufferAttribute as K3,MathUtils as Of,Vector2 as ab}from"three";var sb=Math.PI*2,Ma=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return e.angle=Of.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof je?i.shape:new je,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:r,height:e,spikes:t,angle:o,innerRadius:n,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=i.parameters,c=i.shape,u=r*.5,p=e*.5,d=Q3(c,u,p,o*Math.PI/180,t,n);c.isClosed=!0,c.update();let f;return o===0?(f=new Y3,f.setAttribute("position",new K3([],3))):f=er.create({shape:c,parameters:{subdivisions:d,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function Q3(i,r,e,t,o,n){if(t>=sb)return o>30||o%4===0?(J3(i,r,e,n),Math.round(o/4)):nb(i,t,o,r,e,n);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=eb({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?Z3(i,a.x,a.y,c,o,r,e,n):nb(i,t,o,r,e,n)}function Z3(i,r,e,t,o,n,a,s){let l=Math.round(o/t.length);i.addPoint(Aa(r,e));for(let c=0,u=t.length;c<u;c++){let p=t[c],d=i.points[c],f=Aa(p.x,p.y);d.controls[1].position.set(p.x1,p.y1),f.controls[0].position.set(p.x2,p.y2),i.addPoint(f)}return s>0?lb(i,n,a,s):i.addPoint(Aa(0,0)),l}function nb(i,r,e,t,o,n){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;i.addPoint(Aa(c,u))}return r<sb?n>0?lb(i,t,o,n):i.addPoint(Aa(0,0)):(i.removePoint(i.points[i.points.length-1]),n>0&&cb(i,t,o,n)),1}function J3(i,r,e,t=0,o=0,n=0){let a=.5522847498,s=r*a,l=e*a;i.addPoint(Cu(o-r,n,o-r,n-l,o-r,n+l)),i.addPoint(Cu(o,n+e,o-s,n+e,o+s,n+e)),i.addPoint(Cu(o+r,n,o+r,n+l,o+r,n-l)),i.addPoint(Cu(o,n-e,o+s,n-e,o-s,n-e)),t>0&&cb(i,r,e,t)}function Aa(i,r){return new Gr(Of.generateUUID(),new ab(i,r))}function Cu(i,r,e,t,o,n){let a=Aa(i,r);return a.controls[0].position.set(e,t),a.controls[1].position.set(o,n),a}function lb(i,r,e,t){ub(i,r,e,t).forEach(n=>i.addPoint(n))}function cb(i,r,e,t){let o=ub(i,r,e,t),n=new je;o.forEach(a=>n.addPoint(a)),n.isClosed=!0,i.shapeHoles.push(n)}function ub(i,r,e,t){let o=t*r/100,n=o*(Math.abs(e)/Math.abs(r)),a=new ab(o/r,n/e),s=i.points.map(l=>{let c=l.clone();return c.uuid=Of.generateUUID(),c}).reverse();return s.forEach(l=>{l.position.multiply(a);let c=l.controls[0].position.clone().multiply(a),u=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(u),l.controls[1].position.copy(c)}),s}import{BufferGeometry as eE,Float32BufferAttribute as Tf,Uint32BufferAttribute as tE,Vector3 as db}from"three";var pb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),t=Math.abs(e.width),o=Math.abs(e.height??t),n=Math.abs(e.depth??t),a=Math.abs(Math.min(t,n))/2;return{parameters:Object.assign(e,{width:t,height:o,depth:n,radius:a,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:r,height:e,depth:t,radius:o,revolutions:n,segments:a,pathRadius:s,pathType:l,pathSegments:c,cornerRadius:u,cornerSegments:p}=i.parameters,d=new ol(!1,r,e,t,o,n,a,s,l,c,u,p);return Object.assign(d,{userData:{...i,type:"HelixGeometry"}})}},Cf=new tE([0,0,0],1),ol=class extends eE{constructor(r=!0,e=1,t=1,o=1,n=1,a=1,s=1,l=1,c=1,u=1,p=1,d=1){if(super(),a===0)return;let f=r&&a===1;f&&(d=0),p>100&&(p=100),p===0&&(d=0);let h=()=>new db,m=new db,y=h(),b=h(),v=h(),w,O,S,T,M,g,D,E,I=h(),N=h(),_=h(),R=h(),V=h(),U=h(),B=h(),q=h(),j=t-2*l+.001,F=j/a,H=Math.ceil(s*a),W=H+1,ee=j/H,te=-j/2,Y=u+1,re=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,ie=d*le+le,ce=Y*ie/le,ae=ce+Y*W,me=Math.max(0,Y*(W+ie)),[pe,he,xe]=[3,3,2].map(it=>Array(me*it).fill(0)),ye=[],C=n-l;function ne(it,Ye){let Er=Math.PI/2;g=Ye*ee,E=2*Math.PI*(g%F)/F+Er,g+=te,D=Math.sin(E)*C,M=Math.cos(E)*C,r?it.set(M,D,g):it.set(M,g,D)}ne(m,-1e-10),ne(y,0),I.copy(m),ne(m,1);let Ne=m.distanceTo(y),Ve=f?0:$+Q,_e=Ne*H+2*Ve,Pe=Q,vt=_e-Ve;for(let it=0;it<=H;it++){ne(b,it),q.subVectors(b,I).normalize(),I.copy(b),U.copy(b).setComponent(+r+1,0).normalize(),B.crossVectors(q,U).normalize();let Ye=it===0,Er=it===H,kd=Ye?3*Math.PI/2:K,Hd=Ye?Pe:vt,zl=Ye?Y:ae,ki=Ye?0:me-Y,ct=q.clone().multiplyScalar(Ye?-$:$).add(b),Wd=q.clone().multiplyScalar(Ye?-1:1).normalize();for(let mr=0;mr<Y;mr++){let Cs=mr*re;if(N.addVectors(m.copy(U).multiplyScalar(l*Math.cos(Cs)),y.copy(B).multiplyScalar(l*Math.sin(Cs))),_.copy(N).normalize(),Ye||Er){f||(ue=ki+mr,[0,1,2].forEach(Ht=>{pe[ue*3+Ht]=ct.getComponent(Ht),he[ue*3+Ht]=Wd.getComponent(Ht)}),xe[ue*2]=+Er,xe[ue*2+1]=mr/u),y.copy(_).multiplyScalar(Q),v.addVectors(b,y);for(let Ht=0;Ht<d;Ht++){let Hi=Ht*K+kd;R.addVectors(m.copy(q).multiplyScalar($*Math.sin(Hi)),y.copy(_).multiplyScalar($*Math.cos(Hi))),V.copy(R).normalize(),y.addVectors(v,R),R.normalize(),ue=zl+Ht*Y+mr,[0,1,2].forEach(Tn=>{pe[ue*3+Tn]=y.getComponent(Tn),he[ue*3+Tn]=V.getComponent(Tn)});let Gl=+Ye+Math.sin(Hi);xe[ue*2]=(Hd+$*Gl)/_e,xe[ue*2+1]=mr/u}}y.addVectors(b,N),ue=ce+it*Y+mr,[0,1,2].forEach(Ht=>{pe[ue*3+Ht]=y.getComponent(Ht),he[ue*3+Ht]=_.getComponent(Ht)}),xe[ue*2]=(Ve+it*Ne)/_e,xe[ue*2+1]=mr/u}}let Me=W+2*d+le,xt=1,[St,Ui]=[+f,Me-1];for(let it=St;it<=Ui-1;it++){let Ye=f&&it===Ui-1;for(let Er=0;Er<Y-1;Er++)w=it*Y+Er,O=w+1,S=(Ye?Er:w)+Y,T=(Ye?Er+1:O)+Y,it===0?ye.push(O,T,S):it===Me-2?ye.push(w,O,S):ye.push(w,O,S,O,T,S)}this.setIndex(ye),this.setAttribute("position",new Tf(pe,3)),this.setAttribute("normal",new Tf(he,3)),this.setAttribute("uv",new Tf(xe,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let r=this.userData.parameters,e=Math.ceil(r.tubularSegments),t=r.radialSegments+1,o=Array.from(this.getIndex().array),n,a,s,l,c=6*(e-1)*r.radialSegments,u=e,p=u===e;for(let d=0;d<r.radialSegments;d++)n=u*t+d,a=n+1,s=(p?d:n)+t,l=(p?d+1:a)+t,o[c++]=n,o[c++]=a,o[c++]=s,o[c++]=a,o[c++]=l,o[c++]=s;return o.length=c,Cf.array=o,Cf.count=o.length,Cf}};import{IcosahedronGeometry as rE}from"three";var fb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.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(i){let{width:r,height:e,depth:t,detail:o,corner:n,cornerSides:a}=i.parameters,s=o===0&&n!==0?new il(r*.5,n,a):new rE(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...i,type:"IcosahedronGeometry"}})}},il=class extends xi{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,n=[-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(n,a,s,r,e,t),this.type=s}static fromJSON(r){return new il(r.radius,r.corner,r.cornerSides)}};import{LatheGeometry as oE,Shape as iE}from"three";var hb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){(i.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}]},i.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(i){let{points:r,segments:e,verticalSegments:t}=i.parameters,o=new iE;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 n=new oE(o.extractPoints(t).shape,e);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...i,type:"LatheGeometry"}})}};import{BufferGeometry as wb,BufferGeometryLoader as yE,Vector3 as gE,BoxGeometry as Pb}from"three";import{BufferGeometry as pE,Vector2 as Ef,Vector3 as Sb}from"three";import{Box3 as nE,BufferAttribute as nl,BufferGeometry as mb,Color as If,EventDispatcher as aE,Float32BufferAttribute as Ia,Matrix3 as yb,Matrix4 as vb,MathUtils as sE,Object3D as lE,Sphere as cE,Vector2 as dr,Vector3 as zt,Vector4 as uE}from"three";var lo=new vb,Af=new lE,Au=new zt,Si=class extends aE{constructor(){super(),this.uuid=sE.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 yb().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 n=this.faces[t];n.normal.applyMatrix3(e).normalize();for(let a=0,s=n.vertexNormals.length;a<s;a++)n.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 lo.makeRotationX(r),this.applyMatrix4(lo),this}rotateY(r){return lo.makeRotationY(r),this.applyMatrix4(lo),this}rotateZ(r){return lo.makeRotationZ(r),this.applyMatrix4(lo),this}translate(r,e,t){return lo.makeTranslation(r,e,t),this.applyMatrix4(lo),this}scale(r,e,t){return lo.makeScale(r,e,t),this.applyMatrix4(lo),this}lookAt(r){return Af.lookAt(r),Af.updateMatrix(),this.applyMatrix4(Af.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 n=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<n.count;d++)e.vertices.push(new zt().fromBufferAttribute(n,d)),s!==void 0&&e.colors.push(new If().fromBufferAttribute(s,d));function u(d,f,h,m){let y=s===void 0?[]:[e.colors[d].clone(),e.colors[f].clone(),e.colors[h].clone()],b=a===void 0?[]:[new zt().fromBufferAttribute(a,d),new zt().fromBufferAttribute(a,f),new zt().fromBufferAttribute(a,h)],v=new Ea(d,f,h,b,y,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new dr().fromBufferAttribute(l,d),new dr().fromBufferAttribute(l,f),new dr().fromBufferAttribute(l,h)]),c!==void 0&&e.faceVertexUvs[1].push([new dr().fromBufferAttribute(c,d),new dr().fromBufferAttribute(c,f),new dr().fromBufferAttribute(c,h)])}let p=r.groups;if(p.length>0)for(let d=0;d<p.length;d++){let f=p[d],h=f.start,m=f.count;for(let y=h,b=h+m;y<b;y+=3)t!==void 0?u(t.getX(y),t.getX(y+1),t.getX(y+2),f.materialIndex):u(y,y+1,y+2,f.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<n.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(Au).negate(),this.translate(Au.x,Au.y,Au.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new vb;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 zt,e=new zt;for(let t=0,o=this.faces.length;t<o;t++){let n=this.faces[t],a=this.vertices[n.a],s=this.vertices[n.b],l=this.vertices[n.c];r.subVectors(l,s),e.subVectors(a,s),r.cross(e),r.normalize(),n.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 zt;if(r){let t=new zt,o=new zt;for(let n=0,a=this.faces.length;n<a;n++){let s=this.faces[n],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 n=this.faces[t];e[n.a].add(n.normal),e[n.b].add(n.normal),e[n.c].add(n.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 n=this.faces[t],a=n.vertexNormals;a.length===3?(a[0].copy(e[n.a]),a[1].copy(e[n.b]),a[2].copy(e[n.c])):(a[0]=e[n.a].clone(),a[1]=e[n.b].clone(),a[2]=e[n.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 n=0,a=o.vertexNormals.length;n<a;n++)o.__originalVertexNormals[n]?o.__originalVertexNormals[n].copy(o.vertexNormals[n]):o.__originalVertexNormals[n]=o.vertexNormals[n].clone()}let r=new Si;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 n=this.morphNormals[e].faceNormals,a=this.morphNormals[e].vertexNormals;for(let s=0,l=this.faces.length;s<l;s++){let c=new zt,u={a:new zt,b:new zt,c:new zt};n.push(c),a.push(u)}}let o=this.morphNormals[e];r.vertices=this.morphTargets[e].vertices,r.computeFaceNormals(),r.computeVertexNormals();for(let n=0,a=this.faces.length;n<a;n++){let s=this.faces[n],l=o.faceNormals[n],c=o.vertexNormals[n];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 nE),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new cE),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,n=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 yb().getNormalMatrix(e));for(let d=0,f=s.length;d<f;d++){let m=s[d].clone();e!==void 0&&m.applyMatrix4(e),a.push(m)}for(let d=0,f=p.length;d<f;d++)u.push(p[d].clone());for(let d=0,f=c.length;d<f;d++){let h=c[d],m,y,b=h.vertexNormals,v=h.vertexColors,w=new Ea(h.a+n,h.b+n,h.c+n);w.normal.copy(h.normal),o!==void 0&&w.normal.applyMatrix3(o).normalize();for(let O=0,S=b.length;O<S;O++)m=b[O].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),w.vertexNormals.push(m);w.color.copy(h.color);for(let O=0,S=v.length;O<S;O++)y=v[O],w.vertexColors.push(y.clone());w.materialIndex=h.materialIndex+t,l.push(w)}for(let d=0,f=r.faceVertexUvs.length;d<f;d++){let h=r.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,y=h.length;m<y;m++){let b=h[m],v=[];for(let w=0,O=b.length;w<O;w++)v.push(b[w].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=[],n=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*n)+"_"+Math.round(u.y*n)+"_"+Math.round(u.z*n);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 zt(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],n=this.faceVertexUvs[1],a,s;o&&o.length===e&&(a=[]),n&&n.length===e&&(s=[]);for(let l=0;l<e;l++){let c=r[l]._id;a&&a.push(o[c]),s&&s.push(n[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 h=this.parameters;for(let m in h)h[m]!==void 0&&(r[m]=h[m]);return r}let e=[];for(let h=0;h<this.vertices.length;h++){let m=this.vertices[h];e.push(m.x,m.y,m.z)}let t=[],o=[],n={},a=[],s={},l=[],c={};for(let h=0;h<this.faces.length;h++){let m=this.faces[h],y=!0,b=!1,v=this.faceVertexUvs[0][h]!==void 0,w=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,M=0;if(M=u(M,0,0),M=u(M,1,y),M=u(M,2,b),M=u(M,3,v),M=u(M,4,w),M=u(M,5,O),M=u(M,6,S),M=u(M,7,T),t.push(M),t.push(m.a,m.b,m.c),t.push(m.materialIndex),v){let g=this.faceVertexUvs[0][h];t.push(f(g[0]),f(g[1]),f(g[2]))}if(w&&t.push(p(m.normal)),O){let g=m.vertexNormals;t.push(p(g[0]),p(g[1]),p(g[2]))}if(S&&t.push(d(m.color)),T){let g=m.vertexColors;t.push(d(g[0]),d(g[1]),d(g[2]))}}function u(h,m,y){return y?h|1<<m:h&~(1<<m)}function p(h){let m=h.x.toString()+h.y.toString()+h.z.toString();return n[m]!==void 0||(n[m]=o.length/3,o.push(h.x,h.y,h.z)),n[m]}function d(h){let m=h.r.toString()+h.g.toString()+h.b.toString();return s[m]!==void 0||(s[m]=a.length,a.push(h.getHex())),s[m]}function f(h){let m=h.x.toString()+h.y.toString();return c[m]!==void 0||(c[m]=l.length/2,l.push(h.x,h.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 Si().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,f=e.length;d<f;d++)this.vertices.push(e[d].clone());let t=r.colors;for(let d=0,f=t.length;d<f;d++)this.colors.push(t[d].clone());let o=r.faces;for(let d=0,f=o.length;d<f;d++)this.faces.push(o[d].clone());for(let d=0,f=r.faceVertexUvs.length;d<f;d++){let h=r.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,y=h.length;m<y;m++){let b=h[m],v=[];for(let w=0,O=b.length;w<O;w++){let S=b[w];v.push(S.clone())}this.faceVertexUvs[d].push(v)}}let n=r.morphTargets;for(let d=0,f=n.length;d<f;d++){let h={};if(h.name=n[d].name,n[d].vertices!==void 0){h.vertices=[];for(let m=0,y=n[d].vertices.length;m<y;m++)h.vertices.push(n[d].vertices[m].clone())}if(n[d].normals!==void 0){h.normals=[];for(let m=0,y=n[d].normals.length;m<y;m++)h.normals.push(n[d].normals[m].clone())}this.morphTargets.push(h)}let a=r.morphNormals;for(let d=0,f=a.length;d<f;d++){let h={};if(a[d].vertexNormals!==void 0){h.vertexNormals=[];for(let m=0,y=a[d].vertexNormals.length;m<y;m++){let b=a[d].vertexNormals[m],v={};v.a=b.a.clone(),v.b=b.b.clone(),v.c=b.c.clone(),h.vertexNormals.push(v)}}if(a[d].faceNormals!==void 0){h.faceNormals=[];for(let m=0,y=a[d].faceNormals.length;m<y;m++)h.faceNormals.push(a[d].faceNormals[m].clone())}this.morphNormals.push(h)}let s=r.skinWeights;for(let d=0,f=s.length;d<f;d++)this.skinWeights.push(s[d].clone());let l=r.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let c=r.lineDistances;for(let d=0,f=c.length;d<f;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 mb,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",Mu.call(new nl(t,3),r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",Mu.call(new nl(o,3),r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",gb.call(new nl(o,3),r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",xb.call(new nl(o,2),r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",xb.call(new nl(o,2),r.uvs2))}e.groups=r.groups;for(let o in r.morphTargets){let n=[],a=r.morphTargets[o];for(let s=0,l=a.length;s<l;s++){let c=a[s],u=new Ia(c.data.length*3,3);u.name=c.name,n.push(Mu.call(u,c.data))}e.morphAttributes[o]=n}if(r.skinIndices.length>0){let o=new Ia(r.skinIndices.length*4,4);e.setAttribute("skinIndex",bb.call(o,r.skinIndices))}if(r.skinWeights.length>0){let o=new Ia(r.skinWeights.length*4,4);e.setAttribute("skinWeight",bb.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 mb,t=r.geometry;if(r.isPoints||r.isLine){let o=new Ia(t.vertices.length*3,3),n=new Ia(t.colors.length*3,3);if(e.setAttribute("position",Mu.call(o,t.vertices)),e.setAttribute("color",gb.call(n,t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let a=new Ia(t.lineDistances.length,1);e.setAttribute("lineDistance",dE.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}};Si.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,n,a=r.faces;for(o=0;o<a.length;o++){let s=a[o];s.materialIndex!==n&&(n=s.materialIndex,t!==void 0&&(t.count=o*3-t.start,e.push(t)),t={start:o*3,materialIndex:n})}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,n=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 b=0;b<l;b++)c[b]={name:s[b].name,data:[]};this.morphTargets.position=c}let u=r.morphNormals,p=u.length,d;if(p>0){d=[];for(let b=0;b<p;b++)d[b]={name:u[b].name,data:[]};this.morphTargets.normal=d}let f=r.skinIndices,h=r.skinWeights,m=f.length===t.length,y=h.length===t.length;t.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let b=0;b<e.length;b++){let v=e[b];this.vertices.push(t[v.a],t[v.b],t[v.c]);let w=v.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[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(n===!0){let S=o[0][b];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",b),this.uvs.push(new dr,new dr,new dr))}if(a===!0){let S=o[1][b];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",b),this.uvs2.push(new dr,new dr,new dr))}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[b];d[S].data.push(T.a,T.b,T.c)}m&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),y&&this.skinWeights.push(h[v.a],h[v.b],h[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}},Ea=class{constructor(r,e,t,o,n,a=0){this.a=r,this.b=e,this.c=t,this.normal=o&&o.isVector3?o:new zt,this.vertexNormals=Array.isArray(o)?o:[],this.color=n&&n.isColor?n:new If,this.vertexColors=Array.isArray(n)?n:[],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 dE(i){return this.array.set(i),this}function gb(i){let r=this.array,e=0;for(let t=0,o=i.length;t<o;t++){let n=i[t];n===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",t),n=new If),r[e++]=n.r,r[e++]=n.g,r[e++]=n.b}return this}function xb(i){let r=this.array,e=0;for(let t=0,o=i.length;t<o;t++){let n=i[t];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",t),n=new dr),r[e++]=n.x,r[e++]=n.y}return this}function Mu(i){let r=this.array,e=0;for(let t=0,o=i.length;t<o;t++){let n=i[t];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",t),n=new zt),r[e++]=n.x,r[e++]=n.y,r[e++]=n.z}return this}function bb(i){let r=this.array,e=0;for(let t=0,o=i.length;t<o;t++){let n=i[t];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",t),n=new uE),r[e++]=n.x,r[e++]=n.y,r[e++]=n.z,r[e++]=n.w}return this}var fE=["a","b","c"];function hE(i,r){switch(r){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function Nf(i,r,e){let t=Math.min(i,r),o=Math.max(i,r),n=t+"_"+o;return e.get(n)}function Df(i,r,e,t,o,n){let a=Math.min(i,r),s=Math.max(i,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),n[i].edges.push(c),n[r].edges.push(c)}function mE(i,r,e,t){let o,n,a;for(o=0,n=i.length;o<n;o++)e[o]={edges:[]};for(o=0,n=r.length;o<n;o++)a=r[o],Df(a.a,a.b,i,t,a,e),Df(a.b,a.c,i,t,a,e),Df(a.c,a.a,i,t,a,e)}function Iu(i,r,e,t,o){i.push(new Ea(r,e,t,void 0,void 0,o))}function Na(i,r){return Math.abs(r-i)/2+Math.min(i,r)}function Eu(i,r,e,t){i.push([r.clone(),e.clone(),t.clone()])}var Nu=class{constructor(r=1){this.subdivisions=r}modify(r){r instanceof pE?r=new Si().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 Sb,t,o,n,a,s,l=r.vertices,c=r.faces,u=r.faceVertexUvs[0],p=u!==void 0&&u.length>0,d=[],f=new Map;mE(l,c,d,f);let h=[],m,y,b,v,w,O,S;for(let Z of Array.from(f.keys())){for(y=f.get(Z),b=new Sb,w=3/8,O=1/8,S=y.faces.length,S!=2&&(w=.5,O=0,S!=1),b.addVectors(y.a,y.b).multiplyScalar(w),e.set(0,0,0),a=0;a<S;a++){for(v=y.faces[a],s=0;s<3&&(m=l[hE(v,fE[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(O),b.add(e),y.newEdge=h.length,h.push(b)}let T,M,g,D,E,I,N,_=[];for(o=0,n=l.length;o<n;o++){for(I=l[o],E=d[o].edges,t=E.length,t==3?T=3/16:t>3&&(T=3/(8*t)),M=1-t*Number(T),g=T,t<=2&&(t==2?(M=3/4,g=1/8):t==1||t==0),N=I.clone().multiplyScalar(M),e.set(0,0,0),a=0;a<t;a++)D=E[a],m=D.a!==I?D.a:D.b,e.add(m);e.multiplyScalar(Number(g)),N.add(e),_.push(N)}let R=_.concat(h),V=_.length,U,B,q,j=[],F=[],H,W,ee,te,Y=new Ef,re=new Ef,K=new Ef;for(o=0,n=c.length;o<n;o++)v=c[o],U=Number(Nf(v.a,v.b,f).newEdge)+V,B=Number(Nf(v.b,v.c,f).newEdge)+V,q=Number(Nf(v.c,v.a,f).newEdge)+V,Iu(j,U,B,q,v.materialIndex),Iu(j,v.a,U,q,v.materialIndex),Iu(j,v.b,B,U,v.materialIndex),Iu(j,v.c,q,B,v.materialIndex),p&&(H=u[o],W=H[0],ee=H[1],te=H[2],Y.set(Na(W.x,ee.x),Na(W.y,ee.y)),re.set(Na(ee.x,te.x),Na(ee.y,te.y)),K.set(Na(W.x,te.x),Na(W.y,te.y)),Eu(F,Y,re,K),Eu(F,W,Y,K),Eu(F,ee,re,Y),Eu(F,te,K,re));r.vertices=R,r.faces=j,p&&(r.faceVertexUvs[0]=F)}};var Ot=new gE,Ob=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=i.geometry??r?.geometry??new wb().copy(new Pb(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Ot),t={width:Ot.x,height:Ot.y,depth:Ot.z,subdivisions:0}):t=r.parameters;let o={...t,...i.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(i){let{width:r,height:e,depth:t,subdivisions:o}=i.parameters,n=i.geometry??new wb().copy(new Pb(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(Ot)):Ot.set(a.width,a.height,a.depth),(r!==Ot.x||e!==Ot.y||t!==Ot.z)&&n.scale(Ot.x===0?1:r/Ot.x,Ot.y===0?1:e/Ot.y,Ot.z===0?1:t/Ot.z);let s=n.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=n),n=new Nu(o).modify(s).toBufferGeometry()):(s!==void 0&&(n=s),s=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals())}catch{s!==void 0&&(n=s),s=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()}return s!==void 0&&Object.assign(n,{originalGeometry:s}),delete i.geometry,Object.assign(n,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,r,e){new yE(e).load(i,o=>{let n=this.normalizeInputs({geometry:o});o.boundingBox.getSize(Ot);let a=100/Ot.x;Object.assign(n.parameters,{width:100,height:Ot.y*a,depth:Ot.z*a}),r(this.build(n))})}};var Du=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof je?i.shape:new je,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:r,height:e,spikes:t,cornerRadius:o,depth:n,extrudeBevelSize:a,extrudeBevelSegments:s}=i.parameters,l=i.shape,c=r*.5,u=e*.5,p=0,d=0,f=2*Math.PI/t;for(let m=0;m<t;m++){let y=f*m,b=p+Math.sin(y)*c,v=d+Math.cos(y)*u;l.addPoint(l.createPoint(b,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 h=er.create({shape:l,parameters:{roundness:o,depth:n,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(h,{userData:{...i,type:"PolygonGeometry"}})}};import{BufferGeometry as xE,Float32BufferAttribute as _f,Vector2 as co,Vector3 as Nt}from"three";var Tb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:r,height:e,depth:t,radialSegments:o,heightSegments:n,openEnded:a,cornerRadius:s,cornerSegments:l}=i.parameters,c=new Lf(r*.5,e,o,n,a,s,l);return c.scale(1,1,t/r),Object.assign(c,{userData:{...i,type:"PyramidGeometry"}})}};function al(i,r,e){e.x=i.x*r.x,e.y=i.y,e.z=i.x*r.y}function Rf(i,r,e,t,o,n){let a=r.clone().sub(i),s=e.clone().sub(i),l=a.angleTo(s);if(a.normalize(),s.normalize(),t===o){let c=a.add(s).normalize();n.copy(i).addScaledVector(c,t/Math.sin(l/2))}else{let c=a.angleTo(s);n.copy(i),n.addScaledVector(a,o/Math.sin(c)),n.addScaledVector(s,t/Math.sin(c))}}function bE(i,r,e){let t=i.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var Lf=class extends xE{constructor(r=.5,e=1,t=4,o=1,n=!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,f=e/2,h=Math.PI/t,m=r*Math.cos(Math.PI/t),y=2*Math.PI/t,b=(t-2)*Math.PI/t,v=Math.PI-b,w=new Nt(0,-f,0),O=new Nt(0,f,0),S=new co(r,-f),T=new co(m,-f),M=new co(0,O.y).sub(T),g=new co(0,O.y).sub(S),D=new co(M.y,-M.x).normalize(),E=new co(g.y,-g.x).normalize(),N=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-M.angle())/2)-1e-8;a=Math.min(a,N);let _;{let F=new Nt(D.x,D.y,0),H=new Nt(Math.cos(y)*F.x,F.y,Math.sin(y)*F.x);_=F.angleTo(H)}let R=a/Math.tan((Math.PI-M.angle())/2),V=a/Math.tan((Math.PI-_)/2),U=new Nt;if(!n){c.push(w.x,w.y,w.z),u.push(0,-1,0),p.push(0,0);let F=d++,H=[],W=S.clone(),ee=R/Math.cos(Math.PI/t);W.x-=ee;for(let te=0;te<t;te++){let Y=te/t*Math.PI*2+h,re=new co(Math.sin(Y),Math.cos(Y));al(W,re,U),c.push(U.x,U.y,U.z),u.push(0,-1,0),p.push(0,0),H.push(d++)}for(let te=0;te<H.length;te++)l.push(H[te],F,H[(te+1)%H.length])}let B=[];{let F=new Nt,H=new Nt,W=new Nt,ee=new Nt,te=new Nt,Y=new Nt;for(let re=0;re<t;re++){let K=re/t*Math.PI*2+h,Z=(re+.5)/t*Math.PI*2+h,Q=(re+1)/t*Math.PI*2+h,$=new co(Math.sin(K),Math.cos(K)),ue=new co(Math.sin(Z),Math.cos(Z)),le=new co(Math.sin(Q),Math.cos(Q));al(S,$,H),al(S,le,W),al(D,ue,F),Rf(O,H,W,V,V,ee),c.push(ee.x,ee.y,ee.z),Rf(H,O,W,V,R,te),c.push(te.x,te.y,te.z),Rf(W,H,O,R,V,Y),c.push(Y.x,Y.y,Y.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 ie=d++,ce=d++,ae=d++;if(l.push(ie,ce,ae),a>0){{let he=H.clone().add(W).multiplyScalar(.5),xe=O.clone().sub(he).normalize(),C=w.clone().sub(he).normalize().add(xe).normalize().multiplyScalar(-1),ne=Y.clone().sub(te);q(he,ne,C,M.angle())}let me,pe;{let he=new Nt;al(E,le,he);let xe=Y.clone().add(ee).multiplyScalar(.5);xe=bE(xe,W,O);let ye=Y.clone().sub(ee);[me,pe]=q(xe,ye,he,_,ee.y)}{let he=me,xe=he.clone().setY(0).normalize(),ye=new Nt(0,-1,0),C=xe.clone().cross(ye);j(he,xe,ye,C)}B.concat(pe);{let he=M.angle(),xe=Math.PI-he,ye=O.clone();ye.y-=a/Math.sin(he-Math.PI/2);let C=new Nt,ne=[];for(let Ve=0;Ve<s;Ve++){let _e=[],Pe=Math.PI/2-xe*Ve/s,vt=Math.cos(Pe),Me=Math.sin(Pe),xt=Z;for(let St=0;St<=Ve;St++){let Ui=Math.cos(xt),it=Math.sin(xt);F.x=vt*it,F.y=Me,F.z=vt*Ui,C.copy(ye).addScaledVector(F,a),c.push(C.x,C.y,C.z),u.push(F.x,F.y,F.z),p.push(0,0),_e.push(d++),xt+=Math.PI*2/Ve/t}ne.push(_e)}pe.reverse(),ne.push(pe);let Ne=ne.length-1;for(let Ve=0;Ve<Ne;Ve++){let _e=ne[Ve],Pe=ne[Ve+1],vt=_e.length-1;l.push(Pe[1],_e[0],Pe[0]);for(let Me=1;Me<=vt;Me++)l.push(_e[Me],_e[Me-1],Pe[Me]),l.push(Pe[Me+1],_e[Me],Pe[Me])}}}}}this.setIndex(l),this.setAttribute("position",new _f(c,3)),this.setAttribute("normal",new _f(u,3)),this.setAttribute("uv",new _f(p,2));function q(F,H,W,ee,te){let Y=-ee/2,re=(Math.PI-ee)/2,K=H.clone().normalize().cross(W);F.addScaledVector(W,-a/Math.sin(re));let Z=new Nt,Q=new Nt,$=1,ue=d,le=[];for(let ie=0;ie<=s;ie++){let ce=Y+ie/s*ee;Q.set(0,0,0),Q.addScaledVector(K,Math.sin(ce)),Q.addScaledVector(W,Math.cos(ce));for(let ae=0;ae<=$;ae++){let me=ae/$-.5;if(Z.copy(F),Z.addScaledVector(H,me),Z.addScaledVector(Q,a),te!=null){let pe=Math.max(0,Z.y-te);Z.addScaledVector(H,-pe/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 ie=0;ie<s;ie++)for(let ce=0;ce<$;ce++){let ae=ue+ce+($+1)*ie,me=ae+($+1),pe=me+1,he=ae+1;l.push(ae,me,he),l.push(me,pe,he)}return[F.clone().addScaledVector(H,.5),le]}function j(F,H,W,ee){let te=Math.PI/2,Y=g.angle()-te,re=[],K=new Nt,Z=new Nt;for(let $=0;$<=s;$++){let ue=[],le=$/s;for(let ie=0;ie<=$;ie++){let ae=(($?ie/$:0)-.5)*v,me=Math.cos(ae),pe=Math.sin(ae),he=Math.atan(Math.tan(Y)*me),xe=(te+he)*le,ye=Math.cos(xe),C=Math.sin(xe);K.set(0,0,0),K.addScaledVector(H,C*me),K.addScaledVector(W,ye),K.addScaledVector(ee,C*pe),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++)}re.push(ue)}let Q=re.length-1;for(let $=0;$<Q;$++){let ue=re[$],le=re[$+1],ie=ue.length-1;l.push(ue[0],le[1],le[0]);for(let ce=1;ce<=ie;ce++)l.push(ue[ce-1],ue[ce],le[ce]),l.push(ue[ce],le[ce+1],le[ce])}}}};var Da=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),t=Object.assign(r?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof je?i.shape:new je,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(i){let r=i.shape,{width:e,height:t,cornerRadius:o,cornerType:n,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=i.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 f=[];f[0]=o[0]===0?0:d(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:d(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:d(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:d(o[3],o[3]+o[0],o[3]+o[2]);let h=u.x,m=p.x,y=p.y,b=u.y;r.addPoint(r.createPoint(h,y)),r.addPoint(r.createPoint(m,y)),r.addPoint(r.createPoint(m,b)),r.addPoint(r.createPoint(h,b)),r.isClosed=!0;let v=!0;for(let O=0,S=r.points.length;O<S;O++)r.points[O].roundness=f[O],O>0&&f[O]!==f[O-1]&&(v=!1);v&&(r.roundness=f[0]),r.useCubicForRoundedCorners=n!==1,r.update();let w=er.create({shape:r,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...i,type:"RectangleGeometry"}})}};import{BufferGeometry as vE,Float32BufferAttribute as SE,MathUtils as Cb,SphereGeometry as wE}from"three";var Ab=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},i.parameters);return e.thetaLength=Cb.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(i){let{width:r=100,height:e=r,depth:t=r,widthSegments:o=64,heightSegments:n=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:c}=i.parameters,u;return c===0?(u=new vE,u.setAttribute("position",new SE([],3))):u=new wE(.5*r,o,n,a,s,l,c*Cb.DEG2RAD),u.scale(1,e/r,t/r),Object.assign(u,{userData:{...i,type:"SphereGeometry"}})}};import{PlaneGeometry as PE}from"three";var Mb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:r=100,height:e=r,widthSegments:t=8,heightSegments:o=8}=i.parameters,n=new PE(r,e,t,o);return n.scale(1,1,1),Object.assign(n,{userData:{...i,type:"PlaneGeometry"}})}};import{BufferGeometry as OE,Float32BufferAttribute as Bf,Vector3 as TE}from"three";var Ib=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.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(i){let{width:r,height:e,depth:t,angle:o,cornerRadius:n,cornerSegments:a}=i.parameters,s=new Vf(r,e,t,o,n,a);return Object.assign(s,{userData:{...i,type:"BackdropGeometry"}})}},Vf=class extends OE{constructor(r=1,e=1,t=1,o=90,n=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],c=[],u=.001;n==0&&(a=1),a=Math.max(1,Math.floor(a)),n=Math.min(n,100),o=Math.min(180-u,o),o*=Math.PI/180;let p=[],d=Math.PI/2,f=(Z=0,Q=0,$=0)=>new TE(Z,Q,$),h=f(),m=f(),[y,b,v]=[e/2,r/2,t/2],w=-b,O=+b,[S,T,M]=[f(w,-y,+v),f(w,-y,-v),f(w,+y,-v)],g=(Z,Q=!1)=>Math.sin(Z-Math.PI/(1+ +Q)),D=(Z,Q=!1)=>Math.cos(Z-Math.PI/(1+ +Q));M.y=Math.sin(o)*e-y;let E=Math.cos(o)*e-v,I=S.z-u;o<=d?(M.z=Math.min(E,I),M.z==I&&(M.y-=(E-I)/Math.tan(d-o))):T.z=Math.min(T.z-E-v,S.z-u),h.subVectors(S,T),m.subVectors(M,T);let N=Math.min(h.length(),m.length())*n/100,_=N*Math.tan(o/2),R=N/Math.cos(o/2),V=h.clone().normalize().add(m.normalize()).setLength(R).add(T);h.set(0,g(o,!0),D(o,!0)),p.push([M,h.clone()]);let U=(Math.PI-o)/a;for(let Z=0;Z<=a;Z++){let Q=d+o+Z*U;h.set(0,Math.sin(Q)*_,Math.cos(Q)*_),h.add(V),m.set(0,g(Q),D(Q)),p.push([h.clone(),m.clone()])}p.push([S,f(0,1,0)]);let B=Math.sin(U/2)*_*2,q=p.length-1,j=p[0][0].distanceTo(p[1][0]),F=p[q-1][0].distanceTo(p[q][0]),H=j+B*a+F;p[0].push(1);for(let Z=0;Z<=a;Z++)p[Z+1].push(1-(j+Z*B)/H);p[q].push(0);let[W,ee,te]=p[0],Y,re,K;for(let Z=1;Z<p.length;Z++)[Y,re,K]=p[Z],s.push(w,W.y,W.z,w,Y.y,Y.z,O,W.y,W.z,O,W.y,W.z,w,Y.y,Y.z,O,Y.y,Y.z),l.push(0,ee.y,ee.z,0,re.y,re.z,0,ee.y,ee.z,0,ee.y,ee.z,0,re.y,re.z,0,re.y,re.z),c.push(0,te,0,K,1,te,1,te,0,K,1,K),[W,ee,te]=[Y,re,K];this.setAttribute("position",new Bf(s,3)),this.setAttribute("normal",new Bf(l,3)),this.setAttribute("uv",new Bf(c,2))}};var _u=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof je?i.shape:new je,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:r,height:e,innerRadiusPercent:t,spikes:o,cornerRadius:n,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}=i.parameters,u=i.shape,p=r*.5,d=e*.5,f=0,h=0,m=a*Math.PI/360/o,y=Math.PI/2*3*-1,b=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=f+Math.sin(S)*p,M=h+Math.cos(S)*d;u.addPoint(u.createPoint(T,M))}}else for(let O=0;O<o;O++){let S=f+Math.cos(y)*p,T=h+Math.sin(y)*d;u.addPoint(u.createPoint(S,T)),y+=m,S=f+Math.cos(y)*b,T=h+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=n;u.roundness=n,u.update();let w=er.create({shape:u,parameters:{roundness:n,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(w,{userData:{...i,type:"StarGeometry"}})}};import{PlaneGeometry as CE}from"three";var Eb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,depth:0},i.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(i){let{width:r,height:e}=i.parameters,t=new CE(r,e);return Object.assign(t,{userData:{...i,type:"TextFrameGeometry"}})}};import{BufferGeometry as AE,Float32BufferAttribute as ME,MathUtils as IE}from"three";var Nb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},i.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width);e.shapeBlendNode&&(o=t);let n=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:t,height:o,depth:n})}}static build(i){let{width:r,height:e,depth:t,radialSegments:o,tubularSegments:n,arc:a,cornerRadius:s,cornerSegments:l}=i.parameters,c=EE(r,e,t,r*.5,a,n,0,0,o,s,l);return c.scale(1,e/r,1),Object.assign(c,{userData:{...i,type:"TorusGeometry"}})}};function EE(i,r,e,t,o,n,a,s,l,c,u){[r,e]=[e,r],a=r/2;let p=IE.clamp(o/360,0,1);if(p===0){let d=new AE;return d.setAttribute("position",new ME([],3)),d}return p===1&&(c=0),new ol(!0,i,r,e,t,p,n,a,s,l,c,u)}import{TorusKnotGeometry as NE}from"three";var Db=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:r,tube:e,tubularSegments:t,radialSegments:o,p:n,q:a}=i.parameters,s=r*.5;s!==e&&(s-=e);let l=new NE(s,e,t,o,n,a);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var _b=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof je?i.shape:new je,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(i){let{width:r=100,height:e,cornerRadius:t,depth:o,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:s}=i.parameters,l=i.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,f=l.points.length;d<f;d++)l.points[d].roundness=t;l.roundness=t,l.update();let p=er.create({shape:l,parameters:{roundness:t,depth:o,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...i,type:"TriangleGeometry"}})}};import{Vector2 as Vb,Vector3 as Dt,Matrix3 as HE,Matrix4 as nn,BufferGeometry as zb,BufferAttribute as _a,MathUtils as Lu}from"three";function Rb(i,r){let e=2*Math.PI;return(i%e+e)%e===(r%e+e)%e}function DE(i){return/^(rgba)?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(i.toLowerCase())}function _E(i,r,e){let t,o,n,a=Math.floor(i*6),s=i*6-a,l=e*(1-r),c=e*(1-s*r),u=e*(1-(1-s)*r);switch(a%6){case 0:t=e,o=u,n=l;break;case 1:t=c,o=e,n=l;break;case 2:t=l,o=e,n=u;break;case 3:t=l,o=c,n=e;break;case 4:t=u,o=l,n=e;break;case 5:default:t=e,o=l,n=c;break}return{r:t*255,g:o*255,b:n*255}}function RE(i,r,e){i/=255,r/=255,e/=255;let t=Math.max(i,r,e),o=Math.min(i,r,e),n=t,a=t-o,s=t==0?0:a/t,l;if(t==o)l=0;else{switch(t){case i:l=(r-e)/a+(r<e?6:0);break;case r:l=(e-i)/a+2;break;case e:default:l=(i-r)/a+4;break}l/=6}return{h:l,s,v:n}}function LE(i){return i=Math.floor(i),{r:i>>16&255,g:i>>8&255,b:i&255}}function BE(i,r,e){return(i<<16)+(r<<8)+e}function VE(i,r,e){return i=Math.round(i),r=Math.round(r),e=Math.round(e),"#"+[i,r,e].map(t=>t.toString(16).padStart(2,"0")).join("").toUpperCase()}function zE(i){let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;i=i.replace(r,(t,o,n,a)=>String(o+o+n+n+a+a));let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}var Lb={parseRgba:DE,hsvToRgb:_E,rgbToHsv:RE,hexToRgb:LE,rgbToHex:BE,rgbToHexString:VE,hexStringToRgb:zE};function Fo(i){return{all:i=i||new Map,on:function(r,e){var t=i.get(r);t?t.push(e):i.set(r,[e])},off:function(r,e){var t=i.get(r);t&&(e?t.splice(t.indexOf(e)>>>0,1):i.set(r,[]))},emit:function(r,e){var t=i.get(r);t&&t.slice().map(function(o){o(e)}),(t=i.get("*"))&&t.slice().map(function(o){o(r,e)})}}}var Ru=class{constructor(r,e,t){this.id=r;this.userAPI=e;this.result=void 0;this.error="null";this.isPrefetched=!1;this.isLoading=!1;this.isLoaded=!1;this.prefetchPromise=new Promise(r=>r());this.emitter=Fo();this._innerCallUserAPI=async r=>{this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await kE(this.userAPI,r),this.error="null",this.emitter.emit("success",{userAPIId:this.id})}catch(e){let t=e.message?.split("_:_")?.[0]?.replace("status:","")??"null";this.error=t,this.result=null,this.emitter.emit("error",{userAPIId:this.id})}this.isLoading=!1,this.isPrefetched=!0,this.isLoaded=!0};e?.integration?.type==="OpenAI"?this.result={content:""}:e.method==="GET"&&e.url!==""&&(this.prefetchPromise=this.prefetch(t)),this._debouncedCallUserAPI=this._innerCallUserAPI,this._updateDebouncedCallUserAPI(),this._debouncedPrefetch=wc(this.prefetch,1e3,{trailing:!0})}_updateDebouncedCallUserAPI(){this._debouncedCallUserAPI=this.userAPI.debounce!==void 0&&this.userAPI.debounce>0?wc(this._innerCallUserAPI,this.userAPI.debounce,{leading:!0,trailing:!0}):this._innerCallUserAPI}async prefetch(r){await this.callUserAPI(r)}async callUserAPI(r){await this._debouncedCallUserAPI(r)}update(r,e,t=!0){this.userAPI=r,this._updateDebouncedCallUserAPI(),this.userAPI.url!==""&&this.userAPI.method==="GET"&&t&&this._debouncedPrefetch(e)}retrieveValue(r){if(this.result)try{return Ze.zoom(this.result,r)}catch(e){console.error(e)}}retrieveZoomedKeyValues(r){if(this.result){let e=r&&r.length?Ze.zoom(this.result,r):this.result;if(UE(e))return Object.entries(e);if(jE(e))return e.map((t,o)=>[o.toString(),t]);throw FE(e)?new Error("This path points to a value, use retrieveValue() instead. "+r?.join(".")):new Error("Path error"+r?.join("."))}}dispose(){}on(r,e){this.emitter.on(r,e)}off(r,e){this.emitter.off(r,e)}get autostart(){return this.userAPI.autoStart}};function GE(i){let r=new Headers;return i.headers.forEach(e=>{e.data.key!==""&&r.append(e.data.key,e.data.value)}),r}function FE(i){return typeof i=="string"||typeof i=="number"||typeof i=="boolean"||i===null}function jE(i){return Array.isArray(i)}function UE(i){return typeof i=="object"&&i!==null}async function kE(i,r,e=new AbortController){let t,o=i.url,n=i.proxy?.enabled??!1,a;if(i.integration?.type==="OpenAI"){let l=sl(i.integration.prompt===""?[]:JSON.parse(i.integration.prompt),r),c=i.integration.behavior===""?[]:sl(JSON.parse(i.integration.behavior),r);a=`{
4
4
  "model": "${i.integration.model}",
5
5
  "messages": [${i.integration.useBehavior?`
6
6
  {
@@ -12,14 +12,14 @@ best distance: ${d.d}`);let b=[d.x,d.y];return b.distance=d.d,b.distance}functio
12
12
  "content": "${l}"
13
13
  }
14
14
  ]
15
- }`}if(n){o=`${!1&&window.location.search.includes("api-dev")?"https://api-dev.spline.design/":"https://apis.spline.design/"}file/${i.proxy.fileId}/external-api/request?uuidexternalapi=${i.proxy.proxyId}`;let u;a!==void 0?u=a:i.method==="POST"&&i.body&&(u=sl(JSON.parse(i.body),r)),u!==void 0&&(o+=`&data=${encodeURIComponent(u.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else i.integration?.type==="OpenAI"?t=a:i.method==="POST"&&i.body&&(t=sl(JSON.parse(i.body),r));let s=await fetch(o,{method:n?"GET":i.method,headers:n?void 0:k3(i),signal:e.signal,body:t});if(!s.ok)throw new Error("status:"+s.status+"_:_"+s.statusText);if(i.integration?.type==="OpenAI"){let l=await s.json();return n&&(l=l.response),{content:l.choices[0].message.content}}else{let l=await s.json();return n&&(l=l.response),l}}var gb=(i,r)=>{if(typeof i=="string"){let e=r.getVariable(i);if(e)return gb(e,r)}return yi.isBoolean(i)?yi.getDisplayedValue(i).toLowerCase():yi.getDisplayedValue(i)},sl=(i,r)=>i.map((e,t)=>{if("text"in e)return e.text;if("type"in e){if(e.type==="paragraph")return(t>0?`
16
- `:"")+sl(e.children,r);if(e.type==="variable"){let o=r.getVariable(e.variableId);if(o!==void 0)return gb(o,r)}}return""}).join("");var Y3=new nn,K3=new nn;function Q3(i,r,e){let t=[new Dt,new Dt,new Dt],o=[new Dt,new Dt,new Dt];return i.extractBasis(t[0],t[1],t[2]),r.extractBasis(o[0],o[1],o[2]),t.forEach((n,a)=>{let s=o[a],l=Nu.lerp(n.length(),s.length(),e);n.lerp(s,e).setLength(l)}),new nn().makeBasis(t[0],t[1],t[2])}var vb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),a=r?.shapeData??Ma.create({parameters:Op}).userData.shape;return{path:i.path??la.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:n,extrusion:{...Uc,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new Ef(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new bb,{userData:{...i,type:"PathGeometry"}})}},Ef=class extends bb{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)||!mb(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:n}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),n=Math.max(0,Math.min(n,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(n*a),l=this.inputs.path.isClosed?Math.ceil((o+n)*a):Math.ceil(Math.min(1,o+n)*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]=Q3(p[j],p[F],H)},f=0,h=n*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||n===0)&&(f=h,d(0,1,f));let m=0,y=(n+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&n+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,f,m);let{bevel:b,bevelSides:v}=this.inputs.parameters.extrusion,w=b>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:M}=this._computeShapePoints(O),g=0,D;w==="round"&&(D=new vi(this.inputs.shapeData,2*b,b,O,v,void 0,!0),g=D.getAttribute("position").count);let E=0,I=0;T.sort((j,F)=>j.start-F.start),T.forEach(j=>{j.verticesStart=E,j.verticesCount=j.continuous.reduce((F,H,W)=>F+(W===0||!H?2:1),0),I+=j.verticesCount,E=I});let N=I*c,_,R=0;if(this._isOpenEnded()&&w==="flat"){try{_=Fr({windingRule:Fe.ODD,elementType:st.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=mf}R=_.vertexCount}let V=N+2*R+g*2,U=N+2*R,B={positions:new Float32Array(V*3),normals:new Float32Array(V*3),uvs:new Float32Array(V*2)},q=[];if(T.forEach(j=>{this._extrudeRegion(j,M,p,u,B,q,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,N,q,B,p[0],u[0],!1),this._closeEnd(_,N+R,q,B,p[p.length-1],u[u.length-1],!0)),D){B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);for(let W=U;W<U+g;W++)B.uvs[W*2+1]=1e-4;let j=q.length;q.push(...D.getIndex().array.map(W=>W+U)),U+=g,B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);let F=q.length;q.push(...D.getIndex().array.map(W=>W+U)),this.setAttribute("position",new _a(B.positions,3)),this.setAttribute("normal",new _a(B.normals,3)),this.setAttribute("uv",new _a(B.uvs,2)),this.setIndex(q);let H=Y3;H.copy(p[p.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(p[0]).setPosition(u[0]).multiply(K3.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-g,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new _a(B.positions,3)),this.setAttribute("normal",new _a(B.normals,3)),this.setAttribute("uv",new _a(B.uvs,2)),this.setIndex(q)}_extractPathPoints(){let t=cu(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,n=this.inputs.path.isClosed,a=new Dt,s=new Dt,l=new Dt,c=new Dt,u=new Dt(0,1,0);for(let y=0;y<o;y++){let b=e[y],v;y===0?v=n?e[e.length-2]:b.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let w;y===o-1?w=n?e[1]:b.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let O=b.clone().sub(v).normalize(),S=w.clone().sub(b).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 M=u.clone().cross(T).normalize(),g=T.clone().cross(M).normalize();u.copy(g),c.copy(M),y===0&&(a.copy(g),s.copy(T));let D=new nn().makeBasis(M,g,T);t.push(D)}let p=n?s:l,d=n?a:new Dt(0,1,0),f=p.clone().cross(c).normalize(),h=Math.acos(d.dot(f));if(isNaN(h))return t;let m=d.clone().cross(f);p.dot(m)>0&&(h*=-1);for(let y=1;y<t.length;y++){let b=new nn().makeRotationZ(h*y/t.length);t[y].multiply(b)}return t}_applyPathModifiers(e,t,o){let n=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new nn,p=new nn;return e.forEach((d,f)=>{let h=f===0?0:f===n-1?1:(f-t)/(n-(o===0?0:1)-(t+(1-o)));u.makeRotationZ(Nu.lerp(a,a+s,h)*Nu.DEG2RAD);let m=Nu.lerp(l,c,h);p.makeScale(m,m,m),d.multiply(u).multiply(p)}),e}_computeShapePoints(e=12,t=Fe.ODD){let o=this.inputs.shapeData,n=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),b=[];for(let v=y.length-1;v>=1;v-=2){let w=y[v-1],O=y[v-0];b.push(w,O)}return b}),s;try{s=Fr({windingRule:t,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]})}catch{s=rl}let l;try{l=Fr({windingRule:Fe.ODD,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=hf}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],b=m%2===0?s.vertexCount:0;s.elements.push(y+b)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],b=s.vertexCount;s.vertexIndices.push(y+b)}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,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let b=m*2,v=s.vertices[b+0],w=s.vertices[b+1];v<u&&(u=v),v>p&&(p=v),w<d&&(d=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,b=m*2,v=s.elements[b+0],w=s.elements[b+1],O=v+w,S={start:v,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let T=v,M=O-1,g=v+1,D=o.roundedCurves.length;do{let E=T-v,I=s.vertices[M*2+0],N=s.vertices[M*2+1],_=s.vertices[T*2+0],R=s.vertices[T*2+1],V=s.vertices[g*2+0],U=s.vertices[g*2+1],B=_-I,q=R-N,j=Math.sqrt(B*B+q*q);B/=j,q/=j;let F=_-V,H=R-U,W=Math.sqrt(F*F+H*H);F/=W,H/=W,S.normals[E*2+0]=-H,S.normals[E*2+1]=F;let ee=s.vertexIndices[T];if(Array.isArray(ee))S.continuous[E]=!1;else{let[te,Y]=o.getCurveIndexFromVertexId(ee-1,!0);if(Y>0&&Y<1)S.continuous[E]=!0;else{let re=Y===1?te+1:te-1;re=(re+D)%D;let K=Y===1?0:1,Z=o.roundedCurves[te].getTangent(Y),Q=o.roundedCurves[re].getTangent(K);S.continuous[E]=Z.dot(Q)>.95}}y&&(S.normals[E*2+0]*=-1,S.normals[E*2+1]*=-1),[M,T,g]=[T,g,g+1],g>=O&&(g-=w)}while(g!==v+1)}return{regions:[n,...a],infos:h,vertices:s.vertices}}_insertVertex(e,t,o,n,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]=n.x,e.normals[l+1]=n.y,e.normals[l+2]=n.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,t,o,n,a,s,l){let c=new Dt,u=new Dt,p=new Dt,d=new Dt,f=new xb;o.forEach((m,y)=>{let b=n[y],v=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let O=(e.start+w)*2;if(c.set(t[O+0],t[O+1],0),p.copy(c).applyMatrix4(m).add(b),e.continuous[w])d.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===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(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,v,p,d,f),v++,!e.continuous[w]||w===0){if(w===0)d.set(e.normals[w*2+0],e.normals[w*2+1],0),f.set(0,y/(o.length-1));else{let S=w===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,f),v++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,b=e.verticesStart*o.length+e.verticesCount*(m+1),v=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&v++;let O=w===e.count-1?0:v+1,S=y+v,T=y+O,M=b+O,g=b+v;e.isHole?s.push(S,M,T,S,g,M):s.push(S,T,M,S,M,g),v++}}}_closeEnd(e,t,o,n,a,s,l){let c=e.vertexCount,u=new Dt(0,0,l?-1:1).applyMatrix4(a),p=new Dt,d=new xb;for(let h=0;h<c;h++){let m=2*h;p.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(n,t+h,p,u,d)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+t,b=f[m+(l?1:2)]+t,v=f[m+(l?2:1)]+t;o.push(y,b,v)}}applyMatrix4OnRange(e,t,o){let n=e.elements,a=new X3().getNormalMatrix(e).elements,s,l,c,u,p=this.attributes.position,d=this.attributes.normal;if(!p||!d)return;let f=p.array,h=d.array,m=p.itemSize;for(let y=t*m,b=o*m;y<b;y+=m){if(y===t)debugger;s=f[y+0],l=f[y+1],c=f[y+2],u=1/(n[3]*s+n[7]*l+n[11]*c+n[15]),f[y+0]=(n[0]*s+n[4]*l+n[8]*c+n[12])*u,f[y+1]=(n[1]*s+n[5]*l+n[9]*c+n[13])*u,f[y+2]=(n[2]*s+n[6]*l+n[10]*c+n[14])*u,s=h[y+0],l=h[y+1],c=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*c,h[y+1]=a[1]*s+a[4]*l+a[7]*c,h[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 n=e;n<t;n+=3){let a=o.getX(n),s=o.getX(n+1),l=o.getX(n+2);o.setXYZ(n,l,s,a)}o.needsUpdate=!0}}};import{BufferAttribute as Sb,BufferGeometry as Nf}from"three";import{mergeBufferGeometries as J3}from"three/examples/jsm/utils/BufferGeometryUtils.js";function wb(){let i=new Nf;return i.setAttribute("position",new Sb(new Float32Array([]),3)),i.setIndex(new Sb(new Uint16Array([]),1)),i}var eE=wb().attributes,tE=12,rE=1,an=class extends Nf{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,eE),this.userData={parameters:e,type:"TextGeometry"};let o=t.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e,t)):this.updateFont(e.font,t).then(()=>{this.update(e,t),t?.requestRender()})}async updateFont(e,t){let o=t.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e,t){let o=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!o?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:n,height:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:u,textTransform:p}=e,d=yi.getDisplayedValue(u),f=p===2?d.toUpperCase():p===3?d.toLowerCase():d,h=oE(e,o,f,t),{shapes:m,charWidths:y,charCoords:b}=o.generateShapes(h,e,t),v=(typeof n=="number"?n:Number(t.getVariable(n)))*.5,w=(typeof a=="number"?a:Number(t.getVariable(a)))*.5,O=m.map(M=>new je().fromShape(M,!0));this.vectorShapes=O;let S=O.map(M=>er.create({shape:M,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?Fe.NONZERO:Fe.ODD,subdivisions:this.isLowResolution&&s>0?rE:tE}})),T=S.length?J3(S):wb();T.translate(-v,w,0),this.dispose(),this.wrappedText=h,this.charCoords=b,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(T.attributes).forEach(([M,g])=>{this.setAttribute(M,g)}),this.setIndex(T.index),this.computeBoundingSphere()}clone(){let e=Bt(new Nf,an.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,t){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},t)}get text(){return this.userData.parameters.text??""}};function oE(i,r,e,t){let o=typeof i.width=="string"?Number(t.getVariable(i.width)):i.width,n=[""],a="";for(let s of e)a+=s,s===" "||s===`
15
+ }`}if(n){o=`${!1&&window.location.search.includes("api-dev")?"https://api-dev.spline.design/":"https://apis.spline.design/"}file/${i.proxy.fileId}/external-api/request?uuidexternalapi=${i.proxy.proxyId}`;let u;a!==void 0?u=a:i.method==="POST"&&i.body&&(u=sl(JSON.parse(i.body),r)),u!==void 0&&(o+=`&data=${encodeURIComponent(u.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else i.integration?.type==="OpenAI"?t=a:i.method==="POST"&&i.body&&(t=sl(JSON.parse(i.body),r));let s=await fetch(o,{method:n?"GET":i.method,headers:n?void 0:GE(i),signal:e.signal,body:t});if(!s.ok)throw new Error("status:"+s.status+"_:_"+s.statusText);if(i.integration?.type==="OpenAI"){let l=await s.json();return n&&(l=l.response),{content:l.choices[0].message.content}}else{let l=await s.json();return n&&(l=l.response),l}}var Bb=(i,r)=>{if(typeof i=="string"){let e=r.getVariable(i);if(e)return Bb(e,r)}return yi.isBoolean(i)?yi.getDisplayedValue(i).toLowerCase():yi.getDisplayedValue(i)},sl=(i,r)=>i.map((e,t)=>{if("text"in e)return e.text;if("type"in e){if(e.type==="paragraph")return(t>0?`
16
+ `:"")+sl(e.children,r);if(e.type==="variable"){let o=r.getVariable(e.variableId);if(o!==void 0)return Bb(o,r)}}return""}).join("");var WE=new nn,qE=new nn;function $E(i,r,e){let t=[new Dt,new Dt,new Dt],o=[new Dt,new Dt,new Dt];return i.extractBasis(t[0],t[1],t[2]),r.extractBasis(o[0],o[1],o[2]),t.forEach((n,a)=>{let s=o[a],l=Lu.lerp(n.length(),s.length(),e);n.lerp(s,e).setLength(l)}),new nn().makeBasis(t[0],t[1],t[2])}var Gb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,r){let e=Object.assign({},r?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),a=r?.shapeData??Ma.create({parameters:Dp}).userData.shape;return{path:i.path??la.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:n,extrusion:{...qc,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new zf(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new zb,{userData:{...i,type:"PathGeometry"}})}},zf=class extends zb{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)||!Rb(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:n}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),n=Math.max(0,Math.min(n,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(n*a),l=this.inputs.path.isClosed?Math.ceil((o+n)*a):Math.ceil(Math.min(1,o+n)*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]=$E(p[j],p[F],H)},f=0,h=n*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||n===0)&&(f=h,d(0,1,f));let m=0,y=(n+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&n+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,f,m);let{bevel:b,bevelSides:v}=this.inputs.parameters.extrusion,w=b>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:M}=this._computeShapePoints(O),g=0,D;w==="round"&&(D=new vi(this.inputs.shapeData,2*b,b,O,v,void 0,!0),g=D.getAttribute("position").count);let E=0,I=0;T.sort((j,F)=>j.start-F.start),T.forEach(j=>{j.verticesStart=E,j.verticesCount=j.continuous.reduce((F,H,W)=>F+(W===0||!H?2:1),0),I+=j.verticesCount,E=I});let N=I*c,_,R=0;if(this._isOpenEnded()&&w==="flat"){try{_=Fr({windingRule:Fe.ODD,elementType:st.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=Pf}R=_.vertexCount}let V=N+2*R+g*2,U=N+2*R,B={positions:new Float32Array(V*3),normals:new Float32Array(V*3),uvs:new Float32Array(V*2)},q=[];if(T.forEach(j=>{this._extrudeRegion(j,M,p,u,B,q,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,N,q,B,p[0],u[0],!1),this._closeEnd(_,N+R,q,B,p[p.length-1],u[u.length-1],!0)),D){B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);for(let W=U;W<U+g;W++)B.uvs[W*2+1]=1e-4;let j=q.length;q.push(...D.getIndex().array.map(W=>W+U)),U+=g,B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);let F=q.length;q.push(...D.getIndex().array.map(W=>W+U)),this.setAttribute("position",new _a(B.positions,3)),this.setAttribute("normal",new _a(B.normals,3)),this.setAttribute("uv",new _a(B.uvs,2)),this.setIndex(q);let H=WE;H.copy(p[p.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(p[0]).setPosition(u[0]).multiply(qE.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-g,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new _a(B.positions,3)),this.setAttribute("normal",new _a(B.normals,3)),this.setAttribute("uv",new _a(B.uvs,2)),this.setIndex(q)}_extractPathPoints(){let t=fu(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,n=this.inputs.path.isClosed,a=new Dt,s=new Dt,l=new Dt,c=new Dt,u=new Dt(0,1,0);for(let y=0;y<o;y++){let b=e[y],v;y===0?v=n?e[e.length-2]:b.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let w;y===o-1?w=n?e[1]:b.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let O=b.clone().sub(v).normalize(),S=w.clone().sub(b).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 M=u.clone().cross(T).normalize(),g=T.clone().cross(M).normalize();u.copy(g),c.copy(M),y===0&&(a.copy(g),s.copy(T));let D=new nn().makeBasis(M,g,T);t.push(D)}let p=n?s:l,d=n?a:new Dt(0,1,0),f=p.clone().cross(c).normalize(),h=Math.acos(d.dot(f));if(isNaN(h))return t;let m=d.clone().cross(f);p.dot(m)>0&&(h*=-1);for(let y=1;y<t.length;y++){let b=new nn().makeRotationZ(h*y/t.length);t[y].multiply(b)}return t}_applyPathModifiers(e,t,o){let n=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new nn,p=new nn;return e.forEach((d,f)=>{let h=f===0?0:f===n-1?1:(f-t)/(n-(o===0?0:1)-(t+(1-o)));u.makeRotationZ(Lu.lerp(a,a+s,h)*Lu.DEG2RAD);let m=Lu.lerp(l,c,h);p.makeScale(m,m,m),d.multiply(u).multiply(p)}),e}_computeShapePoints(e=12,t=Fe.ODD){let o=this.inputs.shapeData,n=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),b=[];for(let v=y.length-1;v>=1;v-=2){let w=y[v-1],O=y[v-0];b.push(w,O)}return b}),s;try{s=Fr({windingRule:t,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]})}catch{s=rl}let l;try{l=Fr({windingRule:Fe.ODD,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=wf}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],b=m%2===0?s.vertexCount:0;s.elements.push(y+b)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],b=s.vertexCount;s.vertexIndices.push(y+b)}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,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let b=m*2,v=s.vertices[b+0],w=s.vertices[b+1];v<u&&(u=v),v>p&&(p=v),w<d&&(d=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,b=m*2,v=s.elements[b+0],w=s.elements[b+1],O=v+w,S={start:v,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let T=v,M=O-1,g=v+1,D=o.roundedCurves.length;do{let E=T-v,I=s.vertices[M*2+0],N=s.vertices[M*2+1],_=s.vertices[T*2+0],R=s.vertices[T*2+1],V=s.vertices[g*2+0],U=s.vertices[g*2+1],B=_-I,q=R-N,j=Math.sqrt(B*B+q*q);B/=j,q/=j;let F=_-V,H=R-U,W=Math.sqrt(F*F+H*H);F/=W,H/=W,S.normals[E*2+0]=-H,S.normals[E*2+1]=F;let ee=s.vertexIndices[T];if(Array.isArray(ee))S.continuous[E]=!1;else{let[te,Y]=o.getCurveIndexFromVertexId(ee-1,!0);if(Y>0&&Y<1)S.continuous[E]=!0;else{let re=Y===1?te+1:te-1;re=(re+D)%D;let K=Y===1?0:1,Z=o.roundedCurves[te].getTangent(Y),Q=o.roundedCurves[re].getTangent(K);S.continuous[E]=Z.dot(Q)>.95}}y&&(S.normals[E*2+0]*=-1,S.normals[E*2+1]*=-1),[M,T,g]=[T,g,g+1],g>=O&&(g-=w)}while(g!==v+1)}return{regions:[n,...a],infos:h,vertices:s.vertices}}_insertVertex(e,t,o,n,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]=n.x,e.normals[l+1]=n.y,e.normals[l+2]=n.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,t,o,n,a,s,l){let c=new Dt,u=new Dt,p=new Dt,d=new Dt,f=new Vb;o.forEach((m,y)=>{let b=n[y],v=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let O=(e.start+w)*2;if(c.set(t[O+0],t[O+1],0),p.copy(c).applyMatrix4(m).add(b),e.continuous[w])d.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===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(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,v,p,d,f),v++,!e.continuous[w]||w===0){if(w===0)d.set(e.normals[w*2+0],e.normals[w*2+1],0),f.set(0,y/(o.length-1));else{let S=w===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,f),v++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,b=e.verticesStart*o.length+e.verticesCount*(m+1),v=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&v++;let O=w===e.count-1?0:v+1,S=y+v,T=y+O,M=b+O,g=b+v;e.isHole?s.push(S,M,T,S,g,M):s.push(S,T,M,S,M,g),v++}}}_closeEnd(e,t,o,n,a,s,l){let c=e.vertexCount,u=new Dt(0,0,l?-1:1).applyMatrix4(a),p=new Dt,d=new Vb;for(let h=0;h<c;h++){let m=2*h;p.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(n,t+h,p,u,d)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+t,b=f[m+(l?1:2)]+t,v=f[m+(l?2:1)]+t;o.push(y,b,v)}}applyMatrix4OnRange(e,t,o){let n=e.elements,a=new HE().getNormalMatrix(e).elements,s,l,c,u,p=this.attributes.position,d=this.attributes.normal;if(!p||!d)return;let f=p.array,h=d.array,m=p.itemSize;for(let y=t*m,b=o*m;y<b;y+=m){if(y===t)debugger;s=f[y+0],l=f[y+1],c=f[y+2],u=1/(n[3]*s+n[7]*l+n[11]*c+n[15]),f[y+0]=(n[0]*s+n[4]*l+n[8]*c+n[12])*u,f[y+1]=(n[1]*s+n[5]*l+n[9]*c+n[13])*u,f[y+2]=(n[2]*s+n[6]*l+n[10]*c+n[14])*u,s=h[y+0],l=h[y+1],c=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*c,h[y+1]=a[1]*s+a[4]*l+a[7]*c,h[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 n=e;n<t;n+=3){let a=o.getX(n),s=o.getX(n+1),l=o.getX(n+2);o.setXYZ(n,l,s,a)}o.needsUpdate=!0}}};import{BufferAttribute as Fb,BufferGeometry as Gf}from"three";import{mergeBufferGeometries as YE}from"three/examples/jsm/utils/BufferGeometryUtils.js";function jb(){let i=new Gf;return i.setAttribute("position",new Fb(new Float32Array([]),3)),i.setIndex(new Fb(new Uint16Array([]),1)),i}var KE=jb().attributes,QE=12,ZE=1,an=class extends Gf{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,KE),this.userData={parameters:e,type:"TextGeometry"};let o=t.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e,t)):this.updateFont(e.font,t).then(()=>{this.update(e,t),t?.requestRender()})}async updateFont(e,t){let o=t.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e,t){let o=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!o?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:n,height:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:u,textTransform:p}=e,d=yi.getDisplayedValue(u),f=p===2?d.toUpperCase():p===3?d.toLowerCase():d,h=JE(e,o,f,t),{shapes:m,charWidths:y,charCoords:b}=o.generateShapes(h,e,t),v=(typeof n=="number"?n:Number(t.getVariable(n)))*.5,w=(typeof a=="number"?a:Number(t.getVariable(a)))*.5,O=m.map(M=>new je().fromShape(M,!0));this.vectorShapes=O;let S=O.map(M=>er.create({shape:M,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?Fe.NONZERO:Fe.ODD,subdivisions:this.isLowResolution&&s>0?ZE:QE}})),T=S.length?YE(S):jb();T.translate(-v,w,0),this.dispose(),this.wrappedText=h,this.charCoords=b,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(T.attributes).forEach(([M,g])=>{this.setAttribute(M,g)}),this.setIndex(T.index),this.computeBoundingSphere()}clone(){let e=Bt(new Gf,an.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,t){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},t)}get text(){return this.userData.parameters.text??""}};function JE(i,r,e,t){let o=typeof i.width=="string"?Number(t.getVariable(i.width)):i.width,n=[""],a="";for(let s of e)a+=s,s===" "||s===`
17
17
  `?(n[n.length-1]+=a,a="",s===`
18
- `&&n.push("")):r.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),r.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}import{BufferGeometry as _f,BufferAttribute as Cb,Uint32BufferAttribute as Rf,Float32BufferAttribute as Lf,Matrix4 as lE,Vector3 as cl,Sphere as cE,Box3 as uE,BoxGeometry as dE}from"three";var Ob,_u=new Promise(i=>{Ob=i}),Pb=!1;var Du;function Tb(){if(Pb)return;if(Du)return Du;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.10.27/build",o=import("./process.js"),[n,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(c=>c.arrayBuffer())]),s=n.default,l=await s({wasmBinary:a});Ob(l),Pb=!0}return Du=i(),Du}import{BufferGeometryLoader as iE}from"three";var nE=["font"];function jo(i,r,e,t){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let p of c)u=u[p];for(o in u){let p=u[o];Sp(p)&&!nE.includes(o)&&(u[o]=r.getVariable(p,[t.uuid,"geometry",...c,o]),Sp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=je.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new iE().parse(n),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(n.type==="SubdivGeometry"){let c=new gt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new an(n,r);if(n.type==="InputGeometry")return new an(n,r);if(n.type==="UIGeometry")return Da.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Df(s)}catch(c){console.error(c)}if(!l){let c=je.createFromState(sa.defaultData(),100,100);s.shape=c,l=Df(s)}return l}import{Matrix4 as aE}from"three";var sE=new aE;function ll(i,r,e,t){let o=i.position.array,n=i.normal.array,a=sE.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=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Ru=new uE,Ra=new cl,Se;_u.then(i=>{Se=i});var Ab=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Mb=new Uint32Array([0,1,2,3]),Ib=new Uint8Array([4]),gt=class extends _f{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,n=ui.div(t,o);this.subdividedGeometry&&ll(this.subdividedGeometry.attributes,...n),this.originalGeometry&&ll(this.originalGeometry.attributes,...n),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*n[0],height:a.height*n[1],depth:a.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(Ra.fromArray(n));let s=Ra.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}=gt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new dE(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(gt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new cE,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Ru.setFromBufferAttribute(t),Ru.getCenter(o),e.boundingSphere.radius=o.distanceTo(Ru.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ru.getSize(Ra);let n={width:Ra.x,height:Ra.y,depth:Ra.z};return this.userData.parameters=n,n}static build(e,t,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),t&&(Se.free_bvh(t),Se.free_subdivision_surface(t));try{a=gt.allocate(e,n)}catch(u){console.error(u,e),a=gt.allocate({positionWASM:Ab,indexWASM:Mb,verticesPerFaceWASM:Ib},n)}if(Se.set_destination_refinement_level(a,0),s=gt.buildLevel(a,!0,c),e.subdivisions>0)try{Se.set_destination_refinement_level(a,e.subdivisions),l=gt.buildLevel(a,!1,c)}catch{try{Se.set_destination_refinement_level(a,e.subdivisions-1),l=gt.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 n=e.shape!==void 0||e.path!==void 0?t.geometry:jo(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=Gf(n.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,f=d+e.radialSegments*3;p=[d,f]}return{indices:l,verticesPerFace:c}=Ff(s,u,n,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,t){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=Ab,n=Mb,a=Ib);let c=o.length,u=n.length,p=a.length,d=o.length+s.length+l.length,f=n.length+a.length,h=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,b=Se._malloc(h),v=new Float32Array(Se.HEAPF32.buffer,b,d),w=new Uint32Array(Se.HEAPU32.buffer,b+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(n,0),w.set(a,n.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new lE().makeScale(...e.scaleBaked)),t&&(O?O.premultiply(t):O=t);let S=O?Se.alloc_subdivision_surface2(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):Se.alloc_subdivision_surface(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p);return Se._free(b),S}static buildLevel(e,t,o,n,a){let s=a?Se.get_mesh_data2(e,t?Se.Level.CONTROL:Se.Level.REFINED,o,a.elements):Se.get_mesh_data(e,t?Se.Level.CONTROL:Se.Level.REFINED,o),l=8,c=Se.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=Se.HEAPU32[c[p]>>2],f=Se.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let h=Se.HEAPU32[c[p]>>2],m=Se.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let y=Se.HEAPU32[c[p]>>2],b=Se.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=Se.HEAPU32[c[p]>>2],w=Se.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,n===void 0){let O=new _f;if(O.setIndex(new Rf(w,1)),O.setAttribute("position",new Lf(f,3)),O.setAttribute("normal",new Lf(m,3)),t){O.setAttribute("faceMap",new Rf(b,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new Cb(S,4))}return Se.free_mesh_data(s),O.userData.type="SubdivGeometry",O}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Se.free_mesh_data(s)}static freeSubdivPointer(e){Se.free_bvh(e),Se.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let n=Se.get_wireframe_data_for_base_level(e),a=4,s=Se.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Se.HEAPU32[s[c]>>2],p=Se.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Se.HEAPU32[s[c]>>2],f=Se.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(t===void 0){let h=new _f;h.setAttribute("position",new Lf(p,3));let m=new Float32Array(p.length);for(let y=0,b=p.length;y<b;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new Cb(m,3)),h.setIndex(new Rf(f,1)),Se.free_wireframe_data_for_base_level(n),h}t.getAttribute("position").copyArray(p),t.attributes.position.needsUpdate=!0,Se.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,t,o){let n=t===0;n||Se.set_destination_refinement_level(e,t);let a=o?Se.get_topological_data2(e,n?Se.Level.CONTROL:Se.Level.REFINED,o.elements):Se.get_topological_data(e,n?Se.Level.CONTROL:Se.Level.REFINED),s=6,l=Se.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=Se.HEAPU32[l[u]>>2],d=new Float32Array(Se.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let f=Se.HEAPU32[l[u]>>2],h=new Uint32Array(Se.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Se.HEAPU32[l[u]>>2],y=new Uint8Array(Se.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Se.free_topological_data(a),{positions:d,indices:h,verticesPerFace:y}}};var Eb=["getX","getY","getZ"];function Gf(i,r){let e={},t=r?r.count:i.count,o=0,n=[],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+=`${~~(i[Eb[d]](u)*s)},`;if(p in e)n.push(e[p]);else{for(let d=0;d<3;d++)a.push(i[Eb[d]](u));e[p]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var Lu=new cl,Bf=new cl,Vf=new cl,zf=new cl;function Ff(i,r,e,t){let o=[],n=[];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((f,h)=>Math.floor(h/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]);i.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),o.push(p++);return n.push(p),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<r.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[r[s]*3+2]===a||i[r[s]*3+2]===0)&&l++,(i[r[s+1]*3+2]===a||i[r[s+1]*3+2]===0)&&l++,(i[r[s+2]*3+2]===a||i[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]){Lu.set(i[r[s]*3],i[r[s]*3+1],i[r[s]*3+2]),Bf.set(i[r[s+1]*3],i[r[s+1]*3+1],i[r[s+1]*3+2]),Vf.set(i[r[s+4]*3],i[r[s+4]*3+1],i[r[s+4]*3+2]),zf.set(i[r[s+5]*3],i[r[s+5]*3+1],i[r[s+5]*3+2]),Bf.sub(Lu).normalize(),Vf.sub(Lu).normalize(),zf.sub(Lu).normalize();let l=Bf.cross(Vf).dot(zf);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]),n.push(3),s+=3):(o.push(r[s],r[s+1],r[s+4],r[s+5]),n.push(4),s+=6)}else o.push(r[s],r[s+1],r[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<i.length;p+=3,d++)i[p+2]===0&&(l.push(d),u++),i[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),n.push(u,u)}return{indices:o,verticesPerFace:n}}var wr={};dw(wr,{calcBoolean:()=>yE,calcBooleanTopological:()=>mE,freeMeshSet:()=>vE,getMeshSet:()=>gE,hasOpenEdges:()=>xE,transformMeshSet:()=>bE});var pE,Nb=new Promise(i=>{pE=i});import{Float32BufferAttribute as Db,Sphere as fE}from"three";var Be,La;Nb.then(i=>Be=i);function hE(i,r,e){let t,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=Gf(i.getAttribute("position"),o),s;if(r&&e){let{indices:l,verticesPerFace:c}=Ff(n,a,i);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:n,faceIndices:t,nFaces:s}}function _b(i){let r=i.length,e=r*Uint32Array.BYTES_PER_ELEMENT,t=r*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:t,n=Be._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Be.HEAPU32.buffer,n,r):new Float32Array(Be.HEAPF32.buffer,n,r)).set(i,0),n}function Rb(i){switch(i){case 0:return Be.OP.UNION;case 1:return Be.OP.INTERSECTION;case 2:return Be.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function mE(i,r){La===void 0&&(La=Be.init_csg());let e=_b(i),t=Be.csg_calc_topological(La,e,i.length,Rb(r));Be._free(e);let o=6,n=Be.HEAPU32.subarray(t>>2,(t>>2)+o),a=n.subarray(3,3+3),s=0,l=Be.HEAPU32[n[s]>>2],c=new Float32Array(Be.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Be.HEAPU32[n[s]>>2],p=new Uint32Array(Be.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Be.HEAPU32[n[s]>>2],f=new Uint8Array(Be.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Be.free_mesh_data(t),{positions:c,indices:p,verticesPerFace:f}}function yE(i,r,e,t){La===void 0&&(La=Be.init_csg());let o=_b(i),n=Be.csg_calc(La,o,i.length,t,Rb(r));Be._free(o);let a=5,s=Be.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Be.HEAPU32[s[c]>>2],p=Be.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Be.HEAPU32[s[c]>>2],f=Be.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Db(p,3)),e.setAttribute("normal",new Db(f,3));let m=Be.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new fE),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},Be.free_mesh_data(n),h}function gE(i,r,e){if(Be===void 0)return-1;let t,o,n;if(r&&i.userData.positions!==void 0){let b=i.userData;n=b.verticesPerFace.length,t=b.positions,o=Array(b.verticesPerFace.reduce((v,w)=>v+w,0)+n);for(let v=0,w=0,O=0;v<b.verticesPerFace.length;v++){o[O++]=b.verticesPerFace[v];for(let S=0;S<b.verticesPerFace[v];S++)o[O++]=b.indices[w++]}}else({positions:t,faceIndices:o,nFaces:n}=hE(i,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,f=Be._malloc(u),h=new Float32Array(Be.HEAPF32.buffer,f,l),m=new Uint32Array(Be.HEAPU32.buffer,f+p,c);h.set(t,0),m.set(o,0);let y=Be.get_csg_mesh(f,a,f+p,s,n);return Be._free(f),y}function xE(i){return Be.has_open_edges(i)}function bE(i,r){Be.transform_csg_mesh(i,r.elements)}function vE(i){Be.free_csg_mesh(i)}var SE={ConeGeometry:mx,CubeGeometry:yx,CylinderGeometry:hx,DodecahedronGeometry:gx,EllipseGeometry:Ma,HelixGeometry:$x,IcosahedronGeometry:Xx,LatheGeometry:Yx,NonParametricGeometry:nb,PolygonGeometry:Mu,PyramidGeometry:ab,RectangleGeometry:Da,SphereGeometry:lb,PlaneGeometry:cb,BackdropGeometry:ub,StarGeometry:Iu,TextFrameGeometry:db,TorusGeometry:pb,TorusKnotGeometry:fb,TriangleGeometry:hb,PathGeometry:vb,VectorGeometry:er},Df=i=>SE[i.type].create(i);function Ba(i){return i!==null&&"booleanOp"in i}var Va=class extends va(PE){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new wE}updateVisible(e){super.updateVisible(e),this.visible=!Ba(this.parent)&&this.visible,Ba(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(wr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ba(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Va&&(e.freeBooleanPointer(),Ba(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let o=super.updateTransformState(e,t);return o&&Ba(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ba(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Bu=new OE;function ul(i,r=0,e=i.count,t,o){let n=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=i.getX(p),f=i.getY(p),h=i.getZ(p);d<n&&(n=d),f<a&&(a=f),h<s&&(s=h),d>l&&(l=d),f>c&&(c=f),h>u&&(u=h)}Bu.min.set(n,a,s),Bu.max.set(l,c,u),Bu.getCenter(t),Bu.getSize(o).multiplyScalar(.5)}var AE=new TE,ME=new CE,Tt=class extends Va{constructor(r,e){super(AE,ME),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?ul(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};import{Box3 as QN,Matrix4 as ZN,Sphere as Av,Vector3 as JN}from"three";import{BufferAttribute as XN,Float32BufferAttribute as Cv,MathUtils as mh,Vector3 as yh}from"three";import{ShaderMaterial as CN}from"three";var Uo=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Uo.uuidContext===null)throw new Error("plz startContext");Uo.uuidContext===Uo.globalContext?this.uuid="_gid"+Uo.uuidContext.nodeContextUuid++:this.uuid="_uid"+Uo.uuidContext.nodeContextUuid++,this.type=r,this.name=""}static startContext(r){this.uuidContext===null||this.uuidContext===Uo.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,n,a){return""}generate(r,e,t,o,n){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}},qe=Uo;qe.globalContext={nodeContextUuid:0},qe.uuidContext=Uo.globalContext;import{CubeReflectionMapping as GE,CubeRefractionMapping as FE,CubeUVReflectionMapping as jE,LinearEncoding as Hb,sRGBEncoding as UE}from"three";var dl=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 jf=class{constructor(){this.nodes={};this.keywords={}}add(r){this.nodes[r.name]=r}addKeyword(r,e,t){t=t!==void 0?t:!0,this.keywords[r]={callback:e,cache:t}}remove(r){delete this.nodes[r.name]}removeKeyword(r){delete this.keywords[r]}get(r){return this.nodes[r]}getKeyword(r,e){return this.keywords[r].callback(e)}getKeywordData(r){return this.keywords[r]}contains(r){return this.nodes[r]!==void 0}containsKeyword(r){return this.keywords[r]!==void 0}},Ct=new jf;import{Vector2 as Lb}from"three";import{MathUtils as IE}from"three";var ge=class extends qe{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,n){if(t=t??this.getType(e),this.getShared(e,t)){let a=this.getUnique(e,t);a&&this.uuid===void 0&&(this.uuid=IE.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,n);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,n,a){return this.getShared(e,t)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var $e=class extends ge{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,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,t)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,t))}};var lt=class extends $e{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof Lb?e:new Lb(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,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,t)}};import{Vector3 as Bb}from"three";var Gt=class extends $e{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Bb?e:new Bb(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,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,t)}};import{Color as EE}from"three";var At=class extends EE{constructor(e,t,o,n){super(e,t,o);this.isColorA=!0;this.a=n}setRGBA(e,t,o,n){super.setRGB(e,t,o),this.a=n}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}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 n,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(n[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(n[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 tr=class extends $e{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof At?e:new At(e.r,e.g,e.b,e.a)}generateReadonly(e,t,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,t)}};var NE=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Vb=/[a-z_0-9]+/gi,J=class extends ge{constructor(e,t,o,n,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,n)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,o,n,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=Vb.exec(this.src);)u.push(s);for(let p=0;p<u.length;p++){let d=u[p],f=d[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Ct.containsKeyword(f)){let y=this.keywords[f];if(!y){let b=Ct.getKeywordData(f);b.cache&&(y=e.keywords[f]),y=y||Ct.getKeyword(f,e),b.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Ct.contains(m)&&e.include(Ct.get(m))}return t==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),t)}parse(e,t,o,n){if(this.src=e||"",this.includes=t??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=NE.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Vb);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 DE=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Uf=class extends ge{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Uf.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,o,n,a){this.src=e||"";let s,l,c="",u=DE.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,n,a){return e.format(this.name,this.getType(e),t)}},Ge=Uf;Ge.PI="PI",Ge.PI2="PI2",Ge.RECIPROCAL_PI="RECIPROCAL_PI",Ge.RECIPROCAL_PI2="RECIPROCAL_PI2",Ge.LOG2="LOG2",Ge.EPSILON="EPSILON";var _E=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
19
- )*?)}`,"gim"),RE=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),za=class extends ge{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,n,a){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=_E.exec(e);if(t){let o=t[2],n;for(;n=RE.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=t[1]}else this.name="";this.type=this.name}};var Ga=class extends ge{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:"",n=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(n,this.getType(e),t)}};Ct.addKeyword("uv",function(){return new Ga});Ct.addKeyword("uv2",function(){return new Ga(1)});import{LinearEncoding as LE,sRGBEncoding as BE}from"three";var sn=class extends ge{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??sn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case LE:return["Linear"];case BE:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),n=this.getType(e),a=sn.Nodes[this.method],s=e.include(a);if(s===sn.LINEAR_TO_LINEAR)return e.format(o,n,t);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",n,t)}else return e.format(s+"( "+o+" )",n,t)}fromEncoding(e){let t=sn.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=sn.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Xt=sn;Xt.Nodes={LinearToLinear:new J(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
18
+ `&&n.push("")):r.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),r.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}import{BufferGeometry as jf,BufferAttribute as Wb,Uint32BufferAttribute as Uf,Float32BufferAttribute as kf,Matrix4 as iN,Vector3 as cl,Sphere as nN,Box3 as aN,BoxGeometry as sN}from"three";var kb,Vu=new Promise(i=>{kb=i}),Ub=!1;var Bu;function Hb(i){if(Ub)return;if(Bu)return Bu;async function r(){let e="https://unpkg.com/@splinetool/modelling-wasm@1.10.29/build",t=up(i,"/")??(!1?".":e),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${t}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});kb(c),Ub=!0}return Bu=r(),Bu}import{BufferGeometryLoader as eN}from"three";var tN=["font"];function jo(i,r,e,t){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let p of c)u=u[p];for(o in u){let p=u[o];Ip(p)&&!tN.includes(o)&&(u[o]=r.getVariable(p,[t.uuid,"geometry",...c,o]),Ip(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=je.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new eN().parse(n),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(n.type==="SubdivGeometry"){let c=new gt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new an(n,r);if(n.type==="InputGeometry")return new an(n,r);if(n.type==="UIGeometry")return Da.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Ff(s)}catch(c){console.error(c)}if(!l){let c=je.createFromState(sa.defaultData(),100,100);s.shape=c,l=Ff(s)}return l}import{Matrix4 as rN}from"three";var oN=new rN;function ll(i,r,e,t){let o=i.position.array,n=i.normal.array,a=oN.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=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var zu=new aN,Ra=new cl,Se;Vu.then(i=>{Se=i});var qb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),$b=new Uint32Array([0,1,2,3]),Xb=new Uint8Array([4]),gt=class extends jf{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,n=ui.div(t,o);this.subdividedGeometry&&ll(this.subdividedGeometry.attributes,...n),this.originalGeometry&&ll(this.originalGeometry.attributes,...n),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*n[0],height:a.height*n[1],depth:a.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(Ra.fromArray(n));let s=Ra.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}=gt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new sN(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(gt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new nN,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;zu.setFromBufferAttribute(t),zu.getCenter(o),e.boundingSphere.radius=o.distanceTo(zu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),zu.getSize(Ra);let n={width:Ra.x,height:Ra.y,depth:Ra.z};return this.userData.parameters=n,n}static build(e,t,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),t&&(Se.free_bvh(t),Se.free_subdivision_surface(t));try{a=gt.allocate(e,n)}catch(u){console.error(u,e),a=gt.allocate({positionWASM:qb,indexWASM:$b,verticesPerFaceWASM:Xb},n)}if(Se.set_destination_refinement_level(a,0),s=gt.buildLevel(a,!0,c),e.subdivisions>0)try{Se.set_destination_refinement_level(a,e.subdivisions),l=gt.buildLevel(a,!1,c)}catch{try{Se.set_destination_refinement_level(a,e.subdivisions-1),l=gt.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 n=e.shape!==void 0||e.path!==void 0?t.geometry:jo(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=$f(n.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,f=d+e.radialSegments*3;p=[d,f]}return{indices:l,verticesPerFace:c}=Xf(s,u,n,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,t){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=qb,n=$b,a=Xb);let c=o.length,u=n.length,p=a.length,d=o.length+s.length+l.length,f=n.length+a.length,h=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,b=Se._malloc(h),v=new Float32Array(Se.HEAPF32.buffer,b,d),w=new Uint32Array(Se.HEAPU32.buffer,b+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(n,0),w.set(a,n.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new iN().makeScale(...e.scaleBaked)),t&&(O?O.premultiply(t):O=t);let S=O?Se.alloc_subdivision_surface2(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):Se.alloc_subdivision_surface(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p);return Se._free(b),S}static buildLevel(e,t,o,n,a){let s=a?Se.get_mesh_data2(e,t?Se.Level.CONTROL:Se.Level.REFINED,o,a.elements):Se.get_mesh_data(e,t?Se.Level.CONTROL:Se.Level.REFINED,o),l=8,c=Se.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=Se.HEAPU32[c[p]>>2],f=Se.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let h=Se.HEAPU32[c[p]>>2],m=Se.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let y=Se.HEAPU32[c[p]>>2],b=Se.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=Se.HEAPU32[c[p]>>2],w=Se.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,n===void 0){let O=new jf;if(O.setIndex(new Uf(w,1)),O.setAttribute("position",new kf(f,3)),O.setAttribute("normal",new kf(m,3)),t){O.setAttribute("faceMap",new Uf(b,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new Wb(S,4))}return Se.free_mesh_data(s),O.userData.type="SubdivGeometry",O}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Se.free_mesh_data(s)}static freeSubdivPointer(e){Se.free_bvh(e),Se.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let n=Se.get_wireframe_data_for_base_level(e),a=4,s=Se.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Se.HEAPU32[s[c]>>2],p=Se.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Se.HEAPU32[s[c]>>2],f=Se.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(t===void 0){let h=new jf;h.setAttribute("position",new kf(p,3));let m=new Float32Array(p.length);for(let y=0,b=p.length;y<b;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new Wb(m,3)),h.setIndex(new Uf(f,1)),Se.free_wireframe_data_for_base_level(n),h}t.getAttribute("position").copyArray(p),t.attributes.position.needsUpdate=!0,Se.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,t,o){let n=t===0;n||Se.set_destination_refinement_level(e,t);let a=o?Se.get_topological_data2(e,n?Se.Level.CONTROL:Se.Level.REFINED,o.elements):Se.get_topological_data(e,n?Se.Level.CONTROL:Se.Level.REFINED),s=6,l=Se.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=Se.HEAPU32[l[u]>>2],d=new Float32Array(Se.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let f=Se.HEAPU32[l[u]>>2],h=new Uint32Array(Se.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Se.HEAPU32[l[u]>>2],y=new Uint8Array(Se.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Se.free_topological_data(a),{positions:d,indices:h,verticesPerFace:y}}};var Yb=["getX","getY","getZ"];function $f(i,r){let e={},t=r?r.count:i.count,o=0,n=[],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+=`${~~(i[Yb[d]](u)*s)},`;if(p in e)n.push(e[p]);else{for(let d=0;d<3;d++)a.push(i[Yb[d]](u));e[p]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var Gu=new cl,Hf=new cl,Wf=new cl,qf=new cl;function Xf(i,r,e,t){let o=[],n=[];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((f,h)=>Math.floor(h/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]);i.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),o.push(p++);return n.push(p),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<r.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[r[s]*3+2]===a||i[r[s]*3+2]===0)&&l++,(i[r[s+1]*3+2]===a||i[r[s+1]*3+2]===0)&&l++,(i[r[s+2]*3+2]===a||i[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(i[r[s]*3],i[r[s]*3+1],i[r[s]*3+2]),Hf.set(i[r[s+1]*3],i[r[s+1]*3+1],i[r[s+1]*3+2]),Wf.set(i[r[s+4]*3],i[r[s+4]*3+1],i[r[s+4]*3+2]),qf.set(i[r[s+5]*3],i[r[s+5]*3+1],i[r[s+5]*3+2]),Hf.sub(Gu).normalize(),Wf.sub(Gu).normalize(),qf.sub(Gu).normalize();let l=Hf.cross(Wf).dot(qf);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]),n.push(3),s+=3):(o.push(r[s],r[s+1],r[s+4],r[s+5]),n.push(4),s+=6)}else o.push(r[s],r[s+1],r[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<i.length;p+=3,d++)i[p+2]===0&&(l.push(d),u++),i[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),n.push(u,u)}return{indices:o,verticesPerFace:n}}var wr={};Ew(wr,{calcBoolean:()=>pN,calcBooleanTopological:()=>dN,freeMeshSet:()=>yN,getMeshSet:()=>fN,hasOpenEdges:()=>hN,transformMeshSet:()=>mN});var lN,Kb=new Promise(i=>{lN=i});import{Float32BufferAttribute as Qb,Sphere as cN}from"three";var Be,La;Kb.then(i=>Be=i);function uN(i,r,e){let t,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=$f(i.getAttribute("position"),o),s;if(r&&e){let{indices:l,verticesPerFace:c}=Xf(n,a,i);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:n,faceIndices:t,nFaces:s}}function Zb(i){let r=i.length,e=r*Uint32Array.BYTES_PER_ELEMENT,t=r*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:t,n=Be._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Be.HEAPU32.buffer,n,r):new Float32Array(Be.HEAPF32.buffer,n,r)).set(i,0),n}function Jb(i){switch(i){case 0:return Be.OP.UNION;case 1:return Be.OP.INTERSECTION;case 2:return Be.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function dN(i,r){La===void 0&&(La=Be.init_csg());let e=Zb(i),t=Be.csg_calc_topological(La,e,i.length,Jb(r));Be._free(e);let o=6,n=Be.HEAPU32.subarray(t>>2,(t>>2)+o),a=n.subarray(3,3+3),s=0,l=Be.HEAPU32[n[s]>>2],c=new Float32Array(Be.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Be.HEAPU32[n[s]>>2],p=new Uint32Array(Be.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Be.HEAPU32[n[s]>>2],f=new Uint8Array(Be.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Be.free_mesh_data(t),{positions:c,indices:p,verticesPerFace:f}}function pN(i,r,e,t){La===void 0&&(La=Be.init_csg());let o=Zb(i),n=Be.csg_calc(La,o,i.length,t,Jb(r));Be._free(o);let a=5,s=Be.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Be.HEAPU32[s[c]>>2],p=Be.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Be.HEAPU32[s[c]>>2],f=Be.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Qb(p,3)),e.setAttribute("normal",new Qb(f,3));let m=Be.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new cN),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},Be.free_mesh_data(n),h}function fN(i,r,e){if(Be===void 0)return-1;let t,o,n;if(r&&i.userData.positions!==void 0){let b=i.userData;n=b.verticesPerFace.length,t=b.positions,o=Array(b.verticesPerFace.reduce((v,w)=>v+w,0)+n);for(let v=0,w=0,O=0;v<b.verticesPerFace.length;v++){o[O++]=b.verticesPerFace[v];for(let S=0;S<b.verticesPerFace[v];S++)o[O++]=b.indices[w++]}}else({positions:t,faceIndices:o,nFaces:n}=uN(i,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,f=Be._malloc(u),h=new Float32Array(Be.HEAPF32.buffer,f,l),m=new Uint32Array(Be.HEAPU32.buffer,f+p,c);h.set(t,0),m.set(o,0);let y=Be.get_csg_mesh(f,a,f+p,s,n);return Be._free(f),y}function hN(i){return Be.has_open_edges(i)}function mN(i,r){Be.transform_csg_mesh(i,r.elements)}function yN(i){Be.free_csg_mesh(i)}var gN={ConeGeometry:Rx,CubeGeometry:Lx,CylinderGeometry:_x,DodecahedronGeometry:Bx,EllipseGeometry:Ma,HelixGeometry:pb,IcosahedronGeometry:fb,LatheGeometry:hb,NonParametricGeometry:Ob,PolygonGeometry:Du,PyramidGeometry:Tb,RectangleGeometry:Da,SphereGeometry:Ab,PlaneGeometry:Mb,BackdropGeometry:Ib,StarGeometry:_u,TextFrameGeometry:Eb,TorusGeometry:Nb,TorusKnotGeometry:Db,TriangleGeometry:_b,PathGeometry:Gb,VectorGeometry:er},Ff=i=>gN[i.type].create(i);function Ba(i){return i!==null&&"booleanOp"in i}var Va=class extends va(bN){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new xN}updateVisible(e){super.updateVisible(e),this.visible=!Ba(this.parent)&&this.visible,Ba(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(wr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ba(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Va&&(e.freeBooleanPointer(),Ba(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let o=super.updateTransformState(e,t);return o&&Ba(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ba(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Fu=new vN;function ul(i,r=0,e=i.count,t,o){let n=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=i.getX(p),f=i.getY(p),h=i.getZ(p);d<n&&(n=d),f<a&&(a=f),h<s&&(s=h),d>l&&(l=d),f>c&&(c=f),h>u&&(u=h)}Fu.min.set(n,a,s),Fu.max.set(l,c,u),Fu.getCenter(t),Fu.getSize(o).multiplyScalar(.5)}var PN=new SN,ON=new wN,Tt=class extends Va{constructor(r,e){super(PN,ON),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?ul(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};import{Box3 as $D,Matrix4 as XD,Sphere as qv,Vector3 as YD}from"three";import{BufferAttribute as HD,Float32BufferAttribute as Wv,MathUtils as Ph,Vector3 as Oh}from"three";import{ShaderMaterial as wD}from"three";var Uo=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Uo.uuidContext===null)throw new Error("plz startContext");Uo.uuidContext===Uo.globalContext?this.uuid="_gid"+Uo.uuidContext.nodeContextUuid++:this.uuid="_uid"+Uo.uuidContext.nodeContextUuid++,this.type=r,this.name=""}static startContext(r){this.uuidContext===null||this.uuidContext===Uo.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,n,a){return""}generate(r,e,t,o,n){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}},qe=Uo;qe.globalContext={nodeContextUuid:0},qe.uuidContext=Uo.globalContext;import{CubeReflectionMapping as LN,CubeRefractionMapping as BN,CubeUVReflectionMapping as VN,LinearEncoding as cv,sRGBEncoding as zN}from"three";var dl=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 Yf=class{constructor(){this.nodes={};this.keywords={}}add(r){this.nodes[r.name]=r}addKeyword(r,e,t){t=t!==void 0?t:!0,this.keywords[r]={callback:e,cache:t}}remove(r){delete this.nodes[r.name]}removeKeyword(r){delete this.keywords[r]}get(r){return this.nodes[r]}getKeyword(r,e){return this.keywords[r].callback(e)}getKeywordData(r){return this.keywords[r]}contains(r){return this.nodes[r]!==void 0}containsKeyword(r){return this.keywords[r]!==void 0}},Ct=new Yf;import{Vector2 as ev}from"three";import{MathUtils as TN}from"three";var ge=class extends qe{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,n){if(t=t??this.getType(e),this.getShared(e,t)){let a=this.getUnique(e,t);a&&this.uuid===void 0&&(this.uuid=TN.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,n);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,n,a){return this.getShared(e,t)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var $e=class extends ge{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,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,t)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,t))}};var lt=class extends $e{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof ev?e:new ev(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,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,t)}};import{Vector3 as tv}from"three";var Gt=class extends $e{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof tv?e:new tv(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,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,t)}};import{Color as CN}from"three";var At=class extends CN{constructor(e,t,o,n){super(e,t,o);this.isColorA=!0;this.a=n}setRGBA(e,t,o,n){super.setRGB(e,t,o),this.a=n}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}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 n,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(n[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(n[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 tr=class extends $e{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof At?e:new At(e.r,e.g,e.b,e.a)}generateReadonly(e,t,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,t)}};var AN=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,rv=/[a-z_0-9]+/gi,J=class extends ge{constructor(e,t,o,n,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,n)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,o,n,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=rv.exec(this.src);)u.push(s);for(let p=0;p<u.length;p++){let d=u[p],f=d[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Ct.containsKeyword(f)){let y=this.keywords[f];if(!y){let b=Ct.getKeywordData(f);b.cache&&(y=e.keywords[f]),y=y||Ct.getKeyword(f,e),b.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Ct.contains(m)&&e.include(Ct.get(m))}return t==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),t)}parse(e,t,o,n){if(this.src=e||"",this.includes=t??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=AN.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(rv);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 MN=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Kf=class extends ge{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Kf.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,o,n,a){this.src=e||"";let s,l,c="",u=MN.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,n,a){return e.format(this.name,this.getType(e),t)}},Ge=Kf;Ge.PI="PI",Ge.PI2="PI2",Ge.RECIPROCAL_PI="RECIPROCAL_PI",Ge.RECIPROCAL_PI2="RECIPROCAL_PI2",Ge.LOG2="LOG2",Ge.EPSILON="EPSILON";var IN=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
19
+ )*?)}`,"gim"),EN=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),za=class extends ge{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,n,a){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=IN.exec(e);if(t){let o=t[2],n;for(;n=EN.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=t[1]}else this.name="";this.type=this.name}};var Ga=class extends ge{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:"",n=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(n,this.getType(e),t)}};Ct.addKeyword("uv",function(){return new Ga});Ct.addKeyword("uv2",function(){return new Ga(1)});import{LinearEncoding as NN,sRGBEncoding as DN}from"three";var sn=class extends ge{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??sn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case NN:return["Linear"];case DN:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),n=this.getType(e),a=sn.Nodes[this.method],s=e.include(a);if(s===sn.LINEAR_TO_LINEAR)return e.format(o,n,t);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",n,t)}else return e.format(s+"( "+o+" )",n,t)}fromEncoding(e){let t=sn.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=sn.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Xt=sn;Xt.Nodes={LinearToLinear:new J(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
20
20
  `)),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(`
21
21
  `)),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(`
22
- `))},Xt.LINEAR_TO_LINEAR="LinearToLinear",Xt.SRGB_TO_LINEAR="sRGBToLinear",Xt.LINEAR_TO_SRGB="LinearTosRGB";var Ue=class extends J{constructor(e="",t,o,n,a){super(e,a,n,o,t);this.nodeType="Expression"}};import{Texture as VE}from"three";var Yt=class extends $e{constructor(e=new VE,t,o,n){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t??new Ga,this.bias=o,this.project=n!==void 0?n:!1}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){if(t==="sampler2D")return this.getTexture(e,t);let o=this.getTexture(e,t),n=this.uv.build(e,this.project?"v4":"v2"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s,l;this.project?s="texture2DProj":s=a?"tex2DBias":"tex2D",a?l=s+"( "+o+", "+n+", "+a+" )":l=s+"( "+o+", "+n+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new Xt(new Ue("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,u),e.removeContext(),e.format(l,u,t)}};var se=class extends $e{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,t,o,n,a,s){return e.format(this.value+(this.value%1?"":".0"),n,t)}};var pl=class extends ge{constructor(e,t){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=t??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,o,n,a){n=this.getType(e);let s=this.value,l=s.build(e,t)+"( ",c=[];if(s.inputs){for(let u=0;u<s.inputs.length;u++){let p=s.inputs[u],d=this.inputs[u]||this.inputs[p.name];c.push(d.build(e,e.getTypeByFormat(p.type)))}l+=c.join(", ")+" )"}return e.format(l,n,t)}};var kf=class extends ge{constructor(e,t,o=kf.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=t,this.op=o}getType(e){let t=this.a.getType(e),o=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(o)>e.getTypeLength(t)?o:t}generate(e,t){let o=this.getType(e);this.type=o;let n=this.a.build(e,o),a=this.b.build(e,o);return e.format("( "+n+" "+this.op+" "+a+" )",o,t)}},_t=kf;_t.ADD="+",_t.SUB="-",_t.MUL="*",_t.DIV="/";var Xe=class extends ge{constructor(e,t=Xe.ABS,o,n){super();this.nodeType="Math";this.a=e,typeof t!="string"?this.b=t:n=t,typeof o!="string"?this.c=o:n=o,this.method=n,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case Xe.MIX:case Xe.CLAMP:case Xe.REFRACT:case Xe.SMOOTHSTEP:case Xe.FACEFORWARD:return 3;case Xe.MIN:case Xe.MAX:case Xe.MOD:case Xe.STEP:case Xe.REFLECT:case Xe.DISTANCE:case Xe.DOT:case Xe.CROSS:case Xe.POW:return 2;default:return 1}}getInputType(e){let t=e.getTypeLength(this.a.getType(e)),o=this.b?e.getTypeLength(this.b.getType(e)):0,n=this.c?e.getTypeLength(this.c.getType(e)):0;return t>o&&t>n?this.a.getType(e):o>n?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case Xe.LENGTH:case Xe.DISTANCE:case Xe.DOT:return"f";case Xe.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let o,n,a,s=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,c=this.c?e.getTypeLength(this.c.getType(e)):0,u=this.getInputType(e),p=this.getType(e);switch(this.type=p,this.method){case Xe.NEGATE:return e.format("( -"+this.a.build(e,u)+" )",u,t);case Xe.INVERT:return e.format("( 1.0 - "+this.a.build(e,u)+" )",u,t);case Xe.CROSS:o=this.a.build(e,"v3"),n=this.b.build(e,"v3");break;case Xe.STEP:o=this.a.build(e,s===1?"f":u),n=this.b.build(e,u);break;case Xe.MIN:case Xe.MAX:case Xe.MOD:o=this.a.build(e,u),n=this.b.build(e,l===1?"f":u);break;case Xe.REFRACT:o=this.a.build(e,u),n=this.b.build(e,u),a=this.c.build(e,"f");break;case Xe.MIX:o=this.a.build(e,u),n=this.b.build(e,u),a=this.c.build(e,c===1?"f":u);break;default:o=this.a.build(e,u),this.b&&(n=this.b.build(e,u)),this.c&&(a=this.c.build(e,u));break}let d=[];d.push(o),n&&d.push(n),a&&d.push(a);let f=this.getNumInputs(e);if(d.length!==f)throw Error(`Arguments not match used in "${this.method}". Require ${f}, currently ${d.length}.`);return e.format(this.method+"( "+d.join(", ")+" )",p,t)}},Oe=Xe;Oe.RAD="radians",Oe.DEG="degrees",Oe.EXP="exp",Oe.EXP2="exp2",Oe.LOG="log",Oe.LOG2="log2",Oe.SQRT="sqrt",Oe.INV_SQRT="inversesqrt",Oe.FLOOR="floor",Oe.CEIL="ceil",Oe.NORMALIZE="normalize",Oe.FRACT="fract",Oe.SATURATE="saturate",Oe.SIN="sin",Oe.COS="cos",Oe.TAN="tan",Oe.ASIN="asin",Oe.ACOS="acos",Oe.ARCTAN="atan",Oe.ABS="abs",Oe.SIGN="sign",Oe.LENGTH="length",Oe.NEGATE="negate",Oe.INVERT="invert",Oe.MIN="min",Oe.MAX="max",Oe.MOD="mod",Oe.STEP="step",Oe.REFLECT="reflect",Oe.DISTANCE="distance",Oe.DOT="dot",Oe.CROSS="cross",Oe.POW="pow",Oe.MIX="mix",Oe.CLAMP="clamp",Oe.REFRACT="refract",Oe.SMOOTHSTEP="smoothstep",Oe.FACEFORWARD="faceforward";var Fa=class extends ge{constructor(e,t,o){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=t,this.bias=o}bilinearCubeUV(e,t,o,n){let a=new pl(Fa.Nodes.bilinearCubeUV,[t,o,n]);this.colorSpaceTL=this.colorSpaceTL??new Xt(new Ue("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new Xt(new Ue("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new Xt(new Ue("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new Xt(new Ue("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(a.build(e)+".br");let s={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(s),this.colorSpaceTLExp=new Ue(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Ue(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Ue(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Ue(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new Ue("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return l.keywords.cubeUV_TL=this.colorSpaceTLExp,l.keywords.cubeUV_TR=this.colorSpaceTRExp,l.keywords.cubeUV_BL=this.colorSpaceBLExp,l.keywords.cubeUV_BR=this.colorSpaceBRExp,l.keywords.cubeUV=a,l}generate(e,t){if(e.isShader("fragment")){let o=this.uv,n=this.bias||e.context.roughness,a=new pl(Fa.Nodes.roughnessToMip,[n]),s=new Oe(a,Fa.Nodes.m0,Fa.Nodes.cubeUV_maxMipLevel,Oe.CLAMP),l=new Oe(s,Oe.FLOOR),c=new Oe(s,Oe.FRACT),u=this.bilinearCubeUV(e,this.value,o,l),p=this.bilinearCubeUV(e,this.value,o,new _t(l,new se(1).setReadonly(!0),_t.ADD)),d=new Oe(u,p,c,Oe.MIX);return e.format(d.build(e),"v4",t)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)}},ja=Fa;ja.Nodes=function(){let e=new za(`struct TextureCubeUVData {
22
+ `))},Xt.LINEAR_TO_LINEAR="LinearToLinear",Xt.SRGB_TO_LINEAR="sRGBToLinear",Xt.LINEAR_TO_SRGB="LinearTosRGB";var Ue=class extends J{constructor(e="",t,o,n,a){super(e,a,n,o,t);this.nodeType="Expression"}};import{Texture as _N}from"three";var Yt=class extends $e{constructor(e=new _N,t,o,n){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t??new Ga,this.bias=o,this.project=n!==void 0?n:!1}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){if(t==="sampler2D")return this.getTexture(e,t);let o=this.getTexture(e,t),n=this.uv.build(e,this.project?"v4":"v2"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s,l;this.project?s="texture2DProj":s=a?"tex2DBias":"tex2D",a?l=s+"( "+o+", "+n+", "+a+" )":l=s+"( "+o+", "+n+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new Xt(new Ue("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,u),e.removeContext(),e.format(l,u,t)}};var se=class extends $e{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,t,o,n,a,s){return e.format(this.value+(this.value%1?"":".0"),n,t)}};var pl=class extends ge{constructor(e,t){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=t??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,o,n,a){n=this.getType(e);let s=this.value,l=s.build(e,t)+"( ",c=[];if(s.inputs){for(let u=0;u<s.inputs.length;u++){let p=s.inputs[u],d=this.inputs[u]||this.inputs[p.name];c.push(d.build(e,e.getTypeByFormat(p.type)))}l+=c.join(", ")+" )"}return e.format(l,n,t)}};var Qf=class extends ge{constructor(e,t,o=Qf.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=t,this.op=o}getType(e){let t=this.a.getType(e),o=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(o)>e.getTypeLength(t)?o:t}generate(e,t){let o=this.getType(e);this.type=o;let n=this.a.build(e,o),a=this.b.build(e,o);return e.format("( "+n+" "+this.op+" "+a+" )",o,t)}},_t=Qf;_t.ADD="+",_t.SUB="-",_t.MUL="*",_t.DIV="/";var Xe=class extends ge{constructor(e,t=Xe.ABS,o,n){super();this.nodeType="Math";this.a=e,typeof t!="string"?this.b=t:n=t,typeof o!="string"?this.c=o:n=o,this.method=n,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case Xe.MIX:case Xe.CLAMP:case Xe.REFRACT:case Xe.SMOOTHSTEP:case Xe.FACEFORWARD:return 3;case Xe.MIN:case Xe.MAX:case Xe.MOD:case Xe.STEP:case Xe.REFLECT:case Xe.DISTANCE:case Xe.DOT:case Xe.CROSS:case Xe.POW:return 2;default:return 1}}getInputType(e){let t=e.getTypeLength(this.a.getType(e)),o=this.b?e.getTypeLength(this.b.getType(e)):0,n=this.c?e.getTypeLength(this.c.getType(e)):0;return t>o&&t>n?this.a.getType(e):o>n?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case Xe.LENGTH:case Xe.DISTANCE:case Xe.DOT:return"f";case Xe.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let o,n,a,s=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,c=this.c?e.getTypeLength(this.c.getType(e)):0,u=this.getInputType(e),p=this.getType(e);switch(this.type=p,this.method){case Xe.NEGATE:return e.format("( -"+this.a.build(e,u)+" )",u,t);case Xe.INVERT:return e.format("( 1.0 - "+this.a.build(e,u)+" )",u,t);case Xe.CROSS:o=this.a.build(e,"v3"),n=this.b.build(e,"v3");break;case Xe.STEP:o=this.a.build(e,s===1?"f":u),n=this.b.build(e,u);break;case Xe.MIN:case Xe.MAX:case Xe.MOD:o=this.a.build(e,u),n=this.b.build(e,l===1?"f":u);break;case Xe.REFRACT:o=this.a.build(e,u),n=this.b.build(e,u),a=this.c.build(e,"f");break;case Xe.MIX:o=this.a.build(e,u),n=this.b.build(e,u),a=this.c.build(e,c===1?"f":u);break;default:o=this.a.build(e,u),this.b&&(n=this.b.build(e,u)),this.c&&(a=this.c.build(e,u));break}let d=[];d.push(o),n&&d.push(n),a&&d.push(a);let f=this.getNumInputs(e);if(d.length!==f)throw Error(`Arguments not match used in "${this.method}". Require ${f}, currently ${d.length}.`);return e.format(this.method+"( "+d.join(", ")+" )",p,t)}},Oe=Xe;Oe.RAD="radians",Oe.DEG="degrees",Oe.EXP="exp",Oe.EXP2="exp2",Oe.LOG="log",Oe.LOG2="log2",Oe.SQRT="sqrt",Oe.INV_SQRT="inversesqrt",Oe.FLOOR="floor",Oe.CEIL="ceil",Oe.NORMALIZE="normalize",Oe.FRACT="fract",Oe.SATURATE="saturate",Oe.SIN="sin",Oe.COS="cos",Oe.TAN="tan",Oe.ASIN="asin",Oe.ACOS="acos",Oe.ARCTAN="atan",Oe.ABS="abs",Oe.SIGN="sign",Oe.LENGTH="length",Oe.NEGATE="negate",Oe.INVERT="invert",Oe.MIN="min",Oe.MAX="max",Oe.MOD="mod",Oe.STEP="step",Oe.REFLECT="reflect",Oe.DISTANCE="distance",Oe.DOT="dot",Oe.CROSS="cross",Oe.POW="pow",Oe.MIX="mix",Oe.CLAMP="clamp",Oe.REFRACT="refract",Oe.SMOOTHSTEP="smoothstep",Oe.FACEFORWARD="faceforward";var Fa=class extends ge{constructor(e,t,o){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=t,this.bias=o}bilinearCubeUV(e,t,o,n){let a=new pl(Fa.Nodes.bilinearCubeUV,[t,o,n]);this.colorSpaceTL=this.colorSpaceTL??new Xt(new Ue("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new Xt(new Ue("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new Xt(new Ue("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new Xt(new Ue("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(a.build(e)+".br");let s={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(s),this.colorSpaceTLExp=new Ue(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Ue(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Ue(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Ue(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new Ue("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return l.keywords.cubeUV_TL=this.colorSpaceTLExp,l.keywords.cubeUV_TR=this.colorSpaceTRExp,l.keywords.cubeUV_BL=this.colorSpaceBLExp,l.keywords.cubeUV_BR=this.colorSpaceBRExp,l.keywords.cubeUV=a,l}generate(e,t){if(e.isShader("fragment")){let o=this.uv,n=this.bias||e.context.roughness,a=new pl(Fa.Nodes.roughnessToMip,[n]),s=new Oe(a,Fa.Nodes.m0,Fa.Nodes.cubeUV_maxMipLevel,Oe.CLAMP),l=new Oe(s,Oe.FLOOR),c=new Oe(s,Oe.FRACT),u=this.bilinearCubeUV(e,this.value,o,l),p=this.bilinearCubeUV(e,this.value,o,new _t(l,new se(1).setReadonly(!0),_t.ADD)),d=new Oe(u,p,c,Oe.MIX);return e.format(d.build(e),"v4",t)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)}},ja=Fa;ja.Nodes=function(){let e=new za(`struct TextureCubeUVData {
23
23
  vec4 tl;
24
24
  vec4 tr;
25
25
  vec4 br;
@@ -98,7 +98,7 @@ best distance: ${d.d}`);let b=[d.x,d.y];return b.distance=d.d,b.distance}functio
98
98
  mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
99
99
  }
100
100
  return mip;
101
- }`,D);return{bilinearCubeUV:c,roughnessToMip:E,m0:d,cubeUV_maxMipLevel:t}}();var ln=class extends ge{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??ln.VIEW}getShared(){return this.scope===ln.WORLD}build(e,t,o,n){let a=e.context[this.scope+"Normal"];return a?a.build(e,t,o,n):super.build(e,t,o)}generate(e,t,o,n,a){let s;switch(this.scope){case ln.VIEW:e.isShader("vertex")?s="transformedNormal":s="geometryNormal";break;case ln.LOCAL:e.isShader("vertex")?s="objectNormal":(e.requires.normal=!0,s="vObjectNormal");break;case ln.WORLD:e.isShader("vertex")?s="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,s="vWNormal");break}return e.format(s,this.getType(e),t)}},Rt=ln;Rt.LOCAL="local",Rt.WORLD="world",Rt.VIEW="view",Rt.NORMAL="normal";Ct.addKeyword("viewNormal",function(){return new Rt(Rt.VIEW)});Ct.addKeyword("localNormal",function(){return new Rt(Rt.NORMAL)});Ct.addKeyword("worldNormal",function(){return new Rt(Rt.WORLD)});var uo=class extends ge{constructor(e){super("v3");this.nodeType="Position";this.scope=e??uo.LOCAL}getType(){switch(this.scope){case uo.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case uo.LOCAL:case uo.WORLD:return!1}return!0}generate(e,t,o,n,a){let s;switch(this.scope){case uo.LOCAL:e.isShader("vertex")?s="transformed":(e.requires.position=!0,s="vPosition");break;case uo.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,s="vWPosition";break;case uo.VIEW:s=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case uo.PROJECTION:s=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(s,this.getType(),t)}},rr=uo;rr.LOCAL="local",rr.WORLD="world",rr.VIEW="view",rr.PROJECTION="projection";Ct.addKeyword("position",function(){return new rr});Ct.addKeyword("worldPosition",function(){return new rr(rr.WORLD)});Ct.addKeyword("viewPosition",function(){return new rr(rr.VIEW)});var jr=class extends ge{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??jr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case jr.SPHERE:return"v2"}return this.type}generate(e,t){let o=this.getUnique(e);if(e.isShader("fragment")){let n;switch(this.scope){case jr.VECTOR:{let a=new Rt(Rt.VIEW),s=e.context.roughness,l=a.build(e,"v3"),c=new rr(rr.VIEW).build(e,"v3"),u=s?s.build(e,"f"):void 0,p=`reflect( -normalize( ${c} ), ${l} )`;u&&(p=`normalize( mix( ${p}, ${l}, ${u} * ${u} ) )`);let d=`inverseTransformDirection( ${p}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${d};`),n="reflectVec"):n=d;break}case jr.CUBE:{let a=new jr(jr.VECTOR).build(e,"v3"),s="vec3( -"+a+".x, "+a+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${s};`),n="reflectCubeVec"):n=s;break}case jr.SPHERE:{let s="normalize( ( viewMatrix * vec4( "+new jr(jr.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${s};`),n="reflectSphereVec"):n=s;break}}return e.format(n,this.getType(),t)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}},po=jr;po.CUBE="cube",po.SPHERE="sphere",po.VECTOR="vector";var Vu=class extends ge{constructor(e=new Yt,t,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new ja(this.value,t??new po(po.VECTOR),o),this.irradianceNode=new ja(this.value,new Rt(Rt.WORLD),new se(1).setReadonly(!0))}generate(e,t){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}};import{CubeTexture as zE}from"three";var zu=class extends $e{constructor(e=new zE,t,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t??new po,this.bias=o}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){if(t==="samplerCube")return this.getTexture(e,t);let o=this.getTexture(e,t),n=this.uv?.build(e,"v3"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s;a?s="texCubeBias( "+o+", "+n+", "+a+" )":s="texCube( "+o+", "+n+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new Xt(new Ue("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(s),s=this.colorSpace.build(e,c),e.removeContext(),e.format(s,c,t)}};var zb=`
101
+ }`,D);return{bilinearCubeUV:c,roughnessToMip:E,m0:d,cubeUV_maxMipLevel:t}}();var ln=class extends ge{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??ln.VIEW}getShared(){return this.scope===ln.WORLD}build(e,t,o,n){let a=e.context[this.scope+"Normal"];return a?a.build(e,t,o,n):super.build(e,t,o)}generate(e,t,o,n,a){let s;switch(this.scope){case ln.VIEW:e.isShader("vertex")?s="transformedNormal":s="geometryNormal";break;case ln.LOCAL:e.isShader("vertex")?s="objectNormal":(e.requires.normal=!0,s="vObjectNormal");break;case ln.WORLD:e.isShader("vertex")?s="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,s="vWNormal");break}return e.format(s,this.getType(e),t)}},Rt=ln;Rt.LOCAL="local",Rt.WORLD="world",Rt.VIEW="view",Rt.NORMAL="normal";Ct.addKeyword("viewNormal",function(){return new Rt(Rt.VIEW)});Ct.addKeyword("localNormal",function(){return new Rt(Rt.NORMAL)});Ct.addKeyword("worldNormal",function(){return new Rt(Rt.WORLD)});var uo=class extends ge{constructor(e){super("v3");this.nodeType="Position";this.scope=e??uo.LOCAL}getType(){switch(this.scope){case uo.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case uo.LOCAL:case uo.WORLD:return!1}return!0}generate(e,t,o,n,a){let s;switch(this.scope){case uo.LOCAL:e.isShader("vertex")?s="transformed":(e.requires.position=!0,s="vPosition");break;case uo.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,s="vWPosition";break;case uo.VIEW:s=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case uo.PROJECTION:s=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(s,this.getType(),t)}},rr=uo;rr.LOCAL="local",rr.WORLD="world",rr.VIEW="view",rr.PROJECTION="projection";Ct.addKeyword("position",function(){return new rr});Ct.addKeyword("worldPosition",function(){return new rr(rr.WORLD)});Ct.addKeyword("viewPosition",function(){return new rr(rr.VIEW)});var jr=class extends ge{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??jr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case jr.SPHERE:return"v2"}return this.type}generate(e,t){let o=this.getUnique(e);if(e.isShader("fragment")){let n;switch(this.scope){case jr.VECTOR:{let a=new Rt(Rt.VIEW),s=e.context.roughness,l=a.build(e,"v3"),c=new rr(rr.VIEW).build(e,"v3"),u=s?s.build(e,"f"):void 0,p=`reflect( -normalize( ${c} ), ${l} )`;u&&(p=`normalize( mix( ${p}, ${l}, ${u} * ${u} ) )`);let d=`inverseTransformDirection( ${p}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${d};`),n="reflectVec"):n=d;break}case jr.CUBE:{let a=new jr(jr.VECTOR).build(e,"v3"),s="vec3( -"+a+".x, "+a+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${s};`),n="reflectCubeVec"):n=s;break}case jr.SPHERE:{let s="normalize( ( viewMatrix * vec4( "+new jr(jr.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${s};`),n="reflectSphereVec"):n=s;break}}return e.format(n,this.getType(),t)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}},po=jr;po.CUBE="cube",po.SPHERE="sphere",po.VECTOR="vector";var ju=class extends ge{constructor(e=new Yt,t,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new ja(this.value,t??new po(po.VECTOR),o),this.irradianceNode=new ja(this.value,new Rt(Rt.WORLD),new se(1).setReadonly(!0))}generate(e,t){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}};import{CubeTexture as RN}from"three";var Uu=class extends $e{constructor(e=new RN,t,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t??new po,this.bias=o}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){if(t==="samplerCube")return this.getTexture(e,t);let o=this.getTexture(e,t),n=this.uv?.build(e,"v3"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s;a?s="texCubeBias( "+o+", "+n+", "+a+" )":s="texCube( "+o+", "+n+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new Xt(new Ue("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(s),s=this.colorSpace.build(e,c),e.removeContext(),e.format(s,c,t)}};var ov=`
102
102
  uniform int frameIndex;
103
103
  uniform vec2 resolution;
104
104
  uniform mat4 previousModelViewMatrix;
@@ -106,7 +106,7 @@ uniform mat4 previousProjectionMatrix;
106
106
 
107
107
  varying vec4 vCurrentPosition;
108
108
  varying vec4 vPreviousPosition;
109
- `,Gb=`
109
+ `,iv=`
110
110
  layout(location = 1) out vec4 gVelocity;
111
111
 
112
112
  uniform int frameIndex;
@@ -148,7 +148,7 @@ float getNoiseInterleavedGradient(vec2 screenPos) {
148
148
  return fract(magic.z * fract(dot(screenPos, magic.xy)));
149
149
  }
150
150
 
151
- `,Fb=`
151
+ `,nv=`
152
152
  // TODO: This could be generated CPU side and passed to the shader every frame
153
153
  const vec2 haltonSequence[16] = vec2[16](
154
154
  vec2( 0.000000,-0.333334),
@@ -185,7 +185,7 @@ vPreviousPosition.xy += OUTLINE_COMPENSATION;
185
185
  #endif
186
186
  gl_Position = currentPositionJittered;
187
187
 
188
- `,jb=`
188
+ `,av=`
189
189
  vec2 oldPos = vPreviousPosition.xy;
190
190
  oldPos /= vPreviousPosition.w;
191
191
  oldPos.xy = (oldPos.xy+1.)/2.0;
@@ -200,14 +200,14 @@ vec2 velocity = (newPos - oldPos);
200
200
  if (gl_FragColor.a <= 0.0) discard;
201
201
 
202
202
  gVelocity = vec4(velocity, 0.0, 1.0);
203
- `,Ub=`
203
+ `,sv=`
204
204
  layout(location = 1) out vec4 gVelocity;
205
- `,kb=`
205
+ `,lv=`
206
206
  // Discard fully transparent pixels
207
207
  if (gl_FragColor.a <= 0.0) discard;
208
208
 
209
209
  gVelocity = vec4(0.0, 0.0, 0.0, 1.0);
210
- `;var Wb=["x","y","z","w"],kE=["float","vec2","vec3","vec4"],HE={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},WE={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},Ua=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.needsJitter=!0;this.getIncludesCode=function(){function r(e,t){return e.deps.length-t.deps.length}return function(t,o){let n=this.getIncludes(t,o);if(!n)return"";let a="";n=n.sort(r);for(let s=0;s<n.length;s++)n[s].src&&(a+=n[s].src+`
210
+ `;var uv=["x","y","z","w"],GN=["float","vec2","vec3","vec4"],FN={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},jN={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},Ua=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.needsJitter=!0;this.getIncludesCode=function(){function r(e,t){return e.deps.length-t.deps.length}return function(t,o){let n=this.getIncludes(t,o);if(!n)return"";let a="";n=n.sort(r);for(let s=0;s<n.length;s++)n[s].src&&(a+=n[s].src+`
211
211
  `);return a}}();this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.fragmentParsVariables={},this.vertexParsVariables={},this.requires={uv:[],color:[],transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,modelMatrix:!1,viewMatrix:!1,projectionMatrix:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCube(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2D(a, b, c)","#endif",`
212
212
  // NOTE: Include Spline's blending modes. This could be part of BlendNode
213
213
  #define SPE_BLENDING_NORMAL 0
@@ -245,26 +245,26 @@ layout(location = 1) out vec4 gVelocity;
245
245
  `),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
246
246
  accumAlpha += (1.0 - accumAlpha) * alpha;
247
247
  }`,""].join(`
248
- `)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(r,e){this.addVertexParsCode(zb),this.addFragmentParsCode(Gb),this.buildShader("vertex",r),this.buildShader("fragment",e);for(let t=0;t<this.requires.uv.length;t++)if(this.requires.uv[t]){let o=t>0?t+1:"";this.addVaryCode("varying vec2 vUv"+o+";"),t>0&&this.addVertexParsCode("attribute vec2 uv"+o+";"),this.addVertexFinalCode("vUv"+o+" = uv"+o+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode(`
248
+ `)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(r,e){this.addVertexParsCode(ov),this.addFragmentParsCode(iv),this.buildShader("vertex",r),this.buildShader("fragment",e);for(let t=0;t<this.requires.uv.length;t++)if(this.requires.uv[t]){let o=t>0?t+1:"";this.addVaryCode("varying vec2 vUv"+o+";"),t>0&&this.addVertexParsCode("attribute vec2 uv"+o+";"),this.addVertexFinalCode("vUv"+o+" = uv"+o+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode(`
249
249
  #ifndef SHAPEBLEND
250
250
  vObjectNormal = normal;
251
251
  #else
252
252
  vObjectNormal = objectNormal;
253
253
  #endif
254
- `)),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.needsJitter&&(this.addVertexFinalCode(Fb),this.addFragmentFinalCode(jb)),this}buildShader(r,e){this.resultCode[r]=e.build(this.setShader(r),"v4")}setMaterial(r,e){return this.defines={},this}addFlow(r,e,t){return this.addSlot(r).addCache(e).addContext(t)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(r){return this.cache=r??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(r){return this.context=Object.assign({},this.context,r),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(r){return this.slot=r||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(r,e){this.fragmentVariables[r]===void 0&&(this.addFragmentCode(`${e} ${r};`),this.fragmentVariables[r]="")}addFragmentParsVariable(r,e){this.fragmentParsVariables[r]===void 0&&(this.addFragmentParsCode(`${e} ${r};`),this.fragmentParsVariables[r]="")}addVertexParsVariable(r,e){this.vertexParsVariables[r]===void 0&&(this.addVertexParsCode(`${e} ${r};`),this.vertexParsVariables[r]="")}addVertexCode(r){this.addCode(r,"vertex")}addFragmentCode(r){this.addCode(r,"fragment")}addCode(r,e){this.code[e??this.shader]+=r+`
254
+ `)),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.needsJitter&&(this.addVertexFinalCode(nv),this.addFragmentFinalCode(av)),this}buildShader(r,e){this.resultCode[r]=e.build(this.setShader(r),"v4")}setMaterial(r,e){return this.defines={},this}addFlow(r,e,t){return this.addSlot(r).addCache(e).addContext(t)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(r){return this.cache=r??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(r){return this.context=Object.assign({},this.context,r),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(r){return this.slot=r||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(r,e){this.fragmentVariables[r]===void 0&&(this.addFragmentCode(`${e} ${r};`),this.fragmentVariables[r]="")}addFragmentParsVariable(r,e){this.fragmentParsVariables[r]===void 0&&(this.addFragmentParsCode(`${e} ${r};`),this.fragmentParsVariables[r]="")}addVertexParsVariable(r,e){this.vertexParsVariables[r]===void 0&&(this.addVertexParsCode(`${e} ${r};`),this.vertexParsVariables[r]="")}addVertexCode(r){this.addCode(r,"vertex")}addFragmentCode(r){this.addCode(r,"fragment")}addCode(r,e){this.code[e??this.shader]+=r+`
255
255
  `}addVertexNodeCode(r){this.addNodeCode(r,"vertex")}addFragmentNodeCode(r){this.addNodeCode(r,"fragment")}addNodeCode(r,e){this.nodeCode[e??this.shader]+=r+`
256
256
  `}clearNodeCode(r){r=r??this.shader;let e=this.nodeCode[r];return this.nodeCode[r]="",e}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(r){this.addFinalCode(r,"vertex")}addFragmentFinalCode(r){this.addFinalCode(r,"fragment")}addFinalCode(r,e){this.finalCode[e??this.shader]+=r+`
257
257
  `}addVertexParsCode(r){this.addParsCode(r,"vertex")}addFragmentParsCode(r){this.addParsCode(r,"fragment")}addParsCode(r,e){this.parsCode[e??this.shader]+=r+`
258
258
  `}addVaryCode(r){this.addVertexParsCode(r),this.addFragmentParsCode(r)}isCache(r){return this.caches.indexOf(r)!==-1}isSlot(r){return this.slots.indexOf(r)!==-1}define(r,e){this.defines[r]=e===void 0?1:e}require(r){this.requires[r]=!0}isDefined(r){return this.defines[r]!==void 0}getVar(r,e,t,o="varying",n="V",a=""){let s=this.getVars(o),l=s[r];if(!l){let c=s.length;l={name:t||"node"+n+c+(a?"_"+a:""),type:e},s.push(l),s[r]=l}return l}getTempVar(r,e,t,o){return this.getVar(r,e,t,this.shader,"T",o)}getAttribute(r,e){if(!this.attributes[r]){let t=this.getVar(r,e);this.addVertexParsCode("attribute "+e+" "+r+";"),this.addVertexFinalCode(t.name+" = "+r+";"),this.attributes[r]={varying:t,name:r,type:e}}return this.attributes[r]}getCode(r){return[this.prefixCode,this.parsCode[r],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[r],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[r],"uniform"),this.getIncludesCode("consts",r),this.getIncludesCode("structs",r),this.getIncludesCode("functions",r),"void main() {",this.getVarListCode(this.getVars(r)),this.code[r],this.resultCode[r],this.finalCode[r],"}"].join(`
259
259
  `)}getVarListCode(r,e){e=e??"";let t="";for(let o=0,n=r.length;o<n;++o){let a=r[o],s=a.type,l=a.name,c=a.size,u=this.getFormatByType(s);if(u===void 0)throw new Error("Node pars "+u+" not found.");u.includes("[]")?t+=e+" "+u.substring(0,u.length-2)+" "+l+`[${c}];
260
260
  `:t+=e+" "+u+" "+l+`;
261
- `}return t}getVars(r){return this.inputs.vars[r??this.shader]}getNodeData(r){let e=r instanceof qe?r.uuid:r;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(r,e,t,o,n,a){if(e.includes("[]")){let s=this.inputs.arrayUniforms,l=s.list.length,c=new dl({type:e,size:t.size,name:o||"nodeUA"+l+(a?"_"+a:""),node:t,needsUpdate:n});return s.list.push(c),s[r].push(c),s[r][c.name]=c,this.uniforms[c.name]=c,c}else{let s=this.inputs.uniforms,l=s.list.length,c=new dl({type:e,name:o||"nodeU"+l+(a?"_"+a:""),node:t,needsUpdate:n});return s.list.push(c),s[r].push(c),s[r][c.name]=c,this.uniforms[c.name]=c,c}}createVertexUniform(r,e,t,o,n){return this.createUniform("vertex",r,e,t,o,n)}createFragmentUniform(r,e,t,o,n){return this.createUniform("fragment",r,e,t,o,n)}include(r,e,t){let o;if(r=typeof r=="string"?Ct.get(r):r,this.context.include===!1)return r.name;r instanceof J?o=this.includes.functions:r instanceof Ge?o=this.includes.consts:r instanceof za&&(o=this.includes.structs);let n=o[this.shader]=o[this.shader]||[];if(r){let a=n[r.name];if(a||(a=n[r.name]={node:r,deps:[]},n.push(a),a.src=r.build(this,"source")),r instanceof J&&e&&n[e.name]&&n[e.name].deps.indexOf(r)===-1&&(n[e.name].deps.push(r),r.includes?.length)){let s=0;do this.include(r.includes[s++],e);while(s<r.includes.length)}return t&&(a.src=t),r.name}else throw new Error("Include not found.")}colorToVectorProperties(r){return r.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(r){return r.replace(/c/g,"v3")}getIncludes(r,e){return this.includes[r][e||this.shader]}getConstructorFromLength(r){return kE[r-1]}isTypeMatrix(r){return/^m/.test(r)}getTypeLength(r){return r==="f"?1:parseInt(this.colorToVector(r).substr(1))}getTypeFromLength(r){return r===1?"f":"v"+r}findNode(...r){for(let e=0;e<arguments.length;e++){let t=r[e];if(t?.isNode)return t}}resolve(...r){for(let e=0;e<arguments.length;e++){let t=r[e];if(t!==void 0){if(t.isNode)return t;if(t.isTexture)switch(t.mapping){case GE:case FE:return new zu(t);case jE:return new Vu(new Yt(t));default:return new Yt(t)}else{if(t.isVector2)return new lt(t);if(t.isVector3)return new Gt(t);if(t.isVector4)return new tr(t)}}}}format(r,e,t){switch(this.colorToVector(t+" <- "+e)){case"f <- v2":return r+".x";case"f <- v3":return r+".x";case"f <- v4":return r+".x";case"f <- i":case"f <- b":return"float( "+r+" )";case"v2 <- f":return"vec2( "+r+" )";case"v2 <- v3":return r+".xy";case"v2 <- v4":return r+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+r+" ) )";case"v3 <- f":return"vec3( "+r+" )";case"v3 <- v2":return"vec3( "+r+", 0.0 )";case"v3 <- v4":return r+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+r+" ) )";case"v4 <- f":return"vec4( "+r+" )";case"v4 <- v2":return"vec4( "+r+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+r+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+r+" ) )";case"i <- f":case"i <- b":return"int( "+r+" )";case"i <- v2":return"int( "+r+".x )";case"i <- v3":return"int( "+r+".x )";case"i <- v4":return"int( "+r+".x )";case"b <- f":return"( "+r+" != 0.0 )";case"b <- v2":return"( "+r+" != vec2( 0.0 ) )";case"b <- v3":return"( "+r+" != vec3( 0.0 ) )";case"b <- v4":return"( "+r+" != vec4( 0.0 ) )";case"b <- i":return"( "+r+" != 0 )"}return r}getTypeByFormat(r){return HE[r]||r}getFormatByType(r){return WE[r]||r}getUUID(r,e){return e=e!==void 0?e:!0,e&&this.cache&&(r=this.cache+"-"+r),r}getElementByIndex(r){return Wb[r]}getIndexByElement(r){return Wb.indexOf(r)}isShader(r){return this.shader===r}setShader(r){return this.shader=r,this}mergeDefines(r){for(let e in r)this.defines[e]=r[e];return this.defines}mergeUniform(r){for(let e in r)this.uniforms[e]=r[e];return this.uniforms}getTextureEncodingFromMap(r){let e;return r?r.isTexture&&(e=r.encoding):e=Hb,e===Hb&&this.context.gamma&&(e=UE),e}};import{MathUtils as wN,Vector2 as Wr,Vector3 as mo,Vector4 as ns}from"three";var He=class extends $e{constructor(e=0,t,o,n){super("c");this.nodeType="Color";this.value=e instanceof At?e:new At(e||0,t,o,n)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o),c=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let u=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${u};`)}return c?this.generateReadonly(e,t,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,t)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,t))}generateReadonly(e,t,o,n,a,s){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",n,t)}};var Re=class extends $e{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,t,o,n,a,s){return e.format(this.value.toString(),n,t)}};import{UniformsLib as QE,UniformsUtils as ZE}from"three";var ft=class extends $e{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,t,o,n){return e.format(this.value?"true":"false",n,t)}};var Ur=class extends $e{constructor(e=1,t){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(t)?t:typeof t=="number"?new Array(e).fill(t):new Array(e).fill(0)}};import{Vector3 as qE}from"three";var wi=class extends $e{};var Gu=class extends wi{constructor(e){super("v3");this.image=e;this._value=new qE}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}};var cn=class extends wi{constructor(e,t,o=1008,n=1006){super("t");this.image=e;this.wrap=t;this.minFilter=o;this.magFilter=n}get value(){return this.image.getTexture(this.wrap,this.minFilter,this.magFilter)}};import{Matrix3 as $E}from"three";var ka=class extends $e{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new $E}generateReadonly(e,t,o,n,a,s){return e.format("mat3("+this.value.elements.join(", ")+")",n,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};import{Matrix4 as XE}from"three";var Ft=class extends $e{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new XE}generateReadonly(e,t,o,n,a,s){return e.format("mat4("+this.value.elements.join(", ")+")",n,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};import{MathUtils as YE,Matrix3 as $b}from"three";function qb(i,r,e,t=0){i.setUvTransform(e[0],e[1],r[0],r[1],0,0,0).premultiply(new $b().makeRotation(t*YE.DEG2RAD))}var Fu=class extends ka{constructor(e,t,o=0){super(new $b);this.repeat=e;this.offset=t;this.rotation=o;qb(this.value,e,t,o)}updateMatrix(){qb(this.value,this.repeat,this.offset,this.rotation)}};import{Vector4 as Xb}from"three";var kr=class extends $e{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof Xb?new Array(e).fill(t):new Array(e).fill(new Xb(0))}};var Ha=class extends ge{constructor(e,t,o,n){super("v3");this.nodeType="Blend";this.a=e,this.b=t,this.alpha=o,this.mode=n}generate(e,t){if(e.isShader("fragment")){let o=[];return o.push(this.a.build(e,"c")),o.push(this.b.build(e,"c")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),e.format("spe_blend("+o.join(",")+")",this.getType(e),t)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}};var Hf=class extends ge{constructor(e,t){super("v3");this.nodeType="CustomColor";this.color=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let o=e.include(Hf.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let n=[];return n.push(this.color.build(e,"v3")),n.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},un=Hf;un.Nodes=function(){return{customColor:new J(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
261
+ `}return t}getVars(r){return this.inputs.vars[r??this.shader]}getNodeData(r){let e=r instanceof qe?r.uuid:r;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(r,e,t,o,n,a){if(e.includes("[]")){let s=this.inputs.arrayUniforms,l=s.list.length,c=new dl({type:e,size:t.size,name:o||"nodeUA"+l+(a?"_"+a:""),node:t,needsUpdate:n});return s.list.push(c),s[r].push(c),s[r][c.name]=c,this.uniforms[c.name]=c,c}else{let s=this.inputs.uniforms,l=s.list.length,c=new dl({type:e,name:o||"nodeU"+l+(a?"_"+a:""),node:t,needsUpdate:n});return s.list.push(c),s[r].push(c),s[r][c.name]=c,this.uniforms[c.name]=c,c}}createVertexUniform(r,e,t,o,n){return this.createUniform("vertex",r,e,t,o,n)}createFragmentUniform(r,e,t,o,n){return this.createUniform("fragment",r,e,t,o,n)}include(r,e,t){let o;if(r=typeof r=="string"?Ct.get(r):r,this.context.include===!1)return r.name;r instanceof J?o=this.includes.functions:r instanceof Ge?o=this.includes.consts:r instanceof za&&(o=this.includes.structs);let n=o[this.shader]=o[this.shader]||[];if(r){let a=n[r.name];if(a||(a=n[r.name]={node:r,deps:[]},n.push(a),a.src=r.build(this,"source")),r instanceof J&&e&&n[e.name]&&n[e.name].deps.indexOf(r)===-1&&(n[e.name].deps.push(r),r.includes?.length)){let s=0;do this.include(r.includes[s++],e);while(s<r.includes.length)}return t&&(a.src=t),r.name}else throw new Error("Include not found.")}colorToVectorProperties(r){return r.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(r){return r.replace(/c/g,"v3")}getIncludes(r,e){return this.includes[r][e||this.shader]}getConstructorFromLength(r){return GN[r-1]}isTypeMatrix(r){return/^m/.test(r)}getTypeLength(r){return r==="f"?1:parseInt(this.colorToVector(r).substr(1))}getTypeFromLength(r){return r===1?"f":"v"+r}findNode(...r){for(let e=0;e<arguments.length;e++){let t=r[e];if(t?.isNode)return t}}resolve(...r){for(let e=0;e<arguments.length;e++){let t=r[e];if(t!==void 0){if(t.isNode)return t;if(t.isTexture)switch(t.mapping){case LN:case BN:return new Uu(t);case VN:return new ju(new Yt(t));default:return new Yt(t)}else{if(t.isVector2)return new lt(t);if(t.isVector3)return new Gt(t);if(t.isVector4)return new tr(t)}}}}format(r,e,t){switch(this.colorToVector(t+" <- "+e)){case"f <- v2":return r+".x";case"f <- v3":return r+".x";case"f <- v4":return r+".x";case"f <- i":case"f <- b":return"float( "+r+" )";case"v2 <- f":return"vec2( "+r+" )";case"v2 <- v3":return r+".xy";case"v2 <- v4":return r+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+r+" ) )";case"v3 <- f":return"vec3( "+r+" )";case"v3 <- v2":return"vec3( "+r+", 0.0 )";case"v3 <- v4":return r+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+r+" ) )";case"v4 <- f":return"vec4( "+r+" )";case"v4 <- v2":return"vec4( "+r+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+r+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+r+" ) )";case"i <- f":case"i <- b":return"int( "+r+" )";case"i <- v2":return"int( "+r+".x )";case"i <- v3":return"int( "+r+".x )";case"i <- v4":return"int( "+r+".x )";case"b <- f":return"( "+r+" != 0.0 )";case"b <- v2":return"( "+r+" != vec2( 0.0 ) )";case"b <- v3":return"( "+r+" != vec3( 0.0 ) )";case"b <- v4":return"( "+r+" != vec4( 0.0 ) )";case"b <- i":return"( "+r+" != 0 )"}return r}getTypeByFormat(r){return FN[r]||r}getFormatByType(r){return jN[r]||r}getUUID(r,e){return e=e!==void 0?e:!0,e&&this.cache&&(r=this.cache+"-"+r),r}getElementByIndex(r){return uv[r]}getIndexByElement(r){return uv.indexOf(r)}isShader(r){return this.shader===r}setShader(r){return this.shader=r,this}mergeDefines(r){for(let e in r)this.defines[e]=r[e];return this.defines}mergeUniform(r){for(let e in r)this.uniforms[e]=r[e];return this.uniforms}getTextureEncodingFromMap(r){let e;return r?r.isTexture&&(e=r.encoding):e=cv,e===cv&&this.context.gamma&&(e=zN),e}};import{MathUtils as xD,Vector2 as Wr,Vector3 as mo,Vector4 as ns}from"three";var He=class extends $e{constructor(e=0,t,o,n){super("c");this.nodeType="Color";this.value=e instanceof At?e:new At(e||0,t,o,n)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o),c=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let u=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${u};`)}return c?this.generateReadonly(e,t,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,t)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,t))}generateReadonly(e,t,o,n,a,s){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",n,t)}};var Re=class extends $e{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,t,o,n,a,s){return e.format(this.value.toString(),n,t)}};import{UniformsLib as $N,UniformsUtils as XN}from"three";var ft=class extends $e{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,t,o,n){return e.format(this.value?"true":"false",n,t)}};var Ur=class extends $e{constructor(e=1,t){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(t)?t:typeof t=="number"?new Array(e).fill(t):new Array(e).fill(0)}};import{Vector3 as UN}from"three";var wi=class extends $e{};var ku=class extends wi{constructor(e){super("v3");this.image=e;this._value=new UN}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}};var cn=class extends wi{constructor(e,t,o=1008,n=1006){super("t");this.image=e;this.wrap=t;this.minFilter=o;this.magFilter=n}get value(){return this.image.getTexture(this.wrap,this.minFilter,this.magFilter)}};import{Matrix3 as kN}from"three";var ka=class extends $e{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new kN}generateReadonly(e,t,o,n,a,s){return e.format("mat3("+this.value.elements.join(", ")+")",n,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};import{Matrix4 as HN}from"three";var Ft=class extends $e{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new HN}generateReadonly(e,t,o,n,a,s){return e.format("mat4("+this.value.elements.join(", ")+")",n,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};import{MathUtils as WN,Matrix3 as pv}from"three";function dv(i,r,e,t=0){i.setUvTransform(e[0],e[1],r[0],r[1],0,0,0).premultiply(new pv().makeRotation(t*WN.DEG2RAD))}var Hu=class extends ka{constructor(e,t,o=0){super(new pv);this.repeat=e;this.offset=t;this.rotation=o;dv(this.value,e,t,o)}updateMatrix(){dv(this.value,this.repeat,this.offset,this.rotation)}};import{Vector4 as fv}from"three";var kr=class extends $e{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof fv?new Array(e).fill(t):new Array(e).fill(new fv(0))}};var Ha=class extends ge{constructor(e,t,o,n){super("v3");this.nodeType="Blend";this.a=e,this.b=t,this.alpha=o,this.mode=n}generate(e,t){if(e.isShader("fragment")){let o=[];return o.push(this.a.build(e,"c")),o.push(this.b.build(e,"c")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),e.format("spe_blend("+o.join(",")+")",this.getType(e),t)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}};var Zf=class extends ge{constructor(e,t){super("v3");this.nodeType="CustomColor";this.color=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let o=e.include(Zf.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let n=[];return n.push(this.color.build(e,"v3")),n.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},un=Zf;un.Nodes=function(){return{customColor:new J(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
262
262
  float lalpha = alpha * mask;
263
263
  calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
264
264
  accumAlpha += (1.0 - accumAlpha) * lalpha;
265
265
 
266
266
  return color;
267
- }`)}}();var Wf=class extends ge{constructor(e,t){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let o=e.include(Wf.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");let n=[];return n.push(this.cnormal.build(e,"v3")),n.push("normal"),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Wa=Wf;Wa.Nodes=function(){return{customNormal:new J(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
267
+ }`)}}();var Jf=class extends ge{constructor(e,t){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let o=e.include(Jf.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");let n=[];return n.push(this.cnormal.build(e,"v3")),n.push("normal"),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Wa=Jf;Wa.Nodes=function(){return{customNormal:new J(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
268
268
  vec3 normal = packNormalToRGB( norm ).rgb;
269
269
  normal *= step( vec3(0.5), cnormal );
270
270
 
@@ -514,7 +514,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
514
514
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
515
515
 
516
516
  return color;
517
- }`),n=e.include(o),a=[];return a.push(this.color.build(e,"c")),a.push(this.bias.build(e,"f")),a.push(this.scale.build(e,"f")),a.push(this.intensity.build(e,"f")),a.push(this.factor.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),e.format(n+"("+a.join(",")+")",this.getType(e),t)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}};var qf=class extends ge{constructor(e,t,o,n,a,s,l,c,u){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=t,this.colors=o,this.steps=n,this.offset=a,this.morph=s,this.angle=l,this.isMask=u,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(qf.Nodes.gradient),n=[];return n.push(this.gradientType.build(e,"i")),n.push(this.smooth.build(e,"b")),n.push(this.colors.build(e,"v4[]")),n.push(this.steps.build(e,"f[]")),n.push(this.offset.build(e,"v2")),n.push(this.morph.build(e,"v2")),n.push(this.angle.build(e,"f")),n.push(this.isMask.build(e,"b")),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ya=qf;Ya.Nodes=function(){return{gradient:new J(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) {
517
+ }`),n=e.include(o),a=[];return a.push(this.color.build(e,"c")),a.push(this.bias.build(e,"f")),a.push(this.scale.build(e,"f")),a.push(this.intensity.build(e,"f")),a.push(this.factor.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),e.format(n+"("+a.join(",")+")",this.getType(e),t)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}};var eh=class extends ge{constructor(e,t,o,n,a,s,l,c,u){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=t,this.colors=o,this.steps=n,this.offset=a,this.morph=s,this.angle=l,this.isMask=u,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(eh.Nodes.gradient),n=[];return n.push(this.gradientType.build(e,"i")),n.push(this.smooth.build(e,"b")),n.push(this.colors.build(e,"v4[]")),n.push(this.steps.build(e,"f[]")),n.push(this.offset.build(e,"v2")),n.push(this.morph.build(e,"v2")),n.push(this.angle.build(e,"f")),n.push(this.isMask.build(e,"b")),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ya=eh;Ya.Nodes=function(){return{gradient:new J(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) {
518
518
  vec4 color = colors[0];
519
519
  vec2 m = morph / vUv.xy;
520
520
  vec2 rot = vec2( 0.5 + m.x, m.y );
@@ -556,7 +556,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
556
556
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
557
557
 
558
558
  return color.xyz;
559
- }`)}}();var $f=class extends ge{constructor(e,t,o,n,a){super("v3");this.nodeType="Matcap";this.texture=e,this.isMask=n,this.alpha=t,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`,this.rotation=a}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include($f.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let n=[];return n.push(this.texture.generate(e,"t")),n.push("normal"),n.push(this.isMask.build(e,"b")),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),n.push(this.calpha),n.push(this.rotation.build(e,"f")),e.format(o+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ka=$f;Ka.Nodes=function(){return{matcap:new J(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {
559
+ }`)}}();var th=class extends ge{constructor(e,t,o,n,a){super("v3");this.nodeType="Matcap";this.texture=e,this.isMask=n,this.alpha=t,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`,this.rotation=a}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(th.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let n=[];return n.push(this.texture.generate(e,"t")),n.push("normal"),n.push(this.isMask.build(e,"b")),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),n.push(this.calpha),n.push(this.rotation.build(e,"f")),e.format(o+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ka=th;Ka.Nodes=function(){return{matcap:new J(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {
560
560
  vec3 viewDir = normalize( vViewPosition );
561
561
  vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
562
562
  vec3 y = cross( viewDir, x );
@@ -992,7 +992,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
992
992
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
993
993
 
994
994
  return clamp(color, 0.0, 1.0).rgb;
995
- }`,[Lt.simplexFast,Lt.simplexFractal,Lt.simplexAshima,Lt.fbm,Lt.perlin,Lt.voronoi]),p=e.include(u),d=[];return d.push(this.scale.build(e,"f")),d.push(this.size.build(e,"v3")),d.push(this.move.build(e,"f")),d.push(this.fA.build(e,"v2")),d.push(this.fB.build(e,"v2")),d.push(this.distortion.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.colorC.build(e,"v4")),d.push(this.colorD.build(e,"v4")),d.push(this.voronoiStyle.build(e,"i")),d.push(this.highCut.build(e,"f")),d.push(this.lowCut.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.seed.build(e,"f")),d.push(this.quality.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(p+"("+d.join(",")+")",this.getType(e),t)}};Qa.numOctaves=5;var Xf=class extends ge{constructor(e,t,o,n,a,s,l,c,u,p,d,f,h,m,y,b){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=t,this.outlineWidth=o,this.contourWidth=n,this.contourThreshold=a,this.outlineThreshold=s,this.contourFrequency=l,this.outlineSmoothing=c,this.contourDirection=u,this.positionalLines=p,this.compensation=d,this.resolution=f,this.normalMap=h,this.depthMap=m,this.pixelRatio=y,this.alpha=b,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let o=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${o}_offset`),this.firstTime){let n=this.outlineWidth.build(e,"f"),a=this.resolution.build(e,"v2"),s=this.compensation.build(e,"b"),l=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(n,"uniform float"),e.addVertexParsVariable(a,"uniform vec2"),e.addVertexParsVariable(s,"uniform bool"),e.addVertexParsVariable(l,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
995
+ }`,[Lt.simplexFast,Lt.simplexFractal,Lt.simplexAshima,Lt.fbm,Lt.perlin,Lt.voronoi]),p=e.include(u),d=[];return d.push(this.scale.build(e,"f")),d.push(this.size.build(e,"v3")),d.push(this.move.build(e,"f")),d.push(this.fA.build(e,"v2")),d.push(this.fB.build(e,"v2")),d.push(this.distortion.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.colorC.build(e,"v4")),d.push(this.colorD.build(e,"v4")),d.push(this.voronoiStyle.build(e,"i")),d.push(this.highCut.build(e,"f")),d.push(this.lowCut.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.seed.build(e,"f")),d.push(this.quality.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(p+"("+d.join(",")+")",this.getType(e),t)}};Qa.numOctaves=5;var rh=class extends ge{constructor(e,t,o,n,a,s,l,c,u,p,d,f,h,m,y,b){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=t,this.outlineWidth=o,this.contourWidth=n,this.contourThreshold=a,this.outlineThreshold=s,this.contourFrequency=l,this.outlineSmoothing=c,this.contourDirection=u,this.positionalLines=p,this.compensation=d,this.resolution=f,this.normalMap=h,this.depthMap=m,this.pixelRatio=y,this.alpha=b,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let o=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${o}_offset`),this.firstTime){let n=this.outlineWidth.build(e,"f"),a=this.resolution.build(e,"v2"),s=this.compensation.build(e,"b"),l=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(n,"uniform float"),e.addVertexParsVariable(a,"uniform vec2"),e.addVertexParsVariable(s,"uniform bool"),e.addVertexParsVariable(l,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
996
996
  vID = randomColor.r;
997
997
  vec2 ${o}_offset = vec2(0.0);
998
998
  if (${s}) {
@@ -1007,7 +1007,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
1007
1007
  // if this offset is the biggest of all the potential offsets
1008
1008
  gl_Position = ${o}_clipPosition;
1009
1009
  }
1010
- `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let n=e.include(Xf.Nodes.outline),a=[];return a.push(this.outlineColor.build(e,"c")),a.push(this.contourColor.build(e,"c")),a.push(this.outlineWidth.build(e,"f")),a.push(this.contourWidth.build(e,"f")),a.push(this.contourThreshold.build(e,"f")),a.push(this.outlineThreshold.build(e,"f")),a.push(this.contourFrequency.build(e,"f")),a.push(this.outlineSmoothing.build(e,"f")),a.push(this.contourDirection.build(e,"v3")),a.push(this.positionalLines.build(e,"b")),a.push(this.resolution.build(e,"v2")),a.push(this.normalMap.getTexture(e,"t")),a.push(this.depthMap.getTexture(e,"t")),a.push(this.pixelRatio.build(e,"f")),a.push(this.compensation.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),this.firstTime=!this.firstTime,e.format(n+"("+a.join(",")+")",this.getType(e),t)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},Za=Xf;Za.Nodes=function(){let e=new J(`
1010
+ `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let n=e.include(rh.Nodes.outline),a=[];return a.push(this.outlineColor.build(e,"c")),a.push(this.contourColor.build(e,"c")),a.push(this.outlineWidth.build(e,"f")),a.push(this.contourWidth.build(e,"f")),a.push(this.contourThreshold.build(e,"f")),a.push(this.outlineThreshold.build(e,"f")),a.push(this.contourFrequency.build(e,"f")),a.push(this.outlineSmoothing.build(e,"f")),a.push(this.contourDirection.build(e,"v3")),a.push(this.positionalLines.build(e,"b")),a.push(this.resolution.build(e,"v2")),a.push(this.normalMap.getTexture(e,"t")),a.push(this.depthMap.getTexture(e,"t")),a.push(this.pixelRatio.build(e,"f")),a.push(this.compensation.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),this.firstTime=!this.firstTime,e.format(n+"("+a.join(",")+")",this.getType(e),t)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},Za=rh;Za.Nodes=function(){let e=new J(`
1011
1011
  float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)
1012
1012
  {
1013
1013
  vec2 halton = haltonSequence[frameIndex];
@@ -1407,7 +1407,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1407
1407
  float s = mix(size, size * rand, variation);
1408
1408
 
1409
1409
  return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);
1410
- }`);return{tileAndCenter:t,circle:o,ring:n,polygon:a,cross:s,diamond:l,checkerboard:c,line:u,wave:p}}();var Yf=class extends ge{constructor(e,t,o,n,a,s,l,c){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=t,this.wavelengths=o,this.noiseStrength=n,this.noiseScale=a,this.offset=s,this.isMask=c,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(Yf.Nodes.rainbow),n=[];return n.push(this.filmThickness.build(e,"f")),n.push(this.movement.build(e,"f")),n.push(this.wavelengths.build(e,"v3")),n.push(this.noiseStrength.build(e,"f")),n.push(this.noiseScale.build(e,"f")),n.push(this.offset.build(e,"v3")),n.push(this.isMask.build(e,"b")),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},es=Yf;es.Nodes=function(){let e=new J(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
1410
+ }`);return{tileAndCenter:t,circle:o,ring:n,polygon:a,cross:s,diamond:l,checkerboard:c,line:u,wave:p}}();var oh=class extends ge{constructor(e,t,o,n,a,s,l,c){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=t,this.wavelengths=o,this.noiseStrength=n,this.noiseScale=a,this.offset=s,this.isMask=c,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(oh.Nodes.rainbow),n=[];return n.push(this.filmThickness.build(e,"f")),n.push(this.movement.build(e,"f")),n.push(this.wavelengths.build(e,"v3")),n.push(this.noiseStrength.build(e,"f")),n.push(this.noiseScale.build(e,"f")),n.push(this.offset.build(e,"v3")),n.push(this.isMask.build(e,"b")),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},es=oh;es.Nodes=function(){let e=new J(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
1411
1411
  float f = 0.0;
1412
1412
 
1413
1413
  if (noiseStrength != 0.0) {
@@ -1431,7 +1431,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1431
1431
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
1432
1432
 
1433
1433
  return res;
1434
- }`,[e])}}();var Kf=class extends ge{constructor(e,t,o,n,a,s,l,c,u,p){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=t,this.steps=o,this.source=n,this.isWorldSpace=a,this.noiseStrength=s,this.noiseScale=l,this.shadowColor=c,this.offset=u,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let o=e.include(Kf.Nodes.toon),n=[];return n.push(this.positioning.build(e,"i")),n.push(this.colors.build(e,"v4[]")),n.push(this.steps.build(e,"f[]")),n.push(this.source.build(e,"v3")),n.push(this.isWorldSpace.build(e,"b")),n.push(this.noiseStrength.build(e,"f")),n.push(this.noiseScale.build(e,"f")),n.push(this.shadowColor.build(e,"v4")),n.push(this.offset.build(e,"v3")),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},ts=Kf;ts.Nodes=function(){let e=new J(`float rand(float n) {
1434
+ }`,[e])}}();var ih=class extends ge{constructor(e,t,o,n,a,s,l,c,u,p){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=t,this.steps=o,this.source=n,this.isWorldSpace=a,this.noiseStrength=s,this.noiseScale=l,this.shadowColor=c,this.offset=u,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let o=e.include(ih.Nodes.toon),n=[];return n.push(this.positioning.build(e,"i")),n.push(this.colors.build(e,"v4[]")),n.push(this.steps.build(e,"f[]")),n.push(this.source.build(e,"v3")),n.push(this.isWorldSpace.build(e,"b")),n.push(this.noiseStrength.build(e,"f")),n.push(this.noiseScale.build(e,"f")),n.push(this.shadowColor.build(e,"v4")),n.push(this.offset.build(e,"v3")),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},ts=ih;ts.Nodes=function(){let e=new J(`float rand(float n) {
1435
1435
  return fract(sin(n) * 43758.5453123);
1436
1436
  }`),t=new J(`float hash1(float p) {
1437
1437
  p = fract(p * 0.011);
@@ -1667,7 +1667,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1667
1667
 
1668
1668
  return color.xyz;
1669
1669
 
1670
- }`,[Lt.simplexFast,e,o,a])}}();import{Vector2 as Kb}from"three";var Yb=function(){return{textureBicubic:new J(`float w0( float a ) {
1670
+ }`,[Lt.simplexFast,e,o,a])}}();import{Vector2 as mv}from"three";var hv=function(){return{textureBicubic:new J(`float w0( float a ) {
1671
1671
  return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
1672
1672
  }
1673
1673
 
@@ -1731,7 +1731,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1731
1731
  vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
1732
1732
  vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
1733
1733
  return mix( fSample, cSample, fract( lod ) );
1734
- }`)}}();function Qb(i,r){return i>=r?new Kb(r/i,1):new Kb(1,i/r)}var Qf=class extends ge{constructor(e,t,o,n,a,s,l,c){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=t,this.roughness=o,this.transmissionSamplerSize=n,this.transmissionSamplerMap=a,this.transmissionDepthMap=s,this.aspectRatio=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",6),e.define("BLUR_SLOD",Math.pow(2,Ae.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let o=e.include(Qf.Nodes.transmission),n=[];return n.push(this.thickness.build(e,"f")),n.push(this.ior.build(e,"f")),n.push(this.roughness.build(e,"f")),n.push(this.transmissionSamplerSize.build(e,"v2")),n.push(this.transmissionSamplerMap.getTexture(e,"t")),n.push(this.transmissionDepthMap.getTexture(e,"t")),n.push(this.aspectRatio.build(e,"v2")),n.push("normal"),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},rs=Qf;rs.Nodes=function(){let e=new J(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
1734
+ }`)}}();function yv(i,r){return i>=r?new mv(r/i,1):new mv(1,i/r)}var nh=class extends ge{constructor(e,t,o,n,a,s,l,c){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=t,this.roughness=o,this.transmissionSamplerSize=n,this.transmissionSamplerMap=a,this.transmissionDepthMap=s,this.aspectRatio=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",6),e.define("BLUR_SLOD",Math.pow(2,Ae.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let o=e.include(nh.Nodes.transmission),n=[];return n.push(this.thickness.build(e,"f")),n.push(this.ior.build(e,"f")),n.push(this.roughness.build(e,"f")),n.push(this.transmissionSamplerSize.build(e,"v2")),n.push(this.transmissionSamplerMap.getTexture(e,"t")),n.push(this.transmissionDepthMap.getTexture(e,"t")),n.push(this.aspectRatio.build(e,"v2")),n.push("normal"),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},rs=nh;rs.Nodes=function(){let e=new J(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
1735
1735
  // Slightly modified version of this:
1736
1736
  // https://www.shadertoy.com/view/ltScRG
1737
1737
 
@@ -1791,7 +1791,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1791
1791
  float lod = applyIorToRoughness(roughness, ior);
1792
1792
  return blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
1793
1793
  #endif
1794
- }`,[Yb.textureBicubic,o,e]),a=new J(`vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) {
1794
+ }`,[hv.textureBicubic,o,e]),a=new J(`vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) {
1795
1795
  vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
1796
1796
  vec3 refractedRayExit = position + transmissionRay;
1797
1797
 
@@ -1822,7 +1822,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1822
1822
  accumAlpha += ( 1.0 - accumAlpha ) * alpha;
1823
1823
 
1824
1824
  return transmission;
1825
- }`,[a])}}();var Zf=(e=>(e.NOISE="noise",e.MAP="map",e))(Zf||{}),Jf=class extends ge{constructor(e,t,o,n,a,s,l,c,u,p,d){super("v3");this.displacementTypeIndex=new Re(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=t,Object.values(Zf)[this.displacementTypeIndex.value]==="map"&&(this.mat=new ka(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=p,this.noiseFunctionIndex=d,this.voronoiStyle=n,this.smoothness=a,this.seed=s,this.highCut=l,this.lowCut=c,this.quality=u}generate(e,t){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let o,n=[];switch(n.push("displaced_position"),n.push("displaced_normal"),Object.values(Zf)[this.displacementTypeIndex.value]){case"map":{o=e.include(Jf.Nodes.map),n.push(this.movementOrTexture.getTexture(e,"t")),n.push("uv"),n.push(this.cropOrOffset.build(e,"f")),this.mat&&n.push(this.mat.build(e,"mat3"));break}case"noise":{let l=["simplexPrecise","simplexFractal","simplexAshima","fbm","perlin","voronoi"][this.noiseFunctionIndex.value],c=new J(`vec3 orthogonal(vec3 v) {
1825
+ }`,[a])}}();var ah=(e=>(e.NOISE="noise",e.MAP="map",e))(ah||{}),sh=class extends ge{constructor(e,t,o,n,a,s,l,c,u,p,d){super("v3");this.displacementTypeIndex=new Re(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=t,Object.values(ah)[this.displacementTypeIndex.value]==="map"&&(this.mat=new ka(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=p,this.noiseFunctionIndex=d,this.voronoiStyle=n,this.smoothness=a,this.seed=s,this.highCut=l,this.lowCut=c,this.quality=u}generate(e,t){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let o,n=[];switch(n.push("displaced_position"),n.push("displaced_normal"),Object.values(ah)[this.displacementTypeIndex.value]){case"map":{o=e.include(sh.Nodes.map),n.push(this.movementOrTexture.getTexture(e,"t")),n.push("uv"),n.push(this.cropOrOffset.build(e,"f")),this.mat&&n.push(this.mat.build(e,"mat3"));break}case"noise":{let l=["simplexPrecise","simplexFractal","simplexAshima","fbm","perlin","voronoi"][this.noiseFunctionIndex.value],c=new J(`vec3 orthogonal(vec3 v) {
1826
1826
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
1827
1827
  }`),u=l=="voronoi"?`
1828
1828
  float v = ${l}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);
@@ -1851,7 +1851,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1851
1851
  vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
1852
1852
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1853
1853
  return displaced_position;
1854
- }`,[p,c]);o=e.include(d),n.push(this.scale.build(e,"f")),n.push(this.cropOrOffset.build(e,"v3")),n.push(this.movementOrTexture.build(e,"f")),n.push(this.voronoiStyle.build(e,"i")),n.push(this.smoothness.build(e,"f")),n.push(this.seed.build(e,"f")),n.push(this.highCut.build(e,"f")),n.push(this.lowCut.build(e,"f")),n.push(this.quality.build(e,"i"));break}}return n.push(this.intensity.build(e,"f")),n.push("displaced_normal"),e.format(o+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},os=Jf;os.Nodes=function(){let e=new J(`vec3 orthogonal(vec3 v) {
1854
+ }`,[p,c]);o=e.include(d),n.push(this.scale.build(e,"f")),n.push(this.cropOrOffset.build(e,"v3")),n.push(this.movementOrTexture.build(e,"f")),n.push(this.voronoiStyle.build(e,"i")),n.push(this.smoothness.build(e,"f")),n.push(this.seed.build(e,"f")),n.push(this.highCut.build(e,"f")),n.push(this.lowCut.build(e,"f")),n.push(this.quality.build(e,"i"));break}}return n.push(this.intensity.build(e,"f")),n.push("displaced_normal"),e.format(o+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},os=sh;os.Nodes=function(){let e=new J(`vec3 orthogonal(vec3 v) {
1855
1855
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
1856
1856
  }`),t=new J(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
1857
1857
  vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
@@ -1873,7 +1873,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1873
1873
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
1874
1874
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1875
1875
  return displaced_position;
1876
- }`,[e,t])}}();var Ae={normalRenderTarget:new Yt,normalRenderTargetDepth:new Yt,transmissionRenderTarget:new Yt,aspectRatio:new lt,transmissionSize:new lt(2048,2048),transmissionRenderTargetDepth:new Yt,aoRenderTarget:new Yt,aoEnabled:new ft,pixelRatioNode:new se(1),resolution:new lt,penumbraSize:new Ur(5,.5),frameIndex:new Re(0),transmissionLod:new Re(2)};for(let i of Object.values(Ae))i.isRenderGlobal=!0;var Zb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.10.27/build/ui.wasm"};var ko=class extends qe{constructor(){super("basic");this.nodeType="Basic";this.color=new He(mt),this.shadingAlpha=new se(1),this.shadingBlend=new Re(0),this.previousModelViewMatrix=new Ft,this.previouseProjectionMatrix=new Ft}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(ZE.merge([QE.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
1876
+ }`,[e,t])}}();var Ae={normalRenderTarget:new Yt,normalRenderTargetDepth:new Yt,transmissionRenderTarget:new Yt,aspectRatio:new lt,transmissionSize:new lt(2048,2048),transmissionRenderTargetDepth:new Yt,aoRenderTarget:new Yt,aoEnabled:new ft,pixelRatioNode:new se(1),resolution:new lt,penumbraSize:new Ur(5,.5),frameIndex:new Re(0),transmissionLod:new Re(2)};for(let i of Object.values(Ae))i.isRenderGlobal=!0;var gv={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.10.29/build/ui.wasm"};var ko=class extends qe{constructor(){super("basic");this.nodeType="Basic";this.color=new He(mt),this.shadingAlpha=new se(1),this.shadingBlend=new Re(0),this.previousModelViewMatrix=new Ft,this.previouseProjectionMatrix=new Ft}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(XN.merge([$N.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
1877
1877
  `));let n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
1878
1878
  #include <skinbase_vertex>
1879
1879
  #include <skinnormal_vertex>
@@ -1895,7 +1895,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1895
1895
  `];o&&n.push(o.code,o.result?"displaced_position = "+o.result+";":""),n.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),n.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=n.join(`
1896
1896
  `)}else{this.color===void 0&&(this.color=new He(mt)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let o=this.color.flow(e,"c",{slot:"color"}),n=this.alpha?this.alpha.flow(e,"f"):void 0,a=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=n!==void 0,e.addParsCode(["varying vec3 vWPosition;","#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
1897
1897
  `));let l=["#include <normal_fragment_begin>",o.code];n&&l.push(n.code,"#ifdef ALPHATEST"," if ( "+n.result+" <= ALPHATEST ) discard;","#endif"),s?l.push(s.code,`vec3 outgoingLight = ${o.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):l.push(`vec3 finalColor = ${o.result};`);let c="1.0";this.mask&&(this.mask.analyze(e),c=`luminance(${this.mask.flow(e,"v3").result})`),n?l.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${n.result} * ${c} );`):l.push("gl_FragColor = vec4("+o.result+", 1.0 );"),a&&l.push(`gl_FragColor.a *= ${a.result};`),l.push("#include <fog_fragment>","#include <dithering_fragment>"),t=l.join(`
1898
- `)}return t}};import{UniformsLib as Jb,UniformsUtils as JE}from"three";var hl=class extends qe{constructor(){super("lambert");this.nodeType="Lambert";this.color=new He(mt),this.emissive=new He(0),this.emissiveIntensity=new se(1),this.previousModelViewMatrix=new Ft,this.previouseProjectionMatrix=new Ft,this.shadingAlpha=new se(1),this.shadingBlend=new Re(0),this.occlusion=new ft(!0)}get category(){return"lambert"}build(e){let t;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(JE.merge([Jb.fog,Jb.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1898
+ `)}return t}};import{UniformsLib as xv,UniformsUtils as YN}from"three";var hl=class extends qe{constructor(){super("lambert");this.nodeType="Lambert";this.color=new He(mt),this.emissive=new He(0),this.emissiveIntensity=new se(1),this.previousModelViewMatrix=new Ft,this.previouseProjectionMatrix=new Ft,this.shadingAlpha=new se(1),this.shadingBlend=new Re(0),this.occlusion=new ft(!0)}get category(){return"lambert"}build(e){let t;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(YN.merge([xv.fog,xv.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1899
1899
  `));let n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
1900
1900
  #include <skinbase_vertex>
1901
1901
  #include <skinnormal_vertex>
@@ -2006,7 +2006,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2006
2006
  outgoingLight *= ao;
2007
2007
  }
2008
2008
  `),u&&f.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),p?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result} );`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&f.push(`gl_FragColor.a *= ${d.result};`),f.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=f.join(`
2009
- `)}return t}};import{UniformsLib as ev,UniformsUtils as eN}from"three";var Ho=function(){let i=new J(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {
2009
+ `)}return t}};import{UniformsLib as bv,UniformsUtils as KN}from"three";var Ho=function(){let i=new J(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {
2010
2010
 
2011
2011
  // Gradient of UVs w.r.t. X coordinate (in screen-space)
2012
2012
  vec2 dSTdx = dFdx(bumpMapUv);
@@ -2037,7 +2037,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2037
2037
 
2038
2038
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
2039
2039
  return normalize( abs( fDet ) * vN - vGrad );
2040
- }`);return{dHdxy:i,perturbNormalArb:r}}();var ml=class extends qe{constructor(){super("phong");this.nodeType="Phong";this.color=new He(mt),this.specular=new He(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new Ft,this.previouseProjectionMatrix=new Ft,this.shadingAlpha=new se(1),this.shadingBlend=new Re(0),this.occlusion=new ft(!0)}get category(){return"phong"}build(e){let t;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(eN.merge([ev.fog,ev.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2040
+ }`);return{dHdxy:i,perturbNormalArb:r}}();var ml=class extends qe{constructor(){super("phong");this.nodeType="Phong";this.color=new He(mt),this.specular=new He(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new Ft,this.previouseProjectionMatrix=new Ft,this.shadingAlpha=new se(1),this.shadingBlend=new Re(0),this.occlusion=new ft(!0)}get category(){return"phong"}build(e){let t;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(KN.merge([bv.fog,bv.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2041
2041
  `));let n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
2042
2042
  #include <skinbase_vertex>
2043
2043
  #include <skinnormal_vertex>
@@ -2104,7 +2104,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2104
2104
  outgoingLight *= ao;
2105
2105
  }
2106
2106
  `),u&&f.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),p?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result});`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&f.push(`gl_FragColor.a *= ${d.result};`),f.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=f.join(`
2107
- `)}return t}};import{UniformsLib as eh,UniformsUtils as tN}from"three";var yl=class extends qe{constructor(){super("standard");this.nodeType="Standard";this.color=new He(mt),this.roughness=new se(.3),this.metalness=new se(0),this.reflectivity=new se(.5),this.previousModelViewMatrix=new Ft,this.previouseProjectionMatrix=new Ft,this.shadingAlpha=new se(1),this.shadingBlend=new Re(0),this.occlusion=new ft(!0)}get category(){return"physical"}build(e){let t;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(tN.merge([eh.fog,eh.lights])),eh.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2107
+ `)}return t}};import{UniformsLib as lh,UniformsUtils as QN}from"three";var yl=class extends qe{constructor(){super("standard");this.nodeType="Standard";this.color=new He(mt),this.roughness=new se(.3),this.metalness=new se(0),this.reflectivity=new se(.5),this.previousModelViewMatrix=new Ft,this.previouseProjectionMatrix=new Ft,this.shadingAlpha=new se(1),this.shadingBlend=new Re(0),this.occlusion=new ft(!0)}get category(){return"physical"}build(e){let t;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(QN.merge([lh.fog,lh.lights])),lh.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2108
2108
  `));let n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
2109
2109
  #include <skinbase_vertex>
2110
2110
  #include <skinnormal_vertex>
@@ -2197,7 +2197,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2197
2197
  outgoingLight *= ao;
2198
2198
  }
2199
2199
  `),p&&m.push(p.code,`outgoingLight = spe_blend(outgoingLight, ${p.result}, 1.0, SPE_BLENDING_NORMAL);`),d?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),f&&m.push(`gl_FragColor.a *= ${f.result};`),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=m.join(`
2200
- `)}return t}};import{UniformsLib as tv,UniformsUtils as rN}from"three";var gl=class extends qe{constructor(){super("toon");this.nodeType="Toon";this.color=new He(mt),this.specular=new He(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new Ft,this.previouseProjectionMatrix=new Ft,this.shadingAlpha=new se(1),this.shadingBlend=new Re(0)}get category(){return"toon"}build(e){let t;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(rN.merge([tv.fog,tv.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2200
+ `)}return t}};import{UniformsLib as vv,UniformsUtils as ZN}from"three";var gl=class extends qe{constructor(){super("toon");this.nodeType="Toon";this.color=new He(mt),this.specular=new He(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new Ft,this.previouseProjectionMatrix=new Ft,this.shadingAlpha=new se(1),this.shadingBlend=new Re(0)}get category(){return"toon"}build(e){let t;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(ZN.merge([vv.fog,vv.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2201
2201
  `));let n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
2202
2202
  #include <skinbase_vertex>
2203
2203
  #include <skinnormal_vertex>
@@ -2282,11 +2282,11 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2282
2282
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result} * ${f}, ${l.result} );
2283
2283
  }
2284
2284
  `),c&&d.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),u?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p&&d.push(`gl_FragColor.a *= ${p.result};`),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
2285
- `)}return t}};import{VideoTexture as oN,Texture as iN}from"three";var ju=class{constructor(r=1e3*10){this.timeout=r;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...r){}remove(r){let e=this.cache.get(r);e&&(this.dispose(r,e.data),this.cache.delete(r),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let r=Date.now(),e=this.head.next;for(;e.time<r-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(r){return this.cache.get(r)?.data}load(r){let e=Date.now(),t=this.cache.get(r);return t===void 0?(t={data:this.create(r),src:r,time:e,next:null,prev:null},this.cache.set(r,t)):(t.time=e,t.prev.next=t.next,t.next.prev=t.prev),t.prev=this.tail.prev,t.next=this.tail,this.tail.prev.next=t,this.tail.prev=t,this.scheduleCleanup(),t.data}};var rh=class extends ju{create(r){return URL.createObjectURL(new Blob([r]))}dispose(r,e){URL.revokeObjectURL(e)}},th;function rv(i){return typeof i=="string"?i:(th||(th=new rh),th.load(i))}var Uu=class{constructor(r,e){this.data=r;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},ku=class{constructor(){this.cache=new Map}remove(r){if(this.cache.delete(r.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(r){let e=this.cache.get(r);return e===void 0&&(e=this.create(r),this.cache.set(r,e)),e.refCount+=1,e}};var is=class extends Uu{constructor(e,t){super(e,t.imageHolderCache);this.data=e;this.shared=t;this.loaded=!1;this.isVideo=!1;this.isBuffer=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;for(let n of Object.values(this._cache))for(let a of Object.values(n))for(let s of Object.values(a))s&&(s.image=this.img,s.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var o=new FileReader;o.readAsDataURL(new Blob([e],{type:"video/mp4"}));let n;await new Promise(a=>{o.onloadend=s=>{n=s.target?.result,a(null)}}),this.img.src=n}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=rv(e),this.img.onload=t,await new Promise(n=>{this.img.onload=()=>{t(),n(null)}})}getTexture(e,t=1008,o=1006){let n=this._cache[e]?.[t]?.[o];if(n)return n;{let a;return this.isBuffer?a=this.img.texture:this.isVideo?a=new oN(this.img,void 0,e,e):a=new iN(this.img,void 0,e,e,o,t),this.loaded&&(a.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][t]===void 0&&(this._cache[e][t]={}),this._cache[e][t][o]=a,a}}setNeedsUpdate(e){for(let t of Object.values(this._cache))for(let o of Object.values(t))for(let n of Object.values(o))n&&(n.needsUpdate=e)}disposeTextures(){for(let[e,t]of Object.entries(this._cache))for(let[o,n]of Object.entries(t))for(let[a,s]of Object.entries(n))s?.dispose(),this._cache[e]!==void 0&&this._cache[e][o]!==void 0&&(this._cache[e][o][a]=void 0)}dispose(){super.dispose(),this.disposeTextures()}};var pr=class extends is{};import{Vector2 as Wo,Vector3 as ho,Vector4 as Hu}from"three";function jt(i,r){return r.color(i)}function ov(i,r){switch(i.type){case"fresnel":return sN(i,r);case"gradient":return lN(i,r);case"depth":return cN(i,r);case"normal":return uN(i,r);case"noise":return dN(i,r);case"rainbow":return pN(i,r);case"toon":return fN(i,r);case"outline":return hN(i,r);case"transmission":return mN(i,r);case"color":return aN(i,r);case"pattern":return yN(i,r)}}function nN(i){return{type:i.type}}function Hr(i,r){let{alpha:e,mode:t,isMask:o}=i,n=typeof e=="string"?(Number(r.getVariable(e))??100)/100:e;return{...nN(i),alpha:n,mode:t,isMask:o}}function aN(i,r){return{...Hr(i,r),color:jt(i.color,r)}}function sN(i,r){let{bias:e,scale:t,intensity:o,factor:n,color:a}=i;return{...Hr(i,r),color:jt(a,r),bias:e,scale:t,intensity:o,factor:n}}function lN(i,r){let{gradientType:e,smooth:t,colors:o,steps:n,angle:a,offset:s,morph:l}=i;return{...Hr(i,r),gradientType:e,smooth:t,colors:o.map(c=>new Hu(c[0],c[1],c[2],c[3])),num:o.length,steps:n,offset:new Wo(...s),morph:new Wo(...l),angle:a}}function cN(i,r){let{gradientType:e,near:t,far:o,isVector:n,isWorldSpace:a,origin:s,direction:l,colors:c,steps:u,smooth:p}=i;return{...Hr(i,r),gradientType:e,near:t,far:o,isVector:n,isWorldSpace:a,origin:new ho(...s),direction:l?new ho(...l):new ho(1,0,0),colors:c.map(d=>d!==void 0?new Hu(d[0],d[1],d[2],d[3]):new Hu(0,0,0,0)),steps:u.slice(0,c.length),smooth:p}}function uN(i,r){let{cnormal:e}=i;return{...Hr(i,r),cnormal:new ho(e[0],e[1],e[2])}}function dN(i,r){return{...Hr(i,r),scale:i.scale,move:i.move,fA:new Wo(...i.fA),fB:new Wo(...i.fB),size:new ho(...i.size),distortion:new Wo(...i.distortion),colorA:jt(i.colorA,r),colorB:jt(i.colorB,r),colorC:jt(i.colorC,r),colorD:jt(i.colorD,r),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}function pN(i,r){return{...Hr(i,r),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new ho(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new ho(...i.offset)}}function fN(i,r){return{...Hr(i,r),positioning:i.positioning,colors:i.colors.map(e=>new Hu(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new ho(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:jt(i.shadowColor,r),offset:new ho(...i.offset)}}function hN(i,r){return{...Hr(i,r),outlineColor:jt(i.outlineColor,r),contourColor:jt(i.contourColor,r),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new ho(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}function mN(i,r){return{...Hr(i,r),thickness:i.thickness,ior:i.ior,roughness:i.roughness}}function yN(i,r){return{...Hr(i,r),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new Wo(...i.offset),colorA:jt(i.colorA,r),colorB:jt(i.colorB,r),frequency:new Wo(...i.frequency),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new Wo(...i.vertical),horizontal:new Wo(...i.horizontal),sides:i.sides}}var Oi=class extends At{};import{MathUtils as gN,Vector4 as xN}from"three";var bN={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},vN={depth:["colors"]};function SN(i,r,e){if(r==="isMask")return!0;let t=bN[i.type],o=vN[i.type];if(o!==void 0){let n=i.color;if(o.includes(r)){let a=n[r]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return t!==void 0?t.includes(r):!1}function oh(i,r,e){let t=e.uniforms[`f${e.id}_texture`];if(!t)return!1;let o=!1,n=i;if("image"in n){let a=n.image,s=r.image(a),l=t;l.image instanceof pr||l.image.deref(),l.image=s}if("video"in n){let a=n.video,s=r.video(a),l=t;l.image instanceof pr||l.image.deref(),l.image=s}if("wrapping"in n){let a=t;a.wrap=n.wrapping}if("minFilter"in n){let a=t;a.minFilter=n.minFilter}if("magFilter"in n){let a=t;a.magFilter=n.magFilter}if("rotation"in n&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(n.rotation??0)*gN.DEG2RAD,o;if("repeat"in n||"offset"in n||"rotation"in n){let a="mat",s=e.uniforms[`f${e.id}_${a}`];"repeat"in n&&(s.repeat=n.repeat),"offset"in n&&(s.offset=n.offset),"rotation"in n&&(s.rotation=n.rotation??0),s.updateMatrix()}return o}function iv(i,r,e,t){let o=!1;for(let[n,a]of Object.entries(i)){if(n==="bumpMap"||n==="roughnessMap"){o=!0;continue}if(!n||a===void 0)continue;if(ih(n,e,t,r)){n==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=t.visible;let s=e.uniforms[`f${e.id}_${n}`];if(!!s&&!(s instanceof wi))switch(o=o||SN(e,n,a),s.constructor){case He:if(typeof a=="string"){let l=r.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Oi?s.value=new At(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case tr:if(typeof a=="string"){let l=r.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Oi?s.value=new At(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case lt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case Gt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case Yt:{oh(a,r,e);break}case kr:{s.value=a.map(l=>new xN(...l));break}default:{s.value=a;break}}}return o}var Ti=(i,r,e)=>Math.max(0,Math.min(1,Number(r.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,Ci=class{constructor(r,e,t,o,n){this.id=r;this.uuid=e;this.data=t;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in t)ih(a,this,t,n)}get type(){return this.data.type}static create(r,e,t,o){if(t.type==="light")return Kt.createLightLayer(r,e,t,o);if(t.type==="texture"||t.type==="video"){let n=t.type==="texture"?o.uiBuffer(t.texture.image)??o.image(t.texture.image):o.video(t.texture.video),a=new cn(n,t.texture.wrapping,t.texture.minFilter??1008,t.texture.magFilter??1006),s=new Gu(n),l=new Fu(t.texture.repeat,t.texture.offset,t.texture.rotation??0),c=new se(t.crop?1:0),u=new Re(t.projection??0),p=new Re(["x","y","z"].indexOf(t.axis)??0),d=new Re(t.side??0),f=new lt(t.size?new Wr(t.size[0],t.size[1]):new Wr(100,100)),h=new se(t.blending??0),m=new se(Ti(t.alpha,o)),y=new Re(t.mode??0),b=new ft(t.isMask??!1),v=new Pi(a,s,c,u,p,d,f,h,l,m,y,b),w=new Ue(v.calpha,"f");return new ot(r,e,t,{texture:a,textureSize:s,crop:c,projection:u,axis:p,side:d,size:f,blending:h,mat:l,alpha:m,mode:y,isMask:b},v,y,w,b,o)}else if(t.type==="matcap"){let n=o.image(t.texture.image),a=new cn(n,t.texture.wrapping,t.texture.minFilter??1008,t.texture.magFilter??1006),s=new se(Ti(t.alpha,o)),l=new Re(t.mode??0),c=new ft(t.isMask??!1),u=new se((t.texture.rotation??0)*wN.DEG2RAD),p=new Ka(a,s,l,c,u),d=new Ue(p.calpha,"f");return new ot(r,e,t,{texture:a,alpha:s,mode:l,isMask:c,rotation:u},p,l,d,c,o)}else if(t.type==="displace")if(t.displacementType==="noise"){let n=new Gt(new mo(...t.offset)),a=new se(t.scale??10),s=new se(t.intensity??8),l=new se(t.movement??1),c=new Re(t.noiseType??0),u=new Re(t.voronoiStyle??0),p=new se(t.smoothness??.5),d=new se(t.seed??0),f=new se(t.highCut??1),h=new se(t.lowCut??0),m=new Re(t.quality??1),y=new os(s,l,n,u,p,d,f,h,m,a,c);return new xl(r,e,t,{offset:n,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:u,smoothness:p,seed:d,highCut:f,lowCut:h,quality:m},y,o)}else throw new Error;else return TN(r,e,t,o)}updateByOp(r,e,t){let o=r;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props||"noiseType"in o.props?(t.scene.markNeedsUpdateRendererDirty(),!0):iv(o.props,t.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?oh(o.props,t.shared,this):!0;return!1}dispose(){if(PN(this)){let r=this.uniforms[`f${this.id}_texture`];if(!r)return!1;let e=r;e.image instanceof pr||e.image.deref()}}hasValueByKey(r){return this.uniforms[r]!==void 0}hasValue(r){return this.hasValueByKey(`f${this.id}_${r}`)}setValue(r,e){let t=`f${this.id}_${r}`;this.hasValueByKey(t)&&e!==void 0&&(this.uniforms[t].value=e)}getNode(r){let e=`f${this.id}_${r}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(r){let e=`f${this.id}_${r}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(r){let t=/f\d+_(.*)/.exec(r);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${r}`)}getNames(){let r=[];for(let e in this.uniforms){let t=this.getName(e);t&&r.push(t)}return r}},ot=class extends Ci{constructor(e,t,o,n,a,s,l,c,u){super(e,t,o,n,u);this.params=n;this.color=a;this.mode=s;this.alpha=l;this.isMask=c}},xl=class extends Ci{constructor(e,t,o,n,a,s){super(e,t,o,n,s);this.position=a}},Kt=class extends Ci{constructor(e,t,o,n,a,s){super(e,t,o,a,s);this.node=n}static createLightLayer(e,t,o,n){let a,s=new se(Ti(o.alpha,n)),l=new Re(o.mode),c=new se(o.bumpMapIntensity),u=new se(Ti(o.alphaOverride,n)),p;if(!o.visible)a=new ko,p={};else if(o.category==="lambert"){a=new hl;let d=new He(n.color(o.emissive)??0),f=new ft(o.occlusion??!0);p={emissive:d,occlusion:f},a.emissive=d,a.occlusion=f}else if(o.category==="toon"){a=new gl;let d=new se(o.shininess??30),f=new He(n.color(o.specular)??1118481);p={shininess:d,specular:f},a.shininess=d,a.specular=f}else if(o.category==="physical"){a=new yl;let d=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new ft(o.occlusion??!0);p={roughness:d,metalness:f,reflectivity:h,occlusion:m},a.roughness=d,a.metalness=f,a.reflectivity=h,a.occlusion=m}else{a=new ml;let d=new se(o.shininess??30),f=new He(o.specular!==void 0?n.color(o.specular)??1118481:1118481),h=new ft(o.occlusion??!0);p={shininess:d,specular:f,occlusion:h},a.shininess=d,a.specular=f,a.occlusion=h}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=c,a.alphaOverride=u,p.alpha=a.shadingAlpha,p.mode=a.shadingBlend,p.bumpMapIntensity=a.bumpMapIntensity,p.alphaOverride=a.alphaOverride,new Kt(e,t,o,a,p,n)}get category(){return this.node.category}};function PN(i){let r=i instanceof Ci?i.type:i;return r==="texture"||r==="video"||r==="displace_map"||r==="matcap"}function Pr(i){return{alpha:new se(i.alpha??1),mode:new Re(i.mode??0),isMask:new ft(i.isMask??!1)}}function ON(i,r,e,t,o){switch(i.type){case"color":{let n=new He(t.color??mt),a=Pr(t),s=new un(n,a.alpha),l=new Ue(s.calpha,"f");return new ot(r,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let n=new He(t.color??16777215),a=new se(t.bias??.1),s=new se(t.scale??1),l=new se(t.intensity??2),c=new se(t.factor??1),u=Pr(t),p=new fl(n,a,s,l,c,u.alpha,u.mode,u.isMask),d=new Ue(p.calpha,"f");return new ot(r,e,i,{color:n,bias:a,scale:s,intensity:l,factor:c,...u},p,u.mode,d,u.isMask,o)}case"rainbow":{let n=new se(t.filmThickness??30),a=new se(t.movement??0),s=new Gt(t.wavelengths??new mo(0,0,0)),l=new se(t.noiseStrength??0),c=new se(t.noiseScale??1),u=new Gt(t.offset??new mo(0,0,0)),p=Pr(t),d=new es(n,a,s,l,c,u,p.alpha,p.isMask),f=new Ue(d.calpha,"f");return new ot(r,e,i,{filmThickness:n,movement:a,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...p},d,p.mode,f,p.isMask,o)}case"transmission":{let n=new se(t.thickness??10),a=new se(t.ior??1.5),s=new se(t.roughness??.5),l=Ae.transmissionSize,c=Ae.transmissionRenderTarget,u=Ae.transmissionRenderTargetDepth,p=window.innerWidth,d=window.innerHeight,f=p>=d?new lt(d/p,1):new lt(1,p/d),h=Pr(t),m=new rs(n,a,s,l,c,u,f,h.alpha),y=new Ue(m.calpha,"f");return new ot(r,e,i,{thickness:n,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let n=new Re(t.positioning??0),a;t.colors?a=new kr(t.colors.length,t.colors):(a=new kr(10,new ns(0,0,0,1)),a.value[1]=new ns(1,1,1,1));let s;t.steps?s=new Ur(t.steps.length,t.steps):(s=new Ur(10,1),s.value[0]=0);let l=new Gt(t.source??new mo(0,0,0)),c=new ft(t.isWorldSpace??!0),u=new se(t.noiseStrength??0),p=new se(t.noiseScale??1),d=new tr(t.shadowColor),f=new Gt(t.offset??new mo(0,0,0)),h=Pr(t),m=new ts(n,a,s,l,c,u,p,d,f,h.alpha),y=new Ue(m.calpha,"f");return new ot(r,e,i,{positioning:n,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:p,shadowColor:d,offset:f,...h},m,h.mode,y,h.isMask,o)}case"outline":{let n=new He(t.outlineColor??16777215),a=new He(t.contourColor??16777215),s=new se(t.outlineWidth??.1),l=new se(t.contourWidth??.1),c=new se(t.outlineThreshold??.1),u=new se(t.contourThreshold??.1),p=new se(t.outlineSmoothing??.1),d=new se(t.contourFrequency??.1),f=new Gt(t.contourDirection??new mo(0,1,0)),h=new ft(t.positionalLines??!1),m=new ft(t.compensation??!0),y=Ae.normalRenderTarget,b=Ae.normalRenderTargetDepth,v=Ae.pixelRatioNode,w=Ae.resolution,O=Pr(t),S=new Za(n,a,s,l,c,u,p,d,f,h,m,w,y,b,v,O.alpha),T=new Ue(S.calpha,"f");return new ot(r,e,i,{outlineColor:n,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:p,contourFrequency:d,contourDirection:f,positionalLines:h,compensation:m,...O},S,O.mode,T,O.isMask,o)}case"depth":{let n=new Re(t.gradientType??0),a=new ft(t.smooth??!1),s=new se(t.near??50),l=new se(t.far??200),c=new se(t.isVector??1),u=new se(t.isWorldSpace??0),p=new Gt(t.origin??new mo),d=new Gt(t.direction??new mo),f;t.colors?f=new kr(t.colors.length,t.colors):(f=new kr(2,new ns(0,0,0,1)),f.value[1]=new ns(1,1,1,1));let h;t.steps?h=new Ur(t.steps.length,t.steps):(h=new Ur(2,1),h.value[0]=0);let m=Pr(t),y=new Xa(n,a,s,l,c,u,p,d,f,h,m.alpha,m.isMask),b=new Ue(y.calpha,"f");return new ot(r,e,i,{gradientType:n,smooth:a,near:s,far:l,isVector:c,isWorldSpace:u,origin:p,direction:d,colors:f,steps:h,...m},y,m.mode,b,m.isMask,o)}case"noise":{let n=new se(t.scale??1),a=new Gt(t.size??new mo(100,100,100)),s=new se(t.move??1),l=new lt(t.fA??new Wr(1.7,9.2)),c=new lt(t.fB??new Wr(8.3,2.8)),u=new lt(t.distortion??new Wr(1,1)),p=new tr(t.colorA),d=new tr(t.colorB),f=new tr(t.colorC),h=new tr(t.colorD),m=new Re(t.noiseType??0),y=new Re(t.voronoiStyle??0),b=new se(t.highCut??1),v=new se(t.lowCut??0),w=new se(t.smoothness??.5),O=new se(t.seed??.5),S=new Re(t.quality??1),T=Pr(t),M=new Qa(n,a,s,l,c,u,p,d,f,h,T.alpha,m,T.isMask,y,b,v,w,O,S),g=new Ue(M.calpha,"f");return new ot(r,e,i,{scale:n,size:a,move:s,fA:l,fB:c,distortion:u,colorA:p,colorB:d,colorC:f,colorD:h,noiseType:m,...T,voronoiStyle:y,highCut:b,lowCut:v,smoothness:w,seed:O,quality:S},M,T.mode,g,T.isMask,o)}case"normal":{let n=new Gt(t.cnormal??new mo(1,1,1)),a=Pr(t),s=new Wa(n,a.alpha),l=new Ue(s.calpha,"f");return new ot(r,e,i,{cnormal:n,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let n=new Re(t.gradientType??0),a=new ft(t.smooth??!1),s;t.colors?s=new kr(t.colors.length,t.colors):(s=new kr(10,new ns(0,0,0,1)),s.value[1]=new ns(1,1,1,1));let l;t.steps?l=new Ur(t.steps.length,t.steps):(l=new Ur(10,1),l.value[0]=0);let c=new lt(t.offset??new Wr(0,0)),u=new lt(t.morph??new Wr(0,0)),p=new se(t.angle??0),d=Pr(t),f=new Ya(n,a,s,l,c,u,p,d.alpha,d.isMask),h=new Ue(f.calpha,"f");return new ot(r,e,i,{gradientType:n,smooth:a,colors:s,steps:l,offset:c,morph:u,angle:p,...d},f,d.mode,h,d.isMask,o)}case"pattern":{let n=new Re(t.style??0),a=new Re(t.projection??0),s=new Re(["x","y","z"].indexOf(t.axis)??0),l=new se(t.blending??0),c=new lt(t.offset??new Wr(0,0)),u=new tr(t.colorA),p=new tr(t.colorB),d=new lt(t.frequency??new Wr(10,10)),f=new se(t.size??.5),h=new se(t.variation??0),m=new se(t.smoothness??.5),y=new se(t.zigzag??0),b=new se(t.rotation??0),v=new lt(t.vertical??new Wr(0,1)),w=new lt(t.horizontal??new Wr(0,1)),O=new Re(t.sides??6),S=Pr(t),T=new Ja(n,a,s,l,c,u,p,d,f,h,m,y,b,v,w,O,S.alpha,S.isMask),M=new Ue(T.calpha,"f");return new ot(r,e,i,{style:n,projection:a,axis:s,blending:l,offset:c,colorA:u,colorB:p,frequency:d,size:f,variation:h,smoothness:m,zigzag:y,rotation:b,vertical:v,horizontal:w,sides:O,...S},T,S.mode,M,S.isMask,o)}default:{let n=new He(1,0,0,1),a=Pr(t),s=new un(n,a.alpha),l=new Ue(s.calpha,"f");return new ot(r,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}}}function TN(i,r,e,t){let o=ov(e,t);return ON(e,i,r,o,t)}function ih(i,r,e,t){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let o=r.uniforms[`f${r.id}_intensity`];return o?(o.value=e.intensity*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let o=r.uniforms[`f${r.id}_alpha`];if(!o)return;if(o.value=Ti(e.alpha,t)*(e.visible?1:0),e.type==="outline"&&i==="visible"){let n=r.uniforms[`f${r.id}_compensation`];n&&(n.value=e.compensation&&e.visible)}return o}}function Wu(i,r){let e=0,t=i.layers.find(o=>o.data.type==="light");if(t){let o=t.data,n=Number(r.getVariable(o.alphaOverride));if((typeof o.alphaOverride=="string"?n/100:o.alphaOverride)<1)return!0}for(let o of i.layers){if(o.data.type!=="displace"&&o.data.isMask)return!0;if(o.data.type!=="displace"&&"alpha"in o.data&&o.data.type!=="light"&&o.data.type!=="fresnel"&&o.data.type!=="texture"&&o.data.type!=="matcap"&&o.data.type!=="rainbow"&&o.data.type!=="outline"&&o.data.type!=="pattern"){let n=o.data.visible?o.data.alpha:0;if(typeof n=="string"&&(n=Math.max(0,Math.min(1,Number(r.getVariable(n)??100)/100))),n===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let a of o.data.colors)if(a[3]<1){n=a[3];break}}else if(n===1&&o.data.type==="noise"){let a=r.color(o.data.colorA).a,s=r.color(o.data.colorB).a,l=r.color(o.data.colorC).a,c=r.color(o.data.colorD).a,u=Math.min(a,Math.min(s,Math.min(l,c)));u<1&&(n=u)}e+=(1-e)*n}}return e<1}var or=class extends CN{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.shadersPatchedForShapeBlend=!1;this.nodeContextUuid=0;this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return""}},qu=class extends or{constructor(e,t,o,n){super();this.flatShading=e;this.side=t;this.wireframe=o;this.root=n}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,o,n){return this.root.getFlavor(e,t,o,n)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,t,o){this.root.updateByOp(e,t,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},pn=class extends or{constructor(e,t,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.needsJitter=t.shared.needsJitter,qe.startContext(this),this.reset0(e,t),qe.endContext(this)}get nodeMaterial(){return this}getFlavor(e,t,o,n){let a=o?6:(e?3:0)+t;if(a+=((n?.resolutionLevel??0)-(n?.useChildrenColors?4:0))*7,a===0)return this;this.flavors===void 0&&(this.flavors=[]),a-=1;let s=this.flavors[a];return s===void 0&&(s=new qu(e,t,o,this),s.needsJitter=this.needsJitter,this.flavors[a]=s,s.flatShading=e,s.side=t,s.updateAfterBuild(),n&&(s.defines.SHAPEBLEND=n.resolutionLevel,s.defines.SHAPEBLEND_C=n.useChildrenColors?1:0)),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,t,o=!1){qe.startContext(this),(this.data!==e||o)&&this.reset0(e,t),qe.endContext(this)}reset0(e,t){this.data=e;let o=e.layers??Pt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(n=>Ci.create(this.layerIdGen++,n.id,n.data,t.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(t.shared),this.transparent=Wu(e,t.shared),this.saveVariableLocations(t)}onVariableUpdate(e,t,o){if(e[0]==="alphaOverride")this.transparent=Wu(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));else if(e[0]==="layer"){let n=e[1],a=e[2];if(n&&a){let s=this.layers.find(l=>l.uuid===n);s?.hasValue(a)&&(a==="alpha"?(this.transparent=Wu(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(t)/100,1)))):s.setValue(a,t))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers.find(o=>o.data.type==="light");t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(o=>{"alpha"in o.data&&typeof o.data.alpha=="string"&&e.shared.getVariable(o.data.alpha,["material",this.uuid,"layer",o.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(t=>t instanceof Kt),this.lightLayer===void 0&&(this.lightLayer=new Kt(0,"",{...bt.defaultData("light","phong"),visible:!1},new ko,{},e)),this.dispose();for(let t of this.flavors)t&&t.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}applyTextureMaps(){let e=this.layers.find(a=>a instanceof Kt);if(!e)return;let t=e.data,o=t.bumpMap,n=t.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let a=0;a<this.layers.length;++a){let s=this.layers[a];s instanceof ot&&s.color instanceof Pi&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===n&&(e.node.roughnessMap=s.color))}}updateByOp(e,t,o){if(qe.startContext(this),t!==void 0?this.data=t:t=this.data,this.transparent=Wu(t,o.shared),e.path[0]==="layers"){let n=o.shared,a=e.path[1];if(a===void 0)o.scene.markNeedsUpdateRendererDirty(),this.reset0(t,o);else{e.type===0&&e.props.occlusion!==void 0&&o.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(l=>l.uuid===a);if(s){let l=t.layers.data(a),c;e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?c={...e.props,alpha:Ti(e.props.alpha,n,["material",this.uuid,"layer",a,"alpha"])}:c={...e.props,alphaOverride:Ti(e.props.alphaOverride,n,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...c?{props:c}:{},path:e.path.slice(2)},l,o)&&this.reset0(t,o)}}}else this.reset0(t,o);qe.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof ot?t.color.mask=void 0:t instanceof Kt&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof ot&&t.isMask.value&&t.data.visible&&e>0){let o=e-1,n=this.layers[o];n instanceof Kt?n.node.mask=new _t(t.color,t.alpha,_t.MUL):n instanceof ot&&(n.isMask.value||(n.color.mask=new _t(t.color,t.alpha,_t.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof ot),t=this.layers.findIndex(o=>o instanceof Kt);if(e!==-1&&e<t){let o=this.layers[e].color;for(let n=e+1;n<t;++n){let a=this.layers[n];if(a instanceof ot){if(a.isMask.value)continue;o=new Ha(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Ue("outgoingLight","f"),t=this.layers.findIndex(o=>o instanceof Kt);if(this.layers.length>t+1){for(let o=t+1;o<this.layers.length;++o){let n=this.layers[o];if(n instanceof ot){if(n.isMask.value)continue;e=new Ha(e,n.color,n.alpha,n.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof xl);if(e.length>0){let t=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(t=new _t(t,e[o].position,_t.ADD),t=new _t(t,new se(.5).setReadonly(!0),_t.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.shapeBlendhack&&this.shapeBlendhack(this),e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,t){let o=(n,a,s)=>Math.min(Math.max(n,a),s);for(let n of this.layers)if(n.type==="displace"){let a=o(n.uniforms[`f${n.id}_intensity`].value,e,t);n.uniforms[`f${n.id}_intensity`].value=a}}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new Ua;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let t of this.flavors)t&&t.updateAfterBuild();return this.shadersPatchedForShapeBlend=!1,this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof ot){let t=e.params.texture;if(t instanceof cn&&!t.image.loaded)return!1}return!0}};Object.defineProperties(or.prototype,{properties:{get:function(){return this.fragment.properties}}});var fn=class extends pn{constructor(r,e,t){super(r,e,!1),this.uuid=t,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var nv=new Map;function av(i){if(typeof i=="string")return i;let r=nv.get(i);return r||(r={url:URL.createObjectURL(new Blob([i]))},nv.set(i,r)),r.url}var AN,sv=new Promise(i=>{AN=i});var lv;sv.then(i=>lv=i);var hn=class{constructor({src:r,volume:e,delay:t,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let n;typeof r=="string"?n={src:r}:n={src:av(r),format:"wav"},this.sound=new lv.Howl(n),this.sound.on("end",this.onEnd),this.src=r,e!==void 0&&(this.volume=e),t!==void 0&&(this.delay=t),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(r){this._volume=r,this.sound.volume(r)}get loop(){return this._loop}set loop(r){this._loop=r,this.loopsRemaining=r}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(r,e=1e3){r?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},r)):this.sound.fade(this._volume,0,e)}on(r,e,t){this.sound.on(r,e,t)}off(r,e,t){this.sound.off(r,e,t)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(r=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};import{Box2 as MN,Vector2 as mn,Path as cv,Shape as IN,ShapeUtils as EN,Color as NN}from"three";var $u=class{constructor(){this.type="ShapePath";this.color=new NN;this.subPaths=[];this.currentPath=null}moveTo(r,e){return this.currentPath=new cv,this.subPaths.push(this.currentPath),this.currentPath.moveTo(r,e),this}lineTo(r,e){return this.currentPath?.lineTo(r,e),this}quadraticCurveTo(r,e,t,o){return this.currentPath?.quadraticCurveTo(r,e,t,o),this}bezierCurveTo(r,e,t,o,n,a){return this.currentPath?.bezierCurveTo(r,e,t,o,n,a),this}splineThru(r){return this.currentPath?.splineThru(r),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function o(m,y,b,v){let w=m.x,O=y.x,S=b.x,T=v.x,M=m.y,g=y.y,D=b.y,E=v.y,I=(T-S)*(M-D)-(E-D)*(w-S),N=(O-w)*(M-D)-(g-M)*(w-S),_=(E-D)*(O-w)-(T-S)*(g-M),R=I/_,V=N/_;if(_===0&&I!==0||R<=0||R>=1||V<0||V>1)return null;if(I===0&&_===0){for(let U=0;U<2;U++)if(n(U===0?b:v,m,y),t.loc===e.ORIGIN){let B=U===0?b:v;return{x:B.x,y:B.y,t:t.t}}else if(t.loc===e.BETWEEN){let B=+(w+t.t*(O-w)).toPrecision(10),q=+(M+t.t*(g-M)).toPrecision(10);return{x:B,y:q,t:t.t}}return null}else{for(let q=0;q<2;q++)if(n(q===0?b:v,m,y),t.loc===e.ORIGIN){let j=q===0?b:v;return{x:j.x,y:j.y,t:t.t}}let U=+(w+R*(O-w)).toPrecision(10),B=+(M+R*(g-M)).toPrecision(10);return{x:U,y:B,t:R}}}function n(m,y,b){let v=b.x-y.x,w=b.y-y.y,O=m.x-y.x,S=m.y-y.y,T=v*S-O*w;if(m.x===y.x&&m.y===y.y){t.loc=e.ORIGIN,t.t=0;return}if(m.x===b.x&&m.y===b.y){t.loc=e.DESTINATION,t.t=1;return}if(T<-Number.EPSILON){t.loc=e.LEFT;return}if(T>Number.EPSILON){t.loc=e.RIGHT;return}if(v*O<0||w*S<0){t.loc=e.BEHIND;return}if(Math.sqrt(v*v+w*w)<Math.sqrt(O*O+S*S)){t.loc=e.BEYOND;return}let M;v!==0?M=O/v:M=S/w,t.loc=e.BETWEEN,t.t=M}function a(m,y){let b=[],v=[];for(let w=1;w<m.length;w++){let O=m[w-1],S=m[w];for(let T=1;T<y.length;T++){let M=y[T-1],g=y[T],D=o(O,S,M,g);D!==null&&b.find(E=>E.t<=D.t+Number.EPSILON&&E.t>=D.t-Number.EPSILON)===void 0&&(b.push(D),v.push(new mn(D.x,D.y)))}}return v}function s(m,y,b){let v=new mn;y.getCenter(v);let w=[];return b.forEach(O=>{O.boundingBox.containsPoint(v)&&a(m,O.points).forEach(T=>{w.push({identifier:O.identifier,isCW:O.isCW,point:T})})}),w.sort((O,S)=>O.point.x-S.point.x),w}function l(m,y,b,v,w){(w==null||w==="")&&(w="nonzero");let O=new mn;m.boundingBox.getCenter(O);let S=[new mn(b,O.y),new mn(v,O.y)],T=s(S,m.boundingBox,y);T.sort((N,_)=>N.point.x-_.point.x);let M=[],g=[];T.forEach(N=>{N.identifier===m.identifier?M.push(N):g.push(N)});let D=M[0].point.x,E=[],I=0;for(;I<g.length&&g[I].point.x<D;)E.length>0&&E[E.length-1]===g[I].identifier?E.pop():E.push(g[I].identifier),I++;if(E.push(m.identifier),w==="evenodd"){let N=E.length%2===0,_=E[E.length-2];return{identifier:m.identifier,isHole:N,for:_}}else if(w==="nonzero"){let N=!0,_=null,R=null;for(let V=0;V<E.length;V++){let U=E[V];y[U]&&(N?(R=y[U].isCW,N=!1,_=U):R!==y[U].isCW&&(R=y[U].isCW,N=!0))}return{identifier:m.identifier,isHole:N,for:_}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let c=0,u=999999999,p=-999999999,d=[];this.subPaths.forEach(m=>{let y=m.getPoints(),b=-999999999,v=999999999,w=-999999999,O=999999999;for(let S=0;S<y.length;S++){let T=y[S];T.y>b&&(b=T.y),T.y<v&&(v=T.y),T.x>w&&(w=T.x),T.x<O&&(O=T.x)}p<=w&&(p=w+1),u>=O&&(u=O-1),y.length&&d.push({curves:m.curves,points:y,isCW:EN.isClockWise(y),identifier:c++,boundingBox:new MN(new mn(O,v),new mn(w,b))})});let f=d.map(m=>l(m,d,u,p,this.userData?.style.fillRule)),h=[];return d.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let b=new IN;b.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let O=d[w.identifier],S=new cv;S.curves=O.curves,b.holes.push(S)}}),h.push(b)}}),h}};var nh=!1,dv,ah=new Promise(i=>{dv=i}),uv=!1;var Xu;function pv(){if(nh=!0,uv)return;if(Xu)return Xu;async function i(){let e=await import("./opentype.js");dv(e),uv=!0}return Xu=i(),Xu}var bl=class{async load(r,e,t=()=>{}){let{load:o}=await ah;o(r,(n,a)=>{n||!a?t(n??"Something went wrong"):e(a)})}async parse(r){let{parse:e,Bidi:t}=await ah;try{let o=e(r),n=new t,a=s=>o.charToGlyphIndex(s.char);return n.registerModifier("glyphIndex",null,a),n.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:n}}catch(o){console.error(o)}}};async function DN(i){return await(await fetch(i)).arrayBuffer()}var _N=new bl;async function sh(i){let r,e,t=!1;if(i.url?(r=await DN(i.url),e=i.url,t=i.url.startsWith("/")):i.data&&(r=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),r)if(nh){let o=await _N.parse(r);if(o)return{font:o.font,url:e,intercepted:t,arr:r,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:t,arr:r,bidi:null}}import{CubicBezierCurve as RN,LineCurve as LN,QuadraticBezierCurve as BN}from"three";function VN(i,r){return r.state.glyphIndex===i||r.state.fina===i||r.state.medi===i||r.state.init===i}var Yu=class{constructor(r){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=r.isUserFont??!1,this._loadingPromise=sh(r).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(r){this._isLoaded=!1,this._isUserFont=r.isUserFont??!1,this._loadingPromise=sh(r).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(r,e,t){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let n=o.tokenizer.tokens,a=[],s=0,l=t.length===n.length;for(let c=0;c<t.length;c++){let u=t[c].index,p=String.fromCharCode(t[c].unicode),d=n[s];if(VN(u,d)||l)a.push({char:p,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),s++;else{let f=d.char,h="",m=[d.state.glyphIndex],y=[],b=!1;for(;!b;)s++,h=e.charAt(s),f+=h,m.push(r.charToGlyphIndex(h)),y=r.stringToGlyphs(f),y.length===1&&y[0].index===u&&(b=!0),s>e.length&&(b=!0);a.push({char:p,index:u,replacements:m,replacementChars:Array.from(f)}),s++}}return a}generateShapes(r,e,t){if(!this._isLoaded)return;let o=this.font,n=e.fontSize/this.unitsPerEm,a=e.fontSize*e.lineHeight,s=r.map(v=>this.getTextWidth(v,e)),l=typeof e.width=="string"?Number(t.getVariable(e.width)):e.width,c=typeof e.height=="string"?Number(t.getVariable(e.height)):e.height,u=this.getCharWidth(`
2285
+ `)}return t}};import{VideoTexture as JN,Texture as eD}from"three";var Wu=class{constructor(r=1e3*10){this.timeout=r;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...r){}remove(r){let e=this.cache.get(r);e&&(this.dispose(r,e.data),this.cache.delete(r),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let r=Date.now(),e=this.head.next;for(;e.time<r-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(r){return this.cache.get(r)?.data}load(r){let e=Date.now(),t=this.cache.get(r);return t===void 0?(t={data:this.create(r),src:r,time:e,next:null,prev:null},this.cache.set(r,t)):(t.time=e,t.prev.next=t.next,t.next.prev=t.prev),t.prev=this.tail.prev,t.next=this.tail,this.tail.prev.next=t,this.tail.prev=t,this.scheduleCleanup(),t.data}};var uh=class extends Wu{create(r){return URL.createObjectURL(new Blob([r]))}dispose(r,e){URL.revokeObjectURL(e)}},ch;function Sv(i){return typeof i=="string"?i:(ch||(ch=new uh),ch.load(i))}var qu=class{constructor(r,e){this.data=r;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},$u=class{constructor(){this.cache=new Map}remove(r){if(this.cache.delete(r.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(r){let e=this.cache.get(r);return e===void 0&&(e=this.create(r),this.cache.set(r,e)),e.refCount+=1,e}};var is=class extends qu{constructor(e,t){super(e,t.imageHolderCache);this.data=e;this.shared=t;this.loaded=!1;this.isVideo=!1;this.isBuffer=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;for(let n of Object.values(this._cache))for(let a of Object.values(n))for(let s of Object.values(a))s&&(s.image=this.img,s.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var o=new FileReader;o.readAsDataURL(new Blob([e],{type:"video/mp4"}));let n;await new Promise(a=>{o.onloadend=s=>{n=s.target?.result,a(null)}}),this.img.src=n}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=Sv(e),this.img.onload=t,await new Promise(n=>{this.img.onload=()=>{t(),n(null)}})}getTexture(e,t=1008,o=1006){let n=this._cache[e]?.[t]?.[o];if(n)return n;{let a;return this.isBuffer?a=this.img.texture:this.isVideo?a=new JN(this.img,void 0,e,e):a=new eD(this.img,void 0,e,e,o,t),this.loaded&&(a.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][t]===void 0&&(this._cache[e][t]={}),this._cache[e][t][o]=a,a}}setNeedsUpdate(e){for(let t of Object.values(this._cache))for(let o of Object.values(t))for(let n of Object.values(o))n&&(n.needsUpdate=e)}disposeTextures(){for(let[e,t]of Object.entries(this._cache))for(let[o,n]of Object.entries(t))for(let[a,s]of Object.entries(n))s?.dispose(),this._cache[e]!==void 0&&this._cache[e][o]!==void 0&&(this._cache[e][o][a]=void 0)}dispose(){super.dispose(),this.disposeTextures()}};var pr=class extends is{};import{Vector2 as Wo,Vector3 as ho,Vector4 as Xu}from"three";function jt(i,r){return r.color(i)}function wv(i,r){switch(i.type){case"fresnel":return oD(i,r);case"gradient":return iD(i,r);case"depth":return nD(i,r);case"normal":return aD(i,r);case"noise":return sD(i,r);case"rainbow":return lD(i,r);case"toon":return cD(i,r);case"outline":return uD(i,r);case"transmission":return dD(i,r);case"color":return rD(i,r);case"pattern":return pD(i,r)}}function tD(i){return{type:i.type}}function Hr(i,r){let{alpha:e,mode:t,isMask:o}=i,n=typeof e=="string"?(Number(r.getVariable(e))??100)/100:e;return{...tD(i),alpha:n,mode:t,isMask:o}}function rD(i,r){return{...Hr(i,r),color:jt(i.color,r)}}function oD(i,r){let{bias:e,scale:t,intensity:o,factor:n,color:a}=i;return{...Hr(i,r),color:jt(a,r),bias:e,scale:t,intensity:o,factor:n}}function iD(i,r){let{gradientType:e,smooth:t,colors:o,steps:n,angle:a,offset:s,morph:l}=i;return{...Hr(i,r),gradientType:e,smooth:t,colors:o.map(c=>new Xu(c[0],c[1],c[2],c[3])),num:o.length,steps:n,offset:new Wo(...s),morph:new Wo(...l),angle:a}}function nD(i,r){let{gradientType:e,near:t,far:o,isVector:n,isWorldSpace:a,origin:s,direction:l,colors:c,steps:u,smooth:p}=i;return{...Hr(i,r),gradientType:e,near:t,far:o,isVector:n,isWorldSpace:a,origin:new ho(...s),direction:l?new ho(...l):new ho(1,0,0),colors:c.map(d=>d!==void 0?new Xu(d[0],d[1],d[2],d[3]):new Xu(0,0,0,0)),steps:u.slice(0,c.length),smooth:p}}function aD(i,r){let{cnormal:e}=i;return{...Hr(i,r),cnormal:new ho(e[0],e[1],e[2])}}function sD(i,r){return{...Hr(i,r),scale:i.scale,move:i.move,fA:new Wo(...i.fA),fB:new Wo(...i.fB),size:new ho(...i.size),distortion:new Wo(...i.distortion),colorA:jt(i.colorA,r),colorB:jt(i.colorB,r),colorC:jt(i.colorC,r),colorD:jt(i.colorD,r),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}function lD(i,r){return{...Hr(i,r),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new ho(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new ho(...i.offset)}}function cD(i,r){return{...Hr(i,r),positioning:i.positioning,colors:i.colors.map(e=>new Xu(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new ho(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:jt(i.shadowColor,r),offset:new ho(...i.offset)}}function uD(i,r){return{...Hr(i,r),outlineColor:jt(i.outlineColor,r),contourColor:jt(i.contourColor,r),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new ho(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}function dD(i,r){return{...Hr(i,r),thickness:i.thickness,ior:i.ior,roughness:i.roughness}}function pD(i,r){return{...Hr(i,r),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new Wo(...i.offset),colorA:jt(i.colorA,r),colorB:jt(i.colorB,r),frequency:new Wo(...i.frequency),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new Wo(...i.vertical),horizontal:new Wo(...i.horizontal),sides:i.sides}}var Oi=class extends At{};import{MathUtils as fD,Vector4 as hD}from"three";var mD={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},yD={depth:["colors"]};function gD(i,r,e){if(r==="isMask")return!0;let t=mD[i.type],o=yD[i.type];if(o!==void 0){let n=i.color;if(o.includes(r)){let a=n[r]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return t!==void 0?t.includes(r):!1}function dh(i,r,e){let t=e.uniforms[`f${e.id}_texture`];if(!t)return!1;let o=!1,n=i;if("image"in n){let a=n.image,s=r.image(a),l=t;l.image instanceof pr||l.image.deref(),l.image=s}if("video"in n){let a=n.video,s=r.video(a),l=t;l.image instanceof pr||l.image.deref(),l.image=s}if("wrapping"in n){let a=t;a.wrap=n.wrapping}if("minFilter"in n){let a=t;a.minFilter=n.minFilter}if("magFilter"in n){let a=t;a.magFilter=n.magFilter}if("rotation"in n&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(n.rotation??0)*fD.DEG2RAD,o;if("repeat"in n||"offset"in n||"rotation"in n){let a="mat",s=e.uniforms[`f${e.id}_${a}`];"repeat"in n&&(s.repeat=n.repeat),"offset"in n&&(s.offset=n.offset),"rotation"in n&&(s.rotation=n.rotation??0),s.updateMatrix()}return o}function Pv(i,r,e,t){let o=!1;for(let[n,a]of Object.entries(i)){if(n==="bumpMap"||n==="roughnessMap"){o=!0;continue}if(!n||a===void 0)continue;if(ph(n,e,t,r)){n==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=t.visible;let s=e.uniforms[`f${e.id}_${n}`];if(!!s&&!(s instanceof wi))switch(o=o||gD(e,n,a),s.constructor){case He:if(typeof a=="string"){let l=r.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Oi?s.value=new At(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case tr:if(typeof a=="string"){let l=r.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Oi?s.value=new At(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case lt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case Gt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case Yt:{dh(a,r,e);break}case kr:{s.value=a.map(l=>new hD(...l));break}default:{s.value=a;break}}}return o}var Ti=(i,r,e)=>Math.max(0,Math.min(1,Number(r.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,Ci=class{constructor(r,e,t,o,n){this.id=r;this.uuid=e;this.data=t;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in t)ph(a,this,t,n)}get type(){return this.data.type}static create(r,e,t,o){if(t.type==="light")return Kt.createLightLayer(r,e,t,o);if(t.type==="texture"||t.type==="video"){let n=t.type==="texture"?o.uiBuffer(t.texture.image)??o.image(t.texture.image):o.video(t.texture.video),a=new cn(n,t.texture.wrapping,t.texture.minFilter??1008,t.texture.magFilter??1006),s=new ku(n),l=new Hu(t.texture.repeat,t.texture.offset,t.texture.rotation??0),c=new se(t.crop?1:0),u=new Re(t.projection??0),p=new Re(["x","y","z"].indexOf(t.axis)??0),d=new Re(t.side??0),f=new lt(t.size?new Wr(t.size[0],t.size[1]):new Wr(100,100)),h=new se(t.blending??0),m=new se(Ti(t.alpha,o)),y=new Re(t.mode??0),b=new ft(t.isMask??!1),v=new Pi(a,s,c,u,p,d,f,h,l,m,y,b),w=new Ue(v.calpha,"f");return new ot(r,e,t,{texture:a,textureSize:s,crop:c,projection:u,axis:p,side:d,size:f,blending:h,mat:l,alpha:m,mode:y,isMask:b},v,y,w,b,o)}else if(t.type==="matcap"){let n=o.image(t.texture.image),a=new cn(n,t.texture.wrapping,t.texture.minFilter??1008,t.texture.magFilter??1006),s=new se(Ti(t.alpha,o)),l=new Re(t.mode??0),c=new ft(t.isMask??!1),u=new se((t.texture.rotation??0)*xD.DEG2RAD),p=new Ka(a,s,l,c,u),d=new Ue(p.calpha,"f");return new ot(r,e,t,{texture:a,alpha:s,mode:l,isMask:c,rotation:u},p,l,d,c,o)}else if(t.type==="displace")if(t.displacementType==="noise"){let n=new Gt(new mo(...t.offset)),a=new se(t.scale??10),s=new se(t.intensity??8),l=new se(t.movement??1),c=new Re(t.noiseType??0),u=new Re(t.voronoiStyle??0),p=new se(t.smoothness??.5),d=new se(t.seed??0),f=new se(t.highCut??1),h=new se(t.lowCut??0),m=new Re(t.quality??1),y=new os(s,l,n,u,p,d,f,h,m,a,c);return new xl(r,e,t,{offset:n,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:u,smoothness:p,seed:d,highCut:f,lowCut:h,quality:m},y,o)}else throw new Error;else return SD(r,e,t,o)}updateByOp(r,e,t){let o=r;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props||"noiseType"in o.props?(t.scene.markNeedsUpdateRendererDirty(),!0):Pv(o.props,t.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?dh(o.props,t.shared,this):!0;return!1}dispose(){if(bD(this)){let r=this.uniforms[`f${this.id}_texture`];if(!r)return!1;let e=r;e.image instanceof pr||e.image.deref()}}hasValueByKey(r){return this.uniforms[r]!==void 0}hasValue(r){return this.hasValueByKey(`f${this.id}_${r}`)}setValue(r,e){let t=`f${this.id}_${r}`;this.hasValueByKey(t)&&e!==void 0&&(this.uniforms[t].value=e)}getNode(r){let e=`f${this.id}_${r}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(r){let e=`f${this.id}_${r}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(r){let t=/f\d+_(.*)/.exec(r);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${r}`)}getNames(){let r=[];for(let e in this.uniforms){let t=this.getName(e);t&&r.push(t)}return r}},ot=class extends Ci{constructor(e,t,o,n,a,s,l,c,u){super(e,t,o,n,u);this.params=n;this.color=a;this.mode=s;this.alpha=l;this.isMask=c}},xl=class extends Ci{constructor(e,t,o,n,a,s){super(e,t,o,n,s);this.position=a}},Kt=class extends Ci{constructor(e,t,o,n,a,s){super(e,t,o,a,s);this.node=n}static createLightLayer(e,t,o,n){let a,s=new se(Ti(o.alpha,n)),l=new Re(o.mode),c=new se(o.bumpMapIntensity),u=new se(Ti(o.alphaOverride,n)),p;if(!o.visible)a=new ko,p={};else if(o.category==="lambert"){a=new hl;let d=new He(n.color(o.emissive)??0),f=new ft(o.occlusion??!0);p={emissive:d,occlusion:f},a.emissive=d,a.occlusion=f}else if(o.category==="toon"){a=new gl;let d=new se(o.shininess??30),f=new He(n.color(o.specular)??1118481);p={shininess:d,specular:f},a.shininess=d,a.specular=f}else if(o.category==="physical"){a=new yl;let d=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new ft(o.occlusion??!0);p={roughness:d,metalness:f,reflectivity:h,occlusion:m},a.roughness=d,a.metalness=f,a.reflectivity=h,a.occlusion=m}else{a=new ml;let d=new se(o.shininess??30),f=new He(o.specular!==void 0?n.color(o.specular)??1118481:1118481),h=new ft(o.occlusion??!0);p={shininess:d,specular:f,occlusion:h},a.shininess=d,a.specular=f,a.occlusion=h}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=c,a.alphaOverride=u,p.alpha=a.shadingAlpha,p.mode=a.shadingBlend,p.bumpMapIntensity=a.bumpMapIntensity,p.alphaOverride=a.alphaOverride,new Kt(e,t,o,a,p,n)}get category(){return this.node.category}};function bD(i){let r=i instanceof Ci?i.type:i;return r==="texture"||r==="video"||r==="displace_map"||r==="matcap"}function Pr(i){return{alpha:new se(i.alpha??1),mode:new Re(i.mode??0),isMask:new ft(i.isMask??!1)}}function vD(i,r,e,t,o){switch(i.type){case"color":{let n=new He(t.color??mt),a=Pr(t),s=new un(n,a.alpha),l=new Ue(s.calpha,"f");return new ot(r,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let n=new He(t.color??16777215),a=new se(t.bias??.1),s=new se(t.scale??1),l=new se(t.intensity??2),c=new se(t.factor??1),u=Pr(t),p=new fl(n,a,s,l,c,u.alpha,u.mode,u.isMask),d=new Ue(p.calpha,"f");return new ot(r,e,i,{color:n,bias:a,scale:s,intensity:l,factor:c,...u},p,u.mode,d,u.isMask,o)}case"rainbow":{let n=new se(t.filmThickness??30),a=new se(t.movement??0),s=new Gt(t.wavelengths??new mo(0,0,0)),l=new se(t.noiseStrength??0),c=new se(t.noiseScale??1),u=new Gt(t.offset??new mo(0,0,0)),p=Pr(t),d=new es(n,a,s,l,c,u,p.alpha,p.isMask),f=new Ue(d.calpha,"f");return new ot(r,e,i,{filmThickness:n,movement:a,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...p},d,p.mode,f,p.isMask,o)}case"transmission":{let n=new se(t.thickness??10),a=new se(t.ior??1.5),s=new se(t.roughness??.5),l=Ae.transmissionSize,c=Ae.transmissionRenderTarget,u=Ae.transmissionRenderTargetDepth,p=window.innerWidth,d=window.innerHeight,f=p>=d?new lt(d/p,1):new lt(1,p/d),h=Pr(t),m=new rs(n,a,s,l,c,u,f,h.alpha),y=new Ue(m.calpha,"f");return new ot(r,e,i,{thickness:n,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let n=new Re(t.positioning??0),a;t.colors?a=new kr(t.colors.length,t.colors):(a=new kr(10,new ns(0,0,0,1)),a.value[1]=new ns(1,1,1,1));let s;t.steps?s=new Ur(t.steps.length,t.steps):(s=new Ur(10,1),s.value[0]=0);let l=new Gt(t.source??new mo(0,0,0)),c=new ft(t.isWorldSpace??!0),u=new se(t.noiseStrength??0),p=new se(t.noiseScale??1),d=new tr(t.shadowColor),f=new Gt(t.offset??new mo(0,0,0)),h=Pr(t),m=new ts(n,a,s,l,c,u,p,d,f,h.alpha),y=new Ue(m.calpha,"f");return new ot(r,e,i,{positioning:n,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:p,shadowColor:d,offset:f,...h},m,h.mode,y,h.isMask,o)}case"outline":{let n=new He(t.outlineColor??16777215),a=new He(t.contourColor??16777215),s=new se(t.outlineWidth??.1),l=new se(t.contourWidth??.1),c=new se(t.outlineThreshold??.1),u=new se(t.contourThreshold??.1),p=new se(t.outlineSmoothing??.1),d=new se(t.contourFrequency??.1),f=new Gt(t.contourDirection??new mo(0,1,0)),h=new ft(t.positionalLines??!1),m=new ft(t.compensation??!0),y=Ae.normalRenderTarget,b=Ae.normalRenderTargetDepth,v=Ae.pixelRatioNode,w=Ae.resolution,O=Pr(t),S=new Za(n,a,s,l,c,u,p,d,f,h,m,w,y,b,v,O.alpha),T=new Ue(S.calpha,"f");return new ot(r,e,i,{outlineColor:n,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:p,contourFrequency:d,contourDirection:f,positionalLines:h,compensation:m,...O},S,O.mode,T,O.isMask,o)}case"depth":{let n=new Re(t.gradientType??0),a=new ft(t.smooth??!1),s=new se(t.near??50),l=new se(t.far??200),c=new se(t.isVector??1),u=new se(t.isWorldSpace??0),p=new Gt(t.origin??new mo),d=new Gt(t.direction??new mo),f;t.colors?f=new kr(t.colors.length,t.colors):(f=new kr(2,new ns(0,0,0,1)),f.value[1]=new ns(1,1,1,1));let h;t.steps?h=new Ur(t.steps.length,t.steps):(h=new Ur(2,1),h.value[0]=0);let m=Pr(t),y=new Xa(n,a,s,l,c,u,p,d,f,h,m.alpha,m.isMask),b=new Ue(y.calpha,"f");return new ot(r,e,i,{gradientType:n,smooth:a,near:s,far:l,isVector:c,isWorldSpace:u,origin:p,direction:d,colors:f,steps:h,...m},y,m.mode,b,m.isMask,o)}case"noise":{let n=new se(t.scale??1),a=new Gt(t.size??new mo(100,100,100)),s=new se(t.move??1),l=new lt(t.fA??new Wr(1.7,9.2)),c=new lt(t.fB??new Wr(8.3,2.8)),u=new lt(t.distortion??new Wr(1,1)),p=new tr(t.colorA),d=new tr(t.colorB),f=new tr(t.colorC),h=new tr(t.colorD),m=new Re(t.noiseType??0),y=new Re(t.voronoiStyle??0),b=new se(t.highCut??1),v=new se(t.lowCut??0),w=new se(t.smoothness??.5),O=new se(t.seed??.5),S=new Re(t.quality??1),T=Pr(t),M=new Qa(n,a,s,l,c,u,p,d,f,h,T.alpha,m,T.isMask,y,b,v,w,O,S),g=new Ue(M.calpha,"f");return new ot(r,e,i,{scale:n,size:a,move:s,fA:l,fB:c,distortion:u,colorA:p,colorB:d,colorC:f,colorD:h,noiseType:m,...T,voronoiStyle:y,highCut:b,lowCut:v,smoothness:w,seed:O,quality:S},M,T.mode,g,T.isMask,o)}case"normal":{let n=new Gt(t.cnormal??new mo(1,1,1)),a=Pr(t),s=new Wa(n,a.alpha),l=new Ue(s.calpha,"f");return new ot(r,e,i,{cnormal:n,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let n=new Re(t.gradientType??0),a=new ft(t.smooth??!1),s;t.colors?s=new kr(t.colors.length,t.colors):(s=new kr(10,new ns(0,0,0,1)),s.value[1]=new ns(1,1,1,1));let l;t.steps?l=new Ur(t.steps.length,t.steps):(l=new Ur(10,1),l.value[0]=0);let c=new lt(t.offset??new Wr(0,0)),u=new lt(t.morph??new Wr(0,0)),p=new se(t.angle??0),d=Pr(t),f=new Ya(n,a,s,l,c,u,p,d.alpha,d.isMask),h=new Ue(f.calpha,"f");return new ot(r,e,i,{gradientType:n,smooth:a,colors:s,steps:l,offset:c,morph:u,angle:p,...d},f,d.mode,h,d.isMask,o)}case"pattern":{let n=new Re(t.style??0),a=new Re(t.projection??0),s=new Re(["x","y","z"].indexOf(t.axis)??0),l=new se(t.blending??0),c=new lt(t.offset??new Wr(0,0)),u=new tr(t.colorA),p=new tr(t.colorB),d=new lt(t.frequency??new Wr(10,10)),f=new se(t.size??.5),h=new se(t.variation??0),m=new se(t.smoothness??.5),y=new se(t.zigzag??0),b=new se(t.rotation??0),v=new lt(t.vertical??new Wr(0,1)),w=new lt(t.horizontal??new Wr(0,1)),O=new Re(t.sides??6),S=Pr(t),T=new Ja(n,a,s,l,c,u,p,d,f,h,m,y,b,v,w,O,S.alpha,S.isMask),M=new Ue(T.calpha,"f");return new ot(r,e,i,{style:n,projection:a,axis:s,blending:l,offset:c,colorA:u,colorB:p,frequency:d,size:f,variation:h,smoothness:m,zigzag:y,rotation:b,vertical:v,horizontal:w,sides:O,...S},T,S.mode,M,S.isMask,o)}default:{let n=new He(1,0,0,1),a=Pr(t),s=new un(n,a.alpha),l=new Ue(s.calpha,"f");return new ot(r,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}}}function SD(i,r,e,t){let o=wv(e,t);return vD(e,i,r,o,t)}function ph(i,r,e,t){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let o=r.uniforms[`f${r.id}_intensity`];return o?(o.value=e.intensity*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let o=r.uniforms[`f${r.id}_alpha`];if(!o)return;if(o.value=Ti(e.alpha,t)*(e.visible?1:0),e.type==="outline"&&i==="visible"){let n=r.uniforms[`f${r.id}_compensation`];n&&(n.value=e.compensation&&e.visible)}return o}}function Yu(i,r){let e=0,t=i.layers.find(o=>o.data.type==="light");if(t){let o=t.data,n=Number(r.getVariable(o.alphaOverride));if((typeof o.alphaOverride=="string"?n/100:o.alphaOverride)<1)return!0}for(let o of i.layers){if(o.data.type!=="displace"&&o.data.isMask)return!0;if(o.data.type!=="displace"&&"alpha"in o.data&&o.data.type!=="light"&&o.data.type!=="fresnel"&&o.data.type!=="texture"&&o.data.type!=="matcap"&&o.data.type!=="rainbow"&&o.data.type!=="outline"&&o.data.type!=="pattern"){let n=o.data.visible?o.data.alpha:0;if(typeof n=="string"&&(n=Math.max(0,Math.min(1,Number(r.getVariable(n)??100)/100))),n===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let a of o.data.colors)if(a[3]<1){n=a[3];break}}else if(n===1&&o.data.type==="noise"){let a=r.color(o.data.colorA).a,s=r.color(o.data.colorB).a,l=r.color(o.data.colorC).a,c=r.color(o.data.colorD).a,u=Math.min(a,Math.min(s,Math.min(l,c)));u<1&&(n=u)}e+=(1-e)*n}}return e<1}var or=class extends wD{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.shadersPatchedForShapeBlend=!1;this.nodeContextUuid=0;this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return""}},Ku=class extends or{constructor(e,t,o,n){super();this.flatShading=e;this.side=t;this.wireframe=o;this.root=n}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,o,n){return this.root.getFlavor(e,t,o,n)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,t,o){this.root.updateByOp(e,t,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},pn=class extends or{constructor(e,t,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.needsJitter=t.shared.needsJitter,qe.startContext(this),this.reset0(e,t),qe.endContext(this)}get nodeMaterial(){return this}getFlavor(e,t,o,n){let a=o?6:(e?3:0)+t;if(a+=((n?.resolutionLevel??0)-(n?.useChildrenColors?4:0))*7,a===0)return this;this.flavors===void 0&&(this.flavors=[]),a-=1;let s=this.flavors[a];return s===void 0&&(s=new Ku(e,t,o,this),s.needsJitter=this.needsJitter,this.flavors[a]=s,s.flatShading=e,s.side=t,s.updateAfterBuild(),n&&(s.defines.SHAPEBLEND=n.resolutionLevel,s.defines.SHAPEBLEND_C=n.useChildrenColors?1:0)),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,t,o=!1){qe.startContext(this),(this.data!==e||o)&&this.reset0(e,t),qe.endContext(this)}reset0(e,t){this.data=e;let o=e.layers??Pt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(n=>Ci.create(this.layerIdGen++,n.id,n.data,t.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(t.shared),this.transparent=Yu(e,t.shared),this.saveVariableLocations(t)}onVariableUpdate(e,t,o){if(e[0]==="alphaOverride")this.transparent=Yu(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));else if(e[0]==="layer"){let n=e[1],a=e[2];if(n&&a){let s=this.layers.find(l=>l.uuid===n);s?.hasValue(a)&&(a==="alpha"?(this.transparent=Yu(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(t)/100,1)))):s.setValue(a,t))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers.find(o=>o.data.type==="light");t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(o=>{"alpha"in o.data&&typeof o.data.alpha=="string"&&e.shared.getVariable(o.data.alpha,["material",this.uuid,"layer",o.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(t=>t instanceof Kt),this.lightLayer===void 0&&(this.lightLayer=new Kt(0,"",{...bt.defaultData("light","phong"),visible:!1},new ko,{},e)),this.dispose();for(let t of this.flavors)t&&t.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}applyTextureMaps(){let e=this.layers.find(a=>a instanceof Kt);if(!e)return;let t=e.data,o=t.bumpMap,n=t.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let a=0;a<this.layers.length;++a){let s=this.layers[a];s instanceof ot&&s.color instanceof Pi&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===n&&(e.node.roughnessMap=s.color))}}updateByOp(e,t,o){if(qe.startContext(this),t!==void 0?this.data=t:t=this.data,this.transparent=Yu(t,o.shared),e.path[0]==="layers"){let n=o.shared,a=e.path[1];if(a===void 0)o.scene.markNeedsUpdateRendererDirty(),this.reset0(t,o);else{e.type===0&&e.props.occlusion!==void 0&&o.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(l=>l.uuid===a);if(s){let l=t.layers.data(a),c;e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?c={...e.props,alpha:Ti(e.props.alpha,n,["material",this.uuid,"layer",a,"alpha"])}:c={...e.props,alphaOverride:Ti(e.props.alphaOverride,n,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...c?{props:c}:{},path:e.path.slice(2)},l,o)&&this.reset0(t,o)}}}else this.reset0(t,o);qe.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof ot?t.color.mask=void 0:t instanceof Kt&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof ot&&t.isMask.value&&t.data.visible&&e>0){let o=e-1,n=this.layers[o];n instanceof Kt?n.node.mask=new _t(t.color,t.alpha,_t.MUL):n instanceof ot&&(n.isMask.value||(n.color.mask=new _t(t.color,t.alpha,_t.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof ot),t=this.layers.findIndex(o=>o instanceof Kt);if(e!==-1&&e<t){let o=this.layers[e].color;for(let n=e+1;n<t;++n){let a=this.layers[n];if(a instanceof ot){if(a.isMask.value)continue;o=new Ha(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Ue("outgoingLight","f"),t=this.layers.findIndex(o=>o instanceof Kt);if(this.layers.length>t+1){for(let o=t+1;o<this.layers.length;++o){let n=this.layers[o];if(n instanceof ot){if(n.isMask.value)continue;e=new Ha(e,n.color,n.alpha,n.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof xl);if(e.length>0){let t=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(t=new _t(t,e[o].position,_t.ADD),t=new _t(t,new se(.5).setReadonly(!0),_t.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.shapeBlendhack&&this.shapeBlendhack(this),e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,t){let o=(n,a,s)=>Math.min(Math.max(n,a),s);for(let n of this.layers)if(n.type==="displace"){let a=o(n.uniforms[`f${n.id}_intensity`].value,e,t);n.uniforms[`f${n.id}_intensity`].value=a}}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new Ua;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let t of this.flavors)t&&t.updateAfterBuild();return this.shadersPatchedForShapeBlend=!1,this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof ot){let t=e.params.texture;if(t instanceof cn&&!t.image.loaded)return!1}return!0}};Object.defineProperties(or.prototype,{properties:{get:function(){return this.fragment.properties}}});var fn=class extends pn{constructor(r,e,t){super(r,e,!1),this.uuid=t,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var Ov=new Map;function Tv(i){if(typeof i=="string")return i;let r=Ov.get(i);return r||(r={url:URL.createObjectURL(new Blob([i]))},Ov.set(i,r)),r.url}var PD,Cv=new Promise(i=>{PD=i});var Av;Cv.then(i=>Av=i);var hn=class{constructor({src:r,volume:e,delay:t,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let n;typeof r=="string"?n={src:r}:n={src:Tv(r),format:"wav"},this.sound=new Av.Howl(n),this.sound.on("end",this.onEnd),this.src=r,e!==void 0&&(this.volume=e),t!==void 0&&(this.delay=t),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(r){this._volume=r,this.sound.volume(r)}get loop(){return this._loop}set loop(r){this._loop=r,this.loopsRemaining=r}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(r,e=1e3){r?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},r)):this.sound.fade(this._volume,0,e)}on(r,e,t){this.sound.on(r,e,t)}off(r,e,t){this.sound.off(r,e,t)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(r=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};import{Box2 as OD,Vector2 as mn,Path as Mv,Shape as TD,ShapeUtils as CD,Color as AD}from"three";var Qu=class{constructor(){this.type="ShapePath";this.color=new AD;this.subPaths=[];this.currentPath=null}moveTo(r,e){return this.currentPath=new Mv,this.subPaths.push(this.currentPath),this.currentPath.moveTo(r,e),this}lineTo(r,e){return this.currentPath?.lineTo(r,e),this}quadraticCurveTo(r,e,t,o){return this.currentPath?.quadraticCurveTo(r,e,t,o),this}bezierCurveTo(r,e,t,o,n,a){return this.currentPath?.bezierCurveTo(r,e,t,o,n,a),this}splineThru(r){return this.currentPath?.splineThru(r),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function o(m,y,b,v){let w=m.x,O=y.x,S=b.x,T=v.x,M=m.y,g=y.y,D=b.y,E=v.y,I=(T-S)*(M-D)-(E-D)*(w-S),N=(O-w)*(M-D)-(g-M)*(w-S),_=(E-D)*(O-w)-(T-S)*(g-M),R=I/_,V=N/_;if(_===0&&I!==0||R<=0||R>=1||V<0||V>1)return null;if(I===0&&_===0){for(let U=0;U<2;U++)if(n(U===0?b:v,m,y),t.loc===e.ORIGIN){let B=U===0?b:v;return{x:B.x,y:B.y,t:t.t}}else if(t.loc===e.BETWEEN){let B=+(w+t.t*(O-w)).toPrecision(10),q=+(M+t.t*(g-M)).toPrecision(10);return{x:B,y:q,t:t.t}}return null}else{for(let q=0;q<2;q++)if(n(q===0?b:v,m,y),t.loc===e.ORIGIN){let j=q===0?b:v;return{x:j.x,y:j.y,t:t.t}}let U=+(w+R*(O-w)).toPrecision(10),B=+(M+R*(g-M)).toPrecision(10);return{x:U,y:B,t:R}}}function n(m,y,b){let v=b.x-y.x,w=b.y-y.y,O=m.x-y.x,S=m.y-y.y,T=v*S-O*w;if(m.x===y.x&&m.y===y.y){t.loc=e.ORIGIN,t.t=0;return}if(m.x===b.x&&m.y===b.y){t.loc=e.DESTINATION,t.t=1;return}if(T<-Number.EPSILON){t.loc=e.LEFT;return}if(T>Number.EPSILON){t.loc=e.RIGHT;return}if(v*O<0||w*S<0){t.loc=e.BEHIND;return}if(Math.sqrt(v*v+w*w)<Math.sqrt(O*O+S*S)){t.loc=e.BEYOND;return}let M;v!==0?M=O/v:M=S/w,t.loc=e.BETWEEN,t.t=M}function a(m,y){let b=[],v=[];for(let w=1;w<m.length;w++){let O=m[w-1],S=m[w];for(let T=1;T<y.length;T++){let M=y[T-1],g=y[T],D=o(O,S,M,g);D!==null&&b.find(E=>E.t<=D.t+Number.EPSILON&&E.t>=D.t-Number.EPSILON)===void 0&&(b.push(D),v.push(new mn(D.x,D.y)))}}return v}function s(m,y,b){let v=new mn;y.getCenter(v);let w=[];return b.forEach(O=>{O.boundingBox.containsPoint(v)&&a(m,O.points).forEach(T=>{w.push({identifier:O.identifier,isCW:O.isCW,point:T})})}),w.sort((O,S)=>O.point.x-S.point.x),w}function l(m,y,b,v,w){(w==null||w==="")&&(w="nonzero");let O=new mn;m.boundingBox.getCenter(O);let S=[new mn(b,O.y),new mn(v,O.y)],T=s(S,m.boundingBox,y);T.sort((N,_)=>N.point.x-_.point.x);let M=[],g=[];T.forEach(N=>{N.identifier===m.identifier?M.push(N):g.push(N)});let D=M[0].point.x,E=[],I=0;for(;I<g.length&&g[I].point.x<D;)E.length>0&&E[E.length-1]===g[I].identifier?E.pop():E.push(g[I].identifier),I++;if(E.push(m.identifier),w==="evenodd"){let N=E.length%2===0,_=E[E.length-2];return{identifier:m.identifier,isHole:N,for:_}}else if(w==="nonzero"){let N=!0,_=null,R=null;for(let V=0;V<E.length;V++){let U=E[V];y[U]&&(N?(R=y[U].isCW,N=!1,_=U):R!==y[U].isCW&&(R=y[U].isCW,N=!0))}return{identifier:m.identifier,isHole:N,for:_}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let c=0,u=999999999,p=-999999999,d=[];this.subPaths.forEach(m=>{let y=m.getPoints(),b=-999999999,v=999999999,w=-999999999,O=999999999;for(let S=0;S<y.length;S++){let T=y[S];T.y>b&&(b=T.y),T.y<v&&(v=T.y),T.x>w&&(w=T.x),T.x<O&&(O=T.x)}p<=w&&(p=w+1),u>=O&&(u=O-1),y.length&&d.push({curves:m.curves,points:y,isCW:CD.isClockWise(y),identifier:c++,boundingBox:new OD(new mn(O,v),new mn(w,b))})});let f=d.map(m=>l(m,d,u,p,this.userData?.style.fillRule)),h=[];return d.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let b=new TD;b.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let O=d[w.identifier],S=new Mv;S.curves=O.curves,b.holes.push(S)}}),h.push(b)}}),h}};var fh=!1,Ev,hh=new Promise(i=>{Ev=i}),Iv=!1;var Zu;function Nv(){if(fh=!0,Iv)return;if(Zu)return Zu;async function i(){let e=await import("./opentype.js");Ev(e),Iv=!0}return Zu=i(),Zu}var bl=class{async load(r,e,t=()=>{}){let{load:o}=await hh;o(r,(n,a)=>{n||!a?t(n??"Something went wrong"):e(a)})}async parse(r){let{parse:e,Bidi:t}=await hh;try{let o=e(r),n=new t,a=s=>o.charToGlyphIndex(s.char);return n.registerModifier("glyphIndex",null,a),n.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:n}}catch(o){console.error(o)}}};async function MD(i){return await(await fetch(i)).arrayBuffer()}var ID=new bl;async function mh(i){let r,e,t=!1;if(i.url?(r=await MD(i.url),e=i.url,t=i.url.startsWith("/")):i.data&&(r=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),r)if(fh){let o=await ID.parse(r);if(o)return{font:o.font,url:e,intercepted:t,arr:r,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:t,arr:r,bidi:null}}import{CubicBezierCurve as ED,LineCurve as ND,QuadraticBezierCurve as DD}from"three";function _D(i,r){return r.state.glyphIndex===i||r.state.fina===i||r.state.medi===i||r.state.init===i}var Ju=class{constructor(r){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=r.isUserFont??!1,this._loadingPromise=mh(r).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(r){this._isLoaded=!1,this._isUserFont=r.isUserFont??!1,this._loadingPromise=mh(r).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(r,e,t){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let n=o.tokenizer.tokens,a=[],s=0,l=t.length===n.length;for(let c=0;c<t.length;c++){let u=t[c].index,p=String.fromCharCode(t[c].unicode),d=n[s];if(_D(u,d)||l)a.push({char:p,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),s++;else{let f=d.char,h="",m=[d.state.glyphIndex],y=[],b=!1;for(;!b;)s++,h=e.charAt(s),f+=h,m.push(r.charToGlyphIndex(h)),y=r.stringToGlyphs(f),y.length===1&&y[0].index===u&&(b=!0),s>e.length&&(b=!0);a.push({char:p,index:u,replacements:m,replacementChars:Array.from(f)}),s++}}return a}generateShapes(r,e,t){if(!this._isLoaded)return;let o=this.font,n=e.fontSize/this.unitsPerEm,a=e.fontSize*e.lineHeight,s=r.map(v=>this.getTextWidth(v,e)),l=typeof e.width=="string"?Number(t.getVariable(e.width)):e.width,c=typeof e.height=="string"?Number(t.getVariable(e.height)):e.height,u=this.getCharWidth(`
2286
2286
  `,e),p=e.horizontalAlign===1?u:0,d=this.getLineInitialOffsetX(s[0],l,e.horizontalAlign,r[0],u),f=this.getLineInitialOffsetY(a,r.length,c,n,e.verticalAlign),h=[],m=r.map(v=>[]),y=r.map(v=>[]);for(let v=0;v<r.length;v++){let w=r[v],O={features:{liga:!0},letterSpacing:e.letterSpacing},S=[];try{S=o.stringToGlyphs(w,O)}catch(E){console.warn(E)}d=this.getLineInitialOffsetX(s[v],l,e.horizontalAlign,w,u);let T=[];try{T=this.reverseLigaturesTable(o,w,S)}catch(E){console.warn(E)}let M=this.computeSpaceWidthForLine(r,v,e,t),g=0,D=S[0];D&&e.horizontalAlign===2&&D.leftSideBearing!==void 0&&(d-=D.leftSideBearing*n),this.font?.forEachGlyph(w,d,f,e.fontSize,O,(E,I,N,_,R)=>{let V=E.index===0?`
2287
2287
  `:E.unicode?String.fromCharCode(E.unicode):void 0,U=T[g],B=0;if(V===`
2288
2288
  `)B=p;else if(V===" ")B=M;else{let q=this.createPath(E,n,I,N,e);q&&(B=q.offsetX,h.push(q.path))}if(U.replacements.length===1)y[v].push([I,N]),m[v].push(B);else{let q=U.replacements.map(W=>(o.glyphs.get(W).advanceWidth??0)*n),j=q.reduce((W,ee)=>W+=ee,0),F=q.map(W=>W/j),H=I;for(let W=0;W<F.length;W++){let ee=B*F[W];y[v].push([H,N]),m[v].push(ee),H+=ee}}g++}),f-=a}let b=[];for(let v=0,w=h.length;v<w;v++)b.push(...h[v].toShapes());return{shapes:b,charWidths:m,lineWidths:s,charCoords:y}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(r,e,t,o,n){return(t===3||t===2)&&o.indexOf(`
2289
- `)>=0&&(r-=n),t===3?e*.5-r*.5:t===2?e-r:0}getLineInitialOffsetY(r,e,t,o,n){let a=e*r,s=Math.abs(this.ascender-this.descender)*o,l=r-s,c=-this.ascender*o-l/2;return n===3?-(t-a-c):n===2?-(t*.5-a*.5-c):c}createPath(r,e,t,o,n){let a=r.getPath(t,-o,n.fontSize,{kerning:!1,letterSpacing:n.letterSpacing});if(!a){console.error('THREE.Font: character "'+r+'" does not exists in font family '+this.familyName+".");return}let s=new $u,l=(r.advanceWidth??1)*e;if(r)for(let c of a.commands){let u=s.currentPath?.currentPoint;if(!(u&&c.type!=="Z"&&u.x===c.x&&-u.y===c.y))switch(c.type){case"M":s.moveTo(c.x,-c.y);break;case"L":s.lineTo(c.x,-c.y);break;case"Q":s.quadraticCurveTo(c.x1,-c.y1,c.x,-c.y);break;case"C":s.bezierCurveTo(c.x1,-c.y1,c.x2,-c.y2,c.x,-c.y);break}}return s.subPaths.forEach(c=>{let u=zN(c.curves);u!==void 0&&c.currentPoint.distanceTo(u)>0&&c.lineTo(u.x,u.y)}),{offsetX:l,path:s}}getCharWidth(r,e){return this.font?.getAdvanceWidth(r,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(r,e){return this.font?.getAdvanceWidth(r,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(r,e,t,o){let n=this.getCharWidth(" ",t),a=r[e];if(a){let s=this.countSpaces(a.trimEnd());if(t.horizontalAlign===4&&e<r.length-1&&s){let l=typeof t.width=="string"?Number(o.getVariable(t.width)):t.width,c=this.getTextWidth(a,t);return(l-(c-s*n))/s}}return n}countSpaces(r){return(r.match(/ /g)||[]).length}};function zN(i){if(i.length){let r=i[0];if(r instanceof LN)return r.v1;if(r instanceof RN||r instanceof BN)return r.v0}}var lh=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(r){return this.objects.get(r)}get size(){return this.objects.size}get(r,e,t){let o=this.objects.get(r);return o===void 0?(o=this.createObject(r,e,t),this.objects.set(r,o)):o.isShared=!0,o}forceDelete(r){let e=this.objects.get(r);e&&(this.disposeObject(e),this.objects.delete(r))}mutateIfUnique(r,e){let t=this.objects.get(r);if(t&&t.isShared!==!0)return this.objects.delete(r),this.objects.set(e,t),t}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(r,e){let t=this.objects.get(r);e===t?this.unreachable.delete(r):!1&&console.warn("Reachable but deleted",r)}endGc(){this.unreachable.forEach(r=>{this.disposeObject(this.objects.get(r)),this.objects.delete(r)}),this.unreachable.clear()}dispose(){this.objects.forEach(r=>{this.disposeObject(r)}),this.objects.clear()}},vl=class extends lh{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t,o){let n=jo(e,t,this.flatShading,o);return n.computeBoundingSphere(),n}};var fv={markNeedsUpdateRendererDirty:()=>{}};import{MathUtils as xv}from"three";var Ku=1e3,hv=512*Ku;function GN(i,r){let e=typeof i;return!!((r==="string"||r==="number")&&e===r||r==="boolean"&&(i==="true"||i==="false"||i===!0||i===!1)||r==="image"&&e==="string"&&i.startsWith("http"))}var mv="https://hooks.spline.design",FN=`${mv}/events?hashFile=`,Nre=`${mv}/`,Qu=class{constructor(r,e){this.id=r;this.userWebhook=e;this.result=void 0;this._connected=!1;this.emitter=Fo();this.reconnectWaitFor=Ku;this._onError=r=>{this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this._scheduleReconnect()};this._onConnected=r=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=Ku,this._connected=!0};this._onDisconnected=()=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=Ku,this._connected=!1};this._onMessage=r=>{let e=r.data,t;try{t=JSON.parse(e)}catch(o){console.error("Error parsing webhook message",o)}if(t){let o=!1;this.userWebhook.parametersSchemas.forEach(({data:n})=>{t[n.name]!==void 0&&GN(t[n.name],n.type)&&(this.result===void 0&&(this.result={}),this.result[n.name]=t[n.name],o=!0)}),o&&this.emitter.emit("message",{userWebhookId:this.id})}}}connect(){clearTimeout(this.scheduledReconnectHandle),this.userWebhook.url&&(this.eventSource=new EventSource(FN+this.userWebhook.url),this.eventSource.addEventListener("message",this._onMessage),this.eventSource.addEventListener("error",this._onError),this.eventSource.addEventListener("open",this._onConnected))}disconnect(){this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this.eventSource?.close(),this._onDisconnected(),clearTimeout(this.scheduledReconnectHandle)}_scheduleReconnect(){this.reconnectWaitFor*=2,this.reconnectWaitFor>hv&&(this.reconnectWaitFor=hv),clearTimeout(this.scheduledReconnectHandle),this.scheduledReconnectHandle=setTimeout(()=>{this.scheduledReconnectHandle=void 0,this.connect()},this.reconnectWaitFor)}update(r){this.userWebhook=r}dispose(){this._connected&&this.disconnect()}get connected(){return this._connected}on(r,e){this.emitter.on(r,e)}off(r,e){this.emitter.off(r,e)}getParametersKeys(){return this.userWebhook.parametersSchemas.map(r=>r.data.name)}getParameterValue(r){if(this.getParametersKeys().includes(r)){if(this.result)return this.result?.[r];for(let t of this.userWebhook.parametersSchemas)if(t.data.name===r)return Qc.defaultParameterValueByType(t.data.type)}}};var yv=[4186.01,4434.92,4698.63,4978.03,5274.04,5587.65,5919.91,6271.93,6644.88,7040,7458.62,7902.13],jN=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],qo=[],Ju=[];for(let i=1;i<=8;i++)for(let r=0;r<yv.length;r++){let e=yv[r];qo.push(e/Math.pow(2,8-i)),Ju.push(jN[r]+i)}var Zu=[32,2e3],ch=qo.filter((i,r)=>qo[r]>Zu[0]&&qo[r]<Zu[1]),gv=Ju.filter((i,r)=>qo[r]>Zu[0]&&qo[r]<Zu[1]);var ed=class{static getFrequencies(r,e,t,o="frequency",n=-100,a=-30){t||(t=new Float32Array(r.frequencyBinCount),r.getFloatFrequencyData(t));let s=e/2,l=1/t.length*s,c,u,p;if(o==="music"||o==="voice"){let h=o==="voice"?ch:qo,m=Array(h.length).fill(n);for(let y=0;y<t.length;y++){let b=y*l,v=t[y];for(let w=h.length-1;w>=0;w--)if(b>h[w]){m[w]=Math.max(m[w],v);break}}c=m,u=o==="voice"?ch:qo,p=o==="voice"?gv:Ju}else c=Array.from(t),u=c.map((h,m)=>l*m),p=u.map(h=>`${h.toFixed(2)} Hz`);let d=c.map(h=>Math.max(0,Math.min((h-n)/(a-n),1)));return{values:new Float32Array(d),frequencies:u,labels:p}}};var UN="gpt-4o-realtime-preview-2024-12-17",kN=()=>!1&&window.location.search.includes("api-dev")?"https://relayserver-dev.spline.design/":"https://relayserver.spline.design/";async function HN(i){try{return(await(await fetch(kN()+"session?uuidfile="+i)).json()).token}catch(r){console.error("Token generation error:",r)}}var uh=class{constructor(r){this.value=0;this.frequencies=new Float32Array(0);let e=new AudioContext;this.source=e.createMediaStreamSource(r),this.analyser=e.createAnalyser(),this.source.connect(this.analyser),this.analyser.fftSize=8192,this.analyser.smoothingTimeConstant=.1}getFrequencies(r=-100,e=-30){if(!this.analyser)throw new Error("Not connected, please call .connect() first");return ed.getFrequencies(this.analyser,44100,void 0,"voice",r,e)}update(){let r=this.getFrequencies(),e=r.values.reduce((t,o)=>t+o,0)/r.values.length;this.value=e,this.frequencies=r.values}disconnect(){this.source.disconnect(),this.analyser.disconnect()}},Sl=class{constructor(r,e,t){this.data=r;this.id=e;this.shared=t;this.emitter=Fo();this.rafId=0;this.voice=0;this.frequencies=new Float32Array([0]);this.events=[];this.isConnected=!1;this.isToolsAdded=!1;this.tools=[];this.onMessage=r=>{let e=JSON.parse(r.data);if(this.appendEvent(e),e.type==="session.created"&&this.onSessionCreated(),e.type==="response.done"&&e.response?.output){for(let t of e.response.output)if(t.type==="function_call")for(let[o,n]of this.tools)t.name===o.name&&(n(JSON.parse(t.arguments)),setTimeout(()=>{this.sendClientEvent({type:"response.create",response:{instructions:"notice the user about what you just did"}})}))}};this.onSessionCreated=()=>{this.isToolsAdded||this.registerTools()};this.onOpen=()=>{this.events=[],this.isConnected=!0,this.sendClientEvent({type:"response.create",response:{instructions:"Say hi"}})};this.animate=()=>{if(this.rafId=requestAnimationFrame(this.animate),this.isConnected&&this.analyser){this.analyser.update();let r=this.analyser.value,e=this.analyser.frequencies;this.voice=r,this.frequencies=e,this.emitter.emit("voice",{value:r,frequencies:e})}}}update(r){this.data=r}setColorByName(r,e){let t=this.shared.getColorByName(r);if(t){let{id:o}=t,{r:n,g:a,b:s}=yb.hexStringToRgb(e)??{r:0,g:0,b:0};this.shared.updateColor(o,{r:n/255,g:a/255,b:s/255})}}async connect(){if(this.isConnected)return;let r=await HN(this.data.integration.hash);this.pc=new RTCPeerConnection,this.audioElement=document.createElement("audio"),this.audioElement.autoplay=!0,this.pc.ontrack=l=>{let c=l.streams[0];this.audioElement.srcObject=c,this.analyser=new uh(c)};let e=await navigator.mediaDevices.getUserMedia({audio:!0});this.pc.addTrack(e.getTracks()[0]),this.dc=this.pc.createDataChannel("oai-events"),this.dc.addEventListener("message",this.onMessage),this.dc.addEventListener("open",this.onOpen);let t=await this.pc.createOffer();await this.pc.setLocalDescription(t);let s={type:"answer",sdp:await(await fetch(`https://api.openai.com/v1/realtime?model=${UN}`,{method:"POST",body:t.sdp,headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/sdp"}})).text()};await this.pc.setRemoteDescription(s),this.animate()}appendEvent(r){this.events=[r,...this.events]}sendClientEvent(r){this.dc?(r.event_id=r.event_id||crypto.randomUUID(),this.dc.send(JSON.stringify(r)),this.appendEvent(r)):console.error("Failed to send message - no data channel available",r)}registerTools(){this.isToolsAdded=!0,this.registerTool({type:"function",name:"set_personality_color",description:"returns a color based on the voice personality of the ai assistant. This should be called by the voice assistant each time it is asks to speak differently. If a color cannot be associated to the personality, the color should be a neutral color.",parameters:{type:"object",properties:{color:{type:"string",description:"css hex color string, reflecting the personality"},personality:{type:"string",description:"the personality of the voice assistant"}},required:["color","personality"]}},({color:n})=>{this.setColorByName("Voice Assistant Color",n)});let r=this.shared.getVariablesNames().join(", ");this.registerTool({type:"function",name:"set_variable",description:"Sets a Spline variable value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the variable that needs to be set. Here's a list of available variables: ${r}. It the variable does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"The new value for this variable, should always be a string even for number and boolean variables, assume that the value will be cast to the proper type afterwards."}},required:["name","value","type"]}},({name:n,value:a})=>{let s=this.shared.getVariableByName(n);if(s){let l=this.shared.getVariable(s.id),c;typeof l=="number"?c=parseFloat(a):typeof l=="boolean"?c=a.toLowerCase()==="true":c={textValue:a},this.shared.updateVariable(s.id,c)}});let e=this.shared.getColorNames().join(", ");this.registerTool({type:"function",name:"set_color",description:"Sets a Spline color asset value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the color asset that needs to be set. Here's a list of available color assets: ${e}. It the color asset does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"css hex color string"}},required:["name","value"]}},({name:n,value:a})=>{this.setColorByName(n,a)});let t=this.shared.scene,o=[];t.traverseEntity(n=>{n.data.events.forEach(a=>{if(a.data.type==="AIAssistantTrigger"){let{description:s}=a.data;o.push(s)}})}),this.registerTool({type:"function",name:"trigger_event",description:"Trigger an event by name, here are the available events, please match what the user is asking for to one of these if it applies, otherwise don't call the function and warn the user.",parameters:{type:"object",properties:{description:{type:"string",description:`The name of the event that needs to be triggered. Here's a list of available events: ${JSON.stringify(o)}.`},direction:{type:"string",description:"default is forward, but can be forward or backward. Always set to forward unless the user ask to reverse or cancel the event, then set to backward."}},required:["description","direction"]}},({description:n,direction:a})=>{this.emitter.emit("trigger_event",{description:n,direction:a})}),this.sendClientEvent({type:"session.update",session:{tools:this.tools.map(([n])=>n)}})}registerTool(r,e){this.tools.push([r,e])}disconnect(){cancelAnimationFrame(this.rafId),this.analyser?.disconnect(),this.voice=0,this.isConnected=!1,this.isToolsAdded=!1,this.dc?.removeEventListener("message",this.onMessage),this.dc?.removeEventListener("open",this.onOpen),this.dc?.close(),this.pc?.getSenders().forEach(r=>{r.track&&r.track.stop()}),this.pc?.close(),this.pc=void 0}computeAnalysisForListenerEvent(r){if(r.analysis==="range"){let e=this.frequencies.slice(...r.analysisRange);return e.reduce((t,o)=>t+o,0)/e.length}return r.analysis==="single"?this.frequencies[r.analysisSingle]:this.voice}on(r,e){this.emitter.on(r,e)}off(r,e){this.emitter.off(r,e)}};function bv(i){return"variable_"+i}var dh=class extends ku{constructor(e){super();this.shared=e}create(e){return new is(e,this.shared)}},yn=class{constructor(r,e={},t=!0,o=!1){this.data=r;this.needsJitter=t;this.enableLocalStorageForPersistentVariables=o;this.geometryCache=new vl(!0);this.geometryCache2=new vl(!1);this.imageHolderCache=new dh(this);this.thisContext={scene:fv,shared:this};this.deletedMaterial=new fn(Pt.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new pr(ru.emptyImage,this);this.deletedVideo=new pr(aa.defaultVideo,this);this.materials={};this.images={};this.uiBuffers={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.variables={};this.userAPIs={};this.userWebhooks={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[n,a]of Object.entries(e.images))this.addImage(n,a);if(e.videos)for(let[n,a]of Object.entries(e.videos))this.addVideo(n,a);if(e.audios)for(let[n,a]of Object.entries(e.audios))this.addAudio(n,a);if(e.particles)for(let[n,a]of Object.entries(e.particles))this.addParticle(n,a);this.reset(r)}setRequestRender(r){this._requestRender=r}getImageLoadPromises(){return Object.values(this.images).map(r=>r.loadPromise)}setEntityOpContext(r){this.entityOpContext=r}reset(r,e=!1,t=!1){this.data=r,this.resetLib(r.lib);for(let{id:o,data:n}of r.variables)this.addVariableHolder(o,n),e&&this.updateVariableHolder(o,n);for(let[o,n]of Object.entries(r.userAPIs))this.addUserAPI(o,n);for(let[o,n]of Object.entries(r.userWebhooks))this.addUserWebhook(o,n);if(!t){for(let[o,n]of Object.entries(r.images))this.addImage(o,n);for(let[o,n]of Object.entries(r.videos))this.addVideo(o,n)}for(let[o,n]of Object.entries(r.colors))this.addColor(o,n);for(let[o,n]of Object.entries(r.materials))this.addMaterial(o,n);for(let[o,n]of Object.entries(r.audios))this.addAudio(o,n);for(let[o,n]of Object.entries(r.particles))this.addParticle(o,n);for(let[o,n]of Object.entries(r.fonts))this.addFont(o,n)}addMaterial(r,e){if(this.materials[r]){let t=this.materials[r];t.reset(e,this.thisContext),t.dispose()}else{let t=new fn(e,this.thisContext,r);this.materials[r]=t}}deleteMaterial(r){this.materials[r]&&(this.materials[r].nodeMaterialDispose(),delete this.materials[r])}getMaterial(r){let e=this.materials[r];return e}getMaterialOrDeletedPlaceholder(r){return this.materials[r]??this.deletedMaterial}material(r){return typeof r=="string"?this.getMaterialOrDeletedPlaceholder(r):r==null?(console.error("material is undefined or null"),this.deletedMaterial):new pn(r,this.thisContext)}getMaterials(){return this.materials}addImage(r,e){return this.images[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[r].updateSrc(e.data),!0):(this.images[r]=new pr(e,this),!1)}deleteImage(r){let e=this.images[r];e&&(e.dispose(),delete this.images[r])}getDefaultImage(){return this.images.image_0}getImage(r){return this.images[r]??this.deletedImage}image(r){return typeof r=="string"?this.getImage(r):this.imageHolderCache.load(r)}addUIBuffer(r,e){return this.uiBuffers[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[r].updateSrc(e),!0):(this.uiBuffers[r]=new pr(e,this),!1)}uiBuffer(r){return this.uiBuffers[r]}addVideo(r,e){return this.videos[r]?(this.videos[r].updateSrc(e.data),!0):(this.videos[r]=new pr(e,this),!1)}deleteVideo(r){let e=this.videos[r];e&&(e.dispose(),delete this.videos[r])}getVideo(r){return this.videos[r]??this.deletedVideo}video(r){return typeof r=="string"?this.getVideo(r):this.imageHolderCache.load(r)}addColor(r,e){return this.colors[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[r].setRGBA(e.r,e.g,e.b,e.a):this.colors[r].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[r]=new Oi(e.r,e.g,e.b,e.a):this.colors[r]=new Oi(e.r,e.g,e.b,1),!1)}updateColor(r,e){if(this.colors[r]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let t=this.colors[r];return this.colors[r].r=e.r??t.r,this.colors[r].g=e.g??t.g,this.colors[r].b=e.b??t.b,this.colors[r].a=e.a??t.a,!0}return!1}deleteColor(r){this.colors[r]&&delete this.colors[r]}getColor(r){return this.colors[r]}getColorNames(){return Object.values(this.data.colors).map(r=>r.name)}getColorByName(r){for(let e in this.data.colors)if(this.data.colors[e].name===r)return{color:this.colors[e],id:e}}color(r){let e;if(typeof r=="string"){let t=this.getColor(r);t?e=t:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new At(0,0,0,0))}else return"a"in r?new At(r.r,r.g,r.b,r.a):new At(r.r,r.g,r.b,1);return e}addAudio(r,e){this.audios[r]=e}getAudio(r){let e=this.audios[r];if(e instanceof hn)return e;{let t=new hn({src:e.data});return this.audios[r]=t,t}}addParticle(r,e){this.particles[r]=e}getParticle(r){return this.particles[r]}deleteParticle(r){this.particles[r]&&delete this.particles[r]}deleteAudio(r){let e=this.audios[r];e&&(e instanceof hn&&e.dispose(),delete this.audios[r])}addFont(r,e){this.fonts[r]=new Yu(e),this.fonts[r].loadingPromise.then(()=>this.requestRender())}getFont(r){return this.fonts[r]}deleteFont(r){this.fonts[r]&&delete this.fonts[r]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof hn&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(r,e){if(this.variables[r]===void 0){let t=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let o=localStorage.getItem(bv(r));t=o!==null?JSON.parse(o):e.value}return this.variables[r]={value:t,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[r].dynamicVariablePlayState="Playing",this.variables[r].dynamicVariableToggleIsForward=void 0),!0}return this.variables[r].value=e.value,!1}resetDynamicVariablePlayState(){for(let r in this.variables)this.variables[r].dynamicVariablePlayState!==void 0&&(this.variables[r].dynamicVariablePlayState="Playing",this.variables[r].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(r,e){this.updateVariable(r,e.value)}updateVariable(r,e){if(this.variables[r]===void 0)return!1;this.variables[r].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[r].persistent&&localStorage.setItem(bv(r),JSON.stringify(e));let t=e;for(;typeof t=="string";)t=this.variables[t].value;let o=this.entityOpContext.scene;for(let n=this.variables[r].locations.length-1;n>=0;n--){let a=this.variables[r].locations[n];if(a[0]==="material"){let s=a[1],l=t,c={scene:o,shared:this},u=a.slice(2);o.traverseMaterial(d=>{let f=d.root??d;f.uuid===s&&f.onVariableUpdate(u,l,c)});let p=this.materials[s];p&&p.onVariableUpdate(u,l,c)}else{let s=o.find(a[0]);if(s===void 0){this.variables[r].locations.splice(n,1);continue}if(a[1]!=="geometry"&&a[1]!=="particles"){for(let l=1;l<a.length-1;l++)s=s[a[l]];a[1]==="rotation"?s[a[a.length-1]]=t*xv.DEG2RAD:s[a[a.length-1]]=t}if(s=o.find(a[0]),s.type==="ParticleEmitter"&&s.updateVariableState(t,a),De.is(s))if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")s.onVariableUpdate();else if(a[1]==="geometry"){let l=s;s.component&&(l=s.component);let c=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(c.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.invalidateDownstreamBooleanData(),l.instances.forEach(u=>{let p=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(p.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0),u.invalidateDownstreamBooleanData()})}else a[1]==="morphTargetInfluences"&&s.updateMorphInfluences(a[2],t)}}return this.requestRender(),!0}deleteVariable(r){this.variables[r]&&delete this.variables[r]}getVariable(r,e){if(Array.isArray(r)){if(r[0]==="mouse")return this.mouseProperty?.[r[1]]??0;if(r[0]==="raycast")return this.raycastProperty?.[r[1]]??0;let t=this.entityOpContext.scene.find(r[0]);if(r[1]==="width"||r[1]==="height"||r[1]==="depth")return t.geometry.userData.parameters[r[1]];for(let o=1;o<r.length;o++)t=t[r[o]];return r[1]==="rotation"&&(t*=xv.RAD2DEG),t}for(let t in this.variables){if(e===void 0)break;let o=this.variables[t],n=o.locations?.findIndex(a=>Ze.equal(a,e));n!==void 0&&n!==-1&&o.locations.splice(n,1)}if(typeof r=="string"){let t=r,o=r;do{if(o=t,this.variables[t]===void 0)break;let n=this.variables[t].value;e&&this.variables[o]!==void 0&&this.variables[o].locations.push(e),t=n}while(typeof t=="string");return t}else return r}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(r=>r.data.name)}getVariableByName(r){for(let e of this.data.variables)if(e.data.name===r)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(r){return this.variables[r]?.dynamicVariablePlayState}setDynamicVariablePlayState(r,e){this.variables[r]!==void 0&&(this.variables[r].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(r){return this.variables[r]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(r,e){this.variables[r]!==void 0&&(this.variables[r].dynamicVariableToggleIsForward=e)}resetLib(r){for(let[e,t]of Object.entries(r.images))this.addImage(e,t.asset);for(let[e,t]of Object.entries(r.audios))this.addAudio(e,t.asset);for(let[e,t]of Object.entries(r.particles))this.addParticle(e,t.asset);for(let[e,t]of Object.entries(r.colors))this.addColor(e,t.asset);for(let[e,t]of Object.entries(r.fonts))this.addFont(e,t.asset);for(let[e,t]of Object.entries(r.materials))this.addMaterial(e,t.asset);for(let[e,t]of Object.entries(r.videos))this.addVideo(e,t.asset);for(let[e,t]of Object.entries(r.variables))this.addVariableHolder(e,t.asset)}updateLibByOp(r,e){r.path[0]==="images"?r.path.length===1&&r.type===1?this.addImage(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteImage(r.id):r.path[0]==="videos"?r.path.length===1&&r.type===1?this.addVideo(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteVideo(r.id):r.path[0]==="audios"?r.path.length===1&&r.type===1?this.addAudio(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteAudio(r.id):r.path[0]==="particles"?r.path.length===1&&r.type===1?this.addParticle(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteParticle(r.id):r.path[0]==="colors"?r.path.length===1&&r.type===1?this.addColor(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteColor(r.id):r.path[0]==="materials"?r.path.length===1&&r.type===1?this.addMaterial(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteMaterial(r.id):r.path[0]==="fonts"?r.path.length===1&&r.type===1?this.addFont(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteFont(r.id):r.path[0]==="variables"?r.path.length===1&&r.type===1?this.addVariableHolder(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteVariable(r.id):r.path[0]==="components"&&e.updateByLibOp(r,this)}updateByOp(r,e,t){if(this.data=e,r.path[0]==="images")r.path.length===2&&r.type===0?r.props.data&&this.getImage(r.path[1]).updateSrc(r.props.data):r.path.length===1&&r.type===1?this.addImage(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteImage(r.id);else if(r.path[0]==="videos")r.path.length===2&&r.type===0?r.props.data&&this.getVideo(r.path[1]).updateSrc(r.props.data):r.path.length===1&&r.type===1?this.addVideo(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteVideo(r.id);else if(r.path[0]==="audios")r.path.length===2&&r.type===0?r.props.data&&this.addAudio(r.path[1],e.audios[r.path[1]]):r.path.length===1&&r.type===1?this.addAudio(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteAudio(r.id);else if(r.path[0]==="particles")r.path.length===2&&r.type===0?r.props.data&&this.addParticle(r.path[1],e.particles[r.path[1]]):r.path.length===1&&r.type===1?this.addParticle(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteParticle(r.id);else if(r.path[0]==="colors")r.path.length===2&&r.type===0?this.updateColor(r.path[1],r.props):r.path.length===1&&r.type===1?this.addColor(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteColor(r.id);else if(r.path[0]==="materials")r.path.length===1&&r.type===1?this.addMaterial(r.id,r.data):r.path.length===1&&r.type===2?this.deleteMaterial(r.id):r.path.length>1&&this.getMaterial(r.path[1]).updateByOp(nt.drop(r,2),e.materials[r.path[1]],{shared:this,scene:t});else if(r.path[0]==="fonts")r.path.length===2&&r.type===0?this.updateFont(r.path[1],r,t):r.path.length===1&&r.type===1?this.addFont(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteFont(r.id);else if(r.path[0]==="variables")r.path.length===2&&r.type===0?"value"in r.props?this.updateVariable(r.path[1],r.props.value):"persistent"in r.props&&(this.variables[r.path[1]].persistent=r.props.persistent):r.path.length===1&&r.type===4?this.addVariableHolder(r.id,r.data):r.path.length===1&&r.type===5&&this.deleteVariable(r.id);else if(r.path[0]==="userAPIs"){if(r.path.length===1&&r.type===1)this.addUserAPI(r.id,r.data);else if(r.path.length===1&&r.type===2)this.deleteUserAPI(r.id);else if(typeof r.path[1]=="string"){let o=e.userAPIs[r.path[1]];if(o){let n=r.type===0&&r.props.debounce===void 0,a=this.getUserAPI(r.path[1]);a instanceof Sl?a.update(o):a?.update(o,this,n)}}}else if(r.path[0]==="userWebhooks"){if(r.path.length===1&&r.type===1)this.addUserWebhook(r.id,r.data);else if(r.path.length===1&&r.type===2)this.deleteUserWebhook(r.id);else if(typeof r.path[1]=="string"){let o=e.userWebhooks[r.path[1]];o&&this.getUserWebhook(r.path[1])?.update(o)}}else r.path[0]==="lib"&&this.updateLibByOp(nt.drop(r,1),t)}updateFont(r,e,t){if(e.props.url){let o=this.getFont(r),n={...this.data.fonts[r],url:e.props.url};o.update(n),o.loadingPromise.then(()=>this.requestRender()),t.updateFont(r,this)}}addUserAPI(r,e){return this.userAPIs[r]?(this.userAPIs[r].update(e,this),!0):this.openAIRealtime?.id===r?(this.openAIRealtime.update(e),!0):e.integration?.type==="VoiceAssistant"?(this.openAIRealtime=new Sl(e,r,this),!1):(this.userAPIs[r]=new Eu(r,e,this),!1)}getUserAPI(r){return this.openAIRealtime?.id===r?this.openAIRealtime:this.userAPIs[r]}getUserAPIs(){return this.userAPIs}deleteUserAPI(r){let e=this.userAPIs[r];e&&(e.dispose(),delete this.userAPIs[r])}addUserWebhook(r,e){return this.userWebhooks[r]?(this.userWebhooks[r].update(e),!0):(this.userWebhooks[r]=new Qu(r,e),!1)}getUserWebhook(r){return this.userWebhooks[r]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(r){let e=this.userWebhooks[r];e&&(e.dispose(),delete this.userWebhooks[r])}get scene(){return this.entityOpContext.scene}},vv=new yn(vr.emptyData());var ir=class extends Tt{updateByPatchedOp(e,t,o){if(super.updateByPatchedOp(e,t,o),Yg(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[n,a]of Object.entries(e.props)){let s=o.shared.material(a);this.material[Number(n)]=s}else if(Le(e.path,["material"])&&this.material instanceof or)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(nt.drop(e,1),t.material,o);else if(Le(e.path,["materials","*"])&&Array.isArray(this.material)){let n=e.path[1];if("materials"in t&&n<this.material.length){let a=t.materials[n];typeof a!="string"&&this.material[n].updateByOp(nt.drop(e,2),a,o)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}updateState(e,t){super.updateState(e,t),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let o=this.dataPatched;this.dataPatched.type==="Mesh"&&!!this.dataPatched.geometry.shapeBlendNode&&this.layers.set(9);let a;if(this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(a={resolutionLevel:this.dataPatched.geometry.resolutionLevel,useChildrenColors:this.dataPatched.geometry.useChildrenColors}),e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=t.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe,a),t.scene.markNeedsUpdateRendererDirty()),(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(s=>t.shared.material(s).getFlavor(o.flatShading,o.side,o.wireframe)),t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[t.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe)],t.scene.markNeedsUpdateRendererDirty())),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let s=0;s<this.material.length;s++)this.material[s]=this.material[s].getFlavor(o.flatShading,o.side,o.wireframe);else this.material=this.material.getFlavor(o.flatShading,o.side,o.wireframe,a)}disposeMaterial(){this.material&&Wl(this.material).forEach(e=>{e instanceof or&&(e instanceof fn||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};import{BufferGeometry as qN,Matrix4 as fh,Vector3 as Tv,Vector4 as hh}from"three";var Sv=new Tv,wv=new hh,Pv=new hh,$N=new Tv,Ov=new fh,et=class extends ir{constructor(e,t,o){super(e,t);this.data=t;this.isSkinnedMesh=!1;this.localGeometry=void 0,t.bindMode&&t.bindMatrix&&(this.bindMode=t.bindMode,this.bindMatrix=new fh().fromArray(t.bindMatrix),this.bindMatrixInverse=new fh)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof qN&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof yn){let e=this.geometryCreateDeleyed,t=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=t.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return Fs.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return Fs.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),Le(e.path,["geometry"])&&this.updateByPatchedOpGeometry(nt.drop(e,1),t.geometry,o)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,t){this.invalidateDownstreamBooleanData();let o=this.data.geometry.type;if(o==="NonParametricGeometry"||o==="SubdivGeometry"){let n=e;if(this.localGeometry===void 0){let u={...this.data.geometry,...n};this.localGeometry=jo(u,t,this.data.flatShading,this)}let a,s,l;n.scaleBaked?[a,s,l]=n.scaleBaked:{width:a,height:s,depth:l}=n;let c=this.localGeometry.userData;c.sxPrev!==void 0&&ll(this.localGeometry.attributes,a/c.sxPrev,s/c.syPrev,l/c.szPrev),c.sxPrev=a,c.syPrev=s,c.szPrev=l}else{let n={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=jo(n,t,this.data.flatShading,this)}}refreshAttachedClonersInteractions(){for(let e of this.attachedSurfaceCloners)e.update()}refreshAttachedCloners(e){for(let t of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(t.object)}refreshAttachedPaths(e){for(let t of this.attachedPaths)e.scene.addPendingCommand(()=>t.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,t,o){let n=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof gt&&this.chooseGeoemtryCache(o.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(n=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(t,e.props.scaleBaked),this.refreshAttachedCloners(o),this.refreshAttachedPaths(o)),n||(o.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(o)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,t){this.createGeometryDelayed(t)}updateState(e,t){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,t);let o=e.morphTargetInfluences;if(o){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:n,value:a}}of o)this.updateMorphInfluences(n,t.shared.getVariable(a,[this.uuid,"morphTargetInfluences",n]))}super.updateState(e,t)}updateMorphInfluences(e,t){if(this.morphTargetDictionary===void 0)return;let o=this.morphTargetDictionary[e];o!==void 0&&(this.morphTargetInfluences[o]=t)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,t){let o=this.geometry.userData.parameters;this.is2DType?e.set(0,0,o.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)):o.centerOffset?e.fromArray(o.centerOffset):e.setScalar(0),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,t){this.skeleton=e,this.isSkinnedMesh=!0,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let t=new hh,o=this.geometry.attributes.skinWeight;for(let n=0,a=o.count;n<a;n++){t.fromBufferAttribute(o,n);let s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),o.setXYZW(n,t.x,t.y,t.z,t.w)}}boneTransform(e,t){let o=this.skeleton;if(o===void 0)return;let n=this.geometry;wv.fromBufferAttribute(n.attributes.skinIndex,e),Pv.fromBufferAttribute(n.attributes.skinWeight,e),Sv.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let a=0;a<4;a++){let s=Pv.getComponent(a);if(s!==0){let l=wv.getComponent(a);Ov.multiplyMatrices(o.bones[l].matrixWorld,o.boneInverses[l]),t.addScaledVector($N.copy(Sv).applyMatrix4(Ov),s)}}return t.applyMatrix4(this.bindMatrixInverse)}};function YN(i){if(i.geometry.attributes.extrudeNormal||!i.geometry.attributes.position||!i.geometry.attributes.normal)return;let r=new Map,e=i.geometry.attributes,t=e.position.array,o=e.normal.array,n=new Float32Array(t.length);for(let a=0;a<t.length;a+=3){let s=`${t[a]}_${t[a+1]}_${t[a+2]}`,l=new yh(o[a],o[a+1],o[a+2]);r.has(s)?r.get(s)?.normals.push(l):r.set(s,{normals:[l],result:new yh})}r.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<t.length;a+=3){let s=`${t[a]}_${t[a+1]}_${t[a+2]}`,l=r.get(s)?.result;l&&(n[a]=l.x,n[a+1]=l.y,n[a+2]=l.z)}i.geometry.setAttribute("extrudeNormal",new Cv(n,3))}function KN(i){if(i.geometry.attributes.extrudeNormals||!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,t=new Float32Array(e.length),o=new yh;for(let n=0;n<e.length;n+=3)o.set(e[n],e[n+1],e[n+2]).normalize(),t[n]=o.x,t[n+1]=o.y,t[n+2]=o.z;i.geometry.setAttribute("extrudeNormal",new Cv(t,3))}function as(i){if(Array.isArray(i.material)){for(let r of i.material)if(r.getLayersOfType("outline").length===0)return}else if(!(i.material instanceof or)||i.material.getLayersOfType("outline").length===0)return;i instanceof et&&i.is2DAndNoDepth?KN(i):YN(i)}function ss(i){if(!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,t=new Float32Array(e.length),o=parseInt(i.uuid.replace(/\D/g,"")),n=[mh.seededRandom(o),mh.seededRandom(o+1e4),mh.seededRandom(o+2e4)];for(let a=0;a<e.length;a++)t[a]=n[a%3];i.geometry.setAttribute("randomColor",new XN(t,3))}var yo=new QN,wl=new JN;function Mv(i){let r=!1;return i.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="SubdivGeometry"&&(r=!0)}),r}var gn=class extends et{constructor(e,t,o){super(e,t,o);this.data=t;this.hiddenMatrixOld=new ZN;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,t){let o=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let t=this.localGeometry?.uuid,{originalGeometry:o,subdividedGeometry:n,subdivPointer:a}=gt.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,o!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=o),n!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=n??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,as(this),ss(this),this.calcBoundingBox(),t&&(this.localGeometry.uuid=t)}updateState(e,t){if(super.updateState(e,t),e.flatShading!==void 0){let o=this.material;this.material=Array.isArray(o)?o.map(n=>n.getFlavor(!1,n.side,n.wireframe)):o.getFlavor(!1,o.side,o.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(t)}}updateMesh(e=!1){gt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&gt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=gt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=gt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,t){let o=this.localGeometry;this.localGeometry=this.originalGeometryNew,Tt.prototype.raycast.call(this,e,t),this.localGeometry=o}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Av,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;yo.setFromBufferAttribute(t),yo.getCenter(o),e.boundingSphere.radius=o.distanceTo(yo.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),yo.getSize(wl),this.hasNonUniformScale&&wl.divide(this.scale);let n={width:wl.x,height:wl.y,depth:wl.z};return this.geometry.userData.parameters=n,n}updateBoundingSphere(e){let t=this.originalGeometry;yo.min.set(e[0],e[2],e[4]),yo.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(yo.min.applyMatrix4(this.shearScaleInv),yo.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new Av);let o=t.boundingSphere.center;yo.getCenter(o),t.boundingSphere.radius=o.distanceTo(yo.max)}freeSubdivPointer(){this.subdivPointer&&(gt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,t,o){super.updateByPatchedOpGeometry(e,t,o),this.localGeometry&&this.createGeometryByControls(t)}};import{Triangle as eD,Vector3 as bn}from"three";var Iv=-1,tD=1,Ev={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},Nv={polygon_center:0,edge:1,vertex:2},Pl=(i,r)=>(e,t)=>!r||e===0||i===0?0:i*t/100,Ce=(i,r)=>{let e=Math.abs(r),t=e*-1;return(i-Iv)*(e-t)/(tD-Iv)+t},rD=new bn,td=new bn,oD=new bn,iD=new bn;function ls(i,r){let e=oD.fromArray(i),t=iD.fromArray(r);td.copy(t).sub(e);let o=td.length();return td.normalize().multiplyScalar(o*.5),rD.copy(e).add(td).toArray()}var Or=new eD,rd=new bn,od=new bn,xn=new bn;function Dv(i){let r=[];for(let e=0;e<=i.index.count;e++)if(rd.fromArray(i.index.array,e*3),Or.setFromAttributeAndIndices(i.attributes.position,rd.x,rd.y,rd.z),Or.getNormal(od),Or.getMidpoint(xn),!(isNaN(xn.x)||isNaN(xn.y)||isNaN(xn.z))){let{a:t,b:o,c:n}=Or,a=t.toArray(),s=o.toArray(),l=n.toArray(),c=t.distanceTo(o),u=o.distanceTo(n),p=n.distanceTo(t),d=ls(a,s),f=ls(s,l),h=ls(l,a),m=[c,u,p],y=Math.max(...m),b=m.filter(O=>Math.round(O)===Math.round(y)).length>1,v=[],w=Or.getMidpoint(xn).toArray();y===c&&!b&&(v=[f,h,h],w=d),y===u&&!b&&(v=[d,h,h],w=f),y===p&&!b&&(v=[d,f,f],w=h),b&&(v=[d,f,h]),r.push({vertices:[a,s,l],faceCenters:v,midpoint:w,norm:Or.getNormal(od).toArray()})}return r}function _v(i){let r=[],{position:e}=i.attributes;for(let t=0;t<e.count;t++){Or.setFromAttributeAndIndices(e,t*3,t*3+1,t*3+2),Or.getNormal(od),Or.getMidpoint(xn);let o=Or.a.toArray(),n=Or.b.toArray(),a=Or.c.toArray();r.push({vertices:[o,n,a],faceCenters:[ls(o,n),ls(n,a),ls(a,o)],midpoint:xn.toArray(),norm:od.toArray()})}return r}var nD=4,aD=.5,gh=i=>.5*(1-Math.cos(i*Math.PI)),xh=class{constructor(){this.perlin=new Array(4095+1)}noise(r,e=0,t=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let b=0;b<4095+1;b++)this.perlin[b]=Math.random()}r<0&&(r=-r),e<0&&(e=-e),t<0&&(t=-t);let o=Math.floor(r),n=Math.floor(e),a=Math.floor(t),s=r-o,l=e-n,c=t-a,u,p,d=0,f=.5,h,m,y;for(let b=0;b<nD;b++){let v=o+(n<<4)+(a<<8);u=gh(s),p=gh(l),h=this.perlin[v&4095],h+=u*(this.perlin[v+1&4095]-h),m=this.perlin[v+16&4095],m+=u*(this.perlin[v+16+1&4095]-m),h+=p*(m-h),v+=256,m=this.perlin[v&4095],m+=u*(this.perlin[v+1&4095]-m),y=this.perlin[v+16&4095],y+=u*(this.perlin[v+16+1&4095]-y),m+=p*(y-m),h+=gh(c)*(m-h),d+=h*f,f*=aD,o<<=1,s*=2,n<<=1,l*=2,a<<=1,c*=2,s>=1&&(o++,s--),l>=1&&(n++,l--),c>=1&&(a++,c--)}return d}noiseSeed(r){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(r),this.perlin=new Array(4095+1);for(let t=0;t<4095+1;t++)this.perlin[t]=e.rand()}},Rv=xh;import{Vector3 as sD,Matrix4 as lD,Ray as cD}from"three";var Lv=new sD,Bv=new lD,Vv=new cD;function zv(i){let r=!1;return i.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&(t.geometry.type==="TextGeometry"||t.geometry.type==="InputGeometry")&&(r=!0)}),r}var Ai=class extends et{constructor(e,t,o){super(e,t,o);this.data=t}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,e.geometry.height,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,t){let{matrixWorld:o}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(Bv.copy(o).invert(),Vv.copy(e.ray).applyMatrix4(Bv),Vv.intersectBox(this.singleBBox,Lv))){let n=Lv.applyMatrix4(o),a=e.ray.origin.distanceTo(n);t.push({distance:a,point:n.clone(),object:this})}}};var Qt=1e-4,go,Uv,kv,Hv,Fv=new fr,jv=new fr;_u.then(i=>{go=i,Uv=[go.get_face_center,go.get_edge_midpoint,go.get_vertex_position],kv=[go.get_face_normal,go.get_edge_normal,go.get_vertex_normal],Hv=[go.face_count,go.edge_count,go.vertex_count]});var dD=new vn,pD=new vn,Mi=new fr,id=new fr,Ol=new fr,vh=new fr,fD=new fr,hD=new fr;var Sh=class{constructor(r,e){this.data=r;this.is3D=e;this.perlin=new Rv;r.noiseType==="perlin"?(this.perlin.noiseSeed(r.seed),e?this.noise=(o,n,a)=>this.perlin.noise(o,n,a):this.noise=o=>this.perlin.noise(o)):e?this.noise=ix((0,nd.default)(r.seed)):this.noise=ox((0,nd.default)(r.seed))}},Ii=class extends ga(uD){constructor(e,t){super();this.parameters=t;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.random=null;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let t of this.children)t instanceof Lr&&t.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(t=>{t instanceof Lr&&t.object===e&&(t.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let e of this.children)e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD())}_updateCount(e){let t;if(e!==void 0?t=e:t=this.parameters.type==="grid"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"){if(!this.parameters.toObject.object)t=0;else if(e===void 0&&this.parameters.toObject.spreadType!=="random")return}if(this.parameters.type==="toObject"&&this.objectForSample){let o=this.children;if(o.length===t)return;if(o.length<t)for(let n=0,a=t-o.length;n<a;++n){let s=new Lr(this.object);s.expand(),this.add(s)}else for(let n=0,a=o.length-t;n<a;++n)this.remove(o[n])}else{if(this.children.length===t)return;if(this.children.length<t)for(let o=0,n=t-this.children.length;o<n;++o){let a=new Lr(this.object);a.expand(),this.add(a)}else for(let o=0,n=this.children.length-t;o<n;++o)this.remove(this.children[o])}}getRandom(e,t=!1){return(this.random===null||this.random.data.seed!==e.seed||this.random.is3D!==t)&&(this.random=new Sh(e,t)),this.random}_updateRadial(e){let t=e.radial,o=t.start*Gv.DEG2RAD,n=t.end*Gv.DEG2RAD,a=o-n,s=new bh(t.rotation[0],t.rotation[1],t.rotation[2]),l;switch(t.axis){case"z":l=new fr(0,0,1);break;case"y":l=new fr(0,1,0);break;default:case"x":l=new fr(1,0,0);break}let c=e.randomnessObject??ro.defaultData([1,1,1]).randomnessObject,u=this.getRandom(c),p=Pl(c.strength,this.parameters.randomness);for(let[d,f]of this.children.entries()){let h=d*(c.freqScale/10)+c.movement,m=u.noise(h,h,h),y=d+1;f.scale.x=t.scale[0]+p(y,Ce(m,c.scale[0]))||Qt,f.scale.y=t.scale[1]+p(y,Ce(m,c.scale[1]))||Qt,f.scale.z=t.scale[2]+p(y,Ce(m,c.scale[2]))||Qt,f.position.setScalar(0);let b=a/e.count*d-o;switch(t.axis){case"x":f.rotation.set(0,b,0);break;case"y":f.rotation.set(0,0,b);break;case"z":f.rotation.set(b,0,0);break}f.translateOnAxis(l,t.radius),f.position.x+=t.position[0]+p(y,Ce(m,c.position[0])),f.position.y+=t.position[1]+p(y,Ce(m,c.position[1])),f.position.z+=t.position[2]+p(y,Ce(m,c.position[2]));let v=p(y,Ce(m,c.rotation[0])),w=p(y,Ce(m,c.rotation[1])),O=p(y,Ce(m,c.rotation[2]));t.alignment===!0?(f.rotation.x+=s.x+v,f.rotation.y+=s.y+w,f.rotation.z+=s.z+O):f.rotation.set(s.x+v,s.y+w,s.z+O)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,o=new bh(t.rotation[0],t.rotation[1],t.rotation[2]),n=e.randomnessObject??ro.defaultData([1,1,1]).randomnessObject,a=this.getRandom(n),s=Pl(n.strength,this.parameters.randomness);for(let[l,c]of this.children.entries()){let u=l*(n.freqScale/10)+n.movement,p=a.noise(u,u,u),d=l+1,f=s(d,Ce(p,n.rotation[0])),h=s(d,Ce(p,n.rotation[1])),m=s(d,Ce(p,n.rotation[2]));c.scale.x=1+(t.scale[0]-1)*l+s(d,Ce(p,n.scale[0]))||Qt,c.scale.y=1+(t.scale[1]-1)*l+s(d,Ce(p,n.scale[1]))||Qt,c.scale.z=1+(t.scale[2]-1)*l+s(d,Ce(p,n.scale[2]))||Qt,c.rotation.x=o.x*l+f,c.rotation.y=o.y*l+h,c.rotation.z=o.z*l+m,c.position.x=t.position[0]*l+s(d,Ce(p,n.position[0])),c.position.y=t.position[1]*l+s(d,Ce(p,n.position[1])),c.position.z=t.position[2]*l+s(d,Ce(p,n.position[2]))}}_updateGrid(e){let t=0,o=e.grid,n=e.randomnessObject??ro.defaultData([1,1,1]).randomnessObject,a=this.getRandom(n,!0),s=Pl(n.strength,this.parameters.randomness);if(o.useCenter===!0){let l={x:o.count[0]%2===0?2:1,y:o.count[1]%2===0?2:1,z:o.count[2]%2===0?2:1},c=new fr(o.size[0]*(o.count[0]-l.x)*.5,o.size[1]*(o.count[1]-l.y)*.5,o.size[2]*(o.count[2]-l.z)*.5);for(let u=0;u<o.count[0];u++)for(let p=0;p<o.count[1];p++)for(let d=0;d<o.count[2];d++){let f=a.noise((u+1)*(n.freqScale/10)+n.movement,(p+1)*(n.freqScale/10)+n.movement,(d+1)*(n.freqScale/10)+n.movement),h=this.children[t++];h.scale.x=1+s(t,Ce(f,n.scale[0]))||Qt,h.scale.y=1+s(t,Ce(f,n.scale[1]))||Qt,h.scale.z=1+s(t,Ce(f,n.scale[2]))||Qt;let m=s(t,Ce(f,n.rotation[0])),y=s(t,Ce(f,n.rotation[1])),b=s(t,Ce(f,n.rotation[2]));h.rotation.set(m,y,b),h.position.x=o.size[0]*u-c.x+s(t,Ce(f,n.position[0])),h.position.y=o.size[1]*p-c.y+s(t,Ce(f,n.position[1])),h.position.z=o.size[2]*d-c.z+s(t,Ce(f,n.position[2]))}}else for(let l=0;l<o.count[0];l++)for(let c=0;c<o.count[1];c++)for(let u=0;u<o.count[2];u++){let p=a.noise((l+1)*(n.freqScale/10)+n.movement,(c+1)*(n.freqScale/10)+n.movement,(u+1)*(n.freqScale/10)+n.movement),d=this.children[t++];d.scale.x=1+s(t,Ce(p,n.scale[0]))||Qt,d.scale.y=1+s(t,Ce(p,n.scale[1]))||Qt,d.scale.z=1+s(t,Ce(p,n.scale[2]))||Qt;let f=s(t,Ce(p,n.rotation[0])),h=s(t,Ce(p,n.rotation[1])),m=s(t,Ce(p,n.rotation[2]));d.rotation.set(f,h,m),d.position.x=o.size[0]*l+s(t,Ce(p,n.position[0])),d.position.y=-o.size[1]*c+s(t,Ce(p,n.position[1])),d.position.z=-o.size[2]*u+s(t,Ce(p,n.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:t}=e,o=new bh(t.rotation[0],t.rotation[1],t.rotation[2]),n=e.randomnessObject??ro.defaultData([1,1,1]).randomnessObject,a=this.getRandom(n),s=Pl(n.strength,this.parameters.randomness);if(!t.object){for(let[,d]of this.children.entries())d.position.set(0,0,0),d.scale.setScalar(1),d.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof Ai)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let l=this.getSubdivData();if(l.length>0){let d=Math.round(l.length*t.count/100);this._updateCount(d)}else{let d=this.objectForSample.geometry.getAttribute("position");if(!d||isNaN(d.count)||d.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let c=new su(this.objectForSample).build(),u=Ev[t.axis],p=this.children;c.setRandomGenerator((0,nd.default)(this.object.uuid+t.seed));for(let[d,f]of p.entries()){let h=d*(n.freqScale/10)+n.movement,m=a.noise(h,h,h),y=d+1,b=s(y,Ce(m,n.rotation[0])),v=s(y,Ce(m,n.rotation[1])),w=s(y,Ce(m,n.rotation[2]));t.spreadType==="random"?c.sample(Ol,vh):(l.length&&(Ol.fromArray(l[d].pos),vh.fromArray(l[d].norm)),this.objectForSample instanceof gn&&Ol.applyMatrix4(dD.copy(this.objectForSample.matrixWorld).invert())),Ol.applyMatrix4(this.object.hiddenMatrix.clone().invert()),f.position.copy(Ol),Mi.fromArray(u);let O=t.align==="normal"?vh:this.object.getWorldDirection(hD),S=id.fromArray(t.position);id.x+=s(y,Ce(m,n.position[0])),id.y+=s(y,Ce(m,n.position[1])),id.z+=s(y,Ce(m,n.position[2]));let T=Math.acos(O.dot(Mi)),M=fD.crossVectors(Mi,O).normalize(),g=pD.makeRotationAxis(M,T),D=O.clone().cross(this.object.up).normalize(),E=D.clone().cross(O).normalize(),I=new vn().makeBasis(D,O,E),N=new fr(Mi.y,Mi.z,Mi.x).normalize(),_=N.clone().cross(Mi).normalize(),R=new vn().makeBasis(N,Mi,_).invert(),V=new vn().multiplyMatrices(I,R);f.rotation.setFromRotationMatrix(V),S.applyMatrix4(g),f.position.add(S),f.rotation.x=f.rotation.x+o.x+b,f.rotation.y=f.rotation.y+o.y+v,f.rotation.z=f.rotation.z+o.z+w,f.scale.setScalar(1),f.scale.x=f.scale.x+t.scale[0]+s(y,Ce(m,n.scale[0]))||Qt,f.scale.y=f.scale.y+t.scale[1]+s(y,Ce(m,n.scale[1]))||Qt,f.scale.z=f.scale.z+t.scale[2]+s(y,Ce(m,n.scale[2]))||Qt,f.scale.multiply(this.object.scale),f.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType,t=new Map,o=(a,s)=>{let l=Math.round(a[0]*1e4)+"_"+Math.round(a[1]*1e4)+"_"+Math.round(a[2]*1e4),c=t.get(l);c?(c.pos[0]+=a[0],c.pos[1]+=a[1],c.pos[2]+=a[2],c.norm[0]+=s[0],c.norm[1]+=s[1],c.norm[2]+=s[2],c.count+=1):t.set(l,{pos:[...a],norm:[...s],count:1})};if(e==="random")return[];if(this.objectForSample instanceof gn){let a=this.objectForSample,s=Nv[e],l=Hv[s],c=Uv[s],u=kv[s],p=l(a.subdivPointerNew);for(let d=0;d<=p-1;d++){let f=c(a.subdivPointerNew,d),h=u(a.subdivPointerNew,d);Fv.fromArray(f).applyMatrix4(a.matrixWorld),jv.fromArray(h),o(Fv.toArray(),jv.toArray())}}else(this.objectForSample.geometry.index?Dv(this.objectForSample.geometry):_v(this.objectForSample.geometry)).forEach((s,l)=>{e==="polygon_center"&&o(s.midpoint,s.norm),e==="vertex"&&(o(s.vertices[0],s.norm),o(s.vertices[1],s.norm),o(s.vertices[2],s.norm)),e==="edge"&&(o(s.faceCenters[0],s.norm),o(s.faceCenters[1],s.norm),o(s.faceCenters[2],s.norm))});let n=Array.from(t.values());for(let a of n)a.pos[0]/=a.count,a.pos[1]/=a.count,a.pos[2]/=a.count,a.norm[0]/=a.count,a.norm[1]/=a.count,a.norm[2]/=a.count;return n}updateState(e,t){if(this.parameters=Mo(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let o=t.find(this.parameters.toObject.object);o instanceof Tt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new vn,this.hiddenMatrix=new vn,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};import{Scene as YR,Vector3 as KR,Matrix4 as QR,Box3 as ZR,MeshBasicMaterial as JR,Skeleton as eL}from"three";import{Camera as CD,OrthographicCamera as AD,PerspectiveCamera as MD,Vector3 as $r,Object3D as Xv,Quaternion as ID,Matrix4 as ED}from"three";import{Camera as vD,LineSegments as SD,BufferGeometry as wD,LineBasicMaterial as PD,Color as Ph,Vector3 as OD,Float32BufferAttribute as qv}from"three";import{BoxGeometry as mD}from"three";var xo=i=>{var r;return r=class extends i{},r.geometryHelper=new mD(30,30,30),r};import{Ray as yD,Sphere as gD,Matrix4 as xD,Vector3 as $o}from"three";var ad=new yD,wh=new gD,Wv=new xD,bo=(i,r,e,t,o=!1,n=i)=>{let a=r,s=n.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),wh.copy(a.boundingSphere),wh.applyMatrix4(s),e.ray.intersectsSphere(wh)===!1||(Wv.copy(s).invert(),ad.copy(e.ray).applyMatrix4(Wv),a.boundingBox!==null&&ad.intersectsBox(a.boundingBox)===!1))return;let l,c,u,p,d=a.index,f=a.attributes.position,h=a.drawRange,m,y;if(o===!1){let v=Math.max(0,h.start),w=Math.min(d.count,h.start+h.count);for(m=v,y=w;m<y;m+=3)if(c=d.getX(m),u=d.getX(m+1),p=d.getX(m+2),l=b(i,e,ad,f,c,u,p),l){l.faceIndex=Math.floor(m/3),t.push(l);return}}else{let w=a.attributes.position,O=new $o,S=new $o,T=new $o,M=new $o,g=2,E=1/((n.scale.x+n.scale.y+n.scale.z)/3),I=E*E,N=Math.max(0,h.start),_=Math.min(w.count,h.start+h.count);for(let R=N,V=_-1;R<V;R+=g){if(O.fromBufferAttribute(w,R),S.fromBufferAttribute(w,R+1),ad.distanceSqToSegment(O,S,M,T)>I)continue;M.applyMatrix4(n.matrixWorld);let B=e.ray.origin.distanceTo(M);B<e.near||B>e.far||t.push({distance:B,point:T.clone().applyMatrix4(n.matrixWorld),object:i})}}function b(v,w,O,S,T,M,g){let D=new $o,E=new $o,I=new $o,N=new $o,_=new $o;if(D.fromBufferAttribute(S,T),E.fromBufferAttribute(S,M),I.fromBufferAttribute(S,g),O.intersectTriangle(D,E,I,!1,N)===null)return null;_.copy(N),_.applyMatrix4(v.matrixWorld);let V=w.ray.origin.distanceTo(_);return V<w.near||V>w.far?null:{faceIndex:1,distance:V,point:_.clone(),object:v}}};var sd=new OD,Tr=new vD,Oh=class extends SD{constructor(e){let t=new wD,o=new PD({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],a=[],s={},l=new Ph(15711266),c=new Ph(15711266),u=new Ph(2857471);p("n1","n2",l),p("n2","n4",l),p("n4","n3",l),p("n3","n1",l),p("f1","f2",l),p("f2","f4",l),p("f4","f3",l),p("f3","f1",l),p("n1","f1",l),p("n2","f2",l),p("n3","f3",l),p("n4","f4",l),p("p","n1",c),p("p","n2",c),p("p","n3",c),p("p","n4",c),p("u1","u2",u),p("u2","u3",u),p("u3","u1",u);function p(f,h,m){d(f,m),d(h,m)}function d(f,h){n.push(0,0,0),a.push(h.r,h.g,h.b),s[f]===void 0&&(s[f]=[]),s[f].push(n.length/3-1)}t.setAttribute("position",new qv(n,3)),t.setAttribute("color",new qv(a,3));super(t,o);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,t=this.pointMap,o=!0;Tr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let n=1,a=1,s=o?.8:1e-4;qr("n1",t,e,Tr,-n,-a,s),qr("n2",t,e,Tr,n,-a,s),qr("n3",t,e,Tr,-n,a,s),qr("n4",t,e,Tr,n,a,s);let l=s;qr("f1",t,e,Tr,-n,-a,l),qr("f2",t,e,Tr,n,-a,l),qr("f3",t,e,Tr,-n,a,l),qr("f4",t,e,Tr,n,a,l);let c=l,u=.5;qr("u1",t,e,Tr,n*.7*u,a*1.1,c),qr("u2",t,e,Tr,-n*.7*u,a*1.1,c),qr("u3",t,e,Tr,0,a*(1.1+.9*u),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function qr(i,r,e,t,o,n,a){sd.set(o,n,a).unproject(t);let s=r[i];if(s!==void 0){let l=e.getAttribute("position");for(let c=0,u=s.length;c<u;c++)l.setXYZ(s[c],sd.x,sd.y,sd.z)}}var ld=class extends xo(Oh){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,t){bo(this.object,this.geometry,e,t,!0)}};import{Box3Helper as $v,BoxGeometry as TD}from"three";var cd;(r=>r.is=e=>"objectHelper"in e)(cd||(cd={}));var Cr=(i,r)=>class extends va(i){constructor(){super(...arguments);this.objectHelper=new r(this);this.gizmos={}}get geometryHelper(){return r.geometryHelper}raycast(o,n){this.objectHelper.raycast(o,n)}showGizmos(){for(let o in this.gizmos){let n=this.gizmos[o];n instanceof $v&&(n.visible=!0)}}updateEntityBoxSize(o,n){this.objectHelper.visible&&this.geometryHelper instanceof TD?(o.setScalar(0),n.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(o,n)}hideGizmos(){for(let o in this.gizmos){let n=this.gizmos[o];n instanceof $v&&(n.visible=!1)}}};var ud=790,cs=new $r,Th=new $r,Ch=new ID,Ah=new $r,Tl=new $r,Mh=new $r,Xo=class extends Cr(CD,ld){constructor(e="",t={...Ji.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=hi.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,t),this.previousProjectionMatrix=new ED,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,n=this.height;this.orthoCamera=new AD(o*-.5,o*.5,n*.5,n*-.5,-5e4,1e4),this.perspCamera=new MD(45,o/n,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,t,o){typeof e=="number"&&(e=new $r(e,t,o)),super.lookAt(e),this.getWorldPosition(cs),this.targetOffset=cs.distanceTo(e)}getTarget(e=new $r){return this.getWorldDirection(Th),this.getWorldPosition(cs),Th.multiplyScalar(this.targetOffset),e.copy(cs).add(Th),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(cs),cs.distanceTo(e)}updateUp(){this.getWorldQuaternion(Ch),Ah.set(0,0,1).applyQuaternion(Ch),Tl.copy(Xv.DEFAULT_UP),this.isUpVectorFlipped&&Tl.negate(),Tl.applyQuaternion(Ch),Mh.copy(Xv.DEFAULT_UP).projectOnPlane(Ah),this.angleOffsetFromUp=Mh.angleTo(Tl),this.angleOffsetFromUp*=Mh.cross(Tl).dot(Ah)>=0?1:-1}updateTransformState(e,t){let o=super.updateTransformState(e,t);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),o}getViewFrontToObject(e){let t=e.getWorldPosition(new $r),n=e.getWorldDirection(new $r).multiplyScalar(this.targetOffset);return{position:t.clone().add(n),target:t}}getViewToTarget(e){let o=this.getWorldDirection(new $r).multiplyScalar(this.targetOffset);return{position:e.clone().sub(o),target:e}}getViewToObject(e){let t=new $r,o=e.getWorldPosition(t);return this.getViewToTarget(t)}setViewplaneSize(e,t,o=!1){if(this.aspect=e/t,o){let n=e>t?this.aspect:1,a=e>t?1:this.aspect;this.left=-ud*.5*n,this.right=ud*.5*n,this.top=ud*.5*(1/a),this.bottom=-ud*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,t,o,n,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,o,n,a,s):this.orthoCamera.setViewOffset(e,t,o,n,a,s)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let t={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Yn(t,e)}updateCameraSubtype(e,t){let o=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";t.zoom!==void 0&&this.setZoom(o,t.zoom),t.near!==void 0&&this.setNear(o,t.near),t.fov!==void 0&&o==="PerspectiveCamera"&&(this.fov=t.fov)}updateState(e,t){this.updateCameraState(e,t)}updateCameraState(e,t){this.updateState_Entity(e,t),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}};import{MathUtils as Yne}from"three";import{BufferGeometry as Yv,Matrix4 as Kv,Float32BufferAttribute as ND}from"three";var us=new Kv,DD=new Kv;var nr=class extends ir{constructor(e,t,o){super(e,t);this.data=t;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new Yv;this.onAfterRender=(e,t,o,n,a,s)=>{super.onAfterRender(e,t,o,n,a,s),this.recomputeBoolean()};this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,t=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let n=0;n<this.children.length;n++){let a=this.children[n];a instanceof nr&&a.dataPatched.visible===!0&&a.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let n=0;n<this.children.length;n++){let a=this.children[n];if(a instanceof Tt&&a.dataPatched.visible===!0&&a.geometry.attributes.position?.count>0&&a.geometry.drawRange.count>0&&a.booleanMeshSetAddress!==0){us.multiplyMatrices(a.hiddenMatrix,a.matrix);try{if(a.booleanMeshSetAddress===-1){if((a.geometry.index??a.geometry.getAttribute("position")).count/3<15e5&&(a.booleanMeshSetAddress=wr.getMeshSet(a.geometry,e===!0,t)),a.booleanMeshSetAddress===-1)return;wr.transformMeshSet(a.booleanMeshSetAddress,us),a.booleanMatrixInvOld.copy(us).invert(),a.booleanWasTransformed=!1}else a instanceof nr&&a.needsTransformForDownstream===!0?(wr.transformMeshSet(a.booleanMeshSetAddress,us),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(wr.transformMeshSet(a.booleanMeshSetAddress,DD.multiplyMatrices(us,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(us).invert(),a.booleanWasTransformed=!1)}catch(s){console.error(s),a.booleanMeshSetAddress=0,a.geometry.userData.booleanOperationDidFail=!0;continue}wr.hasOpenEdges(a.booleanMeshSetAddress)===!1||n===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(a.booleanMeshSetAddress),a.geometry.userData.booleanOperationDidFail=!1):a.geometry.userData.booleanOperationDidFail="openEdges"}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new ND([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return wr.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new Yv,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=wr.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(n){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(n)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,as(this),ss(this)}dispose(){super.dispose(),this.geometry.dispose()}};import{Light as _D}from"three";var Qv;(r=>{function i(e){return De.is(e)&&e instanceof _D}r.is=i})(Qv||(Qv={}));var ds=(i,r)=>class extends Cr(i,r){updateState_Light(t,o){this.updateState_Entity(t,o),t.color!==void 0&&(this.color=o.shared.color(t.color)),t.intensity!==void 0&&(this.intensity=t.intensity),t.depth!==void 0&&(this.shadow.camera.far=t.depth,this.shadow.needsUpdate=!0),t.shadows!==void 0&&(this.castShadow=t.shadows)}};var Ei=i=>i instanceof Tt,Cl=i=>i!==null&&i instanceof nr;var Al=i=>cd.is(i);import{Group as GD}from"three";import{AxesHelper as RD,Group as LD,Quaternion as BD,Vector3 as Ih}from"three";var VD=new Ih(1,1,1),Zv=new Ih,zD=new Ih,Jv=new BD,Ar=class extends xo(RD){constructor(e,t=15){super(t);this.object=e;this.dummy=new LD;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,t){bo(this.object,Ar.geometryHelper,e,t,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(Zv,Jv,zD),this.matrix.compose(Zv,Jv,VD),super.updateMatrixWorld(e)}updateWorldMatrix(e,t){}};var Ni=class extends Cr(GD,Ar){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update()}updateState(r,e){this.updateState_Entity(r,e),"buffer"in r&&Object.keys(r).length===1&&e.scene.reloadSplats()}};import{Group as FD}from"three";var ps=class extends Cr(FD,Ar){constructor(e,t,o){super();this.super_Entity(e,t),this.context=o,this.objectHelper.update()}updateState(e,t){this.updateState_Entity(e,t)}};import{Color as M_,Fog as I_,HemisphereLight as E_}from"three";import{ShaderChunk as Ml}from"three";var jD=i=>`
2289
+ `)>=0&&(r-=n),t===3?e*.5-r*.5:t===2?e-r:0}getLineInitialOffsetY(r,e,t,o,n){let a=e*r,s=Math.abs(this.ascender-this.descender)*o,l=r-s,c=-this.ascender*o-l/2;return n===3?-(t-a-c):n===2?-(t*.5-a*.5-c):c}createPath(r,e,t,o,n){let a=r.getPath(t,-o,n.fontSize,{kerning:!1,letterSpacing:n.letterSpacing});if(!a){console.error('THREE.Font: character "'+r+'" does not exists in font family '+this.familyName+".");return}let s=new Qu,l=(r.advanceWidth??1)*e;if(r)for(let c of a.commands){let u=s.currentPath?.currentPoint;if(!(u&&c.type!=="Z"&&u.x===c.x&&-u.y===c.y))switch(c.type){case"M":s.moveTo(c.x,-c.y);break;case"L":s.lineTo(c.x,-c.y);break;case"Q":s.quadraticCurveTo(c.x1,-c.y1,c.x,-c.y);break;case"C":s.bezierCurveTo(c.x1,-c.y1,c.x2,-c.y2,c.x,-c.y);break}}return s.subPaths.forEach(c=>{let u=RD(c.curves);u!==void 0&&c.currentPoint.distanceTo(u)>0&&c.lineTo(u.x,u.y)}),{offsetX:l,path:s}}getCharWidth(r,e){return this.font?.getAdvanceWidth(r,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(r,e){return this.font?.getAdvanceWidth(r,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(r,e,t,o){let n=this.getCharWidth(" ",t),a=r[e];if(a){let s=this.countSpaces(a.trimEnd());if(t.horizontalAlign===4&&e<r.length-1&&s){let l=typeof t.width=="string"?Number(o.getVariable(t.width)):t.width,c=this.getTextWidth(a,t);return(l-(c-s*n))/s}}return n}countSpaces(r){return(r.match(/ /g)||[]).length}};function RD(i){if(i.length){let r=i[0];if(r instanceof ND)return r.v1;if(r instanceof ED||r instanceof DD)return r.v0}}var yh=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(r){return this.objects.get(r)}get size(){return this.objects.size}get(r,e,t){let o=this.objects.get(r);return o===void 0?(o=this.createObject(r,e,t),this.objects.set(r,o)):o.isShared=!0,o}forceDelete(r){let e=this.objects.get(r);e&&(this.disposeObject(e),this.objects.delete(r))}mutateIfUnique(r,e){let t=this.objects.get(r);if(t&&t.isShared!==!0)return this.objects.delete(r),this.objects.set(e,t),t}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(r,e){let t=this.objects.get(r);e===t?this.unreachable.delete(r):!1&&console.warn("Reachable but deleted",r)}endGc(){this.unreachable.forEach(r=>{this.disposeObject(this.objects.get(r)),this.objects.delete(r)}),this.unreachable.clear()}dispose(){this.objects.forEach(r=>{this.disposeObject(r)}),this.objects.clear()}},vl=class extends yh{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t,o){let n=jo(e,t,this.flatShading,o);return n.computeBoundingSphere(),n}};var Dv={markNeedsUpdateRendererDirty:()=>{}};import{MathUtils as Vv}from"three";var ed=1e3,_v=512*ed;function LD(i,r){let e=typeof i;return!!((r==="string"||r==="number")&&e===r||r==="boolean"&&(i==="true"||i==="false"||i===!0||i===!1)||r==="image"&&e==="string"&&i.startsWith("http"))}var Rv="https://hooks.spline.design",BD=`${Rv}/events?hashFile=`,eie=`${Rv}/`,td=class{constructor(r,e){this.id=r;this.userWebhook=e;this.result=void 0;this._connected=!1;this.emitter=Fo();this.reconnectWaitFor=ed;this._onError=r=>{this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this._scheduleReconnect()};this._onConnected=r=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=ed,this._connected=!0};this._onDisconnected=()=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=ed,this._connected=!1};this._onMessage=r=>{let e=r.data,t;try{t=JSON.parse(e)}catch(o){console.error("Error parsing webhook message",o)}if(t){let o=!1;this.userWebhook.parametersSchemas.forEach(({data:n})=>{t[n.name]!==void 0&&LD(t[n.name],n.type)&&(this.result===void 0&&(this.result={}),this.result[n.name]=t[n.name],o=!0)}),o&&this.emitter.emit("message",{userWebhookId:this.id})}}}connect(){clearTimeout(this.scheduledReconnectHandle),this.userWebhook.url&&(this.eventSource=new EventSource(BD+this.userWebhook.url),this.eventSource.addEventListener("message",this._onMessage),this.eventSource.addEventListener("error",this._onError),this.eventSource.addEventListener("open",this._onConnected))}disconnect(){this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this.eventSource?.close(),this._onDisconnected(),clearTimeout(this.scheduledReconnectHandle)}_scheduleReconnect(){this.reconnectWaitFor*=2,this.reconnectWaitFor>_v&&(this.reconnectWaitFor=_v),clearTimeout(this.scheduledReconnectHandle),this.scheduledReconnectHandle=setTimeout(()=>{this.scheduledReconnectHandle=void 0,this.connect()},this.reconnectWaitFor)}update(r){this.userWebhook=r}dispose(){this._connected&&this.disconnect()}get connected(){return this._connected}on(r,e){this.emitter.on(r,e)}off(r,e){this.emitter.off(r,e)}getParametersKeys(){return this.userWebhook.parametersSchemas.map(r=>r.data.name)}getParameterValue(r){if(this.getParametersKeys().includes(r)){if(this.result)return this.result?.[r];for(let t of this.userWebhook.parametersSchemas)if(t.data.name===r)return tu.defaultParameterValueByType(t.data.type)}}};var Lv=[4186.01,4434.92,4698.63,4978.03,5274.04,5587.65,5919.91,6271.93,6644.88,7040,7458.62,7902.13],VD=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],qo=[],od=[];for(let i=1;i<=8;i++)for(let r=0;r<Lv.length;r++){let e=Lv[r];qo.push(e/Math.pow(2,8-i)),od.push(VD[r]+i)}var rd=[32,2e3],gh=qo.filter((i,r)=>qo[r]>rd[0]&&qo[r]<rd[1]),Bv=od.filter((i,r)=>qo[r]>rd[0]&&qo[r]<rd[1]);var id=class{static getFrequencies(r,e,t,o="frequency",n=-100,a=-30){t||(t=new Float32Array(r.frequencyBinCount),r.getFloatFrequencyData(t));let s=e/2,l=1/t.length*s,c,u,p;if(o==="music"||o==="voice"){let h=o==="voice"?gh:qo,m=Array(h.length).fill(n);for(let y=0;y<t.length;y++){let b=y*l,v=t[y];for(let w=h.length-1;w>=0;w--)if(b>h[w]){m[w]=Math.max(m[w],v);break}}c=m,u=o==="voice"?gh:qo,p=o==="voice"?Bv:od}else c=Array.from(t),u=c.map((h,m)=>l*m),p=u.map(h=>`${h.toFixed(2)} Hz`);let d=c.map(h=>Math.max(0,Math.min((h-n)/(a-n),1)));return{values:new Float32Array(d),frequencies:u,labels:p}}};var zD="gpt-4o-realtime-preview-2024-12-17",GD=()=>!1&&window.location.search.includes("api-dev")?"https://relayserver-dev.spline.design/":"https://relayserver.spline.design/";async function FD(i){try{return(await(await fetch(GD()+"session?uuidfile="+i)).json()).token}catch(r){console.error("Token generation error:",r)}}var xh=class{constructor(r){this.value=0;this.frequencies=new Float32Array(0);let e=new AudioContext;this.source=e.createMediaStreamSource(r),this.analyser=e.createAnalyser(),this.source.connect(this.analyser),this.analyser.fftSize=8192,this.analyser.smoothingTimeConstant=.1}getFrequencies(r=-100,e=-30){if(!this.analyser)throw new Error("Not connected, please call .connect() first");return id.getFrequencies(this.analyser,44100,void 0,"voice",r,e)}update(){let r=this.getFrequencies(),e=r.values.reduce((t,o)=>t+o,0)/r.values.length;this.value=e,this.frequencies=r.values}disconnect(){this.source.disconnect(),this.analyser.disconnect()}},Sl=class{constructor(r,e,t){this.data=r;this.id=e;this.shared=t;this.emitter=Fo();this.rafId=0;this.voice=0;this.frequencies=new Float32Array([0]);this.events=[];this.isConnected=!1;this.isToolsAdded=!1;this.tools=[];this.onMessage=r=>{let e=JSON.parse(r.data);if(this.appendEvent(e),e.type==="session.created"&&this.onSessionCreated(),e.type==="response.done"&&e.response?.output){for(let t of e.response.output)if(t.type==="function_call")for(let[o,n]of this.tools)t.name===o.name&&(n(JSON.parse(t.arguments)),setTimeout(()=>{this.sendClientEvent({type:"response.create",response:{instructions:"notice the user about what you just did"}})}))}};this.onSessionCreated=()=>{this.isToolsAdded||this.registerTools()};this.onOpen=()=>{this.events=[],this.isConnected=!0,this.sendClientEvent({type:"response.create",response:{instructions:"Say hi"}})};this.animate=()=>{if(this.rafId=requestAnimationFrame(this.animate),this.isConnected&&this.analyser){this.analyser.update();let r=this.analyser.value,e=this.analyser.frequencies;this.voice=r,this.frequencies=e,this.emitter.emit("voice",{value:r,frequencies:e})}}}update(r){this.data=r}setColorByName(r,e){let t=this.shared.getColorByName(r);if(t){let{id:o}=t,{r:n,g:a,b:s}=Lb.hexStringToRgb(e)??{r:0,g:0,b:0};this.shared.updateColor(o,{r:n/255,g:a/255,b:s/255})}}async connect(){if(this.isConnected)return;let r=await FD(this.data.integration.hash);this.pc=new RTCPeerConnection,this.audioElement=document.createElement("audio"),this.audioElement.autoplay=!0,this.pc.ontrack=l=>{let c=l.streams[0];this.audioElement.srcObject=c,this.analyser=new xh(c)};let e=await navigator.mediaDevices.getUserMedia({audio:!0});this.pc.addTrack(e.getTracks()[0]),this.dc=this.pc.createDataChannel("oai-events"),this.dc.addEventListener("message",this.onMessage),this.dc.addEventListener("open",this.onOpen);let t=await this.pc.createOffer();await this.pc.setLocalDescription(t);let s={type:"answer",sdp:await(await fetch(`https://api.openai.com/v1/realtime?model=${zD}`,{method:"POST",body:t.sdp,headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/sdp"}})).text()};await this.pc.setRemoteDescription(s),this.animate()}appendEvent(r){this.events=[r,...this.events]}sendClientEvent(r){this.dc?(r.event_id=r.event_id||crypto.randomUUID(),this.dc.send(JSON.stringify(r)),this.appendEvent(r)):console.error("Failed to send message - no data channel available",r)}registerTools(){this.isToolsAdded=!0,this.registerTool({type:"function",name:"set_personality_color",description:"returns a color based on the voice personality of the ai assistant. This should be called by the voice assistant each time it is asks to speak differently. If a color cannot be associated to the personality, the color should be a neutral color.",parameters:{type:"object",properties:{color:{type:"string",description:"css hex color string, reflecting the personality"},personality:{type:"string",description:"the personality of the voice assistant"}},required:["color","personality"]}},({color:n})=>{this.setColorByName("Voice Assistant Color",n)});let r=this.shared.getVariablesNames().join(", ");this.registerTool({type:"function",name:"set_variable",description:"Sets a Spline variable value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the variable that needs to be set. Here's a list of available variables: ${r}. It the variable does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"The new value for this variable, should always be a string even for number and boolean variables, assume that the value will be cast to the proper type afterwards."}},required:["name","value","type"]}},({name:n,value:a})=>{let s=this.shared.getVariableByName(n);if(s){let l=this.shared.getVariable(s.id),c;typeof l=="number"?c=parseFloat(a):typeof l=="boolean"?c=a.toLowerCase()==="true":c={textValue:a},this.shared.updateVariable(s.id,c)}});let e=this.shared.getColorNames().join(", ");this.registerTool({type:"function",name:"set_color",description:"Sets a Spline color asset value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the color asset that needs to be set. Here's a list of available color assets: ${e}. It the color asset does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"css hex color string"}},required:["name","value"]}},({name:n,value:a})=>{this.setColorByName(n,a)});let t=this.shared.scene,o=[];t.traverseEntity(n=>{n.data.events.forEach(a=>{if(a.data.type==="AIAssistantTrigger"){let{description:s}=a.data;o.push(s)}})}),this.registerTool({type:"function",name:"trigger_event",description:"Trigger an event by name, here are the available events, please match what the user is asking for to one of these if it applies, otherwise don't call the function and warn the user.",parameters:{type:"object",properties:{description:{type:"string",description:`The name of the event that needs to be triggered. Here's a list of available events: ${JSON.stringify(o)}.`},direction:{type:"string",description:"default is forward, but can be forward or backward. Always set to forward unless the user ask to reverse or cancel the event, then set to backward."}},required:["description","direction"]}},({description:n,direction:a})=>{this.emitter.emit("trigger_event",{description:n,direction:a})}),this.sendClientEvent({type:"session.update",session:{tools:this.tools.map(([n])=>n)}})}registerTool(r,e){this.tools.push([r,e])}disconnect(){cancelAnimationFrame(this.rafId),this.analyser?.disconnect(),this.voice=0,this.isConnected=!1,this.isToolsAdded=!1,this.dc?.removeEventListener("message",this.onMessage),this.dc?.removeEventListener("open",this.onOpen),this.dc?.close(),this.pc?.getSenders().forEach(r=>{r.track&&r.track.stop()}),this.pc?.close(),this.pc=void 0}computeAnalysisForListenerEvent(r){if(r.analysis==="range"){let e=this.frequencies.slice(...r.analysisRange);return e.reduce((t,o)=>t+o,0)/e.length}return r.analysis==="single"?this.frequencies[r.analysisSingle]:this.voice}on(r,e){this.emitter.on(r,e)}off(r,e){this.emitter.off(r,e)}};function zv(i){return"variable_"+i}var bh=class extends $u{constructor(e){super();this.shared=e}create(e){return new is(e,this.shared)}},yn=class{constructor(r,e={},t=!0,o=!1){this.data=r;this.needsJitter=t;this.enableLocalStorageForPersistentVariables=o;this.geometryCache=new vl(!0);this.geometryCache2=new vl(!1);this.imageHolderCache=new bh(this);this.thisContext={scene:Dv,shared:this};this.deletedMaterial=new fn(Pt.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new pr(au.emptyImage,this);this.deletedVideo=new pr(aa.defaultVideo,this);this.materials={};this.images={};this.uiBuffers={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.variables={};this.userAPIs={};this.userWebhooks={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[n,a]of Object.entries(e.images))this.addImage(n,a);if(e.videos)for(let[n,a]of Object.entries(e.videos))this.addVideo(n,a);if(e.audios)for(let[n,a]of Object.entries(e.audios))this.addAudio(n,a);if(e.particles)for(let[n,a]of Object.entries(e.particles))this.addParticle(n,a);this.reset(r)}setRequestRender(r){this._requestRender=r}getImageLoadPromises(){return Object.values(this.images).map(r=>r.loadPromise)}setEntityOpContext(r){this.entityOpContext=r}reset(r,e=!1,t=!1){this.data=r,this.resetLib(r.lib);for(let{id:o,data:n}of r.variables)this.addVariableHolder(o,n),e&&this.updateVariableHolder(o,n);for(let[o,n]of Object.entries(r.userAPIs))this.addUserAPI(o,n);for(let[o,n]of Object.entries(r.userWebhooks))this.addUserWebhook(o,n);if(!t){for(let[o,n]of Object.entries(r.images))this.addImage(o,n);for(let[o,n]of Object.entries(r.videos))this.addVideo(o,n)}for(let[o,n]of Object.entries(r.colors))this.addColor(o,n);for(let[o,n]of Object.entries(r.materials))this.addMaterial(o,n);for(let[o,n]of Object.entries(r.audios))this.addAudio(o,n);for(let[o,n]of Object.entries(r.particles))this.addParticle(o,n);for(let[o,n]of Object.entries(r.fonts))this.addFont(o,n)}addMaterial(r,e){if(this.materials[r]){let t=this.materials[r];t.reset(e,this.thisContext),t.dispose()}else{let t=new fn(e,this.thisContext,r);this.materials[r]=t}}deleteMaterial(r){this.materials[r]&&(this.materials[r].nodeMaterialDispose(),delete this.materials[r])}getMaterial(r){let e=this.materials[r];return e}getMaterialOrDeletedPlaceholder(r){return this.materials[r]??this.deletedMaterial}material(r){return typeof r=="string"?this.getMaterialOrDeletedPlaceholder(r):r==null?(console.error("material is undefined or null"),this.deletedMaterial):new pn(r,this.thisContext)}getMaterials(){return this.materials}addImage(r,e){return this.images[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[r].updateSrc(e.data),!0):(this.images[r]=new pr(e,this),!1)}deleteImage(r){let e=this.images[r];e&&(e.dispose(),delete this.images[r])}getDefaultImage(){return this.images.image_0}getImage(r){return this.images[r]??this.deletedImage}image(r){return typeof r=="string"?this.getImage(r):this.imageHolderCache.load(r)}addUIBuffer(r,e){return this.uiBuffers[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[r].updateSrc(e),!0):(this.uiBuffers[r]=new pr(e,this),!1)}uiBuffer(r){return this.uiBuffers[r]}addVideo(r,e){return this.videos[r]?(this.videos[r].updateSrc(e.data),!0):(this.videos[r]=new pr(e,this),!1)}deleteVideo(r){let e=this.videos[r];e&&(e.dispose(),delete this.videos[r])}getVideo(r){return this.videos[r]??this.deletedVideo}video(r){return typeof r=="string"?this.getVideo(r):this.imageHolderCache.load(r)}addColor(r,e){return this.colors[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[r].setRGBA(e.r,e.g,e.b,e.a):this.colors[r].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[r]=new Oi(e.r,e.g,e.b,e.a):this.colors[r]=new Oi(e.r,e.g,e.b,1),!1)}updateColor(r,e){if(this.colors[r]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let t=this.colors[r];return this.colors[r].r=e.r??t.r,this.colors[r].g=e.g??t.g,this.colors[r].b=e.b??t.b,this.colors[r].a=e.a??t.a,!0}return!1}deleteColor(r){this.colors[r]&&delete this.colors[r]}getColor(r){return this.colors[r]}getColorNames(){return Object.values(this.data.colors).map(r=>r.name)}getColorByName(r){for(let e in this.data.colors)if(this.data.colors[e].name===r)return{color:this.colors[e],id:e}}color(r){let e;if(typeof r=="string"){let t=this.getColor(r);t?e=t:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new At(0,0,0,0))}else return"a"in r?new At(r.r,r.g,r.b,r.a):new At(r.r,r.g,r.b,1);return e}addAudio(r,e){this.audios[r]=e}getAudio(r){let e=this.audios[r];if(e instanceof hn)return e;{let t=new hn({src:e.data});return this.audios[r]=t,t}}addParticle(r,e){this.particles[r]=e}getParticle(r){return this.particles[r]}deleteParticle(r){this.particles[r]&&delete this.particles[r]}deleteAudio(r){let e=this.audios[r];e&&(e instanceof hn&&e.dispose(),delete this.audios[r])}addFont(r,e){this.fonts[r]=new Ju(e),this.fonts[r].loadingPromise.then(()=>this.requestRender())}getFont(r){return this.fonts[r]}deleteFont(r){this.fonts[r]&&delete this.fonts[r]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof hn&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(r,e){if(this.variables[r]===void 0){let t=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let o=localStorage.getItem(zv(r));t=o!==null?JSON.parse(o):e.value}return this.variables[r]={value:t,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[r].dynamicVariablePlayState="Playing",this.variables[r].dynamicVariableToggleIsForward=void 0),!0}return this.variables[r].value=e.value,!1}resetDynamicVariablePlayState(){for(let r in this.variables)this.variables[r].dynamicVariablePlayState!==void 0&&(this.variables[r].dynamicVariablePlayState="Playing",this.variables[r].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(r,e){this.updateVariable(r,e.value)}updateVariable(r,e){if(this.variables[r]===void 0)return!1;this.variables[r].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[r].persistent&&localStorage.setItem(zv(r),JSON.stringify(e));let t=e;for(;typeof t=="string";)t=this.variables[t].value;let o=this.entityOpContext.scene;for(let n=this.variables[r].locations.length-1;n>=0;n--){let a=this.variables[r].locations[n];if(a[0]==="material"){let s=a[1],l=t,c={scene:o,shared:this},u=a.slice(2);o.traverseMaterial(d=>{let f=d.root??d;f.uuid===s&&f.onVariableUpdate(u,l,c)});let p=this.materials[s];p&&p.onVariableUpdate(u,l,c)}else{let s=o.find(a[0]);if(s===void 0){this.variables[r].locations.splice(n,1);continue}if(a[1]!=="geometry"&&a[1]!=="particles"){for(let l=1;l<a.length-1;l++)s=s[a[l]];a[1]==="rotation"?s[a[a.length-1]]=t*Vv.DEG2RAD:s[a[a.length-1]]=t}if(s=o.find(a[0]),s.type==="ParticleEmitter"&&s.updateVariableState(t,a),De.is(s))if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")s.onVariableUpdate();else if(a[1]==="geometry"){let l=s;s.component&&(l=s.component);let c=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(c.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.invalidateDownstreamBooleanData(),l.instances.forEach(u=>{let p=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(p.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0),u.invalidateDownstreamBooleanData()})}else a[1]==="morphTargetInfluences"&&s.updateMorphInfluences(a[2],t)}}return this.requestRender(),!0}deleteVariable(r){this.variables[r]&&delete this.variables[r]}getVariable(r,e){if(Array.isArray(r)){if(r[0]==="mouse")return this.mouseProperty?.[r[1]]??0;if(r[0]==="raycast")return this.raycastProperty?.[r[1]]??0;let t=this.entityOpContext.scene.find(r[0]);if(r[1]==="width"||r[1]==="height"||r[1]==="depth")return t.geometry.userData.parameters[r[1]];for(let o=1;o<r.length;o++)t=t[r[o]];return r[1]==="rotation"&&(t*=Vv.RAD2DEG),t}for(let t in this.variables){if(e===void 0)break;let o=this.variables[t],n=o.locations?.findIndex(a=>Ze.equal(a,e));n!==void 0&&n!==-1&&o.locations.splice(n,1)}if(typeof r=="string"){let t=r,o=r;do{if(o=t,this.variables[t]===void 0)break;let n=this.variables[t].value;e&&this.variables[o]!==void 0&&this.variables[o].locations.push(e),t=n}while(typeof t=="string");return t}else return r}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(r=>r.data.name)}getVariableByName(r){for(let e of this.data.variables)if(e.data.name===r)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(r){return this.variables[r]?.dynamicVariablePlayState}setDynamicVariablePlayState(r,e){this.variables[r]!==void 0&&(this.variables[r].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(r){return this.variables[r]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(r,e){this.variables[r]!==void 0&&(this.variables[r].dynamicVariableToggleIsForward=e)}resetLib(r){for(let[e,t]of Object.entries(r.images))this.addImage(e,t.asset);for(let[e,t]of Object.entries(r.audios))this.addAudio(e,t.asset);for(let[e,t]of Object.entries(r.particles))this.addParticle(e,t.asset);for(let[e,t]of Object.entries(r.colors))this.addColor(e,t.asset);for(let[e,t]of Object.entries(r.fonts))this.addFont(e,t.asset);for(let[e,t]of Object.entries(r.materials))this.addMaterial(e,t.asset);for(let[e,t]of Object.entries(r.videos))this.addVideo(e,t.asset);for(let[e,t]of Object.entries(r.variables))this.addVariableHolder(e,t.asset)}updateLibByOp(r,e){r.path[0]==="images"?r.path.length===1&&r.type===1?this.addImage(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteImage(r.id):r.path[0]==="videos"?r.path.length===1&&r.type===1?this.addVideo(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteVideo(r.id):r.path[0]==="audios"?r.path.length===1&&r.type===1?this.addAudio(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteAudio(r.id):r.path[0]==="particles"?r.path.length===1&&r.type===1?this.addParticle(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteParticle(r.id):r.path[0]==="colors"?r.path.length===1&&r.type===1?this.addColor(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteColor(r.id):r.path[0]==="materials"?r.path.length===1&&r.type===1?this.addMaterial(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteMaterial(r.id):r.path[0]==="fonts"?r.path.length===1&&r.type===1?this.addFont(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteFont(r.id):r.path[0]==="variables"?r.path.length===1&&r.type===1?this.addVariableHolder(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteVariable(r.id):r.path[0]==="components"&&e.updateByLibOp(r,this)}updateByOp(r,e,t){if(this.data=e,r.path[0]==="images")r.path.length===2&&r.type===0?r.props.data&&this.getImage(r.path[1]).updateSrc(r.props.data):r.path.length===1&&r.type===1?this.addImage(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteImage(r.id);else if(r.path[0]==="videos")r.path.length===2&&r.type===0?r.props.data&&this.getVideo(r.path[1]).updateSrc(r.props.data):r.path.length===1&&r.type===1?this.addVideo(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteVideo(r.id);else if(r.path[0]==="audios")r.path.length===2&&r.type===0?r.props.data&&this.addAudio(r.path[1],e.audios[r.path[1]]):r.path.length===1&&r.type===1?this.addAudio(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteAudio(r.id);else if(r.path[0]==="particles")r.path.length===2&&r.type===0?r.props.data&&this.addParticle(r.path[1],e.particles[r.path[1]]):r.path.length===1&&r.type===1?this.addParticle(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteParticle(r.id);else if(r.path[0]==="colors")r.path.length===2&&r.type===0?this.updateColor(r.path[1],r.props):r.path.length===1&&r.type===1?this.addColor(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteColor(r.id);else if(r.path[0]==="materials")r.path.length===1&&r.type===1?this.addMaterial(r.id,r.data):r.path.length===1&&r.type===2?this.deleteMaterial(r.id):r.path.length>1&&this.getMaterial(r.path[1]).updateByOp(nt.drop(r,2),e.materials[r.path[1]],{shared:this,scene:t});else if(r.path[0]==="fonts")r.path.length===2&&r.type===0?this.updateFont(r.path[1],r,t):r.path.length===1&&r.type===1?this.addFont(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteFont(r.id);else if(r.path[0]==="variables")r.path.length===2&&r.type===0?"value"in r.props?this.updateVariable(r.path[1],r.props.value):"persistent"in r.props&&(this.variables[r.path[1]].persistent=r.props.persistent):r.path.length===1&&r.type===4?this.addVariableHolder(r.id,r.data):r.path.length===1&&r.type===5&&this.deleteVariable(r.id);else if(r.path[0]==="userAPIs"){if(r.path.length===1&&r.type===1)this.addUserAPI(r.id,r.data);else if(r.path.length===1&&r.type===2)this.deleteUserAPI(r.id);else if(typeof r.path[1]=="string"){let o=e.userAPIs[r.path[1]];if(o){let n=r.type===0&&r.props.debounce===void 0,a=this.getUserAPI(r.path[1]);a instanceof Sl?a.update(o):a?.update(o,this,n)}}}else if(r.path[0]==="userWebhooks"){if(r.path.length===1&&r.type===1)this.addUserWebhook(r.id,r.data);else if(r.path.length===1&&r.type===2)this.deleteUserWebhook(r.id);else if(typeof r.path[1]=="string"){let o=e.userWebhooks[r.path[1]];o&&this.getUserWebhook(r.path[1])?.update(o)}}else r.path[0]==="lib"&&this.updateLibByOp(nt.drop(r,1),t)}updateFont(r,e,t){if(e.props.url){let o=this.getFont(r),n={...this.data.fonts[r],url:e.props.url};o.update(n),o.loadingPromise.then(()=>this.requestRender()),t.updateFont(r,this)}}addUserAPI(r,e){return this.userAPIs[r]?(this.userAPIs[r].update(e,this),!0):this.openAIRealtime?.id===r?(this.openAIRealtime.update(e),!0):e.integration?.type==="VoiceAssistant"?(this.openAIRealtime=new Sl(e,r,this),!1):(this.userAPIs[r]=new Ru(r,e,this),!1)}getUserAPI(r){return this.openAIRealtime?.id===r?this.openAIRealtime:this.userAPIs[r]}getUserAPIs(){return this.userAPIs}deleteUserAPI(r){let e=this.userAPIs[r];e&&(e.dispose(),delete this.userAPIs[r])}addUserWebhook(r,e){return this.userWebhooks[r]?(this.userWebhooks[r].update(e),!0):(this.userWebhooks[r]=new td(r,e),!1)}getUserWebhook(r){return this.userWebhooks[r]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(r){let e=this.userWebhooks[r];e&&(e.dispose(),delete this.userWebhooks[r])}get scene(){return this.entityOpContext.scene}},Gv=new yn(vr.emptyData());var ir=class extends Tt{updateByPatchedOp(e,t,o){if(super.updateByPatchedOp(e,t,o),h0(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[n,a]of Object.entries(e.props)){let s=o.shared.material(a);this.material[Number(n)]=s}else if(Le(e.path,["material"])&&this.material instanceof or)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(nt.drop(e,1),t.material,o);else if(Le(e.path,["materials","*"])&&Array.isArray(this.material)){let n=e.path[1];if("materials"in t&&n<this.material.length){let a=t.materials[n];typeof a!="string"&&this.material[n].updateByOp(nt.drop(e,2),a,o)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}updateState(e,t){super.updateState(e,t),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let o=this.dataPatched;this.dataPatched.type==="Mesh"&&!!this.dataPatched.geometry.shapeBlendNode&&this.layers.set(9);let a;if(this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(a={resolutionLevel:this.dataPatched.geometry.resolutionLevel,useChildrenColors:this.dataPatched.geometry.useChildrenColors}),e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=t.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe,a),t.scene.markNeedsUpdateRendererDirty()),(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(s=>t.shared.material(s).getFlavor(o.flatShading,o.side,o.wireframe)),t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[t.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe)],t.scene.markNeedsUpdateRendererDirty())),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let s=0;s<this.material.length;s++)this.material[s]=this.material[s].getFlavor(o.flatShading,o.side,o.wireframe);else this.material=this.material.getFlavor(o.flatShading,o.side,o.wireframe,a)}disposeMaterial(){this.material&&Wl(this.material).forEach(e=>{e instanceof or&&(e instanceof fn||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};import{BufferGeometry as UD,Matrix4 as Sh,Vector3 as Hv,Vector4 as wh}from"three";var Fv=new Hv,jv=new wh,Uv=new wh,kD=new Hv,kv=new Sh,et=class extends ir{constructor(e,t,o){super(e,t);this.data=t;this.isSkinnedMesh=!1;this.localGeometry=void 0,t.bindMode&&t.bindMatrix&&(this.bindMode=t.bindMode,this.bindMatrix=new Sh().fromArray(t.bindMatrix),this.bindMatrixInverse=new Sh)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof UD&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof yn){let e=this.geometryCreateDeleyed,t=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=t.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return Fs.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return Fs.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),Le(e.path,["geometry"])&&this.updateByPatchedOpGeometry(nt.drop(e,1),t.geometry,o)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,t){this.invalidateDownstreamBooleanData();let o=this.data.geometry.type;if(o==="NonParametricGeometry"||o==="SubdivGeometry"){let n=e;if(this.localGeometry===void 0){let u={...this.data.geometry,...n};this.localGeometry=jo(u,t,this.data.flatShading,this)}let a,s,l;n.scaleBaked?[a,s,l]=n.scaleBaked:{width:a,height:s,depth:l}=n;let c=this.localGeometry.userData;c.sxPrev!==void 0&&ll(this.localGeometry.attributes,a/c.sxPrev,s/c.syPrev,l/c.szPrev),c.sxPrev=a,c.syPrev=s,c.szPrev=l}else{let n={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=jo(n,t,this.data.flatShading,this)}}refreshAttachedClonersInteractions(){for(let e of this.attachedSurfaceCloners)e.update()}refreshAttachedCloners(e){for(let t of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(t.object)}refreshAttachedPaths(e){for(let t of this.attachedPaths)e.scene.addPendingCommand(()=>t.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,t,o){let n=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof gt&&this.chooseGeoemtryCache(o.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(n=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(t,e.props.scaleBaked),this.refreshAttachedCloners(o),this.refreshAttachedPaths(o)),n||(o.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(o)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,t){this.createGeometryDelayed(t)}updateState(e,t){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,t);let o=e.morphTargetInfluences;if(o){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:n,value:a}}of o)this.updateMorphInfluences(n,t.shared.getVariable(a,[this.uuid,"morphTargetInfluences",n]))}super.updateState(e,t)}updateMorphInfluences(e,t){if(this.morphTargetDictionary===void 0)return;let o=this.morphTargetDictionary[e];o!==void 0&&(this.morphTargetInfluences[o]=t)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,t){let o=this.geometry.userData.parameters;this.is2DType?e.set(0,0,o.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)):o.centerOffset?e.fromArray(o.centerOffset):e.setScalar(0),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,t){this.skeleton=e,this.isSkinnedMesh=!0,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let t=new wh,o=this.geometry.attributes.skinWeight;for(let n=0,a=o.count;n<a;n++){t.fromBufferAttribute(o,n);let s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),o.setXYZW(n,t.x,t.y,t.z,t.w)}}boneTransform(e,t){let o=this.skeleton;if(o===void 0)return;let n=this.geometry;jv.fromBufferAttribute(n.attributes.skinIndex,e),Uv.fromBufferAttribute(n.attributes.skinWeight,e),Fv.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let a=0;a<4;a++){let s=Uv.getComponent(a);if(s!==0){let l=jv.getComponent(a);kv.multiplyMatrices(o.bones[l].matrixWorld,o.boneInverses[l]),t.addScaledVector(kD.copy(Fv).applyMatrix4(kv),s)}}return t.applyMatrix4(this.bindMatrixInverse)}};function WD(i){if(i.geometry.attributes.extrudeNormal||!i.geometry.attributes.position||!i.geometry.attributes.normal)return;let r=new Map,e=i.geometry.attributes,t=e.position.array,o=e.normal.array,n=new Float32Array(t.length);for(let a=0;a<t.length;a+=3){let s=`${t[a]}_${t[a+1]}_${t[a+2]}`,l=new Oh(o[a],o[a+1],o[a+2]);r.has(s)?r.get(s)?.normals.push(l):r.set(s,{normals:[l],result:new Oh})}r.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<t.length;a+=3){let s=`${t[a]}_${t[a+1]}_${t[a+2]}`,l=r.get(s)?.result;l&&(n[a]=l.x,n[a+1]=l.y,n[a+2]=l.z)}i.geometry.setAttribute("extrudeNormal",new Wv(n,3))}function qD(i){if(i.geometry.attributes.extrudeNormals||!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,t=new Float32Array(e.length),o=new Oh;for(let n=0;n<e.length;n+=3)o.set(e[n],e[n+1],e[n+2]).normalize(),t[n]=o.x,t[n+1]=o.y,t[n+2]=o.z;i.geometry.setAttribute("extrudeNormal",new Wv(t,3))}function as(i){if(Array.isArray(i.material)){for(let r of i.material)if(r.getLayersOfType("outline").length===0)return}else if(!(i.material instanceof or)||i.material.getLayersOfType("outline").length===0)return;i instanceof et&&i.is2DAndNoDepth?qD(i):WD(i)}function ss(i){if(!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,t=new Float32Array(e.length),o=parseInt(i.uuid.replace(/\D/g,"")),n=[Ph.seededRandom(o),Ph.seededRandom(o+1e4),Ph.seededRandom(o+2e4)];for(let a=0;a<e.length;a++)t[a]=n[a%3];i.geometry.setAttribute("randomColor",new HD(t,3))}var yo=new $D,wl=new YD;function $v(i){let r=!1;return i.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="SubdivGeometry"&&(r=!0)}),r}var gn=class extends et{constructor(e,t,o){super(e,t,o);this.data=t;this.hiddenMatrixOld=new XD;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,t){let o=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let t=this.localGeometry?.uuid,{originalGeometry:o,subdividedGeometry:n,subdivPointer:a}=gt.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,o!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=o),n!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=n??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,as(this),ss(this),this.calcBoundingBox(),t&&(this.localGeometry.uuid=t)}updateState(e,t){if(super.updateState(e,t),e.flatShading!==void 0){let o=this.material;this.material=Array.isArray(o)?o.map(n=>n.getFlavor(!1,n.side,n.wireframe)):o.getFlavor(!1,o.side,o.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(t)}}updateMesh(e=!1){gt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&gt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=gt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=gt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,t){let o=this.localGeometry;this.localGeometry=this.originalGeometryNew,Tt.prototype.raycast.call(this,e,t),this.localGeometry=o}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new qv,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;yo.setFromBufferAttribute(t),yo.getCenter(o),e.boundingSphere.radius=o.distanceTo(yo.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),yo.getSize(wl),this.hasNonUniformScale&&wl.divide(this.scale);let n={width:wl.x,height:wl.y,depth:wl.z};return this.geometry.userData.parameters=n,n}updateBoundingSphere(e){let t=this.originalGeometry;yo.min.set(e[0],e[2],e[4]),yo.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(yo.min.applyMatrix4(this.shearScaleInv),yo.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new qv);let o=t.boundingSphere.center;yo.getCenter(o),t.boundingSphere.radius=o.distanceTo(yo.max)}freeSubdivPointer(){this.subdivPointer&&(gt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,t,o){super.updateByPatchedOpGeometry(e,t,o),this.localGeometry&&this.createGeometryByControls(t)}};import{Triangle as KD,Vector3 as bn}from"three";var Xv=-1,QD=1,Yv={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},Kv={polygon_center:0,edge:1,vertex:2},Pl=(i,r)=>(e,t)=>!r||e===0||i===0?0:i*t/100,Ce=(i,r)=>{let e=Math.abs(r),t=e*-1;return(i-Xv)*(e-t)/(QD-Xv)+t},ZD=new bn,nd=new bn,JD=new bn,e_=new bn;function ls(i,r){let e=JD.fromArray(i),t=e_.fromArray(r);nd.copy(t).sub(e);let o=nd.length();return nd.normalize().multiplyScalar(o*.5),ZD.copy(e).add(nd).toArray()}var Or=new KD,ad=new bn,sd=new bn,xn=new bn;function Qv(i){let r=[];for(let e=0;e<=i.index.count;e++)if(ad.fromArray(i.index.array,e*3),Or.setFromAttributeAndIndices(i.attributes.position,ad.x,ad.y,ad.z),Or.getNormal(sd),Or.getMidpoint(xn),!(isNaN(xn.x)||isNaN(xn.y)||isNaN(xn.z))){let{a:t,b:o,c:n}=Or,a=t.toArray(),s=o.toArray(),l=n.toArray(),c=t.distanceTo(o),u=o.distanceTo(n),p=n.distanceTo(t),d=ls(a,s),f=ls(s,l),h=ls(l,a),m=[c,u,p],y=Math.max(...m),b=m.filter(O=>Math.round(O)===Math.round(y)).length>1,v=[],w=Or.getMidpoint(xn).toArray();y===c&&!b&&(v=[f,h,h],w=d),y===u&&!b&&(v=[d,h,h],w=f),y===p&&!b&&(v=[d,f,f],w=h),b&&(v=[d,f,h]),r.push({vertices:[a,s,l],faceCenters:v,midpoint:w,norm:Or.getNormal(sd).toArray()})}return r}function Zv(i){let r=[],{position:e}=i.attributes;for(let t=0;t<e.count;t++){Or.setFromAttributeAndIndices(e,t*3,t*3+1,t*3+2),Or.getNormal(sd),Or.getMidpoint(xn);let o=Or.a.toArray(),n=Or.b.toArray(),a=Or.c.toArray();r.push({vertices:[o,n,a],faceCenters:[ls(o,n),ls(n,a),ls(a,o)],midpoint:xn.toArray(),norm:sd.toArray()})}return r}var t_=4,r_=.5,Th=i=>.5*(1-Math.cos(i*Math.PI)),Ch=class{constructor(){this.perlin=new Array(4095+1)}noise(r,e=0,t=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let b=0;b<4095+1;b++)this.perlin[b]=Math.random()}r<0&&(r=-r),e<0&&(e=-e),t<0&&(t=-t);let o=Math.floor(r),n=Math.floor(e),a=Math.floor(t),s=r-o,l=e-n,c=t-a,u,p,d=0,f=.5,h,m,y;for(let b=0;b<t_;b++){let v=o+(n<<4)+(a<<8);u=Th(s),p=Th(l),h=this.perlin[v&4095],h+=u*(this.perlin[v+1&4095]-h),m=this.perlin[v+16&4095],m+=u*(this.perlin[v+16+1&4095]-m),h+=p*(m-h),v+=256,m=this.perlin[v&4095],m+=u*(this.perlin[v+1&4095]-m),y=this.perlin[v+16&4095],y+=u*(this.perlin[v+16+1&4095]-y),m+=p*(y-m),h+=Th(c)*(m-h),d+=h*f,f*=r_,o<<=1,s*=2,n<<=1,l*=2,a<<=1,c*=2,s>=1&&(o++,s--),l>=1&&(n++,l--),c>=1&&(a++,c--)}return d}noiseSeed(r){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(r),this.perlin=new Array(4095+1);for(let t=0;t<4095+1;t++)this.perlin[t]=e.rand()}},Jv=Ch;import{Vector3 as o_,Matrix4 as i_,Ray as n_}from"three";var e1=new o_,t1=new i_,r1=new n_;function o1(i){let r=!1;return i.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&(t.geometry.type==="TextGeometry"||t.geometry.type==="InputGeometry")&&(r=!0)}),r}var Ai=class extends et{constructor(e,t,o){super(e,t,o);this.data=t}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,e.geometry.height,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,t){let{matrixWorld:o}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(t1.copy(o).invert(),r1.copy(e.ray).applyMatrix4(t1),r1.intersectBox(this.singleBBox,e1))){let n=e1.applyMatrix4(o),a=e.ray.origin.distanceTo(n);t.push({distance:a,point:n.clone(),object:this})}}};var Qt=1e-4,go,s1,l1,c1,n1=new fr,a1=new fr;Vu.then(i=>{go=i,s1=[go.get_face_center,go.get_edge_midpoint,go.get_vertex_position],l1=[go.get_face_normal,go.get_edge_normal,go.get_vertex_normal],c1=[go.face_count,go.edge_count,go.vertex_count]});var s_=new vn,l_=new vn,Mi=new fr,ld=new fr,Ol=new fr,Mh=new fr,c_=new fr,u_=new fr;var Ih=class{constructor(r,e){this.data=r;this.is3D=e;this.perlin=new Jv;r.noiseType==="perlin"?(this.perlin.noiseSeed(r.seed),e?this.noise=(o,n,a)=>this.perlin.noise(o,n,a):this.noise=o=>this.perlin.noise(o)):e?this.noise=Px((0,cd.default)(r.seed)):this.noise=wx((0,cd.default)(r.seed))}},Ii=class extends ga(a_){constructor(e,t){super();this.parameters=t;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.random=null;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let t of this.children)t instanceof Lr&&t.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(t=>{t instanceof Lr&&t.object===e&&(t.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let e of this.children)e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD())}_updateCount(e){let t;if(e!==void 0?t=e:t=this.parameters.type==="grid"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"){if(!this.parameters.toObject.object)t=0;else if(e===void 0&&this.parameters.toObject.spreadType!=="random")return}if(this.parameters.type==="toObject"&&this.objectForSample){let o=this.children;if(o.length===t)return;if(o.length<t)for(let n=0,a=t-o.length;n<a;++n){let s=new Lr(this.object);s.expand(),this.add(s)}else for(let n=0,a=o.length-t;n<a;++n)this.remove(o[n])}else{if(this.children.length===t)return;if(this.children.length<t)for(let o=0,n=t-this.children.length;o<n;++o){let a=new Lr(this.object);a.expand(),this.add(a)}else for(let o=0,n=this.children.length-t;o<n;++o)this.remove(this.children[o])}}getRandom(e,t=!1){return(this.random===null||this.random.data.seed!==e.seed||this.random.is3D!==t)&&(this.random=new Ih(e,t)),this.random}_updateRadial(e){let t=e.radial,o=t.start*i1.DEG2RAD,n=t.end*i1.DEG2RAD,a=o-n,s=new Ah(t.rotation[0],t.rotation[1],t.rotation[2]),l;switch(t.axis){case"z":l=new fr(0,0,1);break;case"y":l=new fr(0,1,0);break;default:case"x":l=new fr(1,0,0);break}let c=e.randomnessObject??ro.defaultData([1,1,1]).randomnessObject,u=this.getRandom(c),p=Pl(c.strength,this.parameters.randomness);for(let[d,f]of this.children.entries()){let h=d*(c.freqScale/10)+c.movement,m=u.noise(h,h,h),y=d+1;f.scale.x=t.scale[0]+p(y,Ce(m,c.scale[0]))||Qt,f.scale.y=t.scale[1]+p(y,Ce(m,c.scale[1]))||Qt,f.scale.z=t.scale[2]+p(y,Ce(m,c.scale[2]))||Qt,f.position.setScalar(0);let b=a/e.count*d-o;switch(t.axis){case"x":f.rotation.set(0,b,0);break;case"y":f.rotation.set(0,0,b);break;case"z":f.rotation.set(b,0,0);break}f.translateOnAxis(l,t.radius),f.position.x+=t.position[0]+p(y,Ce(m,c.position[0])),f.position.y+=t.position[1]+p(y,Ce(m,c.position[1])),f.position.z+=t.position[2]+p(y,Ce(m,c.position[2]));let v=p(y,Ce(m,c.rotation[0])),w=p(y,Ce(m,c.rotation[1])),O=p(y,Ce(m,c.rotation[2]));t.alignment===!0?(f.rotation.x+=s.x+v,f.rotation.y+=s.y+w,f.rotation.z+=s.z+O):f.rotation.set(s.x+v,s.y+w,s.z+O)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,o=new Ah(t.rotation[0],t.rotation[1],t.rotation[2]),n=e.randomnessObject??ro.defaultData([1,1,1]).randomnessObject,a=this.getRandom(n),s=Pl(n.strength,this.parameters.randomness);for(let[l,c]of this.children.entries()){let u=l*(n.freqScale/10)+n.movement,p=a.noise(u,u,u),d=l+1,f=s(d,Ce(p,n.rotation[0])),h=s(d,Ce(p,n.rotation[1])),m=s(d,Ce(p,n.rotation[2]));c.scale.x=1+(t.scale[0]-1)*l+s(d,Ce(p,n.scale[0]))||Qt,c.scale.y=1+(t.scale[1]-1)*l+s(d,Ce(p,n.scale[1]))||Qt,c.scale.z=1+(t.scale[2]-1)*l+s(d,Ce(p,n.scale[2]))||Qt,c.rotation.x=o.x*l+f,c.rotation.y=o.y*l+h,c.rotation.z=o.z*l+m,c.position.x=t.position[0]*l+s(d,Ce(p,n.position[0])),c.position.y=t.position[1]*l+s(d,Ce(p,n.position[1])),c.position.z=t.position[2]*l+s(d,Ce(p,n.position[2]))}}_updateGrid(e){let t=0,o=e.grid,n=e.randomnessObject??ro.defaultData([1,1,1]).randomnessObject,a=this.getRandom(n,!0),s=Pl(n.strength,this.parameters.randomness);if(o.useCenter===!0){let l={x:o.count[0]%2===0?2:1,y:o.count[1]%2===0?2:1,z:o.count[2]%2===0?2:1},c=new fr(o.size[0]*(o.count[0]-l.x)*.5,o.size[1]*(o.count[1]-l.y)*.5,o.size[2]*(o.count[2]-l.z)*.5);for(let u=0;u<o.count[0];u++)for(let p=0;p<o.count[1];p++)for(let d=0;d<o.count[2];d++){let f=a.noise((u+1)*(n.freqScale/10)+n.movement,(p+1)*(n.freqScale/10)+n.movement,(d+1)*(n.freqScale/10)+n.movement),h=this.children[t++];h.scale.x=1+s(t,Ce(f,n.scale[0]))||Qt,h.scale.y=1+s(t,Ce(f,n.scale[1]))||Qt,h.scale.z=1+s(t,Ce(f,n.scale[2]))||Qt;let m=s(t,Ce(f,n.rotation[0])),y=s(t,Ce(f,n.rotation[1])),b=s(t,Ce(f,n.rotation[2]));h.rotation.set(m,y,b),h.position.x=o.size[0]*u-c.x+s(t,Ce(f,n.position[0])),h.position.y=o.size[1]*p-c.y+s(t,Ce(f,n.position[1])),h.position.z=o.size[2]*d-c.z+s(t,Ce(f,n.position[2]))}}else for(let l=0;l<o.count[0];l++)for(let c=0;c<o.count[1];c++)for(let u=0;u<o.count[2];u++){let p=a.noise((l+1)*(n.freqScale/10)+n.movement,(c+1)*(n.freqScale/10)+n.movement,(u+1)*(n.freqScale/10)+n.movement),d=this.children[t++];d.scale.x=1+s(t,Ce(p,n.scale[0]))||Qt,d.scale.y=1+s(t,Ce(p,n.scale[1]))||Qt,d.scale.z=1+s(t,Ce(p,n.scale[2]))||Qt;let f=s(t,Ce(p,n.rotation[0])),h=s(t,Ce(p,n.rotation[1])),m=s(t,Ce(p,n.rotation[2]));d.rotation.set(f,h,m),d.position.x=o.size[0]*l+s(t,Ce(p,n.position[0])),d.position.y=-o.size[1]*c+s(t,Ce(p,n.position[1])),d.position.z=-o.size[2]*u+s(t,Ce(p,n.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:t}=e,o=new Ah(t.rotation[0],t.rotation[1],t.rotation[2]),n=e.randomnessObject??ro.defaultData([1,1,1]).randomnessObject,a=this.getRandom(n),s=Pl(n.strength,this.parameters.randomness);if(!t.object){for(let[,d]of this.children.entries())d.position.set(0,0,0),d.scale.setScalar(1),d.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof Ai)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let l=this.getSubdivData();if(l.length>0){let d=Math.round(l.length*t.count/100);this._updateCount(d)}else{let d=this.objectForSample.geometry.getAttribute("position");if(!d||isNaN(d.count)||d.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let c=new du(this.objectForSample).build(),u=Yv[t.axis],p=this.children;c.setRandomGenerator((0,cd.default)(this.object.uuid+t.seed));for(let[d,f]of p.entries()){let h=d*(n.freqScale/10)+n.movement,m=a.noise(h,h,h),y=d+1,b=s(y,Ce(m,n.rotation[0])),v=s(y,Ce(m,n.rotation[1])),w=s(y,Ce(m,n.rotation[2]));t.spreadType==="random"?c.sample(Ol,Mh):(l.length&&(Ol.fromArray(l[d].pos),Mh.fromArray(l[d].norm)),this.objectForSample instanceof gn&&Ol.applyMatrix4(s_.copy(this.objectForSample.matrixWorld).invert())),Ol.applyMatrix4(this.object.hiddenMatrix.clone().invert()),f.position.copy(Ol),Mi.fromArray(u);let O=t.align==="normal"?Mh:this.object.getWorldDirection(u_),S=ld.fromArray(t.position);ld.x+=s(y,Ce(m,n.position[0])),ld.y+=s(y,Ce(m,n.position[1])),ld.z+=s(y,Ce(m,n.position[2]));let T=Math.acos(O.dot(Mi)),M=c_.crossVectors(Mi,O).normalize(),g=l_.makeRotationAxis(M,T),D=O.clone().cross(this.object.up).normalize(),E=D.clone().cross(O).normalize(),I=new vn().makeBasis(D,O,E),N=new fr(Mi.y,Mi.z,Mi.x).normalize(),_=N.clone().cross(Mi).normalize(),R=new vn().makeBasis(N,Mi,_).invert(),V=new vn().multiplyMatrices(I,R);f.rotation.setFromRotationMatrix(V),S.applyMatrix4(g),f.position.add(S),f.rotation.x=f.rotation.x+o.x+b,f.rotation.y=f.rotation.y+o.y+v,f.rotation.z=f.rotation.z+o.z+w,f.scale.setScalar(1),f.scale.x=f.scale.x+t.scale[0]+s(y,Ce(m,n.scale[0]))||Qt,f.scale.y=f.scale.y+t.scale[1]+s(y,Ce(m,n.scale[1]))||Qt,f.scale.z=f.scale.z+t.scale[2]+s(y,Ce(m,n.scale[2]))||Qt,f.scale.multiply(this.object.scale),f.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType,t=new Map,o=(a,s)=>{let l=Math.round(a[0]*1e4)+"_"+Math.round(a[1]*1e4)+"_"+Math.round(a[2]*1e4),c=t.get(l);c?(c.pos[0]+=a[0],c.pos[1]+=a[1],c.pos[2]+=a[2],c.norm[0]+=s[0],c.norm[1]+=s[1],c.norm[2]+=s[2],c.count+=1):t.set(l,{pos:[...a],norm:[...s],count:1})};if(e==="random")return[];if(this.objectForSample instanceof gn){let a=this.objectForSample,s=Kv[e],l=c1[s],c=s1[s],u=l1[s],p=l(a.subdivPointerNew);for(let d=0;d<=p-1;d++){let f=c(a.subdivPointerNew,d),h=u(a.subdivPointerNew,d);n1.fromArray(f).applyMatrix4(a.matrixWorld),a1.fromArray(h),o(n1.toArray(),a1.toArray())}}else(this.objectForSample.geometry.index?Qv(this.objectForSample.geometry):Zv(this.objectForSample.geometry)).forEach((s,l)=>{e==="polygon_center"&&o(s.midpoint,s.norm),e==="vertex"&&(o(s.vertices[0],s.norm),o(s.vertices[1],s.norm),o(s.vertices[2],s.norm)),e==="edge"&&(o(s.faceCenters[0],s.norm),o(s.faceCenters[1],s.norm),o(s.faceCenters[2],s.norm))});let n=Array.from(t.values());for(let a of n)a.pos[0]/=a.count,a.pos[1]/=a.count,a.pos[2]/=a.count,a.norm[0]/=a.count,a.norm[1]/=a.count,a.norm[2]/=a.count;return n}updateState(e,t){if(this.parameters=Mo(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let o=t.find(this.parameters.toObject.object);o instanceof Tt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new vn,this.hiddenMatrix=new vn,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};import{Scene as WL,Vector3 as qL,Matrix4 as $L,Box3 as XL,MeshBasicMaterial as YL,Skeleton as KL}from"three";import{Camera as w_,OrthographicCamera as P_,PerspectiveCamera as O_,Vector3 as $r,Object3D as f1,Quaternion as T_,Matrix4 as C_}from"three";import{Camera as y_,LineSegments as g_,BufferGeometry as x_,LineBasicMaterial as b_,Color as Nh,Vector3 as v_,Float32BufferAttribute as d1}from"three";import{BoxGeometry as d_}from"three";var xo=i=>{var r;return r=class extends i{},r.geometryHelper=new d_(30,30,30),r};import{Ray as p_,Sphere as f_,Matrix4 as h_,Vector3 as $o}from"three";var ud=new p_,Eh=new f_,u1=new h_,bo=(i,r,e,t,o=!1,n=i)=>{let a=r,s=n.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),Eh.copy(a.boundingSphere),Eh.applyMatrix4(s),e.ray.intersectsSphere(Eh)===!1||(u1.copy(s).invert(),ud.copy(e.ray).applyMatrix4(u1),a.boundingBox!==null&&ud.intersectsBox(a.boundingBox)===!1))return;let l,c,u,p,d=a.index,f=a.attributes.position,h=a.drawRange,m,y;if(o===!1){let v=Math.max(0,h.start),w=Math.min(d.count,h.start+h.count);for(m=v,y=w;m<y;m+=3)if(c=d.getX(m),u=d.getX(m+1),p=d.getX(m+2),l=b(i,e,ud,f,c,u,p),l){l.faceIndex=Math.floor(m/3),t.push(l);return}}else{let w=a.attributes.position,O=new $o,S=new $o,T=new $o,M=new $o,g=2,E=1/((n.scale.x+n.scale.y+n.scale.z)/3),I=E*E,N=Math.max(0,h.start),_=Math.min(w.count,h.start+h.count);for(let R=N,V=_-1;R<V;R+=g){if(O.fromBufferAttribute(w,R),S.fromBufferAttribute(w,R+1),ud.distanceSqToSegment(O,S,M,T)>I)continue;M.applyMatrix4(n.matrixWorld);let B=e.ray.origin.distanceTo(M);B<e.near||B>e.far||t.push({distance:B,point:T.clone().applyMatrix4(n.matrixWorld),object:i})}}function b(v,w,O,S,T,M,g){let D=new $o,E=new $o,I=new $o,N=new $o,_=new $o;if(D.fromBufferAttribute(S,T),E.fromBufferAttribute(S,M),I.fromBufferAttribute(S,g),O.intersectTriangle(D,E,I,!1,N)===null)return null;_.copy(N),_.applyMatrix4(v.matrixWorld);let V=w.ray.origin.distanceTo(_);return V<w.near||V>w.far?null:{faceIndex:1,distance:V,point:_.clone(),object:v}}};var dd=new v_,Tr=new y_,Dh=class extends g_{constructor(e){let t=new x_,o=new b_({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],a=[],s={},l=new Nh(15711266),c=new Nh(15711266),u=new Nh(2857471);p("n1","n2",l),p("n2","n4",l),p("n4","n3",l),p("n3","n1",l),p("f1","f2",l),p("f2","f4",l),p("f4","f3",l),p("f3","f1",l),p("n1","f1",l),p("n2","f2",l),p("n3","f3",l),p("n4","f4",l),p("p","n1",c),p("p","n2",c),p("p","n3",c),p("p","n4",c),p("u1","u2",u),p("u2","u3",u),p("u3","u1",u);function p(f,h,m){d(f,m),d(h,m)}function d(f,h){n.push(0,0,0),a.push(h.r,h.g,h.b),s[f]===void 0&&(s[f]=[]),s[f].push(n.length/3-1)}t.setAttribute("position",new d1(n,3)),t.setAttribute("color",new d1(a,3));super(t,o);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,t=this.pointMap,o=!0;Tr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let n=1,a=1,s=o?.8:1e-4;qr("n1",t,e,Tr,-n,-a,s),qr("n2",t,e,Tr,n,-a,s),qr("n3",t,e,Tr,-n,a,s),qr("n4",t,e,Tr,n,a,s);let l=s;qr("f1",t,e,Tr,-n,-a,l),qr("f2",t,e,Tr,n,-a,l),qr("f3",t,e,Tr,-n,a,l),qr("f4",t,e,Tr,n,a,l);let c=l,u=.5;qr("u1",t,e,Tr,n*.7*u,a*1.1,c),qr("u2",t,e,Tr,-n*.7*u,a*1.1,c),qr("u3",t,e,Tr,0,a*(1.1+.9*u),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function qr(i,r,e,t,o,n,a){dd.set(o,n,a).unproject(t);let s=r[i];if(s!==void 0){let l=e.getAttribute("position");for(let c=0,u=s.length;c<u;c++)l.setXYZ(s[c],dd.x,dd.y,dd.z)}}var pd=class extends xo(Dh){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,t){bo(this.object,this.geometry,e,t,!0)}};import{Box3Helper as p1,BoxGeometry as S_}from"three";var fd;(r=>r.is=e=>"objectHelper"in e)(fd||(fd={}));var Cr=(i,r)=>class extends va(i){constructor(){super(...arguments);this.objectHelper=new r(this);this.gizmos={}}get geometryHelper(){return r.geometryHelper}raycast(o,n){this.objectHelper.raycast(o,n)}showGizmos(){for(let o in this.gizmos){let n=this.gizmos[o];n instanceof p1&&(n.visible=!0)}}updateEntityBoxSize(o,n){this.objectHelper.visible&&this.geometryHelper instanceof S_?(o.setScalar(0),n.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(o,n)}hideGizmos(){for(let o in this.gizmos){let n=this.gizmos[o];n instanceof p1&&(n.visible=!1)}}};var hd=790,cs=new $r,_h=new $r,Rh=new T_,Lh=new $r,Tl=new $r,Bh=new $r,Xo=class extends Cr(w_,pd){constructor(e="",t={...Ji.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=hi.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,t),this.previousProjectionMatrix=new C_,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,n=this.height;this.orthoCamera=new P_(o*-.5,o*.5,n*.5,n*-.5,-5e4,1e4),this.perspCamera=new O_(45,o/n,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,t,o){typeof e=="number"&&(e=new $r(e,t,o)),super.lookAt(e),this.getWorldPosition(cs),this.targetOffset=cs.distanceTo(e)}getTarget(e=new $r){return this.getWorldDirection(_h),this.getWorldPosition(cs),_h.multiplyScalar(this.targetOffset),e.copy(cs).add(_h),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(cs),cs.distanceTo(e)}updateUp(){this.getWorldQuaternion(Rh),Lh.set(0,0,1).applyQuaternion(Rh),Tl.copy(f1.DEFAULT_UP),this.isUpVectorFlipped&&Tl.negate(),Tl.applyQuaternion(Rh),Bh.copy(f1.DEFAULT_UP).projectOnPlane(Lh),this.angleOffsetFromUp=Bh.angleTo(Tl),this.angleOffsetFromUp*=Bh.cross(Tl).dot(Lh)>=0?1:-1}updateTransformState(e,t){let o=super.updateTransformState(e,t);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),o}getViewFrontToObject(e){let t=e.getWorldPosition(new $r),n=e.getWorldDirection(new $r).multiplyScalar(this.targetOffset);return{position:t.clone().add(n),target:t}}getViewToTarget(e){let o=this.getWorldDirection(new $r).multiplyScalar(this.targetOffset);return{position:e.clone().sub(o),target:e}}getViewToObject(e){let t=new $r,o=e.getWorldPosition(t);return this.getViewToTarget(t)}setViewplaneSize(e,t,o=!1){if(this.aspect=e/t,o){let n=e>t?this.aspect:1,a=e>t?1:this.aspect;this.left=-hd*.5*n,this.right=hd*.5*n,this.top=hd*.5*(1/a),this.bottom=-hd*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,t,o,n,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,o,n,a,s):this.orthoCamera.setViewOffset(e,t,o,n,a,s)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let t={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Yn(t,e)}updateCameraSubtype(e,t){let o=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";t.zoom!==void 0&&this.setZoom(o,t.zoom),t.near!==void 0&&this.setNear(o,t.near),t.fov!==void 0&&o==="PerspectiveCamera"&&(this.fov=t.fov)}updateState(e,t){this.updateCameraState(e,t)}updateCameraState(e,t){this.updateState_Entity(e,t),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}};import{MathUtils as xse}from"three";import{BufferGeometry as h1,Matrix4 as m1,Float32BufferAttribute as A_}from"three";var us=new m1,M_=new m1;var nr=class extends ir{constructor(e,t,o){super(e,t);this.data=t;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new h1;this.onAfterRender=(e,t,o,n,a,s)=>{super.onAfterRender(e,t,o,n,a,s),this.recomputeBoolean()};this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,t=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let n=0;n<this.children.length;n++){let a=this.children[n];a instanceof nr&&a.dataPatched.visible===!0&&a.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let n=0;n<this.children.length;n++){let a=this.children[n];if(a instanceof Tt&&a.dataPatched.visible===!0&&a.geometry.attributes.position?.count>0&&a.geometry.drawRange.count>0&&a.booleanMeshSetAddress!==0){us.multiplyMatrices(a.hiddenMatrix,a.matrix);try{if(a.booleanMeshSetAddress===-1){if((a.geometry.index??a.geometry.getAttribute("position")).count/3<15e5&&(a.booleanMeshSetAddress=wr.getMeshSet(a.geometry,e===!0,t)),a.booleanMeshSetAddress===-1)return;wr.transformMeshSet(a.booleanMeshSetAddress,us),a.booleanMatrixInvOld.copy(us).invert(),a.booleanWasTransformed=!1}else a instanceof nr&&a.needsTransformForDownstream===!0?(wr.transformMeshSet(a.booleanMeshSetAddress,us),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(wr.transformMeshSet(a.booleanMeshSetAddress,M_.multiplyMatrices(us,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(us).invert(),a.booleanWasTransformed=!1)}catch(s){console.error(s),a.booleanMeshSetAddress=0,a.geometry.userData.booleanOperationDidFail=!0;continue}wr.hasOpenEdges(a.booleanMeshSetAddress)===!1||n===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(a.booleanMeshSetAddress),a.geometry.userData.booleanOperationDidFail=!1):a.geometry.userData.booleanOperationDidFail="openEdges"}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new A_([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return wr.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new h1,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=wr.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(n){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(n)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,as(this),ss(this)}dispose(){super.dispose(),this.geometry.dispose()}};import{Light as I_}from"three";var y1;(r=>{function i(e){return De.is(e)&&e instanceof I_}r.is=i})(y1||(y1={}));var ds=(i,r)=>class extends Cr(i,r){updateState_Light(t,o){this.updateState_Entity(t,o),t.color!==void 0&&(this.color=o.shared.color(t.color)),t.intensity!==void 0&&(this.intensity=t.intensity),t.depth!==void 0&&(this.shadow.camera.far=t.depth,this.shadow.needsUpdate=!0),t.shadows!==void 0&&(this.castShadow=t.shadows)}};var Ei=i=>i instanceof Tt,Cl=i=>i!==null&&i instanceof nr;var Al=i=>fd.is(i);import{Group as L_}from"three";import{AxesHelper as E_,Group as N_,Quaternion as D_,Vector3 as Vh}from"three";var __=new Vh(1,1,1),g1=new Vh,R_=new Vh,x1=new D_,Ar=class extends xo(E_){constructor(e,t=15){super(t);this.object=e;this.dummy=new N_;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,t){bo(this.object,Ar.geometryHelper,e,t,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(g1,x1,R_),this.matrix.compose(g1,x1,__),super.updateMatrixWorld(e)}updateWorldMatrix(e,t){}};var Ni=class extends Cr(L_,Ar){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update()}updateState(r,e){this.updateState_Entity(r,e),"buffer"in r&&Object.keys(r).length===1&&e.scene.reloadSplats()}};import{Group as B_}from"three";var ps=class extends Cr(B_,Ar){constructor(e,t,o){super();this.super_Entity(e,t),this.context=o,this.objectHelper.update()}updateState(e,t){this.updateState_Entity(e,t)}};import{Color as OR,Fog as TR,HemisphereLight as CR}from"three";import{ShaderChunk as Ml}from"three";var V_=i=>`
2290
2290
 
2291
2291
  // PCSS implementation based on:
2292
2292
  // https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
@@ -2660,18 +2660,18 @@ float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, floa
2660
2660
  }
2661
2661
 
2662
2662
  #endif
2663
- `,UD=Ml.lights_fragment_begin,kD=Ml.shadowmask_pars_fragment,e1=null,HD=i=>{switch(i){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},t1=(i="medium")=>{if(e1===i)return!1;e1=i;let r=HD(i);Ml.shadowmap_pars_fragment=jD(r);let e=UD.slice();e=e.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),e=e.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),Ml.lights_fragment_begin=e;let t=kD.slice();return t=t.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),Ml.shadowmask_pars_fragment=t,!0};import{DirectionalLight as YD,CameraHelper as r1}from"three";import{DirectionalLightHelper as WD}from"three";var fs=class extends xo(WD){constructor(e,t=15,o=10066329){super(e,t,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){bo(this.object,fs.geometryHelper,e,t)}};import{PointLightHelper as qD}from"three";var hs=class extends xo(qD){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){bo(this.object,hs.geometryHelper,e,t)}};import{SpotLightHelper as $D,Vector3 as XD}from"three";var dd=class extends xo($D){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){bo(this.object,dd.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=dd._vector,t=this.object.distance?this.object.distance:1e3,o=t*Math.tan(this.object.angle);this.cone.scale.set(o,o,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let a=0,s=this.cone.material.length;a<s;a++)this.cone.material[a].color.set(n);else this.cone.material.color.set(n)}}},Il=dd;Il._vector=new XD;function KD(i,r){i.shadow.camera.right=r/2,i.shadow.camera.left=-r/2,i.shadow.camera.top=r/2,i.shadow.camera.bottom=-r/2,i.shadow.needsUpdate=!0}var ms=class extends ds(YD,fs){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.top=1250,n.bottom=-1250,n.right=1250,n.left=-1250,n.near=-1e4,n.far=2500;let a=new r1(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof r1&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e);let t=r.depth!==void 0&&r.depth!==this.shadow.camera.far||r.size!==void 0&&r.size/2!==this.shadow.camera.right;r.size!==void 0&&KD(this,r.size),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),r.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t&&this.update()}};import{Scene as N_}from"three";import{SpotLight as QD,CameraHelper as o1,MathUtils as ZD,Vector3 as s1,Quaternion as JD}from"three";var i1=new s1,n1=new s1,a1=new JD,ys=class extends ds(QD,Il){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=ZD.RAD2DEG*2*this.angle,n.aspect=1,n.near=100,n.far=2500;let a=new o1(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof o1&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),n1.setFromMatrixPosition(this.matrixWorld),a1.setFromRotationMatrix(this.matrixWorld),i1.copy(this.up).applyQuaternion(a1).negate().multiplyScalar(this.distance),this.target.position.copy(n1).add(i1),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.angle!==void 0&&(this.angle=r.angle),r.penumbra!==void 0&&(this.penumbra=r.penumbra),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};function e_(i){let r=(i[0][0]+i[1][1])/2,e=(i[0][0]-i[1][1])/2,t=(i[1][0]+i[0][1])/2,o=(i[1][0]-i[0][1])/2,n=Math.sqrt(r*r+o*o),a=Math.sqrt(e*e+t*t),s=n+a,l=n-a,c=Math.atan2(t,e),u=Math.atan2(o,r),p=(u-c)/2,d=(u+c)/2,f=[[Math.cos(d),Math.sin(d)],[-Math.sin(d),Math.cos(d)]],h=[[s,0],[0,l]],m=[[Math.cos(p),Math.sin(p)],[-Math.sin(p),Math.cos(p)]];return f[0][0]*=-1,f[0][1]*=-1,m[0][0]*=-1,m[1][0]*=-1,[f,h,m]}function pd(i,r){return[[i[0][0]*r[0][0]+i[0][1]*r[1][0],i[0][0]*r[0][1]+i[0][1]*r[1][1]],[i[1][0]*r[0][0]+i[1][1]*r[1][0],i[1][0]*r[0][1]+i[1][1]*r[1][1]]]}function l1(i){return[[i[0][0],i[1][0]],[i[0][1],i[1][1]]]}function c1(i){let[r,e,t]=e_(i),o=pd(r,l1(t)),n=pd(pd(t,e),l1(t)),a=Math.atan2(o[1][0],o[0][0]),s=[n[0][0],n[1][1]],l=[n[0][1]/n[1][1],n[1][0]/n[0][0]];return{rotation:a,scale:s,shear:l}}function u1({rotation:i,scale:r,shear:e}){let t=Math.cos(i),o=Math.sin(i),n=[[t,-o],[o,t]],a=[[r[0],e[0]*r[1]],[e[1]*r[0],r[1]]],s=pd(n,a);return[s[0][0],s[1][0],s[0][1],s[1][1]]}var Ee;(S=>{function i(){return[1,0,0,0,1,0,0,0,1]}S.identity=i;function r(T,M=S.identity()){for(let g=0,D=T.length;g<D;g++)M[g]=T[g];return M}S.copy=r;function e(T,M,g,D,E,I){return S.setAbcdef(S.identity(),T,M,g,D,E,I)}S.create=e;function t(T,M,g,D,E,I,N){return T[0]=M,T[1]=D,T[2]=I,T[3]=g,T[4]=E,T[5]=N,T}S.setAbcdef=t;function o(T,M){let[g,D,E,I,N,_]=a(T),[R,V,U,B,q,j]=a(M),F=R*g+V*E,H=R*D+V*I,W=U*g+B*E,ee=U*D+B*I,te=q*g+j*E+N,Y=q*D+j*I+_;return S.create(F,H,W,ee,te,Y)}S.append=o;function n(T,M){let[g,D,E,I,N,_]=a(T),[R,V,U,B,q,j]=a(M),F=g,H=D,W=E,ee=I;(R!==1||V!==0||U!==0||B!==1)&&(F=g*R+D*U,H=g*V+D*B,W=E*R+I*U,ee=E*V+I*B);let te=N*R+_*U+q,Y=N*V+_*B+j;return S.create(F,H,W,ee,te,Y)}S.prepend=n;function a(T){return[T[0],T[3],T[1],T[4],T[2],T[5]]}S.getAbcdef=a;function s(T){let[M,g,D,E,I,N]=S.getAbcdef(T),_=M*E-g*D,R=E/_,V=-g/_,U=-D/_,B=M/_,q=(D*N-E*I)/_,j=-(M*N-g*I)/_;return S.create(R,V,U,B,q,j)}S.invert=s;function l([T,M],g){let[D,E,I,N,_,R]=S.getAbcdef(g);return[D*T+I*M+_,E*T+N*M+R]}S.apply=l;function c(T,M){let[g,D,E,I,N,_]=S.getAbcdef(M),R=1/(g*I+E*-D),[V,U]=T;return[I*R*V+-E*R*U+(_*E-N*I)*R,g*R*U+-D*R*V+(-_*g+N*D)*R]}S.applyInverse=c;function u(T,M,g=M){let[D,E,I,N,_,R]=S.getAbcdef(T);return S.setAbcdef(T,D*M,E*g,I*M,N*g,_*M,R*g),T}S.scale=u;function p(T,M){let g=Math.cos(M),D=Math.sin(M),[E,I,N,_,R,V]=S.getAbcdef(T);return S.setAbcdef(T,E*g-I*D,E*D+I*g,N*g-_*D,N*D+_*g,R*g-V*D,R*D+V*g),T}S.rotate=p;function d(T,M,g){let[D,E]=g,I=S.translate(T,-D,-E);return I=S.rotate(I,M),I=S.translate(I,D,E),I}S.rotateAround=d;function f(T,M,g){let[D,E,I,N,_,R]=S.getAbcdef(T);return S.setAbcdef(T,D,E,I,N,_+M,R+g),T}S.translate=f;function h(T,M,g){let[D,E,I,N]=S.getAbcdef(T);return S.setAbcdef(T,D,E,I,N,M,g),T}S.setTranslate=h;function m(T,M,g){let[D,E,I,N]=S.getAbcdef(T);return S.setAbcdef(T,D,E,I,N,M,g),T}S.setPosition=m;function y(T){let[M,g,D,E]=S.getAbcdef(T),I=Math.sqrt(M*M+g*g),N=Math.sqrt(D*D+E*E);return[I,N]}S.getScale=y;function b(T){let[,,,,M,g]=S.getAbcdef(T);return[M,g]}S.getPosition=b;function v(T,M){return S.decompose(T,M).rotation}S.getRotation=v;function w(T,M){let[g,D,E,I,N,_]=S.getAbcdef(T),{rotation:R,scale:V,shear:U}=c1([[g,E],[D,I]]);return{position:[N+(M[0]*g+M[1]*E)-M[0],_+(M[0]*D+M[1]*I)-M[1]],scale:V,rotation:R,shear:U,pivot:M}}S.decompose=w;function O(T,M,g,D,E=[0,0]){let[I,N]=T,[_,R]=D,[V,U,B,q]=u1({rotation:g,scale:M,shear:E}),j=I-(_*V+R*B)+_,F=N-(_*U+R*q)+R;return S.create(V,U,B,q,j,F)}S.compose=O})(Ee||(Ee={}));var t_=Math.PI/180,nse=180/Math.PI;function d1(i,r,e,t,o,n){let a=i-e,s=r-t;return a*a/(o*o)+s*s/(n*n)<=1}function p1(i){return i*t_}var Yo=class{constructor(r,e,t){this.uuid=r;this.data=e;this.localMatrix=Ee.identity();this.worldMatrix=Ee.identity();this.ignoreCameraZoom=!1;this.visible=!0;this._singleBBox=new Di;this._recursiveBBox=new Di;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.stateSelection=null;this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this.name="";this.position=[0,0];this.scale=[1,1];this.rotation=0;this.shear=[0,0];this.emitter=Fo();this.dpr=t.dpr??1,this.dataPatched=e}project(r,e){let t=this.worldMatrix;return e&&(t=Ee.append(e.worldMatrix,t)),Ee.applyInverse(r,t)}intersects(r,e,t,o=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([r,e],t),o)}intersectsInLocalSpace(r,e,t=!1){let{min:o,max:n}=t?this.recursiveBBox:this.singleBBox;return r>=o[0]&&r<=n[0]&&e>=o[1]&&e<=n[1]}applyTransforms(r){r.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=Ee.compose(this.position,this.scale,p1(this.rotation),Bo.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(r,e,t){let o=this.parent;e&&o!==null&&o!==void 0&&o.updateWorldMatrix(r,!0,!1),r&&this.updateLocalMatrix(),this.parent?this.worldMatrix=Ee.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=Ee.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return Bo.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{r.resetBBoxNeedsUpdateSelf()})}updateTransformState(r){let e=!1;r.position!==void 0&&(e=!0,this.position=r.position),r.rotation!==void 0&&(e=!0,this.rotation=r.rotation),r.scale!==void 0&&(e=!0,this.scale=r.scale),r.shear!==void 0&&(e=!0,this.shear=r.shear),e&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(r,e,t){r.type===0&&r.props.visible!==void 0&&(this.visible=r.props.visible),this.data=e,this.data=e;let o=r,n=Le(r.path,["states","*"]);if(n!==null){if(r.type===0){let[a]=n;if(this?.stateSelection===a){let s={...r.props};if(delete s.name,Object.values(r.props).some(l=>l===void 0)){let l=this.data;if(l!==void 0){let c=Ze.zoom(l,r.path.slice(2));if(c)for(let u in r.props)r.props[u]===void 0&&u in c&&(s[u]=c[u])}}o={...r,props:s,path:r.path.slice(2)}}}}else if(r.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(r.props.name!==void 0&&a.name){let{name:l,...c}=a;a=c}let s=Ze.removeOverridden(r.path,r.props,a);o={...r,props:s}}}this.updateByPatchedOpBase(o,tn.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),t)}changeSelectedState(r,e,t=!1){if(!(this.data.states.length===0&&!t)){for(let o of this.data.states)tn.toOps(this.data,o.data).forEach(a=>{let s=ea.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,e)});if(r!==null){let o=this.data.states.data(r);o&&(this.dataPatched=tn.patch(this.data,o),tn.toOps(this.data,o).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,e)}))}t&&this.updateTransformState(this.dataPatched),this.stateSelection=r}}updateState(r,e){r.name!==void 0&&(this.name=r.name),r.visible!==void 0&&(this.visible=r.visible),this.updateTransformState(r)}updateByPatchedOpBase(r,e,t){this.dataPatched=e,this.updateByPatchedOp(r,e,t)}updateByPatchedOp(r,e,t){r.path.length===0&&r.type===0&&this.updateState(r.props,t),this.requestRender()}traverseFrameAncestors(r){this.traverseAncestors(e=>{e.data.type==="frame2d"&&r(e)})}traverseAncestors(r){let e=this.parent;for(;e;)r(e),e=e.parent}requestRender(){this.traverseFrameAncestors(r=>{r.requestRender()})}clone(r){let e=new Yo(this.uuid,this.data,r);return e.parent=void 0,e}addEventListener(r,e){this.emitter.on(r,e)}removeEventListener(r,e){this.emitter.off(r,e)}dispatchEvent(r){this.emitter.emit(r.type,{...r,target:r.target??this})}traverseSortNextHelper(){let r=this.parent;if(r){let e=r.children;if(e){let t=e.indexOf(this)+1;return e[t]?e[t]:r.traverseSortNextHelper()}}}sortNext(){let r=this.children;return r&&r.length>0&&r[0]?r[0]:this.traverseSortNextHelper()}isDescendantOf(r){r instanceof Yo&&(r=r.uuid);let e=this;for(;e.parent;){if(e.parent.uuid===r)return!0;e=e.parent}return!1}};var Ut=class extends Yo{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.context=o;this.children=[]}add(e){e.parent&&e.parent instanceof Ut&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let t=this.children.indexOf(e);t>=0&&(this.children.splice(t,1),e.parent=void 0)}traverse(e){let t=e(this);if(t!==!0)for(let o of this.children)o instanceof Ut?o.traverse(e):t=e(o)}intersectsChildrenHelper(e,t,o,n,a){for(let s of this.children)if(s.intersects(e,t,o,!1)&&(a.push(s),n)||s instanceof Ut&&s.intersectsChildrenHelper(e,t,o,n,a))return!0;return!1}intersectsChildren(e,t,o,n=!1,a=[],s=!1){return this.intersectsChildrenHelper(e,t,o,n,a),a}intersectsChildrenHelperReverse(e,t,o,n,a){for(let s of this.children)if(s instanceof Ut&&s.intersectsChildrenHelperReverse(e,t,o,n,a)||s.intersects(e,t,o,!1)&&(a.push(s),n))return!0;return!1}intersectsChildrenReverse(e,t,o,n=!1,a=[],s=!1){return this.intersectsChildrenHelperReverse(e,t,o,n,a),a}updateWorldMatrix(e,t,o){if(super.updateWorldMatrix(e,t,o),o&&this.children)for(let n of this.children)n.updateWorldMatrix(e,!1,!0)}find(e){let t;return this.traverse(o=>{o.uuid===e&&(t=o)}),t}innerDrawChildren(e){for(let t=this.children.length-1;t>=0;t--)this.children[t].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let t=new Ut(this.uuid,this.data,e);t.parent=void 0;for(let o of this.children)t.add(o.clone(e));return t}},ar=class extends Ut{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.updateState(t,o)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let t=new ar(this.uuid,this.data,e);t.parent=void 0;for(let o of this.children)t.add(o.clone(e));return t}};function r_(i,r){let[[e,t],[o,n]]=i,[[a,s],[l,c]]=r,u=(e-o)*(s-c)-(t-n)*(a-l);if(u===0)return!1;let p=((e-a)*(s-c)-(t-s)*(a-l))/u,d=-((e-o)*(t-s)-(t-n)*(e-a))/u;return p>=0&&p<=1&&d>=0&&d<=1}var h1=[[-1,1],[-1,-1],[1,-1],[1,1]],f1=(i,r,e)=>{let t=i.getCenter(),o=i.getHalfSize(),n=Ee.append(r,i.worldMatrix);o[0]===0&&o[1]===0?e.push(Ee.apply(t,n)):h1.forEach(a=>{let s=[a[0]*o[0]+t[0],a[1]*o[1]+t[1]];e.push(Ee.apply(s,n))})},Di=class{constructor(){this.matrix=Ee.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(r,e=!1){r.updateWorldMatrix(),this.makeEmpty(),Ee.copy(r.worldMatrix,this.matrix);let t=Ee.invert(r.worldMatrix);this.expandByObjectSize(r,t,e)}expandByObjectSize(r,e,t=!1){let o=[];t===!0&&r instanceof Ut?r.traverse(n=>{n.visible&&f1(n,e,o)}):f1(r,e,o),this.setFromPoints(o)}setFromSize(r,e,t){this.makeEmpty(),Ee.copy(t,this.matrix),this.expandBySize(r,e,t)}expandBySize(r,e,t){[Ee.apply([0,0],t),Ee.apply([0,e],t),Ee.apply([r,e],t),Ee.apply([r,0],t)].forEach(n=>this.expandByPoint(n))}getCenter(){let[r,e]=this.min,[t,o]=this.getHalfSize();return Ee.apply([r+t,e+o],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(r){this.makeEmpty();for(let e of r)this.expandByPoint(e)}expandByPoint(r){this.min=[Math.min(this.min[0],r[0]),Math.min(this.min[1],r[1])],this.max=[Math.max(this.max[0],r[0]),Math.max(this.max[1],r[1])]}computeVertices(){let[r,e]=this.getHalfSize(),t=this.getCenter(),[o,n,a,s]=Ee.getAbcdef(this.matrix),l=Ee.create(o,n,a,s,t[0],t[1]);this.vertices=h1.map(([c,u])=>Ee.apply([c*r,u*e],l))}computeEdges(){this.edges=[];for(let r=0,e=this.vertices.length;r<e;++r)this.edges.push([this.vertices[r],this.vertices[(r+1)%e]])}project(r,e){let t=this.matrix;return e&&(t=Ee.append(e.worldMatrix,t)),Ee.applyInverse(r,t)}intersects(r,e,t){return this.intersectsInLocalSpace(...this.project([r,e],t))}intersectsInLocalSpace(r,e){let{min:t,max:o}=this;return r>=t[0]&&r<=o[0]&&e>=t[1]&&e<=o[1]}containsPoint(r){let[e,t]=r,[o,n]=this.min,[a,s]=this.max;return e>=o&&e<=a&&t>=n&&t<=s}intersectsBBox2D(r){for(let e=0,t=this.edges.length;e<t;e++){let o=this.edges[e];for(let n=0,a=r.edges.length;n<a;n++){let s=r.edges[n];if(r_(o,s))return!0}}for(let e=0,t=r.vertices.length;e<t;e++){let o=r.vertices[e];if(this.containsPoint(o))return!0}return!1}ensureMinMax(){let r=this.min,e=this.max;this.min=[Math.min(r[0],e[0]),Math.min(r[1],e[1])],this.max=[Math.max(r[0],e[0]),Math.max(r[1],e[1])]}copy(r){this.min=[...r.min],this.max=[...r.max],Ee.copy(r.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let r=new Di;return r.copy(this),r}};var y1,g1=new Promise(i=>{y1=i}),m1=!1;var fd;function x1(){if(m1)return;if(fd)return fd;async function i(){let e=await import("./ui.js");y1(e.default??e),m1=!0}return fd=i(),fd}function S1(i){let r=!1;return i.scene.objects.traverse((e,t)=>{(t.type==="Mesh"&&t.geometry.type==="UIGeometry"||t.type==="Page"&&t.uiFrame!==void 0)&&(r=!0)}),r}var Te,Nh;async function o_(i){let r=await g1;Te||(Nh||(Nh=r({locateFile:()=>i})),Te=await Nh)}var b1=Ee.identity(),Nl=class{constructor(r,e=1){this.canvas=r;this._dpr=e;this._width=0;this._height=0;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=Ie.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=Ie.transparent;this._fonts=new Map;this._isSizeDirty=!1;try{let t=r.getBoundingClientRect();r.width=t.width*e,r.height=t.height*e}catch{console.log(r.width,e)}this._currentM3Transform=b1,this._currentTransform=new Float32Array(b1)}get dpr(){return this._dpr}set dpr(r){this._dpr=r,this._isSizeDirty=!0}async init(){if(!this.wasmURL)throw Error("Your must set the wasm binary url with renderer.wasmURL = ... before you can call renderer.init");await o_(this.wasmURL),this._surface=Te.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas(),this._paint=new Te.Paint,this._paint.setAntiAlias(!0),this._paintFill=this._paint.copy(),this._paintFill.setStyle(Te.PaintStyle.Fill),this._paintStroke=this._paint.copy(),this._paintStroke.setStyle(Te.PaintStyle.Stroke),this.ctx?.scale(this.dpr,this.dpr)}get currentTransform(){return this._currentM3Transform}get currentTransformBuffer(){return this._currentTransform}set currentTransform(r){this._currentM3Transform=r,this._currentTransform.set(r)}async loadFont(r,e){let t=await(await fetch(r)).arrayBuffer();this.registerFont(t,e)}registerFont(r,e){if(this._fonts.has(e))return;let t=Te.FontMgr.FromData(r);if(t)this._fonts.set(e,t);else throw new Error("Invalid font data for "+e)}get width(){return this._width}get height(){return this._height}set strokeColor(r){this._paintStroke&&this._paintStroke.setColor(hd(r),Te.ColorSpace.DISPLAY_P3)}set fillColor(r){this._paintFill&&this._paintFill.setColor(hd(r),Te.ColorSpace.DISPLAY_P3)}set lineWidth(r){this._paintStroke&&this._paintStroke.setStrokeWidth(this._strokeMode==="center"?r:r*2)}set strokeMode(r){this._strokeMode=r}set dropShadowBlur(r){this._dropShadowBlur=r}set dropShadowColor(r){this._dropShadowColor=r}set dropShadowOffsetX(r){this._dropShadowOffsetX=r}set dropShadowOffsetY(r){this._dropShadowOffsetY=r}set innerShadowBlur(r){this._innerShadowBlur=r}set innerShadowColor(r){this._innerShadowColor=r}set innerShadowOffsetX(r){this._innerShadowOffsetX=r}set innerShadowOffsetY(r){this._innerShadowOffsetY=r}set innerShadowSpread(r){this._innerShadowSpread=r}set layerBlur(r){this._layerBlur=r}set backgroundBlur(r){this._backgroundBlur=r}clear(){this.ctx?.clear(Te.TRANSPARENT)}save(){this.ctx?.save()}restore(){this.ctx?.restore()}beginPath(){this._currentPath?.delete(),this._currentPath=new Te.Path}closePath(){let r=this._currentPath;if(r){if(r.isEmpty())return;let e=r.getBounds();(e[3]-e[1]||e[2]-e[0])&&r.close()}}fill(){this._paintInner(this._paintFill,!0)}stroke(){this._paintInner(this._paintStroke,!1)}clipRect(r,e,t,o,n=0,a=0,s=0,l=0){let c=Te.XYWHRect(r,e,t,o);if(n===0&&a===0&&l===0&&s===0)this.ctx?.clipRect(c,Te.ClipOp.Intersect,!0);else{let u=Te.RRectXY(c,n,n);u[4]=u[5]=n,u[6]=u[7]=a,u[8]=u[9]=s,u[10]=u[11]=l,this.ctx?.clipRRect(u,Te.ClipOp.Intersect,!0)}}_applyShadowOffsetMatrix(){if(this.ctx){let r=Ee.invert(this.currentTransform);this.ctx.concat(r);let e=Ee.translate(Ee.identity(),this._dropShadowOffsetX,this._dropShadowOffsetY);this.ctx.concat(e),this.ctx.concat(this._currentTransform)}}_applyEffectsToPaint(r,e,t=!0){if(this.ctx&&this._currentPath){let o,n=!1;if(t&&this._hasDropShadow()){let a=r.copy();a.setColor(hd(this._dropShadowColor));let s;this._dropShadowBlur>0&&(s=Te.MaskFilter.MakeBlur(Te.BlurStyle.Normal,this._dropShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s)),this.ctx.save(),this.ctx.clipPath(this._currentPath,Te.ClipOp.Difference,!0),this._applyShadowOffsetMatrix(),e(a),this.ctx.restore(),a.delete(),s?.delete()}if(this._backgroundBlur>0&&t){this.ctx.save(),this.ctx.clipPath(this._currentPath,Te.ClipOp.Intersect,!0);let a=Te.ImageFilter.MakeBlur(this._backgroundBlur,this._backgroundBlur,Te.TileMode.Clamp,null),s=r.copy();s.setImageFilter(a),s.setAlphaf(1);let l=this._currentPath.computeTightBounds();this.ctx.saveLayer(s,l,null,Te.SaveLayerInitWithPrevious),this.ctx.drawColor(r.getColor()),this.ctx.restore(),this.ctx.restore(),s.delete(),a.delete(),n=!0}if(this._layerBlur>0){let a=r.copy();o=Te.MaskFilter.MakeBlur(Te.BlurStyle.Normal,this._layerBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(o),e(a),a.delete(),o.delete(),n=!0}if(n||e(r),t&&this._hasInnerShadow()){let a=new Te.Paint;a.setAntiAlias(!0),a.setStyle(Te.PaintStyle.Fill),a.setColor(hd(this._innerShadowColor));let s;this._innerShadowBlur>0&&(s=Te.MaskFilter.MakeBlur(Te.BlurStyle.Normal,this._innerShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s));let l=this._currentPath.computeTightBounds(),[c,u,p,d]=l,f=p-c,h=d-u;this.ctx.save(),this.ctx.clipPath(this._currentPath,Te.ClipOp.Intersect,!0),this.ctx.saveLayer(a,l,null,Te.SaveLayerInitWithPrevious),this.ctx?.translate(this._innerShadowOffsetX,this._innerShadowOffsetY),this.ctx.drawRect(Te.XYWHRect(-1e3-this._innerShadowOffsetX,-1e3-this._innerShadowOffsetY,2e3+f+Math.abs(this._innerShadowOffsetX*2),2e3+h+Math.abs(this._innerShadowOffsetY*2)),a),a.setBlendMode(Te.BlendMode.Clear),this.ctx.drawPath(this._currentPath,a),this.ctx.restore(),this.ctx.restore(),a.delete(),s?.delete()}}}_paintInner(r,e=!0){if(this.ctx&&this._currentPath&&r){let t=this.ctx,o=this._currentPath;this._applyEffectsToPaint(r,n=>{let a=!1;!e&&this._strokeMode!=="center"&&(t.save(),t.clipPath(o,this._strokeMode==="outside"?Te.ClipOp.Difference:Te.ClipOp.Intersect,!0),a=!0),t.drawPath(o,n),a&&t.restore()},e)}}_hasDropShadow(){return this._dropShadowColor?.a>0}_hasInnerShadow(){return this._innerShadowColor?.a>0}path(r){this._currentPath?.addPath(Te.Path.MakeFromSVGString(r))}ellipse(r,e,t,o,n,a,s,l){if(!v1([r,e,t,o])||!this._currentPath)return;if(t<0||o<0)throw Error("radii cannot be negative");let c=Te.XYWHRect(r-t,e-o,t*2,o*2);this._currentPath?.addOval(c)}rect(r,e,t,o,n=0,a=0,s=0,l=0){let c=Te.XYWHRect(r,e,t,o);if(!!v1(c))if(n===0&&a===0&&l===0&&s===0)this._currentPath?.addRect(c);else{let u=Te.RRectXY(c,n,n);u[4]=u[5]=n,u[6]=u[7]=a,u[8]=u[9]=s,u[10]=u[11]=l,this._currentPath?.addRRect(u)}}getHorizontalAlign(r){switch(r){case 2:return Te.TextAlign.Right;case 3:return Te.TextAlign.Center;case 4:return Te.TextAlign.Justify;case 1:default:return Te.TextAlign.Left}}drawTextInner(r,e,t,[o,n,a,s],l,c,u=!0){let p=0,{ctx:d}=this;if(!d)return p;let f=c.copy(),h=c.copy();return h.setAlphaf(0),this._applyEffectsToPaint(f,m=>{e.pushPaintStyle(t,m,h),e.addText(r);let y=e.build();y.layout(a);let b=n;l===2?b+=(s-y.getHeight())/2:l===3&&(b+=s-y.getHeight()),d.drawParagraph(y,o,b),p=y.getHeight(),e.reset(),y.delete()},u),f.delete(),h.delete(),p}drawText(r,e){let t=0,o=this._fonts.get(e.font),{ctx:n,_paintFill:a,_paintStroke:s}=this;if(o&&n){let l=new Te.TextStyle({fontFamilies:[e.font],fontSize:e.fontSize,heightMultiplier:e.lineHeight,letterSpacing:e.letterSpacing}),c=new Te.ParagraphStyle({textStyle:l,textAlign:this.getHorizontalAlign(e.horizontalAlign)}),u=Te.XYWHRect(e.x,e.y,e.width,e.height),p=Te.ParagraphBuilder.Make(c,o);a&&(t=this.drawTextInner(r,p,l,u,e.verticalAlign,a,!0)),s&&(t=this.drawTextInner(r,p,l,u,e.verticalAlign,s,!1)),p.delete()}return{height:t}}render(){this._surface?.flush()}moveTo(r,e){this._currentPath?.moveTo(r,e)}lineTo(r,e){this._currentPath?.lineTo(r,e)}bezierCurveTo(r,e,t,o,n,a){this._currentPath?.cubicTo(r,e,t,o,n,a)}quadraticCurveTo(r,e,t,o){this._currentPath?.quadTo(r,e,t,o)}setTransform(r,e=!1){if(!this.ctx)return;let t=this.ctx.getTotalMatrix(),o=Ee.invert(t);if(o&&this.ctx.concat(o),this.ctx?.scale(this.dpr,this.dpr),this.camera?.enabled&&(this.ctx?.concat(this.camera.worldMatrix),e)){let n=Ee.getScale(this.camera.worldMatrix);this.ctx?.scale(1/n[0],1/n[1])}this.ctx?.concat(r),this.currentTransform=r}transform(r){this.ctx?.concat(r)}setSize(r,e){!this._isSizeDirty&&r===this._width&&e===this._height||(this._isSizeDirty=!1,this._width=r,this._height=e,this.canvas.style.width=r+"px",this.canvas.style.height=e+"px",this.canvas.width=r*this.dpr,this.canvas.height=e*this.dpr,this._surface&&(this._surface=Te.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas()))}};function v1(i){for(let r=0;r<i.length;r++)if(i[r]!==void 0&&!Number.isFinite(i[r]))return!1;return!0}function hd({r:i,g:r,b:e,a:t}){return Te.Color4f(i,r,e,t)}var Dl=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.blurRadius=0;this.offset=[0,0];this.spread=0;this.update(e)}update(r){r.color!==void 0&&(this.color=r.color),r.enabled!==void 0&&(this.enabled=r.enabled),r.blurRadius!==void 0&&(this.blurRadius=r.blurRadius),r.offset!==void 0&&(this.offset=r.offset),r.spread!==void 0&&(this.spread=r.spread)}};var _l=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.radius=0;this.update(e)}update(r){r.enabled!==void 0&&(this.enabled=r.enabled),r.radius!==void 0&&(this.radius=r.radius)}};var md=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.update(e)}update(r){r.enabled!==void 0&&(this.enabled=r.enabled),r.color!==void 0&&(this.color=r.color)}};var yd=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.thickness=0;this.mode="inside";this.update(e)}update(r){r.enabled!==void 0&&(this.enabled=r.enabled),r.color!==void 0&&(this.color=r.color),r.thickness!==void 0&&(this.thickness=r.thickness),r.mode!==void 0&&(this.mode=r.mode)}};var sr=class extends Yo{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.autoClose=!0;this.fill=new md(e+"-fill",t.fill,o),this.stroke=new yd(e+"-stroke",t.stroke,o),this.dropShadow=new Dl(e+"-dropShadow",t.dropShadow,o),this.innerShadow=new Dl(e+"-innerShadow",t.innerShadow,o),this.backgroundBlur=new _l(e+"-backgroundBlur",t.backgroundBlur,o),this.layerBlur=new _l(e+"-layerBlur",t.layerBlur,o)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ie.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ie.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=Ie.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=Ie.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.type===0&&(Le(e.path,["fill"])?this.fill.update(e.props):Le(e.path,["stroke"])?this.stroke.update(e.props):Le(e.path,["dropShadow"])?this.dropShadow.update(e.props):Le(e.path,["innerShadow"])?this.innerShadow.update(e.props):Le(e.path,["layerBlur"])?this.layerBlur.update(e.props):Le(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,t){super.updateState(e,t),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let t=new sr(this.uuid,this.data,e);return t.parent=void 0,t}};var _i=class extends sr{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.width=0;this.height=0;this.updateState(t,o)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,t){return d1(e,t,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e)}clone(e){let t=new _i(this.uuid,this.data,e);return t.parent=void 0,t}};var vo=class extends sr{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.width=0;this.height=0;this.cornerRadius=[0,0,0,0];this.updateState(t,o)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let t=new vo(this.uuid,this.data,e);return t.parent=void 0,t}};var Ri=class extends sr{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this._textHeight=0;this._textHeightDirty=!0;this.width=0;this.height=0;this.updateState(t,o)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ie.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ie.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){this._fontHolder?.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let t=this.data.textTransform,o=this.data.text.textValue.toString(),n=t===2?o.toUpperCase():t===3?o.toLowerCase():o,{height:a}=e.drawText(n,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=a}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:t}){e.font!==void 0&&(this._fontHolder=t.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateFontState(e,t)}clone(e){let t=new Ri(this.uuid,this.data,e);return t.parent=void 0,t}};var gs=class extends sr{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.curves=[];this.extremasBBox={min:[0,0],max:[0,0]};this.updateState(t,o)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(n=>gd.extremas(n)),t=[1/0,1/0],o=[-1/0,-1/0];for(let n=0,a=e.length;n<a;n++){let s=e[n];s[0][0]<t[0]&&(t[0]=s[0][0]),s[0][1]<t[1]&&(t[1]=s[0][1]),s[1][0]>o[0]&&(o[0]=s[1][0]),s[1][1]>o[1]&&(o[1]=s[1][1])}return this.extremasBBox.min=[t[0],t[1]],this.extremasBBox.max=[o[0],o[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let o=1,n=this.data.points.length;o<n;o++){let a=this.data.points[o].data,s=this.data.points[o-1].data,l={start:s.position,cp1:s.controlNext.position,cp2:a.controlPrevious.position,end:a.position};this.curves.push(l)}let e=this.data.points[0].data,t=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let o={start:t.position,cp1:t.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(o)}}getCenter(){let[e,t]=this.extremasBBox.min,[o,n]=this.getHalfSize();return[e+o,t+n]}getHalfSize(){let{min:e,max:t}=this.extremasBBox;return[(t[0]-e[0])*.5,(t[1]-e[1])*.5]}innerDraw(e){for(let n=0,a=this.data.points.length;n<a;n++){let s=this.data.points[n].data;if(n===0){let[l,c]=s.position;e.moveTo(l,c)}else{let l=this.data.points[n-1].data,[c,u]=l.controlNext.position,[p,d]=s.controlPrevious.position,[f,h]=s.position,m={start:l.position,cp1:l.controlNext.position,cp2:s.controlPrevious.position,end:s.position};gd.derive(m),e.bezierCurveTo(c,u,p,d,f,h)}}let t=this.data.points[0].data,o=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[n,a]=o.controlNext.position,[s,l]=t.controlPrevious.position,[c,u]=t.position;e.bezierCurveTo(n,a,s,l,c,u)}}updateState(e,t){super.updateState(e,t),this.computeExtremas()}clone(e){let t=new gs(this.uuid,this.data,e);return t.parent=void 0,t}},gd;(n=>{function i(a){let s=a.start,l=a.cp1,c=a.cp2,u=a.end,p=[3*(l[0]-s[0]),3*(l[1]-s[1])],d=[3*(c[0]-l[0]),3*(c[1]-l[1])],f=[3*(u[0]-c[0]),3*(u[1]-c[1])],h={start:p,cp:d,end:f};return a.derivative=h,h.derivative=Dh.derive(h),h}n.derive=i;function r(a,s,l,c=!1){let u=a-2*s+l;if(u!==0){let p=-Math.sqrt(Math.abs(s*s-a*l)),d=-a+s,f=-(p+d)/u,h=-(-p+d)/u;return[f,h]}else if(s!==l&&u===0)return[(2*s-l)/(2*(s-l))];return[]}function e(a){let s=a.derivative??n.derive(a),l=s.start,c=s.cp,u=s.end;return[r(l[0],c[0],u[0]),r(l[1],c[1],u[1])]}n.droot=e;function t(a){let[s,l]=n.droot(a),c=[a.start[0],a.end[0]],u=[a.start[1],a.end[1]];for(let p of s)c.push(n.compute(a,Math.min(1,Math.max(0,p)))[0]);for(let p of l)u.push(n.compute(a,Math.min(1,Math.max(0,p)))[1]);return c.sort((p,d)=>p-d),u.sort((p,d)=>p-d),[[c[0],u[0]],[c[c.length-1],u[u.length-1]]]}n.extremas=t;function o(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let l=1-s,c=l*l,u=s*s,p=c*l,d=c*s*3,f=l*u*3,h=s*u;return[p*a.start[0]+d*a.cp1[0]+f*a.cp2[0]+h*a.end[0],p*a.start[1]+d*a.cp1[1]+f*a.cp2[1]+h*a.end[1]]}n.compute=o})(gd||(gd={}));var Dh;(t=>{function i(o){let n=o.start,a=o.cp,s=o.end,l=[2*(a[0]-n[0]),2*(a[1]-n[1])],c=[2*(s[0]-a[0]),2*(s[1]-a[1])],u={start:l,end:c};return u.derivative=_h.derive(u),o.derivative=u,u}t.derive=i;function r(o){let n=o.derivative??t.derive(o),a=n.start,s=n.end;return[a[0]!==s[0]?a[0]/(a[0]-s[0]):0,a[1]!==s[1]?a[1]/(a[1]-s[1]):0]}t.droot=r;function e(o,n){if(n===0)return[...o.start];if(n===1)return[...o.end];let a=1-n,s=a*a,l=n*n,c=s,u=a*n*2,p=l;return[c*o.start[0]+u*o.cp[0]+p*o.end[0],c*o.start[1]+u*o.cp[1]+p*o.end[1]]}t.compute=e})(Dh||(Dh={}));var _h;(e=>{function i(t){let o=t.start,n=t.end,a=[n[0]-o[0],n[1]-o[1]];return t.derivative=a,t.derivative}e.derive=i;function r(t,o){if(o===0)return[...t.start];if(o===1)return[...t.end];let n=t.start,a=t.end;return[n[0]+(a[0]-n[0])*o,n[1]+(a[1]-n[1])*o]}e.compute=r})(_h||(_h={}));var hr=class extends Ut{constructor(e,t,o){super(e,t,o);this.uuid=e;this.width=0;this.height=0;this.clipped=!0;this.background=new vo(e+"-background",ya.defaultData,o),this.background.parent=this,this.updateState(t,o)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){super.updateLocalMatrix(),this.background?.updateLocalMatrix()}updateWorldMatrix(e,t,o){super.updateWorldMatrix(e,t,o),this.background?.updateWorldMatrix(e,t,o)}draw(e){if(!this.visible)return;e.save();let t=this.width,o=this.height;this.applyTransforms(e),this.background.width=t,this.background.height=o,this.background.draw(e),this.clipped&&e.clipRect(0,0,t,o,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.type===0&&(Le(e.path,["fill"])?this.fill.update(e.props):Le(e.path,["stroke"])?this.stroke.update(e.props):Le(e.path,["dropShadow"])?this.dropShadow.update(e.props):Le(e.path,["innerShadow"])?this.innerShadow.update(e.props):Le(e.path,["layerBlur"])?this.layerBlur.update(e.props):Le(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let t=new hr(this.uuid,this.data,e);t.parent=void 0;for(let o of this.children)t.add(o.clone(e));return t}};var T1=Ms(Rh(),1),Ko=class extends sr{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this._pathBBox=new DOMRect;this.path="";this.updateState(t,o),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg"),t=document.createElementNS("http://www.w3.org/2000/svg","path");document.body.appendChild(e),t.setAttribute("d",this.path),e.appendChild(t),this._pathBBox=t.getBBox(),e.remove()}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,t){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&t>=this._pathBBox.y&&t<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,t){super.updateState(e,t),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let t=new Ko(this.uuid,this.data,e);return t.parent=void 0,t}};function C1(i,r=1,e=1){if(r<=0||e<=0)return i;let o=(0,T1.parseSVG)(i).map(n=>{let a={...n};return"x"in a&&(a.x=a.x*r),"y"in a&&(a.y=a.y*e),"x1"in a&&(a.x1=a.x1*r),"x2"in a&&(a.x2=a.x2*r),"y1"in a&&(a.y1=a.y1*e),"y2"in a&&(a.y2=a.y2*e),"rx"in a&&(a.rx=a.rx*r),"ry"in a&&(a.ry=a.ry*e),a});return A1(o)}function A1(i){let r=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],e;return i.map(t=>{let o=[];r.forEach(a=>{if(a in t){let s=t[a]*1;o.length&&s>=0&&o.push(","),o.push(s)}});let n=(e===t.code?o[0]<0?"":",":t.code)+o.join("");return e=t.code,n}).join("")}function M1(i,r,e){switch(r.type){case"ellipse2d":return new _i(i,r,e);case"rectangle2d":return new vo(i,r,e);case"text2d":return new Ri(i,r,e);case"vector2d":return new gs(i,r,e);case"path2d":return new Ko(i,r,e);case"frame2d":return new hr(i,r,e);case"group2d":default:return new ar(i,r,e)}}var Lh=class{constructor(r,e,t){this.uuid=r;this.data=e;this.group=new ar(Lh.GROUP_ID,{...ks.defaultData},t),this.createChildrenObjects(e.objects,this.group,t)}createObject(r,e,t,o,n,a){let s=M1(r,e,a);s&&(o.add(s),o.children.splice(n,0,o.children.pop()),s.updateWorldMatrix(),t.length>0&&(s instanceof ar||s instanceof hr)&&this.createChildrenObjects(t,s,a))}createChildrenObjects(r,e,t){let o=0;for(let n of r)this.createObject(n.id,n.data,n.children,e,o,t),o+=1}draw(r){this.group.draw(r)}updateEntityByOp(r,e,t,o){let n=this.find(r);if(n)try{n.updateByOp(e,t,{shared:o})}catch(a){console.error(a)}}updateTreeByOp(r,e){if(r.path.length===0&&r.type===7){let t=r.parent===null?this.group:this.find(r.parent);t!==void 0&&t instanceof Ut&&(this.createObject(r.id,r.data,r.children,t,r.localIndex,e),t.requestRender())}else if(r.path.length===0&&r.type===8){let t=this.find(r.id);if(t!==void 0&&t.parent!==void 0&&t.parent instanceof Ut){let o=t.parent;t.resetBBoxNeedsUpdate(),o?.remove(t),o?.requestRender()}}else if(r.path.length===0&&r.type===9){let t=this.find(r.id);if(t!==void 0){let o=t.parent,n=r.parent===null?this:this.find(r.parent);if(n===void 0&&!1&&console.error("unexpected",n,r),n instanceof Ut||n===this){n.add(t);let a=r.localIndex;n.children.splice(a,0,n.children.pop()),t.updateWorldMatrix(!0,!1,!0),o?.requestRender(),t.requestRender()}t.resetBBoxNeedsUpdate()}}}add(r){this.group.add(r)}remove(r){this.group.remove(r)}traverse(r){this.group.traverse(e=>{e!==this.group&&r(e)})}intersectsChildren(r,e,t,o=!1,n=[]){return this.group.intersectsChildren(r,e,t,o,n,!0)}intersectsChildrenReverse(r,e,t,o=!1,n=[]){return this.group.intersectsChildrenReverse(r,e,t,o,n,!0)}find(r){return this.group.find(r)}get children(){return this.group.children}project(r,e){return this.group.project(r,e)}getWithSortKey(r){let e=this.find(r);if(e===void 0)return;let t=[],o=e;for(;o!==this.group;){let n=o;o=o.parent;let a=o.children.indexOf(n);t.splice(0,0,a)}return{entity:e,sortKey:t}}getAllSorted(r){let e=[];for(let t of r){let o=this.getWithSortKey(t.id);o!==void 0&&e.push(o)}return e.sort((t,o)=>ql(t.sortKey,o.sortKey)),e.map(t=>t.entity)}},wn=Lh;wn.GROUP_ID="scene2d";function Bh({constraints:i,newParentWidth:r,newParentHeight:e,initialParentWidth:t,initialParentHeight:o,objectInitialWidth:n,objectInitialHeight:a,objectInitialPosition:s}){let{horizontalConstraint:l,verticalConstraint:c}=i,u=r-t,p=e-o,d=n,f=a,h=s[0],m=s[1];if(l!==0){if(l===1)h+=u;else if(l===3)h+=u/2;else if(l===2)d=Math.max(1,d+u);else if(l===4){let y=r/t;d*=y,h*=y}}if(c!==0){if(c===1)m+=p;else if(c===3)m+=p/2;else if(c===2)f=Math.max(1,f+p);else if(c===4){let y=e/o;f*=y,m*=y}}return{width:d,height:f,position:[h,m]}}var s_=Ms(Rh(),1);var Rce={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{mm:1,px:1,cm:1,in:1,pt:1,pc:1}};import{BufferGeometry as l_,CanvasTexture as c_,Float32BufferAttribute as I1,HalfFloatType as u_,MathUtils as d_,Mesh as p_,OrthographicCamera as f_,ShaderMaterial as h_,Uniform as m_,WebGLRenderTarget as y_}from"three";var g_=`
2663
+ `,z_=Ml.lights_fragment_begin,G_=Ml.shadowmask_pars_fragment,b1=null,F_=i=>{switch(i){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},v1=(i="medium")=>{if(b1===i)return!1;b1=i;let r=F_(i);Ml.shadowmap_pars_fragment=V_(r);let e=z_.slice();e=e.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),e=e.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),Ml.lights_fragment_begin=e;let t=G_.slice();return t=t.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),Ml.shadowmask_pars_fragment=t,!0};import{DirectionalLight as W_,CameraHelper as S1}from"three";import{DirectionalLightHelper as j_}from"three";var fs=class extends xo(j_){constructor(e,t=15,o=10066329){super(e,t,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){bo(this.object,fs.geometryHelper,e,t)}};import{PointLightHelper as U_}from"three";var hs=class extends xo(U_){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){bo(this.object,hs.geometryHelper,e,t)}};import{SpotLightHelper as k_,Vector3 as H_}from"three";var md=class extends xo(k_){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){bo(this.object,md.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=md._vector,t=this.object.distance?this.object.distance:1e3,o=t*Math.tan(this.object.angle);this.cone.scale.set(o,o,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let a=0,s=this.cone.material.length;a<s;a++)this.cone.material[a].color.set(n);else this.cone.material.color.set(n)}}},Il=md;Il._vector=new H_;function q_(i,r){i.shadow.camera.right=r/2,i.shadow.camera.left=-r/2,i.shadow.camera.top=r/2,i.shadow.camera.bottom=-r/2,i.shadow.needsUpdate=!0}var ms=class extends ds(W_,fs){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.top=1250,n.bottom=-1250,n.right=1250,n.left=-1250,n.near=-1e4,n.far=2500;let a=new S1(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof S1&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e);let t=r.depth!==void 0&&r.depth!==this.shadow.camera.far||r.size!==void 0&&r.size/2!==this.shadow.camera.right;r.size!==void 0&&q_(this,r.size),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),r.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t&&this.update()}};import{Scene as AR}from"three";import{SpotLight as $_,CameraHelper as w1,MathUtils as X_,Vector3 as C1,Quaternion as Y_}from"three";var P1=new C1,O1=new C1,T1=new Y_,ys=class extends ds($_,Il){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=X_.RAD2DEG*2*this.angle,n.aspect=1,n.near=100,n.far=2500;let a=new w1(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof w1&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),O1.setFromMatrixPosition(this.matrixWorld),T1.setFromRotationMatrix(this.matrixWorld),P1.copy(this.up).applyQuaternion(T1).negate().multiplyScalar(this.distance),this.target.position.copy(O1).add(P1),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.angle!==void 0&&(this.angle=r.angle),r.penumbra!==void 0&&(this.penumbra=r.penumbra),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};function K_(i){let r=(i[0][0]+i[1][1])/2,e=(i[0][0]-i[1][1])/2,t=(i[1][0]+i[0][1])/2,o=(i[1][0]-i[0][1])/2,n=Math.sqrt(r*r+o*o),a=Math.sqrt(e*e+t*t),s=n+a,l=n-a,c=Math.atan2(t,e),u=Math.atan2(o,r),p=(u-c)/2,d=(u+c)/2,f=[[Math.cos(d),Math.sin(d)],[-Math.sin(d),Math.cos(d)]],h=[[s,0],[0,l]],m=[[Math.cos(p),Math.sin(p)],[-Math.sin(p),Math.cos(p)]];return f[0][0]*=-1,f[0][1]*=-1,m[0][0]*=-1,m[1][0]*=-1,[f,h,m]}function yd(i,r){return[[i[0][0]*r[0][0]+i[0][1]*r[1][0],i[0][0]*r[0][1]+i[0][1]*r[1][1]],[i[1][0]*r[0][0]+i[1][1]*r[1][0],i[1][0]*r[0][1]+i[1][1]*r[1][1]]]}function A1(i){return[[i[0][0],i[1][0]],[i[0][1],i[1][1]]]}function M1(i){let[r,e,t]=K_(i),o=yd(r,A1(t)),n=yd(yd(t,e),A1(t)),a=Math.atan2(o[1][0],o[0][0]),s=[n[0][0],n[1][1]],l=[n[0][1]/n[1][1],n[1][0]/n[0][0]];return{rotation:a,scale:s,shear:l}}function I1({rotation:i,scale:r,shear:e}){let t=Math.cos(i),o=Math.sin(i),n=[[t,-o],[o,t]],a=[[r[0],e[0]*r[1]],[e[1]*r[0],r[1]]],s=yd(n,a);return[s[0][0],s[1][0],s[0][1],s[1][1]]}var Ee;(S=>{function i(){return[1,0,0,0,1,0,0,0,1]}S.identity=i;function r(T,M=S.identity()){for(let g=0,D=T.length;g<D;g++)M[g]=T[g];return M}S.copy=r;function e(T,M,g,D,E,I){return S.setAbcdef(S.identity(),T,M,g,D,E,I)}S.create=e;function t(T,M,g,D,E,I,N){return T[0]=M,T[1]=D,T[2]=I,T[3]=g,T[4]=E,T[5]=N,T}S.setAbcdef=t;function o(T,M){let[g,D,E,I,N,_]=a(T),[R,V,U,B,q,j]=a(M),F=R*g+V*E,H=R*D+V*I,W=U*g+B*E,ee=U*D+B*I,te=q*g+j*E+N,Y=q*D+j*I+_;return S.create(F,H,W,ee,te,Y)}S.append=o;function n(T,M){let[g,D,E,I,N,_]=a(T),[R,V,U,B,q,j]=a(M),F=g,H=D,W=E,ee=I;(R!==1||V!==0||U!==0||B!==1)&&(F=g*R+D*U,H=g*V+D*B,W=E*R+I*U,ee=E*V+I*B);let te=N*R+_*U+q,Y=N*V+_*B+j;return S.create(F,H,W,ee,te,Y)}S.prepend=n;function a(T){return[T[0],T[3],T[1],T[4],T[2],T[5]]}S.getAbcdef=a;function s(T){let[M,g,D,E,I,N]=S.getAbcdef(T),_=M*E-g*D,R=E/_,V=-g/_,U=-D/_,B=M/_,q=(D*N-E*I)/_,j=-(M*N-g*I)/_;return S.create(R,V,U,B,q,j)}S.invert=s;function l([T,M],g){let[D,E,I,N,_,R]=S.getAbcdef(g);return[D*T+I*M+_,E*T+N*M+R]}S.apply=l;function c(T,M){let[g,D,E,I,N,_]=S.getAbcdef(M),R=1/(g*I+E*-D),[V,U]=T;return[I*R*V+-E*R*U+(_*E-N*I)*R,g*R*U+-D*R*V+(-_*g+N*D)*R]}S.applyInverse=c;function u(T,M,g=M){let[D,E,I,N,_,R]=S.getAbcdef(T);return S.setAbcdef(T,D*M,E*g,I*M,N*g,_*M,R*g),T}S.scale=u;function p(T,M){let g=Math.cos(M),D=Math.sin(M),[E,I,N,_,R,V]=S.getAbcdef(T);return S.setAbcdef(T,E*g-I*D,E*D+I*g,N*g-_*D,N*D+_*g,R*g-V*D,R*D+V*g),T}S.rotate=p;function d(T,M,g){let[D,E]=g,I=S.translate(T,-D,-E);return I=S.rotate(I,M),I=S.translate(I,D,E),I}S.rotateAround=d;function f(T,M,g){let[D,E,I,N,_,R]=S.getAbcdef(T);return S.setAbcdef(T,D,E,I,N,_+M,R+g),T}S.translate=f;function h(T,M,g){let[D,E,I,N]=S.getAbcdef(T);return S.setAbcdef(T,D,E,I,N,M,g),T}S.setTranslate=h;function m(T,M,g){let[D,E,I,N]=S.getAbcdef(T);return S.setAbcdef(T,D,E,I,N,M,g),T}S.setPosition=m;function y(T){let[M,g,D,E]=S.getAbcdef(T),I=Math.sqrt(M*M+g*g),N=Math.sqrt(D*D+E*E);return[I,N]}S.getScale=y;function b(T){let[,,,,M,g]=S.getAbcdef(T);return[M,g]}S.getPosition=b;function v(T,M){return S.decompose(T,M).rotation}S.getRotation=v;function w(T,M){let[g,D,E,I,N,_]=S.getAbcdef(T),{rotation:R,scale:V,shear:U}=M1([[g,E],[D,I]]);return{position:[N+(M[0]*g+M[1]*E)-M[0],_+(M[0]*D+M[1]*I)-M[1]],scale:V,rotation:R,shear:U,pivot:M}}S.decompose=w;function O(T,M,g,D,E=[0,0]){let[I,N]=T,[_,R]=D,[V,U,B,q]=I1({rotation:g,scale:M,shear:E}),j=I-(_*V+R*B)+_,F=N-(_*U+R*q)+R;return S.create(V,U,B,q,j,F)}S.compose=O})(Ee||(Ee={}));var Q_=Math.PI/180,Mle=180/Math.PI;function E1(i,r,e,t,o,n){let a=i-e,s=r-t;return a*a/(o*o)+s*s/(n*n)<=1}function N1(i){return i*Q_}var Yo=class{constructor(r,e,t){this.uuid=r;this.data=e;this.localMatrix=Ee.identity();this.worldMatrix=Ee.identity();this.ignoreCameraZoom=!1;this.visible=!0;this._singleBBox=new Di;this._recursiveBBox=new Di;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.stateSelection=null;this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this.name="";this.position=[0,0];this.scale=[1,1];this.rotation=0;this.shear=[0,0];this.emitter=Fo();this.dpr=t.dpr??1,this.dataPatched=e}project(r,e){let t=this.worldMatrix;return e&&(t=Ee.append(e.worldMatrix,t)),Ee.applyInverse(r,t)}intersects(r,e,t,o=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([r,e],t),o)}intersectsInLocalSpace(r,e,t=!1){let{min:o,max:n}=t?this.recursiveBBox:this.singleBBox;return r>=o[0]&&r<=n[0]&&e>=o[1]&&e<=n[1]}applyTransforms(r){r.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=Ee.compose(this.position,this.scale,N1(this.rotation),Bo.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(r,e,t){let o=this.parent;e&&o!==null&&o!==void 0&&o.updateWorldMatrix(r,!0,!1),r&&this.updateLocalMatrix(),this.parent?this.worldMatrix=Ee.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=Ee.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return Bo.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{r.resetBBoxNeedsUpdateSelf()})}updateTransformState(r){let e=!1;r.position!==void 0&&(e=!0,this.position=r.position),r.rotation!==void 0&&(e=!0,this.rotation=r.rotation),r.scale!==void 0&&(e=!0,this.scale=r.scale),r.shear!==void 0&&(e=!0,this.shear=r.shear),e&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(r,e,t){r.type===0&&r.props.visible!==void 0&&(this.visible=r.props.visible),this.data=e,this.data=e;let o=r,n=Le(r.path,["states","*"]);if(n!==null){if(r.type===0){let[a]=n;if(this?.stateSelection===a){let s={...r.props};if(delete s.name,Object.values(r.props).some(l=>l===void 0)){let l=this.data;if(l!==void 0){let c=Ze.zoom(l,r.path.slice(2));if(c)for(let u in r.props)r.props[u]===void 0&&u in c&&(s[u]=c[u])}}o={...r,props:s,path:r.path.slice(2)}}}}else if(r.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(r.props.name!==void 0&&a.name){let{name:l,...c}=a;a=c}let s=Ze.removeOverridden(r.path,r.props,a);o={...r,props:s}}}this.updateByPatchedOpBase(o,tn.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),t)}changeSelectedState(r,e,t=!1){if(!(this.data.states.length===0&&!t)){for(let o of this.data.states)tn.toOps(this.data,o.data).forEach(a=>{let s=ea.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,e)});if(r!==null){let o=this.data.states.data(r);o&&(this.dataPatched=tn.patch(this.data,o),tn.toOps(this.data,o).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,e)}))}t&&this.updateTransformState(this.dataPatched),this.stateSelection=r}}updateState(r,e){r.name!==void 0&&(this.name=r.name),r.visible!==void 0&&(this.visible=r.visible),this.updateTransformState(r)}updateByPatchedOpBase(r,e,t){this.dataPatched=e,this.updateByPatchedOp(r,e,t)}updateByPatchedOp(r,e,t){r.path.length===0&&r.type===0&&this.updateState(r.props,t),this.requestRender()}traverseFrameAncestors(r){this.traverseAncestors(e=>{e.data.type==="frame2d"&&r(e)})}traverseAncestors(r){let e=this.parent;for(;e;)r(e),e=e.parent}requestRender(){this.traverseFrameAncestors(r=>{r.requestRender()})}clone(r){let e=new Yo(this.uuid,this.data,r);return e.parent=void 0,e}addEventListener(r,e){this.emitter.on(r,e)}removeEventListener(r,e){this.emitter.off(r,e)}dispatchEvent(r){this.emitter.emit(r.type,{...r,target:r.target??this})}traverseSortNextHelper(){let r=this.parent;if(r){let e=r.children;if(e){let t=e.indexOf(this)+1;return e[t]?e[t]:r.traverseSortNextHelper()}}}sortNext(){let r=this.children;return r&&r.length>0&&r[0]?r[0]:this.traverseSortNextHelper()}isDescendantOf(r){r instanceof Yo&&(r=r.uuid);let e=this;for(;e.parent;){if(e.parent.uuid===r)return!0;e=e.parent}return!1}};var Ut=class extends Yo{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.context=o;this.children=[]}add(e){e.parent&&e.parent instanceof Ut&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let t=this.children.indexOf(e);t>=0&&(this.children.splice(t,1),e.parent=void 0)}traverse(e){let t=e(this);if(t!==!0)for(let o of this.children)o instanceof Ut?o.traverse(e):t=e(o)}intersectsChildrenHelper(e,t,o,n,a){for(let s of this.children)if(s.intersects(e,t,o,!1)&&(a.push(s),n)||s instanceof Ut&&s.intersectsChildrenHelper(e,t,o,n,a))return!0;return!1}intersectsChildren(e,t,o,n=!1,a=[],s=!1){return this.intersectsChildrenHelper(e,t,o,n,a),a}intersectsChildrenHelperReverse(e,t,o,n,a){for(let s of this.children)if(s instanceof Ut&&s.intersectsChildrenHelperReverse(e,t,o,n,a)||s.intersects(e,t,o,!1)&&(a.push(s),n))return!0;return!1}intersectsChildrenReverse(e,t,o,n=!1,a=[],s=!1){return this.intersectsChildrenHelperReverse(e,t,o,n,a),a}updateWorldMatrix(e,t,o){if(super.updateWorldMatrix(e,t,o),o&&this.children)for(let n of this.children)n.updateWorldMatrix(e,!1,!0)}find(e){let t;return this.traverse(o=>{o.uuid===e&&(t=o)}),t}innerDrawChildren(e){for(let t=this.children.length-1;t>=0;t--)this.children[t].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let t=new Ut(this.uuid,this.data,e);t.parent=void 0;for(let o of this.children)t.add(o.clone(e));return t}},ar=class extends Ut{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.updateState(t,o)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let t=new ar(this.uuid,this.data,e);t.parent=void 0;for(let o of this.children)t.add(o.clone(e));return t}};function Z_(i,r){let[[e,t],[o,n]]=i,[[a,s],[l,c]]=r,u=(e-o)*(s-c)-(t-n)*(a-l);if(u===0)return!1;let p=((e-a)*(s-c)-(t-s)*(a-l))/u,d=-((e-o)*(t-s)-(t-n)*(e-a))/u;return p>=0&&p<=1&&d>=0&&d<=1}var _1=[[-1,1],[-1,-1],[1,-1],[1,1]],D1=(i,r,e)=>{let t=i.getCenter(),o=i.getHalfSize(),n=Ee.append(r,i.worldMatrix);o[0]===0&&o[1]===0?e.push(Ee.apply(t,n)):_1.forEach(a=>{let s=[a[0]*o[0]+t[0],a[1]*o[1]+t[1]];e.push(Ee.apply(s,n))})},Di=class{constructor(){this.matrix=Ee.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(r,e=!1){r.updateWorldMatrix(),this.makeEmpty(),Ee.copy(r.worldMatrix,this.matrix);let t=Ee.invert(r.worldMatrix);this.expandByObjectSize(r,t,e)}expandByObjectSize(r,e,t=!1){let o=[];t===!0&&r instanceof Ut?r.traverse(n=>{n.visible&&D1(n,e,o)}):D1(r,e,o),this.setFromPoints(o)}setFromSize(r,e,t){this.makeEmpty(),Ee.copy(t,this.matrix),this.expandBySize(r,e,t)}expandBySize(r,e,t){[Ee.apply([0,0],t),Ee.apply([0,e],t),Ee.apply([r,e],t),Ee.apply([r,0],t)].forEach(n=>this.expandByPoint(n))}getCenter(){let[r,e]=this.min,[t,o]=this.getHalfSize();return Ee.apply([r+t,e+o],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(r){this.makeEmpty();for(let e of r)this.expandByPoint(e)}expandByPoint(r){this.min=[Math.min(this.min[0],r[0]),Math.min(this.min[1],r[1])],this.max=[Math.max(this.max[0],r[0]),Math.max(this.max[1],r[1])]}computeVertices(){let[r,e]=this.getHalfSize(),t=this.getCenter(),[o,n,a,s]=Ee.getAbcdef(this.matrix),l=Ee.create(o,n,a,s,t[0],t[1]);this.vertices=_1.map(([c,u])=>Ee.apply([c*r,u*e],l))}computeEdges(){this.edges=[];for(let r=0,e=this.vertices.length;r<e;++r)this.edges.push([this.vertices[r],this.vertices[(r+1)%e]])}project(r,e){let t=this.matrix;return e&&(t=Ee.append(e.worldMatrix,t)),Ee.applyInverse(r,t)}intersects(r,e,t){return this.intersectsInLocalSpace(...this.project([r,e],t))}intersectsInLocalSpace(r,e){let{min:t,max:o}=this;return r>=t[0]&&r<=o[0]&&e>=t[1]&&e<=o[1]}containsPoint(r){let[e,t]=r,[o,n]=this.min,[a,s]=this.max;return e>=o&&e<=a&&t>=n&&t<=s}intersectsBBox2D(r){for(let e=0,t=this.edges.length;e<t;e++){let o=this.edges[e];for(let n=0,a=r.edges.length;n<a;n++){let s=r.edges[n];if(Z_(o,s))return!0}}for(let e=0,t=r.vertices.length;e<t;e++){let o=r.vertices[e];if(this.containsPoint(o))return!0}return!1}ensureMinMax(){let r=this.min,e=this.max;this.min=[Math.min(r[0],e[0]),Math.min(r[1],e[1])],this.max=[Math.max(r[0],e[0]),Math.max(r[1],e[1])]}copy(r){this.min=[...r.min],this.max=[...r.max],Ee.copy(r.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let r=new Di;return r.copy(this),r}};var L1,B1=new Promise(i=>{L1=i}),R1=!1;var gd;function V1(){if(R1)return;if(gd)return gd;async function i(){let e=await import("./ui.js");L1(e.default??e),R1=!0}return gd=i(),gd}function F1(i){let r=!1;return i.scene.objects.traverse((e,t)=>{(t.type==="Mesh"&&t.geometry.type==="UIGeometry"||t.type==="Page"&&t.uiFrame!==void 0)&&(r=!0)}),r}var Te,Gh;async function J_(i){let r=await B1;Te||(Gh||(Gh=r({locateFile:()=>i})),Te=await Gh)}var z1=Ee.identity(),Nl=class{constructor(r,e=1){this.canvas=r;this._dpr=e;this._width=0;this._height=0;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=Ie.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=Ie.transparent;this._fonts=new Map;this._isSizeDirty=!1;try{let t=r.getBoundingClientRect();r.width=t.width*e,r.height=t.height*e}catch{console.log(r.width,e)}this._currentM3Transform=z1,this._currentTransform=new Float32Array(z1)}get dpr(){return this._dpr}set dpr(r){this._dpr=r,this._isSizeDirty=!0}async init(){if(!this.wasmURL)throw Error("Your must set the wasm binary url with renderer.wasmURL = ... before you can call renderer.init");await J_(this.wasmURL),this._surface=Te.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas(),this._paint=new Te.Paint,this._paint.setAntiAlias(!0),this._paintFill=this._paint.copy(),this._paintFill.setStyle(Te.PaintStyle.Fill),this._paintStroke=this._paint.copy(),this._paintStroke.setStyle(Te.PaintStyle.Stroke),this.ctx?.scale(this.dpr,this.dpr)}get currentTransform(){return this._currentM3Transform}get currentTransformBuffer(){return this._currentTransform}set currentTransform(r){this._currentM3Transform=r,this._currentTransform.set(r)}async loadFont(r,e){let t=await(await fetch(r)).arrayBuffer();this.registerFont(t,e)}registerFont(r,e){if(this._fonts.has(e))return;let t=Te.FontMgr.FromData(r);if(t)this._fonts.set(e,t);else throw new Error("Invalid font data for "+e)}get width(){return this._width}get height(){return this._height}set strokeColor(r){this._paintStroke&&this._paintStroke.setColor(xd(r),Te.ColorSpace.DISPLAY_P3)}set fillColor(r){this._paintFill&&this._paintFill.setColor(xd(r),Te.ColorSpace.DISPLAY_P3)}set lineWidth(r){this._paintStroke&&this._paintStroke.setStrokeWidth(this._strokeMode==="center"?r:r*2)}set strokeMode(r){this._strokeMode=r}set dropShadowBlur(r){this._dropShadowBlur=r}set dropShadowColor(r){this._dropShadowColor=r}set dropShadowOffsetX(r){this._dropShadowOffsetX=r}set dropShadowOffsetY(r){this._dropShadowOffsetY=r}set innerShadowBlur(r){this._innerShadowBlur=r}set innerShadowColor(r){this._innerShadowColor=r}set innerShadowOffsetX(r){this._innerShadowOffsetX=r}set innerShadowOffsetY(r){this._innerShadowOffsetY=r}set innerShadowSpread(r){this._innerShadowSpread=r}set layerBlur(r){this._layerBlur=r}set backgroundBlur(r){this._backgroundBlur=r}clear(){this.ctx?.clear(Te.TRANSPARENT)}save(){this.ctx?.save()}restore(){this.ctx?.restore()}beginPath(){this._currentPath?.delete(),this._currentPath=new Te.Path}closePath(){let r=this._currentPath;if(r){if(r.isEmpty())return;let e=r.getBounds();(e[3]-e[1]||e[2]-e[0])&&r.close()}}fill(){this._paintInner(this._paintFill,!0)}stroke(){this._paintInner(this._paintStroke,!1)}clipRect(r,e,t,o,n=0,a=0,s=0,l=0){let c=Te.XYWHRect(r,e,t,o);if(n===0&&a===0&&l===0&&s===0)this.ctx?.clipRect(c,Te.ClipOp.Intersect,!0);else{let u=Te.RRectXY(c,n,n);u[4]=u[5]=n,u[6]=u[7]=a,u[8]=u[9]=s,u[10]=u[11]=l,this.ctx?.clipRRect(u,Te.ClipOp.Intersect,!0)}}_applyShadowOffsetMatrix(){if(this.ctx){let r=Ee.invert(this.currentTransform);this.ctx.concat(r);let e=Ee.translate(Ee.identity(),this._dropShadowOffsetX,this._dropShadowOffsetY);this.ctx.concat(e),this.ctx.concat(this._currentTransform)}}_applyEffectsToPaint(r,e,t=!0){if(this.ctx&&this._currentPath){let o,n=!1;if(t&&this._hasDropShadow()){let a=r.copy();a.setColor(xd(this._dropShadowColor));let s;this._dropShadowBlur>0&&(s=Te.MaskFilter.MakeBlur(Te.BlurStyle.Normal,this._dropShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s)),this.ctx.save(),this.ctx.clipPath(this._currentPath,Te.ClipOp.Difference,!0),this._applyShadowOffsetMatrix(),e(a),this.ctx.restore(),a.delete(),s?.delete()}if(this._backgroundBlur>0&&t){this.ctx.save(),this.ctx.clipPath(this._currentPath,Te.ClipOp.Intersect,!0);let a=Te.ImageFilter.MakeBlur(this._backgroundBlur,this._backgroundBlur,Te.TileMode.Clamp,null),s=r.copy();s.setImageFilter(a),s.setAlphaf(1);let l=this._currentPath.computeTightBounds();this.ctx.saveLayer(s,l,null,Te.SaveLayerInitWithPrevious),this.ctx.drawColor(r.getColor()),this.ctx.restore(),this.ctx.restore(),s.delete(),a.delete(),n=!0}if(this._layerBlur>0){let a=r.copy();o=Te.MaskFilter.MakeBlur(Te.BlurStyle.Normal,this._layerBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(o),e(a),a.delete(),o.delete(),n=!0}if(n||e(r),t&&this._hasInnerShadow()){let a=new Te.Paint;a.setAntiAlias(!0),a.setStyle(Te.PaintStyle.Fill),a.setColor(xd(this._innerShadowColor));let s;this._innerShadowBlur>0&&(s=Te.MaskFilter.MakeBlur(Te.BlurStyle.Normal,this._innerShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s));let l=this._currentPath.computeTightBounds(),[c,u,p,d]=l,f=p-c,h=d-u;this.ctx.save(),this.ctx.clipPath(this._currentPath,Te.ClipOp.Intersect,!0),this.ctx.saveLayer(a,l,null,Te.SaveLayerInitWithPrevious),this.ctx?.translate(this._innerShadowOffsetX,this._innerShadowOffsetY),this.ctx.drawRect(Te.XYWHRect(-1e3-this._innerShadowOffsetX,-1e3-this._innerShadowOffsetY,2e3+f+Math.abs(this._innerShadowOffsetX*2),2e3+h+Math.abs(this._innerShadowOffsetY*2)),a),a.setBlendMode(Te.BlendMode.Clear),this.ctx.drawPath(this._currentPath,a),this.ctx.restore(),this.ctx.restore(),a.delete(),s?.delete()}}}_paintInner(r,e=!0){if(this.ctx&&this._currentPath&&r){let t=this.ctx,o=this._currentPath;this._applyEffectsToPaint(r,n=>{let a=!1;!e&&this._strokeMode!=="center"&&(t.save(),t.clipPath(o,this._strokeMode==="outside"?Te.ClipOp.Difference:Te.ClipOp.Intersect,!0),a=!0),t.drawPath(o,n),a&&t.restore()},e)}}_hasDropShadow(){return this._dropShadowColor?.a>0}_hasInnerShadow(){return this._innerShadowColor?.a>0}path(r){this._currentPath?.addPath(Te.Path.MakeFromSVGString(r))}ellipse(r,e,t,o,n,a,s,l){if(!G1([r,e,t,o])||!this._currentPath)return;if(t<0||o<0)throw Error("radii cannot be negative");let c=Te.XYWHRect(r-t,e-o,t*2,o*2);this._currentPath?.addOval(c)}rect(r,e,t,o,n=0,a=0,s=0,l=0){let c=Te.XYWHRect(r,e,t,o);if(!!G1(c))if(n===0&&a===0&&l===0&&s===0)this._currentPath?.addRect(c);else{let u=Te.RRectXY(c,n,n);u[4]=u[5]=n,u[6]=u[7]=a,u[8]=u[9]=s,u[10]=u[11]=l,this._currentPath?.addRRect(u)}}getHorizontalAlign(r){switch(r){case 2:return Te.TextAlign.Right;case 3:return Te.TextAlign.Center;case 4:return Te.TextAlign.Justify;case 1:default:return Te.TextAlign.Left}}drawTextInner(r,e,t,[o,n,a,s],l,c,u=!0){let p=0,{ctx:d}=this;if(!d)return p;let f=c.copy(),h=c.copy();return h.setAlphaf(0),this._applyEffectsToPaint(f,m=>{e.pushPaintStyle(t,m,h),e.addText(r);let y=e.build();y.layout(a);let b=n;l===2?b+=(s-y.getHeight())/2:l===3&&(b+=s-y.getHeight()),d.drawParagraph(y,o,b),p=y.getHeight(),e.reset(),y.delete()},u),f.delete(),h.delete(),p}drawText(r,e){let t=0,o=this._fonts.get(e.font),{ctx:n,_paintFill:a,_paintStroke:s}=this;if(o&&n){let l=new Te.TextStyle({fontFamilies:[e.font],fontSize:e.fontSize,heightMultiplier:e.lineHeight,letterSpacing:e.letterSpacing}),c=new Te.ParagraphStyle({textStyle:l,textAlign:this.getHorizontalAlign(e.horizontalAlign)}),u=Te.XYWHRect(e.x,e.y,e.width,e.height),p=Te.ParagraphBuilder.Make(c,o);a&&(t=this.drawTextInner(r,p,l,u,e.verticalAlign,a,!0)),s&&(t=this.drawTextInner(r,p,l,u,e.verticalAlign,s,!1)),p.delete()}return{height:t}}render(){this._surface?.flush()}moveTo(r,e){this._currentPath?.moveTo(r,e)}lineTo(r,e){this._currentPath?.lineTo(r,e)}bezierCurveTo(r,e,t,o,n,a){this._currentPath?.cubicTo(r,e,t,o,n,a)}quadraticCurveTo(r,e,t,o){this._currentPath?.quadTo(r,e,t,o)}setTransform(r,e=!1){if(!this.ctx)return;let t=this.ctx.getTotalMatrix(),o=Ee.invert(t);if(o&&this.ctx.concat(o),this.ctx?.scale(this.dpr,this.dpr),this.camera?.enabled&&(this.ctx?.concat(this.camera.worldMatrix),e)){let n=Ee.getScale(this.camera.worldMatrix);this.ctx?.scale(1/n[0],1/n[1])}this.ctx?.concat(r),this.currentTransform=r}transform(r){this.ctx?.concat(r)}setSize(r,e){!this._isSizeDirty&&r===this._width&&e===this._height||(this._isSizeDirty=!1,this._width=r,this._height=e,this.canvas.style.width=r+"px",this.canvas.style.height=e+"px",this.canvas.width=r*this.dpr,this.canvas.height=e*this.dpr,this._surface&&(this._surface=Te.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas()))}};function G1(i){for(let r=0;r<i.length;r++)if(i[r]!==void 0&&!Number.isFinite(i[r]))return!1;return!0}function xd({r:i,g:r,b:e,a:t}){return Te.Color4f(i,r,e,t)}var Dl=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.blurRadius=0;this.offset=[0,0];this.spread=0;this.update(e)}update(r){r.color!==void 0&&(this.color=r.color),r.enabled!==void 0&&(this.enabled=r.enabled),r.blurRadius!==void 0&&(this.blurRadius=r.blurRadius),r.offset!==void 0&&(this.offset=r.offset),r.spread!==void 0&&(this.spread=r.spread)}};var _l=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.radius=0;this.update(e)}update(r){r.enabled!==void 0&&(this.enabled=r.enabled),r.radius!==void 0&&(this.radius=r.radius)}};var bd=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.update(e)}update(r){r.enabled!==void 0&&(this.enabled=r.enabled),r.color!==void 0&&(this.color=r.color)}};var vd=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.thickness=0;this.mode="inside";this.update(e)}update(r){r.enabled!==void 0&&(this.enabled=r.enabled),r.color!==void 0&&(this.color=r.color),r.thickness!==void 0&&(this.thickness=r.thickness),r.mode!==void 0&&(this.mode=r.mode)}};var sr=class extends Yo{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.autoClose=!0;this.fill=new bd(e+"-fill",t.fill,o),this.stroke=new vd(e+"-stroke",t.stroke,o),this.dropShadow=new Dl(e+"-dropShadow",t.dropShadow,o),this.innerShadow=new Dl(e+"-innerShadow",t.innerShadow,o),this.backgroundBlur=new _l(e+"-backgroundBlur",t.backgroundBlur,o),this.layerBlur=new _l(e+"-layerBlur",t.layerBlur,o)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ie.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ie.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=Ie.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=Ie.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.type===0&&(Le(e.path,["fill"])?this.fill.update(e.props):Le(e.path,["stroke"])?this.stroke.update(e.props):Le(e.path,["dropShadow"])?this.dropShadow.update(e.props):Le(e.path,["innerShadow"])?this.innerShadow.update(e.props):Le(e.path,["layerBlur"])?this.layerBlur.update(e.props):Le(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,t){super.updateState(e,t),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let t=new sr(this.uuid,this.data,e);return t.parent=void 0,t}};var _i=class extends sr{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.width=0;this.height=0;this.updateState(t,o)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,t){return E1(e,t,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e)}clone(e){let t=new _i(this.uuid,this.data,e);return t.parent=void 0,t}};var vo=class extends sr{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.width=0;this.height=0;this.cornerRadius=[0,0,0,0];this.updateState(t,o)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let t=new vo(this.uuid,this.data,e);return t.parent=void 0,t}};var Ri=class extends sr{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this._textHeight=0;this._textHeightDirty=!0;this.width=0;this.height=0;this.updateState(t,o)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ie.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ie.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){this._fontHolder?.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let t=this.data.textTransform,o=this.data.text.textValue.toString(),n=t===2?o.toUpperCase():t===3?o.toLowerCase():o,{height:a}=e.drawText(n,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=a}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:t}){e.font!==void 0&&(this._fontHolder=t.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateFontState(e,t)}clone(e){let t=new Ri(this.uuid,this.data,e);return t.parent=void 0,t}};var gs=class extends sr{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.curves=[];this.extremasBBox={min:[0,0],max:[0,0]};this.updateState(t,o)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(n=>Sd.extremas(n)),t=[1/0,1/0],o=[-1/0,-1/0];for(let n=0,a=e.length;n<a;n++){let s=e[n];s[0][0]<t[0]&&(t[0]=s[0][0]),s[0][1]<t[1]&&(t[1]=s[0][1]),s[1][0]>o[0]&&(o[0]=s[1][0]),s[1][1]>o[1]&&(o[1]=s[1][1])}return this.extremasBBox.min=[t[0],t[1]],this.extremasBBox.max=[o[0],o[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let o=1,n=this.data.points.length;o<n;o++){let a=this.data.points[o].data,s=this.data.points[o-1].data,l={start:s.position,cp1:s.controlNext.position,cp2:a.controlPrevious.position,end:a.position};this.curves.push(l)}let e=this.data.points[0].data,t=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let o={start:t.position,cp1:t.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(o)}}getCenter(){let[e,t]=this.extremasBBox.min,[o,n]=this.getHalfSize();return[e+o,t+n]}getHalfSize(){let{min:e,max:t}=this.extremasBBox;return[(t[0]-e[0])*.5,(t[1]-e[1])*.5]}innerDraw(e){for(let n=0,a=this.data.points.length;n<a;n++){let s=this.data.points[n].data;if(n===0){let[l,c]=s.position;e.moveTo(l,c)}else{let l=this.data.points[n-1].data,[c,u]=l.controlNext.position,[p,d]=s.controlPrevious.position,[f,h]=s.position,m={start:l.position,cp1:l.controlNext.position,cp2:s.controlPrevious.position,end:s.position};Sd.derive(m),e.bezierCurveTo(c,u,p,d,f,h)}}let t=this.data.points[0].data,o=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[n,a]=o.controlNext.position,[s,l]=t.controlPrevious.position,[c,u]=t.position;e.bezierCurveTo(n,a,s,l,c,u)}}updateState(e,t){super.updateState(e,t),this.computeExtremas()}clone(e){let t=new gs(this.uuid,this.data,e);return t.parent=void 0,t}},Sd;(n=>{function i(a){let s=a.start,l=a.cp1,c=a.cp2,u=a.end,p=[3*(l[0]-s[0]),3*(l[1]-s[1])],d=[3*(c[0]-l[0]),3*(c[1]-l[1])],f=[3*(u[0]-c[0]),3*(u[1]-c[1])],h={start:p,cp:d,end:f};return a.derivative=h,h.derivative=Fh.derive(h),h}n.derive=i;function r(a,s,l,c=!1){let u=a-2*s+l;if(u!==0){let p=-Math.sqrt(Math.abs(s*s-a*l)),d=-a+s,f=-(p+d)/u,h=-(-p+d)/u;return[f,h]}else if(s!==l&&u===0)return[(2*s-l)/(2*(s-l))];return[]}function e(a){let s=a.derivative??n.derive(a),l=s.start,c=s.cp,u=s.end;return[r(l[0],c[0],u[0]),r(l[1],c[1],u[1])]}n.droot=e;function t(a){let[s,l]=n.droot(a),c=[a.start[0],a.end[0]],u=[a.start[1],a.end[1]];for(let p of s)c.push(n.compute(a,Math.min(1,Math.max(0,p)))[0]);for(let p of l)u.push(n.compute(a,Math.min(1,Math.max(0,p)))[1]);return c.sort((p,d)=>p-d),u.sort((p,d)=>p-d),[[c[0],u[0]],[c[c.length-1],u[u.length-1]]]}n.extremas=t;function o(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let l=1-s,c=l*l,u=s*s,p=c*l,d=c*s*3,f=l*u*3,h=s*u;return[p*a.start[0]+d*a.cp1[0]+f*a.cp2[0]+h*a.end[0],p*a.start[1]+d*a.cp1[1]+f*a.cp2[1]+h*a.end[1]]}n.compute=o})(Sd||(Sd={}));var Fh;(t=>{function i(o){let n=o.start,a=o.cp,s=o.end,l=[2*(a[0]-n[0]),2*(a[1]-n[1])],c=[2*(s[0]-a[0]),2*(s[1]-a[1])],u={start:l,end:c};return u.derivative=jh.derive(u),o.derivative=u,u}t.derive=i;function r(o){let n=o.derivative??t.derive(o),a=n.start,s=n.end;return[a[0]!==s[0]?a[0]/(a[0]-s[0]):0,a[1]!==s[1]?a[1]/(a[1]-s[1]):0]}t.droot=r;function e(o,n){if(n===0)return[...o.start];if(n===1)return[...o.end];let a=1-n,s=a*a,l=n*n,c=s,u=a*n*2,p=l;return[c*o.start[0]+u*o.cp[0]+p*o.end[0],c*o.start[1]+u*o.cp[1]+p*o.end[1]]}t.compute=e})(Fh||(Fh={}));var jh;(e=>{function i(t){let o=t.start,n=t.end,a=[n[0]-o[0],n[1]-o[1]];return t.derivative=a,t.derivative}e.derive=i;function r(t,o){if(o===0)return[...t.start];if(o===1)return[...t.end];let n=t.start,a=t.end;return[n[0]+(a[0]-n[0])*o,n[1]+(a[1]-n[1])*o]}e.compute=r})(jh||(jh={}));var hr=class extends Ut{constructor(e,t,o){super(e,t,o);this.uuid=e;this.width=0;this.height=0;this.clipped=!0;this.background=new vo(e+"-background",ya.defaultData,o),this.background.parent=this,this.updateState(t,o)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){super.updateLocalMatrix(),this.background?.updateLocalMatrix()}updateWorldMatrix(e,t,o){super.updateWorldMatrix(e,t,o),this.background?.updateWorldMatrix(e,t,o)}draw(e){if(!this.visible)return;e.save();let t=this.width,o=this.height;this.applyTransforms(e),this.background.width=t,this.background.height=o,this.background.draw(e),this.clipped&&e.clipRect(0,0,t,o,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.type===0&&(Le(e.path,["fill"])?this.fill.update(e.props):Le(e.path,["stroke"])?this.stroke.update(e.props):Le(e.path,["dropShadow"])?this.dropShadow.update(e.props):Le(e.path,["innerShadow"])?this.innerShadow.update(e.props):Le(e.path,["layerBlur"])?this.layerBlur.update(e.props):Le(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let t=new hr(this.uuid,this.data,e);t.parent=void 0;for(let o of this.children)t.add(o.clone(e));return t}};var H1=Ms(Uh(),1),Ko=class extends sr{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this._pathBBox=new DOMRect;this.path="";this.updateState(t,o),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg"),t=document.createElementNS("http://www.w3.org/2000/svg","path");document.body.appendChild(e),t.setAttribute("d",this.path),e.appendChild(t),this._pathBBox=t.getBBox(),e.remove()}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,t){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&t>=this._pathBBox.y&&t<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,t){super.updateState(e,t),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let t=new Ko(this.uuid,this.data,e);return t.parent=void 0,t}};function W1(i,r=1,e=1){if(r<=0||e<=0)return i;let o=(0,H1.parseSVG)(i).map(n=>{let a={...n};return"x"in a&&(a.x=a.x*r),"y"in a&&(a.y=a.y*e),"x1"in a&&(a.x1=a.x1*r),"x2"in a&&(a.x2=a.x2*r),"y1"in a&&(a.y1=a.y1*e),"y2"in a&&(a.y2=a.y2*e),"rx"in a&&(a.rx=a.rx*r),"ry"in a&&(a.ry=a.ry*e),a});return q1(o)}function q1(i){let r=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],e;return i.map(t=>{let o=[];r.forEach(a=>{if(a in t){let s=t[a]*1;o.length&&s>=0&&o.push(","),o.push(s)}});let n=(e===t.code?o[0]<0?"":",":t.code)+o.join("");return e=t.code,n}).join("")}function $1(i,r,e){switch(r.type){case"ellipse2d":return new _i(i,r,e);case"rectangle2d":return new vo(i,r,e);case"text2d":return new Ri(i,r,e);case"vector2d":return new gs(i,r,e);case"path2d":return new Ko(i,r,e);case"frame2d":return new hr(i,r,e);case"group2d":default:return new ar(i,r,e)}}var kh=class{constructor(r,e,t){this.uuid=r;this.data=e;this.group=new ar(kh.GROUP_ID,{...ks.defaultData},t),this.createChildrenObjects(e.objects,this.group,t)}createObject(r,e,t,o,n,a){let s=$1(r,e,a);s&&(o.add(s),o.children.splice(n,0,o.children.pop()),s.updateWorldMatrix(),t.length>0&&(s instanceof ar||s instanceof hr)&&this.createChildrenObjects(t,s,a))}createChildrenObjects(r,e,t){let o=0;for(let n of r)this.createObject(n.id,n.data,n.children,e,o,t),o+=1}draw(r){this.group.draw(r)}updateEntityByOp(r,e,t,o){let n=this.find(r);if(n)try{n.updateByOp(e,t,{shared:o})}catch(a){console.error(a)}}updateTreeByOp(r,e){if(r.path.length===0&&r.type===7){let t=r.parent===null?this.group:this.find(r.parent);t!==void 0&&t instanceof Ut&&(this.createObject(r.id,r.data,r.children,t,r.localIndex,e),t.requestRender())}else if(r.path.length===0&&r.type===8){let t=this.find(r.id);if(t!==void 0&&t.parent!==void 0&&t.parent instanceof Ut){let o=t.parent;t.resetBBoxNeedsUpdate(),o?.remove(t),o?.requestRender()}}else if(r.path.length===0&&r.type===9){let t=this.find(r.id);if(t!==void 0){let o=t.parent,n=r.parent===null?this:this.find(r.parent);if(n===void 0&&!1&&console.error("unexpected",n,r),n instanceof Ut||n===this){n.add(t);let a=r.localIndex;n.children.splice(a,0,n.children.pop()),t.updateWorldMatrix(!0,!1,!0),o?.requestRender(),t.requestRender()}t.resetBBoxNeedsUpdate()}}}add(r){this.group.add(r)}remove(r){this.group.remove(r)}traverse(r){this.group.traverse(e=>{e!==this.group&&r(e)})}intersectsChildren(r,e,t,o=!1,n=[]){return this.group.intersectsChildren(r,e,t,o,n,!0)}intersectsChildrenReverse(r,e,t,o=!1,n=[]){return this.group.intersectsChildrenReverse(r,e,t,o,n,!0)}find(r){return this.group.find(r)}get children(){return this.group.children}project(r,e){return this.group.project(r,e)}getWithSortKey(r){let e=this.find(r);if(e===void 0)return;let t=[],o=e;for(;o!==this.group;){let n=o;o=o.parent;let a=o.children.indexOf(n);t.splice(0,0,a)}return{entity:e,sortKey:t}}getAllSorted(r){let e=[];for(let t of r){let o=this.getWithSortKey(t.id);o!==void 0&&e.push(o)}return e.sort((t,o)=>ql(t.sortKey,o.sortKey)),e.map(t=>t.entity)}},wn=kh;wn.GROUP_ID="scene2d";function Hh({constraints:i,newParentWidth:r,newParentHeight:e,initialParentWidth:t,initialParentHeight:o,objectInitialWidth:n,objectInitialHeight:a,objectInitialPosition:s}){let{horizontalConstraint:l,verticalConstraint:c}=i,u=r-t,p=e-o,d=n,f=a,h=s[0],m=s[1];if(l!==0){if(l===1)h+=u;else if(l===3)h+=u/2;else if(l===2)d=Math.max(1,d+u);else if(l===4){let y=r/t;d*=y,h*=y}}if(c!==0){if(c===1)m+=p;else if(c===3)m+=p/2;else if(c===2)f=Math.max(1,f+p);else if(c===4){let y=e/o;f*=y,m*=y}}return{width:d,height:f,position:[h,m]}}var oR=Ms(Uh(),1);var ode={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{mm:1,px:1,cm:1,in:1,pt:1,pc:1}};import{BufferGeometry as iR,CanvasTexture as nR,Float32BufferAttribute as X1,HalfFloatType as aR,MathUtils as sR,Mesh as lR,OrthographicCamera as cR,ShaderMaterial as uR,Uniform as dR,WebGLRenderTarget as pR}from"three";var fR=`
2664
2664
  varying vec2 vUv;
2665
2665
  void main() {
2666
2666
  vUv = uv;
2667
2667
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
2668
- }`,x_=`
2668
+ }`,hR=`
2669
2669
  uniform sampler2D tDiffuse;
2670
2670
  varying vec2 vUv;
2671
2671
  void main() {
2672
2672
  vec4 texel = texture2D( tDiffuse, vUv );
2673
2673
  gl_FragColor = texel;
2674
- }`,b_=new f_(-1,1,1,-1,0,1),Gh=class extends l_{constructor(){super(),this.setAttribute("position",new I1([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new I1([0,2,0,0,2,0],2))}},v_=new Gh,Fh=class{constructor(r){this._mesh=new p_(v_,r)}dispose(){this._mesh.geometry.dispose()}render(r){r.render(this._mesh,b_)}get material(){return this._mesh.material}set material(r){this._mesh.material=r}},E1=new h_({defines:{},uniforms:{tDiffuse:new m_(null)},vertexShader:g_,fragmentShader:x_}),S_=new Fh(E1),Vh=null,zh=null,w_=()=>(Vh===null&&(Vh=document.createElement("canvas")),Vh),P_=i=>(zh===null&&(zh=new Nl(i)),zh),O_=Ee.identity(),xs=class{constructor(r,e,t,o){this.uuid=r;this.width=e;this.height=t;this.context=o;this.enabled=!0;this.isScreenSpace=!1;this.dpr=window.devicePixelRatio;this.isFrameDirty=!1;this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.context.shared.requestRender()};this._innerApplySize=()=>{let r=this.width,e=this.height,t=this.dpr;this.renderer.dpr=this.isScreenSpace?t:Math.floor(2048/Math.max(r,e)),this.renderer.setSize(r,e)};this.onFrameOverrideObjectEvent=r=>{if(r.target?.uuid!==void 0){let e=this.frameRoot?.find(r.target.uuid);e&&e.dispatchEvent({...r,target:e})}};this.scene2d=new wn(d_.generateUUID(),au.defaultData,{dpr:window.devicePixelRatio,shared:o.shared}),this.canvas=w_(),this.renderer=P_(this.canvas),this.promise=this.init(),this.renderTarget=new y_(1,1,{type:u_,stencilBuffer:!1,depthBuffer:!1}),o.shared.addUIBuffer(this.uuid,this.renderTarget),this.textureHolder=o.shared.uiBuffer(this.uuid)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new c_(this.canvas)),this._canvasTexture}async init(){this.renderer instanceof Nl&&(this.renderer.wasmURL=Zb.skiaWasmUrl),await this.renderer.init()}render(r){if(this.isFrameDirty){this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),E1.uniforms.tDiffuse.value=this.canvasTexture,this.canvasTexture.needsUpdate=!0;let e=r.getRenderTarget();r.setRenderTarget(this.renderTarget),r.clear(),S_.render(r),r.setRenderTarget(e),this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(r,e,t,o){this.scene2d.updateEntityByOp(r,e,t,o),this.applySize()}updateTreeByOp(r,e){this.scene2d.updateTreeByOp(r,e),this.applySize()}applyOverrides(r){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=r?.width??this.width,t=r?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=t,this.frameOverride.localMatrix=O_,this.isScreenSpace&&(this.frameOverride.fill.color=Ie.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:t},N1({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(r,e=window.devicePixelRatio){let t=Math.max(1,r?.width??this.width),o=Math.max(1,r?.height??this.height);this.dpr=e,this.width=t,this.height=o,this._innerApplySize();let n=1,a=512,s=512;(t*e<a||o*e<s)&&(n=Math.max(a/(t*e),s/(o*e))),this.renderTarget.setSize(t*e*n,o*e*n),this._canvasTexture?.dispose(),this._canvasTexture=void 0,this.applyOverrides(r),this.frameOverride?.requestRender()}applyFrame(r){let e=this.context.scene.find2D(r);if(!(!e||!(e instanceof hr)))return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(t=>{t.addEventListener("beginState",this.onFrameOverrideObjectEvent)}),this.frameOverride.traverse(t=>{t.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(r){return this.scene2d.find(r)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(r=>{r.removeEventListener("beginStateChange",this.onFrameOverrideObjectEvent)}),this.frameOverride?.traverse(r=>{r.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function N1({objectOverride:i,objectRoot:r,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:n}){if(i instanceof hr&&r instanceof hr||i instanceof ar&&r instanceof ar)for(let a=0,s=i.children.length;a<s;a++){let l=i.children[a],c=r.children[a];l&&c&&l.uuid===c.uuid&&C_({objectOverride:l,objectRoot:c,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:n})}}function T_(i){if(jh(i))return[i.width,i.height];if(i instanceof Ko){let[r,e]=i.getHalfSize();return[r*2,e*2]}else if(i instanceof ar){let[r,e]=i.recursiveBBox.getHalfSize();return[r*2,e*2]}return[0,0]}function C_({objectOverride:i,objectRoot:r,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:n}){let[a,s]=T_(r),{width:l,height:c,position:u}=Bh({constraints:i.data,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:n,objectInitialWidth:a,objectInitialHeight:s,objectInitialPosition:r.position});if(i.position=u,i.data={...i.data,position:u},i.states)for(let p in i.states)A_({stateId:p,objectOverride:i,objectRoot:r,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:n});if(jh(i)||i instanceof ar)jh(i)&&(i.width=l,i.height=c,i.data={...i.data,width:l,height:c}),N1({objectOverride:i,objectRoot:r,newParentWidth:l,newParentHeight:c,initialParentWidth:a,initialParentHeight:s});else if(i instanceof Ko){let p=r,d=a!==0?l/a:1,f=s!==0?c/s:1;i.path=C1(p.path,d,f),i.data={...i.data,path:i.path}}}function A_({stateId:i,objectOverride:r,objectRoot:e,newParentWidth:t,newParentHeight:o,initialParentWidth:n,initialParentHeight:a}){let s=r.states?.[i],l=e.states?.[i];if(s&&l){let{width:c,height:u,position:p}=Bh({constraints:r.data,newParentWidth:t,newParentHeight:o,initialParentWidth:n,initialParentHeight:a,objectInitialWidth:Bo.isResizeable(l)?l.width:0,objectInitialHeight:Bo.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(r.states[i],{position:p}),Bo.isResizeable(s)&&Object.assign(r.states[i],{width:c,height:u})}}function jh(i){return i instanceof vo||i instanceof hr||i instanceof _i||i instanceof Ri}var Mr=class extends va(N_){constructor(e,t,o){super();this.data=t;this.bgColor=new At(1,1,1,1);this.fog=null;this.backupFog=new I_(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new M_;this.penumbraSizeArrayCache=null;this.super_Entity(e,t),this.personalCamera=new Xo(pi,{...Ji.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new E_(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),t.uiScene?this.uiScene=new wn((Array.isArray(e)?e[0]:e)+"-ui",t.uiScene,{dpr:window.devicePixelRatio,shared:o.shared}):t.uiFrame&&this.createUICanvas(t.uiFrame,o)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(e,t){this.uiCanvas=new xs(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,t),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=jt(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(t=>{t instanceof nr&&t.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof ir)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&t1(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,t){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let o=this.scene;o.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=jt(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=jt(e.aoColor,t))}updateByOp(e,t,o,n){let a=this.data.uiFrame;super.updateByOp(e,t,o,n);let s=t;Le(e.path,["fog"])?this.updateFog(s.fog,o.shared):Le(e.path,["ao"])?this.updateAo(s.ao,o.shared):Le(e.path,["ambient"])?this.updateAmbientLight(s.ambient,o.shared):Le(e.path,["shadow"])?this.updateShadow(s.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||a!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,o)}updateUIFrame(e,t){e?(this.uiCanvas||this.createUICanvas(e,t),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(jt(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,t){}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,t=0;this.traverseEntity(o=>{if(!o.visible)return!0;o instanceof ms&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize??.5,e+=1),o instanceof ys&&o.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+t]=o.data.penumbraSize??.5,t+=1)})}raycastWithClones(e){let t=[],o=n=>{for(let a of n.children){let s=a.cloner;De.is(a)&&(a.visible||s?.object.data.visible)&&((Ei(a)||Al(a)&&this.scene.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),Rl(a,e,t,!0)),o(a))}};return o(this),t}updateEntity2DByOp(e,t,o,n){this.uiCanvas?.updateEntity2DByOp(e,t,o,n)}};import{PointLight as D_,Vector3 as bd,Box3 as __,Box3Helper as D1,Color as R_}from"three";var vd=class extends ds(D_,hs){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=90,n.aspect=1,n.near=100,n.far=2500;let a=new bd(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),s=new bd(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z),l=new __(a,s),c=new D1(l,new R_(16755200));c.visible=!1,this.gizmos.shadowmap=c,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let r in this.gizmos){let e=this.gizmos[r];if(e instanceof D1){let t=this.shadow.camera,o=new bd(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),n=new bd(t.far+this.position.x,t.far+this.position.y,t.far+this.position.z);e.box.set(o,n),e.updateMatrixWorld(!0)}}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Sd=class extends et{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?ul(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var bs=class extends et{constructor(e,t,o){super(e,t,o);this._shapeId=null;this._context=o}updateState(e,t){super.updateState(e,t),this.updateShape(),this.refreshAttachedCloners(t)}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let n in e)typeof e[n]=="string"&&(e[n]=this._context.shared.getVariable(e[n],[this.uuid,"geometry","extrusion","shape",n]));let t;if(e.type==="Custom"){let n=e.shapeId;if(n!==this._shapeId&&this.detachShape(),n){this._shapeId=n;let a=this._context.scene.find(n);a?.data&&(a.attachedPaths.add(this),t=a.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let n;switch(e.type){case"Rectangle":n=Da;break;case"Ellipse":n=Ma;break;case"Polygon":n=Mu;break;case"Star":n=Iu;break;default:throw new Error(`Unknown shape type: ${e.type}`)}t=n.create({parameters:e}).userData.shape}let o=this.geometry;t&&o.inputs&&(o.inputs.shapeData=t,o.build())}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,t){return super.updateTransformState(e,t)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let o=this.geometry.getAttribute("position");o!==void 0?ul(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,t):super.updateEntityBoxSize(e,t)}};var wd=class extends Ai{constructor(e,t,o){super(e,t,o);this.data=t}};import{Group as L_,Matrix4 as B_,Skeleton as V_}from"three";var Qo=class extends Cr(L_,Ar){constructor(e,t,o){super();t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,o)),this.super_Entity(e,t),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,t){let o=pa.getComponentData({scene:t.scene.data,shared:t.shared.data},e.component);if(o){let n,a;for(let s of io.rootOverrideProps)e[s]===void 0?(n===void 0&&(n={...e}),n[s]=o.data[s]):(a===void 0&&(a={}),a[s]=e[s],n===void 0&&(n={...e}),n[s]=Qr.apply(o.data[s],e[s]));return this.overrideData=a,n}else return{...yt.defaultData,...e,...Nr(yt.defaultData,io.rootOverrideProps)}}updateByOp(e,t,o,n){let a;if(this.isInstanceRoot&&!n){if(t=this.transformAssignData(t,o),e.type===0&&e.path.length===0&&this.component)for(let s of io.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&io.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:t[s]}})}}super.updateByOp(a??e,t,o,n)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){let o=e.scene.find(t.component)??null,n=!1;if(o!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(De.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Pd(s),a+=1;else break;this.children.splice(0,a)}n=!0}if(o){let a={};R1(e,[this.uuid],t.overrides,this,o,o,0,n,a);for(let s of this.children)if(De.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(c=>{let u=c.dataPatched;if(c instanceof et&&u.bones&&u.boneInverses){let p=c.dataPatched;if(p.bones&&p.boneInverses){let d=p.bones.map(m=>e.scene.find(a[m])),f=p.boneInverses.map(m=>new B_().fromArray(m)),h=new V_(d,f);c.bind(h,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function Pd(i){if(i.component){let r=i.component.instances.indexOf(i);r>=0&&i.component.instances.splice(r,1);for(let e of i.children)De.is(e)&&Pd(e)}}function _1(i,r,e,t){return i.component===r&&rp(i.identity,t)?i.overrideData===e?2:1:0}function R1(i,r,e,t,o,n,a,s,l){if(a>50)return!1;if(t.component!==o){if(t.component){let u=t.component.instances.indexOf(t);u>=0&&t.component.instances.splice(u,1)}o.instances.find(u=>u===t)||o.instances.push(t),t.component=o}o instanceof Qo&&o.isInstanceRoot&&o.expandInstanceChildren(i);let c=0;for(let u of o.children)if(De.is(u)){let p=[...r,...typeof u.identity=="string"?[u.identity]:u.identity],d=ua.resolve(e,p,1);if(d!=null&&!(d instanceof Qe)){if(!1)debugger;Object.setPrototypeOf(d,Qe.prototype),console.error("wrong prototype")}let f=null,h;if(!s){let m=t.children[c];if(f=De.is(m)?m:null,f!==null){let y=_1(f,u,d,p);h=y>=1?f.stateSelection:void 0,y!==2&&(f=null)}if(f===null&&(f=i.scene.findInstance(p)??null,f!==null)){let y=_1(f,u,d,p);if(h=y>=1?f.stateSelection:void 0,y!==2)f=null;else{let b=f.parent.children.indexOf(f);f.parent.children.splice(b,1),t.children.splice(c,0,f),f.parent===t?(b<=c&&console.error("not possible"),void 0):(f.parent=t,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),i.pendingDeletes.delete(f),void 0)}}}if(f===null){let m=d?Qr.apply(u.data,d):u.data;Dr.is(m.type)&&(m={...m,type:"Empty"}),f=Br.createEntity(p,m,i),f.overrideData=d,t.add(f),t.children.splice(t.children.length-1,1),t.children.splice(c,0,f),f.updateState(f.data,i),h&&f.changeSelectedState(h,i),i.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let m=f.identity[f.identity.length-1];l[m]=f.uuid}c+=1,R1(i,r,e,f,u,n,a+1,s,l)}if(!s){let u=c;for(;;){let p=t.children[c];if(De.is(p))i.pendingDeletes.add(p);else break;c+=1}t.children.splice(u,c-u)}return!0}import{Bone as z_}from"three";var Od=class extends Cr(z_,Ar){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(r,e){this.updateState_Entity(r,e)}};var Pn=class extends et{constructor(e,t,o){super(e,t,o);this.onBeforeRender=e=>{this.uiCanvas.render(e)};this.uiCanvas=new xs(e+"-canvas",t.geometry.width,t.geometry.height,o),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,o.shared)})}updateByPatchedOpGeometry(e,t,o){super.updateByPatchedOpGeometry(e,t,o),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,o.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,o.shared))}applySize(e,t){let o=e?.width??this.dataPatched.geometry.width,n=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:o,height:n}),this.applyGeometryParametersFromFrame(t)}applyFrame(e,t){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(t),this.applyMaterialParametersFromFrame({shared:t})}applyGeometryParametersFromFrame(e){let t=this.frame;t&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=jo(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let t=this.frame;if(t){let o=t.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),this.material.reset(this.dataPatched.material,e,!0)}}updateEntity2DByOp(e,t,o,n){this.uiCanvas.updateEntity2DByOp(e,t,o,n),e===this.frameId&&t.type===0&&(t.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(n):Le(t.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:n}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.applySize({width:e.width,height:e.height},t)}};import{Object3D as Y_,Vector3 as Ir,InstancedMesh as K_,InstancedBufferAttribute as Q_,PlaneGeometry as Z_,Vector4 as Ll,Quaternion as tS,TextureLoader as J_,Texture as rS,Euler as eR,MathUtils as Xh}from"three";import{GPUComputationRenderer as tR}from"three/examples/jsm/misc/GPUComputationRenderer.js";import{Vector3 as L1,FloatType as Uh,DataTexture as kh,RGBAFormat as Hh,Mesh as G_,Euler as Ode,Matrix4 as Tde}from"three";import{MeshSurfaceSampler as F_}from"three/examples/jsm/math/MeshSurfaceSampler.js";function B1(i){let r=new Float32Array(i*i*2);for(let e=0;e<i;e++)for(let t=0;t<i;t++){let o=e*i+t;r[o*2+0]=e/(i-1),r[o*2+1]=t/(i-1)}return r}function V1(i){let r=Math.ceil(Math.sqrt(i));return Math.max(r,1)}function z1(i,r){let e=new G_(i.geometry,i.material),t=[],o=[],n=new L1,a=new L1;e.geometry.index!==null&&(e.geometry=e.geometry.toNonIndexed());let s=new F_(e).build();for(let u=0;u<r;u++)s.sample(n,a),t.push(n.x,n.y,n.z),o.push(a.x,a.y,a.z);let l=new Float32Array(t),c=new Float32Array(o);return{positions:l,normals:c}}function Wh(i,r){let e=i,t=new Float32Array(4*r*r);for(let n=0;n<r*r;n++)t[4*n]=e[3*n],t[4*n+1]=e[3*n+1],t[4*n+2]=e[3*n+2],t[4*n+3]=0;let o=new kh(t,r,r,Hh,Uh);return o.needsUpdate=!0,o}function G1({size:i}){let r=new Float32Array(4*i*i);for(let t=0;t<i*i;t++)r[4*t]=t,r[4*t+1]=0,r[4*t+2]=0,r[4*t+3]=0;let e=new kh(r,i,i,Hh,Uh);return e.needsUpdate=!0,e}function F1(i){let r=new Float32Array(4*i*i);for(let t=0;t<i*i;t++)r[4*t]=0,r[4*t+1]=0,r[4*t+2]=0,r[4*t+3]=0;let e=new kh(r,i,i,Hh,Uh);return e.needsUpdate=!0,e}var j1=`
2674
+ }`,mR=new cR(-1,1,1,-1,0,1),$h=class extends iR{constructor(){super(),this.setAttribute("position",new X1([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new X1([0,2,0,0,2,0],2))}},yR=new $h,Xh=class{constructor(r){this._mesh=new lR(yR,r)}dispose(){this._mesh.geometry.dispose()}render(r){r.render(this._mesh,mR)}get material(){return this._mesh.material}set material(r){this._mesh.material=r}},Y1=new uR({defines:{},uniforms:{tDiffuse:new dR(null)},vertexShader:fR,fragmentShader:hR}),gR=new Xh(Y1),Wh=null,qh=null,xR=()=>(Wh===null&&(Wh=document.createElement("canvas")),Wh),bR=i=>(qh===null&&(qh=new Nl(i)),qh),vR=Ee.identity(),xs=class{constructor(r,e,t,o){this.uuid=r;this.width=e;this.height=t;this.context=o;this.enabled=!0;this.isScreenSpace=!1;this.dpr=window.devicePixelRatio;this.isFrameDirty=!1;this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.context.shared.requestRender()};this._innerApplySize=()=>{let r=this.width,e=this.height,t=this.dpr;this.renderer.dpr=this.isScreenSpace?t:Math.floor(2048/Math.max(r,e)),this.renderer.setSize(r,e)};this.onFrameOverrideObjectEvent=r=>{if(r.target?.uuid!==void 0){let e=this.frameRoot?.find(r.target.uuid);e&&e.dispatchEvent({...r,target:e})}};this.scene2d=new wn(sR.generateUUID(),uu.defaultData,{dpr:window.devicePixelRatio,shared:o.shared}),this.canvas=xR(),this.renderer=bR(this.canvas),this.promise=this.init(),this.renderTarget=new pR(1,1,{type:aR,stencilBuffer:!1,depthBuffer:!1}),o.shared.addUIBuffer(this.uuid,this.renderTarget),this.textureHolder=o.shared.uiBuffer(this.uuid)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new nR(this.canvas)),this._canvasTexture}async init(){this.renderer instanceof Nl&&(this.renderer.wasmURL=gv.skiaWasmUrl),await this.renderer.init()}render(r){if(this.isFrameDirty){this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),Y1.uniforms.tDiffuse.value=this.canvasTexture,this.canvasTexture.needsUpdate=!0;let e=r.getRenderTarget();r.setRenderTarget(this.renderTarget),r.clear(),gR.render(r),r.setRenderTarget(e),this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(r,e,t,o){this.scene2d.updateEntityByOp(r,e,t,o),this.applySize()}updateTreeByOp(r,e){this.scene2d.updateTreeByOp(r,e),this.applySize()}applyOverrides(r){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=r?.width??this.width,t=r?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=t,this.frameOverride.localMatrix=vR,this.isScreenSpace&&(this.frameOverride.fill.color=Ie.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:t},K1({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(r,e=window.devicePixelRatio){let t=Math.max(1,r?.width??this.width),o=Math.max(1,r?.height??this.height);this.dpr=e,this.width=t,this.height=o,this._innerApplySize();let n=1,a=512,s=512;(t*e<a||o*e<s)&&(n=Math.max(a/(t*e),s/(o*e))),this.renderTarget.setSize(t*e*n,o*e*n),this._canvasTexture?.dispose(),this._canvasTexture=void 0,this.applyOverrides(r),this.frameOverride?.requestRender()}applyFrame(r){let e=this.context.scene.find2D(r);if(!(!e||!(e instanceof hr)))return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(t=>{t.addEventListener("beginState",this.onFrameOverrideObjectEvent)}),this.frameOverride.traverse(t=>{t.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(r){return this.scene2d.find(r)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(r=>{r.removeEventListener("beginStateChange",this.onFrameOverrideObjectEvent)}),this.frameOverride?.traverse(r=>{r.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function K1({objectOverride:i,objectRoot:r,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:n}){if(i instanceof hr&&r instanceof hr||i instanceof ar&&r instanceof ar)for(let a=0,s=i.children.length;a<s;a++){let l=i.children[a],c=r.children[a];l&&c&&l.uuid===c.uuid&&wR({objectOverride:l,objectRoot:c,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:n})}}function SR(i){if(Yh(i))return[i.width,i.height];if(i instanceof Ko){let[r,e]=i.getHalfSize();return[r*2,e*2]}else if(i instanceof ar){let[r,e]=i.recursiveBBox.getHalfSize();return[r*2,e*2]}return[0,0]}function wR({objectOverride:i,objectRoot:r,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:n}){let[a,s]=SR(r),{width:l,height:c,position:u}=Hh({constraints:i.data,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:n,objectInitialWidth:a,objectInitialHeight:s,objectInitialPosition:r.position});if(i.position=u,i.data={...i.data,position:u},i.states)for(let p in i.states)PR({stateId:p,objectOverride:i,objectRoot:r,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:n});if(Yh(i)||i instanceof ar)Yh(i)&&(i.width=l,i.height=c,i.data={...i.data,width:l,height:c}),K1({objectOverride:i,objectRoot:r,newParentWidth:l,newParentHeight:c,initialParentWidth:a,initialParentHeight:s});else if(i instanceof Ko){let p=r,d=a!==0?l/a:1,f=s!==0?c/s:1;i.path=W1(p.path,d,f),i.data={...i.data,path:i.path}}}function PR({stateId:i,objectOverride:r,objectRoot:e,newParentWidth:t,newParentHeight:o,initialParentWidth:n,initialParentHeight:a}){let s=r.states?.[i],l=e.states?.[i];if(s&&l){let{width:c,height:u,position:p}=Hh({constraints:r.data,newParentWidth:t,newParentHeight:o,initialParentWidth:n,initialParentHeight:a,objectInitialWidth:Bo.isResizeable(l)?l.width:0,objectInitialHeight:Bo.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(r.states[i],{position:p}),Bo.isResizeable(s)&&Object.assign(r.states[i],{width:c,height:u})}}function Yh(i){return i instanceof vo||i instanceof hr||i instanceof _i||i instanceof Ri}var Mr=class extends va(AR){constructor(e,t,o){super();this.data=t;this.bgColor=new At(1,1,1,1);this.fog=null;this.backupFog=new TR(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new OR;this.penumbraSizeArrayCache=null;this.super_Entity(e,t),this.personalCamera=new Xo(pi,{...Ji.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new CR(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),t.uiScene?this.uiScene=new wn((Array.isArray(e)?e[0]:e)+"-ui",t.uiScene,{dpr:window.devicePixelRatio,shared:o.shared}):t.uiFrame&&this.createUICanvas(t.uiFrame,o)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(e,t){this.uiCanvas=new xs(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,t),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=jt(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(t=>{t instanceof nr&&t.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof ir)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&v1(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,t){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let o=this.scene;o.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=jt(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=jt(e.aoColor,t))}updateByOp(e,t,o,n){let a=this.data.uiFrame;super.updateByOp(e,t,o,n);let s=t;Le(e.path,["fog"])?this.updateFog(s.fog,o.shared):Le(e.path,["ao"])?this.updateAo(s.ao,o.shared):Le(e.path,["ambient"])?this.updateAmbientLight(s.ambient,o.shared):Le(e.path,["shadow"])?this.updateShadow(s.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||a!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,o)}updateUIFrame(e,t){e?(this.uiCanvas||this.createUICanvas(e,t),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(jt(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,t){}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,t=0;this.traverseEntity(o=>{if(!o.visible)return!0;o instanceof ms&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize??.5,e+=1),o instanceof ys&&o.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+t]=o.data.penumbraSize??.5,t+=1)})}raycastWithClones(e){let t=[],o=n=>{for(let a of n.children){let s=a.cloner;De.is(a)&&(a.visible||s?.object.data.visible)&&((Ei(a)||Al(a)&&this.scene.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),Rl(a,e,t,!0)),o(a))}};return o(this),t}updateEntity2DByOp(e,t,o,n){this.uiCanvas?.updateEntity2DByOp(e,t,o,n)}};import{PointLight as MR,Vector3 as Pd,Box3 as IR,Box3Helper as Q1,Color as ER}from"three";var Od=class extends ds(MR,hs){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=90,n.aspect=1,n.near=100,n.far=2500;let a=new Pd(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),s=new Pd(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z),l=new IR(a,s),c=new Q1(l,new ER(16755200));c.visible=!1,this.gizmos.shadowmap=c,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let r in this.gizmos){let e=this.gizmos[r];if(e instanceof Q1){let t=this.shadow.camera,o=new Pd(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),n=new Pd(t.far+this.position.x,t.far+this.position.y,t.far+this.position.z);e.box.set(o,n),e.updateMatrixWorld(!0)}}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Td=class extends et{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?ul(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var bs=class extends et{constructor(e,t,o){super(e,t,o);this._shapeId=null;this._context=o}updateState(e,t){super.updateState(e,t),this.updateShape(),this.refreshAttachedCloners(t)}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let n in e)typeof e[n]=="string"&&(e[n]=this._context.shared.getVariable(e[n],[this.uuid,"geometry","extrusion","shape",n]));let t;if(e.type==="Custom"){let n=e.shapeId;if(n!==this._shapeId&&this.detachShape(),n){this._shapeId=n;let a=this._context.scene.find(n);a?.data&&(a.attachedPaths.add(this),t=a.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let n;switch(e.type){case"Rectangle":n=Da;break;case"Ellipse":n=Ma;break;case"Polygon":n=Du;break;case"Star":n=_u;break;default:throw new Error(`Unknown shape type: ${e.type}`)}t=n.create({parameters:e}).userData.shape}let o=this.geometry;t&&o.inputs&&(o.inputs.shapeData=t,o.build())}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,t){return super.updateTransformState(e,t)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let o=this.geometry.getAttribute("position");o!==void 0?ul(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,t):super.updateEntityBoxSize(e,t)}};var Cd=class extends Ai{constructor(e,t,o){super(e,t,o);this.data=t}};import{Group as NR,Matrix4 as DR,Skeleton as _R}from"three";var Qo=class extends Cr(NR,Ar){constructor(e,t,o){super();t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,o)),this.super_Entity(e,t),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,t){let o=pa.getComponentData({scene:t.scene.data,shared:t.shared.data},e.component);if(o){let n,a;for(let s of io.rootOverrideProps)e[s]===void 0?(n===void 0&&(n={...e}),n[s]=o.data[s]):(a===void 0&&(a={}),a[s]=e[s],n===void 0&&(n={...e}),n[s]=Qr.apply(o.data[s],e[s]));return this.overrideData=a,n}else return{...yt.defaultData,...e,...Nr(yt.defaultData,io.rootOverrideProps)}}updateByOp(e,t,o,n){let a;if(this.isInstanceRoot&&!n){if(t=this.transformAssignData(t,o),e.type===0&&e.path.length===0&&this.component)for(let s of io.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&io.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:t[s]}})}}super.updateByOp(a??e,t,o,n)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){let o=e.scene.find(t.component)??null,n=!1;if(o!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(De.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Ad(s),a+=1;else break;this.children.splice(0,a)}n=!0}if(o){let a={};J1(e,[this.uuid],t.overrides,this,o,o,0,n,a);for(let s of this.children)if(De.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(c=>{let u=c.dataPatched;if(c instanceof et&&u.bones&&u.boneInverses){let p=c.dataPatched;if(p.bones&&p.boneInverses){let d=p.bones.map(m=>e.scene.find(a[m])),f=p.boneInverses.map(m=>new DR().fromArray(m)),h=new _R(d,f);c.bind(h,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function Ad(i){if(i.component){let r=i.component.instances.indexOf(i);r>=0&&i.component.instances.splice(r,1);for(let e of i.children)De.is(e)&&Ad(e)}}function Z1(i,r,e,t){return i.component===r&&cp(i.identity,t)?i.overrideData===e?2:1:0}function J1(i,r,e,t,o,n,a,s,l){if(a>50)return!1;if(t.component!==o){if(t.component){let u=t.component.instances.indexOf(t);u>=0&&t.component.instances.splice(u,1)}o.instances.find(u=>u===t)||o.instances.push(t),t.component=o}o instanceof Qo&&o.isInstanceRoot&&o.expandInstanceChildren(i);let c=0;for(let u of o.children)if(De.is(u)){let p=[...r,...typeof u.identity=="string"?[u.identity]:u.identity],d=ua.resolve(e,p,1);if(d!=null&&!(d instanceof Qe)){if(!1)debugger;Object.setPrototypeOf(d,Qe.prototype),console.error("wrong prototype")}let f=null,h;if(!s){let m=t.children[c];if(f=De.is(m)?m:null,f!==null){let y=Z1(f,u,d,p);h=y>=1?f.stateSelection:void 0,y!==2&&(f=null)}if(f===null&&(f=i.scene.findInstance(p)??null,f!==null)){let y=Z1(f,u,d,p);if(h=y>=1?f.stateSelection:void 0,y!==2)f=null;else{let b=f.parent.children.indexOf(f);f.parent.children.splice(b,1),t.children.splice(c,0,f),f.parent===t?(b<=c&&console.error("not possible"),void 0):(f.parent=t,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),i.pendingDeletes.delete(f),void 0)}}}if(f===null){let m=d?Qr.apply(u.data,d):u.data;Dr.is(m.type)&&(m={...m,type:"Empty"}),f=Br.createEntity(p,m,i),f.overrideData=d,t.add(f),t.children.splice(t.children.length-1,1),t.children.splice(c,0,f),f.updateState(f.data,i),h&&f.changeSelectedState(h,i),i.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let m=f.identity[f.identity.length-1];l[m]=f.uuid}c+=1,J1(i,r,e,f,u,n,a+1,s,l)}if(!s){let u=c;for(;;){let p=t.children[c];if(De.is(p))i.pendingDeletes.add(p);else break;c+=1}t.children.splice(u,c-u)}return!0}import{Bone as RR}from"three";var Md=class extends Cr(RR,Ar){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(r,e){this.updateState_Entity(r,e)}};var Pn=class extends et{constructor(e,t,o){super(e,t,o);this.onBeforeRender=e=>{this.uiCanvas.render(e)};this.uiCanvas=new xs(e+"-canvas",t.geometry.width,t.geometry.height,o),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,o.shared)})}updateByPatchedOpGeometry(e,t,o){super.updateByPatchedOpGeometry(e,t,o),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,o.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,o.shared))}applySize(e,t){let o=e?.width??this.dataPatched.geometry.width,n=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:o,height:n}),this.applyGeometryParametersFromFrame(t)}applyFrame(e,t){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(t),this.applyMaterialParametersFromFrame({shared:t})}applyGeometryParametersFromFrame(e){let t=this.frame;t&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=jo(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let t=this.frame;if(t){let o=t.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),this.material.reset(this.dataPatched.material,e,!0)}}updateEntity2DByOp(e,t,o,n){this.uiCanvas.updateEntity2DByOp(e,t,o,n),e===this.frameId&&t.type===0&&(t.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(n):Le(t.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:n}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.applySize({width:e.width,height:e.height},t)}};import{Object3D as WR,Vector3 as Ir,InstancedMesh as qR,InstancedBufferAttribute as $R,PlaneGeometry as XR,Vector4 as Ll,Quaternion as vS,TextureLoader as YR,Texture as SS,Euler as KR,MathUtils as rm}from"three";import{GPUComputationRenderer as QR}from"three/examples/jsm/misc/GPUComputationRenderer.js";import{Vector3 as eS,FloatType as Kh,DataTexture as Qh,RGBAFormat as Zh,Mesh as LR,Euler as $pe,Matrix4 as Xpe}from"three";import{MeshSurfaceSampler as BR}from"three/examples/jsm/math/MeshSurfaceSampler.js";function tS(i){let r=new Float32Array(i*i*2);for(let e=0;e<i;e++)for(let t=0;t<i;t++){let o=e*i+t;r[o*2+0]=e/(i-1),r[o*2+1]=t/(i-1)}return r}function rS(i){let r=Math.ceil(Math.sqrt(i));return Math.max(r,1)}function oS(i,r){let e=new LR(i.geometry,i.material),t=[],o=[],n=new eS,a=new eS;e.geometry.index!==null&&(e.geometry=e.geometry.toNonIndexed());let s=new BR(e).build();for(let u=0;u<r;u++)s.sample(n,a),t.push(n.x,n.y,n.z),o.push(a.x,a.y,a.z);let l=new Float32Array(t),c=new Float32Array(o);return{positions:l,normals:c}}function Jh(i,r){let e=i,t=new Float32Array(4*r*r);for(let n=0;n<r*r;n++)t[4*n]=e[3*n],t[4*n+1]=e[3*n+1],t[4*n+2]=e[3*n+2],t[4*n+3]=0;let o=new Qh(t,r,r,Zh,Kh);return o.needsUpdate=!0,o}function iS({size:i}){let r=new Float32Array(4*i*i);for(let t=0;t<i*i;t++)r[4*t]=t,r[4*t+1]=0,r[4*t+2]=0,r[4*t+3]=0;let e=new Qh(r,i,i,Zh,Kh);return e.needsUpdate=!0,e}function nS(i){let r=new Float32Array(4*i*i);for(let t=0;t<i*i;t++)r[4*t]=0,r[4*t+1]=0,r[4*t+2]=0,r[4*t+3]=0;let e=new Qh(r,i,i,Zh,Kh);return e.needsUpdate=!0,e}var aS=`
2675
2675
  // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
2676
2676
  // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
2677
2677
  // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
@@ -2740,7 +2740,7 @@ void main() {
2740
2740
  gl_FragColor = mix(vec4(0.0), activeColor, isActive);
2741
2741
 
2742
2742
  }
2743
- `;var U1=`
2743
+ `;var sS=`
2744
2744
 
2745
2745
  vec3 mod289(vec3 x) {
2746
2746
  return x - floor(x * (1.0 / 289.0)) * 289.0;
@@ -2942,7 +2942,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
2942
2942
  );
2943
2943
  }
2944
2944
 
2945
- `;var k1=`
2945
+ `;var lS=`
2946
2946
  #ifdef USE_COLLIDER
2947
2947
  float restitution = max(uBounce * 2., .01); // Energy Loss
2948
2948
  // SPHERE COLLIDER
@@ -3010,7 +3010,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
3010
3010
  #endif
3011
3011
  #endif
3012
3012
  // END COLLIDER
3013
- `;var H1=`
3013
+ `;var cS=`
3014
3014
  #ifdef USE_ATTRACTOR
3015
3015
 
3016
3016
  #ifdef USE_SPHERE_COLLIDER
@@ -3084,7 +3084,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
3084
3084
  velocity *= uForceDamping;
3085
3085
  #endif
3086
3086
  #endif
3087
- `;var W1=`
3087
+ `;var uS=`
3088
3088
  #ifdef USE_VORTEX
3089
3089
  // Box dimensions
3090
3090
  vec3 boxHalfSize = uColliderSize / 2.0;
@@ -3123,7 +3123,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
3123
3123
  velocity += applyForce( originDirection * uSpeed * (1. - uForceDamping) , mass * .5);
3124
3124
  }
3125
3125
  #endif
3126
- `;var q1=`
3126
+ `;var dS=`
3127
3127
  // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
3128
3128
  // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
3129
3129
  // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
@@ -3149,7 +3149,7 @@ uniform float uForceDamping;
3149
3149
  uniform float uForceIntensity;
3150
3150
 
3151
3151
 
3152
- `+U1+`
3152
+ `+sS+`
3153
3153
  float rand(vec2 co){
3154
3154
  return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
3155
3155
  }
@@ -3225,11 +3225,11 @@ void main() {
3225
3225
  #endif
3226
3226
 
3227
3227
  // COLLIDER
3228
- ${k1}
3228
+ ${lS}
3229
3229
  // ATTRACTION
3230
- ${H1}
3230
+ ${cS}
3231
3231
  // VORTEX
3232
- ${W1}
3232
+ ${uS}
3233
3233
  }
3234
3234
  // End isActive
3235
3235
 
@@ -3247,7 +3247,7 @@ void main() {
3247
3247
 
3248
3248
  gl_FragColor = vec4(velocity, collisionFlag);
3249
3249
  }
3250
- `;import{ShaderMaterial as j_}from"three";var qh=`
3250
+ `;import{ShaderMaterial as VR}from"three";var em=`
3251
3251
 
3252
3252
  // Linear Fade In
3253
3253
  float linearFadeIn(float t) {
@@ -3280,7 +3280,7 @@ void main() {
3280
3280
  float constant(float t) {
3281
3281
  return 1.0;
3282
3282
  }
3283
- `;var $1=`
3283
+ `;var pS=`
3284
3284
 
3285
3285
  float rand(vec3 co){
3286
3286
  return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
@@ -3295,7 +3295,7 @@ vec3 applyForce(vec3 force, float mass) {
3295
3295
 
3296
3296
  return acceleration;
3297
3297
  }
3298
- `;var X1=`
3298
+ `;var fS=`
3299
3299
  vec3 rgb2xyz (in vec3 rgb) {
3300
3300
  float r = rgb.r;
3301
3301
  float g = rgb.g;
@@ -3386,7 +3386,7 @@ vec3 lab2rgb (in vec3 lab) {
3386
3386
  return(rgb);
3387
3387
  }
3388
3388
 
3389
- `;var Y1=`
3389
+ `;var hS=`
3390
3390
  uniform sampler2D uPosition;
3391
3391
  uniform float uSize;
3392
3392
  uniform float uSizeEnd;
@@ -3407,9 +3407,9 @@ vec3 lab2rgb (in vec3 lab) {
3407
3407
  varying vec2 vUv;
3408
3408
  varying vec2 vRef;
3409
3409
 
3410
- ${$1}
3411
- ${qh}
3412
- `,K1=({easeSize:i="linearFadeOut"})=>`
3410
+ ${pS}
3411
+ ${em}
3412
+ `,mS=({easeSize:i="linearFadeOut"})=>`
3413
3413
  vUv = uv;
3414
3414
  vRef = ref;
3415
3415
  // Normalized LifeTime 1 to 0
@@ -3461,7 +3461,7 @@ vec3 lab2rgb (in vec3 lab) {
3461
3461
  mvPosition = modelViewMatrix * instanceMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
3462
3462
  mvPosition.xy += rotatedPosition;
3463
3463
  gl_Position = projectionMatrix * mvPosition;
3464
- `,Q1=`
3464
+ `,yS=`
3465
3465
  uniform vec4 uColor; // start color
3466
3466
  uniform vec4 uColor2; // end color
3467
3467
  uniform sampler2D uTexture; // texture
@@ -3472,10 +3472,10 @@ vec3 lab2rgb (in vec3 lab) {
3472
3472
  float random(vec2 co) {
3473
3473
  return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
3474
3474
  }
3475
- `+qh+`
3476
- ${X1}
3475
+ `+em+`
3476
+ ${fS}
3477
3477
 
3478
- `,Z1=({easeOpacity:i="linearFadeOut"})=>`
3478
+ `,gS=({easeOpacity:i="linearFadeOut"})=>`
3479
3479
  // if Particle is dead, hide it
3480
3480
  if (v_LifeLeft <= 0.005 ) {
3481
3481
  discard;
@@ -3496,7 +3496,7 @@ vec3 lab2rgb (in vec3 lab) {
3496
3496
 
3497
3497
  gl_FragColor = vec4(finalColor, finalAlpha);
3498
3498
 
3499
- `;var Td=class extends j_{constructor(e,t){super();this.needsJitter=!0;this.type="ParticleMaterial";this.easeOpacity="linearFadeIn";this.easeSize="linearFadeIn";this.useSizeEnd=!1;this.isColoringRandom=!1;this.init(e,t),this.context=t}reset(){}init(e,t){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],qe.startContext(qe.globalContext),this.lightLayer=new Kt(0,"",{...bt.defaultData("light","phong"),visible:!1},new ko,{},t.shared),qe.endContext(qe.globalContext),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new Ua;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(Ub),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(kb),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(Y1),e.addFragmentParsCode(Q1),e.addVertexFinalCode(K1({easeSize:this.easeSize})),e.addFragmentFinalCode(Z1({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.extensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}};import{BoxGeometry as U_,ConeGeometry as k_,MeshBasicMaterial as H_,SphereGeometry as $h,Vector3 as W_}from"three";import{Mesh as q_}from"three";import{TorusGeometry as $_}from"three";import{PlaneGeometry as X_}from"three";var vs=class{constructor(r,e,t,o){this.type="SphereEmitterShape";this.targetMesh=void 0;this.size=r,this.type=t,this.textureSize=V1(e);let n=1;this.targetMesh=o?.geometry.type==="BufferGeometry"||o?.type==="Mesh"&&o&&o.geometry.hasAttribute("position")&&o.geometry.hasAttribute("normal")?o:this.getMesh(t,n);let{positions:a,dataTexture:s,dataTextureNormals:l}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(t,n));this.positionsTexture=s,this.positionsAttribute=a,this.directionsTexture=l}createPositions(r,e){let{positions:t,normals:o}=z1(e,r*r),n=Wh(t,r),a=Wh(o,r);return{dataTexture:n,positions:t,dataTextureNormals:a}}getMesh(r,e){let t=null;switch(r){case"SphereEmitterShape":{t=new $h(e*.5,32,32);break}case"TorusEmitterShape":{t=new $_(e*.5,.3,15,40);break}case"ConeEmitterShape":{t=new k_(e,e,15);break}case"BoxEmitterShape":{t=new U_(e,e,e);break}case"PlaneEmitterShape":{t=new X_(e,e),t.rotateX(-Math.PI/2);break}case"MeshEmitterShape":{t=new $h(e,32,32);break}default:{t=new $h(e,32,32);break}}return new q_(t,new H_({color:16711680}))}applyToShader(r,e){this.size=new W_().fromArray(e.size),r.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function Li(i){let r={...i},e=na.defaultData;r.forceFieldObjectId&&(r.colliderEntityId=r.forceFieldObjectId);let t={...e.shape,...r.shape},o={...e.renderMaterial,...r.renderMaterial};return{...e,...r,shape:t,renderMaterial:o}}var J1=`
3499
+ `;var Id=class extends VR{constructor(e,t){super();this.needsJitter=!0;this.type="ParticleMaterial";this.easeOpacity="linearFadeIn";this.easeSize="linearFadeIn";this.useSizeEnd=!1;this.isColoringRandom=!1;this.init(e,t),this.context=t}reset(){}init(e,t){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],qe.startContext(qe.globalContext),this.lightLayer=new Kt(0,"",{...bt.defaultData("light","phong"),visible:!1},new ko,{},t.shared),qe.endContext(qe.globalContext),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new Ua;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(sv),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(lv),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(hS),e.addFragmentParsCode(yS),e.addVertexFinalCode(mS({easeSize:this.easeSize})),e.addFragmentFinalCode(gS({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.extensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}};import{BoxGeometry as zR,ConeGeometry as GR,MeshBasicMaterial as FR,SphereGeometry as tm,Vector3 as jR}from"three";import{Mesh as UR}from"three";import{TorusGeometry as kR}from"three";import{PlaneGeometry as HR}from"three";var vs=class{constructor(r,e,t,o){this.type="SphereEmitterShape";this.targetMesh=void 0;this.size=r,this.type=t,this.textureSize=rS(e);let n=1;this.targetMesh=o?.geometry.type==="BufferGeometry"||o?.type==="Mesh"&&o&&o.geometry.hasAttribute("position")&&o.geometry.hasAttribute("normal")?o:this.getMesh(t,n);let{positions:a,dataTexture:s,dataTextureNormals:l}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(t,n));this.positionsTexture=s,this.positionsAttribute=a,this.directionsTexture=l}createPositions(r,e){let{positions:t,normals:o}=oS(e,r*r),n=Jh(t,r),a=Jh(o,r);return{dataTexture:n,positions:t,dataTextureNormals:a}}getMesh(r,e){let t=null;switch(r){case"SphereEmitterShape":{t=new tm(e*.5,32,32);break}case"TorusEmitterShape":{t=new kR(e*.5,.3,15,40);break}case"ConeEmitterShape":{t=new GR(e,e,15);break}case"BoxEmitterShape":{t=new zR(e,e,e);break}case"PlaneEmitterShape":{t=new HR(e,e),t.rotateX(-Math.PI/2);break}case"MeshEmitterShape":{t=new tm(e,32,32);break}default:{t=new tm(e,32,32);break}}return new UR(t,new FR({color:16711680}))}applyToShader(r,e){this.size=new jR().fromArray(e.size),r.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function Li(i){let r={...i},e=na.defaultData;r.forceFieldObjectId&&(r.colliderEntityId=r.forceFieldObjectId);let t={...e.shape,...r.shape},o={...e.renderMaterial,...r.renderMaterial};return{...e,...r,shape:t,renderMaterial:o}}var xS=`
3500
3500
  // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
3501
3501
  // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
3502
3502
  // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
@@ -3543,14 +3543,14 @@ void main() {
3543
3543
 
3544
3544
 
3545
3545
  }
3546
- `;var Yh=10,Cd=class extends Y_{constructor(e,t){super();this.type="ParticleEmitter";this.debugMode=!1;this.worldSpace=!0;this.rootObject=null;this.gpuCompute=null;this.positionSimRT=null;this.velocitySimRT=null;this.emissionRateSimRT=null;this.emitterShape=void 0;this.isEmitting=!1;this.hasBeenReset=!1;this.emittedParticlesAmount=0;this.lastEmitTime=0;this.globalTime=0;this.targetFPS=60;this.previousRatio=1;this.lerpFactor=.4;this.particlesAmount=0;this.noiseStrength=0;this.noiseScale=0;this.isBillboardBased=!0;this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1};this.textureLoader=new J_;this.currentWorldPosition=new Ir;this.systemQuaternion=new tS;this.worldGravity=new Ir(0,0,0);this.directionAxis=new Ir(0,0,0);this.colliderV3=new Ir(0,0,0);this.colliderQuaternion=new tS(0,0,0,1);this.matrixAutoUpdate=!0,this.renderer=e,this.system=t,this.shared=t.context.shared;let o=t.data;this.material=new Td(o.renderMaterial,t.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:o.renderMaterial.color},uColor2:{value:o.renderMaterial.color2},uPosition:{value:new Ir(0,0,0)},uEmissionData:{value:new Ir(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new Ir(0,0,0)},uWorldQuaternion:{value:new Ll(0,0,0,1)},uRandScaleFactor:{value:o.randomScale??0},uRandRotationFactor:{value:o.randomRotation??0},uRotation:{value:o.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:o.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,o.renderMaterial.texture),this.init(o)}setTexture(e,t){let o=t.data;if(typeof t=="string"){let n=this.shared.image(t),a=new rS(n.img);a.needsUpdate=!0,e.uTexture.value=a;return}if(typeof o!="string"){let n=new Image;n.onload=()=>{let l=new rS(n);l.needsUpdate=!0,e.uTexture.value=l};let a=new Blob([o],{type:"image/*"}),s=URL.createObjectURL(a);n.src=s}}updateGeometryAttributes(e,t){let o=B1(t);!this.emitterShape?.positionsAttribute||e.geometry.setAttribute("ref",new Q_(o,2))}applyWorldSpace(){if(!this.system.started||!this.worldSpace||!this.positionSimRT||!this.velocitySimRT)return;let e=this.system;e.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),e.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(e,t){if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset){this.reset();return}this.applyWorldSpace(),this.globalTime=e,this.positionSimRT.material.uniforms.uTime.value=e,this.emissionRateSimRT.material.uniforms.uTime.value=e;let o=1e3/t,n=this.targetFPS/o,a=this.previousRatio+(n-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=a,this.previousRatio=a;let s=this.isEmitting?this.GoEmitSomeParticles(e,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=s,this.material.uniforms.uPosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT)?.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let e=this.system.colliderEntities[0],t=this.simFeaturesDefinition.USE_COLLIDER||this.simFeaturesDefinition.USE_ATTRACTOR||this.simFeaturesDefinition.USE_VORTEX;if(e.destroyedInAction&&t&&this.init(Li({...this.system.data,colliderEntityId:null})),!e||e.destroyedInAction)return;e.getWorldPosition(this.colliderV3),this.colliderV3.y===0&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let o=e.data.size;this.colliderV3.fromArray(o),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),e.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(e){!this.velocitySimRT||!this.positionSimRT||(e.renderMaterial&&this.updateMaterialState(e.renderMaterial),this.updateParticleState(e))}updateVariableState(e,t){if(!this.velocitySimRT||!this.positionSimRT)return;t[2]==="size"&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),t[2]==="sizeEnd"&&this.material.updateState({size:[this.material.uniforms.uSize.value,e]});let o=(n,a)=>{let s=[...this.system.data.shape.size];s[n]=a,this.updateParticleState({shape:{...this.system.data.shape,size:s}})};t[2]==="shape_size_0"&&o(0,e),t[2]==="shape_size_1"&&o(1,e),t[2]==="shape_size_2"&&o(2,e),t[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/Yh),t[2]==="gravity"&&this.worldGravity.set(0,e/100,0),t[2]==="noiseStrength"&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),t[2]==="noiseScale"&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),t[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),t[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),t[2]==="direction_z"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(e)]))}updateMaterialState(e){this.material.updateState({...e,size:e.size?[Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),e.texture&&(this.setTexture(this.material.uniforms,e.texture),this.material.needsUpdate=!0)}updateParticleState(e){if(!(!this.positionSimRT||!this.velocitySimRT)){if(this.shouldReInitGPUCompute(e)&&this.init(Li(this.system.data)),e.life!==void 0&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=e.life),e.speed!==void 0&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/Yh),e.collisionBounce!==void 0&&(this.velocitySimRT.material.uniforms.uBounce.value=e.collisionBounce),e.noiseStrength!==void 0&&(this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),e.noiseScale!==void 0&&(this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),e.noiseSeed!==void 0&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=e.noiseSeed),e.randomMass!==void 0&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=e.randomMass),e.renderMaterial?.size!==void 0){let t=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(t)}if(e.renderMaterial?.spriteRotation!==void 0&&(this.material.uniforms.uRotation.value=e.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=e.renderMaterial.spriteRotation[1]),e.shape!==void 0){let t=e.shape.size??this.system.data.shape.size,o=[Number(this.shared.getVariable(t[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(t[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(t[2],[this.uuid,"particles","shape_size_2"]))],n={...Li(this.system.data).shape,size:o};this.emitterShape?.applyToShader(this.positionSimRT.material.uniforms,n)}if(e.gravity!==void 0&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),e.direction!==void 0){let t=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(t),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}e.randomRotation!==void 0&&(this.material.uniforms.uRandRotationFactor.value=e.randomRotation),e.randomScale!==void 0&&(this.material.uniforms.uRandScaleFactor.value=e.randomScale)}}updateForceFieldParameters(e){!this.velocitySimRT||(e.forceIntensity!==void 0&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=e.forceIntensity),e.forceDambing!==void 0&&(this.velocitySimRT.material.uniforms.uForceDamping.value=e.forceDambing))}getDirectionAxis(e){let t=[Number(e[0])*Xh.DEG2RAD,Number(e[1])*Xh.DEG2RAD,Number(e[2])*Xh.DEG2RAD],o=new eR(t[0],t[1],t[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(o).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(e){let{birthRatePerSec:t,rootObjectType:o,colliderEntityId:n,shape:a,emitTimeDuration:s,emitTimeCycle:l,life:c,directionMode:u,noiseType:p}=e;return t!==void 0||o!==void 0||(n||n===null)||l!==void 0||a!==void 0||c!==void 0||s!==void 0||u!==void 0||p!==void 0}init(e){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:e.birthRatePerSec,particleMaxLifeTime:e.life,loopDuration:e.emitTimeCycle==="infinity"?0:e.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn(`The maximum number of particles is limited to ${1e5}.`),this.particlesAmount=1e5),this.emitterShape=this.createShape(e.shape,this.particlesAmount);let t=setInterval(()=>{if(!!this.emitterShape)if(isNaN(this.emitterShape.positionsTexture.source.data.data[0])){this.init(e);return}else clearInterval(t)},100);if(!this.emitterShape)return;let o=new tR(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),n=this.updateSimulationDefinition(e),a=o.addVariable("uCurrentPosition",n+j1,this.emitterShape.positionsTexture),s=o.addVariable("uCurrentVelocity",n+q1,this.emitterShape.directionsTexture),l=o.addVariable("uCurrentEmissionRate",J1,F1(this.emitterShape.textureSize));o.setVariableDependencies(a,[a,s,l]),o.setVariableDependencies(s,[a,s,l]),o.setVariableDependencies(l,[a,s,l]);let c=G1({size:this.emitterShape.textureSize}),u={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new Ir(0,0,0)},uWorldQuaternion:{value:new Ll(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:e.life},uEmitterSize:{value:new Ir(Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"])))},particleSize:{value:0}};a.material.uniforms=u;let p=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(p),this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"]));let d=e.colliderEntityId&&this.system.getColliderData(e.colliderEntityId),f={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new Ll(0,0,0,1)},uColliderPos:{value:new Ir(0,0,0)},uColliderSize:{value:new Ir(0,0,0)},uForceIntensity:{value:d?d.forceIntensity:0},uForceDamping:{value:d?d.forceDambing:0},uColliderQuaternion:{value:new Ll(0,0,0,1)},uColliderQuaternionInvert:{value:new Ll(0,0,0,1)},particleSize:{value:0},uGravity:{value:this.worldGravity},uNoiseStrength:{value:this.noiseStrength},uNoiseScale:{value:this.noiseScale},uNoiseSeed:{value:e.noiseSeed},uRandomMassFactor:{value:e.randomMass},uBounce:{value:e.collisionBounce},uSpeed:{value:Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/Yh}};s.material.uniforms=f;let h={uIndex:{value:c},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};l.material.uniforms=h;let m=[Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"]))],y={...Li(this.system.data).shape,size:m};this.emitterShape.applyToShader(a.material.uniforms,y),o.init(),this.gpuCompute=o,this.positionSimRT=a,this.velocitySimRT=s,this.emissionRateSimRT=l,this.rootObject=this.createPrimaryEmitter(this.emitterShape.textureSize),this.add(this.rootObject),this.material.needsUpdate=!0}getDirectionFromVariable(e){let t=Number(this.shared.getVariable(e[0],[this.uuid,"particles","direction_x"])),o=Number(this.shared.getVariable(e[1],[this.uuid,"particles","direction_y"])),n=Number(this.shared.getVariable(e[2],[this.uuid,"particles","direction_z"]));return[t,o,n]}updateSimulationDefinition(e){if(this.simFeaturesDefinition.USE_COLLIDER=!1,this.simFeaturesDefinition.USE_ATTRACTOR=!1,this.simFeaturesDefinition.USE_VORTEX=!1,this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!1,this.simFeaturesDefinition.USE_BOX_COLLIDER=!1,this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!1,this.simFeaturesDefinition.USE_NORMALS=!1,this.simFeaturesDefinition.USE_CURL_NOISE=!1,this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!1,this.simFeaturesDefinition.USE_FBM_NOISE=!1,e.colliderEntityId&&this.system.colliderEntities.length>0){let o=this.system.getColliderData(e.colliderEntityId);switch(o?.forceType){case"attractor":this.simFeaturesDefinition.USE_ATTRACTOR=!0;break;case"collider":this.simFeaturesDefinition.USE_COLLIDER=!0;break;case"vortex":this.simFeaturesDefinition.USE_VORTEX=!0;break}let n=o?.colliderType;n==="sphere"&&(this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!0),n==="box"&&(this.simFeaturesDefinition.USE_BOX_COLLIDER=!0),o?.forceRange==="helper"&&(this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!0)}e.directionMode==="normals"&&(this.simFeaturesDefinition.USE_NORMALS=!0),e.noiseType==="curl"&&(this.simFeaturesDefinition.USE_CURL_NOISE=!0),e.noiseType==="simplex"&&(this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!0),e.noiseType==="fbm"&&(this.simFeaturesDefinition.USE_FBM_NOISE=!0);let t="";for(let[o,n]of Object.entries(this.simFeaturesDefinition))n&&(t+=`#define ${o}
3547
- `);return t}createShape(e,t){this.emitterShape&&this.emitterShape.dispose();let o=new Ir(Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.size[2],[this.uuid,"particles","shape_size_2"])));if(e.type==="MeshEmitterShape"){let n=null;return this.system.context.scene.traverseEntity(a=>{a.uuid===e.fromMeshId&&(n=a)}),n?new vs(o,t,e.type,n):new vs(o,t,"SphereEmitterShape")}else return new vs(o,t,e.type)}createPrimaryEmitter(e){let t,o=e*e;return t=new K_(new Z_(1,1,1),this.material,o),this.updateGeometryAttributes(t,e),this.material.needsUpdate=!0,t.onBeforeRender=()=>{this.applyWorldSpace()},t}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:t,loopDuration:o=0}){return Math.ceil(e*(t+o))}dispose(){!this.gpuCompute||(this.rootObject?.parent?.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),this.emitterShape?.dispose())}GoEmitSomeParticles(e,t){let o=e-this.lastEmitTime,n=1/t;if(o>=n){let a=Math.max(1,Math.floor(o/n));return this.lastEmitTime=e,this.emittedParticlesAmount+a>this.particlesAmount&&(this.emittedParticlesAmount=0),this.emittedParticlesAmount+=a,a}return 0}checkIfAllParticlesAreDead(){return this.lastEmitTime+this.system.data.life+1<this.globalTime}reset(){this.hasBeenReset=!0,this.lastEmitTime=0,this.emittedParticlesAmount=0,this.gpuCompute&&this.init(Li(this.system.data))}startEmitting(e){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=e}stopEmitting(){this.isEmitting=!1}};import{BufferGeometry as rR,Float32BufferAttribute as oR,MeshBasicMaterial as iR}from"three";var Ss=class extends Tt{constructor(e,t,o){super(e,t);this.type="ParticleSystem";this.geometry=new rR;this.actualTime=0;this.currentLoopTime=0;this.started=!1;this.stopped=!1;this.timeoutId=void 0;this.isFrozen=!1;this.isIdle=!0;this.emitter=null;this.colliderEntities=[];this.renderer=null;this.isPreWarm=!1;this._hasOnAfterRenderBeenCalled=!1;this.onAfterRender=e=>{this._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(e))};this.context=o,this.data={...t,...Li(t)},this.geometry.setAttribute("position",new oR([],3)),this.material=new iR({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new Cd(e,this),this.add(this.emitter),this.updateParticleState(this.data)}update(e){if(!this.isReady||!this.started||this.isFrozen||this.isIdle)return;this.actualTime+=e,this.stopped||(this.currentLoopTime+=e);let t=this.data.emitTimeCycle==="one_time";if((this.data.emitTimeCycle==="loop"||t)&&this.currentLoopTime>this.data.emitTimeDuration*1e3&&(this.stopped||(this.stop(),t||this.start(this.data.emitTimeDelay*1e3))),this.emitter&&this.started){let n=this.actualTime/1e3;this.emitter.update(n,e)}this.scale.set(1,1,1),this.updateMatrix()}isReady(){return!!this.emitter}hasCollider(e){return this.colliderEntities.some(t=>t.identity===e)}getColliderData(e){let t=this.colliderEntities.find(o=>o.identity===e);return t?t.data:null}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),Le(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...nt.drop(e,1).props}}),Le(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...nt.drop(e,1).props}})}updateState(e,t){super.updateState(e,t),this.updateParticleState(e)}updateParticleState(e){if(!!this.emitter){if(e.colliderEntityId!==void 0&&e.colliderEntityId!==null){let t=this.context.scene.find(e.colliderEntityId);this.colliderEntities=t?[t]:[]}e.colliderEntityId===null&&(this.colliderEntities=[]),this.emitter.updateState(e),e.emitTimeCycle&&this.started&&this.start()}}updateFromColliderEntity(e){!this.emitter||(this.emitter.updateForceFieldParameters(e),this.stop(),this.start())}start(e=0){if(this.currentLoopTime=0,e){this.timeoutId=window.setTimeout(()=>{this.start(0)},e);return}this.started=!0,this.stopped=!1,this.isFrozen=!1,this.emitter?.startEmitting(this.actualTime/1e3)}froze(){this.isFrozen=!0}unFroze(){this.isFrozen=!1}stop(){this.stopped=!0,this.currentLoopTime=0,this.emitter?.stopEmitting(),clearTimeout(this.timeoutId)}reset(){this.started=!1,this.stopped=!1,this.emitter?.reset()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}};function nR(){try{let i=window.location.href;if(i.includes("reducesubdiv=")){let r=i.indexOf("reducesubdiv=")+13;return parseInt(i.slice(r,r+1))}}catch{}}var Kh=nR();function aR(i,r,e){Kh!==void 0&&(r?.geometry?.subdivisions??0)>Kh&&(console.log("reducing subdivisions",r.name,r.geometry.subdivisions),r.geometry.subdivisions=Kh);let t;return r.geometry.type==="TextGeometry"?new Ai(i,r,e):r.geometry.type==="InputGeometry"?new wd(i,r,e):(r.geometry.type==="SubdivGeometry"?t=new gn(i,r,e):r.geometry.type==="PathGeometry"?t=new bs(i,r,e):r.geometry.type==="VectorGeometry"?t=new Sd(i,r,e):r.geometry.type==="BooleanGeometry"?t=new nr(i,r,e):r.geometry.type==="ShapeBlendGeometry"?t=new Bi(i,r,e):r.geometry.type==="UIGeometry"?t=new Pn(i,r,e):t=new et(i,r,e),t)}function Ad(i,r,e){return console.assert(r.type!==void 0),r.type==="Mesh"?aR(i,r,e):r.type==="Empty"?new Ni(i,r):r.type==="Particle"?new Ss(i,r,e):r.type==="ParticleCollider"?new ps(i,r,e):r.type==="Splat"?new Ni(i,r):r.type==="Bone"?new Od(i,r):r.type==="Page"?new Mr(i,r,e):r.type==="PointLight"?new vd(i,r,e):r.type==="SpotLight"?new ys(i,r,e):r.type==="DirectionalLight"?new ms(i,r,e):r.type==="Component"||r.type==="Instance"?new Qo(i,r,e):Dr.is(r.type)?new Xo(i,r):(console.error(r),new Ni(i,r))}Br.createEntity=Ad;function sR(i,r,e){let t=Ad(i.identity,r,e),o=i.children,n=i.attachedPaths,a=i.parent,s=i.component,l=i.instances,c=i.overrideData,u=i.uuid,p=i.stateSelection;i.dispose();for(let d of Object.keys(i))delete i[d];Object.setPrototypeOf(i,Object.getPrototypeOf(t));for(let d of Object.keys(t))i[d]=t[d];i.children=[...i.children,...o],i.attachedPaths=n,i.parent=a,i.component=s,i.instances=l,i.uuid=u,i.overrideData=c,i.updateState(i.data,e),p&&i.changeSelectedState(p,e),i.resetBBoxNeedsUpdate()}Br.changeEntityProptotype=sR;Br.Cloner=Ii;function oS(i,r,e,t){i.updateByOp(r,e,t,!1)}import{BufferAttribute as nS,BufferGeometry as aS,DataTexture as tm,FloatType as Jo,Matrix4 as lS,Mesh as Qh,NearestFilter as So,PlaneGeometry as gR,Quaternion as cS,RedFormat as Zh,RGBAFormat as Os,Scene as Jh,ShaderMaterial as sS,Vector2 as em,Vector3 as Nd,WebGLMultipleRenderTargets as xR,WebGLRenderTarget as Id}from"three";import{Box2 as lR,BufferAttribute as cR,BufferGeometry as uR,Camera as dR,GLSL3 as pR,Mesh as fR,RawShaderMaterial as hR,Scene as mR,Vector4 as yR}from"three";var Vi=5,ws=new uR;ws.setAttribute("position",new cR(new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),3));var On=class extends hR{constructor(r){super({...r,depthTest:!1,depthWrite:!1,glslVersion:pR,vertexShader:`
3546
+ `;var om=10,Ed=class extends WR{constructor(e,t){super();this.type="ParticleEmitter";this.debugMode=!1;this.worldSpace=!0;this.rootObject=null;this.gpuCompute=null;this.positionSimRT=null;this.velocitySimRT=null;this.emissionRateSimRT=null;this.emitterShape=void 0;this.isEmitting=!1;this.hasBeenReset=!1;this.emittedParticlesAmount=0;this.lastEmitTime=0;this.globalTime=0;this.targetFPS=60;this.previousRatio=1;this.lerpFactor=.4;this.particlesAmount=0;this.noiseStrength=0;this.noiseScale=0;this.isBillboardBased=!0;this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1};this.textureLoader=new YR;this.currentWorldPosition=new Ir;this.systemQuaternion=new vS;this.worldGravity=new Ir(0,0,0);this.directionAxis=new Ir(0,0,0);this.colliderV3=new Ir(0,0,0);this.colliderQuaternion=new vS(0,0,0,1);this.matrixAutoUpdate=!0,this.renderer=e,this.system=t,this.shared=t.context.shared;let o=t.data;this.material=new Id(o.renderMaterial,t.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:o.renderMaterial.color},uColor2:{value:o.renderMaterial.color2},uPosition:{value:new Ir(0,0,0)},uEmissionData:{value:new Ir(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new Ir(0,0,0)},uWorldQuaternion:{value:new Ll(0,0,0,1)},uRandScaleFactor:{value:o.randomScale??0},uRandRotationFactor:{value:o.randomRotation??0},uRotation:{value:o.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:o.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,o.renderMaterial.texture),this.init(o)}setTexture(e,t){let o=t.data;if(typeof t=="string"){let n=this.shared.image(t),a=new SS(n.img);a.needsUpdate=!0,e.uTexture.value=a;return}if(typeof o!="string"){let n=new Image;n.onload=()=>{let l=new SS(n);l.needsUpdate=!0,e.uTexture.value=l};let a=new Blob([o],{type:"image/*"}),s=URL.createObjectURL(a);n.src=s}}updateGeometryAttributes(e,t){let o=tS(t);!this.emitterShape?.positionsAttribute||e.geometry.setAttribute("ref",new $R(o,2))}applyWorldSpace(){if(!this.system.started||!this.worldSpace||!this.positionSimRT||!this.velocitySimRT)return;let e=this.system;e.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),e.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(e,t){if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset){this.reset();return}this.applyWorldSpace(),this.globalTime=e,this.positionSimRT.material.uniforms.uTime.value=e,this.emissionRateSimRT.material.uniforms.uTime.value=e;let o=1e3/t,n=this.targetFPS/o,a=this.previousRatio+(n-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=a,this.previousRatio=a;let s=this.isEmitting?this.GoEmitSomeParticles(e,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=s,this.material.uniforms.uPosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT)?.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let e=this.system.colliderEntities[0],t=this.simFeaturesDefinition.USE_COLLIDER||this.simFeaturesDefinition.USE_ATTRACTOR||this.simFeaturesDefinition.USE_VORTEX;if(e.destroyedInAction&&t&&this.init(Li({...this.system.data,colliderEntityId:null})),!e||e.destroyedInAction)return;e.getWorldPosition(this.colliderV3),this.colliderV3.y===0&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let o=e.data.size;this.colliderV3.fromArray(o),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),e.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(e){!this.velocitySimRT||!this.positionSimRT||(e.renderMaterial&&this.updateMaterialState(e.renderMaterial),this.updateParticleState(e))}updateVariableState(e,t){if(!this.velocitySimRT||!this.positionSimRT)return;t[2]==="size"&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),t[2]==="sizeEnd"&&this.material.updateState({size:[this.material.uniforms.uSize.value,e]});let o=(n,a)=>{let s=[...this.system.data.shape.size];s[n]=a,this.updateParticleState({shape:{...this.system.data.shape,size:s}})};t[2]==="shape_size_0"&&o(0,e),t[2]==="shape_size_1"&&o(1,e),t[2]==="shape_size_2"&&o(2,e),t[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/om),t[2]==="gravity"&&this.worldGravity.set(0,e/100,0),t[2]==="noiseStrength"&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),t[2]==="noiseScale"&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),t[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),t[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),t[2]==="direction_z"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(e)]))}updateMaterialState(e){this.material.updateState({...e,size:e.size?[Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),e.texture&&(this.setTexture(this.material.uniforms,e.texture),this.material.needsUpdate=!0)}updateParticleState(e){if(!(!this.positionSimRT||!this.velocitySimRT)){if(this.shouldReInitGPUCompute(e)&&this.init(Li(this.system.data)),e.life!==void 0&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=e.life),e.speed!==void 0&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/om),e.collisionBounce!==void 0&&(this.velocitySimRT.material.uniforms.uBounce.value=e.collisionBounce),e.noiseStrength!==void 0&&(this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),e.noiseScale!==void 0&&(this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),e.noiseSeed!==void 0&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=e.noiseSeed),e.randomMass!==void 0&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=e.randomMass),e.renderMaterial?.size!==void 0){let t=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(t)}if(e.renderMaterial?.spriteRotation!==void 0&&(this.material.uniforms.uRotation.value=e.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=e.renderMaterial.spriteRotation[1]),e.shape!==void 0){let t=e.shape.size??this.system.data.shape.size,o=[Number(this.shared.getVariable(t[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(t[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(t[2],[this.uuid,"particles","shape_size_2"]))],n={...Li(this.system.data).shape,size:o};this.emitterShape?.applyToShader(this.positionSimRT.material.uniforms,n)}if(e.gravity!==void 0&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),e.direction!==void 0){let t=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(t),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}e.randomRotation!==void 0&&(this.material.uniforms.uRandRotationFactor.value=e.randomRotation),e.randomScale!==void 0&&(this.material.uniforms.uRandScaleFactor.value=e.randomScale)}}updateForceFieldParameters(e){!this.velocitySimRT||(e.forceIntensity!==void 0&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=e.forceIntensity),e.forceDambing!==void 0&&(this.velocitySimRT.material.uniforms.uForceDamping.value=e.forceDambing))}getDirectionAxis(e){let t=[Number(e[0])*rm.DEG2RAD,Number(e[1])*rm.DEG2RAD,Number(e[2])*rm.DEG2RAD],o=new KR(t[0],t[1],t[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(o).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(e){let{birthRatePerSec:t,rootObjectType:o,colliderEntityId:n,shape:a,emitTimeDuration:s,emitTimeCycle:l,life:c,directionMode:u,noiseType:p}=e;return t!==void 0||o!==void 0||(n||n===null)||l!==void 0||a!==void 0||c!==void 0||s!==void 0||u!==void 0||p!==void 0}init(e){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:e.birthRatePerSec,particleMaxLifeTime:e.life,loopDuration:e.emitTimeCycle==="infinity"?0:e.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn(`The maximum number of particles is limited to ${1e5}.`),this.particlesAmount=1e5),this.emitterShape=this.createShape(e.shape,this.particlesAmount);let t=setInterval(()=>{if(!!this.emitterShape)if(isNaN(this.emitterShape.positionsTexture.source.data.data[0])){this.init(e);return}else clearInterval(t)},100);if(!this.emitterShape)return;let o=new QR(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),n=this.updateSimulationDefinition(e),a=o.addVariable("uCurrentPosition",n+aS,this.emitterShape.positionsTexture),s=o.addVariable("uCurrentVelocity",n+dS,this.emitterShape.directionsTexture),l=o.addVariable("uCurrentEmissionRate",xS,nS(this.emitterShape.textureSize));o.setVariableDependencies(a,[a,s,l]),o.setVariableDependencies(s,[a,s,l]),o.setVariableDependencies(l,[a,s,l]);let c=iS({size:this.emitterShape.textureSize}),u={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new Ir(0,0,0)},uWorldQuaternion:{value:new Ll(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:e.life},uEmitterSize:{value:new Ir(Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"])))},particleSize:{value:0}};a.material.uniforms=u;let p=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(p),this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"]));let d=e.colliderEntityId&&this.system.getColliderData(e.colliderEntityId),f={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new Ll(0,0,0,1)},uColliderPos:{value:new Ir(0,0,0)},uColliderSize:{value:new Ir(0,0,0)},uForceIntensity:{value:d?d.forceIntensity:0},uForceDamping:{value:d?d.forceDambing:0},uColliderQuaternion:{value:new Ll(0,0,0,1)},uColliderQuaternionInvert:{value:new Ll(0,0,0,1)},particleSize:{value:0},uGravity:{value:this.worldGravity},uNoiseStrength:{value:this.noiseStrength},uNoiseScale:{value:this.noiseScale},uNoiseSeed:{value:e.noiseSeed},uRandomMassFactor:{value:e.randomMass},uBounce:{value:e.collisionBounce},uSpeed:{value:Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/om}};s.material.uniforms=f;let h={uIndex:{value:c},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};l.material.uniforms=h;let m=[Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"]))],y={...Li(this.system.data).shape,size:m};this.emitterShape.applyToShader(a.material.uniforms,y),o.init(),this.gpuCompute=o,this.positionSimRT=a,this.velocitySimRT=s,this.emissionRateSimRT=l,this.rootObject=this.createPrimaryEmitter(this.emitterShape.textureSize),this.add(this.rootObject),this.material.needsUpdate=!0}getDirectionFromVariable(e){let t=Number(this.shared.getVariable(e[0],[this.uuid,"particles","direction_x"])),o=Number(this.shared.getVariable(e[1],[this.uuid,"particles","direction_y"])),n=Number(this.shared.getVariable(e[2],[this.uuid,"particles","direction_z"]));return[t,o,n]}updateSimulationDefinition(e){if(this.simFeaturesDefinition.USE_COLLIDER=!1,this.simFeaturesDefinition.USE_ATTRACTOR=!1,this.simFeaturesDefinition.USE_VORTEX=!1,this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!1,this.simFeaturesDefinition.USE_BOX_COLLIDER=!1,this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!1,this.simFeaturesDefinition.USE_NORMALS=!1,this.simFeaturesDefinition.USE_CURL_NOISE=!1,this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!1,this.simFeaturesDefinition.USE_FBM_NOISE=!1,e.colliderEntityId&&this.system.colliderEntities.length>0){let o=this.system.getColliderData(e.colliderEntityId);switch(o?.forceType){case"attractor":this.simFeaturesDefinition.USE_ATTRACTOR=!0;break;case"collider":this.simFeaturesDefinition.USE_COLLIDER=!0;break;case"vortex":this.simFeaturesDefinition.USE_VORTEX=!0;break}let n=o?.colliderType;n==="sphere"&&(this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!0),n==="box"&&(this.simFeaturesDefinition.USE_BOX_COLLIDER=!0),o?.forceRange==="helper"&&(this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!0)}e.directionMode==="normals"&&(this.simFeaturesDefinition.USE_NORMALS=!0),e.noiseType==="curl"&&(this.simFeaturesDefinition.USE_CURL_NOISE=!0),e.noiseType==="simplex"&&(this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!0),e.noiseType==="fbm"&&(this.simFeaturesDefinition.USE_FBM_NOISE=!0);let t="";for(let[o,n]of Object.entries(this.simFeaturesDefinition))n&&(t+=`#define ${o}
3547
+ `);return t}createShape(e,t){this.emitterShape&&this.emitterShape.dispose();let o=new Ir(Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.size[2],[this.uuid,"particles","shape_size_2"])));if(e.type==="MeshEmitterShape"){let n=null;return this.system.context.scene.traverseEntity(a=>{a.uuid===e.fromMeshId&&(n=a)}),n?new vs(o,t,e.type,n):new vs(o,t,"SphereEmitterShape")}else return new vs(o,t,e.type)}createPrimaryEmitter(e){let t,o=e*e;return t=new qR(new XR(1,1,1),this.material,o),this.updateGeometryAttributes(t,e),this.material.needsUpdate=!0,t.onBeforeRender=()=>{this.applyWorldSpace()},t}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:t,loopDuration:o=0}){return Math.ceil(e*(t+o))}dispose(){!this.gpuCompute||(this.rootObject?.parent?.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),this.emitterShape?.dispose())}GoEmitSomeParticles(e,t){let o=e-this.lastEmitTime,n=1/t;if(o>=n){let a=Math.max(1,Math.floor(o/n));return this.lastEmitTime=e,this.emittedParticlesAmount+a>this.particlesAmount&&(this.emittedParticlesAmount=0),this.emittedParticlesAmount+=a,a}return 0}checkIfAllParticlesAreDead(){return this.lastEmitTime+this.system.data.life+1<this.globalTime}reset(){this.hasBeenReset=!0,this.lastEmitTime=0,this.emittedParticlesAmount=0,this.gpuCompute&&this.init(Li(this.system.data))}startEmitting(e){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=e}stopEmitting(){this.isEmitting=!1}};import{BufferGeometry as ZR,Float32BufferAttribute as JR,MeshBasicMaterial as eL}from"three";var Ss=class extends Tt{constructor(e,t,o){super(e,t);this.type="ParticleSystem";this.geometry=new ZR;this.actualTime=0;this.currentLoopTime=0;this.started=!1;this.stopped=!1;this.timeoutId=void 0;this.isFrozen=!1;this.isIdle=!0;this.emitter=null;this.colliderEntities=[];this.renderer=null;this.isPreWarm=!1;this._hasOnAfterRenderBeenCalled=!1;this.onAfterRender=e=>{this._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(e))};this.context=o,this.data={...t,...Li(t)},this.geometry.setAttribute("position",new JR([],3)),this.material=new eL({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new Ed(e,this),this.add(this.emitter),this.updateParticleState(this.data)}update(e){if(!this.isReady||!this.started||this.isFrozen||this.isIdle)return;this.actualTime+=e,this.stopped||(this.currentLoopTime+=e);let t=this.data.emitTimeCycle==="one_time";if((this.data.emitTimeCycle==="loop"||t)&&this.currentLoopTime>this.data.emitTimeDuration*1e3&&(this.stopped||(this.stop(),t||this.start(this.data.emitTimeDelay*1e3))),this.emitter&&this.started){let n=this.actualTime/1e3;this.emitter.update(n,e)}this.scale.set(1,1,1),this.updateMatrix()}isReady(){return!!this.emitter}hasCollider(e){return this.colliderEntities.some(t=>t.identity===e)}getColliderData(e){let t=this.colliderEntities.find(o=>o.identity===e);return t?t.data:null}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),Le(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...nt.drop(e,1).props}}),Le(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...nt.drop(e,1).props}})}updateState(e,t){super.updateState(e,t),this.updateParticleState(e)}updateParticleState(e){if(!!this.emitter){if(e.colliderEntityId!==void 0&&e.colliderEntityId!==null){let t=this.context.scene.find(e.colliderEntityId);this.colliderEntities=t?[t]:[]}e.colliderEntityId===null&&(this.colliderEntities=[]),this.emitter.updateState(e),e.emitTimeCycle&&this.started&&this.start()}}updateFromColliderEntity(e){!this.emitter||(this.emitter.updateForceFieldParameters(e),this.stop(),this.start())}start(e=0){if(this.currentLoopTime=0,e){this.timeoutId=window.setTimeout(()=>{this.start(0)},e);return}this.started=!0,this.stopped=!1,this.isFrozen=!1,this.emitter?.startEmitting(this.actualTime/1e3)}froze(){this.isFrozen=!0}unFroze(){this.isFrozen=!1}stop(){this.stopped=!0,this.currentLoopTime=0,this.emitter?.stopEmitting(),clearTimeout(this.timeoutId)}reset(){this.started=!1,this.stopped=!1,this.emitter?.reset()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}};function tL(){try{let i=window.location.href;if(i.includes("reducesubdiv=")){let r=i.indexOf("reducesubdiv=")+13;return parseInt(i.slice(r,r+1))}}catch{}}var im=tL();function rL(i,r,e){im!==void 0&&(r?.geometry?.subdivisions??0)>im&&(console.log("reducing subdivisions",r.name,r.geometry.subdivisions),r.geometry.subdivisions=im);let t;return r.geometry.type==="TextGeometry"?new Ai(i,r,e):r.geometry.type==="InputGeometry"?new Cd(i,r,e):(r.geometry.type==="SubdivGeometry"?t=new gn(i,r,e):r.geometry.type==="PathGeometry"?t=new bs(i,r,e):r.geometry.type==="VectorGeometry"?t=new Td(i,r,e):r.geometry.type==="BooleanGeometry"?t=new nr(i,r,e):r.geometry.type==="ShapeBlendGeometry"?t=new Bi(i,r,e):r.geometry.type==="UIGeometry"?t=new Pn(i,r,e):t=new et(i,r,e),t)}function Nd(i,r,e){return console.assert(r.type!==void 0),r.type==="Mesh"?rL(i,r,e):r.type==="Empty"?new Ni(i,r):r.type==="Particle"?new Ss(i,r,e):r.type==="ParticleCollider"?new ps(i,r,e):r.type==="Splat"?new Ni(i,r):r.type==="Bone"?new Md(i,r):r.type==="Page"?new Mr(i,r,e):r.type==="PointLight"?new Od(i,r,e):r.type==="SpotLight"?new ys(i,r,e):r.type==="DirectionalLight"?new ms(i,r,e):r.type==="Component"||r.type==="Instance"?new Qo(i,r,e):Dr.is(r.type)?new Xo(i,r):(console.error(r),new Ni(i,r))}Br.createEntity=Nd;function oL(i,r,e){let t=Nd(i.identity,r,e),o=i.children,n=i.attachedPaths,a=i.parent,s=i.component,l=i.instances,c=i.overrideData,u=i.uuid,p=i.stateSelection;i.dispose();for(let d of Object.keys(i))delete i[d];Object.setPrototypeOf(i,Object.getPrototypeOf(t));for(let d of Object.keys(t))i[d]=t[d];i.children=[...i.children,...o],i.attachedPaths=n,i.parent=a,i.component=s,i.instances=l,i.uuid=u,i.overrideData=c,i.updateState(i.data,e),p&&i.changeSelectedState(p,e),i.resetBBoxNeedsUpdate()}Br.changeEntityProptotype=oL;Br.Cloner=Ii;function wS(i,r,e,t){i.updateByOp(r,e,t,!1)}import{BufferAttribute as OS,BufferGeometry as TS,DataTexture as cm,FloatType as Jo,Matrix4 as AS,Mesh as nm,NearestFilter as So,PlaneGeometry as fL,Quaternion as MS,RedFormat as am,RGBAFormat as Os,Scene as sm,ShaderMaterial as CS,Vector2 as lm,Vector3 as Ld,WebGLMultipleRenderTargets as hL,WebGLRenderTarget as _d}from"three";import{Box2 as iL,BufferAttribute as nL,BufferGeometry as aL,Camera as sL,GLSL3 as lL,Mesh as cL,RawShaderMaterial as uL,Scene as dL,Vector4 as pL}from"three";var Vi=5,ws=new aL;ws.setAttribute("position",new nL(new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),3));var On=class extends uL{constructor(r){super({...r,depthTest:!1,depthWrite:!1,glslVersion:lL,vertexShader:`
3548
3548
  precision highp float;
3549
3549
  in vec3 position;
3550
3550
  void main() {
3551
3551
  gl_Position = vec4(position, 1);
3552
3552
  }
3553
- `})}customProgramCacheKey(){return""}};function iS(){return{shapeInput:()=>`
3553
+ `})}customProgramCacheKey(){return""}};function PS(){return{shapeInput:()=>`
3554
3554
  const float posRowCoord = ${.5/Vi}; // vec4: px py pz opType
3555
3555
  const float quatRowCoord = ${1.5/Vi}; // vec4: qx qy qz qw
3556
3556
  const float param1RowCoord = ${2.5/Vi};// vec4: type param1 param2 param3
@@ -3603,7 +3603,7 @@ void main() {
3603
3603
  a = t;
3604
3604
  return r;
3605
3605
  }
3606
- `,triTable:new Float32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,1,1,8,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,10,2,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,9,9,2,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,2,8,10,2,8,9,10,-1,-1,-1,-1,-1,-1,-1,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,0,0,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,11,3,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,1,11,9,1,11,8,9,-1,-1,-1,-1,-1,-1,-1,1,10,3,3,10,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,10,0,10,8,0,10,11,8,-1,-1,-1,-1,-1,-1,-1,0,9,3,9,11,3,9,10,11,-1,-1,-1,-1,-1,-1,-1,10,8,9,11,8,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,4,4,3,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,7,4,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,4,1,7,4,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,2,1,7,4,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,4,3,4,0,3,10,2,1,-1,-1,-1,-1,-1,-1,-1,10,2,9,2,0,9,7,4,8,-1,-1,-1,-1,-1,-1,-1,9,10,2,7,9,2,3,7,2,4,9,7,-1,-1,-1,-1,7,4,8,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,4,11,4,2,11,4,0,2,-1,-1,-1,-1,-1,-1,-1,1,0,9,7,4,8,11,3,2,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,9,2,11,9,1,2,9,-1,-1,-1,-1,1,10,3,10,11,3,4,8,7,-1,-1,-1,-1,-1,-1,-1,10,11,1,11,4,1,4,0,1,4,11,7,-1,-1,-1,-1,8,7,4,11,0,9,10,11,9,3,0,11,-1,-1,-1,-1,11,7,4,9,11,4,10,11,9,-1,-1,-1,-1,-1,-1,-1,4,5,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,9,3,8,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,0,0,5,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,8,5,3,8,5,1,3,-1,-1,-1,-1,-1,-1,-1,10,2,1,4,5,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,3,10,2,1,5,9,4,-1,-1,-1,-1,-1,-1,-1,10,2,5,2,4,5,2,0,4,-1,-1,-1,-1,-1,-1,-1,5,10,2,5,2,3,4,5,3,8,4,3,-1,-1,-1,-1,4,5,9,11,3,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,0,11,8,0,5,9,4,-1,-1,-1,-1,-1,-1,-1,4,5,0,5,1,0,11,3,2,-1,-1,-1,-1,-1,-1,-1,5,1,2,8,5,2,11,8,2,5,8,4,-1,-1,-1,-1,11,3,10,3,1,10,4,5,9,-1,-1,-1,-1,-1,-1,-1,5,9,4,1,8,0,1,10,8,10,11,8,-1,-1,-1,-1,0,4,5,11,0,5,10,11,5,3,0,11,-1,-1,-1,-1,8,4,5,10,8,5,11,8,10,-1,-1,-1,-1,-1,-1,-1,8,7,9,9,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,9,3,5,9,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,7,0,7,1,0,7,5,1,-1,-1,-1,-1,-1,-1,-1,3,5,1,7,5,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,7,9,7,5,9,2,1,10,-1,-1,-1,-1,-1,-1,-1,2,1,10,0,5,9,0,3,5,3,7,5,-1,-1,-1,-1,2,0,8,5,2,8,7,5,8,2,5,10,-1,-1,-1,-1,5,10,2,3,5,2,7,5,3,-1,-1,-1,-1,-1,-1,-1,5,9,7,9,8,7,2,11,3,-1,-1,-1,-1,-1,-1,-1,7,5,9,2,7,9,0,2,9,11,7,2,-1,-1,-1,-1,11,3,2,8,1,0,8,7,1,7,5,1,-1,-1,-1,-1,1,2,11,7,1,11,5,1,7,-1,-1,-1,-1,-1,-1,-1,8,5,9,7,5,8,3,1,10,11,3,10,-1,-1,-1,-1,0,7,5,9,0,5,0,11,7,10,0,1,0,10,11,-1,0,10,11,3,0,11,0,5,10,7,0,8,0,7,5,-1,5,10,11,5,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,6,10,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,0,9,6,10,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,1,8,9,1,6,10,5,-1,-1,-1,-1,-1,-1,-1,5,6,1,1,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,6,1,6,2,1,8,0,3,-1,-1,-1,-1,-1,-1,-1,5,6,9,6,0,9,6,2,0,-1,-1,-1,-1,-1,-1,-1,8,9,5,2,8,5,6,2,5,8,2,3,-1,-1,-1,-1,11,3,2,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,11,0,2,11,5,6,10,-1,-1,-1,-1,-1,-1,-1,9,1,0,11,3,2,6,10,5,-1,-1,-1,-1,-1,-1,-1,6,10,5,2,9,1,2,11,9,11,8,9,-1,-1,-1,-1,11,3,6,3,5,6,3,1,5,-1,-1,-1,-1,-1,-1,-1,11,8,0,5,11,0,1,5,0,6,11,5,-1,-1,-1,-1,6,11,3,6,3,0,5,6,0,9,5,0,-1,-1,-1,-1,9,5,6,11,9,6,8,9,11,-1,-1,-1,-1,-1,-1,-1,6,10,5,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,4,3,7,4,10,5,6,-1,-1,-1,-1,-1,-1,-1,0,9,1,6,10,5,7,4,8,-1,-1,-1,-1,-1,-1,-1,5,6,10,7,9,1,3,7,1,4,9,7,-1,-1,-1,-1,2,1,6,1,5,6,8,7,4,-1,-1,-1,-1,-1,-1,-1,5,2,1,6,2,5,4,0,3,7,4,3,-1,-1,-1,-1,7,4,8,5,0,9,5,6,0,6,2,0,-1,-1,-1,-1,9,3,7,4,9,7,9,2,3,6,9,5,9,6,2,-1,2,11,3,4,8,7,5,6,10,-1,-1,-1,-1,-1,-1,-1,6,10,5,2,7,4,0,2,4,11,7,2,-1,-1,-1,-1,9,1,0,8,7,4,11,3,2,6,10,5,-1,-1,-1,-1,1,2,9,2,11,9,11,4,9,4,11,7,6,10,5,-1,7,4,8,5,11,3,1,5,3,6,11,5,-1,-1,-1,-1,11,1,5,6,11,5,11,0,1,4,11,7,11,4,0,-1,9,5,0,5,6,0,6,3,0,3,6,11,7,4,8,-1,9,5,6,11,9,6,9,7,4,9,11,7,-1,-1,-1,-1,9,4,10,10,4,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,10,4,10,9,4,3,8,0,-1,-1,-1,-1,-1,-1,-1,1,0,10,0,6,10,0,4,6,-1,-1,-1,-1,-1,-1,-1,1,3,8,6,1,8,4,6,8,10,1,6,-1,-1,-1,-1,9,4,1,4,2,1,4,6,2,-1,-1,-1,-1,-1,-1,-1,8,0,3,9,2,1,9,4,2,4,6,2,-1,-1,-1,-1,4,2,0,6,2,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,4,2,8,6,2,4,-1,-1,-1,-1,-1,-1,-1,9,4,10,4,6,10,3,2,11,-1,-1,-1,-1,-1,-1,-1,2,8,0,11,8,2,10,9,4,6,10,4,-1,-1,-1,-1,2,11,3,6,1,0,4,6,0,10,1,6,-1,-1,-1,-1,1,4,6,10,1,6,1,8,4,11,1,2,1,11,8,-1,4,6,9,6,3,9,3,1,9,3,6,11,-1,-1,-1,-1,1,11,8,0,1,8,1,6,11,4,1,9,1,4,6,-1,6,11,3,0,6,3,4,6,0,-1,-1,-1,-1,-1,-1,-1,8,4,6,8,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,10,7,10,8,7,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,7,0,7,10,0,10,9,0,10,7,6,-1,-1,-1,-1,7,6,10,7,10,1,8,7,1,0,8,1,-1,-1,-1,-1,7,6,10,1,7,10,3,7,1,-1,-1,-1,-1,-1,-1,-1,6,2,1,8,6,1,9,8,1,7,6,8,-1,-1,-1,-1,9,6,2,1,9,2,9,7,6,3,9,0,9,3,7,-1,0,8,7,6,0,7,2,0,6,-1,-1,-1,-1,-1,-1,-1,2,3,7,2,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,3,2,8,6,10,9,8,10,7,6,8,-1,-1,-1,-1,7,0,2,11,7,2,7,9,0,10,7,6,7,10,9,-1,0,8,1,8,7,1,7,10,1,10,7,6,11,3,2,-1,1,2,11,7,1,11,1,6,10,1,7,6,-1,-1,-1,-1,6,9,8,7,6,8,6,1,9,3,6,11,6,3,1,-1,1,9,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,6,0,7,0,11,3,0,6,11,-1,-1,-1,-1,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,3,6,7,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,6,7,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,8,1,3,8,6,7,11,-1,-1,-1,-1,-1,-1,-1,2,1,10,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,1,8,0,3,7,11,6,-1,-1,-1,-1,-1,-1,-1,0,9,2,9,10,2,7,11,6,-1,-1,-1,-1,-1,-1,-1,7,11,6,3,10,2,3,8,10,8,9,10,-1,-1,-1,-1,3,2,7,7,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,7,0,6,7,0,2,6,-1,-1,-1,-1,-1,-1,-1,6,7,2,7,3,2,9,1,0,-1,-1,-1,-1,-1,-1,-1,2,6,1,6,8,1,8,9,1,6,7,8,-1,-1,-1,-1,6,7,10,7,1,10,7,3,1,-1,-1,-1,-1,-1,-1,-1,6,7,10,10,7,1,7,8,1,8,0,1,-1,-1,-1,-1,7,3,0,10,7,0,9,10,0,7,10,6,-1,-1,-1,-1,10,6,7,8,10,7,9,10,8,-1,-1,-1,-1,-1,-1,-1,4,8,6,6,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,6,3,6,0,3,6,4,0,-1,-1,-1,-1,-1,-1,-1,11,6,8,6,4,8,1,0,9,-1,-1,-1,-1,-1,-1,-1,6,4,9,3,6,9,1,3,9,6,3,11,-1,-1,-1,-1,4,8,6,8,11,6,1,10,2,-1,-1,-1,-1,-1,-1,-1,10,2,1,11,0,3,11,6,0,6,4,0,-1,-1,-1,-1,8,11,4,11,6,4,9,2,0,9,10,2,-1,-1,-1,-1,3,9,10,2,3,10,3,4,9,6,3,11,3,6,4,-1,3,2,8,2,4,8,2,6,4,-1,-1,-1,-1,-1,-1,-1,2,4,0,2,6,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,4,3,2,6,4,2,8,3,4,-1,-1,-1,-1,4,9,1,2,4,1,6,4,2,-1,-1,-1,-1,-1,-1,-1,3,1,8,1,6,8,6,4,8,1,10,6,-1,-1,-1,-1,0,1,10,6,0,10,4,0,6,-1,-1,-1,-1,-1,-1,-1,3,6,4,8,3,4,3,10,6,9,3,0,3,9,10,-1,4,9,10,4,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,9,4,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,5,9,4,6,7,11,-1,-1,-1,-1,-1,-1,-1,1,0,5,0,4,5,11,6,7,-1,-1,-1,-1,-1,-1,-1,6,7,11,4,3,8,4,5,3,5,1,3,-1,-1,-1,-1,4,5,9,2,1,10,11,6,7,-1,-1,-1,-1,-1,-1,-1,7,11,6,10,2,1,3,8,0,5,9,4,-1,-1,-1,-1,11,6,7,10,4,5,10,2,4,2,0,4,-1,-1,-1,-1,8,4,3,4,5,3,5,2,3,2,5,10,6,7,11,-1,3,2,7,2,6,7,9,4,5,-1,-1,-1,-1,-1,-1,-1,4,5,9,6,8,0,2,6,0,7,8,6,-1,-1,-1,-1,2,6,3,6,7,3,0,5,1,0,4,5,-1,-1,-1,-1,8,2,6,7,8,6,8,1,2,5,8,4,8,5,1,-1,4,5,9,6,1,10,6,7,1,7,3,1,-1,-1,-1,-1,10,6,1,6,7,1,7,0,1,0,7,8,4,5,9,-1,10,0,4,5,10,4,10,3,0,7,10,6,10,7,3,-1,10,6,7,8,10,7,10,4,5,10,8,4,-1,-1,-1,-1,5,9,6,9,11,6,9,8,11,-1,-1,-1,-1,-1,-1,-1,11,6,3,3,6,0,6,5,0,5,9,0,-1,-1,-1,-1,8,11,0,11,5,0,5,1,0,11,6,5,-1,-1,-1,-1,3,11,6,5,3,6,1,3,5,-1,-1,-1,-1,-1,-1,-1,10,2,1,11,5,9,8,11,9,6,5,11,-1,-1,-1,-1,3,11,0,11,6,0,6,9,0,9,6,5,10,2,1,-1,5,8,11,6,5,11,5,0,8,2,5,10,5,2,0,-1,3,11,6,5,3,6,3,10,2,3,5,10,-1,-1,-1,-1,9,8,5,8,2,5,2,6,5,2,8,3,-1,-1,-1,-1,6,5,9,0,6,9,2,6,0,-1,-1,-1,-1,-1,-1,-1,8,5,1,0,8,1,8,6,5,2,8,3,8,2,6,-1,6,5,1,6,1,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,3,1,10,6,1,6,8,3,9,6,5,6,9,8,-1,0,1,10,6,0,10,0,5,9,0,6,5,-1,-1,-1,-1,8,3,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,5,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,11,11,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,11,5,7,11,0,3,8,-1,-1,-1,-1,-1,-1,-1,7,11,5,11,10,5,0,9,1,-1,-1,-1,-1,-1,-1,-1,5,7,10,7,11,10,1,8,9,1,3,8,-1,-1,-1,-1,2,1,11,1,7,11,1,5,7,-1,-1,-1,-1,-1,-1,-1,3,8,0,7,2,1,5,7,1,11,2,7,-1,-1,-1,-1,5,7,9,7,2,9,2,0,9,7,11,2,-1,-1,-1,-1,2,5,7,11,2,7,2,9,5,8,2,3,2,8,9,-1,10,5,2,5,3,2,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,2,8,2,5,8,5,7,8,5,2,10,-1,-1,-1,-1,1,0,9,3,10,5,7,3,5,2,10,3,-1,-1,-1,-1,2,8,9,1,2,9,2,7,8,5,2,10,2,5,7,-1,5,3,1,5,7,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,1,7,0,5,7,1,-1,-1,-1,-1,-1,-1,-1,3,0,9,5,3,9,7,3,5,-1,-1,-1,-1,-1,-1,-1,7,8,9,7,9,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,5,8,10,5,8,11,10,-1,-1,-1,-1,-1,-1,-1,4,0,5,0,11,5,11,10,5,0,3,11,-1,-1,-1,-1,9,1,0,10,4,8,11,10,8,5,4,10,-1,-1,-1,-1,4,11,10,5,4,10,4,3,11,1,4,9,4,1,3,-1,1,5,2,5,8,2,8,11,2,8,5,4,-1,-1,-1,-1,11,4,0,3,11,0,11,5,4,1,11,2,11,1,5,-1,5,2,0,9,5,0,5,11,2,8,5,4,5,8,11,-1,5,4,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,2,2,5,3,5,4,3,4,8,3,-1,-1,-1,-1,2,10,5,4,2,5,0,2,4,-1,-1,-1,-1,-1,-1,-1,2,10,3,10,5,3,5,8,3,8,5,4,9,1,0,-1,2,10,5,4,2,5,2,9,1,2,4,9,-1,-1,-1,-1,5,4,8,3,5,8,1,5,3,-1,-1,-1,-1,-1,-1,-1,5,4,0,5,0,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,4,8,3,5,8,5,0,9,5,3,0,-1,-1,-1,-1,5,4,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,11,4,11,9,4,11,10,9,-1,-1,-1,-1,-1,-1,-1,3,8,0,7,9,4,7,11,9,11,10,9,-1,-1,-1,-1,11,10,1,4,11,1,0,4,1,11,4,7,-1,-1,-1,-1,4,1,3,8,4,3,4,10,1,11,4,7,4,11,10,-1,7,11,4,4,11,9,11,2,9,2,1,9,-1,-1,-1,-1,4,7,9,7,11,9,11,1,9,1,11,2,3,8,0,-1,4,7,11,2,4,11,0,4,2,-1,-1,-1,-1,-1,-1,-1,4,7,11,2,4,11,4,3,8,4,2,3,-1,-1,-1,-1,10,9,2,9,7,2,7,3,2,9,4,7,-1,-1,-1,-1,7,10,9,4,7,9,7,2,10,0,7,8,7,0,2,-1,10,7,3,2,10,3,10,4,7,0,10,1,10,0,4,-1,2,10,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,4,7,1,4,3,1,7,-1,-1,-1,-1,-1,-1,-1,1,9,4,7,1,4,1,8,0,1,7,8,-1,-1,-1,-1,3,0,4,3,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,10,9,8,11,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,3,11,9,3,10,9,11,-1,-1,-1,-1,-1,-1,-1,10,1,0,8,10,0,11,10,8,-1,-1,-1,-1,-1,-1,-1,10,1,3,10,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,2,1,9,11,1,8,11,9,-1,-1,-1,-1,-1,-1,-1,9,0,3,11,9,3,9,2,1,9,11,2,-1,-1,-1,-1,11,2,0,11,0,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,2,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,10,8,2,9,8,10,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,10,8,2,8,1,0,8,10,1,-1,-1,-1,-1,2,10,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,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]),numTrisTable:new Float32Array([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,2,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,2,3,4,4,3,3,4,4,3,4,5,5,2,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,4,2,3,3,4,3,4,2,3,3,4,4,5,4,5,3,2,3,4,4,3,4,5,3,2,4,5,5,4,5,2,4,1,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,4,3,4,4,5,3,2,4,3,4,3,5,2,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,4,3,4,4,3,4,5,5,4,4,3,5,2,5,4,2,1,2,3,3,4,3,4,4,5,3,4,4,5,2,3,3,2,3,4,4,5,4,5,5,2,4,3,5,4,3,2,4,1,3,4,4,5,4,5,3,4,4,5,5,2,3,4,2,1,2,3,3,2,3,4,2,1,3,2,4,1,2,1,1,0])}}var Bl=new dR,Md=class{constructor(){this.pyramidPassScene=new mR;this.pyramidPassMaterial=new On({name:"PyramidPass"});this.pyramidPassUniforms={inputTexture:{value:void 0},inputWidth:{value:0},inputHeight:{value:0},inputShiftX:{value:0},outputShiftX:{value:0}};this.pyramidTopLevelReadPixelBuffer=new Float32Array(4);let r=`
3606
+ `,triTable:new Float32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,1,1,8,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,10,2,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,9,9,2,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,2,8,10,2,8,9,10,-1,-1,-1,-1,-1,-1,-1,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,0,0,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,11,3,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,1,11,9,1,11,8,9,-1,-1,-1,-1,-1,-1,-1,1,10,3,3,10,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,10,0,10,8,0,10,11,8,-1,-1,-1,-1,-1,-1,-1,0,9,3,9,11,3,9,10,11,-1,-1,-1,-1,-1,-1,-1,10,8,9,11,8,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,4,4,3,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,7,4,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,4,1,7,4,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,2,1,7,4,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,4,3,4,0,3,10,2,1,-1,-1,-1,-1,-1,-1,-1,10,2,9,2,0,9,7,4,8,-1,-1,-1,-1,-1,-1,-1,9,10,2,7,9,2,3,7,2,4,9,7,-1,-1,-1,-1,7,4,8,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,4,11,4,2,11,4,0,2,-1,-1,-1,-1,-1,-1,-1,1,0,9,7,4,8,11,3,2,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,9,2,11,9,1,2,9,-1,-1,-1,-1,1,10,3,10,11,3,4,8,7,-1,-1,-1,-1,-1,-1,-1,10,11,1,11,4,1,4,0,1,4,11,7,-1,-1,-1,-1,8,7,4,11,0,9,10,11,9,3,0,11,-1,-1,-1,-1,11,7,4,9,11,4,10,11,9,-1,-1,-1,-1,-1,-1,-1,4,5,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,9,3,8,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,0,0,5,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,8,5,3,8,5,1,3,-1,-1,-1,-1,-1,-1,-1,10,2,1,4,5,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,3,10,2,1,5,9,4,-1,-1,-1,-1,-1,-1,-1,10,2,5,2,4,5,2,0,4,-1,-1,-1,-1,-1,-1,-1,5,10,2,5,2,3,4,5,3,8,4,3,-1,-1,-1,-1,4,5,9,11,3,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,0,11,8,0,5,9,4,-1,-1,-1,-1,-1,-1,-1,4,5,0,5,1,0,11,3,2,-1,-1,-1,-1,-1,-1,-1,5,1,2,8,5,2,11,8,2,5,8,4,-1,-1,-1,-1,11,3,10,3,1,10,4,5,9,-1,-1,-1,-1,-1,-1,-1,5,9,4,1,8,0,1,10,8,10,11,8,-1,-1,-1,-1,0,4,5,11,0,5,10,11,5,3,0,11,-1,-1,-1,-1,8,4,5,10,8,5,11,8,10,-1,-1,-1,-1,-1,-1,-1,8,7,9,9,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,9,3,5,9,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,7,0,7,1,0,7,5,1,-1,-1,-1,-1,-1,-1,-1,3,5,1,7,5,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,7,9,7,5,9,2,1,10,-1,-1,-1,-1,-1,-1,-1,2,1,10,0,5,9,0,3,5,3,7,5,-1,-1,-1,-1,2,0,8,5,2,8,7,5,8,2,5,10,-1,-1,-1,-1,5,10,2,3,5,2,7,5,3,-1,-1,-1,-1,-1,-1,-1,5,9,7,9,8,7,2,11,3,-1,-1,-1,-1,-1,-1,-1,7,5,9,2,7,9,0,2,9,11,7,2,-1,-1,-1,-1,11,3,2,8,1,0,8,7,1,7,5,1,-1,-1,-1,-1,1,2,11,7,1,11,5,1,7,-1,-1,-1,-1,-1,-1,-1,8,5,9,7,5,8,3,1,10,11,3,10,-1,-1,-1,-1,0,7,5,9,0,5,0,11,7,10,0,1,0,10,11,-1,0,10,11,3,0,11,0,5,10,7,0,8,0,7,5,-1,5,10,11,5,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,6,10,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,0,9,6,10,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,1,8,9,1,6,10,5,-1,-1,-1,-1,-1,-1,-1,5,6,1,1,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,6,1,6,2,1,8,0,3,-1,-1,-1,-1,-1,-1,-1,5,6,9,6,0,9,6,2,0,-1,-1,-1,-1,-1,-1,-1,8,9,5,2,8,5,6,2,5,8,2,3,-1,-1,-1,-1,11,3,2,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,11,0,2,11,5,6,10,-1,-1,-1,-1,-1,-1,-1,9,1,0,11,3,2,6,10,5,-1,-1,-1,-1,-1,-1,-1,6,10,5,2,9,1,2,11,9,11,8,9,-1,-1,-1,-1,11,3,6,3,5,6,3,1,5,-1,-1,-1,-1,-1,-1,-1,11,8,0,5,11,0,1,5,0,6,11,5,-1,-1,-1,-1,6,11,3,6,3,0,5,6,0,9,5,0,-1,-1,-1,-1,9,5,6,11,9,6,8,9,11,-1,-1,-1,-1,-1,-1,-1,6,10,5,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,4,3,7,4,10,5,6,-1,-1,-1,-1,-1,-1,-1,0,9,1,6,10,5,7,4,8,-1,-1,-1,-1,-1,-1,-1,5,6,10,7,9,1,3,7,1,4,9,7,-1,-1,-1,-1,2,1,6,1,5,6,8,7,4,-1,-1,-1,-1,-1,-1,-1,5,2,1,6,2,5,4,0,3,7,4,3,-1,-1,-1,-1,7,4,8,5,0,9,5,6,0,6,2,0,-1,-1,-1,-1,9,3,7,4,9,7,9,2,3,6,9,5,9,6,2,-1,2,11,3,4,8,7,5,6,10,-1,-1,-1,-1,-1,-1,-1,6,10,5,2,7,4,0,2,4,11,7,2,-1,-1,-1,-1,9,1,0,8,7,4,11,3,2,6,10,5,-1,-1,-1,-1,1,2,9,2,11,9,11,4,9,4,11,7,6,10,5,-1,7,4,8,5,11,3,1,5,3,6,11,5,-1,-1,-1,-1,11,1,5,6,11,5,11,0,1,4,11,7,11,4,0,-1,9,5,0,5,6,0,6,3,0,3,6,11,7,4,8,-1,9,5,6,11,9,6,9,7,4,9,11,7,-1,-1,-1,-1,9,4,10,10,4,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,10,4,10,9,4,3,8,0,-1,-1,-1,-1,-1,-1,-1,1,0,10,0,6,10,0,4,6,-1,-1,-1,-1,-1,-1,-1,1,3,8,6,1,8,4,6,8,10,1,6,-1,-1,-1,-1,9,4,1,4,2,1,4,6,2,-1,-1,-1,-1,-1,-1,-1,8,0,3,9,2,1,9,4,2,4,6,2,-1,-1,-1,-1,4,2,0,6,2,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,4,2,8,6,2,4,-1,-1,-1,-1,-1,-1,-1,9,4,10,4,6,10,3,2,11,-1,-1,-1,-1,-1,-1,-1,2,8,0,11,8,2,10,9,4,6,10,4,-1,-1,-1,-1,2,11,3,6,1,0,4,6,0,10,1,6,-1,-1,-1,-1,1,4,6,10,1,6,1,8,4,11,1,2,1,11,8,-1,4,6,9,6,3,9,3,1,9,3,6,11,-1,-1,-1,-1,1,11,8,0,1,8,1,6,11,4,1,9,1,4,6,-1,6,11,3,0,6,3,4,6,0,-1,-1,-1,-1,-1,-1,-1,8,4,6,8,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,10,7,10,8,7,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,7,0,7,10,0,10,9,0,10,7,6,-1,-1,-1,-1,7,6,10,7,10,1,8,7,1,0,8,1,-1,-1,-1,-1,7,6,10,1,7,10,3,7,1,-1,-1,-1,-1,-1,-1,-1,6,2,1,8,6,1,9,8,1,7,6,8,-1,-1,-1,-1,9,6,2,1,9,2,9,7,6,3,9,0,9,3,7,-1,0,8,7,6,0,7,2,0,6,-1,-1,-1,-1,-1,-1,-1,2,3,7,2,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,3,2,8,6,10,9,8,10,7,6,8,-1,-1,-1,-1,7,0,2,11,7,2,7,9,0,10,7,6,7,10,9,-1,0,8,1,8,7,1,7,10,1,10,7,6,11,3,2,-1,1,2,11,7,1,11,1,6,10,1,7,6,-1,-1,-1,-1,6,9,8,7,6,8,6,1,9,3,6,11,6,3,1,-1,1,9,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,6,0,7,0,11,3,0,6,11,-1,-1,-1,-1,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,3,6,7,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,6,7,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,8,1,3,8,6,7,11,-1,-1,-1,-1,-1,-1,-1,2,1,10,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,1,8,0,3,7,11,6,-1,-1,-1,-1,-1,-1,-1,0,9,2,9,10,2,7,11,6,-1,-1,-1,-1,-1,-1,-1,7,11,6,3,10,2,3,8,10,8,9,10,-1,-1,-1,-1,3,2,7,7,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,7,0,6,7,0,2,6,-1,-1,-1,-1,-1,-1,-1,6,7,2,7,3,2,9,1,0,-1,-1,-1,-1,-1,-1,-1,2,6,1,6,8,1,8,9,1,6,7,8,-1,-1,-1,-1,6,7,10,7,1,10,7,3,1,-1,-1,-1,-1,-1,-1,-1,6,7,10,10,7,1,7,8,1,8,0,1,-1,-1,-1,-1,7,3,0,10,7,0,9,10,0,7,10,6,-1,-1,-1,-1,10,6,7,8,10,7,9,10,8,-1,-1,-1,-1,-1,-1,-1,4,8,6,6,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,6,3,6,0,3,6,4,0,-1,-1,-1,-1,-1,-1,-1,11,6,8,6,4,8,1,0,9,-1,-1,-1,-1,-1,-1,-1,6,4,9,3,6,9,1,3,9,6,3,11,-1,-1,-1,-1,4,8,6,8,11,6,1,10,2,-1,-1,-1,-1,-1,-1,-1,10,2,1,11,0,3,11,6,0,6,4,0,-1,-1,-1,-1,8,11,4,11,6,4,9,2,0,9,10,2,-1,-1,-1,-1,3,9,10,2,3,10,3,4,9,6,3,11,3,6,4,-1,3,2,8,2,4,8,2,6,4,-1,-1,-1,-1,-1,-1,-1,2,4,0,2,6,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,4,3,2,6,4,2,8,3,4,-1,-1,-1,-1,4,9,1,2,4,1,6,4,2,-1,-1,-1,-1,-1,-1,-1,3,1,8,1,6,8,6,4,8,1,10,6,-1,-1,-1,-1,0,1,10,6,0,10,4,0,6,-1,-1,-1,-1,-1,-1,-1,3,6,4,8,3,4,3,10,6,9,3,0,3,9,10,-1,4,9,10,4,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,9,4,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,5,9,4,6,7,11,-1,-1,-1,-1,-1,-1,-1,1,0,5,0,4,5,11,6,7,-1,-1,-1,-1,-1,-1,-1,6,7,11,4,3,8,4,5,3,5,1,3,-1,-1,-1,-1,4,5,9,2,1,10,11,6,7,-1,-1,-1,-1,-1,-1,-1,7,11,6,10,2,1,3,8,0,5,9,4,-1,-1,-1,-1,11,6,7,10,4,5,10,2,4,2,0,4,-1,-1,-1,-1,8,4,3,4,5,3,5,2,3,2,5,10,6,7,11,-1,3,2,7,2,6,7,9,4,5,-1,-1,-1,-1,-1,-1,-1,4,5,9,6,8,0,2,6,0,7,8,6,-1,-1,-1,-1,2,6,3,6,7,3,0,5,1,0,4,5,-1,-1,-1,-1,8,2,6,7,8,6,8,1,2,5,8,4,8,5,1,-1,4,5,9,6,1,10,6,7,1,7,3,1,-1,-1,-1,-1,10,6,1,6,7,1,7,0,1,0,7,8,4,5,9,-1,10,0,4,5,10,4,10,3,0,7,10,6,10,7,3,-1,10,6,7,8,10,7,10,4,5,10,8,4,-1,-1,-1,-1,5,9,6,9,11,6,9,8,11,-1,-1,-1,-1,-1,-1,-1,11,6,3,3,6,0,6,5,0,5,9,0,-1,-1,-1,-1,8,11,0,11,5,0,5,1,0,11,6,5,-1,-1,-1,-1,3,11,6,5,3,6,1,3,5,-1,-1,-1,-1,-1,-1,-1,10,2,1,11,5,9,8,11,9,6,5,11,-1,-1,-1,-1,3,11,0,11,6,0,6,9,0,9,6,5,10,2,1,-1,5,8,11,6,5,11,5,0,8,2,5,10,5,2,0,-1,3,11,6,5,3,6,3,10,2,3,5,10,-1,-1,-1,-1,9,8,5,8,2,5,2,6,5,2,8,3,-1,-1,-1,-1,6,5,9,0,6,9,2,6,0,-1,-1,-1,-1,-1,-1,-1,8,5,1,0,8,1,8,6,5,2,8,3,8,2,6,-1,6,5,1,6,1,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,3,1,10,6,1,6,8,3,9,6,5,6,9,8,-1,0,1,10,6,0,10,0,5,9,0,6,5,-1,-1,-1,-1,8,3,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,5,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,11,11,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,11,5,7,11,0,3,8,-1,-1,-1,-1,-1,-1,-1,7,11,5,11,10,5,0,9,1,-1,-1,-1,-1,-1,-1,-1,5,7,10,7,11,10,1,8,9,1,3,8,-1,-1,-1,-1,2,1,11,1,7,11,1,5,7,-1,-1,-1,-1,-1,-1,-1,3,8,0,7,2,1,5,7,1,11,2,7,-1,-1,-1,-1,5,7,9,7,2,9,2,0,9,7,11,2,-1,-1,-1,-1,2,5,7,11,2,7,2,9,5,8,2,3,2,8,9,-1,10,5,2,5,3,2,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,2,8,2,5,8,5,7,8,5,2,10,-1,-1,-1,-1,1,0,9,3,10,5,7,3,5,2,10,3,-1,-1,-1,-1,2,8,9,1,2,9,2,7,8,5,2,10,2,5,7,-1,5,3,1,5,7,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,1,7,0,5,7,1,-1,-1,-1,-1,-1,-1,-1,3,0,9,5,3,9,7,3,5,-1,-1,-1,-1,-1,-1,-1,7,8,9,7,9,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,5,8,10,5,8,11,10,-1,-1,-1,-1,-1,-1,-1,4,0,5,0,11,5,11,10,5,0,3,11,-1,-1,-1,-1,9,1,0,10,4,8,11,10,8,5,4,10,-1,-1,-1,-1,4,11,10,5,4,10,4,3,11,1,4,9,4,1,3,-1,1,5,2,5,8,2,8,11,2,8,5,4,-1,-1,-1,-1,11,4,0,3,11,0,11,5,4,1,11,2,11,1,5,-1,5,2,0,9,5,0,5,11,2,8,5,4,5,8,11,-1,5,4,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,2,2,5,3,5,4,3,4,8,3,-1,-1,-1,-1,2,10,5,4,2,5,0,2,4,-1,-1,-1,-1,-1,-1,-1,2,10,3,10,5,3,5,8,3,8,5,4,9,1,0,-1,2,10,5,4,2,5,2,9,1,2,4,9,-1,-1,-1,-1,5,4,8,3,5,8,1,5,3,-1,-1,-1,-1,-1,-1,-1,5,4,0,5,0,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,4,8,3,5,8,5,0,9,5,3,0,-1,-1,-1,-1,5,4,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,11,4,11,9,4,11,10,9,-1,-1,-1,-1,-1,-1,-1,3,8,0,7,9,4,7,11,9,11,10,9,-1,-1,-1,-1,11,10,1,4,11,1,0,4,1,11,4,7,-1,-1,-1,-1,4,1,3,8,4,3,4,10,1,11,4,7,4,11,10,-1,7,11,4,4,11,9,11,2,9,2,1,9,-1,-1,-1,-1,4,7,9,7,11,9,11,1,9,1,11,2,3,8,0,-1,4,7,11,2,4,11,0,4,2,-1,-1,-1,-1,-1,-1,-1,4,7,11,2,4,11,4,3,8,4,2,3,-1,-1,-1,-1,10,9,2,9,7,2,7,3,2,9,4,7,-1,-1,-1,-1,7,10,9,4,7,9,7,2,10,0,7,8,7,0,2,-1,10,7,3,2,10,3,10,4,7,0,10,1,10,0,4,-1,2,10,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,4,7,1,4,3,1,7,-1,-1,-1,-1,-1,-1,-1,1,9,4,7,1,4,1,8,0,1,7,8,-1,-1,-1,-1,3,0,4,3,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,10,9,8,11,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,3,11,9,3,10,9,11,-1,-1,-1,-1,-1,-1,-1,10,1,0,8,10,0,11,10,8,-1,-1,-1,-1,-1,-1,-1,10,1,3,10,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,2,1,9,11,1,8,11,9,-1,-1,-1,-1,-1,-1,-1,9,0,3,11,9,3,9,2,1,9,11,2,-1,-1,-1,-1,11,2,0,11,0,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,2,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,10,8,2,9,8,10,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,10,8,2,8,1,0,8,10,1,-1,-1,-1,-1,2,10,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,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]),numTrisTable:new Float32Array([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,2,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,2,3,4,4,3,3,4,4,3,4,5,5,2,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,4,2,3,3,4,3,4,2,3,3,4,4,5,4,5,3,2,3,4,4,3,4,5,3,2,4,5,5,4,5,2,4,1,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,4,3,4,4,5,3,2,4,3,4,3,5,2,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,4,3,4,4,3,4,5,5,4,4,3,5,2,5,4,2,1,2,3,3,4,3,4,4,5,3,4,4,5,2,3,3,2,3,4,4,5,4,5,5,2,4,3,5,4,3,2,4,1,3,4,4,5,4,5,3,4,4,5,5,2,3,4,2,1,2,3,3,2,3,4,2,1,3,2,4,1,2,1,1,0])}}var Bl=new sL,Dd=class{constructor(){this.pyramidPassScene=new dL;this.pyramidPassMaterial=new On({name:"PyramidPass"});this.pyramidPassUniforms={inputTexture:{value:void 0},inputWidth:{value:0},inputHeight:{value:0},inputShiftX:{value:0},outputShiftX:{value:0}};this.pyramidTopLevelReadPixelBuffer=new Float32Array(4);let r=`
3607
3607
  precision highp float;
3608
3608
  precision highp sampler2D;
3609
3609
  layout(location = 0) out vec4 pc_FragColor;
@@ -3643,13 +3643,13 @@ void main() {
3643
3643
  pc_FragColor.g = pc_FragColor.b + tr;
3644
3644
  pc_FragColor.r = pc_FragColor.g + tl;
3645
3645
  }
3646
- `;this.pyramidPassMaterial.fragmentShader=r,this.pyramidPassMaterial.uniforms=this.pyramidPassUniforms,this.pyramidPassMaterial.depthTest=!1,this.pyramidPassMaterial.depthWrite=!1;let e=new fR(ws,this.pyramidPassMaterial);e.frustumCulled=!1,this.pyramidPassScene.add(e)}renderPyramid(r,e,t,o,n){new lR().min.setScalar(0);let s=e.length-1,l=new yR;t.getViewport(l),this.pyramidPassUniforms.inputShiftX.value=0,this.pyramidPassUniforms.outputShiftX.value=0;let c=s-1;for(let p=c;p>=0;p--){let d=p%2===c%2?n[0]:n[1],f=p===c?o:p%2===c%2?n[1]:n[0];this.pyramidPassUniforms.inputTexture.value=Array.isArray(f.texture)?f.texture[1]:f.texture,this.pyramidPassUniforms.inputWidth.value=f.width,this.pyramidPassUniforms.inputHeight.value=f.height,t.setRenderTarget(d);let h=e[p],m=t.getPixelRatio();t.setViewport(this.pyramidPassUniforms.outputShiftX.value/m,0,h/m,h/m),p===2&&r%2!==0&&t.setViewport(this.pyramidPassUniforms.outputShiftX.value/m,0,3/m,3/m),t.render(this.pyramidPassScene,Bl);let y=this.pyramidPassUniforms.inputShiftX.value;this.pyramidPassUniforms.inputShiftX.value=this.pyramidPassUniforms.outputShiftX.value,this.pyramidPassUniforms.outputShiftX.value=y,p<c&&(this.pyramidPassUniforms.outputShiftX.value+=e[p+1])}t.setViewport(l);let u=e.length%2===0?0:1;return t.readRenderTargetPixelsAsync(n[u],n[u].width-1,0,1,1,this.pyramidTopLevelReadPixelBuffer).then(()=>this.pyramidTopLevelReadPixelBuffer[0])}};var Xr=24,kt=96,wo=iS(),Zo=2,rm=class extends et{constructor(e,t,o){super(e,t,o);this.data=t;this.needsRebuild=!0;this.customDepthMaterialNeedsUpdate=!1;this._npart=-1;this.spatialn=1;this.drawRangeNeedsForceUpdate=!0;this._resolutionLevel=-1;this.resolution=64;this.spatialDivisions=25;this.zLayersPerRow=8;this.basePyramidSize=512;this.pyramidTexture1Width=341;this.pyramidTexture1Height=256;this.pyramidTexture2Width=170;this.pyramidTexture2Height=128;this.numLevels=9;this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512];this.bboxSize=0;this.bboxOffset=0;this.shapesDataTexture={value:void 0};this.spatialscene=new Jh;this.potentialPassScene=new Jh;this.voxelPassScene=new Jh;this._spatialPassRenderTargets=[];this._potentialPassRenderTargets=[];this._voxelPassRenderTargets=[];this._pyramidRenderTargets=[];this.geometry=new aS,this.geometry.drawRange.count=0,this.spatialPassUniforms={span:{value:-1},shapesDataTexture:this.shapesDataTexture,npart:{value:this.npart},spatialn:{value:this.spatialn}},this.spatialMesh=new Qh(ws,this.spatialPassMaterial()),this.spatialMesh.frustumCulled=!1,this.spatialscene.add(this.spatialMesh);let n=new tm(wo.triTable,16,256,Zh,Jo);n.needsUpdate=!0;let a=new tm(wo.numTrisTable,256,1,Zh,Jo);a.needsUpdate=!0,this.voxelPassUniforms={potentialPassTexture:{value:void 0},numTrisTable:{value:a}},this.voxelMesh=new Qh(ws,this.voxelPassMaterial()),this.voxelMesh.frustumCulled=!1,this.voxelPassScene.add(this.voxelMesh),this.potentialPassUniforms={shapesDataTexture:this.shapesDataTexture,spatialPassTexture:{value:void 0},npart:{value:this.npart},spatialn:{value:this.spatialn}},this.potentialMesh=new Qh(ws,this.potentialPassMaterial()),this.potentialMesh.frustumCulled=!1,this.potentialPassScene.add(this.potentialMesh),this.marchPassUniforms={triTable:{value:n},potentialPassTexture:{value:void 0},voxelPassTexture:{value:void 0},pyramidTexture1:{value:void 0},pyramidTexture1Size:{value:void 0},pyramidTexture2:{value:void 0},pyramidTexture2Size:{value:void 0}},this.frustumCulled=!1,this.onBeforeShadowPass=s=>{if(PR.call(this),this.npart===0){this.geometry.drawRange.count=0;return}let l=this.material.root;if(!l.shadersPatchedForShapeBlend)this.patchVertexShaderForShapeBlend(l),l.shadersPatchedForShapeBlend=!0,this.customDepthMaterialNeedsUpdate=!0;else if(this.customDepthMaterialNeedsUpdate){this.customDepthMaterialNeedsUpdate=!1,this.customDepthMaterial=new sS({vertexShader:l.vertexShader,fragmentShader:`
3646
+ `;this.pyramidPassMaterial.fragmentShader=r,this.pyramidPassMaterial.uniforms=this.pyramidPassUniforms,this.pyramidPassMaterial.depthTest=!1,this.pyramidPassMaterial.depthWrite=!1;let e=new cL(ws,this.pyramidPassMaterial);e.frustumCulled=!1,this.pyramidPassScene.add(e)}renderPyramid(r,e,t,o,n){new iL().min.setScalar(0);let s=e.length-1,l=new pL;t.getViewport(l),this.pyramidPassUniforms.inputShiftX.value=0,this.pyramidPassUniforms.outputShiftX.value=0;let c=s-1;for(let p=c;p>=0;p--){let d=p%2===c%2?n[0]:n[1],f=p===c?o:p%2===c%2?n[1]:n[0];this.pyramidPassUniforms.inputTexture.value=Array.isArray(f.texture)?f.texture[1]:f.texture,this.pyramidPassUniforms.inputWidth.value=f.width,this.pyramidPassUniforms.inputHeight.value=f.height,t.setRenderTarget(d);let h=e[p],m=t.getPixelRatio();t.setViewport(this.pyramidPassUniforms.outputShiftX.value/m,0,h/m,h/m),p===2&&r%2!==0&&t.setViewport(this.pyramidPassUniforms.outputShiftX.value/m,0,3/m,3/m),t.render(this.pyramidPassScene,Bl);let y=this.pyramidPassUniforms.inputShiftX.value;this.pyramidPassUniforms.inputShiftX.value=this.pyramidPassUniforms.outputShiftX.value,this.pyramidPassUniforms.outputShiftX.value=y,p<c&&(this.pyramidPassUniforms.outputShiftX.value+=e[p+1])}t.setViewport(l);let u=e.length%2===0?0:1;return t.readRenderTargetPixelsAsync(n[u],n[u].width-1,0,1,1,this.pyramidTopLevelReadPixelBuffer).then(()=>this.pyramidTopLevelReadPixelBuffer[0])}};var Xr=24,kt=96,wo=PS(),Zo=2,um=class extends et{constructor(e,t,o){super(e,t,o);this.data=t;this.needsRebuild=!0;this.customDepthMaterialNeedsUpdate=!1;this._npart=-1;this.spatialn=1;this.drawRangeNeedsForceUpdate=!0;this._resolutionLevel=-1;this.resolution=64;this.spatialDivisions=25;this.zLayersPerRow=8;this.basePyramidSize=512;this.pyramidTexture1Width=341;this.pyramidTexture1Height=256;this.pyramidTexture2Width=170;this.pyramidTexture2Height=128;this.numLevels=9;this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512];this.bboxSize=0;this.bboxOffset=0;this.shapesDataTexture={value:void 0};this.spatialscene=new sm;this.potentialPassScene=new sm;this.voxelPassScene=new sm;this._spatialPassRenderTargets=[];this._potentialPassRenderTargets=[];this._voxelPassRenderTargets=[];this._pyramidRenderTargets=[];this.geometry=new TS,this.geometry.drawRange.count=0,this.spatialPassUniforms={span:{value:-1},shapesDataTexture:this.shapesDataTexture,npart:{value:this.npart},spatialn:{value:this.spatialn}},this.spatialMesh=new nm(ws,this.spatialPassMaterial()),this.spatialMesh.frustumCulled=!1,this.spatialscene.add(this.spatialMesh);let n=new cm(wo.triTable,16,256,am,Jo);n.needsUpdate=!0;let a=new cm(wo.numTrisTable,256,1,am,Jo);a.needsUpdate=!0,this.voxelPassUniforms={potentialPassTexture:{value:void 0},numTrisTable:{value:a}},this.voxelMesh=new nm(ws,this.voxelPassMaterial()),this.voxelMesh.frustumCulled=!1,this.voxelPassScene.add(this.voxelMesh),this.potentialPassUniforms={shapesDataTexture:this.shapesDataTexture,spatialPassTexture:{value:void 0},npart:{value:this.npart},spatialn:{value:this.spatialn}},this.potentialMesh=new nm(ws,this.potentialPassMaterial()),this.potentialMesh.frustumCulled=!1,this.potentialPassScene.add(this.potentialMesh),this.marchPassUniforms={triTable:{value:n},potentialPassTexture:{value:void 0},voxelPassTexture:{value:void 0},pyramidTexture1:{value:void 0},pyramidTexture1Size:{value:void 0},pyramidTexture2:{value:void 0},pyramidTexture2Size:{value:void 0}},this.frustumCulled=!1,this.onBeforeShadowPass=s=>{if(bL.call(this),this.npart===0){this.geometry.drawRange.count=0;return}let l=this.material.root;if(!l.shadersPatchedForShapeBlend)this.patchVertexShaderForShapeBlend(l),l.shadersPatchedForShapeBlend=!0,this.customDepthMaterialNeedsUpdate=!0;else if(this.customDepthMaterialNeedsUpdate){this.customDepthMaterialNeedsUpdate=!1,this.customDepthMaterial=new CS({vertexShader:l.vertexShader,fragmentShader:`
3647
3647
  #include <packing>
3648
3648
  void main()
3649
3649
  {
3650
3650
  gl_FragColor = packDepthToRGBA(gl_FragCoord.z);
3651
3651
  }
3652
- `,uniforms:l.uniforms,defines:this.material.defines}),this.isMeshDepthMaterial=!0,this.customDistanceMaterial=new sS({vertexShader:l.vertexShader,fragmentShader:`
3652
+ `,uniforms:l.uniforms,defines:this.material.defines}),this.isMeshDepthMaterial=!0,this.customDistanceMaterial=new CS({vertexShader:l.vertexShader,fragmentShader:`
3653
3653
  #include <common>
3654
3654
  #include <packing>
3655
3655
  uniform vec3 referencePosition;
@@ -3664,7 +3664,7 @@ void main() {
3664
3664
  dist = saturate(dist);
3665
3665
  // Required by Three.js for this to work
3666
3666
  gl_FragColor = packDepthToRGBA( dist );
3667
- }`,uniforms:{nearDistance:{value:0},farDistance:{value:0},referencePosition:{value:new Nd},opacity:{value:0},...l.uniforms},defines:this.material.defines});let p=this.customDistanceMaterial;p.referencePosition=new Nd,p.nearDistance=0,p.farDistance=0,p.opacity=1,p.isMeshDistanceMaterial=!0}if(this.spatialPassUniforms.npart.value=this.npart,this.spatialPassUniforms.spatialn.value=this.spatialn,this.potentialPassUniforms.npart.value=this.npart,this.potentialPassUniforms.spatialn.value=this.spatialn,this.needsRebuild){this.needsRebuild=!1,this.spatialMesh.material.defines.RES=this.resolutionLevel,this.spatialMesh.material.needsUpdate=!0,this.potentialMesh.material.defines.RES=this.resolutionLevel,this.potentialPassUniforms.spatialPassTexture.value=this.spatialPassRenderTarget.texture,this.potentialMesh.material.needsUpdate=!0,this.voxelMesh.material.defines.RES=this.resolutionLevel,this.voxelMesh.material.needsUpdate=!0,this.voxelPassUniforms.potentialPassTexture.value=this.potentialPassRenderTarget.texture,this.marchPassUniforms.potentialPassTexture.value=this.potentialPassRenderTarget.texture,this.marchPassUniforms.voxelPassTexture.value=this.voxelPassRenderTarget.texture[0],this.material.defines.RES=this.resolutionLevel,this.material.defines.LEVELS=this.pyramidLevelSizes.length,this.material.defines.LOOP=this.pyramidLevelSizes.length%2===0?this.pyramidLevelSizes.length-3:this.pyramidLevelSizes.length-2,this.material.defines.HALF=this.pyramidLevelSizes.length%2===0?1:0,this.material.needsUpdate=!0;let p=this.pyramidLevelSizes.length%2===0?0:1,d=this.pyramidLevelSizes.length%2===0?1:0;this.marchPassUniforms.pyramidTexture2.value=this.pyramidRenderTarget[p].texture,this.marchPassUniforms.pyramidTexture2Size.value=new em(this.pyramidRenderTarget[p].width,this.pyramidRenderTarget[p].height),this.marchPassUniforms.pyramidTexture1.value=this.pyramidRenderTarget[d].texture,this.marchPassUniforms.pyramidTexture1Size.value=new em(this.pyramidRenderTarget[d].width,this.pyramidRenderTarget[d].height),Object.assign(this.material.uniforms,this.marchPassUniforms)}let c=s.shadowMap.enabled;s.shadowMap.enabled=!1;let u=s.getRenderTarget();s.setRenderTarget(this.spatialPassRenderTarget),s.render(this.spatialscene,Bl),s.setRenderTarget(this.potentialPassRenderTarget),s.render(this.potentialPassScene,Bl),s.setRenderTarget(this.voxelPassRenderTarget),s.render(this.voxelPassScene,Bl),rm.streamCompaction.renderPyramid(this.resolutionLevel,this.pyramidLevelSizes,s,this.voxelPassRenderTarget,this.pyramidRenderTarget).then(p=>{this.material.wireframe&&(p*3>this.geometry.attributes.position.count||this.drawRangeNeedsForceUpdate)&&(this.geometry.dispose(),this.geometry=new aS,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]},this.geometry.attributes.position=new nS(new Float32Array(p*3*2),3)),(p*3>this.geometry.drawRange.count||this.drawRangeNeedsForceUpdate)&&(this.geometry.drawRange.count=Math.floor(p*1.2)*3),this.drawRangeNeedsForceUpdate=!1}),s.shadowMap.enabled=c,s.setRenderTarget(u)}}set npart(e){e!==this._npart&&(this.drawRangeNeedsForceUpdate=!0,this._npart=e,this.spatialn=Math.ceil(e/(4*Xr)))}get npart(){return this._npart}set resolutionLevel(e){let t=Math.min(8,Math.max(5,e));if(t!==this._resolutionLevel){switch(this._resolutionLevel=t,this.resolution=Math.pow(2,t),this.resolutionLevel){case 5:this.pyramidLevelSizes=[1,2,4,6,12,24,48,96,192],this.bboxSize=31*8*Zo,this.bboxOffset=8*Zo*-1/2;break;case 6:this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512],this.bboxSize=63*4*Zo,this.bboxOffset=4*Zo*-1/2;break;case 7:this.pyramidLevelSizes=[1,2,4,6,12,24,48,96,192,384,768,1536],this.bboxSize=127*2*Zo,this.bboxOffset=2*Zo*-1/2;break;case 8:this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512,1024,2048,4096],this.bboxSize=255*Zo,this.bboxOffset=Zo*-1/2;break}this.pyramidTexture1Width=0,this.pyramidTexture2Width=0,this.pyramidTexture1Height=this.pyramidLevelSizes[this.pyramidLevelSizes.length-2],this.pyramidTexture2Height=this.pyramidLevelSizes[this.pyramidLevelSizes.length-3];for(let o=this.pyramidLevelSizes.length-2;o>=0;o--)(this.pyramidLevelSizes.length-2)%2===o%2?this.pyramidTexture1Width+=this.pyramidLevelSizes[o]:this.pyramidTexture2Width+=this.pyramidLevelSizes[o];this.basePyramidSize=this.pyramidLevelSizes[this.pyramidLevelSizes.length-1],this.zLayersPerRow=this.basePyramidSize/this.resolution,this.numLevels=this.pyramidLevelSizes.length-1,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]},this.needsRebuild=!0,this.customDepthMaterialNeedsUpdate=!0}}get resolutionLevel(){return this._resolutionLevel}get spatialPassRenderTarget(){let e=this._spatialPassRenderTargets[this.resolutionLevel];return e||(e=new Id(this.spatialDivisions*this.spatialn,this.spatialDivisions**2,{format:Os,type:Jo,stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:So,magFilter:So}),this._spatialPassRenderTargets[this.resolutionLevel]=e),e}get potentialPassRenderTarget(){let e=this._potentialPassRenderTargets[this.resolutionLevel];return e||(e=new Id(this.basePyramidSize,this.basePyramidSize,{format:Os,type:Jo,stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:So,magFilter:So}),this._potentialPassRenderTargets[this.resolutionLevel]=e),e}get voxelPassRenderTarget(){let e=this._voxelPassRenderTargets[this.resolutionLevel];return e||(e=new xR(this.basePyramidSize,this.basePyramidSize,2,{stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:So,magFilter:So}),e.texture[0].format=Os,e.texture[0].type=Jo,e.texture[1].format=Zh,e.texture[1].type=Jo,this._voxelPassRenderTargets[this.resolutionLevel]=e),e}get pyramidRenderTarget(){let e=this._pyramidRenderTargets[this.resolutionLevel];if(!e){let t=new Id(this.pyramidTexture1Width,this.pyramidTexture1Height,{format:Os,type:Jo,stencilBuffer:!1,depthBuffer:!1,magFilter:So,minFilter:So}),o=new Id(this.pyramidTexture2Width,this.pyramidTexture2Height,{format:Os,type:Jo,stencilBuffer:!1,depthBuffer:!1,magFilter:So,minFilter:So});e=[t,o],this._pyramidRenderTargets[this.resolutionLevel]=e}return e}updateState(e,t){let o=this.material;super.updateState(e,t),o!==this.material&&(this.needsRebuild=!0),e.geometry&&(this.resolutionLevel=e.geometry.resolutionLevel,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]}),e.wireframe&&!this.geometry.getAttribute("position")?this.geometry.setAttribute("position",new nS(new Float32Array(this.geometry.drawRange.count*3),3)):!e.wireframe&&this.geometry.getAttribute("position")&&this.geometry.deleteAttribute("position")}spatialPassMaterial(){let e=`
3667
+ }`,uniforms:{nearDistance:{value:0},farDistance:{value:0},referencePosition:{value:new Ld},opacity:{value:0},...l.uniforms},defines:this.material.defines});let p=this.customDistanceMaterial;p.referencePosition=new Ld,p.nearDistance=0,p.farDistance=0,p.opacity=1,p.isMeshDistanceMaterial=!0}if(this.spatialPassUniforms.npart.value=this.npart,this.spatialPassUniforms.spatialn.value=this.spatialn,this.potentialPassUniforms.npart.value=this.npart,this.potentialPassUniforms.spatialn.value=this.spatialn,this.needsRebuild){this.needsRebuild=!1,this.spatialMesh.material.defines.RES=this.resolutionLevel,this.spatialMesh.material.needsUpdate=!0,this.potentialMesh.material.defines.RES=this.resolutionLevel,this.potentialPassUniforms.spatialPassTexture.value=this.spatialPassRenderTarget.texture,this.potentialMesh.material.needsUpdate=!0,this.voxelMesh.material.defines.RES=this.resolutionLevel,this.voxelMesh.material.needsUpdate=!0,this.voxelPassUniforms.potentialPassTexture.value=this.potentialPassRenderTarget.texture,this.marchPassUniforms.potentialPassTexture.value=this.potentialPassRenderTarget.texture,this.marchPassUniforms.voxelPassTexture.value=this.voxelPassRenderTarget.texture[0],this.material.defines.RES=this.resolutionLevel,this.material.defines.LEVELS=this.pyramidLevelSizes.length,this.material.defines.LOOP=this.pyramidLevelSizes.length%2===0?this.pyramidLevelSizes.length-3:this.pyramidLevelSizes.length-2,this.material.defines.HALF=this.pyramidLevelSizes.length%2===0?1:0,this.material.needsUpdate=!0;let p=this.pyramidLevelSizes.length%2===0?0:1,d=this.pyramidLevelSizes.length%2===0?1:0;this.marchPassUniforms.pyramidTexture2.value=this.pyramidRenderTarget[p].texture,this.marchPassUniforms.pyramidTexture2Size.value=new lm(this.pyramidRenderTarget[p].width,this.pyramidRenderTarget[p].height),this.marchPassUniforms.pyramidTexture1.value=this.pyramidRenderTarget[d].texture,this.marchPassUniforms.pyramidTexture1Size.value=new lm(this.pyramidRenderTarget[d].width,this.pyramidRenderTarget[d].height),Object.assign(this.material.uniforms,this.marchPassUniforms)}let c=s.shadowMap.enabled;s.shadowMap.enabled=!1;let u=s.getRenderTarget();s.setRenderTarget(this.spatialPassRenderTarget),s.render(this.spatialscene,Bl),s.setRenderTarget(this.potentialPassRenderTarget),s.render(this.potentialPassScene,Bl),s.setRenderTarget(this.voxelPassRenderTarget),s.render(this.voxelPassScene,Bl),um.streamCompaction.renderPyramid(this.resolutionLevel,this.pyramidLevelSizes,s,this.voxelPassRenderTarget,this.pyramidRenderTarget).then(p=>{this.material.wireframe&&(p*3>this.geometry.attributes.position.count||this.drawRangeNeedsForceUpdate)&&(this.geometry.dispose(),this.geometry=new TS,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]},this.geometry.attributes.position=new OS(new Float32Array(p*3*2),3)),(p*3>this.geometry.drawRange.count||this.drawRangeNeedsForceUpdate)&&(this.geometry.drawRange.count=Math.floor(p*1.2)*3),this.drawRangeNeedsForceUpdate=!1}),s.shadowMap.enabled=c,s.setRenderTarget(u)}}set npart(e){e!==this._npart&&(this.drawRangeNeedsForceUpdate=!0,this._npart=e,this.spatialn=Math.ceil(e/(4*Xr)))}get npart(){return this._npart}set resolutionLevel(e){let t=Math.min(8,Math.max(5,e));if(t!==this._resolutionLevel){switch(this._resolutionLevel=t,this.resolution=Math.pow(2,t),this.resolutionLevel){case 5:this.pyramidLevelSizes=[1,2,4,6,12,24,48,96,192],this.bboxSize=31*8*Zo,this.bboxOffset=8*Zo*-1/2;break;case 6:this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512],this.bboxSize=63*4*Zo,this.bboxOffset=4*Zo*-1/2;break;case 7:this.pyramidLevelSizes=[1,2,4,6,12,24,48,96,192,384,768,1536],this.bboxSize=127*2*Zo,this.bboxOffset=2*Zo*-1/2;break;case 8:this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512,1024,2048,4096],this.bboxSize=255*Zo,this.bboxOffset=Zo*-1/2;break}this.pyramidTexture1Width=0,this.pyramidTexture2Width=0,this.pyramidTexture1Height=this.pyramidLevelSizes[this.pyramidLevelSizes.length-2],this.pyramidTexture2Height=this.pyramidLevelSizes[this.pyramidLevelSizes.length-3];for(let o=this.pyramidLevelSizes.length-2;o>=0;o--)(this.pyramidLevelSizes.length-2)%2===o%2?this.pyramidTexture1Width+=this.pyramidLevelSizes[o]:this.pyramidTexture2Width+=this.pyramidLevelSizes[o];this.basePyramidSize=this.pyramidLevelSizes[this.pyramidLevelSizes.length-1],this.zLayersPerRow=this.basePyramidSize/this.resolution,this.numLevels=this.pyramidLevelSizes.length-1,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]},this.needsRebuild=!0,this.customDepthMaterialNeedsUpdate=!0}}get resolutionLevel(){return this._resolutionLevel}get spatialPassRenderTarget(){let e=this._spatialPassRenderTargets[this.resolutionLevel];return e||(e=new _d(this.spatialDivisions*this.spatialn,this.spatialDivisions**2,{format:Os,type:Jo,stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:So,magFilter:So}),this._spatialPassRenderTargets[this.resolutionLevel]=e),e}get potentialPassRenderTarget(){let e=this._potentialPassRenderTargets[this.resolutionLevel];return e||(e=new _d(this.basePyramidSize,this.basePyramidSize,{format:Os,type:Jo,stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:So,magFilter:So}),this._potentialPassRenderTargets[this.resolutionLevel]=e),e}get voxelPassRenderTarget(){let e=this._voxelPassRenderTargets[this.resolutionLevel];return e||(e=new hL(this.basePyramidSize,this.basePyramidSize,2,{stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:So,magFilter:So}),e.texture[0].format=Os,e.texture[0].type=Jo,e.texture[1].format=am,e.texture[1].type=Jo,this._voxelPassRenderTargets[this.resolutionLevel]=e),e}get pyramidRenderTarget(){let e=this._pyramidRenderTargets[this.resolutionLevel];if(!e){let t=new _d(this.pyramidTexture1Width,this.pyramidTexture1Height,{format:Os,type:Jo,stencilBuffer:!1,depthBuffer:!1,magFilter:So,minFilter:So}),o=new _d(this.pyramidTexture2Width,this.pyramidTexture2Height,{format:Os,type:Jo,stencilBuffer:!1,depthBuffer:!1,magFilter:So,minFilter:So});e=[t,o],this._pyramidRenderTargets[this.resolutionLevel]=e}return e}updateState(e,t){let o=this.material;super.updateState(e,t),o!==this.material&&(this.needsRebuild=!0),e.geometry&&(this.resolutionLevel=e.geometry.resolutionLevel,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]}),e.wireframe&&!this.geometry.getAttribute("position")?this.geometry.setAttribute("position",new OS(new Float32Array(this.geometry.drawRange.count*3),3)):!e.wireframe&&this.geometry.getAttribute("position")&&this.geometry.deleteAttribute("position")}spatialPassMaterial(){let e=`
3668
3668
  precision highp float;
3669
3669
  out vec4 pc_FragColor;
3670
3670
  const float spatialDivisions = ${this.spatialDivisions}.;
@@ -4198,7 +4198,7 @@ void main() {
4198
4198
  ${n[0]}
4199
4199
  #endif
4200
4200
  `;e.fragmentShader=`in vec4 marchColor;
4201
- `+e.fragmentShader.replace(n[0],s),Object.assign(e.uniforms,this.marchPassUniforms)}initDebugPass(e){console.log("fboToDebug.width",e.width,e.height),this.geometry=new gR(e.width,e.height),this.geometry.userData={parameters:{width:4,height:4}};let t={inputTexture:{value:Array.isArray(e.texture)?e.texture[1]:e.texture},pyramidTextureSize:{value:void 0}},o=n=>{n.vertexShader=`
4201
+ `+e.fragmentShader.replace(n[0],s),Object.assign(e.uniforms,this.marchPassUniforms)}initDebugPass(e){console.log("fboToDebug.width",e.width,e.height),this.geometry=new fL(e.width,e.height),this.geometry.userData={parameters:{width:4,height:4}};let t={inputTexture:{value:Array.isArray(e.texture)?e.texture[1]:e.texture},pyramidTextureSize:{value:void 0}},o=n=>{n.vertexShader=`
4202
4202
  precision highp float;
4203
4203
 
4204
4204
  varying vec2 vUv;
@@ -4222,7 +4222,7 @@ void main() {
4222
4222
  gl_FragColor = texture(inputTexture, vUv);
4223
4223
  gVelocity = vec4(0.0);
4224
4224
  }
4225
- `,t.pyramidTextureSize.value=new em(this.pyramidRenderTarget.width,this.pyramidRenderTarget.height),Object.assign(n.uniforms,t)};this.material.shapeBlendhack=o,this.material.root.shapeBlendhack=o}},Bi=rm;Bi.streamCompaction=new Md;var bR=new lS,vR=new lS,Ps=new cS,zi=new Nd,Ed=new Nd,SR=new cS;function wR(i,r=0){let e=this.children.length;for(;e--;){let t=this.children[e];Vo.is(t)&&uS.call(t,i,r+1)}}function uS(i,r=0){if(i(this,r)!==!0){let t=this.children.length;for(;t--;){let o=this.children[t];Vo.is(o)&&uS.call(o,i,r+1)}}}function PR(){if(this.shapesDataTexture.value===void 0){let a=new tm(new Float32Array(4*kt*Vi),kt,Vi,Os,Jo);this.shapesDataTexture.value=a}let i=this.shapesDataTexture.value,r=i.image.data;i.needsUpdate=!0;let e=0,t=this.data.geometry.blendRange,o=bR.copy(this.matrixWorld).invert(),n=0;wR.call(this,a=>{if(a.visible===!1)return!0;let s;if(a instanceof Ii)return;if(a instanceof ps||a instanceof Ss)return;a instanceof Lr?s=a.object:s=a;let l=a.data?.cloner;if(De.is(a)&&l&&!l.hideBase&&l.type!=="radial"&&l.disabled!==!0||!(s instanceof et))return;let c=s.geometry.userData.parameters,u=c.shapeBlendNode;if(u===void 0)return;if(vR.multiplyMatrices(o,a.matrixWorld).decompose(Ed,Ps,zi),c.type==="TorusGeometry"&&c.arc!==360){let v=c.arc*Math.PI/180;v=v/4,Ps.multiply(SR.set(0,0,Math.sin(v),Math.cos(v)))}let d=u.overrideGlobalBlend?u.blendRange:t;d=d/this.bboxSize*2,r[n*4]=(Ed.x-this.bboxOffset)/this.bboxSize*2,r[n*4+1]=(Ed.y-this.bboxOffset)/this.bboxSize*2,r[n*4+2]=(Ed.z-this.bboxOffset)/this.bboxSize*2,r[n*4+3]=u.operation===0?1:u.operation===2?-1:-2,r[kt*4+n*4]=-Ps.x,r[kt*4+n*4+1]=-Ps.y,r[kt*4+n*4+2]=-Ps.z,r[kt*4+n*4+3]=Ps.w;let f=new Float32Array(4),h=0;if(c.type==="SphereGeometry")c.width===c.height&&c.width===c.depth?f[0]=0:f[0]=1,f[1]=c.width/this.bboxSize,f[2]=c.height/this.bboxSize,f[3]=c.depth/this.bboxSize,e=Math.max(e,f[1]*zi.x+d,f[2]*zi.x+d,f[3]*zi.x+d);else if(c.type==="CubeGeometry"){h=c.cornerRadius;let v=c.width,w=c.height,O=c.depth;f[0]=2,f[1]=(v-2*h)/this.bboxSize,f[2]=(w-2*h)/this.bboxSize,f[3]=(O-2*h)/this.bboxSize,e=Math.max(e,Math.sqrt(v**2+w**2+O**2)/this.bboxSize*zi.x+d)}else if(c.type==="CylinderGeometry"){h=c.cornerRadius;let v=c.height,w=c.radiusBottom,O=c.radiusTop;if(O>=w){let S=Math.atan2(O-w,v),T=(Math.PI/2-S)/2;O-=h/Math.tan(T),w-=h*Math.tan(T)}else if(w>O){let S=Math.atan2(w-O,v),T=(Math.PI/2-S)/2;O-=h*Math.tan(T),w-=h/Math.tan(T)}f[1]=(c.height-2*h)/this.bboxSize,w===O?(f[0]=3,f[2]=w/this.bboxSize*2):(f[0]=4,f[2]=w/this.bboxSize*2,f[3]=O/this.bboxSize*2),e=Math.max(e,f[1]*4*zi.x+d)}else if(c.type==="TorusGeometry"){if(f[0]=5,f[1]=(c.width-c.depth)/this.bboxSize,f[2]=c.depth/this.bboxSize,c.arc!==360){f[0]=6,f[3]=f[1],r[kt*12+n*4+3]=f[2];let v=2*Math.atan2(f[2]/2,f[1]),w=c.arc*Math.PI/180/2-v;f[1]=Math.sin(w),f[2]=Math.cos(w)}e=Math.max(e,c.width*zi.x/this.bboxSize+d)}r.set(f,kt*8+n*4),r[kt*12+n*4]=d,r[kt*12+n*4+1]=h/this.bboxSize*2,r[kt*12+n*4+2]=zi.x;let m=s.material,y=m.uniforms.nodeU0.node.value,b=m.uniforms.nodeU1.value;u.operation!==0&&!u.useColor&&(b=-1),r[kt*16+n*4]=y.r,r[kt*16+n*4+1]=y.g,r[kt*16+n*4+2]=y.b,r[kt*16+n*4+3]=b,b<1&&this.material.defines.SHAPEBLEND_C===1&&(this.material.transparent=!0),n++}),this.npart=n,this.spatialPassUniforms.span.value=e*1.4}import{Matrix4 as CR,Ray as AR,Raycaster as MR}from"three";var fS=1<<9;function dS(i,r){let e=!1,t=i.layers.mask&fS,o=r.getLayersOfType("transmission"),n=r.getLayersOfType("outline");return n.length>0&&(i.layers.set(8),o.length>0&&i.layers.enable(3),e=!0,ss(i),as(i)),o.length===0&&n.length===0&&i.layers.set(0),t&&i.layers.set(9),i instanceof ir&&i.needsAO&&i.layers.enable(5),e}function pS(i,r){if(!r.layers)return!1;let e=i.layers.mask&fS,t=!1,o=r.getLayersOfType("transmission").filter(a=>a.data.visible),n=r.getLayersOfType("outline").filter(a=>a.data.visible);return o.length>0&&(i.layers.set(3),n.length>0&&i.layers.enable(8),t=!0),o.length===0&&n.length===0&&i.layers.set(0),e&&i.layers.set(9),i.needsAO&&i.layers.enable(5),t}function hS(i){let r=!1;return i.traverseEntity(e=>{if(e instanceof ir)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)dS(e,e.material[t])&&(r=!0);else dS(e,e.material)&&(r=!0)}),r}function mS(i){let r=!1;return i.traverseEntity(e=>{if(e instanceof ir)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)pS(e,e.material[t])&&(r=!0);else pS(e,e.material)&&(r=!0)}),r}var IR=new MR,ER=new CR,NR=new AR;function Rl(i,r,e,t=!1){let o=i.cloner;if(o)for(let n of o.children){let a=ER.copy(n.matrixWorld).invert(),s=NR.copy(r.ray).applyMatrix4(a),l=i.matrixWorld;s.applyMatrix4(l);let c=IR;c.set(s.origin,s.direction),c.near=r.near,c.far=r.far;let u=c.intersectObject(i,!1);u.length>0&&e.push({...u[0],object:t?n:i})}}var Dd=class{constructor(){this._constraints=new Map}setConstraint(r,e){e===null?this._constraints.delete(r):this._constraints.set(r,e)}removeDependencies(r){this._constraints.delete(r)}applyConstraints(r){let e=new Set;this._constraints.forEach((t,o)=>{let n=[o,t],a=t;for(;this._constraints.has(a);){if(a=this._constraints.get(a),n.includes(a)){console.warn(`circular dependency detected: ${n.join(" -> ")}`);break}e.has(a)||n.push(a)}for(let s=n.length-2;s>=0;s--)if(!e.has(n[s])){let l=r.find(n[s]);l?l.applyPathSnapping(r):console.warn(`missing entity ${n[s]}`),e.add(n[s])}})}findDependency(r,e){let t=r;for(;this._constraints.has(t);)if(t=this._constraints.get(t),t===e)return!0;return!1}};var yS="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL";var Po=class{};qi(Po,"DepthMapRange",1<<16),qi(Po,"MemoryPageSize",65536),qi(Po,"BytesPerFloat",4),qi(Po,"BytesPerInt",4);function DR(i){let r,e,t,o,n,a,s,l,c,u,p,d,f,h,m,y;function b(I){let N=new Float64Array(u,a,16);for(let R=0;R<16;R++)N[R]=I[R];let _;if(t>1){r.exports.sortIndexes(o,n,c,a,s,l,d.DepthMapRange,t);let R=new Uint32Array(t);_=R.buffer,R.set(new Uint32Array(u,l,t))}else if(t===1){let R=new Uint32Array(t);R[0]=new Uint32Array(u,o,e)[0],_=R.buffer}else _=new ArrayBuffer(0);i.postMessage({sortDone:!0,indexesBuffer:_},[_])}function v(I,N,_){let R=new Float32Array(u,n,e*3);t=0;let V=new Uint32Array(u,o,e);for(let U=0;U<_.length-1;U++){let B=N[U],q=I[U].elements,j=B.filter(H=>H.enabled&&H.mode==="Include").map(H=>H.type==="Box"?T(H):D(H)),F=B.filter(H=>H.enabled&&H.mode==="Exclude").map(H=>H.type==="Box"?T(H):D(H));for(let H=_[U];H<_[U+1];H++){let W=f[H*3],ee=f[H*3+1],te=f[H*3+2];if((j.length===0||O(W,ee,te,j))&&(F.length===0||!O(W,ee,te,F))){let Y=1/(q[3]*W+q[7]*ee+q[11]*te+q[15]);R[t*3]=(q[0]*W+q[4]*ee+q[8]*te+q[12])*Y,R[t*3+1]=(q[1]*W+q[5]*ee+q[9]*te+q[13])*Y,R[t*3+2]=(q[2]*W+q[6]*ee+q[10]*te+q[14])*Y,V[t]=H,t++}}}}function w(I,N){let _=[],R=N.filter(B=>B.enabled&&B.mode==="Include").map(B=>B.type==="Box"?T(B):D(B)),V=N.filter(B=>B.enabled&&B.mode==="Exclude").map(B=>B.type==="Box"?T(B):D(B)),U=I.length;for(let B=0;B<U;B+=3){let q=I[B],j=I[B+1],F=I[B+2];(R.length===0||O(q,j,F,R))&&(V.length===0||!O(q,j,F,V))||_.push(B/3)}return _}function O(I,N,_,R,V){return R[V==="Intersect"?"every":"some"](U=>{let B=S(I,N,_,U.invRotationMatrix,U.cropCenter);return Array.isArray(U)?g(B.x,B.y,B.z,U):E(B.x,B.y,B.z,U)})}function S(I,N,_,R,V){let U=I-V[0],B=N-V[1],q=_-V[2],j=1/(R[3]*U+R[7]*B+R[11]*q+R[15]);return{x:(R[0]*U+R[4]*B+R[8]*q+R[12])*j+V[0],y:(R[1]*U+R[5]*B+R[9]*q+R[13])*j+V[1],z:(R[2]*U+R[6]*B+R[10]*q+R[14])*j+V[2]}}function T(I){let N=I.cropSize[0]/2,_=I.cropSize[1]/2,R=I.cropSize[2]/2,V=[I.cropCenter[0]-N,I.cropCenter[1]-_,I.cropCenter[2]-R,I.cropCenter[0]+N,I.cropCenter[1]+_,I.cropCenter[2]+R],U=M(I.cropRotation);return Object.assign(V,{invRotationMatrix:U,cropCenter:I.cropCenter})}function M(I){let N=[],_=I[0]*Math.PI/180,R=I[1]*Math.PI/180,V=I[2]*Math.PI/180,U=Math.cos(_),B=Math.sin(_),q=Math.cos(R),j=Math.sin(R),F=Math.cos(V),H=Math.sin(V),W=U*F,ee=U*H,te=B*F,Y=B*H;return N[0]=q*F,N[1]=-q*H,N[2]=j,N[4]=ee+te*j,N[5]=W-Y*j,N[6]=-B*q,N[8]=Y-W*j,N[9]=te+ee*j,N[10]=U*q,N[12]=0,N[13]=0,N[14]=0,N[3]=0,N[7]=0,N[11]=0,N[15]=1,N}function g(I,N,_,R){return I>=R[0]&&I<=R[3]&&N>=R[1]&&N<=R[4]&&_>=R[2]&&_<=R[5]}function D(I){let N=2/I.cropSize[0],_=2/I.cropSize[1],R=2/I.cropSize[2],V=M(I.cropRotation);return{invRadiusX:N,invRadiusY:_,invRadiusZ:R,cropCenter:I.cropCenter,invRotationMatrix:V}}function E(I,N,_,R){let V=(I-R.cropCenter[0])*R.invRadiusX,U=(N-R.cropCenter[1])*R.invRadiusY,B=(_-R.cropCenter[2])*R.invRadiusZ;return V*V+U*U+B*B<=1}i.onmessage=I=>{if(I.data.getCroppedIndexes){let N=new Uint32Array(w(new Float32Array(I.data.positions),I.data.crops)).buffer;i.postMessage({outOfBoundsIndexes:N},[N])}else if(I.data.positions)p=I.data.positions,f=new Float32Array(p),m=I.data.meshMatrixWorlds,y=I.data.cropsArray,h=I.data.meshIndexIntervals,v(m,y,h),i.postMessage({sortSetupComplete:!0});else if(I.data.sort||I.data.newMatrixWorlds||I.data.newCropsArray)(I.data.newMatrixWorlds||I.data.newCropsArray)&&(y=I.data.newCropsArray||y,m=I.data.newMatrixWorlds||m,v(m,y,h)),b(I.data.sort.view,I.data.sort.cameraPosition);else if(I.data.init){d=I.data.init.Constants,e=I.data.init.splatCount;let N=d.BytesPerInt,_=d.BytesPerFloat*3,R=new Uint8Array(I.data.init.sorterWasmBytes),V=N+_,U=e*V,B=e*d.BytesPerInt*2+d.DepthMapRange*d.BytesPerInt*2,q=d.MemoryPageSize*32,j=U+B+q,F=Math.floor(j/d.MemoryPageSize)+1,H={module:{},env:{memory:new WebAssembly.Memory({initial:F*2,maximum:F*3,shared:!0})}};WebAssembly.compile(R).then(W=>WebAssembly.instantiate(W,H)).then(W=>{r=W,o=0,n=e*N,a=n+e*_,c=a+16*d.BytesPerFloat*2,s=c+e*d.BytesPerInt,l=s+d.DepthMapRange*d.BytesPerInt,u=H.env.memory.buffer,i.postMessage({sortSetupPhase1Complete:!0})})}}}function gS(i){let r=new Worker(URL.createObjectURL(new Blob(["(",DR.toString(),")(self)"],{type:"application/javascript"}))),e=atob(yS),t=new Uint8Array(e.length);for(let o=0;o<e.length;o++)t[o]=e.charCodeAt(o);return r.postMessage({init:{sorterWasmBytes:t.buffer,splatCount:i,Constants:{BytesPerFloat:Po.BytesPerFloat,BytesPerInt:Po.BytesPerInt,DepthMapRange:Po.DepthMapRange,MemoryPageSize:Po.MemoryPageSize}}}),r}import{Matrix4 as PS,Quaternion as OS,Vector2 as XR,Vector3 as Ts}from"three";import{BufferAttribute as _R,BufferGeometry as RR,Color as LR,DataTexture as Rd,DataUtils as BR,DoubleSide as VR,DynamicDrawUsage as zR,FloatType as bS,HalfFloatType as GR,InstancedBufferAttribute as FR,InstancedBufferGeometry as jR,Mesh as UR,NormalBlending as kR,RGBAFormat as HR,RGBAIntegerFormat as WR,RGFormat as vS,ShaderMaterial as qR,UnsignedIntType as $R,Vector2 as Gi}from"three";var _d=function(){let i=new Float32Array(1),r=new Int32Array(i.buffer);return function(e){return i[0]=e,r[0]}}(),xS=function(i,r,e,t){return i+(r<<8)+(e<<16)+(t<<24)};var Ld=new Gi;function Bd(i){let r=!1;return i.scene.objects.traverse((e,t)=>{if(t.visible===!1)return!0;t.type==="Splat"&&(r=!0)}),r}var Fi=class extends UR{constructor(e,t,o,n,a=!1,s=1,l,c){super(o,n);this.splatCount=t,this.meshIndexIntervals=l,this.meshMatrixWorlds=c,this.splatBuffers=e,this.geometry=o,this.material=n,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=a,this.devicePixelRatio=s,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,t,o=!1,n=1,a,s){let l=Fi.buildGeomtery(t),c=Fi.buildMaterial(a);return new Fi(e,t,l,c,o,n,a,s)}static buildMaterial(e){let t=`
4225
+ `,t.pyramidTextureSize.value=new lm(this.pyramidRenderTarget.width,this.pyramidRenderTarget.height),Object.assign(n.uniforms,t)};this.material.shapeBlendhack=o,this.material.root.shapeBlendhack=o}},Bi=um;Bi.streamCompaction=new Dd;var mL=new AS,yL=new AS,Ps=new MS,zi=new Ld,Rd=new Ld,gL=new MS;function xL(i,r=0){let e=this.children.length;for(;e--;){let t=this.children[e];Vo.is(t)&&IS.call(t,i,r+1)}}function IS(i,r=0){if(i(this,r)!==!0){let t=this.children.length;for(;t--;){let o=this.children[t];Vo.is(o)&&IS.call(o,i,r+1)}}}function bL(){if(this.shapesDataTexture.value===void 0){let a=new cm(new Float32Array(4*kt*Vi),kt,Vi,Os,Jo);this.shapesDataTexture.value=a}let i=this.shapesDataTexture.value,r=i.image.data;i.needsUpdate=!0;let e=0,t=this.data.geometry.blendRange,o=mL.copy(this.matrixWorld).invert(),n=0;xL.call(this,a=>{if(a.visible===!1)return!0;let s;if(a instanceof Ii)return;if(a instanceof ps||a instanceof Ss)return;a instanceof Lr?s=a.object:s=a;let l=a.data?.cloner;if(De.is(a)&&l&&!l.hideBase&&l.type!=="radial"&&l.disabled!==!0||!(s instanceof et))return;let c=s.geometry.userData.parameters,u=c.shapeBlendNode;if(u===void 0)return;if(yL.multiplyMatrices(o,a.matrixWorld).decompose(Rd,Ps,zi),c.type==="TorusGeometry"&&c.arc!==360){let v=c.arc*Math.PI/180;v=v/4,Ps.multiply(gL.set(0,0,Math.sin(v),Math.cos(v)))}let d=u.overrideGlobalBlend?u.blendRange:t;d=d/this.bboxSize*2,r[n*4]=(Rd.x-this.bboxOffset)/this.bboxSize*2,r[n*4+1]=(Rd.y-this.bboxOffset)/this.bboxSize*2,r[n*4+2]=(Rd.z-this.bboxOffset)/this.bboxSize*2,r[n*4+3]=u.operation===0?1:u.operation===2?-1:-2,r[kt*4+n*4]=-Ps.x,r[kt*4+n*4+1]=-Ps.y,r[kt*4+n*4+2]=-Ps.z,r[kt*4+n*4+3]=Ps.w;let f=new Float32Array(4),h=0;if(c.type==="SphereGeometry")c.width===c.height&&c.width===c.depth?f[0]=0:f[0]=1,f[1]=c.width/this.bboxSize,f[2]=c.height/this.bboxSize,f[3]=c.depth/this.bboxSize,e=Math.max(e,f[1]*zi.x+d,f[2]*zi.x+d,f[3]*zi.x+d);else if(c.type==="CubeGeometry"){h=c.cornerRadius;let v=c.width,w=c.height,O=c.depth;f[0]=2,f[1]=(v-2*h)/this.bboxSize,f[2]=(w-2*h)/this.bboxSize,f[3]=(O-2*h)/this.bboxSize,e=Math.max(e,Math.sqrt(v**2+w**2+O**2)/this.bboxSize*zi.x+d)}else if(c.type==="CylinderGeometry"){h=c.cornerRadius;let v=c.height,w=c.radiusBottom,O=c.radiusTop;if(O>=w){let S=Math.atan2(O-w,v),T=(Math.PI/2-S)/2;O-=h/Math.tan(T),w-=h*Math.tan(T)}else if(w>O){let S=Math.atan2(w-O,v),T=(Math.PI/2-S)/2;O-=h*Math.tan(T),w-=h/Math.tan(T)}f[1]=(c.height-2*h)/this.bboxSize,w===O?(f[0]=3,f[2]=w/this.bboxSize*2):(f[0]=4,f[2]=w/this.bboxSize*2,f[3]=O/this.bboxSize*2),e=Math.max(e,f[1]*4*zi.x+d)}else if(c.type==="TorusGeometry"){if(f[0]=5,f[1]=(c.width-c.depth)/this.bboxSize,f[2]=c.depth/this.bboxSize,c.arc!==360){f[0]=6,f[3]=f[1],r[kt*12+n*4+3]=f[2];let v=2*Math.atan2(f[2]/2,f[1]),w=c.arc*Math.PI/180/2-v;f[1]=Math.sin(w),f[2]=Math.cos(w)}e=Math.max(e,c.width*zi.x/this.bboxSize+d)}r.set(f,kt*8+n*4),r[kt*12+n*4]=d,r[kt*12+n*4+1]=h/this.bboxSize*2,r[kt*12+n*4+2]=zi.x;let m=s.material,y=m.uniforms.nodeU0.node.value,b=m.uniforms.nodeU1.value;u.operation!==0&&!u.useColor&&(b=-1),r[kt*16+n*4]=y.r,r[kt*16+n*4+1]=y.g,r[kt*16+n*4+2]=y.b,r[kt*16+n*4+3]=b,b<1&&this.material.defines.SHAPEBLEND_C===1&&(this.material.transparent=!0),n++}),this.npart=n,this.spatialPassUniforms.span.value=e*1.4}import{Matrix4 as wL,Ray as PL,Raycaster as OL}from"three";var DS=1<<9;function ES(i,r){let e=!1,t=i.layers.mask&DS,o=r.getLayersOfType("transmission"),n=r.getLayersOfType("outline");return n.length>0&&(i.layers.set(8),o.length>0&&i.layers.enable(3),e=!0,ss(i),as(i)),o.length===0&&n.length===0&&i.layers.set(0),t&&i.layers.set(9),i instanceof ir&&i.needsAO&&i.layers.enable(5),e}function NS(i,r){if(!r.layers)return!1;let e=i.layers.mask&DS,t=!1,o=r.getLayersOfType("transmission").filter(a=>a.data.visible),n=r.getLayersOfType("outline").filter(a=>a.data.visible);return o.length>0&&(i.layers.set(3),n.length>0&&i.layers.enable(8),t=!0),o.length===0&&n.length===0&&i.layers.set(0),e&&i.layers.set(9),i.needsAO&&i.layers.enable(5),t}function _S(i){let r=!1;return i.traverseEntity(e=>{if(e instanceof ir)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)ES(e,e.material[t])&&(r=!0);else ES(e,e.material)&&(r=!0)}),r}function RS(i){let r=!1;return i.traverseEntity(e=>{if(e instanceof ir)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)NS(e,e.material[t])&&(r=!0);else NS(e,e.material)&&(r=!0)}),r}var TL=new OL,CL=new wL,AL=new PL;function Rl(i,r,e,t=!1){let o=i.cloner;if(o)for(let n of o.children){let a=CL.copy(n.matrixWorld).invert(),s=AL.copy(r.ray).applyMatrix4(a),l=i.matrixWorld;s.applyMatrix4(l);let c=TL;c.set(s.origin,s.direction),c.near=r.near,c.far=r.far;let u=c.intersectObject(i,!1);u.length>0&&e.push({...u[0],object:t?n:i})}}var Bd=class{constructor(){this._constraints=new Map}setConstraint(r,e){e===null?this._constraints.delete(r):this._constraints.set(r,e)}removeDependencies(r){this._constraints.delete(r)}applyConstraints(r){let e=new Set;this._constraints.forEach((t,o)=>{let n=[o,t],a=t;for(;this._constraints.has(a);){if(a=this._constraints.get(a),n.includes(a)){console.warn(`circular dependency detected: ${n.join(" -> ")}`);break}e.has(a)||n.push(a)}for(let s=n.length-2;s>=0;s--)if(!e.has(n[s])){let l=r.find(n[s]);l?l.applyPathSnapping(r):console.warn(`missing entity ${n[s]}`),e.add(n[s])}})}findDependency(r,e){let t=r;for(;this._constraints.has(t);)if(t=this._constraints.get(t),t===e)return!0;return!1}};var LS="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL";var Po=class{};qi(Po,"DepthMapRange",1<<16),qi(Po,"MemoryPageSize",65536),qi(Po,"BytesPerFloat",4),qi(Po,"BytesPerInt",4);function ML(i){let r,e,t,o,n,a,s,l,c,u,p,d,f,h,m,y;function b(I){let N=new Float64Array(u,a,16);for(let R=0;R<16;R++)N[R]=I[R];let _;if(t>1){r.exports.sortIndexes(o,n,c,a,s,l,d.DepthMapRange,t);let R=new Uint32Array(t);_=R.buffer,R.set(new Uint32Array(u,l,t))}else if(t===1){let R=new Uint32Array(t);R[0]=new Uint32Array(u,o,e)[0],_=R.buffer}else _=new ArrayBuffer(0);i.postMessage({sortDone:!0,indexesBuffer:_},[_])}function v(I,N,_){let R=new Float32Array(u,n,e*3);t=0;let V=new Uint32Array(u,o,e);for(let U=0;U<_.length-1;U++){let B=N[U],q=I[U].elements,j=B.filter(H=>H.enabled&&H.mode==="Include").map(H=>H.type==="Box"?T(H):D(H)),F=B.filter(H=>H.enabled&&H.mode==="Exclude").map(H=>H.type==="Box"?T(H):D(H));for(let H=_[U];H<_[U+1];H++){let W=f[H*3],ee=f[H*3+1],te=f[H*3+2];if((j.length===0||O(W,ee,te,j))&&(F.length===0||!O(W,ee,te,F))){let Y=1/(q[3]*W+q[7]*ee+q[11]*te+q[15]);R[t*3]=(q[0]*W+q[4]*ee+q[8]*te+q[12])*Y,R[t*3+1]=(q[1]*W+q[5]*ee+q[9]*te+q[13])*Y,R[t*3+2]=(q[2]*W+q[6]*ee+q[10]*te+q[14])*Y,V[t]=H,t++}}}}function w(I,N){let _=[],R=N.filter(B=>B.enabled&&B.mode==="Include").map(B=>B.type==="Box"?T(B):D(B)),V=N.filter(B=>B.enabled&&B.mode==="Exclude").map(B=>B.type==="Box"?T(B):D(B)),U=I.length;for(let B=0;B<U;B+=3){let q=I[B],j=I[B+1],F=I[B+2];(R.length===0||O(q,j,F,R))&&(V.length===0||!O(q,j,F,V))||_.push(B/3)}return _}function O(I,N,_,R,V){return R[V==="Intersect"?"every":"some"](U=>{let B=S(I,N,_,U.invRotationMatrix,U.cropCenter);return Array.isArray(U)?g(B.x,B.y,B.z,U):E(B.x,B.y,B.z,U)})}function S(I,N,_,R,V){let U=I-V[0],B=N-V[1],q=_-V[2],j=1/(R[3]*U+R[7]*B+R[11]*q+R[15]);return{x:(R[0]*U+R[4]*B+R[8]*q+R[12])*j+V[0],y:(R[1]*U+R[5]*B+R[9]*q+R[13])*j+V[1],z:(R[2]*U+R[6]*B+R[10]*q+R[14])*j+V[2]}}function T(I){let N=I.cropSize[0]/2,_=I.cropSize[1]/2,R=I.cropSize[2]/2,V=[I.cropCenter[0]-N,I.cropCenter[1]-_,I.cropCenter[2]-R,I.cropCenter[0]+N,I.cropCenter[1]+_,I.cropCenter[2]+R],U=M(I.cropRotation);return Object.assign(V,{invRotationMatrix:U,cropCenter:I.cropCenter})}function M(I){let N=[],_=I[0]*Math.PI/180,R=I[1]*Math.PI/180,V=I[2]*Math.PI/180,U=Math.cos(_),B=Math.sin(_),q=Math.cos(R),j=Math.sin(R),F=Math.cos(V),H=Math.sin(V),W=U*F,ee=U*H,te=B*F,Y=B*H;return N[0]=q*F,N[1]=-q*H,N[2]=j,N[4]=ee+te*j,N[5]=W-Y*j,N[6]=-B*q,N[8]=Y-W*j,N[9]=te+ee*j,N[10]=U*q,N[12]=0,N[13]=0,N[14]=0,N[3]=0,N[7]=0,N[11]=0,N[15]=1,N}function g(I,N,_,R){return I>=R[0]&&I<=R[3]&&N>=R[1]&&N<=R[4]&&_>=R[2]&&_<=R[5]}function D(I){let N=2/I.cropSize[0],_=2/I.cropSize[1],R=2/I.cropSize[2],V=M(I.cropRotation);return{invRadiusX:N,invRadiusY:_,invRadiusZ:R,cropCenter:I.cropCenter,invRotationMatrix:V}}function E(I,N,_,R){let V=(I-R.cropCenter[0])*R.invRadiusX,U=(N-R.cropCenter[1])*R.invRadiusY,B=(_-R.cropCenter[2])*R.invRadiusZ;return V*V+U*U+B*B<=1}i.onmessage=I=>{if(I.data.getCroppedIndexes){let N=new Uint32Array(w(new Float32Array(I.data.positions),I.data.crops)).buffer;i.postMessage({outOfBoundsIndexes:N},[N])}else if(I.data.positions)p=I.data.positions,f=new Float32Array(p),m=I.data.meshMatrixWorlds,y=I.data.cropsArray,h=I.data.meshIndexIntervals,v(m,y,h),i.postMessage({sortSetupComplete:!0});else if(I.data.sort||I.data.newMatrixWorlds||I.data.newCropsArray)(I.data.newMatrixWorlds||I.data.newCropsArray)&&(y=I.data.newCropsArray||y,m=I.data.newMatrixWorlds||m,v(m,y,h)),b(I.data.sort.view,I.data.sort.cameraPosition);else if(I.data.init){d=I.data.init.Constants,e=I.data.init.splatCount;let N=d.BytesPerInt,_=d.BytesPerFloat*3,R=new Uint8Array(I.data.init.sorterWasmBytes),V=N+_,U=e*V,B=e*d.BytesPerInt*2+d.DepthMapRange*d.BytesPerInt*2,q=d.MemoryPageSize*32,j=U+B+q,F=Math.floor(j/d.MemoryPageSize)+1,H={module:{},env:{memory:new WebAssembly.Memory({initial:F*2,maximum:F*3,shared:!0})}};WebAssembly.compile(R).then(W=>WebAssembly.instantiate(W,H)).then(W=>{r=W,o=0,n=e*N,a=n+e*_,c=a+16*d.BytesPerFloat*2,s=c+e*d.BytesPerInt,l=s+d.DepthMapRange*d.BytesPerInt,u=H.env.memory.buffer,i.postMessage({sortSetupPhase1Complete:!0})})}}}function BS(i){let r=new Worker(URL.createObjectURL(new Blob(["(",ML.toString(),")(self)"],{type:"application/javascript"}))),e=atob(LS),t=new Uint8Array(e.length);for(let o=0;o<e.length;o++)t[o]=e.charCodeAt(o);return r.postMessage({init:{sorterWasmBytes:t.buffer,splatCount:i,Constants:{BytesPerFloat:Po.BytesPerFloat,BytesPerInt:Po.BytesPerInt,DepthMapRange:Po.DepthMapRange,MemoryPageSize:Po.MemoryPageSize}}}),r}import{Matrix4 as US,Quaternion as kS,Vector2 as HL,Vector3 as Ts}from"three";import{BufferAttribute as IL,BufferGeometry as EL,Color as NL,DataTexture as zd,DataUtils as DL,DoubleSide as _L,DynamicDrawUsage as RL,FloatType as zS,HalfFloatType as LL,InstancedBufferAttribute as BL,InstancedBufferGeometry as VL,Mesh as zL,NormalBlending as GL,RGBAFormat as FL,RGBAIntegerFormat as jL,RGFormat as GS,ShaderMaterial as UL,UnsignedIntType as kL,Vector2 as Gi}from"three";var Vd=function(){let i=new Float32Array(1),r=new Int32Array(i.buffer);return function(e){return i[0]=e,r[0]}}(),VS=function(i,r,e,t){return i+(r<<8)+(e<<16)+(t<<24)};var Gd=new Gi;function Fd(i){let r=!1;return i.scene.objects.traverse((e,t)=>{if(t.visible===!1)return!0;t.type==="Splat"&&(r=!0)}),r}var Fi=class extends zL{constructor(e,t,o,n,a=!1,s=1,l,c){super(o,n);this.splatCount=t,this.meshIndexIntervals=l,this.meshMatrixWorlds=c,this.splatBuffers=e,this.geometry=o,this.material=n,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=a,this.devicePixelRatio=s,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,t,o=!1,n=1,a,s){let l=Fi.buildGeomtery(t),c=Fi.buildMaterial(a);return new Fi(e,t,l,c,o,n,a,s)}static buildMaterial(e){let t=`
4226
4226
  precision highp float;
4227
4227
  #include <common>
4228
4228
 
@@ -4376,4 +4376,4 @@ void main() {
4376
4376
  A = exp(A) * vColor.a;
4377
4377
  gl_FragColor = vec4(color.rgb, A);
4378
4378
  gVelocity = vec4(0.0); // so it is ignored by TAA
4379
- }`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Gi},viewport:{type:"v2",value:new Gi},basisViewport:{type:"v2",value:new Gi},debugColor:{type:"v3",value:new LR},covariancesTextureSize:{type:"v2",value:new Gi(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Gi(1024,1024)},orthoZoom:{type:"f",value:-1}};return new qR({uniforms:n,vertexShader:t,fragmentShader:o,transparent:!0,alphaTest:1,blending:kR,depthTest:!0,depthWrite:!1,side:VR})}static buildGeomtery(e){let t=new RR;t.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new _R(o,3);t.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new jR().copy(t),s=new Uint32Array(e),l=new FR(s,1,!1);return l.setUsage(zR),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.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 n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(t,t+a*3).set(n.decoded.xyz.denormDequant().data),t+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Gi(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Gi(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=BR.toHalfFloat(this.covariances[h]);s=new Rd(l,n.x,n.y,vS,GR)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Rd(l,n.x,n.y,vS,bS);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,b=h*4;c[b]=xS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[b+1]=_d(this.centers[y]),c[b+2]=_d(this.centers[y+1]),c[b+3]=_d(this.centers[y+2])}let u=new Rd(c,a.x,a.y,WR,$R);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 h=0;h<this.meshMatrixWorlds.length;h++)d.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Rd(d,p,1,HR,bS);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,o,n){this.splatCount>0&&(Ld.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Ld),this.material.uniforms.basisViewport.value.set(2/Ld.x,2/Ld.y),this.material.uniforms.focal.value.set(t,o),this.material.uniforms.orthoZoom.value=n,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 wS,om=new Promise(i=>{wS=i}),SS=!1;var Vd;function im(){if(SS)return;if(Vd)return Vd;async function i(){let e=await import("./gaussian-splat-compression.js");wS(e),SS=!0}return Vd=i(),Vd}var TS;om.then(i=>TS=i);var Vl=class{constructor(r={}){qi(this,"updateView",function(){let r=new PS,e=[],t=new Ts(0,0,-1),o=new Ts(0,0,-1),n=new Ts,a=new Ts;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,f=!1;if(o.dot(t)<=.95&&(d=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.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 PS().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(r,e){let t=new XR;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 Ts().fromArray(r.position)),r.orientation&&(r.orientation=new OS().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 TS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of t)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(t,o,r.position,r.orientation,r.halfPrecisionCovariances,this.devicePixelRatio,n,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,n)=>{this.cropsArray[t][n]===void 0?(r=!0,this.cropsArray[t][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[t][n][a][c])?(r=!0,this.cropsArray[t][n][a]=s):s!==this.cropsArray[t][n]?.[a]&&(r=!0,this.cropsArray[t][n][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 Ts,o=new OS,n=!1,a=1,s,l){this.splatMesh=Fi.buildMesh(r,e,n,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=gS(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 tL=new JR;tL.wireframe=!0;var CS=new KR,zd=class extends YR{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.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Dd;this.invisibleObjects=new Ni("jflkdsafjasdifjaslk",{...Xc.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new Mr("fdasfa",{...No.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=mS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=hS(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 Mr&&(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=[],n=t;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:t,sortKey:o}}getAllSorted(e){let t=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&t.push(n)}return t.sort((o,n)=>ql(o.sortKey,n.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===pi)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 Mr&&t.uiScene){let o=t.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof Mr&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(o=>{t===void 0&&o instanceof Pn&&(t=o.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof Mr&&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 n=this.createObject(e.id,e.data,e.children,o,e.localIndex,t);n.updateVisible(this),n.resetBBoxNeedsUpdate(),Ei(n)&&Cl(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n),this.markPenumbraSizeDirty(),n.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");o.traverseEntity(a=>{a instanceof Bi&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),Cl(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Ei(o)&&(o.freeBooleanPointer(),n instanceof nr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof bs&&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 n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),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()),Ei(o)&&(o.invalidateUpstreamBooleanData(),Cl(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof nr&&n.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 Mr&&(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,n){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{oS(a,t,o,{scene:this,shared:n}),a instanceof et&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,t,o,n,a,s=[]){e.updateEntityByOp(t,o,n,a),this.traverseEntity(l=>{(l instanceof Pn||l instanceof Mr)&&(s.includes(l.frameId??"")||l.frameId===t)&&l.updateEntity2DByOp(t,o,n,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((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[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(n=>{n instanceof Xo&&n.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){De.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{De.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=ai(u.data,p=>{let d=p.events.data(l.id),f=u.goUp(s);if(f){let h=[...Wl(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,b=Ze.zoom(d,t);b[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,t,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...t,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...t,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...t,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...t,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Qo&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(t.forInstancesRec(s=>{s.data=ai(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Zc.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,t,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,t,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,t,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,t,o,n):n.data.condition.type==="Comparison"&&(n.data.condition.lOperand.type==="Property"&&this.relativeizeInner(n.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,t,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,t,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,t,o,n)})}),!0})}expandInstances(e,t,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof Qo&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),t||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Pd(a)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Qo&&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)De.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=[],n=a=>{for(let s of a.children){let l=s.cloner;if(De.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(Ei(s)||Al(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Rl(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let t=[],o=n=>{for(let a of n.children){let s=a.cloner;De.is(a)&&(a.visible||s?.object.data.visible)&&((Ei(a)||Al(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),Rl(a,e,t,!0)),o(a))}};return o(this),t}forEachEntity(e){for(let t of this.children)De.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)De.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)De.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(o=>{if(o instanceof et&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,t).then(()=>{n.update(a,t);let s=o.invalidateDownstreamBooleanData();Cl(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)Vo.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)De.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,t,n,o),n+=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,n,a,s){let l={scene:this,shared:s},c=Ad(e,t,l);return c instanceof Bi&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.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 et&&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 et&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),f=p.boneInverses.map(m=>new QR().fromArray(m)),h=new eL(d,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let t=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;t.push(...u.vertices)}let o=new ZR;return o.setFromPoints(t),o.getCenter(CS),CS}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 Tt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof or&&e(t.material[o]);else t.material instanceof or&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(n=>{n instanceof Xo&&n.setViewplaneSize(e,t,o)})}initializeSplatViewer(){this.splatViewer=new Vl({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as rL}from"three/examples/jsm/loaders/DRACOLoader.js";var ji;function AS(){return ji||(ji=new rL,ji.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),ji.decoderPending}async function oL(i){if(ji){let r={attributeIDs:ji.defaultAttributeIDs,attributeTypes:ji.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await ji.decodeGeometry(new Int8Array(i).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 MS(i,r){let[e,t]=lp(Lc.deserialize(new Uint8Array(i)));return tu(e),r&&r(e),t.result().data}function IS(i){let r=[];return i.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="NonParametricGeometry"&&t.geometry.data.draco!==void 0&&r.push(t)}),r}async function ES(i){for(let r of i){let e=await oL(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:n,array:a,itemSize:s})=>{o[n]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),t.attributes=o,t.draco=void 0}}}import{Mesh as sme}from"three";import{mergeBufferGeometries as ume}from"three/examples/jsm/utils/BufferGeometryUtils.js";function NS(i){let r;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)r=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=r}import{Color as DS,ShaderLib as iL}from"three";function _S(i){let r=new Set;return i.traverse(e=>{if(e instanceof ir)if(dt(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(nL(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new DS,specularColor:new DS});let o=0;e.onBeforeCompile=(n,a)=>{t&&t(n,a),n.uniforms=Object.assign({},iL.physical.uniforms,n.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(n.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=Qb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else aL(e)||(e.onBeforeCompile=(o,n)=>{t&&t(o,n),e.transparent=!1})}),i}function nL(i){return i.getLayersOfType("transmission").length>0}function aL(i){let r=0;for(let e of i.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 RS(i){return i.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),i}function LS(i){let r=[],e=(t,o=0)=>{let n=o>0?t+o:t;return r.includes(n)?e(t,o+1):n};return i.traverse(t=>{if(r.includes(t.name)){let o=t.name,n=e(t.name);if(t.name=n,t.isMesh){let a=t;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,n)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,n))}}r.push(t.name)}),i}import{mergeBufferGeometries as sL}from"three/examples/jsm/utils/BufferGeometryUtils.js";function BS(i){let r=[];return i.traverse(e=>{e instanceof Ii&&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&&NS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&t instanceof Tt&&a.unshift(t.geometry),a.length){let s=sL(a);t instanceof Tt&&(t.geometry=s)}e.removeFromParent(),t.setFromClonerState(null,{scene:i,shared:vv})}),i}function VS(i){return i.traverse(r=>{r.matrixAutoUpdate=!0}),i}function zS(i){Object.values(i.shared.materials).forEach(r=>{nm(r)}),i.scene.objects.traverse((r,e)=>{"material"in e?nm(e.material):"materials"in e&&e.materials.forEach(t=>{nm(t)})})}function nm(i){if(typeof i=="string")return;let r=[];i.layers.forEach((e,t)=>{e.type==="outline"&&r.push(t)}),r.reverse().forEach(e=>{i.layers.delete(e)}),r.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var US=Ms(FS(),1);var jS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",am=class extends cL{load(r,e,t,o=console.error){let n=new lL(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(jS+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(jS),n.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 MS(r,zS),t=IS(e);e.version&&(0,US.default)(e.version,"1.10.27")>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&&AS(),Mv(e)&&Tb(),zv(e)&&pv(),S1(e)&&x1(),Bd(e)&&im()].filter(Boolean)),t.length&&await ES(t);let o=!1,n=new yn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new zd(e.scene,n);Bd(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=BS(a),a=_S(a),a=RS(a),a=LS(a),a=VS(a),a}};export{am as default};
4379
+ }`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Gi},viewport:{type:"v2",value:new Gi},basisViewport:{type:"v2",value:new Gi},debugColor:{type:"v3",value:new NL},covariancesTextureSize:{type:"v2",value:new Gi(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Gi(1024,1024)},orthoZoom:{type:"f",value:-1}};return new UL({uniforms:n,vertexShader:t,fragmentShader:o,transparent:!0,alphaTest:1,blending:GL,depthTest:!0,depthWrite:!1,side:_L})}static buildGeomtery(e){let t=new EL;t.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new IL(o,3);t.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new VL().copy(t),s=new Uint32Array(e),l=new BL(s,1,!1);return l.setUsage(RL),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.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 n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(t,t+a*3).set(n.decoded.xyz.denormDequant().data),t+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Gi(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Gi(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=DL.toHalfFloat(this.covariances[h]);s=new zd(l,n.x,n.y,GS,LL)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new zd(l,n.x,n.y,GS,zS);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,b=h*4;c[b]=VS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[b+1]=Vd(this.centers[y]),c[b+2]=Vd(this.centers[y+1]),c[b+3]=Vd(this.centers[y+2])}let u=new zd(c,a.x,a.y,jL,kL);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 h=0;h<this.meshMatrixWorlds.length;h++)d.set(this.meshMatrixWorlds[h].elements,h*16);let f=new zd(d,p,1,FL,zS);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,o,n){this.splatCount>0&&(Gd.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Gd),this.material.uniforms.basisViewport.value.set(2/Gd.x,2/Gd.y),this.material.uniforms.focal.value.set(t,o),this.material.uniforms.orthoZoom.value=n,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 jS,dm=new Promise(i=>{jS=i}),FS=!1;var jd;function pm(){if(FS)return;if(jd)return jd;async function i(){let e=await import("./gaussian-splat-compression.js");jS(e),FS=!0}return jd=i(),jd}var HS;dm.then(i=>HS=i);var Vl=class{constructor(r={}){qi(this,"updateView",function(){let r=new US,e=[],t=new Ts(0,0,-1),o=new Ts(0,0,-1),n=new Ts,a=new Ts;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,f=!1;if(o.dot(t)<=.95&&(d=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.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 US().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(r,e){let t=new HL;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 Ts().fromArray(r.position)),r.orientation&&(r.orientation=new kS().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 HS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of t)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(t,o,r.position,r.orientation,r.halfPrecisionCovariances,this.devicePixelRatio,n,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,n)=>{this.cropsArray[t][n]===void 0?(r=!0,this.cropsArray[t][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[t][n][a][c])?(r=!0,this.cropsArray[t][n][a]=s):s!==this.cropsArray[t][n]?.[a]&&(r=!0,this.cropsArray[t][n][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 Ts,o=new kS,n=!1,a=1,s,l){this.splatMesh=Fi.buildMesh(r,e,n,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=BS(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 QL=new YL;QL.wireframe=!0;var WS=new qL,Ud=class extends WL{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.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Bd;this.invisibleObjects=new Ni("jflkdsafjasdifjaslk",{...Zc.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new Mr("fdasfa",{...No.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=RS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=_S(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 Mr&&(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=[],n=t;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:t,sortKey:o}}getAllSorted(e){let t=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&t.push(n)}return t.sort((o,n)=>ql(o.sortKey,n.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===pi)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 Mr&&t.uiScene){let o=t.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof Mr&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(o=>{t===void 0&&o instanceof Pn&&(t=o.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof Mr&&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 n=this.createObject(e.id,e.data,e.children,o,e.localIndex,t);n.updateVisible(this),n.resetBBoxNeedsUpdate(),Ei(n)&&Cl(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n),this.markPenumbraSizeDirty(),n.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");o.traverseEntity(a=>{a instanceof Bi&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),Cl(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Ei(o)&&(o.freeBooleanPointer(),n instanceof nr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof bs&&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 n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),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()),Ei(o)&&(o.invalidateUpstreamBooleanData(),Cl(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof nr&&n.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 Mr&&(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,n){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{wS(a,t,o,{scene:this,shared:n}),a instanceof et&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,t,o,n,a,s=[]){e.updateEntityByOp(t,o,n,a),this.traverseEntity(l=>{(l instanceof Pn||l instanceof Mr)&&(s.includes(l.frameId??"")||l.frameId===t)&&l.updateEntity2DByOp(t,o,n,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((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[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(n=>{n instanceof Xo&&n.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){De.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{De.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=ai(u.data,p=>{let d=p.events.data(l.id),f=u.goUp(s);if(f){let h=[...Wl(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,b=Ze.zoom(d,t);b[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,t,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...t,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...t,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...t,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...t,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Qo&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(t.forInstancesRec(s=>{s.data=ai(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of ru.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,t,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,t,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,t,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,t,o,n):n.data.condition.type==="Comparison"&&(n.data.condition.lOperand.type==="Property"&&this.relativeizeInner(n.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,t,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,t,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,t,o,n)})}),!0})}expandInstances(e,t,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof Qo&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),t||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Ad(a)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Qo&&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)De.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=[],n=a=>{for(let s of a.children){let l=s.cloner;if(De.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(Ei(s)||Al(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Rl(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let t=[],o=n=>{for(let a of n.children){let s=a.cloner;De.is(a)&&(a.visible||s?.object.data.visible)&&((Ei(a)||Al(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),Rl(a,e,t,!0)),o(a))}};return o(this),t}forEachEntity(e){for(let t of this.children)De.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)De.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)De.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(o=>{if(o instanceof et&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,t).then(()=>{n.update(a,t);let s=o.invalidateDownstreamBooleanData();Cl(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)Vo.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)De.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,t,n,o),n+=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,n,a,s){let l={scene:this,shared:s},c=Nd(e,t,l);return c instanceof Bi&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.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 et&&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 et&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),f=p.boneInverses.map(m=>new $L().fromArray(m)),h=new KL(d,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let t=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;t.push(...u.vertices)}let o=new XL;return o.setFromPoints(t),o.getCenter(WS),WS}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 Tt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof or&&e(t.material[o]);else t.material instanceof or&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(n=>{n instanceof Xo&&n.setViewplaneSize(e,t,o)})}initializeSplatViewer(){this.splatViewer=new Vl({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as ZL}from"three/examples/jsm/loaders/DRACOLoader.js";var ji;function qS(i){return ji||(ji=new ZL,ji.setDecoderPath(i??"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),ji.decoderPending}async function JL(i){if(ji){let r={attributeIDs:ji.defaultAttributeIDs,attributeTypes:ji.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await ji.decodeGeometry(new Int8Array(i).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 $S(i,r){let[e,t]=yp(Gc.deserialize(new Uint8Array(i)));return nu(e),r&&r(e),t.result().data}function XS(i){let r=[];return i.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="NonParametricGeometry"&&t.geometry.data.draco!==void 0&&r.push(t)}),r}async function YS(i){for(let r of i){let e=await JL(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:n,array:a,itemSize:s})=>{o[n]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),t.attributes=o,t.draco=void 0}}}import{Mesh as Eye}from"three";import{mergeBufferGeometries as _ye}from"three/examples/jsm/utils/BufferGeometryUtils.js";function KS(i){let r;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)r=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=r}import{Color as QS,ShaderLib as eB}from"three";function ZS(i){let r=new Set;return i.traverse(e=>{if(e instanceof ir)if(dt(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(tB(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new QS,specularColor:new QS});let o=0;e.onBeforeCompile=(n,a)=>{t&&t(n,a),n.uniforms=Object.assign({},eB.physical.uniforms,n.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(n.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=yv(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else rB(e)||(e.onBeforeCompile=(o,n)=>{t&&t(o,n),e.transparent=!1})}),i}function tB(i){return i.getLayersOfType("transmission").length>0}function rB(i){let r=0;for(let e of i.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 JS(i){return i.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),i}function ew(i){let r=[],e=(t,o=0)=>{let n=o>0?t+o:t;return r.includes(n)?e(t,o+1):n};return i.traverse(t=>{if(r.includes(t.name)){let o=t.name,n=e(t.name);if(t.name=n,t.isMesh){let a=t;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,n)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,n))}}r.push(t.name)}),i}import{mergeBufferGeometries as oB}from"three/examples/jsm/utils/BufferGeometryUtils.js";function tw(i){let r=[];return i.traverse(e=>{e instanceof Ii&&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&&KS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&t instanceof Tt&&a.unshift(t.geometry),a.length){let s=oB(a);t instanceof Tt&&(t.geometry=s)}e.removeFromParent(),t.setFromClonerState(null,{scene:i,shared:Gv})}),i}function rw(i){return i.traverse(r=>{r.matrixAutoUpdate=!0}),i}function ow(i){Object.values(i.shared.materials).forEach(r=>{fm(r)}),i.scene.objects.traverse((r,e)=>{"material"in e?fm(e.material):"materials"in e&&e.materials.forEach(t=>{fm(t)})})}function fm(i){if(typeof i=="string")return;let r=[];i.layers.forEach((e,t)=>{e.type==="outline"&&r.push(t)}),r.reverse().forEach(e=>{i.layers.delete(e)}),r.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var sw=Ms(nw(),1);var aw="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",hm=class extends nB{load(r,e,t,o=console.error){let n=new iB(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(aw+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(aw),n.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 $S(r,ow),t=XS(e);e.version&&(0,sw.default)(e.version,"1.10.29")>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&&qS(),$v(e)&&Hb(),o1(e)&&Nv(),F1(e)&&V1(),Fd(e)&&pm()].filter(Boolean)),t.length&&await YS(t);let o=!1,n=new yn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new Ud(e.scene,n);Fd(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=tw(a),a=ZS(a),a=JS(a),a=ew(a),a=rw(a),a}};export{hm as default};