@splinetool/loader 0.9.502 → 0.9.503

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 @@ var qv=Object.create;var Ws=Object.defineProperty;var Wv=Object.getOwnPropertyDe
14
14
  ----------`);var u=new Function("compile",t.join(`
15
15
  `));return u(II.bind(void 0,n))}Jx.exports=NI});var rv=qt((eoe,tv)=>{"use strict";var EI=ev();function LI(){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 DI(n){var t=new LI;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,EI(t)}tv.exports=DI});var Ha=qt(Te=>{"use strict";var er=rv(),uu={body:"",args:[],thisVars:[],localVars:[]};function Up(n){if(!n)return uu;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 BI(n){return er({args:n.args,pre:Up(n.pre),body:Up(n.body),post:Up(n.proc),funcName:n.funcName})}function Qe(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(BI(n))}var ov={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var n in ov){var t=ov[n];Te[n]=Qe({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:n}),Te[n+"eq"]=Qe({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:n+"eq"}),Te[n+"s"]=Qe({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:n+"s"}),Te[n+"seq"]=Qe({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:n+"seq"})}})();var nv={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var n in nv){var t=nv[n];Te[n]=Qe({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:n}),Te[n+"eq"]=Qe({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:n+"eq"})}})();var iv={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var n in iv){var t=iv[n];Te[n]=Qe({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:n}),Te[n+"s"]=Qe({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:n+"s"}),Te[n+"eq"]=Qe({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:n+"eq"}),Te[n+"seq"]=Qe({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:n+"seq"})}})();var av=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var n=0;n<av.length;++n){var t=av[n];Te[t]=Qe({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}),Te[t+"eq"]=Qe({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 sv=["max","min","atan2","pow"];(function(){for(var n=0;n<sv.length;++n){var t=sv[n];Te[t]=Qe({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}),Te[t+"s"]=Qe({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"}),Te[t+"eq"]=Qe({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"}),Te[t+"seq"]=Qe({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 lv=["atan2","pow"];(function(){for(var n=0;n<lv.length;++n){var t=lv[n];Te[t+"op"]=Qe({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"}),Te[t+"ops"]=Qe({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"}),Te[t+"opeq"]=Qe({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"}),Te[t+"opseq"]=Qe({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"})}})();Te.any=er({args:["array"],pre:uu,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"});Te.all=er({args:["array"],pre:uu,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"});Te.sum=er({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"});Te.prod=er({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"});Te.norm2squared=er({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"});Te.norm2=er({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"});Te.norminf=er({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"});Te.norm1=er({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"});Te.sup=er({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:[]}});Te.inf=er({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:[]}});Te.argmin=er({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:[]}});Te.argmax=er({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:[]}});Te.random=Qe({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});Te.assign=Qe({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});Te.assigns=Qe({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});Te.equals=er({args:["array","array"],pre:uu,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 Dv=qt((zie,Lv)=>{Lv.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}});import{FileLoader as vN,Loader as bN}from"three";function Jp(n){for(let t of Object.keys(n))n[t]===void 0&&delete n[t];return n}function Wt(n,t){return Object.setPrototypeOf(n,t),n}function $s(n){return Array.isArray(n)?n:[n]}function ef(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 Jv=typeof global=="object"&&global&&global.Object===Object&&global,Ys=Jv;var eb=typeof self=="object"&&self&&self.Object===Object&&self,tb=Ys||eb||Function("return this")(),lt=tb;var rb=lt.Symbol,gt=rb;var tf=Object.prototype,ob=tf.hasOwnProperty,nb=tf.toString,Wa=gt?gt.toStringTag:void 0;function ib(n){var t=ob.call(n,Wa),e=n[Wa];try{n[Wa]=void 0;var r=!0}catch{}var o=nb.call(n);return r&&(t?n[Wa]=e:delete n[Wa]),o}var rf=ib;var ab=Object.prototype,sb=ab.toString;function lb(n){return sb.call(n)}var of=lb;var cb="[object Null]",ub="[object Undefined]",nf=gt?gt.toStringTag:void 0;function db(n){return n==null?n===void 0?ub:cb:nf&&nf in Object(n)?rf(n):of(n)}var rr=db;function pb(n){return n!=null&&typeof n=="object"}var Ct=pb;var fb="[object Symbol]";function hb(n){return typeof n=="symbol"||Ct(n)&&rr(n)==fb}var Zn=hb;function mb(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 Xs=mb;var yb=Array.isArray,Ze=yb;var gb=1/0,af=gt?gt.prototype:void 0,sf=af?af.toString:void 0;function lf(n){if(typeof n=="string")return n;if(Ze(n))return Xs(n,lf)+"";if(Zn(n))return sf?sf.call(n):"";var t=n+"";return t=="0"&&1/n==-gb?"-0":t}var cf=lf;function xb(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var or=xb;function vb(n){return n}var uf=vb;var bb="[object AsyncFunction]",Sb="[object Function]",wb="[object GeneratorFunction]",_b="[object Proxy]";function Ab(n){if(!or(n))return!1;var t=rr(n);return t==Sb||t==wb||t==bb||t==_b}var Ks=Ab;var Tb=lt["__core-js_shared__"],Qs=Tb;var df=function(){var n=/[^.]+$/.exec(Qs&&Qs.keys&&Qs.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function Cb(n){return!!df&&df in n}var pf=Cb;var Pb=Function.prototype,Ob=Pb.toString;function Mb(n){if(n!=null){try{return Ob.call(n)}catch{}try{return n+""}catch{}}return""}var po=Mb;var Ib=/[\\^$.*+?()[\]{}|]/g,Nb=/^\[object .+?Constructor\]$/,Eb=Function.prototype,Lb=Object.prototype,Db=Eb.toString,Bb=Lb.hasOwnProperty,Rb=RegExp("^"+Db.call(Bb).replace(Ib,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Vb(n){if(!or(n)||pf(n))return!1;var t=Ks(n)?Rb:Nb;return t.test(po(n))}var ff=Vb;function Gb(n,t){return n?.[t]}var hf=Gb;function zb(n,t){var e=hf(n,t);return ff(e)?e:void 0}var $t=zb;var kb=$t(lt,"WeakMap"),Zs=kb;var mf=Object.create,Fb=function(){function n(){}return function(t){if(!or(t))return{};if(mf)return mf(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),yf=Fb;function jb(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 gf=jb;function Ub(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}var xf=Ub;var Hb=800,qb=16,Wb=Date.now;function $b(n){var t=0,e=0;return function(){var r=Wb(),o=qb-(r-e);if(e=r,o>0){if(++t>=Hb)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var vf=$b;function Yb(n){return function(){return n}}var bf=Yb;var Xb=function(){try{var n=$t(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Jn=Xb;var Kb=Jn?function(n,t){return Jn(n,"toString",{configurable:!0,enumerable:!1,value:bf(t),writable:!0})}:uf,Sf=Kb;var Qb=vf(Sf),wf=Qb;function Zb(n,t){for(var e=-1,r=n==null?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}var _f=Zb;var Jb=9007199254740991,eS=/^(?:0|[1-9]\d*)$/;function tS(n,t){var e=typeof n;return t=t??Jb,!!t&&(e=="number"||e!="symbol"&&eS.test(n))&&n>-1&&n%1==0&&n<t}var ei=tS;function rS(n,t,e){t=="__proto__"&&Jn?Jn(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}var Js=rS;function oS(n,t){return n===t||n!==n&&t!==t}var ti=oS;var nS=Object.prototype,iS=nS.hasOwnProperty;function aS(n,t,e){var r=n[t];(!(iS.call(n,t)&&ti(r,e))||e===void 0&&!(t in n))&&Js(n,t,e)}var ri=aS;function sS(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?Js(e,s,l):ri(e,s,l)}return e}var Rr=sS;var Af=Math.max;function lS(n,t,e){return t=Af(t===void 0?n.length-1:t,0),function(){for(var r=arguments,o=-1,i=Af(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),gf(n,this,s)}}var Tf=lS;var cS=9007199254740991;function uS(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=cS}var oi=uS;function dS(n){return n!=null&&oi(n.length)&&!Ks(n)}var el=dS;var pS=Object.prototype;function fS(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||pS;return n===e}var ni=fS;function hS(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var Cf=hS;var mS="[object Arguments]";function yS(n){return Ct(n)&&rr(n)==mS}var yu=yS;var Pf=Object.prototype,gS=Pf.hasOwnProperty,xS=Pf.propertyIsEnumerable,vS=yu(function(){return arguments}())?yu:function(n){return Ct(n)&&gS.call(n,"callee")&&!xS.call(n,"callee")},ii=vS;function bS(){return!1}var Of=bS;var Nf=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mf=Nf&&typeof module=="object"&&module&&!module.nodeType&&module,SS=Mf&&Mf.exports===Nf,If=SS?lt.Buffer:void 0,wS=If?If.isBuffer:void 0,_S=wS||Of,xn=_S;var AS="[object Arguments]",TS="[object Array]",CS="[object Boolean]",PS="[object Date]",OS="[object Error]",MS="[object Function]",IS="[object Map]",NS="[object Number]",ES="[object Object]",LS="[object RegExp]",DS="[object Set]",BS="[object String]",RS="[object WeakMap]",VS="[object ArrayBuffer]",GS="[object DataView]",zS="[object Float32Array]",kS="[object Float64Array]",FS="[object Int8Array]",jS="[object Int16Array]",US="[object Int32Array]",HS="[object Uint8Array]",qS="[object Uint8ClampedArray]",WS="[object Uint16Array]",$S="[object Uint32Array]",qe={};qe[zS]=qe[kS]=qe[FS]=qe[jS]=qe[US]=qe[HS]=qe[qS]=qe[WS]=qe[$S]=!0;qe[AS]=qe[TS]=qe[VS]=qe[CS]=qe[GS]=qe[PS]=qe[OS]=qe[MS]=qe[IS]=qe[NS]=qe[ES]=qe[LS]=qe[DS]=qe[BS]=qe[RS]=!1;function YS(n){return Ct(n)&&oi(n.length)&&!!qe[rr(n)]}var Ef=YS;function XS(n){return function(t){return n(t)}}var ai=XS;var Lf=typeof exports=="object"&&exports&&!exports.nodeType&&exports,$a=Lf&&typeof module=="object"&&module&&!module.nodeType&&module,KS=$a&&$a.exports===Lf,gu=KS&&Ys.process,QS=function(){try{var n=$a&&$a.require&&$a.require("util").types;return n||gu&&gu.binding&&gu.binding("util")}catch{}}(),fo=QS;var Df=fo&&fo.isTypedArray,ZS=Df?ai(Df):Ef,tl=ZS;var JS=Object.prototype,e1=JS.hasOwnProperty;function t1(n,t){var e=Ze(n),r=!e&&ii(n),o=!e&&!r&&xn(n),i=!e&&!r&&!o&&tl(n),a=e||r||o||i,s=a?Cf(n.length,String):[],l=s.length;for(var d in n)(t||e1.call(n,d))&&!(a&&(d=="length"||o&&(d=="offset"||d=="parent")||i&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||ei(d,l)))&&s.push(d);return s}var rl=t1;function r1(n,t){return function(e){return n(t(e))}}var ol=r1;var o1=ol(Object.keys,Object),Bf=o1;var n1=Object.prototype,i1=n1.hasOwnProperty;function a1(n){if(!ni(n))return Bf(n);var t=[];for(var e in Object(n))i1.call(n,e)&&e!="constructor"&&t.push(e);return t}var Rf=a1;function s1(n){return el(n)?rl(n):Rf(n)}var si=s1;function l1(n){var t=[];if(n!=null)for(var e in Object(n))t.push(e);return t}var Vf=l1;var c1=Object.prototype,u1=c1.hasOwnProperty;function d1(n){if(!or(n))return Vf(n);var t=ni(n),e=[];for(var r in n)r=="constructor"&&(t||!u1.call(n,r))||e.push(r);return e}var Gf=d1;function p1(n){return el(n)?rl(n,!0):Gf(n)}var li=p1;var f1=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,h1=/^\w*$/;function m1(n,t){if(Ze(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||Zn(n)?!0:h1.test(n)||!f1.test(n)||t!=null&&n in Object(t)}var zf=m1;var y1=$t(Object,"create"),ho=y1;function g1(){this.__data__=ho?ho(null):{},this.size=0}var kf=g1;function x1(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var Ff=x1;var v1="__lodash_hash_undefined__",b1=Object.prototype,S1=b1.hasOwnProperty;function w1(n){var t=this.__data__;if(ho){var e=t[n];return e===v1?void 0:e}return S1.call(t,n)?t[n]:void 0}var jf=w1;var _1=Object.prototype,A1=_1.hasOwnProperty;function T1(n){var t=this.__data__;return ho?t[n]!==void 0:A1.call(t,n)}var Uf=T1;var C1="__lodash_hash_undefined__";function P1(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=ho&&t===void 0?C1:t,this}var Hf=P1;function ci(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])}}ci.prototype.clear=kf;ci.prototype.delete=Ff;ci.prototype.get=jf;ci.prototype.has=Uf;ci.prototype.set=Hf;var xu=ci;function O1(){this.__data__=[],this.size=0}var qf=O1;function M1(n,t){for(var e=n.length;e--;)if(ti(n[e][0],t))return e;return-1}var Eo=M1;var I1=Array.prototype,N1=I1.splice;function E1(n){var t=this.__data__,e=Eo(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():N1.call(t,e,1),--this.size,!0}var Wf=E1;function L1(n){var t=this.__data__,e=Eo(t,n);return e<0?void 0:t[e][1]}var $f=L1;function D1(n){return Eo(this.__data__,n)>-1}var Yf=D1;function B1(n,t){var e=this.__data__,r=Eo(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var Xf=B1;function ui(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])}}ui.prototype.clear=qf;ui.prototype.delete=Wf;ui.prototype.get=$f;ui.prototype.has=Yf;ui.prototype.set=Xf;var Lo=ui;var R1=$t(lt,"Map"),Do=R1;function V1(){this.size=0,this.__data__={hash:new xu,map:new(Do||Lo),string:new xu}}var Kf=V1;function G1(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var Qf=G1;function z1(n,t){var e=n.__data__;return Qf(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Bo=z1;function k1(n){var t=Bo(this,n).delete(n);return this.size-=t?1:0,t}var Zf=k1;function F1(n){return Bo(this,n).get(n)}var Jf=F1;function j1(n){return Bo(this,n).has(n)}var eh=j1;function U1(n,t){var e=Bo(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var th=U1;function di(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])}}di.prototype.clear=Kf;di.prototype.delete=Zf;di.prototype.get=Jf;di.prototype.has=eh;di.prototype.set=th;var vn=di;var H1="Expected a function";function vu(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(H1);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(vu.Cache||vn),e}vu.Cache=vn;var rh=vu;var q1=500;function W1(n){var t=rh(n,function(r){return e.size===q1&&e.clear(),r}),e=t.cache;return t}var oh=W1;var $1=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Y1=/\\(\\)?/g,X1=oh(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace($1,function(e,r,o,i){t.push(o?i.replace(Y1,"$1"):r||e)}),t}),nh=X1;function K1(n){return n==null?"":cf(n)}var ih=K1;function Q1(n,t){return Ze(n)?n:zf(n,t)?[n]:nh(ih(n))}var cr=Q1;var Z1=1/0;function J1(n){if(typeof n=="string"||Zn(n))return n;var t=n+"";return t=="0"&&1/n==-Z1?"-0":t}var Ro=J1;function ew(n,t){t=cr(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[Ro(t[e++])];return e&&e==r?n:void 0}var nl=ew;function tw(n,t){for(var e=-1,r=t.length,o=n.length;++e<r;)n[o+e]=t[e];return n}var pi=tw;var ah=gt?gt.isConcatSpreadable:void 0;function rw(n){return Ze(n)||ii(n)||!!(ah&&n&&n[ah])}var sh=rw;function lh(n,t,e,r,o){var i=-1,a=n.length;for(e||(e=sh),o||(o=[]);++i<a;){var s=n[i];t>0&&e(s)?t>1?lh(s,t-1,e,r,o):pi(o,s):r||(o[o.length]=s)}return o}var ch=lh;function ow(n){var t=n==null?0:n.length;return t?ch(n,1):[]}var uh=ow;function nw(n){return wf(Tf(n,void 0,uh),n+"")}var il=nw;var iw=ol(Object.getPrototypeOf,Object),fi=iw;var aw="[object Object]",sw=Function.prototype,lw=Object.prototype,dh=sw.toString,cw=lw.hasOwnProperty,uw=dh.call(Object);function dw(n){if(!Ct(n)||rr(n)!=aw)return!1;var t=fi(n);if(t===null)return!0;var e=cw.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&dh.call(e)==uw}var ph=dw;function pw(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 fh=pw;function fw(){this.__data__=new Lo,this.size=0}var hh=fw;function hw(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var mh=hw;function mw(n){return this.__data__.get(n)}var yh=mw;function yw(n){return this.__data__.has(n)}var gh=yw;var gw=200;function xw(n,t){var e=this.__data__;if(e instanceof Lo){var r=e.__data__;if(!Do||r.length<gw-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new vn(r)}return e.set(n,t),this.size=e.size,this}var xh=xw;function hi(n){var t=this.__data__=new Lo(n);this.size=t.size}hi.prototype.clear=hh;hi.prototype.delete=mh;hi.prototype.get=yh;hi.prototype.has=gh;hi.prototype.set=xh;var mi=hi;function vw(n,t){return n&&Rr(t,si(t),n)}var vh=vw;function bw(n,t){return n&&Rr(t,li(t),n)}var bh=bw;var Ah=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Sh=Ah&&typeof module=="object"&&module&&!module.nodeType&&module,Sw=Sh&&Sh.exports===Ah,wh=Sw?lt.Buffer:void 0,_h=wh?wh.allocUnsafe:void 0;function ww(n,t){if(t)return n.slice();var e=n.length,r=_h?_h(e):new n.constructor(e);return n.copy(r),r}var Th=ww;function _w(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 Ch=_w;function Aw(){return[]}var al=Aw;var Tw=Object.prototype,Cw=Tw.propertyIsEnumerable,Ph=Object.getOwnPropertySymbols,Pw=Ph?function(n){return n==null?[]:(n=Object(n),Ch(Ph(n),function(t){return Cw.call(n,t)}))}:al,yi=Pw;function Ow(n,t){return Rr(n,yi(n),t)}var Oh=Ow;var Mw=Object.getOwnPropertySymbols,Iw=Mw?function(n){for(var t=[];n;)pi(t,yi(n)),n=fi(n);return t}:al,sl=Iw;function Nw(n,t){return Rr(n,sl(n),t)}var Mh=Nw;function Ew(n,t,e){var r=t(n);return Ze(n)?r:pi(r,e(n))}var ll=Ew;function Lw(n){return ll(n,si,yi)}var Ya=Lw;function Dw(n){return ll(n,li,sl)}var cl=Dw;var Bw=$t(lt,"DataView"),ul=Bw;var Rw=$t(lt,"Promise"),dl=Rw;var Vw=$t(lt,"Set"),pl=Vw;var Ih="[object Map]",Gw="[object Object]",Nh="[object Promise]",Eh="[object Set]",Lh="[object WeakMap]",Dh="[object DataView]",zw=po(ul),kw=po(Do),Fw=po(dl),jw=po(pl),Uw=po(Zs),bn=rr;(ul&&bn(new ul(new ArrayBuffer(1)))!=Dh||Do&&bn(new Do)!=Ih||dl&&bn(dl.resolve())!=Nh||pl&&bn(new pl)!=Eh||Zs&&bn(new Zs)!=Lh)&&(bn=function(n){var t=rr(n),e=t==Gw?n.constructor:void 0,r=e?po(e):"";if(r)switch(r){case zw:return Dh;case kw:return Ih;case Fw:return Nh;case jw:return Eh;case Uw:return Lh}return t});var mo=bn;var Hw=Object.prototype,qw=Hw.hasOwnProperty;function Ww(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&qw.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Bh=Ww;var $w=lt.Uint8Array,gi=$w;function Yw(n){var t=new n.constructor(n.byteLength);return new gi(t).set(new gi(n)),t}var xi=Yw;function Xw(n,t){var e=t?xi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Rh=Xw;var Kw=/\w*$/;function Qw(n){var t=new n.constructor(n.source,Kw.exec(n));return t.lastIndex=n.lastIndex,t}var Vh=Qw;var Gh=gt?gt.prototype:void 0,zh=Gh?Gh.valueOf:void 0;function Zw(n){return zh?Object(zh.call(n)):{}}var kh=Zw;function Jw(n,t){var e=t?xi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var Fh=Jw;var e_="[object Boolean]",t_="[object Date]",r_="[object Map]",o_="[object Number]",n_="[object RegExp]",i_="[object Set]",a_="[object String]",s_="[object Symbol]",l_="[object ArrayBuffer]",c_="[object DataView]",u_="[object Float32Array]",d_="[object Float64Array]",p_="[object Int8Array]",f_="[object Int16Array]",h_="[object Int32Array]",m_="[object Uint8Array]",y_="[object Uint8ClampedArray]",g_="[object Uint16Array]",x_="[object Uint32Array]";function v_(n,t,e){var r=n.constructor;switch(t){case l_:return xi(n);case e_:case t_:return new r(+n);case c_:return Rh(n,e);case u_:case d_:case p_:case f_:case h_:case m_:case y_:case g_:case x_:return Fh(n,e);case r_:return new r;case o_:case a_:return new r(n);case n_:return Vh(n);case i_:return new r;case s_:return kh(n)}}var jh=v_;function b_(n){return typeof n.constructor=="function"&&!ni(n)?yf(fi(n)):{}}var Uh=b_;var S_="[object Map]";function w_(n){return Ct(n)&&mo(n)==S_}var Hh=w_;var qh=fo&&fo.isMap,__=qh?ai(qh):Hh,Wh=__;var A_="[object Set]";function T_(n){return Ct(n)&&mo(n)==A_}var $h=T_;var Yh=fo&&fo.isSet,C_=Yh?ai(Yh):$h,Xh=C_;var P_=1,O_=2,M_=4,Kh="[object Arguments]",I_="[object Array]",N_="[object Boolean]",E_="[object Date]",L_="[object Error]",Qh="[object Function]",D_="[object GeneratorFunction]",B_="[object Map]",R_="[object Number]",Zh="[object Object]",V_="[object RegExp]",G_="[object Set]",z_="[object String]",k_="[object Symbol]",F_="[object WeakMap]",j_="[object ArrayBuffer]",U_="[object DataView]",H_="[object Float32Array]",q_="[object Float64Array]",W_="[object Int8Array]",$_="[object Int16Array]",Y_="[object Int32Array]",X_="[object Uint8Array]",K_="[object Uint8ClampedArray]",Q_="[object Uint16Array]",Z_="[object Uint32Array]",Ue={};Ue[Kh]=Ue[I_]=Ue[j_]=Ue[U_]=Ue[N_]=Ue[E_]=Ue[H_]=Ue[q_]=Ue[W_]=Ue[$_]=Ue[Y_]=Ue[B_]=Ue[R_]=Ue[Zh]=Ue[V_]=Ue[G_]=Ue[z_]=Ue[k_]=Ue[X_]=Ue[K_]=Ue[Q_]=Ue[Z_]=!0;Ue[L_]=Ue[Qh]=Ue[F_]=!1;function fl(n,t,e,r,o,i){var a,s=t&P_,l=t&O_,d=t&M_;if(e&&(a=o?e(n,r,o,i):e(n)),a!==void 0)return a;if(!or(n))return n;var c=Ze(n);if(c){if(a=Bh(n),!s)return xf(n,a)}else{var u=mo(n),p=u==Qh||u==D_;if(xn(n))return Th(n,s);if(u==Zh||u==Kh||p&&!o){if(a=l||p?{}:Uh(n),!s)return l?Mh(n,bh(a,n)):Oh(n,vh(a,n))}else{if(!Ue[u])return o?n:{};a=jh(n,u,s)}}i||(i=new mi);var f=i.get(n);if(f)return f;i.set(n,a),Xh(n)?n.forEach(function(y){a.add(fl(y,t,e,y,n,i))}):Wh(n)&&n.forEach(function(y,g){a.set(g,fl(y,t,e,g,n,i))});var h=d?l?cl:Ya:l?li:si,m=c?void 0:h(n);return _f(m||n,function(y,g){m&&(g=y,y=n[g]),ri(a,g,fl(y,t,e,g,n,i))}),a}var hl=fl;var J_=1,eA=4;function tA(n){return hl(n,J_|eA)}var yo=tA;var rA="__lodash_hash_undefined__";function oA(n){return this.__data__.set(n,rA),this}var Jh=oA;function nA(n){return this.__data__.has(n)}var em=nA;function ml(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new vn;++t<e;)this.add(n[t])}ml.prototype.add=ml.prototype.push=Jh;ml.prototype.has=em;var tm=ml;function iA(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 rm=iA;function aA(n,t){return n.has(t)}var om=aA;var sA=1,lA=2;function cA(n,t,e,r,o,i){var a=e&sA,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&lA?new tm: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(!rm(t,function(g,x){if(!om(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 yl=cA;function uA(n){var t=-1,e=Array(n.size);return n.forEach(function(r,o){e[++t]=[o,r]}),e}var nm=uA;function dA(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var im=dA;var pA=1,fA=2,hA="[object Boolean]",mA="[object Date]",yA="[object Error]",gA="[object Map]",xA="[object Number]",vA="[object RegExp]",bA="[object Set]",SA="[object String]",wA="[object Symbol]",_A="[object ArrayBuffer]",AA="[object DataView]",am=gt?gt.prototype:void 0,bu=am?am.valueOf:void 0;function TA(n,t,e,r,o,i,a){switch(e){case AA:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case _A:return!(n.byteLength!=t.byteLength||!i(new gi(n),new gi(t)));case hA:case mA:case xA:return ti(+n,+t);case yA:return n.name==t.name&&n.message==t.message;case vA:case SA:return n==t+"";case gA:var s=nm;case bA:var l=r&pA;if(s||(s=im),n.size!=t.size&&!l)return!1;var d=a.get(n);if(d)return d==t;r|=fA,a.set(n,t);var c=yl(s(n),s(t),r,o,i,a);return a.delete(n),c;case wA:if(bu)return bu.call(n)==bu.call(t)}return!1}var sm=TA;var CA=1,PA=Object.prototype,OA=PA.hasOwnProperty;function MA(n,t,e,r,o,i){var a=e&CA,s=Ya(n),l=s.length,d=Ya(t),c=d.length;if(l!=c&&!a)return!1;for(var u=l;u--;){var p=s[u];if(!(a?p in t:OA.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 lm=MA;var IA=1,cm="[object Arguments]",um="[object Array]",gl="[object Object]",NA=Object.prototype,dm=NA.hasOwnProperty;function EA(n,t,e,r,o,i){var a=Ze(n),s=Ze(t),l=a?um:mo(n),d=s?um:mo(t);l=l==cm?gl:l,d=d==cm?gl:d;var c=l==gl,u=d==gl,p=l==d;if(p&&xn(n)){if(!xn(t))return!1;a=!0,c=!1}if(p&&!c)return i||(i=new mi),a||tl(n)?yl(n,t,e,r,o,i):sm(n,t,l,e,r,o,i);if(!(e&IA)){var f=c&&dm.call(n,"__wrapped__"),h=u&&dm.call(t,"__wrapped__");if(f||h){var m=f?n.value():n,y=h?t.value():t;return i||(i=new mi),o(m,y,e,r,i)}}return p?(i||(i=new mi),lm(n,t,e,r,o,i)):!1}var pm=EA;function fm(n,t,e,r,o){return n===t?!0:n==null||t==null||!Ct(n)&&!Ct(t)?n!==n&&t!==t:pm(n,t,e,r,fm,o)}var hm=fm;function LA(n,t){return n!=null&&t in Object(n)}var mm=LA;function DA(n,t,e){t=cr(t,n);for(var r=-1,o=t.length,i=!1;++r<o;){var a=Ro(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&&oi(o)&&ei(a,o)&&(Ze(n)||ii(n)))}var ym=DA;function BA(n,t){return n!=null&&ym(n,t,mm)}var gm=BA;function RA(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var xm=RA;function VA(n,t){return t.length<2?n:nl(n,fh(t,0,-1))}var vm=VA;function GA(n,t){return hm(n,t)}var Su=GA;function zA(n,t){return t=cr(t,n),n=vm(n,t),n==null||delete n[Ro(xm(t))]}var bm=zA;function kA(n){return ph(n)?void 0:n}var Sm=kA;var FA=1,jA=2,UA=4,HA=il(function(n,t){var e={};if(n==null)return e;var r=!1;t=Xs(t,function(i){return i=cr(i,n),r||(r=i.length>1),i}),Rr(n,cl(n),e),r&&(e=hl(e,FA|jA|UA,Sm));for(var o=t.length;o--;)bm(e,t[o]);return e}),vi=HA;function qA(n,t,e,r){if(!or(n))return n;t=cr(t,n);for(var o=-1,i=t.length,a=i-1,s=n;s!=null&&++o<i;){var l=Ro(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=or(c)?c:ei(t[o+1])?[]:{})}ri(s,l,d),s=s[l]}return n}var wm=qA;function WA(n,t,e){for(var r=-1,o=t.length,i={};++r<o;){var a=t[r],s=nl(n,a);e(s,a)&&wm(i,cr(a,n),s)}return i}var _m=WA;function $A(n,t){return _m(n,t,function(e,r){return gm(n,r)})}var Am=$A;var YA=il(function(n,t){return n==null?{}:Am(n,t)}),xr=YA;var he=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,he.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,he.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,he.prototype),delete i[r],{data:i,actual:t,reverse:{type:1,id:r,data:o}}}}return null}};function Xa(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"&&Xa(r)}return Object.freeze(n)}function Tm(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 bi=class extends Error{};function xl(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function Vr(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 Si(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 Cm(){return typeof process<"u"}function Pm(n,t){for(let e of n)t(e.id,e.data)!==!0&&Pm(e.children,t)}function Om(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)Om(e,t)}var $e=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,$e.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Xa(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&&Om(o,r)}}traverse(e){Pm(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,$e.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 bi("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)=>Tm(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 Vr(0,o,o);{let a=i[0].fi;return Vr(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 Vr(l,l+o,o)}else return Vr(a.fi,s.fi,o)}}};var wi;(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})(wi||(wi={}));var ye=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ye.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Xa(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,ye.prototype);let r=e;return Cm()||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 Vr(0,r,r);{let i=o[0].fi;return Vr(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 Vr(s,s+r,r)}else return Vr(i.fi,a.fi,r)}}};function _i(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&&!_i(r))return null;o+=1}r=r?xl(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=xl(l),delete r[t.path[o-1]])}else{let l=e[o-1];if(l){let d=xl(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}}},Gr;(r=>{function n(o,i){return Ka(o,i)??o}r.apply=n;function t(o,i){return _u(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=ot.zoomOnce(l,s[a]),l===void 0)return i;if(!_i(l))return;a+=1}if(l===void 0)return i;if(!!_i(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=wu([i],l);return d?(console.log(d),d):i}else return i}r.filterOp=e})(Gr||(Gr={}));function wu(n,t){if(t===void 0)return;let e=!1,r=n.map(o=>{let i=o.id,a=Ka(o.data,t[i]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=wu(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 XA(n,t){if(t===void 0)return;let e=!1,r=n.map(o=>{let i=o.id,a=Ka(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 Ka(n,t){if(!_i(t))return t;if(n instanceof $e){let e=wu(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof ye)return XA(n,t);if(Array.isArray(n)){let e=!1,r=n.map((o,i)=>{let a=Ka(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 _u(n,t);if(n&&typeof n=="object"){let e={},r=!1;for(let[o,i]of Object.entries(n)){let a=Ka(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 _u(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!_i(t))return t;if(!_i(n))return Gr.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=_u(n===void 0?void 0:n[o],t===void 0?void 0:t[o]);r[o]=i}return r}function Mm(n,t){let e={cur:[],result:[],len:0};return n=Qa(n,t,e)??n,[n,e.result]}function vl(n,t){return n===null?null:(n.cur[n.len]=t,n.len+=1,n)}function bl(n){n&&(n.len-=1)}function KA(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Im(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=Qa(i.data,t,vl(e,a));bl(e),r=r||l!==void 0,l===void 0&&(l=i.data);let d=Im(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 QA(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=Qa(i.data,t,vl(e,a));return bl(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 Qa(n,t,e){if(n instanceof $e){let r=Im(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof ye)return QA(n,t,e);if(Array.isArray(n)){let r=!1,o=n.map((i,a)=>{let s=Qa(i,t,vl(e,a));return bl(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"&&!Si(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=Qa(a,t,vl(e,i));bl(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&&KA(e),r}else return}}var Sl;(t=>{function n(e,r){let o=ot.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})(Sl||(Sl={}));var nt;(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 $e||l instanceof ye||l instanceof he?p=l.runOp(d):p=wi.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 $e){if(typeof g=="number")throw new Error("illegal arg");m=x.modifyById(g,m)}else if(x instanceof ye){if(typeof g=="number")throw new Error("illegal arg");m=x.modifyById(g,m)}else if(x instanceof he){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 $e){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else if(l instanceof ye){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})(nt||(nt={}));var Za;(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=>nt.subsumed(p,f))),...c]}l.compress=o;function i(d,c){return d.every(u=>c.every(p=>nt.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=ot.zoom(u,[...h.path,h.id]),g=nt.apply(u,{...h,type:2})):(m=ot.zoom(u,[...h.path,h.id,"value"]),g=nt.apply(u,h)),g!==null){u=g.data;let[x,S]=Mm(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"&&ot.equal(b,O.slice(0,O.length-1)))A.push(T),S.splice(M,1);else break}let v=ot.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=ot.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=nt.apply(u,h);m!==null&&(p.push(m.actual),u=m.data,f.push(m.reverse))}}catch(m){if(m instanceof bi)return null;throw m}return{data:u,actual:p,reverse:f.reverse()}}l.apply=s})(Za||(Za={}));var Nm=Symbol(),ZA=Symbol(),_l=Symbol(),Sn=class{reportOp(t,e,r=[]){let o=this;if(e===null)return;o._current=e.data;let i=r;for(;!(o instanceof wl);){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[_l];r&&r(),delete this._children[t]}}}},Tu=class extends Sn{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,wi.runOp(this._current,t),t.path)}},Cu=class extends Sn{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,he.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},Em={get(n,t){if(t===_l)return()=>{n._parent=null};if(t===Nm)return n._current;if(t===ZA)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=Al(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]}}},JA={...Em,set(n,t,e){let r={type:0,props:{[t]:Ye(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}},eT={...Em,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}},Ai=class extends Sn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[_l]=()=>{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=Al(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)}},Ti=class extends Sn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[_l]=()=>{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=Al(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 Au(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&ot.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push({...t,path:e})}var wl=class extends Sn{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){Au(this.ts,e,t),Au(this.actual,r,t),Au(this.reverse,o,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Al(n,t,e){return e instanceof $e?new Ai(n,t,e):e instanceof ye?new Ti(n,t,e):e instanceof he?new Proxy(new Cu(n,t,e),eT):e!==null&&typeof e=="object"?Si(e)?e:new Proxy(new Tu(n,t,e),JA):e}function Pu(n){let t=new wl(n);return[Al(t,"",n),t]}function Vo(n,t){let[e,r]=Pu(n);return t(e),r.result()}function Ye(n){return n instanceof Ai||n instanceof Ti?n._current:n!==null&&typeof n=="object"?n[Nm]:n}var ot;(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 $e||i instanceof Ai)&&typeof a=="string")return i.data(a);if((i instanceof ye||i instanceof Ti)&&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})(ot||(ot={}));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 Dt(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 Tl=class{},Ja=class extends Tl{constructor(e){super();this.id=e}},es=class extends Tl{constructor(e){super();this.data=e}};var Mu;try{Mu=new TextDecoder}catch{}var re,zo,N=0;var Fm=[],Iu=Fm,Nu=0,Yt={},Le,Go,ur=0,zr=0,nr,go,Vt=[],Be,Dm={useRecords:!1,mapsAsObjects:!0},ts=class{},Lu=new ts;Lu.name="MessagePack 0xC1";var Ci=!1,kr=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 Wm(()=>(Pl(),this?this.unpack(t,e):kr.prototype.unpack.call(Dm,t,e)));zo=e>-1?e:t.length,N=0,Nu=0,zr=0,Go=null,Iu=Fm,nr=null,re=t;try{Be=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 kr){if(Yt=this,this.structures)return Le=this.structures,Cl();(!Le||Le.length>0)&&(Le=[])}else Yt=Dm,(!Le||Le.length>0)&&(Le=[]);return Cl()}unpackMultiple(t,e){let r,o=0;try{Ci=!0;let i=t.length,a=this?this.unpack(t,i):Il.unpack(t,i);if(e){for(e(a);N<i;)if(o=N,e(Cl())===!1)return}else{for(r=[a];N<i;)o=N,r.push(Cl());return r}}catch(i){throw i.lastPosition=o,i.values=r,i}finally{Ci=!1,Pl()}}_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 Cl(){try{if(!Yt.trusted&&!Ci){let t=Le.sharedLength||0;t<Le.length&&(Le.length=t)}let n=Je();if(N==zo)Le.restoreStructures&&Bm(),Le=null,re=null,go&&(go=null);else if(N>zo){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Ci)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Le.restoreStructures&&Bm(),Pl(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Bm(){for(let n in Le.restoreStructures)Le[n]=Le.restoreStructures[n];Le.restoreStructures=null}function Je(){let n=re[N++];if(n<160)if(n<128){if(n<64)return n;{let t=Le[n&63]||Yt.getStructures&&jm()[n&63];return t?(t.read||(t.read=Du(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,Yt.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Hm()]=Je();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(Je(),Je());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=Je();return t}else if(n<192){let t=n-160;if(zr>=N)return Go.slice(N-ur,(N+=t)-ur);if(zr==0&&zo<140){let e=t<16?Bu(t):Um(t);if(e!=null)return e}return Eu(t)}else{let t;switch(n){case 192:return null;case 193:return nr?(t=Je(),t>0?nr[1].slice(nr.position1,nr.position1+=t):nr[0].slice(nr.position0,nr.position0-=t)):Lu;case 194:return!1;case 195:return!0;case 196:return Ou(re[N++]);case 197:return t=Be.getUint16(N),N+=2,Ou(t);case 198:return t=Be.getUint32(N),N+=4,Ou(t);case 199:return wn(re[N++]);case 200:return t=Be.getUint16(N),N+=2,wn(t);case 201:return t=Be.getUint32(N),N+=4,wn(t);case 202:if(t=Be.getFloat32(N),Yt.useFloat32>2){let e=Ml[(re[N]&127)<<1|re[N+1]>>7];return N+=4,(e*t+(t>0?.5:-.5)>>0)/e}return N+=4,t;case 203:return t=Be.getFloat64(N),N+=8,t;case 204:return re[N++];case 205:return t=Be.getUint16(N),N+=2,t;case 206:return t=Be.getUint32(N),N+=4,t;case 207:return Yt.int64AsNumber?(t=Be.getUint32(N)*4294967296,t+=Be.getUint32(N+4)):t=Be.getBigUint64(N),N+=8,t;case 208:return Be.getInt8(N++);case 209:return t=Be.getInt16(N),N+=2,t;case 210:return t=Be.getInt32(N),N+=4,t;case 211:return Yt.int64AsNumber?(t=Be.getInt32(N)*4294967296,t+=Be.getUint32(N+4)):t=Be.getBigInt64(N),N+=8,t;case 212:if(t=re[N++],t==114)return km(re[N++]&63);{let e=Vt[t];if(e)return e.read?(N++,e.read(Je())):e.noBuffer?(N++,e()):e(re.subarray(N,++N));throw new Error("Unknown extension "+t)}case 213:return t=re[N],t==114?(N++,km(re[N++]&63,re[N++])):wn(2);case 214:return wn(4);case 215:return wn(8);case 216:return wn(16);case 217:return t=re[N++],zr>=N?Go.slice(N-ur,(N+=t)-ur):rT(t);case 218:return t=Be.getUint16(N),N+=2,zr>=N?Go.slice(N-ur,(N+=t)-ur):oT(t);case 219:return t=Be.getUint32(N),N+=4,zr>=N?Go.slice(N-ur,(N+=t)-ur):nT(t);case 220:return t=Be.getUint16(N),N+=2,Vm(t);case 221:return t=Be.getUint32(N),N+=4,Vm(t);case 222:return t=Be.getUint16(N),N+=2,Gm(t);case 223:return t=Be.getUint32(N),N+=4,Gm(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 tT=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Du(n,t){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>tT.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(Je);return n.highByte===0&&(n.read=Rm(t,n.read)),o()}let r={};for(let o=0,i=n.length;o<i;o++){let a=n[o];r[a]=Je()}return r}return e.count=0,n.highByte===0?Rm(t,e):e}var Rm=(n,t)=>function(){let e=re[N++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),o=Le[r]||jm()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=Du(o,n)),o.read()};function jm(){let n=Wm(()=>(re=null,Yt.getStructures()));return Le=Yt._mergeStructures(n,Le)}var Eu=Ol,rT=Ol,oT=Ol,nT=Ol;function Ol(n){let t;if(n<16&&(t=Bu(n)))return t;if(n>64&&Mu)return Mu.decode(re.subarray(N,N+=n));let e=N+n,r=[];for(t="";N<e;){let o=re[N++];if((o&128)===0)r.push(o);else if((o&224)===192){let i=re[N++]&63;r.push((o&31)<<6|i)}else if((o&240)===224){let i=re[N++]&63,a=re[N++]&63;r.push((o&31)<<12|i<<6|a)}else if((o&248)===240){let i=re[N++]&63,a=re[N++]&63,s=re[N++]&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+=xt.apply(String,r),r.length=0)}return r.length>0&&(t+=xt.apply(String,r)),t}function Vm(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=Je();return t}function Gm(n){if(Yt.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Hm()]=Je();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(Je(),Je());return t}}var xt=String.fromCharCode;function Um(n){let t=N,e=new Array(n);for(let r=0;r<n;r++){let o=re[N++];if((o&128)>0){N=t;return}e[r]=o}return xt.apply(String,e)}function Bu(n){if(n<4)if(n<2){if(n===0)return"";{let t=re[N++];if((t&128)>1){N-=1;return}return xt(t)}}else{let t=re[N++],e=re[N++];if((t&128)>0||(e&128)>0){N-=2;return}if(n<3)return xt(t,e);let r=re[N++];if((r&128)>0){N-=3;return}return xt(t,e,r)}else{let t=re[N++],e=re[N++],r=re[N++],o=re[N++];if((t&128)>0||(e&128)>0||(r&128)>0||(o&128)>0){N-=4;return}if(n<6){if(n===4)return xt(t,e,r,o);{let i=re[N++];if((i&128)>0){N-=5;return}return xt(t,e,r,o,i)}}else if(n<8){let i=re[N++],a=re[N++];if((i&128)>0||(a&128)>0){N-=6;return}if(n<7)return xt(t,e,r,o,i,a);let s=re[N++];if((s&128)>0){N-=7;return}return xt(t,e,r,o,i,a,s)}else{let i=re[N++],a=re[N++],s=re[N++],l=re[N++];if((i&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){N-=8;return}if(n<10){if(n===8)return xt(t,e,r,o,i,a,s,l);{let d=re[N++];if((d&128)>0){N-=9;return}return xt(t,e,r,o,i,a,s,l,d)}}else if(n<12){let d=re[N++],c=re[N++];if((d&128)>0||(c&128)>0){N-=10;return}if(n<11)return xt(t,e,r,o,i,a,s,l,d,c);let u=re[N++];if((u&128)>0){N-=11;return}return xt(t,e,r,o,i,a,s,l,d,c,u)}else{let d=re[N++],c=re[N++],u=re[N++],p=re[N++];if((d&128)>0||(c&128)>0||(u&128)>0||(p&128)>0){N-=12;return}if(n<14){if(n===12)return xt(t,e,r,o,i,a,s,l,d,c,u,p);{let f=re[N++];if((f&128)>0){N-=13;return}return xt(t,e,r,o,i,a,s,l,d,c,u,p,f)}}else{let f=re[N++],h=re[N++];if((f&128)>0||(h&128)>0){N-=14;return}if(n<15)return xt(t,e,r,o,i,a,s,l,d,c,u,p,f,h);let m=re[N++];if((m&128)>0){N-=15;return}return xt(t,e,r,o,i,a,s,l,d,c,u,p,f,h,m)}}}}}function Ou(n){return Yt.copyBuffers?Uint8Array.prototype.slice.call(re,N,N+=n):re.subarray(N,N+=n)}function wn(n){let t=re[N++];if(Vt[t])return Vt[t](re.subarray(N,N+=n));throw new Error("Unknown extension type "+t)}var zm=new Array(4096);function Hm(){let n=re[N++];if(n>=160&&n<192){if(n=n-160,zr>=N)return Go.slice(N-ur,(N+=n)-ur);if(!(zr==0&&zo<180))return Eu(n)}else return N--,Je();let t=(n<<5^(n>1?Be.getUint16(N):n>0?re[N]:0))&4095,e=zm[t],r=N,o=N+n-3,i,a=0;if(e&&e.bytes==n){for(;r<o;){if(i=Be.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 N=r,e.string;o-=3,r=N}for(e=[],zm[t]=e,e.bytes=n;r<o;)i=Be.getUint32(r),e.push(i),r+=4;for(o+=3;r<o;)i=re[r++],e.push(i);let s=n<16?Bu(n):Um(n);return s!=null?e.string=s:e.string=Eu(n)}var km=(n,t)=>{var e=Je();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let o=Le[n];return o&&o.isShared&&((Le.restoreStructures||(Le.restoreStructures=[]))[n]=o),Le[n]=e,e.read=Du(e,r),e.read()},qm=typeof self=="object"?self:global;Vt[0]=()=>{};Vt[0].noBuffer=!0;Vt[101]=()=>{let n=Je();return(qm[n[0]]||Error)(n[1])};Vt[105]=n=>{let t=Be.getUint32(N-4);go||(go=new Map);let e=re[N],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let o={target:r};go.set(t,o);let i=Je();return o.used?Object.assign(r,i):(o.target=i,i)};Vt[112]=n=>{let t=Be.getUint32(N-4),e=go.get(t);return e.used=!0,e.target};Vt[115]=()=>new Set(Je());var Ru=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");Vt[116]=n=>{let t=n[0],e=Ru[t];if(!e)throw new Error("Could not find typed array for code "+t);return new qm[e](Uint8Array.prototype.slice.call(n,1).buffer)};Vt[120]=()=>{let n=Je();return new RegExp(n[0],n[1])};Vt[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=N;N+=t-4,nr=[Je(),Je()],nr.position0=0,nr.position1=0;let r=N;N=e;try{return Je()}finally{N=r}};Vt[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 Wm(n){let t=zo,e=N,r=Nu,o=ur,i=zr,a=Go,s=Iu,l=go,d=nr,c=new Uint8Array(re.slice(0,zo)),u=Le,p=Le.slice(0,Le.length),f=Yt,h=Ci,m=n();return zo=t,N=e,Nu=r,ur=o,zr=i,Go=a,Iu=s,go=l,nr=d,re=c,Ci=h,Le=u,Le.splice(0,Le.length,...p),Yt=f,Be=new DataView(re.buffer,re.byteOffset,re.byteLength),m}function Pl(){re=null,go=null,Le=null}function $m(n){n.unpack?Vt[n.type]=n.unpack:Vt[n.type]=n}var Ml=new Array(147);for(let n=0;n<256;n++)Ml[n]=+("1e"+Math.floor(45.15-n*.30103));var Il=new kr({useRecords:!1}),iT=Il.unpack,aT=Il.unpackMultiple,sT=Il.unpack,Nl={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},lT=new Float32Array(1),zz=new Uint8Array(lT.buffer,0,4);var El;try{El=new TextEncoder}catch{}var Ll,Gu,Dl=typeof Buffer<"u",Vu=Dl?Buffer.allocUnsafeSlow:Uint8Array,Qm=Dl?Buffer:Uint8Array,Ym=Dl?4294967296:2144337920,k,it,D=0,Fr,jr=null,cT=/[\u0080-\uFFFF]/,rs=Symbol("record-id"),_n=class extends kr{constructor(t){super(t),this.offset=0;let e,r,o,i,a,s,l=0,d=Qm.prototype.utf8Write?function(v,M,O){return k.utf8Write(v,M,O)}:El&&El.encodeInto?function(v,M){return El.encodeInto(v,k.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(k||(k=new Vu(8192),it=new DataView(k.buffer,0,8192),D=0),Fr=k.length-10,Fr-D<2048?(k=new Vu(k.length),it=new DataView(k.buffer,0,k.length),Fr=k.length-10,D=0):D=D+7&2147483640,r=D,s=c.structuredClone?new Map:null,c.bundleStrings?(jr=["",""],k[D++]=214,k[D++]=98,jr.position=D-r,D+=4):jr=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 E=0,R=C.length;E<R;E++){let L=C[E];P=I[L],P||(P=I[L]=Object.create(null)),I=P}I[rs]=T+64}l=O}u||(o.nextId=O+64)}i&&(i=!1),a=o||[];try{if(b(v),jr){it.setUint32(jr.position+r,D-jr.position-r);let O=jr;jr=null,b(O[0]),b(O[1])}if(c.offset=D,s&&s.idsToInsert){D+=s.idsToInsert.length*6,D>Fr&&A(D),c.offset=D;let O=dT(k.subarray(r,D),s.idsToInsert);return s=null,O}return M&Jm?(k.start=r,k.end=D,k):k.subarray(r,D)}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][rs]=0;x=[]}if(i&&c.saveStructures){let O=o.sharedLength||f;o.length>O&&(o=o.slice(0,O));let T=k.subarray(r,D);return c.saveStructures(o,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(v)):(l=O,T)}}M&xT&&(D=r)}};let b=v=>{D>Fr&&(k=A(D));var M=typeof v,O;if(M==="string"){let T=v.length;if(jr&&T>=8&&T<4096){let I=cT.test(v);jr[I?0:1]+=v,k[D++]=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(D+P>Fr&&(k=A(D+P)),T<64||!d){let I,E,R,L=D+C;for(I=0;I<T;I++)E=v.charCodeAt(I),E<128?k[L++]=E:E<2048?(k[L++]=E>>6|192,k[L++]=E&63|128):(E&64512)===55296&&((R=v.charCodeAt(I+1))&64512)===56320?(E=65536+((E&1023)<<10)+(R&1023),I++,k[L++]=E>>18|240,k[L++]=E>>12&63|128,k[L++]=E>>6&63|128,k[L++]=E&63|128):(k[L++]=E>>12|224,k[L++]=E>>6&63|128,k[L++]=E&63|128);O=L-D-C}else O=d(v,D+C,P);O<32?k[D++]=160|O:O<256?(C<2&&k.copyWithin(D+2,D+1,D+1+O),k[D++]=217,k[D++]=O):O<65536?(C<3&&k.copyWithin(D+3,D+2,D+2+O),k[D++]=218,k[D++]=O>>8,k[D++]=O&255):(C<5&&k.copyWithin(D+5,D+3,D+3+O),k[D++]=219,it.setUint32(D,O),D+=4),D+=O}else if(M==="number")if(v>>>0===v)v<64?k[D++]=v:v<256?(k[D++]=204,k[D++]=v):v<65536?(k[D++]=205,k[D++]=v>>8,k[D++]=v&255):(k[D++]=206,it.setUint32(D,v),D+=4);else if(v>>0===v)v>=-32?k[D++]=256+v:v>=-128?(k[D++]=208,k[D++]=v+256):v>=-32768?(k[D++]=209,it.setInt16(D,v),D+=2):(k[D++]=210,it.setInt32(D,v),D+=4);else{let T;if((T=this.useFloat32)>0&&v<4294967296&&v>=-2147483648){k[D++]=202,it.setFloat32(D,v);let C;if(T<4||(C=v*Ml[(k[D]&127)<<1|k[D+1]>>7])>>0===C){D+=4;return}else D--}k[D++]=203,it.setFloat64(D,v),D+=8}else if(M==="object")if(!v)k[D++]=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)}k[D++]=214,k[D++]=112,it.setUint32(D,C.id),D+=4;return}else s.set(v,{offset:D-r})}let T=v.constructor;if(T===Object)_(v,!0);else if(T===Array){O=v.length,O<16?k[D++]=144|O:O<65536?(k[D++]=220,k[D++]=O>>8,k[D++]=O&255):(k[D++]=221,it.setUint32(D,O),D+=4);for(let C=0;C<O;C++)b(v[C])}else if(T===Map){O=v.size,O<16?k[D++]=128|O:O<65536?(k[D++]=222,k[D++]=O>>8,k[D++]=O&255):(k[D++]=223,it.setUint32(D,O),D+=4);for(let[C,P]of v)b(C),b(P)}else{for(let C=0,P=Ll.length;C<P;C++){let I=Gu[C];if(v instanceof I){let E=Ll[C];if(E.write){E.type&&(k[D++]=212,k[D++]=E.type,k[D++]=0),b(E.write.call(this,v));return}let R=k,L=it,F=D;k=null;let V;try{V=E.pack.call(this,v,B=>(k=R,R=null,D+=B,D>Fr&&A(D),{target:k,targetView:it,position:D-B}),b)}finally{R&&(k=R,it=L,D=F,Fr=k.length-10)}V&&(V.length+D>Fr&&A(V.length+D),D=uT(V,k,D,E.type));return}}_(v,!v.hasOwnProperty)}}else if(M==="boolean")k[D++]=v?195:194;else if(M==="bigint"){if(v<BigInt(1)<<BigInt(63)&&v>=-(BigInt(1)<<BigInt(63)))k[D++]=211,it.setBigInt64(D,v);else if(v<BigInt(1)<<BigInt(64)&&v>0)k[D++]=207,it.setBigUint64(D,v);else if(this.largeBigIntToFloat)k[D++]=203,it.setFloat64(D,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");D+=8}else if(M==="undefined")this.encodeUndefinedAsNil?k[D++]=192:(k[D++]=212,k[D++]=0,k[D++]=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?k[D++]=128|O:O<65536?(k[D++]=222,k[D++]=O>>8,k[D++]=O&255):(k[D++]=223,it.setUint32(D,O),D+=4);let T;for(let C=0;C<O;C++)b(T=M[C]),b(v[T])}:(v,M)=>{k[D++]=222;let O=D-r;D+=2;let T=0;for(let C in v)(M||v.hasOwnProperty(C))&&(b(C),b(v[C]),T++);k[O+++r]=T>>8,k[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,E=M.length;I<E;I++){let R=M[I];O=T[R],O||(O=T[R]=Object.create(null),C++),T=O}let P=T[rs];if(P)P>=96&&m?(k[D++]=((P-=96)&31)+96,k[D++]=P>>5):k[D++]=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[rs]=P,a[P-64]=M,P<y?(M.isShared=!0,a.sharedLength=P-63,i=!0,I>=0?(k[D++]=(P&31)+96,k[D++]=I):k[D++]=P):(I>=0?(k[D++]=213,k[D++]=114,k[D++]=(P&31)+96,k[D++]=I):(k[D++]=212,k[D++]=114,k[D++]=P),C&&(S+=w*C),x.length>=h&&(x.shift()[rs]=0),x.push(T),b(M))}for(let I=0,E=M.length;I<E;I++)b(v[M[I]])},A=v=>{let M;if(v>16777216){if(v-r>Ym)throw new Error("Packed buffer would be larger than maximum buffer size");M=Math.min(Ym,Math.round(Math.max((v-r)*(v>67108864?1.25:2),4194304)/4096)*4096)}else M=(Math.max(v-r<<2,k.length-1)>>12)+1<<12;let O=new Vu(M);return it=new DataView(O.buffer,0,M),k.copy?k.copy(O,0,r,v):O.set(k.slice(r,v)),D-=r,r=0,Fr=O.length-10,k=O}}useBuffer(t){k=t,it=new DataView(k.buffer,k.byteOffset,k.byteLength),D=0}};Gu=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,ts];Ll=[{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?Xm(n,16,t):Km(Dl?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==Qm&&this.structuredClone?Xm(n,Ru.indexOf(e.name),t):Km(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function Xm(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 Km(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 uT(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 dT(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 ko(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)");Gu.unshift(n.Class),Ll.unshift(n)}$m(n)}var Zm=new _n({useRecords:!1}),pT=Zm.pack,fT=Zm.pack;var{NEVER:hT,ALWAYS:mT,DECIMAL_ROUND:yT,DECIMAL_FIT:gT}=Nl,Jm=512,xT=1024;var ey=new _n({structuredClone:!0});ko({Class:he.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,he.prototype),n}});ko({Class:ye.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,ye.prototype),n}});ko({Class:$e.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,$e.prototype),n}});ko({Class:Ja.prototype.constructor,type:4,write(n){return n.id},read(n){return new Ja(n)}});ko({Class:es.prototype.constructor,type:5,write(n){return n.data},read(n){return new es(n)}});ko({Class:ke.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,ke.prototype),n}});function vT(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 zu(n){if(Si(n))return n;if(Array.isArray(n))return n.map(zu);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=zu(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var Bl;(r=>{function n(o){return ey.pack(o)}r.serialize=n;function t(o){return ey.unpack(o)}r.deserialize=t;function e(o){return vT(n(zu(o))).toString()}r.checksum=e})(Bl||(Bl={}));var Uo="personal camera",Ho="a218fcc3-276b-49b9-b485-49037fd14f5f",ay=2960946,dt=5526619;var ty;(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})(ty||(ty={}));var Fo;(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})(Fo||(Fo={}));var ry;(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})(ry||(ry={}));var jo;(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})(jo||(jo={}));var vt;(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})(vt||(vt={}));var Gt;(s=>{s.white={...vt.white,a:1},s.transparent={...vt.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{...vt.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 vt.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})(Gt||(Gt={}));var Rl;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Rl||(Rl={}));var oy;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(oy||(oy={}));var ny;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(ny||(ny={}));var iy;(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]))(iy||(iy={}));function sy(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 vr;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(vr||(vr={}));var qo;(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})(qo||(qo={}));var Ur;(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(bT.forEach(a=>{Object.assign(i,{[a]:o[a]??r[a]})}),i.radial={...r.radial},o.radial){let a=r.radial,s=o.radial;ST.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;wT.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;_T.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;AT.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;TT.forEach(l=>{Object.assign(i.randomnessObject,{[l]:s[l]??a[l]})})}return i}e.merge=t})(Ur||(Ur={}));var Vl;(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})(Vl||(Vl={}));var bT=["count"],ST=["radius","start","end","position","scale","rotation"],wT=["position","scale","rotation"],_T=["count","size"],AT=["count","position","scale","rotation"],TT=["strength","scale","rotation","position","movement","seed","freqScale"];var Gl;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Gl||(Gl={}));var zl;(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:Gt.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Gt.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:Gt.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(zl||(zl={}));var Wo;(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]})(Wo||(Wo={}));var ku;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}e.equals=t})(ku||(ku={}));var Fu;(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})(Fu||(Fu={}));var kl;(t=>t.defaultData={...Fu.defaultData,...ku.defaultData})(kl||(kl={}));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 Pi;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Pi||(Pi={}));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"],zt;(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:Pi.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...a,type:"color",color:vt.fromHex(dt)};case"depth":return{...a,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...vt.fromHex(6710886),a:1},colorB:{...vt.fromHex(6710886),a:1},colorC:{...vt.fromHex(16777215),a:1},colorD:{...vt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:Gt.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:Gt.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:Gt.fromHexAndA(0,1),contourColor:Gt.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:{...vt.fromHex(0),a:1},colorB:{...vt.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(zt||(zt={}));var Pt;(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 ye}}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 ye;return p.push({fi:0,data:zt.defaultData("light",d),id:c}),p.push({fi:1,data:zt.defaultData("color"),id:u}),{layers:p}}l.defaultTwoLayerData=i;function a(d,c="phong",u="layer1",p="layer2"){let f=zt.defaultData("texture");Object.assign(f.texture,{image:d});let h=new ye;return h.push({fi:0,data:f,id:u}),h.push({fi:1,data:zt.defaultData("light",c),id:p}),{layers:h}}l.defaultTwoLayerTextureData=a;function s(d,c="phong",u="layer1",p="layer2"){let f=zt.defaultData("video");Object.assign(f.texture,{video:d});let h=new ye;return h.push({fi:0,data:f,id:u}),h.push({fi:1,data:zt.defaultData("light",c),id:p}),{layers:h}}l.defaultTwoLayerVideoTextureData=s})(Pt||(Pt={}));var Oi;(t=>{function n(){return{points:new ye,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(Oi||(Oi={}));var Mi;(t=>{function n(){return{points:new ye,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=n})(Mi||(Mi={}));var ju={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Fl;(t=>{function n(e,r){let o={...e};return CT.forEach(i=>{Object.assign(o,{[i]:r[i]??e[i]})}),o}t.merge=n})(Fl||(Fl={}));var jl={shape:ju,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},CT=["depth","offset","angle","twist","startScale","endScale"];var os;(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})(os||(os={}));var Ul;(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,Fl.merge(o.extrusion,r.extrusion))),o}t.merge=n})(Ul||(Ul={}));var $o;(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:Mi.defaultData(),extrusion:jl};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Oi.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})($o||($o={}));var Hl;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:vt.white,near:.1,far:2e3})(Hl||(Hl={}));var ql;(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}}})(ql||(ql={}));var Uu;(t=>t.defaultData={softShadowQuality:"low"})(Uu||(Uu={}));var Hu;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Hu||(Hu={}));var qu;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(qu||(qu={}));var ns;(t=>t.defaultData={usePhysics:!1,gravity:-10})(ns||(ns={}));var Wu;(t=>t.defaultData={playCamera:Uo,gameControlObject:null})(Wu||(Wu={}));var Wl;(t=>t.defaultData={backgroundColor:Gt.fromHexAndA(ay,1),postprocessing:ql.defaultData,fog:Hl.defaultData,globalPhysics:ns.defaultData,ambient:Hu.defaultData,ao:qu.defaultData,shadow:Uu.defaultData,publish:Wu.defaultData})(Wl||(Wl={}));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 Ii;(o=>{o.identity={...Rl.identity,hiddenMatrix:jo.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 Jp({position:Fo.isEqual(i.position,a.position)?void 0:a.position,rotation:Fo.isEqual(i.rotation,a.rotation)?void 0:a.rotation,scale:Fo.isEqual(i.scale,a.scale)?null:a.scale,hiddenMatrix:jo.isEqual(i.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=r})(Ii||(Ii={}));var Ot;(t=>t.defaultData={states:new ye,events:new ye,visible:!0,raycastLock:!1,physics:Wo.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Ii.identity,cloner:null})(Ot||(Ot={}));var $l;(t=>t.defaultData={type:"Empty",...Ot.defaultData})($l||($l={}));var my;(t=>t.defaultData={type:"Component",...Ot.defaultData})(my||(my={}));var An;(t=>t.defaultData={type:"Mesh",...Ot.defaultData,...kl.defaultData})(An||(An={}));var Tn;(t=>t.defaultData={...Ot.defaultData,...Ii.identity,position:[0,0,qo.DefaultTargetOffset],...qo.defaultData})(Tn||(Tn={}));var Yl;(e=>{function n(r){return{...Ot.defaultData,...zl.defaultData(r)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Yl||(Yl={}));var Ni;(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})(Ni||(Ni={}));var Hr;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function r(a,s){return{...Ot.defaultData,...s,component:a,overrides:new ke,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=r;function o(a){let s=Ii.fromObject(a.data);return r(a.id,s)}i.fromComponentData=o})(Hr||(Hr={}));var xo;(t=>t.defaultData={type:"Page",...Ot.defaultData,physics:{...Wo.defaultData,fusedBody:!1},...Wl.defaultData,camera:Tn.defaultData})(xo||(xo={}));var Xl;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:jo.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Wo.defaultData,states:new ye,events:new ye,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...qo.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",...Ot.defaultData,...An.defaultData,geometry:$o.defaultData("RectangleGeometry"),material:Pt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...Ot.defaultData,...An.defaultData,geometry:$o.defaultData("BooleanGeometry"),material:Pt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...Ot.defaultData,...An.defaultData,geometry:$o.defaultData("TextGeometry"),material:Pt.defaultTwoLayerData("phong","layer1","layer2")}))(Xl||(Xl={}));var Cn;(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})))):vr.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=Vo(s.material,l=>{if(typeof l!="string")for(let[d,c]of Object.entries(a.material.layers)){let u=l.layers.data(d);u&&zt.patch(u,c)}}).data),s.materials&&a.materials&&(s.materials=Vo(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&&zt.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(...Vl.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,Ii.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})}),vr.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:Ul.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=t(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Ur.merge(s.cloner,a.cloner)});else if(i.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Ur.merge(s.cloner,a.cloner)});else if(Gl.is(i.type)){let l=a;l.intensity!==void 0&&(s.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?s.color=l.color:s.color=vt.clone(l.color))}return s}o.patch=r})(Cn||(Cn={}));var Li;(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})(Li||(Li={}));var qr;(t=>t.defaultData={orbitControls:Li.defaultData,playPage:Ho,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})(qr||(qr={}));var $u;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})($u||($u={}));var Yu;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Yu||(Yu={}));var Yo;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...$u.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Yu.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Yo||(Yo={}));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=Di.getComponentData(r,s.component)?.data;l&&i(a,s,l.events)}else i(a,s,s.events)})}e.traverseModuleInstances=t})(yy||(yy={}));var Xo;(s=>{s.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(l={withLight:!0,withSquare:!0}){let d=[],c=Xl.defaultMeshObject;l.withLight===!0&&d.push({fi:-1,data:Yl.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 $e;return u.push({fi:1,id:Ho,data:{...xo.defaultData,name:"Scene 1"},children:d}),u}s.defaultData={objects:t(),publish:qr.defaultData,styles:Yo.defaultData()},s.emptyDataWithoutPage=function(){return{objects:new $e,publish:qr.defaultData,styles:Yo.defaultData()}},s.emptyDataWithPage=function(l){return{objects:t(l),publish:qr.defaultData,styles:Yo.defaultData()}};function i(l){return{...s.defaultData,objects:Wt(l,$e.prototype)}}s.withObjs=i;function a(l,d){return i([{id:l,data:d,children:[],fi:0}])}s.withObj=a})(Xo||(Xo={}));var Bi;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Bi||(Bi={}));var Ri;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Ri||(Ri={}));var Kl;(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})(Kl||(Kl={}));var Xu;(t=>t.all=["images","videos","colors","audios","fonts","materials","variables"])(Xu||(Xu={}));var gy;(t=>t.all=[...Xu.all,"components"])(gy||(gy={}));var xy;(t=>{function n(){return{images:new he,videos:new he,colors:new he,audios:new he,fonts:new he,materials:new he,components:new he,variables:new he}}t.defaultData=n})(xy||(xy={}));var Ko;(t=>{function n(){return{images:new he,videos:new he,colors:new he,audios:new he,fonts:new he,materials:new he,components:new he,variables:new he}}t.defaultData=n})(Ko||(Ko={}));var br;(i=>{function n(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Wt(a,he.prototype)}i.defaultColors=n;function t(a){let s={};return a?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Ri.emptyImage,name:"AI generated image"}),Wt(s,he.prototype)}i.defaultImages=t;function e(){return{catelogs:new he,materials:new he,images:new he,videos:new he,colors:new he,audios:new he,fonts:new he,variables:new ye,lib:Ko.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})(br||(br={}));import{MathUtils as Jl}from"three";var Ql;(t=>t.list=["idle","move","jump","run"])(Ql||(Ql={}));var Zl;(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 ye,move:new ye,jump:new ye,run:new ye},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Gt.fromHexAndA(3728051,1)}}))(Zl||(Zl={}));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={...xr(Ye(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={...Ye(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function vo(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function bo(n,t){n.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((o,i)=>{o===void 0&&(r.materials[i]=Pt.defaultData(),o=r.materials[i]),typeof o!="string"&&t(o)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Pt.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Pt.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&t(o.material)})})}function PT(n){Object.assign(n.scene.publish,{orbitControls:{...Li.defaultData,...Ye(n.scene.publish.orbitControls)}})}function OT(n){Object.assign(n.scene.publish.settings,{video:{...qr.defaultData.settings.video,...Ye(n.scene.publish.settings.video)}})}function MT(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 IT(n){n.scene.publish.withBackground=!0}function NT(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function ET(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 LT(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 DT(n){n.scene.objects.traverse((t,e)=>{let r=n.scene.objects.unproxy().parent(t);if(r){let o=Ye(n.scene.objects.data(r));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Ye(e).booleanExclude!==!0)}})}function BT(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 RT(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=Ye(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=Ye(l).layers;e(d),l.layers=d}})})}function by(n){n.layers===void 0&&Object.assign(n,Pt.defaultTwoLayerData("lambert"))}function Ku(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={...Ye(t),colors:e,steps:r};Object.assign(t,o)}})}function VT(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"&&Ku(r)}):"material"in e&&typeof e.material!="string"&&Ku(e.material)}),Object.values(n.shared.materials).forEach(t=>Ku(t))}function GT(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 zT(n){n.shared.audios=Wt({},he.prototype)}function kT(n){n.shared.videos=Wt({},he.prototype)}function FT(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 jT(n){Object.entries(Ye(n.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.images[r]}),Object.entries(Ye(n.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.audios[r]})}function UT(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 HT(n){n.shared.fonts=Wt({},he.prototype)}function qT(n){return n.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function WT(n){let t=[];n.scene.objects.traverse((e,r)=>{let o=r;if(o.type==="TextFrame"){let i=Pt.defaultTwoLayerData("phong"),a=typeof o.color=="string"?n.shared.colors[o.color]:o.color;i.layers[1].data.color={r:a.r,g:a.g,b:a.b},i.layers[1].data.alpha=o.alpha;let s=qT(o.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let l={name:o.name,...Ot.defaultData,...An.defaultData,flatShading:!1,wireframe:!1,geometry:{...$o.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:Ye(o.states),events:Ye(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},d=Ye(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 $T(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 ye,move:new ye,jump:new ye}});else{let i=new ye;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:Jl.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,xr(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 ye({fi:0,id:Jl.generateUUID(),data:d},{fi:1,id:Jl.generateUUID(),data:p})};i.push({fi:l,id:s,data:f})}),delete o.targets)}})})}function YT(n){n.scene.objects.traverse((t,e)=>{function r(o,i){let a=new ye,s=[];if(e.events.forEach((l,d,c)=>{if(l.type==="Audio"&&l.trigger===i){let u;s.push(d),l.interaction==="play"?u={...xr(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={...xr(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:Jl.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=zt.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function Ty(n){vo(n,Ay),bo(n,Ay)}function XT(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function KT(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 QT(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Pt.defaultTwoLayerData("phong"))})}function ZT(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 JT(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 eC(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 tC(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function rC(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function oC(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function nC(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Zl.defaultDataThirdPerson.navmesh)})})}function iC(n){n.scene.styles||(n.scene.styles=Yo.defaultData())}function Cy(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function aC(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}),bo(n,Cy),vo(n,Cy)}function sC(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new ye})})})}function lC(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&&(bo(n,vy),vo(n,vy),n.schema=1),t<2&&(PT(n),n.schema=2),t<3&&(MT(n),n.schema=3),t<4&&(IT(n),n.schema=4),t<5&&(NT(n),n.schema=5),t<6&&(ET(n),n.schema=6),t<7&&(LT(n),n.schema=7),t<8&&(n.schema=8),t<9&&(Sy(n),n.schema=9),t<10&&(VT(n),n.schema=10),t<11&&(GT(n),n.schema=11),t<12&&(Sy(n),n.schema=12),t<13&&(zT(n),n.schema=13),t<14&&(FT(n),n.schema=14),t<15&&(jT(n),n.schema=15),t<16&&(UT(n),n.schema=16),t<17&&(bo(n,wy),vo(n,wy),n.schema=17),t<18&&(bo(n,by),vo(n,by),n.schema=18),t<19&&(OT(n),n.schema=19),t<20&&(HT(n),WT(n),n.schema=20),t<21&&($T(n),YT(n),n.schema=21),t<22&&(Ty(n),n.schema=22),t<23&&(XT(n),n.schema=23),t<24&&(KT(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(kT(n),t<25&&(n.schema=25)),t<26&&(DT(n),n.schema=26),t<27&&(BT(n),n.schema=27),t<28&&(Ty(n),n.schema=28),t<29&&(RT(n),n.schema=29),t<30&&(QT(n),n.schema=30),t<31&&(ZT(n),n.schema=31),t<33&&(JT(n),n.schema=33),t<34&&(eC(n),n.schema=34),t<35&&(tC(n),n.schema=35),t<36&&(rC(n),n.schema=36),t<37&&(oC(n),n.schema=37),t<38&&(bo(n,_y),vo(n,_y),n.schema=38),t<39&&(nC(n),n.schema=39),t<40&&(iC(n),n.schema=40),t<41&&(aC(n),n.schema=41),t<42&&(sC(n),n.schema=42),t<43&&(lC(n),n.schema=43),t<99){bo(n,Py),vo(n,Py),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=Uo);let e=Ye(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=Ho,r.insertBefore(null,null,[{id:Ho,data:{...xo.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:xr(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:xr(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...ns.defaultData,...xr(n.scene.environment,"usePhysics","gravity")},camera:Ye(n.scene.ownerCamera)??xo.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==Xo.TRASH_CAN_ID&&r.move(Ho,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,Wo.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 cC(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 Vi=180/Math.PI;function Iy(n){n.rotation=n.rotation.slice(0,3).map(t=>t*Vi)}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*Vi))});let t=n.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Vi),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Vi),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Vi,t.extrusion.twist*=Vi),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(Ye(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 uC(n){n.shared.variables=Wt({},he.prototype)}function dC(n){let t=Ye(n.shared.variables);n.shared.variables=Wt(Object.entries(t??{}).map(([e,r],o)=>({fi:o,id:e,data:r})),ye.prototype)}var So=107;function Ey(n,t){t(n.data);for(let e of n.children)Ey(e,t)}function pC(n){let t=n.schema??104;t!==So&&t<105&&(Ey(n.asset,Ny),n.schema=105)}function ec(n){let t=n.schema??0;if(t!==So){console.warn("updating from ",t,"to ",So),Oy(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=qr.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(bo(n,My),vo(n,My),n.schema=101),t<102&&(cC(n),n.schema=102),t<104&&(n.shared.catelogs=new he,n.shared.lib=Ko.defaultData(),n.schema=104),t<105&&(uC(n),n.scene.objects.traverse((e,r)=>{Ny(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))pC(e);t<106&&(dC(n),n.schema=106),t<107&&(n.shared.lib.variables=Ko.defaultData().variables,n.schema=107)}}var Di;(s=>{s.defaultData={schema:So,scene:Xo.defaultData,frames:new he().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Bi.defaultData),shared:{...br.emptyData(),colors:br.defaultColors()}},s.emptyDataForImports=function(l){let d=Xo.emptyDataWithPage(l);return{schema:So,scene:d,frames:new he().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Bi.defaultData),shared:{...br.emptyData(),colors:br.defaultColors(),images:br.defaultImages(l)}}},s.emptyData=function(){return{schema:So,scene:Xo.emptyDataWithPage(),frames:new he().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Bi.defaultData),shared:br.emptyData()}},s.collabHelper={...Za,updateSchema(l){return(l.schema??0)<So?Vo(l,ec):(l.schema??0)-So}};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:Ko.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})(Di||(Di={}));var Ea=Rt(Dy());import{Object3D as aM,Vector3 as lr,Euler as Np,MathUtils as dx,Matrix4 as $n}from"three";var fC=.5*(Math.sqrt(3)-1),is=(3-Math.sqrt(3))/6,hC=1/3,Wr=1/6,wU=(Math.sqrt(5)-1)/4,_U=(5-Math.sqrt(5))/20,as=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]),Zu=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 tc(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)*fC,u=as(i+c),p=as(a+c),f=(u+p)*is,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+is,b=g-S+is,_=y-1+2*is,A=g-1+2*is,v=u&255,M=p&255,O=.5-y*y-g*g;if(O>=0){let P=v+t[M],I=e[P],E=r[P];O*=O,s=O*O*(I*y+E*g)}let T=.5-w*w-b*b;if(T>=0){let P=v+x+t[M+S],I=e[P],E=r[P];T*=T,l=T*T*(I*w+E*b)}let C=.5-_*_-A*A;if(C>=0){let P=v+1+t[M+1],I=e[P],E=r[P];C*=C,d=C*C*(I*_+E*A)}return 70*(s+l+d)}}function Ry(n=Math.random){let t=Vy(n),e=new Float64Array(t).map(i=>Zu[i%12*3]),r=new Float64Array(t).map(i=>Zu[i%12*3+1]),o=new Float64Array(t).map(i=>Zu[i%12*3+2]);return function(a,s,l){let d,c,u,p,f=(a+s+l)*hC,h=as(a+f),m=as(s+f),y=as(l+f),g=(h+m+y)*Wr,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+Wr,E=_-M+Wr,R=A-O+Wr,L=b-T+2*Wr,F=_-C+2*Wr,V=A-P+2*Wr,B=b-1+3*Wr,j=_-1+3*Wr,H=A-1+3*Wr,X=h&255,$=m&255,W=y&255,Y=.6-b*b-_*_-A*A;if(Y<0)d=0;else{let G=X+t[$+t[W]];Y*=Y,d=Y*Y*(e[G]*b+r[G]*_+o[G]*A)}let z=.6-I*I-E*E-R*R;if(z<0)c=0;else{let G=X+v+t[$+M+t[W+O]];z*=z,c=z*z*(e[G]*I+r[G]*E+o[G]*R)}let q=.6-L*L-F*F-V*V;if(q<0)u=0;else{let G=X+T+t[$+C+t[W+P]];q*=q,u=q*q*(e[G]*L+r[G]*F+o[G]*V)}let U=.6-B*B-j*j-H*H;if(U<0)p=0;else{let G=X+1+t[$+1+t[W+1]];U*=U,p=U*U*(e[G]*B+r[G]*j+o[G]*H)}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}import{Triangle as mC}from"three";var Sr=new mC,rc=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;Sr.a.fromBufferAttribute(t,o),Sr.b.fromBufferAttribute(t,o+1),Sr.c.fromBufferAttribute(t,o+2),i*=Sr.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),Sr.a.fromBufferAttribute(this.positionAttribute,t*3),Sr.b.fromBufferAttribute(this.positionAttribute,t*3+1),Sr.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(Sr.a,o).addScaledVector(Sr.b,i).addScaledVector(Sr.c,1-(o+i)),Sr.getNormal(r),this}};import{Object3D as bC}from"three";var ky=Rt(zy());import{Object3D as yC,Matrix4 as $r}from"three";var gC=new $r,xC=new $r,vC=new $r,Gi;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(Gi||(Gi={}));var zi=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new $r;this.copyPreviousMatrix=!0;this.hiddenMatrix=new $r;this.matrixWorldRigid=new $r;this.shearScale=new $r;this.shearScaleInv=new $r}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof yC&&(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)Gi.is(i)&&i.traverseObject(r,o+1)}traverseObject(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Gi.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,ky.SVD)(o),l=gC.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=xC.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=vC.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 $r().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),i.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof $r?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 Ju=class extends zi(bC){},SC=n=>n.type==="Mesh",wo=class extends Ju{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 wo(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 SC(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};import{Box3 as I2,BufferGeometry as N2,MeshBasicMaterial as E2}from"three";import{Matrix4 as O2,Mesh as M2}from"three";import{Matrix4 as ic,Vector3 as Uy,Euler as PC,MathUtils as ls}from"three";import{Box3 as wC,Line3 as _C,Matrix4 as ed,Vector3 as ir}from"three";var Pn=new ir,On=new ir,ki=new ed,jy=[new ir(-1,1,1),new ir(-1,-1,1),new ir(1,-1,1),new ir(1,1,1),new ir(-1,1,-1),new ir(-1,-1,-1),new ir(1,-1,-1),new ir(1,1,-1)],AC=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],TC=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Fy=(n,t,e)=>{n.updateEntityBoxSize(Pn,On),ki.copy(t).multiply(n.matrixWorld),On.x===0&&On.y===0&&On.z===0?e.push(new ir(Pn.x,Pn.y,Pn.z).applyMatrix4(ki)):jy.forEach(r=>{e.push(r.clone().multiply(On).add(Pn).applyMatrix4(ki))})},ss=class extends wC{constructor(){super(...arguments);this.matrix=new ed;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 ed().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 ir);return}Fy(a,r,i)}}):Fy(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(ki.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(On).multiplyScalar(.5),this.getCenter(Pn),ki.copy(this.matrix).setPosition(Pn),this.vertices=jy.map(e=>e.clone().multiply(On).applyMatrix4(ki))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=AC.map(([e,r])=>new _C(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new ir))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=TC.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var wr={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};import{CurvePath as CC,CubicBezierCurve3 as td,Vector3 as _r}from"three";var od=class extends CC{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 nd=.001;function id(n,t,e){return t.clone().sub(n).cross(t.clone().sub(e)).length()<=nd}function rd(n,t){let e=new _r(...n.position),r=new _r(...n.controlNext.position),o=new _r(...t.controlPrevious.position),i=new _r(...t.position);return id(e,r,i)&&id(e,o,i)}function nc(n){let t=n.points.map(c=>new _r(...c.data.position)),e=[n.points[0]],r=new _r(...e[0].data.position);for(let c=0;c<n.points.length-1;c++)id(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 _r(...u.position),f=new _r(...u.controlPrevious.position),h=new _r(...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 _r(...x.position),b=new _r(...S.position),_=w.clone().sub(p).normalize(),A=b.clone().sub(p).normalize();Object.assign(m,{prevDir:_,nextDir:A});let v=rd(x,u),M=rd(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(!rd(e[u].data,e[p].data))f.position.distanceTo(h.position)>nd&&(m=new td(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)>nd&&(m=new td(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 td(f,v,M,h)}let d=new od;return l.forEach(c=>{c&&d.add(c)}),d}var Ae;(t=>{function n(e){return e&&e.__isEntity}t.is=n})(Ae||(Ae={}));var Fi=n=>Ae.is(n),OC={type:"completeState",isfromEntity:!0},MC=["x","y","z"],ad=new Uy,IC=new Uy().set(0,1,0),ji=n=>class extends zi(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 ss;this._recursiveBBox=new ss;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(Ae.is(o))return o}entityChildrenCount(){let r=this.children.length;for(;r--;)if(Ae.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(Ae.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)Cn.toOps(this.data,a.data).forEach(l=>{let d=Sl.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=Cn.patch(this.data,a),Cn.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=>{Fi(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(Ae.is(o[i]))return o[i];if(Ae.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&Ae.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)Fi(o)&&r(o)}traverseEntityAncestors(r){this.traverseAncestors(o=>{Ae.is(o)&&r(o)})}traverseConcreteEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Fi(a)&&a.isConcreteEntity&&a.traverseEntity(r,o+1)}traverseEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Fi(a)&&a.traverseEntity(r,o+1)}traverseVisibleEntity(r){r(this);for(let o of this.children)Fi(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=>Fi(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*ls.RAD2DEG,this.rotation.y*ls.RAD2DEG,this.rotation.z*ls.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,MC[s]])??a)}updateTransformState(r,o){let i=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,o)),i=!0),r.rotation&&(ad.fromArray(this.getTransformValues("rotation",r,o)).multiplyScalar(ls.DEG2RAD),this.rotation.setFromVector3(ad),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??jo.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)Ae.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{Ae.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=Dt(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=ot.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=ot.removeOverridden(r.path,r.props,c);l={...r,props:u}}}if(this.updateByPatchedOpBase(l,Cn.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),Dt(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(Gr.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...c]);if(p){let f=ot.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=Ni.resolve(o.overrides,c),p.updateByOp(r,nt.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 Hr.rootOverrideProps)p in r.props&&(u===void 0&&(u={}),u[p]=r.props[p]);u&&(c={...r,props:u})}else for(let u of Hr.rootOverrideProps)if(Dt(r.path,[u])){c=r;break}c!==void 0&&this.instances.forEach(u=>{if(u.isInstanceRoot){let p=Gr.filterOp(u.overrideData,c);p&&u.updateByOp(p,nt.applySimple(u.data,p),i,!0)}}),this.instances.forEach(u=>{if(!u.isInstanceRoot){let p=Gr.filterOp(u.overrideData,r);if(p){let f;s===u.data&&r===p?f=o:f=nt.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&&!vr.is(r.props.type)&&wr.changeEntityProptotype(this,o,i);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){wr.changeEntityProptotype(this,o,i);for(let a of this.children)Ae.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),Dt(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Dt(r.path,["cloner"])!==null){let a=nt.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=nc(d.geometry.path),u=(i+a)%1;i+a===1&&u===0&&(u=1);let p=c.getPointAt(u),f=this.parent?this.parent?.matrixWorld:new ic;l.updateMatrixWorld();let h=new ic().multiplyMatrices(f.clone().invert(),l.matrixWorld);p.applyMatrix4(h);let m={position:p.toArray(),rotation:d.rotation};if(s==="tangential"){let y=new ic().extractRotation(l.matrixWorld),g=c.getTangentAt(u).applyMatrix4(y).add(p),x=new ic().lookAt(p,g,IC),S=ad.setFromEuler(new PC().setFromRotationMatrix(x)).multiplyScalar(ls.RAD2DEG);m={...m,rotation:S.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(OC)})}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 wr.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 wr.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)}};import{BufferGeometry as LC,ConeGeometry as DC,Float32BufferAttribute as BC,MathUtils as RC}from"three";import{BufferGeometry as qy,CylinderGeometry as NC,Float32BufferAttribute as sc,MathUtils as EC,Vector2 as Ar,Vector3 as ac}from"three";var 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=EC.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 qy,h.setAttribute("position",new sc([],3))):u||f?h=new cs(d,c,r,o,i,a,s,l*Math.PI/180,u,u,p,f):h=new NC(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 Qo(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function Hy(n){return new Ar(n.y,-n.x)}var cs=class extends qy{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 ac,b=new ac;f&&t==0&&(t=d),f&&e==0&&(e=c);let _=new Ar(t,S),A=new Ar(e,-S),v=null,M=null,O=null,T=null,C=_.clone().sub(A),P=0,I=0,E=0;p>0&&(P=Math.min(t,e)*(1-p),I=t-P,E=e-P);let R=_.clone();R.x-=P;let L=Math.PI-C.angle(),F=C.angle(),V=Math.tan(F/2),B=Math.tan(L/2),j=V+B,H=p?j:B,X=p?j:V;if(d=Math.min(d,(t-I)/H,C.length()/j),c=Math.min(c,(e-E)/X,C.length()/j),d>0){let U=d/V;v=_.clone().sub(new Ar(U,d)),p&&(O=v.clone(),O.x-=P-j*d),_.sub(C.clone().setLength(U))}if(c>0){let U=c/B;M=A.clone().sub(new Ar(U,-c)),A.add(C.clone().setLength(U)),p&&(T=M.clone(),T.x-=P-j*c,R.sub(C.clone().setLength(U)))}C=_.clone().sub(A);let $=C.length()<.5,W=[];for(let U=0;U<=o;U++){let G=[],oe=U/o,ee=oe*l+s,Q=new Ar(Math.sin(ee),Math.cos(ee));T&&M?(Y(G,oe,Q,L,c,T,-1,!0),Y(G,oe,Q,F,c,M,-1,!1)):M?(z(G,Q,M.x,0,-1),Y(G,oe,Q,F,c,M,-1,!1)):a||z(G,Q,e,E,-1);let te=Hy(C).normalize();if(Qo(te,Q,w),!$)for(let Z=0;Z<=i;Z++){let se=Z/i,ne=C.clone().multiplyScalar(se).add(A);Qo(ne,Q,b),m.push(b.x,b.y,b.z),y.push(w.x,w.y,w.z),g.push(oe,.5+b.y/r),G.push(x++)}if(O&&v?(Y(G,oe,Q,L,d,v,1,!1),Y(G,oe,Q,F,d,O,1,!0)):v?(Y(G,oe,Q,L,d,v,1,!1),z(G,Q,v.x,0,1)):a||z(G,Q,t,I,1),p&&!$){let Z=Hy(C).multiplyScalar(-1).normalize();Qo(Z,Q,w);for(let se=0;se<=i;se++){let ne=se/i,ie=C.clone().multiplyScalar(-ne).add(R);Qo(ie,Q,b),m.push(b.x,b.y,b.z),y.push(w.x,w.y,w.z),g.push(oe,.5+b.y/r),G.push(x++)}}p&&!a&&G.push(G[0]),W.push(G)}for(let U=0;U<W.length-1;U++)for(let G=0;G<W[0].length-1;G++){if(a&&p&&G==i)continue;let oe=W[U][G],ee=W[U+1][G],Q=W[U+1][G+1],te=W[U][G+1],Z=m[Q*3+0],se=m[Q*3+2];h.push(oe,ee,te),(Z!=0||se!=0)&&h.push(ee,Q,te)}l<Math.PI*2&&(q(-1,W[0],s),q(1,W[W.length-1],s+l)),this.setIndex(h),this.setAttribute("position",new sc(m,3)),this.setAttribute("normal",new sc(y,3)),this.setAttribute("uv",new sc(g,2));function Y(U,G,oe,ee,Q,te,Z,se){for(let ne=0;ne<u+1;ne++){let ie=ne/u,ue=Z<0?ie:1-ie;se&&(ue-=1),ue*=ee;let le=new Ar(Math.sin(ue),Math.cos(ue)*Z),de=le.clone().multiplyScalar(Q).add(te);Qo(de,oe,b),m.push(b.x,b.y,b.z),Qo(le,oe,w),y.push(w.x,w.y,w.z),g.push(G,.5+b.y/r),U.push(x++)}}function z(U,G,oe,ee,Q){let te=new ac,Z=new Ar,se=[oe,ee];Q<0&&se.reverse();for(let ne of se)Z.set(ne,S*Q),Qo(Z,G,te),m.push(te.x,te.y,te.z),y.push(0,Q,0),g.push(.5,.5),U.push(x++)}function q(U,G,oe){let ee=new Ar(Math.sin(oe),Math.cos(oe)),Q=new Ar(-Math.cos(oe),Math.sin(oe)),te=new ac,Z=U<0?(ie,ue,le)=>h.push(ie,ue,le):(ie,ue,le)=>h.push(ie,le,ue),se=new Ar((t+e+I+E)/4,0);Qo(se,ee,te),m.push(te.x,te.y,te.z),y.push(Q.x,0,Q.y),g.push(.5,.5);let ne=x++;for(let ie of G){let ue=m.slice(ie*3,ie*3+3);m.push(...ue),y.push(Q.x,0,Q.y);let le=g.slice(ie*2,ie*2+2);g.push(...le),x++}for(let ie=ne+1;ie<x-1;ie++)Z(ne,ie,ie+1);Z(ne,x-1,ne+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=RC.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 LC,p.setAttribute("position",new BC([],3))):d>0||c>0||l<360?p=new cs(0,t/2,r,o,i,a,s,l*Math.PI/180,d,c,u,0,!0):p=new DC(t/2,r,o,i,a),p.scale(1,1,e/t),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};import{BoxGeometry as VC,BufferGeometry as GC,Float32BufferAttribute as sd,Vector3 as us}from"three";var 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 VC(t,e,r,o,i,a):d=new cd(t,e,r,o,i,a,s,l),Object.assign(d,{userData:{...n,type:"CubeGeometry"}})}},ld=Math.PI/2,cd=class extends GC{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 sd(u,3)),this.setAttribute("normal",new sd(p,3)),this.setAttribute("uv",new sd(f,2));function y(S,w,b,_,A,v,M,O,T,C,P){let I=(v-2*s)/T,E=(M-2*s)/C,R=v/2-s,L=M/2-s,F=O/2,V=T+1,B=C+1,j=0,H=0,X=new us;for(let $=0;$<B;$++){let W=$*E-L;for(let Y=0;Y<V;Y++){let z=Y*I-R;X[S]=z*_,X[w]=W*A,X[b]=F,u.push(X.x,X.y,X.z),X[S]=0,X[w]=0,X[b]=O>0?1:-1,p.push(X.x,X.y,X.z),f.push(Y/T),f.push(1-$/C),j+=1}}for(let $=0;$<C;$++)for(let W=0;W<T;W++){let Y=h+W+V*$,z=h+W+V*($+1),q=h+(W+1)+V*($+1),U=h+(W+1)+V*$;c.push(Y,z,U),c.push(z,q,U),H+=6}d.addGroup(m,H,P),m+=H,h+=j}function g(S,w,b,_,A,v,M,O,T,C,P){let I=(M-2*s)/C,E=M/2-s,R=O/2-s,L=T/2,F=C+1,V=0,B=0,j=new us,H=new us;for(let X=0;X<l+1;X++){let $=X/l*ld,W=Math.sin($)*s,Y=(1-Math.cos($))*s,z=Math.sin($),q=Math.cos($);j[w]=(R+W)*A,j[b]=(L-Y)*v,H[S]=0,H[w]=z*Math.sign(j[w]),H[b]=q*Math.sign(j[b]);for(let U=0;U<F;U++){let G=U*I-E;j[S]=G*_,u.push(j.x,j.y,j.z),p.push(H.x,H.y,H.z),f.push(U/C),f.push(0),V+=1}}for(let X=0;X<l;X++)for(let $=0;$<C;$++){let W=h+$+F*X,Y=h+$+F*(X+1),z=h+($+1)+F*(X+1),q=h+($+1)+F*X;c.push(W,Y,q),c.push(Y,z,q),B+=6}d.addGroup(m,B,P),m+=B,h+=V}function x(S,w,b){let _=new us,A=new us(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=ld*(1-T/l),I=Math.cos(P),E=Math.sin(P),R=0;for(let L=0;L<=T;L++){let F=Math.cos(R),V=Math.sin(R);_.x=I*F,_.y=E,_.z=I*V;let B=A.clone().addScaledVector(_,s);u.push(S*B.x,w*B.y,b*B.z),p.push(S*_.x,w*_.y,b*_.z),f.push(0,0),C.push(h++),R+=ld/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 E=1;E<=I;E++)M(C[E-1],C[E],P[E]),M(C[E],P[E+1],P[E])}}}};import{BufferGeometry as zC,Float32BufferAttribute as ud,Triangle as kC,Vector3 as _o,Vector2 as dd}from"three";var Zo=class extends zC{constructor(t=[],e=[],r="",o=1,i=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],d=[];c(),u(),this.setAttribute("position",new ud(s,3)),this.setAttribute("normal",new ud(d,3)),this.setAttribute("uv",new ud(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 _o,m=h.clone(),y=new kC,g=i*o,x=o-g,S=a+1,w=new _o,b=(V,B)=>w.subVectors(V,B).normalize(),_=(V,B)=>Array(V).fill(void 0).map(B),A=_(t.length/3,(V,B)=>new _o().fromArray(t,B*3).setLength(o)),v=[],M=1e6;for(let V=0;V<A.length;V++){let B=A[V],j=[],H,X,$,W=1e10,Y=-1;for(;(Y=e.indexOf(V,Y+1))!=-1;){let G=Y-Y%3;H=e[G+(Y+1)%3],X=e[G+(Y+2)%3],$=B.distanceToSquared(A[H]),W=Math.min(W,$),j.push([H,X,$])}W+=1e-6;let z=[],q=0,U=j.length;for(let G=0;G<U;G++){[H,X,$]=j[q];let oe=v[H]?.includes(V)==!0;$<=W&&z.push(H+ +oe*M),q=j.findIndex(ee=>ee[0]==X)}v.push(z)}let O=[];{let V=0,B=0,j,H,X=f==3;for(let $=0;$<=a;$++){j=$*($+1)/2,H=($+1)*($+2)/2;for(let W=0;W<a-$;W++)[V,B]=[j+W+$+2,H+W+$+3],O.push(j,H,...X?[B,j]:[V,H],B,V),[j,H]=[V,B];O.push(j,H,j+a+2)}}let T=h.clone(),C=h.clone(),P=h.clone(),I=h.clone(),E=h.clone(),R=[],L=_(A.length,()=>_(f,()=>h.clone()));for(let V=0;V<A.length;V++){h.copy(A[V]).normalize(),T.copy(h).multiplyScalar(x);let B=v[V];for(let z=0;z<B.length;z++){let q=B[z],U=B[(z+1)%f];y.setFromPointsAndIndices(A,V,q%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,L[V][z])}let j=[],H=[],X=[],$=new _o;a==0&&[...L[V]].reduce((z,q)=>z.add(q),$).multiplyScalar(1/f);for(let z=0;z<f;z++){let q=[],U=(z-1+f)%f,G=L[V][U],oe=L[V][z];h.copy(G).sub(T),m.copy(oe).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),H.push(te);let Z=[C,G,oe];for(let se=0;se<2;se++){let ne=Z[se],ie=Z[se+1];I.subVectors(ne,T),E.subVectors(ie,T),P.crossVectors(I,E).normalize();for(let ue=0;ue<S;ue++){let le=[ee,Q][se]*ue/S;h.copy(I).applyAxisAngle(P,le).add(T),j.push(h.clone()),se&&(b(h,T),q.push([ue==0?ne:h.clone(),w.clone()]))}se&&(b(ie,T),q.push([ie,w.clone()]))}X.push(q)}R.push(X);let W=2*S,Y=2;for(let z=0;z<f;z++){let q=W*z,U=W*((z+1)%f),G=[j[q]];for(let ee=1;ee<S;ee++){I=j[q+ee],E=j[U+ee],G.push(I);for(let Q=1,te=ee-Y+1;Q<=te;Q++)h.lerpVectors(I,E,Q/(te+1)),h.sub(T).setLength(H[z]).add(T),G.push(h.clone());G.push(E)}for(let ee=0;ee<S;ee++)G.push(j[ee+S+q]);G.push(j[U+S]);let oe=O.map(ee=>G[ee]);s.push(...oe.map(ee=>[ee.x,ee.y,ee.z]).flat()),d.push(...oe.map(ee=>(b(ee,T),[w.x,w.y,w.z])).flat())}}let F=[];for(let V=0;V<v.length;V++)for(let B=0;B<f;B++){let j=v[V][B];if(j<M){let H=v[j].findIndex(W=>W%M==V),X=R[V][B],$=R[j][H];for(let W=0;W<S;W++){let Y=X[W],z=$[S-W],q=X[W+1],U=$[S-(W+1)];[Y,z,q,q,z,U].forEach(G=>{s.push(G[0].x,G[0].y,G[0].z),d.push(G[1].x,G[1].y,G[1].z)})}F.push(X[0][0],$[S][0],X[S][0],$[0][0])}}for(;F.length;){let V,B,j,H;[V,B]=F.splice(0,2);let X=[V];for(;V!=B;)X.push(B),j=F.indexOf(B),H=j%2,B=F.splice(j-H,2)[1-H];w.subVectors(X[0],X[1]).cross(h.subVectors(X[0],X[2])).normalize();let $=w.dot(X[0])<0;$&&w.negate();for(let W=1;W<=X.length-2;W++)[X[W+ +$],X[W+1-+$],X[0]].forEach(Y=>{s.push(Y.x,Y.y,Y.z),d.push(w.x,w.y,w.z)})}}function u(){let p=new _o;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 _o,h=new _o,m=new _o,y=new _o,g=new dd,x=new dd,S=new dd,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 Zo(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};import{DodecahedronGeometry as FC}from"three";var Xy=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 FC(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},ds=class extends Zo{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)}};import{Plane as ZC,Shape as ug,Vector2 as Ao,Vector3 as JC,MathUtils as xd,LineCurve as vd,QuadraticBezierCurve as dg,CubicBezierCurve as dc}from"three";import{CubicBezierCurve as lc,EllipseCurve as jC,LineCurve as cc,LineCurve3 as UC,MathUtils as HC,QuadraticBezierCurve as fd,SplineCurve as qC,Vector2 as Bt,Vector3 as Zy}from"three";var ps=1e-12,Ui=class{constructor(t){this.position=new Bt;this.startPosition=new Bt;this.uuid=HC.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 Ui(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Hi=class extends Ui{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Hi(this.parent).copy(this)}},Tr=class extends Ui{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Hi(this),new Hi(this))}static create(e,r){let o=new Tr(e,new Bt(...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 Tr(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 Bt,r=new Bt){let[o,i]=this.computeTangents();return o&&i&&(Ky(o,e),Ky(i,r)),[e,r]}computeTangent(e=new Bt){let[r,o]=this.computeTangents();return r&&o&&e.copy(r).add(o).normalize(),e}computeNormal(e=new Bt){let[r,o]=this.computeNormals();return e.copy(r).add(o).normalize(),e}};function Ky(n,t=new Bt){let e=n.length();return t.set(-n.y/e,n.x/e)}var hd=n=>n,qi=new Bt,uc=new Bt,WC=new Bt,$C=new Bt,YC=new Bt,XC=new Bt,Jy=new Zy,eg=new Zy;function tg(n){let t=new Bt;t.addVectors(n.v0,qi.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Bt;return e.addVectors(n.v2,uc.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new lc(n.v0,t,e,n.v2)}function fs(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function KC(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function QC(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function md(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 Qy(n,t)&&Qy(t,e)&&pd(n.position,t.position,e.position)}function pd(n,t,e){return qi.copy(t).sub(n).cross(uc.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 md(t,n,e)>Math.PI&&(c*=-1),fs(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 yd(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function Qy(n,t){return pd(n.position,n.controls[1].position,t.position)&&pd(n.position,t.controls[0].position,t.position)}function ag(n,t,e,r,o=.5){let i=qi.subVectors(t,n).multiplyScalar(o).add(n),a=uc.subVectors(e,t).multiplyScalar(o).add(t),s=WC.subVectors(r,e).multiplyScalar(o).add(e),l=i,d=$C.subVectors(a,i).multiplyScalar(o).add(i),c=YC.subVectors(s,a).multiplyScalar(o).add(a),u=s,p=XC.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=hd(t[l]),c=qi,u=Jo(d,e);s.push(u);for(let p=0;p<=u;p++)if(d instanceof lc||d instanceof fd||d instanceof cc){if(d.getPoint(p/u,c),o.set(c.x,c.y,0),i!==void 0&&QC(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=hd(t[l]),u=qi,p=Jo(c,r);s.push(p);for(let f=0;f<=p;f++)if(c instanceof lc||c instanceof fd||c instanceof cc){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 gd(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=Jo(a.roundedCurveCorner,t)*.5;o>0&&(r[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=Jo(a.curveAfter,t)),r.push(s)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=Jo(n[0].roundedCurveCorner,t)*.5),r}function Jo(n,t=12){return n&&n instanceof jC?t*2:n&&(n instanceof cc||n instanceof UC)?1:n&&n instanceof qC?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=hd(t[a]),l=Jo(s,e),d=qi;for(let c=0;c<=l;c++)if(s instanceof lc||s instanceof fd||s instanceof cc){if(s.getPoint(c/l,d),o!==void 0&&KC(o,d,ps))continue;o===void 0&&(o=uc),o.copy(d),n.push(d.x,d.y),i++}}return fs(n[0],n[n.length-2],ps)&&fs(n[1],n[n.length-1],ps)&&(n.pop(),n.pop()),r&&i>1&&!(fs(n[i-1],n[1],ps)&&fs(n[i-2],n[0],ps))&&(n.push(n[0],n[1]),i++),n}var bd=new Ao,eP=new Ao,tP=new Ao,rP=new Ao,oP=new Ao,nP=new Ao,Ne=class extends ug{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new ZC(new JC(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=xd.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,o){let i=new Ne;return i.isClosed=e.isClosed,i.points=e.points.map(a=>Tr.create(a.id,a.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(a=>Ne.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=bd.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=xd.generateUUID()){let i;e instanceof Ao?i=e:i=new Ao(e,r);let a=new Tr(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=gd(this.points,e,!1),this.roundedCurveDivisions=gd(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=Jo(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(yd(i,a)){let u=i.position.distanceTo(a.position);return i.position.distanceTo(bd.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){yd(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,bd),A=p.getPointAt(b,eP);this._subSplitCurve(u,f,w,_,void 0),this._subSplitCurve(p,h,b,void 0,A);let v;if(this.useCubicForRoundedCorners){let M=md(_,a.position,A)/2,O=Math.tan(M)*_.distanceTo(a.position),[T,C]=og(_,A,O,tP,rP),P=ng(T,C,a.position),[I,E]=ig(P,_,A,O,oP,nP);v=new dc(_.clone(),I.clone(),E.clone(),A.clone())}else v=new dg(_.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 vd)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 Ne(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 Tr(xd.generateUUID(),new Ao(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 Ne;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 dc&&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 dg&&(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 dc?(h=this.createPoint(p.v0),h.controls[1].position.copy(p.v1)):p instanceof vd&&(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 dc?c.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(c.v2),u=!0):c instanceof vd&&c.v2.equals(s[0].position)&&(u=!0),this.isClosed=u,s};return this.points=i(e.curves),e instanceof ug&&(this.shapeHoles=e.holes.map(a=>{let s=new Ne;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 wd=Math.PI*2;function Sd({x:n,y:t},e,r,o,i){return{x:n*e+o,y:t*r+i}}function iP(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 pg(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 aP(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=pg(1,0,S,w),v=pg(S,w,b,_);return!d&&v>0&&(v-=wd),d&&v<0&&(v+=wd),{centerx:g,centery:x,ang1:A,ang2:v}}function fg({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=aP(n,t,e,r,o,i,d,c,a,s),{ang1:f,ang2:h}=p,{centerx:m,centery:y}=p,g=Math.abs(h)/(wd/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(iP(f,h)),f+=h;return l.map(S=>{let{x:w,y:b}=Sd(S[0],o,i,m,y),{x:_,y:A}=Sd(S[1],o,i,m,y),{x:v,y:M}=Sd(S[2],o,i,m,y);return{x1:w,y1:b,x2:_,y2:A,x:v,y:M}})}import{BufferAttribute as yc,BufferGeometry as xP}from"three";var Pe;(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"})(Pe||(Pe={}));var Xe;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Xe||(Xe={}));function me(n,t){if(!n)throw t||"Assertion Failed!"}var pe=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){me(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){me(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){me(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){me(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}(),hs=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}(),pc=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}(),Wi=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}(),hg=function(){function n(){var t=new Wi,e=new hs,r=new pc(0),o=new pc(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 pc(0),r=new pc(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;me(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;me(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 Wi,e=new Wi,r=new hs,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 Wi;this.makeVertex_(i,e,t.Org),t.Org.anEdge=t}if(!r){var a=new hs;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 hs;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 Wi;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 hs;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&&pe.vertCCW(r.Lprev.Org,r.Org,i.Lnext.Lnext.Org)&&pe.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){me(o.prev===i),l=o.anEdge;do me(l.Sym!==l),me(l.Sym.Sym===l),me(l.Lnext.Onext.Sym===l),me(l.Onext.Sym.Lnext===l),me(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(me(o.prev===i&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){me(a.prev===s),l=a.anEdge;do me(l.Sym!==l),me(l.Sym.Sym===l),me(l.Lnext.Onext.Sym===l),me(l.Onext.Sym.Lnext===l),me(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(me(a.prev===s&&a.anEdge===null),d=r,d=r;(l=d.next)!==r;d=l)me(l.Sym.next===d.Sym),me(l.Sym!==l),me(l.Sym.Sym===l),me(l.Org!==null),me(l.Dst!==null),me(l.Lnext.Onext.Sym===l),me(l.Onext.Sym.Lnext===l);me(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}(),mg=function(){function n(){this.handle=null}return n}(),yg=function(){function n(){this.key=null,this.node=0}return n}(),sP=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 mg,this.handles[r]=new yg;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,me(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 mg;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new yg}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;me(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}(),_d=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}(),gg=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),lP=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new gg,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 gg;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}(),cP=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?pe.vertLeq(i.Org,a.Org)?pe.edgeSign(a.Dst,i.Org,a.Org)<=0:pe.edgeSign(i.Dst,a.Org,i.Org)>=0:pe.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return pe.edgeSign(i.Dst,o,i.Org)>=0;var s=pe.edgeEval(i.Dst,o,i.Org),l=pe.edgeEval(a.Dst,o,a.Org);return s>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&me(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){me(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 _d;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 Pe.ODD:return(e&1)!==0;case Pe.NONZERO:return e!==0;case Pe.POSITIVE:return e>0;case Pe.NEGATIVE:return e<0;case Pe.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 me(pe.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,me(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=pe.vertL1dist(e,t),i=pe.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(pe.vertLeq(o.Org,i.Org)){if(pe.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;pe.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(pe.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(me(!pe.vertEq(o.Dst,i.Dst)),pe.vertLeq(o.Dst,i.Dst)){if(pe.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(pe.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 Wi,f,h;if(me(!pe.vertEq(d,l)),me(pe.edgeSign(l,t.event,a)<=0),me(pe.edgeSign(d,t.event,s)>=0),me(a!==t.event&&s!==t.event),me(!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(pe.vertLeq(a,s)){if(pe.edgeSign(d,a,s)>0)return!1}else if(pe.edgeSign(l,s,a)<0)return!1;return n.debugEvent(t),pe.intersect(l,a,d,s,p),me(Math.min(a.t,l.t)<=p.t),me(p.t<=Math.max(s.t,d.t)),me(Math.min(d.s,l.s)<=p.s),me(p.s<=Math.max(s.s,a.s)),pe.vertLeq(p,t.event)&&(p.s=t.event.s,p.t=t.event.t),f=pe.vertLeq(a,s)?a:s,pe.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),pe.vertEq(p,a)||pe.vertEq(p,s)?(n.checkForRightSplice(t,e),!1):!pe.vertEq(l,t.event)&&pe.edgeSign(l,t.event,p)>=0||!pe.vertEq(d,t.event)&&pe.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):(pe.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),pe.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),pe.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),pe.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}pe.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,pe.vertEq(o.Org,r)){me(!1),n.spliceMergeVertices(t,o,r.anEdge);return}if(!pe.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}me(!1),e=n.topRightRegion(e),l=n.regionBelow(e),a=l.eUp.Sym,i=s=a.Onext,l.fixUpperEdge&&(me(i!==a),n.deleteRegion(t,l),t.mesh.delete(a),a=i.Oprev),t.mesh.splice(r.anEdge,a),pe.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 _d;if(d.eUp=e.anEdge.Sym,r=t.dict.search(d).key,o=n.regionBelow(r),!!o){if(a=r.eUp,s=o.eUp,pe.edgeSign(a.Dst,e,a.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(i=pe.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);me(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 _d,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 lP(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||(me(e.fixUpperEdge),me(++r===1)),me(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,pe.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 sP(i,pe.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,me(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||!pe.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}(),uP=function(){function n(){this.mesh=new hg,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=Pe.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(;pe.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;pe.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var i=void 0;r.Lnext!==o;)if(pe.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(pe.edgeGoesLeft(o.Lnext)||pe.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&&(pe.edgeGoesRight(r.Lprev)||pe.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===Xe.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===Xe.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 hg),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=Pe.ODD),e===void 0&&(e=Xe.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_(),cP.computeInterior(this,a);var s=this.mesh;return e===Xe.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===Xe.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,r,o),!0},n}();function Cr(n){var t=n.windingRule,e=t===void 0?Pe.ODD:t,r=n.elementType,o=r===void 0?Xe.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 uP;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 Q4=Pe.ODD,Z4=Pe.NONZERO,J4=Pe.POSITIVE,e5=Pe.NEGATIVE,t5=Pe.ABS_GEQ_TWO,r5=Xe.POLYGONS,o5=Xe.CONNECTED_POLYGONS,n5=Xe.BOUNDARY_CONTOURS;import{Box2 as mP,BufferAttribute as mc,BufferGeometry as yP,Vector2 as gP}from"three";var fc=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*fc.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*fc.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)}},ms=fc;ms.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Sg=Rt(bg()),ys={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Od={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Md={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},Pd=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),tn=class extends yP{constructor(e,r,o=0,i=12,a=3,s=Pe.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 E=C[I-1],R=C[I-0];P.push(E,R)}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 mP().setFromPoints(e.points.map(C=>C.position)).getSize(new gP).length()*.1:u[0].length===0?f=o:f=(0,Sg.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=Cr({windingRule:s,elementType:Xe.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[d]})}catch{h=ys}let m;try{m=Cr({windingRule:Pe.ODD,elementType:Xe.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]})}catch{m=Od}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],E=h.vertices[P+1];I<g&&(g=I),I>x&&(x=I),E<S&&(S=E),E>w&&(w=E)}this._minX=g,this._minY=S,this._width=x-g,this._height=w-S,this._buffer=new ms(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],E=h.elements[P+1],R=I+E,L={start:I,count:E,normals:[],continuous:[],concave:[]},F=I,V=R-1,B=I+1,j=this._shape.roundedCurves.length;do{let Y=F-I,z=h.vertices[V*2+0],q=h.vertices[V*2+1],U=h.vertices[F*2+0],G=h.vertices[F*2+1],oe=h.vertices[B*2+0],ee=h.vertices[B*2+1],Q=U-z,te=G-q,Z=Math.sqrt(Q*Q+te*te);Q/=Z,te/=Z;let se=U-oe,ne=G-ee,ie=Math.sqrt(se*se+ne*ne);se/=ie,ne/=ie,L.normals[Y*2+0]=-ne,L.normals[Y*2+1]=se,L.concave[Y]=Q*ne-te*se>0;let ue=h.vertexIndices[F];if(Array.isArray(ue))L.continuous[Y]=!1;else{let[le,de]=this._shape.getCurveIndexFromVertexId(ue-1,!0);if(de>0&&de<1)L.continuous[Y]=!0;else{let ge=de===1?le+1:le-1;ge=(ge+j)%j;let Oe=de===1?0:1,He=this._shape.roundedCurves[le].getTangent(de),Me=this._shape.roundedCurves[ge].getTangent(Oe);L.continuous[Y]=He.dot(Me)>.95}}C&&(L.normals[Y*2+0]*=-1,L.normals[Y*2+1]*=-1),[V,F,B]=[F,B,B+1],B>=R&&(B-=E)}while(B!==I+1);let H=[];H.push({bevelI:0,angle:0,size:0,boundary:{vertices:h.vertices.slice(I*2,R*2),vertexCount:E,vertexIndices:new Array(E).fill(!0).map((Y,z)=>[z,z]),elements:[0,E],elementCount:1,mesh:null},reverseMap:[],insetPoints:h.vertices.slice(I*2,R*2)});let X=0;for(let Y=1;Y<=this._bevelSegments;Y++){let z=Y/this._bevelSegments*Math.PI/2,q=(1-Math.cos(z))*this._bevel,U=[],G=[],oe=[],ee=[],Q=0;for(let Z=0;Z<E;Z++){let se=Z*2,ne=(Z-1+E)%E*2,ie=h.vertices[L.start*2+se+0],ue=h.vertices[L.start*2+se+1],le=-L.normals[ne+0]*q,de=-L.normals[ne+1]*q,ge=-L.normals[se+0]*q,Oe=-L.normals[se+1]*q;if(L.concave[Z]||!L.concave[Z]&&C){let He=Math.atan2(de,le),Me=Math.atan2(Oe,ge);Me>He&&(Me-=Math.PI*2);let Ge=Me-He;if(L.continuous[Z]||C){let Ut=He+Ge/2,Se=Math.cos(Ut)*q,ut=Math.sin(Ut)*q;U[2*Q+0]=ie+Se*(C?-1:1),U[2*Q+1]=ue+ut*(C?-1:1),ee[Q]=Z,Q++}else{let Ut=Math.max(1,Math.floor(i/4*Math.abs(Ge)/Math.PI));for(let Se=0;Se<=Ut;Se++){let ut=He+Ge*(Se/Ut),mt=Math.cos(ut)*q,Qn=Math.sin(ut)*q;U[2*Q+0]=ie+mt,U[2*Q+1]=ue+Qn,ee[Q]=Z,Q++}}}else U[2*Q+0]=ie+le,U[2*Q+1]=ue+de,ee[Q]=Z,G[Z]=Q,Q++,U[2*Q+0]=ie,U[2*Q+1]=ue,ee[Q]=Z,Q++,U[2*Q+0]=ie+ge,U[2*Q+1]=ue+Oe,ee[Q]=Z,oe[Z]=Q,Q++}let te=Cr({windingRule:Pe.POSITIVE,elementType:Xe.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[U],edgeCreateCallback:Z=>{let ne=Z.Org.idx,ie=ee[ne],ue=ee[(ne+1)%ee.length];Z.idx=[ie,ue],Z.Sym.idx=[ue,ie]},vertexIdCallback:Z=>{let se=Z.Lprev.idx;return[se?se[1]:0,Z.idx?Z.idx[0]:0]}});if(!te)throw console.log("Error"),new Error(`error generating bevel geometry for ${Y}'th loop`);if(!te.vertexCount){let Z=(Y-1)/this._bevelSegments*Math.PI/2;X=(1-Math.sin(Z))*this._bevel;break}for(let Z=0;Z<te.vertexIndices.length;Z++){let[se,ne]=te.vertexIndices[Z];if(se===ne)continue;let ie=ne;ne<se&&(ie+=E);for(let ue=se;ue<ie;ue++){let le=ue%E,de=(ue+1)%E;if(!L.continuous[le]||!L.continuous[de]){te.vertexIndices[Z]=[se,le],te.vertexIndices.splice(Z+1,0,[de,ne]),te.vertices.splice((Z+1)*2,0,te.vertices[Z*2],te.vertices[Z*2+1]);break}}}H.push({bevelI:Y,angle:z,size:q,boundary:te,reverseMap:ee,insetPoints:U})}let $=(Y,z,q)=>{let U=0,G=Y.boundary.vertexIndices.length;for(;U<G&&q(Y.boundary.vertexIndices[z]);)z=(z+1)%G,U++;return U},W=b.length;for(let Y=1;Y<H.length;Y++){let z=H[Y-1],q=H[Y],U=z.boundary.vertexIndices.length,G=q.boundary.vertexIndices.length;if(!U||!G)break;let oe=L.concave.length,ee=0,Q=Pd(ee,E);for(;!z.boundary.vertexIndices.filter(Q).length||!q.boundary.vertexIndices.filter(Q).length;)ee++,Q=Pd(ee,E);let te=z.boundary.vertexIndices.findIndex(Q),Z=q.boundary.vertexIndices.findIndex(Q);do te=(te+1)%U;while(Q(z.boundary.vertexIndices[te]));do Z=(Z+1)%G;while(Q(q.boundary.vertexIndices[Z]));ee=(ee+1)%E;let se=ee,ne=0,ie=this._buildBevelVert(L,z,(te-1+U)%U,void 0,ne),ue=this._buildBevelVert(L,q,(Z-1+G)%G,void 0,ne),le=ie,de=ue,ge,Oe,He=!1;do{ne=(ee||oe)/oe,Q=Pd(ee,E);let Me=$(z,te,Q),Ge=$(q,Z,Q),Ut=He;if(He=!1,Me&&!Ge){for(let Se=0;Se<Me;Se++)ge=this._buildBevelVert(L,z,(te+Se)%U,Se/(Me-1),ne),b.push(le.topN,ge.topP,de.topN),l===!1&&b.push(ge.bottomP,le.bottomN,de.bottomN),le=ge;He=!0}else if(!Me&&Ge)for(let Se=0;Se<Ge;Se++)Oe=this._buildBevelVert(L,q,(Z+Se)%G,Se/(Ge-1),ne),b.push(de.topN,le.topP,Oe.topP),l===!1&&b.push(le.bottomP,de.bottomN,Oe.bottomP),de=Oe;else if(Me&&Ge)if(ge=this._buildBevelVert(L,z,te,0,ne),Oe=this._buildBevelVert(L,q,Z,0,ne),Ut?(b.push(le.topN,Oe.topP,de.topN),b.push(le.topN,ge.topP,Oe.topP),l===!1&&(b.push(Oe.bottomP,le.bottomN,de.bottomN),b.push(Oe.bottomP,ge.bottomP,le.bottomN))):(b.push(de.topN,le.topN,ge.topP),b.push(de.topN,ge.topP,Oe.topP),l===!1&&(b.push(ge.bottomP,le.bottomN,de.bottomN),b.push(ge.bottomP,de.bottomN,Oe.bottomP))),le=ge,de=Oe,Me===Ge)for(let Se=1;Se<Me;Se++)ge=this._buildBevelVert(L,z,(te+Se)%U,Se/(Me-1),ne),Oe=this._buildBevelVert(L,q,(Z+Se)%G,Se/(Ge-1),ne),b.push(le.topN,ge.topP,de.topN),b.push(de.topN,ge.topP,Oe.topP),l===!1&&(b.push(ge.bottomP,le.bottomN,de.bottomN),b.push(ge.bottomP,de.bottomN,Oe.bottomP)),le=ge,de=Oe;else if(Me>Ge){let Se=Me/Ge,ut=0;for(let mt=1;mt<Me;mt++)ge=this._buildBevelVert(L,z,(te+mt)%U,mt/(Me-1),ne),b.push(le.topN,ge.topP,de.topN),l===!1&&b.push(ge.bottomP,le.bottomN,de.bottomN),le=ge,mt>(ut+1)*Se&&(ut++,Oe=this._buildBevelVert(L,q,(Z+ut)%G,ut/(Ge-1),ne),b.push(de.topN,ge.topP,Oe.topP),l===!1&&b.push(ge.bottomP,de.bottomN,Oe.bottomP),de=Oe)}else{let Se=Ge/Me,ut=0;for(let mt=1;mt<Ge;mt++)Oe=this._buildBevelVert(L,q,(Z+mt)%G,mt/(Ge-1),ne),b.push(de.topN,ge.topP,Oe.topP),l===!1&&b.push(ge.bottomP,de.bottomN,Oe.bottomP),de=Oe,mt>(ut+1)*Se&&(ut++,ge=this._buildBevelVert(L,z,(te+ut)%U,ut/(Me-1),ne),b.push(le.topN,ge.topP,de.topN),l===!1&&b.push(ge.bottomP,le.bottomN,de.bottomN),le=ge)}te=(te+Me)%U,Z=(Z+Ge)%G,ee=(ee+1)%oe}while(ee!==se)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(H,L,b),C){let Y=[];for(let z=b.length-1;z>=W+2;z-=3){let q=b[z-2],U=b[z-1],G=b[z-0];Y.push(G,U,q)}b.splice(W,b.length-W,...Y)}if(C){let Y=[];for(let z=H[H.length-1].boundary.vertices.length-1;z>=1;z-=2){let q=H[H.length-1].boundary.vertices[z-1],U=H[H.length-1].boundary.vertices[z-0];Y.push(q,U)}_.push(Y)}if(!C){let Y=H[H.length-1],z;try{z=Cr({windingRule:H.length>1?Pe.POSITIVE:Pe.ODD,elementType:Xe.POLYGONS,vertexSize:2,strict:!0,contours:[Y.insetPoints,..._]})}catch{z=Md}if(!z)throw new Error("Error generating geometry for surface");c.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let q=0;q<z.elementCount*3;q+=3){let U=this._buildSurfaceVert(z,z.elements[q+0],X),G=this._buildSurfaceVert(z,z.elements[q+1],X),oe=this._buildSurfaceVert(z,z.elements[q+2],X);b.push(U.top,G.top,oe.top),l===!1&&b.push(oe.bottom,G.bottom,U.bottom)}}this.vertexCache={}}this._buffer.shrink();let A=new mc(Uint32Array.from(b),1),v=new mc(this._buffer.positions,3),M=new mc(this._buffer.normals,3),O=new mc(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 R=O-v,L=T-M;v=v+R*(1-i),M=M+L*(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,E={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),E.topP=C+0,E.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]=E,E}clone(){let e=new tn(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=yo(this.userData),e}};var $i=class extends xP{constructor(e,r=12,o={}){super();this.type="ShapeGeometry";this.windingRule=Pe.ODD;this.elementType=Xe.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:Pe.ODD,elementType:Xe.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=Cr({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=ys}let p=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new yc(new Float32Array(p*3),3),this._normalAttribute=new yc(new Float32Array(p*3),3),this._uvAttribute=new yc(new Float32Array(p*2),2),this._indexAttribute=new yc(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 $i(this._shape,this._curveSegments);return e.userData=yo(this.userData),e}};var Yi=class extends tn{constructor(e,r,o=0,i=12,a=3,s=Pe.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 Yi(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=yo(this.userData),e}};var Xt=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:Pe.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 Ne?(a.width!==r||a.height!==o)&&a.applySize(r,o):a=new Ne(r,o).fromJSON(a),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&a.update());let l=a??new Ne(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 $i(n.shape,o,{windingRule:a}):s=new Yi(n.shape,t,e,o,r,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};import{BufferGeometry as vP,Float32BufferAttribute as bP,MathUtils as Id,Vector2 as _g}from"three";var Ag=Math.PI*2,Ki=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=Id.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof Ne?n.shape:new Ne,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=SP(d,c,u,o*Math.PI/180,r,i);d.isClosed=!0,d.update();let f;return o===0?(f=new vP,f.setAttribute("position",new bP([],3))):f=Xt.create({shape:d,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function SP(n,t,e,r,o,i){if(r>=Ag)return o>30||o%4===0?(_P(n,t,e,i),Math.round(o/4)):wg(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=fg({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?wP(n,a.x,a.y,d,o,t,e,i):wg(n,r,o,t,e,i)}function wP(n,t,e,r,o,i,a,s){let l=Math.round(o/r.length);n.addPoint(Xi(t,e));for(let d=0,c=r.length;d<c;d++){let u=r[d],p=n.points[d],f=Xi(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?Tg(n,i,a,s):n.addPoint(Xi(0,0)),l}function wg(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(Xi(d,c))}return t<Ag?i>0?Tg(n,r,o,i):n.addPoint(Xi(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&Cg(n,r,o,i)),1}function _P(n,t,e,r=0,o=0,i=0){let a=.5522847498,s=t*a,l=e*a;n.addPoint(gc(o-t,i,o-t,i-l,o-t,i+l)),n.addPoint(gc(o,i+e,o-s,i+e,o+s,i+e)),n.addPoint(gc(o+t,i,o+t,i+l,o+t,i-l)),n.addPoint(gc(o,i-e,o+s,i-e,o-s,i-e)),r>0&&Cg(n,t,e,r)}function Xi(n,t){return new Tr(Id.generateUUID(),new _g(n,t))}function gc(n,t,e,r,o,i){let a=Xi(n,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(o,i),a}function Tg(n,t,e,r){Pg(n,t,e,r).forEach(i=>n.addPoint(i))}function Cg(n,t,e,r){let o=Pg(n,t,e,r),i=new Ne;o.forEach(a=>i.addPoint(a)),i.isClosed=!0,n.shapeHoles.push(i)}function Pg(n,t,e,r){let o=r*t/100,i=o*(Math.abs(e)/Math.abs(t)),a=new _g(o/t,i/e),s=n.points.map(l=>{let d=l.clone();return d.uuid=Id.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}import{BufferGeometry as AP,Float32BufferAttribute as Nd,Uint32BufferAttribute as TP,Vector3 as Og}from"three";var Mg=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 gs(!1,t,e,r,o,i,a,s,l,d,c,u);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},Ed=new TP([0,0,0],1),gs=class extends AP{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 Og,m=new Og,y=h(),g=h(),x=h(),S,w,b,_,A,v,M,O,T=h(),C=h(),P=h(),I=h(),E=h(),R=h(),L=h(),F=h(),V=r-2*l+.001,B=V/a,j=Math.ceil(s*a),H=j+1,X=V/j,$=-V/2,W=c+1,Y=2*Math.PI/c,z=Math.PI/2/p,q=.01,U=Math.min((1-u/100)*l,l-q),G=l-U,oe=0,ee=2,Q=p*ee+ee,te=W*Q/ee,Z=te+W*H,se=Math.max(0,W*(H+Q)),[ne,ie,ue]=[3,3,2].map(rt=>Array(se*rt).fill(0)),le=[],de=i-l;function ge(rt,tr){let Br=Math.PI/2;v=tr*X,O=2*Math.PI*(v%B)/B+Br,v+=$,M=Math.sin(O)*de,A=Math.cos(O)*de,t?rt.set(A,M,v):rt.set(A,v,M)}ge(m,-1e-10),ge(y,0),T.copy(m),ge(m,1);let Oe=m.distanceTo(y),He=f?0:G+U,Me=Oe*j+2*He,Ge=U,Ut=Me-He;for(let rt=0;rt<=j;rt++){ge(g,rt),F.subVectors(g,T).normalize(),T.copy(g),R.copy(g).setComponent(+t+1,0).normalize(),L.crossVectors(F,R).normalize();let tr=rt===0,Br=rt===j,Gv=tr?3*Math.PI/2:z,zv=tr?Ge:Ut,kv=tr?W:Z,Fv=tr?0:se-W,jv=F.clone().multiplyScalar(tr?-G:G).add(g),Uv=F.clone().multiplyScalar(tr?-1:1).normalize();for(let uo=0;uo<W;uo++){let Zp=uo*Y;if(C.addVectors(m.copy(R).multiplyScalar(l*Math.cos(Zp)),y.copy(L).multiplyScalar(l*Math.sin(Zp))),P.copy(C).normalize(),tr||Br){f||(oe=Fv+uo,[0,1,2].forEach(Ht=>{ne[oe*3+Ht]=jv.getComponent(Ht),ie[oe*3+Ht]=Uv.getComponent(Ht)}),ue[oe*2]=+Br,ue[oe*2+1]=uo/c),y.copy(P).multiplyScalar(U),x.addVectors(g,y);for(let Ht=0;Ht<p;Ht++){let mu=Ht*z+Gv;I.addVectors(m.copy(F).multiplyScalar(G*Math.sin(mu)),y.copy(P).multiplyScalar(G*Math.cos(mu))),E.copy(I).normalize(),y.addVectors(x,I),I.normalize(),oe=kv+Ht*W+uo,[0,1,2].forEach(qs=>{ne[oe*3+qs]=y.getComponent(qs),ie[oe*3+qs]=E.getComponent(qs)});let Hv=+tr+Math.sin(mu);ue[oe*2]=(zv+G*Hv)/Me,ue[oe*2+1]=uo/c}}y.addVectors(g,C),oe=te+rt*W+uo,[0,1,2].forEach(Ht=>{ne[oe*3+Ht]=y.getComponent(Ht),ie[oe*3+Ht]=P.getComponent(Ht)}),ue[oe*2]=(He+rt*Oe)/Me,ue[oe*2+1]=uo/c}}let Se=H+2*p+ee,ut=1,[mt,Qn]=[+f,Se-1];for(let rt=mt;rt<=Qn-1;rt++){let tr=f&&rt===Qn-1;for(let Br=0;Br<W-1;Br++)S=rt*W+Br,w=S+1,b=(tr?Br:S)+W,_=(tr?Br+1:w)+W,rt===0?le.push(w,_,b):rt===Se-2?le.push(S,w,b):le.push(S,w,b,w,_,b)}this.setIndex(le),this.setAttribute("position",new Nd(ne,3)),this.setAttribute("normal",new Nd(ie,3)),this.setAttribute("uv",new Nd(ue,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,Ed.array=o,Ed.count=o.length,Ed}};import{IcosahedronGeometry as CP}from"three";var Ig=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 xs(t*.5,i,a):new CP(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},xs=class extends Zo{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 xs(t.radius,t.corner,t.cornerSides)}};import{LatheGeometry as PP,Shape as OP}from"three";var Ng=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 OP;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 PP(o.extractPoints(r).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};import{BufferGeometry as zg,BufferGeometryLoader as kP,Vector3 as FP,BoxGeometry as kg}from"three";import{BufferGeometry as RP,Vector2 as Rd,Vector3 as Gg}from"three";import{Box3 as MP,BufferAttribute as vs,BufferGeometry as Eg,Color as Bd,EventDispatcher as IP,Float32BufferAttribute as Qi,Matrix3 as Lg,Matrix4 as Vg,MathUtils as NP,Object3D as EP,Sphere as LP,Vector2 as ar,Vector3 as Mt,Vector4 as DP}from"three";var Yr=new Vg,Ld=new EP,xc=new Mt,rn=class extends IP{constructor(){super(),this.uuid=NP.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 Lg().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 Yr.makeRotationX(t),this.applyMatrix4(Yr),this}rotateY(t){return Yr.makeRotationY(t),this.applyMatrix4(Yr),this}rotateZ(t){return Yr.makeRotationZ(t),this.applyMatrix4(Yr),this}translate(t,e,r){return Yr.makeTranslation(t,e,r),this.applyMatrix4(Yr),this}scale(t,e,r){return Yr.makeScale(t,e,r),this.applyMatrix4(Yr),this}lookAt(t){return Ld.lookAt(t),Ld.updateMatrix(),this.applyMatrix4(Ld.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 Mt().fromBufferAttribute(i,p)),s!==void 0&&e.colors.push(new Bd().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 Mt().fromBufferAttribute(a,p),new Mt().fromBufferAttribute(a,f),new Mt().fromBufferAttribute(a,h)],x=new Zi(p,f,h,g,y,m);e.faces.push(x),l!==void 0&&e.faceVertexUvs[0].push([new ar().fromBufferAttribute(l,p),new ar().fromBufferAttribute(l,f),new ar().fromBufferAttribute(l,h)]),d!==void 0&&e.faceVertexUvs[1].push([new ar().fromBufferAttribute(d,p),new ar().fromBufferAttribute(d,f),new ar().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(xc).negate(),this.translate(xc.x,xc.y,xc.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,o=new Vg;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 Mt,e=new Mt;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 Mt;if(t){let r=new Mt,o=new Mt;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 rn;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 Mt,c={a:new Mt,b:new Mt,c:new Mt};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 MP),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new LP),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 Lg().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 Zi(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 Mt(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 rn().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 Dd().fromGeometry(this),e=new Eg,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",vc.call(new vs(r,3),t.vertices)),t.normals.length>0){let o=new Float32Array(t.normals.length*3);e.setAttribute("normal",vc.call(new vs(o,3),t.normals))}if(t.colors.length>0){let o=new Float32Array(t.colors.length*3);e.setAttribute("color",Dg.call(new vs(o,3),t.colors))}if(t.uvs.length>0){let o=new Float32Array(t.uvs.length*2);e.setAttribute("uv",Bg.call(new vs(o,2),t.uvs))}if(t.uvs2.length>0){let o=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",Bg.call(new vs(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 Qi(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 Qi(t.skinIndices.length*4,4);e.setAttribute("skinIndex",Rg.call(o,t.skinIndices))}if(t.skinWeights.length>0){let o=new Qi(t.skinWeights.length*4,4);e.setAttribute("skinWeight",Rg.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 Eg,r=t.geometry;if(t.isPoints||t.isLine){let o=new Qi(r.vertices.length*3,3),i=new Qi(r.colors.length*3,3);if(e.setAttribute("position",vc.call(o,r.vertices)),e.setAttribute("color",Dg.call(i,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let a=new Qi(r.lineDistances.length,1);e.setAttribute("lineDistance",BP.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}};rn.prototype.isGeometry=!0;var Dd=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 ar,new ar,new ar))}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 ar,new ar,new ar))}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}},Zi=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 Mt,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new Bd,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 BP(n){return this.array.set(n),this}function Dg(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 Bd),t[e++]=i.r,t[e++]=i.g,t[e++]=i.b}return this}function Bg(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 ar),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 Mt),t[e++]=i.x,t[e++]=i.y,t[e++]=i.z}return this}function Rg(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 DP),t[e++]=i.x,t[e++]=i.y,t[e++]=i.z,t[e++]=i.w}return this}var VP=["a","b","c"];function GP(n,t){switch(t){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function Vd(n,t,e){let r=Math.min(n,t),o=Math.max(n,t),i=r+"_"+o;return e.get(i)}function Gd(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 zP(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],Gd(a.a,a.b,n,r,a,e),Gd(a.b,a.c,n,r,a,e),Gd(a.c,a.a,n,r,a,e)}function bc(n,t,e,r,o){n.push(new Zi(t,e,r,void 0,void 0,o))}function Ji(n,t){return Math.abs(t-n)/2+Math.min(n,t)}function Sc(n,t,e,r){n.push([t.clone(),e.clone(),r.clone()])}var wc=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof RP?t=new rn().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 Gg,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;zP(l,d,p,f);let h=[],m,y,g,x,S,w,b;for(let q of Array.from(f.keys())){for(y=f.get(q),g=new Gg,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[GP(x,VP[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),E=P.length,R,L,F,V=[],B=[],j,H,X,$,W=new Rd,Y=new Rd,z=new Rd;for(o=0,i=d.length;o<i;o++)x=d[o],R=Number(Vd(x.a,x.b,f).newEdge)+E,L=Number(Vd(x.b,x.c,f).newEdge)+E,F=Number(Vd(x.c,x.a,f).newEdge)+E,bc(V,R,L,F,x.materialIndex),bc(V,x.a,R,F,x.materialIndex),bc(V,x.b,L,R,x.materialIndex),bc(V,x.c,F,L,x.materialIndex),u&&(j=c[o],H=j[0],X=j[1],$=j[2],W.set(Ji(H.x,X.x),Ji(H.y,X.y)),Y.set(Ji(X.x,$.x),Ji(X.y,$.y)),z.set(Ji(H.x,$.x),Ji(H.y,$.y)),Sc(B,W,Y,z),Sc(B,H,W,z),Sc(B,X,Y,W),Sc(B,$,z,Y));t.vertices=I,t.faces=V,u&&(t.faceVertexUvs[0]=B)}};var pt=new FP,Fg=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.geometry??t?.geometry??new zg().copy(new kg(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(pt),r={width:pt.x,height:pt.y,depth:pt.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 zg().copy(new kg(100,100,100)),a=i.userData.parameters;a===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(pt)):pt.set(a.width,a.height,a.depth),(t!==pt.x||e!==pt.y||r!==pt.z)&&i.scale(pt.x===0?1:t/pt.x,pt.y===0?1:e/pt.y,pt.z===0?1:r/pt.z);let s=i.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=i),i=new wc(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 kP(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(pt);let a=100/pt.x;Object.assign(i.parameters,{width:100,height:pt.y*a,depth:pt.z*a}),t(this.build(i))})}};var _c=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 Ne?n.shape:new Ne,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=Xt.create({shape:l,parameters:{roundness:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(h,{userData:{...n,type:"PolygonGeometry"}})}};import{BufferGeometry as jP,Float32BufferAttribute as zd,Vector2 as Xr,Vector3 as bt}from"three";var jg=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 Fd(t*.5,e,o,i,a,s,l);return d.scale(1,1,r/t),Object.assign(d,{userData:{...n,type:"PyramidGeometry"}})}};function bs(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function kd(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 UP(n,t,e){let r=n.clone().sub(t),o=e.clone().sub(t);return r.projectOnVector(o),r.add(t)}var Fd=class extends jP{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 bt(0,-f,0),w=new bt(0,f,0),b=new Xr(t,-f),_=new Xr(m,-f),A=new Xr(0,w.y).sub(_),v=new Xr(0,w.y).sub(b),M=new Xr(A.y,-A.x).normalize(),O=new Xr(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 B=new bt(M.x,M.y,0),j=new bt(Math.cos(y)*B.x,B.y,Math.sin(y)*B.x);P=B.angleTo(j)}let I=a/Math.tan((Math.PI-A.angle())/2),E=a/Math.tan((Math.PI-P)/2),R=new bt;if(!i){d.push(S.x,S.y,S.z),c.push(0,-1,0),u.push(0,0);let B=p++,j=[],H=b.clone(),X=I/Math.cos(Math.PI/r);H.x-=X;for(let $=0;$<r;$++){let W=$/r*Math.PI*2+h,Y=new Xr(Math.sin(W),Math.cos(W));bs(H,Y,R),d.push(R.x,R.y,R.z),c.push(0,-1,0),u.push(0,0),j.push(p++)}for(let $=0;$<j.length;$++)l.push(j[$],B,j[($+1)%j.length])}let L=[];{let B=new bt,j=new bt,H=new bt,X=new bt,$=new bt,W=new bt;for(let Y=0;Y<r;Y++){let z=Y/r*Math.PI*2+h,q=(Y+.5)/r*Math.PI*2+h,U=(Y+1)/r*Math.PI*2+h,G=new Xr(Math.sin(z),Math.cos(z)),oe=new Xr(Math.sin(q),Math.cos(q)),ee=new Xr(Math.sin(U),Math.cos(U));bs(b,G,j),bs(b,ee,H),bs(M,oe,B),kd(w,j,H,E,E,X),d.push(X.x,X.y,X.z),kd(j,w,H,E,I,$),d.push($.x,$.y,$.z),kd(H,j,w,I,E,W),d.push(W.x,W.y,W.z),c.push(B.x,B.y,B.z),c.push(B.x,B.y,B.z),c.push(B.x,B.y,B.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 ie=j.clone().add(H).multiplyScalar(.5),ue=w.clone().sub(ie).normalize(),de=S.clone().sub(ie).normalize().add(ue).normalize().multiplyScalar(-1),ge=W.clone().sub($);F(ie,ge,de,A.angle())}let se,ne;{let ie=new bt;bs(O,ee,ie);let ue=W.clone().add(X).multiplyScalar(.5);ue=UP(ue,H,w);let le=W.clone().sub(X);[se,ne]=F(ue,le,ie,P,X.y)}{let ie=se,ue=ie.clone().setY(0).normalize(),le=new bt(0,-1,0),de=ue.clone().cross(le);V(ie,ue,le,de)}L.concat(ne);{let ie=A.angle(),ue=Math.PI-ie,le=w.clone();le.y-=a/Math.sin(ie-Math.PI/2);let de=new bt,ge=[];for(let He=0;He<s;He++){let Me=[],Ge=Math.PI/2-ue*He/s,Ut=Math.cos(Ge),Se=Math.sin(Ge),ut=q;for(let mt=0;mt<=He;mt++){let Qn=Math.cos(ut),rt=Math.sin(ut);B.x=Ut*rt,B.y=Se,B.z=Ut*Qn,de.copy(le).addScaledVector(B,a),d.push(de.x,de.y,de.z),c.push(B.x,B.y,B.z),u.push(0,0),Me.push(p++),ut+=Math.PI*2/He/r}ge.push(Me)}ne.reverse(),ge.push(ne);let Oe=ge.length-1;for(let He=0;He<Oe;He++){let Me=ge[He],Ge=ge[He+1],Ut=Me.length-1;l.push(Ge[1],Me[0],Ge[0]);for(let Se=1;Se<=Ut;Se++)l.push(Me[Se],Me[Se-1],Ge[Se]),l.push(Ge[Se+1],Me[Se],Ge[Se])}}}}}this.setIndex(l),this.setAttribute("position",new zd(d,3)),this.setAttribute("normal",new zd(c,3)),this.setAttribute("uv",new zd(u,2));function F(B,j,H,X,$){let W=-X/2,Y=(Math.PI-X)/2,z=j.clone().normalize().cross(H);B.addScaledVector(H,-a/Math.sin(Y));let q=new bt,U=new bt,G=1,oe=p,ee=[];for(let Q=0;Q<=s;Q++){let te=W+Q/s*X;U.set(0,0,0),U.addScaledVector(z,Math.sin(te)),U.addScaledVector(H,Math.cos(te));for(let Z=0;Z<=G;Z++){let se=Z/G-.5;if(q.copy(B),q.addScaledVector(j,se),q.addScaledVector(U,a),$!=null){let ne=Math.max(0,q.y-$);q.addScaledVector(j,-ne/j.y)}d.push(q.x,q.y,q.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<G;te++){let Z=oe+te+(G+1)*Q,se=Z+(G+1),ne=se+1,ie=Z+1;l.push(Z,se,ie),l.push(se,ne,ie)}return[B.clone().addScaledVector(j,.5),ee]}function V(B,j,H,X){let $=Math.PI/2,W=v.angle()-$,Y=[],z=new bt,q=new bt;for(let G=0;G<=s;G++){let oe=[],ee=G/s;for(let Q=0;Q<=G;Q++){let Z=((G?Q/G:0)-.5)*x,se=Math.cos(Z),ne=Math.sin(Z),ie=Math.atan(Math.tan(W)*se),ue=($+ie)*ee,le=Math.cos(ue),de=Math.sin(ue);z.set(0,0,0),z.addScaledVector(j,de*se),z.addScaledVector(H,le),z.addScaledVector(X,de*ne),q.copy(B).addScaledVector(z,a),d.push(q.x,q.y,q.z),c.push(z.x,z.y,z.z),u.push(0,0),oe.push(p++)}Y.push(oe)}let U=Y.length-1;for(let G=0;G<U;G++){let oe=Y[G],ee=Y[G+1],Q=oe.length-1;l.push(oe[0],ee[1],ee[0]);for(let te=1;te<=Q;te++)l.push(oe[te-1],oe[te],ee[te]),l.push(oe[te],ee[te+1],ee[te])}}}};var Ac=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 Ne?n.shape:new Ne,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=Xt.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(S,{userData:{...n,type:"RectangleGeometry"}})}};import{BufferGeometry as HP,Float32BufferAttribute as qP,MathUtils as Ug,SphereGeometry as WP}from"three";var Hg=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=Ug.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 HP,c.setAttribute("position",new qP([],3))):c=new WP(.5*t,o,i,a,s,l,d*Ug.DEG2RAD),c.scale(1,e/t,r/t),Object.assign(c,{userData:{...n,type:"SphereGeometry"}})}};import{PlaneGeometry as $P}from"three";var qg=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 $P(t,e,r,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};import{BufferGeometry as YP,Float32BufferAttribute as jd,Vector3 as XP}from"three";var Wg=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 Ud(t,e,r,o,i,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},Ud=class extends YP{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=(q=0,U=0,G=0)=>new XP(q,U,G),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=(q,U=!1)=>Math.sin(q-Math.PI/(1+ +U)),M=(q,U=!1)=>Math.cos(q-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),E=h.clone().normalize().add(m.normalize()).setLength(I).add(_);h.set(0,v(o,!0),M(o,!0)),u.push([A,h.clone()]);let R=(Math.PI-o)/a;for(let q=0;q<=a;q++){let U=p+o+q*R;h.set(0,Math.sin(U)*P,Math.cos(U)*P),h.add(E),m.set(0,v(U),M(U)),u.push([h.clone(),m.clone()])}u.push([b,f(0,1,0)]);let L=Math.sin(R/2)*P*2,F=u.length-1,V=u[0][0].distanceTo(u[1][0]),B=u[F-1][0].distanceTo(u[F][0]),j=V+L*a+B;u[0].push(1);for(let q=0;q<=a;q++)u[q+1].push(1-(V+q*L)/j);u[F].push(0);let[H,X,$]=u[0],W,Y,z;for(let q=1;q<u.length;q++)[W,Y,z]=u[q],s.push(S,H.y,H.z,S,W.y,W.z,w,H.y,H.z,w,H.y,H.z,S,W.y,W.z,w,W.y,W.z),l.push(0,X.y,X.z,0,Y.y,Y.z,0,X.y,X.z,0,X.y,X.z,0,Y.y,Y.z,0,Y.y,Y.z),d.push(0,$,0,z,1,$,1,$,0,z,1,z),[H,X,$]=[W,Y,z];this.setAttribute("position",new jd(s,3)),this.setAttribute("normal",new jd(l,3)),this.setAttribute("uv",new jd(d,2))}};var Tc=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 Ne?n.shape:new Ne,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=Xt.create({shape:c,parameters:{roundness:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:d}});return Object.assign(S,{userData:{...n,type:"StarGeometry"}})}};import{PlaneGeometry as KP}from"three";var $g=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 KP(t,e);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};import{BufferGeometry as QP,Float32BufferAttribute as ZP,MathUtils as JP}from"three";var Yg=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=e2(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 e2(n,t,e,r,o,i,a,s,l,d,c){[t,e]=[e,t],a=t/2;let u=JP.clamp(o/360,0,1);if(u===0){let p=new QP;return p.setAttribute("position",new ZP([],3)),p}return u===1&&(d=0),new gs(!0,n,t,e,r,u,i,a,s,l,d,c)}import{TorusKnotGeometry as t2}from"three";var Xg=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 t2(s,e,r,o,i,a);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var Kg=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 Ne?n.shape:new Ne,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=Xt.create({shape:l,parameters:{roundness:r,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a}});return Object.assign(u,{userData:{...n,type:"TriangleGeometry"}})}};import{Vector2 as Zg,Vector3 as St,Matrix3 as r2,Matrix4 as Mn,BufferGeometry as Jg,BufferAttribute as ea,MathUtils as Cc}from"three";function Qg(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var o2=new Mn,n2=new Mn;function i2(n,t,e){let r=[new St,new St,new St],o=[new St,new St,new St];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=Cc.lerp(i.length(),s.length(),e);i.lerp(s,e).setLength(l)}),new Mn().makeBasis(r[0],r[1],r[2])}var e0=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??Ki.create({parameters:ju}).userData.shape;return{path:n.path??Mi.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:i,extrusion:{...jl,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new Hd(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new Jg,{userData:{...n,type:"PathGeometry"}})}},Hd=class extends Jg{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)||!Qg(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 V=0;V<d;V++){let B=this.inputs.path.isClosed?(V+s)%e.length:Math.min(V+s,e.length-1);c.push(e[B].clone()),u.push(r[B].clone())}let p=(V,B,j)=>{c[V]=c[V].clone().lerp(c[B],j),u[V]=i2(u[V],u[B],j)},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 V=c.length-1;c[V].copy(c[0]),u[V].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 tn(this.inputs.shapeData,2*g,g,w,x,void 0,!0),v=M.getAttribute("position").count);let O=0,T=0;_.sort((V,B)=>V.start-B.start),_.forEach(V=>{V.verticesStart=O,V.verticesCount=V.continuous.reduce((B,j,H)=>B+(H===0||!j?2:1),0),T+=V.verticesCount,O=T});let C=T*d,P,I=0;if(this._isOpenEnded()&&S==="flat"){try{P=Cr({windingRule:Pe.ODD,elementType:Xe.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:b})}catch{P=Md}I=P.vertexCount}let E=C+2*I+v*2,R=C+2*I,L={positions:new Float32Array(E*3),normals:new Float32Array(E*3),uvs:new Float32Array(E*2)},F=[];if(_.forEach(V=>{this._extrudeRegion(V,A,u,c,L,F,this._isGeometryClosed()&&!this._isOpenEnded())}),P&&(this._closeEnd(P,C,F,L,u[0],c[0],!1),this._closeEnd(P,C+I,F,L,u[u.length-1],c[c.length-1],!0)),M){L.positions.set(M.getAttribute("position").array,R*3),L.normals.set(M.getAttribute("normal").array,R*3),L.uvs.set(M.getAttribute("uv").array,R*2);let V=F.length;F.push(...M.getIndex().array.map(H=>H+R)),R+=v,L.positions.set(M.getAttribute("position").array,R*3),L.normals.set(M.getAttribute("normal").array,R*3),L.uvs.set(M.getAttribute("uv").array,R*2);let B=F.length;F.push(...M.getIndex().array.map(H=>H+R)),this.setAttribute("position",new ea(L.positions,3)),this.setAttribute("normal",new ea(L.normals,3)),this.setAttribute("uv",new ea(L.uvs,2)),this.setIndex(F);let j=o2;j.copy(u[u.length-1]).setPosition(c[c.length-1]),this.applyMatrix4OnRange(j,R,E),j.copy(u[0]).setPosition(c[0]).multiply(n2.makeScale(1,1,-1)),this.applyMatrix4OnRange(j,R-v,R),this.reverseIndicesOnRange(V,B)}else this.setAttribute("position",new ea(L.positions,3)),this.setAttribute("normal",new ea(L.normals,3)),this.setAttribute("uv",new ea(L.uvs,2)),this.setIndex(F)}_extractPathPoints(){let r=nc(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 St,s=new St,l=new St,d=new St,c=new St(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 Mn().makeBasis(A,v,_);r.push(M)}let u=i?s:l,p=i?a:new St(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 Mn().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 Mn,u=new Mn;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(Cc.lerp(a,a+s,h)*Cc.DEG2RAD);let m=Cc.lerp(l,d,h);u.makeScale(m,m,m),p.multiply(c).multiply(u)}),e}_computeShapePoints(e=12,r=Pe.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=Cr({windingRule:r,elementType:Xe.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{s=ys}let l;try{l=Cr({windingRule:Pe.ODD,elementType:Xe.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Od}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],E=s.vertices[v*2+0],R=s.vertices[v*2+1],L=P-T,F=I-C,V=Math.sqrt(L*L+F*F);L/=V,F/=V;let B=P-E,j=I-R,H=Math.sqrt(B*B+j*j);B/=H,j/=H,b.normals[O*2+0]=-j,b.normals[O*2+1]=B;let X=s.vertexIndices[_];if(Array.isArray(X))b.continuous[O]=!1;else{let[$,W]=o.getCurveIndexFromVertexId(X-1,!0);if(W>0&&W<1)b.continuous[O]=!0;else{let Y=W===1?$+1:$-1;Y=(Y+M)%M;let z=W===1?0:1,q=o.roundedCurves[$].getTangent(W),U=o.roundedCurves[Y].getTangent(z);b.continuous[O]=q.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 St,c=new St,u=new St,p=new St,f=new Zg;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 St(0,0,l?-1:1).applyMatrix4(a),u=new St,p=new Zg;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 r2().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}}};import{BufferAttribute as t0,BufferGeometry as qd}from"three";import{mergeBufferGeometries as a2}from"three/examples/jsm/utils/BufferGeometryUtils.js";function r0(){let n=new qd;return n.setAttribute("position",new t0(new Float32Array([]),3)),n.setIndex(new t0(new Uint16Array([]),1)),n}var s2=r0().attributes,l2=12,c2=1,ta=class extends qd{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,s2),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=Kl.getDisplayedValue(d),p=c===2?u.toUpperCase():c===3?u.toLowerCase():u,f=u2(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 Ne().fromShape(_,!0));this.vectorShapes=S;let w=S.map(_=>Xt.create({shape:_,parameters:{depth:a,extrudeBevelSegments:l,extrudeBevelSize:s,windingRule:a<=0?Pe.NONZERO:Pe.ODD,subdivisions:this.isLowResolution&&a>0?c2:l2}})),b=w.length?a2(w):r0();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=Wt(new qd,ta.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 u2(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}import{BufferGeometry as $d,BufferAttribute as a0,Uint32BufferAttribute as Yd,Float32BufferAttribute as Xd,Matrix4 as h2,Vector3 as ws,Sphere as m2,Box3 as y2,BoxGeometry as g2}from"three";var n0,ra=new Promise(n=>{n0=n}),o0=!1;var Pc;function i0(){if(o0)return;if(Pc)return Pc;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.502/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});n0(l),o0=!0}return Pc=n(),Pc}import{BufferGeometryLoader as d2}from"three";function Nn(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];sy(u)&&(c[o]=t.getVariable(u,[r.uuid,"geometry",...d,o]))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let d=Ne.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 d2().parse(i);else if(i.type==="SubdivGeometry"){let d=new at(i,e);return d.data=n,d}else if(i.type==="TextGeometry")return new ta(i,t);let l;try{l=Wd(s)}catch(d){console.error(d)}if(!l){let d=Ne.createFromState(Oi.defaultData(),100,100);s.shape=d,l=Wd(s)}return l}import{Matrix4 as p2}from"three";var f2=new p2;function Ss(n,t,e,r){let o=n.position.array,i=n.normal.array,a=f2.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 Oc=new y2,oa=new ws,fe;ra.then(n=>{fe=n});var s0=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),l0=new Uint32Array([0,1,2,3]),c0=new Uint8Array([4]),at=class extends $d{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=Fo.div(r,o);this.subdividedGeometry&&Ss(this.subdividedGeometry.attributes,...i),this.originalGeometry&&Ss(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(oa.fromArray(i));let s=oa.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}=at.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new g2(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&&(at.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new m2,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Oc.setFromBufferAttribute(r),Oc.getCenter(o),e.boundingSphere.radius=o.distanceTo(Oc.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Oc.getSize(oa);let i={width:oa.x,height:oa.y,depth:oa.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&&(fe.free_bvh(r),fe.free_subdivision_surface(r));try{a=at.allocate(e,i)}catch(c){console.error(c,e),a=at.allocate({positionWASM:s0,indexWASM:l0,verticesPerFaceWASM:c0},i)}if(fe.set_destination_refinement_level(a,0),s=at.buildLevel(a,!0,d),e.subdivisions>0)try{fe.set_destination_refinement_level(a,e.subdivisions),l=at.buildLevel(a,!1,d)}catch{try{fe.set_destination_refinement_level(a,e.subdivisions-1),l=at.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:Nn(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}=Jd(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}=ep(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=s0,i=l0,a=c0);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=fe._malloc(h),x=new Float32Array(fe.HEAPF32.buffer,g,p),S=new Uint32Array(fe.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 h2().makeScale(...e.scaleBaked)),r&&(w?w.premultiply(r):w=r);let b=w?fe.alloc_subdivision_surface2(g,d,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,u,w.elements):fe.alloc_subdivision_surface(g,d,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,u);return fe._free(g),b}static buildLevel(e,r,o,i,a){let s=a?fe.get_mesh_data2(e,r?fe.Level.CONTROL:fe.Level.REFINED,o,a.elements):fe.get_mesh_data(e,r?fe.Level.CONTROL:fe.Level.REFINED,o),l=8,d=fe.HEAPU32.subarray(s>>2,(s>>2)+l),c=d.subarray(4,4+4),u=0,p=fe.HEAPU32[d[u]>>2],f=fe.HEAPF32.subarray(p>>2,(p>>2)+c[u]);u++;let h=fe.HEAPU32[d[u]>>2],m=fe.HEAPF32.subarray(h>>2,(h>>2)+c[u]);u++;let y=fe.HEAPU32[d[u]>>2],g=fe.HEAPU32.subarray(y>>2,(y>>2)+c[u]);u++;let x=fe.HEAPU32[d[u]>>2],S=fe.HEAPU32.subarray(x>>2,(x>>2)+c[u]);if(u++,i===void 0){let w=new $d;if(w.setIndex(new Yd(S,1)),w.setAttribute("position",new Xd(f,3)),w.setAttribute("normal",new Xd(m,3)),r){w.setAttribute("faceMap",new Yd(g,1));let b=new Float32Array(m.length/3*4).fill(0);w.setAttribute("color",new a0(b,4))}return fe.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,fe.free_mesh_data(s)}static freeSubdivPointer(e){fe.free_bvh(e),fe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let i=fe.get_wireframe_data_for_base_level(e),a=4,s=fe.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),d=0,c=fe.HEAPU32[s[d]>>2],u=fe.HEAPF32.subarray(c>>2,(c>>2)+l[d]);d++;let p=fe.HEAPU32[s[d]>>2],f=fe.HEAPU32.subarray(p>>2,(p>>2)+l[d]);if(r===void 0){let h=new $d;h.setAttribute("position",new Xd(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 a0(m,3)),h.setIndex(new Yd(f,1)),fe.free_wireframe_data_for_base_level(i),h}r.getAttribute("position").copyArray(u),r.attributes.position.needsUpdate=!0,fe.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,r,o){let i=r===0;i||fe.set_destination_refinement_level(e,r);let a=o?fe.get_topological_data2(e,i?fe.Level.CONTROL:fe.Level.REFINED,o.elements):fe.get_topological_data(e,i?fe.Level.CONTROL:fe.Level.REFINED),s=6,l=fe.HEAPU32.subarray(a>>2,(a>>2)+s),d=l.subarray(3,3+3),c=0,u=fe.HEAPU32[l[c]>>2],p=new Float32Array(fe.HEAPF32.subarray(u>>2,(u>>2)+d[c]));c++;let f=fe.HEAPU32[l[c]>>2],h=new Uint32Array(fe.HEAPU32.subarray(f>>2,(f>>2)+d[c]));c++;let m=fe.HEAPU32[l[c]>>2],y=new Uint8Array(fe.HEAPU32.subarray(m>>2,(m>>2)+d[c]));return fe.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var u0=["getX","getY","getZ"];function Jd(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[u0[p]](c)*s)},`;if(u in e)i.push(e[u]);else{for(let p=0;p<3;p++)a.push(n[u0[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 Mc=new ws,Kd=new ws,Qd=new ws,Zd=new ws;function ep(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]){Mc.set(n[t[s]*3],n[t[s]*3+1],n[t[s]*3+2]),Kd.set(n[t[s+1]*3],n[t[s+1]*3+1],n[t[s+1]*3+2]),Qd.set(n[t[s+4]*3],n[t[s+4]*3+1],n[t[s+4]*3+2]),Zd.set(n[t[s+5]*3],n[t[s+5]*3+1],n[t[s+5]*3+2]),Kd.sub(Mc).normalize(),Qd.sub(Mc).normalize(),Zd.sub(Mc).normalize();let l=Kd.cross(Qd).dot(Zd);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 dr={};Qv(dr,{calcBoolean:()=>w2,calcBooleanTopological:()=>S2,freeMeshSet:()=>C2,getMeshSet:()=>_2,hasOpenEdges:()=>A2,transformMeshSet:()=>T2});var x2,d0=new Promise(n=>{x2=n});import{Float32BufferAttribute as p0,Sphere as v2}from"three";var we,na;d0.then(n=>we=n);function b2(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}=Jd(n.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:d}=ep(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 f0(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=we._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(we.HEAPU32.buffer,i,t):new Float32Array(we.HEAPF32.buffer,i,t)).set(n,0),i}function h0(n){switch(n){case 0:return we.OP.UNION;case 1:return we.OP.INTERSECTION;case 2:return we.OP.A_MINUS_B;case 3:return we.OP.B_MINUS_A;case 4:return we.OP.SYMMETRIC_DIFFERENCE;case 5:return we.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function S2(n,t){na===void 0&&(na=we.init_csg());let e=f0(n),r=we.csg_calc_topological(na,e,n.length,h0(t));we._free(e);let o=6,i=we.HEAPU32.subarray(r>>2,(r>>2)+o),a=i.subarray(3,3+3),s=0,l=we.HEAPU32[i[s]>>2],d=new Float32Array(we.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let c=we.HEAPU32[i[s]>>2],u=new Uint32Array(we.HEAPU32.subarray(c>>2,(c>>2)+a[s]));s++;let p=we.HEAPU32[i[s]>>2],f=new Uint8Array(we.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return we.free_mesh_data(r),{positions:d,indices:u,verticesPerFace:f}}function w2(n,t,e,r){na===void 0&&(na=we.init_csg());let o=f0(n),i=we.csg_calc(na,o,n.length,r,h0(t));we._free(o);let a=5,s=we.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),d=0,c=we.HEAPU32[s[d]>>2],u=we.HEAPF32.subarray(c>>2,(c>>2)+l[d]);d++;let p=we.HEAPU32[s[d]>>2],f=we.HEAPF32.subarray(p>>2,(p>>2)+l[d]);d++;let h=l[d];e.setAttribute("position",new p0(u,3)),e.setAttribute("normal",new p0(f,3));let m=we.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new v2),e.boundingSphere.radius=-1,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},we.free_mesh_data(i),h}function _2(n,t,e){if(we===void 0)return-1;let r,o,i;if(t&&n.userData.positions!==void 0){let y=n.userData;i=y.verticesPerFace.length,r=y.positions,o=Array(y.verticesPerFace.reduce((g,x)=>g+x,0)+i);for(let g=0,x=0,S=0;g<y.verticesPerFace.length;g++){o[S++]=y.verticesPerFace[g];for(let w=0;w<y.verticesPerFace[g];w++)o[S++]=y.indices[x++]}}else({positions:r,faceIndices:o,nFaces:i}=b2(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=we._malloc(c),h=new Float32Array(we.HEAPF32.buffer,f,l),m=new Uint32Array(we.HEAPU32.buffer,f+u,d);return h.set(r,0),m.set(o,0),we.get_csg_mesh(f,a,f+u,s,i)}function A2(n){return we.has_open_edges(n)}function T2(n,t){we.transform_csg_mesh(n,t.elements)}function C2(n){we.free_csg_mesh(n)}var P2={ConeGeometry:$y,CubeGeometry:Yy,CylinderGeometry:Wy,DodecahedronGeometry:Xy,EllipseGeometry:Ki,HelixGeometry:Mg,IcosahedronGeometry:Ig,LatheGeometry:Ng,NonParametricGeometry:Fg,PolygonGeometry:_c,PyramidGeometry:jg,RectangleGeometry:Ac,SphereGeometry:Hg,PlaneGeometry:qg,BackdropGeometry:Wg,StarGeometry:Tc,TextFrameGeometry:$g,TorusGeometry:Yg,TorusKnotGeometry:Xg,TriangleGeometry:Kg,PathGeometry:e0,VectorGeometry:Xt},Wd=n=>P2[n.type].create(n);function ia(n){return n!==null&&"booleanOp"in n}var aa=class extends ji(M2){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new O2}updateVisible(e){super.updateVisible(e),this.visible=!ia(this.parent)&&this.visible,ia(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(dr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),ia(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof aa&&(e.freeBooleanPointer(),ia(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&ia(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),ia(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Ic=new I2;function _s(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)}Ic.min.set(i,a,s),Ic.max.set(l,d,c),Ic.getCenter(r),Ic.getSize(o).multiplyScalar(.5)}var L2=new N2,D2=new E2,It=class extends aa{constructor(t,e){super(L2,D2),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?_s(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};import{Box3 as WO,Matrix4 as $O,Sphere as Z0,Vector3 as YO}from"three";import{BufferAttribute as UO,Float32BufferAttribute as Q0,MathUtils as Pp,Vector3 as Op}from"three";import{ShaderMaterial as OO}from"three";import{CubeReflectionMapping as W2,CubeRefractionMapping as $2,CubeUVReflectionMapping as Y2,LinearEncoding as w0,sRGBEncoding as X2}from"three";var As=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}};import{MathUtils as B2}from"three";var wt=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=B2.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 wt&&(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 tp=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}},ft=new tp;import{Vector2 as m0}from"three";import{MathUtils as R2}from"three";var ae=class extends wt{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=R2.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 Re=class extends ae{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 Ke=class extends Re{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof m0?e:new m0(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)}};import{Vector3 as y0}from"three";var Nt=class extends Re{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof y0?e:new y0(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)}};import{Color as V2}from"three";var ht=class extends V2{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 Kt=class extends Re{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof ht?e:new ht(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 G2=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,g0=/[a-z_0-9]+/gi,K=class extends ae{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=g0.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&&ft.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=ft.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||ft.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&&ft.contains(m)&&e.include(ft.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=G2.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(g0);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 z2=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,rp=class extends ae{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||rp.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=z2.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)}},Ie=rp;Ie.PI="PI",Ie.PI2="PI2",Ie.RECIPROCAL_PI="RECIPROCAL_PI",Ie.RECIPROCAL_PI2="RECIPROCAL_PI2",Ie.LOG2="LOG2",Ie.EPSILON="EPSILON";var k2=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}import{BufferGeometry as $d,BufferAttribute as a0,Uint32BufferAttribute as Yd,Float32BufferAttribute as Xd,Matrix4 as h2,Vector3 as ws,Sphere as m2,Box3 as y2,BoxGeometry as g2}from"three";var n0,ra=new Promise(n=>{n0=n}),o0=!1;var Pc;function i0(){if(o0)return;if(Pc)return Pc;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.503/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});n0(l),o0=!0}return Pc=n(),Pc}import{BufferGeometryLoader as d2}from"three";function Nn(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];sy(u)&&(c[o]=t.getVariable(u,[r.uuid,"geometry",...d,o]))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let d=Ne.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 d2().parse(i);else if(i.type==="SubdivGeometry"){let d=new at(i,e);return d.data=n,d}else if(i.type==="TextGeometry")return new ta(i,t);let l;try{l=Wd(s)}catch(d){console.error(d)}if(!l){let d=Ne.createFromState(Oi.defaultData(),100,100);s.shape=d,l=Wd(s)}return l}import{Matrix4 as p2}from"three";var f2=new p2;function Ss(n,t,e,r){let o=n.position.array,i=n.normal.array,a=f2.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 Oc=new y2,oa=new ws,fe;ra.then(n=>{fe=n});var s0=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),l0=new Uint32Array([0,1,2,3]),c0=new Uint8Array([4]),at=class extends $d{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=Fo.div(r,o);this.subdividedGeometry&&Ss(this.subdividedGeometry.attributes,...i),this.originalGeometry&&Ss(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(oa.fromArray(i));let s=oa.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}=at.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new g2(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&&(at.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new m2,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Oc.setFromBufferAttribute(r),Oc.getCenter(o),e.boundingSphere.radius=o.distanceTo(Oc.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Oc.getSize(oa);let i={width:oa.x,height:oa.y,depth:oa.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&&(fe.free_bvh(r),fe.free_subdivision_surface(r));try{a=at.allocate(e,i)}catch(c){console.error(c,e),a=at.allocate({positionWASM:s0,indexWASM:l0,verticesPerFaceWASM:c0},i)}if(fe.set_destination_refinement_level(a,0),s=at.buildLevel(a,!0,d),e.subdivisions>0)try{fe.set_destination_refinement_level(a,e.subdivisions),l=at.buildLevel(a,!1,d)}catch{try{fe.set_destination_refinement_level(a,e.subdivisions-1),l=at.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:Nn(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}=Jd(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}=ep(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=s0,i=l0,a=c0);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=fe._malloc(h),x=new Float32Array(fe.HEAPF32.buffer,g,p),S=new Uint32Array(fe.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 h2().makeScale(...e.scaleBaked)),r&&(w?w.premultiply(r):w=r);let b=w?fe.alloc_subdivision_surface2(g,d,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,u,w.elements):fe.alloc_subdivision_surface(g,d,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,u);return fe._free(g),b}static buildLevel(e,r,o,i,a){let s=a?fe.get_mesh_data2(e,r?fe.Level.CONTROL:fe.Level.REFINED,o,a.elements):fe.get_mesh_data(e,r?fe.Level.CONTROL:fe.Level.REFINED,o),l=8,d=fe.HEAPU32.subarray(s>>2,(s>>2)+l),c=d.subarray(4,4+4),u=0,p=fe.HEAPU32[d[u]>>2],f=fe.HEAPF32.subarray(p>>2,(p>>2)+c[u]);u++;let h=fe.HEAPU32[d[u]>>2],m=fe.HEAPF32.subarray(h>>2,(h>>2)+c[u]);u++;let y=fe.HEAPU32[d[u]>>2],g=fe.HEAPU32.subarray(y>>2,(y>>2)+c[u]);u++;let x=fe.HEAPU32[d[u]>>2],S=fe.HEAPU32.subarray(x>>2,(x>>2)+c[u]);if(u++,i===void 0){let w=new $d;if(w.setIndex(new Yd(S,1)),w.setAttribute("position",new Xd(f,3)),w.setAttribute("normal",new Xd(m,3)),r){w.setAttribute("faceMap",new Yd(g,1));let b=new Float32Array(m.length/3*4).fill(0);w.setAttribute("color",new a0(b,4))}return fe.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,fe.free_mesh_data(s)}static freeSubdivPointer(e){fe.free_bvh(e),fe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let i=fe.get_wireframe_data_for_base_level(e),a=4,s=fe.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),d=0,c=fe.HEAPU32[s[d]>>2],u=fe.HEAPF32.subarray(c>>2,(c>>2)+l[d]);d++;let p=fe.HEAPU32[s[d]>>2],f=fe.HEAPU32.subarray(p>>2,(p>>2)+l[d]);if(r===void 0){let h=new $d;h.setAttribute("position",new Xd(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 a0(m,3)),h.setIndex(new Yd(f,1)),fe.free_wireframe_data_for_base_level(i),h}r.getAttribute("position").copyArray(u),r.attributes.position.needsUpdate=!0,fe.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,r,o){let i=r===0;i||fe.set_destination_refinement_level(e,r);let a=o?fe.get_topological_data2(e,i?fe.Level.CONTROL:fe.Level.REFINED,o.elements):fe.get_topological_data(e,i?fe.Level.CONTROL:fe.Level.REFINED),s=6,l=fe.HEAPU32.subarray(a>>2,(a>>2)+s),d=l.subarray(3,3+3),c=0,u=fe.HEAPU32[l[c]>>2],p=new Float32Array(fe.HEAPF32.subarray(u>>2,(u>>2)+d[c]));c++;let f=fe.HEAPU32[l[c]>>2],h=new Uint32Array(fe.HEAPU32.subarray(f>>2,(f>>2)+d[c]));c++;let m=fe.HEAPU32[l[c]>>2],y=new Uint8Array(fe.HEAPU32.subarray(m>>2,(m>>2)+d[c]));return fe.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var u0=["getX","getY","getZ"];function Jd(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[u0[p]](c)*s)},`;if(u in e)i.push(e[u]);else{for(let p=0;p<3;p++)a.push(n[u0[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 Mc=new ws,Kd=new ws,Qd=new ws,Zd=new ws;function ep(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]){Mc.set(n[t[s]*3],n[t[s]*3+1],n[t[s]*3+2]),Kd.set(n[t[s+1]*3],n[t[s+1]*3+1],n[t[s+1]*3+2]),Qd.set(n[t[s+4]*3],n[t[s+4]*3+1],n[t[s+4]*3+2]),Zd.set(n[t[s+5]*3],n[t[s+5]*3+1],n[t[s+5]*3+2]),Kd.sub(Mc).normalize(),Qd.sub(Mc).normalize(),Zd.sub(Mc).normalize();let l=Kd.cross(Qd).dot(Zd);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 dr={};Qv(dr,{calcBoolean:()=>w2,calcBooleanTopological:()=>S2,freeMeshSet:()=>C2,getMeshSet:()=>_2,hasOpenEdges:()=>A2,transformMeshSet:()=>T2});var x2,d0=new Promise(n=>{x2=n});import{Float32BufferAttribute as p0,Sphere as v2}from"three";var we,na;d0.then(n=>we=n);function b2(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}=Jd(n.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:d}=ep(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 f0(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=we._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(we.HEAPU32.buffer,i,t):new Float32Array(we.HEAPF32.buffer,i,t)).set(n,0),i}function h0(n){switch(n){case 0:return we.OP.UNION;case 1:return we.OP.INTERSECTION;case 2:return we.OP.A_MINUS_B;case 3:return we.OP.B_MINUS_A;case 4:return we.OP.SYMMETRIC_DIFFERENCE;case 5:return we.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function S2(n,t){na===void 0&&(na=we.init_csg());let e=f0(n),r=we.csg_calc_topological(na,e,n.length,h0(t));we._free(e);let o=6,i=we.HEAPU32.subarray(r>>2,(r>>2)+o),a=i.subarray(3,3+3),s=0,l=we.HEAPU32[i[s]>>2],d=new Float32Array(we.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let c=we.HEAPU32[i[s]>>2],u=new Uint32Array(we.HEAPU32.subarray(c>>2,(c>>2)+a[s]));s++;let p=we.HEAPU32[i[s]>>2],f=new Uint8Array(we.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return we.free_mesh_data(r),{positions:d,indices:u,verticesPerFace:f}}function w2(n,t,e,r){na===void 0&&(na=we.init_csg());let o=f0(n),i=we.csg_calc(na,o,n.length,r,h0(t));we._free(o);let a=5,s=we.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),d=0,c=we.HEAPU32[s[d]>>2],u=we.HEAPF32.subarray(c>>2,(c>>2)+l[d]);d++;let p=we.HEAPU32[s[d]>>2],f=we.HEAPF32.subarray(p>>2,(p>>2)+l[d]);d++;let h=l[d];e.setAttribute("position",new p0(u,3)),e.setAttribute("normal",new p0(f,3));let m=we.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new v2),e.boundingSphere.radius=-1,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},we.free_mesh_data(i),h}function _2(n,t,e){if(we===void 0)return-1;let r,o,i;if(t&&n.userData.positions!==void 0){let y=n.userData;i=y.verticesPerFace.length,r=y.positions,o=Array(y.verticesPerFace.reduce((g,x)=>g+x,0)+i);for(let g=0,x=0,S=0;g<y.verticesPerFace.length;g++){o[S++]=y.verticesPerFace[g];for(let w=0;w<y.verticesPerFace[g];w++)o[S++]=y.indices[x++]}}else({positions:r,faceIndices:o,nFaces:i}=b2(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=we._malloc(c),h=new Float32Array(we.HEAPF32.buffer,f,l),m=new Uint32Array(we.HEAPU32.buffer,f+u,d);return h.set(r,0),m.set(o,0),we.get_csg_mesh(f,a,f+u,s,i)}function A2(n){return we.has_open_edges(n)}function T2(n,t){we.transform_csg_mesh(n,t.elements)}function C2(n){we.free_csg_mesh(n)}var P2={ConeGeometry:$y,CubeGeometry:Yy,CylinderGeometry:Wy,DodecahedronGeometry:Xy,EllipseGeometry:Ki,HelixGeometry:Mg,IcosahedronGeometry:Ig,LatheGeometry:Ng,NonParametricGeometry:Fg,PolygonGeometry:_c,PyramidGeometry:jg,RectangleGeometry:Ac,SphereGeometry:Hg,PlaneGeometry:qg,BackdropGeometry:Wg,StarGeometry:Tc,TextFrameGeometry:$g,TorusGeometry:Yg,TorusKnotGeometry:Xg,TriangleGeometry:Kg,PathGeometry:e0,VectorGeometry:Xt},Wd=n=>P2[n.type].create(n);function ia(n){return n!==null&&"booleanOp"in n}var aa=class extends ji(M2){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new O2}updateVisible(e){super.updateVisible(e),this.visible=!ia(this.parent)&&this.visible,ia(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(dr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),ia(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof aa&&(e.freeBooleanPointer(),ia(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&ia(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),ia(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Ic=new I2;function _s(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)}Ic.min.set(i,a,s),Ic.max.set(l,d,c),Ic.getCenter(r),Ic.getSize(o).multiplyScalar(.5)}var L2=new N2,D2=new E2,It=class extends aa{constructor(t,e){super(L2,D2),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?_s(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};import{Box3 as WO,Matrix4 as $O,Sphere as Z0,Vector3 as YO}from"three";import{BufferAttribute as UO,Float32BufferAttribute as Q0,MathUtils as Pp,Vector3 as Op}from"three";import{ShaderMaterial as OO}from"three";import{CubeReflectionMapping as W2,CubeRefractionMapping as $2,CubeUVReflectionMapping as Y2,LinearEncoding as w0,sRGBEncoding as X2}from"three";var As=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}};import{MathUtils as B2}from"three";var wt=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=B2.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 wt&&(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 tp=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}},ft=new tp;import{Vector2 as m0}from"three";import{MathUtils as R2}from"three";var ae=class extends wt{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=R2.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 Re=class extends ae{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 Ke=class extends Re{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof m0?e:new m0(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)}};import{Vector3 as y0}from"three";var Nt=class extends Re{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof y0?e:new y0(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)}};import{Color as V2}from"three";var ht=class extends V2{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 Kt=class extends Re{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof ht?e:new ht(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 G2=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,g0=/[a-z_0-9]+/gi,K=class extends ae{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=g0.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&&ft.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=ft.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||ft.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&&ft.contains(m)&&e.include(ft.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=G2.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(g0);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 z2=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,rp=class extends ae{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||rp.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=z2.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)}},Ie=rp;Ie.PI="PI",Ie.PI2="PI2",Ie.RECIPROCAL_PI="RECIPROCAL_PI",Ie.RECIPROCAL_PI2="RECIPROCAL_PI2",Ie.LOG2="LOG2",Ie.EPSILON="EPSILON";var k2=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
