@splinetool/loader 0.9.524 → 0.9.526

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.
@@ -14,7 +14,7 @@
14
14
  ----------`);var u=new Function("compile",t.join(`
15
15
  `));return u(T2.bind(void 0,n))}kx.exports=C2});var Ux=ar((EQ,jx)=>{"use strict";var P2=Fx();function O2(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function M2(n){var t=new O2;t.pre=n.pre,t.body=n.body,t.post=n.post;var e=n.args.slice(0);t.argTypes=e;for(var r=0;r<e.length;++r){var o=e[r];if(o==="array"||typeof o=="object"&&o.blockIndices){if(t.argTypes[r]="array",t.arrayArgs.push(r),t.arrayBlockIndices.push(o.blockIndices?o.blockIndices:0),t.shimArgs.push("array"+r),r<t.pre.args.length&&t.pre.args[r].count>0)throw new Error("cwise: pre() block may not reference array args");if(r<t.post.args.length&&t.post.args[r].count>0)throw new Error("cwise: post() block may not reference array args")}else if(o==="scalar")t.scalarArgs.push(r),t.shimArgs.push("scalar"+r);else if(o==="index"){if(t.indexArgs.push(r),r<t.pre.args.length&&t.pre.args[r].count>0)throw new Error("cwise: pre() block may not reference array index");if(r<t.body.args.length&&t.body.args[r].lvalue)throw new Error("cwise: body() block may not write to array index");if(r<t.post.args.length&&t.post.args[r].count>0)throw new Error("cwise: post() block may not reference array index")}else if(o==="shape"){if(t.shapeArgs.push(r),r<t.pre.args.length&&t.pre.args[r].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(r<t.body.args.length&&t.body.args[r].lvalue)throw new Error("cwise: body() block may not write to array shape");if(r<t.post.args.length&&t.post.args[r].lvalue)throw new Error("cwise: post() block may not write to array shape")}else if(typeof o=="object"&&o.offset)t.argTypes[r]="offset",t.offsetArgs.push({array:o.array,offset:o.offset}),t.offsetArgIndex.push(r);else throw new Error("cwise: Unknown argument type "+e[r])}if(t.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(t.pre.args.length>e.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>e.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>e.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!n.printCode||!!n.debug,t.funcName=n.funcName||"cwise",t.blockSize=n.blockSize||64,P2(t)}jx.exports=M2});var fs=ar(Me=>{"use strict";var xr=Ux(),Iu={body:"",args:[],thisVars:[],localVars:[]};function Hp(n){if(!n)return Iu;for(var t=0;t<n.args.length;++t){var e=n.args[t];t===0?n.args[t]={name:e,lvalue:!0,rvalue:!!n.rvalue,count:n.count||1}:n.args[t]={name:e,lvalue:!1,rvalue:!0,count:1}}return n.thisVars||(n.thisVars=[]),n.localVars||(n.localVars=[]),n}function I2(n){return xr({args:n.args,pre:Hp(n.pre),body:Hp(n.body),post:Hp(n.proc),funcName:n.funcName})}function ct(n){for(var t=[],e=0;e<n.args.length;++e)t.push("a"+e);var r=new Function("P",["return function ",n.funcName,"_ndarrayops(",t.join(","),") {P(",t.join(","),");return a0}"].join(""));return r(I2(n))}var Hx={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var n in Hx){var t=Hx[n];Me[n]=ct({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:n}),Me[n+"eq"]=ct({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:n+"eq"}),Me[n+"s"]=ct({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:n+"s"}),Me[n+"seq"]=ct({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:n+"seq"})}})();var qx={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var n in qx){var t=qx[n];Me[n]=ct({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:n}),Me[n+"eq"]=ct({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:n+"eq"})}})();var Wx={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var n in Wx){var t=Wx[n];Me[n]=ct({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:n}),Me[n+"s"]=ct({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:n+"s"}),Me[n+"eq"]=ct({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:n+"eq"}),Me[n+"seq"]=ct({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:n+"seq"})}})();var $x=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var n=0;n<$x.length;++n){var t=$x[n];Me[t]=ct({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:t}),Me[t+"eq"]=ct({args:["array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"})}})();var Yx=["max","min","atan2","pow"];(function(){for(var n=0;n<Yx.length;++n){var t=Yx[n];Me[t]=ct({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t}),Me[t+"s"]=ct({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t+"s"}),Me[t+"eq"]=ct({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"}),Me[t+"seq"]=ct({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"seq"})}})();var Xx=["atan2","pow"];(function(){for(var n=0;n<Xx.length;++n){var t=Xx[n];Me[t+"op"]=ct({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"op"}),Me[t+"ops"]=ct({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"ops"}),Me[t+"opeq"]=ct({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opeq"}),Me[t+"opseq"]=ct({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opseq"})}})();Me.any=xr({args:["array"],pre:Iu,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"});Me.all=xr({args:["array"],pre:Iu,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"});Me.sum=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"});Me.prod=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"});Me.norm2squared=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"});Me.norm2=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"});Me.norminf=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});Me.norm1=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});Me.sup=xr({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});Me.inf=xr({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});Me.argmin=xr({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});Me.argmax=xr({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});Me.random=ct({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});Me.assign=ct({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});Me.assigns=ct({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});Me.equals=xr({args:["array","array"],pre:Iu,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})});var vv=ar((aee,xv)=>{xv.exports=function(t,e){for(var r=t.split("."),o=e.split("."),i=0;i<3;i++){var a=Number(r[i]),s=Number(o[i]);if(a>s)return 1;if(s>a)return-1;if(!isNaN(a)&&isNaN(s))return 1;if(isNaN(a)&&!isNaN(s))return-1}return 0}});var j2={};Zp(j2,{default:()=>Lu});module.exports=Rv(j2);var Bu=require("three");function ef(n){for(let t of Object.keys(n))n[t]===void 0&&delete n[t];return n}function sr(n,t){return Object.setPrototypeOf(n,t),n}function vl(n){return Array.isArray(n)?n:[n]}function tf(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var Vv=typeof global=="object"&&global&&global.Object===Object&&global,bl=Vv;var Gv=typeof self=="object"&&self&&self.Object===Object&&self,zv=bl||Gv||Function("return this")(),wt=zv;var kv=wt.Symbol,Et=kv;var rf=Object.prototype,Fv=rf.hasOwnProperty,jv=rf.toString,ms=Et?Et.toStringTag:void 0;function Uv(n){var t=Fv.call(n,ms),e=n[ms];try{n[ms]=void 0;var r=!0}catch{}var o=jv.call(n);return r&&(t?n[ms]=e:delete n[ms]),o}var of=Uv;var Hv=Object.prototype,qv=Hv.toString;function Wv(n){return qv.call(n)}var nf=Wv;var $v="[object Null]",Yv="[object Undefined]",af=Et?Et.toStringTag:void 0;function Xv(n){return n==null?n===void 0?Yv:$v:af&&af in Object(n)?of(n):nf(n)}var Sr=Xv;function Kv(n){return n!=null&&typeof n=="object"}var kt=Kv;var Qv="[object Symbol]";function Zv(n){return typeof n=="symbol"||kt(n)&&Sr(n)==Qv}var yi=Zv;function Jv(n,t){for(var e=-1,r=n==null?0:n.length,o=Array(r);++e<r;)o[e]=t(n[e],e,n);return o}var Sl=Jv;var eb=Array.isArray,ut=eb;var tb=1/0,sf=Et?Et.prototype:void 0,lf=sf?sf.toString:void 0;function cf(n){if(typeof n=="string")return n;if(ut(n))return Sl(n,cf)+"";if(yi(n))return lf?lf.call(n):"";var t=n+"";return t=="0"&&1/n==-tb?"-0":t}var uf=cf;function rb(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var wr=rb;function ob(n){return n}var df=ob;var nb="[object AsyncFunction]",ib="[object Function]",ab="[object GeneratorFunction]",sb="[object Proxy]";function lb(n){if(!wr(n))return!1;var t=Sr(n);return t==ib||t==ab||t==nb||t==sb}var wl=lb;var cb=wt["__core-js_shared__"],_l=cb;var pf=function(){var n=/[^.]+$/.exec(_l&&_l.keys&&_l.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function ub(n){return!!pf&&pf in n}var ff=ub;var db=Function.prototype,pb=db.toString;function fb(n){if(n!=null){try{return pb.call(n)}catch{}try{return n+""}catch{}}return""}var No=fb;var hb=/[\\^$.*+?()[\]{}|]/g,mb=/^\[object .+?Constructor\]$/,yb=Function.prototype,gb=Object.prototype,xb=yb.toString,vb=gb.hasOwnProperty,bb=RegExp("^"+xb.call(vb).replace(hb,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Sb(n){if(!wr(n)||ff(n))return!1;var t=wl(n)?bb:mb;return t.test(No(n))}var hf=Sb;function wb(n,t){return n?.[t]}var mf=wb;function _b(n,t){var e=mf(n,t);return hf(e)?e:void 0}var lr=_b;var Ab=lr(wt,"WeakMap"),Al=Ab;var yf=Object.create,Tb=function(){function n(){}return function(t){if(!wr(t))return{};if(yf)return yf(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),gf=Tb;function Cb(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var xf=Cb;function Pb(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}var vf=Pb;var Ob=800,Mb=16,Ib=Date.now;function Nb(n){var t=0,e=0;return function(){var r=Ib(),o=Mb-(r-e);if(e=r,o>0){if(++t>=Ob)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var bf=Nb;function Eb(n){return function(){return n}}var Sf=Eb;var Db=function(){try{var n=lr(Object,"defineProperty");return n({},"",{}),n}catch{}}(),gi=Db;var Lb=gi?function(n,t){return gi(n,"toString",{configurable:!0,enumerable:!1,value:Sf(t),writable:!0})}:df,wf=Lb;var Bb=bf(wf),_f=Bb;function Rb(n,t){for(var e=-1,r=n==null?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}var Af=Rb;var Vb=9007199254740991,Gb=/^(?:0|[1-9]\d*)$/;function zb(n,t){var e=typeof n;return t=t??Vb,!!t&&(e=="number"||e!="symbol"&&Gb.test(n))&&n>-1&&n%1==0&&n<t}var xi=zb;function kb(n,t,e){t=="__proto__"&&gi?gi(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}var Tl=kb;function Fb(n,t){return n===t||n!==n&&t!==t}var vi=Fb;var jb=Object.prototype,Ub=jb.hasOwnProperty;function Hb(n,t,e){var r=n[t];(!(Ub.call(n,t)&&vi(r,e))||e===void 0&&!(t in n))&&Tl(n,t,e)}var bi=Hb;function qb(n,t,e,r){var o=!e;e||(e={});for(var i=-1,a=t.length;++i<a;){var s=t[i],l=r?r(e[s],n[s],s,e,n):void 0;l===void 0&&(l=n[s]),o?Tl(e,s,l):bi(e,s,l)}return e}var oo=qb;var Tf=Math.max;function Wb(n,t,e){return t=Tf(t===void 0?n.length-1:t,0),function(){for(var r=arguments,o=-1,i=Tf(r.length-t,0),a=Array(i);++o<i;)a[o]=r[t+o];o=-1;for(var s=Array(t+1);++o<t;)s[o]=r[o];return s[t]=e(a),xf(n,this,s)}}var Cf=Wb;var $b=9007199254740991;function Yb(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=$b}var Si=Yb;function Xb(n){return n!=null&&Si(n.length)&&!wl(n)}var Cl=Xb;var Kb=Object.prototype;function Qb(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||Kb;return n===e}var wi=Qb;function Zb(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var Pf=Zb;var Jb="[object Arguments]";function eS(n){return kt(n)&&Sr(n)==Jb}var Vu=eS;var Of=Object.prototype,tS=Of.hasOwnProperty,rS=Of.propertyIsEnumerable,oS=Vu(function(){return arguments}())?Vu:function(n){return kt(n)&&tS.call(n,"callee")&&!rS.call(n,"callee")},_i=oS;function nS(){return!1}var Mf=nS;var Ef=typeof exports=="object"&&exports&&!exports.nodeType&&exports,If=Ef&&typeof module=="object"&&module&&!module.nodeType&&module,iS=If&&If.exports===Ef,Nf=iS?wt.Buffer:void 0,aS=Nf?Nf.isBuffer:void 0,sS=aS||Mf,Gn=sS;var lS="[object Arguments]",cS="[object Array]",uS="[object Boolean]",dS="[object Date]",pS="[object Error]",fS="[object Function]",hS="[object Map]",mS="[object Number]",yS="[object Object]",gS="[object RegExp]",xS="[object Set]",vS="[object String]",bS="[object WeakMap]",SS="[object ArrayBuffer]",wS="[object DataView]",_S="[object Float32Array]",AS="[object Float64Array]",TS="[object Int8Array]",CS="[object Int16Array]",PS="[object Int32Array]",OS="[object Uint8Array]",MS="[object Uint8ClampedArray]",IS="[object Uint16Array]",NS="[object Uint32Array]",rt={};rt[_S]=rt[AS]=rt[TS]=rt[CS]=rt[PS]=rt[OS]=rt[MS]=rt[IS]=rt[NS]=!0;rt[lS]=rt[cS]=rt[SS]=rt[uS]=rt[wS]=rt[dS]=rt[pS]=rt[fS]=rt[hS]=rt[mS]=rt[yS]=rt[gS]=rt[xS]=rt[vS]=rt[bS]=!1;function ES(n){return kt(n)&&Si(n.length)&&!!rt[Sr(n)]}var Df=ES;function DS(n){return function(t){return n(t)}}var Ai=DS;var Lf=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ys=Lf&&typeof module=="object"&&module&&!module.nodeType&&module,LS=ys&&ys.exports===Lf,Gu=LS&&bl.process,BS=function(){try{var n=ys&&ys.require&&ys.require("util").types;return n||Gu&&Gu.binding&&Gu.binding("util")}catch{}}(),Eo=BS;var Bf=Eo&&Eo.isTypedArray,RS=Bf?Ai(Bf):Df,Pl=RS;var VS=Object.prototype,GS=VS.hasOwnProperty;function zS(n,t){var e=ut(n),r=!e&&_i(n),o=!e&&!r&&Gn(n),i=!e&&!r&&!o&&Pl(n),a=e||r||o||i,s=a?Pf(n.length,String):[],l=s.length;for(var d in n)(t||GS.call(n,d))&&!(a&&(d=="length"||o&&(d=="offset"||d=="parent")||i&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||xi(d,l)))&&s.push(d);return s}var Ol=zS;function kS(n,t){return function(e){return n(t(e))}}var Ml=kS;var FS=Ml(Object.keys,Object),Rf=FS;var jS=Object.prototype,US=jS.hasOwnProperty;function HS(n){if(!wi(n))return Rf(n);var t=[];for(var e in Object(n))US.call(n,e)&&e!="constructor"&&t.push(e);return t}var Vf=HS;function qS(n){return Cl(n)?Ol(n):Vf(n)}var Ti=qS;function WS(n){var t=[];if(n!=null)for(var e in Object(n))t.push(e);return t}var Gf=WS;var $S=Object.prototype,YS=$S.hasOwnProperty;function XS(n){if(!wr(n))return Gf(n);var t=wi(n),e=[];for(var r in n)r=="constructor"&&(t||!YS.call(n,r))||e.push(r);return e}var zf=XS;function KS(n){return Cl(n)?Ol(n,!0):zf(n)}var Ci=KS;var QS=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ZS=/^\w*$/;function JS(n,t){if(ut(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||yi(n)?!0:ZS.test(n)||!QS.test(n)||t!=null&&n in Object(t)}var kf=JS;var e1=lr(Object,"create"),Do=e1;function t1(){this.__data__=Do?Do(null):{},this.size=0}var Ff=t1;function r1(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var jf=r1;var o1="__lodash_hash_undefined__",n1=Object.prototype,i1=n1.hasOwnProperty;function a1(n){var t=this.__data__;if(Do){var e=t[n];return e===o1?void 0:e}return i1.call(t,n)?t[n]:void 0}var Uf=a1;var s1=Object.prototype,l1=s1.hasOwnProperty;function c1(n){var t=this.__data__;return Do?t[n]!==void 0:l1.call(t,n)}var Hf=c1;var u1="__lodash_hash_undefined__";function d1(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Do&&t===void 0?u1:t,this}var qf=d1;function Pi(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Pi.prototype.clear=Ff;Pi.prototype.delete=jf;Pi.prototype.get=Uf;Pi.prototype.has=Hf;Pi.prototype.set=qf;var zu=Pi;function p1(){this.__data__=[],this.size=0}var Wf=p1;function f1(n,t){for(var e=n.length;e--;)if(vi(n[e][0],t))return e;return-1}var Ko=f1;var h1=Array.prototype,m1=h1.splice;function y1(n){var t=this.__data__,e=Ko(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():m1.call(t,e,1),--this.size,!0}var $f=y1;function g1(n){var t=this.__data__,e=Ko(t,n);return e<0?void 0:t[e][1]}var Yf=g1;function x1(n){return Ko(this.__data__,n)>-1}var Xf=x1;function v1(n,t){var e=this.__data__,r=Ko(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var Kf=v1;function Oi(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Oi.prototype.clear=Wf;Oi.prototype.delete=$f;Oi.prototype.get=Yf;Oi.prototype.has=Xf;Oi.prototype.set=Kf;var Qo=Oi;var b1=lr(wt,"Map"),Zo=b1;function S1(){this.size=0,this.__data__={hash:new zu,map:new(Zo||Qo),string:new zu}}var Qf=S1;function w1(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var Zf=w1;function _1(n,t){var e=n.__data__;return Zf(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Jo=_1;function A1(n){var t=Jo(this,n).delete(n);return this.size-=t?1:0,t}var Jf=A1;function T1(n){return Jo(this,n).get(n)}var eh=T1;function C1(n){return Jo(this,n).has(n)}var th=C1;function P1(n,t){var e=Jo(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var rh=P1;function Mi(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Mi.prototype.clear=Qf;Mi.prototype.delete=Jf;Mi.prototype.get=eh;Mi.prototype.has=th;Mi.prototype.set=rh;var zn=Mi;var O1="Expected a function";function ku(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(O1);var e=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=e.cache;if(i.has(o))return i.get(o);var a=n.apply(this,r);return e.cache=i.set(o,a)||i,a};return e.cache=new(ku.Cache||zn),e}ku.Cache=zn;var oh=ku;var M1=500;function I1(n){var t=oh(n,function(r){return e.size===M1&&e.clear(),r}),e=t.cache;return t}var nh=I1;var N1=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,E1=/\\(\\)?/g,D1=nh(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(N1,function(e,r,o,i){t.push(o?i.replace(E1,"$1"):r||e)}),t}),ih=D1;function L1(n){return n==null?"":uf(n)}var ah=L1;function B1(n,t){return ut(n)?n:kf(n,t)?[n]:ih(ah(n))}var Or=B1;var R1=1/0;function V1(n){if(typeof n=="string"||yi(n))return n;var t=n+"";return t=="0"&&1/n==-R1?"-0":t}var en=V1;function G1(n,t){t=Or(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[en(t[e++])];return e&&e==r?n:void 0}var Il=G1;function z1(n,t){for(var e=-1,r=t.length,o=n.length;++e<r;)n[o+e]=t[e];return n}var Ii=z1;var sh=Et?Et.isConcatSpreadable:void 0;function k1(n){return ut(n)||_i(n)||!!(sh&&n&&n[sh])}var lh=k1;function ch(n,t,e,r,o){var i=-1,a=n.length;for(e||(e=lh),o||(o=[]);++i<a;){var s=n[i];t>0&&e(s)?t>1?ch(s,t-1,e,r,o):Ii(o,s):r||(o[o.length]=s)}return o}var uh=ch;function F1(n){var t=n==null?0:n.length;return t?uh(n,1):[]}var dh=F1;function j1(n){return _f(Cf(n,void 0,dh),n+"")}var Nl=j1;var U1=Ml(Object.getPrototypeOf,Object),Ni=U1;var H1="[object Object]",q1=Function.prototype,W1=Object.prototype,ph=q1.toString,$1=W1.hasOwnProperty,Y1=ph.call(Object);function X1(n){if(!kt(n)||Sr(n)!=H1)return!1;var t=Ni(n);if(t===null)return!0;var e=$1.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&ph.call(e)==Y1}var fh=X1;function K1(n,t,e){var r=-1,o=n.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 i=Array(o);++r<o;)i[r]=n[r+t];return i}var hh=K1;function Q1(){this.__data__=new Qo,this.size=0}var mh=Q1;function Z1(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var yh=Z1;function J1(n){return this.__data__.get(n)}var gh=J1;function ew(n){return this.__data__.has(n)}var xh=ew;var tw=200;function rw(n,t){var e=this.__data__;if(e instanceof Qo){var r=e.__data__;if(!Zo||r.length<tw-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new zn(r)}return e.set(n,t),this.size=e.size,this}var vh=rw;function Ei(n){var t=this.__data__=new Qo(n);this.size=t.size}Ei.prototype.clear=mh;Ei.prototype.delete=yh;Ei.prototype.get=gh;Ei.prototype.has=xh;Ei.prototype.set=vh;var Di=Ei;function ow(n,t){return n&&oo(t,Ti(t),n)}var bh=ow;function nw(n,t){return n&&oo(t,Ci(t),n)}var Sh=nw;var Th=typeof exports=="object"&&exports&&!exports.nodeType&&exports,wh=Th&&typeof module=="object"&&module&&!module.nodeType&&module,iw=wh&&wh.exports===Th,_h=iw?wt.Buffer:void 0,Ah=_h?_h.allocUnsafe:void 0;function aw(n,t){if(t)return n.slice();var e=n.length,r=Ah?Ah(e):new n.constructor(e);return n.copy(r),r}var Ch=aw;function sw(n,t){for(var e=-1,r=n==null?0:n.length,o=0,i=[];++e<r;){var a=n[e];t(a,e,n)&&(i[o++]=a)}return i}var Ph=sw;function lw(){return[]}var El=lw;var cw=Object.prototype,uw=cw.propertyIsEnumerable,Oh=Object.getOwnPropertySymbols,dw=Oh?function(n){return n==null?[]:(n=Object(n),Ph(Oh(n),function(t){return uw.call(n,t)}))}:El,Li=dw;function pw(n,t){return oo(n,Li(n),t)}var Mh=pw;var fw=Object.getOwnPropertySymbols,hw=fw?function(n){for(var t=[];n;)Ii(t,Li(n)),n=Ni(n);return t}:El,Dl=hw;function mw(n,t){return oo(n,Dl(n),t)}var Ih=mw;function yw(n,t,e){var r=t(n);return ut(n)?r:Ii(r,e(n))}var Ll=yw;function gw(n){return Ll(n,Ti,Li)}var gs=gw;function xw(n){return Ll(n,Ci,Dl)}var Bl=xw;var vw=lr(wt,"DataView"),Rl=vw;var bw=lr(wt,"Promise"),Vl=bw;var Sw=lr(wt,"Set"),Gl=Sw;var Nh="[object Map]",ww="[object Object]",Eh="[object Promise]",Dh="[object Set]",Lh="[object WeakMap]",Bh="[object DataView]",_w=No(Rl),Aw=No(Zo),Tw=No(Vl),Cw=No(Gl),Pw=No(Al),kn=Sr;(Rl&&kn(new Rl(new ArrayBuffer(1)))!=Bh||Zo&&kn(new Zo)!=Nh||Vl&&kn(Vl.resolve())!=Eh||Gl&&kn(new Gl)!=Dh||Al&&kn(new Al)!=Lh)&&(kn=function(n){var t=Sr(n),e=t==ww?n.constructor:void 0,r=e?No(e):"";if(r)switch(r){case _w:return Bh;case Aw:return Nh;case Tw:return Eh;case Cw:return Dh;case Pw:return Lh}return t});var Lo=kn;var Ow=Object.prototype,Mw=Ow.hasOwnProperty;function Iw(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&Mw.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Rh=Iw;var Nw=wt.Uint8Array,Bi=Nw;function Ew(n){var t=new n.constructor(n.byteLength);return new Bi(t).set(new Bi(n)),t}var Ri=Ew;function Dw(n,t){var e=t?Ri(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Vh=Dw;var Lw=/\w*$/;function Bw(n){var t=new n.constructor(n.source,Lw.exec(n));return t.lastIndex=n.lastIndex,t}var Gh=Bw;var zh=Et?Et.prototype:void 0,kh=zh?zh.valueOf:void 0;function Rw(n){return kh?Object(kh.call(n)):{}}var Fh=Rw;function Vw(n,t){var e=t?Ri(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var jh=Vw;var Gw="[object Boolean]",zw="[object Date]",kw="[object Map]",Fw="[object Number]",jw="[object RegExp]",Uw="[object Set]",Hw="[object String]",qw="[object Symbol]",Ww="[object ArrayBuffer]",$w="[object DataView]",Yw="[object Float32Array]",Xw="[object Float64Array]",Kw="[object Int8Array]",Qw="[object Int16Array]",Zw="[object Int32Array]",Jw="[object Uint8Array]",e_="[object Uint8ClampedArray]",t_="[object Uint16Array]",r_="[object Uint32Array]";function o_(n,t,e){var r=n.constructor;switch(t){case Ww:return Ri(n);case Gw:case zw:return new r(+n);case $w:return Vh(n,e);case Yw:case Xw:case Kw:case Qw:case Zw:case Jw:case e_:case t_:case r_:return jh(n,e);case kw:return new r;case Fw:case Hw:return new r(n);case jw:return Gh(n);case Uw:return new r;case qw:return Fh(n)}}var Uh=o_;function n_(n){return typeof n.constructor=="function"&&!wi(n)?gf(Ni(n)):{}}var Hh=n_;var i_="[object Map]";function a_(n){return kt(n)&&Lo(n)==i_}var qh=a_;var Wh=Eo&&Eo.isMap,s_=Wh?Ai(Wh):qh,$h=s_;var l_="[object Set]";function c_(n){return kt(n)&&Lo(n)==l_}var Yh=c_;var Xh=Eo&&Eo.isSet,u_=Xh?Ai(Xh):Yh,Kh=u_;var d_=1,p_=2,f_=4,Qh="[object Arguments]",h_="[object Array]",m_="[object Boolean]",y_="[object Date]",g_="[object Error]",Zh="[object Function]",x_="[object GeneratorFunction]",v_="[object Map]",b_="[object Number]",Jh="[object Object]",S_="[object RegExp]",w_="[object Set]",__="[object String]",A_="[object Symbol]",T_="[object WeakMap]",C_="[object ArrayBuffer]",P_="[object DataView]",O_="[object Float32Array]",M_="[object Float64Array]",I_="[object Int8Array]",N_="[object Int16Array]",E_="[object Int32Array]",D_="[object Uint8Array]",L_="[object Uint8ClampedArray]",B_="[object Uint16Array]",R_="[object Uint32Array]",Je={};Je[Qh]=Je[h_]=Je[C_]=Je[P_]=Je[m_]=Je[y_]=Je[O_]=Je[M_]=Je[I_]=Je[N_]=Je[E_]=Je[v_]=Je[b_]=Je[Jh]=Je[S_]=Je[w_]=Je[__]=Je[A_]=Je[D_]=Je[L_]=Je[B_]=Je[R_]=!0;Je[g_]=Je[Zh]=Je[T_]=!1;function zl(n,t,e,r,o,i){var a,s=t&d_,l=t&p_,d=t&f_;if(e&&(a=o?e(n,r,o,i):e(n)),a!==void 0)return a;if(!wr(n))return n;var c=ut(n);if(c){if(a=Rh(n),!s)return vf(n,a)}else{var u=Lo(n),p=u==Zh||u==x_;if(Gn(n))return Ch(n,s);if(u==Jh||u==Qh||p&&!o){if(a=l||p?{}:Hh(n),!s)return l?Ih(n,Sh(a,n)):Mh(n,bh(a,n))}else{if(!Je[u])return o?n:{};a=Uh(n,u,s)}}i||(i=new Di);var f=i.get(n);if(f)return f;i.set(n,a),Kh(n)?n.forEach(function(y){a.add(zl(y,t,e,y,n,i))}):$h(n)&&n.forEach(function(y,g){a.set(g,zl(y,t,e,g,n,i))});var h=d?l?Bl:gs:l?Ci:Ti,m=c?void 0:h(n);return Af(m||n,function(y,g){m&&(g=y,y=n[g]),bi(a,g,zl(y,t,e,g,n,i))}),a}var kl=zl;var V_=1,G_=4;function z_(n){return kl(n,V_|G_)}var Bo=z_;var k_="__lodash_hash_undefined__";function F_(n){return this.__data__.set(n,k_),this}var em=F_;function j_(n){return this.__data__.has(n)}var tm=j_;function Fl(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new zn;++t<e;)this.add(n[t])}Fl.prototype.add=Fl.prototype.push=em;Fl.prototype.has=tm;var rm=Fl;function U_(n,t){for(var e=-1,r=n==null?0:n.length;++e<r;)if(t(n[e],e,n))return!0;return!1}var om=U_;function H_(n,t){return n.has(t)}var nm=H_;var q_=1,W_=2;function $_(n,t,e,r,o,i){var a=e&q_,s=n.length,l=t.length;if(s!=l&&!(a&&l>s))return!1;var d=i.get(n),c=i.get(t);if(d&&c)return d==t&&c==n;var u=-1,p=!0,f=e&W_?new rm:void 0;for(i.set(n,t),i.set(t,n);++u<s;){var h=n[u],m=t[u];if(r)var y=a?r(m,h,u,t,n,i):r(h,m,u,n,t,i);if(y!==void 0){if(y)continue;p=!1;break}if(f){if(!om(t,function(g,x){if(!nm(f,x)&&(h===g||o(h,g,e,r,i)))return f.push(x)})){p=!1;break}}else if(!(h===m||o(h,m,e,r,i))){p=!1;break}}return i.delete(n),i.delete(t),p}var jl=$_;function Y_(n){var t=-1,e=Array(n.size);return n.forEach(function(r,o){e[++t]=[o,r]}),e}var im=Y_;function X_(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var am=X_;var K_=1,Q_=2,Z_="[object Boolean]",J_="[object Date]",eA="[object Error]",tA="[object Map]",rA="[object Number]",oA="[object RegExp]",nA="[object Set]",iA="[object String]",aA="[object Symbol]",sA="[object ArrayBuffer]",lA="[object DataView]",sm=Et?Et.prototype:void 0,Fu=sm?sm.valueOf:void 0;function cA(n,t,e,r,o,i,a){switch(e){case lA:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case sA:return!(n.byteLength!=t.byteLength||!i(new Bi(n),new Bi(t)));case Z_:case J_:case rA:return vi(+n,+t);case eA:return n.name==t.name&&n.message==t.message;case oA:case iA:return n==t+"";case tA:var s=im;case nA:var l=r&K_;if(s||(s=am),n.size!=t.size&&!l)return!1;var d=a.get(n);if(d)return d==t;r|=Q_,a.set(n,t);var c=jl(s(n),s(t),r,o,i,a);return a.delete(n),c;case aA:if(Fu)return Fu.call(n)==Fu.call(t)}return!1}var lm=cA;var uA=1,dA=Object.prototype,pA=dA.hasOwnProperty;function fA(n,t,e,r,o,i){var a=e&uA,s=gs(n),l=s.length,d=gs(t),c=d.length;if(l!=c&&!a)return!1;for(var u=l;u--;){var p=s[u];if(!(a?p in t:pA.call(t,p)))return!1}var f=i.get(n),h=i.get(t);if(f&&h)return f==t&&h==n;var m=!0;i.set(n,t),i.set(t,n);for(var y=a;++u<l;){p=s[u];var g=n[p],x=t[p];if(r)var S=a?r(x,g,p,t,n,i):r(g,x,p,n,t,i);if(!(S===void 0?g===x||o(g,x,e,r,i):S)){m=!1;break}y||(y=p=="constructor")}if(m&&!y){var w=n.constructor,b=t.constructor;w!=b&&"constructor"in n&&"constructor"in t&&!(typeof w=="function"&&w instanceof w&&typeof b=="function"&&b instanceof b)&&(m=!1)}return i.delete(n),i.delete(t),m}var cm=fA;var hA=1,um="[object Arguments]",dm="[object Array]",Ul="[object Object]",mA=Object.prototype,pm=mA.hasOwnProperty;function yA(n,t,e,r,o,i){var a=ut(n),s=ut(t),l=a?dm:Lo(n),d=s?dm:Lo(t);l=l==um?Ul:l,d=d==um?Ul:d;var c=l==Ul,u=d==Ul,p=l==d;if(p&&Gn(n)){if(!Gn(t))return!1;a=!0,c=!1}if(p&&!c)return i||(i=new Di),a||Pl(n)?jl(n,t,e,r,o,i):lm(n,t,l,e,r,o,i);if(!(e&hA)){var f=c&&pm.call(n,"__wrapped__"),h=u&&pm.call(t,"__wrapped__");if(f||h){var m=f?n.value():n,y=h?t.value():t;return i||(i=new Di),o(m,y,e,r,i)}}return p?(i||(i=new Di),cm(n,t,e,r,o,i)):!1}var fm=yA;function hm(n,t,e,r,o){return n===t?!0:n==null||t==null||!kt(n)&&!kt(t)?n!==n&&t!==t:fm(n,t,e,r,hm,o)}var mm=hm;function gA(n,t){return n!=null&&t in Object(n)}var ym=gA;function xA(n,t,e){t=Or(t,n);for(var r=-1,o=t.length,i=!1;++r<o;){var a=en(t[r]);if(!(i=n!=null&&e(n,a)))break;n=n[a]}return i||++r!=o?i:(o=n==null?0:n.length,!!o&&Si(o)&&xi(a,o)&&(ut(n)||_i(n)))}var gm=xA;function vA(n,t){return n!=null&&gm(n,t,ym)}var xm=vA;function bA(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var vm=bA;function SA(n,t){return t.length<2?n:Il(n,hh(t,0,-1))}var bm=SA;function wA(n,t){return mm(n,t)}var ju=wA;function _A(n,t){return t=Or(t,n),n=bm(n,t),n==null||delete n[en(vm(t))]}var Sm=_A;function AA(n){return fh(n)?void 0:n}var wm=AA;var TA=1,CA=2,PA=4,OA=Nl(function(n,t){var e={};if(n==null)return e;var r=!1;t=Sl(t,function(i){return i=Or(i,n),r||(r=i.length>1),i}),oo(n,Bl(n),e),r&&(e=kl(e,TA|CA|PA,wm));for(var o=t.length;o--;)Sm(e,t[o]);return e}),Vi=OA;function MA(n,t,e,r){if(!wr(n))return n;t=Or(t,n);for(var o=-1,i=t.length,a=i-1,s=n;s!=null&&++o<i;){var l=en(t[o]),d=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return n;if(o!=a){var c=s[l];d=r?r(c,l,s):void 0,d===void 0&&(d=wr(c)?c:xi(t[o+1])?[]:{})}bi(s,l,d),s=s[l]}return n}var _m=MA;function IA(n,t,e){for(var r=-1,o=t.length,i={};++r<o;){var a=t[r],s=Il(n,a);e(s,a)&&_m(i,Or(a,n),s)}return i}var Am=IA;function NA(n,t){return Am(n,t,function(e,r){return xm(n,r)})}var Tm=NA;var EA=Nl(function(n,t){return n==null?{}:Tm(n,t)}),zr=EA;var me=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let i={...r,[t]:e};return Object.setPrototypeOf(i,me.prototype),i}}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:i,data:a}=t,s={...e,[i]:a};return Object.setPrototypeOf(s,me.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 i={...e};return Object.setPrototypeOf(i,me.prototype),delete i[r],{data:i,actual:t,reverse:{type:1,id:r,data:o}}}}return null}};function xs(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let t=Object.getOwnPropertyNames(n);for(let e of t){let r=n[e];r&&typeof r=="object"&&xs(r)}return Object.freeze(n)}function Cm(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var Gi=class extends Error{};function Hl(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function no(n,t,e){if(n===void 0?t===void 0?(n=0,t=10):n=t-10:t===void 0&&(t=n+10),n>t){let i=n;n=t,t=i}let r=[],o=1/(e+1);for(let i=0;i<e;i++){let a=n+(t-n)*(i+.75+Math.random()*.5)*o;r.push(a)}return r}function zi(n){return n instanceof Uint8Array||n instanceof Uint16Array||n instanceof Uint32Array||n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof Float64Array}function Pm(){return typeof process<"u"}function Om(n,t){for(let e of n)t(e.id,e.data)!==!0&&Om(e.children,t)}function Mm(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)Mm(e,t)}var it=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,it.prototype)}deepFreeze(){let e=0;for(;e<this.length;)xs(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&&Mm(o,r)}}traverse(e){Om(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 i=this.parent(e),a=this.childrenArray(i),s=a.findIndex(c=>c.id===e);if(s<0)throw new Error("not expected");let l=a[s];return a=[...a],a[s]={...l,data:r},this.modifyArrayBy(i,a)}}modifyArrayBy(e,r){let o=e,i=r;for(;o!==null;){let s=i,l=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let d=i.findIndex(c=>c.id===l);if(d<0)throw new Error;i=[...i],i[d]={...i[d],children:s}}Object.setPrototypeOf(i,it.prototype);let a=i;return a.fillCaches(),a}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children: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:i,data:a,children:s}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,d=this.childrenArray(l),c={fi:o,id:i,data:a,children:s};return d=[...d,c],d.sort((p,f)=>p.fi-f.fi),e.localIndex=d.indexOf(c),{data:this.modifyArrayBy(l,d),actual:e,reverse:{type:8,id:i}}}}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 i=this.childrenArray(o),a=i.findIndex(d=>d.id===r);e.localIndex=a,i=[...i];let s=i.splice(a,1)[0];return{data:this.modifyArrayBy(o,i),actual:e,reverse:{type:7,...s,parent:o}}}}moveOp(e){let{parent:r,fi:o,id:i}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:i});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===i)throw new Gi("cyclic tree");f=this.parent(f)}}let a=this.parent(i);if(a===void 0)return null;let s=a,l=this.childrenArray(a),d=l.findIndex(f=>f.id===i);l=[...l];let c=l.splice(d,1)[0],u=this.modifyArrayBy(a,l);a=r,l=u.childrenArray(a);let p=c.fi;return c={...c,fi:o},l=[...l,c],l.sort((f,h)=>f.fi-h.fi),e.localIndex=l.indexOf(c),u=u.modifyArrayBy(a,l),{data:u,actual:e,reverse:{type:9,parent:s,fi:p,id:i}}}previous(e,r){if(r===null){let i=this.childrenArray(e);return i.length===0?null:i[i.length-1].id}let o=null;for(let i of this.childrenArray(e)){if(i.id===r)return o;o=i.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),i=o.findIndex(a=>a.id===e)+1;if(i<o.length)return o[i].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),i=o.findIndex(a=>a.id===e)-1;return i>=0?this.traverseSortPrevious(o[i].id):r}}getAllSorted(e){let r=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&r.push({...o,...i})}r.sort((o,i)=>Cm(o.sortKey,i.sortKey));for(let o of r)delete o.sortKey;return r}getWithSortKey(e){var r=e;let o=[],i=this.get(r),a=i;if(i!==void 0){for(;r;)o.splice(0,0,i.fi),r=this.parent(r),r!==null&&(i=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 i=this.childrenArray(e);if(r===null){if(i.length===0)return no(0,o,o);{let a=i[0].fi;return no(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=i.find(l=>l.fi>a.fi);if(s===void 0){let l=i[i.length-1].fi;return no(l,l+o,o)}else return no(a.fi,s.fi,o)}}};var ki;(t=>{function n(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let o=r.props,i={},a=[...e],s=!1;if(o)for(let l of Object.keys(o)){let d=parseInt(l);if(isNaN(d))throw new Error("wrong index");i[l]=a[d],a[d]=o[l],s=!0}return s?{data:a,actual:r,reverse:{type:0,props:i}}:null}else{let o=r.props,i={},a={...e},s=!1;if(o)for(let l of Object.keys(o)){i[l]=a[l];let d=o[l];d===void 0?delete a[l]:a[l]=d,s=!0}return s?{data:a,actual:r,reverse:{type:0,props:i}}:null}}t.runOp=n})(ki||(ki={}));var ge=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ge.prototype)}deepFreeze(){let e=0;for(;e<this.length;)xs(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 i=this,a=i.findIndex(d=>d.id===e);if(a<0)throw new Error("not expected");let s=i[a];return i=[...i],i[a]={...s,data:r},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,ge.prototype);let r=e;return Pm()||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:i}=e,a=this,s={fi:r,id:o,data:i};return a=[...a,s],a.sort((d,c)=>d.fi-c.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,i=o.findIndex(l=>l.id===r);if(i===-1)return null;e.localIndex=i,o=[...o];let a=o.splice(i,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:r,id:o}=e,i=this;i=[...i];let a=i.findIndex(c=>c.id===o);if(a===-1)return null;let s=i[a].fi,l={...i[a],fi:r};return i[a]=l,i.sort((c,u)=>c.fi-u.fi),e.localIndex=i.indexOf(l),{data:this.modifyArrayBy(i),actual:e,reverse:{type:6,fi:s,id:o}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let 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 no(0,r,r);{let i=o[0].fi;return no(i-r,i,r)}}else{let i=this.get(e);if(i===void 0)throw new Error("illegal args");let a=o.find(s=>s.fi>i.fi);if(a===void 0){let s=o[o.length-1].fi;return no(s,s+r,r)}else return no(i.fi,a.fi,r)}}};function Fi(n){return n&&typeof n=="object"&&n instanceof Ke}var Ke=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,o=0,i={};for(;o<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[o]],r!==void 0&&!Fi(r))return null;o+=1}r=r?Hl(r):new Ke;for(let[l,d]of Object.entries(t.props)){let c=r[l];i[l]=c,d===void 0?delete r[l]:r[l]=d}for(;o>0;){if(Object.keys(r).length===0){let l=e[o-1];l&&(r=Hl(l),delete r[t.path[o-1]])}else{let l=e[o-1];if(l){let d=Hl(l);d[t.path[o-1]]=r,r=d}else{let d=new Ke;d[t.path[o-1]]=r,r=d}}o-=1}let a=Object.setPrototypeOf(r,Ke.prototype),s={...t,props:i};return{data:a,actual:t,reverse:s}}},io;(r=>{function n(o,i){return vs(o,i)??o}r.apply=n;function t(o,i){return Hu(o,i)}r.merge=t;function e(o,i){let a=0,s=i.path,l=o;for(;a<s.length&&l!==void 0;){if(l=gt.zoomOnce(l,s[a]),l===void 0)return i;if(!Fi(l))return;a+=1}if(l===void 0)return i;if(!!Fi(l))if(i.type===0){let d={...i.props};for(let c of Object.keys(l))delete d[c];return{...i,props:d}}else if(i.type===1||i.type===4||i.type===7){let d=Uu([i],l);return d?(console.log(d),d):i}else return i}r.filterOp=e})(io||(io={}));function Uu(n,t){if(t===void 0)return;let e=!1,r=n.map(o=>{let i=o.id,a=vs(o.data,t[i]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=Uu(o.children,t);return s!==void 0?e=!0:s=o.children,{...o,id:i,data:a,children:s}}else return{...o,id:i,data:a}});if(e)return r}function DA(n,t){if(t===void 0)return;let e=!1,r=n.map(o=>{let i=o.id,a=vs(o.data,t[i]);return e=e||a!==void 0,a===void 0&&(a=o.data),{...o,id:i,data:a}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function vs(n,t){if(!Fi(t))return t;if(n instanceof it){let e=Uu(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof ge)return DA(n,t);if(Array.isArray(n)){let e=!1,r=n.map((o,i)=>{let a=vs(o,t[i]);return e=e||a!==void 0,a===void 0&&(a=o),a});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else{if(n instanceof Ke)return Hu(n,t);if(n&&typeof n=="object"){let e={},r=!1;for(let[o,i]of Object.entries(n)){let a=vs(i,t[o]);r=r||a!==void 0,a===void 0&&(a=i),e[o]=a}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function Hu(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!Fi(t))return t;if(!Fi(n))return io.apply(n,t);let e=new Set;for(let o of Object.keys(n))e.add(o);for(let o of Object.keys(t))e.add(o);let r=new Ke;for(let o of e){let i=Hu(n===void 0?void 0:n[o],t===void 0?void 0:t[o]);r[o]=i}return r}function Im(n,t){let e={cur:[],result:[],len:0};return n=bs(n,t,e)??n,[n,e.result]}function ql(n,t){return n===null?null:(n.cur[n.len]=t,n.len+=1,n)}function Wl(n){n&&(n.len-=1)}function LA(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Nm(n,t,e){let r=!1,o=n.map(i=>{let a=i.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=bs(i.data,t,ql(e,a));Wl(e),r=r||l!==void 0,l===void 0&&(l=i.data);let d=Nm(i.children,t,e);return d!==void 0?r=!0:d=i.children,{...i,id:a,data:l,children:d}});if(r)return o}function BA(n,t,e){let r=!1,o=n.map(i=>{let a=i.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=bs(i.data,t,ql(e,a));return Wl(e),r=r||l!==void 0,l===void 0&&(l=i.data),{...i,id:a,data:l}});if(r)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}function bs(n,t,e){if(n instanceof it){let r=Nm(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof ge)return BA(n,t,e);if(Array.isArray(n)){let r=!1,o=n.map((i,a)=>{let s=bs(i,t,ql(e,a));return Wl(e),r=r||s!==void 0,s===void 0&&(s=i),s});return r?(Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o):void 0}else if(n&&typeof n=="object"&&!zi(n)){let r={},o=!1;for(let[i,a]of Object.entries(n))if(i!=="name"){let s=t[i];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,i=s}let l=bs(a,t,ql(e,i));Wl(e),o=o||l!==void 0,l===void 0&&(l=a),r[i]=l}else r[i]=a;return o?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else if(typeof n=="string"){let r=t[n];return r!==void 0&&LA(e),r}else return}}var $l;(t=>{function n(e,r){let o=gt.zoom(r,e.path);if(typeof o=="object"){let i={};for(let a of Object.keys(e.props))i[a]=o[a];return{...e,props:i}}else return{...e,props:{}}}t.replaceProps=n})($l||($l={}));var xt;(s=>{function n(l,d){return{...l,path:l.path.slice(d)}}s.drop=n;function t(l,d){return e(l,d)?.data??l}s.applySimple=t;function e(l,d){let c=d.path;for(var u=[];;){let p;if(l instanceof Ke&&d.type===0&&(p=l.runOp({...d,path:c.slice(u.length)}),p===null&&(p=void 0)),p===void 0&&u.length===c.length&&(l instanceof it||l instanceof ge||l instanceof me?p=l.runOp(d):p=ki.runOp(l,d)),p!==void 0)if(p!==null){let m=p.data;for(let y=u.length-1;y>=0;y--){let g=c[y],x=u[y];if(x instanceof it){if(typeof g=="number")throw new Error("illegal arg");m=x.modifyById(g,m)}else if(x instanceof ge){if(typeof g=="number")throw new Error("illegal arg");m=x.modifyById(g,m)}else if(x instanceof me){if(typeof g=="number")throw new Error("illegal arg");m=x.modifyById(g,m)}else if(x instanceof Ke){let S={...x,[g]:m};m=Object.setPrototypeOf(S,Ke.prototype)}else if(typeof x=="object")if(Array.isArray(x)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let S=m;m=[...x],m[g]=S}else m={...x,[g]:m};else return null}return{data:m,actual:{...p.actual,path:c},reverse:{...p.reverse,path:c}}}else return null;let f=c[u.length],h;if(l instanceof it){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else if(l instanceof ge){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else l!==null&&(h=l[f]);if(h!==void 0)u.push(l),l=h;else return null}}s.apply=e;function r(l,d){for(let c=0;c<l.length&&c<d.length;c++)if(l[c]!==d[c])return!0;return!1}s.pathDisjoint=r;function o(l,d){if(l.length!==d.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==d[c])return!1;return!0}s.pathEq=o;function i(l,d){return r(l.path,d.path)}s.commutative=i;function a(l,d){return l.type===0&&d.type===0&&o(l.path,d.path)?Object.keys(l.props).every(c=>d.props[c]!==void 0):!1}s.subsumed=a})(xt||(xt={}));var Ss;(l=>{function n(){return[]}l.empty=n;function t(d,c){let u=[];for(let p of d){let[f,...h]=p.path;f===c&&u.push({...p,path:h})}return u}l.removePrefix=t;function e(d,c){return d.map(u=>({...u,path:[c,...u.path]}))}l.addPrefix=e;function r(d,c){return[...d,...c]}l.concat=r;function o(d,c){return[...d.filter(p=>!c.some(f=>xt.subsumed(p,f))),...c]}l.compress=o;function i(d,c){return d.every(u=>c.every(p=>xt.commutative(u,p)))}l.commutative=i;function a(d,c){for(let u of c){let p=s(d,u);p!==null&&(d=p.data)}return d}l.applyAll=a;function s(d,c){var u=d;let p=[],f=[];for(let h of c)try{if(h.type===3||h.type===5&&h.path[h.path.length-1]==="variables"){let m,y,g;if(h.type===3?(m=gt.zoom(u,[...h.path,h.id]),g=xt.apply(u,{...h,type:2})):(m=gt.zoom(u,[...h.path,h.id,"value"]),g=xt.apply(u,h)),g!==null){u=g.data;let[x,S]=Im(u,{[h.id]:m});u=x;for(let w=0;w<S.length;w++){let b=S[w],_=b.pop();if(typeof _=="number"){let A=[_];for(let M=w+1;M<S.length;M++){let O=S[M],T=O[O.length-1];if(typeof T=="number"&&gt.equal(b,O.slice(0,O.length-1)))A.push(T),S.splice(M,1);else break}let v=gt.zoom(u,b);y=v.map((M,O)=>A.includes(O)?h.id:M),m=v,_=b.pop()}else{if(_==="alphaOverride"||_==="alpha"){m/=100;let A=m,v=gt.zoom(u,b.slice(0,b.length-2)),M=v.layers.map(O=>O.id===b[b.length-1]?{...O,data:{...O.data,[_]:A}}:O);Object.setPrototypeOf(M,Object.getPrototypeOf(v.layers)),v.layers=M}y=h.id}p.push({type:0,path:b,props:{[_]:m}}),f.push({type:0,path:b,props:{[_]:y}})}f.push(g.reverse),p.push(g.actual)}}else{let m=xt.apply(u,h);m!==null&&(p.push(m.actual),u=m.data,f.push(m.reverse))}}catch(m){if(m instanceof Gi)return null;throw m}return{data:u,actual:p,reverse:f.reverse()}}l.apply=s})(Ss||(Ss={}));var Em=Symbol(),RA=Symbol(),Xl=Symbol(),Fn=class{reportOp(t,e,r=[]){let o=this;if(e===null)return;o._current=e.data;let i=r;for(;!(o instanceof Yl);){let a=o._path,s=o._current;if(a!==""&&i.splice(0,0,a),o=o._parent,o===null)return;o.update(a,s)}o.push(i,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[Xl];r&&r(),delete this._children[t]}}}},Wu=class extends Fn{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,ki.runOp(this._current,t),t.path)}},$u=class extends Fn{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,me.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},Dm={get(n,t){if(t===Xl)return()=>{n._parent=null};if(t===Em)return n._current;if(t===RA)return n;let{_current:e,_children:r}=n;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 i=e[t],a=Kl(n,t,i);return a!==i?(r===void 0&&(r={},n._children=r),r[t]=a,a):i},has(n,t){return t in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,t){let e=n._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},VA={...Dm,set(n,t,e){let r={type:0,props:{[t]:at(e)??e}};return n.deleteChildren(t),n.runOp(r),!0},deleteProperty(n,t){let e={type:0,props:{[t]:void 0}};return n.deleteChildren(t),n.runOp(e),!0}},GA={...Dm,set(n,t,e){return e===void 0?this.deleteProperty(n,t):(n.deleteChildren(t),n.runOp({type:1,id:t,data:e})),!0},deleteProperty(n,t){return n.runOp({type:2,id:t}),!0}},ji=class extends Fn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Xl]=()=>{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 i=e.get(t)?.data,a=Kl(this,t,i);return a!==i?(r===void 0&&(r={},this._children=r),r[t]=a,a):i}add(t,e,r,o,i){this.runOp({type:7,parent:t,fi:e,id:r,data:o,children:i})}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 i=0;i<r.length;i++){let a=r[i];this.add(t,o[i],a.id,a.data,a.children)}}insertBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.add(t,o[i],a.id,a.data,a.children)}}moveAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.move(t,o[i],a)}}moveBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.move(t,o[i],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)}},Ui=class extends Fn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Xl]=()=>{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,i=this._current[r].fi;t(this.data(this._current[r].id),o,i)}}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 i=e.get(t)?.data,a=Kl(this,t,i);return a!==i?(r===void 0&&(r={},this._children=r),r[t]=a,a):i}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 i=e[o];this.add(r[o],i.id,i.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(r[o],i.id,i.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(r[o],i)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(r[o],i)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function qu(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&gt.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push({...t,path:e})}var Yl=class extends Fn{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){qu(this.ts,e,t),qu(this.actual,r,t),qu(this.reverse,o,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Kl(n,t,e){return e instanceof it?new ji(n,t,e):e instanceof ge?new Ui(n,t,e):e instanceof me?new Proxy(new $u(n,t,e),GA):e!==null&&typeof e=="object"?zi(e)?e:new Proxy(new Wu(n,t,e),VA):e}function Yu(n){let t=new Yl(n);return[Kl(t,"",n),t]}function tn(n,t){let[e,r]=Yu(n);return t(e),r.result()}function at(n){return n instanceof ji||n instanceof Ui?n._current:n!==null&&typeof n=="object"?n[Em]:n}var gt;(o=>{function n(i,a){if(a.length===i.length)for(var s=0;s<i.length;){if(i[s]!==a[s])return!1;s+=1}else return!1;return!0}o.equal=n;function t(i,a,s){let l=r(s,i);if(l!==void 0&&typeof l=="object"&&l!==null){let d={...a};return Object.keys(l).forEach(c=>{delete d[c]}),d}else return a}o.removeOverridden=t;function e(i,a){if((i instanceof it||i instanceof ji)&&typeof a=="string")return i.data(a);if((i instanceof ge||i instanceof Ui)&&typeof a=="string")return i.data(a);if(typeof a=="number"&&Array.isArray(i))return i[a];if(typeof a=="string"&&typeof i=="object"&&i!==null)return i[a]}o.zoomOnce=e;function r(i,a,s=0){for(;s<a.length&&i!==void 0;)i=e(i,a[s]),s+=1;return i}o.zoom=r})(gt||(gt={}));function Lm(n,t){let e=[];if(t.length===n.length)for(var r=0;r<n.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}function Yt(n,t){let e=[];if(t.length<=n.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}var Ql=class{},ws=class extends Ql{constructor(e){super();this.id=e}},_s=class extends Ql{constructor(e){super();this.data=e}};var Ku;try{Ku=new TextDecoder}catch{}var re,on,E=0;var jm=[],Qu=jm,Zu=0,cr={},ze,rn,Mr=0,ao=0,_r,Ro,Zt=[],je,Bm={useRecords:!1,mapsAsObjects:!0},As=class{},ed=new As;ed.name="MessagePack 0xC1";var Hi=!1,so=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(re)return $m(()=>(Jl(),this?this.unpack(t,e):so.prototype.unpack.call(Bm,t,e)));on=e>-1?e:t.length,E=0,Zu=0,ao=0,rn=null,Qu=jm,_r=null,re=t;try{je=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw re=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 so){if(cr=this,this.structures)return ze=this.structures,Zl();(!ze||ze.length>0)&&(ze=[])}else cr=Bm,(!ze||ze.length>0)&&(ze=[]);return Zl()}unpackMultiple(t,e){let r,o=0;try{Hi=!0;let i=t.length,a=this?this.unpack(t,i):rc.unpack(t,i);if(e){for(e(a);E<i;)if(o=E,e(Zl())===!1)return}else{for(r=[a];E<i;)o=E,r.push(Zl());return r}}catch(i){throw i.lastPosition=o,i.values=r,i}finally{Hi=!1,Jl()}}_mergeStructures(t,e){t=t||[];for(let r=0,o=t.length;r<o;r++){let i=t[r];i&&(i.isShared=!0,r>=32&&(i.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let o=t[r],i=e[r];i&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[r]=o),t[r]=i)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Zl(){try{if(!cr.trusted&&!Hi){let t=ze.sharedLength||0;t<ze.length&&(ze.length=t)}let n=dt();if(E==on)ze.restoreStructures&&Rm(),ze=null,re=null,Ro&&(Ro=null);else if(E>on){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Hi)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw ze.restoreStructures&&Rm(),Jl(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Rm(){for(let n in ze.restoreStructures)ze[n]=ze.restoreStructures[n];ze.restoreStructures=null}function dt(){let n=re[E++];if(n<160)if(n<128){if(n<64)return n;{let t=ze[n&63]||cr.getStructures&&Um()[n&63];return t?(t.read||(t.read=td(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,cr.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[qm()]=dt();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(dt(),dt());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=dt();return t}else if(n<192){let t=n-160;if(ao>=E)return rn.slice(E-Mr,(E+=t)-Mr);if(ao==0&&on<140){let e=t<16?rd(t):Hm(t);if(e!=null)return e}return Ju(t)}else{let t;switch(n){case 192:return null;case 193:return _r?(t=dt(),t>0?_r[1].slice(_r.position1,_r.position1+=t):_r[0].slice(_r.position0,_r.position0-=t)):ed;case 194:return!1;case 195:return!0;case 196:return Xu(re[E++]);case 197:return t=je.getUint16(E),E+=2,Xu(t);case 198:return t=je.getUint32(E),E+=4,Xu(t);case 199:return jn(re[E++]);case 200:return t=je.getUint16(E),E+=2,jn(t);case 201:return t=je.getUint32(E),E+=4,jn(t);case 202:if(t=je.getFloat32(E),cr.useFloat32>2){let e=tc[(re[E]&127)<<1|re[E+1]>>7];return E+=4,(e*t+(t>0?.5:-.5)>>0)/e}return E+=4,t;case 203:return t=je.getFloat64(E),E+=8,t;case 204:return re[E++];case 205:return t=je.getUint16(E),E+=2,t;case 206:return t=je.getUint32(E),E+=4,t;case 207:return cr.int64AsNumber?(t=je.getUint32(E)*4294967296,t+=je.getUint32(E+4)):t=je.getBigUint64(E),E+=8,t;case 208:return je.getInt8(E++);case 209:return t=je.getInt16(E),E+=2,t;case 210:return t=je.getInt32(E),E+=4,t;case 211:return cr.int64AsNumber?(t=je.getInt32(E)*4294967296,t+=je.getUint32(E+4)):t=je.getBigInt64(E),E+=8,t;case 212:if(t=re[E++],t==114)return Fm(re[E++]&63);{let e=Zt[t];if(e)return e.read?(E++,e.read(dt())):e.noBuffer?(E++,e()):e(re.subarray(E,++E));throw new Error("Unknown extension "+t)}case 213:return t=re[E],t==114?(E++,Fm(re[E++]&63,re[E++])):jn(2);case 214:return jn(4);case 215:return jn(8);case 216:return jn(16);case 217:return t=re[E++],ao>=E?rn.slice(E-Mr,(E+=t)-Mr):kA(t);case 218:return t=je.getUint16(E),E+=2,ao>=E?rn.slice(E-Mr,(E+=t)-Mr):FA(t);case 219:return t=je.getUint32(E),E+=4,ao>=E?rn.slice(E-Mr,(E+=t)-Mr):jA(t);case 220:return t=je.getUint16(E),E+=2,Gm(t);case 221:return t=je.getUint32(E),E+=4,Gm(t);case 222:return t=je.getUint16(E),E+=2,zm(t);case 223:return t=je.getUint32(E),E+=4,zm(t);default:if(n>=224)return n-256;if(n===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+n)}}}var zA=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function td(n,t){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>zA.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(dt);return n.highByte===0&&(n.read=Vm(t,n.read)),o()}let r={};for(let o=0,i=n.length;o<i;o++){let a=n[o];r[a]=dt()}return r}return e.count=0,n.highByte===0?Vm(t,e):e}var Vm=(n,t)=>function(){let e=re[E++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),o=ze[r]||Um()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=td(o,n)),o.read()};function Um(){let n=$m(()=>(re=null,cr.getStructures()));return ze=cr._mergeStructures(n,ze)}var Ju=ec,kA=ec,FA=ec,jA=ec;function ec(n){let t;if(n<16&&(t=rd(n)))return t;if(n>64&&Ku)return Ku.decode(re.subarray(E,E+=n));let e=E+n,r=[];for(t="";E<e;){let o=re[E++];if((o&128)===0)r.push(o);else if((o&224)===192){let i=re[E++]&63;r.push((o&31)<<6|i)}else if((o&240)===224){let i=re[E++]&63,a=re[E++]&63;r.push((o&31)<<12|i<<6|a)}else if((o&248)===240){let i=re[E++]&63,a=re[E++]&63,s=re[E++]&63,l=(o&7)<<18|i<<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+=Dt.apply(String,r),r.length=0)}return r.length>0&&(t+=Dt.apply(String,r)),t}function Gm(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=dt();return t}function zm(n){if(cr.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[qm()]=dt();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(dt(),dt());return t}}var Dt=String.fromCharCode;function Hm(n){let t=E,e=new Array(n);for(let r=0;r<n;r++){let o=re[E++];if((o&128)>0){E=t;return}e[r]=o}return Dt.apply(String,e)}function rd(n){if(n<4)if(n<2){if(n===0)return"";{let t=re[E++];if((t&128)>1){E-=1;return}return Dt(t)}}else{let t=re[E++],e=re[E++];if((t&128)>0||(e&128)>0){E-=2;return}if(n<3)return Dt(t,e);let r=re[E++];if((r&128)>0){E-=3;return}return Dt(t,e,r)}else{let t=re[E++],e=re[E++],r=re[E++],o=re[E++];if((t&128)>0||(e&128)>0||(r&128)>0||(o&128)>0){E-=4;return}if(n<6){if(n===4)return Dt(t,e,r,o);{let i=re[E++];if((i&128)>0){E-=5;return}return Dt(t,e,r,o,i)}}else if(n<8){let i=re[E++],a=re[E++];if((i&128)>0||(a&128)>0){E-=6;return}if(n<7)return Dt(t,e,r,o,i,a);let s=re[E++];if((s&128)>0){E-=7;return}return Dt(t,e,r,o,i,a,s)}else{let i=re[E++],a=re[E++],s=re[E++],l=re[E++];if((i&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){E-=8;return}if(n<10){if(n===8)return Dt(t,e,r,o,i,a,s,l);{let d=re[E++];if((d&128)>0){E-=9;return}return Dt(t,e,r,o,i,a,s,l,d)}}else if(n<12){let d=re[E++],c=re[E++];if((d&128)>0||(c&128)>0){E-=10;return}if(n<11)return Dt(t,e,r,o,i,a,s,l,d,c);let u=re[E++];if((u&128)>0){E-=11;return}return Dt(t,e,r,o,i,a,s,l,d,c,u)}else{let d=re[E++],c=re[E++],u=re[E++],p=re[E++];if((d&128)>0||(c&128)>0||(u&128)>0||(p&128)>0){E-=12;return}if(n<14){if(n===12)return Dt(t,e,r,o,i,a,s,l,d,c,u,p);{let f=re[E++];if((f&128)>0){E-=13;return}return Dt(t,e,r,o,i,a,s,l,d,c,u,p,f)}}else{let f=re[E++],h=re[E++];if((f&128)>0||(h&128)>0){E-=14;return}if(n<15)return Dt(t,e,r,o,i,a,s,l,d,c,u,p,f,h);let m=re[E++];if((m&128)>0){E-=15;return}return Dt(t,e,r,o,i,a,s,l,d,c,u,p,f,h,m)}}}}}function Xu(n){return cr.copyBuffers?Uint8Array.prototype.slice.call(re,E,E+=n):re.subarray(E,E+=n)}function jn(n){let t=re[E++];if(Zt[t])return Zt[t](re.subarray(E,E+=n));throw new Error("Unknown extension type "+t)}var km=new Array(4096);function qm(){let n=re[E++];if(n>=160&&n<192){if(n=n-160,ao>=E)return rn.slice(E-Mr,(E+=n)-Mr);if(!(ao==0&&on<180))return Ju(n)}else return E--,dt();let t=(n<<5^(n>1?je.getUint16(E):n>0?re[E]:0))&4095,e=km[t],r=E,o=E+n-3,i,a=0;if(e&&e.bytes==n){for(;r<o;){if(i=je.getUint32(r),i!=e[a++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(i=re[r++],i!=e[a++]){r=1879048192;break}if(r===o)return E=r,e.string;o-=3,r=E}for(e=[],km[t]=e,e.bytes=n;r<o;)i=je.getUint32(r),e.push(i),r+=4;for(o+=3;r<o;)i=re[r++],e.push(i);let s=n<16?rd(n):Hm(n);return s!=null?e.string=s:e.string=Ju(n)}var Fm=(n,t)=>{var e=dt();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let o=ze[n];return o&&o.isShared&&((ze.restoreStructures||(ze.restoreStructures=[]))[n]=o),ze[n]=e,e.read=td(e,r),e.read()},Wm=typeof self=="object"?self:global;Zt[0]=()=>{};Zt[0].noBuffer=!0;Zt[101]=()=>{let n=dt();return(Wm[n[0]]||Error)(n[1])};Zt[105]=n=>{let t=je.getUint32(E-4);Ro||(Ro=new Map);let e=re[E],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let o={target:r};Ro.set(t,o);let i=dt();return o.used?Object.assign(r,i):(o.target=i,i)};Zt[112]=n=>{let t=je.getUint32(E-4),e=Ro.get(t);return e.used=!0,e.target};Zt[115]=()=>new Set(dt());var od=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");Zt[116]=n=>{let t=n[0],e=od[t];if(!e)throw new Error("Could not find typed array for code "+t);return new Wm[e](Uint8Array.prototype.slice.call(n,1).buffer)};Zt[120]=()=>{let n=dt();return new RegExp(n[0],n[1])};Zt[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=E;E+=t-4,_r=[dt(),dt()],_r.position0=0,_r.position1=0;let r=E;E=e;try{return dt()}finally{E=r}};Zt[255]=n=>n.length==4?new Date((n[0]*16777216+(n[1]<<16)+(n[2]<<8)+n[3])*1e3):n.length==8?new Date(((n[0]<<22)+(n[1]<<14)+(n[2]<<6)+(n[3]>>2))/1e6+((n[3]&3)*4294967296+n[4]*16777216+(n[5]<<16)+(n[6]<<8)+n[7])*1e3):n.length==12?new Date(((n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3])/1e6+((n[4]&128?-281474976710656:0)+n[6]*1099511627776+n[7]*4294967296+n[8]*16777216+(n[9]<<16)+(n[10]<<8)+n[11])*1e3):new Date("invalid");function $m(n){let t=on,e=E,r=Zu,o=Mr,i=ao,a=rn,s=Qu,l=Ro,d=_r,c=new Uint8Array(re.slice(0,on)),u=ze,p=ze.slice(0,ze.length),f=cr,h=Hi,m=n();return on=t,E=e,Zu=r,Mr=o,ao=i,rn=a,Qu=s,Ro=l,_r=d,re=c,Hi=h,ze=u,ze.splice(0,ze.length,...p),cr=f,je=new DataView(re.buffer,re.byteOffset,re.byteLength),m}function Jl(){re=null,Ro=null,ze=null}function Ym(n){n.unpack?Zt[n.type]=n.unpack:Zt[n.type]=n}var tc=new Array(147);for(let n=0;n<256;n++)tc[n]=+("1e"+Math.floor(45.15-n*.30103));var rc=new so({useRecords:!1}),UA=rc.unpack,HA=rc.unpackMultiple,qA=rc.unpack,oc={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},WA=new Float32Array(1),sR=new Uint8Array(WA.buffer,0,4);var nc;try{nc=new TextEncoder}catch{}var ic,id,ac=typeof Buffer<"u",nd=ac?Buffer.allocUnsafeSlow:Uint8Array,Zm=ac?Buffer:Uint8Array,Xm=ac?4294967296:2144337920,j,vt,L=0,lo,co=null,$A=/[\u0080-\uFFFF]/,Ts=Symbol("record-id"),Un=class extends so{constructor(t){super(t),this.offset=0;let e,r,o,i,a,s,l=0,d=Zm.prototype.utf8Write?function(v,M,O){return j.utf8Write(v,M,O)}:nc&&nc.encodeInto?function(v,M){return nc.encodeInto(v,j.subarray(M)).written}:!1,c=this;t||(t={});let u=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),u&&!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 x=[],S=0,w=0;this.pack=this.encode=function(v,M){if(j||(j=new nd(8192),vt=new DataView(j.buffer,0,8192),L=0),lo=j.length-10,lo-L<2048?(j=new nd(j.length),vt=new DataView(j.buffer,0,j.length),lo=j.length-10,L=0):L=L+7&2147483640,r=L,s=c.structuredClone?new Map:null,c.bundleStrings?(co=["",""],j[L++]=214,j[L++]=98,co.position=L-r,L+=4):co=null,o=c.structures,o){o.uninitialized&&(o=c._mergeStructures(c.getStructures()));let O=o.sharedLength||0;if(O>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 T=0;T<O;T++){let C=o[T];if(!C)continue;let P,I=o.transitions;for(let D=0,G=C.length;D<G;D++){let N=C[D];P=I[N],P||(P=I[N]=Object.create(null)),I=P}I[Ts]=T+64}l=O}u||(o.nextId=O+64)}i&&(i=!1),a=o||[];try{if(b(v),co){vt.setUint32(co.position+r,L-co.position-r);let O=co;co=null,b(O[0]),b(O[1])}if(c.offset=L,s&&s.idsToInsert){L+=s.idsToInsert.length*6,L>lo&&A(L),c.offset=L;let O=XA(j.subarray(r,L),s.idsToInsert);return s=null,O}return M&ey?(j.start=r,j.end=L,j):j.subarray(r,L)}finally{if(o){if(w<10&&w++,S>1e4)o.transitions=null,w=0,S=0,x.length>0&&(x=[]);else if(x.length>0&&!u){for(let O=0,T=x.length;O<T;O++)x[O][Ts]=0;x=[]}if(i&&c.saveStructures){let O=o.sharedLength||f;o.length>O&&(o=o.slice(0,O));let T=j.subarray(r,L);return c.saveStructures(o,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(v)):(l=O,T)}}M&rT&&(L=r)}};let b=v=>{L>lo&&(j=A(L));var M=typeof v,O;if(M==="string"){let T=v.length;if(co&&T>=8&&T<4096){let I=$A.test(v);co[I?0:1]+=v,j[L++]=193,b(I?-T:T);return}let C;T<32?C=1:T<256?C=2:T<65536?C=3:C=5;let P=T*3;if(L+P>lo&&(j=A(L+P)),T<64||!d){let I,D,G,N=L+C;for(I=0;I<T;I++)D=v.charCodeAt(I),D<128?j[N++]=D:D<2048?(j[N++]=D>>6|192,j[N++]=D&63|128):(D&64512)===55296&&((G=v.charCodeAt(I+1))&64512)===56320?(D=65536+((D&1023)<<10)+(G&1023),I++,j[N++]=D>>18|240,j[N++]=D>>12&63|128,j[N++]=D>>6&63|128,j[N++]=D&63|128):(j[N++]=D>>12|224,j[N++]=D>>6&63|128,j[N++]=D&63|128);O=N-L-C}else O=d(v,L+C,P);O<32?j[L++]=160|O:O<256?(C<2&&j.copyWithin(L+2,L+1,L+1+O),j[L++]=217,j[L++]=O):O<65536?(C<3&&j.copyWithin(L+3,L+2,L+2+O),j[L++]=218,j[L++]=O>>8,j[L++]=O&255):(C<5&&j.copyWithin(L+5,L+3,L+3+O),j[L++]=219,vt.setUint32(L,O),L+=4),L+=O}else if(M==="number")if(v>>>0===v)v<64?j[L++]=v:v<256?(j[L++]=204,j[L++]=v):v<65536?(j[L++]=205,j[L++]=v>>8,j[L++]=v&255):(j[L++]=206,vt.setUint32(L,v),L+=4);else if(v>>0===v)v>=-32?j[L++]=256+v:v>=-128?(j[L++]=208,j[L++]=v+256):v>=-32768?(j[L++]=209,vt.setInt16(L,v),L+=2):(j[L++]=210,vt.setInt32(L,v),L+=4);else{let T;if((T=this.useFloat32)>0&&v<4294967296&&v>=-2147483648){j[L++]=202,vt.setFloat32(L,v);let C;if(T<4||(C=v*tc[(j[L]&127)<<1|j[L+1]>>7])>>0===C){L+=4;return}else L--}j[L++]=203,vt.setFloat64(L,v),L+=8}else if(M==="object")if(!v)j[L++]=192;else{if(s){let C=s.get(v);if(C){if(!C.id){let P=s.idsToInsert||(s.idsToInsert=[]);C.id=P.push(C)}j[L++]=214,j[L++]=112,vt.setUint32(L,C.id),L+=4;return}else s.set(v,{offset:L-r})}let T=v.constructor;if(T===Object)_(v,!0);else if(T===Array){O=v.length,O<16?j[L++]=144|O:O<65536?(j[L++]=220,j[L++]=O>>8,j[L++]=O&255):(j[L++]=221,vt.setUint32(L,O),L+=4);for(let C=0;C<O;C++)b(v[C])}else if(T===Map){O=v.size,O<16?j[L++]=128|O:O<65536?(j[L++]=222,j[L++]=O>>8,j[L++]=O&255):(j[L++]=223,vt.setUint32(L,O),L+=4);for(let[C,P]of v)b(C),b(P)}else{for(let C=0,P=ic.length;C<P;C++){let I=id[C];if(v instanceof I){let D=ic[C];if(D.write){D.type&&(j[L++]=212,j[L++]=D.type,j[L++]=0),b(D.write.call(this,v));return}let G=j,N=vt,F=L;j=null;let B;try{B=D.pack.call(this,v,R=>(j=G,G=null,L+=R,L>lo&&A(L),{target:j,targetView:vt,position:L-R}),b)}finally{G&&(j=G,vt=N,L=F,lo=j.length-10)}B&&(B.length+L>lo&&A(B.length+L),L=YA(B,j,L,D.type));return}}_(v,!v.hasOwnProperty)}}else if(M==="boolean")j[L++]=v?195:194;else if(M==="bigint"){if(v<BigInt(1)<<BigInt(63)&&v>=-(BigInt(1)<<BigInt(63)))j[L++]=211,vt.setBigInt64(L,v);else if(v<BigInt(1)<<BigInt(64)&&v>0)j[L++]=207,vt.setBigUint64(L,v);else if(this.largeBigIntToFloat)j[L++]=203,vt.setFloat64(L,Number(v));else throw new RangeError(v+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");L+=8}else if(M==="undefined")this.encodeUndefinedAsNil?j[L++]=192:(j[L++]=212,j[L++]=0,j[L++]=0);else if(M==="function")b(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+M)},_=this.useRecords===!1?this.variableMapSize?v=>{let M=Object.keys(v),O=M.length;O<16?j[L++]=128|O:O<65536?(j[L++]=222,j[L++]=O>>8,j[L++]=O&255):(j[L++]=223,vt.setUint32(L,O),L+=4);let T;for(let C=0;C<O;C++)b(T=M[C]),b(v[T])}:(v,M)=>{j[L++]=222;let O=L-r;L+=2;let T=0;for(let C in v)(M||v.hasOwnProperty(C))&&(b(C),b(v[C]),T++);j[O+++r]=T>>8,j[O+r]=T&255}:v=>{let M=Object.keys(v),O,T=a.transitions||(a.transitions=Object.create(null)),C=0;for(let I=0,D=M.length;I<D;I++){let G=M[I];O=T[G],O||(O=T[G]=Object.create(null),C++),T=O}let P=T[Ts];if(P)P>=96&&m?(j[L++]=((P-=96)&31)+96,j[L++]=P>>5):j[L++]=P;else{P=a.nextId,P||(P=64),P<y&&this.shouldShareStructure&&!this.shouldShareStructure(M)?(P=a.nextOwnId,P<g||(P=y),a.nextOwnId=P+1):(P>=g&&(P=y),a.nextId=P+1);let I=M.highByte=P>=96&&m?P-96>>5:-1;T[Ts]=P,a[P-64]=M,P<y?(M.isShared=!0,a.sharedLength=P-63,i=!0,I>=0?(j[L++]=(P&31)+96,j[L++]=I):j[L++]=P):(I>=0?(j[L++]=213,j[L++]=114,j[L++]=(P&31)+96,j[L++]=I):(j[L++]=212,j[L++]=114,j[L++]=P),C&&(S+=w*C),x.length>=h&&(x.shift()[Ts]=0),x.push(T),b(M))}for(let I=0,D=M.length;I<D;I++)b(v[M[I]])},A=v=>{let M;if(v>16777216){if(v-r>Xm)throw new Error("Packed buffer would be larger than maximum buffer size");M=Math.min(Xm,Math.round(Math.max((v-r)*(v>67108864?1.25:2),4194304)/4096)*4096)}else M=(Math.max(v-r<<2,j.length-1)>>12)+1<<12;let O=new nd(M);return vt=new DataView(O.buffer,0,M),j.copy?j.copy(O,0,r,v):O.set(j.slice(r,v)),L-=r,r=0,lo=O.length-10,j=O}}useBuffer(t){j=t,vt=new DataView(j.buffer,j.byteOffset,j.byteLength),L=0}};id=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,As];ic=[{pack(n,t,e){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:i,position:a}=t(6);o[a++]=214,o[a++]=255,i.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:o,targetView:i,position:a}=t(10);o[a++]=215,o[a++]=255,i.setUint32(a,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:o,targetView:i,position:a}=t(3);o[a++]=212,o[a++]=255,o[a++]=255}else{let{target:o,targetView:i,position:a}=t(15);o[a++]=199,o[a++]=12,o[a++]=255,i.setUint32(a,n.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(n,t,e){let r=Array.from(n),{target:o,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(o[i++]=212,o[i++]=115,o[i++]=0),e(r)}},{pack(n,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=101,r[o++]=0),e([n.name,n.message])}},{pack(n,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=120,r[o++]=0),e([n.source,n.flags])}},{pack(n,t){this.structuredClone?Km(n,16,t):Qm(ac?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==Zm&&this.structuredClone?Km(n,od.indexOf(e.name),t):Qm(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function Km(n,t,e,r){let o=n.byteLength;if(o+1<256){var{target:i,position:a}=e(4+o);i[a++]=199,i[a++]=o+1}else if(o+1<65536){var{target:i,position:a}=e(5+o);i[a++]=200,i[a++]=o+1>>8,i[a++]=o+1&255}else{var{target:i,position:a,targetView:s}=e(7+o);i[a++]=201,s.setUint32(a,o+1),a+=4}i[a++]=116,i[a++]=t,i.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),a)}function Qm(n,t){let e=n.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:i}=t(e+5);r[o++]=198,i.setUint32(o,e),o+=4}r.set(n,o)}function YA(n,t,e,r){let o=n.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(n,e),e+=o,e}function XA(n,t){let e,r=t.length*6,o=n.length-r;for(t.sort((i,a)=>i.offset>a.offset?1:-1);e=t.pop();){let i=e.offset,a=e.id;n.copyWithin(i+r,i,o),r-=6;let s=i+r;n[s++]=214,n[s++]=105,n[s++]=a>>24,n[s++]=a>>16&255,n[s++]=a>>8&255,n[s++]=a&255,o=i}return n}function nn(n){if(n.Class){if(!n.pack&&!n.write)throw new Error("Extension has no pack or write function");if(n.pack&&!n.type)throw new Error("Extension has no type (numeric code to identify the extension)");id.unshift(n.Class),ic.unshift(n)}Ym(n)}var Jm=new Un({useRecords:!1}),KA=Jm.pack,QA=Jm.pack;var{NEVER:ZA,ALWAYS:JA,DECIMAL_ROUND:eT,DECIMAL_FIT:tT}=oc,ey=512,rT=1024;var ty=new Un({structuredClone:!0});nn({Class:me.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,me.prototype),n}});nn({Class:ge.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,ge.prototype),n}});nn({Class:it.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,it.prototype),n}});nn({Class:ws.prototype.constructor,type:4,write(n){return n.id},read(n){return new ws(n)}});nn({Class:_s.prototype.constructor,type:5,write(n){return n.data},read(n){return new _s(n)}});nn({Class:Ke.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Ke.prototype),n}});function oT(n){var t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){let r=n[e];t=(t<<5)-t+r,t=t&t}return t}function ad(n){if(zi(n))return n;if(Array.isArray(n))return n.map(ad);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=ad(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var sc;(r=>{function n(o){return ty.pack(o)}r.serialize=n;function t(o){return ty.unpack(o)}r.deserialize=t;function e(o){return oT(n(ad(o))).toString()}r.checksum=e})(sc||(sc={}));var ln="personal camera",cn="a218fcc3-276b-49b9-b485-49037fd14f5f",sy=2960946,Tt=5526619;var ry;(e=>{function n(r,o){return r[0]===o[0]&&r[1]===o[1]}e.isEqual=n;function t(r,o,i){return[r[0]+(o[0]-r[0])*i,r[1]+(o[1]-r[1])*i]}e.lerp=t})(ry||(ry={}));var an;(s=>{function n(l,d){return l[0]===d[0]&&l[1]===d[1]&&l[2]===d[2]}s.isEqual=n;function t(l,d){return[l[0]+d[0],l[1]+d[1],l[2]+d[2]]}s.add=t;function e(l,d){return[l[0]-d[0],l[1]-d[1],l[2]-d[2]]}s.sub=e;function r(l,d){return[l[0]/d[0],l[1]/d[1],l[2]/d[2]]}s.div=r;function o(l,d){return[l[0]*d[0],l[1]*d[1],l[2]*d[2]]}s.mul=o;function i(l,d){return Math.hypot(l[0]-d[0],l[1]-d[1],l[2]-d[2])}s.dist=i;function a(l,d,c){return[l[0]+(d[0]-l[0])*c,l[1]+(d[1]-l[1])*c,l[2]+(d[2]-l[2])*c]}s.lerp=a})(an||(an={}));var oy;(e=>{function n(r,o){return r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]}e.isEqual=n;function t(r,o,i){return[r[0]+(o[0]-r[0])*i,r[1]+(o[1]-r[1])*i,r[2]+(o[2]-r[2])*i,r[3]+(o[3]-r[3])*i]}e.lerp=t})(oy||(oy={}));var sn;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(i,a){for(let s=0;s<16;s++)if(i[s]!==a[s])return!1;return!0}o.isEqual=t;function e(i){return i??o.identity}o.simplify=e;function r(i,a){let s=a.slice(0);for(var l=0,d=a.length;l<d;l+=3){let c=i[3]*a[l]+i[7]*a[l+1]+i[11]*a[l+2]+i[15];s[l]=(i[0]*a[l]+i[4]*a[l+1]+i[8]*a[l+2]+i[12])/c,s[l+1]=(i[1]*a[l]+i[5]*a[l+1]+i[9]*a[l+2]+i[13])/c,s[l+2]=(i[2]*a[l]+i[6]*a[l+1]+i[10]*a[l+2]+i[14])/c}return s}o.applyMatrix4=r})(sn||(sn={}));var Lt;(c=>{function n(u){return typeof u=="object"&&typeof u.r=="number"&&typeof u.g=="number"&&typeof u.b=="number"}c.isRGB=n,c.white={r:1,g:1,b:1},c.red={r:1,g:0,b:0},c.black={r:0,g:0,b:0};function o(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:1}}c.toRgb255a1=o;function i(u){return{r:u.r,g:u.g,b:u.b}}c.clone=i;function a(u){return u=Math.floor(u),{r:(u>>16&255)/255,g:(u>>8&255)/255,b:(u&255)/255}}c.fromHex=a;function s(u){return Math.round(u.r*255)*65536+Math.round(u.g*255)*256+Math.round(u.b*255)}c.toHex=s;function l(u,p){return u.r===p.r&&u.g===p.g&&u.b===p.b}c.equals=l;function d(u,p,f){return{r:u.r+(p.r-u.r)*f,g:u.g+(p.g-u.g)*f,b:u.b+(p.b-u.b)*f}}c.lerp=d})(Lt||(Lt={}));var Jt;(s=>{s.white={...Lt.white,a:1},s.transparent={...Lt.white,a:0};function e(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}s.from0to1=e;function r(l,d){return{...Lt.fromHex(l),a:d}}s.fromHexAndA=r;function o(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}s.toRgb255a1=o;function i(l,d){return Lt.equals(l,d)&&l.a===d.a}s.equals=i;function a(l,d,c){return{r:l.r+(d.r-l.r)*c,g:l.g+(d.g-l.g)*c,b:l.b+(d.b-l.b)*c,a:l.a+(d.a-l.a)*c}}s.lerp=a})(Jt||(Jt={}));var lc;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(lc||(lc={}));var ny;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(ny||(ny={}));var iy;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(iy||(iy={}));var ay;(i=>(i.linear=[0,0,1,1],i.ease=[.25,.1,.25,1],i.easeIn=[.42,0,1,1],i.easeOut=[0,0,.58,1],i.easeInOut=[.42,0,.58,1]))(ay||(ay={}));function sd(n){return typeof n=="string"&&n.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n):!1}var kr;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(kr||(kr={}));var un;(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(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}o.getZoom=r})(un||(un={}));var uo;(e=>{function n(r,o=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*o,0,0]},grid:{count:[2,2,2],size:r.map(i=>i*(1+o)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=n;function t(r,o){let i={...r};if(nT.forEach(a=>{Object.assign(i,{[a]:o[a]??r[a]})}),i.radial={...r.radial},o.radial){let a=r.radial,s=o.radial;iT.forEach(l=>{Object.assign(i.radial,{[l]:s[l]??a[l]})})}if(i.linear={...r.linear},o.linear){let a=r.linear,s=o.linear;aT.forEach(l=>{Object.assign(i.linear,{[l]:s[l]??a[l]})})}if(i.grid={...r.grid},o.grid){let a=r.grid,s=o.grid;sT.forEach(l=>{Object.assign(i.grid,{[l]:s[l]??a[l]})})}if(i.toObject={...r.toObject},o.toObject){let a=r.toObject,s=o.toObject;lT.forEach(l=>{Object.assign(i.toObject,{[l]:s[l]??a[l]})})}if(i.randomnessObject={...r.randomnessObject},o.randomnessObject){let a=r.randomnessObject,s=o.randomnessObject;cT.forEach(l=>{Object.assign(i.randomnessObject,{[l]:s[l]??a[l]})})}return i}e.merge=t})(uo||(uo={}));var cc;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(o,i){let a=[];o.count!==void 0&&a.push({type:0,path:i,props:{count:o.count}});for(let s of t){let l=o[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...i,s],props:l})}return a}r.toOps=e})(cc||(cc={}));var nT=["count"],iT=["radius","start","end","position","scale","rotation"],aT=["position","scale","rotation"],sT=["count","size"],lT=["count","position","scale","rotation"],cT=["strength","scale","rotation","position","movement","seed","freqScale"];var uc;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(uc||(uc={}));var dc;(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:Jt.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Jt.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:Jt.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(dc||(dc={}));var dn;(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]})(dn||(dn={}));var ld;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}e.equals=t})(ld||(ld={}));var cd;(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})(cd||(cd={}));var pc;(t=>t.defaultData={...cd.defaultData,...ld.defaultData})(pc||(pc={}));var ly;(t=>{function n(e,r){let o=[];if("material"in e){let i=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;i&&o.push(i)}else if("materials"in e)for(let i of e.materials){let a=typeof i=="string"?r.materials[i]??r.lib.materials[i]?.asset:i;a&&o.push(a)}return o}t.getMaterialData=n})(ly||(ly={}));var qi;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(qi||(qi={}));var cy;(t=>{function n(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=n})(cy||(cy={}));function dy(n){return n.type!=="displace"}var uy;(t=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=n})(uy||(uy={}));var py=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],fy=["wrapping","image","video","name"],er;(o=>{function n(i,a){let{texture:s,...l}=a;if(Object.assign(i,l),s){let d=i.texture;d&&Object.assign(d,s)}}o.patch=n;function t(i,a){return i==="light"&&a?e(a):r(i)}o.defaultData=t;function e(i){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(i){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(i){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(i){case"texture":return{...a,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:qi.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...a,type:"color",color:Lt.fromHex(Tt)};case"depth":return{...a,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Lt.fromHex(6710886),a:1},colorB:{...Lt.fromHex(6710886),a:1},colorC:{...Lt.fromHex(16777215),a:1},colorD:{...Lt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:Jt.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Jt.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:Jt.fromHexAndA(0,1),contourColor:Jt.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...a,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Lt.fromHex(0),a:1},colorB:{...Lt.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}}}})(er||(er={}));var Ft;(l=>{function n(d){return!d.layers.some(u=>u.data.type==="texture"&&u.data.projection!==0||u.data.type==="depth"&&!u.data.isWorldSpace||u.data.type==="noise"||u.data.type==="displace")}l.isMergable=n;function t(d){let c="";return d.layers.forEach(u=>{Object.entries(u.data).forEach(([p,f])=>{c+=`${p}${f}`,Array.isArray(f)?f.forEach(h=>c+=`${h}`):typeof f=="object"?Object.values(f).forEach(h=>{typeof h=="number"?c+=`${h.toFixed(4)}`:c+=`${h}`}):c+=`${f}`})}),c}l.getHash=t;function e(){return{layers:new ge}}l.defaultEmptyData=e;function r(d="layer1",c="layer2"){return i("phong",d,c)}l.defaultData=r;function o(d,c){return{...d,name:c}}l.withName=o;function i(d,c="layer1",u="layer2"){let p=new ge;return p.push({fi:0,data:er.defaultData("light",d),id:c}),p.push({fi:1,data:er.defaultData("color"),id:u}),{layers:p}}l.defaultTwoLayerData=i;function a(d,c="phong",u="layer1",p="layer2"){let f=er.defaultData("texture");Object.assign(f.texture,{image:d});let h=new ge;return h.push({fi:0,data:f,id:u}),h.push({fi:1,data:er.defaultData("light",c),id:p}),{layers:h}}l.defaultTwoLayerTextureData=a;function s(d,c="phong",u="layer1",p="layer2"){let f=er.defaultData("video");Object.assign(f.texture,{video:d});let h=new ge;return h.push({fi:0,data:f,id:u}),h.push({fi:1,data:er.defaultData("light",c),id:p}),{layers:h}}l.defaultTwoLayerVideoTextureData=s})(Ft||(Ft={}));var Wi;(t=>{function n(){return{points:new ge,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(Wi||(Wi={}));var $i;(t=>{function n(){return{points:new ge,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=n})($i||($i={}));var ud={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var fc;(t=>{function n(e,r){let o={...e};return uT.forEach(i=>{Object.assign(o,{[i]:r[i]??e[i]})}),o}t.merge=n})(fc||(fc={}));var hc={shape:ud,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},uT=["depth","offset","angle","twist","startScale","endScale"];var Cs;(e=>{function n(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"}e.is2DParametricMesh=n;function t(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=t})(Cs||(Cs={}));var mc;(t=>{function n(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,fc.merge(o.extrusion,r.extrusion))),o}t.merge=n})(mc||(mc={}));var pn;(t=>{function n(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:$i.defaultData(),extrusion:hc};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Wi.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}t.defaultData=n})(pn||(pn={}));var yc;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:Lt.white,near:.1,far:2e3})(yc||(yc={}));var gc;(e=>{let n={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...n,blendFunction:16,granularity:15},bloom:{...n,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...n,offset:[2,2]},vignette:{...n,darkness:1,offset:0},hueSaturation:{...n,hue:3,saturation:0},brightnessContrast:{...n,brightness:.25,contrast:0},depthOfField:{...n,focalLength:2,focusDistance:2,bokehScale:2},noise:{...n,blendFunction:16}}})(gc||(gc={}));var dd;(t=>t.defaultData={softShadowQuality:"low"})(dd||(dd={}));var pd;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(pd||(pd={}));var fd;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(fd||(fd={}));var Ps;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Ps||(Ps={}));var hd;(t=>t.defaultData={playCamera:ln,gameControlObject:null})(hd||(hd={}));var xc;(t=>t.defaultData={backgroundColor:Jt.fromHexAndA(sy,1),postprocessing:gc.defaultData,fog:yc.defaultData,globalPhysics:Ps.defaultData,ambient:pd.defaultData,ao:fd.defaultData,shadow:dd.defaultData,publish:hd.defaultData})(xc||(xc={}));var hy;(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(hy||(hy={}));var Yi;(o=>{o.identity={...lc.identity,hiddenMatrix:sn.identity};function t(i){return{position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix}}o.fromObject=t;function e(i,a){return{position:a?.position||i.position,rotation:a?.rotation||i.rotation,scale:a?.scale||i.scale,hiddenMatrix:a?.hiddenMatrix||i.hiddenMatrix}}o.merge=e;function r(i,a){return ef({position:an.isEqual(i.position,a.position)?void 0:a.position,rotation:an.isEqual(i.rotation,a.rotation)?void 0:a.rotation,scale:an.isEqual(i.scale,a.scale)?null:a.scale,hiddenMatrix:sn.isEqual(i.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=r})(Yi||(Yi={}));var jt;(t=>t.defaultData={states:new ge,events:new ge,visible:!0,raycastLock:!1,physics:dn.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Yi.identity,cloner:null})(jt||(jt={}));var vc;(t=>t.defaultData={type:"Empty",...jt.defaultData})(vc||(vc={}));var my;(t=>t.defaultData={type:"Component",...jt.defaultData})(my||(my={}));var Hn;(t=>t.defaultData={type:"Mesh",...jt.defaultData,...pc.defaultData})(Hn||(Hn={}));var qn;(t=>t.defaultData={...jt.defaultData,...Yi.identity,position:[0,0,un.DefaultTargetOffset],...un.defaultData})(qn||(qn={}));var bc;(e=>{function n(r){return{...jt.defaultData,...dc.defaultData(r)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(bc||(bc={}));var Xi;(e=>{function n(r,o,i=0){for(;i<o.length;){let a=r?r[o[i]]:void 0;if(o.length===i+1)return a;if(a)r=a.descendants,i+=1;else return}}e.resolveWithDes=n;function t(r,o,i=0){let a=n(r,o,i);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=t})(Xi||(Xi={}));var po;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function r(a,s){return{...jt.defaultData,...s,component:a,overrides:new Ke,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=r;function o(a){let s=Yi.fromObject(a.data);return r(a.id,s)}i.fromComponentData=o})(po||(po={}));var Vo;(t=>t.defaultData={type:"Page",...jt.defaultData,physics:{...dn.defaultData,fusedBody:!1},...xc.defaultData,camera:qn.defaultData})(Vo||(Vo={}));var Sc;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:sn.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:dn.defaultData,states:new ge,events:new ge,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...un.defaultData},i.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},i.defaultMeshObject={name:"Rectangle",...jt.defaultData,...Hn.defaultData,geometry:pn.defaultData("RectangleGeometry"),material:Ft.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...jt.defaultData,...Hn.defaultData,geometry:pn.defaultData("BooleanGeometry"),material:Ft.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...jt.defaultData,...Hn.defaultData,geometry:pn.defaultData("TextGeometry"),material:Ft.defaultTwoLayerData("phong","layer1","layer2")}))(Sc||(Sc={}));var Wn;(o=>{function n(i,a){let s={name:a};return i.type==="Mesh"?(s.geometry={},"material"in i&&(s.material={layers:new Ke}),"materials"in i&&(s.materials=i.materials.map(l=>({layers:new Ke})))):kr.is(i.type)&&(s.perspective={},s.orthographic={}),s}o.newEmpty=n;function t(i,a){if(a===void 0)return i;let s={...i};return"material"in s&&"material"in a&&a.material&&(s.material=tn(s.material,l=>{if(typeof l!="string")for(let[d,c]of Object.entries(a.material.layers)){let u=l.layers.data(d);u&&er.patch(u,c)}}).data),s.materials&&a.materials&&(s.materials=tn(s.materials,l=>{for(let d=0;d<s.materials.length;d++){let c=a.materials[d];if(typeof c!="string")for(let[u,p]of Object.entries(c.layers)){let f=l[d]?.layers?.data(u);f&&er.patch(f,p)}}}).data),s}function e(i,a){let s,l=[],d={orthographic:0,perspective:0,geometry:0};function c(u,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:[...u,"layers",f,"texture"],props:m,type:0};l.push(g)}if(Object.keys(y).length>0){let g={path:[...u,"layers",f],props:y,type:0};l.push(g)}}}for(let[u,p]of Object.entries(a))if(u!=="name")if(u==="cloner")l.push(...cc.toOps(p,["cloner"]));else if(u==="pathSnapping")l.push({path:[u],props:{slide:p.slide,offset:p.offset},type:0});else if(u==="material")c(["material"],p);else if(u==="materials")for(let[f,h]of Object.entries(p))c(["materials",f],h);else if(d[u]===0){if(u==="geometry"&&p.extrusion!==void 0){let f={path:[u,"extrusion"],props:p.extrusion,type:0};l.push(f),p={...p},delete p.extrusion}if(Object.keys(p).length>0){let f={path:[u],props:p,type:0};l.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[u]=p;return l}o.toOps=e;function r(i,a){if(a===void 0)return i;let s={...i};if(Object.assign(s,Yi.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})}),kr.is(i.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let l=a;l.orthographic?.zoom!==void 0&&(s.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(s.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(s.targetOffset=l.targetOffset)}else if(i.type==="Mesh")"geometry"in a&&Object.assign(s,{geometry:mc.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=t(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:uo.merge(s.cloner,a.cloner)});else if(i.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:uo.merge(s.cloner,a.cloner)});else if(uc.is(i.type)){let l=a;l.intensity!==void 0&&(s.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?s.color=l.color:s.color=Lt.clone(l.color))}return s}o.patch=r})(Wn||(Wn={}));var Qi;(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,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Qi||(Qi={}));var fo;(t=>t.defaultData={orbitControls:Qi.defaultData,playPage:cn,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let o=0,i=0;return r<5?i=-30:r<10&&(i=30),r===0||r===10||r===5?o=30:(r===4||r===11||r===9)&&(o=-30),[120,[o,i],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(fo||(fo={}));var md;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(md||(md={}));var yd;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(yd||(yd={}));var fn;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...md.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:yd.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(fn||(fn={}));var yy;(e=>{function n(r){return r.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=n;function t(r,o,i){r.scene.objects.traverseFrom(o,(a,s)=>{if(s.type==="Instance"){let l=Zi.getComponentData(r,s.component)?.data;l&&i(a,s,l.events)}else i(a,s,s.events)})}e.traverseModuleInstances=t})(yy||(yy={}));var hn;(s=>{s.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(l={withLight:!0,withSquare:!0}){let d=[],c=Sc.defaultMeshObject;l.withLight===!0&&d.push({fi:-1,data:bc.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),l.withSquare===!0&&d.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:c,children:[]});let u=new it;return u.push({fi:1,id:cn,data:{...Vo.defaultData,name:"Scene 1"},children:d}),u}s.defaultData={objects:t(),publish:fo.defaultData,styles:fn.defaultData()},s.emptyDataWithoutPage=function(){return{objects:new it,publish:fo.defaultData,styles:fn.defaultData()}},s.emptyDataWithPage=function(l){return{objects:t(l),publish:fo.defaultData,styles:fn.defaultData()}};function i(l){return{...s.defaultData,objects:sr(l,it.prototype)}}s.withObjs=i;function a(l,d){return i([{id:l,data:d,children:[],fi:0}])}s.withObj=a})(hn||(hn={}));var Ji;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Ji||(Ji={}));var ea;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(ea||(ea={}));var wc;(i=>{function n(a){return a.textValue!==void 0}i.isTextValue=n;function t(a){return typeof a=="number"}i.isNumber=t;function e(a){return typeof a=="boolean"}i.isBoolean=e;function r(a){return n(a)?"string":e(a)?"boolean":"number"}i.typeOfVariable=r;function o(a){return i.isTextValue(a)?Array.isArray(a.textValue)?a.textValue.map(s=>s.toString().padStart(a.padding??2,"0")).join(a.deliminator??":")+(a.suffix!==void 0?" "+a.suffix:""):a.textValue.toString():i.isBoolean(a)?a?"True":"False":i.isNumber(a)?parseFloat(a.toFixed(3)).toString():a.toString()}i.getDisplayedValue=o})(wc||(wc={}));var gd;(t=>t.all=["images","videos","colors","audios","fonts","materials","variables"])(gd||(gd={}));var gy;(t=>t.all=[...gd.all,"components"])(gy||(gy={}));var xy;(t=>{function n(){return{images:new me,videos:new me,colors:new me,audios:new me,fonts:new me,materials:new me,components:new me,variables:new me}}t.defaultData=n})(xy||(xy={}));var mn;(t=>{function n(){return{images:new me,videos:new me,colors:new me,audios:new me,fonts:new me,materials:new me,components:new me,variables:new me}}t.defaultData=n})(mn||(mn={}));var Fr;(i=>{function n(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},sr(a,me.prototype)}i.defaultColors=n;function t(a){let s={};return a?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...ea.emptyImage,name:"AI generated image"}),sr(s,me.prototype)}i.defaultImages=t;function e(){return{catelogs:new me,materials:new me,images:new me,videos:new me,colors:new me,audios:new me,fonts:new me,variables:new ge,lib:mn.defaultData()}}i.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)}}i.defaultVariables=r;function o(a,s){if(s.format==="HH:mm:ss"){let l=Math.floor(a/3600),d=Math.floor((a-l*3600)/60),c=Math.round(a-l*3600-d*60);return{textValue:[l,d,c]}}else if(s.format==="mm:ss"){let l=Math.floor(a/60),d=Math.round(a-l*60);return{textValue:[l,d]}}else return s.format==="number"?a=Math.round(a):a=Math.round(a*1e3)/1e3,a}i.getFormattedTimerTime=o})(Fr||(Fr={}));var Os=require("three");var _c;(t=>t.list=["idle","move","jump","run"])(_c||(_c={}));var Ac;(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 ge,move:new ge,jump:new ge,run:new ge},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Jt.fromHexAndA(3728051,1)}}))(Ac||(Ac={}));function vy(n){n.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]],i=[0,1];for(let s=2;s<10;s++)o.push(o[1]),i.push(1);let a={...zr(at(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:o,steps:i,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={...at(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Go(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function zo(n,t){n.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((o,i)=>{o===void 0&&(r.materials[i]=Ft.defaultData(),o=r.materials[i]),typeof o!="string"&&t(o)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Ft.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Ft.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&t(o.material)})})}function dT(n){Object.assign(n.scene.publish,{orbitControls:{...Qi.defaultData,...at(n.scene.publish.orbitControls)}})}function pT(n){Object.assign(n.scene.publish.settings,{video:{...fo.defaultData.settings.video,...at(n.scene.publish.settings.video)}})}function fT(n){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[o,i]of Object.entries(r))if((py.includes(o)||typeof i=="boolean")&&delete r[o],o==="texture")for(let[a,s]of Object.entries(i))(fy.includes(a)||typeof s=="boolean")&&delete i[a]}}}n.scene.objects.traverse((e,r)=>{r.states.forEach(o=>{let i=o;i.material?t(i.material):i.materials&&i.materials.forEach(a=>{t(a)})})})}function hT(n){n.scene.publish.withBackground=!0}function mT(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function yT(n){n.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 gT(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function xT(n){n.scene.objects.traverse((t,e)=>{let r=n.scene.objects.unproxy().parent(t);if(r){let o=at(n.scene.objects.data(r));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=at(e).booleanExclude!==!0)}})}function vT(n){n.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 bT(n){function t(r){Object.setPrototypeOf(r,Ke.prototype),r.texture&&Object.setPrototypeOf(r.texture,Ke.prototype)}function e(r){Object.setPrototypeOf(r,Ke.prototype);for(let o in r)t(r[o])}n.scene.objects.traverse((r,o)=>{o.states.forEach(i=>{let a=i;if(a.material){let s=at(a.material).layers;e(s),a.material.layers=s}if(a.materials)for(let s=0;s<a.materials.length;s++){let l=a.materials[s],d=at(l).layers;e(d),l.layers=d}})})}function by(n){n.layers===void 0&&Object.assign(n,Ft.defaultTwoLayerData("lambert"))}function xd(n){!n.layers||n.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={...at(t),colors:e,steps:r};Object.assign(t,o)}})}function ST(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function Sy(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&xd(r)}):"material"in e&&typeof e.material!="string"&&xd(e.material)}),Object.values(n.shared.materials).forEach(t=>xd(t))}function wT(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}function _T(n){n.shared.audios=sr({},me.prototype)}function AT(n){n.shared.videos=sr({},me.prototype)}function TT(n){let t=n.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 CT(n){Object.entries(at(n.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.images[r]}),Object.entries(at(n.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.audios[r]})}function PT(n){n.scene.publish.settings.web.preload=!1}function wy(n){n.layers&&n.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 _y(n){n.layers&&n.layers.forEach(t=>{dy(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 OT(n){n.shared.fonts=sr({},me.prototype)}function MT(n){return n.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function IT(n){let t=[];n.scene.objects.traverse((e,r)=>{let o=r;if(o.type==="TextFrame"){let i=Ft.defaultTwoLayerData("phong"),a=typeof o.color=="string"?n.shared.colors[o.color]:o.color;i.layers[1].data.color={r:a.r,g:a.g,b:a.b},i.layers[1].data.alpha=o.alpha;let s=MT(o.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let l={name:o.name,...jt.defaultData,...Hn.defaultData,flatShading:!1,wireframe:!1,geometry:{...pn.defaultData("TextGeometry"),width:o.width,height:o.height,font:s,depth:0,horizontalAlign:o.horizontalAlign,verticalAlign:o.verticalAlign,fontSize:o.fontSize*1.40625,lineHeight:o.lineHeight/1.40625,letterSpacing:o.letterSpacing-1,text:o.text,textTransform:o.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:i,states:at(o.states),events:at(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},d=at(n.scene.objects).parent(e);n.scene.objects.insertAfter(d??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{n.scene.objects.delete(e)})}function NT(n){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};n.scene.objects.traverse((e,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 ge,move:new ge,jump:new ge}});else{let i=new ge;Object.assign(o,{actions:i}),(o.type==="MouseDown"||o.type==="MouseUp"||o.type==="KeyDown"||o.type==="KeyUp")&&"url"in o&&i.push({fi:0,id:Os.MathUtils.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((a,s,l)=>{let d={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(c,zr(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(c,{control1:{...a.control1},control2:{...a.control2}});let u={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,...u,...c},f={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ge({fi:0,id:Os.MathUtils.generateUUID(),data:d},{fi:1,id:Os.MathUtils.generateUUID(),data:p})};i.push({fi:l,id:s,data:f})}),delete o.targets)}})})}function ET(n){n.scene.objects.traverse((t,e)=>{function r(o,i){let a=new ge,s=[];if(e.events.forEach((l,d,c)=>{if(l.type==="Audio"&&l.trigger===i){let u;s.push(d),l.interaction==="play"?u={...zr(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")&&(u={...zr(l,"interaction","delay","object","playAudio"),type:"Audio"}),u&&a.push({fi:c,id:d,data:u})}}),s.forEach(l=>e.events.delete(l)),a.length){let l=e.events.find(d=>d.type===o)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):e.events.insertBefore(null,[{id:Os.MathUtils.generateUUID(),data:{type:o,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function Ay(n){let t=n.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=er.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function Ty(n){Go(n,Ay),zo(n,Ay)}function DT(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function LT(n){n.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 BT(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Ft.defaultTwoLayerData("phong"))})}function RT(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.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 VT(n){n.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 GT(n){n.scene.publish.mouseEventTarget===void 0&&(n.scene.publish.mouseEventTarget="canvas"),n.scene.publish.settings.web.hint===void 0&&(n.scene.publish.settings.web.hint=!1)}function zT(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function kT(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function FT(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function jT(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Ac.defaultDataThirdPerson.navmesh)})})}function UT(n){n.scene.styles||(n.scene.styles=fn.defaultData())}function Cy(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function HT(n){n.scene.environment.ambientLight.occlusion===void 0&&(n.scene.environment.ambientLight.occlusion=!1),n.scene.environment.ambientLight.aoFullRes===void 0&&(n.scene.environment.ambientLight.aoFullRes=!1),n.scene.environment.ambientLight.radius===void 0&&(n.scene.environment.ambientLight.radius=256),n.scene.environment.ambientLight.bias===void 0&&(n.scene.environment.ambientLight.bias=.5),n.scene.environment.ambientLight.aoColor===void 0&&(n.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),zo(n,Cy),Go(n,Cy)}function qT(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new ge})})})}function WT(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function Py(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function Oy(n,t){if(t<1&&(zo(n,vy),Go(n,vy),n.schema=1),t<2&&(dT(n),n.schema=2),t<3&&(fT(n),n.schema=3),t<4&&(hT(n),n.schema=4),t<5&&(mT(n),n.schema=5),t<6&&(yT(n),n.schema=6),t<7&&(gT(n),n.schema=7),t<8&&(n.schema=8),t<9&&(Sy(n),n.schema=9),t<10&&(ST(n),n.schema=10),t<11&&(wT(n),n.schema=11),t<12&&(Sy(n),n.schema=12),t<13&&(_T(n),n.schema=13),t<14&&(TT(n),n.schema=14),t<15&&(CT(n),n.schema=15),t<16&&(PT(n),n.schema=16),t<17&&(zo(n,wy),Go(n,wy),n.schema=17),t<18&&(zo(n,by),Go(n,by),n.schema=18),t<19&&(pT(n),n.schema=19),t<20&&(OT(n),IT(n),n.schema=20),t<21&&(NT(n),ET(n),n.schema=21),t<22&&(Ty(n),n.schema=22),t<23&&(DT(n),n.schema=23),t<24&&(LT(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(AT(n),t<25&&(n.schema=25)),t<26&&(xT(n),n.schema=26),t<27&&(vT(n),n.schema=27),t<28&&(Ty(n),n.schema=28),t<29&&(bT(n),n.schema=29),t<30&&(BT(n),n.schema=30),t<31&&(RT(n),n.schema=31),t<33&&(VT(n),n.schema=33),t<34&&(GT(n),n.schema=34),t<35&&(zT(n),n.schema=35),t<36&&(kT(n),n.schema=36),t<37&&(FT(n),n.schema=37),t<38&&(zo(n,_y),Go(n,_y),n.schema=38),t<39&&(jT(n),n.schema=39),t<40&&(UT(n),n.schema=40),t<41&&(HT(n),n.schema=41),t<42&&(qT(n),n.schema=42),t<43&&(WT(n),n.schema=43),t<99){zo(n,Py),Go(n,Py),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=ln);let e=at(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=cn,r.insertBefore(null,null,[{id:cn,data:{...Vo.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:zr(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:zr(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Ps.defaultData,...zr(n.scene.environment,"usePhysics","gravity")},camera:at(n.scene.ownerCamera)??Vo.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==hn.TRASH_CAN_ID&&r.move(cn,a.fi,a.id);let o=0,i=0;n.shared.penumbraSize&&n.scene.objects.traverse((a,s)=>{s.type==="DirectionalLight"?(s.penumbraSize=n.shared.penumbraSize[Math.min(o,2)],o+=1):s.type==="SpotLight"&&(s.penumbraSize=n.shared.penumbraSize[3+Math.min(i,1)],i+=1),(s.physics===void 0||s.physics===null)&&s.type!=="Instance"&&(s.physics={},Object.assign(s.physics,dn.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),n.schema=99}}function My(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function $T(n){n.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"))})}var ta=180/Math.PI;function Iy(n){n.rotation=n.rotation.slice(0,3).map(t=>t*ta)}function Ny(n){Iy(n),n.type==="Page"&&Iy(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*ta))});let t=n.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*ta),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*ta),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=ta,t.extrusion.twist*=ta),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(at(n.events))&&n.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Once")})}function YT(n){n.shared.variables=sr({},me.prototype)}function XT(n){let t=at(n.shared.variables);n.shared.variables=sr(Object.entries(t??{}).map(([e,r],o)=>({fi:o,id:e,data:r})),ge.prototype)}var ko=107;function Ey(n,t){t(n.data);for(let e of n.children)Ey(e,t)}function KT(n){let t=n.schema??104;t!==ko&&t<105&&(Ey(n.asset,Ny),n.schema=105)}function Tc(n){let t=n.schema??0;if(t!==ko){console.warn("updating from ",t,"to ",ko),Oy(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=fo.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(zo(n,My),Go(n,My),n.schema=101),t<102&&($T(n),n.schema=102),t<104&&(n.shared.catelogs=new me,n.shared.lib=mn.defaultData(),n.schema=104),t<105&&(YT(n),n.scene.objects.traverse((e,r)=>{Ny(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))KT(e);t<106&&(XT(n),n.schema=106),t<107&&(n.shared.lib.variables=mn.defaultData().variables,n.schema=107)}}var Zi;(s=>{s.defaultData={schema:ko,scene:hn.defaultData,frames:new me().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ji.defaultData),shared:{...Fr.emptyData(),colors:Fr.defaultColors()}},s.emptyDataForImports=function(l){let d=hn.emptyDataWithPage(l);return{schema:ko,scene:d,frames:new me().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ji.defaultData),shared:{...Fr.emptyData(),colors:Fr.defaultColors(),images:Fr.defaultImages(l)}}},s.emptyData=function(){return{schema:ko,scene:hn.emptyDataWithPage(),frames:new me().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ji.defaultData),shared:Fr.emptyData()}},s.collabHelper={...Ss,updateSchema(l){return(l.schema??0)<ko?tn(l,Tc):(l.schema??0)-ko}};function o(l){let d=s.collabHelper.updateSchema(l);return typeof d=="number"?d===0?l:null:d.data}s.updateSchemaDirectly=o;function i(l){return{...l,shared:{...l.shared,lib:mn.defaultData()}}}s.withoutLib=i;function a(l,d){let c=l.scene.objects.get(d);if(c&&c.data.type==="Component")return c;{let u=l.shared.lib.components[d];if(u)return u.asset}}s.getComponentData=a})(Zi||(Zi={}));var Fe=require("three"),Za=Qt(Ly());var QT=.5*(Math.sqrt(3)-1),Ms=(3-Math.sqrt(3))/6,ZT=1/3,ho=1/6,Uz=(Math.sqrt(5)-1)/4,Hz=(5-Math.sqrt(5))/20,Is=n=>Math.floor(n)|0,By=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]),bd=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 Cc(n=Math.random){let t=Vy(n),e=new Float64Array(t).map(o=>By[o%12*2]),r=new Float64Array(t).map(o=>By[o%12*2+1]);return function(i,a){let s=0,l=0,d=0,c=(i+a)*QT,u=Is(i+c),p=Is(a+c),f=(u+p)*Ms,h=u-f,m=p-f,y=i-h,g=a-m,x,S;y>g?(x=1,S=0):(x=0,S=1);let w=y-x+Ms,b=g-S+Ms,_=y-1+2*Ms,A=g-1+2*Ms,v=u&255,M=p&255,O=.5-y*y-g*g;if(O>=0){let P=v+t[M],I=e[P],D=r[P];O*=O,s=O*O*(I*y+D*g)}let T=.5-w*w-b*b;if(T>=0){let P=v+x+t[M+S],I=e[P],D=r[P];T*=T,l=T*T*(I*w+D*b)}let C=.5-_*_-A*A;if(C>=0){let P=v+1+t[M+1],I=e[P],D=r[P];C*=C,d=C*C*(I*_+D*A)}return 70*(s+l+d)}}function Ry(n=Math.random){let t=Vy(n),e=new Float64Array(t).map(i=>bd[i%12*3]),r=new Float64Array(t).map(i=>bd[i%12*3+1]),o=new Float64Array(t).map(i=>bd[i%12*3+2]);return function(a,s,l){let d,c,u,p,f=(a+s+l)*ZT,h=Is(a+f),m=Is(s+f),y=Is(l+f),g=(h+m+y)*ho,x=h-g,S=m-g,w=y-g,b=a-x,_=s-S,A=l-w,v,M,O,T,C,P;b>=_?_>=A?(v=1,M=0,O=0,T=1,C=1,P=0):b>=A?(v=1,M=0,O=0,T=1,C=0,P=1):(v=0,M=0,O=1,T=1,C=0,P=1):_<A?(v=0,M=0,O=1,T=0,C=1,P=1):b<A?(v=0,M=1,O=0,T=0,C=1,P=1):(v=0,M=1,O=0,T=1,C=1,P=0);let I=b-v+ho,D=_-M+ho,G=A-O+ho,N=b-T+2*ho,F=_-C+2*ho,B=A-P+2*ho,R=b-1+3*ho,V=_-1+3*ho,q=A-1+3*ho,Y=h&255,$=m&255,H=y&255,X=.6-b*b-_*_-A*A;if(X<0)d=0;else{let z=Y+t[$+t[H]];X*=X,d=X*X*(e[z]*b+r[z]*_+o[z]*A)}let k=.6-I*I-D*D-G*G;if(k<0)c=0;else{let z=Y+v+t[$+M+t[H+O]];k*=k,c=k*k*(e[z]*I+r[z]*D+o[z]*G)}let W=.6-N*N-F*F-B*B;if(W<0)u=0;else{let z=Y+T+t[$+C+t[H+P]];W*=W,u=W*W*(e[z]*N+r[z]*F+o[z]*B)}let U=.6-R*R-V*V-q*q;if(U<0)p=0;else{let z=Y+1+t[$+1+t[H+1]];U*=U,p=U*U*(e[z]*R+r[z]*V+o[z]*q)}return 32*(d+c+u+p)}}function Vy(n){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+~~(n()*(256-r)),i=e[r];e[r]=e[o],e[o]=i}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var Gy=require("three"),jr=new Gy.Triangle,Pc=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 i=1;jr.a.fromBufferAttribute(t,o),jr.b.fromBufferAttribute(t,o+1),jr.c.fromBufferAttribute(t,o+2),i*=jr.getArea(),e[o/3]=i}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,i=-1;for(;r<=o;){let a=Math.ceil((r+o)/2);if(a===0||e[a-1]<=t&&e[a]>t){i=a;break}else t<e[a]?o=a-1:r=a+1}return i}sampleFace(t,e,r){let o=this.randomFunction(),i=this.randomFunction();return o+i>1&&(o=1-o,i=1-i),jr.a.fromBufferAttribute(this.positionAttribute,t*3),jr.b.fromBufferAttribute(this.positionAttribute,t*3+1),jr.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(jr.a,o).addScaledVector(jr.b,i).addScaledVector(jr.c,1-(o+i)),jr.getNormal(r),this}};var jy=require("three");var Ar=require("three"),Fy=Qt(ky()),JT=new Ar.Matrix4,eC=new Ar.Matrix4,tC=new Ar.Matrix4,ra;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(ra||(ra={}));var oa=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new Ar.Matrix4;this.copyPreviousMatrix=!0;this.hiddenMatrix=new Ar.Matrix4;this.matrixWorldRigid=new Ar.Matrix4;this.shearScale=new Ar.Matrix4;this.shearScaleInv=new Ar.Matrix4}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof Ar.Object3D&&(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.matrixWorldNeedsUpdate=!1,r=!0);for(let o of this.children)o.updateMatrixWorld(r)}updateWorldMatrix(r,o){let i=this.parent;if(r&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),o)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(r,o=0){for(let i of this.children)ra.is(i)&&i.traverseObject(r,o+1)}traverseObject(r,o=0){if(r(this,o)!==!0)for(let a of this.children)ra.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:i,v:a,q:s}=(0,Fy.SVD)(o),l=JT.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),d=eC.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),c=tC.copy(d).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(c).premultiply(d),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),s.every(u=>Math.abs(s[0]-u)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,o){this.updateWorldMatrix(!0,!1);let i=new Ar.Matrix4().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),i.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof Ar.Matrix4?r.hiddenMatrix.premultiply(i):r.applyMatrix4(i),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,i,a,s,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var Sd=class extends oa(jy.Object3D){},rC=n=>n.type==="Mesh",Fo=class extends Sd{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 Fo(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.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return rC(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var Aa=require("three");var $c=require("three");var Xt=require("three");var pt=require("three"),$n=new pt.Vector3,Yn=new pt.Vector3,na=new pt.Matrix4,Hy=[new pt.Vector3(-1,1,1),new pt.Vector3(-1,-1,1),new pt.Vector3(1,-1,1),new pt.Vector3(1,1,1),new pt.Vector3(-1,1,-1),new pt.Vector3(-1,-1,-1),new pt.Vector3(1,-1,-1),new pt.Vector3(1,1,-1)],oC=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],nC=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Uy=(n,t,e)=>{n.updateEntityBoxSize($n,Yn),na.copy(t).multiply(n.matrixWorld),Yn.x===0&&Yn.y===0&&Yn.z===0?e.push(new pt.Vector3($n.x,$n.y,$n.z).applyMatrix4(na)):Hy.forEach(r=>{e.push(r.clone().multiply(Yn).add($n).applyMatrix4(na))})},Ns=class extends pt.Box3{constructor(){super(...arguments);this.matrix=new pt.Matrix4;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(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 pt.Matrix4().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,r)}expandByObjectSize(e,r,o=!1){let i=[];return o===!0?e.traverseEntity(a=>{if(a.visible||a.cloner&&a.data.visible){if(!("geometry"in a)){i.push(new pt.Vector3);return}Uy(a,r,i)}}):Uy(e,r,i),this.setFromPoints(i)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(na.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Yn).multiplyScalar(.5),this.getCenter($n),na.copy(this.matrix).setPosition($n),this.vertices=Hy.map(e=>e.clone().multiply(Yn).applyMatrix4(na))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=oC.map(([e,r])=>new pt.Line3(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new pt.Vector3))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=nC.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var Ur={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var Bt=require("three"),_d=class extends Bt.CurvePath{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 d=l[s],c=s===0?o[s]:o[s]-o[s-1],u=Math.ceil(t*c/a),p=d.getPoints(u);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 Ad=.001;function Td(n,t,e){return t.clone().sub(n).cross(t.clone().sub(e)).length()<=Ad}function wd(n,t){let e=new Bt.Vector3(...n.position),r=new Bt.Vector3(...n.controlNext.position),o=new Bt.Vector3(...t.controlPrevious.position),i=new Bt.Vector3(...t.position);return Td(e,r,i)&&Td(e,o,i)}function Mc(n){let t=n.points.map(c=>new Bt.Vector3(...c.data.position)),e=[n.points[0]],r=new Bt.Vector3(...e[0].data.position);for(let c=0;c<n.points.length-1;c++)Td(r,t[c],t[c+1])||(e.push(n.points[c]),r=t[c]);e.push(n.points[n.points.length-1]);let o=n.isClosed,i=e.length-(o?0:1),a=e.length,s=[];for(let c=0;c<a;c++){let u=e[c].data,p=new Bt.Vector3(...u.position),f=new Bt.Vector3(...u.controlPrevious.position),h=new Bt.Vector3(...u.controlNext.position),m={position:p,baseRoundness:u.roundness,controlPrevious:f,controlNext:h};if(u.roundness===0||!n.isClosed&&(c===0||c===a-1)){s[c]={...m,removedLength:0};continue}let y=o&&c==0?a-1:c-1,g=o&&c==a-1?0:c+1,x=e[y].data,S=e[g].data,w=new Bt.Vector3(...x.position),b=new Bt.Vector3(...S.position),_=w.clone().sub(p).normalize(),A=b.clone().sub(p).normalize();Object.assign(m,{prevDir:_,nextDir:A});let v=wd(x,u),M=wd(u,S);if(!v||!M)s[c]={...m,removedLength:0};else{let O=_.clone().add(A).normalize(),T=O.clone().cross(_).length()/_.dot(O);s[c]={...m,tan:T,removedLength:u.roundness/T}}}for(let c=0;c<i;c++){let u=c,p=o&&c===a-1?0:c+1,f=s[u],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 c=0;c<i;c++){let u=c,p=o&&c===a-1?0:c+1,f=s[u],h=s[p],m=null;if(!wd(e[u].data,e[p].data))f.position.distanceTo(h.position)>Ad&&(m=new Bt.CubicBezierCurve3(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)>Ad&&(m=new Bt.CubicBezierCurve3(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}l[2*c+1]=m}for(let c=0;c<a;c++){let u=s[c];if(u.removedLength===0){l[2*c]=null;continue}let p=u.position,f=u.prevDir.clone().multiplyScalar(u.removedLength).add(p),h=u.nextDir.clone().multiplyScalar(u.removedLength).add(p),m=u.tan*u.removedLength,y=u.prevDir.clone().add(u.nextDir).normalize(),g=f.clone().lerp(h,.5),x=f.distanceTo(h)/2,S=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(x,2))).add(g),w=y.clone().multiplyScalar(-m).add(S),b=p.distanceTo(w)/p.distanceTo(g),_=u.prevDir.clone().multiplyScalar(b*p.distanceTo(f)).add(p),A=_.clone().lerp(w,2),v=f.clone().lerp(_,4/3),M=h.clone().lerp(A,4/3);l[2*c]=new Bt.CubicBezierCurve3(f,v,M,h)}let d=new _d;return l.forEach(c=>{c&&d.add(c)}),d}var Oe;(t=>{function n(e){return e&&e.__isEntity}t.is=n})(Oe||(Oe={}));var ia=n=>Oe.is(n),iC={type:"completeState",isfromEntity:!0},aC=["x","y","z"],Cd=new Xt.Vector3,sC=new Xt.Vector3().set(0,1,0),aa=n=>class extends oa(n){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.destroyedInAction=!1;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Ns;this._recursiveBBox=new Ns;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let o=this.children[r];if(Oe.is(o))return o}entityChildrenCount(){let r=this.children.length;for(;r--;)if(Oe.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(Oe.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,i=!1){if(!(this.data.states.length===0&&!i)){for(let a of this.data.states)Wn.toOps(this.data,a.data).forEach(l=>{let d=$l.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(d,this.data,o)});if(r!==null){let a=this.data.states.data(r);a&&(this.dataPatched=Wn.patch(this.data,a),Wn.toOps(this.data,a).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,o)}))}i&&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=>{ia(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let o;return this.traverseEntity(i=>{i.uuid===r&&(o=i)}),o}traverseSortNextHelper(){let r=this.parent;if(r){let o=r.children,i=o.indexOf(this)+1;if(Oe.is(o[i]))return o[i];if(Oe.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&Oe.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,i=this;for(;i!==r;){if(i===null)return-1;i=i.parent,o+=1}return o}forEachEntity(r){for(let o of this.children)ia(o)&&r(o)}traverseEntityAncestors(r){this.traverseAncestors(o=>{Oe.is(o)&&r(o)})}traverseConcreteEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)ia(a)&&a.isConcreteEntity&&a.traverseEntity(r,o+1)}traverseEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)ia(a)&&a.traverseEntity(r,o+1)}traverseVisibleEntity(r){r(this);for(let o of this.children)ia(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=>ia(r))}isAncestorOf(r){if(this.uuid===r)return!1;let o=!1;return this.traverseEntity(i=>{i.uuid===r&&(o=!0)}),o}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x*Xt.MathUtils.RAD2DEG,this.rotation.y*Xt.MathUtils.RAD2DEG,this.rotation.z*Xt.MathUtils.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Vi(o,r)}getTransformValues(r,o,i){return o[r].map((a,s)=>i?.shared.getVariable(a,[this.uuid,r,aC[s]])??a)}updateTransformState(r,o){let i=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,o)),i=!0),r.rotation&&(Cd.fromArray(this.getTransformValues("rotation",r,o)).multiplyScalar(Xt.MathUtils.DEG2RAD),this.rotation.setFromVector3(Cd),i=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,o)),i=!0),r.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??sn.identity)),i&&(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),i}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)Oe.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{Oe.is(r)&&r.disposeRecursively()})}toState(r=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return Vi(o,r)}updateByObjUpdateOp(r,o){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},o,!1)}updateByOp(r,o,i,a){let s=this.data;this.data=o;let l=r,d=Yt(r.path,["states","*"]);if(d!==null){if(r.type===0){let[c]=d;if(this?.stateSelection===c){let u={...r.props};if(delete u.name,Object.values(r.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=gt.zoom(p,r.path.slice(2));if(f)for(let h in r.props)r.props[h]===void 0&&h in f&&(u[h]=f[h])}}l={...r,props:u,path:r.path.slice(2)}}}}else if(r.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(r.props.name!==void 0&&c.name){let{name:p,...f}=c;c=f}if(r.props.material!==void 0&&"material"in c){let{material:p,...f}=c;c=f}let u=gt.removeOverridden(r.path,r.props,c);l={...r,props:u}}}if(this.updateByPatchedOpBase(l,Wn.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),Yt(r.path,["overrides"])){let c=[],u=[...r.path];for(c.push(u[1]),u.splice(0,2);u.length>0&&u[0]==="descendants";)c.push(u[1]),u.splice(0,2);if(c[c.length-1]===void 0){if(r.type===0)for(let p of Object.keys(r.props)){c[c.length-1]=p;let f=i.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=r.props[p],f.updateState(io.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...c]);if(p){let f=gt.zoom(p.component.data,u);if(r={...r,path:u},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=Xi.resolve(o.overrides,c),p.updateByOp(r,xt.applySimple(p.data,r),i,!1)}}}else if(this.instances.length>0){let c;if(r.path.length===0&&r.type===0){let u;for(let p of po.rootOverrideProps)p in r.props&&(u===void 0&&(u={}),u[p]=r.props[p]);u&&(c={...r,props:u})}else for(let u of po.rootOverrideProps)if(Yt(r.path,[u])){c=r;break}c!==void 0&&this.instances.forEach(u=>{if(u.isInstanceRoot){let p=io.filterOp(u.overrideData,c);p&&u.updateByOp(p,xt.applySimple(u.data,p),i,!0)}}),this.instances.forEach(u=>{if(!u.isInstanceRoot){let p=io.filterOp(u.overrideData,r);if(p){let f;s===u.data&&r===p?f=o:f=xt.applySimple(u.data,p),u.updateByOp(p,f,i,!0)}}})}}updateByPatchedOpBase(r,o,i){if(this.dataPatched=o,r.path.length===0&&r.type===0)r.props.type!==void 0&&!kr.is(r.props.type)&&Ur.changeEntityProptotype(this,o,i);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){Ur.changeEntityProptotype(this,o,i);for(let a of this.children)Oe.is(a)&&a.updateVisible(i.scene)}this.updateByPatchedOp(r,o,i)}updateByPatchedOp(r,o,i){if(r.path.length===0&&r.type===0&&this.updateState(r.props,i),Yt(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Yt(r.path,["cloner"])!==null){let a=xt.drop(r,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,i):this.cloner?this.cloner.updateState(o.cloner,i.scene):(this.setFromClonerState(o.cloner,i),this.expandCloner(i.scene)),this.updateVisible(i.scene)}}updatePathSnapping(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,i=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,a=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(o===null)return;let l=r.find(o);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let d=l.data;if(d.geometry.path.points.length<=1)return;let c=Mc(d.geometry.path),u=(i+a)%1;i+a===1&&u===0&&(u=1);let p=c.getPointAt(u);if(p===null)return;let f=this.parent?this.parent?.matrixWorld:new Xt.Matrix4;l.updateMatrixWorld();let h=new Xt.Matrix4().multiplyMatrices(f.clone().invert(),l.matrixWorld);p.applyMatrix4(h);let m={position:p.toArray(),rotation:d.rotation};if(s==="tangential"){let y=new Xt.Matrix4().extractRotation(l.matrixWorld),g=c.getTangentAt(u).applyMatrix4(y).add(p),x=new Xt.Matrix4().lookAt(p,g,sC),S=Cd.setFromEuler(new Xt.Euler().setFromRotationMatrix(x)).multiplyScalar(Xt.MathUtils.RAD2DEG);m={...m,rotation:S.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(iC)})}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(i=>{if(i.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 Ur.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 Ur.Cloner(this,r),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,o.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}};var gn=require("three");var $e=require("three"),Wy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);e.thetaLength=$e.MathUtils.clamp(e.thetaLength,0,360);let r=e.width/2,o=e.radiusTop??r,i=e.radiusBottom??r;return o===i?(o=r,i=r):o>i?(o=r,i=i*r/o):(o=o*r/i,i=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:o,radiusBottom:i})}}static build(n){let{width:t,depth:e,height:r,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:d,radiusBottom:c,cornerRadius:u,cornerSegments:p,hollow:f}=n.parameters,h;return l===0?(h=new $e.BufferGeometry,h.setAttribute("position",new $e.Float32BufferAttribute([],3))):u||f?h=new Es(d,c,r,o,i,a,s,l*Math.PI/180,u,u,p,f):h=new $e.CylinderGeometry(d,c,r,o,i,a,s,l*Math.PI/180),h.scale(1,1,e/t),Object.assign(h,{userData:{...n,type:"CylinderGeometry"}})}};function yn(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function qy(n){return new $e.Vector2(n.y,-n.x)}var Es=class extends $e.BufferGeometry{constructor(t,e,r,o,i,a,s,l,d,c,u,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,i=Math.floor(i)||1,a=a!==void 0?a:!1,s=s!==void 0?s:0,l=l!==void 0?l:Math.PI*2,a&&(d=0,c=0);let h=[],m=[],y=[],g=[],x=0,S=r/2,w=new $e.Vector3,b=new $e.Vector3;f&&t==0&&(t=d),f&&e==0&&(e=c);let _=new $e.Vector2(t,S),A=new $e.Vector2(e,-S),v=null,M=null,O=null,T=null,C=_.clone().sub(A),P=0,I=0,D=0;p>0&&(P=Math.min(t,e)*(1-p),I=t-P,D=e-P);let G=_.clone();G.x-=P;let N=Math.PI-C.angle(),F=C.angle(),B=Math.tan(F/2),R=Math.tan(N/2),V=B+R,q=p?V:R,Y=p?V:B;if(d=Math.min(d,(t-I)/q,C.length()/V),c=Math.min(c,(e-D)/Y,C.length()/V),d>0){let U=d/B;v=_.clone().sub(new $e.Vector2(U,d)),p&&(O=v.clone(),O.x-=P-V*d),_.sub(C.clone().setLength(U))}if(c>0){let U=c/R;M=A.clone().sub(new $e.Vector2(U,-c)),A.add(C.clone().setLength(U)),p&&(T=M.clone(),T.x-=P-V*c,G.sub(C.clone().setLength(U)))}C=_.clone().sub(A);let $=C.length()<.5,H=[];for(let U=0;U<=o;U++){let z=[],ne=U/o,ee=ne*l+s,Q=new $e.Vector2(Math.sin(ee),Math.cos(ee));T&&M?(X(z,ne,Q,N,c,T,-1,!0),X(z,ne,Q,F,c,M,-1,!1)):M?(k(z,Q,M.x,0,-1),X(z,ne,Q,F,c,M,-1,!1)):a||k(z,Q,e,D,-1);let te=qy(C).normalize();if(yn(te,Q,w),!$)for(let Z=0;Z<=i;Z++){let le=Z/i,ie=C.clone().multiplyScalar(le).add(A);yn(ie,Q,b),m.push(b.x,b.y,b.z),y.push(w.x,w.y,w.z),g.push(ne,.5+b.y/r),z.push(x++)}if(O&&v?(X(z,ne,Q,N,d,v,1,!1),X(z,ne,Q,F,d,O,1,!0)):v?(X(z,ne,Q,N,d,v,1,!1),k(z,Q,v.x,0,1)):a||k(z,Q,t,I,1),p&&!$){let Z=qy(C).multiplyScalar(-1).normalize();yn(Z,Q,w);for(let le=0;le<=i;le++){let ie=le/i,ae=C.clone().multiplyScalar(-ie).add(G);yn(ae,Q,b),m.push(b.x,b.y,b.z),y.push(w.x,w.y,w.z),g.push(ne,.5+b.y/r),z.push(x++)}}p&&!a&&z.push(z[0]),H.push(z)}for(let U=0;U<H.length-1;U++)for(let z=0;z<H[0].length-1;z++){if(a&&p&&z==i)continue;let ne=H[U][z],ee=H[U+1][z],Q=H[U+1][z+1],te=H[U][z+1],Z=m[Q*3+0],le=m[Q*3+2];h.push(ne,ee,te),(Z!=0||le!=0)&&h.push(ee,Q,te)}l<Math.PI*2&&(W(-1,H[0],s),W(1,H[H.length-1],s+l)),this.setIndex(h),this.setAttribute("position",new $e.Float32BufferAttribute(m,3)),this.setAttribute("normal",new $e.Float32BufferAttribute(y,3)),this.setAttribute("uv",new $e.Float32BufferAttribute(g,2));function X(U,z,ne,ee,Q,te,Z,le){for(let ie=0;ie<u+1;ie++){let ae=ie/u,de=Z<0?ae:1-ae;le&&(de-=1),de*=ee;let ce=new $e.Vector2(Math.sin(de),Math.cos(de)*Z),pe=ce.clone().multiplyScalar(Q).add(te);yn(pe,ne,b),m.push(b.x,b.y,b.z),yn(ce,ne,w),y.push(w.x,w.y,w.z),g.push(z,.5+b.y/r),U.push(x++)}}function k(U,z,ne,ee,Q){let te=new $e.Vector3,Z=new $e.Vector2,le=[ne,ee];Q<0&&le.reverse();for(let ie of le)Z.set(ie,S*Q),yn(Z,z,te),m.push(te.x,te.y,te.z),y.push(0,Q,0),g.push(.5,.5),U.push(x++)}function W(U,z,ne){let ee=new $e.Vector2(Math.sin(ne),Math.cos(ne)),Q=new $e.Vector2(-Math.cos(ne),Math.sin(ne)),te=new $e.Vector3,Z=U<0?(ae,de,ce)=>h.push(ae,de,ce):(ae,de,ce)=>h.push(ae,ce,de),le=new $e.Vector2((t+e+I+D)/4,0);yn(le,ee,te),m.push(te.x,te.y,te.z),y.push(Q.x,0,Q.y),g.push(.5,.5);let ie=x++;for(let ae of z){let de=m.slice(ae*3,ae*3+3);m.push(...de),y.push(Q.x,0,Q.y);let ce=g.slice(ae*2,ae*2+2);g.push(...ce),x++}for(let ae=ie+1;ae<x-1;ae++)Z(ie,ae,ae+1);Z(ie,x-1,ie+1)}}};var $y=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,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},n.parameters);return e.thetaLength=gn.MathUtils.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,depth:e,height:r,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:d,cornerRadiusBottom:c,cornerSegments:u}=n.parameters,p;return l===0?(p=new gn.BufferGeometry,p.setAttribute("position",new gn.Float32BufferAttribute([],3))):d>0||c>0||l<360?p=new Es(0,t/2,r,o,i,a,s,l*Math.PI/180,d,c,u,0,!0):p=new gn.ConeGeometry(t/2,r,o,i,a),p.scale(1,1,e/t),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};var ur=require("three"),Yy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,widthSegments:o,heightSegments:i,depthSegments:a,cornerRadius:s,cornerSegments:l}=n.parameters,d;return s==0?d=new ur.BoxGeometry(t,e,r,o,i,a):d=new Od(t,e,r,o,i,a,s,l),Object.assign(d,{userData:{...n,type:"CubeGeometry"}})}},Pd=Math.PI/2,Od=class extends ur.BufferGeometry{constructor(t=1,e=1,r=1,o=1,i=1,a=1,s=0,l=4){super(),this.type="BoxGeometry";let d=this;o=Math.floor(o),i=Math.floor(i),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,t/2,e/2,r/2);let c=[],u=[],p=[],f=[],h=0,m=0;y("z","y","x",-1,-1,r,e,t,a,i,0),y("z","y","x",1,-1,r,e,-t,a,i,1),y("x","z","y",1,1,t,r,e,o,a,2),y("x","z","y",1,-1,t,r,-e,o,a,3),y("x","y","z",1,-1,t,e,r,o,i,4),y("x","y","z",-1,-1,t,e,-r,o,i,5),s>0&&(g("z","y","x",-1,-1,1,r,e,t,a,0),g("z","y","x",1,-1,-1,r,e,t,a,1),g("z","y","x",-1,1,-1,r,e,t,a,1),g("z","y","x",1,1,1,r,e,t,a,0),g("x","y","z",-1,-1,-1,t,e,r,o,0),g("x","y","z",1,-1,1,t,e,r,o,1),g("x","y","z",-1,1,1,t,e,r,o,0),g("x","y","z",1,1,-1,t,e,r,o,1),g("y","x","z",-1,-1,1,e,t,r,i,0),g("y","x","z",1,-1,-1,e,t,r,i,1),g("y","x","z",1,1,1,e,t,r,i,1),g("y","x","z",-1,1,-1,e,t,r,i,0),x(1,1,1),x(-1,1,1),x(1,-1,1),x(-1,-1,1),x(1,1,-1),x(-1,1,-1),x(1,-1,-1),x(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new ur.Float32BufferAttribute(u,3)),this.setAttribute("normal",new ur.Float32BufferAttribute(p,3)),this.setAttribute("uv",new ur.Float32BufferAttribute(f,2));function y(S,w,b,_,A,v,M,O,T,C,P){let I=(v-2*s)/T,D=(M-2*s)/C,G=v/2-s,N=M/2-s,F=O/2,B=T+1,R=C+1,V=0,q=0,Y=new ur.Vector3;for(let $=0;$<R;$++){let H=$*D-N;for(let X=0;X<B;X++){let k=X*I-G;Y[S]=k*_,Y[w]=H*A,Y[b]=F,u.push(Y.x,Y.y,Y.z),Y[S]=0,Y[w]=0,Y[b]=O>0?1:-1,p.push(Y.x,Y.y,Y.z),f.push(X/T),f.push(1-$/C),V+=1}}for(let $=0;$<C;$++)for(let H=0;H<T;H++){let X=h+H+B*$,k=h+H+B*($+1),W=h+(H+1)+B*($+1),U=h+(H+1)+B*$;c.push(X,k,U),c.push(k,W,U),q+=6}d.addGroup(m,q,P),m+=q,h+=V}function g(S,w,b,_,A,v,M,O,T,C,P){let I=(M-2*s)/C,D=M/2-s,G=O/2-s,N=T/2,F=C+1,B=0,R=0,V=new ur.Vector3,q=new ur.Vector3;for(let Y=0;Y<l+1;Y++){let $=Y/l*Pd,H=Math.sin($)*s,X=(1-Math.cos($))*s,k=Math.sin($),W=Math.cos($);V[w]=(G+H)*A,V[b]=(N-X)*v,q[S]=0,q[w]=k*Math.sign(V[w]),q[b]=W*Math.sign(V[b]);for(let U=0;U<F;U++){let z=U*I-D;V[S]=z*_,u.push(V.x,V.y,V.z),p.push(q.x,q.y,q.z),f.push(U/C),f.push(0),B+=1}}for(let Y=0;Y<l;Y++)for(let $=0;$<C;$++){let H=h+$+F*Y,X=h+$+F*(Y+1),k=h+($+1)+F*(Y+1),W=h+($+1)+F*Y;c.push(H,X,W),c.push(X,k,W),R+=6}d.addGroup(m,R,P),m+=R,h+=B}function x(S,w,b){let _=new ur.Vector3,A=new ur.Vector3(t/2,e/2,r/2);A.subScalar(s);let v=[],M=S*w*b>0?(T,C,P)=>c.push(T,C,P):(T,C,P)=>c.push(T,P,C);for(let T=0;T<=l;T++){let C=[],P=Pd*(1-T/l),I=Math.cos(P),D=Math.sin(P),G=0;for(let N=0;N<=T;N++){let F=Math.cos(G),B=Math.sin(G);_.x=I*F,_.y=D,_.z=I*B;let R=A.clone().addScaledVector(_,s);u.push(S*R.x,w*R.y,b*R.z),p.push(S*_.x,w*_.y,b*_.z),f.push(0,0),C.push(h++),G+=Pd/T}v.push(C)}let O=v.length-1;for(let T=0;T<O;T++){let C=v[T],P=v[T+1],I=C.length-1;M(C[0],P[1],P[0]);for(let D=1;D<=I;D++)M(C[D-1],C[D],P[D]),M(C[D],P[D+1],P[D])}}}};var ft=require("three"),xn=class extends ft.BufferGeometry{constructor(t=[],e=[],r="",o=1,i=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],d=[];c(),u(),this.setAttribute("position",new ft.Float32BufferAttribute(s,3)),this.setAttribute("normal",new ft.Float32BufferAttribute(d,3)),this.setAttribute("uv",new ft.Float32BufferAttribute(l,2));return;function c(){i=Math.min(1-1e-5,i),i==0&&(a=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],h=new ft.Vector3,m=h.clone(),y=new ft.Triangle,g=i*o,x=o-g,S=a+1,w=new ft.Vector3,b=(B,R)=>w.subVectors(B,R).normalize(),_=(B,R)=>Array(B).fill(void 0).map(R),A=_(t.length/3,(B,R)=>new ft.Vector3().fromArray(t,R*3).setLength(o)),v=[],M=1e6;for(let B=0;B<A.length;B++){let R=A[B],V=[],q,Y,$,H=1e10,X=-1;for(;(X=e.indexOf(B,X+1))!=-1;){let z=X-X%3;q=e[z+(X+1)%3],Y=e[z+(X+2)%3],$=R.distanceToSquared(A[q]),H=Math.min(H,$),V.push([q,Y,$])}H+=1e-6;let k=[],W=0,U=V.length;for(let z=0;z<U;z++){[q,Y,$]=V[W];let ne=v[q]?.includes(B)==!0;$<=H&&k.push(q+ +ne*M),W=V.findIndex(ee=>ee[0]==Y)}v.push(k)}let O=[];{let B=0,R=0,V,q,Y=f==3;for(let $=0;$<=a;$++){V=$*($+1)/2,q=($+1)*($+2)/2;for(let H=0;H<a-$;H++)[B,R]=[V+H+$+2,q+H+$+3],O.push(V,q,...Y?[R,V]:[B,q],R,B),[V,q]=[B,R];O.push(V,q,V+a+2)}}let T=h.clone(),C=h.clone(),P=h.clone(),I=h.clone(),D=h.clone(),G=[],N=_(A.length,()=>_(f,()=>h.clone()));for(let B=0;B<A.length;B++){h.copy(A[B]).normalize(),T.copy(h).multiplyScalar(x);let R=v[B];for(let k=0;k<R.length;k++){let W=R[k],U=R[(k+1)%f];y.setFromPointsAndIndices(A,B,W%M,U%M),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(T,N[B][k])}let V=[],q=[],Y=[],$=new ft.Vector3;a==0&&[...N[B]].reduce((k,W)=>k.add(W),$).multiplyScalar(1/f);for(let k=0;k<f;k++){let W=[],U=(k-1+f)%f,z=N[B][U],ne=N[B][k];h.copy(z).sub(T),m.copy(ne).sub(T);let ee=T.angleTo(h),Q=h.angleTo(m),te=Math.cos(ee)*g;a==0?C.copy($):C.copy(T).setLength(x+te),q.push(te);let Z=[C,z,ne];for(let le=0;le<2;le++){let ie=Z[le],ae=Z[le+1];I.subVectors(ie,T),D.subVectors(ae,T),P.crossVectors(I,D).normalize();for(let de=0;de<S;de++){let ce=[ee,Q][le]*de/S;h.copy(I).applyAxisAngle(P,ce).add(T),V.push(h.clone()),le&&(b(h,T),W.push([de==0?ie:h.clone(),w.clone()]))}le&&(b(ae,T),W.push([ae,w.clone()]))}Y.push(W)}G.push(Y);let H=2*S,X=2;for(let k=0;k<f;k++){let W=H*k,U=H*((k+1)%f),z=[V[W]];for(let ee=1;ee<S;ee++){I=V[W+ee],D=V[U+ee],z.push(I);for(let Q=1,te=ee-X+1;Q<=te;Q++)h.lerpVectors(I,D,Q/(te+1)),h.sub(T).setLength(q[k]).add(T),z.push(h.clone());z.push(D)}for(let ee=0;ee<S;ee++)z.push(V[ee+S+W]);z.push(V[U+S]);let ne=O.map(ee=>z[ee]);s.push(...ne.map(ee=>[ee.x,ee.y,ee.z]).flat()),d.push(...ne.map(ee=>(b(ee,T),[w.x,w.y,w.z])).flat())}}let F=[];for(let B=0;B<v.length;B++)for(let R=0;R<f;R++){let V=v[B][R];if(V<M){let q=v[V].findIndex(H=>H%M==B),Y=G[B][R],$=G[V][q];for(let H=0;H<S;H++){let X=Y[H],k=$[S-H],W=Y[H+1],U=$[S-(H+1)];[X,k,W,W,k,U].forEach(z=>{s.push(z[0].x,z[0].y,z[0].z),d.push(z[1].x,z[1].y,z[1].z)})}F.push(Y[0][0],$[S][0],Y[S][0],$[0][0])}}for(;F.length;){let B,R,V,q;[B,R]=F.splice(0,2);let Y=[B];for(;B!=R;)Y.push(R),V=F.indexOf(R),q=V%2,R=F.splice(V-q,2)[1-q];w.subVectors(Y[0],Y[1]).cross(h.subVectors(Y[0],Y[2])).normalize();let $=w.dot(Y[0])<0;$&&w.negate();for(let H=1;H<=Y.length-2;H++)[Y[H+ +$],Y[H+1-+$],Y[0]].forEach(X=>{s.push(X.x,X.y,X.z),d.push(w.x,w.y,w.z)})}}function u(){let p=new ft.Vector3;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 v=b(p)/2/Math.PI+.5,M=_(p)/Math.PI+.5;l.push(v,1-M)}let f=new ft.Vector3,h=new ft.Vector3,m=new ft.Vector3,y=new ft.Vector3,g=new ft.Vector2,x=new ft.Vector2,S=new ft.Vector2,w=(A,v,M,O)=>{O<0&&A.x===1&&(l[v]=A.x-1),M.x===0&&M.z===0&&(l[v]=O/2/Math.PI+.5)};for(let A=0,v=0;A<s.length;A+=9,v+=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[v+0],l[v+1]),x.set(l[v+2],l[v+3]),S.set(l[v+4],l[v+5]),y.copy(f).add(h).add(m).divideScalar(3);let M=b(y);w(g,v+0,f,M),w(x,v+2,h,M),w(S,v+4,m,M)}for(let A=0;A<l.length;A+=6){let v=l[A+0],M=l[A+2],O=l[A+4],T=Math.max(v,M,O),C=Math.min(v,M,O);T>.9&&C<.1&&(v<.2&&(l[A+0]+=1),M<.2&&(l[A+2]+=1),O<.2&&(l[A+4]+=1))}function b(A){return Math.atan2(A.z,-A.x)}function _(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(t){return new xn(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var Xy=require("three"),Ky=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new Ds(t*.5,i,a):new Xy.DodecahedronGeometry(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},Ds=class extends xn{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,i=1/o,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-o,0,-i,o,0,i,-o,0,i,o,-i,-o,0,-i,o,0,i,-o,0,i,o,0,-o,0,-i,o,0,-i,-o,0,i,o,0,i],s=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(a,s,l,t,e,r),this.type=l}static fromJSON(t){return new Ds(t.radius,t.corner,t.cornerSides)}};var Ve=require("three");var _e=require("three"),Ls=1e-12,sa=class{constructor(t){this.position=new _e.Vector2;this.startPosition=new _e.Vector2;this.uuid=_e.MathUtils.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 sa(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},la=class extends sa{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new la(this.parent).copy(this)}},Hr=class extends sa{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new la(this),new la(this))}static create(e,r){let o=new Hr(e,new _e.Vector2(...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,i=this.controls.length;o<i;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 Hr(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 _e.Vector2,r=new _e.Vector2){let[o,i]=this.computeTangents();return o&&i&&(Qy(o,e),Qy(i,r)),[e,r]}computeTangent(e=new _e.Vector2){let[r,o]=this.computeTangents();return r&&o&&e.copy(r).add(o).normalize(),e}computeNormal(e=new _e.Vector2){let[r,o]=this.computeNormals();return e.copy(r).add(o).normalize(),e}};function Qy(n,t=new _e.Vector2){let e=n.length();return t.set(-n.y/e,n.x/e)}var Id=n=>n,ca=new _e.Vector2,Ic=new _e.Vector2,lC=new _e.Vector2,cC=new _e.Vector2,uC=new _e.Vector2,dC=new _e.Vector2,Jy=new _e.Vector3,eg=new _e.Vector3;function tg(n){let t=new _e.Vector2;t.addVectors(n.v0,ca.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new _e.Vector2;return e.addVectors(n.v2,Ic.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new _e.CubicBezierCurve(n.v0,t,e,n.v2)}function Bs(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function pC(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function fC(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function Nd(n,t,e){let r=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),o=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),i=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((o*o+r*r-i*i)/(2*o*r))}function rg(n,t,e){return Zy(n,t)&&Zy(t,e)&&Md(n.position,t.position,e.position)}function Md(n,t,e){return ca.copy(t).sub(n).cross(Ic.copy(e).sub(n))===0}function og(n,t,e,r,o){let i=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),a=(n.y+t.y)/2,s=(n.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(n.y-t.y)/i,d=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(t.x-n.x)/i;return r.set(s+l,a+d),o.set(s-l,a-d),[r,o]}function ng(n,t,e){let r=n.distanceTo(e),o=t.distanceTo(e);return r<o?t:n}function ig(n,t,e,r,o,i){let a=t.x-n.x,s=t.y-n.y,l=e.x-n.x,d=e.y-n.y,c=Math.sqrt((a+l)*(a+l)+(s+d)*(s+d)),u;return Nd(t,n,e)>Math.PI&&(c*=-1),Bs(d,s)?u=(s+d)*(r/c-.5)*8/3/(a-l):u=(a+l)*(r/c-.5)*8/3/(d-s),o.set(t.x-u*s,t.y+u*a),i.set(e.x+u*d,e.y-u*l),[o,i]}function Ed(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function Zy(n,t){return Md(n.position,n.controls[1].position,t.position)&&Md(n.position,t.controls[0].position,t.position)}function ag(n,t,e,r,o=.5){let i=ca.subVectors(t,n).multiplyScalar(o).add(n),a=Ic.subVectors(e,t).multiplyScalar(o).add(t),s=lC.subVectors(r,e).multiplyScalar(o).add(e),l=i,d=cC.subVectors(a,i).multiplyScalar(o).add(i),c=uC.subVectors(s,a).multiplyScalar(o).add(a),u=s,p=dC.subVectors(c,d).multiplyScalar(o).add(d);return[n.x,n.y,l.x,l.y,d.x,d.y,p.x,p.y,c.x,c.y,u.x,u.y,r.x,r.y]}function sg(n,t,e=12,r=!0){let o=eg.set(0,0,0),i,a=0,s=[];for(let l=0;l<t.length;l++){let d=Id(t[l]),c=ca,u=vn(d,e);s.push(u);for(let p=0;p<=u;p++)if(d instanceof _e.CubicBezierCurve||d instanceof _e.QuadraticBezierCurve||d instanceof _e.LineCurve){if(d.getPoint(p/u,c),o.set(c.x,c.y,0),i!==void 0&&fC(i,o))continue;i===void 0&&(i=Jy),i.copy(o),n.setXYZ(a,o.x,o.y,o.z),a++}}return r&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),n}function lg(n,t,e,r=12,o=!0){let i=eg.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let d,c=Id(t[l]),u=ca,p=vn(c,r);s.push(p);for(let f=0;f<=p;f++)if(c instanceof _e.CubicBezierCurve||c instanceof _e.QuadraticBezierCurve||c instanceof _e.LineCurve){if(c.getPoint(f/p,u),i.set(u.x,u.y,0),d?.equals(i))continue;d===void 0?d=Jy:(n.setXYZ(a,d.x,d.y,d.z),a++,n.setXYZ(a,i.x,i.y,i.z),a++),d.copy(i)}}return o&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),s}function Dd(n,t=12,e=!1){let r=[];for(let o=0,i=n.length;o<i;o++){let a=n[o],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=vn(a.roundedCurveCorner,t)*.5;o>0&&(r[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=vn(a.curveAfter,t)),r.push(s)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=vn(n[0].roundedCurveCorner,t)*.5),r}function vn(n,t=12){return n&&n instanceof _e.EllipseCurve?t*2:n&&(n instanceof _e.LineCurve||n instanceof _e.LineCurve3)?1:n&&n instanceof _e.SplineCurve?t*n.points.length:t}function cg(n,t,e=12,r=!0){let o,i=0;for(let a=0;a<t.length;a++){let s=Id(t[a]),l=vn(s,e),d=ca;for(let c=0;c<=l;c++)if(s instanceof _e.CubicBezierCurve||s instanceof _e.QuadraticBezierCurve||s instanceof _e.LineCurve){if(s.getPoint(c/l,d),o!==void 0&&pC(o,d,Ls))continue;o===void 0&&(o=Ic),o.copy(d),n.push(d.x,d.y),i++}}return Bs(n[0],n[n.length-2],Ls)&&Bs(n[1],n[n.length-1],Ls)&&(n.pop(),n.pop()),r&&i>1&&!(Bs(n[i-1],n[1],Ls)&&Bs(n[i-2],n[0],Ls))&&(n.push(n[0],n[1]),i++),n}var Ld=new Ve.Vector2,hC=new Ve.Vector2,mC=new Ve.Vector2,yC=new Ve.Vector2,gC=new Ve.Vector2,xC=new Ve.Vector2,Re=class extends Ve.Shape{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new Ve.Plane(new Ve.Vector3(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this.isText=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Ve.MathUtils.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,o){let i=new Re;return i.isClosed=e.isClosed,i.points=e.points.map(a=>Hr.create(a.id,a.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(a=>Re.createFromState(a)),r!==void 0&&o!==void 0&&i.applySize(r,o),i.update(),i}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let 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(i=>i.uuid===e);if(o<0){let i=r;for(let a=0,s=this.shapeHoles.length;a<s;a++){let l=this.shapeHoles[a],d=l.points.length,c=l.getPointIndexById(e);if(c<0)i+=d;else return c+i}}return o}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let r=this.points.length;for(let o=0,i=this.shapeHoles.length;o<i;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,i=this.shapeHoles.length;o<i;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=Ld.set(e,r);for(let i=0,a=this.points.length;i<a;i++){let s=this.points[i];s.position.multiply(o),s.controls[0].position.multiply(o),s.controls[1].position.multiply(o)}for(let i=0,a=this.shapeHoles.length;i<a;i++)this.shapeHoles[i].applyScale(e,r);this._update()}createPoint(e,r=0,o=Ve.MathUtils.generateUUID()){let i;e instanceof Ve.Vector2?i=e:i=new Ve.Vector2(e,r);let a=new Hr(o,i);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 i=this.points[r];if(i.uuid===e)return i}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 i=o?this.roundedCurveDivisions:this.curveDivisions;return sg(e,o?this.roundedCurves:this.curves,r,this.autoClose),i.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Dd(this.points,e,!1),this.roundedCurveDivisions=Dd(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,o=12){return lg(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),cg(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let i=r?this.roundedCurveDivisions:this.curveDivisions,a=0;r&&this.points[0].roundedCurveCorner!==void 0&&(a=vn(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=i.reduce((l,d)=>l+d,0));for(let l=0,d=i.length;l<d;l++){let c=i[l];if(s<o+c)return[l,(s-o+1)/c];o+=c}return[0,1]}getCurveT(e,r,o){let i=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(Ed(i,a)){let u=i.position.distanceTo(a.position);return i.position.distanceTo(Ld.set(o.x,o.y))/u}let d=0;for(let u=0;u<e;u++)d+=s[u];return(r-d)/l}dispose(){}_applyCurveForPoint(e,r){Ed(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 i=o.clone();e.roundedCurveBefore=i,r.roundedCurveAfter=i,e.roundedCurveCorner=void 0,this.roundedCurves.push(i)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,o=this.points.length;r<o;r++){let i=this.points[r];if(r===0)this.moveTo(i.position.x,i.position.y);else{let a=this.points[r-1];this._applyCurveForPoint(i,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,i=this.points.length;o<i;o++){let a=this.points[o],s=this.points[o-1]??this.points[this.points.length-1],l=this.points[o+1]??this.points[0],d=a.roundness,c=s&&l&&rg(s,a,l);if(!a.controlsMoved()&&d>0&&!c){let u=a.curveBefore,p=a.curveAfter;if(u===void 0||p===void 0)continue;let f=a.roundedCurveBefore,h=a.roundedCurveAfter,m=u.getLength(),y=p.getLength(),g=Math.min(d,m*.499),x=Math.min(d,y*.499),S=Math.min(g,x),w=1-S/m,b=S/y,_=u.getPointAt(w,Ld),A=p.getPointAt(b,hC);this._subSplitCurve(u,f,w,_,void 0),this._subSplitCurve(p,h,b,void 0,A);let v;if(this.useCubicForRoundedCorners){let M=Nd(_,a.position,A)/2,O=Math.tan(M)*_.distanceTo(a.position),[T,C]=og(_,A,O,mC,yC),P=ng(T,C,a.position),[I,D]=ig(P,_,A,O,gC,xC);v=new Ve.CubicBezierCurve(_.clone(),I.clone(),D.clone(),A.clone())}else v=new Ve.QuadraticBezierCurve(_.clone(),a.position.clone(),A.clone());a.roundedCurveCorner=v,this.roundedCurves.splice(o+r,0,v),r++}}}}_subSplitCurve(e,r,o,i,a){if(e instanceof Ve.LineCurve)i!==void 0&&r.v2.copy(i),a!==void 0&&r.v1.copy(a);else{let s=e,l=r,d=s.getUtoTmapping(o,0),c=ag(s.v0,s.v1,s.v2,s.v3,d);return i!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),a!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return r}clone(){let e=new Re(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 i=o*7,a=e.points[i+0],s=e.points[i+1],l=e.points[i+2],d=e.points[i+3],c=e.points[i+4],u=e.points[i+5],p=e.points[i+6],f=new Hr(Ve.MathUtils.generateUUID(),new Ve.Vector2(a,s));f.controls[0].position.set(l,d),f.controls[1].position.set(c,u),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new Re;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let o=(a,s)=>{s instanceof Ve.CubicBezierCurve&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},i=a=>{let s=[],l,d;for(l=0,d=a.length;l<d;l++)a[l]instanceof Ve.QuadraticBezierCurve&&(a[l]=tg(a[l]));for(l=0,d=a.length;l<d;l++){let p=a[l],f=l>0?a[l-1]:null,h;p instanceof Ve.CubicBezierCurve?(h=this.createPoint(p.v0),h.controls[1].position.copy(p.v1)):p instanceof Ve.LineCurve&&(h=this.createPoint(p.v1)),h!==void 0&&(f!==null&&o(h,f),s.push(h))}let c=a[a.length-1],u=!1;return c instanceof Ve.CubicBezierCurve?c.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(c.v2),u=!0):c instanceof Ve.LineCurve&&c.v2.equals(s[0].position)&&(u=!0),this.isClosed=u,s};return this.points=i(e.curves),e instanceof Ve.Shape&&(this.shapeHoles=e.holes.map(a=>{let s=new Re;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 i=this.getPointByUuid(e)?.controls[0];i&&(r.position&&i.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let i=this.getPointByUuid(e)?.controls[1];i&&(r.position&&i.position.fromArray(r.position),this.needsUpdate=!0)}};var Rd=Math.PI*2;function Bd({x:n,y:t},e,r,o,i){return{x:n*e+o,y:t*r+i}}function vC(n,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(n),o=Math.sin(n),i=Math.cos(n+t),a=Math.sin(n+t);return[{x:r-o*e,y:o+r*e},{x:i+a*e,y:a-i*e},{x:i,y:a}]}function ug(n,t,e,r){let o=n*r-t*e<0?-1:1,i=Math.min(1,Math.max(-1,n*e+t*r));return o*Math.acos(i)}function bC(n,t,e,r,o,i,a,s,l,d){let c=Math.pow(o,2),u=Math.pow(i,2),p=Math.pow(a,2),f=Math.pow(s,2),h=c*u-c*f-u*p;h<0&&(h=0),h/=c*f+u*p,h=Math.sqrt(h)*(l===d?-1:1);let m=h*o/i*s,y=h*-i/o*a,g=m+(n+e)/2,x=y+(t+r)/2,S=(a-m)/o,w=(s-y)/i,b=(-a-m)/o,_=(-s-y)/i,A=ug(1,0,S,w),v=ug(S,w,b,_);return!d&&v>0&&(v-=Rd),d&&v<0&&(v+=Rd),{centerx:g,centery:x,ang1:A,ang2:v}}function dg({px:n,py:t,cx:e,cy:r,rx:o,ry:i,largeArcFlag:a,sweepFlag:s}){let l=[];if(o===0||i===0)return[];let d=(n-e)/2,c=(t-r)/2;if(d===0&&c===0)return[];o=Math.abs(o),i=Math.abs(i);let u=Math.pow(d,2)/Math.pow(o,2)+Math.pow(c,2)/Math.pow(i,2);u>1&&(o*=Math.sqrt(u),i*=Math.sqrt(u));let p=bC(n,t,e,r,o,i,d,c,a,s),{ang1:f,ang2:h}=p,{centerx:m,centery:y}=p,g=Math.abs(h)/(Rd/4);Math.abs(1-g)<1e-7&&(g=1);let x=Math.max(Math.ceil(g),1);h/=x;for(let S=0;S<x;S++)l.push(vC(f,h)),f+=h;return l.map(S=>{let{x:w,y:b}=Bd(S[0],o,i,m,y),{x:_,y:A}=Bd(S[1],o,i,m,y),{x:v,y:M}=Bd(S[2],o,i,m,y);return{x1:w,y1:b,x2:_,y2:A,x:v,y:M}})}var Xn=require("three");var Ee;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Ee||(Ee={}));var st;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(st||(st={}));function ye(n,t){if(!n)throw t||"Assertion Failed!"}var fe=function(){function n(){}return n.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},n.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},n.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},n.edgeGoesLeft=function(t){return n.vertLeq(t.Dst,t.Org)},n.edgeGoesRight=function(t){return n.vertLeq(t.Org,t.Dst)},n.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},n.edgeEval=function(t,e,r){ye(n.vertLeq(t,e)&&n.vertLeq(e,r));var o=e.s-t.s,i=r.s-e.s;return o+i>0?o<i?e.t-t.t+(t.t-r.t)*(o/(o+i)):e.t-r.t+(r.t-t.t)*(i/(o+i)):0},n.edgeSign=function(t,e,r){ye(n.vertLeq(t,e)&&n.vertLeq(e,r));var o=e.s-t.s,i=r.s-e.s;return o+i>0?(e.t-r.t)*o+(e.t-t.t)*i:0},n.transEval=function(t,e,r){ye(n.transLeq(t,e)&&n.transLeq(e,r));var o=e.t-t.t,i=r.t-e.t;return o+i>0?o<i?e.s-t.s+(t.s-r.s)*(o/(o+i)):e.s-r.s+(r.s-t.s)*(i/(o+i)):0},n.transSign=function(t,e,r){ye(n.transLeq(t,e)&&n.transLeq(e,r));var o=e.t-t.t,i=r.t-e.t;return o+i>0?(e.s-r.s)*o+(e.s-t.s)*i:0},n.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},n.interpolate=function(t,e,r,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))},n.intersect=function(t,e,r,o,i){var a,s,l;n.vertLeq(t,e)||(l=t,t=e,e=l),n.vertLeq(r,o)||(l=r,r=o,o=l),n.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),n.vertLeq(r,e)?n.vertLeq(e,o)?(a=n.edgeEval(t,r,e),s=n.edgeEval(r,e,o),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,r.s,s,e.s)):(a=n.edgeSign(t,r,e),s=-n.edgeSign(t,o,e),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,r.s,s,o.s)):i.s=(r.s+e.s)/2,n.transLeq(t,e)||(l=t,t=e,e=l),n.transLeq(r,o)||(l=r,r=o,o=l),n.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),n.transLeq(r,e)?n.transLeq(e,o)?(a=n.transEval(t,r,e),s=n.transEval(r,e,o),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,r.t,s,e.t)):(a=n.transSign(t,r,e),s=-n.transSign(t,o,e),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,r.t,s,o.t)):i.t=(r.t+e.t)/2},n}(),Rs=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return n}(),Nc=function(){function n(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),n}(),ua=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return n}(),pg=function(){function n(){var t=new ua,e=new Rs,r=new Nc(0),o=new Nc(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 n.prototype.makeEdge_=function(t){var e=new Nc(0),r=new Nc(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},n.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},n.prototype.makeVertex_=function(t,e,r){var o=t;ye(o,"Vertex can't be null!");var i=r.prev;o.prev=i,i.next=o,o.next=r,r.prev=o,o.anEdge=e;var a=e;do a.Org=o,a=a.Onext;while(a!==e)},n.prototype.makeFace_=function(t,e,r){var o=t;ye(o,"Face can't be null");var i=r.prev;o.prev=i,i.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)},n.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},n.prototype.killVertex_=function(t,e){var r=t.anEdge,o=r;do o.Org=e,o=o.Onext;while(o!==r);var i=t.prev,a=t.next;a.prev=i,i.next=a},n.prototype.killFace_=function(t,e){var r=t.anEdge,o=r;do o.Lface=e,o=o.Lnext;while(o!==r);var i=t.prev,a=t.next;a.prev=i,i.next=a},n.prototype.makeEdge=function(){var t=new ua,e=new ua,r=new Rs,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},n.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 i=new ua;this.makeVertex_(i,e,t.Org),t.Org.anEdge=t}if(!r){var a=new Rs;this.makeFace_(a,e,t.Lface),t.Lface.anEdge=t}}},n.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var o=new Rs;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)},n.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var o=new ua;return this.makeVertex_(o,r,e.Org),e.Lface=r.Lface=t.Lface,e},n.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},n.prototype.connect=function(t,e){var r=!1,o=this.makeEdge_(t),i=o.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(o,t.Lnext),this.splice_(i,e),o.Org=t.Dst,i.Org=e.Org,o.Lface=i.Lface=t.Lface,t.Lface.anEdge=i,!r){var a=new Rs;this.makeFace_(a,o,t.Lface)}return o},n.prototype.zapFace=function(t){var e=t.anEdge,r,o,i,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)),i=r.Sym,i.Onext===i?this.killVertex_(i.Org,null):(i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(r));while(r!=e);a=t.prev,s=t.next,s.prev=a,a.next=s},n.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},n.prototype.mergeConvexFaces=function(t){var e,r,o,i,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,i=r.Sym,i&&i.Lface&&i.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(i.Lface),s+l-2<=t&&fe.vertCCW(r.Lprev.Org,r.Org,i.Lnext.Lnext.Org)&&fe.vertCCW(i.Lprev.Org,i.Org,r.Lnext.Lnext.Org)&&(o=i.Lnext,this.delete(i),r=null,i=null)),!(r&&r.Lnext.Org===a);)r=o;return!0},n.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,o,i,a,s,l,d;for(i=t,i=t;(o=i.next)!==t;i=o){ye(o.prev===i),l=o.anEdge;do ye(l.Sym!==l),ye(l.Sym.Sym===l),ye(l.Lnext.Onext.Sym===l),ye(l.Onext.Sym.Lnext===l),ye(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(ye(o.prev===i&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){ye(a.prev===s),l=a.anEdge;do ye(l.Sym!==l),ye(l.Sym.Sym===l),ye(l.Lnext.Onext.Sym===l),ye(l.Onext.Sym.Lnext===l),ye(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(ye(a.prev===s&&a.anEdge===null),d=r,d=r;(l=d.next)!==r;d=l)ye(l.Sym.next===d.Sym),ye(l.Sym!==l),ye(l.Sym.Sym===l),ye(l.Org!==null),ye(l.Dst!==null),ye(l.Lnext.Onext.Sym===l),ye(l.Onext.Sym.Lnext===l);ye(l.Sym.next===d.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},n}(),fg=function(){function n(){this.handle=null}return n}(),hg=function(){function n(){this.key=null,this.node=0}return n}(),SC=function(){function n(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new fg,this.handles[r]=new hg;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,o,i,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,ye(a<=this.max),i=e[a].handle,a>this.size||this.leq(r[o].key,r[i].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=i,r[i].node=t,t=a}},n.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,o,i,a;for(o=e[t].handle;;){if(a=t>>1,i=e[a].handle,a===0||this.leq(r[i].key,r[o].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=i,r[i].node=t,t=a}},n.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var o,i;for(i=this.nodes.length,this.nodes.length=this.max+1,o=i;o<this.nodes.length;o++)this.nodes[o]=new fg;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new hg}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},n.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,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},n.prototype.delete=function(t){var e=this.nodes,r=this.handles,o;ye(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},n}(),Vd=function(){function n(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return n}(),mg=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),wC=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new mg,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(t){return this.insertBefore(this.head,t)},n.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},n.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new mg;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},n.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},n}(),_C=function(){function n(){}return n.regionBelow=function(t){return t.nodeUp.prev.key},n.regionAbove=function(t){return t.nodeUp.next.key},n.debugEvent=function(t){},n.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.edgeLeq=function(t,e,r){var o=t.event,i=e.eUp,a=r.eUp;if(i.Dst===o)return a.Dst===o?fe.vertLeq(i.Org,a.Org)?fe.edgeSign(a.Dst,i.Org,a.Org)<=0:fe.edgeSign(i.Dst,a.Org,i.Org)>=0:fe.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return fe.edgeSign(i.Dst,o,i.Org)>=0;var s=fe.edgeEval(i.Dst,o,i.Org),l=fe.edgeEval(a.Dst,o,a.Org);return s>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&ye(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){ye(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},n.topLeftRegion=function(t,e){var r=e.eUp.Org,o;do e=n.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(o=t.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;n.fixUpperEdge(t,e,o),e=n.regionAbove(e)}return e},n.topRightRegion=function(t){var e=t.eUp.Dst;do t=n.regionAbove(t);while(t.eUp.Dst===e);return t},n.addRegionBelow=function(t,e,r){var o=new Vd;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},n.isWindingInside=function(t,e){switch(t.windingRule){case Ee.ODD:return(e&1)!==0;case Ee.NONZERO:return e!==0;case Ee.POSITIVE:return e>0;case Ee.NEGATIVE:return e<0;case Ee.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(t,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(t,e.windingNumber)},n.finishRegion=function(t,e){var r=e.eUp,o=r.Lface;o.inside=e.inside,o.anEdge=r,n.deleteRegion(t,e)},n.finishLeftRegions=function(t,e,r){for(var o,i=null,a=e,s=e.eUp;a!==r;){if(a.fixUpperEdge=!1,i=n.regionBelow(a),o=i.eUp,o.Org!=s.Org){if(!i.fixUpperEdge){n.finishRegion(t,a);break}o=t.mesh.connect(s.Lprev,o.Sym),n.fixUpperEdge(t,i,o)}s.Onext!==o&&(t.mesh.splice(o.Oprev,o),t.mesh.splice(s,o)),n.finishRegion(t,a),s=i.eUp,a=i}return s},n.addRightEdges=function(t,e,r,o,i,a){var s,l,d,c,u=!0;d=r;do ye(fe.vertLeq(d.Org,d.Dst)),n.addRegionBelow(t,e,d.Sym),d=d.Onext;while(d!==o);for(i===null&&(i=n.regionBelow(e).eUp.Rprev),l=e,c=i;s=n.regionBelow(l),d=s.eUp.Sym,d.Org===c.Org;)d.Onext!==c&&(t.mesh.splice(d.Oprev,d),t.mesh.splice(c.Oprev,d)),s.windingNumber=l.windingNumber-d.winding,s.inside=n.isWindingInside(t,s.windingNumber),l.dirty=!0,!u&&n.checkForRightSplice(t,l)&&(n.addWinding(d,c),n.deleteRegion(t,l),t.mesh.delete(c)),u=!1,l=s,c=d;l.dirty=!0,ye(l.windingNumber-d.winding===s.windingNumber),a&&n.walkDirtyRegions(t,l)},n.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},n.vertexWeights=function(t,e,r){var o=fe.vertL1dist(e,t),i=fe.vertL1dist(r,t),a=.5*i/(o+i),s=.5*o/(o+i);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]},n.getIntersectData=function(t,e,r,o,i,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,r,o),n.vertexWeights(e,i,a)},n.checkForRightSplice=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp;if(fe.vertLeq(o.Org,i.Org)){if(fe.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;fe.vertEq(o.Org,i.Org)?o.Org!==i.Org&&(t.pq.delete(o.Org.pqHandle),n.spliceMergeVertices(t,i.Oprev,o)):(t.mesh.splitEdge(i.Sym),t.mesh.splice(o,i.Oprev),e.dirty=r.dirty=!0)}else{if(fe.edgeSign(o.Dst,i.Org,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Oprev,o)}return!0},n.checkForLeftSplice=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp,a;if(ye(!fe.vertEq(o.Dst,i.Dst)),fe.vertLeq(o.Dst,i.Dst)){if(fe.edgeSign(o.Dst,i.Dst,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,a=t.mesh.splitEdge(o),t.mesh.splice(i.Sym,a),a.Lface.inside=e.inside}else{if(fe.edgeSign(i.Dst,o.Dst,i.Org)>0)return!1;e.dirty=r.dirty=!0,a=t.mesh.splitEdge(i),t.mesh.splice(o.Lnext,i.Sym),a.Rface.inside=e.inside}return!0},n.checkForIntersect=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp,a=o.Org,s=i.Org,l=o.Dst,d=i.Dst,c,u,p=new ua,f,h;if(ye(!fe.vertEq(d,l)),ye(fe.edgeSign(l,t.event,a)<=0),ye(fe.edgeSign(d,t.event,s)>=0),ye(a!==t.event&&s!==t.event),ye(!e.fixUpperEdge&&!r.fixUpperEdge),a===s||(c=Math.min(a.t,l.t),u=Math.max(s.t,d.t),c>u))return!1;if(fe.vertLeq(a,s)){if(fe.edgeSign(d,a,s)>0)return!1}else if(fe.edgeSign(l,s,a)<0)return!1;return n.debugEvent(t),fe.intersect(l,a,d,s,p),ye(Math.min(a.t,l.t)<=p.t),ye(p.t<=Math.max(s.t,d.t)),ye(Math.min(d.s,l.s)<=p.s),ye(p.s<=Math.max(s.s,a.s)),fe.vertLeq(p,t.event)&&(p.s=t.event.s,p.t=t.event.t),f=fe.vertLeq(a,s)?a:s,fe.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),fe.vertEq(p,a)||fe.vertEq(p,s)?(n.checkForRightSplice(t,e),!1):!fe.vertEq(l,t.event)&&fe.edgeSign(l,t.event,p)>=0||!fe.vertEq(d,t.event)&&fe.edgeSign(d,t.event,p)<=0?d===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Sym,o),e=n.topLeftRegion(t,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),r),n.addRightEdges(t,e,o.Oprev,o,o,!0),!0):l===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(o.Lnext,i.Oprev),r=e,e=n.topRightRegion(e),h=n.regionBelow(e).eUp.Rprev,r.eUp=i.Oprev,i=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,i.Onext,o.Rprev,h,!0),!0):(fe.edgeSign(l,t.event,p)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),fe.edgeSign(d,t.event,p)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),!1):(t.mesh.splitEdge(o.Sym),t.mesh.splitEdge(i.Sym),t.mesh.splice(i.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=t.pq.insert(o.Org),n.getIntersectData(t,o.Org,a,l,s,d),n.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(t,e){for(var r=n.regionBelow(e),o,i;;){for(;r.dirty;)e=r,r=n.regionBelow(r);if(!e.dirty&&(r=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,i=r.eUp,o.Dst!==i.Dst&&n.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(n.deleteRegion(t,r),t.mesh.delete(i),r=n.regionBelow(e),i=r.eUp):e.fixUpperEdge&&(n.deleteRegion(t,e),t.mesh.delete(o),e=n.regionAbove(r),o=e.eUp)),o.Org!==i.Org)if(o.Dst!==i.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(o.Dst===t.event||i.Dst===t.event)){if(n.checkForIntersect(t,e))return}else n.checkForRightSplice(t,e);o.Org===i.Org&&o.Dst===i.Dst&&(n.addWinding(i,o),n.deleteRegion(t,e),t.mesh.delete(o),e=n.regionAbove(r))}},n.connectRightVertex=function(t,e,r){var o,i=r.Onext,a=n.regionBelow(e),s=e.eUp,l=a.eUp,d=!1;if(s.Dst!==l.Dst&&n.checkForIntersect(t,e),fe.vertEq(s.Org,t.event)&&(t.mesh.splice(i.Oprev,s),e=n.topLeftRegion(t,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),a),d=!0),fe.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(t,a,null),d=!0),d){n.addRightEdges(t,e,r.Onext,i,i,!0);return}fe.vertLeq(l.Org,s.Org)?o=l.Oprev:o=s,o=t.mesh.connect(r.Lprev,o),n.addRightEdges(t,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(t,e)},n.connectLeftDegenerate=function(t,e,r){var o,i,a,s,l;if(o=e.eUp,fe.vertEq(o.Org,r)){ye(!1),n.spliceMergeVertices(t,o,r.anEdge);return}if(!fe.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),n.sweepEvent(t,r);return}ye(!1),e=n.topRightRegion(e),l=n.regionBelow(e),a=l.eUp.Sym,i=s=a.Onext,l.fixUpperEdge&&(ye(i!==a),n.deleteRegion(t,l),t.mesh.delete(a),a=i.Oprev),t.mesh.splice(r.anEdge,a),fe.edgeGoesLeft(i)||(i=null),n.addRightEdges(t,e,a.Onext,s,i,!0)},n.connectLeftVertex=function(t,e){var r,o,i,a,s,l,d=new Vd;if(d.eUp=e.anEdge.Sym,r=t.dict.search(d).key,o=n.regionBelow(r),!!o){if(a=r.eUp,s=o.eUp,fe.edgeSign(a.Dst,e,a.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(i=fe.vertLeq(s.Dst,a.Dst)?r:o,r.inside||i.fixUpperEdge){if(i===r)l=t.mesh.connect(e.anEdge.Sym,a.Lnext);else{var c=t.mesh.connect(s.Dnext,e.anEdge);l=c.Sym}i.fixUpperEdge?n.fixUpperEdge(t,i,l):n.computeWinding(t,n.addRegionBelow(t,r,l)),n.sweepEvent(t,e)}else n.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(t,e){t.event=e,n.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){n.connectLeftVertex(t,e);return}var o=n.topLeftRegion(t,r.activeRegion);ye(o!==null);var i=n.regionBelow(o),a=i.eUp,s=n.finishLeftRegions(t,i,null);s.Onext===a?n.connectRightVertex(t,o,s):n.addRightEdges(t,o,s.Onext,a,a,!0)},n.addSentinel=function(t,e,r,o){var i=new Vd,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=o,a.Dst.s=e,a.Dst.t=o,t.event=a.Dst,i.eUp=a,i.windingNumber=0,i.inside=!1,i.fixUpperEdge=!1,i.sentinel=!0,i.dirty=!1,i.nodeUp=t.dict.insert(i)},n.initEdgeDict=function(t){t.dict=new wC(t,n.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],o=t.bmin[0]-e,i=t.bmax[0]+e,a=t.bmin[1]-r,s=t.bmax[1]+r;n.addSentinel(t,o,i,a),n.addSentinel(t,o,i,s)},n.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(ye(e.fixUpperEdge),ye(++r===1)),ye(e.windingNumber===0),n.deleteRegion(t,e)},n.removeDegenerateEdges=function(t){var e,r,o,i=t.mesh.eHead;for(e=i.next;e!==i;e=r)r=e.next,o=e.Lnext,fe.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.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))},n.initPriorityQ=function(t){var e,r,o,i=0;for(o=t.mesh.vHead,r=o.next;r!==o;r=r.next)i++;for(i+=8,e=t.pq=new SC(i,fe.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)},n.donePriorityQ=function(t){t.pq=null},n.removeDegenerateFaces=function(t,e){var r,o,i;for(r=e.fHead.next;r!==e.fHead;r=o)o=r.next,i=r.anEdge,ye(i.Lnext!==i),i.Lnext.Lnext===i&&(n.addWinding(i.Onext,i),t.mesh.delete(i));return!0},n.computeInterior=function(t,e){e===void 0&&(e=!0);var r,o;if(n.removeDegenerateEdges(t),!n.initPriorityQ(t))return!1;for(n.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;o=t.pq.min(),!(o===null||!fe.vertEq(o,r));)o=t.pq.extractMin(),n.spliceMergeVertices(t,r.anEdge,o.anEdge);n.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,n.debugEvent(t),n.doneEdgeDict(t),n.donePriorityQ(t),n.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},n}(),AC=function(){function n(){this.mesh=new pg,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=Ee.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return n.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},n.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},n.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},n.prototype.computeNormal_=function(t){var e,r,o,i,a,s,l=[0,0,0],d=[0,0,0],c=[0,0,0],u=[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)i=e.coords[y],d[y]=i,h[y]=e,l[y]=i,f[y]=e;for(e=m.next;e!==m;e=e.next)for(var g=0;g<3;++g)i=e.coords[g],i<d[g]&&(d[g]=i,h[g]=e),i>l[g]&&(l[g]=i,f[g]=e);var x=0;if(l[1]-d[1]>l[0]-d[0]&&(x=1),l[2]-d[2]>l[x]-d[x]&&(x=2),d[x]>=l[x]){t[0]=0,t[1]=0,t[2]=1;return}for(s=0,r=h[x],o=f[x],c[0]=r.coords[0]-o.coords[0],c[1]=r.coords[1]-o.coords[1],c[2]=r.coords[2]-o.coords[2],e=m.next;e!==m;e=e.next)u[0]=e.coords[0]-o.coords[0],u[1]=e.coords[1]-o.coords[1],u[2]=e.coords[2]-o.coords[2],p[0]=c[1]*u[2]-c[2]*u[1],p[1]=c[2]*u[0]-c[0]*u[2],p[2]=c[0]*u[1]-c[1]*u[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_(c)]=1)},n.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,o,i=0,a=t.next;a!==t;a=a.next)if(o=a.anEdge,!(o.winding<=0))do i+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==a.anEdge);if(i<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},n.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,o,i=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),i=!0),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);i&&this.checkOrientation_();for(var l=!0,d=t.next;d!==t;d=d.next)l?(this.bmin[0]=this.bmax[0]=d.s,this.bmin[1]=this.bmax[1]=d.t,l=!1):(d.s<this.bmin[0]&&(this.bmin[0]=d.s),d.s>this.bmax[0]&&(this.bmax[0]=d.s),d.t<this.bmin[1]&&(this.bmin[1]=d.t),d.t>this.bmax[1]&&(this.bmax[1]=d.t))},n.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(t,e){var r,o;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;fe.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;fe.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var i=void 0;r.Lnext!==o;)if(fe.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(fe.edgeGoesLeft(o.Lnext)||fe.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)i=t.connect(o.Lnext,o),o=i.Sym;o=o.Lprev}else{for(;o.Lnext!==r&&(fe.edgeGoesRight(r.Lprev)||fe.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)i=t.connect(r,r.Lprev),r=i.Sym;r=r.Lnext}if(o.Lnext===r)throw"Mono region invalid";for(;o.Lnext.Lnext!==r;)i=t.connect(o.Lnext,o),o=i.Sym;return!0},n.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},n.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},n.prototype.setWindingNumber_=function(t,e,r){for(var o,i=t.eHead.next;i!==t.eHead;i=o)o=i.next,i.Rface.inside!==i.Lface.inside?i.winding=i.Lface.inside?e:-e:r?t.delete(i):i.winding=0},n.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},n.prototype.outputPolymesh_=function(t,e,r,o){var i,a=0,s=0,l;r>3&&t.mergeConvexFaces(r);for(var d=t.vHead.next;d!==t.vHead;d=d.next)d.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){i=c.anEdge,l=0;do{var d=i.Org;d.n===-1&&(d.n=s,s++),l++,i=i.Lnext}while(i!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=a,++a}this.elementCount=a,e===st.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 d=t.vHead.next;d!==t.vHead;d=d.next)if(d.n!==-1){var u=d.n*o;this.vertices[u+0]=d.coords[0],this.vertices[u+1]=d.coords[1],o>2&&(this.vertices[u+2]=d.coords[2]),this.vertexIndices[d.n]=d.idx}for(var p=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){i=c.anEdge,l=0;do{var d=i.Org;this.elements[p++]=d.n,l++,i=i.Lnext}while(i!==c.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1;if(e===st.CONNECTED_POLYGONS){i=c.anEdge;do this.elements[p++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==c.anEdge);for(var h=l;h<r;++h)this.elements[p++]=-1}}},n.prototype.outputContours_=function(t,e){var r,o,i=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,d=0,c=0;i=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[d++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==o);this.elements[c++]=i,this.elements[c++]=a,i+=a}},n.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new pg),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},n.prototype.tesselate=function(t,e,r,o,i,a){if(t===void 0&&(t=Ee.ODD),e===void 0&&(e=st.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,i&&(this.normal[0]=i[0],this.normal[1]=i[1],this.normal[2]=i[2]),this.windingRule=t,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),_C.computeInterior(this,a);var s=this.mesh;return e===st.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===st.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,r,o),!0},n}();function qr(n){var t=n.windingRule,e=t===void 0?Ee.ODD:t,r=n.elementType,o=r===void 0?st.POLYGONS:r,i=n.polySize,a=i===void 0?3:i,s=n.vertexSize,l=s===void 0?2:s,d=n.normal,c=d===void 0?[0,0,1]:d,u=n.contours,p=u===void 0?[]:u,f=n.strict,h=f===void 0?!0:f,m=n.debug,y=m===void 0?!1:m;if(!p&&h)throw new Error("Contours can't be empty");if(!!p){var g=new AC;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var x=0;x<p.length;x++)g.addContour(l||2,p[x]);return g.tesselate(e,o,a,l,c,h),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var iF=Ee.ODD,aF=Ee.NONZERO,sF=Ee.POSITIVE,lF=Ee.NEGATIVE,cF=Ee.ABS_GEQ_TWO,uF=st.POLYGONS,dF=st.CONNECTED_POLYGONS,pF=st.BOUNDARY_CONTOURS;var Wr=require("three");var Ec=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*Ec.eSize;this.buffer=new ArrayBuffer(r);let o=Float32Array.BYTES_PER_ELEMENT,i=0;this.positions=new Float32Array(this.buffer,i*o,3*t),i+=3*t,this.normals=new Float32Array(this.buffer,i*o,3*t),i+=3*t,this.uvs=new Float32Array(this.buffer,i*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*Ec.eSize,o=new ArrayBuffer(r),i=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*i,3*t);a+=3*t;let l=new Float32Array(o,a*i,3*t);a+=3*t;let d=new Float32Array(o,a*i,2*t);e?(s.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),d.set(this.uvs.subarray(0,this.size*2))):(s.set(this.positions),l.set(this.normals),d.set(this.uvs)),this.buffer=o,this.positions=s,this.normals=l,this.uvs=d,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)}},Vs=Ec;Vs.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var vg=Qt(xg()),Gs={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},jd={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Ud={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},Fd=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),Sn=class extends Wr.BufferGeometry{constructor(e,r,o=0,i=12,a=3,s=Ee.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=i,this._bevelSegmentsInput=a;let d=this._shape.extractShapePointsToFlatArray([],i),c=this._shape.shapeHoles.map(T=>{let C=T.extractShapePointsToFlatArray([],i),P=[];for(let I=C.length-1;I>=1;I-=2){let D=C[I-1],G=C[I-0];P.push(D,G)}return P}),u=[],p=[];for(let T=0;T<d.length;T+=2)p.push([d[T],d[T+1]]);u.push(p);for(let T=0;T<c.length;T++){let C=c[T],P=[];for(let I=0;I<C.length;I+=2)P.push([C[I],C[I+1]]);u.push(P)}let f;e.isText?f=new Wr.Box2().setFromPoints(e.points.map(C=>C.position)).getSize(new Wr.Vector2).length()*.1:u[0].length===0?f=o:f=(0,vg.default)(u).distance,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=qr({windingRule:s,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[d]})}catch{h=Gs}let m;try{m=qr({windingRule:Ee.ODD,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]})}catch{m=jd}if(!h)throw new Error("error generating geometry");let y=h.elementCount;if(m){h.elementCount+=m.elementCount;for(let T=0;T<m.elements.length;T++){let C=m.elements[T],P=T%2===0?h.vertexCount:0;h.elements.push(C+P)}for(let T=0;T<m.vertexIndices.length;T++){let C=m.vertexIndices[T],P=h.vertexCount;h.vertexIndices.push(C+P)}for(let T=0;T<m.vertices.length;T++){let C=m.vertices[T];h.vertices.push(C)}}let g=1/0,x=-1/0,S=1/0,w=-1/0;for(let T=0,C=h.vertexCount;T<C;T++){let P=T*2,I=h.vertices[P+0],D=h.vertices[P+1];I<g&&(g=I),I>x&&(x=I),D<S&&(S=D),D>w&&(w=D)}this._minX=g,this._minY=S,this._width=x-g,this._height=w-S,this._buffer=new Vs(this._computeBufferEstimatedSize(h));let b=[],_=[];for(let T=h.elementCount-1;T>=0;T--){let C=T>=y,P=T*2,I=h.elements[P+0],D=h.elements[P+1],G=I+D,N={start:I,count:D,normals:[],continuous:[],concave:[]},F=I,B=G-1,R=I+1,V=this._shape.roundedCurves.length;do{let X=F-I,k=h.vertices[B*2+0],W=h.vertices[B*2+1],U=h.vertices[F*2+0],z=h.vertices[F*2+1],ne=h.vertices[R*2+0],ee=h.vertices[R*2+1],Q=U-k,te=z-W,Z=Math.sqrt(Q*Q+te*te);Q/=Z,te/=Z;let le=U-ne,ie=z-ee,ae=Math.sqrt(le*le+ie*ie);le/=ae,ie/=ae,N.normals[X*2+0]=-ie,N.normals[X*2+1]=le,N.concave[X]=Q*ie-te*le>0;let de=h.vertexIndices[F];if(Array.isArray(de))N.continuous[X]=!1;else{let[ce,pe]=this._shape.getCurveIndexFromVertexId(de-1,!0);if(pe>0&&pe<1)N.continuous[X]=!0;else{let xe=pe===1?ce+1:ce-1;xe=(xe+V)%V;let De=pe===1?0:1,tt=this._shape.roundedCurves[ce].getTangent(pe),Le=this._shape.roundedCurves[xe].getTangent(De);N.continuous[X]=tt.dot(Le)>.95}}C&&(N.normals[X*2+0]*=-1,N.normals[X*2+1]*=-1),[B,F,R]=[F,R,R+1],R>=G&&(R-=D)}while(R!==I+1);let q=[];q.push({bevelI:0,angle:0,size:0,boundary:{vertices:h.vertices.slice(I*2,G*2),vertexCount:D,vertexIndices:new Array(D).fill(!0).map((X,k)=>[k,k]),elements:[0,D],elementCount:1,mesh:null},reverseMap:[],insetPoints:h.vertices.slice(I*2,G*2)});let Y=0;for(let X=1;X<=this._bevelSegments;X++){let k=X/this._bevelSegments*Math.PI/2,W=(1-Math.cos(k))*this._bevel,U=[],z=[],ne=[],ee=[],Q=0;for(let Z=0;Z<D;Z++){let le=Z*2,ie=(Z-1+D)%D*2,ae=h.vertices[N.start*2+le+0],de=h.vertices[N.start*2+le+1],ce=-N.normals[ie+0]*W,pe=-N.normals[ie+1]*W,xe=-N.normals[le+0]*W,De=-N.normals[le+1]*W;if(N.concave[Z]||!N.concave[Z]&&C){let tt=Math.atan2(pe,ce),Le=Math.atan2(De,xe);Le>tt&&(Le-=Math.PI*2);let We=Le-tt;if(N.continuous[Z]||C){let nr=tt+We/2,Te=Math.cos(nr)*W,At=Math.sin(nr)*W;U[2*Q+0]=ae+Te*(C?-1:1),U[2*Q+1]=de+At*(C?-1:1),ee[Q]=Z,Q++}else{let nr=Math.max(1,Math.floor(i/4*Math.abs(We)/Math.PI));for(let Te=0;Te<=nr;Te++){let At=tt+We*(Te/nr),It=Math.cos(At)*W,mi=Math.sin(At)*W;U[2*Q+0]=ae+It,U[2*Q+1]=de+mi,ee[Q]=Z,Q++}}}else U[2*Q+0]=ae+ce,U[2*Q+1]=de+pe,ee[Q]=Z,z[Z]=Q,Q++,U[2*Q+0]=ae,U[2*Q+1]=de,ee[Q]=Z,Q++,U[2*Q+0]=ae+xe,U[2*Q+1]=de+De,ee[Q]=Z,ne[Z]=Q,Q++}let te=qr({windingRule:Ee.POSITIVE,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[U],edgeCreateCallback:Z=>{let ie=Z.Org.idx,ae=ee[ie],de=ee[(ie+1)%ee.length];Z.idx=[ae,de],Z.Sym.idx=[de,ae]},vertexIdCallback:Z=>{let le=Z.Lprev.idx;return[le?le[1]:0,Z.idx?Z.idx[0]:0]}});if(!te)throw console.log("Error"),new Error(`error generating bevel geometry for ${X}'th loop`);if(!te.vertexCount){let Z=(X-1)/this._bevelSegments*Math.PI/2;Y=(1-Math.sin(Z))*this._bevel;break}for(let Z=0;Z<te.vertexIndices.length;Z++){let[le,ie]=te.vertexIndices[Z];if(le===ie)continue;let ae=ie;ie<le&&(ae+=D);for(let de=le;de<ae;de++){let ce=de%D,pe=(de+1)%D;if(!N.continuous[ce]||!N.continuous[pe]){te.vertexIndices[Z]=[le,ce],te.vertexIndices.splice(Z+1,0,[pe,ie]),te.vertices.splice((Z+1)*2,0,te.vertices[Z*2],te.vertices[Z*2+1]);break}}}q.push({bevelI:X,angle:k,size:W,boundary:te,reverseMap:ee,insetPoints:U})}let $=(X,k,W)=>{let U=0,z=X.boundary.vertexIndices.length;for(;U<z&&W(X.boundary.vertexIndices[k]);)k=(k+1)%z,U++;return U},H=b.length;for(let X=1;X<q.length;X++){let k=q[X-1],W=q[X],U=k.boundary.vertexIndices.length,z=W.boundary.vertexIndices.length;if(!U||!z)break;let ne=N.concave.length,ee=0,Q=Fd(ee,D);for(;!k.boundary.vertexIndices.filter(Q).length||!W.boundary.vertexIndices.filter(Q).length;)ee++,Q=Fd(ee,D);let te=k.boundary.vertexIndices.findIndex(Q),Z=W.boundary.vertexIndices.findIndex(Q);do te=(te+1)%U;while(Q(k.boundary.vertexIndices[te]));do Z=(Z+1)%z;while(Q(W.boundary.vertexIndices[Z]));ee=(ee+1)%D;let le=ee,ie=0,ae=this._buildBevelVert(N,k,(te-1+U)%U,void 0,ie),de=this._buildBevelVert(N,W,(Z-1+z)%z,void 0,ie),ce=ae,pe=de,xe,De,tt=!1;do{ie=(ee||ne)/ne,Q=Fd(ee,D);let Le=$(k,te,Q),We=$(W,Z,Q),nr=tt;if(tt=!1,Le&&!We){for(let Te=0;Te<Le;Te++)xe=this._buildBevelVert(N,k,(te+Te)%U,Te/(Le-1),ie),b.push(ce.topN,xe.topP,pe.topN),l===!1&&b.push(xe.bottomP,ce.bottomN,pe.bottomN),ce=xe;tt=!0}else if(!Le&&We)for(let Te=0;Te<We;Te++)De=this._buildBevelVert(N,W,(Z+Te)%z,Te/(We-1),ie),b.push(pe.topN,ce.topP,De.topP),l===!1&&b.push(ce.bottomP,pe.bottomN,De.bottomP),pe=De;else if(Le&&We)if(xe=this._buildBevelVert(N,k,te,0,ie),De=this._buildBevelVert(N,W,Z,0,ie),nr?(b.push(ce.topN,De.topP,pe.topN),b.push(ce.topN,xe.topP,De.topP),l===!1&&(b.push(De.bottomP,ce.bottomN,pe.bottomN),b.push(De.bottomP,xe.bottomP,ce.bottomN))):(b.push(pe.topN,ce.topN,xe.topP),b.push(pe.topN,xe.topP,De.topP),l===!1&&(b.push(xe.bottomP,ce.bottomN,pe.bottomN),b.push(xe.bottomP,pe.bottomN,De.bottomP))),ce=xe,pe=De,Le===We)for(let Te=1;Te<Le;Te++)xe=this._buildBevelVert(N,k,(te+Te)%U,Te/(Le-1),ie),De=this._buildBevelVert(N,W,(Z+Te)%z,Te/(We-1),ie),b.push(ce.topN,xe.topP,pe.topN),b.push(pe.topN,xe.topP,De.topP),l===!1&&(b.push(xe.bottomP,ce.bottomN,pe.bottomN),b.push(xe.bottomP,pe.bottomN,De.bottomP)),ce=xe,pe=De;else if(Le>We){let Te=Le/We,At=0;for(let It=1;It<Le;It++)xe=this._buildBevelVert(N,k,(te+It)%U,It/(Le-1),ie),b.push(ce.topN,xe.topP,pe.topN),l===!1&&b.push(xe.bottomP,ce.bottomN,pe.bottomN),ce=xe,It>(At+1)*Te&&(At++,De=this._buildBevelVert(N,W,(Z+At)%z,At/(We-1),ie),b.push(pe.topN,xe.topP,De.topP),l===!1&&b.push(xe.bottomP,pe.bottomN,De.bottomP),pe=De)}else{let Te=We/Le,At=0;for(let It=1;It<We;It++)De=this._buildBevelVert(N,W,(Z+It)%z,It/(We-1),ie),b.push(pe.topN,xe.topP,De.topP),l===!1&&b.push(xe.bottomP,pe.bottomN,De.bottomP),pe=De,It>(At+1)*Te&&(At++,xe=this._buildBevelVert(N,k,(te+At)%U,At/(Le-1),ie),b.push(ce.topN,xe.topP,pe.topN),l===!1&&b.push(xe.bottomP,ce.bottomN,pe.bottomN),ce=xe)}te=(te+Le)%U,Z=(Z+We)%z,ee=(ee+1)%ne}while(ee!==le)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(q,N,b),C){let X=[];for(let k=b.length-1;k>=H+2;k-=3){let W=b[k-2],U=b[k-1],z=b[k-0];X.push(z,U,W)}b.splice(H,b.length-H,...X)}if(C){let X=[];for(let k=q[q.length-1].boundary.vertices.length-1;k>=1;k-=2){let W=q[q.length-1].boundary.vertices[k-1],U=q[q.length-1].boundary.vertices[k-0];X.push(W,U)}_.push(X)}if(!C){let X=q[q.length-1],k;try{k=qr({windingRule:q.length>1?Ee.POSITIVE:Ee.ODD,elementType:st.POLYGONS,vertexSize:2,strict:!0,contours:[X.insetPoints,..._]})}catch{k=Ud}if(!k)throw new Error("Error generating geometry for surface");c.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let W=0;W<k.elementCount*3;W+=3){let U=this._buildSurfaceVert(k,k.elements[W+0],Y),z=this._buildSurfaceVert(k,k.elements[W+1],Y),ne=this._buildSurfaceVert(k,k.elements[W+2],Y);b.push(U.top,z.top,ne.top),l===!1&&b.push(ne.bottom,z.bottom,U.bottom)}}this.vertexCache={}}this._buffer.shrink();let A=new Wr.BufferAttribute(Uint32Array.from(b),1),v=new Wr.BufferAttribute(this._buffer.positions,3),M=new Wr.BufferAttribute(this._buffer.normals,3),O=new Wr.BufferAttribute(this._buffer.uvs,2);v.needsUpdate=!0,M.needsUpdate=!0,O.needsUpdate=!0,A.needsUpdate=!0,this.setAttribute("position",v),this.setAttribute("normal",M),this.setAttribute("uv",O),this.setIndex(A)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,i,a),d=this._buildBevelVert(r,i,(a+1)%s);o.push(d.topP,l.topN,l.bottomN),o.push(d.topP,l.bottomN,d.bottomP)}}_buildSurfaceVert(e,r,o){let i=r.toString();if(i in this.vertexCache)return this.vertexCache[i];let a=e.vertices[r*2+0],s=e.vertices[r*2+1],l=(a-this._minX)/this._width,d=(s-this._minY)/this._height;this.forPathBevel&&(d=1);let c=this._buffer.get(this.forPathBevel?1:2),u=c*3,p=c*2,f={top:c+0,bottom:c+1};return this._buffer.positions[u+0]=a,this._buffer.positions[u+1]=s,this._buffer.positions[u+2]=this.forPathBevel?this._bevel:this._depth-o,this._buffer.normals[u+0]=0,this._buffer.normals[u+1]=0,this._buffer.normals[u+2]=1,this._buffer.uvs[p+0]=l,this._buffer.uvs[p+1]=d,this.forPathBevel===!1&&(this._buffer.positions[u+3]=a,this._buffer.positions[u+4]=s,this._buffer.positions[u+5]=o,this._buffer.normals[u+3]=0,this._buffer.normals[u+4]=0,this._buffer.normals[u+5]=-1,this._buffer.uvs[p+2]=l,this._buffer.uvs[p+3]=d),this.vertexCache[i]=f,f}_buildBevelVert(e,r,o,i=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,d]=r.boundary.vertexIndices[o],c,u,p,f;l!==d?(u=l,c=d,f=!1,p=e.continuous[u]&&e.continuous[c]):(c=l,u=(c-1+e.count)%e.count,f=e.concave[c]&&r.bevelI>0,p=e.continuous[c]||f);let h=Math.cos(r.angle),m=Math.sin(r.angle),y=o*2,g=c*2,x=u*2,S=r.boundary.vertices[y+0],w=r.boundary.vertices[y+1],b=(1-m)*this._bevel,_=(S-this._minX)/this._width,A=(w-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(_=a),A=1);let v=e.normals[g+0],M=e.normals[g+1],O=e.normals[x+0],T=e.normals[x+1];if(f){let G=O-v,N=T-M;v=v+G*(1-i),M=M+N*(1-i);let F=Math.sqrt(v*v+M*M);v/=F,M/=F}let C=this.forPathBevel?this._buffer.get(p?1:2):this._buffer.get(p?2:4),P=C*3,I=C*2,D={i:o,fi:c,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1,pathBevelUCoord:a};return this._buffer.positions[P+0]=S,this._buffer.positions[P+1]=w,this._buffer.positions[P+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[P+0]=v*h,this._buffer.normals[P+1]=M*h,this._buffer.normals[P+2]=m,this._buffer.uvs[I+0]=_,this._buffer.uvs[I+1]=A,this.forPathBevel===!1&&(this._buffer.positions[P+3]=S,this._buffer.positions[P+4]=w,this._buffer.positions[P+5]=b,this._buffer.normals[P+3]=v*h,this._buffer.normals[P+4]=M*h,this._buffer.normals[P+5]=-m,this._buffer.uvs[I+2]=A,this._buffer.uvs[I+3]=_),p||(this.forPathBevel?(C+=1,P+=3,I+=2):(C+=2,P+=6,I+=4),D.topP=C+0,D.bottomP=C+1,this._buffer.positions[P+0]=S,this._buffer.positions[P+1]=w,this._buffer.positions[P+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[P+0]=O*h,this._buffer.normals[P+1]=T*h,this._buffer.normals[P+2]=m,this._buffer.uvs[I+0]=_,this._buffer.uvs[I+1]=A,this.forPathBevel===!1&&(this._buffer.positions[P+3]=S,this._buffer.positions[P+4]=w,this._buffer.positions[P+5]=b,this._buffer.normals[P+3]=O*h,this._buffer.normals[P+4]=T*h,this._buffer.normals[P+5]=-m,this._buffer.uvs[I+2]=A,this._buffer.uvs[I+3]=_)),this.vertexCache[s]=D,D}clone(){let e=new Sn(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Bo(this.userData),e}};var da=class extends Xn.BufferGeometry{constructor(e,r=12,o={}){super();this.type="ShapeGeometry";this.windingRule=Ee.ODD;this.elementType=st.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:Ee.ODD,elementType:st.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let i=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(h=>h.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,d=!0,c,u;for(let h=0,m=i.length/2;h<m;h++){let y=h*2,g=i[y+0],x=i[y+1];if(c!==void 0&&g!==c&&(l=!1),u!==void 0&&x!==u&&(d=!1),c=g,u=x,!l&&!d)break}if(!l&&!d)try{s=qr({contours:[i,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=Gs}let p=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new Xn.BufferAttribute(new Float32Array(p*3),3),this._normalAttribute=new Xn.BufferAttribute(new Float32Array(p*3),3),this._uvAttribute=new Xn.BufferAttribute(new Float32Array(p*2),2),this._indexAttribute=new Xn.BufferAttribute(new Uint32Array(f*3),1),s){let h=1/0,m=-1/0,y=1/0,g=-1/0;for(let w=0,b=p;w<b;w++){let _=w*2,A=s.vertices[_+0],v=s.vertices[_+1];A<h&&(h=A),A>m&&(m=A),v<y&&(y=v),v>g&&(g=v)}let x=m-h,S=g-y;for(let w=0,b=p;w<b;w++){let _=w*2,A=s.vertices[_+0],v=s.vertices[_+1],M=(A-h)/x,O=(v-y)/S;this._positionAttribute.setXYZ(w,A,v,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,M,O)}for(let w=0,b=f;w<b;w++){let _=w*3,A=s.elements[_+0],v=s.elements[_+1],M=s.elements[_+2];this._indexAttribute.setX(_+0,A),this._indexAttribute.setX(_+1,v),this._indexAttribute.setX(_+2,M)}}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=Bo(this.userData),e}};var pa=class extends Sn{constructor(e,r,o=0,i=12,a=3,s=Ee.ODD){super(e,r,o,i,a,s);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,i,a),d=this._buildBevelVert(r,i,(a+1)%s);o.push(d.topP,l.topN,l.bottomN),o.push(d.topP,l.bottomN,d.bottomP)}}clone(){let e=new pa(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Bo(this.userData),e}};var dr=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Ee.ODD},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=n.shape??t?.shape,s=a?.roundness??e.roundness;a!==void 0&&(a instanceof Re?(a.width!==r||a.height!==o)&&a.applySize(r,o):a=new Re(r,o).fromJSON(a),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&a.update());let l=a??new Re(r,o);return{parameters:Object.assign(e,{width:r,height:o,depth:i,roundness:s}),shape:l}}static build(n){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:o,roundness:i,windingRule:a}=n.parameters;n.shape.roundness=i;let s;return t<=0?s=new da(n.shape,o,{windingRule:a}):s=new pa(n.shape,t,e,o,r,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};var $r=require("three"),Sg=Math.PI*2,ha=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return e.angle=$r.MathUtils.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof Re?n.shape:new Re,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,angle:o,innerRadius:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,d=n.shape,c=t*.5,u=e*.5,p=MC(d,c,u,o*Math.PI/180,r,i);d.isClosed=!0,d.update();let f;return o===0?(f=new $r.BufferGeometry,f.setAttribute("position",new $r.Float32BufferAttribute([],3))):f=dr.create({shape:d,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function MC(n,t,e,r,o,i){if(r>=Sg)return o>30||o%4===0?(NC(n,t,e,i),Math.round(o/4)):bg(n,r,o,t,e,i);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},d=dg({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%d.length===0?IC(n,a.x,a.y,d,o,t,e,i):bg(n,r,o,t,e,i)}function IC(n,t,e,r,o,i,a,s){let l=Math.round(o/r.length);n.addPoint(fa(t,e));for(let d=0,c=r.length;d<c;d++){let u=r[d],p=n.points[d],f=fa(u.x,u.y);p.controls[1].position.set(u.x1,u.y1),f.controls[0].position.set(u.x2,u.y2),n.addPoint(f)}return s>0?wg(n,i,a,s):n.addPoint(fa(0,0)),l}function bg(n,t,e,r,o,i){let a=-t/e;for(let s=0;s<=e;s++){let l=a*s,d=Math.sin(l)*r,c=Math.cos(l)*o;n.addPoint(fa(d,c))}return t<Sg?i>0?wg(n,r,o,i):n.addPoint(fa(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&_g(n,r,o,i)),1}function NC(n,t,e,r=0,o=0,i=0){let a=.5522847498,s=t*a,l=e*a;n.addPoint(Lc(o-t,i,o-t,i-l,o-t,i+l)),n.addPoint(Lc(o,i+e,o-s,i+e,o+s,i+e)),n.addPoint(Lc(o+t,i,o+t,i+l,o+t,i-l)),n.addPoint(Lc(o,i-e,o+s,i-e,o-s,i-e)),r>0&&_g(n,t,e,r)}function fa(n,t){return new Hr($r.MathUtils.generateUUID(),new $r.Vector2(n,t))}function Lc(n,t,e,r,o,i){let a=fa(n,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(o,i),a}function wg(n,t,e,r){Ag(n,t,e,r).forEach(i=>n.addPoint(i))}function _g(n,t,e,r){let o=Ag(n,t,e,r),i=new Re;o.forEach(a=>i.addPoint(a)),i.isClosed=!0,n.shapeHoles.push(i)}function Ag(n,t,e,r){let o=r*t/100,i=o*(Math.abs(e)/Math.abs(t)),a=new $r.Vector2(o/t,i/e),s=n.points.map(l=>{let d=l.clone();return d.uuid=$r.MathUtils.generateUUID(),d}).reverse();return s.forEach(l=>{l.position.multiply(a);let d=l.controls[0].position.clone().multiply(a),c=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(c),l.controls[1].position.copy(d)}),s}var Yr=require("three"),Tg=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??r),i=Math.abs(e.depth??r),a=Math.abs(Math.min(r,i))/2;return{parameters:Object.assign(e,{width:r,height:o,depth:i,radius:a,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:t,height:e,depth:r,radius:o,revolutions:i,segments:a,pathRadius:s,pathType:l,pathSegments:d,cornerRadius:c,cornerSegments:u}=n.parameters,p=new zs(!1,t,e,r,o,i,a,s,l,d,c,u);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},Hd=new Yr.Uint32BufferAttribute([0,0,0],1),zs=class extends Yr.BufferGeometry{constructor(t=!0,e=1,r=1,o=1,i=1,a=1,s=1,l=1,d=1,c=1,u=1,p=1){if(super(),a===0)return;let f=t&&a===1;f&&(p=0),u>100&&(u=100),u===0&&(p=0);let h=()=>new Yr.Vector3,m=new Yr.Vector3,y=h(),g=h(),x=h(),S,w,b,_,A,v,M,O,T=h(),C=h(),P=h(),I=h(),D=h(),G=h(),N=h(),F=h(),B=r-2*l+.001,R=B/a,V=Math.ceil(s*a),q=V+1,Y=B/V,$=-B/2,H=c+1,X=2*Math.PI/c,k=Math.PI/2/p,W=.01,U=Math.min((1-u/100)*l,l-W),z=l-U,ne=0,ee=2,Q=p*ee+ee,te=H*Q/ee,Z=te+H*q,le=Math.max(0,H*(q+Q)),[ie,ae,de]=[3,3,2].map(yt=>Array(le*yt).fill(0)),ce=[],pe=i-l;function xe(yt,br){let ro=Math.PI/2;v=br*Y,O=2*Math.PI*(v%R)/R+ro,v+=$,M=Math.sin(O)*pe,A=Math.cos(O)*pe,t?yt.set(A,M,v):yt.set(A,v,M)}xe(m,-1e-10),xe(y,0),T.copy(m),xe(m,1);let De=m.distanceTo(y),tt=f?0:z+U,Le=De*V+2*tt,We=U,nr=Le-tt;for(let yt=0;yt<=V;yt++){xe(g,yt),F.subVectors(g,T).normalize(),T.copy(g),G.copy(g).setComponent(+t+1,0).normalize(),N.crossVectors(F,G).normalize();let br=yt===0,ro=yt===V,_v=br?3*Math.PI/2:k,Av=br?We:nr,Tv=br?H:Z,Cv=br?0:le-H,Pv=F.clone().multiplyScalar(br?-z:z).add(g),Ov=F.clone().multiplyScalar(br?-1:1).normalize();for(let Io=0;Io<H;Io++){let Qp=Io*X;if(C.addVectors(m.copy(G).multiplyScalar(l*Math.cos(Qp)),y.copy(N).multiplyScalar(l*Math.sin(Qp))),P.copy(C).normalize(),br||ro){f||(ne=Cv+Io,[0,1,2].forEach(ir=>{ie[ne*3+ir]=Pv.getComponent(ir),ae[ne*3+ir]=Ov.getComponent(ir)}),de[ne*2]=+ro,de[ne*2+1]=Io/c),y.copy(P).multiplyScalar(U),x.addVectors(g,y);for(let ir=0;ir<p;ir++){let Ru=ir*k+_v;I.addVectors(m.copy(F).multiplyScalar(z*Math.sin(Ru)),y.copy(P).multiplyScalar(z*Math.cos(Ru))),D.copy(I).normalize(),y.addVectors(x,I),I.normalize(),ne=Tv+ir*H+Io,[0,1,2].forEach(xl=>{ie[ne*3+xl]=y.getComponent(xl),ae[ne*3+xl]=D.getComponent(xl)});let Mv=+br+Math.sin(Ru);de[ne*2]=(Av+z*Mv)/Le,de[ne*2+1]=Io/c}}y.addVectors(g,C),ne=te+yt*H+Io,[0,1,2].forEach(ir=>{ie[ne*3+ir]=y.getComponent(ir),ae[ne*3+ir]=P.getComponent(ir)}),de[ne*2]=(tt+yt*De)/Le,de[ne*2+1]=Io/c}}let Te=q+2*p+ee,At=1,[It,mi]=[+f,Te-1];for(let yt=It;yt<=mi-1;yt++){let br=f&&yt===mi-1;for(let ro=0;ro<H-1;ro++)S=yt*H+ro,w=S+1,b=(br?ro:S)+H,_=(br?ro+1:w)+H,yt===0?ce.push(w,_,b):yt===Te-2?ce.push(S,w,b):ce.push(S,w,b,w,_,b)}this.setIndex(ce),this.setAttribute("position",new Yr.Float32BufferAttribute(ie,3)),this.setAttribute("normal",new Yr.Float32BufferAttribute(ae,3)),this.setAttribute("uv",new Yr.Float32BufferAttribute(de,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,o=Array.from(this.getIndex().array),i,a,s,l,d=6*(e-1)*t.radialSegments,c=e,u=c===e;for(let p=0;p<t.radialSegments;p++)i=c*r+p,a=i+1,s=(u?p:i)+r,l=(u?p+1:a)+r,o[d++]=i,o[d++]=a,o[d++]=s,o[d++]=a,o[d++]=l,o[d++]=s;return o.length=d,Hd.array=o,Hd.count=o.length,Hd}};var Cg=require("three");var Pg=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new ks(t*.5,i,a):new Cg.IcosahedronGeometry(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},ks=class extends xn{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,i=[-1,o,0,1,o,0,-1,-o,0,1,-o,0,0,-1,o,0,1,o,0,-1,-o,0,1,-o,o,0,-1,o,0,1,-o,0,-1,-o,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],s="IcosahedronGeometry";super(i,a,s,t,e,r),this.type=s}static fromJSON(t){return new ks(t.radius,t.corner,t.cornerSides)}};var Bc=require("three"),Og=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){(n.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}]},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{points:t,segments:e,verticalSegments:r}=n.parameters,o=new Bc.Shape;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 i=new Bc.LatheGeometry(o.extractPoints(r).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};var yo=require("three");var jo=require("three");var oe=require("three"),mo=new oe.Matrix4,qd=new oe.Object3D,Rc=new oe.Vector3,wn=class extends oe.EventDispatcher{constructor(){super(),this.uuid=oe.MathUtils.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new oe.Matrix3().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 i=this.faces[r];i.normal.applyMatrix3(e).normalize();for(let a=0,s=i.vertexNormals.length;a<s;a++)i.vertexNormals[a].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return mo.makeRotationX(t),this.applyMatrix4(mo),this}rotateY(t){return mo.makeRotationY(t),this.applyMatrix4(mo),this}rotateZ(t){return mo.makeRotationZ(t),this.applyMatrix4(mo),this}translate(t,e,r){return mo.makeTranslation(t,e,r),this.applyMatrix4(mo),this}scale(t,e,r){return mo.makeScale(t,e,r),this.applyMatrix4(mo),this}lookAt(t){return qd.lookAt(t),qd.updateMatrix(),this.applyMatrix4(qd.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 i=o.position,a=o.normal,s=o.color,l=o.uv,d=o.uv2;d!==void 0&&(this.faceVertexUvs[1]=[]);for(let p=0;p<i.count;p++)e.vertices.push(new oe.Vector3().fromBufferAttribute(i,p)),s!==void 0&&e.colors.push(new oe.Color().fromBufferAttribute(s,p));function c(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 oe.Vector3().fromBufferAttribute(a,p),new oe.Vector3().fromBufferAttribute(a,f),new oe.Vector3().fromBufferAttribute(a,h)],x=new ma(p,f,h,g,y,m);e.faces.push(x),l!==void 0&&e.faceVertexUvs[0].push([new oe.Vector2().fromBufferAttribute(l,p),new oe.Vector2().fromBufferAttribute(l,f),new oe.Vector2().fromBufferAttribute(l,h)]),d!==void 0&&e.faceVertexUvs[1].push([new oe.Vector2().fromBufferAttribute(d,p),new oe.Vector2().fromBufferAttribute(d,f),new oe.Vector2().fromBufferAttribute(d,h)])}let u=t.groups;if(u.length>0)for(let p=0;p<u.length;p++){let f=u[p],h=f.start,m=f.count;for(let y=h,g=h+m;y<g;y+=3)r!==void 0?c(r.getX(y),r.getX(y+1),r.getX(y+2),f.materialIndex):c(y,y+1,y+2,f.materialIndex)}else if(r!==void 0)for(let p=0;p<r.count;p+=3)c(r.getX(p),r.getX(p+1),r.getX(p+2));else for(let p=0;p<i.count;p+=3)c(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(Rc).negate(),this.translate(Rc.x,Rc.y,Rc.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,o=new oe.Matrix4;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 oe.Vector3,e=new oe.Vector3;for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r],a=this.vertices[i.a],s=this.vertices[i.b],l=this.vertices[i.c];t.subVectors(l,s),e.subVectors(a,s),t.cross(e),t.normalize(),i.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 oe.Vector3;if(t){let r=new oe.Vector3,o=new oe.Vector3;for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=this.vertices[s.a],d=this.vertices[s.b],c=this.vertices[s.c];r.subVectors(c,d),o.subVectors(l,d),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 i=this.faces[r];e[i.a].add(i.normal),e[i.b].add(i.normal),e[i.c].add(i.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 i=this.faces[r],a=i.vertexNormals;a.length===3?(a[0].copy(e[i.a]),a[1].copy(e[i.b]),a[2].copy(e[i.c])):(a[0]=e[i.a].clone(),a[1]=e[i.b].clone(),a[2]=e[i.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let 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 i=0,a=o.vertexNormals.length;i<a;i++)o.__originalVertexNormals[i]?o.__originalVertexNormals[i].copy(o.vertexNormals[i]):o.__originalVertexNormals[i]=o.vertexNormals[i].clone()}let t=new wn;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 i=this.morphNormals[e].faceNormals,a=this.morphNormals[e].vertexNormals;for(let s=0,l=this.faces.length;s<l;s++){let d=new oe.Vector3,c={a:new oe.Vector3,b:new oe.Vector3,c:new oe.Vector3};i.push(d),a.push(c)}}let o=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=o.faceNormals[i],d=o.vertexNormals[i];l.copy(s.normal),d.a.copy(s.vertexNormals[0]),d.b.copy(s.vertexNormals[1]),d.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 oe.Box3),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new oe.Sphere),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,i=this.vertices.length,a=this.vertices,s=t.vertices,l=this.faces,d=t.faces,c=this.colors,u=t.colors;e!==void 0&&(o=new oe.Matrix3().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=u.length;p<f;p++)c.push(u[p].clone());for(let p=0,f=d.length;p<f;p++){let h=d[p],m,y,g=h.vertexNormals,x=h.vertexColors,S=new ma(h.a+i,h.b+i,h.c+i);S.normal.copy(h.normal),o!==void 0&&S.normal.applyMatrix3(o).normalize();for(let w=0,b=g.length;w<b;w++)m=g[w].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),S.vertexNormals.push(m);S.color.copy(h.color);for(let w=0,b=x.length;w<b;w++)y=x[w],S.vertexColors.push(y.clone());S.materialIndex=h.materialIndex+r,l.push(S)}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],x=[];for(let S=0,w=g.length;S<w;S++)x.push(g[S].clone());this.faceVertexUvs[p].push(x)}}}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=[],i=Math.pow(10,t);for(let l=0,d=this.vertices.length;l<d;l++){let c=this.vertices[l],u=Math.round(c.x*i)+"_"+Math.round(c.y*i)+"_"+Math.round(c.z*i);e[u]===void 0?(e[u]=l,r.push(this.vertices[l]),o[l]=r.length-1):o[l]=o[e[u]]}let a=[];for(let l=0,d=this.faces.length;l<d;l++){let c=this.faces[l];c.a=o[c.a],c.b=o[c.b],c.c=o[c.c];let u=[c.a,c.b,c.c];for(let p=0;p<3;p++)if(u[p]===u[(p+1)%3]){a.push(l);break}}for(let l=a.length-1;l>=0;l--){let d=a[l];this.faces.splice(d,1);for(let c=0,u=this.faceVertexUvs.length;c<u;c++)this.faceVertexUvs[c].splice(d,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 oe.Vector3(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,d){return l.materialIndex-d.materialIndex}t.sort(r);let o=this.faceVertexUvs[0],i=this.faceVertexUvs[1],a,s;o&&o.length===e&&(a=[]),i&&i.length===e&&(s=[]);for(let l=0;l<e;l++){let d=t[l]._id;a&&a.push(o[d]),s&&s.push(i[d])}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=[],i={},a=[],s={},l=[],d={};for(let h=0;h<this.faces.length;h++){let m=this.faces[h],y=!0,g=!1,x=this.faceVertexUvs[0][h]!==void 0,S=m.normal.length()>0,w=m.vertexNormals.length>0,b=m.color.r!==1||m.color.g!==1||m.color.b!==1,_=m.vertexColors.length>0,A=0;if(A=c(A,0,0),A=c(A,1,y),A=c(A,2,g),A=c(A,3,x),A=c(A,4,S),A=c(A,5,w),A=c(A,6,b),A=c(A,7,_),r.push(A),r.push(m.a,m.b,m.c),r.push(m.materialIndex),x){let v=this.faceVertexUvs[0][h];r.push(f(v[0]),f(v[1]),f(v[2]))}if(S&&r.push(u(m.normal)),w){let v=m.vertexNormals;r.push(u(v[0]),u(v[1]),u(v[2]))}if(b&&r.push(p(m.color)),_){let v=m.vertexColors;r.push(p(v[0]),p(v[1]),p(v[2]))}}function c(h,m,y){return y?h|1<<m:h&~(1<<m)}function u(h){let m=h.x.toString()+h.y.toString()+h.z.toString();return i[m]!==void 0||(i[m]=o.length/3,o.push(h.x,h.y,h.z)),i[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 d[m]!==void 0||(d[m]=l.length/2,l.push(h.x,h.y)),d[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 wn().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],x=[];for(let S=0,w=g.length;S<w;S++){let b=g[S];x.push(b.clone())}this.faceVertexUvs[p].push(x)}}let i=t.morphTargets;for(let p=0,f=i.length;p<f;p++){let h={};if(h.name=i[p].name,i[p].vertices!==void 0){h.vertices=[];for(let m=0,y=i[p].vertices.length;m<y;m++)h.vertices.push(i[p].vertices[m].clone())}if(i[p].normals!==void 0){h.normals=[];for(let m=0,y=i[p].normals.length;m<y;m++)h.normals.push(i[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],x={};x.a=g.a.clone(),x.b=g.b.clone(),x.c=g.c.clone(),h.vertexNormals.push(x)}}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 d=t.lineDistances;for(let p=0,f=d.length;p<f;p++)this.lineDistances.push(d[p]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let u=t.boundingSphere;return u!==null&&(this.boundingSphere=u.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 Wd().fromGeometry(this),e=new oe.BufferGeometry,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Vc.call(new oe.BufferAttribute(r,3),t.vertices)),t.normals.length>0){let o=new Float32Array(t.normals.length*3);e.setAttribute("normal",Vc.call(new oe.BufferAttribute(o,3),t.normals))}if(t.colors.length>0){let o=new Float32Array(t.colors.length*3);e.setAttribute("color",Mg.call(new oe.BufferAttribute(o,3),t.colors))}if(t.uvs.length>0){let o=new Float32Array(t.uvs.length*2);e.setAttribute("uv",Ig.call(new oe.BufferAttribute(o,2),t.uvs))}if(t.uvs2.length>0){let o=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",Ig.call(new oe.BufferAttribute(o,2),t.uvs2))}e.groups=t.groups;for(let o in t.morphTargets){let i=[],a=t.morphTargets[o];for(let s=0,l=a.length;s<l;s++){let d=a[s],c=new oe.Float32BufferAttribute(d.data.length*3,3);c.name=d.name,i.push(Vc.call(c,d.data))}e.morphAttributes[o]=i}if(t.skinIndices.length>0){let o=new oe.Float32BufferAttribute(t.skinIndices.length*4,4);e.setAttribute("skinIndex",Ng.call(o,t.skinIndices))}if(t.skinWeights.length>0){let o=new oe.Float32BufferAttribute(t.skinWeights.length*4,4);e.setAttribute("skinWeight",Ng.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 oe.BufferGeometry,r=t.geometry;if(t.isPoints||t.isLine){let o=new oe.Float32BufferAttribute(r.vertices.length*3,3),i=new oe.Float32BufferAttribute(r.colors.length*3,3);if(e.setAttribute("position",Vc.call(o,r.vertices)),e.setAttribute("color",Mg.call(i,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let a=new oe.Float32BufferAttribute(r.lineDistances.length,1);e.setAttribute("lineDistance",EC.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}};wn.prototype.isGeometry=!0;var Wd=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,i,a=t.faces;for(o=0;o<a.length;o++){let s=a[o];s.materialIndex!==i&&(i=s.materialIndex,r!==void 0&&(r.count=o*3-r.start,e.push(r)),r={start:o*3,materialIndex:i})}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,i=o[0]&&o[0].length>0,a=o[1]&&o[1].length>0,s=t.morphTargets,l=s.length,d;if(l>0){d=[];for(let g=0;g<l;g++)d[g]={name:s[g].name,data:[]};this.morphTargets.position=d}let c=t.morphNormals,u=c.length,p;if(u>0){p=[];for(let g=0;g<u;g++)p[g]={name:c[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 x=e[g];this.vertices.push(r[x.a],r[x.b],r[x.c]);let S=x.vertexNormals;if(S.length===3)this.normals.push(S[0],S[1],S[2]);else{let b=x.normal;this.normals.push(b,b,b)}let w=x.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[2]);else{let b=x.color;this.colors.push(b,b,b)}if(i===!0){let b=o[0][g];b!==void 0?this.uvs.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new oe.Vector2,new oe.Vector2,new oe.Vector2))}if(a===!0){let b=o[1][g];b!==void 0?this.uvs2.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new oe.Vector2,new oe.Vector2,new oe.Vector2))}for(let b=0;b<l;b++){let _=s[b].vertices;d[b].data.push(_[x.a],_[x.b],_[x.c])}for(let b=0;b<u;b++){let _=c[b].vertexNormals[g];p[b].data.push(_.a,_.b,_.c)}m&&this.skinIndices.push(f[x.a],f[x.b],f[x.c]),y&&this.skinWeights.push(h[x.a],h[x.b],h[x.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}},ma=class{constructor(t,e,r,o,i,a=0){this.a=t,this.b=e,this.c=r,this.normal=o&&o.isVector3?o:new oe.Vector3,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new oe.Color,this.vertexColors=Array.isArray(i)?i:[],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 EC(n){return this.array.set(n),this}function Mg(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),i=new oe.Color),t[e++]=i.r,t[e++]=i.g,t[e++]=i.b}return this}function Ig(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),i=new oe.Vector2),t[e++]=i.x,t[e++]=i.y}return this}function Vc(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),i=new oe.Vector3),t[e++]=i.x,t[e++]=i.y,t[e++]=i.z}return this}function Ng(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),i=new oe.Vector4),t[e++]=i.x,t[e++]=i.y,t[e++]=i.z,t[e++]=i.w}return this}var DC=["a","b","c"];function LC(n,t){switch(t){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function $d(n,t,e){let r=Math.min(n,t),o=Math.max(n,t),i=r+"_"+o;return e.get(i)}function Yd(n,t,e,r,o,i){let a=Math.min(n,t),s=Math.max(n,t),l=a+"_"+s,d;if(r.has(l))d=r.get(l);else{let c=e[a],u=e[s];d={a:c,b:u,newEdge:null,faces:[]},r.set(l,d)}d.faces.push(o),i[n].edges.push(d),i[t].edges.push(d)}function BC(n,t,e,r){let o,i,a;for(o=0,i=n.length;o<i;o++)e[o]={edges:[]};for(o=0,i=t.length;o<i;o++)a=t[o],Yd(a.a,a.b,n,r,a,e),Yd(a.b,a.c,n,r,a,e),Yd(a.c,a.a,n,r,a,e)}function Gc(n,t,e,r,o){n.push(new ma(t,e,r,void 0,void 0,o))}function ya(n,t){return Math.abs(t-n)/2+Math.min(n,t)}function zc(n,t,e,r){n.push([t.clone(),e.clone(),r.clone()])}var kc=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof jo.BufferGeometry?t=new wn().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 jo.Vector3,r,o,i,a,s,l=t.vertices,d=t.faces,c=t.faceVertexUvs[0],u=c!==void 0&&c.length>0,p=[],f=new Map;BC(l,d,p,f);let h=[],m,y,g,x,S,w,b;for(let W of Array.from(f.keys())){for(y=f.get(W),g=new jo.Vector3,S=3/8,w=1/8,b=y.faces.length,b!=2&&(S=.5,w=0,b!=1),g.addVectors(y.a,y.b).multiplyScalar(S),e.set(0,0,0),a=0;a<b;a++){for(x=y.faces[a],s=0;s<3&&(m=l[LC(x,DC[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(w),g.add(e),y.newEdge=h.length,h.push(g)}let _,A,v,M,O,T,C,P=[];for(o=0,i=l.length;o<i;o++){for(T=l[o],O=p[o].edges,r=O.length,r==3?_=3/16:r>3&&(_=3/(8*r)),A=1-r*Number(_),v=_,r<=2&&(r==2?(A=3/4,v=1/8):r==1||r==0),C=T.clone().multiplyScalar(A),e.set(0,0,0),a=0;a<r;a++)M=O[a],m=M.a!==T?M.a:M.b,e.add(m);e.multiplyScalar(Number(v)),C.add(e),P.push(C)}let I=P.concat(h),D=P.length,G,N,F,B=[],R=[],V,q,Y,$,H=new jo.Vector2,X=new jo.Vector2,k=new jo.Vector2;for(o=0,i=d.length;o<i;o++)x=d[o],G=Number($d(x.a,x.b,f).newEdge)+D,N=Number($d(x.b,x.c,f).newEdge)+D,F=Number($d(x.c,x.a,f).newEdge)+D,Gc(B,G,N,F,x.materialIndex),Gc(B,x.a,G,F,x.materialIndex),Gc(B,x.b,N,G,x.materialIndex),Gc(B,x.c,F,N,x.materialIndex),u&&(V=c[o],q=V[0],Y=V[1],$=V[2],H.set(ya(q.x,Y.x),ya(q.y,Y.y)),X.set(ya(Y.x,$.x),ya(Y.y,$.y)),k.set(ya(q.x,$.x),ya(q.y,$.y)),zc(R,H,X,k),zc(R,q,H,k),zc(R,Y,X,H),zc(R,$,k,X));t.vertices=I,t.faces=B,u&&(t.faceVertexUvs[0]=R)}};var Ct=new yo.Vector3,Eg=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.geometry??t?.geometry??new yo.BufferGeometry().copy(new yo.BoxGeometry(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Ct),r={width:Ct.x,height:Ct.y,depth:Ct.z,subdivisions:0}):r=t.parameters;let o={...r,...n.parameters};return{parameters:{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth),subdivisions:Math.abs(o.subdivisions)},geometry:e}}static build(n){let{width:t,height:e,depth:r,subdivisions:o}=n.parameters,i=n.geometry??new yo.BufferGeometry().copy(new yo.BoxGeometry(100,100,100)),a=i.userData.parameters;a===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(Ct)):Ct.set(a.width,a.height,a.depth),(t!==Ct.x||e!==Ct.y||r!==Ct.z)&&i.scale(Ct.x===0?1:t/Ct.x,Ct.y===0?1:e/Ct.y,Ct.z===0?1:r/Ct.z);let s=i.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=i),i=new kc(o).modify(s).toBufferGeometry()):(s!==void 0&&(i=s),s=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals())}catch{s!==void 0&&(i=s),s=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals()}return s!==void 0&&Object.assign(i,{originalGeometry:s}),delete n.geometry,Object.assign(i,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,t,e){new yo.BufferGeometryLoader(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(Ct);let a=100/Ct.x;Object.assign(i.parameters,{width:100,height:Ct.y*a,depth:Ct.z*a}),t(this.build(i))})}};var Fc=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof Re?n.shape:new Re,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,cornerRadius:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}=n.parameters,l=n.shape,d=t*.5,c=e*.5,u=0,p=0,f=2*Math.PI/r;for(let m=0;m<r;m++){let y=f*m,g=u+Math.sin(y)*d,x=p+Math.cos(y)*c;l.addPoint(l.createPoint(g,x))}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=dr.create({shape:l,parameters:{roundness:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(h,{userData:{...n,type:"PolygonGeometry"}})}};var Ne=require("three"),Dg=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,radialSegments:o,heightSegments:i,openEnded:a,cornerRadius:s,cornerSegments:l}=n.parameters,d=new Kd(t*.5,e,o,i,a,s,l);return d.scale(1,1,r/t),Object.assign(d,{userData:{...n,type:"PyramidGeometry"}})}};function Fs(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function Xd(n,t,e,r,o,i){let a=t.clone().sub(n),s=e.clone().sub(n),l=a.angleTo(s);if(a.normalize(),s.normalize(),r===o){let d=a.add(s).normalize();i.copy(n).addScaledVector(d,r/Math.sin(l/2))}else{let d=a.angleTo(s);i.copy(n),i.addScaledVector(a,o/Math.sin(d)),i.addScaledVector(s,r/Math.sin(d))}}function RC(n,t,e){let r=n.clone().sub(t),o=e.clone().sub(t);return r.projectOnVector(o),r.add(t)}var Kd=class extends Ne.BufferGeometry{constructor(t=.5,e=1,r=4,o=1,i=!1,a=0,s=4){super(),r=Math.floor(Math.max(3,r)),o=Math.floor(o),s=Math.floor(s);let l=[],d=[],c=[],u=[],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,x=Math.PI-g,S=new Ne.Vector3(0,-f,0),w=new Ne.Vector3(0,f,0),b=new Ne.Vector2(t,-f),_=new Ne.Vector2(m,-f),A=new Ne.Vector2(0,w.y).sub(_),v=new Ne.Vector2(0,w.y).sub(b),M=new Ne.Vector2(A.y,-A.x).normalize(),O=new Ne.Vector2(v.y,-v.x).normalize(),C=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-A.angle())/2)-1e-8;a=Math.min(a,C);let P;{let R=new Ne.Vector3(M.x,M.y,0),V=new Ne.Vector3(Math.cos(y)*R.x,R.y,Math.sin(y)*R.x);P=R.angleTo(V)}let I=a/Math.tan((Math.PI-A.angle())/2),D=a/Math.tan((Math.PI-P)/2),G=new Ne.Vector3;if(!i){d.push(S.x,S.y,S.z),c.push(0,-1,0),u.push(0,0);let R=p++,V=[],q=b.clone(),Y=I/Math.cos(Math.PI/r);q.x-=Y;for(let $=0;$<r;$++){let H=$/r*Math.PI*2+h,X=new Ne.Vector2(Math.sin(H),Math.cos(H));Fs(q,X,G),d.push(G.x,G.y,G.z),c.push(0,-1,0),u.push(0,0),V.push(p++)}for(let $=0;$<V.length;$++)l.push(V[$],R,V[($+1)%V.length])}let N=[];{let R=new Ne.Vector3,V=new Ne.Vector3,q=new Ne.Vector3,Y=new Ne.Vector3,$=new Ne.Vector3,H=new Ne.Vector3;for(let X=0;X<r;X++){let k=X/r*Math.PI*2+h,W=(X+.5)/r*Math.PI*2+h,U=(X+1)/r*Math.PI*2+h,z=new Ne.Vector2(Math.sin(k),Math.cos(k)),ne=new Ne.Vector2(Math.sin(W),Math.cos(W)),ee=new Ne.Vector2(Math.sin(U),Math.cos(U));Fs(b,z,V),Fs(b,ee,q),Fs(M,ne,R),Xd(w,V,q,D,D,Y),d.push(Y.x,Y.y,Y.z),Xd(V,w,q,D,I,$),d.push($.x,$.y,$.z),Xd(q,V,w,I,D,H),d.push(H.x,H.y,H.z),c.push(R.x,R.y,R.z),c.push(R.x,R.y,R.z),c.push(R.x,R.y,R.z),u.push(0,0),u.push(0,0),u.push(0,0);let Q=p++,te=p++,Z=p++;if(l.push(Q,te,Z),a>0){{let ae=V.clone().add(q).multiplyScalar(.5),de=w.clone().sub(ae).normalize(),pe=S.clone().sub(ae).normalize().add(de).normalize().multiplyScalar(-1),xe=H.clone().sub($);F(ae,xe,pe,A.angle())}let le,ie;{let ae=new Ne.Vector3;Fs(O,ee,ae);let de=H.clone().add(Y).multiplyScalar(.5);de=RC(de,q,w);let ce=H.clone().sub(Y);[le,ie]=F(de,ce,ae,P,Y.y)}{let ae=le,de=ae.clone().setY(0).normalize(),ce=new Ne.Vector3(0,-1,0),pe=de.clone().cross(ce);B(ae,de,ce,pe)}N.concat(ie);{let ae=A.angle(),de=Math.PI-ae,ce=w.clone();ce.y-=a/Math.sin(ae-Math.PI/2);let pe=new Ne.Vector3,xe=[];for(let tt=0;tt<s;tt++){let Le=[],We=Math.PI/2-de*tt/s,nr=Math.cos(We),Te=Math.sin(We),At=W;for(let It=0;It<=tt;It++){let mi=Math.cos(At),yt=Math.sin(At);R.x=nr*yt,R.y=Te,R.z=nr*mi,pe.copy(ce).addScaledVector(R,a),d.push(pe.x,pe.y,pe.z),c.push(R.x,R.y,R.z),u.push(0,0),Le.push(p++),At+=Math.PI*2/tt/r}xe.push(Le)}ie.reverse(),xe.push(ie);let De=xe.length-1;for(let tt=0;tt<De;tt++){let Le=xe[tt],We=xe[tt+1],nr=Le.length-1;l.push(We[1],Le[0],We[0]);for(let Te=1;Te<=nr;Te++)l.push(Le[Te],Le[Te-1],We[Te]),l.push(We[Te+1],Le[Te],We[Te])}}}}}this.setIndex(l),this.setAttribute("position",new Ne.Float32BufferAttribute(d,3)),this.setAttribute("normal",new Ne.Float32BufferAttribute(c,3)),this.setAttribute("uv",new Ne.Float32BufferAttribute(u,2));function F(R,V,q,Y,$){let H=-Y/2,X=(Math.PI-Y)/2,k=V.clone().normalize().cross(q);R.addScaledVector(q,-a/Math.sin(X));let W=new Ne.Vector3,U=new Ne.Vector3,z=1,ne=p,ee=[];for(let Q=0;Q<=s;Q++){let te=H+Q/s*Y;U.set(0,0,0),U.addScaledVector(k,Math.sin(te)),U.addScaledVector(q,Math.cos(te));for(let Z=0;Z<=z;Z++){let le=Z/z-.5;if(W.copy(R),W.addScaledVector(V,le),W.addScaledVector(U,a),$!=null){let ie=Math.max(0,W.y-$);W.addScaledVector(V,-ie/V.y)}d.push(W.x,W.y,W.z),c.push(U.x,U.y,U.z),u.push(0,0),Z===0&&ee.push(p),p++}}for(let Q=0;Q<s;Q++)for(let te=0;te<z;te++){let Z=ne+te+(z+1)*Q,le=Z+(z+1),ie=le+1,ae=Z+1;l.push(Z,le,ae),l.push(le,ie,ae)}return[R.clone().addScaledVector(V,.5),ee]}function B(R,V,q,Y){let $=Math.PI/2,H=v.angle()-$,X=[],k=new Ne.Vector3,W=new Ne.Vector3;for(let z=0;z<=s;z++){let ne=[],ee=z/s;for(let Q=0;Q<=z;Q++){let Z=((z?Q/z:0)-.5)*x,le=Math.cos(Z),ie=Math.sin(Z),ae=Math.atan(Math.tan(H)*le),de=($+ae)*ee,ce=Math.cos(de),pe=Math.sin(de);k.set(0,0,0),k.addScaledVector(V,pe*le),k.addScaledVector(q,ce),k.addScaledVector(Y,pe*ie),W.copy(R).addScaledVector(k,a),d.push(W.x,W.y,W.z),c.push(k.x,k.y,k.z),u.push(0,0),ne.push(p++)}X.push(ne)}let U=X.length-1;for(let z=0;z<U;z++){let ne=X[z],ee=X[z+1],Q=ne.length-1;l.push(ne[0],ee[1],ee[0]);for(let te=1;te<=Q;te++)l.push(ne[te-1],ne[te],ee[te]),l.push(ne[te],ee[te+1],ee[te])}}}};var jc=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof Re?n.shape:new Re,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(n){let t=n.shape,{width:e,height:r,cornerRadius:o,cornerType:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,d={x:e*.5,y:r*.5},c={x:-d.x,y:-d.y},u={x:d.x,y:d.y};function p(w,b,_){return b>e&&_>r?Math.min(w*e/b,w*r/_):b>e?w*e/b:_>r?w*r/_:w}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=c.x,m=u.x,y=u.y,g=c.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 x=!0;for(let w=0,b=t.points.length;w<b;w++)t.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(x=!1);x&&(t.roundness=f[0]),t.useCubicForRoundedCorners=i!==1,t.update();let S=dr.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(S,{userData:{...n,type:"RectangleGeometry"}})}};var Uo=require("three"),Lg=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},n.parameters);return e.thetaLength=Uo.MathUtils.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t=100,height:e=t,depth:r=t,widthSegments:o=64,heightSegments:i=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:d}=n.parameters,c;return d===0?(c=new Uo.BufferGeometry,c.setAttribute("position",new Uo.Float32BufferAttribute([],3))):c=new Uo.SphereGeometry(.5*t,o,i,a,s,l,d*Uo.MathUtils.DEG2RAD),c.scale(1,e/t,r/t),Object.assign(c,{userData:{...n,type:"SphereGeometry"}})}};var Bg=require("three"),Rg=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(n){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:o=8}=n.parameters,i=new Bg.PlaneGeometry(t,e,r,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};var _n=require("three"),Vg=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,angle:o,cornerRadius:i,cornerSegments:a}=n.parameters,s=new Qd(t,e,r,o,i,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},Qd=class extends _n.BufferGeometry{constructor(t=1,e=1,r=1,o=90,i=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],d=[],c=.001;i==0&&(a=1),a=Math.max(1,Math.floor(a)),i=Math.min(i,100),o=Math.min(180-c,o),o*=Math.PI/180;let u=[],p=Math.PI/2,f=(W=0,U=0,z=0)=>new _n.Vector3(W,U,z),h=f(),m=f(),[y,g,x]=[e/2,t/2,r/2],S=-g,w=+g,[b,_,A]=[f(S,-y,+x),f(S,-y,-x),f(S,+y,-x)],v=(W,U=!1)=>Math.sin(W-Math.PI/(1+ +U)),M=(W,U=!1)=>Math.cos(W-Math.PI/(1+ +U));A.y=Math.sin(o)*e-y;let O=Math.cos(o)*e-x,T=b.z-c;o<=p?(A.z=Math.min(O,T),A.z==T&&(A.y-=(O-T)/Math.tan(p-o))):_.z=Math.min(_.z-O-x,b.z-c),h.subVectors(b,_),m.subVectors(A,_);let C=Math.min(h.length(),m.length())*i/100,P=C*Math.tan(o/2),I=C/Math.cos(o/2),D=h.clone().normalize().add(m.normalize()).setLength(I).add(_);h.set(0,v(o,!0),M(o,!0)),u.push([A,h.clone()]);let G=(Math.PI-o)/a;for(let W=0;W<=a;W++){let U=p+o+W*G;h.set(0,Math.sin(U)*P,Math.cos(U)*P),h.add(D),m.set(0,v(U),M(U)),u.push([h.clone(),m.clone()])}u.push([b,f(0,1,0)]);let N=Math.sin(G/2)*P*2,F=u.length-1,B=u[0][0].distanceTo(u[1][0]),R=u[F-1][0].distanceTo(u[F][0]),V=B+N*a+R;u[0].push(1);for(let W=0;W<=a;W++)u[W+1].push(1-(B+W*N)/V);u[F].push(0);let[q,Y,$]=u[0],H,X,k;for(let W=1;W<u.length;W++)[H,X,k]=u[W],s.push(S,q.y,q.z,S,H.y,H.z,w,q.y,q.z,w,q.y,q.z,S,H.y,H.z,w,H.y,H.z),l.push(0,Y.y,Y.z,0,X.y,X.z,0,Y.y,Y.z,0,Y.y,Y.z,0,X.y,X.z,0,X.y,X.z),d.push(0,$,0,k,1,$,1,$,0,k,1,k),[q,Y,$]=[H,X,k];this.setAttribute("position",new _n.Float32BufferAttribute(s,3)),this.setAttribute("normal",new _n.Float32BufferAttribute(l,3)),this.setAttribute("uv",new _n.Float32BufferAttribute(d,2))}};var Uc=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Re?n.shape:new Re,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,innerRadiusPercent:r,spikes:o,cornerRadius:i,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:d}=n.parameters,c=n.shape,u=t*.5,p=e*.5,f=0,h=0,m=a*Math.PI/360/o,y=Math.PI/2*3*-1,g=u*r/100,x=p*r/100;if(o===3&&r===50){m=2*Math.PI/o;for(let w=0;w<o;w++){let b=m*w,_=f+Math.sin(b)*u,A=h+Math.cos(b)*p;c.addPoint(c.createPoint(_,A))}}else for(let w=0;w<o;w++){let b=f+Math.cos(y)*u,_=h+Math.sin(y)*p;c.addPoint(c.createPoint(b,_)),y+=m,b=f+Math.cos(y)*g,_=h+Math.sin(y)*x,w<=o,c.addPoint(c.createPoint(b,_)),y+=m}c.isClosed=!0;for(let w=0,b=c.points.length;w<b;w++)c.points[w].roundness=i;c.roundness=i,c.update();let S=dr.create({shape:c,parameters:{roundness:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:d}});return Object.assign(S,{userData:{...n,type:"StarGeometry"}})}};var Gg=require("three"),zg=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e}=n.parameters,r=new Gg.PlaneGeometry(t,e);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};var ga=require("three");var kg=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:o,depth:i})}}static build(n){let{width:t,height:e,depth:r,radialSegments:o,tubularSegments:i,arc:a,cornerRadius:s,cornerSegments:l}=n.parameters,d=VC(t,e,r,t*.5,a,i,0,0,o,s,l);return d.scale(1,e/t,1),Object.assign(d,{userData:{...n,type:"TorusGeometry"}})}};function VC(n,t,e,r,o,i,a,s,l,d,c){[t,e]=[e,t],a=t/2;let u=ga.MathUtils.clamp(o/360,0,1);if(u===0){let p=new ga.BufferGeometry;return p.setAttribute("position",new ga.Float32BufferAttribute([],3)),p}return u===1&&(d=0),new zs(!0,n,t,e,r,u,i,a,s,l,d,c)}var Fg=require("three"),jg=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(n){let{width:t,tube:e,tubularSegments:r,radialSegments:o,p:i,q:a}=n.parameters,s=t*.5;s!==e&&(s-=e);let l=new Fg.TorusKnotGeometry(s,e,r,o,i,a);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var Ug=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof Re?n.shape:new Re,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t=100,height:e,cornerRadius:r,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a,isRect:s}=n.parameters,l=n.shape,d=t*.5,c=e*.5;s?(l.addPoint(l.createPoint(-d,c)),l.addPoint(l.createPoint(d,-c)),l.addPoint(l.createPoint(-d,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(d,-c)),l.addPoint(l.createPoint(-d,-c))),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 u=dr.create({shape:l,parameters:{roundness:r,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a}});return Object.assign(u,{userData:{...n,type:"TriangleGeometry"}})}};var Se=require("three");function Hg(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var GC=new Se.Matrix4,zC=new Se.Matrix4;function kC(n,t,e){let r=[new Se.Vector3,new Se.Vector3,new Se.Vector3],o=[new Se.Vector3,new Se.Vector3,new Se.Vector3];return n.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((i,a)=>{let s=o[a],l=Se.MathUtils.lerp(i.length(),s.length(),e);i.lerp(s,e).setLength(l)}),new Se.Matrix4().makeBasis(r[0],r[1],r[2])}var qg=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=t?.shapeData??ha.create({parameters:ud}).userData.shape;return{path:n.path??$i.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:i,extrusion:{...hc,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new Zd(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new Se.BufferGeometry,{userData:{...n,type:"PathGeometry"}})}},Zd=class extends Se.BufferGeometry{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!Hg(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:i}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),i=Math.max(0,Math.min(i,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(i*a),l=this.inputs.path.isClosed?Math.ceil((o+i)*a):Math.ceil(Math.min(1,o+i)*a),d=Math.min(Math.max(2,l-s+1),a+2),c=[],u=[];for(let B=0;B<d;B++){let R=this.inputs.path.isClosed?(B+s)%e.length:Math.min(B+s,e.length-1);c.push(e[R].clone()),u.push(r[R].clone())}let p=(B,R,V)=>{c[B]=c[B].clone().lerp(c[R],V),u[B]=kC(u[B],u[R],V)},f=0,h=i*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||i===0)&&(f=h,p(0,1,f));let m=0,y=(i+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&i+o<1)&&y&&(m=y,p(c.length-1,c.length-2,1-m)),o===0){let B=c.length-1;c[B].copy(c[0]),u[B].copy(u[0])}this._applyPathModifiers(u,f,m);let{bevel:g,bevelSides:x}=this.inputs.parameters.extrusion,S=g>0?this.inputs.parameters.extrusion.capType:"flat",w=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(w=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:b,infos:_,vertices:A}=this._computeShapePoints(w),v=0,M;S==="round"&&(M=new Sn(this.inputs.shapeData,2*g,g,w,x,void 0,!0),v=M.getAttribute("position").count);let O=0,T=0;_.sort((B,R)=>B.start-R.start),_.forEach(B=>{B.verticesStart=O,B.verticesCount=B.continuous.reduce((R,V,q)=>R+(q===0||!V?2:1),0),T+=B.verticesCount,O=T});let C=T*d,P,I=0;if(this._isOpenEnded()&&S==="flat"){try{P=qr({windingRule:Ee.ODD,elementType:st.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:b})}catch{P=Ud}I=P.vertexCount}let D=C+2*I+v*2,G=C+2*I,N={positions:new Float32Array(D*3),normals:new Float32Array(D*3),uvs:new Float32Array(D*2)},F=[];if(_.forEach(B=>{this._extrudeRegion(B,A,u,c,N,F,this._isGeometryClosed()&&!this._isOpenEnded())}),P&&(this._closeEnd(P,C,F,N,u[0],c[0],!1),this._closeEnd(P,C+I,F,N,u[u.length-1],c[c.length-1],!0)),M){N.positions.set(M.getAttribute("position").array,G*3),N.normals.set(M.getAttribute("normal").array,G*3),N.uvs.set(M.getAttribute("uv").array,G*2);let B=F.length;F.push(...M.getIndex().array.map(q=>q+G)),G+=v,N.positions.set(M.getAttribute("position").array,G*3),N.normals.set(M.getAttribute("normal").array,G*3),N.uvs.set(M.getAttribute("uv").array,G*2);let R=F.length;F.push(...M.getIndex().array.map(q=>q+G)),this.setAttribute("position",new Se.BufferAttribute(N.positions,3)),this.setAttribute("normal",new Se.BufferAttribute(N.normals,3)),this.setAttribute("uv",new Se.BufferAttribute(N.uvs,2)),this.setIndex(F);let V=GC;V.copy(u[u.length-1]).setPosition(c[c.length-1]),this.applyMatrix4OnRange(V,G,D),V.copy(u[0]).setPosition(c[0]).multiply(zC.makeScale(1,1,-1)),this.applyMatrix4OnRange(V,G-v,G),this.reverseIndicesOnRange(B,R)}else this.setAttribute("position",new Se.BufferAttribute(N.positions,3)),this.setAttribute("normal",new Se.BufferAttribute(N.normals,3)),this.setAttribute("uv",new Se.BufferAttribute(N.uvs,2)),this.setIndex(F)}_extractPathPoints(){let r=Mc(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let o=[r[0]];return r.forEach(a=>{o[o.length-1].distanceToSquared(a)>.001&&o.push(a)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],o=e.length,i=this.inputs.path.isClosed,a=new Se.Vector3,s=new Se.Vector3,l=new Se.Vector3,d=new Se.Vector3,c=new Se.Vector3(0,1,0);for(let y=0;y<o;y++){let g=e[y],x;y===0?x=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):x=e[y-1];let S;y===o-1?S=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):S=e[y+1];let w=g.clone().sub(x).normalize(),b=S.clone().sub(g).normalize(),_=w.clone().add(b).normalize();l.copy(_),y===0&&(_.equals(c)||_.clone().negate().equals(c))&&c.set(0,0,1);let A=c.clone().cross(_).normalize(),v=_.clone().cross(A).normalize();c.copy(v),d.copy(A),y===0&&(a.copy(v),s.copy(_));let M=new Se.Matrix4().makeBasis(A,v,_);r.push(M)}let u=i?s:l,p=i?a:new Se.Vector3(0,1,0),f=u.clone().cross(d).normalize(),h=Math.acos(p.dot(f));if(isNaN(h))return r;let m=p.clone().cross(f);u.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let g=new Se.Matrix4().makeRotationZ(h*y/r.length);r[y].multiply(g)}return r}_applyPathModifiers(e,r,o){let i=e.length,{angle:a,twist:s,startScale:l,endScale:d}=this.inputs.parameters.extrusion,c=new Se.Matrix4,u=new Se.Matrix4;return e.forEach((p,f)=>{let h=f===0?0:f===i-1?1:(f-r)/(i-(o===0?0:1)-(r+(1-o)));c.makeRotationZ(Se.MathUtils.lerp(a,a+s,h)*Se.MathUtils.DEG2RAD);let m=Se.MathUtils.lerp(l,d,h);u.makeScale(m,m,m),p.multiply(c).multiply(u)}),e}_computeShapePoints(e=12,r=Ee.ODD){let o=this.inputs.shapeData,i=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let x=y.length-1;x>=1;x-=2){let S=y[x-1],w=y[x-0];g.push(S,w)}return g}),s;try{s=qr({windingRule:r,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{s=Gs}let l;try{l=qr({windingRule:Ee.ODD,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=jd}if(!s)throw new Error("error generating geometry");let d=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 c=1/0,u=-1/0,p=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,x=s.vertices[g+0],S=s.vertices[g+1];x<c&&(c=x),x>u&&(u=x),S<p&&(p=S),S>f&&(f=S)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=d,g=m*2,x=s.elements[g+0],S=s.elements[g+1],w=x+S,b={start:x,count:S,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(b);let _=x,A=w-1,v=x+1,M=o.roundedCurves.length;do{let O=_-x,T=s.vertices[A*2+0],C=s.vertices[A*2+1],P=s.vertices[_*2+0],I=s.vertices[_*2+1],D=s.vertices[v*2+0],G=s.vertices[v*2+1],N=P-T,F=I-C,B=Math.sqrt(N*N+F*F);N/=B,F/=B;let R=P-D,V=I-G,q=Math.sqrt(R*R+V*V);R/=q,V/=q,b.normals[O*2+0]=-V,b.normals[O*2+1]=R;let Y=s.vertexIndices[_];if(Array.isArray(Y))b.continuous[O]=!1;else{let[$,H]=o.getCurveIndexFromVertexId(Y-1,!0);if(H>0&&H<1)b.continuous[O]=!0;else{let X=H===1?$+1:$-1;X=(X+M)%M;let k=H===1?0:1,W=o.roundedCurves[$].getTangent(H),U=o.roundedCurves[X].getTangent(k);b.continuous[O]=W.dot(U)>.95}}y&&(b.normals[O*2+0]*=-1,b.normals[O*2+1]*=-1),[A,_,v]=[_,v,v+1],v>=w&&(v-=S)}while(v!==x+1)}return{regions:[i,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,i,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]=i.x,e.normals[l+1]=i.y,e.normals[l+2]=i.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,o,i,a,s,l){let d=new Se.Vector3,c=new Se.Vector3,u=new Se.Vector3,p=new Se.Vector3,f=new Se.Vector2;o.forEach((m,y)=>{let g=i[y],x=e.verticesStart*o.length+e.verticesCount*y;for(let S=0;S<e.count;S++){let w=(e.start+S)*2;if(d.set(r[w+0],r[w+1],0),u.copy(d).applyMatrix4(m).add(g),e.continuous[S])p.set(e.normals[S*2+0],e.normals[S*2+1],0);else{let b=S===0?(e.start+e.count-1)*2:w-2;c.set(r[b+0],r[b+1],0),p.copy(d).sub(c),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(m).normalize(),f.set(S===0?1:S/e.count,y/(o.length-1)),this._insertVertex(a,x,u,p,f),x++,!e.continuous[S]||S===0){if(S===0)p.set(e.normals[S*2+0],e.normals[S*2+1],0),f.set(0,y/(o.length-1));else{let b=S===e.count-1?e.start*2:w+2;c.set(r[b+0],r[b+1],0),p.copy(c).sub(d),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(m).normalize(),this._insertVertex(a,x,u,p,f),x++}}});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),x=0;for(let S=0;S<e.count;S++){(!e.continuous[S]||S===0)&&x++;let w=S===e.count-1?0:x+1,b=y+x,_=y+w,A=g+w,v=g+x;e.isHole?s.push(b,A,_,b,v,A):s.push(b,_,A,b,A,v),x++}}}_closeEnd(e,r,o,i,a,s,l){let d=e.vertexCount,c=new Se.Vector3(0,0,l?-1:1).applyMatrix4(a),u=new Se.Vector3,p=new Se.Vector2;for(let h=0;h<d;h++){let m=2*h;u.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(i,r+h,u,c,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,x=f[m+(l?2:1)]+r;o.push(y,g,x)}}applyMatrix4OnRange(e,r,o){let i=e.elements,a=new Se.Matrix3().getNormalMatrix(e).elements,s,l,d,c,u=this.attributes.position,p=this.attributes.normal;if(!u||!p)return;let f=u.array,h=p.array,m=u.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],d=f[y+2],c=1/(i[3]*s+i[7]*l+i[11]*d+i[15]),f[y+0]=(i[0]*s+i[4]*l+i[8]*d+i[12])*c,f[y+1]=(i[1]*s+i[5]*l+i[9]*d+i[13])*c,f[y+2]=(i[2]*s+i[6]*l+i[10]*d+i[14])*c,s=h[y+0],l=h[y+1],d=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*d,h[y+1]=a[1]*s+a[4]*l+a[7]*d,h[y+2]=a[2]*s+a[5]*l+a[8]*d}u.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,r){let o=this.index;if(o){for(let i=e;i<r;i+=3){let a=o.getX(i),s=o.getX(i+1),l=o.getX(i+2);o.setXYZ(i,l,s,a)}o.needsUpdate=!0}}};var Kn=require("three"),Wg=require("three/examples/jsm/utils/BufferGeometryUtils.js");function $g(){let n=new Kn.BufferGeometry;return n.setAttribute("position",new Kn.BufferAttribute(new Float32Array([]),3)),n.setIndex(new Kn.BufferAttribute(new Uint16Array([]),1)),n}var FC=$g().attributes,jC=12,UC=1,xa=class extends Kn.BufferGeometry{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,FC),this.userData={parameters:e,type:"TextGeometry"};let o=r.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e)):this.updateFont(e.font,r).then(()=>{this.update(e),r?.requestRender()})}async updateFont(e,r){let o=r.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e){let r=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!r?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l,text:d,textTransform:c}=e,u=wc.getDisplayedValue(d),p=c===2?u.toUpperCase():c===3?u.toLowerCase():u,f=HC(e,r,p),{shapes:h,charWidths:m,charCoords:y}=r.generateShapes(f,e),g=(typeof o=="number"?o:1)*.5,x=(typeof i=="number"?i:1)*.5,S=h.map(_=>new Re().fromShape(_,!0));this.vectorShapes=S;let w=S.map(_=>dr.create({shape:_,parameters:{depth:a,extrudeBevelSegments:l,extrudeBevelSize:s,windingRule:a<=0?Ee.NONZERO:Ee.ODD,subdivisions:this.isLowResolution&&a>0?UC:jC}})),b=w.length?(0,Wg.mergeBufferGeometries)(w):$g();b.translate(-g,x,0),this.dispose(),this.wrappedText=f,this.charCoords=y,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(b.attributes).forEach(([_,A])=>{this.setAttribute(_,A)}),this.setIndex(b.index),this.computeBoundingSphere()}clone(){let e=sr(new Kn.BufferGeometry,xa.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){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function HC(n,t,e){let r=[""],o="";for(let i of e)o+=i,i===" "||i===`
16
16
  `?(r[r.length-1]+=o,o="",i===`
17
- `&&r.push("")):t.getTextWidth(r[r.length-1]+o,n)>n.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+o,n)>n.width&&(o.length===1?(r[r.length-1]+=o,o=""):(r[r.length-1]+=o.slice(0,-1),o=o[o.length-1],r.push(""))));return r[r.length-1]+=o,r}var Ye=require("three");var Xg,va=new Promise(n=>{Xg=n}),Yg=!1;var Hc;function Kg(){if(Yg)return;if(Hc)return Hc;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.524/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(d=>d.arrayBuffer())]),s=i.default,l=await s({wasmBinary:a});Xg(l),Yg=!0}return Hc=n(),Hc}var Qg=require("three");var qC=["font"];function Zn(n,t,e,r){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let d of a){let c=i;for(let u of d)c=c[u];for(o in c){let u=c[o];sd(u)&&!qC.includes(o)&&(c[o]=t.getVariable(u,[r.uuid,"geometry",...d,o]),sd(c[o])&&(c[o]=1))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let d=Re.createFromState(i.shape,i.width,i.height);s.shape=d}else if(i.type==="NonParametricGeometry")i.data.groups&&i.data.groups?.forEach(d=>d.materialIndex=Math.max(d.materialIndex??0,0)),s.geometry=new Qg.BufferGeometryLoader().parse(i);else if(i.type==="SubdivGeometry"){let d=new bt(i,e);return d.data=n,d}else if(i.type==="TextGeometry")return new xa(i,t);let l;try{l=Jd(s)}catch(d){console.error(d)}if(!l){let d=Re.createFromState(Wi.defaultData(),100,100);s.shape=d,l=Jd(s)}return l}var Zg=require("three"),WC=new Zg.Matrix4;function js(n,t,e,r){let o=n.position.array,i=n.normal.array,a=WC.makeScale(t,e,r).invert().elements,s,l,d;for(var c=0,u=o.length;c<u;c+=3)o[c]*=t,o[c+1]*=e,o[c+2]*=r,s=i[c],l=i[c+1],d=i[c+2],i[c]=a[0]*s+a[4]*l+a[8]*d,i[c+1]=a[1]*s+a[5]*l+a[9]*d,i[c+2]=a[2]*s+a[6]*l+a[10]*d;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var qc=new Ye.Box3,ba=new Ye.Vector3,he;va.then(n=>{he=n});var Jg=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),e0=new Uint32Array([0,1,2,3]),t0=new Uint8Array([4]),bt=class extends Ye.BufferGeometry{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,i=an.div(r,o);this.subdividedGeometry&&js(this.subdividedGeometry.attributes,...i),this.originalGeometry&&js(this.originalGeometry.attributes,...i),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*i[0],height:a.height*i[1],depth:a.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(ba.fromArray(i));let s=ba.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}=bt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Ye.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(bt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Ye.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;qc.setFromBufferAttribute(r),qc.getCenter(o),e.boundingSphere.radius=o.distanceTo(qc.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),qc.getSize(ba);let i={width:ba.x,height:ba.y,depth:ba.z};return this.userData.parameters=i,i}static build(e,r,o,i){let a,s,l,d=e?.phongAngle??35;o===!1&&(d=-1),r&&(he.free_bvh(r),he.free_subdivision_surface(r));try{a=bt.allocate(e,i)}catch(c){console.error(c,e),a=bt.allocate({positionWASM:Jg,indexWASM:e0,verticesPerFaceWASM:t0},i)}if(he.set_destination_refinement_level(a,0),s=bt.buildLevel(a,!0,d),e.subdivisions>0)try{he.set_destination_refinement_level(a,e.subdivisions),l=bt.buildLevel(a,!1,d)}catch{try{he.set_destination_refinement_level(a,e.subdivisions-1),l=bt.buildLevel(a,!1,d)}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 i=e.shape!==void 0||e.path!==void 0?r.geometry:Zn(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,l,d,c;({positions:s,triIndices:c}=op(i.getAttribute("position"),a));let u;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;u=[p,f]}return{indices:l,verticesPerFace:d}=np(s,c,i,u),{positions:s,indices:l,verticesPerFace:d}}static allocate(e,r){let o,i,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=Jg,i=e0,a=t0);let d=o.length,c=i.length,u=a.length,p=o.length+s.length+l.length,f=i.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,g=he._malloc(h),x=new Float32Array(he.HEAPF32.buffer,g,p),S=new Uint32Array(he.HEAPU32.buffer,g+m,f);x.set(o,0),x.set(s,o.length),x.set(l,o.length+s.length),S.set(i,0),S.set(a,i.length);let w;e?.scaleBaked?.some(_=>_!==1)&&(w=new Ye.Matrix4().makeScale(...e.scaleBaked)),r&&(w?w.premultiply(r):w=r);let b=w?he.alloc_subdivision_surface2(g,d,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,u,w.elements):he.alloc_subdivision_surface(g,d,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,u);return he._free(g),b}static buildLevel(e,r,o,i,a){let s=a?he.get_mesh_data2(e,r?he.Level.CONTROL:he.Level.REFINED,o,a.elements):he.get_mesh_data(e,r?he.Level.CONTROL:he.Level.REFINED,o),l=8,d=he.HEAPU32.subarray(s>>2,(s>>2)+l),c=d.subarray(4,4+4),u=0,p=he.HEAPU32[d[u]>>2],f=he.HEAPF32.subarray(p>>2,(p>>2)+c[u]);u++;let h=he.HEAPU32[d[u]>>2],m=he.HEAPF32.subarray(h>>2,(h>>2)+c[u]);u++;let y=he.HEAPU32[d[u]>>2],g=he.HEAPU32.subarray(y>>2,(y>>2)+c[u]);u++;let x=he.HEAPU32[d[u]>>2],S=he.HEAPU32.subarray(x>>2,(x>>2)+c[u]);if(u++,i===void 0){let w=new Ye.BufferGeometry;if(w.setIndex(new Ye.Uint32BufferAttribute(S,1)),w.setAttribute("position",new Ye.Float32BufferAttribute(f,3)),w.setAttribute("normal",new Ye.Float32BufferAttribute(m,3)),r){w.setAttribute("faceMap",new Ye.Uint32BufferAttribute(g,1));let b=new Float32Array(m.length/3*4).fill(0);w.setAttribute("color",new Ye.BufferAttribute(b,4))}return he.free_mesh_data(s),w.userData.type="SubdivGeometry",w}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,he.free_mesh_data(s)}static freeSubdivPointer(e){he.free_bvh(e),he.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let i=he.get_wireframe_data_for_base_level(e),a=4,s=he.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),d=0,c=he.HEAPU32[s[d]>>2],u=he.HEAPF32.subarray(c>>2,(c>>2)+l[d]);d++;let p=he.HEAPU32[s[d]>>2],f=he.HEAPU32.subarray(p>>2,(p>>2)+l[d]);if(r===void 0){let h=new Ye.BufferGeometry;h.setAttribute("position",new Ye.Float32BufferAttribute(u,3));let m=new Float32Array(u.length);for(let y=0,g=u.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new Ye.BufferAttribute(m,3)),h.setIndex(new Ye.Uint32BufferAttribute(f,1)),he.free_wireframe_data_for_base_level(i),h}r.getAttribute("position").copyArray(u),r.attributes.position.needsUpdate=!0,he.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,r,o){let i=r===0;i||he.set_destination_refinement_level(e,r);let a=o?he.get_topological_data2(e,i?he.Level.CONTROL:he.Level.REFINED,o.elements):he.get_topological_data(e,i?he.Level.CONTROL:he.Level.REFINED),s=6,l=he.HEAPU32.subarray(a>>2,(a>>2)+s),d=l.subarray(3,3+3),c=0,u=he.HEAPU32[l[c]>>2],p=new Float32Array(he.HEAPF32.subarray(u>>2,(u>>2)+d[c]));c++;let f=he.HEAPU32[l[c]>>2],h=new Uint32Array(he.HEAPU32.subarray(f>>2,(f>>2)+d[c]));c++;let m=he.HEAPU32[l[c]>>2],y=new Uint8Array(he.HEAPU32.subarray(m>>2,(m>>2)+d[c]));return he.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var r0=["getX","getY","getZ"];function op(n,t){let e={},r=t?t.count:n.count,o=0,i=[],a=[],s=1e4;for(let d=0;d<r;d++){let c=t?t.getX(d):d,u="";for(let p=0;p<3;p++)u+=`${~~(n[r0[p]](c)*s)},`;if(u in e)i.push(e[u]);else{for(let p=0;p<3;p++)a.push(n[r0[p]](c));e[u]=o,i.push(o),o++}}let l=[];for(let d=0;d<i.length;d+=3)i[d]===i[d+1]||i[d]===i[d+2]||i[d+1]===i[d+2]||l.push(i[d],i[d+1],i[d+2]);return{positions:a,triIndices:l}}var Wc=new Ye.Vector3,ep=new Ye.Vector3,tp=new Ye.Vector3,rp=new Ye.Vector3;function np(n,t,e,r){let o=[],i=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),d=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&d<=24&&d%4===0&&e.userData.parameters.angle>=360){let p=l.length/2/d;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let c=0;for(let p=0;p<l.length;p+=2)c+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);n.length=0;let u=0;if(c<0)for(let p=0;p<l.length;p+=2)n.push(l[p],l[p+1],0),o.push(u++);else for(let p=l.length-2;p>=0;p-=2)n.push(l[p],l[p+1],0),o.push(u++);return i.push(u),{indices:o,verticesPerFace:i}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[t[s]*3+2]===a||n[t[s]*3+2]===0)&&l++,(n[t[s+1]*3+2]===a||n[t[s+1]*3+2]===0)&&l++,(n[t[s+2]*3+2]===a||n[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]){Wc.set(n[t[s]*3],n[t[s]*3+1],n[t[s]*3+2]),ep.set(n[t[s+1]*3],n[t[s+1]*3+1],n[t[s+1]*3+2]),tp.set(n[t[s+4]*3],n[t[s+4]*3+1],n[t[s+4]*3+2]),rp.set(n[t[s+5]*3],n[t[s+5]*3+1],n[t[s+5]*3+2]),ep.sub(Wc).normalize(),tp.sub(Wc).normalize(),rp.sub(Wc).normalize();let l=ep.cross(tp).dot(rp);Math.abs(l)>.005||r&&r.some((d,c)=>c%2===1?!1:s>=r[c]&&s<r[c+1])?(o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),i.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],d=[],c=0;for(let u=0,p=0;u<n.length;u+=3,p++)n[u+2]===0&&(l.push(p),c++),n[u+2]===a&&d.push(p);if(e.userData.parameters.extrudeBevelSize===0){let u=d[0];d[0]=d[1],d[1]=u}l.reverse(),o.push(...l,...d),i.push(c,c)}return{indices:o,verticesPerFace:i}}var Ir={};Zp(Ir,{calcBoolean:()=>KC,calcBooleanTopological:()=>XC,freeMeshSet:()=>eP,getMeshSet:()=>QC,hasOpenEdges:()=>ZC,transformMeshSet:()=>JC});var $C,o0=new Promise(n=>{$C=n});var Us=require("three");var Ce,Sa;o0.then(n=>Ce=n);function YC(n,t,e){let r,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:a}=op(n.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:d}=np(i,a,n);s=d.length,r=[];for(let c=0,u=0;c<s;c++){r.push(d[c]);for(let p=0;p<d[c];p++)r.push(l[u++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let d=0,c=0;c<r.length;)r[c++]=3,s++,r[c++]=a[d++],r[c++]=a[d++],r[c++]=a[d++]}return{positions:i,faceIndices:r,nFaces:s}}function n0(n){let t=n.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:r,i=Ce._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Ce.HEAPU32.buffer,i,t):new Float32Array(Ce.HEAPF32.buffer,i,t)).set(n,0),i}function i0(n){switch(n){case 0:return Ce.OP.UNION;case 1:return Ce.OP.INTERSECTION;case 2:return Ce.OP.A_MINUS_B;case 3:return Ce.OP.B_MINUS_A;case 4:return Ce.OP.SYMMETRIC_DIFFERENCE;case 5:return Ce.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function XC(n,t){Sa===void 0&&(Sa=Ce.init_csg());let e=n0(n),r=Ce.csg_calc_topological(Sa,e,n.length,i0(t));Ce._free(e);let o=6,i=Ce.HEAPU32.subarray(r>>2,(r>>2)+o),a=i.subarray(3,3+3),s=0,l=Ce.HEAPU32[i[s]>>2],d=new Float32Array(Ce.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let c=Ce.HEAPU32[i[s]>>2],u=new Uint32Array(Ce.HEAPU32.subarray(c>>2,(c>>2)+a[s]));s++;let p=Ce.HEAPU32[i[s]>>2],f=new Uint8Array(Ce.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Ce.free_mesh_data(r),{positions:d,indices:u,verticesPerFace:f}}function KC(n,t,e,r){Sa===void 0&&(Sa=Ce.init_csg());let o=n0(n),i=Ce.csg_calc(Sa,o,n.length,r,i0(t));Ce._free(o);let a=5,s=Ce.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),d=0,c=Ce.HEAPU32[s[d]>>2],u=Ce.HEAPF32.subarray(c>>2,(c>>2)+l[d]);d++;let p=Ce.HEAPU32[s[d]>>2],f=Ce.HEAPF32.subarray(p>>2,(p>>2)+l[d]);d++;let h=l[d];e.setAttribute("position",new Us.Float32BufferAttribute(u,3)),e.setAttribute("normal",new Us.Float32BufferAttribute(f,3));let m=Ce.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Us.Sphere),e.boundingSphere.radius=-1,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Ce.free_mesh_data(i),h}function QC(n,t,e){if(Ce===void 0)return-1;let r,o,i;if(t&&n.userData.positions!==void 0){let g=n.userData;i=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((x,S)=>x+S,0)+i);for(let x=0,S=0,w=0;x<g.verticesPerFace.length;x++){o[w++]=g.verticesPerFace[x];for(let b=0;b<g.verticesPerFace[x];b++)o[w++]=g.indices[S++]}}else({positions:r,faceIndices:o,nFaces:i}=YC(n,t,e));let a=r.length,s=o.length,l=r.length,d=o.length,c=l*Float32Array.BYTES_PER_ELEMENT+d*Uint32Array.BYTES_PER_ELEMENT,u=l*Float32Array.BYTES_PER_ELEMENT,p=d*Uint32Array.BYTES_PER_ELEMENT,f=Ce._malloc(c),h=new Float32Array(Ce.HEAPF32.buffer,f,l),m=new Uint32Array(Ce.HEAPU32.buffer,f+u,d);h.set(r,0),m.set(o,0);let y=Ce.get_csg_mesh(f,a,f+u,s,i);return Ce._free(f),y}function ZC(n){return Ce.has_open_edges(n)}function JC(n,t){Ce.transform_csg_mesh(n,t.elements)}function eP(n){Ce.free_csg_mesh(n)}var tP={ConeGeometry:$y,CubeGeometry:Yy,CylinderGeometry:Wy,DodecahedronGeometry:Ky,EllipseGeometry:ha,HelixGeometry:Tg,IcosahedronGeometry:Pg,LatheGeometry:Og,NonParametricGeometry:Eg,PolygonGeometry:Fc,PyramidGeometry:Dg,RectangleGeometry:jc,SphereGeometry:Lg,PlaneGeometry:Rg,BackdropGeometry:Vg,StarGeometry:Uc,TextFrameGeometry:zg,TorusGeometry:kg,TorusKnotGeometry:jg,TriangleGeometry:Ug,PathGeometry:qg,VectorGeometry:dr},Jd=n=>tP[n.type].create(n);function wa(n){return n!==null&&"booleanOp"in n}var _a=class extends aa($c.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new $c.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!wa(this.parent)&&this.visible,wa(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Ir.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),wa(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof _a&&(e.freeBooleanPointer(),wa(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&wa(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),wa(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Yc=new Aa.Box3;function Hs(n,t=0,e=n.count,r,o){let i=1/0,a=1/0,s=1/0,l=-1/0,d=-1/0,c=-1/0;for(let u=t;u<e;u++){let p=n.getX(u),f=n.getY(u),h=n.getZ(u);p<i&&(i=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>d&&(d=f),h>c&&(c=h)}Yc.min.set(i,a,s),Yc.max.set(l,d,c),Yc.getCenter(r),Yc.getSize(o).multiplyScalar(.5)}var rP=new Aa.BufferGeometry,oP=new Aa.MeshBasicMaterial,Ut=class extends _a{constructor(t,e){super(rP,oP),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?Hs(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var qo=require("three");var Pr=require("three");var O0=require("three");var Kr=require("three");var qs=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 a0=require("three"),Rt=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=a0.MathUtils.generateUUID(),this.type=t,this.name=""}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,i,a){return""}generate(t,e,r,o,i){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}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof Rt&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)e=this.hashProperties[o],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}};var ip=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}},Pt=new ip;var ap=require("three");var s0=require("three"),se=class extends Rt{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,i){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=s0.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,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 d=this.getTemp(e,o);if(d)return e.format(d,l,r);{d=super.generate(e,r,o,s.output,i);let c=this.generate(e,l,o);return e.addNodeCode(d+" = "+c+";"),e.format(d,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,i,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),a,this.getLabel()).name}};var Ue=class extends se{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,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,r)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,r))}};var lt=class extends Ue{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof ap.Vector2?e:new ap.Vector2(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,i,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,r)}};var sp=require("three");var Ht=class extends Ue{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof sp.Vector3?e:new sp.Vector3(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,i,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,r)}};var l0=require("three"),Ot=class extends l0.Color{constructor(e,r,o,i){super(e,r,o);this.isColorA=!0;this.a=i}setRGBA(e,r,o,i){super.setRGB(e,r,o),this.a=i}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}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 i,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(i[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(i[4]):1,super.setStyle(e,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 pr=class extends Ue{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ot?e:new Ot(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,i,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,r)}};var nP=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,c0=/[a-z_0-9]+/gi,K=class extends se{constructor(e,r,o,i,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,i)}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,i,a){let s,l=0,d=this.src;if(this.includes)for(let u=0;u<this.includes.length;u++)e.include(this.includes[u],this);for(let u in this.extensions)e.extensions[u]=!0;let c=[];for(;s=c0.exec(this.src);)c.push(s);for(let u=0;u<c.length;u++){let p=c[u],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Pt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Pt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Pt.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&d[p.index+l-1]!=="."&&(d=d.substring(0,p.index+l)+m+d.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Pt.contains(m)&&e.include(Pt.get(m))}return r==="source"?d:this.isMethod?(this.isInterface||e.include(this,void 0,d),this.name):e.format("( "+d+" )",this.getType(e),r)}parse(e,r,o,i){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let a=nP.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(c0);if(s){let l=0;for(;l<s.length;){let d=s[l++],c;d==="in"||d==="out"||d==="inout"?c=s[l++]:(c=d,d="");let u=s[l++];this.inputs.push({name:u,type:c,qualifier:d})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var iP=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,lp=class extends se{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||lp.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,i,a){this.src=e||"";let s,l,d="",c=iP.exec(e);this.useDefine=a??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],s=c[2],d=c[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=d}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,i,a){return e.format(this.name,this.getType(e),r)}},Be=lp;Be.PI="PI",Be.PI2="PI2",Be.RECIPROCAL_PI="RECIPROCAL_PI",Be.RECIPROCAL_PI2="RECIPROCAL_PI2",Be.LOG2="LOG2",Be.EPSILON="EPSILON";var aP=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
17
+ `&&r.push("")):t.getTextWidth(r[r.length-1]+o,n)>n.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+o,n)>n.width&&(o.length===1?(r[r.length-1]+=o,o=""):(r[r.length-1]+=o.slice(0,-1),o=o[o.length-1],r.push(""))));return r[r.length-1]+=o,r}var Ye=require("three");var Xg,va=new Promise(n=>{Xg=n}),Yg=!1;var Hc;function Kg(){if(Yg)return;if(Hc)return Hc;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.526/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(d=>d.arrayBuffer())]),s=i.default,l=await s({wasmBinary:a});Xg(l),Yg=!0}return Hc=n(),Hc}var Qg=require("three");var qC=["font"];function Zn(n,t,e,r){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let d of a){let c=i;for(let u of d)c=c[u];for(o in c){let u=c[o];sd(u)&&!qC.includes(o)&&(c[o]=t.getVariable(u,[r.uuid,"geometry",...d,o]),sd(c[o])&&(c[o]=1))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let d=Re.createFromState(i.shape,i.width,i.height);s.shape=d}else if(i.type==="NonParametricGeometry")i.data.groups&&i.data.groups?.forEach(d=>d.materialIndex=Math.max(d.materialIndex??0,0)),s.geometry=new Qg.BufferGeometryLoader().parse(i);else if(i.type==="SubdivGeometry"){let d=new bt(i,e);return d.data=n,d}else if(i.type==="TextGeometry")return new xa(i,t);let l;try{l=Jd(s)}catch(d){console.error(d)}if(!l){let d=Re.createFromState(Wi.defaultData(),100,100);s.shape=d,l=Jd(s)}return l}var Zg=require("three"),WC=new Zg.Matrix4;function js(n,t,e,r){let o=n.position.array,i=n.normal.array,a=WC.makeScale(t,e,r).invert().elements,s,l,d;for(var c=0,u=o.length;c<u;c+=3)o[c]*=t,o[c+1]*=e,o[c+2]*=r,s=i[c],l=i[c+1],d=i[c+2],i[c]=a[0]*s+a[4]*l+a[8]*d,i[c+1]=a[1]*s+a[5]*l+a[9]*d,i[c+2]=a[2]*s+a[6]*l+a[10]*d;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var qc=new Ye.Box3,ba=new Ye.Vector3,he;va.then(n=>{he=n});var Jg=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),e0=new Uint32Array([0,1,2,3]),t0=new Uint8Array([4]),bt=class extends Ye.BufferGeometry{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,i=an.div(r,o);this.subdividedGeometry&&js(this.subdividedGeometry.attributes,...i),this.originalGeometry&&js(this.originalGeometry.attributes,...i),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*i[0],height:a.height*i[1],depth:a.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(ba.fromArray(i));let s=ba.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}=bt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Ye.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(bt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Ye.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;qc.setFromBufferAttribute(r),qc.getCenter(o),e.boundingSphere.radius=o.distanceTo(qc.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),qc.getSize(ba);let i={width:ba.x,height:ba.y,depth:ba.z};return this.userData.parameters=i,i}static build(e,r,o,i){let a,s,l,d=e?.phongAngle??35;o===!1&&(d=-1),r&&(he.free_bvh(r),he.free_subdivision_surface(r));try{a=bt.allocate(e,i)}catch(c){console.error(c,e),a=bt.allocate({positionWASM:Jg,indexWASM:e0,verticesPerFaceWASM:t0},i)}if(he.set_destination_refinement_level(a,0),s=bt.buildLevel(a,!0,d),e.subdivisions>0)try{he.set_destination_refinement_level(a,e.subdivisions),l=bt.buildLevel(a,!1,d)}catch{try{he.set_destination_refinement_level(a,e.subdivisions-1),l=bt.buildLevel(a,!1,d)}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 i=e.shape!==void 0||e.path!==void 0?r.geometry:Zn(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,l,d,c;({positions:s,triIndices:c}=op(i.getAttribute("position"),a));let u;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;u=[p,f]}return{indices:l,verticesPerFace:d}=np(s,c,i,u),{positions:s,indices:l,verticesPerFace:d}}static allocate(e,r){let o,i,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=Jg,i=e0,a=t0);let d=o.length,c=i.length,u=a.length,p=o.length+s.length+l.length,f=i.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,g=he._malloc(h),x=new Float32Array(he.HEAPF32.buffer,g,p),S=new Uint32Array(he.HEAPU32.buffer,g+m,f);x.set(o,0),x.set(s,o.length),x.set(l,o.length+s.length),S.set(i,0),S.set(a,i.length);let w;e?.scaleBaked?.some(_=>_!==1)&&(w=new Ye.Matrix4().makeScale(...e.scaleBaked)),r&&(w?w.premultiply(r):w=r);let b=w?he.alloc_subdivision_surface2(g,d,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,u,w.elements):he.alloc_subdivision_surface(g,d,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,u);return he._free(g),b}static buildLevel(e,r,o,i,a){let s=a?he.get_mesh_data2(e,r?he.Level.CONTROL:he.Level.REFINED,o,a.elements):he.get_mesh_data(e,r?he.Level.CONTROL:he.Level.REFINED,o),l=8,d=he.HEAPU32.subarray(s>>2,(s>>2)+l),c=d.subarray(4,4+4),u=0,p=he.HEAPU32[d[u]>>2],f=he.HEAPF32.subarray(p>>2,(p>>2)+c[u]);u++;let h=he.HEAPU32[d[u]>>2],m=he.HEAPF32.subarray(h>>2,(h>>2)+c[u]);u++;let y=he.HEAPU32[d[u]>>2],g=he.HEAPU32.subarray(y>>2,(y>>2)+c[u]);u++;let x=he.HEAPU32[d[u]>>2],S=he.HEAPU32.subarray(x>>2,(x>>2)+c[u]);if(u++,i===void 0){let w=new Ye.BufferGeometry;if(w.setIndex(new Ye.Uint32BufferAttribute(S,1)),w.setAttribute("position",new Ye.Float32BufferAttribute(f,3)),w.setAttribute("normal",new Ye.Float32BufferAttribute(m,3)),r){w.setAttribute("faceMap",new Ye.Uint32BufferAttribute(g,1));let b=new Float32Array(m.length/3*4).fill(0);w.setAttribute("color",new Ye.BufferAttribute(b,4))}return he.free_mesh_data(s),w.userData.type="SubdivGeometry",w}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,he.free_mesh_data(s)}static freeSubdivPointer(e){he.free_bvh(e),he.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let i=he.get_wireframe_data_for_base_level(e),a=4,s=he.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),d=0,c=he.HEAPU32[s[d]>>2],u=he.HEAPF32.subarray(c>>2,(c>>2)+l[d]);d++;let p=he.HEAPU32[s[d]>>2],f=he.HEAPU32.subarray(p>>2,(p>>2)+l[d]);if(r===void 0){let h=new Ye.BufferGeometry;h.setAttribute("position",new Ye.Float32BufferAttribute(u,3));let m=new Float32Array(u.length);for(let y=0,g=u.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new Ye.BufferAttribute(m,3)),h.setIndex(new Ye.Uint32BufferAttribute(f,1)),he.free_wireframe_data_for_base_level(i),h}r.getAttribute("position").copyArray(u),r.attributes.position.needsUpdate=!0,he.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,r,o){let i=r===0;i||he.set_destination_refinement_level(e,r);let a=o?he.get_topological_data2(e,i?he.Level.CONTROL:he.Level.REFINED,o.elements):he.get_topological_data(e,i?he.Level.CONTROL:he.Level.REFINED),s=6,l=he.HEAPU32.subarray(a>>2,(a>>2)+s),d=l.subarray(3,3+3),c=0,u=he.HEAPU32[l[c]>>2],p=new Float32Array(he.HEAPF32.subarray(u>>2,(u>>2)+d[c]));c++;let f=he.HEAPU32[l[c]>>2],h=new Uint32Array(he.HEAPU32.subarray(f>>2,(f>>2)+d[c]));c++;let m=he.HEAPU32[l[c]>>2],y=new Uint8Array(he.HEAPU32.subarray(m>>2,(m>>2)+d[c]));return he.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var r0=["getX","getY","getZ"];function op(n,t){let e={},r=t?t.count:n.count,o=0,i=[],a=[],s=1e4;for(let d=0;d<r;d++){let c=t?t.getX(d):d,u="";for(let p=0;p<3;p++)u+=`${~~(n[r0[p]](c)*s)},`;if(u in e)i.push(e[u]);else{for(let p=0;p<3;p++)a.push(n[r0[p]](c));e[u]=o,i.push(o),o++}}let l=[];for(let d=0;d<i.length;d+=3)i[d]===i[d+1]||i[d]===i[d+2]||i[d+1]===i[d+2]||l.push(i[d],i[d+1],i[d+2]);return{positions:a,triIndices:l}}var Wc=new Ye.Vector3,ep=new Ye.Vector3,tp=new Ye.Vector3,rp=new Ye.Vector3;function np(n,t,e,r){let o=[],i=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),d=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&d<=24&&d%4===0&&e.userData.parameters.angle>=360){let p=l.length/2/d;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let c=0;for(let p=0;p<l.length;p+=2)c+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);n.length=0;let u=0;if(c<0)for(let p=0;p<l.length;p+=2)n.push(l[p],l[p+1],0),o.push(u++);else for(let p=l.length-2;p>=0;p-=2)n.push(l[p],l[p+1],0),o.push(u++);return i.push(u),{indices:o,verticesPerFace:i}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[t[s]*3+2]===a||n[t[s]*3+2]===0)&&l++,(n[t[s+1]*3+2]===a||n[t[s+1]*3+2]===0)&&l++,(n[t[s+2]*3+2]===a||n[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]){Wc.set(n[t[s]*3],n[t[s]*3+1],n[t[s]*3+2]),ep.set(n[t[s+1]*3],n[t[s+1]*3+1],n[t[s+1]*3+2]),tp.set(n[t[s+4]*3],n[t[s+4]*3+1],n[t[s+4]*3+2]),rp.set(n[t[s+5]*3],n[t[s+5]*3+1],n[t[s+5]*3+2]),ep.sub(Wc).normalize(),tp.sub(Wc).normalize(),rp.sub(Wc).normalize();let l=ep.cross(tp).dot(rp);Math.abs(l)>.005||r&&r.some((d,c)=>c%2===1?!1:s>=r[c]&&s<r[c+1])?(o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),i.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],d=[],c=0;for(let u=0,p=0;u<n.length;u+=3,p++)n[u+2]===0&&(l.push(p),c++),n[u+2]===a&&d.push(p);if(e.userData.parameters.extrudeBevelSize===0){let u=d[0];d[0]=d[1],d[1]=u}l.reverse(),o.push(...l,...d),i.push(c,c)}return{indices:o,verticesPerFace:i}}var Ir={};Zp(Ir,{calcBoolean:()=>KC,calcBooleanTopological:()=>XC,freeMeshSet:()=>eP,getMeshSet:()=>QC,hasOpenEdges:()=>ZC,transformMeshSet:()=>JC});var $C,o0=new Promise(n=>{$C=n});var Us=require("three");var Ce,Sa;o0.then(n=>Ce=n);function YC(n,t,e){let r,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:a}=op(n.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:d}=np(i,a,n);s=d.length,r=[];for(let c=0,u=0;c<s;c++){r.push(d[c]);for(let p=0;p<d[c];p++)r.push(l[u++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let d=0,c=0;c<r.length;)r[c++]=3,s++,r[c++]=a[d++],r[c++]=a[d++],r[c++]=a[d++]}return{positions:i,faceIndices:r,nFaces:s}}function n0(n){let t=n.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:r,i=Ce._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Ce.HEAPU32.buffer,i,t):new Float32Array(Ce.HEAPF32.buffer,i,t)).set(n,0),i}function i0(n){switch(n){case 0:return Ce.OP.UNION;case 1:return Ce.OP.INTERSECTION;case 2:return Ce.OP.A_MINUS_B;case 3:return Ce.OP.B_MINUS_A;case 4:return Ce.OP.SYMMETRIC_DIFFERENCE;case 5:return Ce.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function XC(n,t){Sa===void 0&&(Sa=Ce.init_csg());let e=n0(n),r=Ce.csg_calc_topological(Sa,e,n.length,i0(t));Ce._free(e);let o=6,i=Ce.HEAPU32.subarray(r>>2,(r>>2)+o),a=i.subarray(3,3+3),s=0,l=Ce.HEAPU32[i[s]>>2],d=new Float32Array(Ce.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let c=Ce.HEAPU32[i[s]>>2],u=new Uint32Array(Ce.HEAPU32.subarray(c>>2,(c>>2)+a[s]));s++;let p=Ce.HEAPU32[i[s]>>2],f=new Uint8Array(Ce.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Ce.free_mesh_data(r),{positions:d,indices:u,verticesPerFace:f}}function KC(n,t,e,r){Sa===void 0&&(Sa=Ce.init_csg());let o=n0(n),i=Ce.csg_calc(Sa,o,n.length,r,i0(t));Ce._free(o);let a=5,s=Ce.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),d=0,c=Ce.HEAPU32[s[d]>>2],u=Ce.HEAPF32.subarray(c>>2,(c>>2)+l[d]);d++;let p=Ce.HEAPU32[s[d]>>2],f=Ce.HEAPF32.subarray(p>>2,(p>>2)+l[d]);d++;let h=l[d];e.setAttribute("position",new Us.Float32BufferAttribute(u,3)),e.setAttribute("normal",new Us.Float32BufferAttribute(f,3));let m=Ce.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Us.Sphere),e.boundingSphere.radius=-1,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Ce.free_mesh_data(i),h}function QC(n,t,e){if(Ce===void 0)return-1;let r,o,i;if(t&&n.userData.positions!==void 0){let g=n.userData;i=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((x,S)=>x+S,0)+i);for(let x=0,S=0,w=0;x<g.verticesPerFace.length;x++){o[w++]=g.verticesPerFace[x];for(let b=0;b<g.verticesPerFace[x];b++)o[w++]=g.indices[S++]}}else({positions:r,faceIndices:o,nFaces:i}=YC(n,t,e));let a=r.length,s=o.length,l=r.length,d=o.length,c=l*Float32Array.BYTES_PER_ELEMENT+d*Uint32Array.BYTES_PER_ELEMENT,u=l*Float32Array.BYTES_PER_ELEMENT,p=d*Uint32Array.BYTES_PER_ELEMENT,f=Ce._malloc(c),h=new Float32Array(Ce.HEAPF32.buffer,f,l),m=new Uint32Array(Ce.HEAPU32.buffer,f+u,d);h.set(r,0),m.set(o,0);let y=Ce.get_csg_mesh(f,a,f+u,s,i);return Ce._free(f),y}function ZC(n){return Ce.has_open_edges(n)}function JC(n,t){Ce.transform_csg_mesh(n,t.elements)}function eP(n){Ce.free_csg_mesh(n)}var tP={ConeGeometry:$y,CubeGeometry:Yy,CylinderGeometry:Wy,DodecahedronGeometry:Ky,EllipseGeometry:ha,HelixGeometry:Tg,IcosahedronGeometry:Pg,LatheGeometry:Og,NonParametricGeometry:Eg,PolygonGeometry:Fc,PyramidGeometry:Dg,RectangleGeometry:jc,SphereGeometry:Lg,PlaneGeometry:Rg,BackdropGeometry:Vg,StarGeometry:Uc,TextFrameGeometry:zg,TorusGeometry:kg,TorusKnotGeometry:jg,TriangleGeometry:Ug,PathGeometry:qg,VectorGeometry:dr},Jd=n=>tP[n.type].create(n);function wa(n){return n!==null&&"booleanOp"in n}var _a=class extends aa($c.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new $c.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!wa(this.parent)&&this.visible,wa(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Ir.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),wa(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof _a&&(e.freeBooleanPointer(),wa(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&wa(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),wa(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Yc=new Aa.Box3;function Hs(n,t=0,e=n.count,r,o){let i=1/0,a=1/0,s=1/0,l=-1/0,d=-1/0,c=-1/0;for(let u=t;u<e;u++){let p=n.getX(u),f=n.getY(u),h=n.getZ(u);p<i&&(i=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>d&&(d=f),h>c&&(c=h)}Yc.min.set(i,a,s),Yc.max.set(l,d,c),Yc.getCenter(r),Yc.getSize(o).multiplyScalar(.5)}var rP=new Aa.BufferGeometry,oP=new Aa.MeshBasicMaterial,Ut=class extends _a{constructor(t,e){super(rP,oP),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?Hs(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var qo=require("three");var Pr=require("three");var O0=require("three");var Kr=require("three");var qs=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 a0=require("three"),Rt=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=a0.MathUtils.generateUUID(),this.type=t,this.name=""}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,i,a){return""}generate(t,e,r,o,i){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}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof Rt&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)e=this.hashProperties[o],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}};var ip=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}},Pt=new ip;var ap=require("three");var s0=require("three"),se=class extends Rt{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,i){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=s0.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,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 d=this.getTemp(e,o);if(d)return e.format(d,l,r);{d=super.generate(e,r,o,s.output,i);let c=this.generate(e,l,o);return e.addNodeCode(d+" = "+c+";"),e.format(d,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,i,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),a,this.getLabel()).name}};var Ue=class extends se{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,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,r)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,r))}};var lt=class extends Ue{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof ap.Vector2?e:new ap.Vector2(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,i,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,r)}};var sp=require("three");var Ht=class extends Ue{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof sp.Vector3?e:new sp.Vector3(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,i,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,r)}};var l0=require("three"),Ot=class extends l0.Color{constructor(e,r,o,i){super(e,r,o);this.isColorA=!0;this.a=i}setRGBA(e,r,o,i){super.setRGB(e,r,o),this.a=i}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}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 i,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(i[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(i[4]):1,super.setStyle(e,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 pr=class extends Ue{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ot?e:new Ot(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,i,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,r)}};var nP=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,c0=/[a-z_0-9]+/gi,K=class extends se{constructor(e,r,o,i,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,i)}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,i,a){let s,l=0,d=this.src;if(this.includes)for(let u=0;u<this.includes.length;u++)e.include(this.includes[u],this);for(let u in this.extensions)e.extensions[u]=!0;let c=[];for(;s=c0.exec(this.src);)c.push(s);for(let u=0;u<c.length;u++){let p=c[u],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Pt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Pt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Pt.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&d[p.index+l-1]!=="."&&(d=d.substring(0,p.index+l)+m+d.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Pt.contains(m)&&e.include(Pt.get(m))}return r==="source"?d:this.isMethod?(this.isInterface||e.include(this,void 0,d),this.name):e.format("( "+d+" )",this.getType(e),r)}parse(e,r,o,i){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let a=nP.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(c0);if(s){let l=0;for(;l<s.length;){let d=s[l++],c;d==="in"||d==="out"||d==="inout"?c=s[l++]:(c=d,d="");let u=s[l++];this.inputs.push({name:u,type:c,qualifier:d})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var iP=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,lp=class extends se{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||lp.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,i,a){this.src=e||"";let s,l,d="",c=iP.exec(e);this.useDefine=a??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],s=c[2],d=c[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=d}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,i,a){return e.format(this.name,this.getType(e),r)}},Be=lp;Be.PI="PI",Be.PI2="PI2",Be.RECIPROCAL_PI="RECIPROCAL_PI",Be.RECIPROCAL_PI2="RECIPROCAL_PI2",Be.LOG2="LOG2",Be.EPSILON="EPSILON";var aP=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
18
18
  )*?)}`,"gim"),sP=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Ta=class extends se{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,i,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=aP.exec(e);if(r){let o=r[2],i;for(;i=sP.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=r[1]}else this.name="";this.type=this.name}};var Ca=class extends se{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:"",i=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(i,this.getType(e),r)}};Pt.addKeyword("uv",function(){return new Ca});Pt.addKeyword("uv2",function(){return new Ca(1)});var Xc=require("three");var Jn=class extends se{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??Jn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Xc.LinearEncoding:return["Linear"];case Xc.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),i=this.getType(e),a=Jn.Nodes[this.method],s=e.include(a);if(s===Jn.LINEAR_TO_LINEAR)return e.format(o,i,r);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",i,r)}else return e.format(s+"( "+o+" )",i,r)}fromEncoding(e){let r=Jn.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=Jn.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},tr=Jn;tr.Nodes={LinearToLinear:new K(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
19
19
  `)),sRGBToLinear:new K(["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(`
20
20
  `)),LinearTosRGB:new K(["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(`
@@ -2777,4 +2777,4 @@ end_header
2777
2777
  A = exp(A) * vColor.a;
2778
2778
  gl_FragColor = vec4(color.rgb, A);
2779
2779
  gVelocity = vec4(0.0); // so it is ignored by TAA
2780
- }`,i={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new ve.Vector2},viewport:{type:"v2",value:new ve.Vector2},basisViewport:{type:"v2",value:new ve.Vector2},debugColor:{type:"v3",value:new ve.Color},covariancesTextureSize:{type:"v2",value:new ve.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new ve.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new ve.ShaderMaterial({uniforms:i,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:ve.NormalBlending,depthTest:!0,depthWrite:!1,side:ve.DoubleSide})}static buildGeomtery(e){let r=new ve.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new ve.BufferAttribute(o,3);r.setAttribute("position",i),i.setXYZ(0,-1,-1,0),i.setXYZ(1,-1,1,0),i.setXYZ(2,1,1,0),i.setXYZ(3,1,-1,0),i.needsUpdate=!0;let a=new ve.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new ve.InstancedBufferAttribute(s,1,!1);return l.setUsage(ve.DynamicDrawUsage),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(i=>i.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let i of this.splatBuffers){let a=i.nsplats;this.colors.subarray(e,e+a*4).set(i.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(i.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(i.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,i=new ve.Vector2(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new ve.Vector2(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(i.x*i.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=ve.DataUtils.toHalfFloat(this.covariances[h]);s=new ve.DataTexture(l,i.x,i.y,ve.RGFormat,ve.HalfFloatType)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new ve.DataTexture(l,i.x,i.y,ve.RGFormat,ve.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(i);let d=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,g=h*4;d[g]=av(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),d[g+1]=Nu(this.centers[y]),d[g+2]=Nu(this.centers[y+1]),d[g+3]=Nu(this.centers[y+2])}let c=new ve.DataTexture(d,a.x,a.y,ve.RGBAIntegerFormat,ve.UnsignedIntType);c.internalFormat="RGBA32UI",c.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=c,this.material.uniforms.centersColorsTextureSize.value.copy(a);let u=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 ve.DataTexture(p,u,1,ve.RGBAFormat,ve.FloatType);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:i},centerColors:{data:d,texture:c,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,i){this.splatCount>0&&(Eu.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Eu),this.material.uniforms.basisViewport.value.set(2/Eu.x,2/Eu.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=i,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose())}};var yl=class{constructor(t={}){Nt(this,"updateSplatMeshUniforms",function(){let t=new vr.Vector2;return function(){if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(this.renderer.getSize(t),this.cameraFocalLengthX=this.camera.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=this.camera.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,this.camera.isPerspectiveCamera?-1:this.camera.zoom*this.devicePixelRatio))}}());Nt(this,"updateView",function(){let t=new vr.Matrix4,e=[],r=new vr.Vector3(0,0,-1),o=new vr.Vector3(0,0,-1),i=new vr.Vector3,a=new vr.Vector3;return function(s=!1){let l=this.updateMatrixWorldsInWorkerIfNeeded(),d=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(this.camera.quaternion);let u=!1,p=!1;if(o.dot(r)<=.95&&(u=!0),a.copy(this.camera.position).sub(i).length()>=1&&(p=!0),!u&&!p&&!l&&!d)return}i.copy(this.camera.position),r.copy(o),t.copy(this.camera.matrixWorld).invert(),t.premultiply(this.camera.perspCamera.projectionMatrix),e[0]=this.camera.position.x,e[1]=this.camera.position.y,e[2]=this.camera.position.z;let c={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...l?{newMatrixWorlds:this.meshMatrixWorlds}:{},...d?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=c:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(c))}}());this.scene=t.scene,this.currentPage=null,this.renderer=t.renderer,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.splatRenderingInitialized=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null}get camera(){return this.scene.activeCamera}reloadSplats(){this.splatRenderingInitialized=!1;let t=this.loadSplat();this.renderer.pipeline.opaquePass.splatViewer=t?this:null}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new vr.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new vr.Quaternion().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseEntity(a=>{if(a.data.type==="Splat"){let s=a.visible;a.traverseAncestors(l=>{s&&(s=l.visible)}),s&&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 Bn(new Uint8Array(a.data.buffer).buffer)),o=0,i=[0];for(let a of r)o+=a.getSplatCount(),i.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,i,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,i)=>{this.cropsArray[r][i]===void 0?(t=!0,this.cropsArray[r][i]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,d)=>l!==this.cropsArray[r][i][a][d])?(t=!0,this.cropsArray[r][i][a]=s):s!==this.cropsArray[r][i]?.[a]&&(t=!0,this.cropsArray[r][i][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 vr.Vector3,o=new vr.Quaternion,i=!1,a=1,s,l){this.splatMesh=Rn.buildMesh(t,e,i,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=10,this.updateSplatMeshUniforms(),this.splatRenderCount=e}setupSortWorker(t){this.sortWorker=iv(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.updateView(!0,!0),this.splatRenderingInitialized=!0)}}update(){this.splatRenderingInitialized!==!1&&(this.updateSplatMeshUniforms(),this.updateView())}getSplatMesh(){return this.splatMesh}};var B2=new Gr.MeshBasicMaterial;B2.wireframe=!0;var sv=new Gr.Vector3,Du=class extends Gr.Scene{constructor(e,r){super();this.data=e;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Ou;this.errorPage=new Nn("fdasfa",{...Vo.defaultData,name:""});this.invisibleObjects=new In("jflkdsafjasdifjaslk",{...vc.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Ox(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Px(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 Nn&&(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=[],i=r;for(;i!==this;){let a=i;i=i.parent;let s=i.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&r.push(i)}return r.sort((o,i)=>tf(o.sortKey,i.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===ln)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}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(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,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 i=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);i.updateVisible(),i.resetBBoxNeedsUpdate(),Mn(i)&&ul(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty(),i.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),ul(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Mn(o)&&(o.freeBooleanPointer(),i instanceof yr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof cs&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),Mn(o)&&(o.invalidateUpstreamBooleanData(),ul(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof yr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Nn&&(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,i){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{Ax(a,r,o,{scene:this,shared:i}),a instanceof St&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}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((i,a)=>({data:i[1].asset.data,children:i[1].asset.children,id:i[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared: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(i=>{i instanceof $o&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Oe.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Oe.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,i,a,s,l){if(e){let d=i.find(e);d&&d!==i&&a.forInstancesRec(c=>{c.data=tn(c.data,u=>{let p=u.events.data(l.id),f=c.goUp(s);if(f){let h=[...vl(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=gt.zoom(p,r);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,i,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,i,a,s):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...r,l.id],"object",o,i,a,s)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Yo&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(i=>{if(i.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=tn(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of _c.list)this.rewriteActions(i.data.gameActions[s],["gameActions",s],e,r,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,r,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,r,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,r,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,r,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,r,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,r,o,i)})}),!0})}expandInstances(e,r,o){let i=new Set;this.traverseEntity(a=>{if(a instanceof Yo&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Tu(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Yo&&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)Oe.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=[],i=a=>{for(let s of a.children){let l=s.cloner;if(Oe.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let d=[];if(e.intersectObject(s,!0,d),d.length){let c=d[0];c.object=s,c.point.applyMatrix4(c.object.matrixWorld);let u=s.matrixWorld.clone().invert();c.point.applyMatrix4(u),o.push(c)}}else(Mn(s)||dl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),ml(s,e,o)),i(s)}};return i(this),o}raycastWithClones(e){let r=[],o=i=>{for(let a of i.children){let s=a.cloner;Oe.is(a)&&(a.visible||s?.object.data.visible)&&((Mn(a)||dl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),ml(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Oe.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Oe.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Oe.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof St&&o.data.type==="Mesh"&&o.data.geometry.type==="TextGeometry"&&o.data.geometry.font===e){let i=o.geometry,a=o.data.geometry;i.updateFont(e,r).then(()=>{i.update(a);let s=o.invalidateDownstreamBooleanData();ul(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)ra.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Oe.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let i=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,i,o),i+=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,i,a,s){let l={scene:this,shared:s},d=Pu(e,r,l);return d&&(this.entityByUuid[e]=d,i.add(d),i.children.splice(a,0,i.children.pop()),o.length>0&&(d.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,d,s)),d.updateState(r,l),d instanceof St&&d.updateGeometryGroupsIfNeeded(),d.updateVisible(),d.cloner&&this.toExpandCloner.add(d),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&d.traverseEntity(c=>{let u=c.dataPatched;if(c instanceof St&&u.bones&&u.boneInverses){let p=u.bones.map(m=>this.find(m)),f=u.boneInverses.map(m=>new Gr.Matrix4().fromArray(m)),h=new Gr.Skeleton(p,f);c.bind(h,c.bindMatrix)}else c.matrixAutoUpdate=!0}),d}getCenter(e){let r=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:l}=e[i],d=this.find(s),c=l?d.recursiveBBox:d.singleBBox;r.push(...c.vertices)}let o=new Gr.Box3;return o.setFromPoints(r),o.getCenter(sv),sv}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 Ut)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof hr&&e(r.material[o]);else r.material instanceof hr&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(i=>{i instanceof $o&&i.setViewplaneSize(e,r,o)})}initializeSplatViewer(e){this.splatViewer=new yl({scene:this,renderer:e}),this.reloadSplats()}reloadSplats(){this.splatViewer?.reloadSplats()}};var lv=require("three/examples/jsm/loaders/DRACOLoader.js");var Vn;function R2(){return Vn||(Vn=new lv.DRACOLoader,Vn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Vn.decoderPending}async function V2(n){if(Vn){let t={attributeIDs:Vn.defaultAttributeIDs,attributeTypes:Vn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Vn.decodeGeometry(new Int8Array(n).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function cv(n,t){let[e,r]=Yu(sc.deserialize(new Uint8Array(n)));Tc(e);let o=[];e.scene.objects.traverse((i,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&a.geometry.data.draco!==void 0&&o.push(a)}),o.length&&await R2();for(let i of o){let a=await V2(at(i.geometry.data.draco));if(a){a.index&&(i.geometry.data.index={array:a.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let s={};a.attributes.forEach(({name:l,array:d,itemSize:c})=>{s[l]={array:d,itemSize:c,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=s,i.geometry.data.draco=void 0}}return t&&t(e),r.result().data}var G2=require("three"),z2=require("three/examples/jsm/utils/BufferGeometryUtils.js");function uv(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}var gl=require("three");function dv(n){let t=new Set;return n.traverse(e=>{if(e instanceof mr)if(ut(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(k2(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new gl.Color,specularColor:new gl.Color});let o=0;e.onBeforeCompile=(i,a)=>{r&&r(i,a),i.uniforms=Object.assign({},gl.ShaderLib.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(i.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=_0(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else F2(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function k2(n){return n.getLayersOfType("transmission").length>0}function F2(n){let t=0;for(let e of n.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function pv(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function fv(n){let t=[],e=(r,o=0)=>{let i=o>0?r+o:r;return t.includes(i)?e(r,o+1):i};return n.traverse(r=>{if(t.includes(r.name)){let o=r.name,i=e(r.name);if(r.name=i,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,i)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,i))}}t.push(r.name)}),n}var hv=require("three/examples/jsm/utils/BufferGeometryUtils.js");function mv(n){let t=[];return n.traverse(e=>{e instanceof Ja&&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(d){console.error(d)}return l!==void 0&&s.matrix.determinant()<0&&uv(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Ut&&a.unshift(r.geometry),a.length){let s=(0,hv.mergeBufferGeometries)(a);r instanceof Ut&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:n,shared:V0})}),n}function yv(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function gv(n){Object.values(n.shared.materials).forEach(t=>{Kp(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?Kp(e.material):"materials"in e&&e.materials.forEach(r=>{Kp(r)})})}function Kp(n){if(typeof n=="string")return;let t=[];n.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{n.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var wv=Qt(vv(),1);function bv(n){return n.traverseMaterial(t=>{t.needsJitter=!1}),n}var Sv="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Lu=class extends Bu.Loader{load(t,e,r,o=console.error){let i=new Bu.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(Sv+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(Sv),i.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 cv(t,gv);e.version&&(0,wv.default)(e.version,"0.9.524")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.all([j0(e)&&Kg(),J0(e)&&B0()].filter(Boolean));let r=new li(e.shared);Object.values(r.getMaterials()).forEach(a=>Object.assign(a,{isAsset:!0}));let o=new Du(e.scene,r),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=mv(o),o=dv(o),o=pv(o),o=fv(o),o=yv(o),o=bv(o),o}};
2780
+ }`,i={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new ve.Vector2},viewport:{type:"v2",value:new ve.Vector2},basisViewport:{type:"v2",value:new ve.Vector2},debugColor:{type:"v3",value:new ve.Color},covariancesTextureSize:{type:"v2",value:new ve.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new ve.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new ve.ShaderMaterial({uniforms:i,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:ve.NormalBlending,depthTest:!0,depthWrite:!1,side:ve.DoubleSide})}static buildGeomtery(e){let r=new ve.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new ve.BufferAttribute(o,3);r.setAttribute("position",i),i.setXYZ(0,-1,-1,0),i.setXYZ(1,-1,1,0),i.setXYZ(2,1,1,0),i.setXYZ(3,1,-1,0),i.needsUpdate=!0;let a=new ve.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new ve.InstancedBufferAttribute(s,1,!1);return l.setUsage(ve.DynamicDrawUsage),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(i=>i.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let i of this.splatBuffers){let a=i.nsplats;this.colors.subarray(e,e+a*4).set(i.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(i.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(i.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,i=new ve.Vector2(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new ve.Vector2(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(i.x*i.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=ve.DataUtils.toHalfFloat(this.covariances[h]);s=new ve.DataTexture(l,i.x,i.y,ve.RGFormat,ve.HalfFloatType)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new ve.DataTexture(l,i.x,i.y,ve.RGFormat,ve.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(i);let d=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,g=h*4;d[g]=av(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),d[g+1]=Nu(this.centers[y]),d[g+2]=Nu(this.centers[y+1]),d[g+3]=Nu(this.centers[y+2])}let c=new ve.DataTexture(d,a.x,a.y,ve.RGBAIntegerFormat,ve.UnsignedIntType);c.internalFormat="RGBA32UI",c.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=c,this.material.uniforms.centersColorsTextureSize.value.copy(a);let u=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 ve.DataTexture(p,u,1,ve.RGBAFormat,ve.FloatType);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:i},centerColors:{data:d,texture:c,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,i){this.splatCount>0&&(Eu.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Eu),this.material.uniforms.basisViewport.value.set(2/Eu.x,2/Eu.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=i,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose())}};var yl=class{constructor(t={}){Nt(this,"updateSplatMeshUniforms",function(){let t=new vr.Vector2;return function(){if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(this.renderer.getSize(t),this.cameraFocalLengthX=this.camera.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=this.camera.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,this.camera.isPerspectiveCamera?-1:this.camera.zoom*this.devicePixelRatio))}}());Nt(this,"updateView",function(){let t=new vr.Matrix4,e=[],r=new vr.Vector3(0,0,-1),o=new vr.Vector3(0,0,-1),i=new vr.Vector3,a=new vr.Vector3;return function(s=!1){let l=this.updateMatrixWorldsInWorkerIfNeeded(),d=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(this.camera.quaternion);let u=!1,p=!1;if(o.dot(r)<=.95&&(u=!0),a.copy(this.camera.position).sub(i).length()>=1&&(p=!0),!u&&!p&&!l&&!d)return}i.copy(this.camera.position),r.copy(o),t.copy(this.camera.matrixWorld).invert(),t.premultiply(this.camera.perspCamera.projectionMatrix),e[0]=this.camera.position.x,e[1]=this.camera.position.y,e[2]=this.camera.position.z;let c={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...l?{newMatrixWorlds:this.meshMatrixWorlds}:{},...d?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=c:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(c))}}());this.scene=t.scene,this.currentPage=null,this.renderer=t.renderer,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.splatRenderingInitialized=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null}get camera(){return this.scene.activeCamera}reloadSplats(){this.splatRenderingInitialized=!1;let t=this.loadSplat();this.renderer.pipeline.opaquePass.splatViewer=t?this:null}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new vr.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new vr.Quaternion().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseEntity(a=>{if(a.data.type==="Splat"){let s=a.visible;a.traverseAncestors(l=>{s&&(s=l.visible)}),s&&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 Bn(new Uint8Array(a.data.buffer).buffer)),o=0,i=[0];for(let a of r)o+=a.getSplatCount(),i.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,i,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,i)=>{this.cropsArray[r][i]===void 0?(t=!0,this.cropsArray[r][i]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,d)=>l!==this.cropsArray[r][i][a][d])?(t=!0,this.cropsArray[r][i][a]=s):s!==this.cropsArray[r][i]?.[a]&&(t=!0,this.cropsArray[r][i][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 vr.Vector3,o=new vr.Quaternion,i=!1,a=1,s,l){this.splatMesh=Rn.buildMesh(t,e,i,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=10,this.updateSplatMeshUniforms(),this.splatRenderCount=e}setupSortWorker(t){this.sortWorker=iv(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.updateView(!0,!0),this.splatRenderingInitialized=!0)}}update(){this.splatRenderingInitialized!==!1&&(this.updateSplatMeshUniforms(),this.updateView())}getSplatMesh(){return this.splatMesh}};var B2=new Gr.MeshBasicMaterial;B2.wireframe=!0;var sv=new Gr.Vector3,Du=class extends Gr.Scene{constructor(e,r){super();this.data=e;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Ou;this.errorPage=new Nn("fdasfa",{...Vo.defaultData,name:""});this.invisibleObjects=new In("jflkdsafjasdifjaslk",{...vc.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Ox(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Px(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 Nn&&(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=[],i=r;for(;i!==this;){let a=i;i=i.parent;let s=i.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&r.push(i)}return r.sort((o,i)=>tf(o.sortKey,i.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===ln)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}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(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,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 i=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);i.updateVisible(),i.resetBBoxNeedsUpdate(),Mn(i)&&ul(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty(),i.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),ul(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Mn(o)&&(o.freeBooleanPointer(),i instanceof yr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof cs&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),Mn(o)&&(o.invalidateUpstreamBooleanData(),ul(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof yr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Nn&&(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,i){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{Ax(a,r,o,{scene:this,shared:i}),a instanceof St&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}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((i,a)=>({data:i[1].asset.data,children:i[1].asset.children,id:i[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared: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(i=>{i instanceof $o&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Oe.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Oe.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,i,a,s,l){if(e){let d=i.find(e);d&&d!==i&&a.forInstancesRec(c=>{c.data=tn(c.data,u=>{let p=u.events.data(l.id),f=c.goUp(s);if(f){let h=[...vl(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=gt.zoom(p,r);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,i,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,i,a,s):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...r,l.id],"object",o,i,a,s)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Yo&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(i=>{if(i.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=tn(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of _c.list)this.rewriteActions(i.data.gameActions[s],["gameActions",s],e,r,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,r,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,r,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,r,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,r,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,r,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,r,o,i)})}),!0})}expandInstances(e,r,o){let i=new Set;this.traverseEntity(a=>{if(a instanceof Yo&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Tu(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Yo&&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)Oe.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=[],i=a=>{for(let s of a.children){let l=s.cloner;if(Oe.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let d=[];if(e.intersectObject(s,!0,d),d.length){let c=d[0];c.object=s,c.point.applyMatrix4(c.object.matrixWorld);let u=s.matrixWorld.clone().invert();c.point.applyMatrix4(u),o.push(c)}}else(Mn(s)||dl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),ml(s,e,o)),i(s)}};return i(this),o}raycastWithClones(e){let r=[],o=i=>{for(let a of i.children){let s=a.cloner;Oe.is(a)&&(a.visible||s?.object.data.visible)&&((Mn(a)||dl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),ml(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Oe.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Oe.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Oe.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof St&&o.data.type==="Mesh"&&o.data.geometry.type==="TextGeometry"&&o.data.geometry.font===e){let i=o.geometry,a=o.data.geometry;i.updateFont(e,r).then(()=>{i.update(a);let s=o.invalidateDownstreamBooleanData();ul(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)ra.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Oe.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let i=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,i,o),i+=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,i,a,s){let l={scene:this,shared:s},d=Pu(e,r,l);return d&&(this.entityByUuid[e]=d,i.add(d),i.children.splice(a,0,i.children.pop()),o.length>0&&(d.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,d,s)),d.updateState(r,l),d instanceof St&&d.updateGeometryGroupsIfNeeded(),d.updateVisible(),d.cloner&&this.toExpandCloner.add(d),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&d.traverseEntity(c=>{let u=c.dataPatched;if(c instanceof St&&u.bones&&u.boneInverses){let p=u.bones.map(m=>this.find(m)),f=u.boneInverses.map(m=>new Gr.Matrix4().fromArray(m)),h=new Gr.Skeleton(p,f);c.bind(h,c.bindMatrix)}else c.matrixAutoUpdate=!0}),d}getCenter(e){let r=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:l}=e[i],d=this.find(s),c=l?d.recursiveBBox:d.singleBBox;r.push(...c.vertices)}let o=new Gr.Box3;return o.setFromPoints(r),o.getCenter(sv),sv}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 Ut)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof hr&&e(r.material[o]);else r.material instanceof hr&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(i=>{i instanceof $o&&i.setViewplaneSize(e,r,o)})}initializeSplatViewer(e){this.splatViewer=new yl({scene:this,renderer:e}),this.reloadSplats()}reloadSplats(){this.splatViewer?.reloadSplats()}};var lv=require("three/examples/jsm/loaders/DRACOLoader.js");var Vn;function R2(){return Vn||(Vn=new lv.DRACOLoader,Vn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Vn.decoderPending}async function V2(n){if(Vn){let t={attributeIDs:Vn.defaultAttributeIDs,attributeTypes:Vn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Vn.decodeGeometry(new Int8Array(n).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function cv(n,t){let[e,r]=Yu(sc.deserialize(new Uint8Array(n)));Tc(e);let o=[];e.scene.objects.traverse((i,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&a.geometry.data.draco!==void 0&&o.push(a)}),o.length&&await R2();for(let i of o){let a=await V2(at(i.geometry.data.draco));if(a){a.index&&(i.geometry.data.index={array:a.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let s={};a.attributes.forEach(({name:l,array:d,itemSize:c})=>{s[l]={array:d,itemSize:c,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=s,i.geometry.data.draco=void 0}}return t&&t(e),r.result().data}var G2=require("three"),z2=require("three/examples/jsm/utils/BufferGeometryUtils.js");function uv(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}var gl=require("three");function dv(n){let t=new Set;return n.traverse(e=>{if(e instanceof mr)if(ut(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(k2(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new gl.Color,specularColor:new gl.Color});let o=0;e.onBeforeCompile=(i,a)=>{r&&r(i,a),i.uniforms=Object.assign({},gl.ShaderLib.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(i.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=_0(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else F2(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function k2(n){return n.getLayersOfType("transmission").length>0}function F2(n){let t=0;for(let e of n.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function pv(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function fv(n){let t=[],e=(r,o=0)=>{let i=o>0?r+o:r;return t.includes(i)?e(r,o+1):i};return n.traverse(r=>{if(t.includes(r.name)){let o=r.name,i=e(r.name);if(r.name=i,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,i)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,i))}}t.push(r.name)}),n}var hv=require("three/examples/jsm/utils/BufferGeometryUtils.js");function mv(n){let t=[];return n.traverse(e=>{e instanceof Ja&&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(d){console.error(d)}return l!==void 0&&s.matrix.determinant()<0&&uv(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Ut&&a.unshift(r.geometry),a.length){let s=(0,hv.mergeBufferGeometries)(a);r instanceof Ut&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:n,shared:V0})}),n}function yv(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function gv(n){Object.values(n.shared.materials).forEach(t=>{Kp(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?Kp(e.material):"materials"in e&&e.materials.forEach(r=>{Kp(r)})})}function Kp(n){if(typeof n=="string")return;let t=[];n.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{n.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var wv=Qt(vv(),1);function bv(n){return n.traverseMaterial(t=>{t.needsJitter=!1}),n}var Sv="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Lu=class extends Bu.Loader{load(t,e,r,o=console.error){let i=new Bu.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(Sv+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(Sv),i.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 cv(t,gv);e.version&&(0,wv.default)(e.version,"0.9.526")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.all([j0(e)&&Kg(),J0(e)&&B0()].filter(Boolean));let r=new li(e.shared);Object.values(r.getMaterials()).forEach(a=>Object.assign(a,{isAsset:!0}));let o=new Du(e.scene,r),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=mv(o),o=dv(o),o=pv(o),o=fv(o),o=yv(o),o=bv(o),o}};