@splinetool/loader 1.12.53 → 1.12.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/SplineLoader.cjs +5 -5
- package/build/SplineLoader.js +5 -5
- package/package.json +1 -1
package/build/SplineLoader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var bw=Object.create;var Zl=Object.defineProperty;var vw=Object.getOwnPropertyDescriptor;var Sw=Object.getOwnPropertyNames;var ww=Object.getPrototypeOf,Pw=Object.prototype.hasOwnProperty;var Ow=(i,t,e)=>t in i?Zl(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var Ls=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),Tw=(i,t)=>{for(var e in t)Zl(i,e,{get:t[e],enumerable:!0})},Cw=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Sw(t))!Pw.call(i,o)&&o!==e&&Zl(i,o,{get:()=>t[o],enumerable:!(r=vw(t,o))||r.enumerable});return i};var Bs=(i,t,e)=>(e=i!=null?bw(ww(i)):{},Cw(t||!i||!i.__esModule?Zl(e,"default",{value:i,enumerable:!0}):e,i));var Qi=(i,t,e)=>(Ow(i,typeof t!="symbol"?t+"":t,e),e);var fx=Ls((Yp,px)=>{(function(i,t){typeof Yp=="object"?px.exports=t():typeof define=="function"&&define.amd?define(t):i.Alea=t()})(Yp,function(){"use strict";return i.importState=function(e){var r=new i;return r.importState(e),r},i;function i(){return function(e){var r=0,o=0,n=0,a=1;e.length==0&&(e=[+new Date]);var s=t();r=s(" "),o=s(" "),n=s(" ");for(var l=0;l<e.length;l++)r-=s(e[l]),r<0&&(r+=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*r+a*23283064365386963e-26;return r=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[r,o,n,a]},c.importState=function(u){r=+u[0]||0,o=+u[1]||0,n=+u[2]||0,a=+u[3]||0},c}(Array.prototype.slice.call(arguments))}function t(){var e=4022871197,r=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 r.version="Mash 0.9",r}})});var bx=Ls((xu,xx)=>{(function(i,t){typeof xu=="object"&&typeof xx<"u"?t(xu):typeof define=="function"&&define.amd?define(["exports"],t):t((i=typeof globalThis<"u"?globalThis:i||self).SVDJS={})})(xu,function(i){"use strict";i.SVD=function(t,e,r,o,n){if(e=e===void 0||e,r=r===void 0||r,n=1e-64/(o=o||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var a,s,l,c,u,d,p,f,h,m,y,g,b=t[0].length,w=t.length;if(w<b)throw new TypeError("Invalid matrix: m < n");for(var P=[],S=[],T=[],A=e==="f"?w:b,x=m=p=0;x<w;x++)S[x]=new Array(A).fill(0);for(x=0;x<b;x++)T[x]=new Array(b).fill(0);var N,E=new Array(b).fill(0);for(x=0;x<w;x++)for(a=0;a<b;a++)S[x][a]=t[x][a];for(x=0;x<b;x++){for(P[x]=p,h=0,l=x+1,a=x;a<w;a++)h+=Math.pow(S[a][x],2);if(h<n)p=0;else for(f=(d=S[x][x])*(p=d<0?Math.sqrt(h):-Math.sqrt(h))-h,S[x][x]=d-p,a=l;a<b;a++){for(h=0,s=x;s<w;s++)h+=S[s][x]*S[s][a];for(d=h/f,s=x;s<w;s++)S[s][a]=S[s][a]+d*S[s][x]}for(E[x]=p,h=0,a=l;a<b;a++)h+=Math.pow(S[x][a],2);if(h<n)p=0;else{for(f=(d=S[x][x+1])*(p=d<0?Math.sqrt(h):-Math.sqrt(h))-h,S[x][x+1]=d-p,a=l;a<b;a++)P[a]=S[x][a]/f;for(a=l;a<w;a++){for(h=0,s=l;s<b;s++)h+=S[a][s]*S[x][s];for(s=l;s<b;s++)S[a][s]=S[a][s]+h*P[s]}}m<(y=Math.abs(E[x])+Math.abs(P[x]))&&(m=y)}if(r)for(x=b-1;0<=x;x--){if(p!==0){for(f=S[x][x+1]*p,a=l;a<b;a++)T[a][x]=S[x][a]/f;for(a=l;a<b;a++){for(h=0,s=l;s<b;s++)h+=S[x][s]*T[s][a];for(s=l;s<b;s++)T[s][a]=T[s][a]+h*T[s][x]}}for(a=l;a<b;a++)T[x][a]=0,T[a][x]=0;T[x][x]=1,p=P[x],l=x}if(e){if(e==="f")for(x=b;x<w;x++){for(a=b;a<w;a++)S[x][a]=0;S[x][x]=1}for(x=b-1;0<=x;x--){for(l=x+1,p=E[x],a=l;a<A;a++)S[x][a]=0;if(p!==0){for(f=S[x][x]*p,a=l;a<A;a++){for(h=0,s=l;s<w;s++)h+=S[s][x]*S[s][a];for(d=h/f,s=x;s<w;s++)S[s][a]=S[s][a]+d*S[s][x]}for(a=x;a<w;a++)S[a][x]=S[a][x]/p}else for(a=x;a<w;a++)S[a][x]=0;S[x][x]=S[x][x]+1}}for(o*=m,s=b-1;0<=s;s--)for(var M=0;M<50;M++){for(N=!1,l=s;0<=l;l--){if(Math.abs(P[l])<=o){N=!0;break}if(Math.abs(E[l-1])<=o)break}if(!N){for(u=0,c=l-(h=1),x=l;x<s+1&&(d=h*P[x],P[x]=u*P[x],!(Math.abs(d)<=o));x++)if(p=E[x],E[x]=Math.sqrt(d*d+p*p),u=p/(f=E[x]),h=-d/f,e)for(a=0;a<w;a++)y=S[a][c],g=S[a][x],S[a][c]=y*u+g*h,S[a][x]=-y*h+g*u}if(g=E[s],l===s){if(g<0&&(E[s]=-g,r))for(a=0;a<b;a++)T[a][s]=-T[a][s];break}for(m=E[l],d=(((y=E[s-1])-g)*(y+g)+((p=P[s-1])-(f=P[s]))*(p+f))/(2*f*y),p=Math.sqrt(d*d+1),d=((m-g)*(m+g)+f*(y/(d<0?d-p:d+p)-f))/m,x=l+(h=u=1);x<s+1;x++){if(p=P[x],y=E[x],f=h*p,p*=u,g=Math.sqrt(d*d+f*f),d=m*(u=d/(P[x-1]=g))+p*(h=f/g),p=-m*h+p*u,f=y*h,y*=u,r)for(a=0;a<b;a++)m=T[a][x-1],g=T[a][x],T[a][x-1]=m*u+g*h,T[a][x]=-m*h+g*u;if(g=Math.sqrt(d*d+f*f),d=(u=d/(E[x-1]=g))*p+(h=f/g)*y,m=-h*p+u*y,e)for(a=0;a<w;a++)y=S[a][x-1],g=S[a][x],S[a][x-1]=y*u+g*h,S[a][x]=-y*h+g*u}P[l]=0,P[s]=d,E[s]=m}for(x=0;x<b;x++)E[x]<o&&(E[x]=0);return{u:S,q:E,v:T}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})});var V1=Ls((Dce,B1)=>{"use strict";function b_(i,t){function e(){this.constructor=i}e.prototype=t.prototype,i.prototype=new e}function In(i,t,e,r){this.message=i,this.expected=t,this.found=e,this.location=r,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,In)}b_(In,Error);In.buildMessage=function(i,t){var e={literal:function(c){return'"'+o(c.text)+'"'},class:function(c){var u="",d;for(d=0;d<c.parts.length;d++)u+=c.parts[d]instanceof Array?n(c.parts[d][0])+"-"+n(c.parts[d][1]):n(c.parts[d]);return"["+(c.inverted?"^":"")+u+"]"},any:function(c){return"any character"},end:function(c){return"end of input"},other:function(c){return c.description}};function r(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"+r(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+r(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"+r(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+r(u)})}function a(c){return e[c.type](c)}function s(c){var u=new Array(c.length),d,p;for(d=0;d<c.length;d++)u[d]=a(c[d]);if(u.sort(),u.length>0){for(d=1,p=1;d<u.length;d++)u[d-1]!==u[d]&&(u[p]=u[d],p++);u.length=p}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(t)+" found."};function v_(i,t){t=t!==void 0?t:{};var e={},r={svg_path:Rs},o=Rs,n=function(v){if(!v)return[];for(var O=[],L=0;L<v.length;L++)O=O.concat.apply(O,v[L]);var I=O[0];return I&&I.code=="m"&&(delete I.relative,I.code="M"),O},a=function(v,O){return xw(v,O)},s=/^[Mm]/,l=Qe(["M","m"],!1,!1),c=function(v,O,L){var I=Ln(v,[O]);return L&&(I=I.concat(Ln(v=="M"?"L":"l",L[1]))),I},u=/^[Zz]/,d=Qe(["Z","z"],!1,!1),p=function(){return Ln("Z")},f=/^[Ll]/,h=Qe(["L","l"],!1,!1),m=function(v,O){return Ln(v,O)},y=/^[Hh]/,g=Qe(["H","h"],!1,!1),b=function(v,O){return Ln(v,O.map(function(L){return{x:L}}))},w=/^[Vv]/,P=Qe(["V","v"],!1,!1),S=function(v,O){return Ln(v,O.map(function(L){return{y:L}}))},T=/^[Cc]/,A=Qe(["C","c"],!1,!1),x=function(v,O,L){return{x1:v.x,y1:v.y,x2:O.x,y2:O.y,x:L.x,y:L.y}},N=/^[Ss]/,E=Qe(["S","s"],!1,!1),M=function(v,O){return{x2:v.x,y2:v.y,x:O.x,y:O.y}},D=/^[Qq]/,_=Qe(["Q","q"],!1,!1),R=function(v,O){return{x1:v.x,y1:v.y,x:O.x,y:O.y}},V=/^[Tt]/,U=Qe(["T","t"],!1,!1),B=/^[Aa]/,q=Qe(["A","a"],!1,!1),j=function(v,O,L,I,z,oe){return{rx:v,ry:O,xAxisRotation:L,largeArc:I,sweep:z,x:oe.x,y:oe.y}},F=function(v,O){return{x:v,y:O}},H=function(v){return v*1},W=function(v){return v.join("")*1},ee=/^[01]/,te=Qe(["0","1"],!1,!1),Y=function(v){return v=="1"},re=function(){return""},K=",",Z=nt(",",!1),Q=function(v){return v.join("")},$=".",de=nt(".",!1),le=/^[eE]/,ie=Qe(["e","E"],!1,!1),ce=/^[+\-]/,ae=Qe(["+","-"],!1,!1),me=/^[0-9]/,fe=Qe([["0","9"]],!1,!1),he=function(v){return v.join("")},be=/^[ \t\n\r]/,ye=Qe([" "," ",`
|
|
2
|
-
`,"\r"],!1,!1),C=0,ne=0,De=[{line:1,column:1}],ze=0,Re=[],Oe=0,Ot;if("startRule"in t){if(!(t.startRule in r))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');o=r[t.startRule]}function Ie(){return i.substring(ne,C)}function wt(){return Xi(ne,C)}function Tt(v,O){throw O=O!==void 0?O:Xi(ne,C),xr([Qd(v)],i.substring(ne,C),O)}function $i(v,O){throw O=O!==void 0?O:Xi(ne,C),Zd(v,O)}function nt(v,O){return{type:"literal",text:v,ignoreCase:O}}function Qe(v,O,L){return{type:"class",parts:v,inverted:O,ignoreCase:L}}function _r(){return{type:"any"}}function Kd(){return{type:"end"}}function Qd(v){return{type:"other",description:v}}function $l(v){var O=De[v],L;if(O)return O;for(L=v-1;!De[L];)L--;for(O=De[L],O={line:O.line,column:O.column};L<v;)i.charCodeAt(L)===10?(O.line++,O.column=1):O.column++,L++;return De[v]=O,O}function Xi(v,O){var L=$l(v),I=$l(O);return{start:{offset:v,line:L.line,column:L.column},end:{offset:O,line:I.line,column:I.column}}}function pt(v){C<ze||(C>ze&&(ze=C,Re=[]),Re.push(v))}function Zd(v,O){return new In(v,null,null,O)}function xr(v,O,L){return new In(In.buildMessage(v,O),v,O,L)}function Rs(){var v,O,L,I,z;for(v=C,O=[],L=Ge();L!==e;)O.push(L),L=Ge();if(O!==e)if(L=qt(),L===e&&(L=null),L!==e){for(I=[],z=Ge();z!==e;)I.push(z),z=Ge();I!==e?(ne=v,O=n(L),v=O):(C=v,v=e)}else C=v,v=e;else C=v,v=e;return v}function qt(){var v,O,L,I,z,oe;if(v=C,O=Yi(),O!==e){for(L=[],I=C,z=[],oe=Ge();oe!==e;)z.push(oe),oe=Ge();for(z!==e?(oe=Yi(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;){for(L.push(I),I=C,z=[],oe=Ge();oe!==e;)z.push(oe),oe=Ge();z!==e?(oe=Yi(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e)}L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function Yi(){var v,O,L,I,z,oe;if(v=C,O=_n(),O!==e){for(L=[],I=C,z=[],oe=Ge();oe!==e;)z.push(oe),oe=Ge();for(z!==e?(oe=Xl(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;){for(L.push(I),I=C,z=[],oe=Ge();oe!==e;)z.push(oe),oe=Ge();z!==e?(oe=Xl(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e)}L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function Xl(){var v;return v=ow(),v===e&&(v=iw(),v===e&&(v=nw(),v===e&&(v=aw(),v===e&&(v=sw(),v===e&&(v=cw(),v===e&&(v=dw(),v===e&&(v=fw(),v===e&&(v=mw())))))))),v}function _n(){var v,O,L,I,z,oe,Bn;if(v=C,s.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(l)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=Xt(),I!==e?(z=C,oe=rt(),oe===e&&(oe=null),oe!==e?(Bn=bm(),Bn!==e?(oe=[oe,Bn],z=oe):(C=z,z=e)):(C=z,z=e),z===e&&(z=null),z!==e?(ne=v,O=c(O,I,z),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function ow(){var v,O;return v=C,u.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(d)),O!==e&&(ne=v,O=p()),v=O,v}function iw(){var v,O,L,I;if(v=C,f.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(h)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=bm(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function bm(){var v,O,L,I,z,oe;if(v=C,O=Xt(),O!==e){for(L=[],I=C,z=rt(),z===e&&(z=null),z!==e?(oe=Xt(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=rt(),z===e&&(z=null),z!==e?(oe=Xt(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function nw(){var v,O,L,I;if(v=C,y.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(g)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=vm(),I!==e?(ne=v,O=b(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function vm(){var v,O,L,I,z,oe;if(v=C,O=Rn(),O!==e){for(L=[],I=C,z=rt(),z===e&&(z=null),z!==e?(oe=Rn(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=rt(),z===e&&(z=null),z!==e?(oe=Rn(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function aw(){var v,O,L,I;if(v=C,w.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(P)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=vm(),I!==e?(ne=v,O=S(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function sw(){var v,O,L,I;if(v=C,T.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(A)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=lw(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function lw(){var v,O,L,I,z,oe;if(v=C,O=Jd(),O!==e){for(L=[],I=C,z=rt(),z===e&&(z=null),z!==e?(oe=Jd(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=rt(),z===e&&(z=null),z!==e?(oe=Jd(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function Jd(){var v,O,L,I,z,oe;return v=C,O=Xt(),O!==e?(L=rt(),L===e&&(L=null),L!==e?(I=Xt(),I!==e?(z=rt(),z===e&&(z=null),z!==e?(oe=Xt(),oe!==e?(ne=v,O=x(O,I,oe),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function cw(){var v,O,L,I;if(v=C,N.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(E)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=uw(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function uw(){var v,O,L,I,z,oe;if(v=C,O=ep(),O!==e){for(L=[],I=C,z=rt(),z===e&&(z=null),z!==e?(oe=ep(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=rt(),z===e&&(z=null),z!==e?(oe=ep(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function ep(){var v,O,L,I;return v=C,O=Xt(),O!==e?(L=rt(),L===e&&(L=null),L!==e?(I=Xt(),I!==e?(ne=v,O=M(O,I),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function dw(){var v,O,L,I;if(v=C,D.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(_)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=pw(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function pw(){var v,O,L,I,z,oe;if(v=C,O=tp(),O!==e){for(L=[],I=C,z=rt(),z===e&&(z=null),z!==e?(oe=tp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=rt(),z===e&&(z=null),z!==e?(oe=tp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function tp(){var v,O,L,I;return v=C,O=Xt(),O!==e?(L=rt(),L===e&&(L=null),L!==e?(I=Xt(),I!==e?(ne=v,O=R(O,I),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function fw(){var v,O,L,I;if(v=C,V.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(U)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=hw(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function hw(){var v,O,L,I,z,oe;if(v=C,O=Xt(),O!==e){for(L=[],I=C,z=rt(),z===e&&(z=null),z!==e?(oe=Xt(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=rt(),z===e&&(z=null),z!==e?(oe=Xt(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function mw(){var v,O,L,I;if(v=C,B.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(q)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=yw(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function yw(){var v,O,L,I,z,oe;if(v=C,O=rp(),O!==e){for(L=[],I=C,z=rt(),z===e&&(z=null),z!==e?(oe=rp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=rt(),z===e&&(z=null),z!==e?(oe=rp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function rp(){var v,O,L,I,z,oe,Bn,ip,Kl,np,Ql,ap;return v=C,O=Sm(),O!==e?(L=rt(),L===e&&(L=null),L!==e?(I=Sm(),I!==e?(z=rt(),z===e&&(z=null),z!==e?(oe=Rn(),oe!==e?(Bn=rt(),Bn!==e?(ip=wm(),ip!==e?(Kl=rt(),Kl===e&&(Kl=null),Kl!==e?(np=wm(),np!==e?(Ql=rt(),Ql===e&&(Ql=null),Ql!==e?(ap=Xt(),ap!==e?(ne=v,O=j(O,I,oe,ip,np,ap),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function Xt(){var v,O,L,I;return v=C,O=Rn(),O!==e?(L=rt(),L===e&&(L=null),L!==e?(I=Rn(),I!==e?(ne=v,O=F(O,I),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function Sm(){var v,O;return v=C,O=Om(),O===e&&(O=Ki()),O!==e&&(ne=v,O=H(O)),v=O,v}function Rn(){var v,O,L,I;return v=C,O=C,L=op(),L===e&&(L=null),L!==e?(I=Om(),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e),O===e&&(O=C,L=op(),L===e&&(L=null),L!==e?(I=Ki(),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e)),O!==e&&(ne=v,O=W(O)),v=O,v}function wm(){var v,O;return v=C,ee.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(te)),O!==e&&(ne=v,O=Y(O)),v=O,v}function rt(){var v,O,L,I,z;if(v=C,O=[],L=Ge(),L!==e)for(;L!==e;)O.push(L),L=Ge();else O=e;if(O!==e)if(L=Pm(),L===e&&(L=null),L!==e){for(I=[],z=Ge();z!==e;)I.push(z),z=Ge();I!==e?(O=[O,L,I],v=O):(C=v,v=e)}else C=v,v=e;else C=v,v=e;if(v===e){if(v=C,O=C,L=Pm(),L!==e){for(I=[],z=Ge();z!==e;)I.push(z),z=Ge();I!==e?(L=[L,I],O=L):(C=O,O=e)}else C=O,O=e;O!==e&&(ne=v,O=re()),v=O}return v}function Pm(){var v;return i.charCodeAt(C)===44?(v=K,C++):(v=e,Oe===0&&pt(Z)),v}function Om(){var v,O,L,I;return v=C,O=C,L=gw(),L!==e?(I=Tm(),I===e&&(I=null),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e),O===e&&(O=C,L=Ki(),L!==e?(I=Tm(),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e)),O!==e&&(ne=v,O=Q(O)),v=O,v}function gw(){var v,O,L,I,z;return v=C,O=C,L=Ki(),L===e&&(L=null),L!==e?(i.charCodeAt(C)===46?(I=$,C++):(I=e,Oe===0&&pt(de)),I!==e?(z=Ki(),z!==e?(L=[L,I,z],O=L):(C=O,O=e)):(C=O,O=e)):(C=O,O=e),O===e&&(O=C,L=Ki(),L!==e?(i.charCodeAt(C)===46?(I=$,C++):(I=e,Oe===0&&pt(de)),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e)),O!==e&&(ne=v,O=Q(O)),v=O,v}function Tm(){var v,O,L,I,z;return v=C,O=C,le.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Oe===0&&pt(ie)),L!==e?(I=op(),I===e&&(I=null),I!==e?(z=Ki(),z!==e?(L=[L,I,z],O=L):(C=O,O=e)):(C=O,O=e)):(C=O,O=e),O!==e&&(ne=v,O=Q(O)),v=O,v}function op(){var v;return ce.test(i.charAt(C))?(v=i.charAt(C),C++):(v=e,Oe===0&&pt(ae)),v}function Ki(){var v,O,L;if(v=C,O=[],me.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Oe===0&&pt(fe)),L!==e)for(;L!==e;)O.push(L),me.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Oe===0&&pt(fe));else O=e;return O!==e&&(ne=v,O=he(O)),v=O,v}function Ge(){var v,O;return v=C,be.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(ye)),O!==e&&(ne=v,O=re()),v=O,v}function xw(v,O){if(!O)return[v];for(var L=[v],I=0,z=O.length;I<z;I++)L[I+1]=O[I][1];return L}var Yl={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 Cm in Yl)Yl[Cm.toUpperCase()]=Yl[Cm];function Ln(v,O){O||(O=[{}]);for(var L=O.length;L--;){var I={code:v,command:Yl[v]};v==v.toLowerCase()&&(I.relative=!0);for(var z in O[L])I[z]=O[L][z];O[L]=I}return O}if(Ot=o(),Ot!==e&&C===i.length)return Ot;throw Ot!==e&&C<i.length&&pt(Kd()),xr(Re,ze<i.length?i.charAt(ze):null,ze<i.length?Xi(ze,ze+1):Xi(ze,ze))}B1.exports={SyntaxError:In,parse:v_}});var qh=Ls((_ce,z1)=>{var Md=V1().parse;Md.parseSVG=Md;Md.makeAbsolute=S_;z1.exports=Md;function S_(i){var t,e={x:0,y:0},r={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return i.forEach(function(o){o.command==="moveto"&&(t=o),o.x0=e.x,o.y0=e.y;for(var n in r)n in o&&(o[n]+=o.relative?o[r[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=t.x,o.y=t.y),e=o}),i}});var ew=Ls((Jye,JS)=>{JS.exports=function(t,e){for(var r=t.split("."),o=e.split("."),n=0;n<3;n++){var a=Number(r[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 PL,Loader as OL}from"three";function Jl(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function Ct(i,t){return Object.setPrototypeOf(i,t),i}function ec(i){return Array.isArray(i)?i:[i]}function tc(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var Aw=typeof global=="object"&&global&&global.Object===Object&&global,rc=Aw;var Mw=typeof self=="object"&&self&&self.Object===Object&&self,Iw=rc||Mw||Function("return this")(),ft=Iw;var Ew=ft.Symbol,Dt=Ew;var Am=Object.prototype,Nw=Am.hasOwnProperty,Dw=Am.toString,Vs=Dt?Dt.toStringTag:void 0;function _w(i){var t=Nw.call(i,Vs),e=i[Vs];try{i[Vs]=void 0;var r=!0}catch{}var o=Dw.call(i);return r&&(t?i[Vs]=e:delete i[Vs]),o}var Mm=_w;var Rw=Object.prototype,Lw=Rw.toString;function Bw(i){return Lw.call(i)}var Im=Bw;var Vw="[object Null]",zw="[object Undefined]",Em=Dt?Dt.toStringTag:void 0;function Gw(i){return i==null?i===void 0?zw:Vw:Em&&Em in Object(i)?Mm(i):Im(i)}var dr=Gw;function Fw(i){return i!=null&&typeof i=="object"}var Gt=Fw;var jw="[object Symbol]";function Uw(i){return typeof i=="symbol"||Gt(i)&&dr(i)==jw}var ii=Uw;function kw(i,t){for(var e=-1,r=i==null?0:i.length,o=Array(r);++e<r;)o[e]=t(i[e],e,i);return o}var oc=kw;var Hw=Array.isArray,ht=Hw;var Ww=1/0,Nm=Dt?Dt.prototype:void 0,Dm=Nm?Nm.toString:void 0;function _m(i){if(typeof i=="string")return i;if(ht(i))return oc(i,_m)+"";if(ii(i))return Dm?Dm.call(i):"";var t=i+"";return t=="0"&&1/i==-Ww?"-0":t}var Rm=_m;var qw=/\s/;function $w(i){for(var t=i.length;t--&&qw.test(i.charAt(t)););return t}var Lm=$w;var Xw=/^\s+/;function Yw(i){return i&&i.slice(0,Lm(i)+1).replace(Xw,"")}var Bm=Yw;function Kw(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var mt=Kw;var Vm=0/0,Qw=/^[-+]0x[0-9a-f]+$/i,Zw=/^0b[01]+$/i,Jw=/^0o[0-7]+$/i,e2=parseInt;function t2(i){if(typeof i=="number")return i;if(ii(i))return Vm;if(mt(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=mt(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=Bm(i);var e=Zw.test(i);return e||Jw.test(i)?e2(i.slice(2),e?2:8):Qw.test(i)?Vm:+i}var sp=t2;function r2(i){return i}var zm=r2;var o2="[object AsyncFunction]",i2="[object Function]",n2="[object GeneratorFunction]",a2="[object Proxy]";function s2(i){if(!mt(i))return!1;var t=dr(i);return t==i2||t==n2||t==o2||t==a2}var ic=s2;var l2=ft["__core-js_shared__"],nc=l2;var Gm=function(){var i=/[^.]+$/.exec(nc&&nc.keys&&nc.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function c2(i){return!!Gm&&Gm in i}var Fm=c2;var u2=Function.prototype,d2=u2.toString;function p2(i){if(i!=null){try{return d2.call(i)}catch{}try{return i+""}catch{}}return""}var Mo=p2;var f2=/[\\^$.*+?()[\]{}|]/g,h2=/^\[object .+?Constructor\]$/,m2=Function.prototype,y2=Object.prototype,g2=m2.toString,x2=y2.hasOwnProperty,b2=RegExp("^"+g2.call(x2).replace(f2,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function v2(i){if(!mt(i)||Fm(i))return!1;var t=ic(i)?b2:h2;return t.test(Mo(i))}var jm=v2;function S2(i,t){return i?.[t]}var Um=S2;function w2(i,t){var e=Um(i,t);return jm(e)?e:void 0}var er=w2;var P2=er(ft,"WeakMap"),ac=P2;var km=Object.create,O2=function(){function i(){}return function(t){if(!mt(t))return{};if(km)return km(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),Hm=O2;function T2(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var Wm=T2;function C2(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var qm=C2;var A2=800,M2=16,I2=Date.now;function E2(i){var t=0,e=0;return function(){var r=I2(),o=M2-(r-e);if(e=r,o>0){if(++t>=A2)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var $m=E2;function N2(i){return function(){return i}}var Xm=N2;var D2=function(){try{var i=er(Object,"defineProperty");return i({},"",{}),i}catch{}}(),Vn=D2;var _2=Vn?function(i,t){return Vn(i,"toString",{configurable:!0,enumerable:!1,value:Xm(t),writable:!0})}:zm,Ym=_2;var R2=$m(Ym),Km=R2;function L2(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var Qm=L2;var B2=9007199254740991,V2=/^(?:0|[1-9]\d*)$/;function z2(i,t){var e=typeof i;return t=t??B2,!!t&&(e=="number"||e!="symbol"&&V2.test(i))&&i>-1&&i%1==0&&i<t}var zn=z2;function G2(i,t,e){t=="__proto__"&&Vn?Vn(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var sc=G2;function F2(i,t){return i===t||i!==i&&t!==t}var Gn=F2;var j2=Object.prototype,U2=j2.hasOwnProperty;function k2(i,t,e){var r=i[t];(!(U2.call(i,t)&&Gn(r,e))||e===void 0&&!(t in i))&&sc(i,t,e)}var Fn=k2;function H2(i,t,e,r){var o=!e;e||(e={});for(var n=-1,a=t.length;++n<a;){var s=t[n],l=r?r(e[s],i[s],s,e,i):void 0;l===void 0&&(l=i[s]),o?sc(e,s,l):Fn(e,s,l)}return e}var Jr=H2;var Zm=Math.max;function W2(i,t,e){return t=Zm(t===void 0?i.length-1:t,0),function(){for(var r=arguments,o=-1,n=Zm(r.length-t,0),a=Array(n);++o<n;)a[o]=r[t+o];o=-1;for(var s=Array(t+1);++o<t;)s[o]=r[o];return s[t]=e(a),Wm(i,this,s)}}var Jm=W2;var q2=9007199254740991;function $2(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=q2}var jn=$2;function X2(i){return i!=null&&jn(i.length)&&!ic(i)}var lc=X2;var Y2=Object.prototype;function K2(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||Y2;return i===e}var Un=K2;function Q2(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var ey=Q2;var Z2="[object Arguments]";function J2(i){return Gt(i)&&dr(i)==Z2}var lp=J2;var ty=Object.prototype,eP=ty.hasOwnProperty,tP=ty.propertyIsEnumerable,rP=lp(function(){return arguments}())?lp:function(i){return Gt(i)&&eP.call(i,"callee")&&!tP.call(i,"callee")},kn=rP;function oP(){return!1}var ry=oP;var ny=typeof exports=="object"&&exports&&!exports.nodeType&&exports,oy=ny&&typeof module=="object"&&module&&!module.nodeType&&module,iP=oy&&oy.exports===ny,iy=iP?ft.Buffer:void 0,nP=iy?iy.isBuffer:void 0,aP=nP||ry,Zi=aP;var sP="[object Arguments]",lP="[object Array]",cP="[object Boolean]",uP="[object Date]",dP="[object Error]",pP="[object Function]",fP="[object Map]",hP="[object Number]",mP="[object Object]",yP="[object RegExp]",gP="[object Set]",xP="[object String]",bP="[object WeakMap]",vP="[object ArrayBuffer]",SP="[object DataView]",wP="[object Float32Array]",PP="[object Float64Array]",OP="[object Int8Array]",TP="[object Int16Array]",CP="[object Int32Array]",AP="[object Uint8Array]",MP="[object Uint8ClampedArray]",IP="[object Uint16Array]",EP="[object Uint32Array]",ot={};ot[wP]=ot[PP]=ot[OP]=ot[TP]=ot[CP]=ot[AP]=ot[MP]=ot[IP]=ot[EP]=!0;ot[sP]=ot[lP]=ot[vP]=ot[cP]=ot[SP]=ot[uP]=ot[dP]=ot[pP]=ot[fP]=ot[hP]=ot[mP]=ot[yP]=ot[gP]=ot[xP]=ot[bP]=!1;function NP(i){return Gt(i)&&jn(i.length)&&!!ot[dr(i)]}var ay=NP;function DP(i){return function(t){return i(t)}}var Hn=DP;var sy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,zs=sy&&typeof module=="object"&&module&&!module.nodeType&&module,_P=zs&&zs.exports===sy,cp=_P&&rc.process,RP=function(){try{var i=zs&&zs.require&&zs.require("util").types;return i||cp&&cp.binding&&cp.binding("util")}catch{}}(),Io=RP;var ly=Io&&Io.isTypedArray,LP=ly?Hn(ly):ay,cc=LP;var BP=Object.prototype,VP=BP.hasOwnProperty;function zP(i,t){var e=ht(i),r=!e&&kn(i),o=!e&&!r&&Zi(i),n=!e&&!r&&!o&&cc(i),a=e||r||o||n,s=a?ey(i.length,String):[],l=s.length;for(var c in i)(t||VP.call(i,c))&&!(a&&(c=="length"||o&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||zn(c,l)))&&s.push(c);return s}var uc=zP;function GP(i,t){return function(e){return i(t(e))}}var dc=GP;var FP=dc(Object.keys,Object),cy=FP;var jP=Object.prototype,UP=jP.hasOwnProperty;function kP(i){if(!Un(i))return cy(i);var t=[];for(var e in Object(i))UP.call(i,e)&&e!="constructor"&&t.push(e);return t}var uy=kP;function HP(i){return lc(i)?uc(i):uy(i)}var Wn=HP;function WP(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var dy=WP;var qP=Object.prototype,$P=qP.hasOwnProperty;function XP(i){if(!mt(i))return dy(i);var t=Un(i),e=[];for(var r in i)r=="constructor"&&(t||!$P.call(i,r))||e.push(r);return e}var py=XP;function YP(i){return lc(i)?uc(i,!0):py(i)}var qn=YP;var KP=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,QP=/^\w*$/;function ZP(i,t){if(ht(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||ii(i)?!0:QP.test(i)||!KP.test(i)||t!=null&&i in Object(t)}var fy=ZP;var JP=er(Object,"create"),Eo=JP;function eO(){this.__data__=Eo?Eo(null):{},this.size=0}var hy=eO;function tO(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var my=tO;var rO="__lodash_hash_undefined__",oO=Object.prototype,iO=oO.hasOwnProperty;function nO(i){var t=this.__data__;if(Eo){var e=t[i];return e===rO?void 0:e}return iO.call(t,i)?t[i]:void 0}var yy=nO;var aO=Object.prototype,sO=aO.hasOwnProperty;function lO(i){var t=this.__data__;return Eo?t[i]!==void 0:sO.call(t,i)}var gy=lO;var cO="__lodash_hash_undefined__";function uO(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=Eo&&t===void 0?cO:t,this}var xy=uO;function $n(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}$n.prototype.clear=hy;$n.prototype.delete=my;$n.prototype.get=yy;$n.prototype.has=gy;$n.prototype.set=xy;var up=$n;function dO(){this.__data__=[],this.size=0}var by=dO;function pO(i,t){for(var e=i.length;e--;)if(Gn(i[e][0],t))return e;return-1}var ni=pO;var fO=Array.prototype,hO=fO.splice;function mO(i){var t=this.__data__,e=ni(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():hO.call(t,e,1),--this.size,!0}var vy=mO;function yO(i){var t=this.__data__,e=ni(t,i);return e<0?void 0:t[e][1]}var Sy=yO;function gO(i){return ni(this.__data__,i)>-1}var wy=gO;function xO(i,t){var e=this.__data__,r=ni(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var Py=xO;function Xn(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Xn.prototype.clear=by;Xn.prototype.delete=vy;Xn.prototype.get=Sy;Xn.prototype.has=wy;Xn.prototype.set=Py;var ai=Xn;var bO=er(ft,"Map"),si=bO;function vO(){this.size=0,this.__data__={hash:new up,map:new(si||ai),string:new up}}var Oy=vO;function SO(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var Ty=SO;function wO(i,t){var e=i.__data__;return Ty(t)?e[typeof t=="string"?"string":"hash"]:e.map}var li=wO;function PO(i){var t=li(this,i).delete(i);return this.size-=t?1:0,t}var Cy=PO;function OO(i){return li(this,i).get(i)}var Ay=OO;function TO(i){return li(this,i).has(i)}var My=TO;function CO(i,t){var e=li(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var Iy=CO;function Yn(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Yn.prototype.clear=Oy;Yn.prototype.delete=Cy;Yn.prototype.get=Ay;Yn.prototype.has=My;Yn.prototype.set=Iy;var Ji=Yn;var AO="Expected a function";function dp(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(AO);var e=function(){var r=arguments,o=t?t.apply(this,r):r[0],n=e.cache;if(n.has(o))return n.get(o);var a=i.apply(this,r);return e.cache=n.set(o,a)||n,a};return e.cache=new(dp.Cache||Ji),e}dp.Cache=Ji;var Ey=dp;var MO=500;function IO(i){var t=Ey(i,function(r){return e.size===MO&&e.clear(),r}),e=t.cache;return t}var Ny=IO;var EO=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,NO=/\\(\\)?/g,DO=Ny(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(EO,function(e,r,o,n){t.push(o?n.replace(NO,"$1"):r||e)}),t}),Dy=DO;function _O(i){return i==null?"":Rm(i)}var _y=_O;function RO(i,t){return ht(i)?i:fy(i,t)?[i]:Dy(_y(i))}var br=RO;var LO=1/0;function BO(i){if(typeof i=="string"||ii(i))return i;var t=i+"";return t=="0"&&1/i==-LO?"-0":t}var ci=BO;function VO(i,t){t=br(t,i);for(var e=0,r=t.length;i!=null&&e<r;)i=i[ci(t[e++])];return e&&e==r?i:void 0}var pc=VO;function zO(i,t){for(var e=-1,r=t.length,o=i.length;++e<r;)i[o+e]=t[e];return i}var Kn=zO;var Ry=Dt?Dt.isConcatSpreadable:void 0;function GO(i){return ht(i)||kn(i)||!!(Ry&&i&&i[Ry])}var Ly=GO;function By(i,t,e,r,o){var n=-1,a=i.length;for(e||(e=Ly),o||(o=[]);++n<a;){var s=i[n];t>0&&e(s)?t>1?By(s,t-1,e,r,o):Kn(o,s):r||(o[o.length]=s)}return o}var Vy=By;function FO(i){var t=i==null?0:i.length;return t?Vy(i,1):[]}var zy=FO;function jO(i){return Km(Jm(i,void 0,zy),i+"")}var fc=jO;var UO=dc(Object.getPrototypeOf,Object),Qn=UO;var kO="[object Object]",HO=Function.prototype,WO=Object.prototype,Gy=HO.toString,qO=WO.hasOwnProperty,$O=Gy.call(Object);function XO(i){if(!Gt(i)||dr(i)!=kO)return!1;var t=Qn(i);if(t===null)return!0;var e=qO.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&Gy.call(e)==$O}var Fy=XO;function YO(i,t,e){var r=-1,o=i.length;t<0&&(t=-t>o?0:o+t),e=e>o?o:e,e<0&&(e+=o),o=t>e?0:e-t>>>0,t>>>=0;for(var n=Array(o);++r<o;)n[r]=i[r+t];return n}var jy=YO;function KO(){this.__data__=new ai,this.size=0}var Uy=KO;function QO(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var ky=QO;function ZO(i){return this.__data__.get(i)}var Hy=ZO;function JO(i){return this.__data__.has(i)}var Wy=JO;var eT=200;function tT(i,t){var e=this.__data__;if(e instanceof ai){var r=e.__data__;if(!si||r.length<eT-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new Ji(r)}return e.set(i,t),this.size=e.size,this}var qy=tT;function Zn(i){var t=this.__data__=new ai(i);this.size=t.size}Zn.prototype.clear=Uy;Zn.prototype.delete=ky;Zn.prototype.get=Hy;Zn.prototype.has=Wy;Zn.prototype.set=qy;var Jn=Zn;function rT(i,t){return i&&Jr(t,Wn(t),i)}var $y=rT;function oT(i,t){return i&&Jr(t,qn(t),i)}var Xy=oT;var Zy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Yy=Zy&&typeof module=="object"&&module&&!module.nodeType&&module,iT=Yy&&Yy.exports===Zy,Ky=iT?ft.Buffer:void 0,Qy=Ky?Ky.allocUnsafe:void 0;function nT(i,t){if(t)return i.slice();var e=i.length,r=Qy?Qy(e):new i.constructor(e);return i.copy(r),r}var Jy=nT;function aT(i,t){for(var e=-1,r=i==null?0:i.length,o=0,n=[];++e<r;){var a=i[e];t(a,e,i)&&(n[o++]=a)}return n}var eg=aT;function sT(){return[]}var hc=sT;var lT=Object.prototype,cT=lT.propertyIsEnumerable,tg=Object.getOwnPropertySymbols,uT=tg?function(i){return i==null?[]:(i=Object(i),eg(tg(i),function(t){return cT.call(i,t)}))}:hc,ea=uT;function dT(i,t){return Jr(i,ea(i),t)}var rg=dT;var pT=Object.getOwnPropertySymbols,fT=pT?function(i){for(var t=[];i;)Kn(t,ea(i)),i=Qn(i);return t}:hc,mc=fT;function hT(i,t){return Jr(i,mc(i),t)}var og=hT;function mT(i,t,e){var r=t(i);return ht(i)?r:Kn(r,e(i))}var yc=mT;function yT(i){return yc(i,Wn,ea)}var Gs=yT;function gT(i){return yc(i,qn,mc)}var gc=gT;var xT=er(ft,"DataView"),xc=xT;var bT=er(ft,"Promise"),bc=bT;var vT=er(ft,"Set"),vc=vT;var ig="[object Map]",ST="[object Object]",ng="[object Promise]",ag="[object Set]",sg="[object WeakMap]",lg="[object DataView]",wT=Mo(xc),PT=Mo(si),OT=Mo(bc),TT=Mo(vc),CT=Mo(ac),en=dr;(xc&&en(new xc(new ArrayBuffer(1)))!=lg||si&&en(new si)!=ig||bc&&en(bc.resolve())!=ng||vc&&en(new vc)!=ag||ac&&en(new ac)!=sg)&&(en=function(i){var t=dr(i),e=t==ST?i.constructor:void 0,r=e?Mo(e):"";if(r)switch(r){case wT:return lg;case PT:return ig;case OT:return ng;case TT:return ag;case CT:return sg}return t});var No=en;var AT=Object.prototype,MT=AT.hasOwnProperty;function IT(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&MT.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var cg=IT;var ET=ft.Uint8Array,ta=ET;function NT(i){var t=new i.constructor(i.byteLength);return new ta(t).set(new ta(i)),t}var ra=NT;function DT(i,t){var e=t?ra(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var ug=DT;var _T=/\w*$/;function RT(i){var t=new i.constructor(i.source,_T.exec(i));return t.lastIndex=i.lastIndex,t}var dg=RT;var pg=Dt?Dt.prototype:void 0,fg=pg?pg.valueOf:void 0;function LT(i){return fg?Object(fg.call(i)):{}}var hg=LT;function BT(i,t){var e=t?ra(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var mg=BT;var VT="[object Boolean]",zT="[object Date]",GT="[object Map]",FT="[object Number]",jT="[object RegExp]",UT="[object Set]",kT="[object String]",HT="[object Symbol]",WT="[object ArrayBuffer]",qT="[object DataView]",$T="[object Float32Array]",XT="[object Float64Array]",YT="[object Int8Array]",KT="[object Int16Array]",QT="[object Int32Array]",ZT="[object Uint8Array]",JT="[object Uint8ClampedArray]",eC="[object Uint16Array]",tC="[object Uint32Array]";function rC(i,t,e){var r=i.constructor;switch(t){case WT:return ra(i);case VT:case zT:return new r(+i);case qT:return ug(i,e);case $T:case XT:case YT:case KT:case QT:case ZT:case JT:case eC:case tC:return mg(i,e);case GT:return new r;case FT:case kT:return new r(i);case jT:return dg(i);case UT:return new r;case HT:return hg(i)}}var yg=rC;function oC(i){return typeof i.constructor=="function"&&!Un(i)?Hm(Qn(i)):{}}var gg=oC;var iC="[object Map]";function nC(i){return Gt(i)&&No(i)==iC}var xg=nC;var bg=Io&&Io.isMap,aC=bg?Hn(bg):xg,vg=aC;var sC="[object Set]";function lC(i){return Gt(i)&&No(i)==sC}var Sg=lC;var wg=Io&&Io.isSet,cC=wg?Hn(wg):Sg,Pg=cC;var uC=1,dC=2,pC=4,Og="[object Arguments]",fC="[object Array]",hC="[object Boolean]",mC="[object Date]",yC="[object Error]",Tg="[object Function]",gC="[object GeneratorFunction]",xC="[object Map]",bC="[object Number]",Cg="[object Object]",vC="[object RegExp]",SC="[object Set]",wC="[object String]",PC="[object Symbol]",OC="[object WeakMap]",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]",et={};et[Og]=et[fC]=et[TC]=et[CC]=et[hC]=et[mC]=et[AC]=et[MC]=et[IC]=et[EC]=et[NC]=et[xC]=et[bC]=et[Cg]=et[vC]=et[SC]=et[wC]=et[PC]=et[DC]=et[_C]=et[RC]=et[LC]=!0;et[yC]=et[Tg]=et[OC]=!1;function Sc(i,t,e,r,o,n){var a,s=t&uC,l=t&dC,c=t&pC;if(e&&(a=o?e(i,r,o,n):e(i)),a!==void 0)return a;if(!mt(i))return i;var u=ht(i);if(u){if(a=cg(i),!s)return qm(i,a)}else{var d=No(i),p=d==Tg||d==gC;if(Zi(i))return Jy(i,s);if(d==Cg||d==Og||p&&!o){if(a=l||p?{}:gg(i),!s)return l?og(i,Xy(a,i)):rg(i,$y(a,i))}else{if(!et[d])return o?i:{};a=yg(i,d,s)}}n||(n=new Jn);var f=n.get(i);if(f)return f;n.set(i,a),Pg(i)?i.forEach(function(y){a.add(Sc(y,t,e,y,i,n))}):vg(i)&&i.forEach(function(y,g){a.set(g,Sc(y,t,e,g,i,n))});var h=c?l?gc:Gs:l?qn:Wn,m=u?void 0:h(i);return Qm(m||i,function(y,g){m&&(g=y,y=i[g]),Fn(a,g,Sc(y,t,e,g,i,n))}),a}var wc=Sc;var BC=1,VC=4;function zC(i){return wc(i,BC|VC)}var Do=zC;var GC="__lodash_hash_undefined__";function FC(i){return this.__data__.set(i,GC),this}var Ag=FC;function jC(i){return this.__data__.has(i)}var Mg=jC;function Pc(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new Ji;++t<e;)this.add(i[t])}Pc.prototype.add=Pc.prototype.push=Ag;Pc.prototype.has=Mg;var Ig=Pc;function UC(i,t){for(var e=-1,r=i==null?0:i.length;++e<r;)if(t(i[e],e,i))return!0;return!1}var Eg=UC;function kC(i,t){return i.has(t)}var Ng=kC;var HC=1,WC=2;function qC(i,t,e,r,o,n){var a=e&HC,s=i.length,l=t.length;if(s!=l&&!(a&&l>s))return!1;var c=n.get(i),u=n.get(t);if(c&&u)return c==t&&u==i;var d=-1,p=!0,f=e&WC?new Ig:void 0;for(n.set(i,t),n.set(t,i);++d<s;){var h=i[d],m=t[d];if(r)var y=a?r(m,h,d,t,i,n):r(h,m,d,i,t,n);if(y!==void 0){if(y)continue;p=!1;break}if(f){if(!Eg(t,function(g,b){if(!Ng(f,b)&&(h===g||o(h,g,e,r,n)))return f.push(b)})){p=!1;break}}else if(!(h===m||o(h,m,e,r,n))){p=!1;break}}return n.delete(i),n.delete(t),p}var Oc=qC;function $C(i){var t=-1,e=Array(i.size);return i.forEach(function(r,o){e[++t]=[o,r]}),e}var Dg=$C;function XC(i){var t=-1,e=Array(i.size);return i.forEach(function(r){e[++t]=r}),e}var _g=XC;var YC=1,KC=2,QC="[object Boolean]",ZC="[object Date]",JC="[object Error]",eA="[object Map]",tA="[object Number]",rA="[object RegExp]",oA="[object Set]",iA="[object String]",nA="[object Symbol]",aA="[object ArrayBuffer]",sA="[object DataView]",Rg=Dt?Dt.prototype:void 0,pp=Rg?Rg.valueOf:void 0;function lA(i,t,e,r,o,n,a){switch(e){case sA:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case aA:return!(i.byteLength!=t.byteLength||!n(new ta(i),new ta(t)));case QC:case ZC:case tA:return Gn(+i,+t);case JC:return i.name==t.name&&i.message==t.message;case rA:case iA:return i==t+"";case eA:var s=Dg;case oA:var l=r&YC;if(s||(s=_g),i.size!=t.size&&!l)return!1;var c=a.get(i);if(c)return c==t;r|=KC,a.set(i,t);var u=Oc(s(i),s(t),r,o,n,a);return a.delete(i),u;case nA:if(pp)return pp.call(i)==pp.call(t)}return!1}var Lg=lA;var cA=1,uA=Object.prototype,dA=uA.hasOwnProperty;function pA(i,t,e,r,o,n){var a=e&cA,s=Gs(i),l=s.length,c=Gs(t),u=c.length;if(l!=u&&!a)return!1;for(var d=l;d--;){var p=s[d];if(!(a?p in t:dA.call(t,p)))return!1}var f=n.get(i),h=n.get(t);if(f&&h)return f==t&&h==i;var m=!0;n.set(i,t),n.set(t,i);for(var y=a;++d<l;){p=s[d];var g=i[p],b=t[p];if(r)var w=a?r(b,g,p,t,i,n):r(g,b,p,i,t,n);if(!(w===void 0?g===b||o(g,b,e,r,n):w)){m=!1;break}y||(y=p=="constructor")}if(m&&!y){var P=i.constructor,S=t.constructor;P!=S&&"constructor"in i&&"constructor"in t&&!(typeof P=="function"&&P instanceof P&&typeof S=="function"&&S instanceof S)&&(m=!1)}return n.delete(i),n.delete(t),m}var Bg=pA;var fA=1,Vg="[object Arguments]",zg="[object Array]",Tc="[object Object]",hA=Object.prototype,Gg=hA.hasOwnProperty;function mA(i,t,e,r,o,n){var a=ht(i),s=ht(t),l=a?zg:No(i),c=s?zg:No(t);l=l==Vg?Tc:l,c=c==Vg?Tc:c;var u=l==Tc,d=c==Tc,p=l==c;if(p&&Zi(i)){if(!Zi(t))return!1;a=!0,u=!1}if(p&&!u)return n||(n=new Jn),a||cc(i)?Oc(i,t,e,r,o,n):Lg(i,t,l,e,r,o,n);if(!(e&fA)){var f=u&&Gg.call(i,"__wrapped__"),h=d&&Gg.call(t,"__wrapped__");if(f||h){var m=f?i.value():i,y=h?t.value():t;return n||(n=new Jn),o(m,y,e,r,n)}}return p?(n||(n=new Jn),Bg(i,t,e,r,o,n)):!1}var Fg=mA;function jg(i,t,e,r,o){return i===t?!0:i==null||t==null||!Gt(i)&&!Gt(t)?i!==i&&t!==t:Fg(i,t,e,r,jg,o)}var Ug=jg;function yA(i,t){return i!=null&&t in Object(i)}var kg=yA;function gA(i,t,e){t=br(t,i);for(var r=-1,o=t.length,n=!1;++r<o;){var a=ci(t[r]);if(!(n=i!=null&&e(i,a)))break;i=i[a]}return n||++r!=o?n:(o=i==null?0:i.length,!!o&&jn(o)&&zn(a,o)&&(ht(i)||kn(i)))}var Hg=gA;function xA(i,t){return i!=null&&Hg(i,t,kg)}var Wg=xA;var bA=function(){return ft.Date.now()},Cc=bA;var vA="Expected a function",SA=Math.max,wA=Math.min;function PA(i,t,e){var r,o,n,a,s,l,c=0,u=!1,d=!1,p=!0;if(typeof i!="function")throw new TypeError(vA);t=sp(t)||0,mt(e)&&(u=!!e.leading,d="maxWait"in e,n=d?SA(sp(e.maxWait)||0,t):n,p="trailing"in e?!!e.trailing:p);function f(T){var A=r,x=o;return r=o=void 0,c=T,a=i.apply(x,A),a}function h(T){return c=T,s=setTimeout(g,t),u?f(T):a}function m(T){var A=T-l,x=T-c,N=t-A;return d?wA(N,n-x):N}function y(T){var A=T-l,x=T-c;return l===void 0||A>=t||A<0||d&&x>=n}function g(){var T=Cc();if(y(T))return b(T);s=setTimeout(g,m(T))}function b(T){return s=void 0,p&&r?f(T):(r=o=void 0,a)}function w(){s!==void 0&&clearTimeout(s),c=0,r=l=o=s=void 0}function P(){return s===void 0?a:b(Cc())}function S(){var T=Cc(),A=y(T);if(r=arguments,o=this,l=T,A){if(s===void 0)return h(l);if(d)return clearTimeout(s),s=setTimeout(g,t),f(l)}return s===void 0&&(s=setTimeout(g,t)),a}return S.cancel=w,S.flush=P,S}var Ac=PA;function OA(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var qg=OA;function TA(i,t){return t.length<2?i:pc(i,jy(t,0,-1))}var $g=TA;function CA(i,t){return Ug(i,t)}var fp=CA;function AA(i,t){return t=br(t,i),i=$g(i,t),i==null||delete i[ci(qg(t))]}var Xg=AA;function MA(i){return Fy(i)?void 0:i}var Yg=MA;var IA=1,EA=2,NA=4,DA=fc(function(i,t){var e={};if(i==null)return e;var r=!1;t=oc(t,function(n){return n=br(n,i),r||(r=n.length>1),n}),Jr(i,gc(i),e),r&&(e=wc(e,IA|EA|NA,Yg));for(var o=t.length;o--;)Xg(e,t[o]);return e}),oa=DA;function _A(i,t,e,r){if(!mt(i))return i;t=br(t,i);for(var o=-1,n=t.length,a=n-1,s=i;s!=null&&++o<n;){var l=ci(t[o]),c=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(o!=a){var u=s[l];c=r?r(u,l,s):void 0,c===void 0&&(c=mt(u)?u:zn(t[o+1])?[]:{})}Fn(s,l,c),s=s[l]}return i}var Kg=_A;function RA(i,t,e){for(var r=-1,o=t.length,n={};++r<o;){var a=t[r],s=pc(i,a);e(s,a)&&Kg(n,br(a,i),s)}return n}var Qg=RA;function LA(i,t){return Qg(i,t,function(e,r){return Wg(i,r)})}var Zg=LA;var BA=fc(function(i,t){return i==null?{}:Zg(i,t)}),Rr=BA;var ue=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let n={...r,[t]:e};return Object.setPrototypeOf(n,ue.prototype),n}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],o;r===void 0?o={type:2,id:t.id}:o={type:1,id:t.id,data:r};let{id:n,data:a}=t,s={...e,[n]:a};return Object.setPrototypeOf(s,ue.prototype),{data:s,actual:t,reverse:o}}else if(t.type===2){let{id:r}=t,o=e[r];if(o===void 0)return null;{let n={...e};return Object.setPrototypeOf(n,ue.prototype),delete n[r],{data:n,actual:t,reverse:{type:1,id:r,data:o}}}}return null}};function Fs(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let r=i[e];r&&typeof r=="object"&&Fs(r)}return Object.freeze(i)}function Jg(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var ia=class extends Error{};function Mc(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function eo(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let n=i;i=t,t=n}let r=[],o=1/(e+1);for(let n=0;n<e;n++){let a=i+(t-i)*(n+.75+Math.random()*.5)*o;r.push(a)}return r}function na(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 e0(){return typeof process<"u"}function t0(i,t){for(let e of i)t(e.id,e.data)!==!0&&t0(e.children,t)}function r0(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)r0(e,t)}var Ze=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Ze.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Fs(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,r){if(!this.has(e))return!0;for(;e;){let o=this.parent(e);if(o===r)return!0;e=o}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let o=this.parent(e);if(o===r)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,r){if(e===null)this.traverse(r);else{let o=this.get(e);o&&r0(o,r)}}traverse(e){t0(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let 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:r},this.modifyArrayBy(n,a)}}modifyArrayBy(e,r){let o=e,n=r;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,Ze.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:r}){if(this.get(e)!==void 0)return!0;for(let o of r)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:r,fi:o,id:n,data:a,children:s}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,c=this.childrenArray(l),u={fi:o,id:n,data:a,children:s};return c=[...c,u],c.sort((p,f)=>p.fi-f.fi),e.localIndex=c.indexOf(u),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:n}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let o=this.parent(r);if(o===void 0)return null;let n=this.childrenArray(o),a=n.findIndex(c=>c.id===r);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:r,fi:o,id:n}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:n});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===n)throw new ia("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],d=this.modifyArrayBy(a,l);a=r,l=d.childrenArray(a);let p=u.fi;return u={...u,fi:o},l=[...l,u],l.sort((f,h)=>f.fi-h.fi),e.localIndex=l.indexOf(u),d=d.modifyArrayBy(a,l),{data:d,actual:e,reverse:{type:9,parent:s,fi:p,id:n}}}previous(e,r){if(r===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===r)return o;o=n.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),n=o.findIndex(a=>a.id===e)+1;if(n<o.length)return o[n].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),n=o.findIndex(a=>a.id===e)-1;return n>=0?this.traverseSortPrevious(o[n].id):r}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push({...o,...n})}r.sort((o,n)=>Jg(o.sortKey,n.sortKey));for(let o of r)delete o.sortKey;return r}getWithSortKey(e){var r=e;let o=[],n=this.get(r),a=n;if(n!==void 0){for(;r;)o.splice(0,0,n.fi),r=this.parent(r),r!==null&&(n=this.get(r));return{...a,sortKey:o}}}insertBeforeHelper(e,r,o){return this.insertAfterHelper(e,this.previous(e,r),o)}insertAfterHelper(e,r,o){let n=this.childrenArray(e);if(r===null){if(n.length===0)return eo(0,o,o);{let a=n[0].fi;return eo(a-o,a,o)}}else{let a=this.get(r);if(a===void 0||this.parent(r)!==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 eo(l,l+o,o)}else return eo(a.fi,s.fi,o)}}};var aa;(t=>{function i(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let o=r.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:r,reverse:{type:0,props:n}}:null}else{let o=r.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:r,reverse:{type:0,props:n}}:null}}t.runOp=i})(aa||(aa={}));var xe=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,xe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Fs(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,r){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:r},this.modifyArrayBy(n)}}modifyArrayBy(e){Object.setPrototypeOf(e,xe.prototype);let r=e;return e0()||r.fillCaches(),r}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:r,id:o,data:n}=e,a=this,s={fi:r,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:r}=e,o=this,n=o.findIndex(l=>l.id===r);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:r,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:r};return n[a]=l,n.sort((u,d)=>u.fi-d.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 r=null;for(let o of this){if(o.id===e)return r;r=o.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let o=this;if(e===null){if(o.length===0)return eo(0,r,r);{let n=o[0].fi;return eo(n-r,n,r)}}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 eo(s,s+r,r)}else return eo(n.fi,a.fi,r)}}};function sa(i){return i&&typeof i=="object"&&i instanceof We}var We=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,o=0,n={};for(;o<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[o]],r!==void 0&&!sa(r))return null;o+=1}r=r?Mc(r):new We;for(let[l,c]of Object.entries(t.props)){let u=r[l];n[l]=u,c===void 0?delete r[l]:r[l]=c}for(;o>0;){if(Object.keys(r).length===0){let l=e[o-1];l&&(r=Mc(l),delete r[t.path[o-1]])}else{let l=e[o-1];if(l){let c=Mc(l);c[t.path[o-1]]=r,r=c}else{let c=new We;c[t.path[o-1]]=r,r=c}}o-=1}let a=Object.setPrototypeOf(r,We.prototype),s={...t,props:n};return{data:a,actual:t,reverse:s}}},to;(r=>{function i(o,n){return js(o,n)??o}r.apply=i;function t(o,n){return mp(o,n)}r.merge=t;function e(o,n){let a=0,s=n.path,l=o;for(;a<s.length&&l!==void 0;){if(l=Je.zoomOnce(l,s[a]),l===void 0)return n;if(!sa(l))return;a+=1}if(l===void 0)return n;if(!!sa(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=hp([n],l);return c?c[0]:n}else return n}r.filterOp=e})(to||(to={}));function hp(i,t){if(t===void 0)return;let e=!1,r=i.map(o=>{let n=o.id,a=js(o.data,t[n]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=hp(o.children,t);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 r}function VA(i,t){if(t===void 0)return;let e=!1,r=i.map(o=>{let n=o.id,a=js(o.data,t[n]);return e=e||a!==void 0,a===void 0&&(a=o.data),{...o,id:n,data:a}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function js(i,t){if(!sa(t))return t;if(i instanceof Ze){let e=hp(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof xe)return VA(i,t);if(Array.isArray(i)){let e=!1,r=i.map((o,n)=>{let a=js(o,t[n]);return e=e||a!==void 0,a===void 0&&(a=o),a});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else{if(i instanceof We)return mp(i,t);if(i&&typeof i=="object"){let e={},r=!1;for(let[o,n]of Object.entries(i)){let a=js(n,t[o]);r=r||a!==void 0,a===void 0&&(a=n),e[o]=a}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function mp(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!sa(t))return t;if(!sa(i))return to.apply(i,t);let e=new Set;for(let o of Object.keys(i))e.add(o);for(let o of Object.keys(t))e.add(o);let r=new We;for(let o of e){let n=mp(i===void 0?void 0:i[o],t===void 0?void 0:t[o]);r[o]=n}return r}function o0(i,t){let e={cur:[],result:[],len:0};return i=Us(i,t,e)??i,[i,e.result]}function Ic(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function Ec(i){i&&(i.len-=1)}function zA(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function i0(i,t,e){let r=!1,o=i.map(n=>{let a=n.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=Us(n.data,t,Ic(e,a));Ec(e),r=r||l!==void 0,l===void 0&&(l=n.data);let c=i0(n.children,t,e);return c!==void 0?r=!0:c=n.children,{...n,id:a,data:l,children:c}});if(r)return o}function GA(i,t,e){let r=!1,o=i.map(n=>{let a=n.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=Us(n.data,t,Ic(e,a));return Ec(e),r=r||l!==void 0,l===void 0&&(l=n.data),{...n,id:a,data:l}});if(r)return Object.setPrototypeOf(o,Object.getPrototypeOf(i)),o}function Us(i,t,e){if(i instanceof Ze){let r=i0(i,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}else{if(i instanceof xe)return GA(i,t,e);if(Array.isArray(i)){let r=!1,o=i.map((n,a)=>{let s=Us(n,t,Ic(e,a));return Ec(e),r=r||s!==void 0,s===void 0&&(s=n),s});return r?(Object.setPrototypeOf(o,Object.getPrototypeOf(i)),o):void 0}else if(i&&typeof i=="object"&&!na(i)){let r={},o=!1;for(let[n,a]of Object.entries(i))if(n!=="name"&&n!=="variableId"){let s=t[n];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,n=s}let l=Us(a,t,Ic(e,n));Ec(e),o=o||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return o?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else if(typeof i=="string"){let r=t[i];return r!==void 0&&zA(e),r}else return}}var la;(t=>{function i(e,r){let o=Je.zoom(r,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:{}}}t.replaceProps=i})(la||(la={}));var at;(s=>{function i(l,c){return{...l,path:l.path.slice(c)}}s.drop=i;function t(l,c){return e(l,c)?.data??l}s.applySimple=t;function e(l,c){let u=c.path;for(var d=[];;){let p;if(l instanceof We&&c.type===0&&(p=l.runOp({...c,path:u.slice(d.length)}),p===null&&(p=void 0)),p===void 0&&d.length===u.length&&(l instanceof Ze||l instanceof xe||l instanceof ue?p=l.runOp(c):p=aa.runOp(l,c)),p!==void 0)if(p!==null){let m=p.data;for(let y=d.length-1;y>=0;y--){let g=u[y],b=d[y];if(b instanceof Ze){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof xe){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof ue){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof We){let w={...b,[g]:m};m=Object.setPrototypeOf(w,We.prototype)}else if(typeof b=="object")if(Array.isArray(b)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let w=m;m=[...b],m[g]=w}else m={...b,[g]:m};else return null}return{data:m,actual:{...p.actual,path:u},reverse:{...p.reverse,path:u}}}else return null;let f=u[d.length],h;if(l instanceof Ze){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else if(l instanceof xe){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else l!==null&&(h=l[f]);if(h!==void 0)d.push(l),l=h;else return null}}s.apply=e;function r(l,c){for(let u=0;u<l.length&&u<c.length;u++)if(l[u]!==c[u])return!0;return!1}s.pathDisjoint=r;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 r(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})(at||(at={}));var ks;(l=>{function i(){return[]}l.empty=i;function t(c,u){let d=[];for(let p of c){let[f,...h]=p.path;f===u&&d.push({...p,path:h})}return d}l.removePrefix=t;function e(c,u){return c.map(d=>({...d,path:[u,...d.path]}))}l.addPrefix=e;function r(c,u){return[...c,...u]}l.concat=r;function o(c,u){return[...c.filter(p=>!u.some(f=>at.subsumed(p,f))),...u]}l.compress=o;function n(c,u){return c.every(d=>u.every(p=>at.commutative(d,p)))}l.commutative=n;function a(c,u){for(let d of u){let p=s(c,d);p!==null&&(c=p.data)}return c}l.applyAll=a;function s(c,u){var d=c;let p=[],f=[];for(let h of u)try{if(h.type===3||h.type===5&&h.path[h.path.length-1]==="variables"){let m,y,g;if(h.type===3?(m=Je.zoom(d,[...h.path,h.id]),g=at.apply(d,{...h,type:2})):(m=Je.zoom(d,[...h.path,h.id,"value"]),g=at.apply(d,h)),g!==null){d=g.data;let[b,w]=o0(d,{[h.id]:m});d=b;for(let P=0;P<w.length;P++){let S=w[P],T=S.pop();if(typeof T=="number"){let A=[T];for(let N=P+1;N<w.length;N++){let E=w[N],M=E[E.length-1];if(typeof M=="number"&&Je.equal(S,E.slice(0,E.length-1)))A.push(M),w.splice(N,1);else break}let x=Je.zoom(d,S);y=x.map((N,E)=>A.includes(E)?h.id:N),m=x,T=S.pop()}else{if(T==="alphaOverride"||T==="alpha"){m/=100;let A=m,x=Je.zoom(d,S.slice(0,S.length-2)),N=x.layers.map(E=>E.id===S[S.length-1]?{...E,data:{...E.data,[T]:A}}:E);Object.setPrototypeOf(N,Object.getPrototypeOf(x.layers)),x.layers=N}y=h.id}p.push({type:0,path:S,props:{[T]:m}}),f.push({type:0,path:S,props:{[T]:y}})}f.push(g.reverse),p.push(g.actual)}}else{let m=at.apply(d,h);m!==null&&(p.push(m.actual),d=m.data,f.push(m.reverse))}}catch(m){if(m instanceof ia)return null;throw m}return{data:d,actual:p,reverse:f.reverse()}}l.apply=s})(ks||(ks={}));var n0=Symbol(),FA=Symbol(),Dc=Symbol(),tn=class{reportOp(t,e,r=[]){let o=this;if(e===null)return;o._current=e.data;let n=r;for(;!(o instanceof Nc);){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,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[Dc];r&&r(),delete this._children[t]}}}},gp=class extends tn{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else if(this._current instanceof We){let r={...this._current,[t]:e};this._current=Object.setPrototypeOf(r,We.prototype)}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,aa.runOp(this._current,t),t.path)}},xp=class extends tn{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,ue.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},a0={get(i,t){if(t===Dc)return()=>{i._parent=null};if(t===n0)return i._current;if(t===FA)return i;let{_current:e,_children:r}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e[t],a=_c(i,t,n);return a!==n?(r===void 0&&(r={},i._children=r),r[t]=a,a):n},has(i,t){return t in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,t){let e=i._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},jA={...a0,set(i,t,e){let r={type:0,props:{[t]:lt(e)??e}};return i.deleteChildren(t),i.runOp(r),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},UA={...a0,set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}},ca=class extends tn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Dc]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e.get(t)?.data,a=_c(this,t,n);return a!==n?(r===void 0&&(r={},this._children=r),r[t]=a,a):n}add(t,e,r,o,n){this.runOp({type:7,parent:t,fi:e,id:r,data:o,children:n})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let n=0;n<r.length;n++){let a=r[n];this.add(t,o[n],a.id,a.data,a.children)}}insertBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let n=0;n<r.length;n++){let a=r[n];this.add(t,o[n],a.id,a.data,a.children)}}moveAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let n=0;n<r.length;n++){let a=r[n];this.move(t,o[n],a)}}moveBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let n=0;n<r.length;n++){let a=r[n];this.move(t,o[n],a)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},ua=class extends tn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Dc]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id,n=this._current[r].fi;t(this.data(this._current[r].id),o,n)}}find(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id;if(t(this.data(o),o))return this.get(o)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e.get(t)?.data,a=_c(this,t,n);return a!==n?(r===void 0&&(r={},this._children=r),r[t]=a,a):n}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.add(r[o],n.id,n.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.add(r[o],n.id,n.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.move(r[o],n)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.move(r[o],n)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function yp(i,t,e){if(i.length>0){let r=i[i.length-1];if(r.type===0&&t.type===0&&Je.equal(r.path,e)){Object.assign(r.props,t.props);return}}i.push({...t,path:e})}var Nc=class extends tn{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,o){yp(this.ts,e,t),yp(this.actual,r,t),yp(this.reverse,o,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function _c(i,t,e){return e instanceof Ze?new ca(i,t,e):e instanceof xe?new ua(i,t,e):e instanceof ue?new Proxy(new xp(i,t,e),UA):e!==null&&typeof e=="object"?na(e)?e:new Proxy(new gp(i,t,e),jA):e}function bp(i){let t=new Nc(i);return[_c(t,"",i),t]}function ui(i,t){let[e,r]=bp(i);return t(e),r.result()}function lt(i){return i instanceof ca||i instanceof ua?i._current:i!==null&&typeof i=="object"?i[n0]:i}var Je;(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 t(n,a,s){let l=r(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=t;function e(n,a){if((n instanceof Ze||n instanceof ca)&&typeof a=="string")return n.data(a);if((n instanceof xe||n instanceof ua)&&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 r(n,a,s=0){for(;s<a.length&&n!==void 0;)n=e(n,a[s]),s+=1;return n}o.zoom=r})(Je||(Je={}));function s0(i,t){let e=[];if(t.length===i.length)for(var r=0;r<i.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}function Be(i,t){let e=[];if(t.length<=i.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}var Rc=class{},Hs=class extends Rc{constructor(e){super();this.id=e}},Ws=class extends Rc{constructor(e){super();this.data=e}};var Sp;try{Sp=new TextDecoder}catch{}var pe,pi,G=0;var m0=[],wp=m0,Pp=0,tr={},He,di,vr=0,ro=0,pr,_o,Yt=[],$e,l0={useRecords:!1,mapsAsObjects:!0},qs=class{},Tp=new qs;Tp.name="MessagePack 0xC1";var da=!1,oo=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(pe)return v0(()=>(Bc(),this?this.unpack(t,e):oo.prototype.unpack.call(l0,t,e)));pi=e>-1?e:t.length,G=0,Pp=0,ro=0,di=null,wp=m0,pr=null,pe=t;try{$e=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw pe=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof oo){if(tr=this,this.structures)return He=this.structures,Lc();(!He||He.length>0)&&(He=[])}else tr=l0,(!He||He.length>0)&&(He=[]);return Lc()}unpackMultiple(t,e){let r,o=0;try{da=!0;let n=t.length,a=this?this.unpack(t,n):Gc.unpack(t,n);if(e){for(e(a);G<n;)if(o=G,e(Lc())===!1)return}else{for(r=[a];G<n;)o=G,r.push(Lc());return r}}catch(n){throw n.lastPosition=o,n.values=r,n}finally{da=!1,Bc()}}_mergeStructures(t,e){t=t||[];for(let r=0,o=t.length;r<o;r++){let n=t[r];n&&(n.isShared=!0,r>=32&&(n.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let o=t[r],n=e[r];n&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[r]=o),t[r]=n)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Lc(){try{if(!tr.trusted&&!da){let t=He.sharedLength||0;t<He.length&&(He.length=t)}let i=yt();if(G==pi)He.restoreStructures&&c0(),He=null,pe=null,_o&&(_o=null);else if(G>pi){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!da)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw He.restoreStructures&&c0(),Bc(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function c0(){for(let i in He.restoreStructures)He[i]=He.restoreStructures[i];He.restoreStructures=null}function yt(){let i=pe[G++];if(i<160)if(i<128){if(i<64)return i;{let t=He[i&63]||tr.getStructures&&y0()[i&63];return t?(t.read||(t.read=Cp(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,tr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[x0()]=yt();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(yt(),yt());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=yt();return t}else if(i<192){let t=i-160;if(ro>=G)return di.slice(G-vr,(G+=t)-vr);if(ro==0&&pi<140){let e=t<16?Ap(t):g0(t);if(e!=null)return e}return Op(t)}else{let t;switch(i){case 192:return null;case 193:return pr?(t=yt(),t>0?pr[1].slice(pr.position1,pr.position1+=t):pr[0].slice(pr.position0,pr.position0-=t)):Tp;case 194:return!1;case 195:return!0;case 196:return vp(pe[G++]);case 197:return t=$e.getUint16(G),G+=2,vp(t);case 198:return t=$e.getUint32(G),G+=4,vp(t);case 199:return rn(pe[G++]);case 200:return t=$e.getUint16(G),G+=2,rn(t);case 201:return t=$e.getUint32(G),G+=4,rn(t);case 202:if(t=$e.getFloat32(G),tr.useFloat32>2){let e=zc[(pe[G]&127)<<1|pe[G+1]>>7];return G+=4,(e*t+(t>0?.5:-.5)>>0)/e}return G+=4,t;case 203:return t=$e.getFloat64(G),G+=8,t;case 204:return pe[G++];case 205:return t=$e.getUint16(G),G+=2,t;case 206:return t=$e.getUint32(G),G+=4,t;case 207:return tr.int64AsNumber?(t=$e.getUint32(G)*4294967296,t+=$e.getUint32(G+4)):t=$e.getBigUint64(G),G+=8,t;case 208:return $e.getInt8(G++);case 209:return t=$e.getInt16(G),G+=2,t;case 210:return t=$e.getInt32(G),G+=4,t;case 211:return tr.int64AsNumber?(t=$e.getInt32(G)*4294967296,t+=$e.getUint32(G+4)):t=$e.getBigInt64(G),G+=8,t;case 212:if(t=pe[G++],t==114)return h0(pe[G++]&63);{let e=Yt[t];if(e)return e.read?(G++,e.read(yt())):e.noBuffer?(G++,e()):e(pe.subarray(G,++G));throw new Error("Unknown extension "+t)}case 213:return t=pe[G],t==114?(G++,h0(pe[G++]&63,pe[G++])):rn(2);case 214:return rn(4);case 215:return rn(8);case 216:return rn(16);case 217:return t=pe[G++],ro>=G?di.slice(G-vr,(G+=t)-vr):HA(t);case 218:return t=$e.getUint16(G),G+=2,ro>=G?di.slice(G-vr,(G+=t)-vr):WA(t);case 219:return t=$e.getUint32(G),G+=4,ro>=G?di.slice(G-vr,(G+=t)-vr):qA(t);case 220:return t=$e.getUint16(G),G+=2,d0(t);case 221:return t=$e.getUint32(G),G+=4,d0(t);case 222:return t=$e.getUint16(G),G+=2,p0(t);case 223:return t=$e.getUint32(G),G+=4,p0(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var kA=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Cp(i,t){function e(){if(e.count++>2){let o=i.read=new Function("r","return function(){return {"+i.map(n=>kA.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(yt);return i.highByte===0&&(i.read=u0(t,i.read)),o()}let r={};for(let o=0,n=i.length;o<n;o++){let a=i[o];r[a]=yt()}return r}return e.count=0,i.highByte===0?u0(t,e):e}var u0=(i,t)=>function(){let e=pe[G++];if(e===0)return t();let r=i<32?-(i+(e<<5)):i+(e<<5),o=He[r]||y0()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=Cp(o,i)),o.read()};function y0(){let i=v0(()=>(pe=null,tr.getStructures()));return He=tr._mergeStructures(i,He)}var Op=Vc,HA=Vc,WA=Vc,qA=Vc;function Vc(i){let t;if(i<16&&(t=Ap(i)))return t;if(i>64&&Sp)return Sp.decode(pe.subarray(G,G+=i));let e=G+i,r=[];for(t="";G<e;){let o=pe[G++];if((o&128)===0)r.push(o);else if((o&224)===192){let n=pe[G++]&63;r.push((o&31)<<6|n)}else if((o&240)===224){let n=pe[G++]&63,a=pe[G++]&63;r.push((o&31)<<12|n<<6|a)}else if((o&248)===240){let n=pe[G++]&63,a=pe[G++]&63,s=pe[G++]&63,l=(o&7)<<18|n<<12|a<<6|s;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(o);r.length>=4096&&(t+=_t.apply(String,r),r.length=0)}return r.length>0&&(t+=_t.apply(String,r)),t}function d0(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=yt();return t}function p0(i){if(tr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[x0()]=yt();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(yt(),yt());return t}}var _t=String.fromCharCode;function g0(i){let t=G,e=new Array(i);for(let r=0;r<i;r++){let o=pe[G++];if((o&128)>0){G=t;return}e[r]=o}return _t.apply(String,e)}function Ap(i){if(i<4)if(i<2){if(i===0)return"";{let t=pe[G++];if((t&128)>1){G-=1;return}return _t(t)}}else{let t=pe[G++],e=pe[G++];if((t&128)>0||(e&128)>0){G-=2;return}if(i<3)return _t(t,e);let r=pe[G++];if((r&128)>0){G-=3;return}return _t(t,e,r)}else{let t=pe[G++],e=pe[G++],r=pe[G++],o=pe[G++];if((t&128)>0||(e&128)>0||(r&128)>0||(o&128)>0){G-=4;return}if(i<6){if(i===4)return _t(t,e,r,o);{let n=pe[G++];if((n&128)>0){G-=5;return}return _t(t,e,r,o,n)}}else if(i<8){let n=pe[G++],a=pe[G++];if((n&128)>0||(a&128)>0){G-=6;return}if(i<7)return _t(t,e,r,o,n,a);let s=pe[G++];if((s&128)>0){G-=7;return}return _t(t,e,r,o,n,a,s)}else{let n=pe[G++],a=pe[G++],s=pe[G++],l=pe[G++];if((n&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){G-=8;return}if(i<10){if(i===8)return _t(t,e,r,o,n,a,s,l);{let c=pe[G++];if((c&128)>0){G-=9;return}return _t(t,e,r,o,n,a,s,l,c)}}else if(i<12){let c=pe[G++],u=pe[G++];if((c&128)>0||(u&128)>0){G-=10;return}if(i<11)return _t(t,e,r,o,n,a,s,l,c,u);let d=pe[G++];if((d&128)>0){G-=11;return}return _t(t,e,r,o,n,a,s,l,c,u,d)}else{let c=pe[G++],u=pe[G++],d=pe[G++],p=pe[G++];if((c&128)>0||(u&128)>0||(d&128)>0||(p&128)>0){G-=12;return}if(i<14){if(i===12)return _t(t,e,r,o,n,a,s,l,c,u,d,p);{let f=pe[G++];if((f&128)>0){G-=13;return}return _t(t,e,r,o,n,a,s,l,c,u,d,p,f)}}else{let f=pe[G++],h=pe[G++];if((f&128)>0||(h&128)>0){G-=14;return}if(i<15)return _t(t,e,r,o,n,a,s,l,c,u,d,p,f,h);let m=pe[G++];if((m&128)>0){G-=15;return}return _t(t,e,r,o,n,a,s,l,c,u,d,p,f,h,m)}}}}}function vp(i){return tr.copyBuffers?Uint8Array.prototype.slice.call(pe,G,G+=i):pe.subarray(G,G+=i)}function rn(i){let t=pe[G++];if(Yt[t])return Yt[t](pe.subarray(G,G+=i));throw new Error("Unknown extension type "+t)}var f0=new Array(4096);function x0(){let i=pe[G++];if(i>=160&&i<192){if(i=i-160,ro>=G)return di.slice(G-vr,(G+=i)-vr);if(!(ro==0&&pi<180))return Op(i)}else return G--,yt();let t=(i<<5^(i>1?$e.getUint16(G):i>0?pe[G]:0))&4095,e=f0[t],r=G,o=G+i-3,n,a=0;if(e&&e.bytes==i){for(;r<o;){if(n=$e.getUint32(r),n!=e[a++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(n=pe[r++],n!=e[a++]){r=1879048192;break}if(r===o)return G=r,e.string;o-=3,r=G}for(e=[],f0[t]=e,e.bytes=i;r<o;)n=$e.getUint32(r),e.push(n),r+=4;for(o+=3;r<o;)n=pe[r++],e.push(n);let s=i<16?Ap(i):g0(i);return s!=null?e.string=s:e.string=Op(i)}var h0=(i,t)=>{var e=yt();let r=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let o=He[i];return o&&o.isShared&&((He.restoreStructures||(He.restoreStructures=[]))[i]=o),He[i]=e,e.read=Cp(e,r),e.read()},b0=typeof self=="object"?self:global;Yt[0]=()=>{};Yt[0].noBuffer=!0;Yt[101]=()=>{let i=yt();return(b0[i[0]]||Error)(i[1])};Yt[105]=i=>{let t=$e.getUint32(G-4);_o||(_o=new Map);let e=pe[G],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let o={target:r};_o.set(t,o);let n=yt();return o.used?Object.assign(r,n):(o.target=n,n)};Yt[112]=i=>{let t=$e.getUint32(G-4),e=_o.get(t);return e.used=!0,e.target};Yt[115]=()=>new Set(yt());var Mp=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");Yt[116]=i=>{let t=i[0],e=Mp[t];if(!e)throw new Error("Could not find typed array for code "+t);return new b0[e](Uint8Array.prototype.slice.call(i,1).buffer)};Yt[120]=()=>{let i=yt();return new RegExp(i[0],i[1])};Yt[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=G;G+=t-4,pr=[yt(),yt()],pr.position0=0,pr.position1=0;let r=G;G=e;try{return yt()}finally{G=r}};Yt[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 v0(i){let t=pi,e=G,r=Pp,o=vr,n=ro,a=di,s=wp,l=_o,c=pr,u=new Uint8Array(pe.slice(0,pi)),d=He,p=He.slice(0,He.length),f=tr,h=da,m=i();return pi=t,G=e,Pp=r,vr=o,ro=n,di=a,wp=s,_o=l,pr=c,pe=u,da=h,He=d,He.splice(0,He.length,...p),tr=f,$e=new DataView(pe.buffer,pe.byteOffset,pe.byteLength),m}function Bc(){pe=null,_o=null,He=null}function S0(i){i.unpack?Yt[i.type]=i.unpack:Yt[i.type]=i}var zc=new Array(147);for(let i=0;i<256;i++)zc[i]=+("1e"+Math.floor(45.15-i*.30103));var Gc=new oo({useRecords:!1}),$A=Gc.unpack,XA=Gc.unpackMultiple,YA=Gc.unpack,Fc={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},KA=new Float32Array(1),n5=new Uint8Array(KA.buffer,0,4);var jc;try{jc=new TextEncoder}catch{}var Uc,Ep,kc=typeof Buffer<"u",Ip=kc?Buffer.allocUnsafeSlow:Uint8Array,T0=kc?Buffer:Uint8Array,w0=kc?4294967296:2144337920,X,xt,k=0,io,no=null,QA=/[\u0080-\uFFFF]/,$s=Symbol("record-id"),on=class extends oo{constructor(t){super(t),this.offset=0;let e,r,o,n,a,s,l=0,c=T0.prototype.utf8Write?function(x,N,E){return X.utf8Write(x,N,E)}:jc&&jc.encodeInto?function(x,N){return jc.encodeInto(x,X.subarray(N)).written}:!1,u=this;t||(t={});let d=t&&t.sequential,p=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=p?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let h=t.maxOwnStructures;h==null&&(h=p?32:64),d&&!t.saveStructures&&(this.structures=[]);let m=f>32||h+f>64,y=f+64,g=f+h+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let b=[],w=0,P=0;this.pack=this.encode=function(x,N){if(X||(X=new Ip(8192),xt=new DataView(X.buffer,0,8192),k=0),io=X.length-10,io-k<2048?(X=new Ip(X.length),xt=new DataView(X.buffer,0,X.length),io=X.length-10,k=0):k=k+7&2147483640,r=k,s=u.structuredClone?new Map:null,u.bundleStrings?(no=["",""],X[k++]=214,X[k++]=98,no.position=k-r,k+=4):no=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 M=0;M<E;M++){let D=o[M];if(!D)continue;let _,R=o.transitions;for(let V=0,U=D.length;V<U;V++){let B=D[V];_=R[B],_||(_=R[B]=Object.create(null)),R=_}R[$s]=M+64}l=E}d||(o.nextId=E+64)}n&&(n=!1),a=o||[];try{if(S(x),no){xt.setUint32(no.position+r,k-no.position-r);let E=no;no=null,S(E[0]),S(E[1])}if(u.offset=k,s&&s.idsToInsert){k+=s.idsToInsert.length*6,k>io&&A(k),u.offset=k;let E=JA(X.subarray(r,k),s.idsToInsert);return s=null,E}return N&A0?(X.start=r,X.end=k,X):X.subarray(r,k)}finally{if(o){if(P<10&&P++,w>1e4)o.transitions=null,P=0,w=0,b.length>0&&(b=[]);else if(b.length>0&&!d){for(let E=0,M=b.length;E<M;E++)b[E][$s]=0;b=[]}if(n&&u.saveStructures){let E=o.sharedLength||f;o.length>E&&(o=o.slice(0,E));let M=X.subarray(r,k);return u.saveStructures(o,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(x)):(l=E,M)}}N&aM&&(k=r)}};let S=x=>{k>io&&(X=A(k));var N=typeof x,E;if(N==="string"){let M=x.length;if(no&&M>=8&&M<4096){let R=QA.test(x);no[R?0:1]+=x,X[k++]=193,S(R?-M:M);return}let D;M<32?D=1:M<256?D=2:M<65536?D=3:D=5;let _=M*3;if(k+_>io&&(X=A(k+_)),M<64||!c){let R,V,U,B=k+D;for(R=0;R<M;R++)V=x.charCodeAt(R),V<128?X[B++]=V:V<2048?(X[B++]=V>>6|192,X[B++]=V&63|128):(V&64512)===55296&&((U=x.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-D}else E=c(x,k+D,_);E<32?X[k++]=160|E:E<256?(D<2&&X.copyWithin(k+2,k+1,k+1+E),X[k++]=217,X[k++]=E):E<65536?(D<3&&X.copyWithin(k+3,k+2,k+2+E),X[k++]=218,X[k++]=E>>8,X[k++]=E&255):(D<5&&X.copyWithin(k+5,k+3,k+3+E),X[k++]=219,xt.setUint32(k,E),k+=4),k+=E}else if(N==="number")if(x>>>0===x)x<64?X[k++]=x:x<256?(X[k++]=204,X[k++]=x):x<65536?(X[k++]=205,X[k++]=x>>8,X[k++]=x&255):(X[k++]=206,xt.setUint32(k,x),k+=4);else if(x>>0===x)x>=-32?X[k++]=256+x:x>=-128?(X[k++]=208,X[k++]=x+256):x>=-32768?(X[k++]=209,xt.setInt16(k,x),k+=2):(X[k++]=210,xt.setInt32(k,x),k+=4);else{let M;if((M=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){X[k++]=202,xt.setFloat32(k,x);let D;if(M<4||(D=x*zc[(X[k]&127)<<1|X[k+1]>>7])>>0===D){k+=4;return}else k--}X[k++]=203,xt.setFloat64(k,x),k+=8}else if(N==="object")if(!x)X[k++]=192;else{if(s){let D=s.get(x);if(D){if(!D.id){let _=s.idsToInsert||(s.idsToInsert=[]);D.id=_.push(D)}X[k++]=214,X[k++]=112,xt.setUint32(k,D.id),k+=4;return}else s.set(x,{offset:k-r})}let M=x.constructor;if(M===Object)T(x,!0);else if(M===Array){E=x.length,E<16?X[k++]=144|E:E<65536?(X[k++]=220,X[k++]=E>>8,X[k++]=E&255):(X[k++]=221,xt.setUint32(k,E),k+=4);for(let D=0;D<E;D++)S(x[D])}else if(M===Map){E=x.size,E<16?X[k++]=128|E:E<65536?(X[k++]=222,X[k++]=E>>8,X[k++]=E&255):(X[k++]=223,xt.setUint32(k,E),k+=4);for(let[D,_]of x)S(D),S(_)}else{for(let D=0,_=Uc.length;D<_;D++){let R=Ep[D];if(x instanceof R){let V=Uc[D];if(V.write){V.type&&(X[k++]=212,X[k++]=V.type,X[k++]=0),S(V.write.call(this,x));return}let U=X,B=xt,q=k;X=null;let j;try{j=V.pack.call(this,x,F=>(X=U,U=null,k+=F,k>io&&A(k),{target:X,targetView:xt,position:k-F}),S)}finally{U&&(X=U,xt=B,k=q,io=X.length-10)}j&&(j.length+k>io&&A(j.length+k),k=ZA(j,X,k,V.type));return}}T(x,!x.hasOwnProperty)}}else if(N==="boolean")X[k++]=x?195:194;else if(N==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))X[k++]=211,xt.setBigInt64(k,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)X[k++]=207,xt.setBigUint64(k,x);else if(this.largeBigIntToFloat)X[k++]=203,xt.setFloat64(k,Number(x));else throw new RangeError(x+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");k+=8}else if(N==="undefined")this.encodeUndefinedAsNil?X[k++]=192:(X[k++]=212,X[k++]=0,X[k++]=0);else if(N==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+N)},T=this.useRecords===!1?this.variableMapSize?x=>{let N=Object.keys(x),E=N.length;E<16?X[k++]=128|E:E<65536?(X[k++]=222,X[k++]=E>>8,X[k++]=E&255):(X[k++]=223,xt.setUint32(k,E),k+=4);let M;for(let D=0;D<E;D++)S(M=N[D]),S(x[M])}:(x,N)=>{X[k++]=222;let E=k-r;k+=2;let M=0;for(let D in x)(N||x.hasOwnProperty(D))&&(S(D),S(x[D]),M++);X[E+++r]=M>>8,X[E+r]=M&255}:x=>{let N=Object.keys(x),E,M=a.transitions||(a.transitions=Object.create(null)),D=0;for(let R=0,V=N.length;R<V;R++){let U=N[R];E=M[U],E||(E=M[U]=Object.create(null),D++),M=E}let _=M[$s];if(_)_>=96&&m?(X[k++]=((_-=96)&31)+96,X[k++]=_>>5):X[k++]=_;else{_=a.nextId,_||(_=64),_<y&&this.shouldShareStructure&&!this.shouldShareStructure(N)?(_=a.nextOwnId,_<g||(_=y),a.nextOwnId=_+1):(_>=g&&(_=y),a.nextId=_+1);let R=N.highByte=_>=96&&m?_-96>>5:-1;M[$s]=_,a[_-64]=N,_<y?(N.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++]=_),D&&(w+=P*D),b.length>=h&&(b.shift()[$s]=0),b.push(M),S(N))}for(let R=0,V=N.length;R<V;R++)S(x[N[R]])},A=x=>{let N;if(x>16777216){if(x-r>w0)throw new Error("Packed buffer would be larger than maximum buffer size");N=Math.min(w0,Math.round(Math.max((x-r)*(x>67108864?1.25:2),4194304)/4096)*4096)}else N=(Math.max(x-r<<2,X.length-1)>>12)+1<<12;let E=new Ip(N);return xt=new DataView(E.buffer,0,N),X.copy?X.copy(E,0,r,x):E.set(X.slice(r,x)),k-=r,r=0,io=E.length-10,X=E}}useBuffer(t){X=t,xt=new DataView(X.buffer,X.byteOffset,X.byteLength),k=0}};Ep=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,qs];Uc=[{pack(i,t,e){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:n,position:a}=t(6);o[a++]=214,o[a++]=255,n.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:o,targetView:n,position:a}=t(10);o[a++]=215,o[a++]=255,n.setUint32(a,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),n.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:o,targetView:n,position:a}=t(3);o[a++]=212,o[a++]=255,o[a++]=255}else{let{target:o,targetView:n,position:a}=t(15);o[a++]=199,o[a++]=12,o[a++]=255,n.setUint32(a,i.getMilliseconds()*1e6),n.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(i,t,e){let r=Array.from(i),{target:o,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(o[n++]=212,o[n++]=115,o[n++]=0),e(r)}},{pack(i,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=101,r[o++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=120,r[o++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?P0(i,16,t):O0(kc?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==T0&&this.structuredClone?P0(i,Mp.indexOf(e.name),t):O0(i,t)}},{pack(i,t){let{target:e,position:r}=t(1);e[r]=193}}];function P0(i,t,e,r){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++]=t,n.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),a)}function O0(i,t){let e=i.byteLength;var r,o;if(e<256){var{target:r,position:o}=t(e+2);r[o++]=196,r[o++]=e}else if(e<65536){var{target:r,position:o}=t(e+3);r[o++]=197,r[o++]=e>>8,r[o++]=e&255}else{var{target:r,position:o,targetView:n}=t(e+5);r[o++]=198,n.setUint32(o,e),o+=4}r.set(i,o)}function ZA(i,t,e,r){let o=i.length;switch(o){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:o<256?(t[e++]=199,t[e++]=o):o<65536?(t[e++]=200,t[e++]=o>>8,t[e++]=o&255):(t[e++]=201,t[e++]=o>>24,t[e++]=o>>16&255,t[e++]=o>>8&255,t[e++]=o&255)}return t[e++]=r,t.set(i,e),e+=o,e}function JA(i,t){let e,r=t.length*6,o=i.length-r;for(t.sort((n,a)=>n.offset>a.offset?1:-1);e=t.pop();){let n=e.offset,a=e.id;i.copyWithin(n+r,n,o),r-=6;let s=n+r;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 fi(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)");Ep.unshift(i.Class),Uc.unshift(i)}S0(i)}var C0=new on({useRecords:!1}),eM=C0.pack,tM=C0.pack;var{NEVER:rM,ALWAYS:oM,DECIMAL_ROUND:iM,DECIMAL_FIT:nM}=Fc,A0=512,aM=1024;var M0=new on({structuredClone:!0});fi({Class:ue.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,ue.prototype),i}});fi({Class:xe.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,xe.prototype),i}});fi({Class:Ze.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Ze.prototype),i}});fi({Class:Hs.prototype.constructor,type:4,write(i){return i.id},read(i){return new Hs(i)}});fi({Class:Ws.prototype.constructor,type:5,write(i){return i.data},read(i){return new Ws(i)}});fi({Class:We.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,We.prototype),i}});function sM(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let r=i[e];t=(t<<5)-t+r,t=t&t}return t}function Np(i){if(na(i))return i;if(Array.isArray(i))return i.map(Np);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=Np(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var Hc;(r=>{function i(o){return M0.pack(o)}r.serialize=i;function t(o){return M0.unpack(o)}r.deserialize=t;function e(o){return sM(i(Np(o))).toString()}r.checksum=e})(Hc||(Hc={}));var yi="personal camera",gi="a218fcc3-276b-49b9-b485-49037fd14f5f",R0=2960946;var bt=5526619;var pa;(f=>{function i(h,m){return h[0]===m[0]&&h[1]===m[1]}f.isEqual=i;function t(h,m,y){return[h[0]+(m[0]-h[0])*y,h[1]+(m[1]-h[1])*y]}f.lerp=t;function e(h,m){return[h[0]+m[0],h[1]+m[1]]}f.add=e;function r(h,m){return[h[0]-m[0],h[1]-m[1]]}f.sub=r;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 g=f.sub(m,h),b=f.sub(y,h),w=f.dot(g,b)/f.dot(g,g),P=f.scalarMultiply(g,w);return f.add(h,P)}f.projectionOnto=u;function d(h,m,y){return s(h,u(h,m,y))}f.projectionOntoDistance=d;function p(h,m){return[(h[0]+m[0])*.5,(h[1]+m[1])*.5]}f.center=p})(pa||(pa={}));var hi;(s=>{function i(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}s.isEqual=i;function t(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]}s.add=t;function e(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]}s.sub=e;function r(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]}s.div=r;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})(hi||(hi={}));var I0;(e=>{function i(r,o){return r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]}e.isEqual=i;function t(r,o,n){return[r[0]+(o[0]-r[0])*n,r[1]+(o[1]-r[1])*n,r[2]+(o[2]-r[2])*n,r[3]+(o[3]-r[3])*n]}e.lerp=t})(I0||(I0={}));var E0;(a=>{let i=180/Math.PI,t=Math.PI/180;function e(s){return typeof s=="number"?s*i:s}function r(s){return typeof s=="number"?s*t:s}function o(s){return[e(s[0]),e(s[1]),e(s[2])]}a.radToDeg=o;function n(s){return[r(s[0]),r(s[1]),r(s[2])]}a.degToRad=n})(E0||(E0={}));var mi;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(n,a){for(let s=0;s<16;s++)if(n[s]!==a[s])return!1;return!0}o.isEqual=t;function e(n){return n??o.identity}o.simplify=e;function r(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=r})(mi||(mi={}));var Pt;(p=>{function i(f){return typeof f=="object"&&typeof f.r=="number"&&typeof f.g=="number"&&typeof f.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(f){return{r:Math.round(f.r*255),g:Math.round(f.g*255),b:Math.round(f.b*255),a:1}}p.toRgb255a1=o;function n(f){return{r:f.r,g:f.g,b:f.b}}p.clone=n;function a(f){return f=Math.floor(f),{r:(f>>16&255)/255,g:(f>>8&255)/255,b:(f&255)/255}}p.fromHex=a;function s(f){return Math.round(f.r*255)*65536+Math.round(f.g*255)*256+Math.round(f.b*255)}p.toHex=s;function l(f,h){return f.r===h.r&&f.g===h.g&&f.b===h.b}p.equals=l;function c(f,h){return f.r.toFixed(2)===h.r.toFixed(2)&&f.g.toFixed(2)===h.g.toFixed(2)&&f.b.toFixed(2)===h.b.toFixed(2)}p.equalsFixed=c;function u(f,h,m){return{r:f.r+(h.r-f.r)*m,g:f.g+(h.g-f.g)*m,b:f.b+(h.b-f.b)*m}}p.lerp=u;function d(f){return mt(f)?"r"in f&&"g"in f&&"b"in f&&!("a"in f):!1}p.is=d})(Pt||(Pt={}));var Ee;(u=>{u.white={...Pt.white,a:1};function t(d){return mt(d)?"r"in d&&"g"in d&&"b"in d&&"a"in d:!1}u.is=t,u.transparent={...Pt.white,a:0};function r(d){return{r:d[0],g:d[1],b:d[2],a:d[3]}}u.from0to1=r;function o(d,p){return{...Pt.fromHex(d),a:p}}u.fromHexAndA=o;function n(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:d.a}}u.toRgb255a1=n;function a(d,p){return Pt.equals(d,p)&&d.a===p.a}u.equals=a;function s(d,p){return Pt.equalsFixed(d,p)&&d.a.toFixed(2)===p.a.toFixed(2)}u.equalsFixed=s;function l(d,p,f){return{r:d.r+(p.r-d.r)*f,g:d.g+(p.g-d.g)*f,b:d.b+(p.b-d.b)*f,a:d.a+(p.a-d.a)*f}}u.lerp=l;function c({r:d,g:p,b:f,a:h}=u.white){return`rgba(${d*255}, ${p*255}, ${f*255}, ${h})`}u.toStyle=c})(Ee||(Ee={}));var Wc;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]})(Wc||(Wc={}));var N0;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(N0||(N0={}));var D0;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(D0||(D0={}));var _0;(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]))(_0||(_0={}));function Dp(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 Lr;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(Lr||(Lr={}));var xi;(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 r(n){return n.type==="PerspectiveCamera"?n.perspective?.zoom??1:n.orthographic?.zoom??1}o.getZoom=r})(xi||(xi={}));var ao;(r=>{function i(o,n=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(typeof o[0]=="number"?o[0]:1,typeof o[1]=="number"?o[1]:1)*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0],pivot:[0,0,0],pivotRotation:[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",pivot:[0,0,0],pivotRotation:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[(typeof o[0]=="number"?o[0]+o[0]:1)*n,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:o.map(a=>(typeof a=="number"?a:1)*(1+n)),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"}}}r.defaultData=i;function t(o,n){let a={...o};if(lM.forEach(s=>{Object.assign(a,{[s]:n[s]??o[s]})}),a.radial={...o.radial},n.radial){let s=o.radial,l=n.radial;cM.forEach(c=>{Object.assign(a.radial,{[c]:l[c]??s[c]})})}if(a.linear={...o.linear},n.linear){let s=o.linear,l=n.linear;uM.forEach(c=>{Object.assign(a.linear,{[c]:l[c]??s[c]})})}if(a.grid={...o.grid},n.grid){let s=o.grid,l=n.grid;dM.forEach(c=>{Object.assign(a.grid,{[c]:l[c]??s[c]})})}if(a.toObject={...o.toObject},n.toObject){let s=o.toObject,l=n.toObject;pM.forEach(c=>{Object.assign(a.toObject,{[c]:l[c]??s[c]})})}if(a.randomnessObject={...o.randomnessObject},n.randomnessObject){let s=o.randomnessObject,l=n.randomnessObject;fM.forEach(c=>{Object.assign(a.randomnessObject,{[c]:l[c]??s[c]})})}return a}r.merge=t;function e(o){return!!(o.randomnessObject||o.toObject)}r.isPartial=e})(ao||(ao={}));var qc;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["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 t){let l=o[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...n,s],props:l})}return a}r.toOps=e})(qc||(qc={}));var lM=["count"],cM=["radius","start","end","position","scale","rotation"],uM=["position","scale","rotation"],dM=["count","size"],pM=["count","position","scale","rotation"],fM=["strength","scale","rotation","position","movement","seed","freqScale"];var $c;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})($c||($c={}));var Xc;(e=>{function i(r){return t(r)}e.defaultData=i;function t(r){if(r==="PointLight")return{type:r,color:Ee.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Ee.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(r==="DirectionalLight")return{type:r,color:Ee.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Xc||(Xc={}));var fa;(r=>(r.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},r.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},r.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:r.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...r.defaultCollisionData}))(fa||(fa={}));var bi;(t=>t.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]})(bi||(bi={}));var _p;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}e.equals=t})(_p||(_p={}));var Rp;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,o){return r.flatShading===o.flatShading&&r.side===o.side&&r.wireframe===o.wireframe}e.equals=t})(Rp||(Rp={}));var Yc;(t=>t.defaultData={...Rp.defaultData,..._p.defaultData})(Yc||(Yc={}));var L0;(t=>{function i(e,r){let o=[];if("material"in e){let n=typeof e.material=="string"?r.materials[e.material]??r.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"?r.materials[n]??r.lib.materials[n]?.asset:n;a&&o.push(a)}return o}t.getMaterialData=i})(L0||(L0={}));var ha;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(ha||(ha={}));var B0;(t=>{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"}t.is=i})(B0||(B0={}));function z0(i){return i.type!=="displace"}var V0;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(V0||(V0={}));var G0=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],F0=["wrapping","image","video","name","minFilter","magFilter"],gt;(n=>{function i(a,s){let{texture:l,...c}=s;if(Object.assign(a,c),l){let u=a.texture;u&&Object.assign(u,l)}}n.patch=i;function t(a){return{...n.defaultData("color"),color:a}}n.defaultColorLayer=t;function e(a,s){return a==="light"&&s?r(s):o(a)}n.defaultData=e;function r(a){let s={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(a){case"phong":return{...s,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...s,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...s,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...s,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function o(a){let s={alpha:1,mode:0,isMask:!1,visible:!0};switch(a){case"texture":return{...s,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{...s,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:ha.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...s,type:"color",color:Pt.fromHex(bt)};case"depth":return{...s,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{...s,type:"normal",cnormal:[1,1,1]};case"gradient":return{...s,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{...s,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Pt.fromHex(6710886),a:1},colorB:{...Pt.fromHex(6710886),a:1},colorC:{...Pt.fromHex(16777215),a:1},colorD:{...Pt.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{...s,type:"fresnel",color:Ee.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...s,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...s,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:Ee.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...s,type:"outline",outlineColor:Ee.fromHexAndA(0,1),contourColor:Ee.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{...s,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...s,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{...s,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Pt.fromHex(0),a:1},colorB:{...Pt.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(gt||(gt={}));var At;(u=>{function i(d){return!d.layers.some(f=>f.data.type==="texture"&&f.data.projection!==0||f.data.type==="depth"&&!f.data.isWorldSpace||f.data.type==="noise"||f.data.type==="displace")}u.isMergable=i;function t(d){let p="";return d.layers.forEach(f=>{Object.entries(f.data).forEach(([h,m])=>{p+=`${h}${m}`,Array.isArray(m)?m.forEach(y=>p+=`${y}`):typeof m=="object"?Object.values(m).forEach(y=>{typeof y=="number"?p+=`${y.toFixed(4)}`:p+=`${y}`}):p+=`${m}`})}),p}u.getHash=t;function e(){return{layers:new xe}}u.defaultEmptyData=e;function r(d="layer1",p="layer2"){return n("phong",d,p)}u.defaultData=r;function o(d,p){return{...d,name:p}}u.withName=o;function n(d,p="layer1",f="layer2",h=Pt.fromHex(16777215)){let m=new xe;return m.push({fi:0,data:gt.defaultData("light",d),id:p}),m.push({fi:1,data:gt.defaultData("color"),id:f}),{layers:m}}u.defaultTwoLayerData=n;function a(d,p,f="layer1",h="layer2"){let m=new xe;return m.push({fi:0,data:gt.defaultData("light",p),id:f}),m.push({fi:1,data:gt.defaultColorLayer(d),id:h}),{layers:m}}u.defaultColorMaterial=a;function s(d){let p=gt.defaultData("texture");d&&Object.assign(p.texture,{image:d});let f=new xe;return f.push({fi:0,data:p,id:"layer1"}),f.push({fi:1,data:{...gt.defaultData("transmission"),alpha:1},id:"layer2"}),f.push({fi:2,data:{...gt.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:f}}u.defaultUIObjectMaterial=s;function l(d,p="phong",f="layer1",h="layer2"){let m=gt.defaultData("texture");Object.assign(m.texture,{image:d});let y=new xe;return y.push({fi:0,data:m,id:f}),y.push({fi:1,data:gt.defaultData("light",p),id:h}),{layers:y}}u.defaultTwoLayerTextureData=l;function c(d,p="phong",f="layer1",h="layer2"){let m=gt.defaultData("video");Object.assign(m.texture,{video:d});let y=new xe;return y.push({fi:0,data:m,id:f}),y.push({fi:1,data:gt.defaultData("light",p),id:h}),{layers:y}}u.defaultTwoLayerVideoTextureData=c})(At||(At={}));var ma;(t=>{function i(){return{points:new xe,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(ma||(ma={}));var ya;(t=>{function i(){return{points:new xe,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}}t.defaultData=i})(ya||(ya={}));var nn={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Kc;(t=>{function i(e,r){let o={...e};return hM.forEach(n=>{Object.assign(o,{[n]:r[n]??e[n]})}),o}t.merge=i})(Kc||(Kc={}));var Qc={shape:nn,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},hM=["depth","offset","angle","twist","startScale","endScale"];var Xs;(r=>{function i(o){return o==="PolygonGeometry"||o==="RectangleGeometry"||o==="StarGeometry"||o==="TriangleGeometry"||o==="EllipseGeometry"||o==="UIGeometry"}r.is2DParametricMesh=i;function t(o){return o==="PolygonGeometry"||o==="RectangleGeometry"||o==="StarGeometry"||o==="TriangleGeometry"||o==="EllipseGeometry"||o==="PathGeometry"||o==="VectorGeometry"||o==="ConeGeometry"||o==="CubeGeometry"||o==="CylinderGeometry"||o==="DodecahedronGeometry"||o==="HelixGeometry"||o==="IcosahedronGeometry"||o==="LatheGeometry"||o==="PyramidGeometry"||o==="SphereGeometry"||o==="PlaneGeometry"||o==="BackdropGeometry"||o==="TorusGeometry"||o==="TorusKnotGeometry"||o==="BooleanGeometry"||o==="TextGeometry"||o==="InputGeometry"}r.isParametricMesh=t;function e(o){return o==="PolygonGeometry"||o==="RectangleGeometry"||o==="StarGeometry"||o==="TriangleGeometry"||o==="EllipseGeometry"||o==="PathGeometry"||o==="VectorGeometry"||o==="ConeGeometry"||o==="CubeGeometry"||o==="CylinderGeometry"||o==="DodecahedronGeometry"||o==="HelixGeometry"||o==="IcosahedronGeometry"||o==="LatheGeometry"||o==="PyramidGeometry"||o==="SphereGeometry"||o==="PlaneGeometry"||o==="BackdropGeometry"||o==="TorusGeometry"||o==="TorusKnotGeometry"||o==="TextGeometry"||o==="SubdivGeometry"||o==="NonParametricGeometry"}r.isSwappableGeometry=e})(Xs||(Xs={}));var Zc;(t=>{function i(e,r){let o={...e};return Object.assign(o,r),o.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(o.extrusion={...e.extrusion},Object.assign(o.extrusion,Kc.merge(o.extrusion,r.extrusion))),o}t.merge=i})(Zc||(Zc={}));var so;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};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:ya.defaultData(),extrusion:Qc};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:ma.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{...t.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")}t.defaultData=i})(so||(so={}));var Jc;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:Pt.white,near:.1,far:2e3})(Jc||(Jc={}));var eu;(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}}})(eu||(eu={}));var Lp;(t=>t.defaultData={softShadowQuality:"low"})(Lp||(Lp={}));var Bp;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Bp||(Bp={}));var Vp;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Vp||(Vp={}));var Ys;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Ys||(Ys={}));var zp;(t=>t.defaultData={playCamera:yi,gameControlObject:null})(zp||(zp={}));var tu;(t=>t.defaultData={backgroundColor:Ee.fromHexAndA(R0,1),postprocessing:eu.defaultData,fog:Jc.defaultData,globalPhysics:Ys.defaultData,ambient:Bp.defaultData,ao:Vp.defaultData,shadow:Lp.defaultData,publish:zp.defaultData})(tu||(tu={}));var ru;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(ru||(ru={}));var j0;(e=>{function i(r){return r==="Component"||r==="Instance"}e.isComponentRelated=i;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(j0||(j0={}));var ga;(o=>{o.identity={...Wc.identity,hiddenMatrix:mi.identity};function t(n){return{position:n.position,rotation:n.rotation,scale:n.scale,pivot:n.pivot,pivotRotation:n.pivotRotation,hiddenMatrix:n.hiddenMatrix}}o.fromObject=t;function e(n,a){return{position:a?.position||n.position,rotation:a?.rotation||n.rotation,pivot:a?.pivot||n.pivot,pivotRotation:a?.pivotRotation||n.pivotRotation,scale:a?.scale||n.scale,hiddenMatrix:a?.hiddenMatrix||n.hiddenMatrix}}o.merge=e;function r(n,a){return Jl({position:hi.isEqual(n.position,a.position)?void 0:a.position,rotation:hi.isEqual(n.rotation,a.rotation)?void 0:a.rotation,scale:hi.isEqual(n.scale,a.scale)?null:a.scale,hiddenMatrix:mi.isEqual(n.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=r})(ga||(ga={}));var vt;(t=>t.defaultData={states:new xe,events:new xe,timelineAnimations:new ue,visible:!0,raycastLock:!1,physics:bi.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...ga.identity,cloner:null})(vt||(vt={}));var ou;(t=>t.defaultData={type:"Empty",...vt.defaultData})(ou||(ou={}));var U0;(t=>t.defaultData={type:"ParticleCollider",...ru.defaultData,...vt.defaultData})(U0||(U0={}));var k0;(t=>t.defaultData={type:"Component",...vt.defaultData})(k0||(k0={}));var H0;(t=>t.defaultData={type:"Particle",...vt.defaultData,...fa.defaultData})(H0||(H0={}));var Ro;(t=>t.defaultData={type:"Mesh",...vt.defaultData,...Yc.defaultData})(Ro||(Ro={}));var an;(t=>t.defaultData={...vt.defaultData,...ga.identity,position:[0,0,xi.DefaultTargetOffset],...xi.defaultData})(an||(an={}));var iu;(e=>{function i(r){return{...vt.defaultData,...Xc.defaultData(r)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(iu||(iu={}));var xa;(e=>{function i(r,o,n=0){for(;n<o.length;){let a=r?r[o[n]]:void 0;if(o.length===n+1)return a;if(a)r=a.descendants,n+=1;else return}}e.resolveWithDes=i;function t(r,o,n=0){let a=i(r,o,n);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=t})(xa||(xa={}));var lo;(n=>{n.rootOverrideProps=["physics","events"],n.compositeNonOptionalOverrideProps=["geometry"],n.compositeEntireOverrideOverrideProps=["material"];function r(a,s){return{...vt.defaultData,...s,component:a,overrides:new We,physics:void 0,events:void 0,type:"Instance"}}n.ofComponent=r;function o(a){let s=ga.fromObject(a.data);return r(a.id,s)}n.fromComponentData=o})(lo||(lo={}));var Lo;(e=>{e.defaultData={type:"Page",...vt.defaultData,physics:{...bi.defaultData,fusedBody:!1},...tu.defaultData,camera:an.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(Lo||(Lo={}));var nu;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:mi.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:bi.defaultData,states:new xe,events:new xe,timelineAnimations:new ue,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...xi.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",...vt.defaultData,...Ro.defaultData,geometry:so.defaultData("RectangleGeometry"),material:At.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...vt.defaultData,...Ro.defaultData,geometry:so.defaultData("BooleanGeometry"),material:At.defaultTwoLayerData("phong","layer1","layer2")},s.defaultShapeBlendObject={name:"Shape Blend",...vt.defaultData,...Ro.defaultData,geometry:so.defaultData("ShapeBlendGeometry"),material:At.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...vt.defaultData,...Ro.defaultData,geometry:so.defaultData("TextGeometry"),material:At.defaultTwoLayerData("phong","layer1","layer2")},s.defaultInputObject={name:"Input",...vt.defaultData,...Ro.defaultData,geometry:so.defaultData("InputGeometry"),material:At.defaultTwoLayerData("phong","layer1","layer2")}))(nu||(nu={}));var sn;(o=>{function i(n,a){let s={name:a};return n.type==="Mesh"?(s.geometry={},"material"in n&&(s.material={layers:new We}),"materials"in n&&(s.materials=n.materials.map(l=>({layers:new We})))):Lr.is(n.type)&&(s.perspective={},s.orthographic={}),s}o.newEmpty=i;function t(n,a){if(a===void 0)return n;let s={...n};return"material"in s&&"material"in a&&a.material&&(s.material=ui(s.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(a.material.layers)){let d=l.layers.data(c);d&>.patch(d,u)}}).data),s.materials&&a.materials&&(s.materials=ui(s.materials,l=>{for(let c=0;c<s.materials.length;c++){let u=a.materials[c];if(typeof u!="string")for(let[d,p]of Object.entries(u.layers)){let f=l[c]?.layers?.data(d);f&>.patch(f,p)}}}).data),s}function e(n,a){let s,l=[],c={orthographic:0,perspective:0,geometry:0};function u(d,p){for(let[f,h]of Object.entries(p.layers)){let{texture:m,...y}=h;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...d,"layers",f,"texture"],props:m,type:0};l.push(g)}if(Object.keys(y).length>0){let g={path:[...d,"layers",f],props:y,type:0};l.push(g)}}}for(let[d,p]of Object.entries(a))if(d!=="name")if(d==="cloner")l.push(...qc.toOps(p,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:p.slide,offset:p.offset},type:0});else if(d==="material")u(["material"],p);else if(d==="materials")for(let[f,h]of Object.entries(p))u(["materials",f],h);else if(c[d]===0){if(d==="geometry"&&p.extrusion!==void 0){let f={path:[d,"extrusion"],props:p.extrusion,type:0};l.push(f),p={...p},delete p.extrusion}if(Object.keys(p).length>0){let f={path:[d],props:p,type:0};l.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[d]=p;return l}o.toOps=e;function r(n,a){if(a===void 0)return n;let s={...n};if(Object.assign(s,ga.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})}),Lr.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:Zc.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=t(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:ao.merge(s.cloner,a.cloner)});else if(n.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:ao.merge(s.cloner,a.cloner)});else if($c.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=Pt.clone(l.color))}return s}o.patch=r})(sn||(sn={}));var ba;(t=>t.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,rotationSpeed:1,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})(ba||(ba={}));var wr;(t=>t.defaultData={orbitControls:ba.defaultData,playPage:gi,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let o=0,n=0;return r<5?n=-30:r<10&&(n=30),r===0||r===10||r===5?o=30:(r===4||r===11||r===9)&&(o=-30),[120,[o,n],"show"]}),settings:{image:{format:"jpg",ratio:1,colorSpace:"display-p3"},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,format:"mp4",imageFormat:"jpg",activeTimeline:null,colorSpace:"display-p3"},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1})(wr||(wr={}));var Gp;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Gp||(Gp={}));var Fp;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Fp||(Fp={}));var Bo;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Gp.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Fp.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Bo||(Bo={}));var W0;(e=>{function i(r){return r.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function t(r,o,n){r.scene.objects.traverseFrom(o,(a,s)=>{if(s.type==="Instance"){let l=co.getComponentData(r,s.component)?.data;l&&n(a,s,l.events)}else n(a,s,s.events)})}e.traverseModuleInstances=t})(W0||(W0={}));var Vo;(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:iu.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(u=!0,d=[]){let p=[],f=nu.defaultMeshObject;u&&(p.push({...c.defaultLight}),p.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:f,children:[]})),p.push(...d);let h=new Ze;return h.push({fi:1,id:gi,data:{...Lo.defaultData,name:"Scene 1"},children:p}),h}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:wr.defaultData,styles:Bo.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new Ze,publish:wr.defaultData,styles:Bo.defaultData()}},c.emptyDataWithPage=function(u=!0){return{objects:e(u),publish:wr.defaultData,styles:Bo.defaultData()}},c.emptyData=function(){return{objects:new Ze,publish:{...wr.defaultData},styles:Bo.defaultData()}};function s(u){return{...c.defaultData,objects:Ct(u,Ze.prototype)}}c.withObjs=s;function l(u,d){return s([{id:u,data:d,children:[],fi:0}])}c.withObj=l})(Vo||(Vo={}));var va;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(va||(va={}));var au;(e=>(e.defaultData=r=>({url:r,name:"New Webhook",parametersSchemas:new xe}),e.defaultParameterValueByType=r=>r==="number"?0:r==="boolean"?!1:""))(au||(au={}));var q0;(t=>t.defaultData=(e,r="GET")=>({url:e,method:r,name:"New API",headers:new xe,queries:new xe,autoStart:!0}))(q0||(q0={}));var vi;(n=>{function i(a){return a.textValue!==void 0}n.isTextValue=i;function t(a){return typeof a=="number"}n.isNumber=t;function e(a){return typeof a=="boolean"}n.isBoolean=e;function r(a){return i(a)?"string":e(a)?"boolean":"number"}n.typeOfVariable=r;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})(vi||(vi={}));var jp;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(jp||(jp={}));var $0;(t=>t.all=[...jp.all,"components"])($0||($0={}));var X0;(t=>{function i(){return{images:new ue,videos:new ue,colors:new ue,audios:new ue,particles:new ue,fonts:new ue,materials:new ue,components:new ue,variables:new ue,userAPIs:new ue,userWebhooks:new ue,timelineAnimations:new ue}}t.defaultData=i})(X0||(X0={}));var Br;(t=>{function i(){return{images:new ue,videos:new ue,colors:new ue,audios:new ue,particles:new ue,fonts:new ue,materials:new ue,components:new ue,variables:new ue,userAPIs:new ue,userWebhooks:new ue,timelineAnimations:new ue}}t.defaultData=i})(Br||(Br={}));var Pr;(n=>{function i(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ct(a,ue.prototype)}n.defaultColors=i;function t(){return Ct({},ue.prototype)}n.defaultImages=t;function e(){return{catelogs:new ue,materials:new ue,images:new ue,videos:new ue,colors:new ue,timelineAnimations:new ue,audios:new ue,particles:new ue,fonts:new ue,variables:new xe,userAPIs:new ue,userWebhooks:new ue,lib:Br.defaultData()}}n.emptyData=e;function r(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=r;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})(Pr||(Pr={}));import{MathUtils as cu}from"three";var su;(t=>t.list=["idle","move","jump","run"])(su||(su={}));var lu;(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 xe,move:new xe,jump:new xe,run:new xe},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Ee.fromHexAndA(3728051,1)}}))(lu||(lu={}));function Y0(i){i.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,o=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let s=2;s<10;s++)o.push(o[1]),n.push(1);let a={...Rr(lt(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:o,steps:n,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...lt(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function zo(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function Go(i,t){i.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((o,n)=>{o===void 0&&(r.materials[n]=At.defaultData(),o=r.materials[n]),typeof o!="string"&&t(o)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=At.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=At.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&Object.getPrototypeOf(o.material)!==We.prototype&&t(o.material)})})}function mM(i){Object.assign(i.scene.publish,{orbitControls:{...ba.defaultData,...lt(i.scene.publish.orbitControls)}})}function yM(i){Object.assign(i.scene.publish.settings,{video:{...wr.defaultData.settings.video,...lt(i.scene.publish.settings.video)}})}function gM(i){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[o,n]of Object.entries(r))if((G0.includes(o)||typeof n=="boolean")&&delete r[o],o==="texture")for(let[a,s]of Object.entries(n))(F0.includes(a)||typeof s=="boolean")&&delete n[a]}}}i.scene.objects.traverse((e,r)=>{r.states.forEach(o=>{let n=o;n.material?t(n.material):n.materials&&n.materials.forEach(a=>{t(a)})})})}function xM(i){i.scene.publish.withBackground=!0}function bM(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function vM(i){i.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(o=>o+1),r.linear.scale=r.linear.scale.map(o=>o+1))})}function SM(i){i.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function wM(i){i.scene.objects.traverse((t,e)=>{let r=i.scene.objects.unproxy().parent(t);if(r){let o=lt(i.scene.objects.data(r));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=lt(e).booleanExclude!==!0)}})}function PM(i){i.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function OM(i){function t(r){Object.setPrototypeOf(r,We.prototype),r.texture&&Object.setPrototypeOf(r.texture,We.prototype)}function e(r){Object.setPrototypeOf(r,We.prototype);for(let o in r)t(r[o])}i.scene.objects.traverse((r,o)=>{o.states.forEach(n=>{let a=n;if(a.material){let s=lt(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=lt(l).layers;e(c),l.layers=c}})})}function K0(i){i.layers===void 0&&Object.assign(i,At.defaultTwoLayerData("lambert"))}function Up(i){!i.layers||i.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let o={...lt(t),colors:e,steps:r};Object.assign(t,o)}})}function TM(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function Q0(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&Up(r)}):"material"in e&&typeof e.material!="string"&&Up(e.material)}),Object.values(i.shared.materials).forEach(t=>Up(t))}function CM(i){i.scene.environment.ambientLight.softShadows=!1,i.scene.environment.ambientLight.softShadowQuality="low",i.scene.objects.traverse((t,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 AM(i){i.shared.audios=Ct({},ue.prototype)}function MM(i){i.shared.videos=Ct({},ue.prototype)}function IM(i){let t=i.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.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(t,{[e]:o})}})}function EM(i){Object.entries(lt(i.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.images[r]}),Object.entries(lt(i.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.audios[r]})}function NM(i){i.scene.publish.settings.web.preload=!1}function Z0(i){i.layers&&i.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function J0(i){i.layers&&i.layers.forEach(t=>{z0(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function DM(i){i.shared.fonts=Ct({},ue.prototype)}function _M(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 RM(i){let t=[];i.scene.objects.traverse((e,r)=>{let o=r;if(o.type==="TextFrame"){let n=At.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=_M(o.font);i.shared.fonts[s]===void 0&&(i.shared.fonts[s]={name:s});let l={name:o.name,...vt.defaultData,...Ro.defaultData,flatShading:!1,wireframe:!1,geometry:{...so.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:lt(o.states),events:lt(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},c=lt(i.scene.objects).parent(e);i.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{i.scene.objects.delete(e)})}function LM(i){let t={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,r)=>{r.events.forEach(o=>{if(!!t[Number(o.type)])if(Object.assign(o,{type:t[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 xe,move:new xe,jump:new xe}});else{let n=new xe;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:cu.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,Rr(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(u,{control1:{...a.control1},control2:{...a.control2}});let d={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},p={state:a.state,...d,...u},f={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new xe({fi:0,id:cu.generateUUID(),data:c},{fi:1,id:cu.generateUUID(),data:p})};n.push({fi:l,id:s,data:f})}),delete o.targets)}})})}function BM(i){i.scene.objects.traverse((t,e)=>{function r(o,n){let a=new xe,s=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===n){let d;s.push(c),l.interaction==="play"?d={...Rr(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")&&(d={...Rr(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&a.push({fi:u,id:c,data:d})}}),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:cu.generateUUID(),data:{type:o,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function ex(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=gt.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function tx(i){zo(i,ex),Go(i,ex)}function VM(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function zM(i){i.scene.objects.traverse((t,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 GM(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=At.defaultTwoLayerData("phong"))})}function FM(i){i.scene.publish.orbitControls.autoZoom===void 0&&(i.scene.publish.orbitControls.autoZoom=!1),i.scene.objects.traverse((t,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 jM(i){i.scene.objects.traverse((t,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 UM(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 kM(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function HM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function WM(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function qM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=lu.defaultDataThirdPerson.navmesh)})})}function $M(i){i.scene.styles||(i.scene.styles=Bo.defaultData())}function rx(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function XM(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}),Go(i,rx),zo(i,rx)}function YM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new xe})})})}function KM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function ox(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function ix(i,t){if(t<1&&(Go(i,Y0),zo(i,Y0),i.schema=1),t<2&&(mM(i),i.schema=2),t<3&&(gM(i),i.schema=3),t<4&&(xM(i),i.schema=4),t<5&&(bM(i),i.schema=5),t<6&&(vM(i),i.schema=6),t<7&&(SM(i),i.schema=7),t<8&&(i.schema=8),t<9&&(Q0(i),i.schema=9),t<10&&(TM(i),i.schema=10),t<11&&(CM(i),i.schema=11),t<12&&(Q0(i),i.schema=12),t<13&&(AM(i),i.schema=13),t<14&&(IM(i),i.schema=14),t<15&&(EM(i),i.schema=15),t<16&&(NM(i),i.schema=16),t<17&&(Go(i,Z0),zo(i,Z0),i.schema=17),t<18&&(Go(i,K0),zo(i,K0),i.schema=18),t<19&&(yM(i),i.schema=19),t<20&&(DM(i),RM(i),i.schema=20),t<21&&(LM(i),BM(i),i.schema=21),t<22&&(tx(i),i.schema=22),t<23&&(VM(i),i.schema=23),t<24&&(zM(i),i.schema=24),(t<25||i.shared.videos===void 0)&&(MM(i),t<25&&(i.schema=25)),t<26&&(wM(i),i.schema=26),t<27&&(PM(i),i.schema=27),t<28&&(tx(i),i.schema=28),t<29&&(OM(i),i.schema=29),t<30&&(GM(i),i.schema=30),t<31&&(FM(i),i.schema=31),t<33&&(jM(i),i.schema=33),t<34&&(UM(i),i.schema=34),t<35&&(kM(i),i.schema=35),t<36&&(HM(i),i.schema=36),t<37&&(WM(i),i.schema=37),t<38&&(Go(i,J0),zo(i,J0),i.schema=38),t<39&&(qM(i),i.schema=39),t<40&&($M(i),i.schema=40),t<41&&(XM(i),i.schema=41),t<42&&(YM(i),i.schema=42),t<43&&(KM(i),i.schema=43),t<99){Go(i,ox),zo(i,ox),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=yi);let e=lt(i.scene.objects),r=i.scene.objects;i.scene.publish.playPage=gi,r.insertBefore(null,null,[{id:gi,data:{...Lo.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Rr(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Rr(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Ys.defaultData,...Rr(i.scene.environment,"usePhysics","gravity")},camera:lt(i.scene.ownerCamera)??Lo.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==Vo.TRASH_CAN_ID&&r.move(gi,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,bi.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),i.schema=99}}function nx(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function QM(i){i.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function ZM(i){Array.isArray(lt(i.events))&&i.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var Sa=180/Math.PI;function ax(i){i.rotation=i.rotation.slice(0,3).map(t=>t*Sa)}function sx(i){ax(i),i.type==="Page"&&ax(i.camera),i.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*Sa))});let t=i.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Sa),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Sa),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Sa,t.extrusion.twist*=Sa),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(lt(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 JM(i){i.shared.variables=Ct({},ue.prototype)}function eI(i){let t=lt(i.shared.variables);i.shared.variables=Ct(Object.entries(t??{}).map(([e,r],o)=>({fi:o,id:e,data:r})),xe.prototype)}var uo=122;function uu(i,t){t(i.data);for(let e of i.children)uu(e,t)}function tI(i){let t=i.schema??104;t!==uo&&(t<105&&(uu(i.asset,sx),i.schema=105),t<118&&(uu(i.asset,lx),i.schema=118),t<121&&(uu(i.asset,kp),i.schema=121))}function rI(i){i.shared.particles=Ct({},ue.prototype),i.shared.lib&&(i.shared.lib.particles=Br.defaultData().particles)}function oI(i){i.scene.objects.traverse((t,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function iI(i){i.scene.objects.traverse((t,e)=>{e.type==="Page"&&(e.postprocessing.depthOfField.focusDistance=100,e.postprocessing.depthOfField.focalLength=20,e.postprocessing.depthOfField.bokehScale=5)})}function nI(i){i.scene.objects.traverse((t,e)=>{Array.isArray(lt(e.events))!==!1&&e.events?.forEach(r=>{let o=r.runMode;r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="Collision"||r.type==="Trigger"?r.actions?.forEach(n=>{n.type==="Transition"&&(n.runMode=o??"Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode=o==="Toggle"?"Toggle":"Normal")}):r.type==="MouseHover"||r.type==="MousePress"||r.type==="KeyPress"?r.actions?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")}):r.type==="GameControl"?(delete r.actions,Object.keys(r.gameActions).forEach(a=>{r.gameActions[a]?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),s.type==="Animation"&&(s.runMode="Normal")})})):r.type==="DragDrop"?(delete r.actions,r.dragDropActions?.drag?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")}),r.dragDropActions?.drop?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")})):r.type==="Resize"?(delete r.actions,r.breakpoints?.forEach(n=>{n.actions?.forEach(a=>{(a.type==="Transition"||a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Toggle")})})):r.type==="Start"?r.actions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Once"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}):r.type==="VariableChange"||r.type==="Scroll"?r.actions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}):r.type==="Conditional"&&(delete r.actions,r.inActions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}),r.outActions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}))})})}function aI(i){i.shared.userAPIs=Ct({},ue.prototype),i.shared.userWebhooks=Ct({},ue.prototype),i.shared.lib&&(i.shared.lib.userAPIs=Br.defaultData().userAPIs,i.shared.lib.userWebhooks=Br.defaultData().userWebhooks)}function sI(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=wr.defaultData.settings.videoStatic)}function lx(i){i.timelineAnimations=Ct({},ue.prototype)}function kp(i){console.log("Updating pivot for object:",i.name),i.pivot=[0,0,0],i.pivotRotation=[0,0,0]}function du(i){let t=i.schema??0;if(t!==uo){console.warn("updating from ",t,"to ",uo),ix(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=wr.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(Go(i,nx),zo(i,nx),i.schema=101),t<102&&(QM(i),i.schema=102),t<104&&(i.shared.catelogs=new ue,i.shared.lib=Br.defaultData(),i.schema=104),t<105&&(JM(i),i.scene.objects.traverse((e,r)=>{sx(r)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))tI(e);t<106&&(eI(i),i.schema=106),t<107&&(i.shared.lib.variables=Br.defaultData().variables,i.schema=107),t<109&&(rI(i),i.schema=109),t<110&&(oI(i),i.schema=110),t<111&&(i.scene.objects.traverse((e,r)=>{ZM(r)}),i.schema=111),t<112&&(iI(i),i.schema=112),t<113&&(nI(i),i.schema=113),t<114&&(i.scene.publish.settings.web.imageQuality===void 0&&(i.scene.publish.settings.web.imageQuality=70),i.schema=114),t<115&&(aI(i),i.schema=115),t<116&&(sI(i),i.schema=116),t<117&&(i.scene.publish.settings.web.pixelRatioMobile===void 0&&(i.scene.publish.settings.web.pixelRatioMobile=0),i.scene.publish.settings.web.pixelRatioDesktop===void 0&&(i.scene.publish.settings.web.pixelRatioDesktop=0),i.schema=117),t<118&&(i.shared.timelineAnimations=Ct({},ue.prototype),i.scene.objects.traverse((e,r)=>{lx(r)}),i.schema=118),t<119&&(i.scene.publish.settings.videoStatic.format=co.defaultData.scene.publish.settings.videoStatic.format,i.scene.publish.settings.videoStatic.imageFormat=co.defaultData.scene.publish.settings.videoStatic.imageFormat,i.schema=119),t<120&&(i.scene.publish.settings.image.colorSpace="display-p3",i.scene.publish.settings.videoStatic.colorSpace="display-p3",i.schema=120),t<121&&(i.scene.objects.traverse((e,r)=>{kp(r),r.type==="Page"&&kp(r.camera)}),i.schema=121),t<122&&(delete i.scene.publish.settings.video,i.scene.publish.orbitControls.rotationSpeed=co.defaultData.scene.publish.orbitControls.rotationSpeed,i.schema=122)}}var co;(c=>{c.defaultData={schema:uo,scene:Vo.defaultData,frames:new ue().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",va.defaultData),shared:{...Pr.emptyData(),colors:Pr.defaultColors()}},c.emptyDataForImports=function(){let u=Vo.emptyDataWithPage();return{schema:uo,scene:u,frames:new ue().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",va.defaultData),shared:{...Pr.emptyData(),colors:Pr.defaultColors(),images:Pr.defaultImages()}}},c.emptyData=function(){return{schema:uo,scene:Vo.emptyDataWithPage(),frames:new ue().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",va.defaultData),shared:Pr.emptyData()}},c.clipboard2dData=function(){return{schema:uo,scene:Vo.emptyData(),frames:new ue,shared:Pr.emptyData()}},c.collabHelper={...ks,updateSchema(u){return(u.schema??0)<uo?ui(u,du):(u.schema??0)-uo}};function n(u){let d=c.collabHelper.updateSchema(u);return typeof d=="number"?d===0?u:null:d.data}c.updateSchemaDirectly=n;function a(u){return{...u,shared:{...u.shared,lib:Br.defaultData()}}}c.withoutLib=a;function s(u,d){let p=u.scene.objects.get(d);if(p&&p.data.type==="Component")return p;{let f=u.shared.lib.components[d];if(f)return{...f.asset,id:d}}}c.getComponentData=s;function l(u){let d=Object.values(u.shared.userAPIs);for(let p of d){let f=p.headers;for(let h of f)if(h.data.key.toLowerCase()==="authorization"&&h.data.value!=="")return!0}return!1}c.hasSensitiveData=l})(co||(co={}));var pu;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(pu||(pu={}));var cx;(t=>{function i(e){return!0}t.is=i})(cx||(cx={}));var fu;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(o,n){return{position:n?.position??o.position,rotation:n?.rotation??o.rotation,scale:n?.scale??o.scale,shear:n?.shear??o.shear}}r.merge=t;function e(o,n){return Jl({position:pa.isEqual(o.position,n.position)?void 0:n.position,rotation:o.rotation===n.rotation?void 0:n.rotation,scale:pa.isEqual(o.scale,n.scale)?void 0:n.scale,shear:o.shear&&n.shear&&pa.isEqual(o.shear,n.shear)?void 0:n.shear})}r.diff=e})(fu||(fu={}));var Hp;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(Hp||(Hp={}));var ux;(t=>t.defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8})(ux||(ux={}));var hu;(t=>t.defaultData={opacity:1,fill:{color:Ee.fromHexAndA(bt,1),enabled:!0},stroke:{color:Ee.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:Ee.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Ee.from0to1([0,0,0,1]),enabled:!1,spread:0}})(hu||(hu={}));var ln;(n=>{function i(a,s){return{name:s}}n.newEmpty=i;function t(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 r(a,s){if(s===void 0)return a;let l={...a};return Object.assign(l,fu.merge(l,s)),l=t(l,s),l=e(l,s),l}n.patch=r;function o(a,s){let l,c=[];for(let[u,d]of Object.entries(s))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[u]=d);return c}n.toOps=o})(ln||(ln={}));var Ks;(t=>t.defaultData={...fu.defaultData,...Hp.defaultData,states:new xe,events:new xe,visible:!0,raycastLock:!1})(Ks||(Ks={}));var wa;(t=>t.defaultData={...Ks.defaultData,...hu.defaultData})(wa||(wa={}));var mu;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(mu||(mu={}));var Wp;(t=>t.defaultData={...wa.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(Wp||(Wp={}));var Pa;(t=>t.defaultData={...wa.defaultData,...mu.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Pa||(Pa={}));var qp;(t=>t.defaultData={...wa.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"})(qp||(qp={}));var $p;(t=>t.defaultData={...wa.defaultData,type:"path2d",path:"",name:"Path"})($p||($p={}));var dx;(t=>{function i(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=i})(dx||(dx={}));var Qs;(t=>t.defaultData={...Ks.defaultData,name:"Group",type:"group2d"})(Qs||(Qs={}));var Xp;(t=>t.defaultData=()=>({...Ks.defaultData,...mu.defaultData,...hu.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Ee.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Ee.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(Xp||(Xp={}));var Fo;(n=>{function i(a){switch(a){case"rectangle2d":return{...Pa.defaultData};case"ellipse2d":return{...Wp.defaultData};case"text2d":return{...qp.defaultData};case"vector2d":return{...Pa.defaultData};case"path2d":return{...$p.defaultData};case"frame2d":return{...Xp.defaultData()};case"group2d":return{...Qs.defaultData}}}n.defaultData=i;function t(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=t;function e(a){return a.type==="rectangle2d"||a.type==="ellipse2d"||a.type==="text2d"||a.type==="frame2d"}n.isResizeable=e;function r(a){return a.type==="frame2d"&&a.autoLayout!==void 0}n.isAutoLayoutable=r;function o(a){return a.type==="rectangle2d"||a.type==="frame2d"}n.hasCorners=o})(Fo||(Fo={}));var yu;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new Ze},e.emptyData=function(){return{type:"scene2d",objects:new Ze}}))(yu||(yu={}));import{Color as lI}from"three";var Mt=class extends lI{constructor(e,r,o,n){super(e,r,o);this.isColorA=!0;this.a=n}setRGBA(e,r,o,n){super.setRGB(e,r,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,r="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,r);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,r);break}}return super.setStyle(e,r)}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 md=Bs(fx());import{Object3D as TD,Vector3 as yr,Euler as Nh,MathUtils as Jv,Matrix4 as Mn}from"three";var cI=.5*(Math.sqrt(3)-1),Zs=(3-Math.sqrt(3))/6,uI=1/3,po=1/6,e8=(Math.sqrt(5)-1)/4,t8=(5-Math.sqrt(5))/20,Js=i=>Math.floor(i)|0,hx=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]),Kp=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 mx(i=Math.random){let t=gx(i),e=new Float64Array(t).map(o=>hx[o%12*2]),r=new Float64Array(t).map(o=>hx[o%12*2+1]);return function(n,a){let s=0,l=0,c=0,u=(n+a)*cI,d=Js(n+u),p=Js(a+u),f=(d+p)*Zs,h=d-f,m=p-f,y=n-h,g=a-m,b,w;y>g?(b=1,w=0):(b=0,w=1);let P=y-b+Zs,S=g-w+Zs,T=y-1+2*Zs,A=g-1+2*Zs,x=d&255,N=p&255,E=.5-y*y-g*g;if(E>=0){let _=x+t[N],R=e[_],V=r[_];E*=E,s=E*E*(R*y+V*g)}let M=.5-P*P-S*S;if(M>=0){let _=x+b+t[N+w],R=e[_],V=r[_];M*=M,l=M*M*(R*P+V*S)}let D=.5-T*T-A*A;if(D>=0){let _=x+1+t[N+1],R=e[_],V=r[_];D*=D,c=D*D*(R*T+V*A)}return 70*(s+l+c)}}function yx(i=Math.random){let t=gx(i),e=new Float64Array(t).map(n=>Kp[n%12*3]),r=new Float64Array(t).map(n=>Kp[n%12*3+1]),o=new Float64Array(t).map(n=>Kp[n%12*3+2]);return function(a,s,l){let c,u,d,p,f=(a+s+l)*uI,h=Js(a+f),m=Js(s+f),y=Js(l+f),g=(h+m+y)*po,b=h-g,w=m-g,P=y-g,S=a-b,T=s-w,A=l-P,x,N,E,M,D,_;S>=T?T>=A?(x=1,N=0,E=0,M=1,D=1,_=0):S>=A?(x=1,N=0,E=0,M=1,D=0,_=1):(x=0,N=0,E=1,M=1,D=0,_=1):T<A?(x=0,N=0,E=1,M=0,D=1,_=1):S<A?(x=0,N=1,E=0,M=0,D=1,_=1):(x=0,N=1,E=0,M=1,D=1,_=0);let R=S-x+po,V=T-N+po,U=A-E+po,B=S-M+2*po,q=T-D+2*po,j=A-_+2*po,F=S-1+3*po,H=T-1+3*po,W=A-1+3*po,ee=h&255,te=m&255,Y=y&255,re=.6-S*S-T*T-A*A;if(re<0)c=0;else{let $=ee+t[te+t[Y]];re*=re,c=re*re*(e[$]*S+r[$]*T+o[$]*A)}let K=.6-R*R-V*V-U*U;if(K<0)u=0;else{let $=ee+x+t[te+N+t[Y+E]];K*=K,u=K*K*(e[$]*R+r[$]*V+o[$]*U)}let Z=.6-B*B-q*q-j*j;if(Z<0)d=0;else{let $=ee+M+t[te+D+t[Y+_]];Z*=Z,d=Z*Z*(e[$]*B+r[$]*q+o[$]*j)}let Q=.6-F*F-H*H-W*W;if(Q<0)p=0;else{let $=ee+1+t[te+1+t[Y+1]];Q*=Q,p=Q*Q*(e[$]*F+r[$]*H+o[$]*W)}return 32*(c+u+d+p)}}function gx(i){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let o=r+~~(i()*(256-r)),n=e[r];e[r]=e[o],e[o]=n}for(let r=256;r<512;r++)e[r]=e[r-256];return e}import{Triangle as dI}from"three";var Vr=new dI,gu=class{constructor(t){this.weightAttribute=null;let e=t.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 t=this.positionAttribute,e=new Float32Array(t.count/3);for(let o=0;o<t.count;o+=3){let n=1;Vr.a.fromBufferAttribute(t,o),Vr.b.fromBufferAttribute(t,o+1),Vr.c.fromBufferAttribute(t,o+2),n*=Vr.getArea(),e[o/3]=n}this.distribution=new Float32Array(t.count/3);let r=0;for(let o=0;o<e.length;o++)r+=e[o],this.distribution[o]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],o=this.binarySearch(this.randomFunction()*r);return this.sampleFace(o,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,o=e.length-1,n=-1;for(;r<=o;){let a=Math.ceil((r+o)/2);if(a===0||e[a-1]<=t&&e[a]>t){n=a;break}else t<e[a]?o=a-1:r=a+1}return n}sampleFace(t,e,r){let o=this.randomFunction(),n=this.randomFunction();return o+n>1&&(o=1-o,n=1-n),Vr.a.fromBufferAttribute(this.positionAttribute,t*3),Vr.b.fromBufferAttribute(this.positionAttribute,t*3+1),Vr.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(Vr.a,o).addScaledVector(Vr.b,n).addScaledVector(Vr.c,1-(o+n)),Vr.getNormal(r),this}};import{Object3D as yI}from"three";var vx=Bs(bx());import{Object3D as pI,Matrix4 as zr}from"three";var fI=new zr,hI=new zr,mI=new zr,jo;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(jo||(jo={}));var Oa=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new zr;this.copyPreviousMatrix=!0;this.hiddenMatrix=new zr;this.pivotMatrix=new zr;this.matrixWorldRigid=new zr;this.shearScale=new zr;this.shearScaleInv=new zr}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof pI&&(r=r.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===r)return!0;o=o.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,r=!0);for(let o of this.children)o.updateMatrixWorld(r)}updateWorldMatrix(r,o){let n=this.parent;if(r&&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)),this.matrixWorld.multiply(this.pivotMatrix),o)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(r,o=0){for(let n of this.children)jo.is(n)&&n.traverseObject(r,o+1)}traverseObject(r,o=0){if(r(this,o)!==!0)for(let a of this.children)jo.is(a)&&a.traverseObject(r,o+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,o=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:n,v:a,q:s}=(0,vx.SVD)(o),l=fI.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=hI.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=mI.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(d=>Math.abs(s[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,o){this.updateWorldMatrix(!0,!1);let n=new zr().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),n.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof zr?r.hiddenMatrix.premultiply(n):r.applyMatrix4(n),r.updateWorldMatrix(!1,!1),this.add(r),o!==void 0&&(this.children.pop(),this.children.splice(o,0,r)),this}copy(r,o=!1){return super.copy(r,o),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,o,n,a,s,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var Qp=class extends Oa(yI){},gI=i=>i.type==="Mesh",Gr=class extends Qp{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let o=this.children[e];o?.object!==r&&(o&&this.remove(o),o=new Gr(r),this.add(o),this.children.splice(e,0,this.children.pop()),o.matrixWorldNeedsUpdate=!0,o.matrixAutoUpdate=!1,o.matrix=r.matrix,o.hiddenMatrix=r.hiddenMatrix,o.pivotMatrix=r.pivotMatrix),o.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}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 gI(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}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(e){}};import{Box3 as GE,BufferGeometry as FE,MeshBasicMaterial as jE}from"three";import{Matrix4 as VE,Mesh as zE}from"three";import{Matrix4 as vu,Vector3 as af,Euler as Tx,MathUtils as dn,Quaternion as PI}from"three";import{Box3 as xI,Line3 as bI,Matrix4 as Zp,Vector3 as fr}from"three";var cn=new fr,un=new fr,Ta=new Zp,wx=[new fr(-1,1,1),new fr(-1,-1,1),new fr(1,-1,1),new fr(1,1,1),new fr(-1,1,-1),new fr(-1,-1,-1),new fr(1,-1,-1),new fr(1,1,-1)],vI=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],SI=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Sx=(i,t,e)=>{i.updateEntityBoxSize(cn,un),Ta.copy(t).multiply(i.matrixWorld),un.x===0&&un.y===0&&un.z===0?e.push(new fr(cn.x,cn.y,cn.z).applyMatrix4(Ta)):wx.forEach(r=>{e.push(r.clone().multiply(un).add(cn).applyMatrix4(Ta))})},el=class extends xI{constructor(){super(...arguments);this.matrix=new Zp;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let o=new Zp().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,r)}expandByObjectSize(e,r,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 fr);return}Sx(a,r,n)}}):Sx(e,r,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(Ta.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(un).multiplyScalar(.5),this.getCenter(cn),Ta.copy(this.matrix).setPosition(cn),this.vertices=wx.map(e=>e.clone().multiply(un).applyMatrix4(Ta))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=vI.map(([e,r])=>new bI(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new fr))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=SI.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var Fr={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};import{CurvePath as wI,CubicBezierCurve3 as Jp,Vector3 as jr}from"three";var tf=class extends wI{constructor(){super()}getPoints(t=12){let e=[],r,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],d=Math.ceil(t*u/a),p=c.getPoints(d);for(let f=0;f<p.length;f++){let h=p[f];r&&r.equals(h)||(e.push(h),r=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var rf=.001;function of(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=rf}function ef(i,t){let e=new jr(...i.position),r=new jr(...i.controlNext.position),o=new jr(...t.controlPrevious.position),n=new jr(...t.position);return of(e,r,n)&&of(e,o,n)}function bu(i){let t=i.points.map(u=>new jr(...u.data.position)),e=[i.points[0]],r=new jr(...e[0].data.position);for(let u=0;u<i.points.length-1;u++)of(r,t[u],t[u+1])||(e.push(i.points[u]),r=t[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 d=e[u].data,p=new jr(...d.position),f=new jr(...d.controlPrevious.position),h=new jr(...d.controlNext.position),m={position:p,baseRoundness:d.roundness,controlPrevious:f,controlNext:h};if(d.roundness===0||!i.isClosed&&(u===0||u===a-1)){s[u]={...m,removedLength:0};continue}let y=o&&u==0?a-1:u-1,g=o&&u==a-1?0:u+1,b=e[y].data,w=e[g].data,P=new jr(...b.position),S=new jr(...w.position),T=P.clone().sub(p).normalize(),A=S.clone().sub(p).normalize();Object.assign(m,{prevDir:T,nextDir:A});let x=ef(b,d),N=ef(d,w);if(!x||!N)s[u]={...m,removedLength:0};else{let E=T.clone().add(A).normalize(),M=E.clone().cross(T).length()/T.dot(E);s[u]={...m,tan:M,removedLength:d.roundness/M}}}for(let u=0;u<n;u++){let d=u,p=o&&u===a-1?0:u+1,f=s[d],h=s[p];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 d=u,p=o&&u===a-1?0:u+1,f=s[d],h=s[p],m=null;if(!ef(e[d].data,e[p].data))f.position.distanceTo(h.position)>rf&&(m=new Jp(f.position,f.controlNext,h.controlPrevious,h.position));else{let y=f.position.clone(),g=h.position.clone();(f.removedLength!==0||h.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),h.prevDir&&g.add(h.prevDir.clone().setLength(h.removedLength))),y.distanceTo(g)>rf&&(m=new Jp(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}l[2*u+1]=m}for(let u=0;u<a;u++){let d=s[u];if(d.removedLength===0){l[2*u]=null;continue}let p=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(p),h=d.nextDir.clone().multiplyScalar(d.removedLength).add(p),m=d.tan*d.removedLength,y=d.prevDir.clone().add(d.nextDir).normalize(),g=f.clone().lerp(h,.5),b=f.distanceTo(h)/2,w=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(b,2))).add(g),P=y.clone().multiplyScalar(-m).add(w),S=p.distanceTo(P)/p.distanceTo(g),T=d.prevDir.clone().multiplyScalar(S*p.distanceTo(f)).add(p),A=T.clone().lerp(P,2),x=f.clone().lerp(T,4/3),N=h.clone().lerp(A,4/3);l[2*u]=new Jp(f,x,N,h)}let c=new tf;return l.forEach(u=>{u&&c.add(u)}),c}var _e;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(_e||(_e={}));var Ca=i=>_e.is(i),OI={type:"completeState",isfromEntity:!0},TI=["x","y","z"],tl=new af,Px=new af(1,1,1),nf=new PI,Ox=new Tx,CI=new af().set(0,1,0),Aa=i=>class extends Oa(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.currentAnimationAction=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new el;this._recursiveBBox=new el;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let o=this.children[r];if(_e.is(o))return o}entityChildrenCount(){let r=this.children.length;for(;r--;)if(_e.is(this.children[r]))return r+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 r=this;for(;r.data.type!=="Instance";){let o=r.parent;if(_e.is(o))r=o;else return}return r}forInstancesRec(r){this.instances.forEach(o=>{o.disposed||r(o),o.forInstancesRec(r)})}super_Entity(r,o){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=o,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,o,n=!1){if(!(this.data.states.length===0&&!n)){for(let a of this.data.states)sn.toOps(this.data,a.data).forEach(l=>{let c=la.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(c,this.data,o)});if(r!==null){let a=this.data.states.data(r);a&&(this.dataPatched=sn.patch(this.data,a),sn.toOps(this.data,a).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,o)}))}n&&this.updateTransformState(this.dataPatched,o),this.stateSelection=r,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(r,o){r.setScalar(0),o.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{Ca(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let o;return this.traverseEntity(n=>{n.uuid===r&&(o=n)}),o}traverseSortNextHelper(){let r=this.parent;if(r){let o=r.children,n=o.indexOf(this)+1;if(_e.is(o[n]))return o[n];if(_e.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&_e.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let o=this;for(;r>0&&o!==null;)o=o.parent,r-=1;return o}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let o=this.parent;for(;o;){if(r===o)return!0;o=o.parent}return!1}countToAccestor(r){let o=0,n=this;for(;n!==r;){if(n===null)return-1;n=n.parent,o+=1}return o}forEachEntity(r){for(let o of this.children)Ca(o)&&r(o)}traverseEntityAncestors(r){this.traverseAncestors(o=>{_e.is(o)&&r(o)})}traverseConcreteEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Ca(a)&&a.isConcreteEntity&&a.traverseEntity(r,o+1)}traverseEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Ca(a)&&a.traverseEntity(r,o+1)}traverseVisibleEntity(r){r(this);for(let o of this.children)Ca(o)&&o.visible&&o.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,o=!1){return super.copy(r,o),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>Ca(r))}isAncestorOf(r){if(this.uuid===r)return!1;let o=!1;return this.traverseEntity(n=>{n.uuid===r&&(o=!0)}),o}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x*dn.RAD2DEG,this.rotation.y*dn.RAD2DEG,this.rotation.z*dn.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]};return oa(o,r)}getTransformValues(r,o,n){return o[r].map((a,s)=>n?.shared.getVariable(a,[this.uuid,r,TI[s]])??a)}updateTransformState(r,o){let n=!1;if(r.position&&(this.position.fromArray(this.getTransformValues("position",r,o)),n=!0),r.rotation&&(tl.fromArray(this.getTransformValues("rotation",r,o)).multiplyScalar(dn.DEG2RAD),this.rotation.setFromVector3(tl),n=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,o)),n=!0),r.hiddenMatrix!==void 0&&(n=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??mi.identity)),r.pivot!==void 0||r.pivotRotation!==void 0){if(n=!0,r.pivot!==void 0&&r.pivotRotation!==void 0)this.pivotMatrix.compose(tl.fromArray(r.pivot).negate(),nf.setFromEuler(Ox.fromArray(r.pivotRotation.map(a=>a*dn.DEG2RAD))).invert(),Px);else if(r.pivot!==void 0)this.pivotMatrix.setPosition(-r.pivot[0],-r.pivot[1],-r.pivot[2]);else if(r.pivotRotation!==void 0){let a=tl.setFromMatrixPosition(this.pivotMatrix);nf.setFromEuler(Ox.fromArray(r.pivotRotation.map(s=>s*dn.DEG2RAD))).invert(),this.pivotMatrix.compose(a,nf,Px)}}return n&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(a=>{a.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),n}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)}),this.requestRender()}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)_e.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{_e.is(r)&&r.disposeRecursively()})}toState(r=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return oa(o,r)}updateByObjUpdateOp(r,o){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},o,!1)}updateByOp(r,o,n,a){let s=this.data;this.data=o;let l=r,c=Be(r.path,["states","*"]);if(c!==null){if(r.type===0){let[u]=c;if(this?.stateSelection===u){let d={...r.props};if(delete d.name,Object.values(r.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=Je.zoom(p,r.path.slice(2));if(f)for(let h in r.props)r.props[h]===void 0&&h in f&&(d[h]=f[h])}}l={...r,props:d,path:r.path.slice(2)}}}}else if(r.type===0){let u=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(u!==void 0){if(r.props.name!==void 0&&u.name){let{name:p,...f}=u;u=f}if(r.props.material!==void 0&&"material"in u){let{material:p,...f}=u;u=f}let d=Je.removeOverridden(r.path,r.props,u);l={...r,props:d}}}if(this.updateByPatchedOpBase(l,sn.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),n),Be(r.path,["overrides"])){let u=[],d=[...r.path];for(u.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)u.push(d[1]),d.splice(0,2);if(u[u.length-1]===void 0){if(r.type===0)for(let p of Object.keys(r.props)){u[u.length-1]=p;let f=n.scene.findInstance([this.uuid,...u]);f&&(f.overrideData=r.props[p],f.updateState(to.apply(f.component.data,f.overrideData),n))}}else{let p=n.scene.findInstance([this.uuid,...u]);if(p){let f=Je.zoom(p.component.data,d);if(r={...r,path:d},r.type===0){let h=r.props;if(f)for(let[m,y]of Object.entries(r.props))y===void 0&&(h===r.props&&(h={...r.props}),h[m]=f[m]);r={...r,props:h}}p.overrideData=xa.resolve(o.overrides,u),p.updateByOp(r,at.applySimple(p.data,r),n,!1)}}}else if(this.instances.length>0){let u;if(r.path.length===0&&r.type===0){let d;for(let p of lo.rootOverrideProps)p in r.props&&(d===void 0&&(d={}),d[p]=r.props[p]);d&&(u={...r,props:d})}else for(let d of lo.rootOverrideProps)if(Be(r.path,[d])){u=r;break}u!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=to.filterOp(d.overrideData,u);p&&d.updateByOp(p,at.applySimple(d.data,p),n,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=to.filterOp(d.overrideData,r);if(p){let f;s===d.data&&r===p?f=o:f=at.applySimple(d.data,p),d.updateByOp(p,f,n,!0)}}})}}updateByPatchedOpBase(r,o,n){if(this.dataPatched=o,r.path.length===0&&r.type===0)r.props.type!==void 0&&!Lr.is(r.props.type)&&Fr.changeEntityProptotype(this,o,n);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){Fr.changeEntityProptotype(this,o,n);for(let a of this.children)_e.is(a)&&a.updateVisible(n.scene)}this.updateByPatchedOp(r,o,n)}updateByPatchedOp(r,o,n){if(r.path.length===0&&r.type===0?this.updateState(r.props,n):r.type===0&&("resolutionLevel"in r.props||"useChildrenColors"in r.props)&&this.updateState(o,n),r.path[0]==="morphTargetInfluences"&&r.type===0){let s=o.morphTargetInfluences.get(r.path[1])?.data.name;s&&this.updateMorphInfluences(s,n.shared.getVariable(r.props.value,[this.uuid,"morphTargetInfluences",s]))}if(Be(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Be(r.path,["cloner"])!==null){let a=at.drop(r,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,n):this.cloner?this.cloner.updateState(o.cloner,n):(this.setFromClonerState(o.cloner,n),this.expandCloner(n)),this.updateVisible(n.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){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=r.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=bu(c.geometry.path),d=(n+a)%1;n+a===1&&d===0&&(d=1);let p=null;try{p=u.curves.length?u.getPointAt(d):null}catch(y){!1&&(console.warn(`The aligned path on ${this.name} is invalid. (${l.name})`),console.error(y))}if(p===null)return;let f=this.parent?this.parent?.matrixWorld:new vu;l.updateMatrixWorld();let h=new vu().multiplyMatrices(f.clone().invert(),l.matrixWorld);p.applyMatrix4(h);let m={position:p.toArray(),rotation:c.rotation};if(s==="tangential"){let y=new vu().extractRotation(l.matrixWorld),g=u.getTangentAt(d).applyMatrix4(y).add(p),b=new vu().lookAt(p,g,CI),w=tl.setFromEuler(new Tx().setFromRotationMatrix(b)).multiplyScalar(dn.RAD2DEG);m={...m,rotation:w.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(OI)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let o=!1;this.traverseEntity(n=>{if(n.data.type==="Splat")return o=!0,!0}),o&&r.reloadSplats()}updateState_Entity(r,o){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(o?.scene),this.resetBBoxNeedsUpdate()),o&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,o),this.updateVisible(o.scene)),this.updateTransformState(r,o)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof Fr.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,o){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Fr.Cloner(this,r),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,o))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};import{BufferGeometry as II,ConeGeometry as EI,Float32BufferAttribute as NI,MathUtils as DI}from"three";import{BufferGeometry as Ax,CylinderGeometry as AI,Float32BufferAttribute as wu,MathUtils as MI,Vector2 as Ur,Vector3 as Su}from"three";var Mx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.parameters?.radiusTop,r=i.parameters?.radiusBottom,o=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters);o.thetaLength=MI.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=r??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:t,depth:e,height:r,radialSegments:o,heightSegments:n,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:d,cornerSegments:p,hollow:f}=i.parameters,h;return l===0?(h=new Ax,h.setAttribute("position",new wu([],3))):d||f?h=new rl(c,u,r,o,n,a,s,l*Math.PI/180,d,d,p,f):h=new AI(c,u,r,o,n,a,s,l*Math.PI/180),h.scale(1,1,e/t),Object.assign(h,{userData:{...i,type:"CylinderGeometry"}})}};function Si(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function Cx(i){return new Ur(i.y,-i.x)}var rl=class extends Ax{constructor(t,e,r,o,n,a,s,l,c,u,d,p,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||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=[],g=[],b=0,w=r/2,P=new Su,S=new Su;f&&t==0&&(t=c),f&&e==0&&(e=u);let T=new Ur(t,w),A=new Ur(e,-w),x=null,N=null,E=null,M=null,D=T.clone().sub(A),_=0,R=0,V=0;p>0&&(_=Math.min(t,e)*(1-p),R=t-_,V=e-_);let U=T.clone();U.x-=_;let B=Math.PI-D.angle(),q=D.angle(),j=Math.tan(q/2),F=Math.tan(B/2),H=j+F,W=p?H:F,ee=p?H:j;if(c=Math.min(c,(t-R)/W,D.length()/H),u=Math.min(u,(e-V)/ee,D.length()/H),c>0){let Q=c/j;x=T.clone().sub(new Ur(Q,c)),p&&(E=x.clone(),E.x-=_-H*c),T.sub(D.clone().setLength(Q))}if(u>0){let Q=u/F;N=A.clone().sub(new Ur(Q,-u)),A.add(D.clone().setLength(Q)),p&&(M=N.clone(),M.x-=_-H*u,U.sub(D.clone().setLength(Q)))}D=T.clone().sub(A);let te=D.length()<.5,Y=[];for(let Q=0;Q<=o;Q++){let $=[],de=Q/o,le=de*l+s,ie=new Ur(Math.sin(le),Math.cos(le));M&&N?(re($,de,ie,B,u,M,-1,!0),re($,de,ie,q,u,N,-1,!1)):N?(K($,ie,N.x,0,-1),re($,de,ie,q,u,N,-1,!1)):a||K($,ie,e,V,-1);let ce=Cx(D).normalize();if(Si(ce,ie,P),!te)for(let ae=0;ae<=n;ae++){let me=ae/n,fe=D.clone().multiplyScalar(me).add(A);Si(fe,ie,S),m.push(S.x,S.y,S.z),y.push(P.x,P.y,P.z),g.push(de,.5+S.y/r),$.push(b++)}if(E&&x?(re($,de,ie,B,c,x,1,!1),re($,de,ie,q,c,E,1,!0)):x?(re($,de,ie,B,c,x,1,!1),K($,ie,x.x,0,1)):a||K($,ie,t,R,1),p&&!te){let ae=Cx(D).multiplyScalar(-1).normalize();Si(ae,ie,P);for(let me=0;me<=n;me++){let fe=me/n,he=D.clone().multiplyScalar(-fe).add(U);Si(he,ie,S),m.push(S.x,S.y,S.z),y.push(P.x,P.y,P.z),g.push(de,.5+S.y/r),$.push(b++)}}p&&!a&&$.push($[0]),Y.push($)}for(let Q=0;Q<Y.length-1;Q++)for(let $=0;$<Y[0].length-1;$++){if(a&&p&&$==n)continue;let de=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(de,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 wu(m,3)),this.setAttribute("normal",new wu(y,3)),this.setAttribute("uv",new wu(g,2));function re(Q,$,de,le,ie,ce,ae,me){for(let fe=0;fe<d+1;fe++){let he=fe/d,be=ae<0?he:1-he;me&&(be-=1),be*=le;let ye=new Ur(Math.sin(be),Math.cos(be)*ae),C=ye.clone().multiplyScalar(ie).add(ce);Si(C,de,S),m.push(S.x,S.y,S.z),Si(ye,de,P),y.push(P.x,P.y,P.z),g.push($,.5+S.y/r),Q.push(b++)}}function K(Q,$,de,le,ie){let ce=new Su,ae=new Ur,me=[de,le];ie<0&&me.reverse();for(let fe of me)ae.set(fe,w*ie),Si(ae,$,ce),m.push(ce.x,ce.y,ce.z),y.push(0,ie,0),g.push(.5,.5),Q.push(b++)}function Z(Q,$,de){let le=new Ur(Math.sin(de),Math.cos(de)),ie=new Ur(-Math.cos(de),Math.sin(de)),ce=new Su,ae=Q<0?(he,be,ye)=>h.push(he,be,ye):(he,be,ye)=>h.push(he,ye,be),me=new Ur((t+e+R+V)/4,0);Si(me,le,ce),m.push(ce.x,ce.y,ce.z),y.push(ie.x,0,ie.y),g.push(.5,.5);let fe=b++;for(let he of $){let be=m.slice(he*3,he*3+3);m.push(...be),y.push(ie.x,0,ie.y);let ye=g.slice(he*2,he*2+2);g.push(...ye),b++}for(let he=fe+1;he<b-1;he++)ae(fe,he,he+1);ae(fe,b-1,fe+1)}}};var Ix=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},i.parameters);return e.thetaLength=DI.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:t,depth:e,height:r,radialSegments:o,heightSegments:n,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:u,cornerSegments:d}=i.parameters,p;return l===0?(p=new II,p.setAttribute("position",new NI([],3))):c>0||u>0||l<360?p=new rl(0,t/2,r,o,n,a,s,l*Math.PI/180,c,u,d,0,!0):p=new EI(t/2,r,o,n,a),p.scale(1,1,e/t),Object.assign(p,{userData:{...i,type:"ConeGeometry"}})}};import{BoxGeometry as _I,BufferGeometry as RI,Float32BufferAttribute as sf,Vector3 as ol}from"three";var Ex=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.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:t,height:e,depth:r,widthSegments:o,heightSegments:n,depthSegments:a,cornerRadius:s,cornerSegments:l}=i.parameters,c;return s===0?c=new _I(t,e,r,o,n,a):c=new cf(t,e,r,o,n,a,s,l),Object.assign(c,{userData:{...i,type:"CubeGeometry"}})}},lf=Math.PI/2,cf=class extends RI{constructor(t=1,e=1,r=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,t/2,e/2,r/2);let c=[],u=[],d=[],p=[],f=0;h("z","y","x",-1,-1,r,e,t,a,n),h("z","y","x",1,-1,r,e,-t,a,n),h("x","z","y",1,1,t,r,e,o,a),h("x","z","y",1,-1,t,r,-e,o,a),h("x","y","z",1,-1,t,e,r,o,n),h("x","y","z",-1,-1,t,e,-r,o,n),s>0&&(m("z","y","x",-1,-1,1,r,e,t,a),m("z","y","x",1,-1,-1,r,e,t,a),m("z","y","x",-1,1,-1,r,e,t,a),m("z","y","x",1,1,1,r,e,t,a),m("x","y","z",-1,-1,-1,t,e,r,o),m("x","y","z",1,-1,1,t,e,r,o),m("x","y","z",-1,1,1,t,e,r,o),m("x","y","z",1,1,-1,t,e,r,o),m("y","x","z",-1,-1,1,e,t,r,n),m("y","x","z",1,-1,-1,e,t,r,n),m("y","x","z",1,1,1,e,t,r,n),m("y","x","z",-1,1,-1,e,t,r,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 sf(u,3)),this.setAttribute("normal",new sf(d,3)),this.setAttribute("uv",new sf(p,2));function h(g,b,w,P,S,T,A,x,N,E){let M=(T-2*s)/N,D=(A-2*s)/E,_=T/2-s,R=A/2-s,V=x/2,U=N+1,B=E+1,q=0,j=new ol;for(let F=0;F<B;F++){let H=F*D-R;for(let W=0;W<U;W++){let ee=W*M-_;j[g]=ee*P,j[b]=H*S,j[w]=V,u.push(j.x,j.y,j.z),j[g]=0,j[b]=0,j[w]=x>0?1:-1,d.push(j.x,j.y,j.z),p.push(W/N),p.push(1-F/E),q+=1}}for(let F=0;F<E;F++)for(let H=0;H<N;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(g,b,w,P,S,T,A,x,N,E){let M=(A-2*s)/E,D=A/2-s,_=x/2-s,R=N/2,V=E+1,U=0,B=new ol,q=new ol;for(let j=0;j<l+1;j++){let F=j/l*lf,H=Math.sin(F)*s,W=(1-Math.cos(F))*s,ee=Math.sin(F),te=Math.cos(F);B[b]=(_+H)*S,B[w]=(R-W)*T,q[g]=0,q[b]=ee*Math.sign(B[b]),q[w]=te*Math.sign(B[w]);for(let Y=0;Y<V;Y++){let re=Y*M-D;B[g]=re*P,u.push(B.x,B.y,B.z),d.push(q.x,q.y,q.z),p.push(Y/E),p.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(g,b,w){let P=new ol,S=new ol(t/2,e/2,r/2);S.subScalar(s);let T=[],A=g*b*w>0?(N,E,M)=>c.push(N,E,M):(N,E,M)=>c.push(N,M,E);for(let N=0;N<=l;N++){let E=[],M=lf*(1-N/l),D=Math.cos(M),_=Math.sin(M),R=0;for(let V=0;V<=N;V++){let U=Math.cos(R),B=Math.sin(R);P.x=D*U,P.y=_,P.z=D*B;let q=S.clone().addScaledVector(P,s);u.push(g*q.x,b*q.y,w*q.z),d.push(g*P.x,b*P.y,w*P.z),p.push(0,0),E.push(f++),R+=lf/N}T.push(E)}let x=T.length-1;for(let N=0;N<x;N++){let E=T[N],M=T[N+1],D=E.length-1;A(E[0],M[1],M[0]);for(let _=1;_<=D;_++)A(E[_-1],E[_],M[_]),A(E[_],M[_+1],M[_])}}}};import{BufferGeometry as LI,Float32BufferAttribute as uf,Triangle as BI,Vector3 as Uo,Vector2 as df}from"three";var wi=class extends LI{constructor(t=[],e=[],r="",o=1,n=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],c=[];u(),d(),this.setAttribute("position",new uf(s,3)),this.setAttribute("normal",new uf(c,3)),this.setAttribute("uv",new uf(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}[r],h=new Uo,m=h.clone(),y=new BI,g=n*o,b=o-g,w=a+1,P=new Uo,S=(j,F)=>P.subVectors(j,F).normalize(),T=(j,F)=>Array(j).fill(void 0).map(F),A=T(t.length/3,(j,F)=>new Uo().fromArray(t,F*3).setLength(o)),x=[],N=1e6;for(let j=0;j<A.length;j++){let F=A[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(A[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 de=x[W]?.includes(j)==!0;te<=Y&&K.push(W+ +de*N),Z=H.findIndex(le=>le[0]==ee)}x.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 M=h.clone(),D=h.clone(),_=h.clone(),R=h.clone(),V=h.clone(),U=[],B=T(A.length,()=>T(f,()=>h.clone()));for(let j=0;j<A.length;j++){h.copy(A[j]).normalize(),M.copy(h).multiplyScalar(b);let F=x[j];for(let K=0;K<F.length;K++){let Z=F[K],Q=F[(K+1)%f];y.setFromPointsAndIndices(A,j,Z%N,Q%N),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(M,B[j][K])}let H=[],W=[],ee=[],te=new Uo;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],de=B[j][K];h.copy($).sub(M),m.copy(de).sub(M);let le=M.angleTo(h),ie=h.angleTo(m),ce=Math.cos(le)*g;a==0?D.copy(te):D.copy(M).setLength(b+ce),W.push(ce);let ae=[D,$,de];for(let me=0;me<2;me++){let fe=ae[me],he=ae[me+1];R.subVectors(fe,M),V.subVectors(he,M),_.crossVectors(R,V).normalize();for(let be=0;be<w;be++){let ye=[le,ie][me]*be/w;h.copy(R).applyAxisAngle(_,ye).add(M),H.push(h.clone()),me&&(S(h,M),Z.push([be==0?fe:h.clone(),P.clone()]))}me&&(S(he,M),Z.push([he,P.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(M).setLength(W[K]).add(M),$.push(h.clone());$.push(V)}for(let le=0;le<w;le++)$.push(H[le+w+Z]);$.push(H[Q+w]);let de=E.map(le=>$[le]);s.push(...de.map(le=>[le.x,le.y,le.z]).flat()),c.push(...de.map(le=>(S(le,M),[P.x,P.y,P.z])).flat())}}let q=[];for(let j=0;j<x.length;j++)for(let F=0;F<f;F++){let H=x[j][F];if(H<N){let W=x[H].findIndex(Y=>Y%N==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];P.subVectors(ee[0],ee[1]).cross(h.subVectors(ee[0],ee[2])).normalize();let te=P.dot(ee[0])<0;te&&P.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(P.x,P.y,P.z)})}}function d(){let p=new Uo;for(let A=0;A<s.length;A+=3){p.x=s[A+0],p.y=s[A+1],p.z=s[A+2];let x=S(p)/2/Math.PI+.5,N=T(p)/Math.PI+.5;l.push(x,1-N)}let f=new Uo,h=new Uo,m=new Uo,y=new Uo,g=new df,b=new df,w=new df,P=(A,x,N,E)=>{E<0&&A.x===1&&(l[x]=A.x-1),N.x===0&&N.z===0&&(l[x]=E/2/Math.PI+.5)};for(let A=0,x=0;A<s.length;A+=9,x+=6){f.set(s[A+0],s[A+1],s[A+2]),h.set(s[A+3],s[A+4],s[A+5]),m.set(s[A+6],s[A+7],s[A+8]),g.set(l[x+0],l[x+1]),b.set(l[x+2],l[x+3]),w.set(l[x+4],l[x+5]),y.copy(f).add(h).add(m).divideScalar(3);let N=S(y);P(g,x+0,f,N),P(b,x+2,h,N),P(w,x+4,m,N)}for(let A=0;A<l.length;A+=6){let x=l[A+0],N=l[A+2],E=l[A+4],M=Math.max(x,N,E),D=Math.min(x,N,E);M>.9&&D<.1&&(x<.2&&(l[A+0]+=1),N<.2&&(l[A+2]+=1),E<.2&&(l[A+4]+=1))}function S(A){return Math.atan2(A.z,-A.x)}function T(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(t){return new wi(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};import{DodecahedronGeometry as VI}from"three";var Nx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.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:t,height:e,depth:r,detail:o,corner:n,cornerSides:a}=i.parameters,s=o===0&&n!==0?new il(t*.5,n,a):new VI(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...i,type:"DodecahedronGeometry"}})}},il=class extends wi{constructor(t=1,e=.2,r=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,t,e,r),this.type=l}static fromJSON(t){return new il(t.radius,t.corner,t.cornerSides)}};import{Plane as XI,Shape as qx,Vector2 as ko,Vector3 as YI,MathUtils as xf,LineCurve as bf,QuadraticBezierCurve as $x,CubicBezierCurve as Cu}from"three";import{CubicBezierCurve as Pu,EllipseCurve as zI,LineCurve as Ou,LineCurve3 as GI,MathUtils as FI,QuadraticBezierCurve as ff,SplineCurve as jI,Vector2 as $t,Vector3 as Rx}from"three";var nl=1e-12,Ma=class{constructor(t){this.position=new $t;this.startPosition=new $t;this.uuid=FI.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Ma(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Ia=class extends Ma{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Ia(this.parent).copy(this)}},kr=class extends Ma{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Ia(this),new Ia(this))}static create(e,r){let o=new kr(e,new $t(...r.position));return o.controls[0].position.set(...r.controlPrevious.position),o.controls[1].position.set(...r.controlNext.position),o.roundness=r.roundness,o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,o}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let o=0,n=this.controls.length;o<n;o++){let a=this.controls[o];this.position.distanceTo(a.position)<=r?a.position.copy(this.position):a.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new kr(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),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new $t,r=new $t){let[o,n]=this.computeTangents();return o&&n&&(Dx(o,e),Dx(n,r)),[e,r]}computeTangent(e=new $t){let[r,o]=this.computeTangents();return r&&o&&e.copy(r).add(o).normalize(),e}computeNormal(e=new $t){let[r,o]=this.computeNormals();return e.copy(r).add(o).normalize(),e}};function Dx(i,t=new $t){let e=i.length();return t.set(-i.y/e,i.x/e)}var hf=i=>i,Ea=new $t,Tu=new $t,UI=new $t,kI=new $t,HI=new $t,WI=new $t,Lx=new Rx,Bx=new Rx;function Vx(i){let t=new $t;t.addVectors(i.v0,Ea.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new $t;return e.addVectors(i.v2,Tu.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new Pu(i.v0,t,e,i.v2)}function al(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function qI(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function $I(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function mf(i,t,e){let r=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),o=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.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+r*r-n*n)/(2*o*r))}function zx(i,t,e){return _x(i,t)&&_x(t,e)&&pf(i.position,t.position,e.position)}function pf(i,t,e){return Ea.copy(t).sub(i).cross(Tu.copy(e).sub(i))===0}function Gx(i,t,e,r,o){let n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),a=(i.y+t.y)/2,s=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(n/2,2))*(i.y-t.y)/n,c=Math.sqrt(Math.pow(e,2)-Math.pow(n/2,2))*(t.x-i.x)/n;return r.set(s+l,a+c),o.set(s-l,a-c),[r,o]}function Fx(i,t,e){let r=i.distanceTo(e),o=t.distanceTo(e);return r<o?t:i}function jx(i,t,e,r,o,n){let a=t.x-i.x,s=t.y-i.y,l=e.x-i.x,c=e.y-i.y,u=Math.sqrt((a+l)*(a+l)+(s+c)*(s+c)),d;return mf(t,i,e)>Math.PI&&(u*=-1),al(c,s)?d=(s+c)*(r/u-.5)*8/3/(a-l):d=(a+l)*(r/u-.5)*8/3/(c-s),o.set(t.x-d*s,t.y+d*a),n.set(e.x+d*c,e.y-d*l),[o,n]}function yf(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function _x(i,t){return pf(i.position,i.controls[1].position,t.position)&&pf(i.position,t.controls[0].position,t.position)}function Ux(i,t,e,r,o=.5){let n=Ea.subVectors(t,i).multiplyScalar(o).add(i),a=Tu.subVectors(e,t).multiplyScalar(o).add(t),s=UI.subVectors(r,e).multiplyScalar(o).add(e),l=n,c=kI.subVectors(a,n).multiplyScalar(o).add(n),u=HI.subVectors(s,a).multiplyScalar(o).add(a),d=s,p=WI.subVectors(u,c).multiplyScalar(o).add(c);return[i.x,i.y,l.x,l.y,c.x,c.y,p.x,p.y,u.x,u.y,d.x,d.y,r.x,r.y]}function kx(i,t,e=12,r=!0){let o=Bx.set(0,0,0),n,a=0,s=[];for(let l=0;l<t.length;l++){let c=hf(t[l]),u=Ea,d=Pi(c,e);s.push(d);for(let p=0;p<=d;p++)if(c instanceof Pu||c instanceof ff||c instanceof Ou){if(c.getPoint(p/d,u),o.set(u.x,u.y,0),n!==void 0&&$I(n,o))continue;n===void 0&&(n=Lx),n.copy(o),i.setXYZ(a,o.x,o.y,o.z),a++}}return r&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),i}function Hx(i,t,e,r=12,o=!0){let n=Bx.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,u=hf(t[l]),d=Ea,p=Pi(u,r);s.push(p);for(let f=0;f<=p;f++)if(u instanceof Pu||u instanceof ff||u instanceof Ou){if(u.getPoint(f/p,d),n.set(d.x,d.y,0),c?.equals(n))continue;c===void 0?c=Lx:(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 gf(i,t=12,e=!1){let r=[];for(let o=0,n=i.length;o<n;o++){let a=i[o],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=Pi(a.roundedCurveCorner,t)*.5;o>0&&(r[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=Pi(a.curveAfter,t)),r.push(s)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=Pi(i[0].roundedCurveCorner,t)*.5),r}function Pi(i,t=12){return i&&i instanceof zI?t*2:i&&(i instanceof Ou||i instanceof GI)?1:i&&i instanceof jI?t*i.points.length:t}function Wx(i,t,e=12,r=!0){let o,n=0;for(let a=0;a<t.length;a++){let s=hf(t[a]),l=Pi(s,e),c=Ea;for(let u=0;u<=l;u++)if(s instanceof Pu||s instanceof ff||s instanceof Ou){if(s.getPoint(u/l,c),o!==void 0&&qI(o,c,nl))continue;o===void 0&&(o=Tu),o.copy(c),i.push(c.x,c.y),n++}}return al(i[0],i[i.length-2],nl)&&al(i[1],i[i.length-1],nl)&&(i.pop(),i.pop()),r&&n>1&&!(al(i[n-1],i[1],nl)&&al(i[n-2],i[0],nl))&&(i.push(i[0],i[1]),n++),i}var vf=new ko,KI=new ko,QI=new ko,ZI=new ko,JI=new ko,e3=new ko,Ue=class extends qx{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new XI(new YI(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=xf.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,o){let n=new Ue;return n.isClosed=e.isClosed,n.points=e.points.map(a=>kr.create(a.id,a.data)),typeof e.roundness=="number"&&(n.roundness=e.roundness),n.shapeHoles=e.shapeHoles.map(a=>Ue.createFromState(a)),r!==void 0&&o!==void 0&&n.applySize(r,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 r=0,o=this.points.length;r<o;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,o=this.points.findIndex(n=>n.uuid===e);if(o<0){let n=r;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 r=this.points.length;for(let o=0,n=this.shapeHoles.length;o<n;o++){let a=this.shapeHoles[o],s=e-r;if(s<=a.points.length-1)return a.points[s];r+=a.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let o=0,n=this.shapeHoles.length;o<n;o++){let a=this.shapeHoles[o],s=a.points.indexOf(e);if(s>=0)return r+s;r+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let o=vf.set(e,r);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,r);this._update()}createPoint(e,r=0,o=xf.generateUUID()){let n;e instanceof ko?n=e:n=new ko(e,r);let a=new kr(o,n);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,o=this.points.length;r<o;r++){let n=this.points[r];if(n.uuid===e)return n}for(let r=0,o=this.shapeHoles.length;r<o;r++){let a=this.shapeHoles[r].getPointByUuid(e);if(a)return a}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(o=>o.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,o=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let n=o?this.roundedCurveDivisions:this.curveDivisions;return kx(e,o?this.roundedCurves:this.curves,r,this.autoClose),n.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=gf(this.points,e,!1),this.roundedCurveDivisions=gf(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,o=12){return Hx(e,this.curves,r,o,this.autoClose).reduce((a,s)=>a+s,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),Wx(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let n=r?this.roundedCurveDivisions:this.curveDivisions,a=0;r&&this.points[0].roundedCurveCorner!==void 0&&(a=Pi(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,r,o){let n=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(yf(n,a)){let d=n.position.distanceTo(a.position);return n.position.distanceTo(vf.set(o.x,o.y))/d}let c=0;for(let d=0;d<e;d++)c+=s[d];return(r-c)/l}dispose(){}_applyCurveForPoint(e,r){yf(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let o=this.curves[this.curves.length-1];e.curveBefore=o,r.curveAfter=o;let n=o.clone();e.roundedCurveBefore=n,r.roundedCurveAfter=n,e.roundedCurveCorner=void 0,this.roundedCurves.push(n)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,o=this.points.length;r<o;r++){let n=this.points[r];if(r===0)this.moveTo(n.position.x,n.position.y);else{let a=this.points[r-1];this._applyCurveForPoint(n,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],o=this.points[this.points.length-1];this._applyCurveForPoint(r,o)}if(this.points.length>2){let r=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&&zx(s,a,l);if(!a.controlsMoved()&&c>0&&!u){let d=a.curveBefore,p=a.curveAfter;if(d===void 0||p===void 0)continue;let f=a.roundedCurveBefore,h=a.roundedCurveAfter,m=d.getLength(),y=p.getLength(),g=Math.min(c,m*.499),b=Math.min(c,y*.499),w=Math.min(g,b),P=1-w/m,S=w/y,T=d.getPointAt(P,vf),A=p.getPointAt(S,KI);this._subSplitCurve(d,f,P,T,void 0),this._subSplitCurve(p,h,S,void 0,A);let x;if(this.useCubicForRoundedCorners){let N=mf(T,a.position,A)/2,E=Math.tan(N)*T.distanceTo(a.position),[M,D]=Gx(T,A,E,QI,ZI),_=Fx(M,D,a.position),[R,V]=jx(_,T,A,E,JI,e3);x=new Cu(T.clone(),R.clone(),V.clone(),A.clone())}else x=new $x(T.clone(),a.position.clone(),A.clone());a.roundedCurveCorner=x,this.roundedCurves.splice(o+r,0,x),r++}}}}_subSplitCurve(e,r,o,n,a){if(e instanceof bf)n!==void 0&&r.v2.copy(n),a!==void 0&&r.v1.copy(a);else{let s=e,l=r,c=s.getUtoTmapping(o,0),u=Ux(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 r}clone(){let e=new Ue(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let o=0;o<r;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],d=e.points[n+5],p=e.points[n+6],f=new kr(xf.generateUUID(),new ko(a,s));f.controls[0].position.set(l,c),f.controls[1].position.set(u,d),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let n=new Ue;return n.fromJSON(o),n}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let o=(a,s)=>{s instanceof Cu&&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]=Vx(a[l]));for(l=0,c=a.length;l<c;l++){let p=a[l],f=l>0?a[l-1]:null,h;p instanceof Cu?(h=this.createPoint(p.v0),h.controls[1].position.copy(p.v1)):p instanceof bf&&(h=this.createPoint(p.v1)),h!==void 0&&(f!==null&&o(h,f),s.push(h))}let u=a[a.length-1],d=!1;return u instanceof Cu?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),d=!0):u instanceof bf&&u.v2.equals(s[0].position)&&(d=!0),this.isClosed=d,s};return this.points=n(e.curves),e instanceof qx&&(this.shapeHoles=e.holes.map(a=>{let s=new Ue;return s.fromShape(a),s})),this.update(),this}updatePoint(e,r){let o=this.getPointByUuid(e);o&&(r.position!==void 0&&o.position.fromArray(r.position),r.roundness!==void 0&&(o.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let n=this.getPointByUuid(e)?.controls[0];n&&(r.position&&n.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let n=this.getPointByUuid(e)?.controls[1];n&&(r.position&&n.position.fromArray(r.position),this.needsUpdate=!0)}};var wf=Math.PI*2;function Sf({x:i,y:t},e,r,o,n){return{x:i*e+o,y:t*r+n}}function t3(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(i),o=Math.sin(i),n=Math.cos(i+t),a=Math.sin(i+t);return[{x:r-o*e,y:o+r*e},{x:n+a*e,y:a-n*e},{x:n,y:a}]}function Xx(i,t,e,r){let o=i*r-t*e<0?-1:1,n=Math.min(1,Math.max(-1,i*e+t*r));return o*Math.acos(n)}function r3(i,t,e,r,o,n,a,s,l,c){let u=Math.pow(o,2),d=Math.pow(n,2),p=Math.pow(a,2),f=Math.pow(s,2),h=u*d-u*f-d*p;h<0&&(h=0),h/=u*f+d*p,h=Math.sqrt(h)*(l===c?-1:1);let m=h*o/n*s,y=h*-n/o*a,g=m+(i+e)/2,b=y+(t+r)/2,w=(a-m)/o,P=(s-y)/n,S=(-a-m)/o,T=(-s-y)/n,A=Xx(1,0,w,P),x=Xx(w,P,S,T);return!c&&x>0&&(x-=wf),c&&x<0&&(x+=wf),{centerx:g,centery:b,ang1:A,ang2:x}}function Yx({px:i,py:t,cx:e,cy:r,rx:o,ry:n,largeArcFlag:a,sweepFlag:s}){let l=[];if(o===0||n===0)return[];let c=(i-e)/2,u=(t-r)/2;if(c===0&&u===0)return[];o=Math.abs(o),n=Math.abs(n);let d=Math.pow(c,2)/Math.pow(o,2)+Math.pow(u,2)/Math.pow(n,2);d>1&&(o*=Math.sqrt(d),n*=Math.sqrt(d));let p=r3(i,t,e,r,o,n,c,u,a,s),{ang1:f,ang2:h}=p,{centerx:m,centery:y}=p,g=Math.abs(h)/(wf/4);Math.abs(1-g)<1e-7&&(g=1);let b=Math.max(Math.ceil(g),1);h/=b;for(let w=0;w<b;w++)l.push(t3(f,h)),f+=h;return l.map(w=>{let{x:P,y:S}=Sf(w[0],o,n,m,y),{x:T,y:A}=Sf(w[1],o,n,m,y),{x,y:N}=Sf(w[2],o,n,m,y);return{x1:P,y1:S,x2:T,y2:A,x,y:N}})}import{BufferAttribute as Nu,BufferGeometry as f3}from"three";var je;(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"})(je||(je={}));var ct;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(ct||(ct={}));function Pe(i,t){if(!i)throw t||"Assertion Failed!"}var ve=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,r){Pe(i.vertLeq(t,e)&&i.vertLeq(e,r));var o=e.s-t.s,n=r.s-e.s;return o+n>0?o<n?e.t-t.t+(t.t-r.t)*(o/(o+n)):e.t-r.t+(r.t-t.t)*(n/(o+n)):0},i.edgeSign=function(t,e,r){Pe(i.vertLeq(t,e)&&i.vertLeq(e,r));var o=e.s-t.s,n=r.s-e.s;return o+n>0?(e.t-r.t)*o+(e.t-t.t)*n:0},i.transEval=function(t,e,r){Pe(i.transLeq(t,e)&&i.transLeq(e,r));var o=e.t-t.t,n=r.t-e.t;return o+n>0?o<n?e.s-t.s+(t.s-r.s)*(o/(o+n)):e.s-r.s+(r.s-t.s)*(n/(o+n)):0},i.transSign=function(t,e,r){Pe(i.transLeq(t,e)&&i.transLeq(e,r));var o=e.t-t.t,n=r.t-e.t;return o+n>0?(e.s-r.s)*o+(e.s-t.s)*n:0},i.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},i.interpolate=function(t,e,r,o){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+o)/2:e+(o-e)*(t/(t+r)):o+(e-o)*(r/(t+r))},i.intersect=function(t,e,r,o,n){var a,s,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(r,o)||(l=r,r=o,o=l),i.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),i.vertLeq(r,e)?i.vertLeq(e,o)?(a=i.edgeEval(t,r,e),s=i.edgeEval(r,e,o),a+s<0&&(a=-a,s=-s),n.s=i.interpolate(a,r.s,s,e.s)):(a=i.edgeSign(t,r,e),s=-i.edgeSign(t,o,e),a+s<0&&(a=-a,s=-s),n.s=i.interpolate(a,r.s,s,o.s)):n.s=(r.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(r,o)||(l=r,r=o,o=l),i.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),i.transLeq(r,e)?i.transLeq(e,o)?(a=i.transEval(t,r,e),s=i.transEval(r,e,o),a+s<0&&(a=-a,s=-s),n.t=i.interpolate(a,r.t,s,e.t)):(a=i.transSign(t,r,e),s=-i.transSign(t,o,e),a+s<0&&(a=-a,s=-s),n.t=i.interpolate(a,r.t,s,o.t)):n.t=(r.t+e.t)/2},i}(),sl=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}(),Au=function(){function i(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),Na=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}(),Kx=function(){function i(){var t=new Na,e=new sl,r=new Au(0),o=new Au(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=o,o.next=o,o.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=o}return i.prototype.makeEdge_=function(t){var e=new Au(0),r=new Au(1);t.Sym.side<t.side&&(t=t.Sym);var o=t.Sym.next;return r.next=o,o.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},i.prototype.splice_=function(t,e){var r=t.Onext,o=e.Onext;r.Sym.Lnext=e,o.Sym.Lnext=t,t.Onext=o,e.Onext=r},i.prototype.makeVertex_=function(t,e,r){var o=t;Pe(o,"Vertex can't be null!");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=e;var a=e;do a.Org=o,a=a.Onext;while(a!==e)},i.prototype.makeFace_=function(t,e,r){var o=t;Pe(o,"Face can't be null");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=r.inside;var a=e;do a.Lface=o,a=a.Lnext;while(a!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},i.prototype.killVertex_=function(t,e){var r=t.anEdge,o=r;do o.Org=e,o=o.Onext;while(o!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},i.prototype.killFace_=function(t,e){var r=t.anEdge,o=r;do o.Lface=e,o=o.Lnext;while(o!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},i.prototype.makeEdge=function(){var t=new Na,e=new Na,r=new sl,o=this.makeEdge_(this.eHead);return this.makeVertex_(t,o,this.vHead),this.makeVertex_(e,o.Sym,this.vHead),this.makeFace_(r,o,this.fHead),o},i.prototype.splice=function(t,e){var r=!1,o=!1;if(t!==e){if(e.Org!==t.Org&&(o=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!o){var n=new Na;this.makeVertex_(n,e,t.Org),t.Org.anEdge=t}if(!r){var a=new sl;this.makeFace_(a,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var o=new sl;this.makeFace_(o,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var o=new Na;return this.makeVertex_(o,r,e.Org),e.Lface=r.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},i.prototype.connect=function(t,e){var r=!1,o=this.makeEdge_(t),n=o.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(o,t.Lnext),this.splice_(n,e),o.Org=t.Dst,n.Org=e.Org,o.Lface=n.Lface=t.Lface,t.Lface.anEdge=n,!r){var a=new sl;this.makeFace_(a,o,t.Lface)}return o},i.prototype.zapFace=function(t){var e=t.anEdge,r,o,n,a,s;o=e.Lnext;do r=o,o=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),n=r.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=e);a=t.prev,s=t.next,s.prev=a,a.next=s},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},i.prototype.mergeConvexFaces=function(t){var e,r,o,n,a,s,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,a=r.Org;o=r.Lnext,n=r.Sym,n&&n.Lface&&n.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(n.Lface),s+l-2<=t&&ve.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&ve.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(o=n.Lnext,this.delete(n),r=null,n=null)),!(r&&r.Lnext.Org===a);)r=o;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,o,n,a,s,l,c;for(n=t,n=t;(o=n.next)!==t;n=o){Pe(o.prev===n),l=o.anEdge;do Pe(l.Sym!==l),Pe(l.Sym.Sym===l),Pe(l.Lnext.Onext.Sym===l),Pe(l.Onext.Sym.Lnext===l),Pe(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(Pe(o.prev===n&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){Pe(a.prev===s),l=a.anEdge;do Pe(l.Sym!==l),Pe(l.Sym.Sym===l),Pe(l.Lnext.Onext.Sym===l),Pe(l.Onext.Sym.Lnext===l),Pe(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(Pe(a.prev===s&&a.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)Pe(l.Sym.next===c.Sym),Pe(l.Sym!==l),Pe(l.Sym.Sym===l),Pe(l.Org!==null),Pe(l.Dst!==null),Pe(l.Lnext.Onext.Sym===l),Pe(l.Onext.Sym.Lnext===l);Pe(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),Qx=function(){function i(){this.handle=null}return i}(),Zx=function(){function i(){this.key=null,this.node=0}return i}(),o3=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new Qx,this.handles[r]=new Zx;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,o,n,a;for(o=e[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[e[a+1].handle].key,r[e[a].handle].key)&&++a,Pe(a<=this.max),n=e[a].handle,a>this.size||this.leq(r[o].key,r[n].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=n,r[n].node=t,t=a}},i.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,o,n,a;for(o=e[t].handle;;){if(a=t>>1,n=e[a].handle,a===0||this.leq(r[n].key,r[o].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=n,r[n].node=t,t=a}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var o,n;for(n=this.nodes.length,this.nodes.length=this.max+1,o=n;o<this.nodes.length;o++)this.nodes[o]=new Qx;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?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,o=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),o},i.prototype.delete=function(t){var e=this.nodes,r=this.handles,o;Pe(t>=1&&t<=this.max&&r[t].key!==null),o=r[t].node,e[o].handle=e[this.size].handle,r[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(r[e[o>>1].handle].key,r[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},i}(),Pf=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}(),Jx=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),i3=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new Jx,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new Jx;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),n3=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,r){var o=t.event,n=e.eUp,a=r.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(t,e){e.fixUpperEdge&&Pe(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){Pe(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},i.topLeftRegion=function(t,e){var r=e.eUp.Org,o;do e=i.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(o=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;i.fixUpperEdge(t,e,o),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,r){var o=new Pf;return o.eUp=r,o.nodeUp=t.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,r.activeRegion=o,o},i.isWindingInside=function(t,e){switch(t.windingRule){case je.ODD:return(e&1)!==0;case je.NONZERO:return e!==0;case je.POSITIVE:return e>0;case je.NEGATIVE:return e<0;case je.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var r=e.eUp,o=r.Lface;o.inside=e.inside,o.anEdge=r,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,r){for(var o,n=null,a=e,s=e.eUp;a!==r;){if(a.fixUpperEdge=!1,n=i.regionBelow(a),o=n.eUp,o.Org!=s.Org){if(!n.fixUpperEdge){i.finishRegion(t,a);break}o=t.mesh.connect(s.Lprev,o.Sym),i.fixUpperEdge(t,n,o)}s.Onext!==o&&(t.mesh.splice(o.Oprev,o),t.mesh.splice(s,o)),i.finishRegion(t,a),s=n.eUp,a=n}return s},i.addRightEdges=function(t,e,r,o,n,a){var s,l,c,u,d=!0;c=r;do Pe(ve.vertLeq(c.Org,c.Dst)),i.addRegionBelow(t,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&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(u.Oprev,c)),s.windingNumber=l.windingNumber-c.winding,s.inside=i.isWindingInside(t,s.windingNumber),l.dirty=!0,!d&&i.checkForRightSplice(t,l)&&(i.addWinding(c,u),i.deleteRegion(t,l),t.mesh.delete(u)),d=!1,l=s,u=c;l.dirty=!0,Pe(l.windingNumber-c.winding===s.windingNumber),a&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},i.vertexWeights=function(t,e,r){var o=ve.vertL1dist(e,t),n=ve.vertL1dist(r,t),a=.5*n/(o+n),s=.5*o/(o+n);t.coords[0]+=a*e.coords[0]+s*r.coords[0],t.coords[1]+=a*e.coords[1]+s*r.coords[1],t.coords[2]+=a*e.coords[2]+s*r.coords[2]},i.getIntersectData=function(t,e,r,o,n,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,r,o),i.vertexWeights(e,n,a)},i.checkForRightSplice=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.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&&(t.pq.delete(o.Org.pqHandle),i.spliceMergeVertices(t,n.Oprev,o)):(t.mesh.splitEdge(n.Sym),t.mesh.splice(o,n.Oprev),e.dirty=r.dirty=!0)}else{if(ve.edgeSign(o.Dst,n.Org,o.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Oprev,o)}return!0},i.checkForLeftSplice=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.eUp,a;if(Pe(!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=t.mesh.splitEdge(o),t.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=r.dirty=!0,a=t.mesh.splitEdge(n),t.mesh.splice(o.Lnext,n.Sym),a.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.eUp,a=o.Org,s=n.Org,l=o.Dst,c=n.Dst,u,d,p=new Na,f,h;if(Pe(!ve.vertEq(c,l)),Pe(ve.edgeSign(l,t.event,a)<=0),Pe(ve.edgeSign(c,t.event,s)>=0),Pe(a!==t.event&&s!==t.event),Pe(!e.fixUpperEdge&&!r.fixUpperEdge),a===s||(u=Math.min(a.t,l.t),d=Math.max(s.t,c.t),u>d))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(t),ve.intersect(l,a,c,s,p),Pe(Math.min(a.t,l.t)<=p.t),Pe(p.t<=Math.max(s.t,c.t)),Pe(Math.min(c.s,l.s)<=p.s),Pe(p.s<=Math.max(s.s,a.s)),ve.vertLeq(p,t.event)&&(p.s=t.event.s,p.t=t.event.t),f=ve.vertLeq(a,s)?a:s,ve.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),ve.vertEq(p,a)||ve.vertEq(p,s)?(i.checkForRightSplice(t,e),!1):!ve.vertEq(l,t.event)&&ve.edgeSign(l,t.event,p)>=0||!ve.vertEq(c,t.event)&&ve.edgeSign(c,t.event,p)<=0?c===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Sym,o),e=i.topLeftRegion(t,e),o=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),r),i.addRightEdges(t,e,o.Oprev,o,o,!0),!0):l===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(o.Lnext,n.Oprev),r=e,e=i.topRightRegion(e),h=i.regionBelow(e).eUp.Rprev,r.eUp=n.Oprev,n=i.finishLeftRegions(t,r,null),i.addRightEdges(t,e,n.Onext,o.Rprev,h,!0),!0):(ve.edgeSign(l,t.event,p)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),ve.edgeSign(c,t.event,p)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),!1):(t.mesh.splitEdge(o.Sym),t.mesh.splitEdge(n.Sym),t.mesh.splice(n.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=t.pq.insert(o.Org),i.getIntersectData(t,o.Org,a,l,s,c),i.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var r=i.regionBelow(e),o,n;;){for(;r.dirty;)e=r,r=i.regionBelow(r);if(!e.dirty&&(r=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,n=r.eUp,o.Dst!==n.Dst&&i.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(i.deleteRegion(t,r),t.mesh.delete(n),r=i.regionBelow(e),n=r.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(o),e=i.regionAbove(r),o=e.eUp)),o.Org!==n.Org)if(o.Dst!==n.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(o.Dst===t.event||n.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);o.Org===n.Org&&o.Dst===n.Dst&&(i.addWinding(n,o),i.deleteRegion(t,e),t.mesh.delete(o),e=i.regionAbove(r))}},i.connectRightVertex=function(t,e,r){var o,n=r.Onext,a=i.regionBelow(e),s=e.eUp,l=a.eUp,c=!1;if(s.Dst!==l.Dst&&i.checkForIntersect(t,e),ve.vertEq(s.Org,t.event)&&(t.mesh.splice(n.Oprev,s),e=i.topLeftRegion(t,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),a),c=!0),ve.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(t,a,null),c=!0),c){i.addRightEdges(t,e,r.Onext,n,n,!0);return}ve.vertLeq(l.Org,s.Org)?o=l.Oprev:o=s,o=t.mesh.connect(r.Lprev,o),i.addRightEdges(t,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,r){var o,n,a,s,l;if(o=e.eUp,ve.vertEq(o.Org,r)){Pe(!1),i.spliceMergeVertices(t,o,r.anEdge);return}if(!ve.vertEq(o.Dst,r)){t.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(t.mesh.delete(o.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,o),i.sweepEvent(t,r);return}Pe(!1),e=i.topRightRegion(e),l=i.regionBelow(e),a=l.eUp.Sym,n=s=a.Onext,l.fixUpperEdge&&(Pe(n!==a),i.deleteRegion(t,l),t.mesh.delete(a),a=n.Oprev),t.mesh.splice(r.anEdge,a),ve.edgeGoesLeft(n)||(n=null),i.addRightEdges(t,e,a.Onext,s,n,!0)},i.connectLeftVertex=function(t,e){var r,o,n,a,s,l,c=new Pf;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,o=i.regionBelow(r),!!o){if(a=r.eUp,s=o.eUp,ve.edgeSign(a.Dst,e,a.Org)===0){i.connectLeftDegenerate(t,r,e);return}if(n=ve.vertLeq(s.Dst,a.Dst)?r:o,r.inside||n.fixUpperEdge){if(n===r)l=t.mesh.connect(e.anEdge.Sym,a.Lnext);else{var u=t.mesh.connect(s.Dnext,e.anEdge);l=u.Sym}n.fixUpperEdge?i.fixUpperEdge(t,n,l):i.computeWinding(t,i.addRegionBelow(t,r,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){i.connectLeftVertex(t,e);return}var o=i.topLeftRegion(t,r.activeRegion);Pe(o!==null);var n=i.regionBelow(o),a=n.eUp,s=i.finishLeftRegions(t,n,null);s.Onext===a?i.connectRightVertex(t,o,s):i.addRightEdges(t,o,s.Onext,a,a,!0)},i.addSentinel=function(t,e,r,o){var n=new Pf,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=o,a.Dst.s=e,a.Dst.t=o,t.event=a.Dst,n.eUp=a,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=t.dict.insert(n)},i.initEdgeDict=function(t){t.dict=new i3(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],o=t.bmin[0]-e,n=t.bmax[0]+e,a=t.bmin[1]-r,s=t.bmax[1]+r;i.addSentinel(t,o,n,a),i.addSentinel(t,o,n,s)},i.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(Pe(e.fixUpperEdge),Pe(++r===1)),Pe(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,r,o,n=t.mesh.eHead;for(e=n.next;e!==n;e=r)r=e.next,o=e.Lnext,ve.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,o,e),t.mesh.delete(e),e=o,o=e.Lnext),o.Lnext===e&&(o!==e&&((o===r||o===r.Sym)&&(r=r.next),t.mesh.delete(o)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,r,o,n=0;for(o=t.mesh.vHead,r=o.next;r!==o;r=r.next)n++;for(n+=8,e=t.pq=new o3(n,ve.vertLeq),o=t.mesh.vHead,r=o.next;r!==o;r=r.next)r.pqHandle=e.insert(r);return r!==o?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var r,o,n;for(r=e.fHead.next;r!==e.fHead;r=o)o=r.next,n=r.anEdge,Pe(n.Lnext!==n),n.Lnext.Lnext===n&&(i.addWinding(n.Onext,n),t.mesh.delete(n));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var r,o;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;o=t.pq.min(),!(o===null||!ve.vertEq(o,r));)o=t.pq.extractMin(),i.spliceMergeVertices(t,r.anEdge,o.anEdge);i.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),a3=function(){function i(){this.mesh=new Kx,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=je.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,r,o,n,a,s,l=[0,0,0],c=[0,0,0],u=[0,0,0],d=[0,0,0],p=[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 g=0;g<3;++g)n=e.coords[g],n<c[g]&&(c[g]=n,h[g]=e),n>l[g]&&(l[g]=n,f[g]=e);var b=0;if(l[1]-c[1]>l[0]-c[0]&&(b=1),l[2]-c[2]>l[b]-c[b]&&(b=2),c[b]>=l[b]){t[0]=0,t[1]=0,t[2]=1;return}for(s=0,r=h[b],o=f[b],u[0]=r.coords[0]-o.coords[0],u[1]=r.coords[1]-o.coords[1],u[2]=r.coords[2]-o.coords[2],e=m.next;e!==m;e=e.next)d[0]=e.coords[0]-o.coords[0],d[1]=e.coords[1]-o.coords[1],d[2]=e.coords[2]-o.coords[2],p[0]=u[1]*d[2]-u[2]*d[1],p[1]=u[2]*d[0]-u[0]*d[2],p[2]=u[0]*d[1]-u[1]*d[0],a=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],a>s&&(s=a,t[0]=p[0],t[1]=p[1],t[2]=p[2]);s<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(u)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,o,n=0,a=t.next;a!==t;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=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,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),r=this.sUnit,o=this.tUnit;var a=this.longAxis_(e);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,o[a]=0,o[(a+1)%3]=0,o[(a+2)%3]=e[a]>0?1:-1;for(var s=t.next;s!==t;s=s.next)s.s=this.dot_(s.coords,r),s.t=this.dot_(s.coords,o);n&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var r,o;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;ve.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ve.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var n=void 0;r.Lnext!==o;)if(ve.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(ve.edgeGoesLeft(o.Lnext)||ve.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)n=t.connect(o.Lnext,o),o=n.Sym;o=o.Lprev}else{for(;o.Lnext!==r&&(ve.edgeGoesRight(r.Lprev)||ve.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)n=t.connect(r,r.Lprev),r=n.Sym;r=r.Lnext}if(o.Lnext===r)throw"Mono region invalid";for(;o.Lnext.Lnext!==r;)n=t.connect(o.Lnext,o),o=n.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},i.prototype.setWindingNumber_=function(t,e,r){for(var o,n=t.eHead.next;n!==t.eHead;n=o)o=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?e:-e:r?t.delete(n):n.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,r,o){var n,a=0,s=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var u=t.fHead.next;u!==t.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>r)throw"Face vertex greater that support polygon";u.n=a,++a}this.elementCount=a,e===ct.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=s,this.vertices=[],this.vertices.length=s*o,this.vertexIndices=[],this.vertexIndices.length=s;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var d=c.n*o;this.vertices[d+0]=c.coords[0],this.vertices[d+1]=c.coords[1],o>2&&(this.vertices[d+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var p=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(!!u.inside){n=u.anEdge,l=0;do{var c=n.Org;this.elements[p++]=c.n,l++,n=n.Lnext}while(n!==u.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1;if(e===ct.CONNECTED_POLYGONS){n=u.anEdge;do this.elements[p++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==u.anEdge);for(var h=l;h<r;++h)this.elements[p++]=-1}}},i.prototype.outputContours_=function(t,e){var r,o,n=0,a=0;this.vertexCount=0,this.elementCount=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){o=r=s.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==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=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){a=0,o=r=s.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==o);this.elements[u++]=n,this.elements[u++]=a,n+=a}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new Kx),t<2&&(t=2),t>3&&(t=3);for(var r=null,o=0;o<e.length;o+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[o+0],r.Org.coords[1]=e[o+1],t>2?r.Org.coords[2]=e[o+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(t,e,r,o,n,a){if(t===void 0&&(t=je.ODD),e===void 0&&(e=ct.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=t,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),n3.computeInterior(this,a);var s=this.mesh;return e===ct.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===ct.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,r,o),!0},i}();function Hr(i){var t=i.windingRule,e=t===void 0?je.ODD:t,r=i.elementType,o=r===void 0?ct.POLYGONS:r,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,d=i.contours,p=d===void 0?[]:d,f=i.strict,h=f===void 0?!0:f,m=i.debug,y=m===void 0?!1:m;if(!p&&h)throw new Error("Contours can't be empty");if(!!p){var g=new a3;i.edgeCreateCallback&&(g.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(g.vertexIdCallback=i.vertexIdCallback);for(var b=0;b<p.length;b++)g.addContour(l||2,p[b]);return g.tesselate(e,o,a,l,u,h),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var Nq=je.ODD,Dq=je.NONZERO,_q=je.POSITIVE,Rq=je.NEGATIVE,Lq=je.ABS_GEQ_TWO,Bq=ct.POLYGONS,Vq=ct.CONNECTED_POLYGONS,zq=ct.BOUNDARY_CONTOURS;import{Box2 as u3,BufferAttribute as Eu,BufferGeometry as d3,Vector2 as p3}from"three";var Mu=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*Mu.eSize;this.buffer=new ArrayBuffer(r);let o=Float32Array.BYTES_PER_ELEMENT,n=0;this.positions=new Float32Array(this.buffer,n*o,3*t),n+=3*t,this.normals=new Float32Array(this.buffer,n*o,3*t),n+=3*t,this.uvs=new Float32Array(this.buffer,n*o,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*Mu.eSize,o=new ArrayBuffer(r),n=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*n,3*t);a+=3*t;let l=new Float32Array(o,a*n,3*t);a+=3*t;let c=new Float32Array(o,a*n,2*t);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=t}get(t=1){let e=this.size+t;if(e>this.capacity){let o=this.capacity;for(;e>o;)o*=2;this.realloc(o)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},ll=Mu;ll.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var cl=class{constructor(t=[],e=(r,o)=>r<o?-1:r>o?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:e,compare:r}=this,o=e[t];for(;t>0;){let n=t-1>>1,a=e[n];if(r(o,a)>=0)break;e[t]=a,t=n}e[t]=o}_down(t){let{data:e,compare:r}=this,o=this.length>>1,n=e[t];for(;t<o;){let a=(t<<1)+1,s=a+1;if(s<this.length&&r(e[s],e[a])<0&&(a=s),r(e[a],n)>=0)break;e[t]=e[a],t=a}e[t]=n}};function Of(i,t,e=1,r=!1){let o=1/0,n=1/0,a=-1/0,s=-1/0;for(let[b,w]of i[0])b<o&&(o=b),w<n&&(n=w),b>a&&(a=b),w>s&&(s=w);let l=a-o,c=s-n,u=Math.max(e,Math.min(l,c));if(u===e){let b=[o,n];return b.distance=0,b.distance}let d=new cl([],(b,w)=>w.max-b.max),p=l3(i),f=new Iu(o+l/2,n+c/2,0,i);f.d>p.d&&(p=f);let h=2;function m(b,w,P){let S=new Iu(b,w,P,i);if(h++,S.max>p.d+e&&d.push(S),S.d>p.d&&(p=S,r&&console.log(`found best ${Math.round(1e4*S.d)/1e4} after ${h} probes`),p.d>t))return t}let y=u/2;for(let b=o;b<a;b+=u)for(let w=n;w<s;w+=u)m(b+y,w+y,y);for(;d.length;){let{max:b,x:w,y:P,h:S}=d.pop();if(b-p.d<=e)break;y=S/2,m(w-y,P-y,y),m(w+y,P-y,y),m(w-y,P+y,y),m(w+y,P+y,y)}r&&console.log(`num probes: ${h}
|
|
2
|
+
`,"\r"],!1,!1),C=0,ne=0,De=[{line:1,column:1}],ze=0,Re=[],Oe=0,Ot;if("startRule"in t){if(!(t.startRule in r))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');o=r[t.startRule]}function Ie(){return i.substring(ne,C)}function wt(){return Xi(ne,C)}function Tt(v,O){throw O=O!==void 0?O:Xi(ne,C),xr([Qd(v)],i.substring(ne,C),O)}function $i(v,O){throw O=O!==void 0?O:Xi(ne,C),Zd(v,O)}function nt(v,O){return{type:"literal",text:v,ignoreCase:O}}function Qe(v,O,L){return{type:"class",parts:v,inverted:O,ignoreCase:L}}function _r(){return{type:"any"}}function Kd(){return{type:"end"}}function Qd(v){return{type:"other",description:v}}function $l(v){var O=De[v],L;if(O)return O;for(L=v-1;!De[L];)L--;for(O=De[L],O={line:O.line,column:O.column};L<v;)i.charCodeAt(L)===10?(O.line++,O.column=1):O.column++,L++;return De[v]=O,O}function Xi(v,O){var L=$l(v),I=$l(O);return{start:{offset:v,line:L.line,column:L.column},end:{offset:O,line:I.line,column:I.column}}}function pt(v){C<ze||(C>ze&&(ze=C,Re=[]),Re.push(v))}function Zd(v,O){return new In(v,null,null,O)}function xr(v,O,L){return new In(In.buildMessage(v,O),v,O,L)}function Rs(){var v,O,L,I,z;for(v=C,O=[],L=Ge();L!==e;)O.push(L),L=Ge();if(O!==e)if(L=qt(),L===e&&(L=null),L!==e){for(I=[],z=Ge();z!==e;)I.push(z),z=Ge();I!==e?(ne=v,O=n(L),v=O):(C=v,v=e)}else C=v,v=e;else C=v,v=e;return v}function qt(){var v,O,L,I,z,oe;if(v=C,O=Yi(),O!==e){for(L=[],I=C,z=[],oe=Ge();oe!==e;)z.push(oe),oe=Ge();for(z!==e?(oe=Yi(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;){for(L.push(I),I=C,z=[],oe=Ge();oe!==e;)z.push(oe),oe=Ge();z!==e?(oe=Yi(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e)}L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function Yi(){var v,O,L,I,z,oe;if(v=C,O=_n(),O!==e){for(L=[],I=C,z=[],oe=Ge();oe!==e;)z.push(oe),oe=Ge();for(z!==e?(oe=Xl(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;){for(L.push(I),I=C,z=[],oe=Ge();oe!==e;)z.push(oe),oe=Ge();z!==e?(oe=Xl(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e)}L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function Xl(){var v;return v=ow(),v===e&&(v=iw(),v===e&&(v=nw(),v===e&&(v=aw(),v===e&&(v=sw(),v===e&&(v=cw(),v===e&&(v=dw(),v===e&&(v=fw(),v===e&&(v=mw())))))))),v}function _n(){var v,O,L,I,z,oe,Bn;if(v=C,s.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(l)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=Xt(),I!==e?(z=C,oe=rt(),oe===e&&(oe=null),oe!==e?(Bn=bm(),Bn!==e?(oe=[oe,Bn],z=oe):(C=z,z=e)):(C=z,z=e),z===e&&(z=null),z!==e?(ne=v,O=c(O,I,z),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function ow(){var v,O;return v=C,u.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(d)),O!==e&&(ne=v,O=p()),v=O,v}function iw(){var v,O,L,I;if(v=C,f.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(h)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=bm(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function bm(){var v,O,L,I,z,oe;if(v=C,O=Xt(),O!==e){for(L=[],I=C,z=rt(),z===e&&(z=null),z!==e?(oe=Xt(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=rt(),z===e&&(z=null),z!==e?(oe=Xt(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function nw(){var v,O,L,I;if(v=C,y.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(g)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=vm(),I!==e?(ne=v,O=b(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function vm(){var v,O,L,I,z,oe;if(v=C,O=Rn(),O!==e){for(L=[],I=C,z=rt(),z===e&&(z=null),z!==e?(oe=Rn(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=rt(),z===e&&(z=null),z!==e?(oe=Rn(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function aw(){var v,O,L,I;if(v=C,w.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(P)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=vm(),I!==e?(ne=v,O=S(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function sw(){var v,O,L,I;if(v=C,T.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(A)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=lw(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function lw(){var v,O,L,I,z,oe;if(v=C,O=Jd(),O!==e){for(L=[],I=C,z=rt(),z===e&&(z=null),z!==e?(oe=Jd(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=rt(),z===e&&(z=null),z!==e?(oe=Jd(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function Jd(){var v,O,L,I,z,oe;return v=C,O=Xt(),O!==e?(L=rt(),L===e&&(L=null),L!==e?(I=Xt(),I!==e?(z=rt(),z===e&&(z=null),z!==e?(oe=Xt(),oe!==e?(ne=v,O=x(O,I,oe),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function cw(){var v,O,L,I;if(v=C,N.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(E)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=uw(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function uw(){var v,O,L,I,z,oe;if(v=C,O=ep(),O!==e){for(L=[],I=C,z=rt(),z===e&&(z=null),z!==e?(oe=ep(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=rt(),z===e&&(z=null),z!==e?(oe=ep(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function ep(){var v,O,L,I;return v=C,O=Xt(),O!==e?(L=rt(),L===e&&(L=null),L!==e?(I=Xt(),I!==e?(ne=v,O=M(O,I),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function dw(){var v,O,L,I;if(v=C,D.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(_)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=pw(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function pw(){var v,O,L,I,z,oe;if(v=C,O=tp(),O!==e){for(L=[],I=C,z=rt(),z===e&&(z=null),z!==e?(oe=tp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=rt(),z===e&&(z=null),z!==e?(oe=tp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function tp(){var v,O,L,I;return v=C,O=Xt(),O!==e?(L=rt(),L===e&&(L=null),L!==e?(I=Xt(),I!==e?(ne=v,O=R(O,I),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function fw(){var v,O,L,I;if(v=C,V.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(U)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=hw(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function hw(){var v,O,L,I,z,oe;if(v=C,O=Xt(),O!==e){for(L=[],I=C,z=rt(),z===e&&(z=null),z!==e?(oe=Xt(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=rt(),z===e&&(z=null),z!==e?(oe=Xt(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function mw(){var v,O,L,I;if(v=C,B.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(q)),O!==e){for(L=[],I=Ge();I!==e;)L.push(I),I=Ge();L!==e?(I=yw(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function yw(){var v,O,L,I,z,oe;if(v=C,O=rp(),O!==e){for(L=[],I=C,z=rt(),z===e&&(z=null),z!==e?(oe=rp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=rt(),z===e&&(z=null),z!==e?(oe=rp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function rp(){var v,O,L,I,z,oe,Bn,ip,Kl,np,Ql,ap;return v=C,O=Sm(),O!==e?(L=rt(),L===e&&(L=null),L!==e?(I=Sm(),I!==e?(z=rt(),z===e&&(z=null),z!==e?(oe=Rn(),oe!==e?(Bn=rt(),Bn!==e?(ip=wm(),ip!==e?(Kl=rt(),Kl===e&&(Kl=null),Kl!==e?(np=wm(),np!==e?(Ql=rt(),Ql===e&&(Ql=null),Ql!==e?(ap=Xt(),ap!==e?(ne=v,O=j(O,I,oe,ip,np,ap),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function Xt(){var v,O,L,I;return v=C,O=Rn(),O!==e?(L=rt(),L===e&&(L=null),L!==e?(I=Rn(),I!==e?(ne=v,O=F(O,I),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function Sm(){var v,O;return v=C,O=Om(),O===e&&(O=Ki()),O!==e&&(ne=v,O=H(O)),v=O,v}function Rn(){var v,O,L,I;return v=C,O=C,L=op(),L===e&&(L=null),L!==e?(I=Om(),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e),O===e&&(O=C,L=op(),L===e&&(L=null),L!==e?(I=Ki(),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e)),O!==e&&(ne=v,O=W(O)),v=O,v}function wm(){var v,O;return v=C,ee.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(te)),O!==e&&(ne=v,O=Y(O)),v=O,v}function rt(){var v,O,L,I,z;if(v=C,O=[],L=Ge(),L!==e)for(;L!==e;)O.push(L),L=Ge();else O=e;if(O!==e)if(L=Pm(),L===e&&(L=null),L!==e){for(I=[],z=Ge();z!==e;)I.push(z),z=Ge();I!==e?(O=[O,L,I],v=O):(C=v,v=e)}else C=v,v=e;else C=v,v=e;if(v===e){if(v=C,O=C,L=Pm(),L!==e){for(I=[],z=Ge();z!==e;)I.push(z),z=Ge();I!==e?(L=[L,I],O=L):(C=O,O=e)}else C=O,O=e;O!==e&&(ne=v,O=re()),v=O}return v}function Pm(){var v;return i.charCodeAt(C)===44?(v=K,C++):(v=e,Oe===0&&pt(Z)),v}function Om(){var v,O,L,I;return v=C,O=C,L=gw(),L!==e?(I=Tm(),I===e&&(I=null),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e),O===e&&(O=C,L=Ki(),L!==e?(I=Tm(),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e)),O!==e&&(ne=v,O=Q(O)),v=O,v}function gw(){var v,O,L,I,z;return v=C,O=C,L=Ki(),L===e&&(L=null),L!==e?(i.charCodeAt(C)===46?(I=$,C++):(I=e,Oe===0&&pt(de)),I!==e?(z=Ki(),z!==e?(L=[L,I,z],O=L):(C=O,O=e)):(C=O,O=e)):(C=O,O=e),O===e&&(O=C,L=Ki(),L!==e?(i.charCodeAt(C)===46?(I=$,C++):(I=e,Oe===0&&pt(de)),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e)),O!==e&&(ne=v,O=Q(O)),v=O,v}function Tm(){var v,O,L,I,z;return v=C,O=C,le.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Oe===0&&pt(ie)),L!==e?(I=op(),I===e&&(I=null),I!==e?(z=Ki(),z!==e?(L=[L,I,z],O=L):(C=O,O=e)):(C=O,O=e)):(C=O,O=e),O!==e&&(ne=v,O=Q(O)),v=O,v}function op(){var v;return ce.test(i.charAt(C))?(v=i.charAt(C),C++):(v=e,Oe===0&&pt(ae)),v}function Ki(){var v,O,L;if(v=C,O=[],me.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Oe===0&&pt(fe)),L!==e)for(;L!==e;)O.push(L),me.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Oe===0&&pt(fe));else O=e;return O!==e&&(ne=v,O=he(O)),v=O,v}function Ge(){var v,O;return v=C,be.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Oe===0&&pt(ye)),O!==e&&(ne=v,O=re()),v=O,v}function xw(v,O){if(!O)return[v];for(var L=[v],I=0,z=O.length;I<z;I++)L[I+1]=O[I][1];return L}var Yl={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 Cm in Yl)Yl[Cm.toUpperCase()]=Yl[Cm];function Ln(v,O){O||(O=[{}]);for(var L=O.length;L--;){var I={code:v,command:Yl[v]};v==v.toLowerCase()&&(I.relative=!0);for(var z in O[L])I[z]=O[L][z];O[L]=I}return O}if(Ot=o(),Ot!==e&&C===i.length)return Ot;throw Ot!==e&&C<i.length&&pt(Kd()),xr(Re,ze<i.length?i.charAt(ze):null,ze<i.length?Xi(ze,ze+1):Xi(ze,ze))}B1.exports={SyntaxError:In,parse:v_}});var qh=Ls((_ce,z1)=>{var Md=V1().parse;Md.parseSVG=Md;Md.makeAbsolute=S_;z1.exports=Md;function S_(i){var t,e={x:0,y:0},r={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return i.forEach(function(o){o.command==="moveto"&&(t=o),o.x0=e.x,o.y0=e.y;for(var n in r)n in o&&(o[n]+=o.relative?o[r[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=t.x,o.y=t.y),e=o}),i}});var ew=Ls((Jye,JS)=>{JS.exports=function(t,e){for(var r=t.split("."),o=e.split("."),n=0;n<3;n++){var a=Number(r[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 PL,Loader as OL}from"three";function Jl(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function Ct(i,t){return Object.setPrototypeOf(i,t),i}function ec(i){return Array.isArray(i)?i:[i]}function tc(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var Aw=typeof global=="object"&&global&&global.Object===Object&&global,rc=Aw;var Mw=typeof self=="object"&&self&&self.Object===Object&&self,Iw=rc||Mw||Function("return this")(),ft=Iw;var Ew=ft.Symbol,Dt=Ew;var Am=Object.prototype,Nw=Am.hasOwnProperty,Dw=Am.toString,Vs=Dt?Dt.toStringTag:void 0;function _w(i){var t=Nw.call(i,Vs),e=i[Vs];try{i[Vs]=void 0;var r=!0}catch{}var o=Dw.call(i);return r&&(t?i[Vs]=e:delete i[Vs]),o}var Mm=_w;var Rw=Object.prototype,Lw=Rw.toString;function Bw(i){return Lw.call(i)}var Im=Bw;var Vw="[object Null]",zw="[object Undefined]",Em=Dt?Dt.toStringTag:void 0;function Gw(i){return i==null?i===void 0?zw:Vw:Em&&Em in Object(i)?Mm(i):Im(i)}var dr=Gw;function Fw(i){return i!=null&&typeof i=="object"}var Gt=Fw;var jw="[object Symbol]";function Uw(i){return typeof i=="symbol"||Gt(i)&&dr(i)==jw}var ii=Uw;function kw(i,t){for(var e=-1,r=i==null?0:i.length,o=Array(r);++e<r;)o[e]=t(i[e],e,i);return o}var oc=kw;var Hw=Array.isArray,ht=Hw;var Ww=1/0,Nm=Dt?Dt.prototype:void 0,Dm=Nm?Nm.toString:void 0;function _m(i){if(typeof i=="string")return i;if(ht(i))return oc(i,_m)+"";if(ii(i))return Dm?Dm.call(i):"";var t=i+"";return t=="0"&&1/i==-Ww?"-0":t}var Rm=_m;var qw=/\s/;function $w(i){for(var t=i.length;t--&&qw.test(i.charAt(t)););return t}var Lm=$w;var Xw=/^\s+/;function Yw(i){return i&&i.slice(0,Lm(i)+1).replace(Xw,"")}var Bm=Yw;function Kw(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var mt=Kw;var Vm=0/0,Qw=/^[-+]0x[0-9a-f]+$/i,Zw=/^0b[01]+$/i,Jw=/^0o[0-7]+$/i,e2=parseInt;function t2(i){if(typeof i=="number")return i;if(ii(i))return Vm;if(mt(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=mt(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=Bm(i);var e=Zw.test(i);return e||Jw.test(i)?e2(i.slice(2),e?2:8):Qw.test(i)?Vm:+i}var sp=t2;function r2(i){return i}var zm=r2;var o2="[object AsyncFunction]",i2="[object Function]",n2="[object GeneratorFunction]",a2="[object Proxy]";function s2(i){if(!mt(i))return!1;var t=dr(i);return t==i2||t==n2||t==o2||t==a2}var ic=s2;var l2=ft["__core-js_shared__"],nc=l2;var Gm=function(){var i=/[^.]+$/.exec(nc&&nc.keys&&nc.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function c2(i){return!!Gm&&Gm in i}var Fm=c2;var u2=Function.prototype,d2=u2.toString;function p2(i){if(i!=null){try{return d2.call(i)}catch{}try{return i+""}catch{}}return""}var Mo=p2;var f2=/[\\^$.*+?()[\]{}|]/g,h2=/^\[object .+?Constructor\]$/,m2=Function.prototype,y2=Object.prototype,g2=m2.toString,x2=y2.hasOwnProperty,b2=RegExp("^"+g2.call(x2).replace(f2,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function v2(i){if(!mt(i)||Fm(i))return!1;var t=ic(i)?b2:h2;return t.test(Mo(i))}var jm=v2;function S2(i,t){return i?.[t]}var Um=S2;function w2(i,t){var e=Um(i,t);return jm(e)?e:void 0}var er=w2;var P2=er(ft,"WeakMap"),ac=P2;var km=Object.create,O2=function(){function i(){}return function(t){if(!mt(t))return{};if(km)return km(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),Hm=O2;function T2(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var Wm=T2;function C2(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var qm=C2;var A2=800,M2=16,I2=Date.now;function E2(i){var t=0,e=0;return function(){var r=I2(),o=M2-(r-e);if(e=r,o>0){if(++t>=A2)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var $m=E2;function N2(i){return function(){return i}}var Xm=N2;var D2=function(){try{var i=er(Object,"defineProperty");return i({},"",{}),i}catch{}}(),Vn=D2;var _2=Vn?function(i,t){return Vn(i,"toString",{configurable:!0,enumerable:!1,value:Xm(t),writable:!0})}:zm,Ym=_2;var R2=$m(Ym),Km=R2;function L2(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var Qm=L2;var B2=9007199254740991,V2=/^(?:0|[1-9]\d*)$/;function z2(i,t){var e=typeof i;return t=t??B2,!!t&&(e=="number"||e!="symbol"&&V2.test(i))&&i>-1&&i%1==0&&i<t}var zn=z2;function G2(i,t,e){t=="__proto__"&&Vn?Vn(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var sc=G2;function F2(i,t){return i===t||i!==i&&t!==t}var Gn=F2;var j2=Object.prototype,U2=j2.hasOwnProperty;function k2(i,t,e){var r=i[t];(!(U2.call(i,t)&&Gn(r,e))||e===void 0&&!(t in i))&&sc(i,t,e)}var Fn=k2;function H2(i,t,e,r){var o=!e;e||(e={});for(var n=-1,a=t.length;++n<a;){var s=t[n],l=r?r(e[s],i[s],s,e,i):void 0;l===void 0&&(l=i[s]),o?sc(e,s,l):Fn(e,s,l)}return e}var Jr=H2;var Zm=Math.max;function W2(i,t,e){return t=Zm(t===void 0?i.length-1:t,0),function(){for(var r=arguments,o=-1,n=Zm(r.length-t,0),a=Array(n);++o<n;)a[o]=r[t+o];o=-1;for(var s=Array(t+1);++o<t;)s[o]=r[o];return s[t]=e(a),Wm(i,this,s)}}var Jm=W2;var q2=9007199254740991;function $2(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=q2}var jn=$2;function X2(i){return i!=null&&jn(i.length)&&!ic(i)}var lc=X2;var Y2=Object.prototype;function K2(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||Y2;return i===e}var Un=K2;function Q2(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var ey=Q2;var Z2="[object Arguments]";function J2(i){return Gt(i)&&dr(i)==Z2}var lp=J2;var ty=Object.prototype,eP=ty.hasOwnProperty,tP=ty.propertyIsEnumerable,rP=lp(function(){return arguments}())?lp:function(i){return Gt(i)&&eP.call(i,"callee")&&!tP.call(i,"callee")},kn=rP;function oP(){return!1}var ry=oP;var ny=typeof exports=="object"&&exports&&!exports.nodeType&&exports,oy=ny&&typeof module=="object"&&module&&!module.nodeType&&module,iP=oy&&oy.exports===ny,iy=iP?ft.Buffer:void 0,nP=iy?iy.isBuffer:void 0,aP=nP||ry,Zi=aP;var sP="[object Arguments]",lP="[object Array]",cP="[object Boolean]",uP="[object Date]",dP="[object Error]",pP="[object Function]",fP="[object Map]",hP="[object Number]",mP="[object Object]",yP="[object RegExp]",gP="[object Set]",xP="[object String]",bP="[object WeakMap]",vP="[object ArrayBuffer]",SP="[object DataView]",wP="[object Float32Array]",PP="[object Float64Array]",OP="[object Int8Array]",TP="[object Int16Array]",CP="[object Int32Array]",AP="[object Uint8Array]",MP="[object Uint8ClampedArray]",IP="[object Uint16Array]",EP="[object Uint32Array]",ot={};ot[wP]=ot[PP]=ot[OP]=ot[TP]=ot[CP]=ot[AP]=ot[MP]=ot[IP]=ot[EP]=!0;ot[sP]=ot[lP]=ot[vP]=ot[cP]=ot[SP]=ot[uP]=ot[dP]=ot[pP]=ot[fP]=ot[hP]=ot[mP]=ot[yP]=ot[gP]=ot[xP]=ot[bP]=!1;function NP(i){return Gt(i)&&jn(i.length)&&!!ot[dr(i)]}var ay=NP;function DP(i){return function(t){return i(t)}}var Hn=DP;var sy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,zs=sy&&typeof module=="object"&&module&&!module.nodeType&&module,_P=zs&&zs.exports===sy,cp=_P&&rc.process,RP=function(){try{var i=zs&&zs.require&&zs.require("util").types;return i||cp&&cp.binding&&cp.binding("util")}catch{}}(),Io=RP;var ly=Io&&Io.isTypedArray,LP=ly?Hn(ly):ay,cc=LP;var BP=Object.prototype,VP=BP.hasOwnProperty;function zP(i,t){var e=ht(i),r=!e&&kn(i),o=!e&&!r&&Zi(i),n=!e&&!r&&!o&&cc(i),a=e||r||o||n,s=a?ey(i.length,String):[],l=s.length;for(var c in i)(t||VP.call(i,c))&&!(a&&(c=="length"||o&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||zn(c,l)))&&s.push(c);return s}var uc=zP;function GP(i,t){return function(e){return i(t(e))}}var dc=GP;var FP=dc(Object.keys,Object),cy=FP;var jP=Object.prototype,UP=jP.hasOwnProperty;function kP(i){if(!Un(i))return cy(i);var t=[];for(var e in Object(i))UP.call(i,e)&&e!="constructor"&&t.push(e);return t}var uy=kP;function HP(i){return lc(i)?uc(i):uy(i)}var Wn=HP;function WP(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var dy=WP;var qP=Object.prototype,$P=qP.hasOwnProperty;function XP(i){if(!mt(i))return dy(i);var t=Un(i),e=[];for(var r in i)r=="constructor"&&(t||!$P.call(i,r))||e.push(r);return e}var py=XP;function YP(i){return lc(i)?uc(i,!0):py(i)}var qn=YP;var KP=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,QP=/^\w*$/;function ZP(i,t){if(ht(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||ii(i)?!0:QP.test(i)||!KP.test(i)||t!=null&&i in Object(t)}var fy=ZP;var JP=er(Object,"create"),Eo=JP;function eO(){this.__data__=Eo?Eo(null):{},this.size=0}var hy=eO;function tO(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var my=tO;var rO="__lodash_hash_undefined__",oO=Object.prototype,iO=oO.hasOwnProperty;function nO(i){var t=this.__data__;if(Eo){var e=t[i];return e===rO?void 0:e}return iO.call(t,i)?t[i]:void 0}var yy=nO;var aO=Object.prototype,sO=aO.hasOwnProperty;function lO(i){var t=this.__data__;return Eo?t[i]!==void 0:sO.call(t,i)}var gy=lO;var cO="__lodash_hash_undefined__";function uO(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=Eo&&t===void 0?cO:t,this}var xy=uO;function $n(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}$n.prototype.clear=hy;$n.prototype.delete=my;$n.prototype.get=yy;$n.prototype.has=gy;$n.prototype.set=xy;var up=$n;function dO(){this.__data__=[],this.size=0}var by=dO;function pO(i,t){for(var e=i.length;e--;)if(Gn(i[e][0],t))return e;return-1}var ni=pO;var fO=Array.prototype,hO=fO.splice;function mO(i){var t=this.__data__,e=ni(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():hO.call(t,e,1),--this.size,!0}var vy=mO;function yO(i){var t=this.__data__,e=ni(t,i);return e<0?void 0:t[e][1]}var Sy=yO;function gO(i){return ni(this.__data__,i)>-1}var wy=gO;function xO(i,t){var e=this.__data__,r=ni(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var Py=xO;function Xn(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Xn.prototype.clear=by;Xn.prototype.delete=vy;Xn.prototype.get=Sy;Xn.prototype.has=wy;Xn.prototype.set=Py;var ai=Xn;var bO=er(ft,"Map"),si=bO;function vO(){this.size=0,this.__data__={hash:new up,map:new(si||ai),string:new up}}var Oy=vO;function SO(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var Ty=SO;function wO(i,t){var e=i.__data__;return Ty(t)?e[typeof t=="string"?"string":"hash"]:e.map}var li=wO;function PO(i){var t=li(this,i).delete(i);return this.size-=t?1:0,t}var Cy=PO;function OO(i){return li(this,i).get(i)}var Ay=OO;function TO(i){return li(this,i).has(i)}var My=TO;function CO(i,t){var e=li(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var Iy=CO;function Yn(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Yn.prototype.clear=Oy;Yn.prototype.delete=Cy;Yn.prototype.get=Ay;Yn.prototype.has=My;Yn.prototype.set=Iy;var Ji=Yn;var AO="Expected a function";function dp(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(AO);var e=function(){var r=arguments,o=t?t.apply(this,r):r[0],n=e.cache;if(n.has(o))return n.get(o);var a=i.apply(this,r);return e.cache=n.set(o,a)||n,a};return e.cache=new(dp.Cache||Ji),e}dp.Cache=Ji;var Ey=dp;var MO=500;function IO(i){var t=Ey(i,function(r){return e.size===MO&&e.clear(),r}),e=t.cache;return t}var Ny=IO;var EO=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,NO=/\\(\\)?/g,DO=Ny(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(EO,function(e,r,o,n){t.push(o?n.replace(NO,"$1"):r||e)}),t}),Dy=DO;function _O(i){return i==null?"":Rm(i)}var _y=_O;function RO(i,t){return ht(i)?i:fy(i,t)?[i]:Dy(_y(i))}var br=RO;var LO=1/0;function BO(i){if(typeof i=="string"||ii(i))return i;var t=i+"";return t=="0"&&1/i==-LO?"-0":t}var ci=BO;function VO(i,t){t=br(t,i);for(var e=0,r=t.length;i!=null&&e<r;)i=i[ci(t[e++])];return e&&e==r?i:void 0}var pc=VO;function zO(i,t){for(var e=-1,r=t.length,o=i.length;++e<r;)i[o+e]=t[e];return i}var Kn=zO;var Ry=Dt?Dt.isConcatSpreadable:void 0;function GO(i){return ht(i)||kn(i)||!!(Ry&&i&&i[Ry])}var Ly=GO;function By(i,t,e,r,o){var n=-1,a=i.length;for(e||(e=Ly),o||(o=[]);++n<a;){var s=i[n];t>0&&e(s)?t>1?By(s,t-1,e,r,o):Kn(o,s):r||(o[o.length]=s)}return o}var Vy=By;function FO(i){var t=i==null?0:i.length;return t?Vy(i,1):[]}var zy=FO;function jO(i){return Km(Jm(i,void 0,zy),i+"")}var fc=jO;var UO=dc(Object.getPrototypeOf,Object),Qn=UO;var kO="[object Object]",HO=Function.prototype,WO=Object.prototype,Gy=HO.toString,qO=WO.hasOwnProperty,$O=Gy.call(Object);function XO(i){if(!Gt(i)||dr(i)!=kO)return!1;var t=Qn(i);if(t===null)return!0;var e=qO.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&Gy.call(e)==$O}var Fy=XO;function YO(i,t,e){var r=-1,o=i.length;t<0&&(t=-t>o?0:o+t),e=e>o?o:e,e<0&&(e+=o),o=t>e?0:e-t>>>0,t>>>=0;for(var n=Array(o);++r<o;)n[r]=i[r+t];return n}var jy=YO;function KO(){this.__data__=new ai,this.size=0}var Uy=KO;function QO(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var ky=QO;function ZO(i){return this.__data__.get(i)}var Hy=ZO;function JO(i){return this.__data__.has(i)}var Wy=JO;var eT=200;function tT(i,t){var e=this.__data__;if(e instanceof ai){var r=e.__data__;if(!si||r.length<eT-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new Ji(r)}return e.set(i,t),this.size=e.size,this}var qy=tT;function Zn(i){var t=this.__data__=new ai(i);this.size=t.size}Zn.prototype.clear=Uy;Zn.prototype.delete=ky;Zn.prototype.get=Hy;Zn.prototype.has=Wy;Zn.prototype.set=qy;var Jn=Zn;function rT(i,t){return i&&Jr(t,Wn(t),i)}var $y=rT;function oT(i,t){return i&&Jr(t,qn(t),i)}var Xy=oT;var Zy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Yy=Zy&&typeof module=="object"&&module&&!module.nodeType&&module,iT=Yy&&Yy.exports===Zy,Ky=iT?ft.Buffer:void 0,Qy=Ky?Ky.allocUnsafe:void 0;function nT(i,t){if(t)return i.slice();var e=i.length,r=Qy?Qy(e):new i.constructor(e);return i.copy(r),r}var Jy=nT;function aT(i,t){for(var e=-1,r=i==null?0:i.length,o=0,n=[];++e<r;){var a=i[e];t(a,e,i)&&(n[o++]=a)}return n}var eg=aT;function sT(){return[]}var hc=sT;var lT=Object.prototype,cT=lT.propertyIsEnumerable,tg=Object.getOwnPropertySymbols,uT=tg?function(i){return i==null?[]:(i=Object(i),eg(tg(i),function(t){return cT.call(i,t)}))}:hc,ea=uT;function dT(i,t){return Jr(i,ea(i),t)}var rg=dT;var pT=Object.getOwnPropertySymbols,fT=pT?function(i){for(var t=[];i;)Kn(t,ea(i)),i=Qn(i);return t}:hc,mc=fT;function hT(i,t){return Jr(i,mc(i),t)}var og=hT;function mT(i,t,e){var r=t(i);return ht(i)?r:Kn(r,e(i))}var yc=mT;function yT(i){return yc(i,Wn,ea)}var Gs=yT;function gT(i){return yc(i,qn,mc)}var gc=gT;var xT=er(ft,"DataView"),xc=xT;var bT=er(ft,"Promise"),bc=bT;var vT=er(ft,"Set"),vc=vT;var ig="[object Map]",ST="[object Object]",ng="[object Promise]",ag="[object Set]",sg="[object WeakMap]",lg="[object DataView]",wT=Mo(xc),PT=Mo(si),OT=Mo(bc),TT=Mo(vc),CT=Mo(ac),en=dr;(xc&&en(new xc(new ArrayBuffer(1)))!=lg||si&&en(new si)!=ig||bc&&en(bc.resolve())!=ng||vc&&en(new vc)!=ag||ac&&en(new ac)!=sg)&&(en=function(i){var t=dr(i),e=t==ST?i.constructor:void 0,r=e?Mo(e):"";if(r)switch(r){case wT:return lg;case PT:return ig;case OT:return ng;case TT:return ag;case CT:return sg}return t});var No=en;var AT=Object.prototype,MT=AT.hasOwnProperty;function IT(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&MT.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var cg=IT;var ET=ft.Uint8Array,ta=ET;function NT(i){var t=new i.constructor(i.byteLength);return new ta(t).set(new ta(i)),t}var ra=NT;function DT(i,t){var e=t?ra(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var ug=DT;var _T=/\w*$/;function RT(i){var t=new i.constructor(i.source,_T.exec(i));return t.lastIndex=i.lastIndex,t}var dg=RT;var pg=Dt?Dt.prototype:void 0,fg=pg?pg.valueOf:void 0;function LT(i){return fg?Object(fg.call(i)):{}}var hg=LT;function BT(i,t){var e=t?ra(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var mg=BT;var VT="[object Boolean]",zT="[object Date]",GT="[object Map]",FT="[object Number]",jT="[object RegExp]",UT="[object Set]",kT="[object String]",HT="[object Symbol]",WT="[object ArrayBuffer]",qT="[object DataView]",$T="[object Float32Array]",XT="[object Float64Array]",YT="[object Int8Array]",KT="[object Int16Array]",QT="[object Int32Array]",ZT="[object Uint8Array]",JT="[object Uint8ClampedArray]",eC="[object Uint16Array]",tC="[object Uint32Array]";function rC(i,t,e){var r=i.constructor;switch(t){case WT:return ra(i);case VT:case zT:return new r(+i);case qT:return ug(i,e);case $T:case XT:case YT:case KT:case QT:case ZT:case JT:case eC:case tC:return mg(i,e);case GT:return new r;case FT:case kT:return new r(i);case jT:return dg(i);case UT:return new r;case HT:return hg(i)}}var yg=rC;function oC(i){return typeof i.constructor=="function"&&!Un(i)?Hm(Qn(i)):{}}var gg=oC;var iC="[object Map]";function nC(i){return Gt(i)&&No(i)==iC}var xg=nC;var bg=Io&&Io.isMap,aC=bg?Hn(bg):xg,vg=aC;var sC="[object Set]";function lC(i){return Gt(i)&&No(i)==sC}var Sg=lC;var wg=Io&&Io.isSet,cC=wg?Hn(wg):Sg,Pg=cC;var uC=1,dC=2,pC=4,Og="[object Arguments]",fC="[object Array]",hC="[object Boolean]",mC="[object Date]",yC="[object Error]",Tg="[object Function]",gC="[object GeneratorFunction]",xC="[object Map]",bC="[object Number]",Cg="[object Object]",vC="[object RegExp]",SC="[object Set]",wC="[object String]",PC="[object Symbol]",OC="[object WeakMap]",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]",et={};et[Og]=et[fC]=et[TC]=et[CC]=et[hC]=et[mC]=et[AC]=et[MC]=et[IC]=et[EC]=et[NC]=et[xC]=et[bC]=et[Cg]=et[vC]=et[SC]=et[wC]=et[PC]=et[DC]=et[_C]=et[RC]=et[LC]=!0;et[yC]=et[Tg]=et[OC]=!1;function Sc(i,t,e,r,o,n){var a,s=t&uC,l=t&dC,c=t&pC;if(e&&(a=o?e(i,r,o,n):e(i)),a!==void 0)return a;if(!mt(i))return i;var u=ht(i);if(u){if(a=cg(i),!s)return qm(i,a)}else{var d=No(i),p=d==Tg||d==gC;if(Zi(i))return Jy(i,s);if(d==Cg||d==Og||p&&!o){if(a=l||p?{}:gg(i),!s)return l?og(i,Xy(a,i)):rg(i,$y(a,i))}else{if(!et[d])return o?i:{};a=yg(i,d,s)}}n||(n=new Jn);var f=n.get(i);if(f)return f;n.set(i,a),Pg(i)?i.forEach(function(y){a.add(Sc(y,t,e,y,i,n))}):vg(i)&&i.forEach(function(y,g){a.set(g,Sc(y,t,e,g,i,n))});var h=c?l?gc:Gs:l?qn:Wn,m=u?void 0:h(i);return Qm(m||i,function(y,g){m&&(g=y,y=i[g]),Fn(a,g,Sc(y,t,e,g,i,n))}),a}var wc=Sc;var BC=1,VC=4;function zC(i){return wc(i,BC|VC)}var Do=zC;var GC="__lodash_hash_undefined__";function FC(i){return this.__data__.set(i,GC),this}var Ag=FC;function jC(i){return this.__data__.has(i)}var Mg=jC;function Pc(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new Ji;++t<e;)this.add(i[t])}Pc.prototype.add=Pc.prototype.push=Ag;Pc.prototype.has=Mg;var Ig=Pc;function UC(i,t){for(var e=-1,r=i==null?0:i.length;++e<r;)if(t(i[e],e,i))return!0;return!1}var Eg=UC;function kC(i,t){return i.has(t)}var Ng=kC;var HC=1,WC=2;function qC(i,t,e,r,o,n){var a=e&HC,s=i.length,l=t.length;if(s!=l&&!(a&&l>s))return!1;var c=n.get(i),u=n.get(t);if(c&&u)return c==t&&u==i;var d=-1,p=!0,f=e&WC?new Ig:void 0;for(n.set(i,t),n.set(t,i);++d<s;){var h=i[d],m=t[d];if(r)var y=a?r(m,h,d,t,i,n):r(h,m,d,i,t,n);if(y!==void 0){if(y)continue;p=!1;break}if(f){if(!Eg(t,function(g,b){if(!Ng(f,b)&&(h===g||o(h,g,e,r,n)))return f.push(b)})){p=!1;break}}else if(!(h===m||o(h,m,e,r,n))){p=!1;break}}return n.delete(i),n.delete(t),p}var Oc=qC;function $C(i){var t=-1,e=Array(i.size);return i.forEach(function(r,o){e[++t]=[o,r]}),e}var Dg=$C;function XC(i){var t=-1,e=Array(i.size);return i.forEach(function(r){e[++t]=r}),e}var _g=XC;var YC=1,KC=2,QC="[object Boolean]",ZC="[object Date]",JC="[object Error]",eA="[object Map]",tA="[object Number]",rA="[object RegExp]",oA="[object Set]",iA="[object String]",nA="[object Symbol]",aA="[object ArrayBuffer]",sA="[object DataView]",Rg=Dt?Dt.prototype:void 0,pp=Rg?Rg.valueOf:void 0;function lA(i,t,e,r,o,n,a){switch(e){case sA:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case aA:return!(i.byteLength!=t.byteLength||!n(new ta(i),new ta(t)));case QC:case ZC:case tA:return Gn(+i,+t);case JC:return i.name==t.name&&i.message==t.message;case rA:case iA:return i==t+"";case eA:var s=Dg;case oA:var l=r&YC;if(s||(s=_g),i.size!=t.size&&!l)return!1;var c=a.get(i);if(c)return c==t;r|=KC,a.set(i,t);var u=Oc(s(i),s(t),r,o,n,a);return a.delete(i),u;case nA:if(pp)return pp.call(i)==pp.call(t)}return!1}var Lg=lA;var cA=1,uA=Object.prototype,dA=uA.hasOwnProperty;function pA(i,t,e,r,o,n){var a=e&cA,s=Gs(i),l=s.length,c=Gs(t),u=c.length;if(l!=u&&!a)return!1;for(var d=l;d--;){var p=s[d];if(!(a?p in t:dA.call(t,p)))return!1}var f=n.get(i),h=n.get(t);if(f&&h)return f==t&&h==i;var m=!0;n.set(i,t),n.set(t,i);for(var y=a;++d<l;){p=s[d];var g=i[p],b=t[p];if(r)var w=a?r(b,g,p,t,i,n):r(g,b,p,i,t,n);if(!(w===void 0?g===b||o(g,b,e,r,n):w)){m=!1;break}y||(y=p=="constructor")}if(m&&!y){var P=i.constructor,S=t.constructor;P!=S&&"constructor"in i&&"constructor"in t&&!(typeof P=="function"&&P instanceof P&&typeof S=="function"&&S instanceof S)&&(m=!1)}return n.delete(i),n.delete(t),m}var Bg=pA;var fA=1,Vg="[object Arguments]",zg="[object Array]",Tc="[object Object]",hA=Object.prototype,Gg=hA.hasOwnProperty;function mA(i,t,e,r,o,n){var a=ht(i),s=ht(t),l=a?zg:No(i),c=s?zg:No(t);l=l==Vg?Tc:l,c=c==Vg?Tc:c;var u=l==Tc,d=c==Tc,p=l==c;if(p&&Zi(i)){if(!Zi(t))return!1;a=!0,u=!1}if(p&&!u)return n||(n=new Jn),a||cc(i)?Oc(i,t,e,r,o,n):Lg(i,t,l,e,r,o,n);if(!(e&fA)){var f=u&&Gg.call(i,"__wrapped__"),h=d&&Gg.call(t,"__wrapped__");if(f||h){var m=f?i.value():i,y=h?t.value():t;return n||(n=new Jn),o(m,y,e,r,n)}}return p?(n||(n=new Jn),Bg(i,t,e,r,o,n)):!1}var Fg=mA;function jg(i,t,e,r,o){return i===t?!0:i==null||t==null||!Gt(i)&&!Gt(t)?i!==i&&t!==t:Fg(i,t,e,r,jg,o)}var Ug=jg;function yA(i,t){return i!=null&&t in Object(i)}var kg=yA;function gA(i,t,e){t=br(t,i);for(var r=-1,o=t.length,n=!1;++r<o;){var a=ci(t[r]);if(!(n=i!=null&&e(i,a)))break;i=i[a]}return n||++r!=o?n:(o=i==null?0:i.length,!!o&&jn(o)&&zn(a,o)&&(ht(i)||kn(i)))}var Hg=gA;function xA(i,t){return i!=null&&Hg(i,t,kg)}var Wg=xA;var bA=function(){return ft.Date.now()},Cc=bA;var vA="Expected a function",SA=Math.max,wA=Math.min;function PA(i,t,e){var r,o,n,a,s,l,c=0,u=!1,d=!1,p=!0;if(typeof i!="function")throw new TypeError(vA);t=sp(t)||0,mt(e)&&(u=!!e.leading,d="maxWait"in e,n=d?SA(sp(e.maxWait)||0,t):n,p="trailing"in e?!!e.trailing:p);function f(T){var A=r,x=o;return r=o=void 0,c=T,a=i.apply(x,A),a}function h(T){return c=T,s=setTimeout(g,t),u?f(T):a}function m(T){var A=T-l,x=T-c,N=t-A;return d?wA(N,n-x):N}function y(T){var A=T-l,x=T-c;return l===void 0||A>=t||A<0||d&&x>=n}function g(){var T=Cc();if(y(T))return b(T);s=setTimeout(g,m(T))}function b(T){return s=void 0,p&&r?f(T):(r=o=void 0,a)}function w(){s!==void 0&&clearTimeout(s),c=0,r=l=o=s=void 0}function P(){return s===void 0?a:b(Cc())}function S(){var T=Cc(),A=y(T);if(r=arguments,o=this,l=T,A){if(s===void 0)return h(l);if(d)return clearTimeout(s),s=setTimeout(g,t),f(l)}return s===void 0&&(s=setTimeout(g,t)),a}return S.cancel=w,S.flush=P,S}var Ac=PA;function OA(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var qg=OA;function TA(i,t){return t.length<2?i:pc(i,jy(t,0,-1))}var $g=TA;function CA(i,t){return Ug(i,t)}var fp=CA;function AA(i,t){return t=br(t,i),i=$g(i,t),i==null||delete i[ci(qg(t))]}var Xg=AA;function MA(i){return Fy(i)?void 0:i}var Yg=MA;var IA=1,EA=2,NA=4,DA=fc(function(i,t){var e={};if(i==null)return e;var r=!1;t=oc(t,function(n){return n=br(n,i),r||(r=n.length>1),n}),Jr(i,gc(i),e),r&&(e=wc(e,IA|EA|NA,Yg));for(var o=t.length;o--;)Xg(e,t[o]);return e}),oa=DA;function _A(i,t,e,r){if(!mt(i))return i;t=br(t,i);for(var o=-1,n=t.length,a=n-1,s=i;s!=null&&++o<n;){var l=ci(t[o]),c=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(o!=a){var u=s[l];c=r?r(u,l,s):void 0,c===void 0&&(c=mt(u)?u:zn(t[o+1])?[]:{})}Fn(s,l,c),s=s[l]}return i}var Kg=_A;function RA(i,t,e){for(var r=-1,o=t.length,n={};++r<o;){var a=t[r],s=pc(i,a);e(s,a)&&Kg(n,br(a,i),s)}return n}var Qg=RA;function LA(i,t){return Qg(i,t,function(e,r){return Wg(i,r)})}var Zg=LA;var BA=fc(function(i,t){return i==null?{}:Zg(i,t)}),Rr=BA;var ue=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let n={...r,[t]:e};return Object.setPrototypeOf(n,ue.prototype),n}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],o;r===void 0?o={type:2,id:t.id}:o={type:1,id:t.id,data:r};let{id:n,data:a}=t,s={...e,[n]:a};return Object.setPrototypeOf(s,ue.prototype),{data:s,actual:t,reverse:o}}else if(t.type===2){let{id:r}=t,o=e[r];if(o===void 0)return null;{let n={...e};return Object.setPrototypeOf(n,ue.prototype),delete n[r],{data:n,actual:t,reverse:{type:1,id:r,data:o}}}}return null}};function Fs(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let r=i[e];r&&typeof r=="object"&&Fs(r)}return Object.freeze(i)}function Jg(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var ia=class extends Error{};function Mc(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function eo(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let n=i;i=t,t=n}let r=[],o=1/(e+1);for(let n=0;n<e;n++){let a=i+(t-i)*(n+.75+Math.random()*.5)*o;r.push(a)}return r}function na(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 e0(){return typeof process<"u"}function t0(i,t){for(let e of i)t(e.id,e.data)!==!0&&t0(e.children,t)}function r0(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)r0(e,t)}var Ze=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Ze.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Fs(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,r){if(!this.has(e))return!0;for(;e;){let o=this.parent(e);if(o===r)return!0;e=o}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let o=this.parent(e);if(o===r)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,r){if(e===null)this.traverse(r);else{let o=this.get(e);o&&r0(o,r)}}traverse(e){t0(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let 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:r},this.modifyArrayBy(n,a)}}modifyArrayBy(e,r){let o=e,n=r;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,Ze.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:r}){if(this.get(e)!==void 0)return!0;for(let o of r)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:r,fi:o,id:n,data:a,children:s}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,c=this.childrenArray(l),u={fi:o,id:n,data:a,children:s};return c=[...c,u],c.sort((p,f)=>p.fi-f.fi),e.localIndex=c.indexOf(u),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:n}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let o=this.parent(r);if(o===void 0)return null;let n=this.childrenArray(o),a=n.findIndex(c=>c.id===r);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:r,fi:o,id:n}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:n});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===n)throw new ia("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],d=this.modifyArrayBy(a,l);a=r,l=d.childrenArray(a);let p=u.fi;return u={...u,fi:o},l=[...l,u],l.sort((f,h)=>f.fi-h.fi),e.localIndex=l.indexOf(u),d=d.modifyArrayBy(a,l),{data:d,actual:e,reverse:{type:9,parent:s,fi:p,id:n}}}previous(e,r){if(r===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===r)return o;o=n.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),n=o.findIndex(a=>a.id===e)+1;if(n<o.length)return o[n].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),n=o.findIndex(a=>a.id===e)-1;return n>=0?this.traverseSortPrevious(o[n].id):r}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push({...o,...n})}r.sort((o,n)=>Jg(o.sortKey,n.sortKey));for(let o of r)delete o.sortKey;return r}getWithSortKey(e){var r=e;let o=[],n=this.get(r),a=n;if(n!==void 0){for(;r;)o.splice(0,0,n.fi),r=this.parent(r),r!==null&&(n=this.get(r));return{...a,sortKey:o}}}insertBeforeHelper(e,r,o){return this.insertAfterHelper(e,this.previous(e,r),o)}insertAfterHelper(e,r,o){let n=this.childrenArray(e);if(r===null){if(n.length===0)return eo(0,o,o);{let a=n[0].fi;return eo(a-o,a,o)}}else{let a=this.get(r);if(a===void 0||this.parent(r)!==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 eo(l,l+o,o)}else return eo(a.fi,s.fi,o)}}};var aa;(t=>{function i(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let o=r.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:r,reverse:{type:0,props:n}}:null}else{let o=r.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:r,reverse:{type:0,props:n}}:null}}t.runOp=i})(aa||(aa={}));var xe=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,xe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Fs(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,r){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:r},this.modifyArrayBy(n)}}modifyArrayBy(e){Object.setPrototypeOf(e,xe.prototype);let r=e;return e0()||r.fillCaches(),r}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:r,id:o,data:n}=e,a=this,s={fi:r,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:r}=e,o=this,n=o.findIndex(l=>l.id===r);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:r,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:r};return n[a]=l,n.sort((u,d)=>u.fi-d.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 r=null;for(let o of this){if(o.id===e)return r;r=o.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let o=this;if(e===null){if(o.length===0)return eo(0,r,r);{let n=o[0].fi;return eo(n-r,n,r)}}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 eo(s,s+r,r)}else return eo(n.fi,a.fi,r)}}};function sa(i){return i&&typeof i=="object"&&i instanceof We}var We=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,o=0,n={};for(;o<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[o]],r!==void 0&&!sa(r))return null;o+=1}r=r?Mc(r):new We;for(let[l,c]of Object.entries(t.props)){let u=r[l];n[l]=u,c===void 0?delete r[l]:r[l]=c}for(;o>0;){if(Object.keys(r).length===0){let l=e[o-1];l&&(r=Mc(l),delete r[t.path[o-1]])}else{let l=e[o-1];if(l){let c=Mc(l);c[t.path[o-1]]=r,r=c}else{let c=new We;c[t.path[o-1]]=r,r=c}}o-=1}let a=Object.setPrototypeOf(r,We.prototype),s={...t,props:n};return{data:a,actual:t,reverse:s}}},to;(r=>{function i(o,n){return js(o,n)??o}r.apply=i;function t(o,n){return mp(o,n)}r.merge=t;function e(o,n){let a=0,s=n.path,l=o;for(;a<s.length&&l!==void 0;){if(l=Je.zoomOnce(l,s[a]),l===void 0)return n;if(!sa(l))return;a+=1}if(l===void 0)return n;if(!!sa(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=hp([n],l);return c?c[0]:n}else return n}r.filterOp=e})(to||(to={}));function hp(i,t){if(t===void 0)return;let e=!1,r=i.map(o=>{let n=o.id,a=js(o.data,t[n]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=hp(o.children,t);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 r}function VA(i,t){if(t===void 0)return;let e=!1,r=i.map(o=>{let n=o.id,a=js(o.data,t[n]);return e=e||a!==void 0,a===void 0&&(a=o.data),{...o,id:n,data:a}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function js(i,t){if(!sa(t))return t;if(i instanceof Ze){let e=hp(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof xe)return VA(i,t);if(Array.isArray(i)){let e=!1,r=i.map((o,n)=>{let a=js(o,t[n]);return e=e||a!==void 0,a===void 0&&(a=o),a});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else{if(i instanceof We)return mp(i,t);if(i&&typeof i=="object"){let e={},r=!1;for(let[o,n]of Object.entries(i)){let a=js(n,t[o]);r=r||a!==void 0,a===void 0&&(a=n),e[o]=a}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function mp(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!sa(t))return t;if(!sa(i))return to.apply(i,t);let e=new Set;for(let o of Object.keys(i))e.add(o);for(let o of Object.keys(t))e.add(o);let r=new We;for(let o of e){let n=mp(i===void 0?void 0:i[o],t===void 0?void 0:t[o]);r[o]=n}return r}function o0(i,t){let e={cur:[],result:[],len:0};return i=Us(i,t,e)??i,[i,e.result]}function Ic(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function Ec(i){i&&(i.len-=1)}function zA(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function i0(i,t,e){let r=!1,o=i.map(n=>{let a=n.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=Us(n.data,t,Ic(e,a));Ec(e),r=r||l!==void 0,l===void 0&&(l=n.data);let c=i0(n.children,t,e);return c!==void 0?r=!0:c=n.children,{...n,id:a,data:l,children:c}});if(r)return o}function GA(i,t,e){let r=!1,o=i.map(n=>{let a=n.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=Us(n.data,t,Ic(e,a));return Ec(e),r=r||l!==void 0,l===void 0&&(l=n.data),{...n,id:a,data:l}});if(r)return Object.setPrototypeOf(o,Object.getPrototypeOf(i)),o}function Us(i,t,e){if(i instanceof Ze){let r=i0(i,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}else{if(i instanceof xe)return GA(i,t,e);if(Array.isArray(i)){let r=!1,o=i.map((n,a)=>{let s=Us(n,t,Ic(e,a));return Ec(e),r=r||s!==void 0,s===void 0&&(s=n),s});return r?(Object.setPrototypeOf(o,Object.getPrototypeOf(i)),o):void 0}else if(i&&typeof i=="object"&&!na(i)){let r={},o=!1;for(let[n,a]of Object.entries(i))if(n!=="name"&&n!=="variableId"){let s=t[n];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,n=s}let l=Us(a,t,Ic(e,n));Ec(e),o=o||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return o?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else if(typeof i=="string"){let r=t[i];return r!==void 0&&zA(e),r}else return}}var la;(t=>{function i(e,r){let o=Je.zoom(r,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:{}}}t.replaceProps=i})(la||(la={}));var at;(s=>{function i(l,c){return{...l,path:l.path.slice(c)}}s.drop=i;function t(l,c){return e(l,c)?.data??l}s.applySimple=t;function e(l,c){let u=c.path;for(var d=[];;){let p;if(l instanceof We&&c.type===0&&(p=l.runOp({...c,path:u.slice(d.length)}),p===null&&(p=void 0)),p===void 0&&d.length===u.length&&(l instanceof Ze||l instanceof xe||l instanceof ue?p=l.runOp(c):p=aa.runOp(l,c)),p!==void 0)if(p!==null){let m=p.data;for(let y=d.length-1;y>=0;y--){let g=u[y],b=d[y];if(b instanceof Ze){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof xe){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof ue){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof We){let w={...b,[g]:m};m=Object.setPrototypeOf(w,We.prototype)}else if(typeof b=="object")if(Array.isArray(b)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let w=m;m=[...b],m[g]=w}else m={...b,[g]:m};else return null}return{data:m,actual:{...p.actual,path:u},reverse:{...p.reverse,path:u}}}else return null;let f=u[d.length],h;if(l instanceof Ze){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else if(l instanceof xe){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else l!==null&&(h=l[f]);if(h!==void 0)d.push(l),l=h;else return null}}s.apply=e;function r(l,c){for(let u=0;u<l.length&&u<c.length;u++)if(l[u]!==c[u])return!0;return!1}s.pathDisjoint=r;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 r(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})(at||(at={}));var ks;(l=>{function i(){return[]}l.empty=i;function t(c,u){let d=[];for(let p of c){let[f,...h]=p.path;f===u&&d.push({...p,path:h})}return d}l.removePrefix=t;function e(c,u){return c.map(d=>({...d,path:[u,...d.path]}))}l.addPrefix=e;function r(c,u){return[...c,...u]}l.concat=r;function o(c,u){return[...c.filter(p=>!u.some(f=>at.subsumed(p,f))),...u]}l.compress=o;function n(c,u){return c.every(d=>u.every(p=>at.commutative(d,p)))}l.commutative=n;function a(c,u){for(let d of u){let p=s(c,d);p!==null&&(c=p.data)}return c}l.applyAll=a;function s(c,u){var d=c;let p=[],f=[];for(let h of u)try{if(h.type===3||h.type===5&&h.path[h.path.length-1]==="variables"){let m,y,g;if(h.type===3?(m=Je.zoom(d,[...h.path,h.id]),g=at.apply(d,{...h,type:2})):(m=Je.zoom(d,[...h.path,h.id,"value"]),g=at.apply(d,h)),g!==null){d=g.data;let[b,w]=o0(d,{[h.id]:m});d=b;for(let P=0;P<w.length;P++){let S=w[P],T=S.pop();if(typeof T=="number"){let A=[T];for(let N=P+1;N<w.length;N++){let E=w[N],M=E[E.length-1];if(typeof M=="number"&&Je.equal(S,E.slice(0,E.length-1)))A.push(M),w.splice(N,1);else break}let x=Je.zoom(d,S);y=x.map((N,E)=>A.includes(E)?h.id:N),m=x,T=S.pop()}else{if(T==="alphaOverride"||T==="alpha"){m/=100;let A=m,x=Je.zoom(d,S.slice(0,S.length-2)),N=x.layers.map(E=>E.id===S[S.length-1]?{...E,data:{...E.data,[T]:A}}:E);Object.setPrototypeOf(N,Object.getPrototypeOf(x.layers)),x.layers=N}y=h.id}p.push({type:0,path:S,props:{[T]:m}}),f.push({type:0,path:S,props:{[T]:y}})}f.push(g.reverse),p.push(g.actual)}}else{let m=at.apply(d,h);m!==null&&(p.push(m.actual),d=m.data,f.push(m.reverse))}}catch(m){if(m instanceof ia)return null;throw m}return{data:d,actual:p,reverse:f.reverse()}}l.apply=s})(ks||(ks={}));var n0=Symbol(),FA=Symbol(),Dc=Symbol(),tn=class{reportOp(t,e,r=[]){let o=this;if(e===null)return;o._current=e.data;let n=r;for(;!(o instanceof Nc);){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,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[Dc];r&&r(),delete this._children[t]}}}},gp=class extends tn{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else if(this._current instanceof We){let r={...this._current,[t]:e};this._current=Object.setPrototypeOf(r,We.prototype)}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,aa.runOp(this._current,t),t.path)}},xp=class extends tn{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,ue.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},a0={get(i,t){if(t===Dc)return()=>{i._parent=null};if(t===n0)return i._current;if(t===FA)return i;let{_current:e,_children:r}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e[t],a=_c(i,t,n);return a!==n?(r===void 0&&(r={},i._children=r),r[t]=a,a):n},has(i,t){return t in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,t){let e=i._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},jA={...a0,set(i,t,e){let r={type:0,props:{[t]:lt(e)??e}};return i.deleteChildren(t),i.runOp(r),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},UA={...a0,set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}},ca=class extends tn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Dc]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e.get(t)?.data,a=_c(this,t,n);return a!==n?(r===void 0&&(r={},this._children=r),r[t]=a,a):n}add(t,e,r,o,n){this.runOp({type:7,parent:t,fi:e,id:r,data:o,children:n})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let n=0;n<r.length;n++){let a=r[n];this.add(t,o[n],a.id,a.data,a.children)}}insertBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let n=0;n<r.length;n++){let a=r[n];this.add(t,o[n],a.id,a.data,a.children)}}moveAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let n=0;n<r.length;n++){let a=r[n];this.move(t,o[n],a)}}moveBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let n=0;n<r.length;n++){let a=r[n];this.move(t,o[n],a)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},ua=class extends tn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Dc]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id,n=this._current[r].fi;t(this.data(this._current[r].id),o,n)}}find(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id;if(t(this.data(o),o))return this.get(o)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e.get(t)?.data,a=_c(this,t,n);return a!==n?(r===void 0&&(r={},this._children=r),r[t]=a,a):n}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.add(r[o],n.id,n.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.add(r[o],n.id,n.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.move(r[o],n)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.move(r[o],n)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function yp(i,t,e){if(i.length>0){let r=i[i.length-1];if(r.type===0&&t.type===0&&Je.equal(r.path,e)){Object.assign(r.props,t.props);return}}i.push({...t,path:e})}var Nc=class extends tn{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,o){yp(this.ts,e,t),yp(this.actual,r,t),yp(this.reverse,o,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function _c(i,t,e){return e instanceof Ze?new ca(i,t,e):e instanceof xe?new ua(i,t,e):e instanceof ue?new Proxy(new xp(i,t,e),UA):e!==null&&typeof e=="object"?na(e)?e:new Proxy(new gp(i,t,e),jA):e}function bp(i){let t=new Nc(i);return[_c(t,"",i),t]}function ui(i,t){let[e,r]=bp(i);return t(e),r.result()}function lt(i){return i instanceof ca||i instanceof ua?i._current:i!==null&&typeof i=="object"?i[n0]:i}var Je;(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 t(n,a,s){let l=r(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=t;function e(n,a){if((n instanceof Ze||n instanceof ca)&&typeof a=="string")return n.data(a);if((n instanceof xe||n instanceof ua)&&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 r(n,a,s=0){for(;s<a.length&&n!==void 0;)n=e(n,a[s]),s+=1;return n}o.zoom=r})(Je||(Je={}));function s0(i,t){let e=[];if(t.length===i.length)for(var r=0;r<i.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}function Be(i,t){let e=[];if(t.length<=i.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}var Rc=class{},Hs=class extends Rc{constructor(e){super();this.id=e}},Ws=class extends Rc{constructor(e){super();this.data=e}};var Sp;try{Sp=new TextDecoder}catch{}var pe,pi,G=0;var m0=[],wp=m0,Pp=0,tr={},He,di,vr=0,ro=0,pr,_o,Yt=[],$e,l0={useRecords:!1,mapsAsObjects:!0},qs=class{},Tp=new qs;Tp.name="MessagePack 0xC1";var da=!1,oo=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(pe)return v0(()=>(Bc(),this?this.unpack(t,e):oo.prototype.unpack.call(l0,t,e)));pi=e>-1?e:t.length,G=0,Pp=0,ro=0,di=null,wp=m0,pr=null,pe=t;try{$e=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw pe=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof oo){if(tr=this,this.structures)return He=this.structures,Lc();(!He||He.length>0)&&(He=[])}else tr=l0,(!He||He.length>0)&&(He=[]);return Lc()}unpackMultiple(t,e){let r,o=0;try{da=!0;let n=t.length,a=this?this.unpack(t,n):Gc.unpack(t,n);if(e){for(e(a);G<n;)if(o=G,e(Lc())===!1)return}else{for(r=[a];G<n;)o=G,r.push(Lc());return r}}catch(n){throw n.lastPosition=o,n.values=r,n}finally{da=!1,Bc()}}_mergeStructures(t,e){t=t||[];for(let r=0,o=t.length;r<o;r++){let n=t[r];n&&(n.isShared=!0,r>=32&&(n.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let o=t[r],n=e[r];n&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[r]=o),t[r]=n)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Lc(){try{if(!tr.trusted&&!da){let t=He.sharedLength||0;t<He.length&&(He.length=t)}let i=yt();if(G==pi)He.restoreStructures&&c0(),He=null,pe=null,_o&&(_o=null);else if(G>pi){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!da)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw He.restoreStructures&&c0(),Bc(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function c0(){for(let i in He.restoreStructures)He[i]=He.restoreStructures[i];He.restoreStructures=null}function yt(){let i=pe[G++];if(i<160)if(i<128){if(i<64)return i;{let t=He[i&63]||tr.getStructures&&y0()[i&63];return t?(t.read||(t.read=Cp(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,tr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[x0()]=yt();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(yt(),yt());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=yt();return t}else if(i<192){let t=i-160;if(ro>=G)return di.slice(G-vr,(G+=t)-vr);if(ro==0&&pi<140){let e=t<16?Ap(t):g0(t);if(e!=null)return e}return Op(t)}else{let t;switch(i){case 192:return null;case 193:return pr?(t=yt(),t>0?pr[1].slice(pr.position1,pr.position1+=t):pr[0].slice(pr.position0,pr.position0-=t)):Tp;case 194:return!1;case 195:return!0;case 196:return vp(pe[G++]);case 197:return t=$e.getUint16(G),G+=2,vp(t);case 198:return t=$e.getUint32(G),G+=4,vp(t);case 199:return rn(pe[G++]);case 200:return t=$e.getUint16(G),G+=2,rn(t);case 201:return t=$e.getUint32(G),G+=4,rn(t);case 202:if(t=$e.getFloat32(G),tr.useFloat32>2){let e=zc[(pe[G]&127)<<1|pe[G+1]>>7];return G+=4,(e*t+(t>0?.5:-.5)>>0)/e}return G+=4,t;case 203:return t=$e.getFloat64(G),G+=8,t;case 204:return pe[G++];case 205:return t=$e.getUint16(G),G+=2,t;case 206:return t=$e.getUint32(G),G+=4,t;case 207:return tr.int64AsNumber?(t=$e.getUint32(G)*4294967296,t+=$e.getUint32(G+4)):t=$e.getBigUint64(G),G+=8,t;case 208:return $e.getInt8(G++);case 209:return t=$e.getInt16(G),G+=2,t;case 210:return t=$e.getInt32(G),G+=4,t;case 211:return tr.int64AsNumber?(t=$e.getInt32(G)*4294967296,t+=$e.getUint32(G+4)):t=$e.getBigInt64(G),G+=8,t;case 212:if(t=pe[G++],t==114)return h0(pe[G++]&63);{let e=Yt[t];if(e)return e.read?(G++,e.read(yt())):e.noBuffer?(G++,e()):e(pe.subarray(G,++G));throw new Error("Unknown extension "+t)}case 213:return t=pe[G],t==114?(G++,h0(pe[G++]&63,pe[G++])):rn(2);case 214:return rn(4);case 215:return rn(8);case 216:return rn(16);case 217:return t=pe[G++],ro>=G?di.slice(G-vr,(G+=t)-vr):HA(t);case 218:return t=$e.getUint16(G),G+=2,ro>=G?di.slice(G-vr,(G+=t)-vr):WA(t);case 219:return t=$e.getUint32(G),G+=4,ro>=G?di.slice(G-vr,(G+=t)-vr):qA(t);case 220:return t=$e.getUint16(G),G+=2,d0(t);case 221:return t=$e.getUint32(G),G+=4,d0(t);case 222:return t=$e.getUint16(G),G+=2,p0(t);case 223:return t=$e.getUint32(G),G+=4,p0(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var kA=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Cp(i,t){function e(){if(e.count++>2){let o=i.read=new Function("r","return function(){return {"+i.map(n=>kA.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(yt);return i.highByte===0&&(i.read=u0(t,i.read)),o()}let r={};for(let o=0,n=i.length;o<n;o++){let a=i[o];r[a]=yt()}return r}return e.count=0,i.highByte===0?u0(t,e):e}var u0=(i,t)=>function(){let e=pe[G++];if(e===0)return t();let r=i<32?-(i+(e<<5)):i+(e<<5),o=He[r]||y0()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=Cp(o,i)),o.read()};function y0(){let i=v0(()=>(pe=null,tr.getStructures()));return He=tr._mergeStructures(i,He)}var Op=Vc,HA=Vc,WA=Vc,qA=Vc;function Vc(i){let t;if(i<16&&(t=Ap(i)))return t;if(i>64&&Sp)return Sp.decode(pe.subarray(G,G+=i));let e=G+i,r=[];for(t="";G<e;){let o=pe[G++];if((o&128)===0)r.push(o);else if((o&224)===192){let n=pe[G++]&63;r.push((o&31)<<6|n)}else if((o&240)===224){let n=pe[G++]&63,a=pe[G++]&63;r.push((o&31)<<12|n<<6|a)}else if((o&248)===240){let n=pe[G++]&63,a=pe[G++]&63,s=pe[G++]&63,l=(o&7)<<18|n<<12|a<<6|s;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(o);r.length>=4096&&(t+=_t.apply(String,r),r.length=0)}return r.length>0&&(t+=_t.apply(String,r)),t}function d0(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=yt();return t}function p0(i){if(tr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[x0()]=yt();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(yt(),yt());return t}}var _t=String.fromCharCode;function g0(i){let t=G,e=new Array(i);for(let r=0;r<i;r++){let o=pe[G++];if((o&128)>0){G=t;return}e[r]=o}return _t.apply(String,e)}function Ap(i){if(i<4)if(i<2){if(i===0)return"";{let t=pe[G++];if((t&128)>1){G-=1;return}return _t(t)}}else{let t=pe[G++],e=pe[G++];if((t&128)>0||(e&128)>0){G-=2;return}if(i<3)return _t(t,e);let r=pe[G++];if((r&128)>0){G-=3;return}return _t(t,e,r)}else{let t=pe[G++],e=pe[G++],r=pe[G++],o=pe[G++];if((t&128)>0||(e&128)>0||(r&128)>0||(o&128)>0){G-=4;return}if(i<6){if(i===4)return _t(t,e,r,o);{let n=pe[G++];if((n&128)>0){G-=5;return}return _t(t,e,r,o,n)}}else if(i<8){let n=pe[G++],a=pe[G++];if((n&128)>0||(a&128)>0){G-=6;return}if(i<7)return _t(t,e,r,o,n,a);let s=pe[G++];if((s&128)>0){G-=7;return}return _t(t,e,r,o,n,a,s)}else{let n=pe[G++],a=pe[G++],s=pe[G++],l=pe[G++];if((n&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){G-=8;return}if(i<10){if(i===8)return _t(t,e,r,o,n,a,s,l);{let c=pe[G++];if((c&128)>0){G-=9;return}return _t(t,e,r,o,n,a,s,l,c)}}else if(i<12){let c=pe[G++],u=pe[G++];if((c&128)>0||(u&128)>0){G-=10;return}if(i<11)return _t(t,e,r,o,n,a,s,l,c,u);let d=pe[G++];if((d&128)>0){G-=11;return}return _t(t,e,r,o,n,a,s,l,c,u,d)}else{let c=pe[G++],u=pe[G++],d=pe[G++],p=pe[G++];if((c&128)>0||(u&128)>0||(d&128)>0||(p&128)>0){G-=12;return}if(i<14){if(i===12)return _t(t,e,r,o,n,a,s,l,c,u,d,p);{let f=pe[G++];if((f&128)>0){G-=13;return}return _t(t,e,r,o,n,a,s,l,c,u,d,p,f)}}else{let f=pe[G++],h=pe[G++];if((f&128)>0||(h&128)>0){G-=14;return}if(i<15)return _t(t,e,r,o,n,a,s,l,c,u,d,p,f,h);let m=pe[G++];if((m&128)>0){G-=15;return}return _t(t,e,r,o,n,a,s,l,c,u,d,p,f,h,m)}}}}}function vp(i){return tr.copyBuffers?Uint8Array.prototype.slice.call(pe,G,G+=i):pe.subarray(G,G+=i)}function rn(i){let t=pe[G++];if(Yt[t])return Yt[t](pe.subarray(G,G+=i));throw new Error("Unknown extension type "+t)}var f0=new Array(4096);function x0(){let i=pe[G++];if(i>=160&&i<192){if(i=i-160,ro>=G)return di.slice(G-vr,(G+=i)-vr);if(!(ro==0&&pi<180))return Op(i)}else return G--,yt();let t=(i<<5^(i>1?$e.getUint16(G):i>0?pe[G]:0))&4095,e=f0[t],r=G,o=G+i-3,n,a=0;if(e&&e.bytes==i){for(;r<o;){if(n=$e.getUint32(r),n!=e[a++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(n=pe[r++],n!=e[a++]){r=1879048192;break}if(r===o)return G=r,e.string;o-=3,r=G}for(e=[],f0[t]=e,e.bytes=i;r<o;)n=$e.getUint32(r),e.push(n),r+=4;for(o+=3;r<o;)n=pe[r++],e.push(n);let s=i<16?Ap(i):g0(i);return s!=null?e.string=s:e.string=Op(i)}var h0=(i,t)=>{var e=yt();let r=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let o=He[i];return o&&o.isShared&&((He.restoreStructures||(He.restoreStructures=[]))[i]=o),He[i]=e,e.read=Cp(e,r),e.read()},b0=typeof self=="object"?self:global;Yt[0]=()=>{};Yt[0].noBuffer=!0;Yt[101]=()=>{let i=yt();return(b0[i[0]]||Error)(i[1])};Yt[105]=i=>{let t=$e.getUint32(G-4);_o||(_o=new Map);let e=pe[G],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let o={target:r};_o.set(t,o);let n=yt();return o.used?Object.assign(r,n):(o.target=n,n)};Yt[112]=i=>{let t=$e.getUint32(G-4),e=_o.get(t);return e.used=!0,e.target};Yt[115]=()=>new Set(yt());var Mp=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");Yt[116]=i=>{let t=i[0],e=Mp[t];if(!e)throw new Error("Could not find typed array for code "+t);return new b0[e](Uint8Array.prototype.slice.call(i,1).buffer)};Yt[120]=()=>{let i=yt();return new RegExp(i[0],i[1])};Yt[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=G;G+=t-4,pr=[yt(),yt()],pr.position0=0,pr.position1=0;let r=G;G=e;try{return yt()}finally{G=r}};Yt[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 v0(i){let t=pi,e=G,r=Pp,o=vr,n=ro,a=di,s=wp,l=_o,c=pr,u=new Uint8Array(pe.slice(0,pi)),d=He,p=He.slice(0,He.length),f=tr,h=da,m=i();return pi=t,G=e,Pp=r,vr=o,ro=n,di=a,wp=s,_o=l,pr=c,pe=u,da=h,He=d,He.splice(0,He.length,...p),tr=f,$e=new DataView(pe.buffer,pe.byteOffset,pe.byteLength),m}function Bc(){pe=null,_o=null,He=null}function S0(i){i.unpack?Yt[i.type]=i.unpack:Yt[i.type]=i}var zc=new Array(147);for(let i=0;i<256;i++)zc[i]=+("1e"+Math.floor(45.15-i*.30103));var Gc=new oo({useRecords:!1}),$A=Gc.unpack,XA=Gc.unpackMultiple,YA=Gc.unpack,Fc={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},KA=new Float32Array(1),n5=new Uint8Array(KA.buffer,0,4);var jc;try{jc=new TextEncoder}catch{}var Uc,Ep,kc=typeof Buffer<"u",Ip=kc?Buffer.allocUnsafeSlow:Uint8Array,T0=kc?Buffer:Uint8Array,w0=kc?4294967296:2144337920,X,xt,k=0,io,no=null,QA=/[\u0080-\uFFFF]/,$s=Symbol("record-id"),on=class extends oo{constructor(t){super(t),this.offset=0;let e,r,o,n,a,s,l=0,c=T0.prototype.utf8Write?function(x,N,E){return X.utf8Write(x,N,E)}:jc&&jc.encodeInto?function(x,N){return jc.encodeInto(x,X.subarray(N)).written}:!1,u=this;t||(t={});let d=t&&t.sequential,p=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=p?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let h=t.maxOwnStructures;h==null&&(h=p?32:64),d&&!t.saveStructures&&(this.structures=[]);let m=f>32||h+f>64,y=f+64,g=f+h+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let b=[],w=0,P=0;this.pack=this.encode=function(x,N){if(X||(X=new Ip(8192),xt=new DataView(X.buffer,0,8192),k=0),io=X.length-10,io-k<2048?(X=new Ip(X.length),xt=new DataView(X.buffer,0,X.length),io=X.length-10,k=0):k=k+7&2147483640,r=k,s=u.structuredClone?new Map:null,u.bundleStrings?(no=["",""],X[k++]=214,X[k++]=98,no.position=k-r,k+=4):no=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 M=0;M<E;M++){let D=o[M];if(!D)continue;let _,R=o.transitions;for(let V=0,U=D.length;V<U;V++){let B=D[V];_=R[B],_||(_=R[B]=Object.create(null)),R=_}R[$s]=M+64}l=E}d||(o.nextId=E+64)}n&&(n=!1),a=o||[];try{if(S(x),no){xt.setUint32(no.position+r,k-no.position-r);let E=no;no=null,S(E[0]),S(E[1])}if(u.offset=k,s&&s.idsToInsert){k+=s.idsToInsert.length*6,k>io&&A(k),u.offset=k;let E=JA(X.subarray(r,k),s.idsToInsert);return s=null,E}return N&A0?(X.start=r,X.end=k,X):X.subarray(r,k)}finally{if(o){if(P<10&&P++,w>1e4)o.transitions=null,P=0,w=0,b.length>0&&(b=[]);else if(b.length>0&&!d){for(let E=0,M=b.length;E<M;E++)b[E][$s]=0;b=[]}if(n&&u.saveStructures){let E=o.sharedLength||f;o.length>E&&(o=o.slice(0,E));let M=X.subarray(r,k);return u.saveStructures(o,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(x)):(l=E,M)}}N&aM&&(k=r)}};let S=x=>{k>io&&(X=A(k));var N=typeof x,E;if(N==="string"){let M=x.length;if(no&&M>=8&&M<4096){let R=QA.test(x);no[R?0:1]+=x,X[k++]=193,S(R?-M:M);return}let D;M<32?D=1:M<256?D=2:M<65536?D=3:D=5;let _=M*3;if(k+_>io&&(X=A(k+_)),M<64||!c){let R,V,U,B=k+D;for(R=0;R<M;R++)V=x.charCodeAt(R),V<128?X[B++]=V:V<2048?(X[B++]=V>>6|192,X[B++]=V&63|128):(V&64512)===55296&&((U=x.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-D}else E=c(x,k+D,_);E<32?X[k++]=160|E:E<256?(D<2&&X.copyWithin(k+2,k+1,k+1+E),X[k++]=217,X[k++]=E):E<65536?(D<3&&X.copyWithin(k+3,k+2,k+2+E),X[k++]=218,X[k++]=E>>8,X[k++]=E&255):(D<5&&X.copyWithin(k+5,k+3,k+3+E),X[k++]=219,xt.setUint32(k,E),k+=4),k+=E}else if(N==="number")if(x>>>0===x)x<64?X[k++]=x:x<256?(X[k++]=204,X[k++]=x):x<65536?(X[k++]=205,X[k++]=x>>8,X[k++]=x&255):(X[k++]=206,xt.setUint32(k,x),k+=4);else if(x>>0===x)x>=-32?X[k++]=256+x:x>=-128?(X[k++]=208,X[k++]=x+256):x>=-32768?(X[k++]=209,xt.setInt16(k,x),k+=2):(X[k++]=210,xt.setInt32(k,x),k+=4);else{let M;if((M=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){X[k++]=202,xt.setFloat32(k,x);let D;if(M<4||(D=x*zc[(X[k]&127)<<1|X[k+1]>>7])>>0===D){k+=4;return}else k--}X[k++]=203,xt.setFloat64(k,x),k+=8}else if(N==="object")if(!x)X[k++]=192;else{if(s){let D=s.get(x);if(D){if(!D.id){let _=s.idsToInsert||(s.idsToInsert=[]);D.id=_.push(D)}X[k++]=214,X[k++]=112,xt.setUint32(k,D.id),k+=4;return}else s.set(x,{offset:k-r})}let M=x.constructor;if(M===Object)T(x,!0);else if(M===Array){E=x.length,E<16?X[k++]=144|E:E<65536?(X[k++]=220,X[k++]=E>>8,X[k++]=E&255):(X[k++]=221,xt.setUint32(k,E),k+=4);for(let D=0;D<E;D++)S(x[D])}else if(M===Map){E=x.size,E<16?X[k++]=128|E:E<65536?(X[k++]=222,X[k++]=E>>8,X[k++]=E&255):(X[k++]=223,xt.setUint32(k,E),k+=4);for(let[D,_]of x)S(D),S(_)}else{for(let D=0,_=Uc.length;D<_;D++){let R=Ep[D];if(x instanceof R){let V=Uc[D];if(V.write){V.type&&(X[k++]=212,X[k++]=V.type,X[k++]=0),S(V.write.call(this,x));return}let U=X,B=xt,q=k;X=null;let j;try{j=V.pack.call(this,x,F=>(X=U,U=null,k+=F,k>io&&A(k),{target:X,targetView:xt,position:k-F}),S)}finally{U&&(X=U,xt=B,k=q,io=X.length-10)}j&&(j.length+k>io&&A(j.length+k),k=ZA(j,X,k,V.type));return}}T(x,!x.hasOwnProperty)}}else if(N==="boolean")X[k++]=x?195:194;else if(N==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))X[k++]=211,xt.setBigInt64(k,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)X[k++]=207,xt.setBigUint64(k,x);else if(this.largeBigIntToFloat)X[k++]=203,xt.setFloat64(k,Number(x));else throw new RangeError(x+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");k+=8}else if(N==="undefined")this.encodeUndefinedAsNil?X[k++]=192:(X[k++]=212,X[k++]=0,X[k++]=0);else if(N==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+N)},T=this.useRecords===!1?this.variableMapSize?x=>{let N=Object.keys(x),E=N.length;E<16?X[k++]=128|E:E<65536?(X[k++]=222,X[k++]=E>>8,X[k++]=E&255):(X[k++]=223,xt.setUint32(k,E),k+=4);let M;for(let D=0;D<E;D++)S(M=N[D]),S(x[M])}:(x,N)=>{X[k++]=222;let E=k-r;k+=2;let M=0;for(let D in x)(N||x.hasOwnProperty(D))&&(S(D),S(x[D]),M++);X[E+++r]=M>>8,X[E+r]=M&255}:x=>{let N=Object.keys(x),E,M=a.transitions||(a.transitions=Object.create(null)),D=0;for(let R=0,V=N.length;R<V;R++){let U=N[R];E=M[U],E||(E=M[U]=Object.create(null),D++),M=E}let _=M[$s];if(_)_>=96&&m?(X[k++]=((_-=96)&31)+96,X[k++]=_>>5):X[k++]=_;else{_=a.nextId,_||(_=64),_<y&&this.shouldShareStructure&&!this.shouldShareStructure(N)?(_=a.nextOwnId,_<g||(_=y),a.nextOwnId=_+1):(_>=g&&(_=y),a.nextId=_+1);let R=N.highByte=_>=96&&m?_-96>>5:-1;M[$s]=_,a[_-64]=N,_<y?(N.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++]=_),D&&(w+=P*D),b.length>=h&&(b.shift()[$s]=0),b.push(M),S(N))}for(let R=0,V=N.length;R<V;R++)S(x[N[R]])},A=x=>{let N;if(x>16777216){if(x-r>w0)throw new Error("Packed buffer would be larger than maximum buffer size");N=Math.min(w0,Math.round(Math.max((x-r)*(x>67108864?1.25:2),4194304)/4096)*4096)}else N=(Math.max(x-r<<2,X.length-1)>>12)+1<<12;let E=new Ip(N);return xt=new DataView(E.buffer,0,N),X.copy?X.copy(E,0,r,x):E.set(X.slice(r,x)),k-=r,r=0,io=E.length-10,X=E}}useBuffer(t){X=t,xt=new DataView(X.buffer,X.byteOffset,X.byteLength),k=0}};Ep=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,qs];Uc=[{pack(i,t,e){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:n,position:a}=t(6);o[a++]=214,o[a++]=255,n.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:o,targetView:n,position:a}=t(10);o[a++]=215,o[a++]=255,n.setUint32(a,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),n.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:o,targetView:n,position:a}=t(3);o[a++]=212,o[a++]=255,o[a++]=255}else{let{target:o,targetView:n,position:a}=t(15);o[a++]=199,o[a++]=12,o[a++]=255,n.setUint32(a,i.getMilliseconds()*1e6),n.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(i,t,e){let r=Array.from(i),{target:o,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(o[n++]=212,o[n++]=115,o[n++]=0),e(r)}},{pack(i,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=101,r[o++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=120,r[o++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?P0(i,16,t):O0(kc?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==T0&&this.structuredClone?P0(i,Mp.indexOf(e.name),t):O0(i,t)}},{pack(i,t){let{target:e,position:r}=t(1);e[r]=193}}];function P0(i,t,e,r){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++]=t,n.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),a)}function O0(i,t){let e=i.byteLength;var r,o;if(e<256){var{target:r,position:o}=t(e+2);r[o++]=196,r[o++]=e}else if(e<65536){var{target:r,position:o}=t(e+3);r[o++]=197,r[o++]=e>>8,r[o++]=e&255}else{var{target:r,position:o,targetView:n}=t(e+5);r[o++]=198,n.setUint32(o,e),o+=4}r.set(i,o)}function ZA(i,t,e,r){let o=i.length;switch(o){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:o<256?(t[e++]=199,t[e++]=o):o<65536?(t[e++]=200,t[e++]=o>>8,t[e++]=o&255):(t[e++]=201,t[e++]=o>>24,t[e++]=o>>16&255,t[e++]=o>>8&255,t[e++]=o&255)}return t[e++]=r,t.set(i,e),e+=o,e}function JA(i,t){let e,r=t.length*6,o=i.length-r;for(t.sort((n,a)=>n.offset>a.offset?1:-1);e=t.pop();){let n=e.offset,a=e.id;i.copyWithin(n+r,n,o),r-=6;let s=n+r;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 fi(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)");Ep.unshift(i.Class),Uc.unshift(i)}S0(i)}var C0=new on({useRecords:!1}),eM=C0.pack,tM=C0.pack;var{NEVER:rM,ALWAYS:oM,DECIMAL_ROUND:iM,DECIMAL_FIT:nM}=Fc,A0=512,aM=1024;var M0=new on({structuredClone:!0});fi({Class:ue.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,ue.prototype),i}});fi({Class:xe.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,xe.prototype),i}});fi({Class:Ze.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Ze.prototype),i}});fi({Class:Hs.prototype.constructor,type:4,write(i){return i.id},read(i){return new Hs(i)}});fi({Class:Ws.prototype.constructor,type:5,write(i){return i.data},read(i){return new Ws(i)}});fi({Class:We.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,We.prototype),i}});function sM(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let r=i[e];t=(t<<5)-t+r,t=t&t}return t}function Np(i){if(na(i))return i;if(Array.isArray(i))return i.map(Np);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=Np(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var Hc;(r=>{function i(o){return M0.pack(o)}r.serialize=i;function t(o){return M0.unpack(o)}r.deserialize=t;function e(o){return sM(i(Np(o))).toString()}r.checksum=e})(Hc||(Hc={}));var yi="personal camera",gi="a218fcc3-276b-49b9-b485-49037fd14f5f",R0=2960946;var bt=5526619;var pa;(f=>{function i(h,m){return h[0]===m[0]&&h[1]===m[1]}f.isEqual=i;function t(h,m,y){return[h[0]+(m[0]-h[0])*y,h[1]+(m[1]-h[1])*y]}f.lerp=t;function e(h,m){return[h[0]+m[0],h[1]+m[1]]}f.add=e;function r(h,m){return[h[0]-m[0],h[1]-m[1]]}f.sub=r;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 g=f.sub(m,h),b=f.sub(y,h),w=f.dot(g,b)/f.dot(g,g),P=f.scalarMultiply(g,w);return f.add(h,P)}f.projectionOnto=u;function d(h,m,y){return s(h,u(h,m,y))}f.projectionOntoDistance=d;function p(h,m){return[(h[0]+m[0])*.5,(h[1]+m[1])*.5]}f.center=p})(pa||(pa={}));var hi;(s=>{function i(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}s.isEqual=i;function t(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]}s.add=t;function e(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]}s.sub=e;function r(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]}s.div=r;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})(hi||(hi={}));var I0;(e=>{function i(r,o){return r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]}e.isEqual=i;function t(r,o,n){return[r[0]+(o[0]-r[0])*n,r[1]+(o[1]-r[1])*n,r[2]+(o[2]-r[2])*n,r[3]+(o[3]-r[3])*n]}e.lerp=t})(I0||(I0={}));var E0;(a=>{let i=180/Math.PI,t=Math.PI/180;function e(s){return typeof s=="number"?s*i:s}function r(s){return typeof s=="number"?s*t:s}function o(s){return[e(s[0]),e(s[1]),e(s[2])]}a.radToDeg=o;function n(s){return[r(s[0]),r(s[1]),r(s[2])]}a.degToRad=n})(E0||(E0={}));var mi;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(n,a){for(let s=0;s<16;s++)if(n[s]!==a[s])return!1;return!0}o.isEqual=t;function e(n){return n??o.identity}o.simplify=e;function r(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=r})(mi||(mi={}));var Pt;(p=>{function i(f){return typeof f=="object"&&typeof f.r=="number"&&typeof f.g=="number"&&typeof f.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(f){return{r:Math.round(f.r*255),g:Math.round(f.g*255),b:Math.round(f.b*255),a:1}}p.toRgb255a1=o;function n(f){return{r:f.r,g:f.g,b:f.b}}p.clone=n;function a(f){return f=Math.floor(f),{r:(f>>16&255)/255,g:(f>>8&255)/255,b:(f&255)/255}}p.fromHex=a;function s(f){return Math.round(f.r*255)*65536+Math.round(f.g*255)*256+Math.round(f.b*255)}p.toHex=s;function l(f,h){return f.r===h.r&&f.g===h.g&&f.b===h.b}p.equals=l;function c(f,h){return f.r.toFixed(2)===h.r.toFixed(2)&&f.g.toFixed(2)===h.g.toFixed(2)&&f.b.toFixed(2)===h.b.toFixed(2)}p.equalsFixed=c;function u(f,h,m){return{r:f.r+(h.r-f.r)*m,g:f.g+(h.g-f.g)*m,b:f.b+(h.b-f.b)*m}}p.lerp=u;function d(f){return mt(f)?"r"in f&&"g"in f&&"b"in f&&!("a"in f):!1}p.is=d})(Pt||(Pt={}));var Ee;(u=>{u.white={...Pt.white,a:1};function t(d){return mt(d)?"r"in d&&"g"in d&&"b"in d&&"a"in d:!1}u.is=t,u.transparent={...Pt.white,a:0};function r(d){return{r:d[0],g:d[1],b:d[2],a:d[3]}}u.from0to1=r;function o(d,p){return{...Pt.fromHex(d),a:p}}u.fromHexAndA=o;function n(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:d.a}}u.toRgb255a1=n;function a(d,p){return Pt.equals(d,p)&&d.a===p.a}u.equals=a;function s(d,p){return Pt.equalsFixed(d,p)&&d.a.toFixed(2)===p.a.toFixed(2)}u.equalsFixed=s;function l(d,p,f){return{r:d.r+(p.r-d.r)*f,g:d.g+(p.g-d.g)*f,b:d.b+(p.b-d.b)*f,a:d.a+(p.a-d.a)*f}}u.lerp=l;function c({r:d,g:p,b:f,a:h}=u.white){return`rgba(${d*255}, ${p*255}, ${f*255}, ${h})`}u.toStyle=c})(Ee||(Ee={}));var Wc;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]})(Wc||(Wc={}));var N0;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(N0||(N0={}));var D0;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(D0||(D0={}));var _0;(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]))(_0||(_0={}));function Dp(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 Lr;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(Lr||(Lr={}));var xi;(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 r(n){return n.type==="PerspectiveCamera"?n.perspective?.zoom??1:n.orthographic?.zoom??1}o.getZoom=r})(xi||(xi={}));var ao;(r=>{function i(o,n=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(typeof o[0]=="number"?o[0]:1,typeof o[1]=="number"?o[1]:1)*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0],pivot:[0,0,0],pivotRotation:[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",pivot:[0,0,0],pivotRotation:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[(typeof o[0]=="number"?o[0]+o[0]:1)*n,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:o.map(a=>(typeof a=="number"?a:1)*(1+n)),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"}}}r.defaultData=i;function t(o,n){let a={...o};if(lM.forEach(s=>{Object.assign(a,{[s]:n[s]??o[s]})}),a.radial={...o.radial},n.radial){let s=o.radial,l=n.radial;cM.forEach(c=>{Object.assign(a.radial,{[c]:l[c]??s[c]})})}if(a.linear={...o.linear},n.linear){let s=o.linear,l=n.linear;uM.forEach(c=>{Object.assign(a.linear,{[c]:l[c]??s[c]})})}if(a.grid={...o.grid},n.grid){let s=o.grid,l=n.grid;dM.forEach(c=>{Object.assign(a.grid,{[c]:l[c]??s[c]})})}if(a.toObject={...o.toObject},n.toObject){let s=o.toObject,l=n.toObject;pM.forEach(c=>{Object.assign(a.toObject,{[c]:l[c]??s[c]})})}if(a.randomnessObject={...o.randomnessObject},n.randomnessObject){let s=o.randomnessObject,l=n.randomnessObject;fM.forEach(c=>{Object.assign(a.randomnessObject,{[c]:l[c]??s[c]})})}return a}r.merge=t;function e(o){return!!(o.randomnessObject||o.toObject)}r.isPartial=e})(ao||(ao={}));var qc;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["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 t){let l=o[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...n,s],props:l})}return a}r.toOps=e})(qc||(qc={}));var lM=["count"],cM=["radius","start","end","position","scale","rotation"],uM=["position","scale","rotation"],dM=["count","size"],pM=["count","position","scale","rotation"],fM=["strength","scale","rotation","position","movement","seed","freqScale"];var $c;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})($c||($c={}));var Xc;(e=>{function i(r){return t(r)}e.defaultData=i;function t(r){if(r==="PointLight")return{type:r,color:Ee.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Ee.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(r==="DirectionalLight")return{type:r,color:Ee.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Xc||(Xc={}));var fa;(r=>(r.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},r.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},r.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:r.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...r.defaultCollisionData}))(fa||(fa={}));var bi;(t=>t.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]})(bi||(bi={}));var _p;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}e.equals=t})(_p||(_p={}));var Rp;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,o){return r.flatShading===o.flatShading&&r.side===o.side&&r.wireframe===o.wireframe}e.equals=t})(Rp||(Rp={}));var Yc;(t=>t.defaultData={...Rp.defaultData,..._p.defaultData})(Yc||(Yc={}));var L0;(t=>{function i(e,r){let o=[];if("material"in e){let n=typeof e.material=="string"?r.materials[e.material]??r.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"?r.materials[n]??r.lib.materials[n]?.asset:n;a&&o.push(a)}return o}t.getMaterialData=i})(L0||(L0={}));var ha;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(ha||(ha={}));var B0;(t=>{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"}t.is=i})(B0||(B0={}));function z0(i){return i.type!=="displace"}var V0;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(V0||(V0={}));var G0=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],F0=["wrapping","image","video","name","minFilter","magFilter"],gt;(n=>{function i(a,s){let{texture:l,...c}=s;if(Object.assign(a,c),l){let u=a.texture;u&&Object.assign(u,l)}}n.patch=i;function t(a){return{...n.defaultData("color"),color:a}}n.defaultColorLayer=t;function e(a,s){return a==="light"&&s?r(s):o(a)}n.defaultData=e;function r(a){let s={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(a){case"phong":return{...s,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...s,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...s,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...s,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function o(a){let s={alpha:1,mode:0,isMask:!1,visible:!0};switch(a){case"texture":return{...s,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{...s,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:ha.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...s,type:"color",color:Pt.fromHex(bt)};case"depth":return{...s,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{...s,type:"normal",cnormal:[1,1,1]};case"gradient":return{...s,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{...s,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Pt.fromHex(6710886),a:1},colorB:{...Pt.fromHex(6710886),a:1},colorC:{...Pt.fromHex(16777215),a:1},colorD:{...Pt.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{...s,type:"fresnel",color:Ee.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...s,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...s,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:Ee.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...s,type:"outline",outlineColor:Ee.fromHexAndA(0,1),contourColor:Ee.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{...s,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...s,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{...s,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Pt.fromHex(0),a:1},colorB:{...Pt.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(gt||(gt={}));var At;(u=>{function i(d){return!d.layers.some(f=>f.data.type==="texture"&&f.data.projection!==0||f.data.type==="depth"&&!f.data.isWorldSpace||f.data.type==="noise"||f.data.type==="displace")}u.isMergable=i;function t(d){let p="";return d.layers.forEach(f=>{Object.entries(f.data).forEach(([h,m])=>{p+=`${h}${m}`,Array.isArray(m)?m.forEach(y=>p+=`${y}`):typeof m=="object"?Object.values(m).forEach(y=>{typeof y=="number"?p+=`${y.toFixed(4)}`:p+=`${y}`}):p+=`${m}`})}),p}u.getHash=t;function e(){return{layers:new xe}}u.defaultEmptyData=e;function r(d="layer1",p="layer2"){return n("phong",d,p)}u.defaultData=r;function o(d,p){return{...d,name:p}}u.withName=o;function n(d,p="layer1",f="layer2",h=Pt.fromHex(16777215)){let m=new xe;return m.push({fi:0,data:gt.defaultData("light",d),id:p}),m.push({fi:1,data:gt.defaultData("color"),id:f}),{layers:m}}u.defaultTwoLayerData=n;function a(d,p,f="layer1",h="layer2"){let m=new xe;return m.push({fi:0,data:gt.defaultData("light",p),id:f}),m.push({fi:1,data:gt.defaultColorLayer(d),id:h}),{layers:m}}u.defaultColorMaterial=a;function s(d){let p=gt.defaultData("texture");d&&Object.assign(p.texture,{image:d});let f=new xe;return f.push({fi:0,data:p,id:"layer1"}),f.push({fi:1,data:{...gt.defaultData("transmission"),alpha:1},id:"layer2"}),f.push({fi:2,data:{...gt.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:f}}u.defaultUIObjectMaterial=s;function l(d,p="phong",f="layer1",h="layer2"){let m=gt.defaultData("texture");Object.assign(m.texture,{image:d});let y=new xe;return y.push({fi:0,data:m,id:f}),y.push({fi:1,data:gt.defaultData("light",p),id:h}),{layers:y}}u.defaultTwoLayerTextureData=l;function c(d,p="phong",f="layer1",h="layer2"){let m=gt.defaultData("video");Object.assign(m.texture,{video:d});let y=new xe;return y.push({fi:0,data:m,id:f}),y.push({fi:1,data:gt.defaultData("light",p),id:h}),{layers:y}}u.defaultTwoLayerVideoTextureData=c})(At||(At={}));var ma;(t=>{function i(){return{points:new xe,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(ma||(ma={}));var ya;(t=>{function i(){return{points:new xe,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}}t.defaultData=i})(ya||(ya={}));var nn={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Kc;(t=>{function i(e,r){let o={...e};return hM.forEach(n=>{Object.assign(o,{[n]:r[n]??e[n]})}),o}t.merge=i})(Kc||(Kc={}));var Qc={shape:nn,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},hM=["depth","offset","angle","twist","startScale","endScale"];var Xs;(r=>{function i(o){return o==="PolygonGeometry"||o==="RectangleGeometry"||o==="StarGeometry"||o==="TriangleGeometry"||o==="EllipseGeometry"||o==="UIGeometry"}r.is2DParametricMesh=i;function t(o){return o==="PolygonGeometry"||o==="RectangleGeometry"||o==="StarGeometry"||o==="TriangleGeometry"||o==="EllipseGeometry"||o==="PathGeometry"||o==="VectorGeometry"||o==="ConeGeometry"||o==="CubeGeometry"||o==="CylinderGeometry"||o==="DodecahedronGeometry"||o==="HelixGeometry"||o==="IcosahedronGeometry"||o==="LatheGeometry"||o==="PyramidGeometry"||o==="SphereGeometry"||o==="PlaneGeometry"||o==="BackdropGeometry"||o==="TorusGeometry"||o==="TorusKnotGeometry"||o==="BooleanGeometry"||o==="TextGeometry"||o==="InputGeometry"}r.isParametricMesh=t;function e(o){return o==="PolygonGeometry"||o==="RectangleGeometry"||o==="StarGeometry"||o==="TriangleGeometry"||o==="EllipseGeometry"||o==="PathGeometry"||o==="VectorGeometry"||o==="ConeGeometry"||o==="CubeGeometry"||o==="CylinderGeometry"||o==="DodecahedronGeometry"||o==="HelixGeometry"||o==="IcosahedronGeometry"||o==="LatheGeometry"||o==="PyramidGeometry"||o==="SphereGeometry"||o==="PlaneGeometry"||o==="BackdropGeometry"||o==="TorusGeometry"||o==="TorusKnotGeometry"||o==="TextGeometry"||o==="SubdivGeometry"||o==="NonParametricGeometry"}r.isSwappableGeometry=e})(Xs||(Xs={}));var Zc;(t=>{function i(e,r){let o={...e};return Object.assign(o,r),o.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(o.extrusion={...e.extrusion},Object.assign(o.extrusion,Kc.merge(o.extrusion,r.extrusion))),o}t.merge=i})(Zc||(Zc={}));var so;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};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:ya.defaultData(),extrusion:Qc};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:ma.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{...t.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")}t.defaultData=i})(so||(so={}));var Jc;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:Pt.white,near:.1,far:2e3})(Jc||(Jc={}));var eu;(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}}})(eu||(eu={}));var Lp;(t=>t.defaultData={softShadowQuality:"low"})(Lp||(Lp={}));var Bp;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Bp||(Bp={}));var Vp;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Vp||(Vp={}));var Ys;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Ys||(Ys={}));var zp;(t=>t.defaultData={playCamera:yi,gameControlObject:null})(zp||(zp={}));var tu;(t=>t.defaultData={backgroundColor:Ee.fromHexAndA(R0,1),postprocessing:eu.defaultData,fog:Jc.defaultData,globalPhysics:Ys.defaultData,ambient:Bp.defaultData,ao:Vp.defaultData,shadow:Lp.defaultData,publish:zp.defaultData})(tu||(tu={}));var ru;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(ru||(ru={}));var j0;(e=>{function i(r){return r==="Component"||r==="Instance"}e.isComponentRelated=i;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(j0||(j0={}));var ga;(o=>{o.identity={...Wc.identity,hiddenMatrix:mi.identity};function t(n){return{position:n.position,rotation:n.rotation,scale:n.scale,pivot:n.pivot,pivotRotation:n.pivotRotation,hiddenMatrix:n.hiddenMatrix}}o.fromObject=t;function e(n,a){return{position:a?.position||n.position,rotation:a?.rotation||n.rotation,pivot:a?.pivot||n.pivot,pivotRotation:a?.pivotRotation||n.pivotRotation,scale:a?.scale||n.scale,hiddenMatrix:a?.hiddenMatrix||n.hiddenMatrix}}o.merge=e;function r(n,a){return Jl({position:hi.isEqual(n.position,a.position)?void 0:a.position,rotation:hi.isEqual(n.rotation,a.rotation)?void 0:a.rotation,scale:hi.isEqual(n.scale,a.scale)?null:a.scale,hiddenMatrix:mi.isEqual(n.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=r})(ga||(ga={}));var vt;(t=>t.defaultData={states:new xe,events:new xe,timelineAnimations:new ue,visible:!0,raycastLock:!1,physics:bi.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...ga.identity,cloner:null})(vt||(vt={}));var ou;(t=>t.defaultData={type:"Empty",...vt.defaultData})(ou||(ou={}));var U0;(t=>t.defaultData={type:"ParticleCollider",...ru.defaultData,...vt.defaultData})(U0||(U0={}));var k0;(t=>t.defaultData={type:"Component",...vt.defaultData})(k0||(k0={}));var H0;(t=>t.defaultData={type:"Particle",...vt.defaultData,...fa.defaultData})(H0||(H0={}));var Ro;(t=>t.defaultData={type:"Mesh",...vt.defaultData,...Yc.defaultData})(Ro||(Ro={}));var an;(t=>t.defaultData={...vt.defaultData,...ga.identity,position:[0,0,xi.DefaultTargetOffset],...xi.defaultData})(an||(an={}));var iu;(e=>{function i(r){return{...vt.defaultData,...Xc.defaultData(r)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(iu||(iu={}));var xa;(e=>{function i(r,o,n=0){for(;n<o.length;){let a=r?r[o[n]]:void 0;if(o.length===n+1)return a;if(a)r=a.descendants,n+=1;else return}}e.resolveWithDes=i;function t(r,o,n=0){let a=i(r,o,n);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=t})(xa||(xa={}));var lo;(n=>{n.rootOverrideProps=["physics","events"],n.compositeNonOptionalOverrideProps=["geometry"],n.compositeEntireOverrideOverrideProps=["material"];function r(a,s){return{...vt.defaultData,...s,component:a,overrides:new We,physics:void 0,events:void 0,type:"Instance"}}n.ofComponent=r;function o(a){let s=ga.fromObject(a.data);return r(a.id,s)}n.fromComponentData=o})(lo||(lo={}));var Lo;(e=>{e.defaultData={type:"Page",...vt.defaultData,physics:{...bi.defaultData,fusedBody:!1},...tu.defaultData,camera:an.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(Lo||(Lo={}));var nu;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:mi.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:bi.defaultData,states:new xe,events:new xe,timelineAnimations:new ue,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...xi.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",...vt.defaultData,...Ro.defaultData,geometry:so.defaultData("RectangleGeometry"),material:At.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...vt.defaultData,...Ro.defaultData,geometry:so.defaultData("BooleanGeometry"),material:At.defaultTwoLayerData("phong","layer1","layer2")},s.defaultShapeBlendObject={name:"Shape Blend",...vt.defaultData,...Ro.defaultData,geometry:so.defaultData("ShapeBlendGeometry"),material:At.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...vt.defaultData,...Ro.defaultData,geometry:so.defaultData("TextGeometry"),material:At.defaultTwoLayerData("phong","layer1","layer2")},s.defaultInputObject={name:"Input",...vt.defaultData,...Ro.defaultData,geometry:so.defaultData("InputGeometry"),material:At.defaultTwoLayerData("phong","layer1","layer2")}))(nu||(nu={}));var sn;(o=>{function i(n,a){let s={name:a};return n.type==="Mesh"?(s.geometry={},"material"in n&&(s.material={layers:new We}),"materials"in n&&(s.materials=n.materials.map(l=>({layers:new We})))):Lr.is(n.type)&&(s.perspective={},s.orthographic={}),s}o.newEmpty=i;function t(n,a){if(a===void 0)return n;let s={...n};return"material"in s&&"material"in a&&a.material&&(s.material=ui(s.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(a.material.layers)){let d=l.layers.data(c);d&>.patch(d,u)}}).data),s.materials&&a.materials&&(s.materials=ui(s.materials,l=>{for(let c=0;c<s.materials.length;c++){let u=a.materials[c];if(typeof u!="string")for(let[d,p]of Object.entries(u.layers)){let f=l[c]?.layers?.data(d);f&>.patch(f,p)}}}).data),s}function e(n,a){let s,l=[],c={orthographic:0,perspective:0,geometry:0};function u(d,p){for(let[f,h]of Object.entries(p.layers)){let{texture:m,...y}=h;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...d,"layers",f,"texture"],props:m,type:0};l.push(g)}if(Object.keys(y).length>0){let g={path:[...d,"layers",f],props:y,type:0};l.push(g)}}}for(let[d,p]of Object.entries(a))if(d!=="name")if(d==="cloner")l.push(...qc.toOps(p,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:p.slide,offset:p.offset},type:0});else if(d==="material")u(["material"],p);else if(d==="materials")for(let[f,h]of Object.entries(p))u(["materials",f],h);else if(c[d]===0){if(d==="geometry"&&p.extrusion!==void 0){let f={path:[d,"extrusion"],props:p.extrusion,type:0};l.push(f),p={...p},delete p.extrusion}if(Object.keys(p).length>0){let f={path:[d],props:p,type:0};l.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[d]=p;return l}o.toOps=e;function r(n,a){if(a===void 0)return n;let s={...n};if(Object.assign(s,ga.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})}),Lr.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:Zc.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=t(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:ao.merge(s.cloner,a.cloner)});else if(n.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:ao.merge(s.cloner,a.cloner)});else if($c.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=Pt.clone(l.color))}return s}o.patch=r})(sn||(sn={}));var ba;(t=>t.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,rotationSpeed:1,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})(ba||(ba={}));var wr;(t=>t.defaultData={orbitControls:ba.defaultData,playPage:gi,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let o=0,n=0;return r<5?n=-30:r<10&&(n=30),r===0||r===10||r===5?o=30:(r===4||r===11||r===9)&&(o=-30),[120,[o,n],"show"]}),settings:{image:{format:"jpg",ratio:1,colorSpace:"display-p3"},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,format:"mp4",imageFormat:"jpg",activeTimeline:null,colorSpace:"display-p3"},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1})(wr||(wr={}));var Gp;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Gp||(Gp={}));var Fp;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Fp||(Fp={}));var Bo;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Gp.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Fp.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Bo||(Bo={}));var W0;(e=>{function i(r){return r.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function t(r,o,n){r.scene.objects.traverseFrom(o,(a,s)=>{if(s.type==="Instance"){let l=co.getComponentData(r,s.component)?.data;l&&n(a,s,l.events)}else n(a,s,s.events)})}e.traverseModuleInstances=t})(W0||(W0={}));var Vo;(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:iu.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(u=!0,d=[]){let p=[],f=nu.defaultMeshObject;u&&(p.push({...c.defaultLight}),p.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:f,children:[]})),p.push(...d);let h=new Ze;return h.push({fi:1,id:gi,data:{...Lo.defaultData,name:"Scene 1"},children:p}),h}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:wr.defaultData,styles:Bo.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new Ze,publish:wr.defaultData,styles:Bo.defaultData()}},c.emptyDataWithPage=function(u=!0){return{objects:e(u),publish:wr.defaultData,styles:Bo.defaultData()}},c.emptyData=function(){return{objects:new Ze,publish:{...wr.defaultData},styles:Bo.defaultData()}};function s(u){return{...c.defaultData,objects:Ct(u,Ze.prototype)}}c.withObjs=s;function l(u,d){return s([{id:u,data:d,children:[],fi:0}])}c.withObj=l})(Vo||(Vo={}));var va;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(va||(va={}));var au;(e=>(e.defaultData=r=>({url:r,name:"New Webhook",parametersSchemas:new xe}),e.defaultParameterValueByType=r=>r==="number"?0:r==="boolean"?!1:""))(au||(au={}));var q0;(t=>t.defaultData=(e,r="GET")=>({url:e,method:r,name:"New API",headers:new xe,queries:new xe,autoStart:!0}))(q0||(q0={}));var vi;(n=>{function i(a){return a.textValue!==void 0}n.isTextValue=i;function t(a){return typeof a=="number"}n.isNumber=t;function e(a){return typeof a=="boolean"}n.isBoolean=e;function r(a){return i(a)?"string":e(a)?"boolean":"number"}n.typeOfVariable=r;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})(vi||(vi={}));var jp;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(jp||(jp={}));var $0;(t=>t.all=[...jp.all,"components"])($0||($0={}));var X0;(t=>{function i(){return{images:new ue,videos:new ue,colors:new ue,audios:new ue,particles:new ue,fonts:new ue,materials:new ue,components:new ue,variables:new ue,userAPIs:new ue,userWebhooks:new ue,timelineAnimations:new ue}}t.defaultData=i})(X0||(X0={}));var Br;(t=>{function i(){return{images:new ue,videos:new ue,colors:new ue,audios:new ue,particles:new ue,fonts:new ue,materials:new ue,components:new ue,variables:new ue,userAPIs:new ue,userWebhooks:new ue,timelineAnimations:new ue}}t.defaultData=i})(Br||(Br={}));var Pr;(n=>{function i(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ct(a,ue.prototype)}n.defaultColors=i;function t(){return Ct({},ue.prototype)}n.defaultImages=t;function e(){return{catelogs:new ue,materials:new ue,images:new ue,videos:new ue,colors:new ue,timelineAnimations:new ue,audios:new ue,particles:new ue,fonts:new ue,variables:new xe,userAPIs:new ue,userWebhooks:new ue,lib:Br.defaultData()}}n.emptyData=e;function r(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=r;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})(Pr||(Pr={}));import{MathUtils as cu}from"three";var su;(t=>t.list=["idle","move","jump","run"])(su||(su={}));var lu;(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 xe,move:new xe,jump:new xe,run:new xe},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Ee.fromHexAndA(3728051,1)}}))(lu||(lu={}));function Y0(i){i.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,o=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let s=2;s<10;s++)o.push(o[1]),n.push(1);let a={...Rr(lt(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:o,steps:n,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...lt(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function zo(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function Go(i,t){i.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((o,n)=>{o===void 0&&(r.materials[n]=At.defaultData(),o=r.materials[n]),typeof o!="string"&&t(o)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=At.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=At.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&Object.getPrototypeOf(o.material)!==We.prototype&&t(o.material)})})}function mM(i){Object.assign(i.scene.publish,{orbitControls:{...ba.defaultData,...lt(i.scene.publish.orbitControls)}})}function yM(i){Object.assign(i.scene.publish.settings,{video:{...wr.defaultData.settings.video,...lt(i.scene.publish.settings.video)}})}function gM(i){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[o,n]of Object.entries(r))if((G0.includes(o)||typeof n=="boolean")&&delete r[o],o==="texture")for(let[a,s]of Object.entries(n))(F0.includes(a)||typeof s=="boolean")&&delete n[a]}}}i.scene.objects.traverse((e,r)=>{r.states.forEach(o=>{let n=o;n.material?t(n.material):n.materials&&n.materials.forEach(a=>{t(a)})})})}function xM(i){i.scene.publish.withBackground=!0}function bM(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function vM(i){i.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(o=>o+1),r.linear.scale=r.linear.scale.map(o=>o+1))})}function SM(i){i.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function wM(i){i.scene.objects.traverse((t,e)=>{let r=i.scene.objects.unproxy().parent(t);if(r){let o=lt(i.scene.objects.data(r));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=lt(e).booleanExclude!==!0)}})}function PM(i){i.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function OM(i){function t(r){Object.setPrototypeOf(r,We.prototype),r.texture&&Object.setPrototypeOf(r.texture,We.prototype)}function e(r){Object.setPrototypeOf(r,We.prototype);for(let o in r)t(r[o])}i.scene.objects.traverse((r,o)=>{o.states.forEach(n=>{let a=n;if(a.material){let s=lt(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=lt(l).layers;e(c),l.layers=c}})})}function K0(i){i.layers===void 0&&Object.assign(i,At.defaultTwoLayerData("lambert"))}function Up(i){!i.layers||i.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let o={...lt(t),colors:e,steps:r};Object.assign(t,o)}})}function TM(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function Q0(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&Up(r)}):"material"in e&&typeof e.material!="string"&&Up(e.material)}),Object.values(i.shared.materials).forEach(t=>Up(t))}function CM(i){i.scene.environment.ambientLight.softShadows=!1,i.scene.environment.ambientLight.softShadowQuality="low",i.scene.objects.traverse((t,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 AM(i){i.shared.audios=Ct({},ue.prototype)}function MM(i){i.shared.videos=Ct({},ue.prototype)}function IM(i){let t=i.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.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(t,{[e]:o})}})}function EM(i){Object.entries(lt(i.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.images[r]}),Object.entries(lt(i.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.audios[r]})}function NM(i){i.scene.publish.settings.web.preload=!1}function Z0(i){i.layers&&i.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function J0(i){i.layers&&i.layers.forEach(t=>{z0(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function DM(i){i.shared.fonts=Ct({},ue.prototype)}function _M(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 RM(i){let t=[];i.scene.objects.traverse((e,r)=>{let o=r;if(o.type==="TextFrame"){let n=At.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=_M(o.font);i.shared.fonts[s]===void 0&&(i.shared.fonts[s]={name:s});let l={name:o.name,...vt.defaultData,...Ro.defaultData,flatShading:!1,wireframe:!1,geometry:{...so.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:lt(o.states),events:lt(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},c=lt(i.scene.objects).parent(e);i.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{i.scene.objects.delete(e)})}function LM(i){let t={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,r)=>{r.events.forEach(o=>{if(!!t[Number(o.type)])if(Object.assign(o,{type:t[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 xe,move:new xe,jump:new xe}});else{let n=new xe;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:cu.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,Rr(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(u,{control1:{...a.control1},control2:{...a.control2}});let d={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},p={state:a.state,...d,...u},f={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new xe({fi:0,id:cu.generateUUID(),data:c},{fi:1,id:cu.generateUUID(),data:p})};n.push({fi:l,id:s,data:f})}),delete o.targets)}})})}function BM(i){i.scene.objects.traverse((t,e)=>{function r(o,n){let a=new xe,s=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===n){let d;s.push(c),l.interaction==="play"?d={...Rr(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")&&(d={...Rr(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&a.push({fi:u,id:c,data:d})}}),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:cu.generateUUID(),data:{type:o,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function ex(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=gt.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function tx(i){zo(i,ex),Go(i,ex)}function VM(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function zM(i){i.scene.objects.traverse((t,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 GM(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=At.defaultTwoLayerData("phong"))})}function FM(i){i.scene.publish.orbitControls.autoZoom===void 0&&(i.scene.publish.orbitControls.autoZoom=!1),i.scene.objects.traverse((t,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 jM(i){i.scene.objects.traverse((t,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 UM(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 kM(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function HM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function WM(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function qM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=lu.defaultDataThirdPerson.navmesh)})})}function $M(i){i.scene.styles||(i.scene.styles=Bo.defaultData())}function rx(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function XM(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}),Go(i,rx),zo(i,rx)}function YM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new xe})})})}function KM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function ox(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function ix(i,t){if(t<1&&(Go(i,Y0),zo(i,Y0),i.schema=1),t<2&&(mM(i),i.schema=2),t<3&&(gM(i),i.schema=3),t<4&&(xM(i),i.schema=4),t<5&&(bM(i),i.schema=5),t<6&&(vM(i),i.schema=6),t<7&&(SM(i),i.schema=7),t<8&&(i.schema=8),t<9&&(Q0(i),i.schema=9),t<10&&(TM(i),i.schema=10),t<11&&(CM(i),i.schema=11),t<12&&(Q0(i),i.schema=12),t<13&&(AM(i),i.schema=13),t<14&&(IM(i),i.schema=14),t<15&&(EM(i),i.schema=15),t<16&&(NM(i),i.schema=16),t<17&&(Go(i,Z0),zo(i,Z0),i.schema=17),t<18&&(Go(i,K0),zo(i,K0),i.schema=18),t<19&&(yM(i),i.schema=19),t<20&&(DM(i),RM(i),i.schema=20),t<21&&(LM(i),BM(i),i.schema=21),t<22&&(tx(i),i.schema=22),t<23&&(VM(i),i.schema=23),t<24&&(zM(i),i.schema=24),(t<25||i.shared.videos===void 0)&&(MM(i),t<25&&(i.schema=25)),t<26&&(wM(i),i.schema=26),t<27&&(PM(i),i.schema=27),t<28&&(tx(i),i.schema=28),t<29&&(OM(i),i.schema=29),t<30&&(GM(i),i.schema=30),t<31&&(FM(i),i.schema=31),t<33&&(jM(i),i.schema=33),t<34&&(UM(i),i.schema=34),t<35&&(kM(i),i.schema=35),t<36&&(HM(i),i.schema=36),t<37&&(WM(i),i.schema=37),t<38&&(Go(i,J0),zo(i,J0),i.schema=38),t<39&&(qM(i),i.schema=39),t<40&&($M(i),i.schema=40),t<41&&(XM(i),i.schema=41),t<42&&(YM(i),i.schema=42),t<43&&(KM(i),i.schema=43),t<99){Go(i,ox),zo(i,ox),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=yi);let e=lt(i.scene.objects),r=i.scene.objects;i.scene.publish.playPage=gi,r.insertBefore(null,null,[{id:gi,data:{...Lo.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Rr(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Rr(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Ys.defaultData,...Rr(i.scene.environment,"usePhysics","gravity")},camera:lt(i.scene.ownerCamera)??Lo.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==Vo.TRASH_CAN_ID&&r.move(gi,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,bi.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),i.schema=99}}function nx(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function QM(i){i.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function ZM(i){Array.isArray(lt(i.events))&&i.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var Sa=180/Math.PI;function ax(i){i.rotation=i.rotation.slice(0,3).map(t=>t*Sa)}function sx(i){ax(i),i.type==="Page"&&ax(i.camera),i.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*Sa))});let t=i.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Sa),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Sa),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Sa,t.extrusion.twist*=Sa),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(lt(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 JM(i){i.shared.variables=Ct({},ue.prototype)}function eI(i){let t=lt(i.shared.variables);i.shared.variables=Ct(Object.entries(t??{}).map(([e,r],o)=>({fi:o,id:e,data:r})),xe.prototype)}var uo=122;function uu(i,t){t(i.data);for(let e of i.children)uu(e,t)}function tI(i){let t=i.schema??104;t!==uo&&(t<105&&(uu(i.asset,sx),i.schema=105),t<118&&(uu(i.asset,lx),i.schema=118),t<121&&(uu(i.asset,kp),i.schema=121))}function rI(i){i.shared.particles=Ct({},ue.prototype),i.shared.lib&&(i.shared.lib.particles=Br.defaultData().particles)}function oI(i){i.scene.objects.traverse((t,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function iI(i){i.scene.objects.traverse((t,e)=>{e.type==="Page"&&(e.postprocessing.depthOfField.focusDistance=100,e.postprocessing.depthOfField.focalLength=20,e.postprocessing.depthOfField.bokehScale=5)})}function nI(i){i.scene.objects.traverse((t,e)=>{Array.isArray(lt(e.events))!==!1&&e.events?.forEach(r=>{let o=r.runMode;r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="Collision"||r.type==="Trigger"?r.actions?.forEach(n=>{n.type==="Transition"&&(n.runMode=o??"Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode=o==="Toggle"?"Toggle":"Normal")}):r.type==="MouseHover"||r.type==="MousePress"||r.type==="KeyPress"?r.actions?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")}):r.type==="GameControl"?(delete r.actions,Object.keys(r.gameActions).forEach(a=>{r.gameActions[a]?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),s.type==="Animation"&&(s.runMode="Normal")})})):r.type==="DragDrop"?(delete r.actions,r.dragDropActions?.drag?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")}),r.dragDropActions?.drop?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")})):r.type==="Resize"?(delete r.actions,r.breakpoints?.forEach(n=>{n.actions?.forEach(a=>{(a.type==="Transition"||a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Toggle")})})):r.type==="Start"?r.actions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Once"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}):r.type==="VariableChange"||r.type==="Scroll"?r.actions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}):r.type==="Conditional"&&(delete r.actions,r.inActions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}),r.outActions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}))})})}function aI(i){i.shared.userAPIs=Ct({},ue.prototype),i.shared.userWebhooks=Ct({},ue.prototype),i.shared.lib&&(i.shared.lib.userAPIs=Br.defaultData().userAPIs,i.shared.lib.userWebhooks=Br.defaultData().userWebhooks)}function sI(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=wr.defaultData.settings.videoStatic)}function lx(i){i.timelineAnimations=Ct({},ue.prototype)}function kp(i){i.pivot=[0,0,0],i.pivotRotation=[0,0,0]}function du(i){let t=i.schema??0;if(t!==uo){console.warn("updating from ",t,"to ",uo),ix(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=wr.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(Go(i,nx),zo(i,nx),i.schema=101),t<102&&(QM(i),i.schema=102),t<104&&(i.shared.catelogs=new ue,i.shared.lib=Br.defaultData(),i.schema=104),t<105&&(JM(i),i.scene.objects.traverse((e,r)=>{sx(r)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))tI(e);t<106&&(eI(i),i.schema=106),t<107&&(i.shared.lib.variables=Br.defaultData().variables,i.schema=107),t<109&&(rI(i),i.schema=109),t<110&&(oI(i),i.schema=110),t<111&&(i.scene.objects.traverse((e,r)=>{ZM(r)}),i.schema=111),t<112&&(iI(i),i.schema=112),t<113&&(nI(i),i.schema=113),t<114&&(i.scene.publish.settings.web.imageQuality===void 0&&(i.scene.publish.settings.web.imageQuality=70),i.schema=114),t<115&&(aI(i),i.schema=115),t<116&&(sI(i),i.schema=116),t<117&&(i.scene.publish.settings.web.pixelRatioMobile===void 0&&(i.scene.publish.settings.web.pixelRatioMobile=0),i.scene.publish.settings.web.pixelRatioDesktop===void 0&&(i.scene.publish.settings.web.pixelRatioDesktop=0),i.schema=117),t<118&&(i.shared.timelineAnimations=Ct({},ue.prototype),i.scene.objects.traverse((e,r)=>{lx(r)}),i.schema=118),t<119&&(i.scene.publish.settings.videoStatic.format=co.defaultData.scene.publish.settings.videoStatic.format,i.scene.publish.settings.videoStatic.imageFormat=co.defaultData.scene.publish.settings.videoStatic.imageFormat,i.schema=119),t<120&&(i.scene.publish.settings.image.colorSpace="display-p3",i.scene.publish.settings.videoStatic.colorSpace="display-p3",i.schema=120),t<121&&(i.scene.objects.traverse((e,r)=>{kp(r),r.type==="Page"&&kp(r.camera)}),i.schema=121),t<122&&(delete i.scene.publish.settings.video,i.scene.publish.orbitControls.rotationSpeed=co.defaultData.scene.publish.orbitControls.rotationSpeed,i.schema=122)}}var co;(c=>{c.defaultData={schema:uo,scene:Vo.defaultData,frames:new ue().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",va.defaultData),shared:{...Pr.emptyData(),colors:Pr.defaultColors()}},c.emptyDataForImports=function(){let u=Vo.emptyDataWithPage();return{schema:uo,scene:u,frames:new ue().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",va.defaultData),shared:{...Pr.emptyData(),colors:Pr.defaultColors(),images:Pr.defaultImages()}}},c.emptyData=function(){return{schema:uo,scene:Vo.emptyDataWithPage(),frames:new ue().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",va.defaultData),shared:Pr.emptyData()}},c.clipboard2dData=function(){return{schema:uo,scene:Vo.emptyData(),frames:new ue,shared:Pr.emptyData()}},c.collabHelper={...ks,updateSchema(u){return(u.schema??0)<uo?ui(u,du):(u.schema??0)-uo}};function n(u){let d=c.collabHelper.updateSchema(u);return typeof d=="number"?d===0?u:null:d.data}c.updateSchemaDirectly=n;function a(u){return{...u,shared:{...u.shared,lib:Br.defaultData()}}}c.withoutLib=a;function s(u,d){let p=u.scene.objects.get(d);if(p&&p.data.type==="Component")return p;{let f=u.shared.lib.components[d];if(f)return{...f.asset,id:d}}}c.getComponentData=s;function l(u){let d=Object.values(u.shared.userAPIs);for(let p of d){let f=p.headers;for(let h of f)if(h.data.key.toLowerCase()==="authorization"&&h.data.value!=="")return!0}return!1}c.hasSensitiveData=l})(co||(co={}));var pu;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(pu||(pu={}));var cx;(t=>{function i(e){return!0}t.is=i})(cx||(cx={}));var fu;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(o,n){return{position:n?.position??o.position,rotation:n?.rotation??o.rotation,scale:n?.scale??o.scale,shear:n?.shear??o.shear}}r.merge=t;function e(o,n){return Jl({position:pa.isEqual(o.position,n.position)?void 0:n.position,rotation:o.rotation===n.rotation?void 0:n.rotation,scale:pa.isEqual(o.scale,n.scale)?void 0:n.scale,shear:o.shear&&n.shear&&pa.isEqual(o.shear,n.shear)?void 0:n.shear})}r.diff=e})(fu||(fu={}));var Hp;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(Hp||(Hp={}));var ux;(t=>t.defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8})(ux||(ux={}));var hu;(t=>t.defaultData={opacity:1,fill:{color:Ee.fromHexAndA(bt,1),enabled:!0},stroke:{color:Ee.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:Ee.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Ee.from0to1([0,0,0,1]),enabled:!1,spread:0}})(hu||(hu={}));var ln;(n=>{function i(a,s){return{name:s}}n.newEmpty=i;function t(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 r(a,s){if(s===void 0)return a;let l={...a};return Object.assign(l,fu.merge(l,s)),l=t(l,s),l=e(l,s),l}n.patch=r;function o(a,s){let l,c=[];for(let[u,d]of Object.entries(s))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[u]=d);return c}n.toOps=o})(ln||(ln={}));var Ks;(t=>t.defaultData={...fu.defaultData,...Hp.defaultData,states:new xe,events:new xe,visible:!0,raycastLock:!1})(Ks||(Ks={}));var wa;(t=>t.defaultData={...Ks.defaultData,...hu.defaultData})(wa||(wa={}));var mu;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(mu||(mu={}));var Wp;(t=>t.defaultData={...wa.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(Wp||(Wp={}));var Pa;(t=>t.defaultData={...wa.defaultData,...mu.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Pa||(Pa={}));var qp;(t=>t.defaultData={...wa.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"})(qp||(qp={}));var $p;(t=>t.defaultData={...wa.defaultData,type:"path2d",path:"",name:"Path"})($p||($p={}));var dx;(t=>{function i(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=i})(dx||(dx={}));var Qs;(t=>t.defaultData={...Ks.defaultData,name:"Group",type:"group2d"})(Qs||(Qs={}));var Xp;(t=>t.defaultData=()=>({...Ks.defaultData,...mu.defaultData,...hu.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Ee.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Ee.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(Xp||(Xp={}));var Fo;(n=>{function i(a){switch(a){case"rectangle2d":return{...Pa.defaultData};case"ellipse2d":return{...Wp.defaultData};case"text2d":return{...qp.defaultData};case"vector2d":return{...Pa.defaultData};case"path2d":return{...$p.defaultData};case"frame2d":return{...Xp.defaultData()};case"group2d":return{...Qs.defaultData}}}n.defaultData=i;function t(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=t;function e(a){return a.type==="rectangle2d"||a.type==="ellipse2d"||a.type==="text2d"||a.type==="frame2d"}n.isResizeable=e;function r(a){return a.type==="frame2d"&&a.autoLayout!==void 0}n.isAutoLayoutable=r;function o(a){return a.type==="rectangle2d"||a.type==="frame2d"}n.hasCorners=o})(Fo||(Fo={}));var yu;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new Ze},e.emptyData=function(){return{type:"scene2d",objects:new Ze}}))(yu||(yu={}));import{Color as lI}from"three";var Mt=class extends lI{constructor(e,r,o,n){super(e,r,o);this.isColorA=!0;this.a=n}setRGBA(e,r,o,n){super.setRGB(e,r,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,r="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,r);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,r);break}}return super.setStyle(e,r)}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 md=Bs(fx());import{Object3D as TD,Vector3 as yr,Euler as Nh,MathUtils as Jv,Matrix4 as Mn}from"three";var cI=.5*(Math.sqrt(3)-1),Zs=(3-Math.sqrt(3))/6,uI=1/3,po=1/6,e8=(Math.sqrt(5)-1)/4,t8=(5-Math.sqrt(5))/20,Js=i=>Math.floor(i)|0,hx=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]),Kp=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 mx(i=Math.random){let t=gx(i),e=new Float64Array(t).map(o=>hx[o%12*2]),r=new Float64Array(t).map(o=>hx[o%12*2+1]);return function(n,a){let s=0,l=0,c=0,u=(n+a)*cI,d=Js(n+u),p=Js(a+u),f=(d+p)*Zs,h=d-f,m=p-f,y=n-h,g=a-m,b,w;y>g?(b=1,w=0):(b=0,w=1);let P=y-b+Zs,S=g-w+Zs,T=y-1+2*Zs,A=g-1+2*Zs,x=d&255,N=p&255,E=.5-y*y-g*g;if(E>=0){let _=x+t[N],R=e[_],V=r[_];E*=E,s=E*E*(R*y+V*g)}let M=.5-P*P-S*S;if(M>=0){let _=x+b+t[N+w],R=e[_],V=r[_];M*=M,l=M*M*(R*P+V*S)}let D=.5-T*T-A*A;if(D>=0){let _=x+1+t[N+1],R=e[_],V=r[_];D*=D,c=D*D*(R*T+V*A)}return 70*(s+l+c)}}function yx(i=Math.random){let t=gx(i),e=new Float64Array(t).map(n=>Kp[n%12*3]),r=new Float64Array(t).map(n=>Kp[n%12*3+1]),o=new Float64Array(t).map(n=>Kp[n%12*3+2]);return function(a,s,l){let c,u,d,p,f=(a+s+l)*uI,h=Js(a+f),m=Js(s+f),y=Js(l+f),g=(h+m+y)*po,b=h-g,w=m-g,P=y-g,S=a-b,T=s-w,A=l-P,x,N,E,M,D,_;S>=T?T>=A?(x=1,N=0,E=0,M=1,D=1,_=0):S>=A?(x=1,N=0,E=0,M=1,D=0,_=1):(x=0,N=0,E=1,M=1,D=0,_=1):T<A?(x=0,N=0,E=1,M=0,D=1,_=1):S<A?(x=0,N=1,E=0,M=0,D=1,_=1):(x=0,N=1,E=0,M=1,D=1,_=0);let R=S-x+po,V=T-N+po,U=A-E+po,B=S-M+2*po,q=T-D+2*po,j=A-_+2*po,F=S-1+3*po,H=T-1+3*po,W=A-1+3*po,ee=h&255,te=m&255,Y=y&255,re=.6-S*S-T*T-A*A;if(re<0)c=0;else{let $=ee+t[te+t[Y]];re*=re,c=re*re*(e[$]*S+r[$]*T+o[$]*A)}let K=.6-R*R-V*V-U*U;if(K<0)u=0;else{let $=ee+x+t[te+N+t[Y+E]];K*=K,u=K*K*(e[$]*R+r[$]*V+o[$]*U)}let Z=.6-B*B-q*q-j*j;if(Z<0)d=0;else{let $=ee+M+t[te+D+t[Y+_]];Z*=Z,d=Z*Z*(e[$]*B+r[$]*q+o[$]*j)}let Q=.6-F*F-H*H-W*W;if(Q<0)p=0;else{let $=ee+1+t[te+1+t[Y+1]];Q*=Q,p=Q*Q*(e[$]*F+r[$]*H+o[$]*W)}return 32*(c+u+d+p)}}function gx(i){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let o=r+~~(i()*(256-r)),n=e[r];e[r]=e[o],e[o]=n}for(let r=256;r<512;r++)e[r]=e[r-256];return e}import{Triangle as dI}from"three";var Vr=new dI,gu=class{constructor(t){this.weightAttribute=null;let e=t.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 t=this.positionAttribute,e=new Float32Array(t.count/3);for(let o=0;o<t.count;o+=3){let n=1;Vr.a.fromBufferAttribute(t,o),Vr.b.fromBufferAttribute(t,o+1),Vr.c.fromBufferAttribute(t,o+2),n*=Vr.getArea(),e[o/3]=n}this.distribution=new Float32Array(t.count/3);let r=0;for(let o=0;o<e.length;o++)r+=e[o],this.distribution[o]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],o=this.binarySearch(this.randomFunction()*r);return this.sampleFace(o,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,o=e.length-1,n=-1;for(;r<=o;){let a=Math.ceil((r+o)/2);if(a===0||e[a-1]<=t&&e[a]>t){n=a;break}else t<e[a]?o=a-1:r=a+1}return n}sampleFace(t,e,r){let o=this.randomFunction(),n=this.randomFunction();return o+n>1&&(o=1-o,n=1-n),Vr.a.fromBufferAttribute(this.positionAttribute,t*3),Vr.b.fromBufferAttribute(this.positionAttribute,t*3+1),Vr.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(Vr.a,o).addScaledVector(Vr.b,n).addScaledVector(Vr.c,1-(o+n)),Vr.getNormal(r),this}};import{Object3D as yI}from"three";var vx=Bs(bx());import{Object3D as pI,Matrix4 as zr}from"three";var fI=new zr,hI=new zr,mI=new zr,jo;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(jo||(jo={}));var Oa=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new zr;this.copyPreviousMatrix=!0;this.hiddenMatrix=new zr;this.pivotMatrix=new zr;this.matrixWorldRigid=new zr;this.shearScale=new zr;this.shearScaleInv=new zr}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof pI&&(r=r.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===r)return!0;o=o.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,r=!0);for(let o of this.children)o.updateMatrixWorld(r)}updateWorldMatrix(r,o){let n=this.parent;if(r&&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)),this.matrixWorld.multiply(this.pivotMatrix),o)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(r,o=0){for(let n of this.children)jo.is(n)&&n.traverseObject(r,o+1)}traverseObject(r,o=0){if(r(this,o)!==!0)for(let a of this.children)jo.is(a)&&a.traverseObject(r,o+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,o=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:n,v:a,q:s}=(0,vx.SVD)(o),l=fI.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=hI.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=mI.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(d=>Math.abs(s[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,o){this.updateWorldMatrix(!0,!1);let n=new zr().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),n.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof zr?r.hiddenMatrix.premultiply(n):r.applyMatrix4(n),r.updateWorldMatrix(!1,!1),this.add(r),o!==void 0&&(this.children.pop(),this.children.splice(o,0,r)),this}copy(r,o=!1){return super.copy(r,o),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,o,n,a,s,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var Qp=class extends Oa(yI){},gI=i=>i.type==="Mesh",Gr=class extends Qp{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let o=this.children[e];o?.object!==r&&(o&&this.remove(o),o=new Gr(r),this.add(o),this.children.splice(e,0,this.children.pop()),o.matrixWorldNeedsUpdate=!0,o.matrixAutoUpdate=!1,o.matrix=r.matrix,o.hiddenMatrix=r.hiddenMatrix,o.pivotMatrix=r.pivotMatrix),o.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}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 gI(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}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(e){}};import{Box3 as GE,BufferGeometry as FE,MeshBasicMaterial as jE}from"three";import{Matrix4 as VE,Mesh as zE}from"three";import{Matrix4 as vu,Vector3 as af,Euler as Tx,MathUtils as dn,Quaternion as PI}from"three";import{Box3 as xI,Line3 as bI,Matrix4 as Zp,Vector3 as fr}from"three";var cn=new fr,un=new fr,Ta=new Zp,wx=[new fr(-1,1,1),new fr(-1,-1,1),new fr(1,-1,1),new fr(1,1,1),new fr(-1,1,-1),new fr(-1,-1,-1),new fr(1,-1,-1),new fr(1,1,-1)],vI=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],SI=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Sx=(i,t,e)=>{i.updateEntityBoxSize(cn,un),Ta.copy(t).multiply(i.matrixWorld),un.x===0&&un.y===0&&un.z===0?e.push(new fr(cn.x,cn.y,cn.z).applyMatrix4(Ta)):wx.forEach(r=>{e.push(r.clone().multiply(un).add(cn).applyMatrix4(Ta))})},el=class extends xI{constructor(){super(...arguments);this.matrix=new Zp;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let o=new Zp().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,r)}expandByObjectSize(e,r,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 fr);return}Sx(a,r,n)}}):Sx(e,r,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(Ta.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(un).multiplyScalar(.5),this.getCenter(cn),Ta.copy(this.matrix).setPosition(cn),this.vertices=wx.map(e=>e.clone().multiply(un).applyMatrix4(Ta))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=vI.map(([e,r])=>new bI(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new fr))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=SI.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var Fr={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};import{CurvePath as wI,CubicBezierCurve3 as Jp,Vector3 as jr}from"three";var tf=class extends wI{constructor(){super()}getPoints(t=12){let e=[],r,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],d=Math.ceil(t*u/a),p=c.getPoints(d);for(let f=0;f<p.length;f++){let h=p[f];r&&r.equals(h)||(e.push(h),r=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var rf=.001;function of(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=rf}function ef(i,t){let e=new jr(...i.position),r=new jr(...i.controlNext.position),o=new jr(...t.controlPrevious.position),n=new jr(...t.position);return of(e,r,n)&&of(e,o,n)}function bu(i){let t=i.points.map(u=>new jr(...u.data.position)),e=[i.points[0]],r=new jr(...e[0].data.position);for(let u=0;u<i.points.length-1;u++)of(r,t[u],t[u+1])||(e.push(i.points[u]),r=t[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 d=e[u].data,p=new jr(...d.position),f=new jr(...d.controlPrevious.position),h=new jr(...d.controlNext.position),m={position:p,baseRoundness:d.roundness,controlPrevious:f,controlNext:h};if(d.roundness===0||!i.isClosed&&(u===0||u===a-1)){s[u]={...m,removedLength:0};continue}let y=o&&u==0?a-1:u-1,g=o&&u==a-1?0:u+1,b=e[y].data,w=e[g].data,P=new jr(...b.position),S=new jr(...w.position),T=P.clone().sub(p).normalize(),A=S.clone().sub(p).normalize();Object.assign(m,{prevDir:T,nextDir:A});let x=ef(b,d),N=ef(d,w);if(!x||!N)s[u]={...m,removedLength:0};else{let E=T.clone().add(A).normalize(),M=E.clone().cross(T).length()/T.dot(E);s[u]={...m,tan:M,removedLength:d.roundness/M}}}for(let u=0;u<n;u++){let d=u,p=o&&u===a-1?0:u+1,f=s[d],h=s[p];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 d=u,p=o&&u===a-1?0:u+1,f=s[d],h=s[p],m=null;if(!ef(e[d].data,e[p].data))f.position.distanceTo(h.position)>rf&&(m=new Jp(f.position,f.controlNext,h.controlPrevious,h.position));else{let y=f.position.clone(),g=h.position.clone();(f.removedLength!==0||h.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),h.prevDir&&g.add(h.prevDir.clone().setLength(h.removedLength))),y.distanceTo(g)>rf&&(m=new Jp(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}l[2*u+1]=m}for(let u=0;u<a;u++){let d=s[u];if(d.removedLength===0){l[2*u]=null;continue}let p=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(p),h=d.nextDir.clone().multiplyScalar(d.removedLength).add(p),m=d.tan*d.removedLength,y=d.prevDir.clone().add(d.nextDir).normalize(),g=f.clone().lerp(h,.5),b=f.distanceTo(h)/2,w=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(b,2))).add(g),P=y.clone().multiplyScalar(-m).add(w),S=p.distanceTo(P)/p.distanceTo(g),T=d.prevDir.clone().multiplyScalar(S*p.distanceTo(f)).add(p),A=T.clone().lerp(P,2),x=f.clone().lerp(T,4/3),N=h.clone().lerp(A,4/3);l[2*u]=new Jp(f,x,N,h)}let c=new tf;return l.forEach(u=>{u&&c.add(u)}),c}var _e;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(_e||(_e={}));var Ca=i=>_e.is(i),OI={type:"completeState",isfromEntity:!0},TI=["x","y","z"],tl=new af,Px=new af(1,1,1),nf=new PI,Ox=new Tx,CI=new af().set(0,1,0),Aa=i=>class extends Oa(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.currentAnimationAction=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new el;this._recursiveBBox=new el;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let o=this.children[r];if(_e.is(o))return o}entityChildrenCount(){let r=this.children.length;for(;r--;)if(_e.is(this.children[r]))return r+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 r=this;for(;r.data.type!=="Instance";){let o=r.parent;if(_e.is(o))r=o;else return}return r}forInstancesRec(r){this.instances.forEach(o=>{o.disposed||r(o),o.forInstancesRec(r)})}super_Entity(r,o){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=o,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,o,n=!1){if(!(this.data.states.length===0&&!n)){for(let a of this.data.states)sn.toOps(this.data,a.data).forEach(l=>{let c=la.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(c,this.data,o)});if(r!==null){let a=this.data.states.data(r);a&&(this.dataPatched=sn.patch(this.data,a),sn.toOps(this.data,a).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,o)}))}n&&this.updateTransformState(this.dataPatched,o),this.stateSelection=r,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(r,o){r.setScalar(0),o.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{Ca(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let o;return this.traverseEntity(n=>{n.uuid===r&&(o=n)}),o}traverseSortNextHelper(){let r=this.parent;if(r){let o=r.children,n=o.indexOf(this)+1;if(_e.is(o[n]))return o[n];if(_e.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&_e.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let o=this;for(;r>0&&o!==null;)o=o.parent,r-=1;return o}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let o=this.parent;for(;o;){if(r===o)return!0;o=o.parent}return!1}countToAccestor(r){let o=0,n=this;for(;n!==r;){if(n===null)return-1;n=n.parent,o+=1}return o}forEachEntity(r){for(let o of this.children)Ca(o)&&r(o)}traverseEntityAncestors(r){this.traverseAncestors(o=>{_e.is(o)&&r(o)})}traverseConcreteEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Ca(a)&&a.isConcreteEntity&&a.traverseEntity(r,o+1)}traverseEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Ca(a)&&a.traverseEntity(r,o+1)}traverseVisibleEntity(r){r(this);for(let o of this.children)Ca(o)&&o.visible&&o.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,o=!1){return super.copy(r,o),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>Ca(r))}isAncestorOf(r){if(this.uuid===r)return!1;let o=!1;return this.traverseEntity(n=>{n.uuid===r&&(o=!0)}),o}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x*dn.RAD2DEG,this.rotation.y*dn.RAD2DEG,this.rotation.z*dn.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]};return oa(o,r)}getTransformValues(r,o,n){return o[r].map((a,s)=>n?.shared.getVariable(a,[this.uuid,r,TI[s]])??a)}updateTransformState(r,o){let n=!1;if(r.position&&(this.position.fromArray(this.getTransformValues("position",r,o)),n=!0),r.rotation&&(tl.fromArray(this.getTransformValues("rotation",r,o)).multiplyScalar(dn.DEG2RAD),this.rotation.setFromVector3(tl),n=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,o)),n=!0),r.hiddenMatrix!==void 0&&(n=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??mi.identity)),r.pivot!==void 0||r.pivotRotation!==void 0){if(n=!0,r.pivot!==void 0&&r.pivotRotation!==void 0)this.pivotMatrix.compose(tl.fromArray(r.pivot).negate(),nf.setFromEuler(Ox.fromArray(r.pivotRotation.map(a=>a*dn.DEG2RAD))).invert(),Px);else if(r.pivot!==void 0)this.pivotMatrix.setPosition(-r.pivot[0],-r.pivot[1],-r.pivot[2]);else if(r.pivotRotation!==void 0){let a=tl.setFromMatrixPosition(this.pivotMatrix);nf.setFromEuler(Ox.fromArray(r.pivotRotation.map(s=>s*dn.DEG2RAD))).invert(),this.pivotMatrix.compose(a,nf,Px)}}return n&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(a=>{a.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),n}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)}),this.requestRender()}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)_e.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{_e.is(r)&&r.disposeRecursively()})}toState(r=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return oa(o,r)}updateByObjUpdateOp(r,o){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},o,!1)}updateByOp(r,o,n,a){let s=this.data;this.data=o;let l=r,c=Be(r.path,["states","*"]);if(c!==null){if(r.type===0){let[u]=c;if(this?.stateSelection===u){let d={...r.props};if(delete d.name,Object.values(r.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=Je.zoom(p,r.path.slice(2));if(f)for(let h in r.props)r.props[h]===void 0&&h in f&&(d[h]=f[h])}}l={...r,props:d,path:r.path.slice(2)}}}}else if(r.type===0){let u=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(u!==void 0){if(r.props.name!==void 0&&u.name){let{name:p,...f}=u;u=f}if(r.props.material!==void 0&&"material"in u){let{material:p,...f}=u;u=f}let d=Je.removeOverridden(r.path,r.props,u);l={...r,props:d}}}if(this.updateByPatchedOpBase(l,sn.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),n),Be(r.path,["overrides"])){let u=[],d=[...r.path];for(u.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)u.push(d[1]),d.splice(0,2);if(u[u.length-1]===void 0){if(r.type===0)for(let p of Object.keys(r.props)){u[u.length-1]=p;let f=n.scene.findInstance([this.uuid,...u]);f&&(f.overrideData=r.props[p],f.updateState(to.apply(f.component.data,f.overrideData),n))}}else{let p=n.scene.findInstance([this.uuid,...u]);if(p){let f=Je.zoom(p.component.data,d);if(r={...r,path:d},r.type===0){let h=r.props;if(f)for(let[m,y]of Object.entries(r.props))y===void 0&&(h===r.props&&(h={...r.props}),h[m]=f[m]);r={...r,props:h}}p.overrideData=xa.resolve(o.overrides,u),p.updateByOp(r,at.applySimple(p.data,r),n,!1)}}}else if(this.instances.length>0){let u;if(r.path.length===0&&r.type===0){let d;for(let p of lo.rootOverrideProps)p in r.props&&(d===void 0&&(d={}),d[p]=r.props[p]);d&&(u={...r,props:d})}else for(let d of lo.rootOverrideProps)if(Be(r.path,[d])){u=r;break}u!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=to.filterOp(d.overrideData,u);p&&d.updateByOp(p,at.applySimple(d.data,p),n,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=to.filterOp(d.overrideData,r);if(p){let f;s===d.data&&r===p?f=o:f=at.applySimple(d.data,p),d.updateByOp(p,f,n,!0)}}})}}updateByPatchedOpBase(r,o,n){if(this.dataPatched=o,r.path.length===0&&r.type===0)r.props.type!==void 0&&!Lr.is(r.props.type)&&Fr.changeEntityProptotype(this,o,n);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){Fr.changeEntityProptotype(this,o,n);for(let a of this.children)_e.is(a)&&a.updateVisible(n.scene)}this.updateByPatchedOp(r,o,n)}updateByPatchedOp(r,o,n){if(r.path.length===0&&r.type===0?this.updateState(r.props,n):r.type===0&&("resolutionLevel"in r.props||"useChildrenColors"in r.props)&&this.updateState(o,n),r.path[0]==="morphTargetInfluences"&&r.type===0){let s=o.morphTargetInfluences.get(r.path[1])?.data.name;s&&this.updateMorphInfluences(s,n.shared.getVariable(r.props.value,[this.uuid,"morphTargetInfluences",s]))}if(Be(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Be(r.path,["cloner"])!==null){let a=at.drop(r,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,n):this.cloner?this.cloner.updateState(o.cloner,n):(this.setFromClonerState(o.cloner,n),this.expandCloner(n)),this.updateVisible(n.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){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=r.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=bu(c.geometry.path),d=(n+a)%1;n+a===1&&d===0&&(d=1);let p=null;try{p=u.curves.length?u.getPointAt(d):null}catch(y){!1&&(console.warn(`The aligned path on ${this.name} is invalid. (${l.name})`),console.error(y))}if(p===null)return;let f=this.parent?this.parent?.matrixWorld:new vu;l.updateMatrixWorld();let h=new vu().multiplyMatrices(f.clone().invert(),l.matrixWorld);p.applyMatrix4(h);let m={position:p.toArray(),rotation:c.rotation};if(s==="tangential"){let y=new vu().extractRotation(l.matrixWorld),g=u.getTangentAt(d).applyMatrix4(y).add(p),b=new vu().lookAt(p,g,CI),w=tl.setFromEuler(new Tx().setFromRotationMatrix(b)).multiplyScalar(dn.RAD2DEG);m={...m,rotation:w.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(OI)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let o=!1;this.traverseEntity(n=>{if(n.data.type==="Splat")return o=!0,!0}),o&&r.reloadSplats()}updateState_Entity(r,o){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(o?.scene),this.resetBBoxNeedsUpdate()),o&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,o),this.updateVisible(o.scene)),this.updateTransformState(r,o)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof Fr.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,o){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Fr.Cloner(this,r),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,o))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};import{BufferGeometry as II,ConeGeometry as EI,Float32BufferAttribute as NI,MathUtils as DI}from"three";import{BufferGeometry as Ax,CylinderGeometry as AI,Float32BufferAttribute as wu,MathUtils as MI,Vector2 as Ur,Vector3 as Su}from"three";var Mx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.parameters?.radiusTop,r=i.parameters?.radiusBottom,o=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters);o.thetaLength=MI.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=r??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:t,depth:e,height:r,radialSegments:o,heightSegments:n,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:d,cornerSegments:p,hollow:f}=i.parameters,h;return l===0?(h=new Ax,h.setAttribute("position",new wu([],3))):d||f?h=new rl(c,u,r,o,n,a,s,l*Math.PI/180,d,d,p,f):h=new AI(c,u,r,o,n,a,s,l*Math.PI/180),h.scale(1,1,e/t),Object.assign(h,{userData:{...i,type:"CylinderGeometry"}})}};function Si(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function Cx(i){return new Ur(i.y,-i.x)}var rl=class extends Ax{constructor(t,e,r,o,n,a,s,l,c,u,d,p,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||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=[],g=[],b=0,w=r/2,P=new Su,S=new Su;f&&t==0&&(t=c),f&&e==0&&(e=u);let T=new Ur(t,w),A=new Ur(e,-w),x=null,N=null,E=null,M=null,D=T.clone().sub(A),_=0,R=0,V=0;p>0&&(_=Math.min(t,e)*(1-p),R=t-_,V=e-_);let U=T.clone();U.x-=_;let B=Math.PI-D.angle(),q=D.angle(),j=Math.tan(q/2),F=Math.tan(B/2),H=j+F,W=p?H:F,ee=p?H:j;if(c=Math.min(c,(t-R)/W,D.length()/H),u=Math.min(u,(e-V)/ee,D.length()/H),c>0){let Q=c/j;x=T.clone().sub(new Ur(Q,c)),p&&(E=x.clone(),E.x-=_-H*c),T.sub(D.clone().setLength(Q))}if(u>0){let Q=u/F;N=A.clone().sub(new Ur(Q,-u)),A.add(D.clone().setLength(Q)),p&&(M=N.clone(),M.x-=_-H*u,U.sub(D.clone().setLength(Q)))}D=T.clone().sub(A);let te=D.length()<.5,Y=[];for(let Q=0;Q<=o;Q++){let $=[],de=Q/o,le=de*l+s,ie=new Ur(Math.sin(le),Math.cos(le));M&&N?(re($,de,ie,B,u,M,-1,!0),re($,de,ie,q,u,N,-1,!1)):N?(K($,ie,N.x,0,-1),re($,de,ie,q,u,N,-1,!1)):a||K($,ie,e,V,-1);let ce=Cx(D).normalize();if(Si(ce,ie,P),!te)for(let ae=0;ae<=n;ae++){let me=ae/n,fe=D.clone().multiplyScalar(me).add(A);Si(fe,ie,S),m.push(S.x,S.y,S.z),y.push(P.x,P.y,P.z),g.push(de,.5+S.y/r),$.push(b++)}if(E&&x?(re($,de,ie,B,c,x,1,!1),re($,de,ie,q,c,E,1,!0)):x?(re($,de,ie,B,c,x,1,!1),K($,ie,x.x,0,1)):a||K($,ie,t,R,1),p&&!te){let ae=Cx(D).multiplyScalar(-1).normalize();Si(ae,ie,P);for(let me=0;me<=n;me++){let fe=me/n,he=D.clone().multiplyScalar(-fe).add(U);Si(he,ie,S),m.push(S.x,S.y,S.z),y.push(P.x,P.y,P.z),g.push(de,.5+S.y/r),$.push(b++)}}p&&!a&&$.push($[0]),Y.push($)}for(let Q=0;Q<Y.length-1;Q++)for(let $=0;$<Y[0].length-1;$++){if(a&&p&&$==n)continue;let de=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(de,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 wu(m,3)),this.setAttribute("normal",new wu(y,3)),this.setAttribute("uv",new wu(g,2));function re(Q,$,de,le,ie,ce,ae,me){for(let fe=0;fe<d+1;fe++){let he=fe/d,be=ae<0?he:1-he;me&&(be-=1),be*=le;let ye=new Ur(Math.sin(be),Math.cos(be)*ae),C=ye.clone().multiplyScalar(ie).add(ce);Si(C,de,S),m.push(S.x,S.y,S.z),Si(ye,de,P),y.push(P.x,P.y,P.z),g.push($,.5+S.y/r),Q.push(b++)}}function K(Q,$,de,le,ie){let ce=new Su,ae=new Ur,me=[de,le];ie<0&&me.reverse();for(let fe of me)ae.set(fe,w*ie),Si(ae,$,ce),m.push(ce.x,ce.y,ce.z),y.push(0,ie,0),g.push(.5,.5),Q.push(b++)}function Z(Q,$,de){let le=new Ur(Math.sin(de),Math.cos(de)),ie=new Ur(-Math.cos(de),Math.sin(de)),ce=new Su,ae=Q<0?(he,be,ye)=>h.push(he,be,ye):(he,be,ye)=>h.push(he,ye,be),me=new Ur((t+e+R+V)/4,0);Si(me,le,ce),m.push(ce.x,ce.y,ce.z),y.push(ie.x,0,ie.y),g.push(.5,.5);let fe=b++;for(let he of $){let be=m.slice(he*3,he*3+3);m.push(...be),y.push(ie.x,0,ie.y);let ye=g.slice(he*2,he*2+2);g.push(...ye),b++}for(let he=fe+1;he<b-1;he++)ae(fe,he,he+1);ae(fe,b-1,fe+1)}}};var Ix=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},i.parameters);return e.thetaLength=DI.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:t,depth:e,height:r,radialSegments:o,heightSegments:n,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:u,cornerSegments:d}=i.parameters,p;return l===0?(p=new II,p.setAttribute("position",new NI([],3))):c>0||u>0||l<360?p=new rl(0,t/2,r,o,n,a,s,l*Math.PI/180,c,u,d,0,!0):p=new EI(t/2,r,o,n,a),p.scale(1,1,e/t),Object.assign(p,{userData:{...i,type:"ConeGeometry"}})}};import{BoxGeometry as _I,BufferGeometry as RI,Float32BufferAttribute as sf,Vector3 as ol}from"three";var Ex=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.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:t,height:e,depth:r,widthSegments:o,heightSegments:n,depthSegments:a,cornerRadius:s,cornerSegments:l}=i.parameters,c;return s===0?c=new _I(t,e,r,o,n,a):c=new cf(t,e,r,o,n,a,s,l),Object.assign(c,{userData:{...i,type:"CubeGeometry"}})}},lf=Math.PI/2,cf=class extends RI{constructor(t=1,e=1,r=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,t/2,e/2,r/2);let c=[],u=[],d=[],p=[],f=0;h("z","y","x",-1,-1,r,e,t,a,n),h("z","y","x",1,-1,r,e,-t,a,n),h("x","z","y",1,1,t,r,e,o,a),h("x","z","y",1,-1,t,r,-e,o,a),h("x","y","z",1,-1,t,e,r,o,n),h("x","y","z",-1,-1,t,e,-r,o,n),s>0&&(m("z","y","x",-1,-1,1,r,e,t,a),m("z","y","x",1,-1,-1,r,e,t,a),m("z","y","x",-1,1,-1,r,e,t,a),m("z","y","x",1,1,1,r,e,t,a),m("x","y","z",-1,-1,-1,t,e,r,o),m("x","y","z",1,-1,1,t,e,r,o),m("x","y","z",-1,1,1,t,e,r,o),m("x","y","z",1,1,-1,t,e,r,o),m("y","x","z",-1,-1,1,e,t,r,n),m("y","x","z",1,-1,-1,e,t,r,n),m("y","x","z",1,1,1,e,t,r,n),m("y","x","z",-1,1,-1,e,t,r,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 sf(u,3)),this.setAttribute("normal",new sf(d,3)),this.setAttribute("uv",new sf(p,2));function h(g,b,w,P,S,T,A,x,N,E){let M=(T-2*s)/N,D=(A-2*s)/E,_=T/2-s,R=A/2-s,V=x/2,U=N+1,B=E+1,q=0,j=new ol;for(let F=0;F<B;F++){let H=F*D-R;for(let W=0;W<U;W++){let ee=W*M-_;j[g]=ee*P,j[b]=H*S,j[w]=V,u.push(j.x,j.y,j.z),j[g]=0,j[b]=0,j[w]=x>0?1:-1,d.push(j.x,j.y,j.z),p.push(W/N),p.push(1-F/E),q+=1}}for(let F=0;F<E;F++)for(let H=0;H<N;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(g,b,w,P,S,T,A,x,N,E){let M=(A-2*s)/E,D=A/2-s,_=x/2-s,R=N/2,V=E+1,U=0,B=new ol,q=new ol;for(let j=0;j<l+1;j++){let F=j/l*lf,H=Math.sin(F)*s,W=(1-Math.cos(F))*s,ee=Math.sin(F),te=Math.cos(F);B[b]=(_+H)*S,B[w]=(R-W)*T,q[g]=0,q[b]=ee*Math.sign(B[b]),q[w]=te*Math.sign(B[w]);for(let Y=0;Y<V;Y++){let re=Y*M-D;B[g]=re*P,u.push(B.x,B.y,B.z),d.push(q.x,q.y,q.z),p.push(Y/E),p.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(g,b,w){let P=new ol,S=new ol(t/2,e/2,r/2);S.subScalar(s);let T=[],A=g*b*w>0?(N,E,M)=>c.push(N,E,M):(N,E,M)=>c.push(N,M,E);for(let N=0;N<=l;N++){let E=[],M=lf*(1-N/l),D=Math.cos(M),_=Math.sin(M),R=0;for(let V=0;V<=N;V++){let U=Math.cos(R),B=Math.sin(R);P.x=D*U,P.y=_,P.z=D*B;let q=S.clone().addScaledVector(P,s);u.push(g*q.x,b*q.y,w*q.z),d.push(g*P.x,b*P.y,w*P.z),p.push(0,0),E.push(f++),R+=lf/N}T.push(E)}let x=T.length-1;for(let N=0;N<x;N++){let E=T[N],M=T[N+1],D=E.length-1;A(E[0],M[1],M[0]);for(let _=1;_<=D;_++)A(E[_-1],E[_],M[_]),A(E[_],M[_+1],M[_])}}}};import{BufferGeometry as LI,Float32BufferAttribute as uf,Triangle as BI,Vector3 as Uo,Vector2 as df}from"three";var wi=class extends LI{constructor(t=[],e=[],r="",o=1,n=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],c=[];u(),d(),this.setAttribute("position",new uf(s,3)),this.setAttribute("normal",new uf(c,3)),this.setAttribute("uv",new uf(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}[r],h=new Uo,m=h.clone(),y=new BI,g=n*o,b=o-g,w=a+1,P=new Uo,S=(j,F)=>P.subVectors(j,F).normalize(),T=(j,F)=>Array(j).fill(void 0).map(F),A=T(t.length/3,(j,F)=>new Uo().fromArray(t,F*3).setLength(o)),x=[],N=1e6;for(let j=0;j<A.length;j++){let F=A[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(A[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 de=x[W]?.includes(j)==!0;te<=Y&&K.push(W+ +de*N),Z=H.findIndex(le=>le[0]==ee)}x.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 M=h.clone(),D=h.clone(),_=h.clone(),R=h.clone(),V=h.clone(),U=[],B=T(A.length,()=>T(f,()=>h.clone()));for(let j=0;j<A.length;j++){h.copy(A[j]).normalize(),M.copy(h).multiplyScalar(b);let F=x[j];for(let K=0;K<F.length;K++){let Z=F[K],Q=F[(K+1)%f];y.setFromPointsAndIndices(A,j,Z%N,Q%N),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(M,B[j][K])}let H=[],W=[],ee=[],te=new Uo;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],de=B[j][K];h.copy($).sub(M),m.copy(de).sub(M);let le=M.angleTo(h),ie=h.angleTo(m),ce=Math.cos(le)*g;a==0?D.copy(te):D.copy(M).setLength(b+ce),W.push(ce);let ae=[D,$,de];for(let me=0;me<2;me++){let fe=ae[me],he=ae[me+1];R.subVectors(fe,M),V.subVectors(he,M),_.crossVectors(R,V).normalize();for(let be=0;be<w;be++){let ye=[le,ie][me]*be/w;h.copy(R).applyAxisAngle(_,ye).add(M),H.push(h.clone()),me&&(S(h,M),Z.push([be==0?fe:h.clone(),P.clone()]))}me&&(S(he,M),Z.push([he,P.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(M).setLength(W[K]).add(M),$.push(h.clone());$.push(V)}for(let le=0;le<w;le++)$.push(H[le+w+Z]);$.push(H[Q+w]);let de=E.map(le=>$[le]);s.push(...de.map(le=>[le.x,le.y,le.z]).flat()),c.push(...de.map(le=>(S(le,M),[P.x,P.y,P.z])).flat())}}let q=[];for(let j=0;j<x.length;j++)for(let F=0;F<f;F++){let H=x[j][F];if(H<N){let W=x[H].findIndex(Y=>Y%N==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];P.subVectors(ee[0],ee[1]).cross(h.subVectors(ee[0],ee[2])).normalize();let te=P.dot(ee[0])<0;te&&P.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(P.x,P.y,P.z)})}}function d(){let p=new Uo;for(let A=0;A<s.length;A+=3){p.x=s[A+0],p.y=s[A+1],p.z=s[A+2];let x=S(p)/2/Math.PI+.5,N=T(p)/Math.PI+.5;l.push(x,1-N)}let f=new Uo,h=new Uo,m=new Uo,y=new Uo,g=new df,b=new df,w=new df,P=(A,x,N,E)=>{E<0&&A.x===1&&(l[x]=A.x-1),N.x===0&&N.z===0&&(l[x]=E/2/Math.PI+.5)};for(let A=0,x=0;A<s.length;A+=9,x+=6){f.set(s[A+0],s[A+1],s[A+2]),h.set(s[A+3],s[A+4],s[A+5]),m.set(s[A+6],s[A+7],s[A+8]),g.set(l[x+0],l[x+1]),b.set(l[x+2],l[x+3]),w.set(l[x+4],l[x+5]),y.copy(f).add(h).add(m).divideScalar(3);let N=S(y);P(g,x+0,f,N),P(b,x+2,h,N),P(w,x+4,m,N)}for(let A=0;A<l.length;A+=6){let x=l[A+0],N=l[A+2],E=l[A+4],M=Math.max(x,N,E),D=Math.min(x,N,E);M>.9&&D<.1&&(x<.2&&(l[A+0]+=1),N<.2&&(l[A+2]+=1),E<.2&&(l[A+4]+=1))}function S(A){return Math.atan2(A.z,-A.x)}function T(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(t){return new wi(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};import{DodecahedronGeometry as VI}from"three";var Nx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.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:t,height:e,depth:r,detail:o,corner:n,cornerSides:a}=i.parameters,s=o===0&&n!==0?new il(t*.5,n,a):new VI(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...i,type:"DodecahedronGeometry"}})}},il=class extends wi{constructor(t=1,e=.2,r=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,t,e,r),this.type=l}static fromJSON(t){return new il(t.radius,t.corner,t.cornerSides)}};import{Plane as XI,Shape as qx,Vector2 as ko,Vector3 as YI,MathUtils as xf,LineCurve as bf,QuadraticBezierCurve as $x,CubicBezierCurve as Cu}from"three";import{CubicBezierCurve as Pu,EllipseCurve as zI,LineCurve as Ou,LineCurve3 as GI,MathUtils as FI,QuadraticBezierCurve as ff,SplineCurve as jI,Vector2 as $t,Vector3 as Rx}from"three";var nl=1e-12,Ma=class{constructor(t){this.position=new $t;this.startPosition=new $t;this.uuid=FI.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Ma(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Ia=class extends Ma{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Ia(this.parent).copy(this)}},kr=class extends Ma{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Ia(this),new Ia(this))}static create(e,r){let o=new kr(e,new $t(...r.position));return o.controls[0].position.set(...r.controlPrevious.position),o.controls[1].position.set(...r.controlNext.position),o.roundness=r.roundness,o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,o}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let o=0,n=this.controls.length;o<n;o++){let a=this.controls[o];this.position.distanceTo(a.position)<=r?a.position.copy(this.position):a.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new kr(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),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new $t,r=new $t){let[o,n]=this.computeTangents();return o&&n&&(Dx(o,e),Dx(n,r)),[e,r]}computeTangent(e=new $t){let[r,o]=this.computeTangents();return r&&o&&e.copy(r).add(o).normalize(),e}computeNormal(e=new $t){let[r,o]=this.computeNormals();return e.copy(r).add(o).normalize(),e}};function Dx(i,t=new $t){let e=i.length();return t.set(-i.y/e,i.x/e)}var hf=i=>i,Ea=new $t,Tu=new $t,UI=new $t,kI=new $t,HI=new $t,WI=new $t,Lx=new Rx,Bx=new Rx;function Vx(i){let t=new $t;t.addVectors(i.v0,Ea.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new $t;return e.addVectors(i.v2,Tu.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new Pu(i.v0,t,e,i.v2)}function al(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function qI(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function $I(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function mf(i,t,e){let r=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),o=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.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+r*r-n*n)/(2*o*r))}function zx(i,t,e){return _x(i,t)&&_x(t,e)&&pf(i.position,t.position,e.position)}function pf(i,t,e){return Ea.copy(t).sub(i).cross(Tu.copy(e).sub(i))===0}function Gx(i,t,e,r,o){let n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),a=(i.y+t.y)/2,s=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(n/2,2))*(i.y-t.y)/n,c=Math.sqrt(Math.pow(e,2)-Math.pow(n/2,2))*(t.x-i.x)/n;return r.set(s+l,a+c),o.set(s-l,a-c),[r,o]}function Fx(i,t,e){let r=i.distanceTo(e),o=t.distanceTo(e);return r<o?t:i}function jx(i,t,e,r,o,n){let a=t.x-i.x,s=t.y-i.y,l=e.x-i.x,c=e.y-i.y,u=Math.sqrt((a+l)*(a+l)+(s+c)*(s+c)),d;return mf(t,i,e)>Math.PI&&(u*=-1),al(c,s)?d=(s+c)*(r/u-.5)*8/3/(a-l):d=(a+l)*(r/u-.5)*8/3/(c-s),o.set(t.x-d*s,t.y+d*a),n.set(e.x+d*c,e.y-d*l),[o,n]}function yf(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function _x(i,t){return pf(i.position,i.controls[1].position,t.position)&&pf(i.position,t.controls[0].position,t.position)}function Ux(i,t,e,r,o=.5){let n=Ea.subVectors(t,i).multiplyScalar(o).add(i),a=Tu.subVectors(e,t).multiplyScalar(o).add(t),s=UI.subVectors(r,e).multiplyScalar(o).add(e),l=n,c=kI.subVectors(a,n).multiplyScalar(o).add(n),u=HI.subVectors(s,a).multiplyScalar(o).add(a),d=s,p=WI.subVectors(u,c).multiplyScalar(o).add(c);return[i.x,i.y,l.x,l.y,c.x,c.y,p.x,p.y,u.x,u.y,d.x,d.y,r.x,r.y]}function kx(i,t,e=12,r=!0){let o=Bx.set(0,0,0),n,a=0,s=[];for(let l=0;l<t.length;l++){let c=hf(t[l]),u=Ea,d=Pi(c,e);s.push(d);for(let p=0;p<=d;p++)if(c instanceof Pu||c instanceof ff||c instanceof Ou){if(c.getPoint(p/d,u),o.set(u.x,u.y,0),n!==void 0&&$I(n,o))continue;n===void 0&&(n=Lx),n.copy(o),i.setXYZ(a,o.x,o.y,o.z),a++}}return r&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),i}function Hx(i,t,e,r=12,o=!0){let n=Bx.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,u=hf(t[l]),d=Ea,p=Pi(u,r);s.push(p);for(let f=0;f<=p;f++)if(u instanceof Pu||u instanceof ff||u instanceof Ou){if(u.getPoint(f/p,d),n.set(d.x,d.y,0),c?.equals(n))continue;c===void 0?c=Lx:(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 gf(i,t=12,e=!1){let r=[];for(let o=0,n=i.length;o<n;o++){let a=i[o],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=Pi(a.roundedCurveCorner,t)*.5;o>0&&(r[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=Pi(a.curveAfter,t)),r.push(s)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=Pi(i[0].roundedCurveCorner,t)*.5),r}function Pi(i,t=12){return i&&i instanceof zI?t*2:i&&(i instanceof Ou||i instanceof GI)?1:i&&i instanceof jI?t*i.points.length:t}function Wx(i,t,e=12,r=!0){let o,n=0;for(let a=0;a<t.length;a++){let s=hf(t[a]),l=Pi(s,e),c=Ea;for(let u=0;u<=l;u++)if(s instanceof Pu||s instanceof ff||s instanceof Ou){if(s.getPoint(u/l,c),o!==void 0&&qI(o,c,nl))continue;o===void 0&&(o=Tu),o.copy(c),i.push(c.x,c.y),n++}}return al(i[0],i[i.length-2],nl)&&al(i[1],i[i.length-1],nl)&&(i.pop(),i.pop()),r&&n>1&&!(al(i[n-1],i[1],nl)&&al(i[n-2],i[0],nl))&&(i.push(i[0],i[1]),n++),i}var vf=new ko,KI=new ko,QI=new ko,ZI=new ko,JI=new ko,e3=new ko,Ue=class extends qx{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new XI(new YI(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=xf.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,o){let n=new Ue;return n.isClosed=e.isClosed,n.points=e.points.map(a=>kr.create(a.id,a.data)),typeof e.roundness=="number"&&(n.roundness=e.roundness),n.shapeHoles=e.shapeHoles.map(a=>Ue.createFromState(a)),r!==void 0&&o!==void 0&&n.applySize(r,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 r=0,o=this.points.length;r<o;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,o=this.points.findIndex(n=>n.uuid===e);if(o<0){let n=r;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 r=this.points.length;for(let o=0,n=this.shapeHoles.length;o<n;o++){let a=this.shapeHoles[o],s=e-r;if(s<=a.points.length-1)return a.points[s];r+=a.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let o=0,n=this.shapeHoles.length;o<n;o++){let a=this.shapeHoles[o],s=a.points.indexOf(e);if(s>=0)return r+s;r+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let o=vf.set(e,r);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,r);this._update()}createPoint(e,r=0,o=xf.generateUUID()){let n;e instanceof ko?n=e:n=new ko(e,r);let a=new kr(o,n);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,o=this.points.length;r<o;r++){let n=this.points[r];if(n.uuid===e)return n}for(let r=0,o=this.shapeHoles.length;r<o;r++){let a=this.shapeHoles[r].getPointByUuid(e);if(a)return a}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(o=>o.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,o=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let n=o?this.roundedCurveDivisions:this.curveDivisions;return kx(e,o?this.roundedCurves:this.curves,r,this.autoClose),n.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=gf(this.points,e,!1),this.roundedCurveDivisions=gf(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,o=12){return Hx(e,this.curves,r,o,this.autoClose).reduce((a,s)=>a+s,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),Wx(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let n=r?this.roundedCurveDivisions:this.curveDivisions,a=0;r&&this.points[0].roundedCurveCorner!==void 0&&(a=Pi(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,r,o){let n=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(yf(n,a)){let d=n.position.distanceTo(a.position);return n.position.distanceTo(vf.set(o.x,o.y))/d}let c=0;for(let d=0;d<e;d++)c+=s[d];return(r-c)/l}dispose(){}_applyCurveForPoint(e,r){yf(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let o=this.curves[this.curves.length-1];e.curveBefore=o,r.curveAfter=o;let n=o.clone();e.roundedCurveBefore=n,r.roundedCurveAfter=n,e.roundedCurveCorner=void 0,this.roundedCurves.push(n)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,o=this.points.length;r<o;r++){let n=this.points[r];if(r===0)this.moveTo(n.position.x,n.position.y);else{let a=this.points[r-1];this._applyCurveForPoint(n,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],o=this.points[this.points.length-1];this._applyCurveForPoint(r,o)}if(this.points.length>2){let r=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&&zx(s,a,l);if(!a.controlsMoved()&&c>0&&!u){let d=a.curveBefore,p=a.curveAfter;if(d===void 0||p===void 0)continue;let f=a.roundedCurveBefore,h=a.roundedCurveAfter,m=d.getLength(),y=p.getLength(),g=Math.min(c,m*.499),b=Math.min(c,y*.499),w=Math.min(g,b),P=1-w/m,S=w/y,T=d.getPointAt(P,vf),A=p.getPointAt(S,KI);this._subSplitCurve(d,f,P,T,void 0),this._subSplitCurve(p,h,S,void 0,A);let x;if(this.useCubicForRoundedCorners){let N=mf(T,a.position,A)/2,E=Math.tan(N)*T.distanceTo(a.position),[M,D]=Gx(T,A,E,QI,ZI),_=Fx(M,D,a.position),[R,V]=jx(_,T,A,E,JI,e3);x=new Cu(T.clone(),R.clone(),V.clone(),A.clone())}else x=new $x(T.clone(),a.position.clone(),A.clone());a.roundedCurveCorner=x,this.roundedCurves.splice(o+r,0,x),r++}}}}_subSplitCurve(e,r,o,n,a){if(e instanceof bf)n!==void 0&&r.v2.copy(n),a!==void 0&&r.v1.copy(a);else{let s=e,l=r,c=s.getUtoTmapping(o,0),u=Ux(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 r}clone(){let e=new Ue(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let o=0;o<r;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],d=e.points[n+5],p=e.points[n+6],f=new kr(xf.generateUUID(),new ko(a,s));f.controls[0].position.set(l,c),f.controls[1].position.set(u,d),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let n=new Ue;return n.fromJSON(o),n}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let o=(a,s)=>{s instanceof Cu&&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]=Vx(a[l]));for(l=0,c=a.length;l<c;l++){let p=a[l],f=l>0?a[l-1]:null,h;p instanceof Cu?(h=this.createPoint(p.v0),h.controls[1].position.copy(p.v1)):p instanceof bf&&(h=this.createPoint(p.v1)),h!==void 0&&(f!==null&&o(h,f),s.push(h))}let u=a[a.length-1],d=!1;return u instanceof Cu?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),d=!0):u instanceof bf&&u.v2.equals(s[0].position)&&(d=!0),this.isClosed=d,s};return this.points=n(e.curves),e instanceof qx&&(this.shapeHoles=e.holes.map(a=>{let s=new Ue;return s.fromShape(a),s})),this.update(),this}updatePoint(e,r){let o=this.getPointByUuid(e);o&&(r.position!==void 0&&o.position.fromArray(r.position),r.roundness!==void 0&&(o.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let n=this.getPointByUuid(e)?.controls[0];n&&(r.position&&n.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let n=this.getPointByUuid(e)?.controls[1];n&&(r.position&&n.position.fromArray(r.position),this.needsUpdate=!0)}};var wf=Math.PI*2;function Sf({x:i,y:t},e,r,o,n){return{x:i*e+o,y:t*r+n}}function t3(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(i),o=Math.sin(i),n=Math.cos(i+t),a=Math.sin(i+t);return[{x:r-o*e,y:o+r*e},{x:n+a*e,y:a-n*e},{x:n,y:a}]}function Xx(i,t,e,r){let o=i*r-t*e<0?-1:1,n=Math.min(1,Math.max(-1,i*e+t*r));return o*Math.acos(n)}function r3(i,t,e,r,o,n,a,s,l,c){let u=Math.pow(o,2),d=Math.pow(n,2),p=Math.pow(a,2),f=Math.pow(s,2),h=u*d-u*f-d*p;h<0&&(h=0),h/=u*f+d*p,h=Math.sqrt(h)*(l===c?-1:1);let m=h*o/n*s,y=h*-n/o*a,g=m+(i+e)/2,b=y+(t+r)/2,w=(a-m)/o,P=(s-y)/n,S=(-a-m)/o,T=(-s-y)/n,A=Xx(1,0,w,P),x=Xx(w,P,S,T);return!c&&x>0&&(x-=wf),c&&x<0&&(x+=wf),{centerx:g,centery:b,ang1:A,ang2:x}}function Yx({px:i,py:t,cx:e,cy:r,rx:o,ry:n,largeArcFlag:a,sweepFlag:s}){let l=[];if(o===0||n===0)return[];let c=(i-e)/2,u=(t-r)/2;if(c===0&&u===0)return[];o=Math.abs(o),n=Math.abs(n);let d=Math.pow(c,2)/Math.pow(o,2)+Math.pow(u,2)/Math.pow(n,2);d>1&&(o*=Math.sqrt(d),n*=Math.sqrt(d));let p=r3(i,t,e,r,o,n,c,u,a,s),{ang1:f,ang2:h}=p,{centerx:m,centery:y}=p,g=Math.abs(h)/(wf/4);Math.abs(1-g)<1e-7&&(g=1);let b=Math.max(Math.ceil(g),1);h/=b;for(let w=0;w<b;w++)l.push(t3(f,h)),f+=h;return l.map(w=>{let{x:P,y:S}=Sf(w[0],o,n,m,y),{x:T,y:A}=Sf(w[1],o,n,m,y),{x,y:N}=Sf(w[2],o,n,m,y);return{x1:P,y1:S,x2:T,y2:A,x,y:N}})}import{BufferAttribute as Nu,BufferGeometry as f3}from"three";var je;(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"})(je||(je={}));var ct;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(ct||(ct={}));function Pe(i,t){if(!i)throw t||"Assertion Failed!"}var ve=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,r){Pe(i.vertLeq(t,e)&&i.vertLeq(e,r));var o=e.s-t.s,n=r.s-e.s;return o+n>0?o<n?e.t-t.t+(t.t-r.t)*(o/(o+n)):e.t-r.t+(r.t-t.t)*(n/(o+n)):0},i.edgeSign=function(t,e,r){Pe(i.vertLeq(t,e)&&i.vertLeq(e,r));var o=e.s-t.s,n=r.s-e.s;return o+n>0?(e.t-r.t)*o+(e.t-t.t)*n:0},i.transEval=function(t,e,r){Pe(i.transLeq(t,e)&&i.transLeq(e,r));var o=e.t-t.t,n=r.t-e.t;return o+n>0?o<n?e.s-t.s+(t.s-r.s)*(o/(o+n)):e.s-r.s+(r.s-t.s)*(n/(o+n)):0},i.transSign=function(t,e,r){Pe(i.transLeq(t,e)&&i.transLeq(e,r));var o=e.t-t.t,n=r.t-e.t;return o+n>0?(e.s-r.s)*o+(e.s-t.s)*n:0},i.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},i.interpolate=function(t,e,r,o){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+o)/2:e+(o-e)*(t/(t+r)):o+(e-o)*(r/(t+r))},i.intersect=function(t,e,r,o,n){var a,s,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(r,o)||(l=r,r=o,o=l),i.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),i.vertLeq(r,e)?i.vertLeq(e,o)?(a=i.edgeEval(t,r,e),s=i.edgeEval(r,e,o),a+s<0&&(a=-a,s=-s),n.s=i.interpolate(a,r.s,s,e.s)):(a=i.edgeSign(t,r,e),s=-i.edgeSign(t,o,e),a+s<0&&(a=-a,s=-s),n.s=i.interpolate(a,r.s,s,o.s)):n.s=(r.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(r,o)||(l=r,r=o,o=l),i.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),i.transLeq(r,e)?i.transLeq(e,o)?(a=i.transEval(t,r,e),s=i.transEval(r,e,o),a+s<0&&(a=-a,s=-s),n.t=i.interpolate(a,r.t,s,e.t)):(a=i.transSign(t,r,e),s=-i.transSign(t,o,e),a+s<0&&(a=-a,s=-s),n.t=i.interpolate(a,r.t,s,o.t)):n.t=(r.t+e.t)/2},i}(),sl=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}(),Au=function(){function i(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),Na=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}(),Kx=function(){function i(){var t=new Na,e=new sl,r=new Au(0),o=new Au(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=o,o.next=o,o.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=o}return i.prototype.makeEdge_=function(t){var e=new Au(0),r=new Au(1);t.Sym.side<t.side&&(t=t.Sym);var o=t.Sym.next;return r.next=o,o.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},i.prototype.splice_=function(t,e){var r=t.Onext,o=e.Onext;r.Sym.Lnext=e,o.Sym.Lnext=t,t.Onext=o,e.Onext=r},i.prototype.makeVertex_=function(t,e,r){var o=t;Pe(o,"Vertex can't be null!");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=e;var a=e;do a.Org=o,a=a.Onext;while(a!==e)},i.prototype.makeFace_=function(t,e,r){var o=t;Pe(o,"Face can't be null");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=r.inside;var a=e;do a.Lface=o,a=a.Lnext;while(a!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},i.prototype.killVertex_=function(t,e){var r=t.anEdge,o=r;do o.Org=e,o=o.Onext;while(o!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},i.prototype.killFace_=function(t,e){var r=t.anEdge,o=r;do o.Lface=e,o=o.Lnext;while(o!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},i.prototype.makeEdge=function(){var t=new Na,e=new Na,r=new sl,o=this.makeEdge_(this.eHead);return this.makeVertex_(t,o,this.vHead),this.makeVertex_(e,o.Sym,this.vHead),this.makeFace_(r,o,this.fHead),o},i.prototype.splice=function(t,e){var r=!1,o=!1;if(t!==e){if(e.Org!==t.Org&&(o=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!o){var n=new Na;this.makeVertex_(n,e,t.Org),t.Org.anEdge=t}if(!r){var a=new sl;this.makeFace_(a,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var o=new sl;this.makeFace_(o,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var o=new Na;return this.makeVertex_(o,r,e.Org),e.Lface=r.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},i.prototype.connect=function(t,e){var r=!1,o=this.makeEdge_(t),n=o.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(o,t.Lnext),this.splice_(n,e),o.Org=t.Dst,n.Org=e.Org,o.Lface=n.Lface=t.Lface,t.Lface.anEdge=n,!r){var a=new sl;this.makeFace_(a,o,t.Lface)}return o},i.prototype.zapFace=function(t){var e=t.anEdge,r,o,n,a,s;o=e.Lnext;do r=o,o=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),n=r.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=e);a=t.prev,s=t.next,s.prev=a,a.next=s},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},i.prototype.mergeConvexFaces=function(t){var e,r,o,n,a,s,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,a=r.Org;o=r.Lnext,n=r.Sym,n&&n.Lface&&n.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(n.Lface),s+l-2<=t&&ve.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&ve.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(o=n.Lnext,this.delete(n),r=null,n=null)),!(r&&r.Lnext.Org===a);)r=o;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,o,n,a,s,l,c;for(n=t,n=t;(o=n.next)!==t;n=o){Pe(o.prev===n),l=o.anEdge;do Pe(l.Sym!==l),Pe(l.Sym.Sym===l),Pe(l.Lnext.Onext.Sym===l),Pe(l.Onext.Sym.Lnext===l),Pe(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(Pe(o.prev===n&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){Pe(a.prev===s),l=a.anEdge;do Pe(l.Sym!==l),Pe(l.Sym.Sym===l),Pe(l.Lnext.Onext.Sym===l),Pe(l.Onext.Sym.Lnext===l),Pe(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(Pe(a.prev===s&&a.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)Pe(l.Sym.next===c.Sym),Pe(l.Sym!==l),Pe(l.Sym.Sym===l),Pe(l.Org!==null),Pe(l.Dst!==null),Pe(l.Lnext.Onext.Sym===l),Pe(l.Onext.Sym.Lnext===l);Pe(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),Qx=function(){function i(){this.handle=null}return i}(),Zx=function(){function i(){this.key=null,this.node=0}return i}(),o3=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new Qx,this.handles[r]=new Zx;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,o,n,a;for(o=e[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[e[a+1].handle].key,r[e[a].handle].key)&&++a,Pe(a<=this.max),n=e[a].handle,a>this.size||this.leq(r[o].key,r[n].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=n,r[n].node=t,t=a}},i.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,o,n,a;for(o=e[t].handle;;){if(a=t>>1,n=e[a].handle,a===0||this.leq(r[n].key,r[o].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=n,r[n].node=t,t=a}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var o,n;for(n=this.nodes.length,this.nodes.length=this.max+1,o=n;o<this.nodes.length;o++)this.nodes[o]=new Qx;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?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,o=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),o},i.prototype.delete=function(t){var e=this.nodes,r=this.handles,o;Pe(t>=1&&t<=this.max&&r[t].key!==null),o=r[t].node,e[o].handle=e[this.size].handle,r[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(r[e[o>>1].handle].key,r[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},i}(),Pf=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}(),Jx=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),i3=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new Jx,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new Jx;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),n3=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,r){var o=t.event,n=e.eUp,a=r.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(t,e){e.fixUpperEdge&&Pe(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){Pe(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},i.topLeftRegion=function(t,e){var r=e.eUp.Org,o;do e=i.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(o=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;i.fixUpperEdge(t,e,o),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,r){var o=new Pf;return o.eUp=r,o.nodeUp=t.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,r.activeRegion=o,o},i.isWindingInside=function(t,e){switch(t.windingRule){case je.ODD:return(e&1)!==0;case je.NONZERO:return e!==0;case je.POSITIVE:return e>0;case je.NEGATIVE:return e<0;case je.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var r=e.eUp,o=r.Lface;o.inside=e.inside,o.anEdge=r,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,r){for(var o,n=null,a=e,s=e.eUp;a!==r;){if(a.fixUpperEdge=!1,n=i.regionBelow(a),o=n.eUp,o.Org!=s.Org){if(!n.fixUpperEdge){i.finishRegion(t,a);break}o=t.mesh.connect(s.Lprev,o.Sym),i.fixUpperEdge(t,n,o)}s.Onext!==o&&(t.mesh.splice(o.Oprev,o),t.mesh.splice(s,o)),i.finishRegion(t,a),s=n.eUp,a=n}return s},i.addRightEdges=function(t,e,r,o,n,a){var s,l,c,u,d=!0;c=r;do Pe(ve.vertLeq(c.Org,c.Dst)),i.addRegionBelow(t,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&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(u.Oprev,c)),s.windingNumber=l.windingNumber-c.winding,s.inside=i.isWindingInside(t,s.windingNumber),l.dirty=!0,!d&&i.checkForRightSplice(t,l)&&(i.addWinding(c,u),i.deleteRegion(t,l),t.mesh.delete(u)),d=!1,l=s,u=c;l.dirty=!0,Pe(l.windingNumber-c.winding===s.windingNumber),a&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},i.vertexWeights=function(t,e,r){var o=ve.vertL1dist(e,t),n=ve.vertL1dist(r,t),a=.5*n/(o+n),s=.5*o/(o+n);t.coords[0]+=a*e.coords[0]+s*r.coords[0],t.coords[1]+=a*e.coords[1]+s*r.coords[1],t.coords[2]+=a*e.coords[2]+s*r.coords[2]},i.getIntersectData=function(t,e,r,o,n,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,r,o),i.vertexWeights(e,n,a)},i.checkForRightSplice=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.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&&(t.pq.delete(o.Org.pqHandle),i.spliceMergeVertices(t,n.Oprev,o)):(t.mesh.splitEdge(n.Sym),t.mesh.splice(o,n.Oprev),e.dirty=r.dirty=!0)}else{if(ve.edgeSign(o.Dst,n.Org,o.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Oprev,o)}return!0},i.checkForLeftSplice=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.eUp,a;if(Pe(!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=t.mesh.splitEdge(o),t.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=r.dirty=!0,a=t.mesh.splitEdge(n),t.mesh.splice(o.Lnext,n.Sym),a.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.eUp,a=o.Org,s=n.Org,l=o.Dst,c=n.Dst,u,d,p=new Na,f,h;if(Pe(!ve.vertEq(c,l)),Pe(ve.edgeSign(l,t.event,a)<=0),Pe(ve.edgeSign(c,t.event,s)>=0),Pe(a!==t.event&&s!==t.event),Pe(!e.fixUpperEdge&&!r.fixUpperEdge),a===s||(u=Math.min(a.t,l.t),d=Math.max(s.t,c.t),u>d))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(t),ve.intersect(l,a,c,s,p),Pe(Math.min(a.t,l.t)<=p.t),Pe(p.t<=Math.max(s.t,c.t)),Pe(Math.min(c.s,l.s)<=p.s),Pe(p.s<=Math.max(s.s,a.s)),ve.vertLeq(p,t.event)&&(p.s=t.event.s,p.t=t.event.t),f=ve.vertLeq(a,s)?a:s,ve.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),ve.vertEq(p,a)||ve.vertEq(p,s)?(i.checkForRightSplice(t,e),!1):!ve.vertEq(l,t.event)&&ve.edgeSign(l,t.event,p)>=0||!ve.vertEq(c,t.event)&&ve.edgeSign(c,t.event,p)<=0?c===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Sym,o),e=i.topLeftRegion(t,e),o=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),r),i.addRightEdges(t,e,o.Oprev,o,o,!0),!0):l===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(o.Lnext,n.Oprev),r=e,e=i.topRightRegion(e),h=i.regionBelow(e).eUp.Rprev,r.eUp=n.Oprev,n=i.finishLeftRegions(t,r,null),i.addRightEdges(t,e,n.Onext,o.Rprev,h,!0),!0):(ve.edgeSign(l,t.event,p)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),ve.edgeSign(c,t.event,p)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),!1):(t.mesh.splitEdge(o.Sym),t.mesh.splitEdge(n.Sym),t.mesh.splice(n.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=t.pq.insert(o.Org),i.getIntersectData(t,o.Org,a,l,s,c),i.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var r=i.regionBelow(e),o,n;;){for(;r.dirty;)e=r,r=i.regionBelow(r);if(!e.dirty&&(r=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,n=r.eUp,o.Dst!==n.Dst&&i.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(i.deleteRegion(t,r),t.mesh.delete(n),r=i.regionBelow(e),n=r.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(o),e=i.regionAbove(r),o=e.eUp)),o.Org!==n.Org)if(o.Dst!==n.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(o.Dst===t.event||n.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);o.Org===n.Org&&o.Dst===n.Dst&&(i.addWinding(n,o),i.deleteRegion(t,e),t.mesh.delete(o),e=i.regionAbove(r))}},i.connectRightVertex=function(t,e,r){var o,n=r.Onext,a=i.regionBelow(e),s=e.eUp,l=a.eUp,c=!1;if(s.Dst!==l.Dst&&i.checkForIntersect(t,e),ve.vertEq(s.Org,t.event)&&(t.mesh.splice(n.Oprev,s),e=i.topLeftRegion(t,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),a),c=!0),ve.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(t,a,null),c=!0),c){i.addRightEdges(t,e,r.Onext,n,n,!0);return}ve.vertLeq(l.Org,s.Org)?o=l.Oprev:o=s,o=t.mesh.connect(r.Lprev,o),i.addRightEdges(t,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,r){var o,n,a,s,l;if(o=e.eUp,ve.vertEq(o.Org,r)){Pe(!1),i.spliceMergeVertices(t,o,r.anEdge);return}if(!ve.vertEq(o.Dst,r)){t.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(t.mesh.delete(o.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,o),i.sweepEvent(t,r);return}Pe(!1),e=i.topRightRegion(e),l=i.regionBelow(e),a=l.eUp.Sym,n=s=a.Onext,l.fixUpperEdge&&(Pe(n!==a),i.deleteRegion(t,l),t.mesh.delete(a),a=n.Oprev),t.mesh.splice(r.anEdge,a),ve.edgeGoesLeft(n)||(n=null),i.addRightEdges(t,e,a.Onext,s,n,!0)},i.connectLeftVertex=function(t,e){var r,o,n,a,s,l,c=new Pf;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,o=i.regionBelow(r),!!o){if(a=r.eUp,s=o.eUp,ve.edgeSign(a.Dst,e,a.Org)===0){i.connectLeftDegenerate(t,r,e);return}if(n=ve.vertLeq(s.Dst,a.Dst)?r:o,r.inside||n.fixUpperEdge){if(n===r)l=t.mesh.connect(e.anEdge.Sym,a.Lnext);else{var u=t.mesh.connect(s.Dnext,e.anEdge);l=u.Sym}n.fixUpperEdge?i.fixUpperEdge(t,n,l):i.computeWinding(t,i.addRegionBelow(t,r,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){i.connectLeftVertex(t,e);return}var o=i.topLeftRegion(t,r.activeRegion);Pe(o!==null);var n=i.regionBelow(o),a=n.eUp,s=i.finishLeftRegions(t,n,null);s.Onext===a?i.connectRightVertex(t,o,s):i.addRightEdges(t,o,s.Onext,a,a,!0)},i.addSentinel=function(t,e,r,o){var n=new Pf,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=o,a.Dst.s=e,a.Dst.t=o,t.event=a.Dst,n.eUp=a,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=t.dict.insert(n)},i.initEdgeDict=function(t){t.dict=new i3(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],o=t.bmin[0]-e,n=t.bmax[0]+e,a=t.bmin[1]-r,s=t.bmax[1]+r;i.addSentinel(t,o,n,a),i.addSentinel(t,o,n,s)},i.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(Pe(e.fixUpperEdge),Pe(++r===1)),Pe(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,r,o,n=t.mesh.eHead;for(e=n.next;e!==n;e=r)r=e.next,o=e.Lnext,ve.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,o,e),t.mesh.delete(e),e=o,o=e.Lnext),o.Lnext===e&&(o!==e&&((o===r||o===r.Sym)&&(r=r.next),t.mesh.delete(o)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,r,o,n=0;for(o=t.mesh.vHead,r=o.next;r!==o;r=r.next)n++;for(n+=8,e=t.pq=new o3(n,ve.vertLeq),o=t.mesh.vHead,r=o.next;r!==o;r=r.next)r.pqHandle=e.insert(r);return r!==o?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var r,o,n;for(r=e.fHead.next;r!==e.fHead;r=o)o=r.next,n=r.anEdge,Pe(n.Lnext!==n),n.Lnext.Lnext===n&&(i.addWinding(n.Onext,n),t.mesh.delete(n));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var r,o;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;o=t.pq.min(),!(o===null||!ve.vertEq(o,r));)o=t.pq.extractMin(),i.spliceMergeVertices(t,r.anEdge,o.anEdge);i.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),a3=function(){function i(){this.mesh=new Kx,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=je.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,r,o,n,a,s,l=[0,0,0],c=[0,0,0],u=[0,0,0],d=[0,0,0],p=[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 g=0;g<3;++g)n=e.coords[g],n<c[g]&&(c[g]=n,h[g]=e),n>l[g]&&(l[g]=n,f[g]=e);var b=0;if(l[1]-c[1]>l[0]-c[0]&&(b=1),l[2]-c[2]>l[b]-c[b]&&(b=2),c[b]>=l[b]){t[0]=0,t[1]=0,t[2]=1;return}for(s=0,r=h[b],o=f[b],u[0]=r.coords[0]-o.coords[0],u[1]=r.coords[1]-o.coords[1],u[2]=r.coords[2]-o.coords[2],e=m.next;e!==m;e=e.next)d[0]=e.coords[0]-o.coords[0],d[1]=e.coords[1]-o.coords[1],d[2]=e.coords[2]-o.coords[2],p[0]=u[1]*d[2]-u[2]*d[1],p[1]=u[2]*d[0]-u[0]*d[2],p[2]=u[0]*d[1]-u[1]*d[0],a=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],a>s&&(s=a,t[0]=p[0],t[1]=p[1],t[2]=p[2]);s<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(u)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,o,n=0,a=t.next;a!==t;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=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,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),r=this.sUnit,o=this.tUnit;var a=this.longAxis_(e);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,o[a]=0,o[(a+1)%3]=0,o[(a+2)%3]=e[a]>0?1:-1;for(var s=t.next;s!==t;s=s.next)s.s=this.dot_(s.coords,r),s.t=this.dot_(s.coords,o);n&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var r,o;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;ve.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ve.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var n=void 0;r.Lnext!==o;)if(ve.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(ve.edgeGoesLeft(o.Lnext)||ve.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)n=t.connect(o.Lnext,o),o=n.Sym;o=o.Lprev}else{for(;o.Lnext!==r&&(ve.edgeGoesRight(r.Lprev)||ve.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)n=t.connect(r,r.Lprev),r=n.Sym;r=r.Lnext}if(o.Lnext===r)throw"Mono region invalid";for(;o.Lnext.Lnext!==r;)n=t.connect(o.Lnext,o),o=n.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},i.prototype.setWindingNumber_=function(t,e,r){for(var o,n=t.eHead.next;n!==t.eHead;n=o)o=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?e:-e:r?t.delete(n):n.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,r,o){var n,a=0,s=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var u=t.fHead.next;u!==t.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>r)throw"Face vertex greater that support polygon";u.n=a,++a}this.elementCount=a,e===ct.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=s,this.vertices=[],this.vertices.length=s*o,this.vertexIndices=[],this.vertexIndices.length=s;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var d=c.n*o;this.vertices[d+0]=c.coords[0],this.vertices[d+1]=c.coords[1],o>2&&(this.vertices[d+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var p=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(!!u.inside){n=u.anEdge,l=0;do{var c=n.Org;this.elements[p++]=c.n,l++,n=n.Lnext}while(n!==u.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1;if(e===ct.CONNECTED_POLYGONS){n=u.anEdge;do this.elements[p++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==u.anEdge);for(var h=l;h<r;++h)this.elements[p++]=-1}}},i.prototype.outputContours_=function(t,e){var r,o,n=0,a=0;this.vertexCount=0,this.elementCount=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){o=r=s.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==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=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){a=0,o=r=s.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==o);this.elements[u++]=n,this.elements[u++]=a,n+=a}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new Kx),t<2&&(t=2),t>3&&(t=3);for(var r=null,o=0;o<e.length;o+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[o+0],r.Org.coords[1]=e[o+1],t>2?r.Org.coords[2]=e[o+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(t,e,r,o,n,a){if(t===void 0&&(t=je.ODD),e===void 0&&(e=ct.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=t,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),n3.computeInterior(this,a);var s=this.mesh;return e===ct.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===ct.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,r,o),!0},i}();function Hr(i){var t=i.windingRule,e=t===void 0?je.ODD:t,r=i.elementType,o=r===void 0?ct.POLYGONS:r,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,d=i.contours,p=d===void 0?[]:d,f=i.strict,h=f===void 0?!0:f,m=i.debug,y=m===void 0?!1:m;if(!p&&h)throw new Error("Contours can't be empty");if(!!p){var g=new a3;i.edgeCreateCallback&&(g.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(g.vertexIdCallback=i.vertexIdCallback);for(var b=0;b<p.length;b++)g.addContour(l||2,p[b]);return g.tesselate(e,o,a,l,u,h),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var Nq=je.ODD,Dq=je.NONZERO,_q=je.POSITIVE,Rq=je.NEGATIVE,Lq=je.ABS_GEQ_TWO,Bq=ct.POLYGONS,Vq=ct.CONNECTED_POLYGONS,zq=ct.BOUNDARY_CONTOURS;import{Box2 as u3,BufferAttribute as Eu,BufferGeometry as d3,Vector2 as p3}from"three";var Mu=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*Mu.eSize;this.buffer=new ArrayBuffer(r);let o=Float32Array.BYTES_PER_ELEMENT,n=0;this.positions=new Float32Array(this.buffer,n*o,3*t),n+=3*t,this.normals=new Float32Array(this.buffer,n*o,3*t),n+=3*t,this.uvs=new Float32Array(this.buffer,n*o,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*Mu.eSize,o=new ArrayBuffer(r),n=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*n,3*t);a+=3*t;let l=new Float32Array(o,a*n,3*t);a+=3*t;let c=new Float32Array(o,a*n,2*t);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=t}get(t=1){let e=this.size+t;if(e>this.capacity){let o=this.capacity;for(;e>o;)o*=2;this.realloc(o)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},ll=Mu;ll.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var cl=class{constructor(t=[],e=(r,o)=>r<o?-1:r>o?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:e,compare:r}=this,o=e[t];for(;t>0;){let n=t-1>>1,a=e[n];if(r(o,a)>=0)break;e[t]=a,t=n}e[t]=o}_down(t){let{data:e,compare:r}=this,o=this.length>>1,n=e[t];for(;t<o;){let a=(t<<1)+1,s=a+1;if(s<this.length&&r(e[s],e[a])<0&&(a=s),r(e[a],n)>=0)break;e[t]=e[a],t=a}e[t]=n}};function Of(i,t,e=1,r=!1){let o=1/0,n=1/0,a=-1/0,s=-1/0;for(let[b,w]of i[0])b<o&&(o=b),w<n&&(n=w),b>a&&(a=b),w>s&&(s=w);let l=a-o,c=s-n,u=Math.max(e,Math.min(l,c));if(u===e){let b=[o,n];return b.distance=0,b.distance}let d=new cl([],(b,w)=>w.max-b.max),p=l3(i),f=new Iu(o+l/2,n+c/2,0,i);f.d>p.d&&(p=f);let h=2;function m(b,w,P){let S=new Iu(b,w,P,i);if(h++,S.max>p.d+e&&d.push(S),S.d>p.d&&(p=S,r&&console.log(`found best ${Math.round(1e4*S.d)/1e4} after ${h} probes`),p.d>t))return t}let y=u/2;for(let b=o;b<a;b+=u)for(let w=n;w<s;w+=u)m(b+y,w+y,y);for(;d.length;){let{max:b,x:w,y:P,h:S}=d.pop();if(b-p.d<=e)break;y=S/2,m(w-y,P-y,y),m(w+y,P-y,y),m(w-y,P+y,y),m(w+y,P+y,y)}r&&console.log(`num probes: ${h}
|
|
3
3
|
best distance: ${p.d}`);let g=[p.x,p.y];return g.distance=p.d,g.distance}function Iu(i,t,e,r){this.x=i,this.y=t,this.h=e,this.d=s3(i,t,r),this.max=this.d+this.h*Math.SQRT2}function s3(i,t,e){let r=!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]>t!=u[1]>t&&i<(u[0]-c[0])*(t-c[1])/(u[1]-c[1])+c[0]&&(r=!r),o=Math.min(o,c3(i,t,c,u))}return o===0?0:(r?1:-1)*Math.sqrt(o)}function l3(i){let t=0,e=0,r=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],d=c[0]*u[1]-u[0]*c[1];e+=(c[0]+u[0])*d,r+=(c[1]+u[1])*d,t+=d*3}let n=new Iu(e/t,r/t,0,i);return t===0||n.d<0?new Iu(o[0][0],o[0][1],0,i):n}function c3(i,t,e,r){let o=e[0],n=e[1],a=r[0]-o,s=r[1]-n;if(a!==0||s!==0){let l=((i-o)*a+(t-n)*s)/(a*a+s*s);l>1?(o=r[0],n=r[1]):l>0&&(o+=a*l,n+=s*l)}return a=i-o,s=t-n,a*a+s*s}var ul={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Cf={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Af={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},Tf=(i,t)=>([e,r])=>(r<e&&(r+=t),(i>=e?i:i+t)<=r),Oi=class extends d3{constructor(e,r,o=0,n=12,a=3,s=je.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=n,this._bevelSegmentsInput=a;let c=this._shape.extractShapePointsToFlatArray([],n),u=this._shape.shapeHoles.map(M=>{let D=M.extractShapePointsToFlatArray([],n),_=[];for(let R=D.length-1;R>=1;R-=2){let V=D[R-1],U=D[R-0];_.push(V,U)}return _}),d=[],p=[];for(let M=0;M<c.length;M+=2)p.push([c[M],c[M+1]]);d.push(p);for(let M=0;M<u.length;M++){let D=u[M],_=[];for(let R=0;R<D.length;R+=2)_.push([D[R],D[R+1]]);d.push(_)}let f;e.isText?f=new u3().setFromPoints(e.points.map(D=>D.position)).getSize(new p3).length()*.1:d[0].length===0?f=o:o>0?f=Of(d,o):f=1e-5,o<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(o,f,r/2),this._bevelSegments=Math.floor(a));let h;try{h=Hr({windingRule:s,elementType:ct.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{h=ul}let m;try{m=Hr({windingRule:je.ODD,elementType:ct.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{m=Cf}if(!h)throw new Error("error generating geometry");let y=h.elementCount;if(m){h.elementCount+=m.elementCount;for(let M=0;M<m.elements.length;M++){let D=m.elements[M],_=M%2===0?h.vertexCount:0;h.elements.push(D+_)}for(let M=0;M<m.vertexIndices.length;M++){let D=m.vertexIndices[M],_=h.vertexCount;h.vertexIndices.push(D+_)}for(let M=0;M<m.vertices.length;M++){let D=m.vertices[M];h.vertices.push(D)}}let g=1/0,b=-1/0,w=1/0,P=-1/0;for(let M=0,D=h.vertexCount;M<D;M++){let _=M*2,R=h.vertices[_+0],V=h.vertices[_+1];R<g&&(g=R),R>b&&(b=R),V<w&&(w=V),V>P&&(P=V)}this._minX=g,this._minY=w,this._width=b-g,this._height=P-w,this._buffer=new ll(this._computeBufferEstimatedSize(h));let S=[],T=[];for(let M=h.elementCount-1;M>=0;M--){let D=M>=y,_=M*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],de=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-de,fe=$-le,he=Math.sqrt(me*me+fe*fe);me/=he,fe/=he,B.normals[re*2+0]=-fe,B.normals[re*2+1]=me,B.concave[re]=ie*fe-ce*me>0;let be=h.vertexIndices[q];if(Array.isArray(be))B.continuous[re]=!1;else{let[ye,C]=this._shape.getCurveIndexFromVertexId(be-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 De=C===1?0:1,ze=this._shape.roundedCurves[ye].getTangent(C),Re=this._shape.roundedCurves[ne].getTangent(De);B.continuous[re]=ze.dot(Re)>.95}}D&&(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=[],$=[],de=[],le=[],ie=0;for(let ae=0;ae<V;ae++){let me=ae*2,fe=(ae-1+V)%V*2,he=h.vertices[B.start*2+me+0],be=h.vertices[B.start*2+me+1],ye=-B.normals[fe+0]*Z,C=-B.normals[fe+1]*Z,ne=-B.normals[me+0]*Z,De=-B.normals[me+1]*Z;if(B.concave[ae]||!B.concave[ae]&&D){let ze=Math.atan2(C,ye),Re=Math.atan2(De,ne);Re>ze&&(Re-=Math.PI*2);let Oe=Re-ze;if(B.continuous[ae]||D){let Ot=ze+Oe/2,Ie=Math.cos(Ot)*Z,wt=Math.sin(Ot)*Z;Q[2*ie+0]=he+Ie*(D?-1:1),Q[2*ie+1]=be+wt*(D?-1:1),le[ie]=ae,ie++}else{let Ot=Math.max(1,Math.floor(n/4*Math.abs(Oe)/Math.PI));for(let Ie=0;Ie<=Ot;Ie++){let wt=ze+Oe*(Ie/Ot),Tt=Math.cos(wt)*Z,$i=Math.sin(wt)*Z;Q[2*ie+0]=he+Tt,Q[2*ie+1]=be+$i,le[ie]=ae,ie++}}}else Q[2*ie+0]=he+ye,Q[2*ie+1]=be+C,le[ie]=ae,$[ae]=ie,ie++,Q[2*ie+0]=he,Q[2*ie+1]=be,le[ie]=ae,ie++,Q[2*ie+0]=he+ne,Q[2*ie+1]=be+De,le[ie]=ae,de[ae]=ie,ie++}let ce=Hr({windingRule:je.POSITIVE,elementType:ct.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Q],edgeCreateCallback:ae=>{let fe=ae.Org.idx,he=le[fe],be=le[(fe+1)%le.length];ae.idx=[he,be],ae.Sym.idx=[be,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,fe]=ce.vertexIndices[ae];if(me===fe)continue;let he=fe;fe<me&&(he+=V);for(let be=me;be<he;be++){let ye=be%V,C=(be+1)%V;if(!B.continuous[ye]||!B.continuous[C]){ce.vertexIndices[ae]=[me,ye],ce.vertexIndices.splice(ae+1,0,[C,fe]),ce.vertices.splice((ae+1)*2,0,ce.vertices[ae*2],ce.vertices[ae*2+1]);break}}}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 de=B.concave.length,le=0,ie=Tf(le,V);for(;!K.boundary.vertexIndices.filter(ie).length||!Z.boundary.vertexIndices.filter(ie).length;)le++,ie=Tf(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,fe=0,he=this._buildBevelVert(B,K,(ce-1+Q)%Q,void 0,fe),be=this._buildBevelVert(B,Z,(ae-1+$)%$,void 0,fe),ye=he,C=be,ne,De,ze=!1;do{fe=(le||de)/de,ie=Tf(le,V);let Re=te(K,ce,ie),Oe=te(Z,ae,ie),Ot=ze;if(ze=!1,Re&&!Oe){for(let Ie=0;Ie<Re;Ie++)ne=this._buildBevelVert(B,K,(ce+Ie)%Q,Ie/(Re-1),fe),S.push(ye.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,ye.bottomN,C.bottomN),ye=ne;ze=!0}else if(!Re&&Oe)for(let Ie=0;Ie<Oe;Ie++)De=this._buildBevelVert(B,Z,(ae+Ie)%$,Ie/(Oe-1),fe),S.push(C.topN,ye.topP,De.topP),l===!1&&S.push(ye.bottomP,C.bottomN,De.bottomP),C=De;else if(Re&&Oe)if(ne=this._buildBevelVert(B,K,ce,0,fe),De=this._buildBevelVert(B,Z,ae,0,fe),Ot?(S.push(ye.topN,De.topP,C.topN),S.push(ye.topN,ne.topP,De.topP),l===!1&&(S.push(De.bottomP,ye.bottomN,C.bottomN),S.push(De.bottomP,ne.bottomP,ye.bottomN))):(S.push(C.topN,ye.topN,ne.topP),S.push(C.topN,ne.topP,De.topP),l===!1&&(S.push(ne.bottomP,ye.bottomN,C.bottomN),S.push(ne.bottomP,C.bottomN,De.bottomP))),ye=ne,C=De,Re===Oe)for(let Ie=1;Ie<Re;Ie++)ne=this._buildBevelVert(B,K,(ce+Ie)%Q,Ie/(Re-1),fe),De=this._buildBevelVert(B,Z,(ae+Ie)%$,Ie/(Oe-1),fe),S.push(ye.topN,ne.topP,C.topN),S.push(C.topN,ne.topP,De.topP),l===!1&&(S.push(ne.bottomP,ye.bottomN,C.bottomN),S.push(ne.bottomP,C.bottomN,De.bottomP)),ye=ne,C=De;else if(Re>Oe){let Ie=Re/Oe,wt=0;for(let Tt=1;Tt<Re;Tt++)ne=this._buildBevelVert(B,K,(ce+Tt)%Q,Tt/(Re-1),fe),S.push(ye.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,ye.bottomN,C.bottomN),ye=ne,Tt>(wt+1)*Ie&&(wt++,De=this._buildBevelVert(B,Z,(ae+wt)%$,wt/(Oe-1),fe),S.push(C.topN,ne.topP,De.topP),l===!1&&S.push(ne.bottomP,C.bottomN,De.bottomP),C=De)}else{let Ie=Oe/Re,wt=0;for(let Tt=1;Tt<Oe;Tt++)De=this._buildBevelVert(B,Z,(ae+Tt)%$,Tt/(Oe-1),fe),S.push(C.topN,ne.topP,De.topP),l===!1&&S.push(ne.bottomP,C.bottomN,De.bottomP),C=De,Tt>(wt+1)*Ie&&(wt++,ne=this._buildBevelVert(B,K,(ce+wt)%Q,wt/(Re-1),fe),S.push(ye.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,ye.bottomN,C.bottomN),ye=ne)}ce=(ce+Re)%Q,ae=(ae+Oe)%$,le=(le+1)%de}while(le!==me)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(W,B,S),D){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(D){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(!D){let re=W[W.length-1],K;try{K=Hr({windingRule:W.length>1?je.POSITIVE:je.ODD,elementType:ct.POLYGONS,vertexSize:2,strict:!0,contours:[re.insetPoints,...T]})}catch{K=Af}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),de=this._buildSurfaceVert(K,K.elements[Z+2],ee);S.push(Q.top,$.top,de.top),l===!1&&S.push(de.bottom,$.bottom,Q.bottom)}}this.vertexCache={}}this._buffer.shrink();let A=new Eu(Uint32Array.from(S),1),x=new Eu(this._buffer.positions,3),N=new Eu(this._buffer.normals,3),E=new Eu(this._buffer.uvs,2);x.needsUpdate=!0,N.needsUpdate=!0,E.needsUpdate=!0,A.needsUpdate=!0,this.setAttribute("position",x),this.setAttribute("normal",N),this.setAttribute("uv",E),this.setIndex(A)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let n=e[0];for(let a=0,s=n.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,n,a),c=this._buildBevelVert(r,n,(a+1)%s);o.push(c.topP,l.topN,l.bottomN),o.push(c.topP,l.bottomN,c.bottomP)}}_buildSurfaceVert(e,r,o){let n=r.toString();if(n in this.vertexCache)return this.vertexCache[n];let a=e.vertices[r*2+0],s=e.vertices[r*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),d=u*3,p=u*2,f={top:u+0,bottom:u+1};return this._buffer.positions[d+0]=a,this._buffer.positions[d+1]=s,this._buffer.positions[d+2]=this.forPathBevel?this._bevel:this._depth-o,this._buffer.normals[d+0]=0,this._buffer.normals[d+1]=0,this._buffer.normals[d+2]=1,this._buffer.uvs[p+0]=l,this._buffer.uvs[p+1]=c,this.forPathBevel===!1&&(this._buffer.positions[d+3]=a,this._buffer.positions[d+4]=s,this._buffer.positions[d+5]=o,this._buffer.normals[d+3]=0,this._buffer.normals[d+4]=0,this._buffer.normals[d+5]=-1,this._buffer.uvs[p+2]=l,this._buffer.uvs[p+3]=c),this.vertexCache[n]=f,f}_buildBevelVert(e,r,o,n=1,a){let s=`${r.bevelI}:${o}`;if(s in this.vertexCache&&a!==0&&a!==1&&(!a||a===this.vertexCache[s].pathBevelUCoord))return this.vertexCache[s];let[l,c]=r.boundary.vertexIndices[o],u,d,p,f;l!==c?(d=l,u=c,f=!1,p=e.continuous[d]&&e.continuous[u]):(u=l,d=(u-1+e.count)%e.count,f=e.concave[u]&&r.bevelI>0,p=e.continuous[u]||f);let h=Math.cos(r.angle),m=Math.sin(r.angle),y=o*2,g=u*2,b=d*2,w=r.boundary.vertices[y+0],P=r.boundary.vertices[y+1],S=(1-m)*this._bevel,T=(w-this._minX)/this._width,A=(P-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(T=a),A=1);let x=e.normals[g+0],N=e.normals[g+1],E=e.normals[b+0],M=e.normals[b+1];if(f){let U=E-x,B=M-N;x=x+U*(1-n),N=N+B*(1-n);let q=Math.sqrt(x*x+N*N);x/=q,N/=q}let D=this.forPathBevel?this._buffer.get(p?1:2):this._buffer.get(p?2:4),_=D*3,R=D*2,V={i:o,fi:u,topP:D+0,topN:D+0,bottomP:D+1,bottomN:D+1,pathBevelUCoord:a};return this._buffer.positions[_+0]=w,this._buffer.positions[_+1]=P,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[_+0]=x*h,this._buffer.normals[_+1]=N*h,this._buffer.normals[_+2]=m,this._buffer.uvs[R+0]=T,this._buffer.uvs[R+1]=A,this.forPathBevel===!1&&(this._buffer.positions[_+3]=w,this._buffer.positions[_+4]=P,this._buffer.positions[_+5]=S,this._buffer.normals[_+3]=x*h,this._buffer.normals[_+4]=N*h,this._buffer.normals[_+5]=-m,this._buffer.uvs[R+2]=A,this._buffer.uvs[R+3]=T),p||(this.forPathBevel?(D+=1,_+=3,R+=2):(D+=2,_+=6,R+=4),V.topP=D+0,V.bottomP=D+1,this._buffer.positions[_+0]=w,this._buffer.positions[_+1]=P,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[_+0]=E*h,this._buffer.normals[_+1]=M*h,this._buffer.normals[_+2]=m,this._buffer.uvs[R+0]=T,this._buffer.uvs[R+1]=A,this.forPathBevel===!1&&(this._buffer.positions[_+3]=w,this._buffer.positions[_+4]=P,this._buffer.positions[_+5]=S,this._buffer.normals[_+3]=E*h,this._buffer.normals[_+4]=M*h,this._buffer.normals[_+5]=-m,this._buffer.uvs[R+2]=A,this._buffer.uvs[R+3]=T)),this.vertexCache[s]=V,V}clone(){let e=new Oi(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Do(this.userData),e}};var Da=class extends f3{constructor(e,r=12,o={}){super();this.type="ShapeGeometry";this.windingRule=je.ODD;this.elementType=ct.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:je.ODD,elementType:ct.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,d;for(let h=0,m=n.length/2;h<m;h++){let y=h*2,g=n[y+0],b=n[y+1];if(u!==void 0&&g!==u&&(l=!1),d!==void 0&&b!==d&&(c=!1),u=g,d=b,!l&&!c)break}if(!l&&!c)try{s=Hr({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=ul}let p=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new Nu(new Float32Array(p*3),3),this._normalAttribute=new Nu(new Float32Array(p*3),3),this._uvAttribute=new Nu(new Float32Array(p*2),2),this._indexAttribute=new Nu(new Uint32Array(f*3),1),s){let h=1/0,m=-1/0,y=1/0,g=-1/0;for(let P=0,S=p;P<S;P++){let T=P*2,A=s.vertices[T+0],x=s.vertices[T+1];A<h&&(h=A),A>m&&(m=A),x<y&&(y=x),x>g&&(g=x)}let b=m-h,w=g-y;for(let P=0,S=p;P<S;P++){let T=P*2,A=s.vertices[T+0],x=s.vertices[T+1],N=(A-h)/b,E=(x-y)/w;this._positionAttribute.setXYZ(P,A,x,0),this._normalAttribute.setXYZ(P,0,0,1),this._uvAttribute.setXY(P,N,E)}for(let P=0,S=f;P<S;P++){let T=P*3,A=s.elements[T+0],x=s.elements[T+1],N=s.elements[T+2];this._indexAttribute.setX(T+0,A),this._indexAttribute.setX(T+1,x),this._indexAttribute.setX(T+2,N)}}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 Da(this._shape,this._curveSegments);return e.userData=Do(this.userData),e}};var _a=class extends Oi{constructor(e,r,o=0,n=12,a=3,s=je.ODD){super(e,r,o,n,a,s);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let n=e[0];for(let a=0,s=n.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,n,a),c=this._buildBevelVert(r,n,(a+1)%s);o.push(c.topP,l.topN,l.bottomN),o.push(c.topP,l.bottomN,c.bottomP)}}clone(){let e=new _a(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Do(this.userData),e}};var rr=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:je.ODD},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),a=i.shape??t?.shape,s=a?.roundness??e.roundness;a!==void 0&&(a instanceof Ue?(a.width!==r||a.height!==o)&&a.applySize(r,o):a=new Ue(r,o).fromJSON(a),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&a.update());let l=a??new Ue(r,o);return{parameters:Object.assign(e,{width:r,height:o,depth:n,roundness:s}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:o,roundness:n,windingRule:a}=i.parameters;i.shape.roundness=n;let s;return t<=0?s=new Da(i.shape,o,{windingRule:a}):s=new _a(i.shape,t,e,o,r,a),Object.assign(s,{userData:{...i,type:"VectorGeometry"}})}};import{BufferGeometry as h3,Float32BufferAttribute as m3,MathUtils as Mf,Vector2 as tb}from"three";var rb=Math.PI*2,La=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return e.angle=Mf.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof Ue?i.shape:new Ue,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:t,height:e,spikes:r,angle:o,innerRadius:n,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=i.parameters,c=i.shape,u=t*.5,d=e*.5,p=y3(c,u,d,o*Math.PI/180,r,n);c.isClosed=!0,c.update();let f;return o===0?(f=new h3,f.setAttribute("position",new m3([],3))):f=rr.create({shape:c,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function y3(i,t,e,r,o,n){if(r>=rb)return o>30||o%4===0?(x3(i,t,e,n),Math.round(o/4)):eb(i,r,o,t,e,n);r=Math.max(r,.001);let a={x:0,y:e},s=r+Math.PI*.5,l={x:Math.cos(s)*t,y:Math.sin(s)*e},c=Yx({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return o>30||o%c.length===0?g3(i,a.x,a.y,c,o,t,e,n):eb(i,r,o,t,e,n)}function g3(i,t,e,r,o,n,a,s){let l=Math.round(o/r.length);i.addPoint(Ra(t,e));for(let c=0,u=r.length;c<u;c++){let d=r[c],p=i.points[c],f=Ra(d.x,d.y);p.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),i.addPoint(f)}return s>0?ob(i,n,a,s):i.addPoint(Ra(0,0)),l}function eb(i,t,e,r,o,n){let a=-t/e;for(let s=0;s<=e;s++){let l=a*s,c=Math.sin(l)*r,u=Math.cos(l)*o;i.addPoint(Ra(c,u))}return t<rb?n>0?ob(i,r,o,n):i.addPoint(Ra(0,0)):(i.removePoint(i.points[i.points.length-1]),n>0&&ib(i,r,o,n)),1}function x3(i,t,e,r=0,o=0,n=0){let a=.5522847498,s=t*a,l=e*a;i.addPoint(Du(o-t,n,o-t,n-l,o-t,n+l)),i.addPoint(Du(o,n+e,o-s,n+e,o+s,n+e)),i.addPoint(Du(o+t,n,o+t,n+l,o+t,n-l)),i.addPoint(Du(o,n-e,o+s,n-e,o-s,n-e)),r>0&&ib(i,t,e,r)}function Ra(i,t){return new kr(Mf.generateUUID(),new tb(i,t))}function Du(i,t,e,r,o,n){let a=Ra(i,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(o,n),a}function ob(i,t,e,r){nb(i,t,e,r).forEach(n=>i.addPoint(n))}function ib(i,t,e,r){let o=nb(i,t,e,r),n=new Ue;o.forEach(a=>n.addPoint(a)),n.isClosed=!0,i.shapeHoles.push(n)}function nb(i,t,e,r){let o=r*t/100,n=o*(Math.abs(e)/Math.abs(t)),a=new tb(o/t,n/e),s=i.points.map(l=>{let c=l.clone();return c.uuid=Mf.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 b3,Float32BufferAttribute as If,Uint32BufferAttribute as v3,Vector3 as ab}from"three";var sb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??r),n=Math.abs(e.depth??r),a=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(e,{width:r,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:t,height:e,depth:r,radius:o,revolutions:n,segments:a,pathRadius:s,pathType:l,pathSegments:c,cornerRadius:u,cornerSegments:d}=i.parameters,p=new dl(!1,t,e,r,o,n,a,s,l,c,u,d);return Object.assign(p,{userData:{...i,type:"HelixGeometry"}})}},Ef=new v3([0,0,0],1),dl=class extends b3{constructor(t=!0,e=1,r=1,o=1,n=1,a=1,s=1,l=1,c=1,u=1,d=1,p=1){if(super(),a===0)return;let f=t&&a===1;f&&(p=0),d>100&&(d=100),d===0&&(p=0);let h=()=>new ab,m=new ab,y=h(),g=h(),b=h(),w,P,S,T,A,x,N,E,M=h(),D=h(),_=h(),R=h(),V=h(),U=h(),B=h(),q=h(),j=r-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/p,Z=.01,Q=Math.min((1-d/100)*l,l-Z),$=l-Q,de=0,le=2,ie=p*le+le,ce=Y*ie/le,ae=ce+Y*W,me=Math.max(0,Y*(W+ie)),[fe,he,be]=[3,3,2].map(nt=>Array(me*nt).fill(0)),ye=[],C=n-l;function ne(nt,Qe){let _r=Math.PI/2;x=Qe*ee,E=2*Math.PI*(x%F)/F+_r,x+=te,N=Math.sin(E)*C,A=Math.cos(E)*C,t?nt.set(A,N,x):nt.set(A,x,N)}ne(m,-1e-10),ne(y,0),M.copy(m),ne(m,1);let De=m.distanceTo(y),ze=f?0:$+Q,Re=De*H+2*ze,Oe=Q,Ot=Re-ze;for(let nt=0;nt<=H;nt++){ne(g,nt),q.subVectors(g,M).normalize(),M.copy(g),U.copy(g).setComponent(+t+1,0).normalize(),B.crossVectors(q,U).normalize();let Qe=nt===0,_r=nt===H,Kd=Qe?3*Math.PI/2:K,Qd=Qe?Oe:Ot,$l=Qe?Y:ae,Xi=Qe?0:me-Y,pt=q.clone().multiplyScalar(Qe?-$:$).add(g),Zd=q.clone().multiplyScalar(Qe?-1:1).normalize();for(let xr=0;xr<Y;xr++){let Rs=xr*re;if(D.addVectors(m.copy(U).multiplyScalar(l*Math.cos(Rs)),y.copy(B).multiplyScalar(l*Math.sin(Rs))),_.copy(D).normalize(),Qe||_r){f||(de=Xi+xr,[0,1,2].forEach(qt=>{fe[de*3+qt]=pt.getComponent(qt),he[de*3+qt]=Zd.getComponent(qt)}),be[de*2]=+_r,be[de*2+1]=xr/u),y.copy(_).multiplyScalar(Q),b.addVectors(g,y);for(let qt=0;qt<p;qt++){let Yi=qt*K+Kd;R.addVectors(m.copy(q).multiplyScalar($*Math.sin(Yi)),y.copy(_).multiplyScalar($*Math.cos(Yi))),V.copy(R).normalize(),y.addVectors(b,R),R.normalize(),de=$l+qt*Y+xr,[0,1,2].forEach(_n=>{fe[de*3+_n]=y.getComponent(_n),he[de*3+_n]=V.getComponent(_n)});let Xl=+Qe+Math.sin(Yi);be[de*2]=(Qd+$*Xl)/Re,be[de*2+1]=xr/u}}y.addVectors(g,D),de=ce+nt*Y+xr,[0,1,2].forEach(qt=>{fe[de*3+qt]=y.getComponent(qt),he[de*3+qt]=_.getComponent(qt)}),be[de*2]=(ze+nt*De)/Re,be[de*2+1]=xr/u}}let Ie=W+2*p+le,wt=1,[Tt,$i]=[+f,Ie-1];for(let nt=Tt;nt<=$i-1;nt++){let Qe=f&&nt===$i-1;for(let _r=0;_r<Y-1;_r++)w=nt*Y+_r,P=w+1,S=(Qe?_r:w)+Y,T=(Qe?_r+1:P)+Y,nt===0?ye.push(P,T,S):nt===Ie-2?ye.push(w,P,S):ye.push(w,P,S,P,T,S)}this.setIndex(ye),this.setAttribute("position",new If(fe,3)),this.setAttribute("normal",new If(he,3)),this.setAttribute("uv",new If(be,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,o=Array.from(this.getIndex().array),n,a,s,l,c=6*(e-1)*t.radialSegments,u=e,d=u===e;for(let p=0;p<t.radialSegments;p++)n=u*r+p,a=n+1,s=(d?p:n)+r,l=(d?p+1:a)+r,o[c++]=n,o[c++]=a,o[c++]=s,o[c++]=a,o[c++]=l,o[c++]=s;return o.length=c,Ef.array=o,Ef.count=o.length,Ef}};import{IcosahedronGeometry as S3}from"three";var lb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.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:t,height:e,depth:r,detail:o,corner:n,cornerSides:a}=i.parameters,s=o===0&&n!==0?new pl(t*.5,n,a):new S3(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...i,type:"IcosahedronGeometry"}})}},pl=class extends wi{constructor(t=1,e=.2,r=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,t,e,r),this.type=s}static fromJSON(t){return new pl(t.radius,t.corner,t.cornerSides)}};import{LatheGeometry as w3,Shape as P3}from"three";var cb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=Object.assign({},t?.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:t,segments:e,verticalSegments:r}=i.parameters,o=new P3;o.moveTo(t[0].x,t[0].y),o.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let n=new w3(o.extractPoints(r).shape,e);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...i,type:"LatheGeometry"}})}};import{BufferGeometry as gb,BufferGeometryLoader as L3,Vector3 as B3,BoxGeometry as xb}from"three";import{BufferGeometry as N3,Vector2 as Rf,Vector3 as yb}from"three";import{Box3 as O3,BufferAttribute as fl,BufferGeometry as ub,Color as _f,EventDispatcher as T3,Float32BufferAttribute as Ba,Matrix3 as db,Matrix4 as mb,MathUtils as C3,Object3D as A3,Sphere as M3,Vector2 as hr,Vector3 as Ft,Vector4 as I3}from"three";var fo=new mb,Nf=new A3,_u=new Ft,Ti=class extends T3{constructor(){super(),this.uuid=C3.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(t){let e=new db().getNormalMatrix(t);for(let r=0,o=this.vertices.length;r<o;r++)this.vertices[r].applyMatrix4(t);for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r];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(t){return fo.makeRotationX(t),this.applyMatrix4(fo),this}rotateY(t){return fo.makeRotationY(t),this.applyMatrix4(fo),this}rotateZ(t){return fo.makeRotationZ(t),this.applyMatrix4(fo),this}translate(t,e,r){return fo.makeTranslation(t,e,r),this.applyMatrix4(fo),this}scale(t,e,r){return fo.makeScale(t,e,r),this.applyMatrix4(fo),this}lookAt(t){return Nf.lookAt(t),Nf.updateMatrix(),this.applyMatrix4(Nf.matrix),this}fromBufferGeometry(t){let e=this,r=t.index!==null?t.index:void 0,o=t.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 p=0;p<n.count;p++)e.vertices.push(new Ft().fromBufferAttribute(n,p)),s!==void 0&&e.colors.push(new _f().fromBufferAttribute(s,p));function u(p,f,h,m){let y=s===void 0?[]:[e.colors[p].clone(),e.colors[f].clone(),e.colors[h].clone()],g=a===void 0?[]:[new Ft().fromBufferAttribute(a,p),new Ft().fromBufferAttribute(a,f),new Ft().fromBufferAttribute(a,h)],b=new Va(p,f,h,g,y,m);e.faces.push(b),l!==void 0&&e.faceVertexUvs[0].push([new hr().fromBufferAttribute(l,p),new hr().fromBufferAttribute(l,f),new hr().fromBufferAttribute(l,h)]),c!==void 0&&e.faceVertexUvs[1].push([new hr().fromBufferAttribute(c,p),new hr().fromBufferAttribute(c,f),new hr().fromBufferAttribute(c,h)])}let d=t.groups;if(d.length>0)for(let p=0;p<d.length;p++){let f=d[p],h=f.start,m=f.count;for(let y=h,g=h+m;y<g;y+=3)r!==void 0?u(r.getX(y),r.getX(y+1),r.getX(y+2),f.materialIndex):u(y,y+1,y+2,f.materialIndex)}else if(r!==void 0)for(let p=0;p<r.count;p+=3)u(r.getX(p),r.getX(p+1),r.getX(p+2));else for(let p=0;p<n.count;p+=3)u(p,p+1,p+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(_u).negate(),this.translate(_u.x,_u.y,_u.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,o=new mb;return o.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let t=new Ft,e=new Ft;for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r],a=this.vertices[n.a],s=this.vertices[n.b],l=this.vertices[n.c];t.subVectors(l,s),e.subVectors(a,s),t.cross(e),t.normalize(),n.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let r=0,o=this.vertices.length;r<o;r++)e[r]=new Ft;if(t){let r=new Ft,o=new Ft;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];r.subVectors(u,c),o.subVectors(l,c),r.cross(o),e[s.a].add(r),e[s.b].add(r),e[s.c].add(r)}}else{this.computeFaceNormals();for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r];e[n.a].add(n.normal),e[n.b].add(n.normal),e[n.c].add(n.normal)}}for(let r=0,o=this.vertices.length;r<o;r++)e[r].normalize();for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r],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 t=0,e=this.faces.length;t<e;t++){let r=this.faces[t],o=r.vertexNormals;o.length===3?(o[0].copy(r.normal),o[1].copy(r.normal),o[2].copy(r.normal)):(o[0]=r.normal.clone(),o[1]=r.normal.clone(),o[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e<r;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 t=new Ti;t.faces=this.faces;for(let e=0,r=this.morphTargets.length;e<r;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 Ft,u={a:new Ft,b:new Ft,c:new Ft};n.push(c),a.push(u)}}let o=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.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,r=this.faces.length;e<r;e++){let o=this.faces[e];o.normal=o.__originalFaceNormal,o.vertexNormals=o.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new O3),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new M3),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,r=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let o,n=this.vertices.length,a=this.vertices,s=t.vertices,l=this.faces,c=t.faces,u=this.colors,d=t.colors;e!==void 0&&(o=new db().getNormalMatrix(e));for(let p=0,f=s.length;p<f;p++){let m=s[p].clone();e!==void 0&&m.applyMatrix4(e),a.push(m)}for(let p=0,f=d.length;p<f;p++)u.push(d[p].clone());for(let p=0,f=c.length;p<f;p++){let h=c[p],m,y,g=h.vertexNormals,b=h.vertexColors,w=new Va(h.a+n,h.b+n,h.c+n);w.normal.copy(h.normal),o!==void 0&&w.normal.applyMatrix3(o).normalize();for(let P=0,S=g.length;P<S;P++)m=g[P].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),w.vertexNormals.push(m);w.color.copy(h.color);for(let P=0,S=b.length;P<S;P++)y=b[P],w.vertexColors.push(y.clone());w.materialIndex=h.materialIndex+r,l.push(w)}for(let p=0,f=t.faceVertexUvs.length;p<f;p++){let h=t.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let m=0,y=h.length;m<y;m++){let g=h[m],b=[];for(let w=0,P=g.length;w<P;w++)b.push(g[w].clone());this.faceVertexUvs[p].push(b)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},r=[],o=[],n=Math.pow(10,t);for(let l=0,c=this.vertices.length;l<c;l++){let u=this.vertices[l],d=Math.round(u.x*n)+"_"+Math.round(u.y*n)+"_"+Math.round(u.z*n);e[d]===void 0?(e[d]=l,r.push(this.vertices[l]),o[l]=r.length-1):o[l]=o[e[d]]}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 d=[u.a,u.b,u.c];for(let p=0;p<3;p++)if(d[p]===d[(p+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,d=this.faceVertexUvs.length;u<d;u++)this.faceVertexUvs[u].splice(c,1)}let s=this.vertices.length-r.length;return this.vertices=r,s}setFromPoints(t){this.vertices=[];for(let e=0,r=t.length;e<r;e++){let o=t[e];this.vertices.push(new Ft(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function r(l,c){return l.materialIndex-c.materialIndex}t.sort(r);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=t[l]._id;a&&a.push(o[c]),s&&s.push(n[c])}a&&(this.faceVertexUvs[0]=a),s&&(this.faceVertexUvs[1]=s)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let h=this.parameters;for(let m in h)h[m]!==void 0&&(t[m]=h[m]);return t}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 r=[],o=[],n={},a=[],s={},l=[],c={};for(let h=0;h<this.faces.length;h++){let m=this.faces[h],y=!0,g=!1,b=this.faceVertexUvs[0][h]!==void 0,w=m.normal.length()>0,P=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,T=m.vertexColors.length>0,A=0;if(A=u(A,0,0),A=u(A,1,y),A=u(A,2,g),A=u(A,3,b),A=u(A,4,w),A=u(A,5,P),A=u(A,6,S),A=u(A,7,T),r.push(A),r.push(m.a,m.b,m.c),r.push(m.materialIndex),b){let x=this.faceVertexUvs[0][h];r.push(f(x[0]),f(x[1]),f(x[2]))}if(w&&r.push(d(m.normal)),P){let x=m.vertexNormals;r.push(d(x[0]),d(x[1]),d(x[2]))}if(S&&r.push(p(m.color)),T){let x=m.vertexColors;r.push(p(x[0]),p(x[1]),p(x[2]))}}function u(h,m,y){return y?h|1<<m:h&~(1<<m)}function d(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 p(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 t.data={},t.data.vertices=e,t.data.normals=o,a.length>0&&(t.data.colors=a),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new Ti().copy(this)}copy(t){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=t.name;let e=t.vertices;for(let p=0,f=e.length;p<f;p++)this.vertices.push(e[p].clone());let r=t.colors;for(let p=0,f=r.length;p<f;p++)this.colors.push(r[p].clone());let o=t.faces;for(let p=0,f=o.length;p<f;p++)this.faces.push(o[p].clone());for(let p=0,f=t.faceVertexUvs.length;p<f;p++){let h=t.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let m=0,y=h.length;m<y;m++){let g=h[m],b=[];for(let w=0,P=g.length;w<P;w++){let S=g[w];b.push(S.clone())}this.faceVertexUvs[p].push(b)}}let n=t.morphTargets;for(let p=0,f=n.length;p<f;p++){let h={};if(h.name=n[p].name,n[p].vertices!==void 0){h.vertices=[];for(let m=0,y=n[p].vertices.length;m<y;m++)h.vertices.push(n[p].vertices[m].clone())}if(n[p].normals!==void 0){h.normals=[];for(let m=0,y=n[p].normals.length;m<y;m++)h.normals.push(n[p].normals[m].clone())}this.morphTargets.push(h)}let a=t.morphNormals;for(let p=0,f=a.length;p<f;p++){let h={};if(a[p].vertexNormals!==void 0){h.vertexNormals=[];for(let m=0,y=a[p].vertexNormals.length;m<y;m++){let g=a[p].vertexNormals[m],b={};b.a=g.a.clone(),b.b=g.b.clone(),b.c=g.c.clone(),h.vertexNormals.push(b)}}if(a[p].faceNormals!==void 0){h.faceNormals=[];for(let m=0,y=a[p].faceNormals.length;m<y;m++)h.faceNormals.push(a[p].faceNormals[m].clone())}this.morphNormals.push(h)}let s=t.skinWeights;for(let p=0,f=s.length;p<f;p++)this.skinWeights.push(s[p].clone());let l=t.skinIndices;for(let p=0,f=l.length;p<f;p++)this.skinIndices.push(l[p].clone());let c=t.lineDistances;for(let p=0,f=c.length;p<f;p++)this.lineDistances.push(c[p]);let u=t.boundingBox;u!==null&&(this.boundingBox=u.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new Df().fromGeometry(this),e=new ub,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Ru.call(new fl(r,3),t.vertices)),t.normals.length>0){let o=new Float32Array(t.normals.length*3);e.setAttribute("normal",Ru.call(new fl(o,3),t.normals))}if(t.colors.length>0){let o=new Float32Array(t.colors.length*3);e.setAttribute("color",pb.call(new fl(o,3),t.colors))}if(t.uvs.length>0){let o=new Float32Array(t.uvs.length*2);e.setAttribute("uv",fb.call(new fl(o,2),t.uvs))}if(t.uvs2.length>0){let o=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",fb.call(new fl(o,2),t.uvs2))}e.groups=t.groups;for(let o in t.morphTargets){let n=[],a=t.morphTargets[o];for(let s=0,l=a.length;s<l;s++){let c=a[s],u=new Ba(c.data.length*3,3);u.name=c.name,n.push(Ru.call(u,c.data))}e.morphAttributes[o]=n}if(t.skinIndices.length>0){let o=new Ba(t.skinIndices.length*4,4);e.setAttribute("skinIndex",hb.call(o,t.skinIndices))}if(t.skinWeights.length>0){let o=new Ba(t.skinWeights.length*4,4);e.setAttribute("skinWeight",hb.call(o,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.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(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new ub,r=t.geometry;if(t.isPoints||t.isLine){let o=new Ba(r.vertices.length*3,3),n=new Ba(r.colors.length*3,3);if(e.setAttribute("position",Ru.call(o,r.vertices)),e.setAttribute("color",pb.call(n,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let a=new Ba(r.lineDistances.length,1);e.setAttribute("lineDistance",E3.call(a,r.lineDistances))}r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone())}else t.isMesh&&(e=r.toBufferGeometry());return e}};Ti.prototype.isGeometry=!0;var Df=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(t){let e=[],r,o,n,a=t.faces;for(o=0;o<a.length;o++){let s=a[o];s.materialIndex!==n&&(n=s.materialIndex,r!==void 0&&(r.count=o*3-r.start,e.push(r)),r={start:o*3,materialIndex:n})}r!==void 0&&(r.count=o*3-r.start,e.push(r)),this.groups=e}fromGeometry(t){let e=t.faces,r=t.vertices,o=t.faceVertexUvs,n=o[0]&&o[0].length>0,a=o[1]&&o[1].length>0,s=t.morphTargets,l=s.length,c;if(l>0){c=[];for(let g=0;g<l;g++)c[g]={name:s[g].name,data:[]};this.morphTargets.position=c}let u=t.morphNormals,d=u.length,p;if(d>0){p=[];for(let g=0;g<d;g++)p[g]={name:u[g].name,data:[]};this.morphTargets.normal=p}let f=t.skinIndices,h=t.skinWeights,m=f.length===r.length,y=h.length===r.length;r.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<e.length;g++){let b=e[g];this.vertices.push(r[b.a],r[b.b],r[b.c]);let w=b.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[2]);else{let S=b.normal;this.normals.push(S,S,S)}let P=b.vertexColors;if(P.length===3)this.colors.push(P[0],P[1],P[2]);else{let S=b.color;this.colors.push(S,S,S)}if(n===!0){let S=o[0][g];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new hr,new hr,new hr))}if(a===!0){let S=o[1][g];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new hr,new hr,new hr))}for(let S=0;S<l;S++){let T=s[S].vertices;c[S].data.push(T[b.a],T[b.b],T[b.c])}for(let S=0;S<d;S++){let T=u[S].vertexNormals[g];p[S].data.push(T.a,T.b,T.c)}m&&this.skinIndices.push(f[b.a],f[b.b],f[b.c]),y&&this.skinWeights.push(h[b.a],h[b.b],h[b.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},Va=class{constructor(t,e,r,o,n,a=0){this.a=t,this.b=e,this.c=r,this.normal=o&&o.isVector3?o:new Ft,this.vertexNormals=Array.isArray(o)?o:[],this.color=n&&n.isColor?n:new _f,this.vertexColors=Array.isArray(n)?n:[],this.materialIndex=a}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,r=t.vertexNormals.length;e<r;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,r=t.vertexColors.length;e<r;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function E3(i){return this.array.set(i),this}function pb(i){let t=this.array,e=0;for(let r=0,o=i.length;r<o;r++){let n=i[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),n=new _f),t[e++]=n.r,t[e++]=n.g,t[e++]=n.b}return this}function fb(i){let t=this.array,e=0;for(let r=0,o=i.length;r<o;r++){let n=i[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),n=new hr),t[e++]=n.x,t[e++]=n.y}return this}function Ru(i){let t=this.array,e=0;for(let r=0,o=i.length;r<o;r++){let n=i[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),n=new Ft),t[e++]=n.x,t[e++]=n.y,t[e++]=n.z}return this}function hb(i){let t=this.array,e=0;for(let r=0,o=i.length;r<o;r++){let n=i[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),n=new I3),t[e++]=n.x,t[e++]=n.y,t[e++]=n.z,t[e++]=n.w}return this}var D3=["a","b","c"];function _3(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function Lf(i,t,e){let r=Math.min(i,t),o=Math.max(i,t),n=r+"_"+o;return e.get(n)}function Bf(i,t,e,r,o,n){let a=Math.min(i,t),s=Math.max(i,t),l=a+"_"+s,c;if(r.has(l))c=r.get(l);else{let u=e[a],d=e[s];c={a:u,b:d,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(o),n[i].edges.push(c),n[t].edges.push(c)}function R3(i,t,e,r){let o,n,a;for(o=0,n=i.length;o<n;o++)e[o]={edges:[]};for(o=0,n=t.length;o<n;o++)a=t[o],Bf(a.a,a.b,i,r,a,e),Bf(a.b,a.c,i,r,a,e),Bf(a.c,a.a,i,r,a,e)}function Lu(i,t,e,r,o){i.push(new Va(t,e,r,void 0,void 0,o))}function za(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function Bu(i,t,e,r){i.push([t.clone(),e.clone(),r.clone()])}var Vu=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof N3?t=new Ti().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new yb,r,o,n,a,s,l=t.vertices,c=t.faces,u=t.faceVertexUvs[0],d=u!==void 0&&u.length>0,p=[],f=new Map;R3(l,c,p,f);let h=[],m,y,g,b,w,P,S;for(let Z of Array.from(f.keys())){for(y=f.get(Z),g=new yb,w=3/8,P=1/8,S=y.faces.length,S!=2&&(w=.5,P=0,S!=1),g.addVectors(y.a,y.b).multiplyScalar(w),e.set(0,0,0),a=0;a<S;a++){for(b=y.faces[a],s=0;s<3&&(m=l[_3(b,D3[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(P),g.add(e),y.newEdge=h.length,h.push(g)}let T,A,x,N,E,M,D,_=[];for(o=0,n=l.length;o<n;o++){for(M=l[o],E=p[o].edges,r=E.length,r==3?T=3/16:r>3&&(T=3/(8*r)),A=1-r*Number(T),x=T,r<=2&&(r==2?(A=3/4,x=1/8):r==1||r==0),D=M.clone().multiplyScalar(A),e.set(0,0,0),a=0;a<r;a++)N=E[a],m=N.a!==M?N.a:N.b,e.add(m);e.multiplyScalar(Number(x)),D.add(e),_.push(D)}let R=_.concat(h),V=_.length,U,B,q,j=[],F=[],H,W,ee,te,Y=new Rf,re=new Rf,K=new Rf;for(o=0,n=c.length;o<n;o++)b=c[o],U=Number(Lf(b.a,b.b,f).newEdge)+V,B=Number(Lf(b.b,b.c,f).newEdge)+V,q=Number(Lf(b.c,b.a,f).newEdge)+V,Lu(j,U,B,q,b.materialIndex),Lu(j,b.a,U,q,b.materialIndex),Lu(j,b.b,B,U,b.materialIndex),Lu(j,b.c,q,B,b.materialIndex),d&&(H=u[o],W=H[0],ee=H[1],te=H[2],Y.set(za(W.x,ee.x),za(W.y,ee.y)),re.set(za(ee.x,te.x),za(ee.y,te.y)),K.set(za(W.x,te.x),za(W.y,te.y)),Bu(F,Y,re,K),Bu(F,W,Y,K),Bu(F,ee,re,Y),Bu(F,te,K,re));t.vertices=R,t.faces=j,d&&(t.faceVertexUvs[0]=F)}};var It=new B3,bb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new gb().copy(new xb(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(It),r={width:It.x,height:It.y,depth:It.z,subdivisions:0}):r=t.parameters;let o={...r,...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:t,height:e,depth:r,subdivisions:o}=i.parameters,n=i.geometry??new gb().copy(new xb(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(It)):It.set(a.width,a.height,a.depth),(t!==It.x||e!==It.y||r!==It.z)&&n.scale(It.x===0?1:t/It.x,It.y===0?1:e/It.y,It.z===0?1:r/It.z);let s=n.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=n),n=new Vu(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,t,e){new L3(e).load(i,o=>{let n=this.normalizeInputs({geometry:o});o.boundingBox.getSize(It);let a=100/It.x;Object.assign(n.parameters,{width:100,height:It.y*a,depth:It.z*a}),t(this.build(n))})}};var zu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Ue?i.shape:new Ue,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:t,height:e,spikes:r,cornerRadius:o,depth:n,extrudeBevelSize:a,extrudeBevelSegments:s}=i.parameters,l=i.shape,c=t*.5,u=e*.5,d=0,p=0,f=2*Math.PI/r;for(let m=0;m<r;m++){let y=f*m,g=d+Math.sin(y)*c,b=p+Math.cos(y)*u;l.addPoint(l.createPoint(g,b))}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=rr.create({shape:l,parameters:{roundness:o,depth:n,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(h,{userData:{...i,type:"PolygonGeometry"}})}};import{BufferGeometry as V3,Float32BufferAttribute as Vf,Vector2 as ho,Vector3 as Rt}from"three";var vb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.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:t,height:e,depth:r,radialSegments:o,heightSegments:n,openEnded:a,cornerRadius:s,cornerSegments:l}=i.parameters,c=new Gf(t*.5,e,o,n,a,s,l);return c.scale(1,1,r/t),Object.assign(c,{userData:{...i,type:"PyramidGeometry"}})}};function hl(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function zf(i,t,e,r,o,n){let a=t.clone().sub(i),s=e.clone().sub(i),l=a.angleTo(s);if(a.normalize(),s.normalize(),r===o){let c=a.add(s).normalize();n.copy(i).addScaledVector(c,r/Math.sin(l/2))}else{let c=a.angleTo(s);n.copy(i),n.addScaledVector(a,o/Math.sin(c)),n.addScaledVector(s,r/Math.sin(c))}}function z3(i,t,e){let r=i.clone().sub(t),o=e.clone().sub(t);return r.projectOnVector(o),r.add(t)}var Gf=class extends V3{constructor(t=.5,e=1,r=4,o=1,n=!1,a=0,s=4){super(),r=Math.floor(Math.max(3,r)),o=Math.floor(o),s=Math.floor(s);let l=[],c=[],u=[],d=[],p=0,f=e/2,h=Math.PI/r,m=t*Math.cos(Math.PI/r),y=2*Math.PI/r,g=(r-2)*Math.PI/r,b=Math.PI-g,w=new Rt(0,-f,0),P=new Rt(0,f,0),S=new ho(t,-f),T=new ho(m,-f),A=new ho(0,P.y).sub(T),x=new ho(0,P.y).sub(S),N=new ho(A.y,-A.x).normalize(),E=new ho(x.y,-x.x).normalize(),D=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-A.angle())/2)-1e-8;a=Math.min(a,D);let _;{let F=new Rt(N.x,N.y,0),H=new Rt(Math.cos(y)*F.x,F.y,Math.sin(y)*F.x);_=F.angleTo(H)}let R=a/Math.tan((Math.PI-A.angle())/2),V=a/Math.tan((Math.PI-_)/2),U=new Rt;if(!n){c.push(w.x,w.y,w.z),u.push(0,-1,0),d.push(0,0);let F=p++,H=[],W=S.clone(),ee=R/Math.cos(Math.PI/r);W.x-=ee;for(let te=0;te<r;te++){let Y=te/r*Math.PI*2+h,re=new ho(Math.sin(Y),Math.cos(Y));hl(W,re,U),c.push(U.x,U.y,U.z),u.push(0,-1,0),d.push(0,0),H.push(p++)}for(let te=0;te<H.length;te++)l.push(H[te],F,H[(te+1)%H.length])}let B=[];{let F=new Rt,H=new Rt,W=new Rt,ee=new Rt,te=new Rt,Y=new Rt;for(let re=0;re<r;re++){let K=re/r*Math.PI*2+h,Z=(re+.5)/r*Math.PI*2+h,Q=(re+1)/r*Math.PI*2+h,$=new ho(Math.sin(K),Math.cos(K)),de=new ho(Math.sin(Z),Math.cos(Z)),le=new ho(Math.sin(Q),Math.cos(Q));hl(S,$,H),hl(S,le,W),hl(N,de,F),zf(P,H,W,V,V,ee),c.push(ee.x,ee.y,ee.z),zf(H,P,W,V,R,te),c.push(te.x,te.y,te.z),zf(W,H,P,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),d.push(0,0),d.push(0,0),d.push(0,0);let ie=p++,ce=p++,ae=p++;if(l.push(ie,ce,ae),a>0){{let he=H.clone().add(W).multiplyScalar(.5),be=P.clone().sub(he).normalize(),C=w.clone().sub(he).normalize().add(be).normalize().multiplyScalar(-1),ne=Y.clone().sub(te);q(he,ne,C,A.angle())}let me,fe;{let he=new Rt;hl(E,le,he);let be=Y.clone().add(ee).multiplyScalar(.5);be=z3(be,W,P);let ye=Y.clone().sub(ee);[me,fe]=q(be,ye,he,_,ee.y)}{let he=me,be=he.clone().setY(0).normalize(),ye=new Rt(0,-1,0),C=be.clone().cross(ye);j(he,be,ye,C)}B.concat(fe);{let he=A.angle(),be=Math.PI-he,ye=P.clone();ye.y-=a/Math.sin(he-Math.PI/2);let C=new Rt,ne=[];for(let ze=0;ze<s;ze++){let Re=[],Oe=Math.PI/2-be*ze/s,Ot=Math.cos(Oe),Ie=Math.sin(Oe),wt=Z;for(let Tt=0;Tt<=ze;Tt++){let $i=Math.cos(wt),nt=Math.sin(wt);F.x=Ot*nt,F.y=Ie,F.z=Ot*$i,C.copy(ye).addScaledVector(F,a),c.push(C.x,C.y,C.z),u.push(F.x,F.y,F.z),d.push(0,0),Re.push(p++),wt+=Math.PI*2/ze/r}ne.push(Re)}fe.reverse(),ne.push(fe);let De=ne.length-1;for(let ze=0;ze<De;ze++){let Re=ne[ze],Oe=ne[ze+1],Ot=Re.length-1;l.push(Oe[1],Re[0],Oe[0]);for(let Ie=1;Ie<=Ot;Ie++)l.push(Re[Ie],Re[Ie-1],Oe[Ie]),l.push(Oe[Ie+1],Re[Ie],Oe[Ie])}}}}}this.setIndex(l),this.setAttribute("position",new Vf(c,3)),this.setAttribute("normal",new Vf(u,3)),this.setAttribute("uv",new Vf(d,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 Rt,Q=new Rt,$=1,de=p,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 fe=Math.max(0,Z.y-te);Z.addScaledVector(H,-fe/H.y)}c.push(Z.x,Z.y,Z.z),u.push(Q.x,Q.y,Q.z),d.push(0,0),ae===0&&le.push(p),p++}}for(let ie=0;ie<s;ie++)for(let ce=0;ce<$;ce++){let ae=de+ce+($+1)*ie,me=ae+($+1),fe=me+1,he=ae+1;l.push(ae,me,he),l.push(me,fe,he)}return[F.clone().addScaledVector(H,.5),le]}function j(F,H,W,ee){let te=Math.PI/2,Y=x.angle()-te,re=[],K=new Rt,Z=new Rt;for(let $=0;$<=s;$++){let de=[],le=$/s;for(let ie=0;ie<=$;ie++){let ae=(($?ie/$:0)-.5)*b,me=Math.cos(ae),fe=Math.sin(ae),he=Math.atan(Math.tan(Y)*me),be=(te+he)*le,ye=Math.cos(be),C=Math.sin(be);K.set(0,0,0),K.addScaledVector(H,C*me),K.addScaledVector(W,ye),K.addScaledVector(ee,C*fe),Z.copy(F).addScaledVector(K,a),c.push(Z.x,Z.y,Z.z),u.push(K.x,K.y,K.z),d.push(0,0),de.push(p++)}re.push(de)}let Q=re.length-1;for(let $=0;$<Q;$++){let de=re[$],le=re[$+1],ie=de.length-1;l.push(de[0],le[1],le[0]);for(let ce=1;ce<=ie;ce++)l.push(de[ce-1],de[ce],le[ce]),l.push(de[ce],le[ce+1],le[ce])}}}};var Ga=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof Ue?i.shape:new Ue,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(i){let t=i.shape,{width:e,height:r,cornerRadius:o,cornerType:n,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=i.parameters,c={x:e*.5,y:r*.5},u={x:-c.x,y:-c.y},d={x:c.x,y:c.y};function p(P,S,T){return S>e&&T>r?Math.min(P*e/S,P*r/T):S>e?P*e/S:T>r?P*r/T:P}let f=[];f[0]=o[0]===0?0:p(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:p(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:p(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:p(o[3],o[3]+o[0],o[3]+o[2]);let h=u.x,m=d.x,y=d.y,g=u.y;t.addPoint(t.createPoint(h,y)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(h,g)),t.isClosed=!0;let b=!0;for(let P=0,S=t.points.length;P<S;P++)t.points[P].roundness=f[P],P>0&&f[P]!==f[P-1]&&(b=!1);b&&(t.roundness=f[0]),t.useCubicForRoundedCorners=n!==1,t.update();let w=rr.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...i,type:"RectangleGeometry"}})}};import{BufferGeometry as G3,Float32BufferAttribute as F3,MathUtils as Sb,SphereGeometry as j3}from"three";var wb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.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:t=100,height:e=t,depth:r=t,widthSegments:o=64,heightSegments:n=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:c}=i.parameters,u;return c===0?(u=new G3,u.setAttribute("position",new F3([],3))):u=new j3(.5*t,o,n,a,s,l,c*Sb.DEG2RAD),u.scale(1,e/t,r/t),Object.assign(u,{userData:{...i,type:"SphereGeometry"}})}};import{PlaneGeometry as U3}from"three";var Pb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.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:t=100,height:e=t,widthSegments:r=8,heightSegments:o=8}=i.parameters,n=new U3(t,e,r,o);return n.scale(1,1,1),Object.assign(n,{userData:{...i,type:"PlaneGeometry"}})}};import{BufferGeometry as k3,Float32BufferAttribute as Ff,Vector3 as H3}from"three";var Ob=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.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:t,height:e,depth:r,angle:o,cornerRadius:n,cornerSegments:a}=i.parameters,s=new jf(t,e,r,o,n,a);return Object.assign(s,{userData:{...i,type:"BackdropGeometry"}})}},jf=class extends k3{constructor(t=1,e=1,r=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 d=[],p=Math.PI/2,f=(Z=0,Q=0,$=0)=>new H3(Z,Q,$),h=f(),m=f(),[y,g,b]=[e/2,t/2,r/2],w=-g,P=+g,[S,T,A]=[f(w,-y,+b),f(w,-y,-b),f(w,+y,-b)],x=(Z,Q=!1)=>Math.sin(Z-Math.PI/(1+ +Q)),N=(Z,Q=!1)=>Math.cos(Z-Math.PI/(1+ +Q));A.y=Math.sin(o)*e-y;let E=Math.cos(o)*e-b,M=S.z-u;o<=p?(A.z=Math.min(E,M),A.z==M&&(A.y-=(E-M)/Math.tan(p-o))):T.z=Math.min(T.z-E-b,S.z-u),h.subVectors(S,T),m.subVectors(A,T);let D=Math.min(h.length(),m.length())*n/100,_=D*Math.tan(o/2),R=D/Math.cos(o/2),V=h.clone().normalize().add(m.normalize()).setLength(R).add(T);h.set(0,x(o,!0),N(o,!0)),d.push([A,h.clone()]);let U=(Math.PI-o)/a;for(let Z=0;Z<=a;Z++){let Q=p+o+Z*U;h.set(0,Math.sin(Q)*_,Math.cos(Q)*_),h.add(V),m.set(0,x(Q),N(Q)),d.push([h.clone(),m.clone()])}d.push([S,f(0,1,0)]);let B=Math.sin(U/2)*_*2,q=d.length-1,j=d[0][0].distanceTo(d[1][0]),F=d[q-1][0].distanceTo(d[q][0]),H=j+B*a+F;d[0].push(1);for(let Z=0;Z<=a;Z++)d[Z+1].push(1-(j+Z*B)/H);d[q].push(0);let[W,ee,te]=d[0],Y,re,K;for(let Z=1;Z<d.length;Z++)[Y,re,K]=d[Z],s.push(w,W.y,W.z,w,Y.y,Y.z,P,W.y,W.z,P,W.y,W.z,w,Y.y,Y.z,P,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 Ff(s,3)),this.setAttribute("normal",new Ff(l,3)),this.setAttribute("uv",new Ff(c,2))}};var Gu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.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 Ue?i.shape:new Ue,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:t,height:e,innerRadiusPercent:r,spikes:o,cornerRadius:n,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}=i.parameters,u=i.shape,d=t*.5,p=e*.5,f=0,h=0,m=a*Math.PI/360/o,y=Math.PI/2*3*-1,g=d*r/100,b=p*r/100;if(o===3&&r===50){m=2*Math.PI/o;for(let P=0;P<o;P++){let S=m*P,T=f+Math.sin(S)*d,A=h+Math.cos(S)*p;u.addPoint(u.createPoint(T,A))}}else for(let P=0;P<o;P++){let S=f+Math.cos(y)*d,T=h+Math.sin(y)*p;u.addPoint(u.createPoint(S,T)),y+=m,S=f+Math.cos(y)*g,T=h+Math.sin(y)*b,P<=o,u.addPoint(u.createPoint(S,T)),y+=m}u.isClosed=!0;for(let P=0,S=u.points.length;P<S;P++)u.points[P].roundness=n;u.roundness=n,u.update();let w=rr.create({shape:u,parameters:{roundness:n,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(w,{userData:{...i,type:"StarGeometry"}})}};import{PlaneGeometry as W3}from"three";var Tb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.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:t,height:e}=i.parameters,r=new W3(t,e);return Object.assign(r,{userData:{...i,type:"TextFrameGeometry"}})}};import{BufferGeometry as q3,Float32BufferAttribute as $3,MathUtils as X3}from"three";var Cb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width);e.shapeBlendNode&&(o=r);let n=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:o,depth:n})}}static build(i){let{width:t,height:e,depth:r,radialSegments:o,tubularSegments:n,arc:a,cornerRadius:s,cornerSegments:l}=i.parameters,c=Y3(t,e,r,t*.5,a,n,0,0,o,s,l);return c.scale(1,e/t,1),Object.assign(c,{userData:{...i,type:"TorusGeometry"}})}};function Y3(i,t,e,r,o,n,a,s,l,c,u){[t,e]=[e,t],a=t/2;let d=X3.clamp(o/360,0,1);if(d===0){let p=new q3;return p.setAttribute("position",new $3([],3)),p}return d===1&&(c=0),new dl(!0,i,t,e,r,d,n,a,s,l,c,u)}import{TorusKnotGeometry as K3}from"three";var Ab=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.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:t,tube:e,tubularSegments:r,radialSegments:o,p:n,q:a}=i.parameters,s=t*.5;s!==e&&(s-=e);let l=new K3(s,e,r,o,n,a);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var Mb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Ue?i.shape:new Ue,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:t=100,height:e,cornerRadius:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:s}=i.parameters,l=i.shape,c=t*.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 p=0,f=l.points.length;p<f;p++)l.points[p].roundness=r;l.roundness=r,l.update();let d=rr.create({shape:l,parameters:{roundness:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(d,{userData:{...i,type:"TriangleGeometry"}})}};import{Vector2 as Db,Vector3 as Lt,Matrix3 as cE,Matrix4 as pn,BufferGeometry as _b,BufferAttribute as Fa,MathUtils as ju}from"three";function Ib(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}function Q3(i){return/^(rgba)?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(i.toLowerCase())}function Z3(i,t,e){let r,o,n,a=Math.floor(i*6),s=i*6-a,l=e*(1-t),c=e*(1-s*t),u=e*(1-(1-s)*t);switch(a%6){case 0:r=e,o=u,n=l;break;case 1:r=c,o=e,n=l;break;case 2:r=l,o=e,n=u;break;case 3:r=l,o=c,n=e;break;case 4:r=u,o=l,n=e;break;case 5:default:r=e,o=l,n=c;break}return{r:r*255,g:o*255,b:n*255}}function J3(i,t,e){i/=255,t/=255,e/=255;let r=Math.max(i,t,e),o=Math.min(i,t,e),n=r,a=r-o,s=r==0?0:a/r,l;if(r==o)l=0;else{switch(r){case i:l=(t-e)/a+(t<e?6:0);break;case t:l=(e-i)/a+2;break;case e:default:l=(i-t)/a+4;break}l/=6}return{h:l,s,v:n}}function eE(i){return i=Math.floor(i),{r:i>>16&255,g:i>>8&255,b:i&255}}function tE(i,t,e){return(i<<16)+(t<<8)+e}function rE(i,t,e){return i=Math.round(i),t=Math.round(t),e=Math.round(e),"#"+[i,t,e].map(r=>r.toString(16).padStart(2,"0")).join("").toUpperCase()}function oE(i){let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;i=i.replace(t,(r,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 Eb={parseRgba:Q3,hsvToRgb:Z3,rgbToHsv:J3,hexToRgb:eE,rgbToHex:tE,rgbToHexString:rE,hexStringToRgb:oE};function Ho(i){return{all:i=i||new Map,on:function(t,e){var r=i.get(t);r?r.push(e):i.set(t,[e])},off:function(t,e){var r=i.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):i.set(t,[]))},emit:function(t,e){var r=i.get(t);r&&r.slice().map(function(o){o(e)}),(r=i.get("*"))&&r.slice().map(function(o){o(t,e)})}}}var Fu=class{constructor(t,e,r){this.id=t;this.userAPI=e;this.result=void 0;this.error="null";this.isPrefetched=!1;this.isLoading=!1;this.isLoaded=!1;this.prefetchPromise=new Promise(t=>t());this.emitter=Ho();this._innerCallUserAPI=async t=>{this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await lE(this.userAPI,t),this.error="null",this.emitter.emit("success",{userAPIId:this.id})}catch(e){let r=e.message?.split("_:_")?.[0]?.replace("status:","")??"null";this.error=r,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(r)),this._debouncedCallUserAPI=this._innerCallUserAPI,this._updateDebouncedCallUserAPI(),this._debouncedPrefetch=Ac(this.prefetch,1e3,{trailing:!0})}_updateDebouncedCallUserAPI(){this._debouncedCallUserAPI=this.userAPI.debounce!==void 0&&this.userAPI.debounce>0?Ac(this._innerCallUserAPI,this.userAPI.debounce,{leading:!0,trailing:!0}):this._innerCallUserAPI}async prefetch(t){await this.callUserAPI(t)}async callUserAPI(t){await this._debouncedCallUserAPI(t)}update(t,e,r=!0){this.userAPI=t,this._updateDebouncedCallUserAPI(),this.userAPI.url!==""&&this.userAPI.method==="GET"&&r&&this._debouncedPrefetch(e)}retrieveValue(t){if(this.result)try{return Je.zoom(this.result,t)}catch(e){console.error(e)}}retrieveZoomedKeyValues(t){if(this.result){let e=t&&t.length?Je.zoom(this.result,t):this.result;if(sE(e))return Object.entries(e);if(aE(e))return e.map((r,o)=>[o.toString(),r]);throw nE(e)?new Error("This path points to a value, use retrieveValue() instead. "+t?.join(".")):new Error("Path error"+t?.join("."))}}dispose(){}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}get autostart(){return this.userAPI.autoStart}};function iE(i){let t=new Headers;return i.headers.forEach(e=>{e.data.key!==""&&t.append(e.data.key,e.data.value)}),t}function nE(i){return typeof i=="string"||typeof i=="number"||typeof i=="boolean"||i===null}function aE(i){return Array.isArray(i)}function sE(i){return typeof i=="object"&&i!==null}async function lE(i,t,e=new AbortController){let r,o=i.url,n=i.proxy?.enabled??!1,a;if(i.integration?.type==="OpenAI"){let l=ml(i.integration.prompt===""?[]:JSON.parse(i.integration.prompt),t),c=i.integration.behavior===""?[]:ml(JSON.parse(i.integration.behavior),t);a=`{
|
|
4
4
|
"model": "${i.integration.model}",
|
|
5
5
|
"messages": [${i.integration.useBehavior?`
|
|
@@ -15,7 +15,7 @@ best distance: ${p.d}`);let g=[p.x,p.y];return g.distance=p.d,g.distance}functio
|
|
|
15
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=ml(JSON.parse(i.body),t)),u!==void 0&&(o+=`&data=${encodeURIComponent(u.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else i.integration?.type==="OpenAI"?r=a:i.method==="POST"&&i.body&&(r=ml(JSON.parse(i.body),t));let s=await fetch(o,{method:n?"GET":i.method,headers:n?void 0:iE(i),signal:e.signal,body:r});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 Nb=(i,t)=>{if(typeof i=="string"){let e=t.getVariable(i);if(e)return Nb(e,t)}return vi.isBoolean(i)?vi.getDisplayedValue(i).toLowerCase():vi.getDisplayedValue(i)},ml=(i,t)=>i.map((e,r)=>{if("text"in e)return e.text;if("type"in e){if(e.type==="paragraph")return(r>0?`
|
|
16
16
|
`:"")+ml(e.children,t);if(e.type==="variable"){let o=t.getVariable(e.variableId);if(o!==void 0)return Nb(o,t)}}return""}).join("");var uE=new pn,dE=new pn;function pE(i,t,e){let r=[new Lt,new Lt,new Lt],o=[new Lt,new Lt,new Lt];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((n,a)=>{let s=o[a],l=ju.lerp(n.length(),s.length(),e);n.lerp(s,e).setLength(l)}),new pn().makeBasis(r[0],r[1],r[2])}var Rb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),a=t?.shapeData??La.create({parameters:{...nn,width:typeof nn.width=="number"?nn.width:100,height:typeof nn.height=="number"?nn.height:100}}).userData.shape;return{path:i.path??ya.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:n,extrusion:{...Qc,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new Uf(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new _b,{userData:{...i,type:"PathGeometry"}})}},Uf=class extends _b{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)||!Ib(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=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=[],d=[];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()),d.push(r[F].clone())}let p=(j,F,H)=>{u[j]=u[j].clone().lerp(u[F],H),d[j]=pE(d[j],d[F],H)},f=0,h=n*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||n===0)&&(f=h,p(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,p(u.length-1,u.length-2,1-m)),o===0){let j=u.length-1;u[j].copy(u[0]),d[j].copy(d[0])}this._applyPathModifiers(d,f,m);let{bevel:g,bevelSides:b}=this.inputs.parameters.extrusion,w=g>0?this.inputs.parameters.extrusion.capType:"flat",P=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(P=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:A}=this._computeShapePoints(P),x=0,N;w==="round"&&(N=new Oi(this.inputs.shapeData,2*g,g,P,b,void 0,!0),x=N.getAttribute("position").count);let E=0,M=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),M+=j.verticesCount,E=M});let D=M*c,_,R=0;if(this._isOpenEnded()&&w==="flat"){try{_=Hr({windingRule:je.ODD,elementType:ct.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=Af}R=_.vertexCount}let V=D+2*R+x*2,U=D+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,A,d,u,B,q,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,D,q,B,d[0],u[0],!1),this._closeEnd(_,D+R,q,B,d[d.length-1],u[u.length-1],!0)),N){B.positions.set(N.getAttribute("position").array,U*3),B.normals.set(N.getAttribute("normal").array,U*3),B.uvs.set(N.getAttribute("uv").array,U*2);for(let W=U;W<U+x;W++)B.uvs[W*2+1]=1e-4;let j=q.length;q.push(...N.getIndex().array.map(W=>W+U)),U+=x,B.positions.set(N.getAttribute("position").array,U*3),B.normals.set(N.getAttribute("normal").array,U*3),B.uvs.set(N.getAttribute("uv").array,U*2);let F=q.length;q.push(...N.getIndex().array.map(W=>W+U)),this.setAttribute("position",new Fa(B.positions,3)),this.setAttribute("normal",new Fa(B.normals,3)),this.setAttribute("uv",new Fa(B.uvs,2)),this.setIndex(q);let H=uE;H.copy(d[d.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(d[0]).setPosition(u[0]).multiply(dE.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-x,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new Fa(B.positions,3)),this.setAttribute("normal",new Fa(B.normals,3)),this.setAttribute("uv",new Fa(B.uvs,2)),this.setIndex(q)}_extractPathPoints(){let e=bu(this.inputs.path),r=this.inputs.path.subdivisions,o=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(r*4):e.getPoints(r);if(o.length<2)return[];let n=[o[0]];return o.forEach(s=>{n[n.length-1].distanceToSquared(s)>.001&&n.push(s)}),this.inputs.path.isClosed&&n[n.length-1].distanceTo(n[0])<.001&&n.pop(),n}_computeBasisMatrices(e){let r=[],o=e.length,n=this.inputs.path.isClosed,a=new Lt,s=new Lt,l=new Lt,c=new Lt,u=new Lt(0,1,0);for(let y=0;y<o;y++){let g=e[y],b;y===0?b=n?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):b=e[y-1];let w;y===o-1?w=n?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let P=g.clone().sub(b).normalize(),S=w.clone().sub(g).normalize(),T=P.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let A=u.clone().cross(T).normalize(),x=T.clone().cross(A).normalize();u.copy(x),c.copy(A),y===0&&(a.copy(x),s.copy(T));let N=new pn().makeBasis(A,x,T);r.push(N)}let d=n?s:l,p=n?a:new Lt(0,1,0),f=d.clone().cross(c).normalize(),h=Math.acos(p.dot(f));if(isNaN(h))return r;let m=p.clone().cross(f);d.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let g=new pn().makeRotationZ(h*y/r.length);r[y].multiply(g)}return r}_applyPathModifiers(e,r,o){let n=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new pn,d=new pn;return e.forEach((p,f)=>{let h=f===0?0:f===n-1?1:(f-r)/(n-(o===0?0:1)-(r+(1-o)));u.makeRotationZ(ju.lerp(a,a+s,h)*ju.DEG2RAD);let m=ju.lerp(l,c,h);d.makeScale(m,m,m),p.multiply(u).multiply(d)}),e}_computeShapePoints(e=12,r=je.ODD){let o=this.inputs.shapeData,n=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let b=y.length-1;b>=1;b-=2){let w=y[b-1],P=y[b-0];g.push(w,P)}return g}),s;try{s=Hr({windingRule:r,elementType:ct.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]})}catch{s=ul}let l;try{l=Hr({windingRule:je.ODD,elementType:ct.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Cf}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let u=1/0,d=-1/0,p=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,b=s.vertices[g+0],w=s.vertices[g+1];b<u&&(u=b),b>d&&(d=b),w<p&&(p=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,b=s.elements[g+0],w=s.elements[g+1],P=b+w,S={start:b,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let T=b,A=P-1,x=b+1,N=o.roundedCurves.length;do{let E=T-b,M=s.vertices[A*2+0],D=s.vertices[A*2+1],_=s.vertices[T*2+0],R=s.vertices[T*2+1],V=s.vertices[x*2+0],U=s.vertices[x*2+1],B=_-M,q=R-D,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+N)%N;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),[A,T,x]=[T,x,x+1],x>=P&&(x-=w)}while(x!==b+1)}return{regions:[n,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,n,a){let s=r*2,l=r*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,r,o,n,a,s,l){let c=new Lt,u=new Lt,d=new Lt,p=new Lt,f=new Db;o.forEach((m,y)=>{let g=n[y],b=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let P=(e.start+w)*2;if(c.set(r[P+0],r[P+1],0),d.copy(c).applyMatrix4(m).add(g),e.continuous[w])p.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===0?(e.start+e.count-1)*2:P-2;u.set(r[S+0],r[S+1],0),p.copy(c).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(m).normalize(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,b,d,p,f),b++,!e.continuous[w]||w===0){if(w===0)p.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:P+2;u.set(r[S+0],r[S+1],0),p.copy(u).sub(c),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(m).normalize(),this._insertVertex(a,b,d,p,f),b++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,g=e.verticesStart*o.length+e.verticesCount*(m+1),b=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&b++;let P=w===e.count-1?0:b+1,S=y+b,T=y+P,A=g+P,x=g+b;e.isHole?s.push(S,A,T,S,x,A):s.push(S,T,A,S,A,x),b++}}}_closeEnd(e,r,o,n,a,s,l){let c=e.vertexCount,u=new Lt(0,0,l?-1:1).applyMatrix4(a),d=new Lt,p=new Db;for(let h=0;h<c;h++){let m=2*h;d.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(n,r+h,d,u,p)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+r,g=f[m+(l?1:2)]+r,b=f[m+(l?2:1)]+r;o.push(y,g,b)}}applyMatrix4OnRange(e,r,o){let n=e.elements,a=new cE().getNormalMatrix(e).elements,s,l,c,u,d=this.attributes.position,p=this.attributes.normal;if(!d||!p)return;let f=d.array,h=p.array,m=d.itemSize;for(let y=r*m,g=o*m;y<g;y+=m){if(y===r)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}d.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,r){let o=this.index;if(o){for(let n=e;n<r;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 Lb,BufferGeometry as kf}from"three";import{mergeBufferGeometries as hE}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Bb(){let i=new kf;return i.setAttribute("position",new Lb(new Float32Array([]),3)),i.setIndex(new Lb(new Uint16Array([]),1)),i}var mE=Bb().attributes,yE=12,gE=1,fn=class extends kf{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,mE),this.userData={parameters:e,type:"TextGeometry"};let o=r.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e,r)):this.updateFont(e.font,r).then(()=>{this.update(e,r),r?.requestRender()})}async updateFont(e,r){let o=r.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e,r){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:d}=e,p=vi.getDisplayedValue(u),f=d===2?p.toUpperCase():d===3?p.toLowerCase():p,h=xE(e,o,f,r),{shapes:m,charWidths:y,charCoords:g}=o.generateShapes(h,e,r),b=(typeof n=="number"?n:Number(r.getVariable(n)))*.5,w=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,P=m.map(A=>new Ue().fromShape(A,!0));this.vectorShapes=P;let S=P.map(A=>rr.create({shape:A,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?je.NONZERO:je.ODD,subdivisions:this.isLowResolution&&s>0?gE:yE}})),T=S.length?hE(S):Bb();T.translate(-b,w,0),this.dispose(),this.wrappedText=h,this.charCoords=g,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(T.attributes).forEach(([A,x])=>{this.setAttribute(A,x)}),this.setIndex(T.index),this.computeBoundingSphere()}clone(){let e=Ct(new kf,fn.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,o])=>{this.setAttribute(r,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,r){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},r)}get text(){return this.userData.parameters.text??""}};function xE(i,t,e,r){let o=typeof i.width=="string"?Number(r.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("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.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 Wf,BufferAttribute as Fb,Uint32BufferAttribute as qf,Float32BufferAttribute as $f,Matrix4 as PE,Vector3 as gl,Sphere as OE,Box3 as TE,BoxGeometry as CE}from"three";var zb,ku=new Promise(i=>{zb=i}),Vb=!1;var Uu;function Gb(i){if(Vb)return;if(Uu)return Uu;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.12.53/build"),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});zb(c),Vb=!0}return Uu=t(),Uu}import{BufferGeometryLoader as bE}from"three";var vE=["font"];function mo(i,t,e,r){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 d of c)u=u[d];for(o in u){let d=u[o];Dp(d)&&!vE.includes(o)&&(u[o]=t.getVariable(d,[r.uuid,"geometry",...c,o]),Dp(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=Ue.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 bE().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 St(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new fn(n,t);if(n.type==="InputGeometry")return new fn(n,t);if(n.type==="UIGeometry")return Ga.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Hf(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=Ue.createFromState(ma.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=Hf(s)}return l}import{Matrix4 as SE}from"three";var wE=new SE;function yl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=wE.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,d=o.length;u<d;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,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 Hu=new TE,ja=new gl,we;ku.then(i=>{we=i});var jb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Ub=new Uint32Array([0,1,2,3]),kb=new Uint8Array([4]),St=class extends Wf{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked.map(l=>typeof l=="number"?l:1),n=hi.div(r.map(l=>typeof l=="number"?l:0),o);if(n.every(l=>l===1))return;this.subdividedGeometry&&yl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&yl(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(ja.fromArray(n));let s=ja.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,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=St.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new CE(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(St.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new OE,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Hu.setFromBufferAttribute(r),Hu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Hu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Hu.getSize(ja);let n={width:ja.x,height:ja.y,depth:ja.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(we.free_bvh(r),we.free_subdivision_surface(r));try{a=St.allocate(e,n)}catch(u){console.error(u,e),a=St.allocate({positionWASM:jb,indexWASM:Ub,verticesPerFaceWASM:kb},n)}if(we.set_destination_refinement_level(a,0),s=St.buildLevel(a,!0,c),e.subdivisions>0)try{we.set_destination_refinement_level(a,e.subdivisions),l=St.buildLevel(a,!1,c)}catch{try{we.set_destination_refinement_level(a,e.subdivisions-1),l=St.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,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?r.geometry:mo(e,o,!1,r),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=Qf(n.getAttribute("position"),a));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;d=[p,f]}return{indices:l,verticesPerFace:c}=Zf(s,u,n,d),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=jb,n=Ub,a=kb);let c=o.length,u=n.length,d=a.length,p=o.length+s.length+l.length,f=n.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=we._malloc(h),g=new Float32Array(we.HEAPF32.buffer,y,p),b=new Uint32Array(we.HEAPU32.buffer,y+m,f);g.set(o,0),g.set(s,o.length),g.set(l,o.length+s.length),b.set(n,0),b.set(a,n.length);let w;e?.scaleBaked?.some(S=>S!==1)&&(w=new PE().makeScale(...e.scaleBaked.map(S=>typeof S=="number"?S:1))),r&&(w?w.premultiply(r):w=r);let P=w?we.alloc_subdivision_surface2(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):we.alloc_subdivision_surface(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return we._free(y),P}static buildLevel(e,r,o,n,a){let s=a?we.get_mesh_data2(e,r?we.Level.CONTROL:we.Level.REFINED,o,a.elements):we.get_mesh_data(e,r?we.Level.CONTROL:we.Level.REFINED,o),l=8,c=we.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),d=0,p=we.HEAPU32[c[d]>>2],f=we.HEAPF32.subarray(p>>2,(p>>2)+u[d]);d++;let h=we.HEAPU32[c[d]>>2],m=we.HEAPF32.subarray(h>>2,(h>>2)+u[d]);d++;let y=we.HEAPU32[c[d]>>2],g=we.HEAPU32.subarray(y>>2,(y>>2)+u[d]);d++;let b=we.HEAPU32[c[d]>>2],w=we.HEAPU32.subarray(b>>2,(b>>2)+u[d]);if(d++,n===void 0){let P=new Wf;if(P.setIndex(new qf(w,1)),P.setAttribute("position",new $f(f,3)),P.setAttribute("normal",new $f(m,3)),r){P.setAttribute("faceMap",new qf(g,1));let S=new Float32Array(m.length/3*4).fill(0);P.setAttribute("color",new Fb(S,4))}return we.free_mesh_data(s),P.userData.type="SubdivGeometry",P}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,we.free_mesh_data(s)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=we.HEAPU32[s[c]>>2],d=we.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=we.HEAPU32[s[c]>>2],f=we.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let h=new Wf;h.setAttribute("position",new $f(d,3));let m=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new Fb(m,3)),h.setIndex(new qf(f,1)),we.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||we.set_destination_refinement_level(e,r);let a=o?we.get_topological_data2(e,n?we.Level.CONTROL:we.Level.REFINED,o.elements):we.get_topological_data(e,n?we.Level.CONTROL:we.Level.REFINED),s=6,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,d=we.HEAPU32[l[u]>>2],p=new Float32Array(we.HEAPF32.subarray(d>>2,(d>>2)+c[u]));u++;let f=we.HEAPU32[l[u]>>2],h=new Uint32Array(we.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=we.HEAPU32[l[u]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return we.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var Hb=["getX","getY","getZ"];function Qf(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,d="";for(let p=0;p<3;p++)d+=`${~~(i[Hb[p]](u)*s)},`;if(d in e)n.push(e[d]);else{for(let p=0;p<3;p++)a.push(i[Hb[p]](u));e[d]=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 Wu=new gl,Xf=new gl,Yf=new gl,Kf=new gl;function Zf(i,t,e,r){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 p=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let u=0;for(let p=0;p<l.length;p+=2)u+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);i.length=0;let d=0;if(u<0)for(let p=0;p<l.length;p+=2)i.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)i.push(l[p],l[p+1],0),o.push(d++);return n.push(d),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){Wu.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Xf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Yf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),Kf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Xf.sub(Wu).normalize(),Yf.sub(Wu).normalize(),Kf.sub(Wu).normalize();let l=Xf.cross(Yf).dot(Kf),c=s;Math.abs(l)>.005||r&&r.some((u,d)=>d%2===1?!1:c>=r[d]&&c<r[d+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let d=0,p=0;d<i.length;d+=3,p++)i[d+2]===0&&(l.push(p),u++),i[d+2]===a&&c.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=c[0];c[0]=c[1],c[1]=d}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var Tr={};Tw(Tr,{calcBoolean:()=>NE,calcBooleanTopological:()=>EE,freeMeshSet:()=>LE,getMeshSet:()=>DE,hasOpenEdges:()=>_E,transformMeshSet:()=>RE});var AE,Wb=new Promise(i=>{AE=i});import{Float32BufferAttribute as qb,Sphere as ME}from"three";var Ve,Ua;Wb.then(i=>Ve=i);function IE(i,t,e){let r,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=Qf(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=Zf(n,a,i);s=c.length,r=[];for(let u=0,d=0;u<s;u++){r.push(c[u]);for(let p=0;p<c[u];p++)r.push(l[d++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function $b(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Ve._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Ve.HEAPU32.buffer,n,t):new Float32Array(Ve.HEAPF32.buffer,n,t)).set(i,0),n}function Xb(i){switch(i){case 0:return Ve.OP.UNION;case 1:return Ve.OP.INTERSECTION;case 2:return Ve.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function EE(i,t){Ua===void 0&&(Ua=Ve.init_csg());let e=$b(i),r=Ve.csg_calc_topological(Ua,e,i.length,Xb(t));Ve._free(e);let o=6,n=Ve.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Ve.HEAPU32[n[s]>>2],c=new Float32Array(Ve.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ve.HEAPU32[n[s]>>2],d=new Uint32Array(Ve.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let p=Ve.HEAPU32[n[s]>>2],f=new Uint8Array(Ve.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Ve.free_mesh_data(r),{positions:c,indices:d,verticesPerFace:f}}function NE(i,t,e,r){Ua===void 0&&(Ua=Ve.init_csg());let o=$b(i),n=Ve.csg_calc(Ua,o,i.length,r,Xb(t));Ve._free(o);let a=5,s=Ve.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Ve.HEAPU32[s[c]>>2],d=Ve.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Ve.HEAPU32[s[c]>>2],f=Ve.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new qb(d,3)),e.setAttribute("normal",new qb(f,3));let m=Ve.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new ME),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},Ve.free_mesh_data(n),h}function DE(i,t,e){if(Ve===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let g=i.userData;n=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+n);for(let b=0,w=0,P=0;b<g.verticesPerFace.length;b++){o[P++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[P++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=IE(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,p=c*Uint32Array.BYTES_PER_ELEMENT,f=Ve._malloc(u),h=new Float32Array(Ve.HEAPF32.buffer,f,l),m=new Uint32Array(Ve.HEAPU32.buffer,f+d,c);h.set(r,0),m.set(o,0);let y=Ve.get_csg_mesh(f,a,f+d,s,n);return Ve._free(f),y}function _E(i){return Ve.has_open_edges(i)}function RE(i,t){Ve.transform_csg_mesh(i,t.elements)}function LE(i){Ve.free_csg_mesh(i)}var BE={ConeGeometry:Ix,CubeGeometry:Ex,CylinderGeometry:Mx,DodecahedronGeometry:Nx,EllipseGeometry:La,HelixGeometry:sb,IcosahedronGeometry:lb,LatheGeometry:cb,NonParametricGeometry:bb,PolygonGeometry:zu,PyramidGeometry:vb,RectangleGeometry:Ga,SphereGeometry:wb,PlaneGeometry:Pb,BackdropGeometry:Ob,StarGeometry:Gu,TextFrameGeometry:Tb,TorusGeometry:Cb,TorusKnotGeometry:Ab,TriangleGeometry:Mb,PathGeometry:Rb,VectorGeometry:rr},Hf=i=>BE[i.type].create(i);function ka(i){return i!==null&&"booleanOp"in i}var Ha=class extends Aa(zE){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new VE}updateVisible(e){super.updateVisible(e),this.visible=!ka(this.parent)&&this.visible,ka(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Tr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),ka(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Ha&&(e.freeBooleanPointer(),ka(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&ka(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),ka(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var qu=new GE;function xl(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let d=t;d<e;d++){let p=i.getX(d),f=i.getY(d),h=i.getZ(d);p<n&&(n=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>c&&(c=f),h>u&&(u=h)}qu.min.set(n,a,s),qu.max.set(l,c,u),qu.getCenter(r),qu.getSize(o).multiplyScalar(.5)}var UE=new FE,kE=new jE,Et=class extends Ha{constructor(t,e){super(UE,kE),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?xl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};import{Box3 as pD,Matrix4 as fD,Sphere as jv,Vector3 as hD}from"three";import{BufferAttribute as cD,Float32BufferAttribute as Fv,MathUtils as Ah,Vector3 as Mh}from"three";import{ShaderMaterial as FN,Texture as jN}from"three";var Wo=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Wo.uuidContext===null)throw new Error("plz startContext");Wo.uuidContext===Wo.globalContext?this.uuid="_gid"+Wo.uuidContext.nodeContextUuid++:this.uuid="_uid"+Wo.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===Wo.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},Xe=Wo;Xe.globalContext={nodeContextUuid:0},Xe.uuidContext=Wo.globalContext;import{CubeReflectionMapping as JE,CubeRefractionMapping as eN,CubeUVReflectionMapping as tN,LinearEncoding as iv,sRGBEncoding as rN}from"three";var bl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var Jf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Nt=new Jf;import{Vector2 as Yb}from"three";import{MathUtils as HE}from"three";var ge=class extends Xe{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=HE.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,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var Ye=class extends ge{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,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,r,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,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var ut=class extends Ye{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof Yb?e:new Yb(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};import{Vector3 as Kb}from"three";var jt=class extends Ye{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Kb?e:new Kb(e,r,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,r,o,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};var or=class extends Ye{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Mt?e:new Mt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var WE=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Qb=/[a-z_0-9]+/gi,J=class extends ge{constructor(e,r,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,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let u=[];for(;s=Qb.exec(this.src);)u.push(s);for(let d=0;d<u.length;d++){let p=u[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Nt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Nt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Nt.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[p.index+l-1]!=="."&&(c=c.substring(0,p.index+l)+m+c.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Nt.contains(m)&&e.include(Nt.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=WE.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Qb);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 d=s[l++];this.inputs.push({name:d,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var qE=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,eh=class extends ge{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||eh.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=qE.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,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},Fe=eh;Fe.PI="PI",Fe.PI2="PI2",Fe.RECIPROCAL_PI="RECIPROCAL_PI",Fe.RECIPROCAL_PI2="RECIPROCAL_PI2",Fe.LOG2="LOG2",Fe.EPSILON="EPSILON";var $E=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
18
|
+
`&&n.push("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.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 Wf,BufferAttribute as Fb,Uint32BufferAttribute as qf,Float32BufferAttribute as $f,Matrix4 as PE,Vector3 as gl,Sphere as OE,Box3 as TE,BoxGeometry as CE}from"three";var zb,ku=new Promise(i=>{zb=i}),Vb=!1;var Uu;function Gb(i){if(Vb)return;if(Uu)return Uu;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.12.54/build"),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});zb(c),Vb=!0}return Uu=t(),Uu}import{BufferGeometryLoader as bE}from"three";var vE=["font"];function mo(i,t,e,r){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 d of c)u=u[d];for(o in u){let d=u[o];Dp(d)&&!vE.includes(o)&&(u[o]=t.getVariable(d,[r.uuid,"geometry",...c,o]),Dp(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=Ue.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 bE().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 St(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new fn(n,t);if(n.type==="InputGeometry")return new fn(n,t);if(n.type==="UIGeometry")return Ga.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Hf(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=Ue.createFromState(ma.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=Hf(s)}return l}import{Matrix4 as SE}from"three";var wE=new SE;function yl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=wE.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,d=o.length;u<d;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,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 Hu=new TE,ja=new gl,we;ku.then(i=>{we=i});var jb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Ub=new Uint32Array([0,1,2,3]),kb=new Uint8Array([4]),St=class extends Wf{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked.map(l=>typeof l=="number"?l:1),n=hi.div(r.map(l=>typeof l=="number"?l:0),o);if(n.every(l=>l===1))return;this.subdividedGeometry&&yl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&yl(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(ja.fromArray(n));let s=ja.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,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=St.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new CE(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(St.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new OE,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Hu.setFromBufferAttribute(r),Hu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Hu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Hu.getSize(ja);let n={width:ja.x,height:ja.y,depth:ja.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(we.free_bvh(r),we.free_subdivision_surface(r));try{a=St.allocate(e,n)}catch(u){console.error(u,e),a=St.allocate({positionWASM:jb,indexWASM:Ub,verticesPerFaceWASM:kb},n)}if(we.set_destination_refinement_level(a,0),s=St.buildLevel(a,!0,c),e.subdivisions>0)try{we.set_destination_refinement_level(a,e.subdivisions),l=St.buildLevel(a,!1,c)}catch{try{we.set_destination_refinement_level(a,e.subdivisions-1),l=St.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,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?r.geometry:mo(e,o,!1,r),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=Qf(n.getAttribute("position"),a));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;d=[p,f]}return{indices:l,verticesPerFace:c}=Zf(s,u,n,d),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=jb,n=Ub,a=kb);let c=o.length,u=n.length,d=a.length,p=o.length+s.length+l.length,f=n.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=we._malloc(h),g=new Float32Array(we.HEAPF32.buffer,y,p),b=new Uint32Array(we.HEAPU32.buffer,y+m,f);g.set(o,0),g.set(s,o.length),g.set(l,o.length+s.length),b.set(n,0),b.set(a,n.length);let w;e?.scaleBaked?.some(S=>S!==1)&&(w=new PE().makeScale(...e.scaleBaked.map(S=>typeof S=="number"?S:1))),r&&(w?w.premultiply(r):w=r);let P=w?we.alloc_subdivision_surface2(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):we.alloc_subdivision_surface(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return we._free(y),P}static buildLevel(e,r,o,n,a){let s=a?we.get_mesh_data2(e,r?we.Level.CONTROL:we.Level.REFINED,o,a.elements):we.get_mesh_data(e,r?we.Level.CONTROL:we.Level.REFINED,o),l=8,c=we.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),d=0,p=we.HEAPU32[c[d]>>2],f=we.HEAPF32.subarray(p>>2,(p>>2)+u[d]);d++;let h=we.HEAPU32[c[d]>>2],m=we.HEAPF32.subarray(h>>2,(h>>2)+u[d]);d++;let y=we.HEAPU32[c[d]>>2],g=we.HEAPU32.subarray(y>>2,(y>>2)+u[d]);d++;let b=we.HEAPU32[c[d]>>2],w=we.HEAPU32.subarray(b>>2,(b>>2)+u[d]);if(d++,n===void 0){let P=new Wf;if(P.setIndex(new qf(w,1)),P.setAttribute("position",new $f(f,3)),P.setAttribute("normal",new $f(m,3)),r){P.setAttribute("faceMap",new qf(g,1));let S=new Float32Array(m.length/3*4).fill(0);P.setAttribute("color",new Fb(S,4))}return we.free_mesh_data(s),P.userData.type="SubdivGeometry",P}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,we.free_mesh_data(s)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=we.HEAPU32[s[c]>>2],d=we.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=we.HEAPU32[s[c]>>2],f=we.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let h=new Wf;h.setAttribute("position",new $f(d,3));let m=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new Fb(m,3)),h.setIndex(new qf(f,1)),we.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||we.set_destination_refinement_level(e,r);let a=o?we.get_topological_data2(e,n?we.Level.CONTROL:we.Level.REFINED,o.elements):we.get_topological_data(e,n?we.Level.CONTROL:we.Level.REFINED),s=6,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,d=we.HEAPU32[l[u]>>2],p=new Float32Array(we.HEAPF32.subarray(d>>2,(d>>2)+c[u]));u++;let f=we.HEAPU32[l[u]>>2],h=new Uint32Array(we.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=we.HEAPU32[l[u]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return we.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var Hb=["getX","getY","getZ"];function Qf(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,d="";for(let p=0;p<3;p++)d+=`${~~(i[Hb[p]](u)*s)},`;if(d in e)n.push(e[d]);else{for(let p=0;p<3;p++)a.push(i[Hb[p]](u));e[d]=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 Wu=new gl,Xf=new gl,Yf=new gl,Kf=new gl;function Zf(i,t,e,r){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 p=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let u=0;for(let p=0;p<l.length;p+=2)u+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);i.length=0;let d=0;if(u<0)for(let p=0;p<l.length;p+=2)i.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)i.push(l[p],l[p+1],0),o.push(d++);return n.push(d),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){Wu.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Xf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Yf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),Kf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Xf.sub(Wu).normalize(),Yf.sub(Wu).normalize(),Kf.sub(Wu).normalize();let l=Xf.cross(Yf).dot(Kf),c=s;Math.abs(l)>.005||r&&r.some((u,d)=>d%2===1?!1:c>=r[d]&&c<r[d+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let d=0,p=0;d<i.length;d+=3,p++)i[d+2]===0&&(l.push(p),u++),i[d+2]===a&&c.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=c[0];c[0]=c[1],c[1]=d}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var Tr={};Tw(Tr,{calcBoolean:()=>NE,calcBooleanTopological:()=>EE,freeMeshSet:()=>LE,getMeshSet:()=>DE,hasOpenEdges:()=>_E,transformMeshSet:()=>RE});var AE,Wb=new Promise(i=>{AE=i});import{Float32BufferAttribute as qb,Sphere as ME}from"three";var Ve,Ua;Wb.then(i=>Ve=i);function IE(i,t,e){let r,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=Qf(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=Zf(n,a,i);s=c.length,r=[];for(let u=0,d=0;u<s;u++){r.push(c[u]);for(let p=0;p<c[u];p++)r.push(l[d++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function $b(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Ve._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Ve.HEAPU32.buffer,n,t):new Float32Array(Ve.HEAPF32.buffer,n,t)).set(i,0),n}function Xb(i){switch(i){case 0:return Ve.OP.UNION;case 1:return Ve.OP.INTERSECTION;case 2:return Ve.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function EE(i,t){Ua===void 0&&(Ua=Ve.init_csg());let e=$b(i),r=Ve.csg_calc_topological(Ua,e,i.length,Xb(t));Ve._free(e);let o=6,n=Ve.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Ve.HEAPU32[n[s]>>2],c=new Float32Array(Ve.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ve.HEAPU32[n[s]>>2],d=new Uint32Array(Ve.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let p=Ve.HEAPU32[n[s]>>2],f=new Uint8Array(Ve.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Ve.free_mesh_data(r),{positions:c,indices:d,verticesPerFace:f}}function NE(i,t,e,r){Ua===void 0&&(Ua=Ve.init_csg());let o=$b(i),n=Ve.csg_calc(Ua,o,i.length,r,Xb(t));Ve._free(o);let a=5,s=Ve.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Ve.HEAPU32[s[c]>>2],d=Ve.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Ve.HEAPU32[s[c]>>2],f=Ve.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new qb(d,3)),e.setAttribute("normal",new qb(f,3));let m=Ve.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new ME),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},Ve.free_mesh_data(n),h}function DE(i,t,e){if(Ve===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let g=i.userData;n=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+n);for(let b=0,w=0,P=0;b<g.verticesPerFace.length;b++){o[P++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[P++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=IE(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,p=c*Uint32Array.BYTES_PER_ELEMENT,f=Ve._malloc(u),h=new Float32Array(Ve.HEAPF32.buffer,f,l),m=new Uint32Array(Ve.HEAPU32.buffer,f+d,c);h.set(r,0),m.set(o,0);let y=Ve.get_csg_mesh(f,a,f+d,s,n);return Ve._free(f),y}function _E(i){return Ve.has_open_edges(i)}function RE(i,t){Ve.transform_csg_mesh(i,t.elements)}function LE(i){Ve.free_csg_mesh(i)}var BE={ConeGeometry:Ix,CubeGeometry:Ex,CylinderGeometry:Mx,DodecahedronGeometry:Nx,EllipseGeometry:La,HelixGeometry:sb,IcosahedronGeometry:lb,LatheGeometry:cb,NonParametricGeometry:bb,PolygonGeometry:zu,PyramidGeometry:vb,RectangleGeometry:Ga,SphereGeometry:wb,PlaneGeometry:Pb,BackdropGeometry:Ob,StarGeometry:Gu,TextFrameGeometry:Tb,TorusGeometry:Cb,TorusKnotGeometry:Ab,TriangleGeometry:Mb,PathGeometry:Rb,VectorGeometry:rr},Hf=i=>BE[i.type].create(i);function ka(i){return i!==null&&"booleanOp"in i}var Ha=class extends Aa(zE){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new VE}updateVisible(e){super.updateVisible(e),this.visible=!ka(this.parent)&&this.visible,ka(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Tr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),ka(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Ha&&(e.freeBooleanPointer(),ka(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&ka(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),ka(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var qu=new GE;function xl(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let d=t;d<e;d++){let p=i.getX(d),f=i.getY(d),h=i.getZ(d);p<n&&(n=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>c&&(c=f),h>u&&(u=h)}qu.min.set(n,a,s),qu.max.set(l,c,u),qu.getCenter(r),qu.getSize(o).multiplyScalar(.5)}var UE=new FE,kE=new jE,Et=class extends Ha{constructor(t,e){super(UE,kE),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?xl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};import{Box3 as pD,Matrix4 as fD,Sphere as jv,Vector3 as hD}from"three";import{BufferAttribute as cD,Float32BufferAttribute as Fv,MathUtils as Ah,Vector3 as Mh}from"three";import{ShaderMaterial as FN,Texture as jN}from"three";var Wo=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Wo.uuidContext===null)throw new Error("plz startContext");Wo.uuidContext===Wo.globalContext?this.uuid="_gid"+Wo.uuidContext.nodeContextUuid++:this.uuid="_uid"+Wo.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===Wo.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},Xe=Wo;Xe.globalContext={nodeContextUuid:0},Xe.uuidContext=Wo.globalContext;import{CubeReflectionMapping as JE,CubeRefractionMapping as eN,CubeUVReflectionMapping as tN,LinearEncoding as iv,sRGBEncoding as rN}from"three";var bl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var Jf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Nt=new Jf;import{Vector2 as Yb}from"three";import{MathUtils as HE}from"three";var ge=class extends Xe{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=HE.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,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var Ye=class extends ge{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,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,r,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,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var ut=class extends Ye{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof Yb?e:new Yb(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};import{Vector3 as Kb}from"three";var jt=class extends Ye{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Kb?e:new Kb(e,r,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,r,o,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};var or=class extends Ye{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Mt?e:new Mt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var WE=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Qb=/[a-z_0-9]+/gi,J=class extends ge{constructor(e,r,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,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let u=[];for(;s=Qb.exec(this.src);)u.push(s);for(let d=0;d<u.length;d++){let p=u[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Nt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Nt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Nt.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[p.index+l-1]!=="."&&(c=c.substring(0,p.index+l)+m+c.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Nt.contains(m)&&e.include(Nt.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=WE.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Qb);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 d=s[l++];this.inputs.push({name:d,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var qE=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,eh=class extends ge{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||eh.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=qE.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,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},Fe=eh;Fe.PI="PI",Fe.PI2="PI2",Fe.RECIPROCAL_PI="RECIPROCAL_PI",Fe.RECIPROCAL_PI2="RECIPROCAL_PI2",Fe.LOG2="LOG2",Fe.EPSILON="EPSILON";var $E=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
19
19
|
)*?)}`,"gim"),XE=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Wa=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 r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,o,n,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=$E.exec(e);if(r){let o=r[2],n;for(;n=XE.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=r[1]}else this.name="";this.type=this.name}};var qa=class extends ge{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){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),r)}};Nt.addKeyword("uv",function(){return new qa});Nt.addKeyword("uv2",function(){return new qa(1)});import{LinearEncoding as YE,sRGBEncoding as KE}from"three";var hn=class extends ge{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??hn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case YE:return["Linear"];case KE:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),n=this.getType(e),a=hn.Nodes[this.method],s=e.include(a);if(s===hn.LINEAR_TO_LINEAR)return e.format(o,n,r);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",n,r)}else return e.format(s+"( "+o+" )",n,r)}fromEncoding(e){let r=hn.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=hn.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},Kt=hn;Kt.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(`
|
|
@@ -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,r])}}();var Me={normalRenderTarget:new Qt,normalRenderTargetDepth:new Qt,transmissionRenderTarget:new Qt,aspectRatio:new ut,transmissionSize:new ut(2048,2048),transmissionRenderTargetDepth:new Qt,aoRenderTarget:new Qt,aoEnabled:new dt,pixelRatioNode:new se(1),resolution:new ut,penumbraSize:new qr(5,.5),frameIndex:new Le(0),transmissionLod:new Le(2),taaEnabled:new dt(!0)};for(let i of Object.values(Me))i.isRenderGlobal=!0;var pv={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.12.
|
|
1876
|
+
}`,[e,r])}}();var Me={normalRenderTarget:new Qt,normalRenderTargetDepth:new Qt,transmissionRenderTarget:new Qt,aspectRatio:new ut,transmissionSize:new ut(2048,2048),transmissionRenderTargetDepth:new Qt,aoRenderTarget:new Qt,aoEnabled:new dt,pixelRatioNode:new se(1),resolution:new ut,penumbraSize:new qr(5,.5),frameIndex:new Le(0),transmissionLod:new Le(2),taaEnabled:new dt(!0)};for(let i of Object.values(Me))i.isRenderGlobal=!0;var pv={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.12.54/build/ui.wasm"};var qo=class extends Xe{constructor(){super("basic");this.nodeType="Basic";this.color=new qe(bt),this.shadingAlpha=new se(1),this.shadingBlend=new Le(0),this.previousModelViewMatrix=new Ut,this.previouseProjectionMatrix=new Ut}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Me.frameIndex}),e.mergeUniform({resolution:Me.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(pN.merge([dN.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>
|
|
@@ -2282,7 +2282,7 @@ 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&&p.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),u?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&p.push(`gl_FragColor.a *= ${d.result};`),p.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=p.join(`
|
|
2285
|
-
`)}return r}};import{VideoTexture as gN,Texture as xN}from"three";var Qu=class{constructor(t=1e3*10){this.timeout=t;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(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),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 t=Date.now(),e=this.head.next;for(;e.time<t-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(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}};var hh=class extends Qu{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},fh;function yv(i){return typeof i=="string"?i:(fh||(fh=new hh),fh.load(i))}var Zu=class{constructor(t,e){this.data=t;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")}},Ju=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var ds=class extends Zu{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;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 r=()=>{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=()=>{r()}}else this.img=new Image,this.img.src=yv(e),this.img.onload=r,await new Promise(n=>{this.img.onload=()=>{r(),n(null)}})}getTexture(e,r=1008,o=1006){let n=this._cache[e]?.[r]?.[o];if(n)return n;{let a;return this.isBuffer?a=this.img.texture:this.isVideo?a=new gN(this.img,void 0,e,e):a=new xN(this.img,void 0,e,e,o,r),this.loaded&&(a.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]===void 0&&(this._cache[e][r]={}),this._cache[e][r][o]=a,a}}setNeedsUpdate(e){for(let r of Object.values(this._cache))for(let o of Object.values(r))for(let n of Object.values(o))n&&(n.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[o,n]of Object.entries(r))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 mr=class extends ds{};import{Vector2 as Xo,Vector3 as bo,Vector4 as ed}from"three";function kt(i,t){return t.color(i)}function gv(i,t){switch(i.type){case"fresnel":return SN(i,t);case"gradient":return wN(i,t);case"depth":return PN(i,t);case"normal":return ON(i,t);case"noise":return TN(i,t);case"rainbow":return CN(i,t);case"toon":return AN(i,t);case"outline":return MN(i,t);case"transmission":return IN(i,t);case"pattern":return EN(i,t);case"color":default:return vN(i,t)}}function bN(i){return{type:i.type}}function Xr(i,t){let{alpha:e,mode:r,isMask:o}=i,n=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...bN(i),alpha:n,mode:r,isMask:o}}function vN(i,t){return{...Xr(i,t),color:kt(i.color,t)}}function SN(i,t){let{bias:e,scale:r,intensity:o,factor:n,color:a}=i;return{...Xr(i,t),color:kt(a,t),bias:e,scale:r,intensity:o,factor:n}}function wN(i,t){let{gradientType:e,smooth:r,colors:o,steps:n,angle:a,offset:s,morph:l}=i;return{...Xr(i,t),gradientType:e,smooth:r,colors:o.map(c=>new ed(c[0],c[1],c[2],c[3])),num:o.length,steps:n,offset:new Xo(...s.map(c=>typeof c=="number"?c:0)),morph:new Xo(...l.map(c=>typeof c=="number"?c:0)),angle:a}}function PN(i,t){let{gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:s,direction:l,colors:c,steps:u,smooth:d}=i;return{...Xr(i,t),gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:new bo(...s),direction:l?new bo(...l):new bo(1,0,0),colors:c.map(p=>p!==void 0?new ed(p[0],p[1],p[2],p[3]):new ed(0,0,0,0)),steps:u.slice(0,c.length),smooth:d}}function ON(i,t){let{cnormal:e}=i;return{...Xr(i,t),cnormal:new bo(e[0],e[1],e[2])}}function TN(i,t){return{...Xr(i,t),scale:i.scale,move:i.move,fA:new Xo(...i.fA.map(e=>typeof e=="number"?e:0)),fB:new Xo(...i.fB.map(e=>typeof e=="number"?e:0)),size:new bo(...i.size),distortion:new Xo(...i.distortion.map(e=>typeof e=="number"?e:0)),colorA:kt(i.colorA,t),colorB:kt(i.colorB,t),colorC:kt(i.colorC,t),colorD:kt(i.colorD,t),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}function CN(i,t){return{...Xr(i,t),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new bo(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new bo(...i.offset)}}function AN(i,t){return{...Xr(i,t),positioning:i.positioning,colors:i.colors.map(e=>new ed(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new bo(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:kt(i.shadowColor,t),offset:new bo(...i.offset)}}function MN(i,t){return{...Xr(i,t),outlineColor:kt(i.outlineColor,t),contourColor:kt(i.contourColor,t),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new bo(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}function IN(i,t){return{...Xr(i,t),thickness:i.thickness,ior:i.ior,roughness:i.roughness}}function EN(i,t){return{...Xr(i,t),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new Xo(...i.offset.map(e=>typeof e=="number"?e:0)),colorA:kt(i.colorA,t),colorB:kt(i.colorB,t),frequency:new Xo(...i.frequency.map(e=>typeof e=="number"?e:0)),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new Xo(...i.vertical.map(e=>typeof e=="number"?e:0)),horizontal:new Xo(...i.horizontal.map(e=>typeof e=="number"?e:0)),sides:i.sides}}var Mi=class extends Mt{};import{MathUtils as NN,Vector4 as DN}from"three";var _N={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},RN={depth:["colors"]};function LN(i,t,e){if(t==="isMask")return!0;let r=_N[i.type],o=RN[i.type];if(o!==void 0){let n=i.color;if(o.includes(t)){let a=n[t]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return r!==void 0?r.includes(t):!1}function mh(i,t){if(Array.isArray(t)){if(!Array.isArray(i)||i.length!==t.length)return!1;for(let[o,n]of t.entries()){let a=i[o];if(typeof n=="string"||typeof n=="number"&&typeof a=="string")return!0}return!1}let e=typeof i=="string",r=typeof t=="string";return e!==r||e&&r}function Cl(i,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let o=!1,n=i;if("image"in n){let a=n.image,s=t.image(a),l=r;l.image instanceof mr||l.image.deref(),l.image=s}if("video"in n){let a=n.video,s=t.video(a),l=r;l.image instanceof mr||l.image.deref(),l.image=s}if("wrapping"in n){let a=r;a.wrap=n.wrapping}if("minFilter"in n){let a=r;a.minFilter=n.minFilter}if("magFilter"in n){let a=r;a.magFilter=n.magFilter}if("rotation"in n&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(Se(n.rotation??0,t)??0)*NN.DEG2RAD,o;if("repeat"in n||"offset"in n||"rotation"in n){let a="mat",s=e.uniforms[`f${e.id}_${a}`];if(!s)return o;if("repeat"in n){let l=n.repeat;mh(e.data.texture.repeat,l)&&(o=!0),s.repeat=ps(l,t).map((c,u)=>typeof l[u]=="string"?1/c:c)}if("offset"in n){let l=n.offset;mh(e.data.texture.offset,l)&&(o=!0),s.offset=ps(l,t).map((c,u)=>typeof l[u]=="string"?-c:c)}if("rotation"in n){let l=e.data.texture.rotation,c=n.rotation??0;(l===void 0||mh(l,c))&&(o=!0),s.rotation=Se(c,t)??0}s.updateMatrix()}return o}function xv(i,t,e,r){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(yh(n,e,r,t)){n==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=r.visible;let s=e.uniforms[`f${e.id}_${n}`];if(!!s&&!(s instanceof Ci))switch(o=o||LN(e,n,a),s.constructor){case qe:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Mi?s.value=new Mt(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case or:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Mi?s.value=new Mt(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case ut:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case jt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case Qt:{Cl(a,t,e);break}case $r:{s.value=a.map(l=>new DN(...l));break}default:{s.value=a;break}}}return o}var Ei=(i,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,Se=(i,t,e)=>typeof i=="number"?i:t.getVariable(i,e),Ii=(i,t)=>(i||(i=new bn),i.x=Se(i.x,t)??0,i.y=Se(i.y,t)??0,i.z=Se(i.z,t)??0,i),Yo=(i,t)=>(i||(i=new Yr),i.x=Se(i.x,t)??0,i.y=Se(i.y,t)??0,i),ps=(i,t)=>{let e=i.map(r=>Se(r,t)??0);return[e[0],e[1]]},Ni=class{constructor(t,e,r,o,n){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in r)yh(a,this,r,n)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return Zt.createLightLayer(t,e,r,o);if(r.type==="texture"||r.type==="video"){let n=r.type==="texture"?o.uiBuffer(r.texture.image)??o.image(r.texture.image):o.video(r.texture.video),a=new yn(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new Yu(n),l=new Ku(ps(r.texture.repeat,o),ps(r.texture.offset,o),Se(r.texture.rotation??0,o)),c=new se(r.crop?1:0),u=new Le(r.projection??0),d=new Le(["x","y","z"].indexOf(r.axis)??0),p=new Le(r.side??0),f=new ut(r.size?new Yr(...ps(r.size,o)):new Yr(100,100)),h=new se(r.blending??0),m=new se(Ei(r.alpha,o)),y=new Le(r.mode??0),g=new dt(r.isMask??!1),b=new Ai(a,s,c,u,d,p,f,h,l,m,y,g),w=new ke(b.calpha,"f");return new it(t,e,r,{texture:a,textureSize:s,crop:c,projection:u,axis:d,side:p,size:f,blending:h,mat:l,alpha:m,mode:y,isMask:g},b,y,w,g,o)}else if(r.type==="matcap"){let n=o.image(r.texture.image),a=new yn(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new se(Ei(r.alpha,o)),l=new Le(r.mode??0),c=new dt(r.isMask??!1),u=new se((Se(r.texture.rotation??0,o)??0)*BN.DEG2RAD),d=new os(a,s,l,c,u),p=new ke(d.calpha,"f");return new it(t,e,r,{texture:a,alpha:s,mode:l,isMask:c,rotation:u},d,l,p,c,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let n=new jt(new bn(...r.offset.map(g=>Se(g,o)??0))),a=new se(Se(r.scale,o)??10),s=new se(Se(r.intensity,o)??8),l=new se(Se(r.movement,o)??1),c=new Le(r.noiseType??0),u=new Le(r.voronoiStyle??0),d=new se(Se(r.smoothness,o)??.5),p=new se(Se(r.seed,o)??0),f=new se(Se(r.highCut,o)??1),h=new se(Se(r.lowCut,o)??0),m=new Le(Se(r.quality,o)??1),y=new us(s,l,n,u,d,p,f,h,m,a,c);return new Al(t,e,r,{offset:n,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:u,smoothness:d,seed:p,highCut:f,lowCut:h,quality:m},y,o)}else throw new Error;else return GN(t,e,r,o)}updateByOp(t,e,r){let o=t,n=!1;if(o.path[0]===void 0){for(let a of Object.keys(o.props))try{let s=this.data[a],l=e[a];if(Array.isArray(s)&&Array.isArray(l)){for(let[c,u]of l.entries()){let d=s[c];if(typeof u=="string"||typeof u=="number"&&typeof d=="string"){n=!0;break}}if(n)break}else if(typeof l=="string"&&typeof s=="number"||typeof l=="number"&&typeof s=="string"||typeof l=="string"&&typeof s=="string"&&l!==s){n=!0;break}}catch(s){console.error(s)}if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props||"noiseType"in o.props?(r.scene.markNeedsUpdateRendererDirty(),!0):xv(o.props,r.shared,this,e)||n}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Cl(o.props,r.shared,this)||n:!0;return n}dispose(){if(VN(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof mr||e.image.deref()}}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}},it=class extends Ni{constructor(e,r,o,n,a,s,l,c,u){super(e,r,o,n,u);this.params=n;this.color=a;this.mode=s;this.alpha=l;this.isMask=c}},Al=class extends Ni{constructor(e,r,o,n,a,s){super(e,r,o,n,s);this.position=a}},Zt=class extends Ni{constructor(e,r,o,n,a,s){super(e,r,o,a,s);this.node=n}static createLightLayer(e,r,o,n){let a,s=new se(Ei(o.alpha,n)),l=new Le(o.mode),c=new se(o.bumpMapIntensity),u=new se(Ei(o.alphaOverride,n)),d;if(!o.visible)a=new qo,d={};else if(o.category==="lambert"){a=new wl;let p=new qe(n.color(o.emissive)??0),f=new dt(o.occlusion??!0);d={emissive:p,occlusion:f},a.emissive=p,a.occlusion=f}else if(o.category==="toon"){a=new Tl;let p=new se(o.shininess??30),f=new qe(n.color(o.specular)??1118481);d={shininess:p,specular:f},a.shininess=p,a.specular=f}else if(o.category==="physical"){a=new Ol;let p=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new dt(o.occlusion??!0);d={roughness:p,metalness:f,reflectivity:h,occlusion:m},a.roughness=p,a.metalness=f,a.reflectivity=h,a.occlusion=m}else{a=new Pl;let p=new se(o.shininess??30),f=new qe(o.specular!==void 0?n.color(o.specular)??1118481:1118481),h=new dt(o.occlusion??!0);d={shininess:p,specular:f,occlusion:h},a.shininess=p,a.specular=f,a.occlusion=h}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=c,a.alphaOverride=u,d.alpha=a.shadingAlpha,d.mode=a.shadingBlend,d.bumpMapIntensity=a.bumpMapIntensity,d.alphaOverride=a.alphaOverride,new Zt(e,r,o,a,d,n)}get category(){return this.node.category}};function VN(i){let t=i instanceof Ni?i.type:i;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Cr(i){return{alpha:new se(i.alpha??1),mode:new Le(i.mode??0),isMask:new dt(i.isMask??!1)}}function zN(i,t,e,r,o){switch(i.type){case"color":{let n=new qe(r.color??bt),a=Cr(r),s=new gn(n,a.alpha),l=new ke(s.calpha,"f");return new it(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let n=new qe(r.color??16777215),a=new se(Se(r.bias,o)??.1),s=new se(Se(r.scale,o)??1),l=new se(Se(r.intensity,o)??2),c=new se(Se(r.factor,o)??1),u=Cr(r),d=new Sl(n,a,s,l,c,u.alpha,u.mode,u.isMask),p=new ke(d.calpha,"f");return new it(t,e,i,{color:n,bias:a,scale:s,intensity:l,factor:c,...u},d,u.mode,p,u.isMask,o)}case"rainbow":{let n=new se(Se(r.filmThickness,o)??30),a=new se(Se(r.movement,o)??0),s=new jt(Ii(r.wavelengths,o)),l=new se(Se(r.noiseStrength,o)??0),c=new se(Se(r.noiseScale,o)??1),u=new jt(Ii(r.offset,o)),d=Cr(r),p=new ss(n,a,s,l,c,u,d.alpha,d.isMask),f=new ke(p.calpha,"f");return new it(t,e,i,{filmThickness:n,movement:a,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...d},p,d.mode,f,d.isMask,o)}case"transmission":{let n=new se(Se(r.thickness??10,o)),a=new se(Se(r.ior??1.5,o)),s=new se(Se(r.roughness??.5,o)),l=Me.transmissionSize,c=Me.transmissionRenderTarget,u=Me.transmissionRenderTargetDepth,d=window.innerWidth,p=window.innerHeight,f=d>=p?new ut(p/d,1):new ut(1,d/p),h=Cr(r),m=new cs(n,a,s,l,c,u,f,h.alpha),y=new ke(m.calpha,"f");return new it(t,e,i,{thickness:n,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let n=new Le(r.positioning??0),a;r.colors?a=new $r(r.colors.length,r.colors):(a=new $r(10,new fs(0,0,0,1)),a.value[1]=new fs(1,1,1,1));let s;r.steps?s=new qr(r.steps.length,r.steps):(s=new qr(10,1),s.value[0]=0);let l=new jt(Ii(r.source??new bn(0,0,0),o)),c=new dt(r.isWorldSpace??!0),u=new se(Se(r.noiseStrength??0,o)),d=new se(Se(r.noiseScale??1,o)),p=new or(r.shadowColor),f=new jt(Ii(r.offset??new bn(0,0,0),o)),h=Cr(r),m=new ls(n,a,s,l,c,u,d,p,f,h.alpha),y=new ke(m.calpha,"f");return new it(t,e,i,{positioning:n,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:d,shadowColor:p,offset:f,...h},m,h.mode,y,h.isMask,o)}case"outline":{let n=new qe(r.outlineColor??16777215),a=new qe(r.contourColor??16777215),s=new se(Se(r.outlineWidth??.1,o)),l=new se(Se(r.contourWidth??.1,o)),c=new se(Se(r.outlineThreshold??.1,o)),u=new se(Se(r.contourThreshold??.1,o)),d=new se(Se(r.outlineSmoothing??.1,o)),p=new se(Se(r.contourFrequency??.1,o)),f=new jt(Ii(r.contourDirection??new bn(0,1,0),o)),h=new dt(r.positionalLines??!1),m=new dt(r.compensation??!0),y=Me.normalRenderTarget,g=Me.normalRenderTargetDepth,b=Me.pixelRatioNode,w=Me.resolution,P=Cr(r),S=new ns(n,a,s,l,c,u,d,p,f,h,m,w,y,g,b,P.alpha),T=new ke(S.calpha,"f");return new it(t,e,i,{outlineColor:n,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:d,contourFrequency:p,contourDirection:f,positionalLines:h,compensation:m,...P},S,P.mode,T,P.isMask,o)}case"depth":{let n=new Le(r.gradientType??0),a=new dt(r.smooth??!1),s=new se(Se(r.near,o)??50),l=new se(Se(r.far,o)??200),c=new se(r.isVector??1),u=new se(r.isWorldSpace??0),d=new jt(Ii(r.origin,o)),p=new jt(Ii(r.direction,o)),f;r.colors?f=new $r(r.colors.length,r.colors):(f=new $r(2,new fs(0,0,0,1)),f.value[1]=new fs(1,1,1,1));let h;r.steps?h=new qr(r.steps.length,r.steps):(h=new qr(2,1),h.value[0]=0);let m=Cr(r),y=new ts(n,a,s,l,c,u,d,p,f,h,m.alpha,m.isMask),g=new ke(y.calpha,"f");return new it(t,e,i,{gradientType:n,smooth:a,near:s,far:l,isVector:c,isWorldSpace:u,origin:d,direction:p,colors:f,steps:h,...m},y,m.mode,g,m.isMask,o)}case"noise":{let n=new se(Se(r.scale,o)??1),a=new jt(Ii(r.size??new bn(100,100,100),o)),s=new se(Se(r.move,o)??1),l=new ut(Yo(r.fA??new Yr(1.7,9.2),o)),c=new ut(Yo(r.fB??new Yr(8.3,2.8),o)),u=new ut(Yo(r.distortion??new Yr(1,1),o)),d=new or(r.colorA),p=new or(r.colorB),f=new or(r.colorC),h=new or(r.colorD),m=new Le(r.noiseType??0),y=new Le(r.voronoiStyle??0),g=new se(Se(r.highCut,o)??1),b=new se(Se(r.lowCut,o)??0),w=new se(Se(r.smoothness,o)??.5),P=new se(Se(r.seed,o)??.5),S=new Le(r.quality??1),T=Cr(r),A=new is(n,a,s,l,c,u,d,p,f,h,T.alpha,m,T.isMask,y,g,b,w,P,S),x=new ke(A.calpha,"f");return new it(t,e,i,{scale:n,size:a,move:s,fA:l,fB:c,distortion:u,colorA:d,colorB:p,colorC:f,colorD:h,noiseType:m,...T,voronoiStyle:y,highCut:g,lowCut:b,smoothness:w,seed:P,quality:S},A,T.mode,x,T.isMask,o)}case"normal":{let n=new jt(r.cnormal??new bn(1,1,1)),a=Cr(r),s=new Za(n,a.alpha),l=new ke(s.calpha,"f");return new it(t,e,i,{cnormal:n,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let n=new Le(r.gradientType??0),a=new dt(r.smooth??!1),s;r.colors?s=new $r(r.colors.length,r.colors):(s=new $r(10,new fs(0,0,0,1)),s.value[1]=new fs(1,1,1,1));let l;r.steps?l=new qr(r.steps.length,r.steps):(l=new qr(10,1),l.value[0]=0);let c=new ut(Yo(r.offset??new Yr(0,0),o)),u=new ut(Yo(r.morph??new Yr(0,0),o)),d=new se(Se(r.angle??0,o)),p=Cr(r),f=new rs(n,a,s,l,c,u,d,p.alpha,p.isMask),h=new ke(f.calpha,"f");return new it(t,e,i,{gradientType:n,smooth:a,colors:s,steps:l,offset:c,morph:u,angle:d,...p},f,p.mode,h,p.isMask,o)}case"pattern":{let n=new Le(r.style??0),a=new Le(r.projection??0),s=new Le(["x","y","z"].indexOf(r.axis)??0),l=new se(Se(r.blending??0,o)),c=new ut(Yo(r.offset,o)),u=new or(r.colorA),d=new or(r.colorB),p=new ut(Yo(r.frequency??new Yr(10,10),o)),f=new se(Se(r.size??.5,o)),h=new se(Se(r.variation??0,o)),m=new se(Se(r.smoothness??.5,o)),y=new se(Se(r.zigzag??0,o)),g=new se(Se(r.rotation??0,o)),b=new ut(Yo(r.vertical??new Yr(0,1),o)),w=new ut(Yo(r.horizontal??new Yr(0,1),o)),P=new Le(r.sides??6),S=Cr(r),T=new as(n,a,s,l,c,u,d,p,f,h,m,y,g,b,w,P,S.alpha,S.isMask),A=new ke(T.calpha,"f");return new it(t,e,i,{style:n,projection:a,axis:s,blending:l,offset:c,colorA:u,colorB:d,frequency:p,size:f,variation:h,smoothness:m,zigzag:y,rotation:g,vertical:b,horizontal:w,sides:P,...S},T,S.mode,A,S.isMask,o)}default:{let n=new qe(1,0,0,1),a=Cr(r),s=new gn(n,a.alpha),l=new ke(s.calpha,"f");return new it(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}}}function GN(i,t,e,r){let o=gv(e,r);return zN(e,i,t,o,r)}function yh(i,t,e,r){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let o=t.uniforms[`f${t.id}_intensity`];return o?(o.value=(Se(e.intensity,r)??1)*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let o=t.uniforms[`f${t.id}_alpha`];if(!o)return;if(o.value=Ei(e.alpha,r)*(e.visible?1:0),e.type==="outline"&&i==="visible"){let n=t.uniforms[`f${t.id}_compensation`];n&&(n.value=e.compensation&&e.visible)}return o}}function nr(i,t,e,r,o,n,a=[]){let s=e;for(let l of a)l in s&&(s=s[l]);for(let l of i)l in s&&o.getVariable(s[l],["material",n,"layer",r,...a,String(l)]);for(let l of t)l in s&&s[l].forEach((c,u)=>{o.getVariable(c,["material",n,"layer",r,...a,String(l),u===0?"x":u===1?"y":"z"])})}function td(i,t){let e=0,r=i.layers.find(o=>o.data.type==="light");if(r){let o=r.data,n=Number(t.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(t.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=t.color(o.data.colorA).a,s=t.color(o.data.colorB).a,l=t.color(o.data.colorC).a,c=t.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 ar=class extends FN{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""}},rd=class extends ar{constructor(e,r,o,n){super();this.flatShading=e;this.side=r;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,r){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,r,o,n){return this.root.getFlavor(e,r,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,r,o){this.root.updateByOp(e,r,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},vn=class extends ar{constructor(e,r,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.needsJitter=r.shared.needsJitter,Xe.startContext(this),this.reset0(e,r),Xe.endContext(this)}get nodeMaterial(){return this}getFlavor(e,r,o,n){let a=o?6:(e?3:0)+r;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 rd(e,r,o,this),s.needsJitter=this.needsJitter,this.flavors[a]=s,s.flatShading=e,s.side=r,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,r,o=!1){Xe.startContext(this),(this.data!==e||o)&&this.reset0(e,r),Xe.endContext(this)}reset0(e,r){this.data=e;let o=e.layers??At.defaultTwoLayerData("phong").layers;try{this.layers=o.map(n=>Ni.create(this.layerIdGen++,n.id,n.data,r.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r.shared),this.transparent=td(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=td(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(r)/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);if(s?.hasValue(a))if(a==="alpha")this.transparent=td(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(r)/100,1)));else{let l=s.getValue(a),c=e[3],u=e[4];if(l instanceof jN){let d=l[c],p;typeof d=="number"?p=Number(r):d.isVector2&&(p=d.toArray(),u==="x"?p[0]=Number(r):u==="y"&&(p[1]=Number(r))),Cl({[c]:p},o.shared,s);return}(c==="x"||c==="y"||c==="z")&&l.isVector3||(c==="x"||c==="y")&&l.isVector2?l[c]=Number(r):s.setValue(a,r)}}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let r=this.data.layers.find(o=>o.data.type==="light");r&&e.shared.getVariable(r.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"]),o.data.type==="displace"?o.data.displacementType==="noise"?nr(["intensity","scale","movement","smoothness","seed","highCut","lowCut"],["offset"],o.data,o.id,e.shared,this.uuid):nr(["intensity"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="depth"?nr(["near","far"],["origin","direction"],o.data,o.id,e.shared,this.uuid):o.data.type==="fresnel"?nr(["bias","scale","intensity","factor"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="rainbow"?nr(["filmThickness","movement","noiseStrength","noiseScale"],["offset","wavelengths"],o.data,o.id,e.shared,this.uuid):o.data.type==="noise"?nr(["scale","move","seed","highCut","lowCut","smoothness"],["size","distortion","fA","fB"],o.data,o.id,e.shared,this.uuid):o.data.type==="pattern"?nr(["blending","size","variation","smoothness","zigzag","rotation"],["offset","frequency","vertical","horizontal"],o.data,o.id,e.shared,this.uuid):o.data.type==="outline"?nr(["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],["contourDirection"],o.data,o.id,e.shared,this.uuid):o.data.type==="toon"?nr(["noiseStrength","noiseScale"],["offset","source"],o.data,o.id,e.shared,this.uuid):o.data.type==="transmission"?nr(["roughness","thickness","ior"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="texture"||o.data.type==="video"?(nr([],["size"],o.data,o.id,e.shared,this.uuid),nr(["rotation"],["repeat","offset"],o.data,o.id,e.shared,this.uuid,["texture"])):o.data.type==="gradient"?nr(["angle"],["offset","morph"],o.data,o.id,e.shared,this.uuid):o.data.type==="matcap"&&nr(["rotation"],[],o.data,o.id,e.shared,this.uuid,["texture"])})}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(r=>r instanceof Zt),this.lightLayer===void 0&&(this.lightLayer=new Zt(0,"",{...gt.defaultData("light","phong"),visible:!1},new qo,{},e)),this.dispose();for(let r of this.flavors)r&&r.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 Zt);if(!e)return;let r=e.data,o=r.bumpMap,n=r.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 it&&s.color instanceof Ai&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===n&&(e.node.roughnessMap=s.color))}}updateByOp(e,r,o){if(Xe.startContext(this),r!==void 0?this.data=r:r=this.data,this.transparent=td(r,o.shared),e.path[0]==="layers"){let n=o.shared,a=e.path[1];if(a===void 0)o.scene.markNeedsUpdateRendererDirty(),this.reset0(r,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=r.layers.data(a),c;e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?c={...e.props,alpha:Ei(e.props.alpha,n,["material",this.uuid,"layer",a,"alpha"])}:c={...e.props,alphaOverride:Ei(e.props.alphaOverride,n,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...c?{props:c}:{},path:e.path.slice(2)},l,o)&&this.reset0(r,o)}}}else this.reset0(r,o);Xe.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let r=this.layers[e];r instanceof it?r.color.mask=void 0:r instanceof Zt&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof it&&r.isMask.value&&r.data.visible&&e>0){let o=e-1,n=this.layers[o];n instanceof Zt?n.node.mask=new Bt(r.color,r.alpha,Bt.MUL):n instanceof it&&(n.isMask.value||(n.color.mask=new Bt(r.color,r.alpha,Bt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof it),r=this.layers.findIndex(o=>o instanceof Zt);if(e!==-1&&e<r){let o=this.layers[e].color;for(let n=e+1;n<r;++n){let a=this.layers[n];if(a instanceof it){if(a.isMask.value)continue;o=new Qa(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new ke("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof Zt);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let n=this.layers[o];if(n instanceof it){if(n.isMask.value)continue;e=new Qa(e,n.color,n.alpha,n.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof Al);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new Bt(r,e[o].position,Bt.ADD),r=new Bt(r,new se(.5).setReadonly(!0),Bt.MUL));this.fragment.position=r}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,r){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,r);n.uniforms[`f${n.id}_intensity`].value=a}}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(){let e=new Ya;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 r of this.flavors)r&&r.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 it){let r=e.params.texture;if(r instanceof yn&&!r.image.loaded)return!1}return!0}};Object.defineProperties(ar.prototype,{properties:{get:function(){return this.fragment.properties}}});var Sn=class extends vn{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var bv=new Map;function vv(i){if(typeof i=="string")return i;let t=bv.get(i);return t||(t={url:URL.createObjectURL(new Blob([i]))},bv.set(i,t)),t.url}var UN,Sv=new Promise(i=>{UN=i});var wv;Sv.then(i=>wv=i);var wn=class{constructor({src:t,volume:e,delay:r,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 t=="string"?n={src:t}:n={src:vv(t),format:"wav"},this.sound=new wv.Howl(n),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}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(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};import{Box2 as kN,Vector2 as Pn,Path as Pv,Shape as HN,ShapeUtils as WN,Color as qN}from"three";var od=class{constructor(){this.type="ShapePath";this.color=new qN;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new Pv,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,r,o){return this.currentPath?.quadraticCurveTo(t,e,r,o),this}bezierCurveTo(t,e,r,o,n,a){return this.currentPath?.bezierCurveTo(t,e,r,o,n,a),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},r={loc:e.ORIGIN,t:0};function o(m,y,g,b){let w=m.x,P=y.x,S=g.x,T=b.x,A=m.y,x=y.y,N=g.y,E=b.y,M=(T-S)*(A-N)-(E-N)*(w-S),D=(P-w)*(A-N)-(x-A)*(w-S),_=(E-N)*(P-w)-(T-S)*(x-A),R=M/_,V=D/_;if(_===0&&M!==0||R<=0||R>=1||V<0||V>1)return null;if(M===0&&_===0){for(let U=0;U<2;U++)if(n(U===0?g:b,m,y),r.loc===e.ORIGIN){let B=U===0?g:b;return{x:B.x,y:B.y,t:r.t}}else if(r.loc===e.BETWEEN){let B=+(w+r.t*(P-w)).toPrecision(10),q=+(A+r.t*(x-A)).toPrecision(10);return{x:B,y:q,t:r.t}}return null}else{for(let q=0;q<2;q++)if(n(q===0?g:b,m,y),r.loc===e.ORIGIN){let j=q===0?g:b;return{x:j.x,y:j.y,t:r.t}}let U=+(w+R*(P-w)).toPrecision(10),B=+(A+R*(x-A)).toPrecision(10);return{x:U,y:B,t:R}}}function n(m,y,g){let b=g.x-y.x,w=g.y-y.y,P=m.x-y.x,S=m.y-y.y,T=b*S-P*w;if(m.x===y.x&&m.y===y.y){r.loc=e.ORIGIN,r.t=0;return}if(m.x===g.x&&m.y===g.y){r.loc=e.DESTINATION,r.t=1;return}if(T<-Number.EPSILON){r.loc=e.LEFT;return}if(T>Number.EPSILON){r.loc=e.RIGHT;return}if(b*P<0||w*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(b*b+w*w)<Math.sqrt(P*P+S*S)){r.loc=e.BEYOND;return}let A;b!==0?A=P/b:A=S/w,r.loc=e.BETWEEN,r.t=A}function a(m,y){let g=[],b=[];for(let w=1;w<m.length;w++){let P=m[w-1],S=m[w];for(let T=1;T<y.length;T++){let A=y[T-1],x=y[T],N=o(P,S,A,x);N!==null&&g.find(E=>E.t<=N.t+Number.EPSILON&&E.t>=N.t-Number.EPSILON)===void 0&&(g.push(N),b.push(new Pn(N.x,N.y)))}}return b}function s(m,y,g){let b=new Pn;y.getCenter(b);let w=[];return g.forEach(P=>{P.boundingBox.containsPoint(b)&&a(m,P.points).forEach(T=>{w.push({identifier:P.identifier,isCW:P.isCW,point:T})})}),w.sort((P,S)=>P.point.x-S.point.x),w}function l(m,y,g,b,w){(w==null||w==="")&&(w="nonzero");let P=new Pn;m.boundingBox.getCenter(P);let S=[new Pn(g,P.y),new Pn(b,P.y)],T=s(S,m.boundingBox,y);T.sort((D,_)=>D.point.x-_.point.x);let A=[],x=[];T.forEach(D=>{D.identifier===m.identifier?A.push(D):x.push(D)});let N=A[0].point.x,E=[],M=0;for(;M<x.length&&x[M].point.x<N;)E.length>0&&E[E.length-1]===x[M].identifier?E.pop():E.push(x[M].identifier),M++;if(E.push(m.identifier),w==="evenodd"){let D=E.length%2===0,_=E[E.length-2];return{identifier:m.identifier,isHole:D,for:_}}else if(w==="nonzero"){let D=!0,_=null,R=null;for(let V=0;V<E.length;V++){let U=E[V];y[U]&&(D?(R=y[U].isCW,D=!1,_=U):R!==y[U].isCW&&(R=y[U].isCW,D=!0))}return{identifier:m.identifier,isHole:D,for:_}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let c=0,u=999999999,d=-999999999,p=[];this.subPaths.forEach(m=>{let y=m.getPoints(),g=-999999999,b=999999999,w=-999999999,P=999999999;for(let S=0;S<y.length;S++){let T=y[S];T.y>g&&(g=T.y),T.y<b&&(b=T.y),T.x>w&&(w=T.x),T.x<P&&(P=T.x)}d<=w&&(d=w+1),u>=P&&(u=P-1),y.length&&p.push({curves:m.curves,points:y,isCW:WN.isClockWise(y),identifier:c++,boundingBox:new kN(new Pn(P,b),new Pn(w,g))})});let f=p.map(m=>l(m,p,u,d,this.userData?.style.fillRule)),h=[];return p.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let g=new HN;g.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let P=p[w.identifier],S=new Pv;S.curves=P.curves,g.holes.push(S)}}),h.push(g)}}),h}};var gh=!1,Tv,xh=new Promise(i=>{Tv=i}),Ov=!1;var id;function Cv(){if(gh=!0,Ov)return;if(id)return id;async function i(){let e=await import("./opentype.js");Tv(e),Ov=!0}return id=i(),id}var Ml=class{async load(t,e,r=()=>{}){let{load:o}=await xh;o(t,(n,a)=>{n||!a?r(n??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await xh;try{let o=e(t),n=new r,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 $N(i){return await(await fetch(i)).arrayBuffer()}var XN=new Ml;async function bh(i){let t,e,r=!1;if(i.url?(t=await $N(i.url),e=i.url,r=i.url.startsWith("/")):i.data&&(t=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),t)if(gh){let o=await XN.parse(t);if(o)return{font:o.font,url:e,intercepted:r,arr:t,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:r,arr:t,bidi:null}}import{CubicBezierCurve as YN,LineCurve as KN,QuadraticBezierCurve as QN}from"three";function ZN(i,t){return t.state.glyphIndex===i||t.state.fina===i||t.state.medi===i||t.state.init===i}var nd=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=bh(t).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(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=bh(t).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(t,e,r){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let n=o.tokenizer.tokens,a=[],s=0,l=r.length===n.length;for(let c=0;c<r.length;c++){let u=r[c].index,d=String.fromCharCode(r[c].unicode),p=n[s];if(ZN(u,p)||l)a.push({char:d,index:u,replacements:[p.state.glyphIndex],replacementChars:[p.char]}),s++;else{let f=p.char,h="",m=[p.state.glyphIndex],y=[],g=!1;for(;!g;)s++,h=e.charAt(s),f+=h,m.push(t.charToGlyphIndex(h)),y=t.stringToGlyphs(f),y.length===1&&y[0].index===u&&(g=!0),s>e.length&&(g=!0);a.push({char:d,index:u,replacements:m,replacementChars:Array.from(f)}),s++}}return a}generateShapes(t,e,r){if(!this._isLoaded)return;let o=this.font,n=e.fontSize/this.unitsPerEm,a=e.fontSize*e.lineHeight,s=t.map(b=>this.getTextWidth(b,e)),l=typeof e.width=="string"?Number(r.getVariable(e.width)):e.width,c=typeof e.height=="string"?Number(r.getVariable(e.height)):e.height,u=this.getCharWidth(`
|
|
2285
|
+
`)}return r}};import{VideoTexture as gN,Texture as xN}from"three";var Qu=class{constructor(t=1e3*10){this.timeout=t;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.cleanupTimer=null;this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev,e.next=null,e.prev=null,e.data=null)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,this.cleanupTimer=setTimeout(()=>{this.hasClean=!1,this.cleanupTimer=null,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;){this.dispose(e.src,e.data),this.cache.delete(e.src);let r=e;e=e.next,e.prev=this.head,this.head.next=e,r.next=null,r.prev=null,r.data=null}this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}disposeAll(){this.cleanupTimer!==null&&(clearTimeout(this.cleanupTimer),this.cleanupTimer=null),this.hasClean=!1,this.cache.forEach((t,e)=>{this.dispose(e,t.data),t.next=null,t.prev=null,t.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}};var hh=class extends Qu{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},fh;function yv(i){return typeof i=="string"?i:(fh||(fh=new hh),fh.load(i))}var Zu=class{constructor(t,e){this.data=t;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")}},Ju=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var ds=class extends Zu{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;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 r=()=>{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=()=>{r()}}else this.img=new Image,this.img.src=yv(e),this.img.onload=r,await new Promise(n=>{this.img.onload=()=>{r(),n(null)}})}getTexture(e,r=1008,o=1006){let n=this._cache[e]?.[r]?.[o];if(n)return n;{let a;return this.isBuffer?a=this.img.texture:this.isVideo?a=new gN(this.img,void 0,e,e):a=new xN(this.img,void 0,e,e,o,r),this.loaded&&(a.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]===void 0&&(this._cache[e][r]={}),this._cache[e][r][o]=a,a}}setNeedsUpdate(e){for(let r of Object.values(this._cache))for(let o of Object.values(r))for(let n of Object.values(o))n&&(n.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[o,n]of Object.entries(r))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 mr=class extends ds{};import{Vector2 as Xo,Vector3 as bo,Vector4 as ed}from"three";function kt(i,t){return t.color(i)}function gv(i,t){switch(i.type){case"fresnel":return SN(i,t);case"gradient":return wN(i,t);case"depth":return PN(i,t);case"normal":return ON(i,t);case"noise":return TN(i,t);case"rainbow":return CN(i,t);case"toon":return AN(i,t);case"outline":return MN(i,t);case"transmission":return IN(i,t);case"pattern":return EN(i,t);case"color":default:return vN(i,t)}}function bN(i){return{type:i.type}}function Xr(i,t){let{alpha:e,mode:r,isMask:o}=i,n=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...bN(i),alpha:n,mode:r,isMask:o}}function vN(i,t){return{...Xr(i,t),color:kt(i.color,t)}}function SN(i,t){let{bias:e,scale:r,intensity:o,factor:n,color:a}=i;return{...Xr(i,t),color:kt(a,t),bias:e,scale:r,intensity:o,factor:n}}function wN(i,t){let{gradientType:e,smooth:r,colors:o,steps:n,angle:a,offset:s,morph:l}=i;return{...Xr(i,t),gradientType:e,smooth:r,colors:o.map(c=>new ed(c[0],c[1],c[2],c[3])),num:o.length,steps:n,offset:new Xo(...s.map(c=>typeof c=="number"?c:0)),morph:new Xo(...l.map(c=>typeof c=="number"?c:0)),angle:a}}function PN(i,t){let{gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:s,direction:l,colors:c,steps:u,smooth:d}=i;return{...Xr(i,t),gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:new bo(...s),direction:l?new bo(...l):new bo(1,0,0),colors:c.map(p=>p!==void 0?new ed(p[0],p[1],p[2],p[3]):new ed(0,0,0,0)),steps:u.slice(0,c.length),smooth:d}}function ON(i,t){let{cnormal:e}=i;return{...Xr(i,t),cnormal:new bo(e[0],e[1],e[2])}}function TN(i,t){return{...Xr(i,t),scale:i.scale,move:i.move,fA:new Xo(...i.fA.map(e=>typeof e=="number"?e:0)),fB:new Xo(...i.fB.map(e=>typeof e=="number"?e:0)),size:new bo(...i.size),distortion:new Xo(...i.distortion.map(e=>typeof e=="number"?e:0)),colorA:kt(i.colorA,t),colorB:kt(i.colorB,t),colorC:kt(i.colorC,t),colorD:kt(i.colorD,t),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}function CN(i,t){return{...Xr(i,t),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new bo(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new bo(...i.offset)}}function AN(i,t){return{...Xr(i,t),positioning:i.positioning,colors:i.colors.map(e=>new ed(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new bo(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:kt(i.shadowColor,t),offset:new bo(...i.offset)}}function MN(i,t){return{...Xr(i,t),outlineColor:kt(i.outlineColor,t),contourColor:kt(i.contourColor,t),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new bo(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}function IN(i,t){return{...Xr(i,t),thickness:i.thickness,ior:i.ior,roughness:i.roughness}}function EN(i,t){return{...Xr(i,t),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new Xo(...i.offset.map(e=>typeof e=="number"?e:0)),colorA:kt(i.colorA,t),colorB:kt(i.colorB,t),frequency:new Xo(...i.frequency.map(e=>typeof e=="number"?e:0)),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new Xo(...i.vertical.map(e=>typeof e=="number"?e:0)),horizontal:new Xo(...i.horizontal.map(e=>typeof e=="number"?e:0)),sides:i.sides}}var Mi=class extends Mt{};import{MathUtils as NN,Vector4 as DN}from"three";var _N={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},RN={depth:["colors"]};function LN(i,t,e){if(t==="isMask")return!0;let r=_N[i.type],o=RN[i.type];if(o!==void 0){let n=i.color;if(o.includes(t)){let a=n[t]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return r!==void 0?r.includes(t):!1}function mh(i,t){if(Array.isArray(t)){if(!Array.isArray(i)||i.length!==t.length)return!1;for(let[o,n]of t.entries()){let a=i[o];if(typeof n=="string"||typeof n=="number"&&typeof a=="string")return!0}return!1}let e=typeof i=="string",r=typeof t=="string";return e!==r||e&&r}function Cl(i,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let o=!1,n=i;if("image"in n){let a=n.image,s=t.image(a),l=r;l.image instanceof mr||l.image.deref(),l.image=s}if("video"in n){let a=n.video,s=t.video(a),l=r;l.image instanceof mr||l.image.deref(),l.image=s}if("wrapping"in n){let a=r;a.wrap=n.wrapping}if("minFilter"in n){let a=r;a.minFilter=n.minFilter}if("magFilter"in n){let a=r;a.magFilter=n.magFilter}if("rotation"in n&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(Se(n.rotation??0,t)??0)*NN.DEG2RAD,o;if("repeat"in n||"offset"in n||"rotation"in n){let a="mat",s=e.uniforms[`f${e.id}_${a}`];if(!s)return o;if("repeat"in n){let l=n.repeat;mh(e.data.texture.repeat,l)&&(o=!0),s.repeat=ps(l,t).map((c,u)=>typeof l[u]=="string"?1/c:c)}if("offset"in n){let l=n.offset;mh(e.data.texture.offset,l)&&(o=!0),s.offset=ps(l,t).map((c,u)=>typeof l[u]=="string"?-c:c)}if("rotation"in n){let l=e.data.texture.rotation,c=n.rotation??0;(l===void 0||mh(l,c))&&(o=!0),s.rotation=Se(c,t)??0}s.updateMatrix()}return o}function xv(i,t,e,r){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(yh(n,e,r,t)){n==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=r.visible;let s=e.uniforms[`f${e.id}_${n}`];if(!!s&&!(s instanceof Ci))switch(o=o||LN(e,n,a),s.constructor){case qe:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Mi?s.value=new Mt(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case or:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Mi?s.value=new Mt(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case ut:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case jt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case Qt:{Cl(a,t,e);break}case $r:{s.value=a.map(l=>new DN(...l));break}default:{s.value=a;break}}}return o}var Ei=(i,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,Se=(i,t,e)=>typeof i=="number"?i:t.getVariable(i,e),Ii=(i,t)=>(i||(i=new bn),i.x=Se(i.x,t)??0,i.y=Se(i.y,t)??0,i.z=Se(i.z,t)??0,i),Yo=(i,t)=>(i||(i=new Yr),i.x=Se(i.x,t)??0,i.y=Se(i.y,t)??0,i),ps=(i,t)=>{let e=i.map(r=>Se(r,t)??0);return[e[0],e[1]]},Ni=class{constructor(t,e,r,o,n){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in r)yh(a,this,r,n)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return Zt.createLightLayer(t,e,r,o);if(r.type==="texture"||r.type==="video"){let n=r.type==="texture"?o.uiBuffer(r.texture.image)??o.image(r.texture.image):o.video(r.texture.video),a=new yn(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new Yu(n),l=new Ku(ps(r.texture.repeat,o),ps(r.texture.offset,o),Se(r.texture.rotation??0,o)),c=new se(r.crop?1:0),u=new Le(r.projection??0),d=new Le(["x","y","z"].indexOf(r.axis)??0),p=new Le(r.side??0),f=new ut(r.size?new Yr(...ps(r.size,o)):new Yr(100,100)),h=new se(r.blending??0),m=new se(Ei(r.alpha,o)),y=new Le(r.mode??0),g=new dt(r.isMask??!1),b=new Ai(a,s,c,u,d,p,f,h,l,m,y,g),w=new ke(b.calpha,"f");return new it(t,e,r,{texture:a,textureSize:s,crop:c,projection:u,axis:d,side:p,size:f,blending:h,mat:l,alpha:m,mode:y,isMask:g},b,y,w,g,o)}else if(r.type==="matcap"){let n=o.image(r.texture.image),a=new yn(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new se(Ei(r.alpha,o)),l=new Le(r.mode??0),c=new dt(r.isMask??!1),u=new se((Se(r.texture.rotation??0,o)??0)*BN.DEG2RAD),d=new os(a,s,l,c,u),p=new ke(d.calpha,"f");return new it(t,e,r,{texture:a,alpha:s,mode:l,isMask:c,rotation:u},d,l,p,c,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let n=new jt(new bn(...r.offset.map(g=>Se(g,o)??0))),a=new se(Se(r.scale,o)??10),s=new se(Se(r.intensity,o)??8),l=new se(Se(r.movement,o)??1),c=new Le(r.noiseType??0),u=new Le(r.voronoiStyle??0),d=new se(Se(r.smoothness,o)??.5),p=new se(Se(r.seed,o)??0),f=new se(Se(r.highCut,o)??1),h=new se(Se(r.lowCut,o)??0),m=new Le(Se(r.quality,o)??1),y=new us(s,l,n,u,d,p,f,h,m,a,c);return new Al(t,e,r,{offset:n,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:u,smoothness:d,seed:p,highCut:f,lowCut:h,quality:m},y,o)}else throw new Error;else return GN(t,e,r,o)}updateByOp(t,e,r){let o=t,n=!1;if(o.path[0]===void 0){for(let a of Object.keys(o.props))try{let s=this.data[a],l=e[a];if(Array.isArray(s)&&Array.isArray(l)){for(let[c,u]of l.entries()){let d=s[c];if(typeof u=="string"||typeof u=="number"&&typeof d=="string"){n=!0;break}}if(n)break}else if(typeof l=="string"&&typeof s=="number"||typeof l=="number"&&typeof s=="string"||typeof l=="string"&&typeof s=="string"&&l!==s){n=!0;break}}catch(s){console.error(s)}if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props||"noiseType"in o.props?(r.scene.markNeedsUpdateRendererDirty(),!0):xv(o.props,r.shared,this,e)||n}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Cl(o.props,r.shared,this)||n:!0;return n}dispose(){if(VN(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof mr||e.image.deref()}}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}},it=class extends Ni{constructor(e,r,o,n,a,s,l,c,u){super(e,r,o,n,u);this.params=n;this.color=a;this.mode=s;this.alpha=l;this.isMask=c}},Al=class extends Ni{constructor(e,r,o,n,a,s){super(e,r,o,n,s);this.position=a}},Zt=class extends Ni{constructor(e,r,o,n,a,s){super(e,r,o,a,s);this.node=n}static createLightLayer(e,r,o,n){let a,s=new se(Ei(o.alpha,n)),l=new Le(o.mode),c=new se(o.bumpMapIntensity),u=new se(Ei(o.alphaOverride,n)),d;if(!o.visible)a=new qo,d={};else if(o.category==="lambert"){a=new wl;let p=new qe(n.color(o.emissive)??0),f=new dt(o.occlusion??!0);d={emissive:p,occlusion:f},a.emissive=p,a.occlusion=f}else if(o.category==="toon"){a=new Tl;let p=new se(o.shininess??30),f=new qe(n.color(o.specular)??1118481);d={shininess:p,specular:f},a.shininess=p,a.specular=f}else if(o.category==="physical"){a=new Ol;let p=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new dt(o.occlusion??!0);d={roughness:p,metalness:f,reflectivity:h,occlusion:m},a.roughness=p,a.metalness=f,a.reflectivity=h,a.occlusion=m}else{a=new Pl;let p=new se(o.shininess??30),f=new qe(o.specular!==void 0?n.color(o.specular)??1118481:1118481),h=new dt(o.occlusion??!0);d={shininess:p,specular:f,occlusion:h},a.shininess=p,a.specular=f,a.occlusion=h}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=c,a.alphaOverride=u,d.alpha=a.shadingAlpha,d.mode=a.shadingBlend,d.bumpMapIntensity=a.bumpMapIntensity,d.alphaOverride=a.alphaOverride,new Zt(e,r,o,a,d,n)}get category(){return this.node.category}};function VN(i){let t=i instanceof Ni?i.type:i;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Cr(i){return{alpha:new se(i.alpha??1),mode:new Le(i.mode??0),isMask:new dt(i.isMask??!1)}}function zN(i,t,e,r,o){switch(i.type){case"color":{let n=new qe(r.color??bt),a=Cr(r),s=new gn(n,a.alpha),l=new ke(s.calpha,"f");return new it(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let n=new qe(r.color??16777215),a=new se(Se(r.bias,o)??.1),s=new se(Se(r.scale,o)??1),l=new se(Se(r.intensity,o)??2),c=new se(Se(r.factor,o)??1),u=Cr(r),d=new Sl(n,a,s,l,c,u.alpha,u.mode,u.isMask),p=new ke(d.calpha,"f");return new it(t,e,i,{color:n,bias:a,scale:s,intensity:l,factor:c,...u},d,u.mode,p,u.isMask,o)}case"rainbow":{let n=new se(Se(r.filmThickness,o)??30),a=new se(Se(r.movement,o)??0),s=new jt(Ii(r.wavelengths,o)),l=new se(Se(r.noiseStrength,o)??0),c=new se(Se(r.noiseScale,o)??1),u=new jt(Ii(r.offset,o)),d=Cr(r),p=new ss(n,a,s,l,c,u,d.alpha,d.isMask),f=new ke(p.calpha,"f");return new it(t,e,i,{filmThickness:n,movement:a,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...d},p,d.mode,f,d.isMask,o)}case"transmission":{let n=new se(Se(r.thickness??10,o)),a=new se(Se(r.ior??1.5,o)),s=new se(Se(r.roughness??.5,o)),l=Me.transmissionSize,c=Me.transmissionRenderTarget,u=Me.transmissionRenderTargetDepth,d=window.innerWidth,p=window.innerHeight,f=d>=p?new ut(p/d,1):new ut(1,d/p),h=Cr(r),m=new cs(n,a,s,l,c,u,f,h.alpha),y=new ke(m.calpha,"f");return new it(t,e,i,{thickness:n,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let n=new Le(r.positioning??0),a;r.colors?a=new $r(r.colors.length,r.colors):(a=new $r(10,new fs(0,0,0,1)),a.value[1]=new fs(1,1,1,1));let s;r.steps?s=new qr(r.steps.length,r.steps):(s=new qr(10,1),s.value[0]=0);let l=new jt(Ii(r.source??new bn(0,0,0),o)),c=new dt(r.isWorldSpace??!0),u=new se(Se(r.noiseStrength??0,o)),d=new se(Se(r.noiseScale??1,o)),p=new or(r.shadowColor),f=new jt(Ii(r.offset??new bn(0,0,0),o)),h=Cr(r),m=new ls(n,a,s,l,c,u,d,p,f,h.alpha),y=new ke(m.calpha,"f");return new it(t,e,i,{positioning:n,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:d,shadowColor:p,offset:f,...h},m,h.mode,y,h.isMask,o)}case"outline":{let n=new qe(r.outlineColor??16777215),a=new qe(r.contourColor??16777215),s=new se(Se(r.outlineWidth??.1,o)),l=new se(Se(r.contourWidth??.1,o)),c=new se(Se(r.outlineThreshold??.1,o)),u=new se(Se(r.contourThreshold??.1,o)),d=new se(Se(r.outlineSmoothing??.1,o)),p=new se(Se(r.contourFrequency??.1,o)),f=new jt(Ii(r.contourDirection??new bn(0,1,0),o)),h=new dt(r.positionalLines??!1),m=new dt(r.compensation??!0),y=Me.normalRenderTarget,g=Me.normalRenderTargetDepth,b=Me.pixelRatioNode,w=Me.resolution,P=Cr(r),S=new ns(n,a,s,l,c,u,d,p,f,h,m,w,y,g,b,P.alpha),T=new ke(S.calpha,"f");return new it(t,e,i,{outlineColor:n,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:d,contourFrequency:p,contourDirection:f,positionalLines:h,compensation:m,...P},S,P.mode,T,P.isMask,o)}case"depth":{let n=new Le(r.gradientType??0),a=new dt(r.smooth??!1),s=new se(Se(r.near,o)??50),l=new se(Se(r.far,o)??200),c=new se(r.isVector??1),u=new se(r.isWorldSpace??0),d=new jt(Ii(r.origin,o)),p=new jt(Ii(r.direction,o)),f;r.colors?f=new $r(r.colors.length,r.colors):(f=new $r(2,new fs(0,0,0,1)),f.value[1]=new fs(1,1,1,1));let h;r.steps?h=new qr(r.steps.length,r.steps):(h=new qr(2,1),h.value[0]=0);let m=Cr(r),y=new ts(n,a,s,l,c,u,d,p,f,h,m.alpha,m.isMask),g=new ke(y.calpha,"f");return new it(t,e,i,{gradientType:n,smooth:a,near:s,far:l,isVector:c,isWorldSpace:u,origin:d,direction:p,colors:f,steps:h,...m},y,m.mode,g,m.isMask,o)}case"noise":{let n=new se(Se(r.scale,o)??1),a=new jt(Ii(r.size??new bn(100,100,100),o)),s=new se(Se(r.move,o)??1),l=new ut(Yo(r.fA??new Yr(1.7,9.2),o)),c=new ut(Yo(r.fB??new Yr(8.3,2.8),o)),u=new ut(Yo(r.distortion??new Yr(1,1),o)),d=new or(r.colorA),p=new or(r.colorB),f=new or(r.colorC),h=new or(r.colorD),m=new Le(r.noiseType??0),y=new Le(r.voronoiStyle??0),g=new se(Se(r.highCut,o)??1),b=new se(Se(r.lowCut,o)??0),w=new se(Se(r.smoothness,o)??.5),P=new se(Se(r.seed,o)??.5),S=new Le(r.quality??1),T=Cr(r),A=new is(n,a,s,l,c,u,d,p,f,h,T.alpha,m,T.isMask,y,g,b,w,P,S),x=new ke(A.calpha,"f");return new it(t,e,i,{scale:n,size:a,move:s,fA:l,fB:c,distortion:u,colorA:d,colorB:p,colorC:f,colorD:h,noiseType:m,...T,voronoiStyle:y,highCut:g,lowCut:b,smoothness:w,seed:P,quality:S},A,T.mode,x,T.isMask,o)}case"normal":{let n=new jt(r.cnormal??new bn(1,1,1)),a=Cr(r),s=new Za(n,a.alpha),l=new ke(s.calpha,"f");return new it(t,e,i,{cnormal:n,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let n=new Le(r.gradientType??0),a=new dt(r.smooth??!1),s;r.colors?s=new $r(r.colors.length,r.colors):(s=new $r(10,new fs(0,0,0,1)),s.value[1]=new fs(1,1,1,1));let l;r.steps?l=new qr(r.steps.length,r.steps):(l=new qr(10,1),l.value[0]=0);let c=new ut(Yo(r.offset??new Yr(0,0),o)),u=new ut(Yo(r.morph??new Yr(0,0),o)),d=new se(Se(r.angle??0,o)),p=Cr(r),f=new rs(n,a,s,l,c,u,d,p.alpha,p.isMask),h=new ke(f.calpha,"f");return new it(t,e,i,{gradientType:n,smooth:a,colors:s,steps:l,offset:c,morph:u,angle:d,...p},f,p.mode,h,p.isMask,o)}case"pattern":{let n=new Le(r.style??0),a=new Le(r.projection??0),s=new Le(["x","y","z"].indexOf(r.axis)??0),l=new se(Se(r.blending??0,o)),c=new ut(Yo(r.offset,o)),u=new or(r.colorA),d=new or(r.colorB),p=new ut(Yo(r.frequency??new Yr(10,10),o)),f=new se(Se(r.size??.5,o)),h=new se(Se(r.variation??0,o)),m=new se(Se(r.smoothness??.5,o)),y=new se(Se(r.zigzag??0,o)),g=new se(Se(r.rotation??0,o)),b=new ut(Yo(r.vertical??new Yr(0,1),o)),w=new ut(Yo(r.horizontal??new Yr(0,1),o)),P=new Le(r.sides??6),S=Cr(r),T=new as(n,a,s,l,c,u,d,p,f,h,m,y,g,b,w,P,S.alpha,S.isMask),A=new ke(T.calpha,"f");return new it(t,e,i,{style:n,projection:a,axis:s,blending:l,offset:c,colorA:u,colorB:d,frequency:p,size:f,variation:h,smoothness:m,zigzag:y,rotation:g,vertical:b,horizontal:w,sides:P,...S},T,S.mode,A,S.isMask,o)}default:{let n=new qe(1,0,0,1),a=Cr(r),s=new gn(n,a.alpha),l=new ke(s.calpha,"f");return new it(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}}}function GN(i,t,e,r){let o=gv(e,r);return zN(e,i,t,o,r)}function yh(i,t,e,r){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let o=t.uniforms[`f${t.id}_intensity`];return o?(o.value=(Se(e.intensity,r)??1)*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let o=t.uniforms[`f${t.id}_alpha`];if(!o)return;if(o.value=Ei(e.alpha,r)*(e.visible?1:0),e.type==="outline"&&i==="visible"){let n=t.uniforms[`f${t.id}_compensation`];n&&(n.value=e.compensation&&e.visible)}return o}}function nr(i,t,e,r,o,n,a=[]){let s=e;for(let l of a)l in s&&(s=s[l]);for(let l of i)l in s&&o.getVariable(s[l],["material",n,"layer",r,...a,String(l)]);for(let l of t)l in s&&s[l].forEach((c,u)=>{o.getVariable(c,["material",n,"layer",r,...a,String(l),u===0?"x":u===1?"y":"z"])})}function td(i,t){let e=0,r=i.layers.find(o=>o.data.type==="light");if(r){let o=r.data,n=Number(t.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(t.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=t.color(o.data.colorA).a,s=t.color(o.data.colorB).a,l=t.color(o.data.colorC).a,c=t.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 ar=class extends FN{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""}},rd=class extends ar{constructor(e,r,o,n){super();this.flatShading=e;this.side=r;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,r){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,r,o,n){return this.root.getFlavor(e,r,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,r,o){this.root.updateByOp(e,r,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},vn=class extends ar{constructor(e,r,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.needsJitter=r.shared.needsJitter,Xe.startContext(this),this.reset0(e,r),Xe.endContext(this)}get nodeMaterial(){return this}getFlavor(e,r,o,n){let a=o?6:(e?3:0)+r;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 rd(e,r,o,this),s.needsJitter=this.needsJitter,this.flavors[a]=s,s.flatShading=e,s.side=r,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,r,o=!1){Xe.startContext(this),(this.data!==e||o)&&this.reset0(e,r),Xe.endContext(this)}reset0(e,r){this.data=e;let o=e.layers??At.defaultTwoLayerData("phong").layers;try{this.layers=o.map(n=>Ni.create(this.layerIdGen++,n.id,n.data,r.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r.shared),this.transparent=td(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=td(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(r)/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);if(s?.hasValue(a))if(a==="alpha")this.transparent=td(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(r)/100,1)));else{let l=s.getValue(a),c=e[3],u=e[4];if(l instanceof jN){let d=l[c],p;typeof d=="number"?p=Number(r):d.isVector2&&(p=d.toArray(),u==="x"?p[0]=Number(r):u==="y"&&(p[1]=Number(r))),Cl({[c]:p},o.shared,s);return}(c==="x"||c==="y"||c==="z")&&l.isVector3||(c==="x"||c==="y")&&l.isVector2?l[c]=Number(r):s.setValue(a,r)}}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let r=this.data.layers.find(o=>o.data.type==="light");r&&e.shared.getVariable(r.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"]),o.data.type==="displace"?o.data.displacementType==="noise"?nr(["intensity","scale","movement","smoothness","seed","highCut","lowCut"],["offset"],o.data,o.id,e.shared,this.uuid):nr(["intensity"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="depth"?nr(["near","far"],["origin","direction"],o.data,o.id,e.shared,this.uuid):o.data.type==="fresnel"?nr(["bias","scale","intensity","factor"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="rainbow"?nr(["filmThickness","movement","noiseStrength","noiseScale"],["offset","wavelengths"],o.data,o.id,e.shared,this.uuid):o.data.type==="noise"?nr(["scale","move","seed","highCut","lowCut","smoothness"],["size","distortion","fA","fB"],o.data,o.id,e.shared,this.uuid):o.data.type==="pattern"?nr(["blending","size","variation","smoothness","zigzag","rotation"],["offset","frequency","vertical","horizontal"],o.data,o.id,e.shared,this.uuid):o.data.type==="outline"?nr(["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],["contourDirection"],o.data,o.id,e.shared,this.uuid):o.data.type==="toon"?nr(["noiseStrength","noiseScale"],["offset","source"],o.data,o.id,e.shared,this.uuid):o.data.type==="transmission"?nr(["roughness","thickness","ior"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="texture"||o.data.type==="video"?(nr([],["size"],o.data,o.id,e.shared,this.uuid),nr(["rotation"],["repeat","offset"],o.data,o.id,e.shared,this.uuid,["texture"])):o.data.type==="gradient"?nr(["angle"],["offset","morph"],o.data,o.id,e.shared,this.uuid):o.data.type==="matcap"&&nr(["rotation"],[],o.data,o.id,e.shared,this.uuid,["texture"])})}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(r=>r instanceof Zt),this.lightLayer===void 0&&(this.lightLayer=new Zt(0,"",{...gt.defaultData("light","phong"),visible:!1},new qo,{},e)),this.dispose();for(let r of this.flavors)r&&r.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 Zt);if(!e)return;let r=e.data,o=r.bumpMap,n=r.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 it&&s.color instanceof Ai&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===n&&(e.node.roughnessMap=s.color))}}updateByOp(e,r,o){if(Xe.startContext(this),r!==void 0?this.data=r:r=this.data,this.transparent=td(r,o.shared),e.path[0]==="layers"){let n=o.shared,a=e.path[1];if(a===void 0)o.scene.markNeedsUpdateRendererDirty(),this.reset0(r,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=r.layers.data(a),c;e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?c={...e.props,alpha:Ei(e.props.alpha,n,["material",this.uuid,"layer",a,"alpha"])}:c={...e.props,alphaOverride:Ei(e.props.alphaOverride,n,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...c?{props:c}:{},path:e.path.slice(2)},l,o)&&this.reset0(r,o)}}}else this.reset0(r,o);Xe.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let r=this.layers[e];r instanceof it?r.color.mask=void 0:r instanceof Zt&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof it&&r.isMask.value&&r.data.visible&&e>0){let o=e-1,n=this.layers[o];n instanceof Zt?n.node.mask=new Bt(r.color,r.alpha,Bt.MUL):n instanceof it&&(n.isMask.value||(n.color.mask=new Bt(r.color,r.alpha,Bt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof it),r=this.layers.findIndex(o=>o instanceof Zt);if(e!==-1&&e<r){let o=this.layers[e].color;for(let n=e+1;n<r;++n){let a=this.layers[n];if(a instanceof it){if(a.isMask.value)continue;o=new Qa(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new ke("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof Zt);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let n=this.layers[o];if(n instanceof it){if(n.isMask.value)continue;e=new Qa(e,n.color,n.alpha,n.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof Al);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new Bt(r,e[o].position,Bt.ADD),r=new Bt(r,new se(.5).setReadonly(!0),Bt.MUL));this.fragment.position=r}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,r){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,r);n.uniforms[`f${n.id}_intensity`].value=a}}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(){let e=new Ya;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 r of this.flavors)r&&r.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 it){let r=e.params.texture;if(r instanceof yn&&!r.image.loaded)return!1}return!0}};Object.defineProperties(ar.prototype,{properties:{get:function(){return this.fragment.properties}}});var Sn=class extends vn{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var bv=new Map;function vv(i){if(typeof i=="string")return i;let t=bv.get(i);return t||(t={url:URL.createObjectURL(new Blob([i]))},bv.set(i,t)),t.url}var UN,Sv=new Promise(i=>{UN=i});var wv;Sv.then(i=>wv=i);var wn=class{constructor({src:t,volume:e,delay:r,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 t=="string"?n={src:t}:n={src:vv(t),format:"wav"},this.sound=new wv.Howl(n),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}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(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};import{Box2 as kN,Vector2 as Pn,Path as Pv,Shape as HN,ShapeUtils as WN,Color as qN}from"three";var od=class{constructor(){this.type="ShapePath";this.color=new qN;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new Pv,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,r,o){return this.currentPath?.quadraticCurveTo(t,e,r,o),this}bezierCurveTo(t,e,r,o,n,a){return this.currentPath?.bezierCurveTo(t,e,r,o,n,a),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},r={loc:e.ORIGIN,t:0};function o(m,y,g,b){let w=m.x,P=y.x,S=g.x,T=b.x,A=m.y,x=y.y,N=g.y,E=b.y,M=(T-S)*(A-N)-(E-N)*(w-S),D=(P-w)*(A-N)-(x-A)*(w-S),_=(E-N)*(P-w)-(T-S)*(x-A),R=M/_,V=D/_;if(_===0&&M!==0||R<=0||R>=1||V<0||V>1)return null;if(M===0&&_===0){for(let U=0;U<2;U++)if(n(U===0?g:b,m,y),r.loc===e.ORIGIN){let B=U===0?g:b;return{x:B.x,y:B.y,t:r.t}}else if(r.loc===e.BETWEEN){let B=+(w+r.t*(P-w)).toPrecision(10),q=+(A+r.t*(x-A)).toPrecision(10);return{x:B,y:q,t:r.t}}return null}else{for(let q=0;q<2;q++)if(n(q===0?g:b,m,y),r.loc===e.ORIGIN){let j=q===0?g:b;return{x:j.x,y:j.y,t:r.t}}let U=+(w+R*(P-w)).toPrecision(10),B=+(A+R*(x-A)).toPrecision(10);return{x:U,y:B,t:R}}}function n(m,y,g){let b=g.x-y.x,w=g.y-y.y,P=m.x-y.x,S=m.y-y.y,T=b*S-P*w;if(m.x===y.x&&m.y===y.y){r.loc=e.ORIGIN,r.t=0;return}if(m.x===g.x&&m.y===g.y){r.loc=e.DESTINATION,r.t=1;return}if(T<-Number.EPSILON){r.loc=e.LEFT;return}if(T>Number.EPSILON){r.loc=e.RIGHT;return}if(b*P<0||w*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(b*b+w*w)<Math.sqrt(P*P+S*S)){r.loc=e.BEYOND;return}let A;b!==0?A=P/b:A=S/w,r.loc=e.BETWEEN,r.t=A}function a(m,y){let g=[],b=[];for(let w=1;w<m.length;w++){let P=m[w-1],S=m[w];for(let T=1;T<y.length;T++){let A=y[T-1],x=y[T],N=o(P,S,A,x);N!==null&&g.find(E=>E.t<=N.t+Number.EPSILON&&E.t>=N.t-Number.EPSILON)===void 0&&(g.push(N),b.push(new Pn(N.x,N.y)))}}return b}function s(m,y,g){let b=new Pn;y.getCenter(b);let w=[];return g.forEach(P=>{P.boundingBox.containsPoint(b)&&a(m,P.points).forEach(T=>{w.push({identifier:P.identifier,isCW:P.isCW,point:T})})}),w.sort((P,S)=>P.point.x-S.point.x),w}function l(m,y,g,b,w){(w==null||w==="")&&(w="nonzero");let P=new Pn;m.boundingBox.getCenter(P);let S=[new Pn(g,P.y),new Pn(b,P.y)],T=s(S,m.boundingBox,y);T.sort((D,_)=>D.point.x-_.point.x);let A=[],x=[];T.forEach(D=>{D.identifier===m.identifier?A.push(D):x.push(D)});let N=A[0].point.x,E=[],M=0;for(;M<x.length&&x[M].point.x<N;)E.length>0&&E[E.length-1]===x[M].identifier?E.pop():E.push(x[M].identifier),M++;if(E.push(m.identifier),w==="evenodd"){let D=E.length%2===0,_=E[E.length-2];return{identifier:m.identifier,isHole:D,for:_}}else if(w==="nonzero"){let D=!0,_=null,R=null;for(let V=0;V<E.length;V++){let U=E[V];y[U]&&(D?(R=y[U].isCW,D=!1,_=U):R!==y[U].isCW&&(R=y[U].isCW,D=!0))}return{identifier:m.identifier,isHole:D,for:_}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let c=0,u=999999999,d=-999999999,p=[];this.subPaths.forEach(m=>{let y=m.getPoints(),g=-999999999,b=999999999,w=-999999999,P=999999999;for(let S=0;S<y.length;S++){let T=y[S];T.y>g&&(g=T.y),T.y<b&&(b=T.y),T.x>w&&(w=T.x),T.x<P&&(P=T.x)}d<=w&&(d=w+1),u>=P&&(u=P-1),y.length&&p.push({curves:m.curves,points:y,isCW:WN.isClockWise(y),identifier:c++,boundingBox:new kN(new Pn(P,b),new Pn(w,g))})});let f=p.map(m=>l(m,p,u,d,this.userData?.style.fillRule)),h=[];return p.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let g=new HN;g.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let P=p[w.identifier],S=new Pv;S.curves=P.curves,g.holes.push(S)}}),h.push(g)}}),h}};var gh=!1,Tv,xh=new Promise(i=>{Tv=i}),Ov=!1;var id;function Cv(){if(gh=!0,Ov)return;if(id)return id;async function i(){let e=await import("./opentype.js");Tv(e),Ov=!0}return id=i(),id}var Ml=class{async load(t,e,r=()=>{}){let{load:o}=await xh;o(t,(n,a)=>{n||!a?r(n??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await xh;try{let o=e(t),n=new r,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 $N(i){return await(await fetch(i)).arrayBuffer()}var XN=new Ml;async function bh(i){let t,e,r=!1;if(i.url?(t=await $N(i.url),e=i.url,r=i.url.startsWith("/")):i.data&&(t=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),t)if(gh){let o=await XN.parse(t);if(o)return{font:o.font,url:e,intercepted:r,arr:t,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:r,arr:t,bidi:null}}import{CubicBezierCurve as YN,LineCurve as KN,QuadraticBezierCurve as QN}from"three";function ZN(i,t){return t.state.glyphIndex===i||t.state.fina===i||t.state.medi===i||t.state.init===i}var nd=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=bh(t).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(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=bh(t).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(t,e,r){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let n=o.tokenizer.tokens,a=[],s=0,l=r.length===n.length;for(let c=0;c<r.length;c++){let u=r[c].index,d=String.fromCharCode(r[c].unicode),p=n[s];if(ZN(u,p)||l)a.push({char:d,index:u,replacements:[p.state.glyphIndex],replacementChars:[p.char]}),s++;else{let f=p.char,h="",m=[p.state.glyphIndex],y=[],g=!1;for(;!g;)s++,h=e.charAt(s),f+=h,m.push(t.charToGlyphIndex(h)),y=t.stringToGlyphs(f),y.length===1&&y[0].index===u&&(g=!0),s>e.length&&(g=!0);a.push({char:d,index:u,replacements:m,replacementChars:Array.from(f)}),s++}}return a}generateShapes(t,e,r){if(!this._isLoaded)return;let o=this.font,n=e.fontSize/this.unitsPerEm,a=e.fontSize*e.lineHeight,s=t.map(b=>this.getTextWidth(b,e)),l=typeof e.width=="string"?Number(r.getVariable(e.width)):e.width,c=typeof e.height=="string"?Number(r.getVariable(e.height)):e.height,u=this.getCharWidth(`
|
|
2286
2286
|
`,e),d=e.horizontalAlign===1?u:0,p=this.getLineInitialOffsetX(s[0],l,e.horizontalAlign,t[0],u),f=this.getLineInitialOffsetY(a,t.length,c,n,e.verticalAlign),h=[],m=t.map(b=>[]),y=t.map(b=>[]);for(let b=0;b<t.length;b++){let w=t[b],P={features:{liga:!0},letterSpacing:e.letterSpacing},S=[];try{S=o.stringToGlyphs(w,P)}catch(E){console.warn(E)}p=this.getLineInitialOffsetX(s[b],l,e.horizontalAlign,w,u);let T=[];try{T=this.reverseLigaturesTable(o,w,S)}catch(E){console.warn(E)}let A=this.computeSpaceWidthForLine(t,b,e,r),x=0,N=S[0];N&&e.horizontalAlign===2&&N.leftSideBearing!==void 0&&(p-=N.leftSideBearing*n),this.font?.forEachGlyph(w,p,f,e.fontSize,P,(E,M,D,_,R)=>{let V=E.index===0?`
|
|
2287
2287
|
`:E.unicode?String.fromCharCode(E.unicode):void 0,U=T[x],B=0;if(V===`
|
|
2288
2288
|
`)B=d;else if(V===" ")B=A;else{let q=this.createPath(E,n,M,D,e);q&&(B=q.offsetX,h.push(q.path))}if(U.replacements.length===1)y[b].push([M,D]),m[b].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=M;for(let W=0;W<F.length;W++){let ee=B*F[W];y[b].push([H,D]),m[b].push(ee),H+=ee}}x++}),f-=a}let g=[];for(let b=0,w=h.length;b<w;b++)g.push(...h[b].toShapes());return{shapes:g,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(t,e,r,o,n){return(r===3||r===2)&&o.indexOf(`
|
|
@@ -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 Hi},viewport:{type:"v2",value:new Hi},basisViewport:{type:"v2",value:new Hi},debugColor:{type:"v3",value:new KR},covariancesTextureSize:{type:"v2",value:new Hi(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Hi(1024,1024)},orthoZoom:{type:"f",value:-1}};return new sL({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:iL,depthTest:!0,depthWrite:!1,side:ZR})}static buildGeomtery(e){let r=new YR;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new XR(o,3);r.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 rL().copy(r),s=new Uint32Array(e),l=new tL(s,1,!1);return l.setUsage(JR),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,r=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(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Hi(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Hi(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]=QR.toHalfFloat(this.covariances[h]);s=new Wd(l,n.x,n.y,RS,eL)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Wd(l,n.x,n.y,RS,_S);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,g=h*4;c[g]=DS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=Hd(this.centers[y]),c[g+2]=Hd(this.centers[y+1]),c[g+3]=Hd(this.centers[y+2])}let u=new Wd(c,a.x,a.y,aL,lL);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let d=256*4,p=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)p.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Wd(p,d,1,nL,_S);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:p,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(qd.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(qd),this.material.uniforms.basisViewport.value.set(2/qd.x,2/qd.y),this.material.uniforms.focal.value.set(r,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 BS,mm=new Promise(i=>{BS=i}),LS=!1;var Xd;function ym(){if(LS)return;if(Xd)return Xd;async function i(){let e=await import("./gaussian-splat-compression.js");BS(e),LS=!0}return Xd=i(),Xd}var GS;mm.then(i=>GS=i);var ql=class{constructor(t={}){Qi(this,"updateView",function(){let t=new VS,e=[],r=new _s(0,0,-1),o=new _s(0,0,-1),n=new _s,a=new _s;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let p=!1,f=!1;if(o.dot(r)<=.95&&(p=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!p&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let d={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}());this.scene=t.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 VS().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new cL;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new _s().fromArray(t.position)),t.orientation&&(t.orientation=new zS().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.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 r=e.map(a=>new GS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of r)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,n)=>{this.cropsArray[r][n]===void 0?(t=!0,this.cropsArray[r][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[r][n][a][c])?(t=!0,this.cropsArray[r][n][a]=s):s!==this.cropsArray[r][n]?.[a]&&(t=!0,this.cropsArray[r][n][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new _s,o=new zS,n=!1,a=1,s,l){this.splatMesh=Wi.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,d)=>this.update(c,d)}setupSortWorker(t){this.sortWorker=NS(t),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(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var yL=new hL;yL.wireframe=!0;var FS=new dL,Yd=class extends uL{constructor(e,r){super();this.data=e;this.sharedAssets=r;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 kd;this.invisibleObjects=new Bi("jflkdsafjasdifjaslk",{...ou.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Nr("fdasfa",{...Lo.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=IS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=MS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Nr&&(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 r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>tc(o.sortKey,n.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)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===yi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof Nr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Nr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Nn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Nr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.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(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(e){this.toExpandCloner.forEach(r=>{r.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(r=>{r.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){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,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),Li(n)&&Ll(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 ji&&(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),Ll(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Li(o)&&(o.freeBooleanPointer(),n instanceof lr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof As&&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()),Li(o)&&(o.invalidateUpstreamBooleanData(),Ll(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof lr&&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 r of this.children)r instanceof Nr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{gS(a,r,o,{scene:this,shared:n}),a instanceof tt&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Nn||l instanceof Nr)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,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,r){let o=Object.entries(r.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:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof Zo&&n.updateUp()}),this.doPendingExpandCloner({scene:this,shared:r}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){_e.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{_e.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=ui(u.data,d=>{let p=d.events.data(l.id),f=u.goUp(s);if(f){let h=[...ec(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=Je.zoom(p,r);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof ti&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=ui(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of su.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,r,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,r,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,r,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,r,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,r,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,r,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,r,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,r,o,n)})}),!0})}expandInstances(e,r,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof ti&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Rd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof ti&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)_e.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(_e.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!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 d=s.matrixWorld.clone().invert();u.point.applyMatrix4(d),o.push(u)}}else(Li(s)||Bl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),kl(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;_e.is(a)&&(a.visible||s?.object.data.visible)&&((Li(a)||Bl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),kl(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)_e.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)_e.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)_e.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof tt&&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,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();Ll(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)jo.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)_e.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=zd(e,r,l);return c instanceof ji&&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(r,l),c instanceof tt&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let d=u.dataPatched;if(u instanceof tt&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new pL().fromArray(m)),h=new mL(p,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];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;r.push(...u.vertices)}let o=new fL;return o.setFromPoints(r),o.getCenter(FS),FS}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Et)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof ar&&e(r.material[o]);else r.material instanceof ar&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof Zo&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new ql({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as gL}from"three/examples/jsm/loaders/DRACOLoader.js";var qi;function jS(i){return qi||(qi=new gL,qi.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),qi.decoderPending}async function xL(i){if(qi){let t={attributeIDs:qi.defaultAttributeIDs,attributeTypes:qi.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await qi.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function US(i,t){let[e,r]=bp(Hc.deserialize(new Uint8Array(i)));return du(e),t&&t(e),r.result().data}function kS(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function HS(i){for(let t of i){let e=await xL(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.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}}),r.attributes=o,r.draco=void 0}}}import{Mesh as Jme}from"three";import{mergeBufferGeometries as rye}from"three/examples/jsm/utils/BufferGeometryUtils.js";function WS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}import{Color as qS,ShaderLib as bL}from"three";function $S(i){let t=new Set;return i.traverse(e=>{if(e instanceof sr)if(ht(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(vL(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new qS,specularColor:new qS});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},bL.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=dv(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else SL(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function vL(i){return i.getLayersOfType("transmission").length>0}function SL(i){let t=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&&(t+=(1-t)*o.value)}}return t<1}function XS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function YS(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let a=r;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))}}t.push(r.name)}),i}import{mergeBufferGeometries as wL}from"three/examples/jsm/utils/BufferGeometryUtils.js";function KS(i){let t=[];return i.traverse(e=>{e instanceof Ri&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&WS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Et&&a.unshift(r.geometry),a.length){let s=wL(a);r instanceof Et&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:Rv})}),i}function QS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function ZS(i){Object.values(i.shared.materials).forEach(t=>{gm(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?gm(e.material):"materials"in e&&e.materials.forEach(r=>{gm(r)})})}function gm(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var rw=Bs(ew(),1);var tw="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",xm=class extends OL{load(t,e,r,o=console.error){let n=new PL(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(tw+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(tw),n.load(t,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)}},r,o)}async parse(t){let e=await US(t,ZS),r=kS(e);e.version&&(0,rw.default)(e.version,"1.12.53")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&jS(),Uv(e)&&Gb(),Zv(e)&&Cv(),L1(e)&&D1(),$d(e)&&ym()].filter(Boolean)),r.length&&await HS(r);let o=!1,n=new On(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new Yd(e.scene,n);$d(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=KS(a),a=$S(a),a=XS(a),a=YS(a),a=QS(a),a}};export{xm 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 Hi},viewport:{type:"v2",value:new Hi},basisViewport:{type:"v2",value:new Hi},debugColor:{type:"v3",value:new KR},covariancesTextureSize:{type:"v2",value:new Hi(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Hi(1024,1024)},orthoZoom:{type:"f",value:-1}};return new sL({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:iL,depthTest:!0,depthWrite:!1,side:ZR})}static buildGeomtery(e){let r=new YR;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new XR(o,3);r.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 rL().copy(r),s=new Uint32Array(e),l=new tL(s,1,!1);return l.setUsage(JR),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,r=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(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Hi(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Hi(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]=QR.toHalfFloat(this.covariances[h]);s=new Wd(l,n.x,n.y,RS,eL)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Wd(l,n.x,n.y,RS,_S);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,g=h*4;c[g]=DS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=Hd(this.centers[y]),c[g+2]=Hd(this.centers[y+1]),c[g+3]=Hd(this.centers[y+2])}let u=new Wd(c,a.x,a.y,aL,lL);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let d=256*4,p=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)p.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Wd(p,d,1,nL,_S);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:p,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(qd.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(qd),this.material.uniforms.basisViewport.value.set(2/qd.x,2/qd.y),this.material.uniforms.focal.value.set(r,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 BS,mm=new Promise(i=>{BS=i}),LS=!1;var Xd;function ym(){if(LS)return;if(Xd)return Xd;async function i(){let e=await import("./gaussian-splat-compression.js");BS(e),LS=!0}return Xd=i(),Xd}var GS;mm.then(i=>GS=i);var ql=class{constructor(t={}){Qi(this,"updateView",function(){let t=new VS,e=[],r=new _s(0,0,-1),o=new _s(0,0,-1),n=new _s,a=new _s;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let p=!1,f=!1;if(o.dot(r)<=.95&&(p=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!p&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let d={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}());this.scene=t.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 VS().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new cL;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new _s().fromArray(t.position)),t.orientation&&(t.orientation=new zS().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.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 r=e.map(a=>new GS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of r)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,n)=>{this.cropsArray[r][n]===void 0?(t=!0,this.cropsArray[r][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[r][n][a][c])?(t=!0,this.cropsArray[r][n][a]=s):s!==this.cropsArray[r][n]?.[a]&&(t=!0,this.cropsArray[r][n][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new _s,o=new zS,n=!1,a=1,s,l){this.splatMesh=Wi.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,d)=>this.update(c,d)}setupSortWorker(t){this.sortWorker=NS(t),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(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var yL=new hL;yL.wireframe=!0;var FS=new dL,Yd=class extends uL{constructor(e,r){super();this.data=e;this.sharedAssets=r;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 kd;this.invisibleObjects=new Bi("jflkdsafjasdifjaslk",{...ou.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Nr("fdasfa",{...Lo.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=IS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=MS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Nr&&(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 r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>tc(o.sortKey,n.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)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===yi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof Nr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Nr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Nn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Nr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.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(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(e){this.toExpandCloner.forEach(r=>{r.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(r=>{r.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){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,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),Li(n)&&Ll(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 ji&&(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),Ll(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Li(o)&&(o.freeBooleanPointer(),n instanceof lr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof As&&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()),Li(o)&&(o.invalidateUpstreamBooleanData(),Ll(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof lr&&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 r of this.children)r instanceof Nr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{gS(a,r,o,{scene:this,shared:n}),a instanceof tt&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Nn||l instanceof Nr)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,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,r){let o=Object.entries(r.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:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof Zo&&n.updateUp()}),this.doPendingExpandCloner({scene:this,shared:r}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){_e.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{_e.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=ui(u.data,d=>{let p=d.events.data(l.id),f=u.goUp(s);if(f){let h=[...ec(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=Je.zoom(p,r);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof ti&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=ui(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of su.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,r,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,r,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,r,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,r,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,r,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,r,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,r,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,r,o,n)})}),!0})}expandInstances(e,r,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof ti&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Rd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof ti&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)_e.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(_e.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!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 d=s.matrixWorld.clone().invert();u.point.applyMatrix4(d),o.push(u)}}else(Li(s)||Bl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),kl(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;_e.is(a)&&(a.visible||s?.object.data.visible)&&((Li(a)||Bl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),kl(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)_e.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)_e.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)_e.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof tt&&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,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();Ll(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)jo.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)_e.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=zd(e,r,l);return c instanceof ji&&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(r,l),c instanceof tt&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let d=u.dataPatched;if(u instanceof tt&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new pL().fromArray(m)),h=new mL(p,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];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;r.push(...u.vertices)}let o=new fL;return o.setFromPoints(r),o.getCenter(FS),FS}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Et)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof ar&&e(r.material[o]);else r.material instanceof ar&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof Zo&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new ql({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as gL}from"three/examples/jsm/loaders/DRACOLoader.js";var qi;function jS(i){return qi||(qi=new gL,qi.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),qi.decoderPending}async function xL(i){if(qi){let t={attributeIDs:qi.defaultAttributeIDs,attributeTypes:qi.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await qi.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function US(i,t){let[e,r]=bp(Hc.deserialize(new Uint8Array(i)));return du(e),t&&t(e),r.result().data}function kS(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function HS(i){for(let t of i){let e=await xL(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.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}}),r.attributes=o,r.draco=void 0}}}import{Mesh as Jme}from"three";import{mergeBufferGeometries as rye}from"three/examples/jsm/utils/BufferGeometryUtils.js";function WS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}import{Color as qS,ShaderLib as bL}from"three";function $S(i){let t=new Set;return i.traverse(e=>{if(e instanceof sr)if(ht(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(vL(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new qS,specularColor:new qS});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},bL.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=dv(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else SL(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function vL(i){return i.getLayersOfType("transmission").length>0}function SL(i){let t=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&&(t+=(1-t)*o.value)}}return t<1}function XS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function YS(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let a=r;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))}}t.push(r.name)}),i}import{mergeBufferGeometries as wL}from"three/examples/jsm/utils/BufferGeometryUtils.js";function KS(i){let t=[];return i.traverse(e=>{e instanceof Ri&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&WS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Et&&a.unshift(r.geometry),a.length){let s=wL(a);r instanceof Et&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:Rv})}),i}function QS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function ZS(i){Object.values(i.shared.materials).forEach(t=>{gm(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?gm(e.material):"materials"in e&&e.materials.forEach(r=>{gm(r)})})}function gm(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var rw=Bs(ew(),1);var tw="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",xm=class extends OL{load(t,e,r,o=console.error){let n=new PL(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(tw+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(tw),n.load(t,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)}},r,o)}async parse(t){let e=await US(t,ZS),r=kS(e);e.version&&(0,rw.default)(e.version,"1.12.54")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&jS(),Uv(e)&&Gb(),Zv(e)&&Cv(),L1(e)&&D1(),$d(e)&&ym()].filter(Boolean)),r.length&&await HS(r);let o=!1,n=new On(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new Yd(e.scene,n);$d(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=KS(a),a=$S(a),a=XS(a),a=YS(a),a=QS(a),a}};export{xm as default};
|