18
18
  )*?)}`,"gim"),F2=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),sa=class extends ae{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=k2.exec(e);if(r){let o=r[2],i;for(;i=F2.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=r[1]}else this.name="";this.type=this.name}};var la=class extends ae{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)}};ft.addKeyword("uv",function(){return new la});ft.addKeyword("uv2",function(){return new la(1)});import{LinearEncoding as j2,sRGBEncoding as U2}from"three";var En=class extends ae{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??En.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case j2:return["Linear"];case U2:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),i=this.getType(e),a=En.Nodes[this.method],s=e.include(a);if(s===En.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=En.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=En.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},kt=En;kt.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(`
@@ -2623,7 +2623,7 @@ property scaling ${t.scaling.method}
2623
2623
  property quaternion ${t.quaternion.method}`;if(t.harmonics&&t.harmonics.length>0)for(let M=0;M<t.harmonics.length;M++)o=`${o}
2624
2624
  property harmonics_${M} ${t.harmonics[M].method}`;o=`${o}
2625
2625
  end_header
2626
- `;let a=new TextEncoder().encode(o),s=r*2*4,l=t.xyz.quantized.data.buffer.byteLength,d=t.xyz instanceof je?s:0,c=t.color.quantized.data.buffer.byteLength,u=t.color instanceof je?s:0,p=t.opacity.quantized.data.buffer.byteLength,f=t.opacity instanceof je?s:0,h=t.scaling.quantized.data.buffer.byteLength,m=t.scaling instanceof je?s:0,y=t.quaternion.quantized.data.buffer.byteLength,g=t.quaternion instanceof je?s:0,x=t.variableChunkSize?Uint16Array.from(t.variableChunkSize):void 0,S=x?x.byteLength:0,w=a.byteLength+S+l+d+c+u+p+f+h+m+y+g,b=0,_=0;if(t.harmonics&&t.harmonics.length>0)for(let M=0;M<t.harmonics.length;M++)b+=t.harmonics[M].quantized.data.buffer.byteLength,_+=t.harmonics[M]instanceof je?s:0;b=0,_=0,w+=b+_;let A=new Uint8Array(w),v=0;if(A.set(a,v),v+=a.byteLength,S>0&&(A.set(new Uint8Array(x.buffer),v),v+=S),t.xyz instanceof je&&(A.set(new Uint8Array(t.xyz.minmaxMatrix.data.buffer),v),v+=s),A.set(new Uint8Array(t.xyz.quantized.data.buffer),v),v+=l,t.color instanceof je&&(A.set(new Uint8Array(t.color.minmaxMatrix.data.buffer),v),v+=s),A.set(new Uint8Array(t.color.quantized.data.buffer),v),v+=c,t.opacity instanceof je&&(A.set(new Uint8Array(t.opacity.minmaxMatrix.data.buffer),v),v+=s),A.set(new Uint8Array(t.opacity.quantized.data.buffer),v),v+=p,t.scaling instanceof je&&(A.set(new Uint8Array(t.scaling.minmaxMatrix.data.buffer),v),v+=s),A.set(new Uint8Array(t.scaling.quantized.data.buffer),v),v+=h,t.quaternion instanceof je&&(A.set(new Uint8Array(t.quaternion.minmaxMatrix.data.buffer),v),v+=s),A.set(new Uint8Array(t.quaternion.quantized.data.buffer),v),v+=y,b>0&&t.harmonics&&t.harmonics.length>0)for(let M=0;M<t.harmonics.length;M++){let O=t.harmonics[M];O instanceof je&&(A.set(new Uint8Array(O.minmaxMatrix.data.buffer),v),v+=s),A.set(new Uint8Array(O.quantized.data.buffer),v),v+=O.quantized.data.byteLength}return new hn(A.buffer)}};var gv="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL";var co=class{};yt(co,"DepthMapRange",1<<16),yt(co,"MemoryPageSize",65536),yt(co,"BytesPerFloat",4),yt(co,"BytesPerInt",4);function FI(n){let t,e,r,o,i,a,s,l,d,c,u,p,f,h,m,y;function g(T){let C=new Float64Array(c,a,16);for(let E=0;E<16;E++)C[E]=T[E];t.exports.sortIndexes(o,i,d,a,s,l,p.DepthMapRange,r);let P=new Uint32Array(r),I=P.buffer;P.set(new Uint32Array(c,l,r)),n.postMessage({sortDone:!0,indexesBuffer:I},[I])}function x(T,C,P){let I=new Float32Array(c,i,e*3);r=0;let E=new Uint32Array(c,o,e);for(let R=0;R<P.length-1;R++){let L=C[R],F=T[R].elements,V;L?.length>0&&(V=L.map(B=>B.type==="Box"?_(B):M(B)));for(let B=P[R];B<P[R+1];B++){let j=f[B*3],H=f[B*3+1],X=f[B*3+2];if(!V||w(j,H,X,V)){let $=1/(F[3]*j+F[7]*H+F[11]*X+F[15]);I[r*3]=(F[0]*j+F[4]*H+F[8]*X+F[12])*$,I[r*3+1]=(F[1]*j+F[5]*H+F[9]*X+F[13])*$,I[r*3+2]=(F[2]*j+F[6]*H+F[10]*X+F[14])*$,E[r]=B,r++}}}}function S(T,C){let P=[],I;C?.length>0&&(I=C.map(R=>R.type==="Box"?_(R):M(R)));let E=T.length;for(let R=0;R<E;R+=3){let L=T[R],F=T[R+1],V=T[R+2];w(L,F,V,I)===!1&&P.push(R/3)}return P}function w(T,C,P,I,E){return I[E==="Intersect"?"every":"some"](R=>{let L=b(T,C,P,R.invRotationMatrix,R.cropCenter);return Array.isArray(R)?v(L.x,L.y,L.z,R):O(L.x,L.y,L.z,R)})}function b(T,C,P,I,E){let R=T-E[0],L=C-E[1],F=P-E[2],V=1/(I[3]*R+I[7]*L+I[11]*F+I[15]);return{x:(I[0]*R+I[4]*L+I[8]*F+I[12])*V+E[0],y:(I[1]*R+I[5]*L+I[9]*F+I[13])*V+E[1],z:(I[2]*R+I[6]*L+I[10]*F+I[14])*V+E[2]}}function _(T){let C=T.cropSize[0]/2,P=T.cropSize[1]/2,I=T.cropSize[2]/2,E=[T.cropCenter[0]-C,T.cropCenter[1]-P,T.cropCenter[2]-I,T.cropCenter[0]+C,T.cropCenter[1]+P,T.cropCenter[2]+I],R=A(T.cropRotation);return Object.assign(E,{invRotationMatrix:R,cropCenter:T.cropCenter})}function A(T){let C=[],P=T[0]*Math.PI/180,I=T[1]*Math.PI/180,E=T[2]*Math.PI/180,R=Math.cos(P),L=Math.sin(P),F=Math.cos(I),V=Math.sin(I),B=Math.cos(E),j=Math.sin(E),H=R*B,X=R*j,$=L*B,W=L*j;return C[0]=F*B,C[1]=-F*j,C[2]=V,C[4]=X+$*V,C[5]=H-W*V,C[6]=-L*F,C[8]=W-H*V,C[9]=$+X*V,C[10]=R*F,C[12]=0,C[13]=0,C[14]=0,C[3]=0,C[7]=0,C[11]=0,C[15]=1,C}function v(T,C,P,I){return T>=I[0]&&T<=I[3]&&C>=I[1]&&C<=I[4]&&P>=I[2]&&P<=I[5]}function M(T){let C=2/T.cropSize[0],P=2/T.cropSize[1],I=2/T.cropSize[2],E=A(T.cropRotation);return{invRadiusX:C,invRadiusY:P,invRadiusZ:I,cropCenter:T.cropCenter,invRotationMatrix:E}}function O(T,C,P,I){let E=(T-I.cropCenter[0])*I.invRadiusX,R=(C-I.cropCenter[1])*I.invRadiusY,L=(P-I.cropCenter[2])*I.invRadiusZ;return E*E+R*R+L*L<=1}n.onmessage=T=>{if(T.data.getCroppedIndexes){let C=new Uint32Array(S(new Float32Array(T.data.positions),T.data.crops)).buffer;n.postMessage({outOfBoundsIndexes:C},[C])}else if(T.data.positions)u=T.data.positions,f=new Float32Array(u),m=T.data.meshMatrixWorlds,y=T.data.cropsArray,h=T.data.meshIndexIntervals,x(m,y,h),n.postMessage({sortSetupComplete:!0});else if(T.data.sort||T.data.newMatrixWorlds||T.data.newCropsArray)(T.data.newMatrixWorlds||T.data.newCropsArray)&&(y=T.data.newCropsArray||y,m=T.data.newMatrixWorlds||m,x(m,y,h)),g(T.data.sort.view,T.data.sort.cameraPosition);else if(T.data.init){p=T.data.init.Constants,e=T.data.init.splatCount;let C=p.BytesPerInt,P=p.BytesPerFloat*3,I=new Uint8Array(T.data.init.sorterWasmBytes),E=C+P,R=e*E,L=e*p.BytesPerInt*2+p.DepthMapRange*p.BytesPerInt*2,F=p.MemoryPageSize*32,V=R+L+F,B=Math.floor(V/p.MemoryPageSize)+1,j={module:{},env:{memory:new WebAssembly.Memory({initial:B*2,maximum:B*3,shared:!0})}};WebAssembly.compile(I).then(H=>WebAssembly.instantiate(H,j)).then(H=>{t=H,o=0,i=e*C,a=i+e*P,d=a+16*p.BytesPerFloat*2,s=d+e*p.BytesPerInt,l=s+p.DepthMapRange*p.BytesPerInt,c=j.env.memory.buffer,n.postMessage({sortSetupPhase1Complete:!0})})}}}function xv(n){let t=new Worker(URL.createObjectURL(new Blob(["(",FI.toString(),")(self)"],{type:"application/javascript"}))),e=atob(gv),r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e.charCodeAt(o);return t.postMessage({init:{sorterWasmBytes:r.buffer,splatCount:n,Constants:{BytesPerFloat:co.BytesPerFloat,BytesPerInt:co.BytesPerInt,DepthMapRange:co.DepthMapRange,MemoryPageSize:co.MemoryPageSize}}}),t}import{Matrix4 as oN,Quaternion as wv,Vector2 as nN,Vector3 as qa}from"three";import{BufferAttribute as jI,BufferGeometry as UI,Color as HI,DataTexture as pu,DataUtils as qI,DoubleSide as WI,DynamicDrawUsage as $I,FloatType as bv,HalfFloatType as YI,InstancedBufferAttribute as XI,InstancedBufferGeometry as KI,Mesh as QI,NormalBlending as ZI,RGBAFormat as JI,RGBAIntegerFormat as eN,RGFormat as Sv,ShaderMaterial as tN,UnsignedIntType as rN,Vector2 as mn}from"three";var du=function(){let n=new Float32Array(1),t=new Int32Array(n.buffer);return function(e){return n[0]=e,t[0]}}(),vv=function(n,t,e,r){return n+(t<<8)+(e<<16)+(r<<24)};var fu=new mn,yn=class extends QI{constructor(e,r,o,i,a=!1,s=1,l,d){super(o,i);this.splatCount=r,this.meshIndexIntervals=l,this.meshMatrixWorlds=d,this.splatBuffers=e,this.geometry=o,this.material=i,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=a,this.devicePixelRatio=s,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,r,o=!1,i=1,a,s){let l=yn.buildGeomtery(r),d=yn.buildMaterial(a);return new yn(e,r,l,d,o,i,a,s)}static buildMaterial(e){let r=`
2626
+ `;let a=new TextEncoder().encode(o),s=r*2*4,l=t.xyz.quantized.data.buffer.byteLength,d=t.xyz instanceof je?s:0,c=t.color.quantized.data.buffer.byteLength,u=t.color instanceof je?s:0,p=t.opacity.quantized.data.buffer.byteLength,f=t.opacity instanceof je?s:0,h=t.scaling.quantized.data.buffer.byteLength,m=t.scaling instanceof je?s:0,y=t.quaternion.quantized.data.buffer.byteLength,g=t.quaternion instanceof je?s:0,x=t.variableChunkSize?Uint16Array.from(t.variableChunkSize):void 0,S=x?x.byteLength:0,w=a.byteLength+S+l+d+c+u+p+f+h+m+y+g,b=0,_=0;if(t.harmonics&&t.harmonics.length>0)for(let M=0;M<t.harmonics.length;M++)b+=t.harmonics[M].quantized.data.buffer.byteLength,_+=t.harmonics[M]instanceof je?s:0;b=0,_=0,w+=b+_;let A=new Uint8Array(w),v=0;if(A.set(a,v),v+=a.byteLength,S>0&&(A.set(new Uint8Array(x.buffer),v),v+=S),t.xyz instanceof je&&(A.set(new Uint8Array(t.xyz.minmaxMatrix.data.buffer),v),v+=s),A.set(new Uint8Array(t.xyz.quantized.data.buffer),v),v+=l,t.color instanceof je&&(A.set(new Uint8Array(t.color.minmaxMatrix.data.buffer),v),v+=s),A.set(new Uint8Array(t.color.quantized.data.buffer),v),v+=c,t.opacity instanceof je&&(A.set(new Uint8Array(t.opacity.minmaxMatrix.data.buffer),v),v+=s),A.set(new Uint8Array(t.opacity.quantized.data.buffer),v),v+=p,t.scaling instanceof je&&(A.set(new Uint8Array(t.scaling.minmaxMatrix.data.buffer),v),v+=s),A.set(new Uint8Array(t.scaling.quantized.data.buffer),v),v+=h,t.quaternion instanceof je&&(A.set(new Uint8Array(t.quaternion.minmaxMatrix.data.buffer),v),v+=s),A.set(new Uint8Array(t.quaternion.quantized.data.buffer),v),v+=y,b>0&&t.harmonics&&t.harmonics.length>0)for(let M=0;M<t.harmonics.length;M++){let O=t.harmonics[M];O instanceof je&&(A.set(new Uint8Array(O.minmaxMatrix.data.buffer),v),v+=s),A.set(new Uint8Array(O.quantized.data.buffer),v),v+=O.quantized.data.byteLength}return new hn(A.buffer)}};var gv="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL";var co=class{};yt(co,"DepthMapRange",1<<16),yt(co,"MemoryPageSize",65536),yt(co,"BytesPerFloat",4),yt(co,"BytesPerInt",4);function FI(n){let t,e,r,o,i,a,s,l,d,c,u,p,f,h,m,y;function g(T){let C=new Float64Array(c,a,16);for(let I=0;I<16;I++)C[I]=T[I];let P;if(r>1){t.exports.sortIndexes(o,i,d,a,s,l,p.DepthMapRange,r);let I=new Uint32Array(r);P=I.buffer,I.set(new Uint32Array(c,l,r))}else if(r===1){let I=new Uint32Array(r);I[0]=new Uint32Array(c,o,e)[0],P=I.buffer}else P=new ArrayBuffer(0);n.postMessage({sortDone:!0,indexesBuffer:P},[P])}function x(T,C,P){let I=new Float32Array(c,i,e*3);r=0;let E=new Uint32Array(c,o,e);for(let R=0;R<P.length-1;R++){let L=C[R],F=T[R].elements,V;L?.length>0&&(V=L.map(B=>B.type==="Box"?_(B):M(B)));for(let B=P[R];B<P[R+1];B++){let j=f[B*3],H=f[B*3+1],X=f[B*3+2];if(!V||w(j,H,X,V)){let $=1/(F[3]*j+F[7]*H+F[11]*X+F[15]);I[r*3]=(F[0]*j+F[4]*H+F[8]*X+F[12])*$,I[r*3+1]=(F[1]*j+F[5]*H+F[9]*X+F[13])*$,I[r*3+2]=(F[2]*j+F[6]*H+F[10]*X+F[14])*$,E[r]=B,r++}}}}function S(T,C){let P=[],I;C?.length>0&&(I=C.map(R=>R.type==="Box"?_(R):M(R)));let E=T.length;for(let R=0;R<E;R+=3){let L=T[R],F=T[R+1],V=T[R+2];w(L,F,V,I)===!1&&P.push(R/3)}return P}function w(T,C,P,I,E){return I[E==="Intersect"?"every":"some"](R=>{let L=b(T,C,P,R.invRotationMatrix,R.cropCenter);return Array.isArray(R)?v(L.x,L.y,L.z,R):O(L.x,L.y,L.z,R)})}function b(T,C,P,I,E){let R=T-E[0],L=C-E[1],F=P-E[2],V=1/(I[3]*R+I[7]*L+I[11]*F+I[15]);return{x:(I[0]*R+I[4]*L+I[8]*F+I[12])*V+E[0],y:(I[1]*R+I[5]*L+I[9]*F+I[13])*V+E[1],z:(I[2]*R+I[6]*L+I[10]*F+I[14])*V+E[2]}}function _(T){let C=T.cropSize[0]/2,P=T.cropSize[1]/2,I=T.cropSize[2]/2,E=[T.cropCenter[0]-C,T.cropCenter[1]-P,T.cropCenter[2]-I,T.cropCenter[0]+C,T.cropCenter[1]+P,T.cropCenter[2]+I],R=A(T.cropRotation);return Object.assign(E,{invRotationMatrix:R,cropCenter:T.cropCenter})}function A(T){let C=[],P=T[0]*Math.PI/180,I=T[1]*Math.PI/180,E=T[2]*Math.PI/180,R=Math.cos(P),L=Math.sin(P),F=Math.cos(I),V=Math.sin(I),B=Math.cos(E),j=Math.sin(E),H=R*B,X=R*j,$=L*B,W=L*j;return C[0]=F*B,C[1]=-F*j,C[2]=V,C[4]=X+$*V,C[5]=H-W*V,C[6]=-L*F,C[8]=W-H*V,C[9]=$+X*V,C[10]=R*F,C[12]=0,C[13]=0,C[14]=0,C[3]=0,C[7]=0,C[11]=0,C[15]=1,C}function v(T,C,P,I){return T>=I[0]&&T<=I[3]&&C>=I[1]&&C<=I[4]&&P>=I[2]&&P<=I[5]}function M(T){let C=2/T.cropSize[0],P=2/T.cropSize[1],I=2/T.cropSize[2],E=A(T.cropRotation);return{invRadiusX:C,invRadiusY:P,invRadiusZ:I,cropCenter:T.cropCenter,invRotationMatrix:E}}function O(T,C,P,I){let E=(T-I.cropCenter[0])*I.invRadiusX,R=(C-I.cropCenter[1])*I.invRadiusY,L=(P-I.cropCenter[2])*I.invRadiusZ;return E*E+R*R+L*L<=1}n.onmessage=T=>{if(T.data.getCroppedIndexes){let C=new Uint32Array(S(new Float32Array(T.data.positions),T.data.crops)).buffer;n.postMessage({outOfBoundsIndexes:C},[C])}else if(T.data.positions)u=T.data.positions,f=new Float32Array(u),m=T.data.meshMatrixWorlds,y=T.data.cropsArray,h=T.data.meshIndexIntervals,x(m,y,h),n.postMessage({sortSetupComplete:!0});else if(T.data.sort||T.data.newMatrixWorlds||T.data.newCropsArray)(T.data.newMatrixWorlds||T.data.newCropsArray)&&(y=T.data.newCropsArray||y,m=T.data.newMatrixWorlds||m,x(m,y,h)),g(T.data.sort.view,T.data.sort.cameraPosition);else if(T.data.init){p=T.data.init.Constants,e=T.data.init.splatCount;let C=p.BytesPerInt,P=p.BytesPerFloat*3,I=new Uint8Array(T.data.init.sorterWasmBytes),E=C+P,R=e*E,L=e*p.BytesPerInt*2+p.DepthMapRange*p.BytesPerInt*2,F=p.MemoryPageSize*32,V=R+L+F,B=Math.floor(V/p.MemoryPageSize)+1,j={module:{},env:{memory:new WebAssembly.Memory({initial:B*2,maximum:B*3,shared:!0})}};WebAssembly.compile(I).then(H=>WebAssembly.instantiate(H,j)).then(H=>{t=H,o=0,i=e*C,a=i+e*P,d=a+16*p.BytesPerFloat*2,s=d+e*p.BytesPerInt,l=s+p.DepthMapRange*p.BytesPerInt,c=j.env.memory.buffer,n.postMessage({sortSetupPhase1Complete:!0})})}}}function xv(n){let t=new Worker(URL.createObjectURL(new Blob(["(",FI.toString(),")(self)"],{type:"application/javascript"}))),e=atob(gv),r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e.charCodeAt(o);return t.postMessage({init:{sorterWasmBytes:r.buffer,splatCount:n,Constants:{BytesPerFloat:co.BytesPerFloat,BytesPerInt:co.BytesPerInt,DepthMapRange:co.DepthMapRange,MemoryPageSize:co.MemoryPageSize}}}),t}import{Matrix4 as oN,Quaternion as wv,Vector2 as nN,Vector3 as qa}from"three";import{BufferAttribute as jI,BufferGeometry as UI,Color as HI,DataTexture as pu,DataUtils as qI,DoubleSide as WI,DynamicDrawUsage as $I,FloatType as bv,HalfFloatType as YI,InstancedBufferAttribute as XI,InstancedBufferGeometry as KI,Mesh as QI,NormalBlending as ZI,RGBAFormat as JI,RGBAIntegerFormat as eN,RGFormat as Sv,ShaderMaterial as tN,UnsignedIntType as rN,Vector2 as mn}from"three";var du=function(){let n=new Float32Array(1),t=new Int32Array(n.buffer);return function(e){return n[0]=e,t[0]}}(),vv=function(n,t,e,r){return n+(t<<8)+(e<<16)+(r<<24)};var fu=new mn,yn=class extends QI{constructor(e,r,o,i,a=!1,s=1,l,d){super(o,i);this.splatCount=r,this.meshIndexIntervals=l,this.meshMatrixWorlds=d,this.splatBuffers=e,this.geometry=o,this.material=i,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=a,this.devicePixelRatio=s,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,r,o=!1,i=1,a,s){let l=yn.buildGeomtery(r),d=yn.buildMaterial(a);return new yn(e,r,l,d,o,i,a,s)}static buildMaterial(e){let r=`
2627
2627
  precision highp float;
2628
2628
  #include <common>
2629
2629
 
@@ -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 mn},viewport:{type:"v2",value:new mn},basisViewport:{type:"v2",value:new mn},debugColor:{type:"v3",value:new HI},covariancesTextureSize:{type:"v2",value:new mn(1024,1024)},centersColorsTextureSize:{type:"v2",value:new mn(1024,1024)},orthoZoom:{type:"f",value:-1}};return new tN({uniforms:i,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:ZI,depthTest:!0,depthWrite:!1,side:WI})}static buildGeomtery(e){let r=new UI;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new jI(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 KI().copy(r),s=new Uint32Array(e),l=new XI(s,1,!1);return l.setUsage($I),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 mn(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new mn(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]=qI.toHalfFloat(this.covariances[h]);s=new pu(l,i.x,i.y,Sv,YI)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new pu(l,i.x,i.y,Sv,bv);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]=vv(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),d[g+1]=du(this.centers[y]),d[g+2]=du(this.centers[y+1]),d[g+3]=du(this.centers[y+2])}let c=new pu(d,a.x,a.y,eN,rN);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 pu(p,u,1,JI,bv);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&&(fu.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(fu),this.material.uniforms.basisViewport.value.set(2/fu.x,2/fu.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}};var Hs=class{constructor(t={}){yt(this,"updateSplatMeshUniforms",function(){let t=new nN;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))}}());yt(this,"updateView",function(){let t=new oN,e=[],r=new qa(0,0,-1),o=new qa(0,0,-1),i=new qa,a=new qa;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 qa().fromArray(t.position)),t.orientation&&(t.orientation=new wv().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)}}),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 hn(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 qa,o=new wv,i=!1,a=1,s,l){this.splatMesh=yn.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=xv(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 dN=new cN;dN.wireframe=!0;var _v=new aN,hu=class extends iN{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 lu;this.errorPage=new dn("fdasfa",{...xo.defaultData,name:""});this.invisibleObjects=new un("jflkdsafjasdifjaslk",{...$l.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=Fx(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=kx(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 dn&&(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)=>ef(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===Uo)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(),cn(i)&&Va(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),Va(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),cn(o)&&(o.freeBooleanPointer(),i instanceof yr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof ja&&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()),cn(o)&&(o.invalidateUpstreamBooleanData(),Va(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 dn&&(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{Vx(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=>{Va(i)&&i.recomputeBoolean(),i instanceof Mo&&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){Ae.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Ae.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=Vo(c.data,u=>{let p=u.events.data(l.id),f=c.goUp(s);if(f){let h=[...$s(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=ot.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 Io&&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=Vo(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of Ql.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 Io&&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),iu(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Io&&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)Ae.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(Ae.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(cn(s)||zs(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Us(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;Ae.is(a)&&(a.visible||s?.object.data.visible)&&((cn(a)||zs(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Us(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Ae.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Ae.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Ae.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();Va(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)Gi.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Ae.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=su(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=>{if(c instanceof st&&c.isSkinnedMesh){let u=c.dataPatched;if(u.bones&&u.boneInverses){let p=u.bones.map(m=>this.find(m)),f=u.boneInverses.map(m=>new sN().fromArray(m)),h=new uN(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 lN;return o.setFromPoints(r),o.getCenter(_v),_v}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 It)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Zt&&e(r.material[o]);else r.material instanceof Zt&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(i=>{i instanceof Mo&&i.setViewplaneSize(e,r,o)})}initializeSplatViewer(e){this.splatViewer=new Hs({scene:this,renderer:e}),this.reloadSplats()}reloadSplats(){this.splatViewer?.reloadSplats()}};import{DRACOLoader as pN}from"three/examples/jsm/loaders/DRACOLoader.js";var gn;function fN(){return gn||(gn=new pN,gn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),gn.decoderPending}async function hN(n){if(gn){let t={attributeIDs:gn.defaultAttributeIDs,attributeTypes:gn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await gn.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 Av(n,t){let[e,r]=Pu(Bl.deserialize(new Uint8Array(n)));ec(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 fN();for(let i of o){let a=await hN(Ye(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}import{Mesh as zne}from"three";import{mergeBufferGeometries as jne}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Tv(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}import{Color as Cv,ShaderLib as mN}from"three";function Pv(n){let t=new Set;return n.traverse(e=>{if(e instanceof Jt)if(Ze(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(yN(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Cv,specularColor:new Cv});let o=0;e.onBeforeCompile=(i,a)=>{r&&r(i,a),i.uniforms=Object.assign({},mN.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=O0(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else gN(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function yN(n){return n.getLayersOfType("transmission").length>0}function gN(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 Ov(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function Mv(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}import{mergeBufferGeometries as xN}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Iv(n){let t=[];return n.traverse(e=>{e instanceof La&&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&&Tv(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof It&&a.unshift(r.geometry),a.length){let s=xN(a);r instanceof It&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:n,shared:q0})}),n}function Nv(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function Ev(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 Vv=Rt(Dv(),1);function Bv(n){return n.traverseMaterial(t=>{t.needsJitter=!1}),n}var Rv="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Qp=class extends bN{load(t,e,r,o=console.error){let i=new vN(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(Rv+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(Rv),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 Av(t,Ev);e.version&&(0,Vv.default)(e.version,"0.9.502")>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)&&i0(),ux(e)&&j0()].filter(Boolean));let r=new jn(e.shared);Object.values(r.getMaterials()).forEach(a=>Object.assign(a,{isAsset:!0}));let o=new hu(e.scene,r),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=Iv(o),o=Pv(o),o=Ov(o),o=Mv(o),o=Nv(o),o=Bv(o),o}};export{Qp as default};
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 mn},viewport:{type:"v2",value:new mn},basisViewport:{type:"v2",value:new mn},debugColor:{type:"v3",value:new HI},covariancesTextureSize:{type:"v2",value:new mn(1024,1024)},centersColorsTextureSize:{type:"v2",value:new mn(1024,1024)},orthoZoom:{type:"f",value:-1}};return new tN({uniforms:i,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:ZI,depthTest:!0,depthWrite:!1,side:WI})}static buildGeomtery(e){let r=new UI;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new jI(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 KI().copy(r),s=new Uint32Array(e),l=new XI(s,1,!1);return l.setUsage($I),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 mn(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new mn(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]=qI.toHalfFloat(this.covariances[h]);s=new pu(l,i.x,i.y,Sv,YI)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new pu(l,i.x,i.y,Sv,bv);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]=vv(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),d[g+1]=du(this.centers[y]),d[g+2]=du(this.centers[y+1]),d[g+3]=du(this.centers[y+2])}let c=new pu(d,a.x,a.y,eN,rN);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 pu(p,u,1,JI,bv);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&&(fu.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(fu),this.material.uniforms.basisViewport.value.set(2/fu.x,2/fu.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 Hs=class{constructor(t={}){yt(this,"updateSplatMeshUniforms",function(){let t=new nN;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))}}());yt(this,"updateView",function(){let t=new oN,e=[],r=new qa(0,0,-1),o=new qa(0,0,-1),i=new qa,a=new qa;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 qa().fromArray(t.position)),t.orientation&&(t.orientation=new wv().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 hn(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 qa,o=new wv,i=!1,a=1,s,l){this.splatMesh=yn.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=xv(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 dN=new cN;dN.wireframe=!0;var _v=new aN,hu=class extends iN{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 lu;this.errorPage=new dn("fdasfa",{...xo.defaultData,name:""});this.invisibleObjects=new un("jflkdsafjasdifjaslk",{...$l.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=Fx(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=kx(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 dn&&(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)=>ef(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===Uo)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(),cn(i)&&Va(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),Va(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),cn(o)&&(o.freeBooleanPointer(),i instanceof yr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof ja&&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()),cn(o)&&(o.invalidateUpstreamBooleanData(),Va(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 dn&&(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{Vx(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=>{Va(i)&&i.recomputeBoolean(),i instanceof Mo&&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){Ae.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Ae.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=Vo(c.data,u=>{let p=u.events.data(l.id),f=c.goUp(s);if(f){let h=[...$s(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=ot.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 Io&&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=Vo(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of Ql.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 Io&&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),iu(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Io&&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)Ae.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(Ae.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(cn(s)||zs(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Us(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;Ae.is(a)&&(a.visible||s?.object.data.visible)&&((cn(a)||zs(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Us(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Ae.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Ae.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Ae.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();Va(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)Gi.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Ae.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=su(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=>{if(c instanceof st&&c.isSkinnedMesh){let u=c.dataPatched;if(u.bones&&u.boneInverses){let p=u.bones.map(m=>this.find(m)),f=u.boneInverses.map(m=>new sN().fromArray(m)),h=new uN(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 lN;return o.setFromPoints(r),o.getCenter(_v),_v}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 It)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Zt&&e(r.material[o]);else r.material instanceof Zt&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(i=>{i instanceof Mo&&i.setViewplaneSize(e,r,o)})}initializeSplatViewer(e){this.splatViewer=new Hs({scene:this,renderer:e}),this.reloadSplats()}reloadSplats(){this.splatViewer?.reloadSplats()}};import{DRACOLoader as pN}from"three/examples/jsm/loaders/DRACOLoader.js";var gn;function fN(){return gn||(gn=new pN,gn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),gn.decoderPending}async function hN(n){if(gn){let t={attributeIDs:gn.defaultAttributeIDs,attributeTypes:gn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await gn.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 Av(n,t){let[e,r]=Pu(Bl.deserialize(new Uint8Array(n)));ec(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 fN();for(let i of o){let a=await hN(Ye(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}import{Mesh as zne}from"three";import{mergeBufferGeometries as jne}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Tv(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}import{Color as Cv,ShaderLib as mN}from"three";function Pv(n){let t=new Set;return n.traverse(e=>{if(e instanceof Jt)if(Ze(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(yN(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Cv,specularColor:new Cv});let o=0;e.onBeforeCompile=(i,a)=>{r&&r(i,a),i.uniforms=Object.assign({},mN.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=O0(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else gN(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function yN(n){return n.getLayersOfType("transmission").length>0}function gN(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 Ov(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function Mv(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}import{mergeBufferGeometries as xN}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Iv(n){let t=[];return n.traverse(e=>{e instanceof La&&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&&Tv(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof It&&a.unshift(r.geometry),a.length){let s=xN(a);r instanceof It&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:n,shared:q0})}),n}function Nv(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function Ev(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 Vv=Rt(Dv(),1);function Bv(n){return n.traverseMaterial(t=>{t.needsJitter=!1}),n}var Rv="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Qp=class extends bN{load(t,e,r,o=console.error){let i=new vN(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(Rv+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(Rv),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 Av(t,Ev);e.version&&(0,Vv.default)(e.version,"0.9.503")>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)&&i0(),ux(e)&&j0()].filter(Boolean));let r=new jn(e.shared);Object.values(r.getMaterials()).forEach(a=>Object.assign(a,{isAsset:!0}));let o=new hu(e.scene,r),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=Iv(o),o=Pv(o),o=Ov(o),o=Mv(o),o=Nv(o),o=Bv(o),o}};export{Qp as default};