@splinetool/loader 0.9.32 → 0.9.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/SplineLoader.js +11 -11
- package/package.json +2 -2
package/build/SplineLoader.js
CHANGED
|
@@ -17,7 +17,7 @@ __p += '`),nt&&(ie+=`' +
|
|
|
17
17
|
function print() { __p += __j.call(arguments, '') }
|
|
18
18
|
`:`;
|
|
19
19
|
`)+ie+`return __p
|
|
20
|
-
}`;var Je=rg(function(){return lt(v,Le+"return "+ie).apply(i,N)});if(Je.source=ie,zf(Je))throw Je;return Je}function VL(o){return ut(o).toLowerCase()}function UL(o){return ut(o).toUpperCase()}function kL(o,a,u){if(o=ut(o),o&&(u||a===i))return o.replace(tt,"");if(!o||!(a=qr(a)))return o;var p=_n(o),m=_n(a),v=pd(p,m),N=dd(p,m)+1;return Pi(p,v,N).join("")}function HL(o,a,u){if(o=ut(o),o&&(u||a===i))return o.replace(mt,"");if(!o||!(a=qr(a)))return o;var p=_n(o),m=dd(p,_n(a))+1;return Pi(p,0,m).join("")}function WL(o,a,u){if(o=ut(o),o&&(u||a===i))return o.replace(at,"");if(!o||!(a=qr(a)))return o;var p=_n(o),m=pd(p,_n(a));return Pi(p,m).join("")}function qL(o,a){var u=E,p=b;if(Dt(a)){var m="separator"in a?a.separator:m;u="length"in a?We(a.length):u,p="omission"in a?qr(a.omission):p}o=ut(o);var v=o.length;if(Eo(o)){var N=_n(o);v=N.length}if(u>=v)return o;var L=u-Ro(p);if(L<1)return p;var I=N?Pi(N,0,L).join(""):o.slice(0,L);if(m===i)return I+p;if(N&&(L+=I.length-L),Ff(m)){if(o.slice(L).search(m)){var Q,te=I;for(m.global||(m=tf(m.source,ut(Ln.exec(m))+"g")),m.lastIndex=0;Q=m.exec(te);)var ie=Q.index;I=I.slice(0,ie===i?L:ie)}}else if(o.indexOf(qr(m),L)!=L){var me=I.lastIndexOf(m);me>-1&&(I=I.slice(0,me))}return I+p}function $L(o){return o=ut(o),o&&Do.test(o)?o.replace(ro,wS):o}var JL=Ho(function(o,a,u){return o+(u?" ":"")+a.toUpperCase()}),kf=nm("toUpperCase");function tg(o,a,u){return o=ut(o),a=u?i:a,a===i?yS(o)?LS(o):lS(o):o.match(a)||[]}var rg=Ze(function(o,a){try{return Hr(o,i,a)}catch(u){return zf(u)?u:new Ue(u)}}),KL=si(function(o,a){return sn(a,function(u){u=Vn(u),ii(o,u,Ef(o[u],o))}),o});function XL(o){var a=o==null?0:o.length,u=De();return o=a?Ot(o,function(p){if(typeof p[1]!="function")throw new an(n);return[u(p[0]),p[1]]}):[],Ze(function(p){for(var m=-1;++m<a;){var v=o[m];if(Hr(v[0],this,p))return Hr(v[1],this,p)}})}function ZL(o){return ww(cn(o,f))}function Hf(o){return function(){return o}}function YL(o,a){return o==null||o!==o?a:o}var QL=om(),e_=om(!0);function Br(o){return o}function Wf(o){return Gd(typeof o=="function"?o:cn(o,f))}function t_(o){return Ed(cn(o,f))}function r_(o,a){return Rd(o,cn(a,f))}var n_=Ze(function(o,a){return function(u){return Ks(u,o,a)}}),i_=Ze(function(o,a){return function(u){return Ks(o,u,a)}});function qf(o,a,u){var p=nr(a),m=bl(a,p);u==null&&!(Dt(a)&&(m.length||!p.length))&&(u=a,a=o,o=this,m=bl(a,nr(a)));var v=!(Dt(u)&&"chain"in u)||!!u.chain,N=li(o);return sn(m,function(L){var I=a[L];o[L]=I,N&&(o.prototype[L]=function(){var Q=this.__chain__;if(v||Q){var te=o(this.__wrapped__),ie=te.__actions__=Or(this.__actions__);return ie.push({func:I,args:arguments,thisArg:o}),te.__chain__=Q,te}return I.apply(o,Li([this.value()],arguments))})}),o}function o_(){return rr._===this&&(rr._=OS),this}function $f(){}function s_(o){return o=We(o),Ze(function(a){return zd(a,o)})}var a_=Cf(Ot),l_=Cf(ld),c_=Cf(Ju);function ng(o){return Of(o)?Ku(Vn(o)):zw(o)}function u_(o){return function(a){return o==null?i:uo(o,a)}}var f_=am(),h_=am(!0);function Jf(){return[]}function Kf(){return!1}function p_(){return{}}function d_(){return""}function m_(){return!0}function g_(o,a){if(o=We(o),o<1||o>re)return[];var u=Me,p=dr(o,Me);a=De(a),o-=Me;for(var m=Yu(p,a);++u<o;)a(u);return m}function y_(o){return ke(o)?Ot(o,Vn):$r(o)?[o]:Or(Nm(ut(o)))}function x_(o){var a=++MS;return ut(o)+a}var v_=_l(function(o,a){return o+a},0),b_=Lf("ceil"),S_=_l(function(o,a){return o/a},1),w_=Lf("floor");function N_(o){return o&&o.length?vl(o,Br,uf):i}function C_(o,a){return o&&o.length?vl(o,De(a,2),uf):i}function L_(o){return fd(o,Br)}function __(o,a){return fd(o,De(a,2))}function T_(o){return o&&o.length?vl(o,Br,df):i}function I_(o,a){return o&&o.length?vl(o,De(a,2),df):i}var M_=_l(function(o,a){return o*a},1),A_=Lf("round"),O_=_l(function(o,a){return o-a},0);function P_(o){return o&&o.length?Zu(o,Br):0}function D_(o,a){return o&&o.length?Zu(o,De(a,2)):0}return y.after=tC,y.ary=Bm,y.assign=UC,y.assignIn=Jm,y.assignInWith=zl,y.assignWith=kC,y.at=HC,y.before=Gm,y.bind=Ef,y.bindAll=KL,y.bindKey=jm,y.castArray=pC,y.chain=Om,y.chunk=w1,y.compact=N1,y.concat=C1,y.cond=XL,y.conforms=ZL,y.constant=Hf,y.countBy=PN,y.create=WC,y.curry=Em,y.curryRight=Rm,y.debounce=zm,y.defaults=qC,y.defaultsDeep=$C,y.defer=rC,y.delay=nC,y.difference=L1,y.differenceBy=_1,y.differenceWith=T1,y.drop=I1,y.dropRight=M1,y.dropRightWhile=A1,y.dropWhile=O1,y.fill=P1,y.filter=BN,y.flatMap=EN,y.flatMapDeep=RN,y.flatMapDepth=zN,y.flatten=Tm,y.flattenDeep=D1,y.flattenDepth=B1,y.flip=iC,y.flow=QL,y.flowRight=e_,y.fromPairs=G1,y.functions=eL,y.functionsIn=tL,y.groupBy=FN,y.initial=E1,y.intersection=R1,y.intersectionBy=z1,y.intersectionWith=F1,y.invert=nL,y.invertBy=iL,y.invokeMap=UN,y.iteratee=Wf,y.keyBy=kN,y.keys=nr,y.keysIn=Dr,y.map=Dl,y.mapKeys=sL,y.mapValues=aL,y.matches=t_,y.matchesProperty=r_,y.memoize=Gl,y.merge=lL,y.mergeWith=Km,y.method=n_,y.methodOf=i_,y.mixin=qf,y.negate=jl,y.nthArg=s_,y.omit=cL,y.omitBy=uL,y.once=oC,y.orderBy=HN,y.over=a_,y.overArgs=sC,y.overEvery=l_,y.overSome=c_,y.partial=Rf,y.partialRight=Fm,y.partition=WN,y.pick=fL,y.pickBy=Xm,y.property=ng,y.propertyOf=u_,y.pull=H1,y.pullAll=Mm,y.pullAllBy=W1,y.pullAllWith=q1,y.pullAt=$1,y.range=f_,y.rangeRight=h_,y.rearg=aC,y.reject=JN,y.remove=J1,y.rest=lC,y.reverse=Gf,y.sampleSize=XN,y.set=pL,y.setWith=dL,y.shuffle=ZN,y.slice=K1,y.sortBy=eC,y.sortedUniq=rN,y.sortedUniqBy=nN,y.split=EL,y.spread=cC,y.tail=iN,y.take=oN,y.takeRight=sN,y.takeRightWhile=aN,y.takeWhile=lN,y.tap=NN,y.throttle=uC,y.thru=Pl,y.toArray=Wm,y.toPairs=Zm,y.toPairsIn=Ym,y.toPath=y_,y.toPlainObject=$m,y.transform=mL,y.unary=fC,y.union=cN,y.unionBy=uN,y.unionWith=fN,y.uniq=hN,y.uniqBy=pN,y.uniqWith=dN,y.unset=gL,y.unzip=jf,y.unzipWith=Am,y.update=yL,y.updateWith=xL,y.values=$o,y.valuesIn=vL,y.without=mN,y.words=tg,y.wrap=hC,y.xor=gN,y.xorBy=yN,y.xorWith=xN,y.zip=vN,y.zipObject=bN,y.zipObjectDeep=SN,y.zipWith=wN,y.entries=Zm,y.entriesIn=Ym,y.extend=Jm,y.extendWith=zl,qf(y,y),y.add=v_,y.attempt=rg,y.camelCase=NL,y.capitalize=Qm,y.ceil=b_,y.clamp=bL,y.clone=dC,y.cloneDeep=gC,y.cloneDeepWith=yC,y.cloneWith=mC,y.conformsTo=xC,y.deburr=eg,y.defaultTo=YL,y.divide=S_,y.endsWith=CL,y.eq=In,y.escape=LL,y.escapeRegExp=_L,y.every=DN,y.find=GN,y.findIndex=Lm,y.findKey=JC,y.findLast=jN,y.findLastIndex=_m,y.findLastKey=KC,y.floor=w_,y.forEach=Pm,y.forEachRight=Dm,y.forIn=XC,y.forInRight=ZC,y.forOwn=YC,y.forOwnRight=QC,y.get=Vf,y.gt=vC,y.gte=bC,y.has=rL,y.hasIn=Uf,y.head=Im,y.identity=Br,y.includes=VN,y.indexOf=j1,y.inRange=SL,y.invoke=oL,y.isArguments=po,y.isArray=ke,y.isArrayBuffer=SC,y.isArrayLike=Pr,y.isArrayLikeObject=zt,y.isBoolean=wC,y.isBuffer=Di,y.isDate=NC,y.isElement=CC,y.isEmpty=LC,y.isEqual=_C,y.isEqualWith=TC,y.isError=zf,y.isFinite=IC,y.isFunction=li,y.isInteger=Vm,y.isLength=El,y.isMap=Um,y.isMatch=MC,y.isMatchWith=AC,y.isNaN=OC,y.isNative=PC,y.isNil=BC,y.isNull=DC,y.isNumber=km,y.isObject=Dt,y.isObjectLike=Gt,y.isPlainObject=ta,y.isRegExp=Ff,y.isSafeInteger=GC,y.isSet=Hm,y.isString=Rl,y.isSymbol=$r,y.isTypedArray=qo,y.isUndefined=jC,y.isWeakMap=EC,y.isWeakSet=RC,y.join=V1,y.kebabCase=TL,y.last=fn,y.lastIndexOf=U1,y.lowerCase=IL,y.lowerFirst=ML,y.lt=zC,y.lte=FC,y.max=N_,y.maxBy=C_,y.mean=L_,y.meanBy=__,y.min=T_,y.minBy=I_,y.stubArray=Jf,y.stubFalse=Kf,y.stubObject=p_,y.stubString=d_,y.stubTrue=m_,y.multiply=M_,y.nth=k1,y.noConflict=o_,y.noop=$f,y.now=Bl,y.pad=AL,y.padEnd=OL,y.padStart=PL,y.parseInt=DL,y.random=wL,y.reduce=qN,y.reduceRight=$N,y.repeat=BL,y.replace=GL,y.result=hL,y.round=A_,y.runInContext=O,y.sample=KN,y.size=YN,y.snakeCase=jL,y.some=QN,y.sortedIndex=X1,y.sortedIndexBy=Z1,y.sortedIndexOf=Y1,y.sortedLastIndex=Q1,y.sortedLastIndexBy=eN,y.sortedLastIndexOf=tN,y.startCase=RL,y.startsWith=zL,y.subtract=O_,y.sum=P_,y.sumBy=D_,y.template=FL,y.times=g_,y.toFinite=ci,y.toInteger=We,y.toLength=qm,y.toLower=VL,y.toNumber=hn,y.toSafeInteger=VC,y.toString=ut,y.toUpper=UL,y.trim=kL,y.trimEnd=HL,y.trimStart=WL,y.truncate=qL,y.unescape=$L,y.uniqueId=x_,y.upperCase=JL,y.upperFirst=kf,y.each=Pm,y.eachRight=Dm,y.first=Im,qf(y,function(){var o={};return zn(y,function(a,u){pt.call(y.prototype,u)||(o[u]=a)}),o}(),{chain:!1}),y.VERSION=e,sn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){y[o].placeholder=y}),sn(["drop","take"],function(o,a){rt.prototype[o]=function(u){u=u===i?1:Xt(We(u),0);var p=this.__filtered__&&!a?new rt(this):this.clone();return p.__filtered__?p.__takeCount__=dr(u,p.__takeCount__):p.__views__.push({size:dr(u,Me),type:o+(p.__dir__<0?"Right":"")}),p},rt.prototype[o+"Right"]=function(u){return this.reverse()[o](u).reverse()}}),sn(["filter","map","takeWhile"],function(o,a){var u=a+1,p=u==z||u==$;rt.prototype[o]=function(m){var v=this.clone();return v.__iteratees__.push({iteratee:De(m,3),type:u}),v.__filtered__=v.__filtered__||p,v}}),sn(["head","last"],function(o,a){var u="take"+(a?"Right":"");rt.prototype[o]=function(){return this[u](1).value()[0]}}),sn(["initial","tail"],function(o,a){var u="drop"+(a?"":"Right");rt.prototype[o]=function(){return this.__filtered__?new rt(this):this[u](1)}}),rt.prototype.compact=function(){return this.filter(Br)},rt.prototype.find=function(o){return this.filter(o).head()},rt.prototype.findLast=function(o){return this.reverse().find(o)},rt.prototype.invokeMap=Ze(function(o,a){return typeof o=="function"?new rt(this):this.map(function(u){return Ks(u,o,a)})}),rt.prototype.reject=function(o){return this.filter(jl(De(o)))},rt.prototype.slice=function(o,a){o=We(o);var u=this;return u.__filtered__&&(o>0||a<0)?new rt(u):(o<0?u=u.takeRight(-o):o&&(u=u.drop(o)),a!==i&&(a=We(a),u=a<0?u.dropRight(-a):u.take(a-o)),u)},rt.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},rt.prototype.toArray=function(){return this.take(Me)},zn(rt.prototype,function(o,a){var u=/^(?:filter|find|map|reject)|While$/.test(a),p=/^(?:head|last)$/.test(a),m=y[p?"take"+(a=="last"?"Right":""):a],v=p||/^find/.test(a);!m||(y.prototype[a]=function(){var N=this.__wrapped__,L=p?[1]:arguments,I=N instanceof rt,Q=L[0],te=I||ke(N),ie=function(et){var nt=m.apply(y,Li([et],L));return p&&me?nt[0]:nt};te&&u&&typeof Q=="function"&&Q.length!=1&&(I=te=!1);var me=this.__chain__,Le=!!this.__actions__.length,Re=v&&!me,Je=I&&!Le;if(!v&&te){N=Je?N:new rt(this);var je=o.apply(N,L);return je.__actions__.push({func:Pl,args:[ie],thisArg:i}),new ln(je,me)}return Re&&Je?o.apply(this,L):(je=this.thru(ie),Re?p?je.value()[0]:je.value():je)})}),sn(["pop","push","shift","sort","splice","unshift"],function(o){var a=il[o],u=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",p=/^(?:pop|shift)$/.test(o);y.prototype[o]=function(){var m=arguments;if(p&&!this.__chain__){var v=this.value();return a.apply(ke(v)?v:[],m)}return this[u](function(N){return a.apply(ke(N)?N:[],m)})}}),zn(rt.prototype,function(o,a){var u=y[a];if(u){var p=u.name+"";pt.call(Vo,p)||(Vo[p]=[]),Vo[p].push({name:a,func:u})}}),Vo[Ll(i,S).name]=[{name:"wrapper",func:i}],rt.prototype.clone=$S,rt.prototype.reverse=JS,rt.prototype.value=KS,y.prototype.at=CN,y.prototype.chain=LN,y.prototype.commit=_N,y.prototype.next=TN,y.prototype.plant=MN,y.prototype.reverse=AN,y.prototype.toJSON=y.prototype.valueOf=y.prototype.value=ON,y.prototype.first=y.prototype.head,Us&&(y.prototype[Us]=IN),y},Ti=_S();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(rr._=Ti,define(function(){return Ti})):oo?((oo.exports=Ti)._=Ti,Hu._=Ti):rr._=Ti}).call(Fs)});import{FileLoader as rB,Loader as nB}from"three";function fg(i){return Array.isArray(i)?i:[i]}var k_=typeof global=="object"&&global&&global.Object===Object&&global,Fl=k_;var H_=typeof self=="object"&&self&&self.Object===Object&&self,W_=Fl||H_||Function("return this")(),qt=W_;var q_=qt.Symbol,Nr=q_;var hg=Object.prototype,$_=hg.hasOwnProperty,J_=hg.toString,na=Nr?Nr.toStringTag:void 0;function K_(i){var e=$_.call(i,na),t=i[na];try{i[na]=void 0;var r=!0}catch(s){}var n=J_.call(i);return r&&(e?i[na]=t:delete i[na]),n}var pg=K_;var X_=Object.prototype,Z_=X_.toString;function Y_(i){return Z_.call(i)}var dg=Y_;var Q_="[object Null]",eT="[object Undefined]",mg=Nr?Nr.toStringTag:void 0;function tT(i){return i==null?i===void 0?eT:Q_:mg&&mg in Object(i)?pg(i):dg(i)}var Xr=tT;function rT(i){return i!=null&&typeof i=="object"}var gr=rT;var nT="[object Symbol]";function iT(i){return typeof i=="symbol"||gr(i)&&Xr(i)==nT}var Jo=iT;function oT(i,e){for(var t=-1,r=i==null?0:i.length,n=Array(r);++t<r;)n[t]=e(i[t],t,i);return n}var Vl=oT;var sT=Array.isArray,cr=sT;var aT=1/0,gg=Nr?Nr.prototype:void 0,yg=gg?gg.toString:void 0;function xg(i){if(typeof i=="string")return i;if(cr(i))return Vl(i,xg)+"";if(Jo(i))return yg?yg.call(i):"";var e=i+"";return e=="0"&&1/i==-aT?"-0":e}var vg=xg;function lT(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var yr=lT;function cT(i){return i}var Ul=cT;var uT="[object AsyncFunction]",fT="[object Function]",hT="[object GeneratorFunction]",pT="[object Proxy]";function dT(i){if(!yr(i))return!1;var e=Xr(i);return e==fT||e==hT||e==uT||e==pT}var Ko=dT;var mT=qt["__core-js_shared__"],kl=mT;var bg=function(){var i=/[^.]+$/.exec(kl&&kl.keys&&kl.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function gT(i){return!!bg&&bg in i}var Sg=gT;var yT=Function.prototype,xT=yT.toString;function vT(i){if(i!=null){try{return xT.call(i)}catch(e){}try{return i+""}catch(e){}}return""}var fi=vT;var bT=/[\\^$.*+?()[\]{}|]/g,ST=/^\[object .+?Constructor\]$/,wT=Function.prototype,NT=Object.prototype,CT=wT.toString,LT=NT.hasOwnProperty,_T=RegExp("^"+CT.call(LT).replace(bT,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function TT(i){if(!yr(i)||Sg(i))return!1;var e=Ko(i)?_T:ST;return e.test(fi(i))}var wg=TT;function IT(i,e){return i==null?void 0:i[e]}var Ng=IT;function MT(i,e){var t=Ng(i,e);return wg(t)?t:void 0}var Gr=MT;var AT=Gr(qt,"WeakMap"),Hl=AT;var Cg=Object.create,OT=function(){function i(){}return function(e){if(!yr(e))return{};if(Cg)return Cg(e);i.prototype=e;var t=new i;return i.prototype=void 0,t}}(),Lg=OT;function PT(i,e,t){switch(t.length){case 0:return i.call(e);case 1:return i.call(e,t[0]);case 2:return i.call(e,t[0],t[1]);case 3:return i.call(e,t[0],t[1],t[2])}return i.apply(e,t)}var _g=PT;function DT(i,e){var t=-1,r=i.length;for(e||(e=Array(r));++t<r;)e[t]=i[t];return e}var Wl=DT;var BT=800,GT=16,jT=Date.now;function ET(i){var e=0,t=0;return function(){var r=jT(),n=GT-(r-t);if(t=r,n>0){if(++e>=BT)return arguments[0]}else e=0;return i.apply(void 0,arguments)}}var Tg=ET;function RT(i){return function(){return i}}var Ig=RT;var zT=function(){try{var i=Gr(Object,"defineProperty");return i({},"",{}),i}catch(e){}}(),Xo=zT;var FT=Xo?function(i,e){return Xo(i,"toString",{configurable:!0,enumerable:!1,value:Ig(e),writable:!0})}:Ul,Mg=FT;var VT=Tg(Mg),ql=VT;function UT(i,e){for(var t=-1,r=i==null?0:i.length;++t<r&&e(i[t],t,i)!==!1;);return i}var Ag=UT;var kT=9007199254740991,HT=/^(?:0|[1-9]\d*)$/;function WT(i,e){var t=typeof i;return e=e==null?kT:e,!!e&&(t=="number"||t!="symbol"&&HT.test(i))&&i>-1&&i%1==0&&i<e}var $l=WT;function qT(i,e,t){e=="__proto__"&&Xo?Xo(i,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):i[e]=t}var Zo=qT;function $T(i,e){return i===e||i!==i&&e!==e}var Bi=$T;var JT=Object.prototype,KT=JT.hasOwnProperty;function XT(i,e,t){var r=i[e];(!(KT.call(i,e)&&Bi(r,t))||t===void 0&&!(e in i))&&Zo(i,e,t)}var Jl=XT;function ZT(i,e,t,r){var n=!t;t||(t={});for(var s=-1,l=e.length;++s<l;){var c=e[s],f=r?r(t[c],i[c],c,t,i):void 0;f===void 0&&(f=i[c]),n?Zo(t,c,f):Jl(t,c,f)}return t}var pn=ZT;var Og=Math.max;function YT(i,e,t){return e=Og(e===void 0?i.length-1:e,0),function(){for(var r=arguments,n=-1,s=Og(r.length-e,0),l=Array(s);++n<s;)l[n]=r[e+n];n=-1;for(var c=Array(e+1);++n<e;)c[n]=r[n];return c[e]=t(l),_g(i,this,c)}}var Kl=YT;function QT(i,e){return ql(Kl(i,e,Ul),i+"")}var Pg=QT;var eI=9007199254740991;function tI(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=eI}var Xl=tI;function rI(i){return i!=null&&Xl(i.length)&&!Ko(i)}var Gi=rI;function nI(i,e,t){if(!yr(t))return!1;var r=typeof e;return(r=="number"?Gi(t)&&$l(e,t.length):r=="string"&&e in t)?Bi(t[e],i):!1}var Dg=nI;function iI(i){return Pg(function(e,t){var r=-1,n=t.length,s=n>1?t[n-1]:void 0,l=n>2?t[2]:void 0;for(s=i.length>3&&typeof s=="function"?(n--,s):void 0,l&&Dg(t[0],t[1],l)&&(s=n<3?void 0:s,n=1),e=Object(e);++r<n;){var c=t[r];c&&i(e,c,r,s)}return e})}var Bg=iI;var oI=Object.prototype;function sI(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||oI;return i===t}var Yo=sI;function aI(i,e){for(var t=-1,r=Array(i);++t<i;)r[t]=e(t);return r}var Gg=aI;var lI="[object Arguments]";function cI(i){return gr(i)&&Xr(i)==lI}var Xf=cI;var jg=Object.prototype,uI=jg.hasOwnProperty,fI=jg.propertyIsEnumerable,hI=Xf(function(){return arguments}())?Xf:function(i){return gr(i)&&uI.call(i,"callee")&&!fI.call(i,"callee")},mo=hI;function pI(){return!1}var Eg=pI;var Rg=typeof exports=="object"&&exports&&!exports.nodeType&&exports,zg=Rg&&typeof module=="object"&&module&&!module.nodeType&&module,dI=zg&&zg.exports===Rg,Fg=dI?qt.Buffer:void 0,mI=Fg?Fg.isBuffer:void 0,gI=mI||Eg,Qo=gI;var yI="[object Arguments]",xI="[object Array]",vI="[object Boolean]",bI="[object Date]",SI="[object Error]",wI="[object Function]",NI="[object Map]",CI="[object Number]",LI="[object Object]",_I="[object RegExp]",TI="[object Set]",II="[object String]",MI="[object WeakMap]",AI="[object ArrayBuffer]",OI="[object DataView]",PI="[object Float32Array]",DI="[object Float64Array]",BI="[object Int8Array]",GI="[object Int16Array]",jI="[object Int32Array]",EI="[object Uint8Array]",RI="[object Uint8ClampedArray]",zI="[object Uint16Array]",FI="[object Uint32Array]",Tt={};Tt[PI]=Tt[DI]=Tt[BI]=Tt[GI]=Tt[jI]=Tt[EI]=Tt[RI]=Tt[zI]=Tt[FI]=!0;Tt[yI]=Tt[xI]=Tt[AI]=Tt[vI]=Tt[OI]=Tt[bI]=Tt[SI]=Tt[wI]=Tt[NI]=Tt[CI]=Tt[LI]=Tt[_I]=Tt[TI]=Tt[II]=Tt[MI]=!1;function VI(i){return gr(i)&&Xl(i.length)&&!!Tt[Xr(i)]}var Vg=VI;function UI(i){return function(e){return i(e)}}var es=UI;var Ug=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ia=Ug&&typeof module=="object"&&module&&!module.nodeType&&module,kI=ia&&ia.exports===Ug,Zf=kI&&Fl.process,HI=function(){try{var i=ia&&ia.require&&ia.require("util").types;return i||Zf&&Zf.binding&&Zf.binding("util")}catch(e){}}(),hi=HI;var kg=hi&&hi.isTypedArray,WI=kg?es(kg):Vg,Zl=WI;var qI=Object.prototype,$I=qI.hasOwnProperty;function JI(i,e){var t=cr(i),r=!t&&mo(i),n=!t&&!r&&Qo(i),s=!t&&!r&&!n&&Zl(i),l=t||r||n||s,c=l?Gg(i.length,String):[],f=c.length;for(var h in i)(e||$I.call(i,h))&&!(l&&(h=="length"||n&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||$l(h,f)))&&c.push(h);return c}var Yl=JI;function KI(i,e){return function(t){return i(e(t))}}var Ql=KI;var XI=Ql(Object.keys,Object),Hg=XI;var ZI=Object.prototype,YI=ZI.hasOwnProperty;function QI(i){if(!Yo(i))return Hg(i);var e=[];for(var t in Object(i))YI.call(i,t)&&t!="constructor"&&e.push(t);return e}var Wg=QI;function eM(i){return Gi(i)?Yl(i):Wg(i)}var ts=eM;function tM(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e}var qg=tM;var rM=Object.prototype,nM=rM.hasOwnProperty;function iM(i){if(!yr(i))return qg(i);var e=Yo(i),t=[];for(var r in i)r=="constructor"&&(e||!nM.call(i,r))||t.push(r);return t}var $g=iM;function oM(i){return Gi(i)?Yl(i,!0):$g(i)}var Un=oM;var sM=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,aM=/^\w*$/;function lM(i,e){if(cr(i))return!1;var t=typeof i;return t=="number"||t=="symbol"||t=="boolean"||i==null||Jo(i)?!0:aM.test(i)||!sM.test(i)||e!=null&&i in Object(e)}var Jg=lM;var cM=Gr(Object,"create"),pi=cM;function uM(){this.__data__=pi?pi(null):{},this.size=0}var Kg=uM;function fM(i){var e=this.has(i)&&delete this.__data__[i];return this.size-=e?1:0,e}var Xg=fM;var hM="__lodash_hash_undefined__",pM=Object.prototype,dM=pM.hasOwnProperty;function mM(i){var e=this.__data__;if(pi){var t=e[i];return t===hM?void 0:t}return dM.call(e,i)?e[i]:void 0}var Zg=mM;var gM=Object.prototype,yM=gM.hasOwnProperty;function xM(i){var e=this.__data__;return pi?e[i]!==void 0:yM.call(e,i)}var Yg=xM;var vM="__lodash_hash_undefined__";function bM(i,e){var t=this.__data__;return this.size+=this.has(i)?0:1,t[i]=pi&&e===void 0?vM:e,this}var Qg=bM;function rs(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}rs.prototype.clear=Kg;rs.prototype.delete=Xg;rs.prototype.get=Zg;rs.prototype.has=Yg;rs.prototype.set=Qg;var Yf=rs;function SM(){this.__data__=[],this.size=0}var ey=SM;function wM(i,e){for(var t=i.length;t--;)if(Bi(i[t][0],e))return t;return-1}var ji=wM;var NM=Array.prototype,CM=NM.splice;function LM(i){var e=this.__data__,t=ji(e,i);if(t<0)return!1;var r=e.length-1;return t==r?e.pop():CM.call(e,t,1),--this.size,!0}var ty=LM;function _M(i){var e=this.__data__,t=ji(e,i);return t<0?void 0:e[t][1]}var ry=_M;function TM(i){return ji(this.__data__,i)>-1}var ny=TM;function IM(i,e){var t=this.__data__,r=ji(t,i);return r<0?(++this.size,t.push([i,e])):t[r][1]=e,this}var iy=IM;function ns(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}ns.prototype.clear=ey;ns.prototype.delete=ty;ns.prototype.get=ry;ns.prototype.has=ny;ns.prototype.set=iy;var Ei=ns;var MM=Gr(qt,"Map"),Ri=MM;function AM(){this.size=0,this.__data__={hash:new Yf,map:new(Ri||Ei),string:new Yf}}var oy=AM;function OM(i){var e=typeof i;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?i!=="__proto__":i===null}var sy=OM;function PM(i,e){var t=i.__data__;return sy(e)?t[typeof e=="string"?"string":"hash"]:t.map}var zi=PM;function DM(i){var e=zi(this,i).delete(i);return this.size-=e?1:0,e}var ay=DM;function BM(i){return zi(this,i).get(i)}var ly=BM;function GM(i){return zi(this,i).has(i)}var cy=GM;function jM(i,e){var t=zi(this,i),r=t.size;return t.set(i,e),this.size+=t.size==r?0:1,this}var uy=jM;function is(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}is.prototype.clear=oy;is.prototype.delete=ay;is.prototype.get=ly;is.prototype.has=cy;is.prototype.set=uy;var oa=is;var EM="Expected a function";function Qf(i,e){if(typeof i!="function"||e!=null&&typeof e!="function")throw new TypeError(EM);var t=function(){var r=arguments,n=e?e.apply(this,r):r[0],s=t.cache;if(s.has(n))return s.get(n);var l=i.apply(this,r);return t.cache=s.set(n,l)||s,l};return t.cache=new(Qf.Cache||oa),t}Qf.Cache=oa;var fy=Qf;var RM=500;function zM(i){var e=fy(i,function(r){return t.size===RM&&t.clear(),r}),t=e.cache;return e}var hy=zM;var FM=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,VM=/\\(\\)?/g,UM=hy(function(i){var e=[];return i.charCodeAt(0)===46&&e.push(""),i.replace(FM,function(t,r,n,s){e.push(n?s.replace(VM,"$1"):r||t)}),e}),py=UM;function kM(i){return i==null?"":vg(i)}var dy=kM;function HM(i,e){return cr(i)?i:Jg(i,e)?[i]:py(dy(i))}var os=HM;var WM=1/0;function qM(i){if(typeof i=="string"||Jo(i))return i;var e=i+"";return e=="0"&&1/i==-WM?"-0":e}var ec=qM;function $M(i,e){e=os(e,i);for(var t=0,r=e.length;i!=null&&t<r;)i=i[ec(e[t++])];return t&&t==r?i:void 0}var my=$M;function JM(i,e){for(var t=-1,r=e.length,n=i.length;++t<r;)i[n+t]=e[t];return i}var ss=JM;var gy=Nr?Nr.isConcatSpreadable:void 0;function KM(i){return cr(i)||mo(i)||!!(gy&&i&&i[gy])}var yy=KM;function xy(i,e,t,r,n){var s=-1,l=i.length;for(t||(t=yy),n||(n=[]);++s<l;){var c=i[s];e>0&&t(c)?e>1?xy(c,e-1,t,r,n):ss(n,c):r||(n[n.length]=c)}return n}var vy=xy;function XM(i){var e=i==null?0:i.length;return e?vy(i,1):[]}var by=XM;function ZM(i){return ql(Kl(i,void 0,by),i+"")}var Sy=ZM;var YM=Ql(Object.getPrototypeOf,Object),as=YM;var QM="[object Object]",eA=Function.prototype,tA=Object.prototype,wy=eA.toString,rA=tA.hasOwnProperty,nA=wy.call(Object);function iA(i){if(!gr(i)||Xr(i)!=QM)return!1;var e=as(i);if(e===null)return!0;var t=rA.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&wy.call(t)==nA}var tc=iA;function oA(i,e,t){var r=-1,n=i.length;e<0&&(e=-e>n?0:n+e),t=t>n?n:t,t<0&&(t+=n),n=e>t?0:t-e>>>0,e>>>=0;for(var s=Array(n);++r<n;)s[r]=i[r+e];return s}var Ny=oA;function sA(){this.__data__=new Ei,this.size=0}var Cy=sA;function aA(i){var e=this.__data__,t=e.delete(i);return this.size=e.size,t}var Ly=aA;function lA(i){return this.__data__.get(i)}var _y=lA;function cA(i){return this.__data__.has(i)}var Ty=cA;var uA=200;function fA(i,e){var t=this.__data__;if(t instanceof Ei){var r=t.__data__;if(!Ri||r.length<uA-1)return r.push([i,e]),this.size=++t.size,this;t=this.__data__=new oa(r)}return t.set(i,e),this.size=t.size,this}var Iy=fA;function ls(i){var e=this.__data__=new Ei(i);this.size=e.size}ls.prototype.clear=Cy;ls.prototype.delete=Ly;ls.prototype.get=_y;ls.prototype.has=Ty;ls.prototype.set=Iy;var rc=ls;function hA(i,e){return i&&pn(e,ts(e),i)}var My=hA;function pA(i,e){return i&&pn(e,Un(e),i)}var Ay=pA;var Oy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Py=Oy&&typeof module=="object"&&module&&!module.nodeType&&module,dA=Py&&Py.exports===Oy,Dy=dA?qt.Buffer:void 0,By=Dy?Dy.allocUnsafe:void 0;function mA(i,e){if(e)return i.slice();var t=i.length,r=By?By(t):new i.constructor(t);return i.copy(r),r}var nc=mA;function gA(i,e){for(var t=-1,r=i==null?0:i.length,n=0,s=[];++t<r;){var l=i[t];e(l,t,i)&&(s[n++]=l)}return s}var Gy=gA;function yA(){return[]}var ic=yA;var xA=Object.prototype,vA=xA.propertyIsEnumerable,jy=Object.getOwnPropertySymbols,bA=jy?function(i){return i==null?[]:(i=Object(i),Gy(jy(i),function(e){return vA.call(i,e)}))}:ic,cs=bA;function SA(i,e){return pn(i,cs(i),e)}var Ey=SA;var wA=Object.getOwnPropertySymbols,NA=wA?function(i){for(var e=[];i;)ss(e,cs(i)),i=as(i);return e}:ic,oc=NA;function CA(i,e){return pn(i,oc(i),e)}var Ry=CA;function LA(i,e,t){var r=e(i);return cr(i)?r:ss(r,t(i))}var sc=LA;function _A(i){return sc(i,ts,cs)}var zy=_A;function TA(i){return sc(i,Un,oc)}var ac=TA;var IA=Gr(qt,"DataView"),lc=IA;var MA=Gr(qt,"Promise"),cc=MA;var AA=Gr(qt,"Set"),uc=AA;var Fy="[object Map]",OA="[object Object]",Vy="[object Promise]",Uy="[object Set]",ky="[object WeakMap]",Hy="[object DataView]",PA=fi(lc),DA=fi(Ri),BA=fi(cc),GA=fi(uc),jA=fi(Hl),go=Xr;(lc&&go(new lc(new ArrayBuffer(1)))!=Hy||Ri&&go(new Ri)!=Fy||cc&&go(cc.resolve())!=Vy||uc&&go(new uc)!=Uy||Hl&&go(new Hl)!=ky)&&(go=function(i){var e=Xr(i),t=e==OA?i.constructor:void 0,r=t?fi(t):"";if(r)switch(r){case PA:return Hy;case DA:return Fy;case BA:return Vy;case GA:return Uy;case jA:return ky}return e});var us=go;var EA=Object.prototype,RA=EA.hasOwnProperty;function zA(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&RA.call(i,"index")&&(t.index=i.index,t.input=i.input),t}var Wy=zA;var FA=qt.Uint8Array,eh=FA;function VA(i){var e=new i.constructor(i.byteLength);return new eh(e).set(new eh(i)),e}var fs=VA;function UA(i,e){var t=e?fs(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength)}var qy=UA;var kA=/\w*$/;function HA(i){var e=new i.constructor(i.source,kA.exec(i));return e.lastIndex=i.lastIndex,e}var $y=HA;var Jy=Nr?Nr.prototype:void 0,Ky=Jy?Jy.valueOf:void 0;function WA(i){return Ky?Object(Ky.call(i)):{}}var Xy=WA;function qA(i,e){var t=e?fs(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length)}var fc=qA;var $A="[object Boolean]",JA="[object Date]",KA="[object Map]",XA="[object Number]",ZA="[object RegExp]",YA="[object Set]",QA="[object String]",eO="[object Symbol]",tO="[object ArrayBuffer]",rO="[object DataView]",nO="[object Float32Array]",iO="[object Float64Array]",oO="[object Int8Array]",sO="[object Int16Array]",aO="[object Int32Array]",lO="[object Uint8Array]",cO="[object Uint8ClampedArray]",uO="[object Uint16Array]",fO="[object Uint32Array]";function hO(i,e,t){var r=i.constructor;switch(e){case tO:return fs(i);case $A:case JA:return new r(+i);case rO:return qy(i,t);case nO:case iO:case oO:case sO:case aO:case lO:case cO:case uO:case fO:return fc(i,t);case KA:return new r;case XA:case QA:return new r(i);case ZA:return $y(i);case YA:return new r;case eO:return Xy(i)}}var Zy=hO;function pO(i){return typeof i.constructor=="function"&&!Yo(i)?Lg(as(i)):{}}var hc=pO;var dO="[object Map]";function mO(i){return gr(i)&&us(i)==dO}var Yy=mO;var Qy=hi&&hi.isMap,gO=Qy?es(Qy):Yy,ex=gO;var yO="[object Set]";function xO(i){return gr(i)&&us(i)==yO}var tx=xO;var rx=hi&&hi.isSet,vO=rx?es(rx):tx,nx=vO;var bO=1,SO=2,wO=4,ix="[object Arguments]",NO="[object Array]",CO="[object Boolean]",LO="[object Date]",_O="[object Error]",ox="[object Function]",TO="[object GeneratorFunction]",IO="[object Map]",MO="[object Number]",sx="[object Object]",AO="[object RegExp]",OO="[object Set]",PO="[object String]",DO="[object Symbol]",BO="[object WeakMap]",GO="[object ArrayBuffer]",jO="[object DataView]",EO="[object Float32Array]",RO="[object Float64Array]",zO="[object Int8Array]",FO="[object Int16Array]",VO="[object Int32Array]",UO="[object Uint8Array]",kO="[object Uint8ClampedArray]",HO="[object Uint16Array]",WO="[object Uint32Array]",Nt={};Nt[ix]=Nt[NO]=Nt[GO]=Nt[jO]=Nt[CO]=Nt[LO]=Nt[EO]=Nt[RO]=Nt[zO]=Nt[FO]=Nt[VO]=Nt[IO]=Nt[MO]=Nt[sx]=Nt[AO]=Nt[OO]=Nt[PO]=Nt[DO]=Nt[UO]=Nt[kO]=Nt[HO]=Nt[WO]=!0;Nt[_O]=Nt[ox]=Nt[BO]=!1;function pc(i,e,t,r,n,s){var l,c=e&bO,f=e&SO,h=e&wO;if(t&&(l=n?t(i,r,n,s):t(i)),l!==void 0)return l;if(!yr(i))return i;var d=cr(i);if(d){if(l=Wy(i),!c)return Wl(i,l)}else{var x=us(i),g=x==ox||x==TO;if(Qo(i))return nc(i,c);if(x==sx||x==ix||g&&!n){if(l=f||g?{}:hc(i),!c)return f?Ry(i,Ay(l,i)):Ey(i,My(l,i))}else{if(!Nt[x])return n?i:{};l=Zy(i,x,c)}}s||(s=new rc);var w=s.get(i);if(w)return w;s.set(i,l),nx(i)?i.forEach(function(C){l.add(pc(C,e,t,C,i,s))}):ex(i)&&i.forEach(function(C,G){l.set(G,pc(C,e,t,G,i,s))});var S=h?f?ac:zy:f?Un:ts,D=d?void 0:S(i);return Ag(D||i,function(C,G){D&&(G=C,C=i[G]),Jl(l,G,pc(C,e,t,G,i,s))}),l}var dc=pc;var qO=1,$O=4;function JO(i){return dc(i,qO|$O)}var sa=JO;function KO(i){return function(e,t,r){for(var n=-1,s=Object(e),l=r(e),c=l.length;c--;){var f=l[i?c:++n];if(t(s[f],f,s)===!1)break}return e}}var ax=KO;var XO=ax(),lx=XO;function ZO(i,e,t){(t!==void 0&&!Bi(i[e],t)||t===void 0&&!(e in i))&&Zo(i,e,t)}var aa=ZO;function YO(i){return gr(i)&&Gi(i)}var cx=YO;function QO(i,e){if(!(e==="constructor"&&typeof i[e]=="function")&&e!="__proto__")return i[e]}var la=QO;function eP(i){return pn(i,Un(i))}var ux=eP;function tP(i,e,t,r,n,s,l){var c=la(i,t),f=la(e,t),h=l.get(f);if(h){aa(i,t,h);return}var d=s?s(c,f,t+"",i,e,l):void 0,x=d===void 0;if(x){var g=cr(f),w=!g&&Qo(f),S=!g&&!w&&Zl(f);d=f,g||w||S?cr(c)?d=c:cx(c)?d=Wl(c):w?(x=!1,d=nc(f,!0)):S?(x=!1,d=fc(f,!0)):d=[]:tc(f)||mo(f)?(d=c,mo(c)?d=ux(c):(!yr(c)||Ko(c))&&(d=hc(f))):x=!1}x&&(l.set(f,d),n(d,f,r,s,l),l.delete(f)),aa(i,t,d)}var fx=tP;function hx(i,e,t,r,n){i!==e&&lx(e,function(s,l){if(n||(n=new rc),yr(s))fx(i,e,l,t,hx,r,n);else{var c=r?r(la(i,l),s,l+"",i,e,n):void 0;c===void 0&&(c=s),aa(i,l,c)}},Un)}var px=hx;function rP(i){var e=i==null?0:i.length;return e?i[e-1]:void 0}var dx=rP;function nP(i,e){return e.length<2?i:my(i,Ny(e,0,-1))}var mx=nP;var iP=Bg(function(i,e,t){px(i,e,t)}),yo=iP;function oP(i,e){return e=os(e,i),i=mx(i,e),i==null||delete i[ec(dx(e))]}var gx=oP;function sP(i){return tc(i)?void 0:i}var yx=sP;var aP=1,lP=2,cP=4,uP=Sy(function(i,e){var t={};if(i==null)return t;var r=!1;e=Vl(e,function(s){return s=os(s,i),r||(r=s.length>1),s}),pn(i,ac(i),t),r&&(t=dc(t,aP|lP|cP,yx));for(var n=e.length;n--;)gx(t,e[n]);return t}),hs=uP;var ps;(function(t){t.all=["PerspectiveCamera","OrthographicCamera"];function e(r){return t.all.includes(r)}t.is=e})(ps||(ps={}));var xo;(function(n){n.DefaultUp=[0,1,0],n.DefaultTargetOffset=1e3,n.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:n.DefaultUp,isUpVectorFlipped:!1,targetOffset:n.DefaultTargetOffset};function r(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}n.getZoom=r})(xo||(xo={}));var ds;(function(r){r.x="x",r.y="y",r.z="z"})(ds||(ds={}));var xx;(function(s){s.Top="top",s.Right="right",s.Bottom="bottom",s.Left="left",s.Center="center"})(xx||(xx={}));var vx;(function(t){function i(r,n){return r[0]===n[0]&&r[1]===n[1]}t.isEqual=i;function e(r,n,s){return[r[0]+(n[0]-r[0])*s,r[1]+(n[1]-r[1])*s]}t.lerp=e})(vx||(vx={}));var ms;(function(n){function i(s,l){return s[0]===l[0]&&s[1]===l[1]&&s[2]===l[2]}n.isEqual=i;function e(s,l){return[s[0]+l[0],s[1]+l[1],s[2]+l[2]]}n.add=e;function t(s,l){return[s[0]-l[0],s[1]-l[1],s[2]-l[2]]}n.sub=t;function r(s,l,c){return[s[0]+(l[0]-s[0])*c,s[1]+(l[1]-s[1])*c,s[2]+(l[2]-s[2])*c]}n.lerp=r})(ms||(ms={}));var bx;(function(t){function i(r,n){return r[0]===n[0]&&r[1]===n[1]&&r[2]===n[2]&&r[3]===n[3]}t.isEqual=i;function e(r,n,s){return[r[0]+(n[0]-r[0])*s,r[1]+(n[1]-r[1])*s,r[2]+(n[2]-r[2])*s,r[3]+(n[3]-r[3])*s]}t.lerp=e})(bx||(bx={}));var Fi;(function(s){s.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function e(l,c){for(let f=0;f<16;f++)if(l[f]!==c[f])return!1;return!0}s.isEqual=e;function t(l){return l!=null?l:s.identity}s.simplify=t;function r(l,c){let f=c.slice(0);for(var h=0,d=c.length;h<d;h+=3){let x=1/(l[3]*c[h]+l[7]*c[h+1]+l[11]*c[h+2]+l[15]);f[h]=(l[0]*c[h]+l[4]*c[h+1]+l[8]*c[h+2]+l[12])*x,f[h+1]=(l[1]*c[h]+l[5]*c[h+1]+l[9]*c[h+2]+l[13])*x,f[h+2]=(l[2]*c[h]+l[6]*c[h+1]+l[10]*c[h+2]+l[14])*x}return f}s.applyMatrix4=r;function n(l,c){let f=c.slice(0);for(var h=0,d=c.length;h<d;h+=3)f[h]=l[0]*c[h]+l[4]*c[h+1]+l[8]*c[h+2],f[h+1]=l[1]*c[h]+l[5]*c[h+1]+l[9]*c[h+2],f[h+2]=l[2]*c[h]+l[6]*c[h+1]+l[10]*c[h+2];return f}s.applyMatrix3Components=n})(Fi||(Fi={}));var Zr;(function(f){f.white={r:1,g:1,b:1},f.red={r:1,g:0,b:0},f.black={r:0,g:0,b:0};function r(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}f.toRgb255a1=r;function n(h){return{r:h.r,g:h.g,b:h.b}}f.clone=n;function s(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}f.fromHex=s;function l(h,d){return h.r===d.r&&h.g===d.g&&h.b===d.b}f.equals=l;function c(h,d,x){return{r:h.r+(d.r-h.r)*x,g:h.g+(d.g-h.g)*x,b:h.b+(d.b-h.b)*x}}f.lerp=c})(Zr||(Zr={}));var kn;(function(l){l.white=fe(U({},Zr.white),{a:1});function e(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}l.from0to1=e;function t(c,f){return fe(U({},Zr.fromHex(c)),{a:f})}l.fromHexAndA=t;function r(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:c.a}}l.toRgb255a1=r;function n(c,f){return Zr.equals(c,f)&&c.a===f.a}l.equals=n;function s(c,f,h){return{r:c.r+(f.r-c.r)*h,g:c.g+(f.g-c.g)*h,b:c.b+(f.b-c.b)*h,a:c.a+(f.a-c.a)*h}}l.lerp=s})(kn||(kn={}));var mc;(function(e){e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]}})(mc||(mc={}));var Sx;(function(P){P[P.SKIP=0]="SKIP",P[P.ADD=1]="ADD",P[P.ALPHA=2]="ALPHA",P[P.AVERAGE=3]="AVERAGE",P[P.COLOR_BURN=4]="COLOR_BURN",P[P.COLOR_DODGE=5]="COLOR_DODGE",P[P.DARKEN=6]="DARKEN",P[P.DIFFERENCE=7]="DIFFERENCE",P[P.EXCLUSION=8]="EXCLUSION",P[P.LIGHTEN=9]="LIGHTEN",P[P.MULTIPLY=10]="MULTIPLY",P[P.DIVIDE=11]="DIVIDE",P[P.NEGATION=12]="NEGATION",P[P.NORMAL=13]="NORMAL",P[P.OVERLAY=14]="OVERLAY",P[P.REFLECT=15]="REFLECT",P[P.SCREEN=16]="SCREEN",P[P.SOFT_LIGHT=17]="SOFT_LIGHT",P[P.SUBTRACT=18]="SUBTRACT"})(Sx||(Sx={}));var wx;(function(c){c[c.LINEAR=0]="LINEAR",c[c.EASE=1]="EASE",c[c.EASE_IN=2]="EASE_IN",c[c.EASE_OUT=3]="EASE_OUT",c[c.EASE_IN_OUT=4]="EASE_IN_OUT",c[c.CUBIC=5]="CUBIC",c[c.SPRING=6]="SPRING"})(wx||(wx={}));var Nx;(function(e){e.defaultData={mass:1,stiffness:80,damping:10,velocity:0}})(Nx||(Nx={}));var Cx;(function(e){e.defaultData={control1:[.5,.05],control2:[.1,.3]}})(Cx||(Cx={}));var gc;(function(e){function i(t,r=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:ds.y,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[0,0,0],rotation:[0,0,0],position:[t[0]+t[0]*r,0,0]},grid:{count:[2,2,2],size:t.map(n=>n*(1+r)),useCenter:!0}}}e.defaultData=i})(gc||(gc={}));var Hn;(function(e){e[e.Update=0]="Update"})(Hn||(Hn={}));var dn;(function(r){r[r.Add=1]="Add",r[r.Delete=2]="Delete",r[r.Unlink=3]="Unlink"})(dn||(dn={}));var Yr;(function(r){r[r.Add=4]="Add",r[r.Delete=5]="Delete",r[r.Move=6]="Move"})(Yr||(Yr={}));var jr;(function(r){r[r.Add=7]="Add",r[r.Delete=8]="Delete",r[r.Move=9]="Move"})(jr||(jr={}));var An=class{modifyById(e,t){let r=this;if(r[e]===void 0)throw new Error("not expected");{let s=fe(U({},r),{[e]:t});return Object.setPrototypeOf(s,An.prototype),s}}add(e,t){var n;let r=this.runOp({type:dn.Add,id:e,data:t});return(n=r==null?void 0:r.data)!=null?n:this}runOp(e){let t=this;if(e.type===dn.Add){let r=t[e.id],n;r===void 0?n={type:dn.Delete,id:e.id}:n={type:dn.Add,id:e.id,data:r};let{id:s,data:l}=e,c=fe(U({},t),{[s]:l});return Object.setPrototypeOf(c,An.prototype),{data:c,actual:e,reverse:n}}else if(e.type===dn.Delete){let{id:r}=e,n=t[r];if(n===void 0)return null;{let s=U({},t);return Object.setPrototypeOf(s,An.prototype),delete s[r],{data:s,actual:e,reverse:{type:dn.Add,id:r,data:n}}}}throw new Error("illegal arg")}};function ca(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let e=Object.getOwnPropertyNames(i);for(let t of e){let r=i[t];r&&typeof r=="object"&&ca(r)}return Object.freeze(i)}function Lx(i,e){let t=0;for(;t<i.length&&t<e.length;){if(i[t]<e[t])return-1;if(i[t]>e[t])return 1;t+=1}return t!==e.length?-1:t!==i.length?1:0}var th=class extends Error{};function Wn(i,e,t){if(i===void 0?e===void 0?(i=0,e=10):i=e-10:e===void 0&&(e=i+10),i>e){let s=i;i=e,e=s}let r=[],n=1/(t+1);for(let s=0;s<t;s++){let l=i+(e-i)*(s+.75+Math.random()*.5)*n;r.push(l)}return r}function _x(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function Tx(){return typeof process!="undefined"}function Ix(i,e){for(let t of i)e(t.id,t.data),Ix(t.children,e)}function Mx(i,e){e(i.id,i.data);for(let t of i.children)Mx(t,e)}var On=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,On.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ca(this[e]),e++}fillCaches0(e,t){var r;if((r=this.objCaches)==null?void 0:r.has(e.id))throw new Error("duplicated item");this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let n of e.children)this.fillCaches0(n,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)]}isDescendantOf(e,t){for(;e;){let r=this.parent(e);if(r===t)return!0;e=r}return!1}data(e){var t;return(t=this.get(e))==null?void 0:t.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){var t;return e===null?this:(t=this.get(e))==null?void 0:t.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let r=this.get(e);r&&Mx(r,t)}}traverse(e){Ix(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let n=this.parent(e),s=this.childrenArray(n),l=s.findIndex(h=>h.id===e);if(l<0)throw new Error("not expected");let c=s[l];return s=[...s],s[l]=fe(U({},c),{data:t}),this.modifyArrayBy(n,s)}}modifyArrayBy(e,t){let r=e,n=t;for(;r!==null;){let l=n,c=r;if(r=this.parent(r),r===void 0)throw new Error;n=this.childrenArray(r);let f=n.findIndex(h=>h.id===c);if(f<0)throw new Error;n=[...n],n[f]=fe(U({},n[f]),{children:l})}Object.setPrototypeOf(n,On.prototype);let s=n;return s.fillCaches(),s}runOp(e){switch(e.type){case jr.Add:return this.addOp(e);case jr.Delete:return this.deleteOp(e);case jr.Move:return this.moveOp(e)}}addOp(e){let{parent:t,fi:r,id:n,data:s,children:l}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.get(n)!==void 0)return null;{let c=t,f=this.childrenArray(c),h={fi:r,id:n,data:s,children:l};return f=[...f,h],f.sort((x,g)=>x.fi-g.fi),e.localIndex=f.indexOf(h),{data:this.modifyArrayBy(c,f),actual:e,reverse:{type:jr.Delete,id:n}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let r=this.parent(t);if(r===void 0)return null;let n=this.childrenArray(r),s=n.findIndex(f=>f.id===t);e.localIndex=s,n=[...n];let l=n.splice(s,1)[0];return{data:this.modifyArrayBy(r,n),actual:e,reverse:fe(U({type:jr.Add},l),{parent:r})}}}moveOp(e){let{parent:t,fi:r,id:n}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:jr.Delete,id:n});if(t!==null){let g=t;for(;g!==null;){if(g===void 0)throw new Error;if(g===n)throw new th("cyclic tree");g=this.parent(g)}}let s=this.parent(n);if(s===void 0)return null;let l=s,c=this.childrenArray(s),f=c.findIndex(g=>g.id===n);c=[...c];let h=c.splice(f,1)[0],d=this.modifyArrayBy(s,c);s=t,c=d.childrenArray(s);let x=h.fi;return h=fe(U({},h),{fi:r}),c=[...c,h],c.sort((g,w)=>g.fi-w.fi),e.localIndex=c.indexOf(h),d=d.modifyArrayBy(s,c),{data:d,actual:e,reverse:{type:jr.Move,parent:l,fi:x,id:n}}}previous(e,t){if(t===null){let n=this.childrenArray(e);return n.length===0?null:n[n.length-1].id}let r=null;for(let n of this.childrenArray(e)){if(n.id===t)return r;r=n.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let r=this.childrenArray(t),n=r.findIndex(s=>s.id===e)+1;if(n<r.length)return r[n].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let r=this.childrenArray(t),n=r.findIndex(s=>s.id===e)-1;return n>=0?this.traverseSortPrevious(r[n].id):t}}getAllSorted(e){let t=[];for(let r of e){let n=this.getWithSortKey(r.id);n!==void 0&&t.push(U(U({},r),n))}t.sort((r,n)=>Lx(r.sortKey,n.sortKey));for(let r of t)delete r.sortKey;return t}getWithSortKey(e){var t=e;let r=[],n=this.get(t),s=n;if(n!==void 0){for(;t;)r.splice(0,0,n.fi),t=this.parent(t),t!==null&&(n=this.get(t));return fe(U({},s),{sortKey:r})}}insertBeforeHelper(e,t,r){return this.insertAfterHelper(e,this.previous(e,t),r)}insertAfterHelper(e,t,r){let n=this.childrenArray(e);if(t===null){if(n.length===0)return Wn(0,r,r);{let s=n[0].fi;return Wn(s-r,s,r)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let l=n.find(c=>c.fi>s.fi);if(l===void 0){let c=n[n.length-1].fi;return Wn(c,c+r,r)}else return Wn(s.fi,l.fi,r)}}};var yc;(function(e){function i(t,r){if(Array.isArray(t)){let n=r.props,s={},l=[...t],c=!1;if(n)for(let f of Object.keys(n)){let h=parseInt(f);if(isNaN(h))throw new Error("wrong index");s[f]=l[h],l[h]=n[f],c=!0}return c?{data:l,actual:r,reverse:{type:Hn.Update,props:s}}:null}else{let n=r.props,s={},l=U({},t),c=!1;if(n)for(let f of Object.keys(n)){s[f]=l[f];let h=n[f];h===void 0?delete l[f]:l[f]=h,c=!0}return c?{data:l,actual:r,reverse:{type:Hn.Update,props:s}}:null}}e.runOp=i})(yc||(yc={}));var jt=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,jt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ca(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){var t;return(t=this.get(e))==null?void 0:t.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let n=this,s=n.findIndex(f=>f.id===e);if(s<0)throw new Error("not expected");let l=n[s];return n=[...n],n[s]=fe(U({},l),{data:t}),this.modifyArrayBy(n)}}modifyArrayBy(e){Object.setPrototypeOf(e,jt.prototype);let t=e;return Tx()||t.fillCaches(),t}runOp(e){switch(e.type){case Yr.Add:return this.addOp(e);case Yr.Delete:return this.deleteOp(e);case Yr.Move:return this.moveOp(e)}}addOp(e){let{fi:t,id:r,data:n}=e,s=this,l={fi:t,id:r,data:n};return s=[...s,l],s.sort((f,h)=>f.fi-h.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:Yr.Delete,id:r}}}deleteOp(e){let{id:t}=e,r=this,n=r.findIndex(c=>c.id===t);if(n===-1)return null;e.localIndex=n,r=[...r];let s=r.splice(n,1)[0];return{data:this.modifyArrayBy(r),actual:e,reverse:U({type:Yr.Add},s)}}moveOp(e){let{fi:t,id:r}=e,n=this;n=[...n];let s=n.findIndex(h=>h.id===r);if(s===-1)return null;let l=n[s].fi,c=fe(U({},n[s]),{fi:t});return n[s]=c,n.sort((h,d)=>h.fi-d.fi),e.localIndex=n.indexOf(c),{data:this.modifyArrayBy(n),actual:e,reverse:{type:Yr.Move,fi:l,id:r}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let r of this){if(r.id===e)return t;t=r.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let r=this;if(e===null){if(r.length===0)return Wn(0,t,t);{let n=r[0].fi;return Wn(n-t,n,t)}}else{let n=this.get(e);if(n===void 0)throw new Error("illegal args");let s=r.find(l=>l.fi>n.fi);if(s===void 0){let l=r[r.length-1].fi;return Wn(l,l+t,t)}else return Wn(n.fi,s.fi,t)}}};var Ax=Symbol(),xc=Symbol(),ua=class{reportOp(e,t){let r=this;if(t===null)return;r._current=t.data;let n=[];for(;!(r instanceof nh);){let s=r._path,l=r._current;if(s!==""&&n.splice(0,0,s),r=r._parent,r===null)return;r.update(s,l)}r.push(n,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let r=t[xc];r&&r(),delete this._children[e]}}}},Ox=class extends ua{constructor(e,t,r){super();this._parent=e,this._path=t,this._current=r}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current=fe(U({},this._current),{[e]:t})}runOp(e){this.reportOp(e,yc.runOp(this._current,e))}},Px=class extends ua{constructor(e,t,r){super();this._parent=e,this._path=t,this._current=r}update(e,t){this._current=fe(U({},this._current),{[e]:t}),Object.setPrototypeOf(this._current,An.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},Dx={get(i,e){if(e===xc)return()=>{i._parent=null};if(e===Ax)return i._current;let{_current:t,_children:r}=i;if(e==="push"&&Array.isArray(t))throw new Error("not supported to expand array");let n=r===void 0?void 0:r[e];if(n!==void 0)return n;let s=t[e],l=vc(i,e,s);return l!==s?(r===void 0&&(r={},i._children=r),r[e]=l,l):s},has(i,e){return e in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,e){let t=i._current,r=Reflect.getOwnPropertyDescriptor(t,e);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:t[e]}}},fP=fe(U({},Dx),{set(i,e,t){var n;let r={type:Hn.Update,props:{[e]:(n=sh(t))!=null?n:t}};return i.deleteChildren(e),i.runOp(r),!0},deleteProperty(i,e){let t={type:Hn.Update,props:{[e]:void 0}};return i.deleteChildren(e),i.runOp(t),!0}}),hP=fe(U({},Dx),{set(i,e,t){return t===void 0?this.deleteProperty(i,e):(i.deleteChildren(e),i.runOp({type:dn.Add,id:e,data:t})),!0},deleteProperty(i,e){return i.runOp({type:dn.Delete,id:e}),!0}}),fa=class extends ua{constructor(e,t,r){super();this._children={},this._parent=e,this._path=t,this._current=r,this[xc]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,r)=>{e(t,this.data(t))})}data(e){var c;let{_current:t,_children:r}=this,n=r===void 0?void 0:r[e];if(n!==void 0)return n;let s=(c=t.get(e))==null?void 0:c.data,l=vc(this,e,s);return l!==s?(r===void 0&&(r={},this._children=r),r[e]=l,l):s}add(e,t,r,n,s){this.runOp({type:jr.Add,parent:e,fi:t,id:r,data:n,children:s})}move(e,t,r){this.runOp({type:jr.Move,parent:e,fi:t,id:r})}insertAfter(e,t,r){let n=this._current.insertAfterHelper(e,t,r.length);for(let s=0;s<r.length;s++){let l=r[s];this.add(e,n[s],l.id,l.data,l.children)}}insertBefore(e,t,r){let n=this._current.insertBeforeHelper(e,t,r.length);for(let s=0;s<r.length;s++){let l=r[s];this.add(e,n[s],l.id,l.data,l.children)}}moveAfter(e,t,r){let n=this._current.insertAfterHelper(e,t,r.length);for(let s=0;s<r.length;s++){let l=r[s];this.move(e,n[s],l)}}moveBefore(e,t,r){let n=this._current.insertBeforeHelper(e,t,r.length);for(let s=0;s<r.length;s++){let l=r[s];this.move(e,n[s],l)}}delete(e){this.deleteChildren(e),this.runOp({type:jr.Delete,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},ha=class extends ua{constructor(e,t,r){super();this._children={},this._parent=e,this._path=t,this._current=r,this[xc]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let r=0;r<t;r++){let n=this._current[r].id;e(this.data(this._current[r].id),n)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return fe(U({},this._current.get(e)),{data:this.data(e)})}data(e){var c;let{_current:t,_children:r}=this,n=r===void 0?void 0:r[e];if(n!==void 0)return n;let s=(c=t.get(e))==null?void 0:c.data,l=vc(this,e,s);return l!==s?(r===void 0&&(r={},this._children=r),r[e]=l,l):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,r){this.runOp({type:Yr.Add,fi:e,id:t,data:r})}move(e,t){this.runOp({type:Yr.Move,fi:e,id:t})}insertAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let n=0;n<t.length;n++){let s=t[n];this.add(r[n],s.id,s.data)}}insertBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let n=0;n<t.length;n++){let s=t[n];this.add(r[n],s.id,s.data)}}moveAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let n=0;n<t.length;n++){let s=t[n];this.move(r[n],s)}}moveBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let n=0;n<t.length;n++){let s=t[n];this.move(r[n],s)}}delete(e){this.deleteChildren(e),this.runOp({type:Yr.Delete,id:e})}};function rh(i,e,t){if(i.length>0){let r=i[i.length-1];if(r.type===Hn.Update&&e.type===Hn.Update&&bc.equal(r.path,t)){Object.assign(r.props,e.props);return}}i.push(fe(U({},e),{path:t}))}var nh=class{constructor(e){this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,r,n){rh(this.ts,t,e),rh(this.actual,r,e),rh(this.reverse,n,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function vc(i,e,t){return t instanceof On?new fa(i,e,t):t instanceof jt?new ha(i,e,t):t instanceof An?new Proxy(new Px(i,e,t),hP):t!==null&&typeof t=="object"?_x(t)?t:new Proxy(new Ox(i,e,t),fP):t}function ih(i){let e=new nh(i);return[vc(e,"",i),e]}function oh(i,e){let[t,r]=ih(i);return e(t),r.result()}function sh(i){return i instanceof fa||i instanceof ha?i._current:i!==null&&typeof i=="object"?i[Ax]:i}var bc;(function(r){function i(n,s){if(s.length===n.length)for(var l=0;l<n.length;){if(n[l]!==s[l])return!1;l+=1}else return!1;return!0}r.equal=i;function e(n,s,l){let c=t(l,n);if(c!==void 0&&typeof c=="object"&&c!==null){let f=U({},s);return Object.keys(c).forEach(h=>{delete f[h]}),f}else return s}r.removeOverridden=e;function t(n,s,l=0){if(s.length<=l)return n;if((n instanceof On||n instanceof fa)&&typeof s[l]=="string")return t(n.data(s[l]),s,l+1);if((n instanceof jt||n instanceof ha)&&typeof s[l]=="string")return t(n.data(s[l]),s,l+1);if(typeof s[l]=="number"&&Array.isArray(n))return t(n[s[l]],s,l+1);if(typeof s[l]=="string"&&typeof n=="object")return t(n[s[l]],s,l+1)}r.zoom=t})(bc||(bc={}));var ah=class{},Sc=class extends ah{constructor(e){super();this.id=e}},wc=class extends ah{constructor(e){super();this.data=e}};"use strict";var lh;try{lh=new TextDecoder}catch(i){}var ge,Vi,j=0;var Bx=[],ch=Bx,uh=0,Er={},ot,Ui,mn=0,qn=0,Qr,di,Cr=[],ft,Gx={useRecords:!1,mapsAsObjects:!0},Nc=class{},fh=new Nc;fh.name="MessagePack 0xC1";var gs=!1,mi=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(ge)return qx(()=>(_c(),this?this.unpack(e,t):mi.prototype.unpack.call(Gx,e,t)));Vi=t>-1?t:e.length,j=0,uh=0,qn=0,Ui=null,ch=Bx,Qr=null,ge=e;try{ft=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(r){throw ge=null,e instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof mi){if(Er=this,this.structures)return ot=this.structures,Cc();(!ot||ot.length>0)&&(ot=[])}else Er=Gx,(!ot||ot.length>0)&&(ot=[]);return Cc()}unpackMultiple(e,t){let r,n=0;try{gs=!0;let s=e.length,l=this?this.unpack(e,s):Ic.unpack(e,s);if(t){for(t(l);j<s;)if(n=j,t(Cc())===!1)return}else{for(r=[l];j<s;)n=j,r.push(Cc());return r}}catch(s){throw s.lastPosition=n,s.values=r,s}finally{gs=!1,_c()}}_mergeStructures(e,t){e=e||[];for(let r=0,n=e.length;r<n;r++){let s=e[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}e.sharedLength=e.length;for(let r in t||[])if(r>=0){let n=e[r],s=t[r];s&&(n&&((e.restoreStructures||(e.restoreStructures=[]))[r]=n),e[r]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Cc(){try{if(!Er.trusted&&!gs){let e=ot.sharedLength||0;e<ot.length&&(ot.length=e)}let i=Et();if(j==Vi)ot.restoreStructures&&jx(),ot=null,ge=null,di&&(di=null);else if(j>Vi){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}else if(!gs)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw ot.restoreStructures&&jx(),_c(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function jx(){for(let i in ot.restoreStructures)ot[i]=ot.restoreStructures[i];ot.restoreStructures=null}function Et(){let i=ge[j++];if(i<160)if(i<128){if(i<64)return i;{let e=ot[i&63]||Er.getStructures&&Rx()[i&63];return e?(e.read||(e.read=hh(e,i&63)),e.read()):i}}else if(i<144)if(i-=128,Er.mapsAsObjects){let e={};for(let t=0;t<i;t++)e[kx()]=Et();return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(Et(),Et());return e}else{i-=144;let e=new Array(i);for(let t=0;t<i;t++)e[t]=Et();return e}else if(i<192){let e=i-160;if(qn>=j)return Ui.slice(j-mn,(j+=e)-mn);if(qn==0&&Vi<140){let t=e<16?dh(e):Vx(e);if(t!=null)return t}return ph(e)}else{let e;switch(i){case 192:return null;case 193:return Qr?(e=Et(),e>0?Qr[1].slice(Qr.position1,Qr.position1+=e):Qr[0].slice(Qr.position0,Qr.position0-=e)):fh;case 194:return!1;case 195:return!0;case 196:return mh(ge[j++]);case 197:return e=ft.getUint16(j),j+=2,mh(e);case 198:return e=ft.getUint32(j),j+=4,mh(e);case 199:return vo(ge[j++]);case 200:return e=ft.getUint16(j),j+=2,vo(e);case 201:return e=ft.getUint32(j),j+=4,vo(e);case 202:if(e=ft.getFloat32(j),Er.useFloat32>2){let t=Tc[(ge[j]&127)<<1|ge[j+1]>>7];return j+=4,(t*e+(e>0?.5:-.5)>>0)/t}return j+=4,e;case 203:return e=ft.getFloat64(j),j+=8,e;case 204:return ge[j++];case 205:return e=ft.getUint16(j),j+=2,e;case 206:return e=ft.getUint32(j),j+=4,e;case 207:return Er.int64AsNumber?(e=ft.getUint32(j)*4294967296,e+=ft.getUint32(j+4)):e=ft.getBigUint64(j),j+=8,e;case 208:return ft.getInt8(j++);case 209:return e=ft.getInt16(j),j+=2,e;case 210:return e=ft.getInt32(j),j+=4,e;case 211:return Er.int64AsNumber?(e=ft.getInt32(j)*4294967296,e+=ft.getUint32(j+4)):e=ft.getBigInt64(j),j+=8,e;case 212:if(e=ge[j++],e==114)return Hx(ge[j++]&63);{let t=Cr[e];if(t)return t.read?(j++,t.read(Et())):t.noBuffer?(j++,t()):t(ge.subarray(j,++j));throw new Error("Unknown extension "+e)}case 213:return e=ge[j],e==114?(j++,Hx(ge[j++]&63,ge[j++])):vo(2);case 214:return vo(4);case 215:return vo(8);case 216:return vo(16);case 217:return e=ge[j++],qn>=j?Ui.slice(j-mn,(j+=e)-mn):dP(e);case 218:return e=ft.getUint16(j),j+=2,qn>=j?Ui.slice(j-mn,(j+=e)-mn):mP(e);case 219:return e=ft.getUint32(j),j+=4,qn>=j?Ui.slice(j-mn,(j+=e)-mn):gP(e);case 220:return e=ft.getUint16(j),j+=2,zx(e);case 221:return e=ft.getUint32(j),j+=4,zx(e);case 222:return e=ft.getUint16(j),j+=2,Fx(e);case 223:return e=ft.getUint32(j),j+=4,Fx(e);default:if(i>=224)return i-256;if(i===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+i)}}}var pP=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function hh(i,e){function t(){if(t.count++>2){let n=i.read=new Function("r","return function(){return {"+i.map(s=>pP.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Et);return i.highByte===0&&(i.read=Ex(e,i.read)),n()}let r={};for(let n=0,s=i.length;n<s;n++){let l=i[n];r[l]=Et()}return r}return t.count=0,i.highByte===0?Ex(e,t):t}var Ex=(i,e)=>function(){let t=ge[j++];if(t===0)return e();let r=i<32?-(i+(t<<5)):i+(t<<5),n=ot[r]||Rx()[r];if(!n)throw new Error("Record id is not defined for "+r);return n.read||(n.read=hh(n,i)),n.read()};function Rx(){let i=qx(()=>(ge=null,Er.getStructures()));return ot=Er._mergeStructures(i,ot)}var ph=Lc,dP=Lc,mP=Lc,gP=Lc;function Lc(i){let e;if(i<16&&(e=dh(i)))return e;if(i>64&&lh)return lh.decode(ge.subarray(j,j+=i));let t=j+i,r=[];for(e="";j<t;){let n=ge[j++];if((n&128)==0)r.push(n);else if((n&224)==192){let s=ge[j++]&63;r.push((n&31)<<6|s)}else if((n&240)==224){let s=ge[j++]&63,l=ge[j++]&63;r.push((n&31)<<12|s<<6|l)}else if((n&248)==240){let s=ge[j++]&63,l=ge[j++]&63,c=ge[j++]&63,f=(n&7)<<18|s<<12|l<<6|c;f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|f&1023),r.push(f)}else r.push(n);r.length>=4096&&(e+=ir.apply(String,r),r.length=0)}return r.length>0&&(e+=ir.apply(String,r)),e}function zx(i){let e=new Array(i);for(let t=0;t<i;t++)e[t]=Et();return e}function Fx(i){if(Er.mapsAsObjects){let e={};for(let t=0;t<i;t++)e[kx()]=Et();return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(Et(),Et());return e}}var ir=String.fromCharCode;function Vx(i){let e=j,t=new Array(i);for(let r=0;r<i;r++){let n=ge[j++];if((n&128)>0){j=e;return}t[r]=n}return ir.apply(String,t)}function dh(i){if(i<4)if(i<2){if(i===0)return"";{let e=ge[j++];if((e&128)>1){j-=1;return}return ir(e)}}else{let e=ge[j++],t=ge[j++];if((e&128)>0||(t&128)>0){j-=2;return}if(i<3)return ir(e,t);let r=ge[j++];if((r&128)>0){j-=3;return}return ir(e,t,r)}else{let e=ge[j++],t=ge[j++],r=ge[j++],n=ge[j++];if((e&128)>0||(t&128)>0||(r&128)>0||(n&128)>0){j-=4;return}if(i<6){if(i===4)return ir(e,t,r,n);{let s=ge[j++];if((s&128)>0){j-=5;return}return ir(e,t,r,n,s)}}else if(i<8){let s=ge[j++],l=ge[j++];if((s&128)>0||(l&128)>0){j-=6;return}if(i<7)return ir(e,t,r,n,s,l);let c=ge[j++];if((c&128)>0){j-=7;return}return ir(e,t,r,n,s,l,c)}else{let s=ge[j++],l=ge[j++],c=ge[j++],f=ge[j++];if((s&128)>0||(l&128)>0||(c&128)>0||(f&128)>0){j-=8;return}if(i<10){if(i===8)return ir(e,t,r,n,s,l,c,f);{let h=ge[j++];if((h&128)>0){j-=9;return}return ir(e,t,r,n,s,l,c,f,h)}}else if(i<12){let h=ge[j++],d=ge[j++];if((h&128)>0||(d&128)>0){j-=10;return}if(i<11)return ir(e,t,r,n,s,l,c,f,h,d);let x=ge[j++];if((x&128)>0){j-=11;return}return ir(e,t,r,n,s,l,c,f,h,d,x)}else{let h=ge[j++],d=ge[j++],x=ge[j++],g=ge[j++];if((h&128)>0||(d&128)>0||(x&128)>0||(g&128)>0){j-=12;return}if(i<14){if(i===12)return ir(e,t,r,n,s,l,c,f,h,d,x,g);{let w=ge[j++];if((w&128)>0){j-=13;return}return ir(e,t,r,n,s,l,c,f,h,d,x,g,w)}}else{let w=ge[j++],S=ge[j++];if((w&128)>0||(S&128)>0){j-=14;return}if(i<15)return ir(e,t,r,n,s,l,c,f,h,d,x,g,w,S);let D=ge[j++];if((D&128)>0){j-=15;return}return ir(e,t,r,n,s,l,c,f,h,d,x,g,w,S,D)}}}}}function mh(i){return Er.copyBuffers?Uint8Array.prototype.slice.call(ge,j,j+=i):ge.subarray(j,j+=i)}function vo(i){let e=ge[j++];if(Cr[e])return Cr[e](ge.subarray(j,j+=i));throw new Error("Unknown extension type "+e)}var Ux=new Array(4096);function kx(){let i=ge[j++];if(i>=160&&i<192){if(i=i-160,qn>=j)return Ui.slice(j-mn,(j+=i)-mn);if(!(qn==0&&Vi<180))return ph(i)}else return j--,Et();let e=(i<<5^(i>1?ft.getUint16(j):i>0?ge[j]:0))&4095,t=Ux[e],r=j,n=j+i-3,s,l=0;if(t&&t.bytes==i){for(;r<n;){if(s=ft.getUint32(r),s!=t[l++]){r=1879048192;break}r+=4}for(n+=3;r<n;)if(s=ge[r++],s!=t[l++]){r=1879048192;break}if(r===n)return j=r,t.string;n-=3,r=j}for(t=[],Ux[e]=t,t.bytes=i;r<n;)s=ft.getUint32(r),t.push(s),r+=4;for(n+=3;r<n;)s=ge[r++],t.push(s);let c=i<16?dh(i):Vx(i);return c!=null?t.string=c:t.string=ph(i)}var Hx=(i,e)=>{var t=Et();let r=i;e!==void 0&&(i=i<32?-((e<<5)+i):(e<<5)+i,t.highByte=e);let n=ot[i];return n&&n.isShared&&((ot.restoreStructures||(ot.restoreStructures=[]))[i]=n),ot[i]=t,t.read=hh(t,r),t.read()},Wx=typeof self=="object"?self:global;Cr[0]=()=>{};Cr[0].noBuffer=!0;Cr[101]=()=>{let i=Et();return(Wx[i[0]]||Error)(i[1])};Cr[105]=i=>{let e=ft.getUint32(j-4);di||(di=new Map);let t=ge[j],r;t>=144&&t<160||t==220||t==221?r=[]:r={};let n={target:r};di.set(e,n);let s=Et();return n.used?Object.assign(r,s):(n.target=s,s)};Cr[112]=i=>{let e=ft.getUint32(j-4),t=di.get(e);return t.used=!0,t.target};Cr[115]=()=>new Set(Et());var gh=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");Cr[116]=i=>{let e=i[0],t=gh[e];if(!t)throw new Error("Could not find typed array for code "+e);return new Wx[t](Uint8Array.prototype.slice.call(i,1).buffer)};Cr[120]=()=>{let i=Et();return new RegExp(i[0],i[1])};Cr[98]=i=>{let e=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],t=j;j+=e-4,Qr=[Et(),Et()],Qr.position0=0,Qr.position1=0;let r=j;j=t;try{return Et()}finally{j=r}};Cr[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function qx(i){let e=Vi,t=j,r=uh,n=mn,s=qn,l=Ui,c=ch,f=di,h=Qr,d=new Uint8Array(ge.slice(0,Vi)),x=ot,g=ot.slice(0,ot.length),w=Er,S=gs,D=i();return Vi=e,j=t,uh=r,mn=n,qn=s,Ui=l,ch=c,di=f,Qr=h,ge=d,gs=S,ot=x,ot.splice(0,ot.length,...g),Er=w,ft=new DataView(ge.buffer,ge.byteOffset,ge.byteLength),D}function _c(){ge=null,di=null,ot=null}function $x(i){i.unpack?Cr[i.type]=i.unpack:Cr[i.type]=i}var Tc=new Array(147);for(let i=0;i<256;i++)Tc[i]=+("1e"+Math.floor(45.15-i*.30103));var Ic=new mi({useRecords:!1}),yP=Ic.unpack,xP=Ic.unpackMultiple,vP=Ic.unpack;var bP=new Float32Array(1),FU=new Uint8Array(bP.buffer,0,4);"use strict";var Mc;try{Mc=new TextEncoder}catch(i){}var Ac,yh,Oc=typeof Buffer!="undefined",xh=Oc?Buffer.allocUnsafeSlow:Uint8Array,Kx=Oc?Buffer:Uint8Array,Xx=Oc?4294967296:2144337920,Z,Vt,F=0,$n,Jn=null,SP=/[\u0080-\uFFFF]/,pa=Symbol("record-id"),ys=class extends mi{constructor(e){super(e);this.offset=0;let t,r,n,s,l,c,f=0,h=Kx.prototype.utf8Write?function(b,R,T){return Z.utf8Write(b,R,T)}:Mc&&Mc.encodeInto?function(b,R){return Mc.encodeInto(b,Z.subarray(R)).written}:!1,d=this;e||(e={});let x=e&&e.sequential,g=e.structures||e.saveStructures,w=e.maxSharedStructures;if(w==null&&(w=g?32:0),w>8160)throw new Error("Maximum maxSharedStructure is 8160");let S=e.maxOwnStructures;S==null&&(S=g?32:64),x&&!e.saveStructures&&(this.structures=[]);let D=w>32||S+w>64,C=w+64,G=w+S+64;if(G>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let B=[],P=0,W=0;this.pack=this.encode=function(b,R){if(Z||(Z=new xh(8192),Vt=new DataView(Z.buffer,0,8192),F=0),$n=Z.length-10,$n-F<2048?(Z=new xh(Z.length),Vt=new DataView(Z.buffer,0,Z.length),$n=Z.length-10,F=0):F=F+7&2147483640,r=F,c=d.structuredClone?new Map:null,d.bundleStrings?(Jn=["",""],Z[F++]=214,Z[F++]=98,Jn.position=F-r,F+=4):Jn=null,n=d.structures,n){n.uninitialized&&(n=d._mergeStructures(d.getStructures()));let T=n.sharedLength||0;if(T>w)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+n.sharedLength);if(!n.transitions){n.transitions=Object.create(null);for(let z=0;z<T;z++){let A=n[z];if(!A)continue;let $,he=n.transitions;for(let re=0,Ne=A.length;re<Ne;re++){let ye=A[re];$=he[ye],$||($=he[ye]=Object.create(null)),he=$}he[pa]=z+64}f=T}x||(n.nextId=T+64)}s&&(s=!1),l=n||[];try{if(M(b),Jn){Vt.setUint32(Jn.position+r,F-Jn.position-r);let T=Jn;Jn=null,M(T[0]),M(T[1])}if(d.offset=F,c&&c.idsToInsert){F+=c.idsToInsert.length*6,F>$n&&E(F),d.offset=F;let T=NP(Z.subarray(r,F),c.idsToInsert);return c=null,T}return R&e0?(Z.start=r,Z.end=F,Z):Z.subarray(r,F)}finally{if(n){if(W<10&&W++,P>1e4)n.transitions=null,W=0,P=0,B.length>0&&(B=[]);else if(B.length>0&&!x){for(let T=0,z=B.length;T<z;T++)B[T][pa]=0;B=[]}if(s&&d.saveStructures){let T=n.sharedLength||w;n.length>T&&(n=n.slice(0,T));let z=Z.subarray(r,F);return d.saveStructures(n,f)===!1?(d._mergeStructures(d.getStructures()),d.pack(b)):(f=T,z)}}R&_P&&(F=r)}};let M=b=>{F>$n&&(Z=E(F));var R=typeof b,T;if(R==="string"){let z=b.length;if(Jn&&z>=8&&z<4096){let he=SP.test(b);Jn[he?0:1]+=b,Z[F++]=193,M(he?-z:z);return}let A;z<32?A=1:z<256?A=2:z<65536?A=3:A=5;let $=z*3;if(F+$>$n&&(Z=E(F+$)),z<64||!h){let he,re,Ne,ye=F+A;for(he=0;he<z;he++)re=b.charCodeAt(he),re<128?Z[ye++]=re:re<2048?(Z[ye++]=re>>6|192,Z[ye++]=re&63|128):(re&64512)==55296&&((Ne=b.charCodeAt(he+1))&64512)==56320?(re=65536+((re&1023)<<10)+(Ne&1023),he++,Z[ye++]=re>>18|240,Z[ye++]=re>>12&63|128,Z[ye++]=re>>6&63|128,Z[ye++]=re&63|128):(Z[ye++]=re>>12|224,Z[ye++]=re>>6&63|128,Z[ye++]=re&63|128);T=ye-F-A}else T=h(b,F+A,$);T<32?Z[F++]=160|T:T<256?(A<2&&Z.copyWithin(F+2,F+1,F+1+T),Z[F++]=217,Z[F++]=T):T<65536?(A<3&&Z.copyWithin(F+3,F+2,F+2+T),Z[F++]=218,Z[F++]=T>>8,Z[F++]=T&255):(A<5&&Z.copyWithin(F+5,F+3,F+3+T),Z[F++]=219,Vt.setUint32(F,T),F+=4),F+=T}else if(R==="number")if(b>>>0===b)b<64?Z[F++]=b:b<256?(Z[F++]=204,Z[F++]=b):b<65536?(Z[F++]=205,Z[F++]=b>>8,Z[F++]=b&255):(Z[F++]=206,Vt.setUint32(F,b),F+=4);else if(b>>0===b)b>=-32?Z[F++]=256+b:b>=-128?(Z[F++]=208,Z[F++]=b+256):b>=-32768?(Z[F++]=209,Vt.setInt16(F,b),F+=2):(Z[F++]=210,Vt.setInt32(F,b),F+=4);else{let z;if((z=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){Z[F++]=202,Vt.setFloat32(F,b);let A;if(z<4||(A=b*Tc[(Z[F]&127)<<1|Z[F+1]>>7])>>0===A){F+=4;return}else F--}Z[F++]=203,Vt.setFloat64(F,b),F+=8}else if(R==="object")if(!b)Z[F++]=192;else{if(c){let A=c.get(b);if(A){if(!A.id){let $=c.idsToInsert||(c.idsToInsert=[]);A.id=$.push(A)}Z[F++]=214,Z[F++]=112,Vt.setUint32(F,A.id),F+=4;return}else c.set(b,{offset:F-r})}let z=b.constructor;if(z===Object)q(b,!0);else if(z===Array){T=b.length,T<16?Z[F++]=144|T:T<65536?(Z[F++]=220,Z[F++]=T>>8,Z[F++]=T&255):(Z[F++]=221,Vt.setUint32(F,T),F+=4);for(let A=0;A<T;A++)M(b[A])}else if(z===Map){T=b.size,T<16?Z[F++]=128|T:T<65536?(Z[F++]=222,Z[F++]=T>>8,Z[F++]=T&255):(Z[F++]=223,Vt.setUint32(F,T),F+=4);for(let[A,$]of b)M(A),M($)}else{for(let A=0,$=Ac.length;A<$;A++){let he=yh[A];if(b instanceof he){let re=Ac[A];if(re.write){re.type&&(Z[F++]=212,Z[F++]=re.type,Z[F++]=0),M(re.write.call(this,b));return}let Ne=Z,ye=Vt,Me=F;Z=null;let Fe;try{Fe=re.pack.call(this,b,k=>(Z=Ne,Ne=null,F+=k,F>$n&&E(F),{target:Z,targetView:Vt,position:F-k}),M)}finally{Ne&&(Z=Ne,Vt=ye,F=Me,$n=Z.length-10)}Fe&&(Fe.length+F>$n&&E(Fe.length+F),F=wP(Fe,Z,F,re.type));return}}q(b,!b.hasOwnProperty)}}else if(R==="boolean")Z[F++]=b?195:194;else if(R==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))Z[F++]=211,Vt.setBigInt64(F,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)Z[F++]=207,Vt.setBigUint64(F,b);else if(this.largeBigIntToFloat)Z[F++]=203,Vt.setFloat64(F,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");F+=8}else if(R==="undefined")this.encodeUndefinedAsNil?Z[F++]=192:(Z[F++]=212,Z[F++]=0,Z[F++]=0);else if(R==="function")M(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+R)},q=this.useRecords===!1?this.variableMapSize?b=>{let R=Object.keys(b),T=R.length;T<16?Z[F++]=128|T:T<65536?(Z[F++]=222,Z[F++]=T>>8,Z[F++]=T&255):(Z[F++]=223,Vt.setUint32(F,T),F+=4);let z;for(let A=0;A<T;A++)M(z=R[A]),M(b[z])}:(b,R)=>{Z[F++]=222;let T=F-r;F+=2;let z=0;for(let A in b)(R||b.hasOwnProperty(A))&&(M(A),M(b[A]),z++);Z[T+++r]=z>>8,Z[T+r]=z&255}:b=>{let R=Object.keys(b),T,z=l.transitions||(l.transitions=Object.create(null)),A=0;for(let he=0,re=R.length;he<re;he++){let Ne=R[he];T=z[Ne],T||(T=z[Ne]=Object.create(null),A++),z=T}let $=z[pa];if($)$>=96&&D?(Z[F++]=(($-=96)&31)+96,Z[F++]=$>>5):Z[F++]=$;else{$=l.nextId,$||($=64),$<C&&this.shouldShareStructure&&!this.shouldShareStructure(R)?($=l.nextOwnId,$<G||($=C),l.nextOwnId=$+1):($>=G&&($=C),l.nextId=$+1);let he=R.highByte=$>=96&&D?$-96>>5:-1;z[pa]=$,l[$-64]=R,$<C?(R.isShared=!0,l.sharedLength=$-63,s=!0,he>=0?(Z[F++]=($&31)+96,Z[F++]=he):Z[F++]=$):(he>=0?(Z[F++]=213,Z[F++]=114,Z[F++]=($&31)+96,Z[F++]=he):(Z[F++]=212,Z[F++]=114,Z[F++]=$),A&&(P+=W*A),B.length>=S&&(B.shift()[pa]=0),B.push(z),M(R))}for(let he=0,re=R.length;he<re;he++)M(b[R[he]])},E=b=>{let R;if(b>16777216){if(b-r>Xx)throw new Error("Packed buffer would be larger than maximum buffer size");R=Math.min(Xx,Math.round(Math.max((b-r)*(b>67108864?1.25:2),4194304)/4096)*4096)}else R=(Math.max(b-r<<2,Z.length-1)>>12)+1<<12;let T=new xh(R);return Vt=new DataView(T.buffer,0,R),Z.copy?Z.copy(T,0,r,b):T.set(Z.slice(r,b)),F-=r,r=0,$n=T.length-10,Z=T}}useBuffer(e){Z=e,Vt=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),F=0}};yh=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Nc];Ac=[{pack(i,e,t){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:n,targetView:s,position:l}=e(6);n[l++]=214,n[l++]=255,s.setUint32(l,r)}else if(r>0&&r<17179869184){let{target:n,targetView:s,position:l}=e(10);n[l++]=215,n[l++]=255,s.setUint32(l,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(l+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:n,targetView:s,position:l}=e(3);n[l++]=212,n[l++]=255,n[l++]=255}else{let{target:n,targetView:s,position:l}=e(15);n[l++]=199,n[l++]=12,n[l++]=255,s.setUint32(l,i.getMilliseconds()*1e6),s.setBigInt64(l+4,BigInt(Math.floor(r)))}}},{pack(i,e,t){let r=Array.from(i),{target:n,position:s}=e(this.structuredClone?3:0);this.structuredClone&&(n[s++]=212,n[s++]=115,n[s++]=0),t(r)}},{pack(i,e,t){let{target:r,position:n}=e(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=101,r[n++]=0),t([i.name,i.message])}},{pack(i,e,t){let{target:r,position:n}=e(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=120,r[n++]=0),t([i.source,i.flags])}},{pack(i,e){this.structuredClone?Zx(i,16,e):Yx(Oc?Buffer.from(i):new Uint8Array(i),e)}},{pack(i,e){let t=i.constructor;t!==Kx&&this.structuredClone?Zx(i,gh.indexOf(t.name),e):Yx(i,e)}},{pack(i,e){let{target:t,position:r}=e(1);t[r]=193}}];function Zx(i,e,t,r){let n=i.byteLength;if(n+1<256){var{target:s,position:l}=t(4+n);s[l++]=199,s[l++]=n+1}else if(n+1<65536){var{target:s,position:l}=t(5+n);s[l++]=200,s[l++]=n+1>>8,s[l++]=n+1&255}else{var{target:s,position:l,targetView:c}=t(7+n);s[l++]=201,c.setUint32(l,n+1),l+=4}s[l++]=116,s[l++]=e,s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),l)}function Yx(i,e){let t=i.byteLength;var r,n;if(t<256){var{target:r,position:n}=e(t+2);r[n++]=196,r[n++]=t}else if(t<65536){var{target:r,position:n}=e(t+3);r[n++]=197,r[n++]=t>>8,r[n++]=t&255}else{var{target:r,position:n,targetView:s}=e(t+5);r[n++]=198,s.setUint32(n,t),n+=4}r.set(i,n)}function wP(i,e,t,r){let n=i.length;switch(n){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:n<256?(e[t++]=199,e[t++]=n):n<65536?(e[t++]=200,e[t++]=n>>8,e[t++]=n&255):(e[t++]=201,e[t++]=n>>24,e[t++]=n>>16&255,e[t++]=n>>8&255,e[t++]=n&255)}return e[t++]=r,e.set(i,t),t+=n,t}function NP(i,e){let t,r=e.length*6,n=i.length-r;for(e.sort((s,l)=>s.offset>l.offset?1:-1);t=e.pop();){let s=t.offset,l=t.id;i.copyWithin(s+r,s,n),r-=6;let c=s+r;i[c++]=214,i[c++]=105,i[c++]=l>>24,i[c++]=l>>16&255,i[c++]=l>>8&255,i[c++]=l&255,n=s}return i}function bo(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");yh.unshift(i.Class),Ac.unshift(i)}$x(i)}var Qx=new ys({useRecords:!1}),CP=Qx.pack,LP=Qx.pack;var e0=512,_P=1024;var t0=new ys({structuredClone:!0});bo({Class:An.prototype.constructor,type:1,write(i){return U({},i)},read(i){return Object.setPrototypeOf(i,An.prototype),i}});bo({Class:jt.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,jt.prototype),i}});bo({Class:On.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,On.prototype),i}});bo({Class:Sc.prototype.constructor,type:4,write(i){return i.id},read(i){return new Sc(i)}});bo({Class:wc.prototype.constructor,type:5,write(i){return i.data},read(i){return new wc(i)}});function TP(i){var e=0;if(i.length===0)return e;for(let t=0;t<i.length;t++){let r=i[t];e=(e<<5)-e+r,e=e&e}return e}var Pc;(function(r){function i(n){return t0.pack(n)}r.serialize=i;function e(n){return t0.unpack(n)}r.deserialize=e;function t(n){return TP(i(n)).toString()}r.checksum=t})(Pc||(Pc={}));var Dc;(function(t){t.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function e(r){return t.all.includes(r)}t.is=e})(Dc||(Dc={}));var Bc;(function(t){function i(r){return e(r)}t.defaultData=i;function e(r){if(r==="PointLight")return{type:r,color:kn.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:2500,helper:!0};if(r==="SpotLight")return{type:r,color:kn.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:2500,helper:!0};if(r==="DirectionalLight")return{type:r,color:kn.white,intensity:1,shadows:!0,size:2500,depth:2500,helper:!0};throw new Error("not implemented")}})(Bc||(Bc={}));var xs;(function(r){r[r.Front=0]="Front",r[r.Back=1]="Back",r[r.Double=2]="Double"})(xs||(xs={}));var vh;(function(t){t.defaultData={castShadow:!0,receiveShadow:!0};function e(r,n){return r.castShadow===n.castShadow&&r.receiveShadow===n.receiveShadow}t.equals=e})(vh||(vh={}));var bh;(function(t){t.defaultData={flatShading:!1,wireframe:!1,side:0};function e(r,n){return r.flatShading===n.flatShading&&r.side===n.side&&r.wireframe===n.wireframe}t.equals=e})(bh||(bh={}));var Gc;(function(e){e.defaultData=fe(U(U({},bh.defaultData),vh.defaultData),{cloner:null})})(Gc||(Gc={}));var Lr;(function(n){n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.Center=3]="Center",n[n.Justify=4]="Justify"})(Lr||(Lr={}));var gi;(function(r){r[r.Top=1]="Top",r[r.Center=2]="Center",r[r.Bottom=3]="Bottom"})(gi||(gi={}));var ki;(function(r){r[r.None=1]="None",r[r.Upper=2]="Upper",r[r.Lower=3]="Lower"})(ki||(ki={}));var jc;(function(e){e.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:kn.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"}})(jc||(jc={}));var Zt;(function(n){n[n.Normal=0]="Normal",n[n.Multiply=1]="Multiply",n[n.Screen=2]="Screen",n[n.Overlay=3]="Overlay"})(Zt||(Zt={}));var vs;(function(r){r[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar"})(vs||(vs={}));var Ec;(function(r){r[r.RepeatWrapping=1e3]="RepeatWrapping",r[r.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",r[r.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping"})(Ec||(Ec={}));var Rc;(function(n){n[n.UV=0]="UV",n[n.Planar=1]="Planar",n[n.Spherical=2]="Spherical",n[n.Cylindrical=3]="Cylindrical"})(Rc||(Rc={}));var zc;(function(s){s[s.Simplex=0]="Simplex",s[s.SimplexFractal=1]="SimplexFractal",s[s.Ashima=2]="Ashima",s[s.Fbm=3]="Fbm",s[s.Perlin=4]="Perlin"})(zc||(zc={}));var bs;(function(r){function i(n,s){return n==="light"&&s?e(s):t(n)}r.defaultData=i;function e(n){switch(n){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:.2,g:.2,b:.2,a:1},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function t(n){switch(n){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:ds.x,type:"texture",projection:0,texture:{image:"image_0",wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:Zr.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,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],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,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{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:fe(U({},Zr.fromHex(6710886)),{a:1}),colorB:fe(U({},Zr.fromHex(6710886)),{a:1}),colorC:fe(U({},Zr.fromHex(16777215)),{a:1}),colorD:fe(U({},Zr.fromHex(16777215)),{a:1}),distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:kn.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(bs||(bs={}));var Ss;(function(c){function i(f){return!f.layers.some(d=>{if(d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")return!0})&&!t(f)}c.isMergable=i;function e(f){let h="";return f.layers.forEach(d=>{Object.entries(d.data).forEach(([x,g])=>{h+=`${x}${g}`,Array.isArray(g)?g.forEach(w=>h+=`${w}`):typeof g=="object"?Object.values(g).forEach(w=>{typeof w=="number"?h+=`${w.toFixed(4)}`:h+=`${w}`}):h+=`${g}`})}),h}c.getHash=e;function t(f){let h=0;for(let d of f.layers)"alpha"in d.data&&d.data.type!=="light"&&d.data.type!=="fresnel"&&(h+=(1-h)*d.data.alpha);return h<1}c.isTransparent=t;function r(){return{layers:new jt}}c.defaultEmptyData=r;function n(f="layer1",h="layer2"){return s("phong",f,h)}c.defaultData=n;function s(f,h="layer1",d="layer2"){let x=new jt;return x.push({fi:0,data:bs.defaultData("light",f),id:h}),x.push({fi:1,data:bs.defaultData("color"),id:d}),{layers:x}}c.defaultTwoLayerData=s;function l(f,h="basic",d="layer1",x="layer2"){let g=bs.defaultData("texture");Object.assign(g.texture,{image:f});let w=new jt;return w.push({fi:0,data:g,id:d}),w.push({fi:1,data:bs.defaultData("light",h),id:x}),{layers:w}}c.defaultTwoLayerTextureData=l})(Ss||(Ss={}));var ws;(function(r){function i(){return{points:new jt,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=i;function e(n,s){let{points:l}=s;if(l){for(let c of l)if(c.data.position[0]===n[0]&&c.data.position[1]===n[1])return!0}return!1}r.isOverlappingExistingPoint=e;function t(n,s){let l=n.controlNext,c=s.controlPrevious;return n.position[0]===l.position[0]&&n.position[1]===l.position[1]&&s.position[0]===c.position[0]&&s.position[1]===c.position[1]}r.isStraightLine=t})(ws||(ws={}));var Fc;(function(e){function i(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=i})(Fc||(Fc={}));var Vc;(function(e){function i(t){if(t==="RectangleGeometry")return{width:320,height:320,type:t,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};if(t==="VectorGeometry")return{width:100,height:100,type:t,subdivisions:12,shape:ws.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};throw new Error("not implemented")}e.defaultData=i})(Vc||(Vc={}));var da;(function(n){n.identity=fe(U({},mc.identity),{hiddenMatrix:Fi.identity});function e(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}n.fromObject=e;function t(s,l){return{position:(l==null?void 0:l.position)||s.position,rotation:(l==null?void 0:l.rotation)||s.rotation,scale:(l==null?void 0:l.scale)||s.scale,hiddenMatrix:(l==null?void 0:l.hiddenMatrix)||s.hiddenMatrix}}n.merge=t;function r(s,l){return{position:ms.isEqual(s.position,l.position)?null:l.position,rotation:ms.isEqual(s.rotation,l.rotation)?null:l.rotation,scale:ms.isEqual(s.scale,l.scale)?null:l.scale,hiddenMatrix:Fi.isEqual(s.hiddenMatrix,l.hiddenMatrix)?null:l.hiddenMatrix}}n.diff=r})(da||(da={}));var Hi;(function(e){e.defaultData=U({states:new jt,events:new jt,visible:!0,raycastLock:!1},da.identity)})(Hi||(Hi={}));var r0;(function(e){e.defaultData=U({type:"Empty"},Hi.defaultData)})(r0||(r0={}));var Sh;(function(e){e.defaultData=U(U({type:"Mesh"},Hi.defaultData),Gc.defaultData)})(Sh||(Sh={}));var n0;(function(e){e.defaultData=U(U({type:"TextFrame"},Hi.defaultData),jc.defaultData)})(n0||(n0={}));var Uc;(function(e){e.defaultData=U(U(U({},Hi.defaultData),da.identity),xo.defaultData)})(Uc||(Uc={}));var i0;(function(e){function i(t){return U(U({},Hi.defaultData),Bc.defaultData(t))}e.defaultData=i})(i0||(i0={}));var o0;(function(t){t.defaultCamera=U({position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Fi.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new jt,events:new jt},xo.defaultData),t.defaultMeshObject=fe(U(U({name:"Rectangle"},Hi.defaultData),Sh.defaultData),{geometry:Vc.defaultData("RectangleGeometry"),material:Ss.defaultTwoLayerData("basic","layer1","layer2")})})(o0||(o0={}));var s0;(function(t){function i(r,n){if(n===void 0)return r;let s=U({},r);return"material"in s&&"material"in n&&n.material&&(s.material=oh(s.material,l=>{if(typeof l!="string")for(let[c,f]of Object.entries(n.material.layers)){let h=l.layers.data(c);h&&yo(h,f)}}).data),s.materials&&n.materials&&(s.materials=oh(s.materials,l=>{var c,f;for(let h=0;h<s.materials.length;h++){let d=n.materials[h];if(typeof d!="string")for(let[x,g]of Object.entries(d.layers)){let w=(f=(c=l[h])==null?void 0:c.layers)==null?void 0:f.data(x);w&&yo(w,g)}}}).data),s}t.patchMaterialState=i;function e(r,n){var l,c;if(n===void 0)return r;let s=U({},r);if(Object.assign(s,da.merge(s,n)),ps.is(r.type)){s.orthographic=U({},s.orthographic),s.perspective=U({},s.perspective);let f=n;((l=f.orthographic)==null?void 0:l.zoom)!==void 0&&(s.orthographic.zoom=f.orthographic.zoom),((c=f.perspective)==null?void 0:c.zoom)!==void 0&&(s.perspective.zoom=f.perspective.zoom)}else if(r.type==="Mesh")s.geometry=U({},s.geometry),Object.assign(s.geometry,n.geometry),s=i(s,n);else if(Dc.is(r.type)){let f=n;s.intensity!==void 0&&(s.intensity=f.intensity),f.color!==void 0&&(typeof f.color=="string"?s.color=f.color:s.color=Zr.clone(f.color))}return s}t.patch=e})(s0||(s0={}));var Yt=5855577;var a0=2857471;var wh=15711266;import{DoubleSide as IP,Mesh as MP,MeshBasicMaterial as AP,ShapeBufferGeometry as OP,Vector2 as PP,Vector3 as DP}from"three";import{FontLoader as BP}from"three/examples/jsm/loaders/FontLoader.js";var Ut=class extends MP{constructor({char:e,originalChar:t,fontFamily:r,letterSpacing:n,fontSize:s,LOD:l=16},c=new AP({color:0,opacity:1,visible:!0,transparent:!0,side:IP})){let f=Ut.loadChar(e,r,l);super(f.geometry,c);this.char=e,this.originalChar=t!=null?t:e,this.fontFamily=r,this.letterSpacing=n,this.fontSize=s,this.LOD=l,this.resolution=f.resolution,this.glyphsHa=f.glyphsHa,this.localPosition=new PP,this.charSize=0,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}static get FONTS_PATH(){return Ut._fontPath}static set FONTS_PATH(e){Ut._fontPath=e}updatePosition(e,t){this.localPosition.copy(e);let r=new DP(this.localPosition.x,-this.localPosition.y,0);this.position.copy(r).add(t)}updateFontSize(e){let t=e/this.resolution;this.fontSize=e,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*t*this.letterSpacing}updateFontFamily(e){if(this.fontFamily===e)return;this.fontFamily=e;let t=Ut.loadChar(this.char,e,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateChar(e){if(this.char===e)return;this.char=e;let t=Ut.loadChar(e,this.fontFamily,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateLetterSpacing(e){this.letterSpacing!==e&&(this.letterSpacing=e,this.updateFontSize(this.fontSize))}updateLOD(e){if(this.LOD===e)return;this.LOD=e;let t=Ut.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}clone(){let e={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new Ut(e).copy(this)}static loadFont(e){return new Promise(function(t,r){Ut.fontCache[e]?t(Ut.fontCache[e]):new BP().load(Ut.FONTS_PATH+e+".json",s=>{Ut.fontCache[e]=s,t(s)},void 0,r)})}static loadChar(e,t,r){if(Ut.charCache[e]){if(Ut.charCache[e][r]&&Ut.charCache[e][r].fontFamily===t)return Ut.charCache[e][r]}else Ut.charCache[e]={};let n=Ut.fontCache[t],s=n.generateShapes(e,1);return Ut.charCache[e][r]={geometry:new OP(s,r),fontFamily:t,resolution:n.data.resolution,glyphsHa:n.data.glyphs[e].ha},Ut.charCache[e][r]}},Rr=Ut;Rr.charCache={},Rr.fontCache={},Rr._fontPath="/_assets/_fonts/";import{DoubleSide as ju,MeshBasicMaterial as Xv,Vector3 as Zv,Object3D as _3}from"three";import{Mesh as nD}from"three";import{BufferGeometry as ck,ConeBufferGeometry as EP,Float32BufferAttribute as uk,Vector2 as fk,Vector3 as hk}from"three";import{BufferGeometry as GP,CylinderBufferGeometry as jP,Float32BufferAttribute as Nh,Vector2 as Pn,Vector3 as kc}from"three";var l0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var l,c,f,h,d;let t=Object.assign({},(l=e==null?void 0:e.parameters)!=null?l:{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},i.parameters),r=t.width/2,n=(c=t.radiusTop)!=null?c:r,s=(f=t.radiusBottom)!=null?f:r;return n===s?(n=r,s=r):n>s?(n=r,s=s*r/n):(n=n*r/s,s=r),{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((h=t.height)!=null?h:t.width),depth:Math.abs((d=t.depth)!=null?d:t.width),radiusTop:n,radiusBottom:s})}}static build(i){let{width:e,depth:t,height:r,radialSegments:n,heightSegments:s,openEnded:l,thetaStart:c,thetaLength:f,radiusTop:h,radiusBottom:d,cornerRadius:x,cornerSegments:g,hollow:w}=i.parameters,S;return x||w?S=new Hc(h,d,r,n,s,l,c,f*Math.PI/180,x,x,g,w):S=new jP(h,d,r,n,s,l,c,f*Math.PI/180),S.scale(1,1,t/e),Object.assign(S,{userData:fe(U({},i),{type:"CylinderGeometry"})})}};function Wi(i,e,t){t.x=i.x*e.x,t.y=i.y,t.z=i.x*e.y}function c0(i){return new Pn(i.y,-i.x)}var Hc=class extends GP{constructor(e,t,r,n,s,l,c,f,h,d,x,g,w=!1){super();this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,r=r||1,n=Math.floor(n)||8,s=Math.floor(s)||1,l=l!==void 0?l:!1,c=c!==void 0?c:0,f=f!==void 0?f:Math.PI*2,l&&(h=0,d=0);let S=[],D=[],C=[],G=[],B=0,P=r/2,W=new kc,M=new kc;w&&e==0&&(e=h),w&&t==0&&(t=d);let q=new Pn(e,P),E=new Pn(t,-P),b=null,R=null,T=null,z=null,A=q.clone().sub(E),$=0,he=0,re=0;g>0&&($=Math.min(e,t)*(1-g),he=e-$,re=t-$);let Ne=q.clone();Ne.x-=$;let ye=Math.PI-A.angle(),Me=A.angle(),Fe=Math.tan(Me/2),k=Math.tan(ye/2),H=Fe+k,_=g?H:k,J=g?H:Fe;if(h=Math.min(h,(e-he)/_,A.length()/H),d=Math.min(d,(t-re)/J,A.length()/H),h>0){let K=h/Fe;b=q.clone().sub(new Pn(K,h)),g&&(T=b.clone(),T.x-=$-H*h),q.sub(A.clone().setLength(K))}if(d>0){let K=d/k;R=E.clone().sub(new Pn(K,-d)),E.add(A.clone().setLength(K)),g&&(z=R.clone(),z.x-=$-H*d,Ne.sub(A.clone().setLength(K)))}A=q.clone().sub(E);let ee=A.length()<.5,oe=[];for(let K=0;K<=n;K++){let ae=[],ne=K/n,Ce=ne*f+c,Y=new Pn(Math.sin(Ce),Math.cos(Ce));z&&R?(se(ae,ne,Y,ye,d,z,-1,!0),se(ae,ne,Y,Me,d,R,-1,!1)):R?(ce(ae,Y,R.x,0,-1),se(ae,ne,Y,Me,d,R,-1,!1)):l||ce(ae,Y,t,re,-1);let le=c0(A).normalize();if(Wi(le,Y,W),!ee)for(let pe=0;pe<=s;pe++){let xe=pe/s,_e=A.clone().multiplyScalar(xe).add(E);Wi(_e,Y,M),D.push(M.x,M.y,M.z),C.push(W.x,W.y,W.z),G.push(ne,.5+M.y/r),ae.push(B++)}if(T&&b?(se(ae,ne,Y,ye,h,b,1,!1),se(ae,ne,Y,Me,h,T,1,!0)):b?(se(ae,ne,Y,ye,h,b,1,!1),ce(ae,Y,b.x,0,1)):l||ce(ae,Y,e,he,1),g&&!ee){let pe=c0(A).multiplyScalar(-1).normalize();Wi(pe,Y,W);for(let xe=0;xe<=s;xe++){let _e=xe/s,de=A.clone().multiplyScalar(-_e).add(Ne);Wi(de,Y,M),D.push(M.x,M.y,M.z),C.push(W.x,W.y,W.z),G.push(ne,.5+M.y/r),ae.push(B++)}}g&&!l&&ae.push(ae[0]),oe.push(ae)}for(let K=0;K<oe.length-1;K++)for(let ae=0;ae<oe[0].length-1;ae++){if(l&&g&&ae==s)continue;let ne=oe[K][ae],Ce=oe[K+1][ae],Y=oe[K+1][ae+1],le=oe[K][ae+1],pe=D[Y*3+0],xe=D[Y*3+2];S.push(ne,Ce,le),(pe!=0||xe!=0)&&S.push(Ce,Y,le)}f<Math.PI*2&&(ue(-1,oe[0],c),ue(1,oe[oe.length-1],c+f)),this.setIndex(S),this.setAttribute("position",new Nh(D,3)),this.setAttribute("normal",new Nh(C,3)),this.setAttribute("uv",new Nh(G,2));function se(K,ae,ne,Ce,Y,le,pe,xe){for(let _e=0;_e<x+1;_e++){let de=_e/x,we=pe<0?de:1-de;xe&&(we-=1),we*=Ce;let Ve=new Pn(Math.sin(we),Math.cos(we)*pe),Ge=Ve.clone().multiplyScalar(Y).add(le);Wi(Ge,ne,M),D.push(M.x,M.y,M.z),Wi(Ve,ne,W),C.push(W.x,W.y,W.z),G.push(ae,.5+M.y/r),K.push(B++)}}function ce(K,ae,ne,Ce,Y){let le=new kc,pe=new Pn,xe=[ne,Ce];Y<0&&xe.reverse();for(let _e of xe)pe.set(_e,P*Y),Wi(pe,ae,le),D.push(le.x,le.y,le.z),C.push(0,Y,0),G.push(.5,.5),K.push(B++)}function ue(K,ae,ne){let Ce=new Pn(Math.sin(ne),Math.cos(ne)),Y=new Pn(-Math.cos(ne),Math.sin(ne)),le=new kc,pe=K<0?(de,we,Ve)=>S.push(de,we,Ve):(de,we,Ve)=>S.push(de,Ve,we),xe=new Pn((e+t+he+re)/4,0);Wi(xe,Ce,le),D.push(le.x,le.y,le.z),C.push(Y.x,0,Y.y),G.push(.5,.5);let _e=B++;for(let de of ae){let we=D.slice(de*3,de*3+3);D.push(...we),C.push(Y.x,0,Y.y);let Ve=G.slice(de*2,de*2+2);G.push(...Ve),B++}for(let de=_e+1;de<B-1;de++)pe(_e,de,de+1);pe(_e,B-1,_e+1)}}};var u0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,depth:t,height:r,radialSegments:n,heightSegments:s,openEnded:l,thetaStart:c,thetaLength:f,cornerRadiusTop:h,cornerRadiusBottom:d,cornerSegments:x}=i.parameters,g;return h>0||d>0||f<360?g=new Hc(0,e/2,r,n,s,l,c,f*Math.PI/180,h,d,x,0,!0):g=new EP(e/2,r,n,s,l),g.scale(1,1,t/e),Object.assign(g,{userData:fe(U({},i),{type:"ConeGeometry"})})}};import{BoxBufferGeometry as RP,BufferGeometry as zP,Float32BufferAttribute as Ch,Vector3 as ma}from"three";var f0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,height:t,depth:r,widthSegments:n,heightSegments:s,depthSegments:l,cornerRadius:c,cornerSegments:f}=i.parameters,h;return c==0?h=new RP(e,t,r,n,s,l):h=new h0(e,t,r,n,s,l,c,f),Object.assign(h,{userData:fe(U({},i),{type:"CubeGeometry"})})}},Lh=Math.PI/2,h0=class extends zP{constructor(e=1,t=1,r=1,n=1,s=1,l=1,c=0,f=4){super();this.type="BoxBufferGeometry";let h=this;n=Math.floor(n),s=Math.floor(s),l=Math.floor(l),f=Math.floor(f),c=Math.min(c,e/2,t/2,r/2);let d=[],x=[],g=[],w=[],S=0,D=0;C("z","y","x",-1,-1,r,t,e,l,s,0),C("z","y","x",1,-1,r,t,-e,l,s,1),C("x","z","y",1,1,e,r,t,n,l,2),C("x","z","y",1,-1,e,r,-t,n,l,3),C("x","y","z",1,-1,e,t,r,n,s,4),C("x","y","z",-1,-1,e,t,-r,n,s,5),c>0&&(G("z","y","x",-1,-1,1,r,t,e,l,0),G("z","y","x",1,-1,-1,r,t,e,l,1),G("z","y","x",-1,1,-1,r,t,e,l,1),G("z","y","x",1,1,1,r,t,e,l,0),G("x","y","z",-1,-1,-1,e,t,r,n,0),G("x","y","z",1,-1,1,e,t,r,n,1),G("x","y","z",-1,1,1,e,t,r,n,0),G("x","y","z",1,1,-1,e,t,r,n,1),G("y","x","z",-1,-1,1,t,e,r,s,0),G("y","x","z",1,-1,-1,t,e,r,s,1),G("y","x","z",1,1,1,t,e,r,s,1),G("y","x","z",-1,1,-1,t,e,r,s,0),B(1,1,1),B(-1,1,1),B(1,-1,1),B(-1,-1,1),B(1,1,-1),B(-1,1,-1),B(1,-1,-1),B(-1,-1,-1)),this.setIndex(d),this.setAttribute("position",new Ch(x,3)),this.setAttribute("normal",new Ch(g,3)),this.setAttribute("uv",new Ch(w,2));function C(P,W,M,q,E,b,R,T,z,A,$){let he=(b-2*c)/z,re=(R-2*c)/A,Ne=b/2-c,ye=R/2-c,Me=T/2,Fe=z+1,k=A+1,H=0,_=0,J=new ma;for(let ee=0;ee<k;ee++){let oe=ee*re-ye;for(let se=0;se<Fe;se++){let ce=se*he-Ne;J[P]=ce*q,J[W]=oe*E,J[M]=Me,x.push(J.x,J.y,J.z),J[P]=0,J[W]=0,J[M]=T>0?1:-1,g.push(J.x,J.y,J.z),w.push(se/z),w.push(1-ee/A),H+=1}}for(let ee=0;ee<A;ee++)for(let oe=0;oe<z;oe++){let se=S+oe+Fe*ee,ce=S+oe+Fe*(ee+1),ue=S+(oe+1)+Fe*(ee+1),K=S+(oe+1)+Fe*ee;d.push(se,ce,K),d.push(ce,ue,K),_+=6}h.addGroup(D,_,$),D+=_,S+=H}function G(P,W,M,q,E,b,R,T,z,A,$){let he=(R-2*c)/A,re=R/2-c,Ne=T/2-c,ye=z/2,Me=A+1,Fe=0,k=0,H=new ma,_=new ma;for(let J=0;J<f+1;J++){let ee=J/f*Lh,oe=Math.sin(ee)*c,se=(1-Math.cos(ee))*c,ce=Math.sin(ee),ue=Math.cos(ee);H[W]=(Ne+oe)*E,H[M]=(ye-se)*b,_[P]=0,_[W]=ce*Math.sign(H[W]),_[M]=ue*Math.sign(H[M]);for(let K=0;K<Me;K++){let ae=K*he-re;H[P]=ae*q,x.push(H.x,H.y,H.z),g.push(_.x,_.y,_.z),w.push(K/A),w.push(0),Fe+=1}}for(let J=0;J<f;J++)for(let ee=0;ee<A;ee++){let oe=S+ee+Me*J,se=S+ee+Me*(J+1),ce=S+(ee+1)+Me*(J+1),ue=S+(ee+1)+Me*J;d.push(oe,se,ue),d.push(se,ce,ue),k+=6}h.addGroup(D,k,$),D+=k,S+=Fe}function B(P,W,M){let q=new ma,E=new ma(e/2,t/2,r/2);E.subScalar(c);let b=[],R=P*W*M>0?(z,A,$)=>d.push(z,A,$):(z,A,$)=>d.push(z,$,A);for(let z=0;z<=f;z++){let A=[],$=Lh*(1-z/f),he=Math.cos($),re=Math.sin($),Ne=0;for(let ye=0;ye<=z;ye++){let Me=Math.cos(Ne),Fe=Math.sin(Ne);q.x=he*Me,q.y=re,q.z=he*Fe;let k=E.clone().addScaledVector(q,c);x.push(P*k.x,W*k.y,M*k.z),g.push(P*q.x,W*q.y,M*q.z),w.push(0,0),A.push(S++),Ne+=Lh/z}b.push(A)}let T=b.length-1;for(let z=0;z<T;z++){let A=b[z],$=b[z+1],he=A.length-1;R(A[0],$[1],$[0]);for(let re=1;re<=he;re++)R(A[re-1],A[re],$[re]),R(A[re],$[re+1],$[re])}}}};import{BufferGeometry as FP,Float32BufferAttribute as _h,Triangle as VP,Vector3 as yi,Vector2 as Th}from"three";var So=class extends FP{constructor(e=[],t=[],r="",n=1,s=.2,l=4){super();this.type="PolyhedronGeometryRound";let c=[],f=[],h=[];d(),x(),this.setAttribute("position",new _h(c,3)),this.setAttribute("normal",new _h(h,3)),this.setAttribute("uv",new _h(f,2));return;function d(){var Fe;s=Math.min(1-1e-5,s),s==0&&(l=0);let w={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],S=new yi,D=S.clone(),C=new VP,G=s*n,B=n-G,P=l+1,W=new yi,M=(k,H)=>W.subVectors(k,H).normalize(),q=(k,H)=>Array(k).fill(void 0).map(H),E=q(e.length/3,(k,H)=>new yi().fromArray(e,H*3).setLength(n)),b=[],R=1e6;for(let k=0;k<E.length;k++){let H=E[k],_=[],J,ee,oe,se=1e10,ce=-1;for(;(ce=t.indexOf(k,ce+1))!=-1;){let ne=ce-ce%3;J=t[ne+(ce+1)%3],ee=t[ne+(ce+2)%3],oe=H.distanceToSquared(E[J]),se=Math.min(se,oe),_.push([J,ee,oe])}se+=1e-6;let ue=[],K=0,ae=_.length;for(let ne=0;ne<ae;ne++){[J,ee,oe]=_[K];let Ce=((Fe=b[J])==null?void 0:Fe.includes(k))==!0;oe<=se&&ue.push(J+ +Ce*R),K=_.findIndex(Y=>Y[0]==ee)}b.push(ue)}let T=[];{let k=0,H=0,_,J,ee=w==3;for(let oe=0;oe<=l;oe++){_=oe*(oe+1)/2,J=(oe+1)*(oe+2)/2;for(let se=0;se<l-oe;se++)[k,H]=[_+se+oe+2,J+se+oe+3],T.push(_,J,...ee?[H,_]:[k,J],H,k),[_,J]=[k,H];T.push(_,J,_+l+2)}}let z=S.clone(),A=S.clone(),$=S.clone(),he=S.clone(),re=S.clone(),Ne=[],ye=q(E.length,()=>q(w,()=>S.clone()));for(let k=0;k<E.length;k++){S.copy(E[k]).normalize(),z.copy(S).multiplyScalar(B);let H=b[k];for(let ue=0;ue<H.length;ue++){let K=H[ue],ae=H[(ue+1)%w];C.setFromPointsAndIndices(E,k,K%R,ae%R),C.b.sub(C.a).setLength(1e10).add(C.a),C.c.sub(C.a).setLength(1e10).add(C.a),C.closestPointToPoint(z,ye[k][ue])}let _=[],J=[],ee=[],oe=new yi;l==0&&[...ye[k]].reduce((ue,K)=>ue.add(K),oe).multiplyScalar(1/w);for(let ue=0;ue<w;ue++){let K=[],ae=(ue-1+w)%w,ne=ye[k][ae],Ce=ye[k][ue];S.copy(ne).sub(z),D.copy(Ce).sub(z);let Y=z.angleTo(S),le=S.angleTo(D),pe=Math.cos(Y)*G;l==0?A.copy(oe):A.copy(z).setLength(B+pe),J.push(pe);let xe=[A,ne,Ce];for(let _e=0;_e<2;_e++){let de=xe[_e],we=xe[_e+1];he.subVectors(de,z),re.subVectors(we,z),$.crossVectors(he,re).normalize();for(let Ve=0;Ve<P;Ve++){let Ge=[Y,le][_e]*Ve/P;S.copy(he).applyAxisAngle($,Ge).add(z),_.push(S.clone()),_e&&(M(S,z),K.push([Ve==0?de:S.clone(),W.clone()]))}_e&&(M(we,z),K.push([we,W.clone()]))}ee.push(K)}Ne.push(ee);let se=2*P,ce=2;for(let ue=0;ue<w;ue++){let K=se*ue,ae=se*((ue+1)%w),ne=[_[K]];for(let Y=1;Y<P;Y++){he=_[K+Y],re=_[ae+Y],ne.push(he);for(let le=1,pe=Y-ce+1;le<=pe;le++)S.lerpVectors(he,re,le/(pe+1)),S.sub(z).setLength(J[ue]).add(z),ne.push(S.clone());ne.push(re)}for(let Y=0;Y<P;Y++)ne.push(_[Y+P+K]);ne.push(_[ae+P]);let Ce=T.map(Y=>ne[Y]);c.push(...Ce.map(Y=>[Y.x,Y.y,Y.z]).flat()),h.push(...Ce.map(Y=>(M(Y,z),[W.x,W.y,W.z])).flat())}}let Me=[];for(let k=0;k<b.length;k++)for(let H=0;H<w;H++){let _=b[k][H];if(_<R){let J=b[_].findIndex(se=>se%R==k),ee=Ne[k][H],oe=Ne[_][J];for(let se=0;se<P;se++){let ce=ee[se],ue=oe[P-se],K=ee[se+1],ae=oe[P-(se+1)];[ce,ue,K,K,ue,ae].forEach(ne=>{c.push(ne[0].x,ne[0].y,ne[0].z),h.push(ne[1].x,ne[1].y,ne[1].z)})}Me.push(ee[0][0],oe[P][0],ee[P][0],oe[0][0])}}for(;Me.length;){let k,H,_,J;[k,H]=Me.splice(0,2);let ee=[k];for(;k!=H;)ee.push(H),_=Me.indexOf(H),J=_%2,H=Me.splice(_-J,2)[1-J];W.subVectors(ee[0],ee[1]).cross(S.subVectors(ee[0],ee[2])).normalize();let oe=W.dot(ee[0])<0;oe&&W.negate();for(let se=1;se<=ee.length-2;se++)[ee[se+ +oe],ee[se+1-+oe],ee[0]].forEach(ce=>{c.push(ce.x,ce.y,ce.z),h.push(W.x,W.y,W.z)})}}function x(){let g=new yi;for(let E=0;E<c.length;E+=3){g.x=c[E+0],g.y=c[E+1],g.z=c[E+2];let b=M(g)/2/Math.PI+.5,R=q(g)/Math.PI+.5;f.push(b,1-R)}let w=new yi,S=new yi,D=new yi,C=new yi,G=new Th,B=new Th,P=new Th,W=(E,b,R,T)=>{T<0&&E.x===1&&(f[b]=E.x-1),R.x===0&&R.z===0&&(f[b]=T/2/Math.PI+.5)};for(let E=0,b=0;E<c.length;E+=9,b+=6){w.set(c[E+0],c[E+1],c[E+2]),S.set(c[E+3],c[E+4],c[E+5]),D.set(c[E+6],c[E+7],c[E+8]),G.set(f[b+0],f[b+1]),B.set(f[b+2],f[b+3]),P.set(f[b+4],f[b+5]),C.copy(w).add(S).add(D).divideScalar(3);let R=M(C);W(G,b+0,w,R),W(B,b+2,S,R),W(P,b+4,D,R)}for(let E=0;E<f.length;E+=6){let b=f[E+0],R=f[E+2],T=f[E+4],z=Math.max(b,R,T),A=Math.min(b,R,T);z>.9&&A<.1&&(b<.2&&(f[E+0]+=1),R<.2&&(f[E+2]+=1),T<.2&&(f[E+4]+=1))}function M(E){return Math.atan2(E.z,-E.x)}function q(E){return Math.atan2(-E.y,Math.sqrt(E.x*E.x+E.z*E.z))}}}static fromJSON(e){return new So(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};import{DodecahedronBufferGeometry as UP}from"three";var p0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,height:t,depth:r,detail:n,corner:s,cornerSides:l}=i.parameters,c=n===0&&s!==0?new Wc(e*.5,s,l):new UP(e*.5,n);return c.scale(1,t/e,r/e),Object.assign(c,{userData:fe(U({},i),{type:"DodecahedronGeometry"})})}},Wc=class extends So{constructor(e=1,t=.2,r=4){let n=(1+Math.sqrt(5))/2,s=1/n,l=[-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,-s,-n,0,-s,n,0,s,-n,0,s,n,-s,-n,0,-s,n,0,s,-n,0,s,n,0,-n,0,-s,n,0,-s,-n,0,s,n,0,s],c=[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],f="DodecahedronGeometry";super(l,c,f,e,t,r);this.type=f}static fromJSON(e){return new Wc(e.radius,e.corner,e.cornerSides)}};import{EventDispatcher as QP,Plane as e2,Shape as L0,Vector2 as xi,Vector3 as t2,MathUtils as Bh,LineCurve as Gh,QuadraticBezierCurve as _0,CubicBezierCurve as Jc}from"three";import{CubicBezierCurve as qc,EllipseCurve as kP,LineCurve as $c,LineCurve3 as HP,MathUtils as WP,QuadraticBezierCurve as Ih,SplineCurve as qP,Vector2 as Dn,Vector3 as d0}from"three";var ga=1e-12,ya=class{constructor(e){this.position=new Dn;this.startPosition=new Dn;this.uuid=WP.generateUUID();this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new ya(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},xa=class extends ya{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new xa(this.parent).copy(this)}},Kn=class extends ya{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new xa(this),new xa(this))}static create(e,t){let r=new Kn(e,new Dn(...t.position));return r.controls[0].position.set(...t.controlPrevious.position),r.controls[1].position.set(...t.controlNext.position),r.roundness=t.roundness,r.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,r}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let r=0,n=this.controls.length;r<n;r++){let s=this.controls[r];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.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 Kn(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}},Mh=i=>i,va=new Dn,Ah=new Dn,$P=new Dn,JP=new Dn,KP=new Dn,XP=new Dn,m0=new d0,g0=new d0;function y0(i){let e=new Dn;e.addVectors(i.v0,va.subVectors(i.v1,i.v0).multiplyScalar(2/3));let t=new Dn;return t.addVectors(i.v2,Ah.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new qc(i.v0,e,t,i.v2)}function ba(i,e,t=Number.EPSILON){return Math.abs(i-e)<t}function ZP(i,e,t=Number.EPSILON){return i.distanceTo(e)<t}function YP(i,e,t=Number.EPSILON){return i.distanceTo(e)<t}function Oh(i,e,t){let r=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2));return Math.acos((n*n+r*r-s*s)/(2*n*r))}function x0(i,e,t,r,n){let s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),l=(i.y+e.y)/2,c=(i.x+e.x)/2,f=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(i.y-e.y)/s,h=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(e.x-i.x)/s;return r.set(c+f,l+h),n.set(c-f,l-h),[r,n]}function v0(i,e,t){let r=i.distanceTo(t),n=e.distanceTo(t);return r<n?e:i}function b0(i,e,t,r,n,s){let l=e.x-i.x,c=e.y-i.y,f=t.x-i.x,h=t.y-i.y,d=Math.sqrt((l+f)*(l+f)+(c+h)*(c+h)),x;return Oh(e,i,t)>Math.PI&&(d*=-1),ba(h,c)?x=(c+h)*(r/d-.5)*8/3/(l-f):x=(l+f)*(r/d-.5)*8/3/(h-c),n.set(e.x-x*c,e.y+x*l),s.set(t.x+x*h,t.y-x*f),[n,s]}function Ph(i,e){return i.position.equals(i.controls[1].position)&&e.position.equals(e.controls[0].position)}function S0(i,e,t,r,n=.5){let s=va.subVectors(e,i).multiplyScalar(n).add(i),l=Ah.subVectors(t,e).multiplyScalar(n).add(e),c=$P.subVectors(r,t).multiplyScalar(n).add(t),f=s,h=JP.subVectors(l,s).multiplyScalar(n).add(s),d=KP.subVectors(c,l).multiplyScalar(n).add(l),x=c,g=XP.subVectors(d,h).multiplyScalar(n).add(h);return[i.x,i.y,f.x,f.y,h.x,h.y,g.x,g.y,d.x,d.y,x.x,x.y,r.x,r.y]}function w0(i,e,t=12,r=!0){let n=g0.set(0,0,0),s,l=0,c=[];for(let f=0;f<e.length;f++){let h=Mh(e[f]),d=va,x=qi(h,t);c.push(x);for(let g=0;g<=x;g++)if(h instanceof qc||h instanceof Ih||h instanceof $c){if(h.getPoint(g/x,d),n.set(d.x,d.y,0),s!==void 0&&YP(s,n))continue;s===void 0&&(s=m0),s.copy(n),i.setXYZ(l,n.x,n.y,n.z),l++}}return r&&l>1&&!(i.getX(l-1)===i.getX(0)&&i.getY(l-1)===i.getY(0)&&i.getZ(l-1)===i.getZ(0))&&(i.setXYZ(l,i.getX(0),i.getY(0),i.getZ(0)),l++),i}function N0(i,e,t,r=12,n=!0){let s=g0.set(0,0,0),l=0,c=[];for(let f=0;f<e.length;f++){if(t[f]===!1)continue;let h,d=Mh(e[f]),x=va,g=qi(d,r);c.push(g);for(let w=0;w<=g;w++)if(d instanceof qc||d instanceof Ih||d instanceof $c){if(d.getPoint(w/g,x),s.set(x.x,x.y,0),h==null?void 0:h.equals(s))continue;h===void 0?h=m0:(i.setXYZ(l,h.x,h.y,h.z),l++,i.setXYZ(l,s.x,s.y,s.z),l++),h.copy(s)}}return n&&l>1&&!(i.getX(l-1)===i.getX(0)&&i.getY(l-1)===i.getY(0)&&i.getZ(l-1)===i.getZ(0))&&(i.setXYZ(l,i.getX(0),i.getY(0),i.getZ(0)),l++),c}function Dh(i,e=12,t=!1){let r=[];for(let n=0,s=i.length;n<s;n++){let l=i[n],c=0;if(t&&l.roundedCurveCorner!==void 0){let f=qi(l.roundedCurveCorner,e)*.5;n>0&&(r[n-1]+=f),c+=f}l.curveAfter!==void 0&&(c+=qi(l.curveAfter,e)),r.push(c)}return i.length>0&&t&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=qi(i[0].roundedCurveCorner,e)*.5),r}function qi(i,e=12){return i&&i instanceof kP?e*2:i&&(i instanceof $c||i instanceof HP)?1:i&&i instanceof qP?e*i.points.length:e}function C0(i,e,t=12,r=!0){let n,s=0;for(let l=0;l<e.length;l++){let c=Mh(e[l]),f=qi(c,t),h=va;for(let d=0;d<=f;d++)if(c instanceof qc||c instanceof Ih||c instanceof $c){if(c.getPoint(d/f,h),n!==void 0&&ZP(n,h,ga))continue;n===void 0&&(n=Ah),n.copy(h),i.push(h.x,h.y),s++}}return ba(i[0],i[i.length-2],ga)&&ba(i[1],i[i.length-1],ga)&&(i.pop(),i.pop()),r&&s>1&&!(ba(i[s-1],i[1],ga)&&ba(i[s-2],i[0],ga))&&(i.push(i[0],i[1]),s++),i}var jh=new xi,r2=new xi,n2=new xi,i2=new xi,o2=new xi,s2=new xi,st=class extends L0{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new QP;this.plane=new e2(new t2(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Bh.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,r){let n=new st;return n.isClosed=e.isClosed,n.points=e.points.map(s=>Kn.create(s.id,s.data)),typeof e.roundness=="number"&&(n.roundness=e.roundness),n.shapeHoles=e.shapeHoles.map(s=>st.createFromState(s)),t!==void 0&&r!==void 0&&n.applySize(t,r),n.update(),n}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,r=this.points.length;t<r;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){return this.points.findIndex(t=>t.uuid===e)}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0)for(let t=0,r=this.shapeHoles.length;t<r;t++){let n=this.shapeHoles[t],s=e-this.points.length;if(s<=n.points.length-1)return n.points[s]}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let r=0,n=this.shapeHoles.length;r<n;r++){let s=this.shapeHoles[r],l=s.points.indexOf(e);if(l>=0)return t+l;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let r=jh.set(e,t);for(let n=0,s=this.points.length;n<s;n++){let l=this.points[n];l.position.multiply(r),l.controls[0].position.multiply(r),l.controls[1].position.multiply(r)}for(let n=0,s=this.shapeHoles.length;n<s;n++)this.shapeHoles[n].applyScale(e,t);this._update(!1)}createPoint(e,t=0,r=Bh.generateUUID()){let n;e instanceof xi?n=e:n=new xi(e,t);let s=new Kn(r,n);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,r=this.points.length;t<r;t++){let n=this.points[t];if(n.uuid===e)return n}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(r=>r.uuid===e);t&&this.removePoint(t)}update(e=!0){for(let t=0,r=this.shapeHoles.length;t<r;t++)this.shapeHoles[t].update(!1);this._update(e)}extractShapePointsToBuffer(e,t=12,r=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let n=r?this.roundedCurveDivisions:this.curveDivisions;return w0(e,r?this.roundedCurves:this.curves,t,this.autoClose),n.reduce((s,l)=>s+l,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Dh(this.points,e,!1),this.roundedCurveDivisions=Dh(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,r=12){return N0(e,this.curves,t,r,this.autoClose).reduce((s,l)=>s+l,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),C0(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let r=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let n=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=qi(this.points[0].roundedCurveCorner,this.subdivision)*.5);let l=e-s;l<0&&(l+=n.reduce((c,f)=>c+f,0));for(let c=0,f=n.length;c<f;c++){let h=n[c];if(l<r+h)return[c,(l-r+1)/h];r+=h}return[0,1]}getCurveT(e,t,r){let n=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],l=this.curveDivisions,c=l[e];if(Ph(n,s)){let d=n.position.distanceTo(s.position);return n.position.distanceTo(jh.set(r.x,r.y))/d}let f=0;for(let d=0;d<e;d++)f+=l[d];return(t-f)/c}dispose(){this.eventDispatcher=null}_applyCurveForPoint(e,t){Ph(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let r=this.curves[this.curves.length-1];e.curveBefore=r,t.curveAfter=r;let n=r.clone();e.roundedCurveBefore=n,t.roundedCurveAfter=n,e.roundedCurveCorner=void 0,this.roundedCurves.push(n)}_update(e=!0){var r;if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let n=0,s=this.points.length;n<s;n++){let l=this.points[n];if(n===0)this.moveTo(l.position.x,l.position.y);else{let c=this.points[n-1];this._applyCurveForPoint(l,c)}}let t=this.getLastPoint();if((t==null?void 0:t.curveAfter)&&(t.curveAfter=void 0),this.isClosed){let n=this.points[0],s=this.points[this.points.length-1];this._applyCurveForPoint(n,s)}if(this.points.length>2){let n=0;for(let s=0,l=this.points.length;s<l;s++){let c=this.points[s],f=c.roundness;if(!c.controlsMoved()&&f>0){let h=c.curveBefore,d=c.curveAfter;if(h===void 0||d===void 0)continue;let x=c.roundedCurveBefore,g=c.roundedCurveAfter,w=h.getLength(),S=d.getLength(),D=Math.min(f,w*.499),C=Math.min(f,S*.499),G=Math.min(D,C),B=1-G/w,P=G/S,W=h.getPointAt(B,jh),M=d.getPointAt(P,r2);this._subSplitCurve(h,x,B,W,void 0),this._subSplitCurve(d,g,P,void 0,M);let q;if(this.useCubicForRoundedCorners){let E=Oh(W,c.position,M)/2,b=Math.tan(E)*W.distanceTo(c.position),[R,T]=x0(W,M,b,n2,i2),z=v0(R,T,c.position),[A,$]=b0(z,W,M,b,o2,s2);q=new Jc(W.clone(),A.clone(),$.clone(),M.clone())}else q=new _0(W.clone(),c.position.clone(),M.clone());c.roundedCurveCorner=q,this.roundedCurves.splice(s+n,0,q),n++}}}e&&((r=this.eventDispatcher)==null||r.dispatchEvent({type:"update"}))}_subSplitCurve(e,t,r,n,s){if(e instanceof Gh)n!==void 0&&t.v2.copy(n),s!==void 0&&t.v1.copy(s);else{let l=e,c=t,f=l.getUtoTmapping(r,0),h=S0(l.v0,l.v1,l.v2,l.v3,f);return n!==void 0&&(c.v0.set(h[0],h[1]),c.v1.set(h[2],h[3]),c.v2.set(h[4],h[5]),c.v3.set(h[6],h[7])),s!==void 0&&(c.v0.set(h[6],h[7]),c.v1.set(h[8],h[9]),c.v2.set(h[10],h[11]),c.v3.set(h[12],h[13])),c}return t}clone(){let e=new st(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){var r;this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let n=0;n<t;n++){let s=n*7,l=e.points[s+0],c=e.points[s+1],f=e.points[s+2],h=e.points[s+3],d=e.points[s+4],x=e.points[s+5],g=e.points[s+6],w=new Kn(Bh.generateUUID(),new xi(l,c));w.controls[0].position.set(f,h),w.controls[1].position.set(d,x),w.roundness=g,this.points.push(w)}return this.shapeHoles=((r=e.shapeHoles)==null?void 0:r.length)?e.shapeHoles.map(n=>{let s=new st;return s.fromJSON(n),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(n,s)=>{s instanceof Jc&&s.v3.equals(n.position)&&n.controls[0].position.copy(s.v2)},r=n=>{let s=[],l,c;for(l=0,c=n.length;l<c;l++)n[l]instanceof _0&&(n[l]=y0(n[l]));for(l=0,c=n.length;l<c;l++){let d=n[l],x=l>0?n[l-1]:null,g;d instanceof Jc?(g=this.createPoint(d.v0),g.controls[1].position.copy(d.v1)):d instanceof Gh&&(g=this.createPoint(d.v1)),g!==void 0&&(x!==null&&t(g,x),s.push(g))}let f=n[n.length-1],h=!1;return f instanceof Jc?f.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(f.v2),h=!0):f instanceof Gh&&f.v2.equals(s[0].position)&&(h=!0),this.isClosed=h,s};return this.points=r(e.curves),e instanceof L0&&(this.shapeHoles=e.holes.map(n=>{let s=new st;return s.fromShape(n),s})),this.update(),this}};var Eh=Math.PI*2;function Rh({x:i,y:e},t,r,n,s){return{x:i*t+n,y:e*r+s}}function a2(i,e){let t=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:4/3*Math.tan(e/4),r=Math.cos(i),n=Math.sin(i),s=Math.cos(i+e),l=Math.sin(i+e);return[{x:r-n*t,y:n+r*t},{x:s+l*t,y:l-s*t},{x:s,y:l}]}function T0(i,e,t,r){let n=i*r-e*t<0?-1:1,s=Math.min(1,Math.max(-1,i*t+e*r));return n*Math.acos(s)}function l2(i,e,t,r,n,s,l,c,f,h){let d=Math.pow(n,2),x=Math.pow(s,2),g=Math.pow(l,2),w=Math.pow(c,2),S=d*x-d*w-x*g;S<0&&(S=0),S/=d*w+x*g,S=Math.sqrt(S)*(f===h?-1:1);let D=S*n/s*c,C=S*-s/n*l,G=D+(i+t)/2,B=C+(e+r)/2,P=(l-D)/n,W=(c-C)/s,M=(-l-D)/n,q=(-c-C)/s,E=T0(1,0,P,W),b=T0(P,W,M,q);return!h&&b>0&&(b-=Eh),h&&b<0&&(b+=Eh),{centerx:G,centery:B,ang1:E,ang2:b}}function I0({px:i,py:e,cx:t,cy:r,rx:n,ry:s,largeArcFlag:l,sweepFlag:c}){let f=[];if(n===0||s===0)return[];let h=(i-t)/2,d=(e-r)/2;if(h===0&&d===0)return[];n=Math.abs(n),s=Math.abs(s);let x=Math.pow(h,2)/Math.pow(n,2)+Math.pow(d,2)/Math.pow(s,2);x>1&&(n*=Math.sqrt(x),s*=Math.sqrt(x));let g=l2(i,e,t,r,n,s,h,d,l,c),{ang1:w,ang2:S}=g,{centerx:D,centery:C}=g,G=Math.abs(S)/(Eh/4);Math.abs(1-G)<1e-7&&(G=1);let B=Math.max(Math.ceil(G),1);S/=B;for(let P=0;P<B;P++)f.push(a2(w,S)),w+=S;return f.map(P=>{let{x:W,y:M}=Rh(P[0],n,s,D,C),{x:q,y:E}=Rh(P[1],n,s,D,C),{x:b,y:R}=Rh(P[2],n,s,D,C);return{x1:W,y1:M,x2:q,y2:E,x:b,y:R}})}import{BufferAttribute as Xc,BufferGeometry as p2}from"three";var Pt;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Pt||(Pt={}));var Qt;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Qt||(Qt={}));function Ae(i,e){if(!i)throw e||"Assertion Failed!"}var Te=function(){function i(){}return i.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},i.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},i.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},i.edgeGoesLeft=function(e){return i.vertLeq(e.Dst,e.Org)},i.edgeGoesRight=function(e){return i.vertLeq(e.Org,e.Dst)},i.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},i.edgeEval=function(e,t,r){Ae(i.vertLeq(e,t)&&i.vertLeq(t,r));var n=t.s-e.s,s=r.s-t.s;return n+s>0?n<s?t.t-e.t+(e.t-r.t)*(n/(n+s)):t.t-r.t+(r.t-e.t)*(s/(n+s)):0},i.edgeSign=function(e,t,r){Ae(i.vertLeq(e,t)&&i.vertLeq(t,r));var n=t.s-e.s,s=r.s-t.s;return n+s>0?(t.t-r.t)*n+(t.t-e.t)*s:0},i.transEval=function(e,t,r){Ae(i.transLeq(e,t)&&i.transLeq(t,r));var n=t.t-e.t,s=r.t-t.t;return n+s>0?n<s?t.s-e.s+(e.s-r.s)*(n/(n+s)):t.s-r.s+(r.s-e.s)*(s/(n+s)):0},i.transSign=function(e,t,r){Ae(i.transLeq(e,t)&&i.transLeq(t,r));var n=t.t-e.t,s=r.t-t.t;return n+s>0?(t.s-r.s)*n+(t.s-e.s)*s:0},i.vertCCW=function(e,t,r){return e.s*(t.t-r.t)+t.s*(r.t-e.t)+r.s*(e.t-t.t)>=0},i.interpolate=function(e,t,r,n){return e=e<0?0:e,r=r<0?0:r,e<=r?r===0?(t+n)/2:t+(n-t)*(e/(e+r)):n+(t-n)*(r/(e+r))},i.intersect=function(e,t,r,n,s){var l,c,f;i.vertLeq(e,t)||(f=e,e=t,t=f),i.vertLeq(r,n)||(f=r,r=n,n=f),i.vertLeq(e,r)||(f=e,e=r,r=f,f=t,t=n,n=f),i.vertLeq(r,t)?i.vertLeq(t,n)?(l=i.edgeEval(e,r,t),c=i.edgeEval(r,t,n),l+c<0&&(l=-l,c=-c),s.s=i.interpolate(l,r.s,c,t.s)):(l=i.edgeSign(e,r,t),c=-i.edgeSign(e,n,t),l+c<0&&(l=-l,c=-c),s.s=i.interpolate(l,r.s,c,n.s)):s.s=(r.s+t.s)/2,i.transLeq(e,t)||(f=e,e=t,t=f),i.transLeq(r,n)||(f=r,r=n,n=f),i.transLeq(e,r)||(f=e,e=r,r=f,f=t,t=n,n=f),i.transLeq(r,t)?i.transLeq(t,n)?(l=i.transEval(e,r,t),c=i.transEval(r,t,n),l+c<0&&(l=-l,c=-c),s.t=i.interpolate(l,r.t,c,t.t)):(l=i.transSign(e,r,t),c=-i.transSign(e,n,t),l+c<0&&(l=-l,c=-c),s.t=i.interpolate(l,r.t,c,n.t)):s.t=(r.t+t.t)/2},i}(),Sa=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),Kc=function(){function i(e){this.side=e,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),i}(),Ns=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return i}(),M0=function(){function i(){var e=new Ns,t=new Sa,r=new Kc(0),n=new Kc(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,r.next=r,r.Sym=n,n.next=n,n.Sym=r,this.vHead=e,this.fHead=t,this.eHead=r,this.eHeadSym=n}return i.prototype.makeEdge_=function(e){var t=new Kc(0),r=new Kc(1);e.Sym.side<e.side&&(e=e.Sym);var n=e.Sym.next;return r.next=n,n.Sym.next=t,t.next=e,e.Sym.next=r,t.Sym=r,t.Onext=t,t.Lnext=r,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,r.Sym=t,r.Onext=r,r.Lnext=t,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,t},i.prototype.splice_=function(e,t){var r=e.Onext,n=t.Onext;r.Sym.Lnext=t,n.Sym.Lnext=e,e.Onext=n,t.Onext=r},i.prototype.makeVertex_=function(e,t,r){var n=e;Ae(n,"Vertex can't be null!");var s=r.prev;n.prev=s,s.next=n,n.next=r,r.prev=n,n.anEdge=t;var l=t;do l.Org=n,l=l.Onext;while(l!==t)},i.prototype.makeFace_=function(e,t,r){var n=e;Ae(n,"Face can't be null");var s=r.prev;n.prev=s,s.next=n,n.next=r,r.prev=n,n.anEdge=t,n.trail=null,n.marked=!1,n.inside=r.inside;var l=t;do l.Lface=n,l=l.Lnext;while(l!==t)},i.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,r=e.Sym.next;t.Sym.next=r,r.Sym.next=t},i.prototype.killVertex_=function(e,t){var r=e.anEdge,n=r;do n.Org=t,n=n.Onext;while(n!==r);var s=e.prev,l=e.next;l.prev=s,s.next=l},i.prototype.killFace_=function(e,t){var r=e.anEdge,n=r;do n.Lface=t,n=n.Lnext;while(n!==r);var s=e.prev,l=e.next;l.prev=s,s.next=l},i.prototype.makeEdge=function(){var e=new Ns,t=new Ns,r=new Sa,n=this.makeEdge_(this.eHead);return this.makeVertex_(e,n,this.vHead),this.makeVertex_(t,n.Sym,this.vHead),this.makeFace_(r,n,this.fHead),n},i.prototype.splice=function(e,t){var r=!1,n=!1;if(e!==t){if(t.Org!==e.Org&&(n=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!n){var s=new Ns;this.makeVertex_(s,t,e.Org),e.Org.anEdge=e}if(!r){var l=new Sa;this.makeFace_(l,t,e.Lface),e.Lface.anEdge=e}}},i.prototype.delete=function(e){var t=e.Sym,r=!1;if(e.Lface!==e.Rface&&(r=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!r){var n=new Sa;this.makeFace_(n,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},i.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),r=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var n=new Ns;return this.makeVertex_(n,r,t.Org),t.Lface=r.Lface=e.Lface,t},i.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e),r=t.Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,r),e.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=e.Rface,r.winding=e.winding,r.Sym.winding=e.Sym.winding,r.idx=e.idx,r.Sym.idx=e.Sym.idx,r},i.prototype.connect=function(e,t){var r=!1,n=this.makeEdge_(e),s=n.Sym;if(t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(n,e.Lnext),this.splice_(s,t),n.Org=e.Dst,s.Org=t.Org,n.Lface=s.Lface=e.Lface,e.Lface.anEdge=s,!r){var l=new Sa;this.makeFace_(l,n,e.Lface)}return n},i.prototype.zapFace=function(e){var t=e.anEdge,r,n,s,l,c;n=t.Lnext;do r=n,n=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)),s=r.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=t);l=e.prev,c=e.next,c.prev=l,l.next=c},i.prototype.countFaceVerts_=function(e){var t=e.anEdge,r=0;do r++,t=t.Lnext;while(t!==e.anEdge);return r},i.prototype.mergeConvexFaces=function(e){var t,r,n,s,l,c,f;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(!!t.inside)for(r=t.anEdge,l=r.Org;n=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(c=this.countFaceVerts_(t),f=this.countFaceVerts_(s.Lface),c+f-2<=e&&Te.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&Te.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(n=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===l);)r=n;return!0},i.prototype.check=function(){var e=this.fHead,t=this.vHead,r=this.eHead,n,s,l,c,f,h;for(s=e,s=e;(n=s.next)!==e;s=n){Ae(n.prev===s),f=n.anEdge;do Ae(f.Sym!==f),Ae(f.Sym.Sym===f),Ae(f.Lnext.Onext.Sym===f),Ae(f.Onext.Sym.Lnext===f),Ae(f.Lface===n),f=f.Lnext;while(f!==n.anEdge)}for(Ae(n.prev===s&&n.anEdge===null),c=t,c=t;(l=c.next)!==t;c=l){Ae(l.prev===c),f=l.anEdge;do Ae(f.Sym!==f),Ae(f.Sym.Sym===f),Ae(f.Lnext.Onext.Sym===f),Ae(f.Onext.Sym.Lnext===f),Ae(f.Org===l),f=f.Onext;while(f!==l.anEdge)}for(Ae(l.prev===c&&l.anEdge===null),h=r,h=r;(f=h.next)!==r;h=f)Ae(f.Sym.next===h.Sym),Ae(f.Sym!==f),Ae(f.Sym.Sym===f),Ae(f.Org!==null),Ae(f.Dst!==null),Ae(f.Lnext.Onext.Sym===f),Ae(f.Onext.Sym.Lnext===f);Ae(f.Sym.next===h.Sym&&f.Sym===this.eHeadSym&&f.Sym.Sym===f&&f.Org===null&&f.Dst===null&&f.Lface===null&&f.Rface===null)},i}(),A0=function(){function i(){this.handle=null}return i}(),O0=function(){function i(){this.key=null,this.node=0}return i}(),c2=function(){function i(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var r=0;r<e+1;r++)this.nodes[r]=new A0,this.handles[r]=new O0;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(e){var t=this.nodes,r=this.handles,n,s,l;for(n=t[e].handle;;){if(l=e<<1,l<this.size&&this.leq(r[t[l+1].handle].key,r[t[l].handle].key)&&++l,Ae(l<=this.max),s=t[l].handle,l>this.size||this.leq(r[n].key,r[s].key)){t[e].handle=n,r[n].node=e;break}t[e].handle=s,r[s].node=e,e=l}},i.prototype.floatUp_=function(e){var t=this.nodes,r=this.handles,n,s,l;for(n=t[e].handle;;){if(l=e>>1,s=t[l].handle,l===0||this.leq(r[s].key,r[n].key)){t[e].handle=n,r[n].node=e;break}t[e].handle=s,r[s].node=e,e=l}},i.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(e){var t,r;if(t=++this.size,t*2>this.max){this.max*=2;var n,s;for(s=this.nodes.length,this.nodes.length=this.max+1,n=s;n<this.nodes.length;n++)this.nodes[n]=new A0;for(s=this.handles.length,this.handles.length=this.max+1,n=s;n<this.handles.length;n++)this.handles[n]=new O0}return this.freeList===0?r=t:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[t].handle=r,this.handles[r].node=t,this.handles[r].key=e,this.initialized&&this.floatUp_(t),r},i.prototype.extractMin=function(){var e=this.nodes,t=this.handles,r=e[1].handle,n=t[r].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[r].key=null,t[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),n},i.prototype.delete=function(e){var t=this.nodes,r=this.handles,n;Ae(e>=1&&e<=this.max&&r[e].key!==null),n=r[e].node,t[n].handle=t[this.size].handle,r[t[n].handle].node=n,--this.size,n<=this.size&&(n<=1||this.leq(r[t[n>>1].handle].key,r[t[n].handle].key)?this.floatDown_(n):this.floatUp_(n)),r[e].key=null,r[e].node=this.freeList,this.freeList=e},i}(),zh=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),P0=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),u2=function(){function i(e,t){this.frame=e,this.leq=t,this.head=new P0,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(e){return this.insertBefore(this.head,e)},i.prototype.search=function(e){var t=this.head;do t=t.next;while(t.key!==null&&!this.leq(this.frame,e,t.key));return t},i.prototype.insertBefore=function(e,t){do e=e.prev;while(e.key!==null&&!this.leq(this.frame,e.key,t));var r=new P0;return r.key=t,r.next=e.next,e.next.prev=r,r.prev=e,e.next=r,r},i.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},i}(),f2=function(){function i(){}return i.regionBelow=function(e){return e.nodeUp.prev.key},i.regionAbove=function(e){return e.nodeUp.next.key},i.debugEvent=function(e){},i.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},i.edgeLeq=function(e,t,r){var n=e.event,s=t.eUp,l=r.eUp;if(s.Dst===n)return l.Dst===n?Te.vertLeq(s.Org,l.Org)?Te.edgeSign(l.Dst,s.Org,l.Org)<=0:Te.edgeSign(s.Dst,l.Org,s.Org)>=0:Te.edgeSign(l.Dst,n,l.Org)<=0;if(l.Dst===n)return Te.edgeSign(s.Dst,n,s.Org)>=0;var c=Te.edgeEval(s.Dst,n,s.Org),f=Te.edgeEval(l.Dst,n,l.Org);return c>=f},i.deleteRegion=function(e,t){t.fixUpperEdge&&Ae(t.eUp.winding===0),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},i.fixUpperEdge=function(e,t,r){Ae(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=r,r.activeRegion=t},i.topLeftRegion=function(e,t){var r=t.eUp.Org,n;do t=i.regionAbove(t);while(t.eUp.Org===r);if(t.fixUpperEdge){if(n=e.mesh.connect(i.regionBelow(t).eUp.Sym,t.eUp.Lnext),n===null)return null;i.fixUpperEdge(e,t,n),t=i.regionAbove(t)}return t},i.topRightRegion=function(e){var t=e.eUp.Dst;do e=i.regionAbove(e);while(e.eUp.Dst===t);return e},i.addRegionBelow=function(e,t,r){var n=new zh;return n.eUp=r,n.nodeUp=e.dict.insertBefore(t.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,r.activeRegion=n,n},i.isWindingInside=function(e,t){switch(e.windingRule){case Pt.ODD:return(t&1)!=0;case Pt.NONZERO:return t!==0;case Pt.POSITIVE:return t>0;case Pt.NEGATIVE:return t<0;case Pt.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(e,t){t.windingNumber=i.regionAbove(t).windingNumber+t.eUp.winding,t.inside=i.isWindingInside(e,t.windingNumber)},i.finishRegion=function(e,t){var r=t.eUp,n=r.Lface;n.inside=t.inside,n.anEdge=r,i.deleteRegion(e,t)},i.finishLeftRegions=function(e,t,r){for(var n,s=null,l=t,c=t.eUp;l!==r;){if(l.fixUpperEdge=!1,s=i.regionBelow(l),n=s.eUp,n.Org!=c.Org){if(!s.fixUpperEdge){i.finishRegion(e,l);break}n=e.mesh.connect(c.Lprev,n.Sym),i.fixUpperEdge(e,s,n)}c.Onext!==n&&(e.mesh.splice(n.Oprev,n),e.mesh.splice(c,n)),i.finishRegion(e,l),c=s.eUp,l=s}return c},i.addRightEdges=function(e,t,r,n,s,l){var c,f,h,d,x=!0;h=r;do Ae(Te.vertLeq(h.Org,h.Dst)),i.addRegionBelow(e,t,h.Sym),h=h.Onext;while(h!==n);for(s===null&&(s=i.regionBelow(t).eUp.Rprev),f=t,d=s;c=i.regionBelow(f),h=c.eUp.Sym,h.Org===d.Org;)h.Onext!==d&&(e.mesh.splice(h.Oprev,h),e.mesh.splice(d.Oprev,h)),c.windingNumber=f.windingNumber-h.winding,c.inside=i.isWindingInside(e,c.windingNumber),f.dirty=!0,!x&&i.checkForRightSplice(e,f)&&(i.addWinding(h,d),i.deleteRegion(e,f),e.mesh.delete(d)),x=!1,f=c,d=h;f.dirty=!0,Ae(f.windingNumber-h.winding===c.windingNumber),l&&i.walkDirtyRegions(e,f)},i.spliceMergeVertices=function(e,t,r){e.mesh.splice(t,r)},i.vertexWeights=function(e,t,r){var n=Te.vertL1dist(t,e),s=Te.vertL1dist(r,e),l=.5*s/(n+s),c=.5*n/(n+s);e.coords[0]+=l*t.coords[0]+c*r.coords[0],e.coords[1]+=l*t.coords[1]+c*r.coords[1],e.coords[2]+=l*t.coords[2]+c*r.coords[2]},i.getIntersectData=function(e,t,r,n,s,l){t.coords[0]=t.coords[1]=t.coords[2]=0,t.idx=-1,i.vertexWeights(t,r,n),i.vertexWeights(t,s,l)},i.checkForRightSplice=function(e,t){var r=i.regionBelow(t),n=t.eUp,s=r.eUp;if(Te.vertLeq(n.Org,s.Org)){if(Te.edgeSign(s.Dst,n.Org,s.Org)>0)return!1;Te.vertEq(n.Org,s.Org)?n.Org!==s.Org&&(e.pq.delete(n.Org.pqHandle),i.spliceMergeVertices(e,s.Oprev,n)):(e.mesh.splitEdge(s.Sym),e.mesh.splice(n,s.Oprev),t.dirty=r.dirty=!0)}else{if(Te.edgeSign(n.Dst,s.Org,n.Org)<0)return!1;i.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(n.Sym),e.mesh.splice(s.Oprev,n)}return!0},i.checkForLeftSplice=function(e,t){var r=i.regionBelow(t),n=t.eUp,s=r.eUp,l;if(Ae(!Te.vertEq(n.Dst,s.Dst)),Te.vertLeq(n.Dst,s.Dst)){if(Te.edgeSign(n.Dst,s.Dst,n.Org)<0)return!1;i.regionAbove(t).dirty=t.dirty=!0,l=e.mesh.splitEdge(n),e.mesh.splice(s.Sym,l),l.Lface.inside=t.inside}else{if(Te.edgeSign(s.Dst,n.Dst,s.Org)>0)return!1;t.dirty=r.dirty=!0,l=e.mesh.splitEdge(s),e.mesh.splice(n.Lnext,s.Sym),l.Rface.inside=t.inside}return!0},i.checkForIntersect=function(e,t){var r=i.regionBelow(t),n=t.eUp,s=r.eUp,l=n.Org,c=s.Org,f=n.Dst,h=s.Dst,d,x,g=new Ns,w,S;if(Ae(!Te.vertEq(h,f)),Ae(Te.edgeSign(f,e.event,l)<=0),Ae(Te.edgeSign(h,e.event,c)>=0),Ae(l!==e.event&&c!==e.event),Ae(!t.fixUpperEdge&&!r.fixUpperEdge),l===c||(d=Math.min(l.t,f.t),x=Math.max(c.t,h.t),d>x))return!1;if(Te.vertLeq(l,c)){if(Te.edgeSign(h,l,c)>0)return!1}else if(Te.edgeSign(f,c,l)<0)return!1;return i.debugEvent(e),Te.intersect(f,l,h,c,g),Ae(Math.min(l.t,f.t)<=g.t),Ae(g.t<=Math.max(c.t,h.t)),Ae(Math.min(h.s,f.s)<=g.s),Ae(g.s<=Math.max(c.s,l.s)),Te.vertLeq(g,e.event)&&(g.s=e.event.s,g.t=e.event.t),w=Te.vertLeq(l,c)?l:c,Te.vertLeq(w,g)&&(g.s=w.s,g.t=w.t),Te.vertEq(g,l)||Te.vertEq(g,c)?(i.checkForRightSplice(e,t),!1):!Te.vertEq(f,e.event)&&Te.edgeSign(f,e.event,g)>=0||!Te.vertEq(h,e.event)&&Te.edgeSign(h,e.event,g)<=0?h===e.event?(e.mesh.splitEdge(n.Sym),e.mesh.splice(s.Sym,n),t=i.topLeftRegion(e,t),n=i.regionBelow(t).eUp,i.finishLeftRegions(e,i.regionBelow(t),r),i.addRightEdges(e,t,n.Oprev,n,n,!0),!0):f===e.event?(e.mesh.splitEdge(s.Sym),e.mesh.splice(n.Lnext,s.Oprev),r=t,t=i.topRightRegion(t),S=i.regionBelow(t).eUp.Rprev,r.eUp=s.Oprev,s=i.finishLeftRegions(e,r,null),i.addRightEdges(e,t,s.Onext,n.Rprev,S,!0),!0):(Te.edgeSign(f,e.event,g)>=0&&(i.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(n.Sym),n.Org.s=e.event.s,n.Org.t=e.event.t),Te.edgeSign(h,e.event,g)<=0&&(t.dirty=r.dirty=!0,e.mesh.splitEdge(s.Sym),s.Org.s=e.event.s,s.Org.t=e.event.t),!1):(e.mesh.splitEdge(n.Sym),e.mesh.splitEdge(s.Sym),e.mesh.splice(s.Oprev,n),n.Org.s=g.s,n.Org.t=g.t,n.Org.pqHandle=e.pq.insert(n.Org),i.getIntersectData(e,n.Org,l,f,c,h),i.regionAbove(t).dirty=t.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(e,t){for(var r=i.regionBelow(t),n,s;;){for(;r.dirty;)t=r,r=i.regionBelow(r);if(!t.dirty&&(r=t,t=i.regionAbove(t),t===null||!t.dirty))return;if(t.dirty=!1,n=t.eUp,s=r.eUp,n.Dst!==s.Dst&&i.checkForLeftSplice(e,t)&&(r.fixUpperEdge?(i.deleteRegion(e,r),e.mesh.delete(s),r=i.regionBelow(t),s=r.eUp):t.fixUpperEdge&&(i.deleteRegion(e,t),e.mesh.delete(n),t=i.regionAbove(r),n=t.eUp)),n.Org!==s.Org)if(n.Dst!==s.Dst&&!t.fixUpperEdge&&!r.fixUpperEdge&&(n.Dst===e.event||s.Dst===e.event)){if(i.checkForIntersect(e,t))return}else i.checkForRightSplice(e,t);n.Org===s.Org&&n.Dst===s.Dst&&(i.addWinding(s,n),i.deleteRegion(e,t),e.mesh.delete(n),t=i.regionAbove(r))}},i.connectRightVertex=function(e,t,r){var n,s=r.Onext,l=i.regionBelow(t),c=t.eUp,f=l.eUp,h=!1;if(c.Dst!==f.Dst&&i.checkForIntersect(e,t),Te.vertEq(c.Org,e.event)&&(e.mesh.splice(s.Oprev,c),t=i.topLeftRegion(e,t),s=i.regionBelow(t).eUp,i.finishLeftRegions(e,i.regionBelow(t),l),h=!0),Te.vertEq(f.Org,e.event)&&(e.mesh.splice(r,f.Oprev),r=i.finishLeftRegions(e,l,null),h=!0),h){i.addRightEdges(e,t,r.Onext,s,s,!0);return}Te.vertLeq(f.Org,c.Org)?n=f.Oprev:n=c,n=e.mesh.connect(r.Lprev,n),i.addRightEdges(e,t,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(e,t)},i.connectLeftDegenerate=function(e,t,r){var n,s,l,c,f;if(n=t.eUp,Te.vertEq(n.Org,r)){Ae(!1),i.spliceMergeVertices(e,n,r.anEdge);return}if(!Te.vertEq(n.Dst,r)){e.mesh.splitEdge(n.Sym),t.fixUpperEdge&&(e.mesh.delete(n.Onext),t.fixUpperEdge=!1),e.mesh.splice(r.anEdge,n),i.sweepEvent(e,r);return}Ae(!1),t=i.topRightRegion(t),f=i.regionBelow(t),l=f.eUp.Sym,s=c=l.Onext,f.fixUpperEdge&&(Ae(s!==l),i.deleteRegion(e,f),e.mesh.delete(l),l=s.Oprev),e.mesh.splice(r.anEdge,l),Te.edgeGoesLeft(s)||(s=null),i.addRightEdges(e,t,l.Onext,c,s,!0)},i.connectLeftVertex=function(e,t){var r,n,s,l,c,f,h=new zh;if(h.eUp=t.anEdge.Sym,r=e.dict.search(h).key,n=i.regionBelow(r),!!n){if(l=r.eUp,c=n.eUp,Te.edgeSign(l.Dst,t,l.Org)===0){i.connectLeftDegenerate(e,r,t);return}if(s=Te.vertLeq(c.Dst,l.Dst)?r:n,r.inside||s.fixUpperEdge){if(s===r)f=e.mesh.connect(t.anEdge.Sym,l.Lnext);else{var d=e.mesh.connect(c.Dnext,t.anEdge);f=d.Sym}s.fixUpperEdge?i.fixUpperEdge(e,s,f):i.computeWinding(e,i.addRegionBelow(e,r,f)),i.sweepEvent(e,t)}else i.addRightEdges(e,r,t.anEdge,t.anEdge,null,!0)}},i.sweepEvent=function(e,t){e.event=t,i.debugEvent(e);for(var r=t.anEdge;r.activeRegion===null;)if(r=r.Onext,r===t.anEdge){i.connectLeftVertex(e,t);return}var n=i.topLeftRegion(e,r.activeRegion);Ae(n!==null);var s=i.regionBelow(n),l=s.eUp,c=i.finishLeftRegions(e,s,null);c.Onext===l?i.connectRightVertex(e,n,c):i.addRightEdges(e,n,c.Onext,l,l,!0)},i.addSentinel=function(e,t,r,n){var s=new zh,l=e.mesh.makeEdge();l.Org.s=r,l.Org.t=n,l.Dst.s=t,l.Dst.t=n,e.event=l.Dst,s.eUp=l,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=e.dict.insert(s)},i.initEdgeDict=function(e){e.dict=new u2(e,i.edgeLeq);var t=e.bmax[0]-e.bmin[0],r=e.bmax[1]-e.bmin[1],n=e.bmin[0]-t,s=e.bmax[0]+t,l=e.bmin[1]-r,c=e.bmax[1]+r;i.addSentinel(e,n,s,l),i.addSentinel(e,n,s,c)},i.doneEdgeDict=function(e){for(var t,r=0;(t=e.dict.min().key)!==null;)t.sentinel||(Ae(t.fixUpperEdge),Ae(++r==1)),Ae(t.windingNumber===0),i.deleteRegion(e,t)},i.removeDegenerateEdges=function(e){var t,r,n,s=e.mesh.eHead;for(t=s.next;t!==s;t=r)r=t.next,n=t.Lnext,Te.vertEq(t.Org,t.Dst)&&t.Lnext.Lnext!==t&&(i.spliceMergeVertices(e,n,t),e.mesh.delete(t),t=n,n=t.Lnext),n.Lnext===t&&(n!==t&&((n===r||n===r.Sym)&&(r=r.next),e.mesh.delete(n)),(t===r||t===r.Sym)&&(r=r.next),e.mesh.delete(t))},i.initPriorityQ=function(e){var t,r,n,s=0;for(n=e.mesh.vHead,r=n.next;r!==n;r=r.next)s++;for(s+=8,t=e.pq=new c2(s,Te.vertLeq),n=e.mesh.vHead,r=n.next;r!==n;r=r.next)r.pqHandle=t.insert(r);return r!==n?!1:(t.init(),!0)},i.donePriorityQ=function(e){e.pq=null},i.removeDegenerateFaces=function(e,t){var r,n,s;for(r=t.fHead.next;r!==t.fHead;r=n)n=r.next,s=r.anEdge,Ae(s.Lnext!==s),s.Lnext.Lnext===s&&(i.addWinding(s.Onext,s),e.mesh.delete(s));return!0},i.computeInterior=function(e,t){t===void 0&&(t=!0);var r,n;if(i.removeDegenerateEdges(e),!i.initPriorityQ(e))return!1;for(i.initEdgeDict(e);(r=e.pq.extractMin())!==null;){for(;n=e.pq.min(),!(n===null||!Te.vertEq(n,r));)n=e.pq.extractMin(),i.spliceMergeVertices(e,r.anEdge,n.anEdge);i.sweepEvent(e,r)}return e.event=e.dict.min().key.eUp.Org,i.debugEvent(e),i.doneEdgeDict(e),i.donePriorityQ(e),i.removeDegenerateFaces(e,e.mesh)?(t&&e.mesh.check(),!0):!1},i}(),h2=function(){function i(){this.mesh=new M0,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=Pt.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},i.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},i.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},i.prototype.computeNormal_=function(e){var t,r,n,s,l,c,f=[0,0,0],h=[0,0,0],d=[0,0,0],x=[0,0,0],g=[0,0,0],w=[null,null,null],S=[null,null,null],D=this.mesh.vHead;t=D.next;for(var C=0;C<3;++C)s=t.coords[C],h[C]=s,S[C]=t,f[C]=s,w[C]=t;for(t=D.next;t!==D;t=t.next)for(var G=0;G<3;++G)s=t.coords[G],s<h[G]&&(h[G]=s,S[G]=t),s>f[G]&&(f[G]=s,w[G]=t);var B=0;if(f[1]-h[1]>f[0]-h[0]&&(B=1),f[2]-h[2]>f[B]-h[B]&&(B=2),h[B]>=f[B]){e[0]=0,e[1]=0,e[2]=1;return}for(c=0,r=S[B],n=w[B],d[0]=r.coords[0]-n.coords[0],d[1]=r.coords[1]-n.coords[1],d[2]=r.coords[2]-n.coords[2],t=D.next;t!==D;t=t.next)x[0]=t.coords[0]-n.coords[0],x[1]=t.coords[1]-n.coords[1],x[2]=t.coords[2]-n.coords[2],g[0]=d[1]*x[2]-d[2]*x[1],g[1]=d[2]*x[0]-d[0]*x[2],g[2]=d[0]*x[1]-d[1]*x[0],l=g[0]*g[0]+g[1]*g[1]+g[2]*g[2],l>c&&(c=l,e[0]=g[0],e[1]=g[1],e[2]=g[2]);c<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(d)]=1)},i.prototype.checkOrientation_=function(){for(var e=this.mesh.fHead,t,r=this.mesh.vHead,n,s=0,l=e.next;l!==e;l=l.next)if(n=l.anEdge,!(n.winding<=0))do s+=(n.Org.s-n.Dst.s)*(n.Org.t+n.Dst.t),n=n.Lnext;while(n!==l.anEdge);if(s<0){for(t=r.next;t!==r;t=t.next)t.t=-t.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var e=this.mesh.vHead,t=[0,0,0],r,n,s=!1;t[0]=this.normal[0],t[1]=this.normal[1],t[2]=this.normal[2],!t[0]&&!t[1]&&!t[2]&&(this.computeNormal_(t),s=!0),r=this.sUnit,n=this.tUnit;var l=this.longAxis_(t);r[l]=0,r[(l+1)%3]=1,r[(l+2)%3]=0,n[l]=0,n[(l+1)%3]=0,n[(l+2)%3]=t[l]>0?1:-1;for(var c=e.next;c!==e;c=c.next)c.s=this.dot_(c.coords,r),c.t=this.dot_(c.coords,n);s&&this.checkOrientation_();for(var f=!0,h=e.next;h!==e;h=h.next)f?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,f=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},i.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},i.prototype.tessellateMonoRegion_=function(e,t){var r,n;if(r=t.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Te.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Te.vertLeq(r.Org,r.Dst);r=r.Lnext);n=r.Lprev;for(var s=void 0;r.Lnext!==n;)if(Te.vertLeq(r.Dst,n.Org)){for(;n.Lnext!==r&&(Te.edgeGoesLeft(n.Lnext)||Te.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)s=e.connect(n.Lnext,n),n=s.Sym;n=n.Lprev}else{for(;n.Lnext!==r&&(Te.edgeGoesRight(r.Lprev)||Te.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=e.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(n.Lnext===r)throw"Mono region invalid";for(;n.Lnext.Lnext!==r;)s=e.connect(n.Lnext,n),n=s.Sym;return!0},i.prototype.tessellateInterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)if(t=r.next,r.inside&&!this.tessellateMonoRegion_(e,r))return!1;return!0},i.prototype.discardExterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)t=r.next,r.inside||e.zapFace(r)},i.prototype.setWindingNumber_=function(e,t,r){for(var n,s=e.eHead.next;s!==e.eHead;s=n)n=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?t:-t:r?e.delete(s):s.winding=0},i.prototype.getNeighbourFace_=function(e){return!e.Rface||!e.Rface.inside?-1:e.Rface.n},i.prototype.outputPolymesh_=function(e,t,r,n){var s,l=0,c=0,f;r>3&&e.mergeConvexFaces(r);for(var h=e.vHead.next;h!==e.vHead;h=h.next)h.n=-1;for(var d=e.fHead.next;d!==e.fHead;d=d.next)if(d.n=-1,!!d.inside){s=d.anEdge,f=0;do{var h=s.Org;h.n===-1&&(h.n=c,c++),f++,s=s.Lnext}while(s!==d.anEdge);if(f>r)throw"Face vertex greater that support polygon";d.n=l,++l}this.elementCount=l,t===Qt.CONNECTED_POLYGONS&&(l*=2),this.elements=[],this.elements.length=l*r,this.vertexCount=c,this.vertices=[],this.vertices.length=c*n,this.vertexIndices=[],this.vertexIndices.length=c;for(var h=e.vHead.next;h!==e.vHead;h=h.next)if(h.n!==-1){var x=h.n*n;this.vertices[x+0]=h.coords[0],this.vertices[x+1]=h.coords[1],n>2&&(this.vertices[x+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var g=0,d=e.fHead.next;d!==e.fHead;d=d.next)if(!!d.inside){s=d.anEdge,f=0;do{var h=s.Org;this.elements[g++]=h.n,f++,s=s.Lnext}while(s!==d.anEdge);for(var w=f;w<r;++w)this.elements[g++]=-1;if(t===Qt.CONNECTED_POLYGONS){s=d.anEdge;do this.elements[g++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==d.anEdge);for(var S=f;S<r;++S)this.elements[g++]=-1}}},i.prototype.outputContours_=function(e,t){var r,n,s=0,l=0;this.vertexCount=0,this.elementCount=0;for(var c=e.fHead.next;c!==e.fHead;c=c.next)if(!!c.inside){n=r=c.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==n);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var f=0,h=0,d=0;s=0;for(var c=e.fHead.next;c!==e.fHead;c=c.next)if(!!c.inside){l=0,n=r=c.anEdge;do this.vertices[f++]=r.Org.coords[0],this.vertices[f++]=r.Org.coords[1],t>2&&(this.vertices[f++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,l++,r=r.Lnext;while(r!==n);this.elements[d++]=s,this.elements[d++]=l,s+=l}},i.prototype.addContour=function(e,t){this.mesh===null&&(this.mesh=new M0),e<2&&(e=2),e>3&&(e=3);for(var r=null,n=0;n<t.length;n+=e)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=t[n+0],r.Org.coords[1]=t[n+1],e>2?r.Org.coords[2]=t[n+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(e,t,r,n,s,l){if(e===void 0&&(e=Pt.ODD),t===void 0&&(t=Qt.POLYGONS),l===void 0&&(l=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=e,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),f2.computeInterior(this,l);var c=this.mesh;return t===Qt.BOUNDARY_CONTOURS?this.setWindingNumber_(c,1,!0):this.tessellateInterior_(c),l&&c.check(),t===Qt.BOUNDARY_CONTOURS?this.outputContours_(c,n):this.outputPolymesh_(c,t,r,n),!0},i}();function wo(i){var e=i.windingRule,t=e===void 0?Pt.ODD:e,r=i.elementType,n=r===void 0?Qt.POLYGONS:r,s=i.polySize,l=s===void 0?3:s,c=i.vertexSize,f=c===void 0?2:c,h=i.normal,d=h===void 0?[0,0,1]:h,x=i.contours,g=x===void 0?[]:x,w=i.strict,S=w===void 0?!0:w,D=i.debug,C=D===void 0?!1:D;if(!g&&S)throw new Error("Contours can't be empty");if(!!g){var G=new h2;i.edgeCreateCallback&&(G.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(G.vertexIdCallback=i.vertexIdCallback);for(var B=0;B<g.length;B++)G.addContour(f||2,g[B]);return G.tesselate(t,n,l,f,d,S),{vertices:G.vertices,vertexIndices:G.vertexIndices,vertexCount:G.vertexCount,elements:G.elements,elementCount:G.elementCount,mesh:C?G.mesh:void 0}}}var Dk=Pt.ODD,Bk=Pt.NONZERO,Gk=Pt.POSITIVE,jk=Pt.NEGATIVE,Ek=Pt.ABS_GEQ_TWO,Rk=Qt.POLYGONS,zk=Qt.CONNECTED_POLYGONS,Fk=Qt.BOUNDARY_CONTOURS;var No=class extends p2{constructor(e,t=12,r=100,n={}){super();this.type="ShapeGeometry";this.windingRule=Pt.ODD;this.elementType=Qt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._drawCount=0,this._shape=e,this._curveSegments=t,this._maxCount=r,this._maxDrawCount=r*3,this._triangulationOptions=Object.assign({windingRule:Pt.ODD,elementType:Qt.POLYGONS,polySize:3,vertexSize:2,strict:!0},n),this._positionAttribute=new Xc(new Float32Array(r*3),3),this._normalAttribute=new Xc(new Float32Array(r*3),3),this._uvAttribute=new Xc(new Float32Array(r*2),2),this._indexAttribute=new Xc(new Uint32Array(r*3),1),this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.updateFromShape()}copy(e){return this._drawCount=e.drawCount,this._maxDrawCount=e._maxDrawCount,this._maxCount=e.maxCount,super.copy(e)}get curveSegments(){return this._curveSegments}set curveSegments(e){this._curveSegments=e,this.updateFromShape()}get drawCount(){return this._drawCount}get maxDrawCount(){return this._maxDrawCount}get maxCount(){return this._maxCount}updateFromShape(){let e=this._shape.extractShapePointsToFlatArray([],this._curveSegments),t=this._shape.shapeHoles.map(f=>f.extractShapePointsToFlatArray([],this._curveSegments)),r,n=!0,s=!0,l,c;for(let f=0,h=e.length/2;f<h;f++){let d=f*2,x=e[d+0],g=e[d+1];if(l!==void 0&&x!==l&&(n=!1),c!==void 0&&g!==c&&(s=!1),l=x,c=g,!n&&!s)break}if(!n&&!s&&(r=wo({contours:[e,...t],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})),this._positionAttribute.array.fill(0),this._normalAttribute.array.fill(0),this._uvAttribute.array.fill(0),this._indexAttribute.array.fill(0),this._drawCount=0,r){let f=1/0,h=-1/0,d=1/0,x=-1/0;for(let S=0,D=r.vertexCount;S<D;S++){let C=S*2,G=r.vertices[C+0],B=r.vertices[C+1];G<f&&(f=G),G>h&&(h=G),B<d&&(d=B),B>x&&(x=B)}let g=h-f,w=x-d;for(let S=0,D=r.vertexCount;S<D;S++){let C=S*2,G=r.vertices[C+0],B=r.vertices[C+1],P=(G-f)/g,W=(B-d)/w;this._positionAttribute.setXYZ(S,G,B,0),this._normalAttribute.setXYZ(S,0,0,1),this._uvAttribute.setXY(S,P,W)}for(let S=0,D=r.elementCount;S<D;S++){let C=S*3,G=r.elements[C+0],B=r.elements[C+1],P=r.elements[C+2];this._indexAttribute.setX(C+0,G),this._indexAttribute.setX(C+1,B),this._indexAttribute.setX(C+2,P),this._drawCount+=3}}return this._positionAttribute.needsUpdate=!0,this._normalAttribute.needsUpdate=!0,this._uvAttribute.needsUpdate=!0,this._indexAttribute.needsUpdate=!0,this.setDrawRange(0,this._drawCount),this._drawCount>this._maxDrawCount}clone(){let e=new No(this._shape,this._curveSegments,this._maxCount);return e.userData=sa(this.userData),e}};import{BufferAttribute as Qc,BufferGeometry as d2}from"three";var Yc=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let r=e*Yc.eSize;this.buffer=new ArrayBuffer(r);let n=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*n,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*n,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*n,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let r=e*Yc.eSize,n=new ArrayBuffer(r),s=Float32Array.BYTES_PER_ELEMENT,l=0,c=new Float32Array(n,l*s,3*e);l+=3*e;let f=new Float32Array(n,l*s,3*e);l+=3*e;let h=new Float32Array(n,l*s,2*e);c.set(this.positions.slice(0,this.size*3)),f.set(this.normals.slice(0,this.size*3)),h.set(this.uvs.slice(0,this.size*2)),this.buffer=n,this.positions=c,this.normals=f,this.uvs=h,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let n=this.capacity;for(;t>n;)n*=2;this.realloc(n)}let r=this.size;return this.size=t,r}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Zc=Yc;Zc.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Fh=(i,e)=>([t,r])=>(r<t&&(r+=e),(i>=t?i:i+e)<=r),wa=class extends d2{constructor(e,t,r=0,n=12,s=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._bevel=r,this._curveSegments=n,this._bevelSegmentsInput=s,r<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(r,t/2-1e-12),this._bevelSegments=Math.floor(s));let l=this._shape.extractShapePointsToFlatArray([],n),c=this._shape.shapeHoles.map(q=>{let E=q.extractShapePointsToFlatArray([],n),b=[];for(let R=E.length-1;R>=1;R-=2){let T=E[R-1],z=E[R-0];b.push(T,z)}return b}),f=wo({windingRule:Pt.ODD,elementType:Qt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[l]}),h=wo({windingRule:Pt.ODD,elementType:Qt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]});if(!f)throw new Error("error generating geometry");let d=f.elementCount;if(h){f.elementCount+=h.elementCount;for(let q=0;q<h.elements.length;q++){let E=h.elements[q],b=q%2==0?f.vertexCount:0;f.elements.push(E+b)}for(let q=0;q<h.vertexIndices.length;q++){let E=h.vertexIndices[q],b=f.vertexCount;f.vertexIndices.push(E+b)}for(let q=0;q<h.vertices.length;q++){let E=h.vertices[q];f.vertices.push(E)}}let x=1/0,g=-1/0,w=1/0,S=-1/0;for(let q=0,E=f.vertexCount;q<E;q++){let b=q*2,R=f.vertices[b+0],T=f.vertices[b+1];R<x&&(x=R),R>g&&(g=R),T<w&&(w=T),T>S&&(S=T)}this._minX=x,this._minY=w,this._width=g-x,this._height=S-w;let D=f.vertexCount*2*(2+this._bevelSegments);this._buffer=new Zc(D);let C=[],G=[];for(let q=f.elementCount-1;q>=0;q--){let E=q>=d,b=q*2,R=f.elements[b+0],T=f.elements[b+1],z=R+T,A={start:R,count:T,normals:[],continuous:[],concave:[]},$=R,he=z-1,re=R+1,Ne=this._shape.roundedCurves.length;do{let k=$-R,H=f.vertices[he*2+0],_=f.vertices[he*2+1],J=f.vertices[$*2+0],ee=f.vertices[$*2+1],oe=f.vertices[re*2+0],se=f.vertices[re*2+1],ce=J-H,ue=ee-_,K=Math.sqrt(ce*ce+ue*ue);ce/=K,ue/=K;let ae=J-oe,ne=ee-se,Ce=Math.sqrt(ae*ae+ne*ne);ae/=Ce,ne/=Ce,A.normals[k*2+0]=-ne,A.normals[k*2+1]=ae,A.concave[k]=ce*ne-ue*ae>0;let Y=f.vertexIndices[$];if(Array.isArray(Y))A.continuous[k]=!1;else{let[le,pe]=this._shape.getCurveIndexFromVertexId(Y-1,!0);if(pe>0&&pe<1)A.continuous[k]=!0;else{let xe=pe===1?le+1:le-1;xe=(xe+Ne)%Ne;let _e=pe===1?0:1,de=this._shape.roundedCurves[le].getTangent(pe),we=this._shape.roundedCurves[xe].getTangent(_e);A.continuous[k]=de.dot(we)>.95}}E&&(A.normals[k*2+0]*=-1,A.normals[k*2+1]*=-1),[he,$,re]=[$,re,re+1],re>=z&&(re-=T)}while(re!==R+1);let ye=[];ye.push({bevelI:0,angle:0,size:0,boundary:{vertices:f.vertices.slice(R*2,z*2),vertexCount:T,vertexIndices:new Array(T).fill(!0).map((k,H)=>[H,H]),elements:[0,T],elementCount:1,mesh:null},reverseMap:[],insetPoints:f.vertices.slice(R*2,z*2)});for(let k=1;k<=this._bevelSegments;k++){let H=k/this._bevelSegments*Math.PI/2,_=(1-Math.cos(H))*this._bevelSize,J=[],ee=[],oe=[],se=[],ce=0;for(let K=0;K<T;K++){let ae=K*2,ne=(K-1+T)%T*2,Ce=f.vertices[A.start*2+ae+0],Y=f.vertices[A.start*2+ae+1],le=-A.normals[ne+0]*_,pe=-A.normals[ne+1]*_,xe=-A.normals[ae+0]*_,_e=-A.normals[ae+1]*_;if(A.concave[K]||!A.concave[K]&&E){let de=Math.atan2(pe,le),we=Math.atan2(_e,xe);we>de&&(we-=Math.PI*2);let Ve=we-de;if(A.continuous[K]||E){let Ge=de+Ve/2,Qe=Math.cos(Ge)*_,bt=Math.sin(Ge)*_;J[2*ce+0]=Ce+Qe*(E?-1:1),J[2*ce+1]=Y+bt*(E?-1:1),se[ce]=K,ce++}else{let Ge=Math.max(1,Math.floor(n/4*Math.abs(Ve)/Math.PI));for(let Qe=0;Qe<=Ge;Qe++){let bt=de+Ve*(Qe/Ge),Lt=Math.cos(bt)*_,At=Math.sin(bt)*_;J[2*ce+0]=Ce+Lt,J[2*ce+1]=Y+At,se[ce]=K,ce++}}}else J[2*ce+0]=Ce+le,J[2*ce+1]=Y+pe,se[ce]=K,ee[K]=ce,ce++,J[2*ce+0]=Ce,J[2*ce+1]=Y,se[ce]=K,ce++,J[2*ce+0]=Ce+xe,J[2*ce+1]=Y+_e,se[ce]=K,oe[K]=ce,ce++}let ue=wo({windingRule:Pt.POSITIVE,elementType:Qt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[J],edgeCreateCallback:K=>{let ne=K.Org.idx,Ce=se[ne],Y=se[(ne+1)%se.length];K.idx=[Ce,Y],K.Sym.idx=[Y,Ce]},vertexIdCallback:K=>{let ae=K.Lprev.idx;return[ae?ae[1]:0,K.idx[0]]}});if(!ue)throw console.log("Error"),new Error(`error generating bevel geometry for ${k}'th loop`);if(!ue.vertexCount)break;for(let K=0;K<ue.vertexIndices.length;K++){let[ae,ne]=ue.vertexIndices[K];if(ae===ne)continue;let Ce=ne;ne<ae&&(Ce+=T);for(let Y=ae;Y<Ce;Y++){let le=Y%T,pe=(Y+1)%T;if(!A.continuous[le]||!A.continuous[pe]){ue.vertexIndices[K]=[ae,le],ue.vertexIndices.splice(K+1,0,[pe,ne]),ue.vertices.splice((K+1)*2,0,ue.vertices[K*2],ue.vertices[K*2+1]);break}}}ye.push({bevelI:k,angle:H,size:_,boundary:ue,reverseMap:se,insetPoints:J})}let Me=(k,H,_)=>{let J=0,ee=k.boundary.vertexIndices.length;for(;J<ee&&_(k.boundary.vertexIndices[H]);)H=(H+1)%ee,J++;return J},Fe=C.length;for(let k=1;k<ye.length;k++){let H=ye[k-1],_=ye[k],J=H.boundary.vertexIndices.length,ee=_.boundary.vertexIndices.length;if(!J||!ee)break;let oe=A.concave.length,se=0,ce=Fh(se,T);for(;!H.boundary.vertexIndices.filter(ce).length||!_.boundary.vertexIndices.filter(ce).length;)se++,ce=Fh(se,T);let ue=H.boundary.vertexIndices.findIndex(ce),K=_.boundary.vertexIndices.findIndex(ce);do ue=(ue+1)%J;while(ce(H.boundary.vertexIndices[ue]));do K=(K+1)%ee;while(ce(_.boundary.vertexIndices[K]));se=(se+1)%T;let ae=se,ne=this.buildBevelVert(A,H,(ue-1+J)%J),Ce=this.buildBevelVert(A,_,(K-1+ee)%ee),Y=ne,le=Ce,pe,xe,_e=!1;do{ce=Fh(se,T);let de=Me(H,ue,ce),we=Me(_,K,ce),Ve=_e;if(_e=!1,de&&!we){for(let Ge=0;Ge<de;Ge++)pe=this.buildBevelVert(A,H,(ue+Ge)%J,Ge/(de-1)),C.push(Y.topN,pe.topP,le.topN),C.push(pe.bottomP,Y.bottomN,le.bottomN),Y=pe;_e=!0}else if(!de&&we)for(let Ge=0;Ge<we;Ge++)xe=this.buildBevelVert(A,_,(K+Ge)%ee,Ge/(we-1)),C.push(le.topN,Y.topP,xe.topP),C.push(Y.bottomP,le.bottomN,xe.bottomP),le=xe;else if(de&&we)if(pe=this.buildBevelVert(A,H,ue,0),xe=this.buildBevelVert(A,_,K,0),Ve?(C.push(Y.topN,xe.topP,le.topN),C.push(Y.topN,pe.topP,xe.topP),C.push(xe.bottomP,Y.bottomN,le.bottomN),C.push(pe.bottomP,Y.bottomN,xe.bottomP)):(C.push(Y.topN,pe.topP,le.topN),C.push(le.topN,pe.topP,xe.topP),C.push(pe.bottomP,Y.bottomN,le.bottomN),C.push(pe.bottomP,le.bottomN,xe.bottomP)),Y=pe,le=xe,de===we)for(let Ge=1;Ge<de;Ge++)pe=this.buildBevelVert(A,H,(ue+Ge)%J,Ge/(de-1)),xe=this.buildBevelVert(A,_,(K+Ge)%ee,Ge/(we-1)),C.push(Y.topN,pe.topP,le.topN),C.push(le.topN,pe.topP,xe.topP),C.push(pe.bottomP,Y.bottomN,le.bottomN),C.push(pe.bottomP,le.bottomN,xe.bottomP),Y=pe,le=xe;else if(de>we){let Ge=de/we,Qe=0;for(let bt=1;bt<de;bt++)pe=this.buildBevelVert(A,H,(ue+bt)%J,bt/(de-1)),C.push(Y.topN,pe.topP,le.topN),C.push(pe.bottomP,Y.bottomN,le.bottomN),Y=pe,bt>(Qe+1)*Ge&&(Qe++,xe=this.buildBevelVert(A,_,(K+Qe)%ee,Qe/(we-1)),C.push(le.topN,pe.topP,xe.topP),C.push(pe.bottomP,le.bottomN,xe.bottomP),le=xe)}else{let Ge=we/de,Qe=0;for(let bt=1;bt<we;bt++)xe=this.buildBevelVert(A,_,(K+bt)%ee,bt/(we-1)),C.push(le.topN,pe.topP,xe.topP),C.push(pe.bottomP,le.bottomN,xe.bottomP),le=xe,bt>(Qe+1)*Ge&&(Qe++,pe=this.buildBevelVert(A,H,(ue+Qe)%J,Qe/(de-1)),C.push(Y.topN,pe.topP,le.topN),C.push(pe.bottomP,Y.bottomN,le.bottomN),Y=pe)}ue=(ue+de)%J,K=(K+we)%ee,se=(se+1)%oe}while(se!==ae)}{let k=ye[0];for(let H=0,_=k.boundary.vertexCount;H<_;H++){let J=this.buildBevelVert(A,k,H),ee=this.buildBevelVert(A,k,(H+1)%_);C.push(ee.topP,J.topN,J.bottomN),C.push(ee.topP,J.bottomN,ee.bottomP)}}if(E){let k=[];for(let H=C.length-1;H>=Fe+2;H-=3){let _=C[H-2],J=C[H-1],ee=C[H-0];k.push(ee,J,_)}C.splice(Fe,C.length-Fe,...k)}if(E){let k=[];for(let H=ye[ye.length-1].boundary.vertices.length-1;H>=1;H-=2){let _=ye[ye.length-1].boundary.vertices[H-1],J=ye[ye.length-1].boundary.vertices[H-0];k.push(_,J)}G.push(k)}if(!E){let k=ye[ye.length-1],H=wo({windingRule:ye.length>1?Pt.POSITIVE:Pt.ODD,elementType:Qt.POLYGONS,vertexSize:2,strict:!0,contours:[k.insetPoints,...G]});if(!H)throw new Error("Error generating geometry for surface");for(let _=0;_<H.elementCount*3;_+=3){let J=this.buildSurfaceVert(H,H.elements[_+0]),ee=this.buildSurfaceVert(H,H.elements[_+1]),oe=this.buildSurfaceVert(H,H.elements[_+2]);C.push(J.top,ee.top,oe.top),C.push(oe.bottom,ee.bottom,J.bottom)}}this.vertexCache={}}this._buffer.shrink();let B=new Qc(Uint32Array.from(C),1),P=new Qc(this._buffer.positions,3),W=new Qc(this._buffer.normals,3),M=new Qc(this._buffer.uvs,2);P.needsUpdate=!0,W.needsUpdate=!0,M.needsUpdate=!0,B.needsUpdate=!0,this.setAttribute("position",P),this.setAttribute("normal",W),this.setAttribute("uv",M),this.setIndex(B)}buildSurfaceVert(e,t){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let n=e.vertices[t*2+0],s=e.vertices[t*2+1],l=(n-this._minX)/this._width,c=(s-this._minY)/this._height,f=this._buffer.get(2),h=f*3,d=f*2,x={top:f+0,bottom:f+1};return this._buffer.positions[h+0]=n,this._buffer.positions[h+1]=s,this._buffer.positions[h+2]=this._depth,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=c,this._buffer.positions[h+3]=n,this._buffer.positions[h+4]=s,this._buffer.positions[h+5]=0,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=c,this.vertexCache[r]=x,x}buildBevelVert(e,t,r,n=1){let s=`${t.bevelI}:${r}`;if(s in this.vertexCache)return this.vertexCache[s];let[l,c]=t.boundary.vertexIndices[r],f,h,d,x;l!==c?(h=l,f=c,x=!1,d=e.continuous[h]&&e.continuous[f]):(f=l,h=(f-1+e.count)%e.count,x=e.concave[f]&&t.bevelI>0,d=e.continuous[f]||x);let g=Math.cos(t.angle),w=Math.sin(t.angle),S=r*2,D=f*2,C=h*2,G=t.boundary.vertices[S+0],B=t.boundary.vertices[S+1],P=(1-w)*this._bevelSize,W=(G-this._minX)/this._width,M=(B-this._minY)/this._height,q=e.normals[D+0],E=e.normals[D+1],b=e.normals[C+0],R=e.normals[C+1];if(x){let he=b-q,re=R-E;q=q+he*(1-n),E=E+re*(1-n);let Ne=Math.sqrt(q*q+E*E);q/=Ne,E/=Ne}let T=this._buffer.get(d?2:4),z=T*3,A=T*2,$={i:r,fi:f,topP:T+0,topN:T+0,bottomP:T+1,bottomN:T+1};return this._buffer.positions[z+0]=G,this._buffer.positions[z+1]=B,this._buffer.positions[z+2]=this._depth-P,this._buffer.normals[z+0]=q*g,this._buffer.normals[z+1]=E*g,this._buffer.normals[z+2]=w,this._buffer.uvs[A+0]=W,this._buffer.uvs[A+1]=M,this._buffer.positions[z+3]=G,this._buffer.positions[z+4]=B,this._buffer.positions[z+5]=P,this._buffer.normals[z+3]=q*g,this._buffer.normals[z+4]=E*g,this._buffer.normals[z+5]=-w,this._buffer.uvs[A+2]=M,this._buffer.uvs[A+3]=W,d||(T+=2,z+=6,A+=4,$.topP=T+0,$.bottomP=T+1,this._buffer.positions[z+0]=G,this._buffer.positions[z+1]=B,this._buffer.positions[z+2]=this._depth-P,this._buffer.normals[z+0]=b*g,this._buffer.normals[z+1]=R*g,this._buffer.normals[z+2]=w,this._buffer.uvs[A+0]=W,this._buffer.uvs[A+1]=M,this._buffer.positions[z+3]=G,this._buffer.positions[z+4]=B,this._buffer.positions[z+5]=P,this._buffer.normals[z+3]=b*g,this._buffer.normals[z+4]=R*g,this._buffer.normals[z+5]=-w,this._buffer.uvs[A+2]=M,this._buffer.uvs[A+3]=W),this.vertexCache[s]=$,$}clone(){let e=new wa(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=sa(this.userData),e}};var ur=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var h,d,x,g,w,S,D;let t=Object.assign({},(h=e==null?void 0:e.parameters)!=null?h:{width:100,subdivisions:40,roundness:0,extrudeDepth:0,surfaceMaxCount:100,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(t.width),n=Math.abs((d=t.height)!=null?d:t.width),s=Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(x=t.depth)!=null?x:0),l=(g=i.shape)!=null?g:e==null?void 0:e.shape,c=(w=l==null?void 0:l.roundness)!=null?w:t.roundness;l!==void 0&&(l instanceof st?(l.width!==r||l.height!==n)&&l.applySize(r,n):l=new st(r,n).fromJSON(l),((S=i.parameters)==null?void 0:S.roundness)!==void 0&&((D=i.parameters)==null?void 0:D.roundness)>0&&l.update(!1));let f=l!=null?l:new st(r,n);return{parameters:Object.assign(t,{width:r,height:n,depth:s,extrudeDepth:s,roundness:c}),shape:f}}static build(i){let{extrudeDepth:e,extrudeBevelSize:t,extrudeBevelSegments:r,subdivisions:n,roundness:s,surfaceMaxCount:l}=i.parameters;i.shape.roundness=s;let c;return e<=0?c=new No(i.shape,n,l):c=new wa(i.shape,e,t,n,r),Object.assign(c,{userData:fe(U({},i),{type:"VectorGeometry"})})}};import{MathUtils as D0,Vector2 as B0}from"three";var G0=Math.PI*2,j0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,s,l;let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1e3},i.parameters);return{shape:i.shape&&i.shape instanceof st?i.shape:new st,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(l=t.depth)!=null?l:0)})}}static build(i){let{width:e,height:t,spikes:r,angle:n,innerRadius:s,depth:l,extrudeBevelSize:c,extrudeBevelSegments:f,surfaceMaxCount:h}=i.parameters,d=i.shape,x=e*.5,g=t*.5,w=m2(d,x,g,n*Math.PI/180,r,s);d.isClosed=!0,d.update();let S=ur.create({shape:d,parameters:{subdivisions:w,surfaceMaxCount:h,depth:l,extrudeBevelSize:c,extrudeBevelSegments:f}});return Object.assign(S,{userData:fe(U({},i),{type:"EllipseGeometry"})})}};function m2(i,e,t,r,n,s){if(r>=G0)return n>30||n%4==0?(y2(i,e,t,s),Math.round(n/4)):E0(i,r,n,e,t,s);let l={x:0,y:t},c=r+Math.PI*.5,f={x:Math.cos(c)*e,y:Math.sin(c)*t},h=I0({px:l.x,py:l.y,cx:f.x,cy:f.y,rx:e,ry:t,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%h.length==0?g2(i,l.x,l.y,h,n,e,t,s):E0(i,r,n,e,t,s)}function g2(i,e,t,r,n,s,l,c){let f=Math.round(n/r.length);i.addPoint(Cs(e,t));for(let h=0,d=r.length;h<d;h++){let x=r[h],g=i.points[h],w=Cs(x.x,x.y);g.controls[1].position.set(x.x1,x.y1),w.controls[0].position.set(x.x2,x.y2),i.addPoint(w)}return c>0?R0(i,s,l,c):i.addPoint(Cs(0,0)),f}function E0(i,e,t,r,n,s){let l=-e/t;for(let c=0;c<=t;c++){let f=l*c,h=Math.sin(f)*r,d=Math.cos(f)*n;i.addPoint(Cs(h,d))}return e<G0?s>0?R0(i,r,n,s):i.addPoint(Cs(0,0)):(i.removePoint(i.points[i.points.length-1]),s>0&&z0(i,r,n,s)),1}function y2(i,e,t,r=0,n=0,s=0){let l=.5522847498,c=e*l,f=t*l;i.addPoint(eu(n-e,s,n-e,s-f,n-e,s+f)),i.addPoint(eu(n,s+t,n-c,s+t,n+c,s+t)),i.addPoint(eu(n+e,s,n+e,s+f,n+e,s-f)),i.addPoint(eu(n,s-t,n+c,s-t,n-c,s-t)),r>0&&z0(i,e,t,r)}function Cs(i,e){return new Kn(D0.generateUUID(),new B0(i,e))}function eu(i,e,t,r,n,s){let l=Cs(i,e);return l.controls[0].position.set(t,r),l.controls[1].position.set(n,s),l}function R0(i,e,t,r){F0(i,e,t,r).forEach(s=>i.addPoint(s))}function z0(i,e,t,r){let n=F0(i,e,t,r),s=new st;n.forEach(l=>s.addPoint(l)),s.isClosed=!0,i.shapeHoles.push(s)}function F0(i,e,t,r){let n=r*e/100,s=n*(Math.abs(t)/Math.abs(e)),l=new B0(n/e,s/t),c=i.points.map(f=>{let h=f.clone();return h.uuid=D0.generateUUID(),h}).reverse();return c.forEach(f=>{f.position.multiply(l);let h=f.controls[0].position.clone().multiply(l),d=f.controls[1].position.clone().multiply(l);f.controls[0].position.copy(d),f.controls[1].position.copy(h)}),c}import{BufferGeometry as x2,Float32BufferAttribute as Vh,Vector3 as V0}from"three";var U0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var c,f,h;let t=Object.assign({},(c=e==null?void 0:e.parameters)!=null?c:{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(t.width),n=Math.abs((f=t.height)!=null?f:r),s=Math.abs((h=t.depth)!=null?h:r),l=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(t,{width:r,height:n,depth:s,radius:l,segments:Math.round(t.segments),pathSegments:Math.round(t.pathSegments),cornerSegments:Math.round(t.cornerSegments)})}}static build(i){let{width:e,height:t,depth:r,radius:n,revolutions:s,segments:l,pathRadius:c,pathType:f,pathSegments:h,cornerRadius:d,cornerSegments:x}=i.parameters,g=new tu(!1,e,t,r,n,s,l,c,f,h,d,x);return Object.assign(g,{userData:fe(U({},i),{type:"HelixGeometry"})})}},tu=class extends x2{constructor(e=!0,t=1,r=1,n=1,s=1,l=1,c=1,f=1,h=1,d=1,x=1,g=1){super();let w=e&&l===1;w&&(g=0),x>100&&(x=100);let S=()=>new V0,D=new V0,C=S(),G=S(),B=S(),P,W,M,q,E,b,R,T,z=S(),A=S(),$=S(),he=S(),re=S(),Ne=S(),ye=S(),Me=S(),Fe=r-2*f+.001,k=Fe/l,H=Math.ceil(c*l),_=H+1,J=Fe/H,ee=-Fe/2,oe=d+1,se=2*Math.PI/d,ce=Math.PI/2/g,ue=.01,K=Math.min((1-x/100)*f,f-ue),ae=f-K,ne=0,Ce=2,Y=g*Ce+Ce,le=oe*Y/Ce,pe=le+oe*_,xe=oe*(_+Y),[_e,de,we]=[3,3,2].map(dt=>Array(xe*dt).fill(0)),Ve=[],Ge=s-f;function Qe(dt,Wt){let ar=Math.PI/2;b=Wt*J,T=2*Math.PI*(b%k)/k+ar,b+=ee,R=Math.sin(T)*Ge,E=Math.cos(T)*Ge,e?dt.set(E,R,b):dt.set(E,b,R)}Qe(D,-1e-10),Qe(C,0),z.copy(D),Qe(D,1);let bt=D.distanceTo(C),Lt=ae+K,At=bt*H+2*Lt,sr=K,Ur=At-Lt;for(let dt=0;dt<=H;dt++){Qe(G,dt),Me.subVectors(G,z).normalize(),z.copy(G),Ne.copy(G).setComponent(+e+1,0).normalize(),ye.crossVectors(Me,Ne).normalize();let Wt=dt===0,ar=dt===H,Ao=Wt?3*Math.PI/2:ce,Oo=Wt?sr:Ur,Po=Wt?oe:pe,ro=Wt?0:xe-oe,no=Me.clone().multiplyScalar(Wt?-ae:ae).add(G),Do=Me.clone().multiplyScalar(Wt?-1:1).normalize();for(let Mr=0;Mr<oe;Mr++){let io=Mr*se;if(A.addVectors(D.copy(Ne).multiplyScalar(f*Math.cos(io)),C.copy(ye).multiplyScalar(f*Math.sin(io))),$.copy(A).normalize(),Wt||ar){w||(ne=ro+Mr,[0,1,2].forEach(Jt=>{_e[ne*3+Jt]=no.getComponent(Jt),de[ne*3+Jt]=Do.getComponent(Jt)}),we[ne*2]=+ar,we[ne*2+1]=Mr/d),C.copy($).multiplyScalar(K),B.addVectors(G,C);for(let Jt=0;Jt<g;Jt++){let ti=Jt*ce+Ao;he.addVectors(D.copy(Me).multiplyScalar(ae*Math.sin(ti)),C.copy($).multiplyScalar(ae*Math.cos(ti))),re.copy(he).normalize(),C.addVectors(B,he),he.normalize(),ne=Po+Jt*oe+Mr,[0,1,2].forEach(Ee=>{_e[ne*3+Ee]=C.getComponent(Ee),de[ne*3+Ee]=re.getComponent(Ee)});let Bo=+Wt+Math.sin(ti);we[ne*2]=(Oo+ae*Bo)/At,we[ne*2+1]=Mr/d}}C.addVectors(G,A),ne=le+dt*oe+Mr,[0,1,2].forEach(Jt=>{_e[ne*3+Jt]=C.getComponent(Jt),de[ne*3+Jt]=$.getComponent(Jt)}),we[ne*2]=(Lt+dt*bt)/At,we[ne*2+1]=Mr/d}}let Ht=_+2*g+Ce,kr=1,[wn,Nn]=w?[kr,kr+_-1]:[0,Ht-1];for(let dt=wn;dt<=Nn-1;dt++){let Wt=w&&dt===Nn-1;for(let ar=0;ar<oe-1;ar++)P=dt*oe+ar,W=P+1,M=(Wt?ar:P)+oe,q=(Wt?ar+1:W)+oe,dt===0?Ve.push(W,q,M):dt===Ht-2?Ve.push(P,W,M):Ve.push(P,W,M,W,q,M)}this.setIndex(Ve),this.setAttribute("position",new Vh(_e,3)),this.setAttribute("normal",new Vh(de,3)),this.setAttribute("uv",new Vh(we,2))}};import{IcosahedronBufferGeometry as v2}from"three";var k0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,height:t,depth:r,detail:n,corner:s,cornerSides:l}=i.parameters,c=n===0&&s!==0?new ru(e*.5,s,l):new v2(e*.5,n);return c.scale(1,t/e,r/e),Object.assign(c,{userData:fe(U({},i),{type:"IcosahedronGeometry"})})}},ru=class extends So{constructor(e=1,t=.2,r=4){let n=(1+Math.sqrt(5))/2,s=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],l=[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],c="IcosahedronGeometry";super(s,l,c,e,t,r);this.type=c}static fromJSON(e){return new ru(e.radius,e.corner,e.cornerSides)}};import{LatheBufferGeometry as b2,Shape as S2}from"three";var H0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s,l,c;((n=(r=i.parameters)==null?void 0:r.points)!=null?n:[]).forEach(f=>{Array.isArray(f)&&(f.x=f[0],f.y=f[1])});let t=Object.assign({},(s=e==null?void 0:e.parameters)!=null?s:{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((l=t.height)!=null?l:t.width),depth:Math.abs((c=t.depth)!=null?c:t.width)})}}static build(i){let{points:e,segments:t,verticalSegments:r}=i.parameters,n=new S2;n.moveTo(e[0].x,e[0].y),n.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let s=new b2(n.extractPoints(r).shape,t);return s.rotateZ(Math.PI),Object.assign(s,{userData:fe(U({},i),{type:"LatheGeometry"})})}};import{BufferGeometry as q0,BufferGeometryLoader as I2,Vector3 as M2,BoxBufferGeometry as $0}from"three";import{BufferGeometry as w2,Vector2 as Uh,Vector3 as W0}from"three";import{Geometry as N2,Face3 as C2}from"three/examples/jsm/deprecated/Geometry.js";var L2=["a","b","c"];function _2(i,e){switch(e){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function kh(i,e,t){let r=Math.min(i,e),n=Math.max(i,e),s=r+"_"+n;return t.get(s)}function Hh(i,e,t,r,n,s){let l=Math.min(i,e),c=Math.max(i,e),f=l+"_"+c,h;if(r.has(f))h=r.get(f);else{let d=t[l],x=t[c];h={a:d,b:x,newEdge:null,faces:[]},r.set(f,h)}h.faces.push(n),s[i].edges.push(h),s[e].edges.push(h)}function T2(i,e,t,r){let n,s,l;for(n=0,s=i.length;n<s;n++)t[n]={edges:[]};for(n=0,s=e.length;n<s;n++)l=e[n],Hh(l.a,l.b,i,r,l,t),Hh(l.b,l.c,i,r,l,t),Hh(l.c,l.a,i,r,l,t)}function nu(i,e,t,r,n){i.push(new C2(e,t,r,void 0,void 0,n))}function Ls(i,e){return Math.abs(e-i)/2+Math.min(i,e)}function iu(i,e,t,r){i.push([e.clone(),t.clone(),r.clone()])}var Wh=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof w2?e=new N2().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new W0,r,n,s,l,c,f=e.vertices,h=e.faces,d=e.faceVertexUvs[0],x=d!==void 0&&d.length>0,g=[],w=new Map;T2(f,h,g,w);let S=[],D,C,G,B,P,W,M;for(let ue of Array.from(w.keys())){for(C=w.get(ue),G=new W0,P=3/8,W=1/8,M=C.faces.length,M!=2&&(P=.5,W=0,M!=1),G.addVectors(C.a,C.b).multiplyScalar(P),t.set(0,0,0),l=0;l<M;l++){for(B=C.faces[l],c=0;c<3&&(D=f[_2(B,L2[c])],!(D!==C.a&&D!==C.b));c++);D&&t.add(D)}t.multiplyScalar(W),G.add(t),C.newEdge=S.length,S.push(G)}let q,E,b,R,T,z,A,$=[];for(n=0,s=f.length;n<s;n++){for(z=f[n],T=g[n].edges,r=T.length,r==3?q=3/16:r>3&&(q=3/(8*r)),E=1-r*Number(q),b=q,r<=2&&(r==2?(E=3/4,b=1/8):r==1||r==0),A=z.clone().multiplyScalar(E),t.set(0,0,0),l=0;l<r;l++)R=T[l],D=R.a!==z?R.a:R.b,t.add(D);t.multiplyScalar(Number(b)),A.add(t),$.push(A)}let he=$.concat(S),re=$.length,Ne,ye,Me,Fe=[],k=[],H,_,J,ee,oe=new Uh,se=new Uh,ce=new Uh;for(n=0,s=h.length;n<s;n++)B=h[n],Ne=Number(kh(B.a,B.b,w).newEdge)+re,ye=Number(kh(B.b,B.c,w).newEdge)+re,Me=Number(kh(B.c,B.a,w).newEdge)+re,nu(Fe,Ne,ye,Me,B.materialIndex),nu(Fe,B.a,Ne,Me,B.materialIndex),nu(Fe,B.b,ye,Ne,B.materialIndex),nu(Fe,B.c,Me,ye,B.materialIndex),x&&(H=d[n],_=H[0],J=H[1],ee=H[2],oe.set(Ls(_.x,J.x),Ls(_.y,J.y)),se.set(Ls(J.x,ee.x),Ls(J.y,ee.y)),ce.set(Ls(_.x,ee.x),Ls(_.y,ee.y)),iu(k,oe,se,ce),iu(k,_,oe,ce),iu(k,J,se,oe),iu(k,ee,ce,se));e.vertices=he,e.faces=Fe,x&&(e.faceVertexUvs[0]=k)}};var er=new M2,J0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var s,l;let t=(l=(s=i.geometry)!=null?s:e==null?void 0:e.geometry)!=null?l:new q0().copy(new $0(100,100,100)),r;e===void 0?(t.computeBoundingBox(),t.boundingBox.getSize(er),r={width:er.x,height:er.y,depth:er.z,subdivisions:0}):r=e.parameters;let n=U(U({},r),i.parameters);return{parameters:{width:Math.abs(n.width),height:Math.abs(n.height),depth:Math.abs(n.depth),subdivisions:Math.abs(n.subdivisions)},geometry:t}}static build(i){var f;let{width:e,height:t,depth:r,subdivisions:n}=i.parameters,s=(f=i.geometry)!=null?f:new q0().copy(new $0(100,100,100)),l=s.userData.parameters;l===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(er)):er.set(l.width,l.height,l.depth),(e!==er.x||t!==er.y||r!==er.z)&&s.scale(er.x===0?1:e/er.x,er.y===0?1:t/er.y,er.z===0?1:r/er.z);let c=s.originalGeometry;return n>0?(c===void 0||(l==null?void 0:l.subdivisions)!==n)&&(c===void 0&&(c=s),s=new Wh(n).modify(c).toBufferGeometry()):(c!==void 0&&(s=c),c=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()),c!==void 0&&Object.assign(s,{originalGeometry:c}),delete i.geometry,Object.assign(s,{userData:fe(U({},i),{type:"NonParametricGeometry"})})}static loadFromUrl(i,e,t){new I2(t).load(i,n=>{let s=this.normalizeInputs({geometry:n});n.boundingBox.getSize(er);let l=100/er.x;Object.assign(s.parameters,{width:100,height:er.y*l,depth:er.z*l}),e(this.build(s))})}};var K0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,s,l,c;let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof st?i.shape:new st,parameters:Object.assign(t,{surfaceMaxCount:((s=t.surfaceMaxCount)!=null?s:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((l=t.height)!=null?l:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(c=t.depth)!=null?c:0)})}}static build(i){let{width:e,height:t,spikes:r,cornerRadius:n,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,surfaceMaxCount:f}=i.parameters,h=i.shape,d=e*.5,x=t*.5,g=0,w=0,S=2*Math.PI/r;for(let C=0;C<r;C++){let G=S*C,B=g+Math.sin(G)*d,P=w+Math.cos(G)*x;h.addPoint(h.createPoint(B,P))}h.isClosed=!0;for(let C=0,G=h.points.length;C<G;C++)h.points[C].roundness=n;h.roundness=n,h.update();let D=ur.create({shape:h,parameters:{surfaceMaxCount:f,roundness:n,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(D,{userData:fe(U({},i),{type:"PolygonGeometry"})})}};import{BufferGeometry as A2,Float32BufferAttribute as qh,Vector2 as Xn,Vector3 as or}from"three";var X0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,height:t,depth:r,radialSegments:n,heightSegments:s,openEnded:l,cornerRadius:c,cornerSegments:f}=i.parameters,h=new Z0(e*.5,t,n,s,l,c,f);return h.scale(1,1,r/e),Object.assign(h,{userData:fe(U({},i),{type:"PyramidGeometry"})})}};function Na(i,e,t){t.x=i.x*e.x,t.y=i.y,t.z=i.x*e.y}function $h(i,e,t,r,n,s){let l=e.clone().sub(i),c=t.clone().sub(i),f=l.angleTo(c);if(l.normalize(),c.normalize(),r===n){let h=l.add(c).normalize();s.copy(i).addScaledVector(h,r/Math.sin(f/2))}else{let h=l.angleTo(c);s.copy(i),s.addScaledVector(l,n/Math.sin(h)),s.addScaledVector(c,r/Math.sin(h))}}function O2(i,e,t){let r=i.clone().sub(e),n=t.clone().sub(e);return r.projectOnVector(n),r.add(e)}var Z0=class extends A2{constructor(e=.5,t=1,r=4,n=1,s=!1,l=0,c=4){super();r=Math.floor(Math.max(3,r)),n=Math.floor(n),c=Math.floor(c);let f=[],h=[],d=[],x=[],g=0,w=t/2,S=Math.PI/r,D=e*Math.cos(Math.PI/r),C=2*Math.PI/r,G=(r-2)*Math.PI/r,B=Math.PI-G,P=new or(0,-w,0),W=new or(0,w,0),M=new Xn(e,-w),q=new Xn(D,-w),E=new Xn(0,W.y).sub(q),b=new Xn(0,W.y).sub(M),R=new Xn(E.y,-E.x).normalize(),T=new Xn(b.y,-b.x).normalize(),A=e*Math.cos(Math.PI/r)*Math.tan((Math.PI-E.angle())/2)-1e-8;l=Math.min(l,A);let $;{let k=new or(R.x,R.y,0),H=new or(Math.cos(C)*k.x,k.y,Math.sin(C)*k.x);$=k.angleTo(H)}let he=l/Math.tan((Math.PI-E.angle())/2),re=l/Math.tan((Math.PI-$)/2),Ne=new or;if(!s){h.push(P.x,P.y,P.z),d.push(0,-1,0),x.push(0,0);let k=g++,H=[],_=M.clone(),J=he/Math.cos(Math.PI/r);_.x-=J;for(let ee=0;ee<r;ee++){let oe=ee/r*Math.PI*2+S,se=new Xn(Math.sin(oe),Math.cos(oe));Na(_,se,Ne),h.push(Ne.x,Ne.y,Ne.z),d.push(0,-1,0),x.push(0,0),H.push(g++)}for(let ee=0;ee<H.length;ee++)f.push(H[ee],k,H[(ee+1)%H.length])}let ye=[];{let k=new or,H=new or,_=new or,J=new or,ee=new or,oe=new or;for(let se=0;se<r;se++){let ce=se/r*Math.PI*2+S,ue=(se+.5)/r*Math.PI*2+S,K=(se+1)/r*Math.PI*2+S,ae=new Xn(Math.sin(ce),Math.cos(ce)),ne=new Xn(Math.sin(ue),Math.cos(ue)),Ce=new Xn(Math.sin(K),Math.cos(K));Na(M,ae,H),Na(M,Ce,_),Na(R,ne,k),$h(W,H,_,re,re,J),h.push(J.x,J.y,J.z),$h(H,W,_,re,he,ee),h.push(ee.x,ee.y,ee.z),$h(_,H,W,he,re,oe),h.push(oe.x,oe.y,oe.z),d.push(k.x,k.y,k.z),d.push(k.x,k.y,k.z),d.push(k.x,k.y,k.z),x.push(0,0),x.push(0,0),x.push(0,0);let Y=g++,le=g++,pe=g++;if(f.push(Y,le,pe),l>0){{let de=H.clone().add(_).multiplyScalar(.5),we=W.clone().sub(de).normalize(),Ge=P.clone().sub(de).normalize().add(we).normalize().multiplyScalar(-1),Qe=oe.clone().sub(ee);Me(de,Qe,Ge,E.angle())}let xe,_e;{let de=new or;Na(T,Ce,de);let we=oe.clone().add(J).multiplyScalar(.5);we=O2(we,_,W);let Ve=oe.clone().sub(J);[xe,_e]=Me(we,Ve,de,$,J.y)}{let de=xe,we=de.clone().setY(0).normalize(),Ve=new or(0,-1,0),Ge=we.clone().cross(Ve);Fe(de,we,Ve,Ge)}ye.concat(_e);{let de=E.angle(),we=Math.PI-de,Ve=W.clone();Ve.y-=l/Math.sin(de-Math.PI/2);let Ge=new or,Qe=[];for(let Lt=0;Lt<c;Lt++){let At=[],sr=Math.PI/2-we*Lt/c,Ur=Math.cos(sr),Ht=Math.sin(sr),kr=ue;for(let wn=0;wn<=Lt;wn++){let Nn=Math.cos(kr),dt=Math.sin(kr);k.x=Ur*dt,k.y=Ht,k.z=Ur*Nn,Ge.copy(Ve).addScaledVector(k,l),h.push(Ge.x,Ge.y,Ge.z),d.push(k.x,k.y,k.z),x.push(0,0),At.push(g++),kr+=Math.PI*2/Lt/r}Qe.push(At)}_e.reverse(),Qe.push(_e);let bt=Qe.length-1;for(let Lt=0;Lt<bt;Lt++){let At=Qe[Lt],sr=Qe[Lt+1],Ur=At.length-1;f.push(sr[1],At[0],sr[0]);for(let Ht=1;Ht<=Ur;Ht++)f.push(At[Ht],At[Ht-1],sr[Ht]),f.push(sr[Ht+1],At[Ht],sr[Ht])}}}}}this.setIndex(f),this.setAttribute("position",new qh(h,3)),this.setAttribute("normal",new qh(d,3)),this.setAttribute("uv",new qh(x,2));function Me(k,H,_,J,ee){let oe=-J/2,se=(Math.PI-J)/2,ce=H.clone().normalize().cross(_);k.addScaledVector(_,-l/Math.sin(se));let ue=new or,K=new or,ae=1,ne=g,Ce=[];for(let Y=0;Y<=c;Y++){let le=oe+Y/c*J;K.set(0,0,0),K.addScaledVector(ce,Math.sin(le)),K.addScaledVector(_,Math.cos(le));for(let pe=0;pe<=ae;pe++){let xe=pe/ae-.5;if(ue.copy(k),ue.addScaledVector(H,xe),ue.addScaledVector(K,l),ee!=null){let _e=Math.max(0,ue.y-ee);ue.addScaledVector(H,-_e/H.y)}h.push(ue.x,ue.y,ue.z),d.push(K.x,K.y,K.z),x.push(0,0),pe===0&&Ce.push(g),g++}}for(let Y=0;Y<c;Y++)for(let le=0;le<ae;le++){let pe=ne+le+(ae+1)*Y,xe=pe+(ae+1),_e=xe+1,de=pe+1;f.push(pe,xe,de),f.push(xe,_e,de)}return[k.clone().addScaledVector(H,.5),Ce]}function Fe(k,H,_,J){let ee=Math.PI/2,oe=b.angle()-ee,se=[],ce=new or,ue=new or;for(let ae=0;ae<=c;ae++){let ne=[],Ce=ae/c;for(let Y=0;Y<=ae;Y++){let pe=((ae?Y/ae:0)-.5)*B,xe=Math.cos(pe),_e=Math.sin(pe),de=Math.atan(Math.tan(oe)*xe),we=(ee+de)*Ce,Ve=Math.cos(we),Ge=Math.sin(we);ce.set(0,0,0),ce.addScaledVector(H,Ge*xe),ce.addScaledVector(_,Ve),ce.addScaledVector(J,Ge*_e),ue.copy(k).addScaledVector(ce,l),h.push(ue.x,ue.y,ue.z),d.push(ce.x,ce.y,ce.z),x.push(0,0),ne.push(g++)}se.push(ne)}let K=se.length-1;for(let ae=0;ae<K;ae++){let ne=se[ae],Ce=se[ae+1],Y=ne.length-1;f.push(ne[0],Ce[1],Ce[0]);for(let le=1;le<=Y;le++)f.push(ne[le-1],ne[le],Ce[le]),f.push(ne[le],Ce[le+1],Ce[le])}}}};var ou=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var l,c,f,h,d;let t=Object.assign({},(l=e==null?void 0:e.parameters)!=null?l:{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign((c=e==null?void 0:e.ui)!=null?c:{enabledIndieCorners:!1},i.ui),n=t.cornerRadius.reduce((x,g)=>x+g,0);return{shape:i.shape&&i.shape instanceof st?i.shape:new st,parameters:Object.assign(t,{surfaceMaxCount:((f=t.surfaceMaxCount)!=null?f:n>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((h=t.height)!=null?h:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(d=t.depth)!=null?d:0)}),ui:r}}static build(i){let e=i.shape,{width:t,height:r,cornerRadius:n,cornerType:s,depth:l,extrudeBevelSize:c,extrudeBevelSegments:f,surfaceMaxCount:h}=i.parameters,d={x:t*.5,y:r*.5},x={x:-d.x,y:-d.y},g={x:d.x,y:d.y};function w(M,q,E){return q>t&&E>r?Math.min(M*t/q,M*r/E):q>t?M*t/q:E>r?M*r/E:M}let S=[];S[0]=n[0]===0?0:w(n[0],n[0]+n[3],n[0]+n[1]),S[1]=n[1]===0?0:w(n[1],n[1]+n[2],n[1]+n[0]),S[2]=n[2]===0?0:w(n[2],n[2]+n[1],n[2]+n[3]),S[3]=n[3]===0?0:w(n[3],n[3]+n[0],n[3]+n[2]);let D=x.x,C=g.x,G=g.y,B=x.y;e.addPoint(e.createPoint(D,G)),e.addPoint(e.createPoint(C,G)),e.addPoint(e.createPoint(C,B)),e.addPoint(e.createPoint(D,B)),e.isClosed=!0;let P=!0;for(let M=0,q=e.points.length;M<q;M++)e.points[M].roundness=S[M],M>0&&S[M]!==S[M-1]&&(P=!1);P&&(e.roundness=S[0]),e.useCubicForRoundedCorners=s!==1,e.update();let W=ur.create({shape:e,parameters:{surfaceMaxCount:h,depth:l,extrudeBevelSize:c,extrudeBevelSegments:f}});return Object.assign(W,{userData:fe(U({},i),{type:"RectangleGeometry"})})}};import{SphereBufferGeometry as P2}from"three";var Y0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e=100,height:t=e,depth:r=e,widthSegments:n=64,heightSegments:s=64,phiStart:l,phiLength:c,thetaStart:f,thetaLength:h}=i.parameters,d=new P2(.5*e,n,s,l,c,f,h);return d.scale(1,t/e,r/e),Object.assign(d,{userData:fe(U({},i),{type:"SphereGeometry"})})}};import{PlaneBufferGeometry as D2}from"three";var Q0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:0})}}static build(i){let{width:e=100,height:t=e,widthSegments:r=8,heightSegments:n=8}=i.parameters,s=new D2(e,t,r,n);return s.scale(1,1,1),Object.assign(s,{userData:fe(U({},i),{type:"PlaneGeometry"})})}};var ev=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,s,l,c;let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof st?i.shape:new st,parameters:Object.assign(t,{surfaceMaxCount:((s=t.surfaceMaxCount)!=null?s:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((l=t.height)!=null?l:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(c=t.depth)!=null?c:0)})}}static build(i){let{width:e,height:t,innerRadiusPercent:r,spikes:n,cornerRadius:s,angle:l,depth:c,extrudeBevelSize:f,extrudeBevelSegments:h,surfaceMaxCount:d}=i.parameters,x=i.shape,g=e*.5,w=t*.5,S=0,D=0,C=l*Math.PI/360/n,G=Math.PI/2*3*-1,B=g*r/100,P=w*r/100;if(n==3&&r==50){C=2*Math.PI/n;for(let M=0;M<n;M++){let q=C*M,E=S+Math.sin(q)*g,b=D+Math.cos(q)*w;x.addPoint(x.createPoint(E,b))}}else for(let M=0;M<n;M++){let q=S+Math.cos(G)*g,E=D+Math.sin(G)*w;x.addPoint(x.createPoint(q,E)),G+=C,q=S+Math.cos(G)*B,E=D+Math.sin(G)*P,M<=n,x.addPoint(x.createPoint(q,E)),G+=C}x.isClosed=!0;for(let M=0,q=x.points.length;M<q;M++)x.points[M].roundness=s;x.roundness=s,x.update();let W=ur.create({shape:x,parameters:{surfaceMaxCount:d,roundness:s,depth:c,extrudeBevelSize:f,extrudeBevelSegments:h}});return Object.assign(W,{userData:fe(U({},i),{type:"StarGeometry"})})}};import{PlaneBufferGeometry as B2}from"three";var su=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,depth:0},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:0)})}}static build(i){let{width:e,height:t}=i.parameters,r=new B2(e,t);return Object.assign(r,{userData:fe(U({},i),{type:"TextFrameGeometry"})})}};var tv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var l,c,f;let t=Object.assign({},(l=e==null?void 0:e.parameters)!=null?l:{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(t.width),n=Math.abs((c=t.height)!=null?c:t.width),s=Math.abs((f=t.depth)!=null?f:t.width*.25);return{parameters:Object.assign(t,{width:r,height:n,depth:s})}}static build(i){let{width:e,height:t,depth:r,radialSegments:n,tubularSegments:s,arc:l,cornerRadius:c,cornerSegments:f}=i.parameters,h=G2(e,t,r,e*.5,l,s,0,0,n,c,f);return h.scale(1,t/e,1),Object.assign(h,{userData:fe(U({},i),{type:"TorusGeometry"})})}};function G2(i,e,t,r,n,s,l,c,f,h,d){return[e,t]=[t,e],l=e/2,n/=2*Math.PI,n==1&&(h=0),new tu(!0,i,e,t,r,n,s,l,c,f,h,d)}import{TorusKnotBufferGeometry as j2}from"three";var rv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s,l;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width),tube:(l=t.tube)!=null?l:t.width*.125})}}static build(i){let{width:e,tube:t,tubularSegments:r,radialSegments:n,p:s,q:l}=i.parameters,c=e*.5;c!==t&&(c-=t);let f=new j2(c,t,r,n,s,l);return Object.assign(f,{userData:fe(U({},i),{type:"TorusKnotGeometry"})})}};var nv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,s,l,c;let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof st?i.shape:new st,parameters:Object.assign(t,{surfaceMaxCount:((s=t.surfaceMaxCount)!=null?s:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((l=t.height)!=null?l:t.width*(t.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(c=t.depth)!=null?c:0)})}}static build(i){let{width:e=100,height:t,cornerRadius:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:l,isRect:c,surfaceMaxCount:f}=i.parameters,h=i.shape,d=e*.5,x=t*.5;c?(h.addPoint(h.createPoint(-d,x)),h.addPoint(h.createPoint(d,-x)),h.addPoint(h.createPoint(-d,-x))):(h.addPoint(h.createPoint(0,x)),h.addPoint(h.createPoint(d,-x)),h.addPoint(h.createPoint(-d,-x))),h.isClosed=!0;for(let w=0,S=h.points.length;w<S;w++)h.points[w].roundness=r;h.roundness=r,h.update();let g=ur.create({shape:h,parameters:{surfaceMaxCount:f,roundness:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(g,{userData:fe(U({},i),{type:"TriangleGeometry"})})}};var Ca={};V_(Ca,{addBarycentricAttribute:()=>V2,fixUvs:()=>k2,loadFromUrl:()=>U2,resizeGeometry:()=>F2,roundShapePolygon:()=>z2});import{BufferGeometryLoader as E2,Float32BufferAttribute as R2,Vector3 as Jh}from"three";var iv=function(i,e){let t=e.x-i.x,r=e.y-i.y,n=Math.sqrt(t*t+r*r),s=t/n,l=r/n,c=Math.atan2(l,s);return{x:t,y:r,len:n,nx:s,ny:l,ang:c}},z2=(i,e,t)=>{let r,n,s,l,c,f,h,d,x,g,w,S,D,C,G=e.length;for(l=e[G-2],i.curves=[],r=1;r<G-1;r++){c=e[r%G],f=e[(r+1)%G];let B=iv(c,l),P=iv(c,f);h=B.nx*P.ny-B.ny*P.nx,d=B.nx*P.nx-B.ny*-P.ny,w=Math.asin(h),x=1,g=!1,d<0?w<0?w=Math.PI+w:(w=Math.PI-w,x=-1,g=!0):w>0&&(x=-1,g=!0),S=w/2,C=Math.abs(Math.cos(S)*t/Math.sin(S)),C>Math.min(B.len/2,P.len/2)?(C=Math.min(B.len/2,P.len/2),D=Math.abs(C*Math.sin(S)/Math.cos(S))):D=t,n=c.x+P.nx*C,s=c.y+P.ny*C,n+=-P.ny*D*x,s+=P.nx*D*x,i.absarc(n,s,D,B.ang+Math.PI/2*x,P.ang-Math.PI/2*x,g),l=c,c=f}i.closePath()},F2=(i,{width:e,height:t,depth:r})=>{e=Math.abs(e),t=Math.abs(t),r=Math.abs(r);let n=i.userData.parameters,s,l,c;e===0?(e=n.width,s=1):s=e/n.width,t===0?(t=n.height,l=1):l=t/n.height,r===0?(r=n.depth,c=1):c=r/n.depth,i.scale(s,l,c),n.width=e,n.height=t,n.depth=r},V2=(i,e)=>{let t=[new Jh(1,0,0),new Jh(0,1,0),new Jh(0,0,1)],r=i.attributes.position,n=new Float32Array(r.count*3);for(let s=0,l=r.count;s<l;s++)t[s%3].toArray(n,s*3);i.setAttribute(e,new R2(n,3))},U2=i=>new Promise(e=>{new E2().load(i,r=>e(r))}),k2=(i,e,t)=>{let r=i.getAttribute("uv");if(r)for(let n=0;n<r.count;n++){let s=r.getX(n),l=r.getY(n);r.setXY(n,(s+e/2)/e,1-(l-t/2)/t*-1)}};import{BufferGeometry as ov,BufferAttribute as sv,Uint32BufferAttribute as Kh,Float32BufferAttribute as Xh,Matrix4 as W2}from"three";import{mergeVertices as q2}from"three/examples/jsm/utils/BufferGeometryUtils.js";var H2,au=new Promise(i=>{H2=i});var Oe;au.then(i=>{Oe=i});var av=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),lv=new Uint32Array([0,1,2,3]),cv=new Uint8Array([4]),en=class{static build(i,e,t,r,n){let s,l,c;if(i===void 0)s=en.allocate(n,t),Oe.set_destination_refinement_level(s,0),l=en.buildLevel(s,!0,r);else if(i.positionWASM!==void 0){e&&e!==0&&(Oe.free_bvh(e),Oe.free_subdivision_surface(e));try{s=en.allocate(n,void 0,i)}catch(f){console.error(f,i),s=en.allocate(n,void 0,{positionWASM:av,indexWASM:lv,verticesPerFaceWASM:cv})}Oe.set_destination_refinement_level(s,0),l=en.buildLevel(s,!0,r)}else s=e;if(i!==void 0&&i.subdivisions!==void 0){let f=$2(i.subdivisions,i.positionWASM.length);Oe.set_destination_refinement_level(s,f),f>0?c=en.buildLevel(s,!1,r):c=null}return{subdivPointer:s,originalGeometry:l,subdividedGeometry:c}}static allocate(i,e,t){var M;let r,n,s,l=[],c=[];if(t)t.positionWASM&&t.positionWASM.length>0?(r=t.positionWASM,n=t.indexWASM,s=t.verticesPerFaceWASM):(r=av,n=lv,s=cv);else{e.deleteAttribute("normal"),e.deleteAttribute("uv");let q=q2(e);r=q.attributes.position.array;let E=q.getIndex().array,b=E.length;switch(e.userData.type==="TorusGeometry"&&(e==null?void 0:e.userData.parameters.arc)===Math.PI*2&&(e.userData.type="ClosedTorusGeometry"),e.userData.type){case"ClosedTorusGeometry":case"PlaneGeometry":case"TorusKnotGeometry":case"CubeGeometry":n=new Uint32Array(b/3*2),s=new Uint8Array(b/6).fill(4);for(let re=0,Ne=0;re<b;re+=6)n[Ne++]=E[re],n[Ne++]=E[re+1],n[Ne++]=E[re+4],n[Ne++]=E[re+5];break;case"TorusGeometry":case"SphereGeometry":case"HelixGeometry":case"CylinderGeometry":case"ConeGeometry":let R,T,z;if(e.userData.type==="SphereGeometry")T=e.parameters.heightSegments,R=e.parameters.widthSegments,e.parameters.thetaLength!==Math.PI&&(z=!0);else if(e.userData.type==="CylinderGeometry")T=e.parameters.heightSegments+2,R=e.parameters.radialSegments;else if(e.userData.type==="ConeGeometry")T=e.parameters.heightSegments+1,R=e.parameters.radialSegments;else if(e.userData.type==="TorusGeometry"){let re=e.userData.parameters;T=Math.ceil(re.tubularSegments*re.arc/(2*Math.PI))+2,R=re.radialSegments}else{let{pathSegments:re,segments:Ne,revolutions:ye}=e.userData.parameters;T=Math.ceil(Ne*ye)+2,R=re}z?(n=new Uint32Array(1*R*3+(T-1)*R*4),s=new Uint8Array(1*R+(T-1)*R)):(n=new Uint32Array(2*R*3+(T-2)*R*4),s=new Uint8Array(2*R+(T-2)*R));let A=0,$=0,he=0;if(e.userData.type==="SphereGeometry"||e.userData.type==="HelixGeometry"||e.userData.type==="TorusGeometry"){for(;$<3*R;)n[$++]=E[A++],n[$++]=E[A++],n[$++]=E[A++],s[he++]=3;let re=z?n.length:3*R+4*(T-2)*R;for(;$<re;A+=6)n[$++]=E[A],n[$++]=E[A+1],n[$++]=E[A+4],n[$++]=E[A+5],s[he++]=4}else for(;$<4*(T-2)*R;A+=6)n[$++]=E[A],n[$++]=E[A+1],n[$++]=E[A+4],n[$++]=E[A+5],s[he++]=4;for(;$<n.length;)n[$++]=E[A++],n[$++]=E[A++],n[$++]=E[A++],s[he++]=3;break;default:n=E,s=new Uint8Array(b/3).fill(3);break}}let f=r.length,h=n.length,d=s.length,x=r.length+l.length+c.length,g=n.length+s.length,w=x*Float32Array.BYTES_PER_ELEMENT+g*Uint32Array.BYTES_PER_ELEMENT,S=x*Float32Array.BYTES_PER_ELEMENT,D=g*Uint32Array.BYTES_PER_ELEMENT,C=Oe._malloc(w),G=new Float32Array(Oe.HEAPF32.buffer,C,x),B=new Uint32Array(Oe.HEAPU32.buffer,C+S,g);G.set(r,0),G.set(l,r.length),G.set(c,r.length+l.length),B.set(n,0),B.set(s,n.length);let P;((M=t==null?void 0:t.scaleBaked)==null?void 0:M.some(q=>q!==1))&&(P=new W2().makeScale(...t.scaleBaked)),i&&(P?P.premultiply(i):P=i);let W=P?Oe.alloc_subdivision_surface2(C,f,C+S,h,C+S+n.length*Uint32Array.BYTES_PER_ELEMENT,d,P.elements):Oe.alloc_subdivision_surface(C,f,C+S,h,C+S+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return Oe._free(C),W}static buildLevel(i,e,t,r,n){let s=n?Oe.get_mesh_data2(i,e?Oe.Level.CONTROL:Oe.Level.REFINED,t!=null?t:!e,n.elements):Oe.get_mesh_data(i,e?Oe.Level.CONTROL:Oe.Level.REFINED,t!=null?t:!e),l=8,c=Oe.HEAPU32.subarray(s>>2,(s>>2)+l),f=c.subarray(4,4+4),h=0,d=Oe.HEAPU32[c[h]>>2],x=Oe.HEAPF32.subarray(d>>2,(d>>2)+f[h]);h++;let g=Oe.HEAPU32[c[h]>>2],w=Oe.HEAPF32.subarray(g>>2,(g>>2)+f[h]);h++;let S=Oe.HEAPU32[c[h]>>2],D=Oe.HEAPU32.subarray(S>>2,(S>>2)+f[h]);h++;let C=Oe.HEAPU32[c[h]>>2],G=Oe.HEAPU32.subarray(C>>2,(C>>2)+f[h]);if(h++,r===void 0){let B=new ov;if(B.setIndex(new Kh(G,1)),B.setAttribute("position",new Xh(x,3)),B.setAttribute("normal",new Xh(w,3)),e){B.setAttribute("faceMap",new Kh(D,1));let P=new Float32Array(w.length/3*4).fill(0);B.setAttribute("color",new sv(P,4))}return Oe.free_mesh_data(s),B.userData.type="SubdivGeometry",B}r.getAttribute("position").copyArray(x),r.getAttribute("normal").copyArray(w),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,Oe.free_mesh_data(s)}static buildControlCageWireframe(i,e,t){let r=Oe.get_wireframe_data_for_base_level(i),n=4,s=Oe.HEAPU32.subarray(r>>2,(r>>2)+n),l=s.subarray(2,2+2),c=0,f=Oe.HEAPU32[s[c]>>2],h=Oe.HEAPF32.subarray(f>>2,(f>>2)+l[c]);c++;let d=Oe.HEAPU32[s[c]>>2],x=Oe.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(e===void 0){let g=new ov;g.setAttribute("position",new Xh(h,3));let w=new Float32Array(h.length);for(let S=0,D=h.length;S<D;)w[S++]=t.r,w[S++]=t.g,w[S++]=t.b;return g.setAttribute("color",new sv(w,3)),g.setIndex(new Kh(x,1)),Oe.free_wireframe_data_for_base_level(r),g}e.getAttribute("position").copyArray(h),e.attributes.position.needsUpdate=!0,Oe.free_wireframe_data_for_base_level(r)}static updateCollabMesh(i,e,t){e||Oe.set_destination_refinement_level(i,1);let r=t?Oe.get_topological_data2(i,e?Oe.Level.CONTROL:Oe.Level.REFINED,t.elements):Oe.get_topological_data(i,e?Oe.Level.CONTROL:Oe.Level.REFINED),n=6,s=Oe.HEAPU32.subarray(r>>2,(r>>2)+n),l=s.subarray(3,3+3),c=0,f=Oe.HEAPU32[s[c]>>2],h=new Float32Array(Oe.HEAPF32.subarray(f>>2,(f>>2)+l[c]));c++;let d=Oe.HEAPU32[s[c]>>2],x=new Uint32Array(Oe.HEAPU32.subarray(d>>2,(d>>2)+l[c]));c++;let g=Oe.HEAPU32[s[c]>>2],w=new Uint8Array(Oe.HEAPU32.subarray(g>>2,(g>>2)+l[c]));return Oe.free_topological_data(r),{positions:h,indices:x,verticesPerFace:w}}};function $2(i,e){let t=i;return t=Math.min(t,3-Math.ceil(Math.log(e/172e3)/Math.log(4))),Math.max(t,0)}var Zh={ConeGeometry:u0,CubeGeometry:f0,CylinderGeometry:l0,DodecahedronGeometry:p0,EllipseGeometry:j0,HelixGeometry:U0,IcosahedronGeometry:k0,LatheGeometry:H0,NonParametricGeometry:J0,PolygonGeometry:K0,PyramidGeometry:X0,RectangleGeometry:ou,SphereGeometry:Y0,PlaneGeometry:Q0,StarGeometry:ev,TextFrameGeometry:su,TorusGeometry:tv,TorusKnotGeometry:rv,TriangleGeometry:nv,VectorGeometry:ur},La=i=>Zh[i.type].create(i);import{Matrix4 as Qh}from"three";import{Box3 as pv,Line3 as gn,Matrix4 as Yh,Vector3 as Ct}from"three";import{HemisphereLight as uv}from"three";import{Color as J2}from"three";var tn=class extends J2{constructor(e,t,r,n){super(e,t,r);this.isColorA=!0;this.a=n}setRGBA(e,t,r,n){super.setRGB(e,t,r),this.a=n}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}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}};function kt(i,e){let t;if(typeof i=="string"){let r=e==null?void 0:e.getColor(i);r?t=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new tn(0,0,0,0))}else return"a"in i?new tn(i.r,i.g,i.b,i.a):new tn(i.r,i.g,i.b,1);return t}var lu=i=>"isEntity"in i,_s=i=>"isAbstractMesh"in i;var vi=i=>"objectHelper"in i;function K2(i,e){var r;let t=!1;e.position&&(i.position.fromArray(e.position),t=!0),e.rotation&&(i.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,i.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in i&&(t=!0,i.hiddenMatrix.fromArray((r=e.hiddenMatrix)!=null?r:Fi.identity)),t&&i.updateMatrix(),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&i.updateWorldMatrix(!1,!0),i.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(i.isUpVectorFlipped=e.isUpVectorFlipped),i.updateUp())}function X2(i,e){K2(i,e),e.name!==void 0&&(i.name=e.name),e.visible!==void 0&&(i.isEntity?i.visibility=e.visible:i.visible=e.visible)}function fv(i,e,t){X2(i,e),e.color!==void 0&&(i.color=kt(e.color,t)),e.intensity!==void 0&&(i.intensity=e.intensity),e.shadows!==void 0&&!(i instanceof uv)&&(i.castShadow=e.shadows),i.shadow&&!(i instanceof uv)&&e.depth!==void 0&&(i.shadow.camera.far=e.depth,i.shadow.needsUpdate=!0),e.helper!==void 0&&vi(i)&&(i.enableHelper=e.helper,i.gizmos.shadowmap.visible=e.helper)}function hv(i,e){i.shadow.camera.right=e/2,i.shadow.camera.left=-e/2,i.shadow.camera.top=e/2,i.shadow.camera.bottom=-e/2,i.shadow.needsUpdate=!0}var Ts=new pv,fr=new Ct,Ie=new Ct,$t=new Yh;function Z2(i,e,t=0,r=e.count){let n=1/0,s=1/0,l=1/0,c=-1/0,f=-1/0,h=-1/0;for(let d=t;d<r;d++){let x=e.getX(d),g=e.getY(d),w=e.getZ(d);x<n&&(n=x),g<s&&(s=g),w<l&&(l=w),x>c&&(c=x),g>f&&(f=g),w>h&&(h=w)}return i.min.set(n,s,l),i.max.set(c,f,h),i}var dv=(i,e,t,r)=>{var n;if(_s(i)){let s=i.geometry.userData.parameters,l=i.geometry.getAttribute("position");i.geometry.userData.type==="SubdivGeometry"?fr.copy(i.originalGeometry.boundingSphere.center):(Z2(Ts,l,i.geometry.drawRange.start,i.geometry.drawRange.count<1/0?i.geometry.drawRange.count:l.count),Ts.getCenter(fr)),i.forceComputeSize?Ts.getSize(Ie).multiplyScalar(.5):Ie.set(s.width,s.height,(n=s.depth)!=null?n:0).multiplyScalar(.5)}else if(vi(i)&&r===!0){let s=i.geometryHelper.getAttribute("position");Ts.setFromArray(s.array),Ts.getCenter(fr),Ts.getSize(Ie).multiplyScalar(.5)}else fr.setScalar(0),Ie.setScalar(0);$t.copy(e).multiply(i.matrixWorld),Ie.x===0&&Ie.y===0&&Ie.z===0?t.push(new Ct(fr.x,fr.y,fr.z).applyMatrix4($t)):t.push(new Ct(-Ie.x,Ie.y,Ie.z).add(fr).applyMatrix4($t),new Ct(-Ie.x,-Ie.y,Ie.z).add(fr).applyMatrix4($t),new Ct(Ie.x,-Ie.y,Ie.z).add(fr).applyMatrix4($t),new Ct(Ie.x,Ie.y,Ie.z).add(fr).applyMatrix4($t),new Ct(-Ie.x,Ie.y,-Ie.z).add(fr).applyMatrix4($t),new Ct(-Ie.x,-Ie.y,-Ie.z).add(fr).applyMatrix4($t),new Ct(Ie.x,-Ie.y,-Ie.z).add(fr).applyMatrix4($t),new Ct(Ie.x,Ie.y,-Ie.z).add(fr).applyMatrix4($t))},cu=class extends pv{constructor(){super(...arguments);this.matrix=new Yh;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let r=new Yh().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,r,t)}expandByObjectSize(e,t,r=!1){let n=[];return r===!0?e.traverseEntity(s=>dv(s,t,n,e.enableHelper===!0)):dv(e,t,n,e.enableHelper===!0),this.setFromPoints(n)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4($t.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Ie).multiplyScalar(.5),this.getCenter(fr),$t.copy(this.matrix).setPosition(fr),this.vertices=[new Ct(-Ie.x,Ie.y,Ie.z).applyMatrix4($t),new Ct(-Ie.x,-Ie.y,Ie.z).applyMatrix4($t),new Ct(Ie.x,-Ie.y,Ie.z).applyMatrix4($t),new Ct(Ie.x,Ie.y,Ie.z).applyMatrix4($t),new Ct(-Ie.x,Ie.y,-Ie.z).applyMatrix4($t),new Ct(-Ie.x,-Ie.y,-Ie.z).applyMatrix4($t),new Ct(Ie.x,-Ie.y,-Ie.z).applyMatrix4($t),new Ct(Ie.x,Ie.y,-Ie.z).applyMatrix4($t)]}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=[new gn(this.vertices[0],this.vertices[3]),new gn(this.vertices[1],this.vertices[2]),new gn(this.vertices[5],this.vertices[6]),new gn(this.vertices[4],this.vertices[7]),new gn(this.vertices[0],this.vertices[1]),new gn(this.vertices[3],this.vertices[2]),new gn(this.vertices[7],this.vertices[6]),new gn(this.vertices[4],this.vertices[5]),new gn(this.vertices[0],this.vertices[4]),new gn(this.vertices[1],this.vertices[5]),new gn(this.vertices[2],this.vertices[6]),new gn(this.vertices[3],this.vertices[7])],this.centerEdges=this.edges.map(e=>e.getCenter(new Ct))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=[new Ct().copy(this.vertices[0]).sub(this.vertices[2]).multiplyScalar(.5).add(this.vertices[2]),new Ct().copy(this.vertices[7]).sub(this.vertices[5]).multiplyScalar(.5).add(this.vertices[5]),new Ct().copy(this.vertices[4]).sub(this.vertices[1]).multiplyScalar(.5).add(this.vertices[1]),new Ct().copy(this.vertices[3]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6]),new Ct().copy(this.vertices[4]).sub(this.vertices[3]).multiplyScalar(.5).add(this.vertices[3]),new Ct().copy(this.vertices[1]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6])]}};import{Object3D as Y2,Matrix4 as Q2,Light as eD}from"three";function _a(i){let e=[];for(let t in i){let r=i[t];delete r.metadata,e.push(r)}return e}function tD(i){let e=[];for(let t in i)e.push(i[t]);return e}var uu=i=>class extends i{hasEntityChild(){return this.children.some(t=>lu(t))}isDescendantOf(t){t instanceof Y2&&(t=t.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===t)return!0;r=r.parent}return!1}attach(t,r){this.updateWorldMatrix(!0,!1);let n=new Q2().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),n.multiply(t.parent.matrixWorld)),lu(t)?t.hiddenMatrix.premultiply(n):t.applyMatrix4(n),t.updateWorldMatrix(!1,!1),this.add(t),r!==void 0&&(this.children.pop(),this.children.splice(r,0,t)),this}copy(t,r=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),r===!0)for(let n=0;n<t.children.length;n++){let s=t.children[n];this.add(s.clone())}return this}toJSON(t){let r=t===void 0,n={object:{uuid:"",objectType:""}};t===void 0&&(t={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},n.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let s={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(s.name=this.name),s.matrix=this.matrix.toArray(),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),s.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(s.userData=this.userData),this.children.length>0){s.children=[];for(let l of this.children)(lu(l)||l instanceof eD)&&s.children.push(l.toJSON(t).object)}if(r){let l=_a(t.geometries),c=_a(t.materials),f=_a(t.textures),h=_a(t.images),d=_a(t.interactionStates),x=tD(t.nodes);l.length>0&&(n.geometries=l),c.length>0&&(n.materials=c),f.length>0&&(n.textures=f),h.length>0&&(n.images=h),d.length>0&&(n.interactionStates=d),x.length>0&&(n.nodes=x)}return n.object=s,n}fromJSON(t){return this.uuid=t.uuid,t.name!==void 0&&(this.name=t.name),t.matrix!==void 0?(this.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=t.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(t.position!==void 0&&this.position.fromArray(t.position),t.rotation!==void 0&&this.rotation.fromArray(t.rotation),t.quaternion!==void 0&&this.quaternion.fromArray(t.quaternion),t.scale!==void 0&&this.scale.fromArray(t.scale)),this.castShadow=t.castShadow!==void 0,this.receiveShadow=t.receiveShadow!==void 0,t.visible!==void 0&&(this.visible=t.visible),t.frustumCulled!==void 0&&(this.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(this.renderOrder=t.renderOrder),t.layers!==void 0&&(this.layers.mask=t.layers),t.userData!==void 0&&(this.userData=t.userData),this}};var yn=i=>"isEntity"in i;var xn=i=>class extends uu(i){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Qh;this._singleBBox=new cu;this._recursiveBBox=new cu;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(t){this.visible=t;for(let r of this.children)yn(r)&&r.traverseEntity(n=>{vi(n)&&n.visible&&(n.objectHelper.visible=t)})}get visibility(){return this.visible}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}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(t=>{yn(t)&&(t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(t=>{t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0})}traverseEntity(t){t(this);for(let r of this.children)yn(r)&&r.traverseEntity(t)}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let r of this.children)r.updateMatrixWorld(t)}updateWorldMatrix(t,r){let n=this.parent;if(t&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),r)for(let s of this.children)s.updateWorldMatrix(!1,!0)}shallowClone(t){return new this.constructor().shallowCopy(this,t)}shallowCopy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),r===!0)for(let n of t.children)yn(n)&&this.add(n.shallowClone());return this}clone(t){return new this.constructor().copy(this,t)}copy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),r===!0)for(let n of t.children)yn(n)&&this.add(n.clone());return this}keepChildrenMatrixWorld(){let t=new Qh,r=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),t.copy(this.matrixWorld).invert(),t.multiply(r);for(let n of this.children)yn(n)&&n.hiddenMatrix.premultiply(t)}toJSON(t){let r=super.toJSON(t),n=r.object;return this.raycastLock===!0&&(n.raycastLock=!0),this.scaleLock===!0&&(n.scaleLock=!0),n.hiddenMatrix=this.hiddenMatrix.toArray(),r}fromJSON(t){return super.fromJSON(t),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.scaleLock!==void 0&&(this.scaleLock=t.scaleLock),this.hiddenMatrix.fromArray(t.hiddenMatrix),this}fromObject3D(t){let r=t.children;return t.children=[],Object.assign(t,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new Qh}),this.copy(t),t.children=r,this}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let r={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return hs(r,t)}fromObjectTransformState(t){return t.position&&this.position.fromArray(t.position),t.rotation&&this.rotation.fromArray(t.rotation),t.scale&&this.scale.fromArray(t.scale),t.hiddenMatrix&&this.hiddenMatrix.fromArray(t.hiddenMatrix),this.updateMatrix(),this}toState(t=[]){let r=U({name:this.name,visible:this.visible,raycastLock:this.raycastLock},this.toObjectTransformState(t));return hs(r,t)}fromState(t,r){return t.name&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.type!=="OrthographicCamera"&&t.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),t.visible!==void 0&&(this.visibility=t.visible),this.fromObjectTransformState(t),this}};import{Object3D as rD,Vector3 as Ta,Euler as mv,MathUtils as $i}from"three";var fu=class extends rD{constructor(e,t={}){super();this.object=e;let r=e.recursiveBBox.getSize(new Ta),n=.1;this.parameters=gc.defaultData(r.toArray(),n),yo(this.parameters,t),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let e of this.children)e.material=this.object.material}setHideBase(e){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let t of this.object.material)t.visible=!0;if(e){let t=this.object.material.map(r=>r.clone());for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material}for(let t of this.object.material)t.visible=!e}else{if(this.children.length>0)if(this.object.material.visible=!0,e){let t=this.object.material.clone();for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material;this.object.material.visible=!e}this.parameters.hideBase=e}}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}this.children.forEach(e=>e.updateMatrix())}_updateCount(){let e=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==e)if(this.children.length<e)for(let t=0,r=e-this.children.length;t<r;++t){let n=this.object.shallowClone(!1);n.visible=!0,this.add(n),this.parameters.hideBase&&this.setHideBase(!0)}else for(let t=0,r=this.children.length-e;t<r;++t)this.remove(this.children[0])}_updateRadial(e){let t=e.radial,r=t.start*$i.DEG2RAD,n=t.end*$i.DEG2RAD,s=r-n,l=new mv(t.rotation[0]*$i.DEG2RAD,t.rotation[1]*$i.DEG2RAD,t.rotation[2]*$i.DEG2RAD),c;switch(t.axis){case"z":c=new Ta(0,0,1);break;case"y":c=new Ta(0,1,0);break;default:case"x":c=new Ta(1,0,0);break}for(let[f,h]of this.children.entries()){h.hiddenMatrix.identity(),h.scale.x=t.scale[0]+1,h.scale.y=t.scale[1]+1,h.scale.z=t.scale[2]+1,h.position.setScalar(0);let d=s/e.count*f-r;switch(t.axis){case"x":h.rotation.set(0,d,0);break;case"y":h.rotation.set(0,0,d);break;case"z":h.rotation.set(d,0,0);break}h.translateOnAxis(c,t.radius),h.position.x+=t.position[0],h.position.y+=t.position[1],h.position.z+=t.position[2],t.alignment===!0?(h.rotation.x+=l.x,h.rotation.y+=l.y,h.rotation.z+=l.z):h.rotation.copy(l)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,r=new mv(t.rotation[0]*$i.DEG2RAD,t.rotation[1]*$i.DEG2RAD,t.rotation[2]*$i.DEG2RAD);for(let[n,s]of this.children.entries())s.hiddenMatrix.identity(),s.scale.x=t.scale[0]*n+1,s.scale.y=t.scale[1]*n+1,s.scale.z=t.scale[2]*n+1,s.rotation.x=r.x*n,s.rotation.y=r.y*n,s.rotation.z=r.z*n,s.position.x=t.position[0]*n,s.position.y=t.position[1]*n,s.position.z=t.position[2]*n}_updateGrid(e){let t=0,r=e.grid;if(r.useCenter===!0){let n={x:r.count[0]%2==0?2:1,y:r.count[1]%2==0?2:1,z:r.count[2]%2==0?2:1},s=new Ta(r.size[0]*(r.count[0]-n.x)*.5,r.size[1]*(r.count[1]-n.y)*.5,r.size[2]*(r.count[2]-n.z)*.5);for(let l=0;l<r.count[0];l++)for(let c=0;c<r.count[1];c++)for(let f=0;f<r.count[2];f++){let h=this.children[t++];h.hiddenMatrix.identity(),h.scale.setScalar(1),h.rotation.set(0,0,0),h.position.x=r.size[0]*l-s.x,h.position.y=r.size[1]*c-s.y,h.position.z=r.size[2]*f-s.z}}else for(let n=0;n<r.count[0];n++)for(let s=0;s<r.count[1];s++)for(let l=0;l<r.count[2];l++){let c=this.children[t++];c.hiddenMatrix.identity(),c.scale.setScalar(1),c.rotation.set(0,0,0),c.position.x=r.size[0]*n,c.position.y=-r.size[1]*s,c.position.z=-r.size[2]*l}}fromJSON(e){return this}toJSON(){return{}}fromClonerState(e){return e.hideBase!==void 0&&this.setHideBase(e.hideBase),yo(this.parameters,e),this.update(),this}};var hr=class extends xn(nD){constructor(e,t){super(e,t);this.isAbstractMesh=!0;Array.isArray(t)&&(this.selectedMaterial=0,e.groups.length===0&&e.addGroup(0,e.getAttribute("position").count,0))}get cloner(){return this._cloner}set cloner(e){this._cloner&&this.remove(this._cloner),e&&this.add(e),this._cloner=e}getSelectedMaterial(e){return Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=e!=null?e:0),this.material[e!=null?e:this.selectedMaterial]):this.material}setSelectedMaterial(e,t){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=t!=null?t:0),t=t!=null?t:this.selectedMaterial,this.material[t].dispose(),this.material[t]=e):(this.material.dispose(),this.material=e)}updateGeometry(e){let t=this.geometry,r=Zh[t.userData.type],n=this.objectType==="NonParametric"?Object.assign({},t.userData,{geometry:t}):t.userData,s=r.build(r.normalizeInputs(e,n)),l=t.uuid;if(this.geometry.dispose(),this.geometry=s,this.geometry.uuid=l,this.geometry.computeBoundingSphere(),this.cloner)for(let c of this.cloner.children)c.geometry=this.geometry}resizeGeometry(e,t,r){Ca.resizeGeometry(this.geometry,{width:e,height:t,depth:r})}shallowClone(e){return new this.constructor(this.geometry,this.material).shallowCopy(this,e)}clone(e){let t=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,r=La(t),n=Array.isArray(this.material)?this.material.map(s=>s.clone()):this.material.clone();return new this.constructor(r,n).copy(this,e)}copy(e,t=!0){return super.copy(e,t),e.cloner&&(this.cloner=new fu(e,e.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new fu(this)),this.cloner.fromClonerState(e))}fromState(e,t){var r,n;return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=(r=e.castShadow)!=null?r:!0,this.receiveShadow=(n=e.receiveShadow)!=null?n:!0),this}};import{NormalBlending as LD,ShaderMaterial as _D,FrontSide as TD}from"three";import{CubeReflectionMapping as mD,CubeRefractionMapping as gD,CubeUVReflectionMapping as yD,CubeUVRefractionMapping as xD,LinearEncoding as Sv,sRGBEncoding as vD}from"three";var hu=class{constructor(e){e=e!=null?e:{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}};import{MathUtils as iD}from"three";var Pe=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=iD.generateUUID(),this.type=e,this.name="",this.userData={}}analyze(e,t){t=t!=null?t:{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,r){return r=r!=null?r:{},this.analyze(e,r),this.flow(e,t,r)}flow(e,t,r){r=r!=null?r:{},e.addFlow(r.slot,r.cache,r.context);let n={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),n}build(e,t,r){t=t!=null?t:this.getType(e,t);let n=e.getNodeData(r!=null?r:this);return e.analyzing&&this.appendDepsNode(e,n,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,r)}updateFrame(e){}generateReadonly(e,t,r,n,s,l){return""}generate(e,t,r,n,s){return""}parse(e,t,r,n){}appendDepsNode(e,t,r){t.deps=(t.deps||0)+1;let n=e.getTypeLength(r);(n>(t.outputMax||0)||this.getType(e,r))&&(t.outputMax=n,t.output=r)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getJSONNode(e){if((e==null?void 0:e.materials)&&(e==null?void 0:e.materials[this.uuid])!==void 0)return e.materials[this.uuid]}getHash(){let e="{",t,r;for(t in this)r=this[t],r instanceof Pe&&(e+='"'+t+'":'+r.getHash()+",");if(this.hashProperties)for(let n=0;n<this.hashProperties.length;n++)t=this.hashProperties[n],r=this[t],e+='"'+t+'":"'+String(r)+'",';return e+='"id":"'+this.uuid+'"}',e}copy(e){return this.name=e.name,e.type&&(this.type=e.type),e.frameId&&(this.frameId=e.frameId),e.hashProperties&&(this.hashProperties=e.hashProperties.map(t=>t)),this.userData=JSON.parse(JSON.stringify(e.userData)),this.shortcuts=JSON.parse(JSON.stringify(e.shortcuts)),this}clone(){return new this.constructor().copy(this)}createJSONNode(e){let t=e===void 0||typeof e=="string";if(typeof this.type!="string")throw new Error("Node does not allow serialization.");let r={};return r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),JSON.stringify(this.userData)!=="{}"&&(r.userData=this.userData),!t&&e&&(e.nodes[this.uuid]=r),r}toJSON(e){var t;return(t=this.getJSONNode(e))!=null?t:this.createJSONNode(e)}fromJSON(e,t){return this.uuid=e.uuid,this.type=e.type,e.name&&(this.name=e.name),e.userData&&(this.userData=e.userData),this}};var gv=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,r){r=r!==void 0?r:!0,this.keywords[e]={callback:t,cache:r}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},tr=new gv;import{Vector2 as yv}from"three";import{MathUtils as oD}from"three";var Be=class extends Pe{constructor(e,t){super(e);this.scope="";t=t!=null?t:{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,r,n){if(t=t!=null?t:this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=oD.generateUUID()),r=e.getUUID(r!=null?r:this.getUUID(),!s);let l=e.getNodeData(r),c=l.output||this.getType(e);if(e.analyzing)return(l.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,l,t),this.generate(e,t,r)):super.build(e,t,r);if(s)return l.name=l.name||super.build(e,t,r),l.name;if(!this.getLabel()&&(!this.getShared(e,c)||e.context.ignoreCache||l.deps===1))return super.build(e,t,r);r=this.getUUID(!1);let f=this.getTemp(e,r);if(f)return e.format(f,c,t);{f=super.generate(e,t,r,l.output,n);let h=this.generate(e,c,r);return e.addNodeCode(f+" = "+h+";"),e.format(f,c,t)}}return super.build(e,t,r)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let r=e.getVars()[t];return r?r.name:void 0}generate(e,t,r,n,s){return this.getShared(e,t)||console.error("TempNode is not shared"),r=r!=null?r:this.uuid,e.getTempVar(r,n!=null?n:this.getType(e),s,this.getLabel()).name}};var It=class extends Be{constructor(e,t){t=t!=null?t:{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}createJSONNode(e){let t=super.createJSONNode(e);return this.readonly===!0&&(t.readonly=this.readonly),t}fromJSON(e,t){return super.fromJSON(e,t),e.readonly!==void 0&&this.setReadonly(e.readonly),this}generate(e,t,r,n,s,l){r=e.getUUID(r!=null?r:this.getUUID()),n=n!=null?n:this.getType(e);let c=e.getNodeData(r);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,r,n,s,l):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(n,this,s,l,this.getLabel())),e.format(c.vertex.name,n,t)):(c.fragment||(c.fragment=e.createFragmentUniform(n,this,s,l,this.getLabel())),e.format(c.fragment.name,n,t))}copy(e){return super.copy(e),this.readonly=e.readonly,this}};var _r=class extends It{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof yv?e:new yv(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,r,n,s,l){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};import{Vector3 as xv}from"three";var Tr=class extends It{constructor(e=0,t,r){super("v3");this.nodeType="Vector3";this.value=e instanceof xv?e:new xv(e,t,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}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,r,n,s,l){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var Ji=class extends It{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof tn?e:new tn(e.r,e.g,e.b,e.a)}generateReadonly(e,t,r,n,s,l){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var sD=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,vv=/[a-z_0-9]+/gi,Se=class extends Be{constructor(e,t,r,n,s){super(s);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,r,n)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,r,n,s){let l,c=0,f=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let h=[];for(;l=vv.exec(this.src);)h.push(l);for(let d=0;d<h.length;d++){let x=h[d],g=x[0],w=this.isMethod?!this.getInputByName(g):!0,S=g;if(this.keywords[g]||this.useKeywords&&w&&tr.containsKeyword(g)){let D=this.keywords[g];if(!D){let C=tr.getKeywordData(g);C.cache&&(D=e.keywords[g]),D=D||tr.getKeyword(g,e),C.cache&&(e.keywords[g]=D)}S=D.build(e)}g!==S&&(f=f.substring(0,x.index+c)+S+f.substring(x.index+g.length+c),c+=S.length-g.length),this.getIncludeByName(S)===void 0&&tr.contains(S)&&e.include(tr.get(S))}return t==="source"?f:this.isMethod?(this.isInterface||e.include(this,void 0,f),this.name):e.format("( "+f+" )",this.getType(e),t)}parse(e,t,r,n){if(this.src=e||"",this.includes=t!=null?t:[],this.extensions=r!=null?r:{},this.keywords=n!=null?n:{},this.isMethod){let s=sD.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let l=s[3].match(vv);if(l){let c=0;for(;c<l.length;){let f=l[c++],h;f==="in"||f==="out"||f==="inout"?h=l[c++]:(h=f,f="");let d=l[c++];this.inputs.push({name:d,type:h,qualifier:f})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}copy(e){return super.copy(e),this.isMethod=e.isMethod,this.useKeywords=e.useKeywords,e.type!==void 0&&(this.type=e.type),this.parse(e.src,e.includes,e.extensions,e.keywords),this}toJSON(e){var r;let t=this.getJSONNode(e);if(!t){t=this.createJSONNode(e),t.src=this.src,t.isMethod=this.isMethod,t.useKeywords=this.useKeywords,this.isMethod||(t.type=this.type),t.extensions=JSON.parse(JSON.stringify(this.extensions));let n={};for(let s in this.keywords)n[s]=this.keywords[s].toJSON(e).uuid;if(t.keywords=n,(r=this.includes)==null?void 0:r.length){let s=[];for(let l=0;l<this.includes.length;l++)s.push(this.includes[l].toJSON(e).uuid);t.includes=s}t.isMethod=this.isMethod,t.inputs=this.inputs}return t.nodeType=this.nodeType,t}fromJSON(e,t){if(super.fromJSON(e,t),e.inputs!==void 0&&(this.inputs=e.inputs),e.isMethod!==void 0&&(this.isMethod=e.isMethod),e.src&&(this.src=e.src),e.isMethod&&(this.isMethod=e.isMethod),e.useKeywords&&(this.useKeywords=e.useKeywords),e.type&&(this.type=e.type),e.extensions&&(this.extensions=e.extensions),e.keywords&&t){this.keywords={};for(let r in e.keywords)this.keywords[r]=t.getNode(e.keywords[r])}return e.includes&&t&&(this.includes=e.includes.map(r=>t.getNode(r))),this}};var aD=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,ep=class extends Be{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||ep.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,r,n,s){this.src=e||"";let l,c,f="",h=aD.exec(e);this.useDefine=s!=null?s:this.src.charAt(0)==="#",h&&h.length>1?(c=h[1],l=h[2],f=h[3]):(l=this.src,c="f"),this.name=l,this.type=c,this.value=f}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,r,n,s){return e.format(this.name,this.getType(e),t)}copy(e){return super.copy(e),this.parse(e.src,void 0,void 0,void 0,e.useDefine),this}},it=ep;it.PI="PI",it.PI2="PI2",it.RECIPROCAL_PI="RECIPROCAL_PI",it.RECIPROCAL_PI2="RECIPROCAL_PI2",it.LOG2="LOG2",it.EPSILON="EPSILON";var lD=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
20
|
+
}`;var Je=rg(function(){return lt(v,Le+"return "+ie).apply(i,N)});if(Je.source=ie,zf(Je))throw Je;return Je}function VL(o){return ut(o).toLowerCase()}function UL(o){return ut(o).toUpperCase()}function kL(o,a,u){if(o=ut(o),o&&(u||a===i))return o.replace(tt,"");if(!o||!(a=qr(a)))return o;var p=_n(o),m=_n(a),v=pd(p,m),N=dd(p,m)+1;return Pi(p,v,N).join("")}function HL(o,a,u){if(o=ut(o),o&&(u||a===i))return o.replace(mt,"");if(!o||!(a=qr(a)))return o;var p=_n(o),m=dd(p,_n(a))+1;return Pi(p,0,m).join("")}function WL(o,a,u){if(o=ut(o),o&&(u||a===i))return o.replace(at,"");if(!o||!(a=qr(a)))return o;var p=_n(o),m=pd(p,_n(a));return Pi(p,m).join("")}function qL(o,a){var u=E,p=b;if(Dt(a)){var m="separator"in a?a.separator:m;u="length"in a?We(a.length):u,p="omission"in a?qr(a.omission):p}o=ut(o);var v=o.length;if(Eo(o)){var N=_n(o);v=N.length}if(u>=v)return o;var L=u-Ro(p);if(L<1)return p;var I=N?Pi(N,0,L).join(""):o.slice(0,L);if(m===i)return I+p;if(N&&(L+=I.length-L),Ff(m)){if(o.slice(L).search(m)){var Q,te=I;for(m.global||(m=tf(m.source,ut(Ln.exec(m))+"g")),m.lastIndex=0;Q=m.exec(te);)var ie=Q.index;I=I.slice(0,ie===i?L:ie)}}else if(o.indexOf(qr(m),L)!=L){var me=I.lastIndexOf(m);me>-1&&(I=I.slice(0,me))}return I+p}function $L(o){return o=ut(o),o&&Do.test(o)?o.replace(ro,wS):o}var JL=Ho(function(o,a,u){return o+(u?" ":"")+a.toUpperCase()}),kf=nm("toUpperCase");function tg(o,a,u){return o=ut(o),a=u?i:a,a===i?yS(o)?LS(o):lS(o):o.match(a)||[]}var rg=Ze(function(o,a){try{return Hr(o,i,a)}catch(u){return zf(u)?u:new Ue(u)}}),KL=si(function(o,a){return sn(a,function(u){u=Vn(u),ii(o,u,Ef(o[u],o))}),o});function XL(o){var a=o==null?0:o.length,u=De();return o=a?Ot(o,function(p){if(typeof p[1]!="function")throw new an(n);return[u(p[0]),p[1]]}):[],Ze(function(p){for(var m=-1;++m<a;){var v=o[m];if(Hr(v[0],this,p))return Hr(v[1],this,p)}})}function ZL(o){return ww(cn(o,f))}function Hf(o){return function(){return o}}function YL(o,a){return o==null||o!==o?a:o}var QL=om(),e_=om(!0);function Br(o){return o}function Wf(o){return Gd(typeof o=="function"?o:cn(o,f))}function t_(o){return Ed(cn(o,f))}function r_(o,a){return Rd(o,cn(a,f))}var n_=Ze(function(o,a){return function(u){return Ks(u,o,a)}}),i_=Ze(function(o,a){return function(u){return Ks(o,u,a)}});function qf(o,a,u){var p=nr(a),m=bl(a,p);u==null&&!(Dt(a)&&(m.length||!p.length))&&(u=a,a=o,o=this,m=bl(a,nr(a)));var v=!(Dt(u)&&"chain"in u)||!!u.chain,N=li(o);return sn(m,function(L){var I=a[L];o[L]=I,N&&(o.prototype[L]=function(){var Q=this.__chain__;if(v||Q){var te=o(this.__wrapped__),ie=te.__actions__=Or(this.__actions__);return ie.push({func:I,args:arguments,thisArg:o}),te.__chain__=Q,te}return I.apply(o,Li([this.value()],arguments))})}),o}function o_(){return rr._===this&&(rr._=OS),this}function $f(){}function s_(o){return o=We(o),Ze(function(a){return zd(a,o)})}var a_=Cf(Ot),l_=Cf(ld),c_=Cf(Ju);function ng(o){return Of(o)?Ku(Vn(o)):zw(o)}function u_(o){return function(a){return o==null?i:uo(o,a)}}var f_=am(),h_=am(!0);function Jf(){return[]}function Kf(){return!1}function p_(){return{}}function d_(){return""}function m_(){return!0}function g_(o,a){if(o=We(o),o<1||o>re)return[];var u=Me,p=dr(o,Me);a=De(a),o-=Me;for(var m=Yu(p,a);++u<o;)a(u);return m}function y_(o){return ke(o)?Ot(o,Vn):$r(o)?[o]:Or(Nm(ut(o)))}function x_(o){var a=++MS;return ut(o)+a}var v_=_l(function(o,a){return o+a},0),b_=Lf("ceil"),S_=_l(function(o,a){return o/a},1),w_=Lf("floor");function N_(o){return o&&o.length?vl(o,Br,uf):i}function C_(o,a){return o&&o.length?vl(o,De(a,2),uf):i}function L_(o){return fd(o,Br)}function __(o,a){return fd(o,De(a,2))}function T_(o){return o&&o.length?vl(o,Br,df):i}function I_(o,a){return o&&o.length?vl(o,De(a,2),df):i}var M_=_l(function(o,a){return o*a},1),A_=Lf("round"),O_=_l(function(o,a){return o-a},0);function P_(o){return o&&o.length?Zu(o,Br):0}function D_(o,a){return o&&o.length?Zu(o,De(a,2)):0}return y.after=tC,y.ary=Bm,y.assign=UC,y.assignIn=Jm,y.assignInWith=zl,y.assignWith=kC,y.at=HC,y.before=Gm,y.bind=Ef,y.bindAll=KL,y.bindKey=jm,y.castArray=pC,y.chain=Om,y.chunk=w1,y.compact=N1,y.concat=C1,y.cond=XL,y.conforms=ZL,y.constant=Hf,y.countBy=PN,y.create=WC,y.curry=Em,y.curryRight=Rm,y.debounce=zm,y.defaults=qC,y.defaultsDeep=$C,y.defer=rC,y.delay=nC,y.difference=L1,y.differenceBy=_1,y.differenceWith=T1,y.drop=I1,y.dropRight=M1,y.dropRightWhile=A1,y.dropWhile=O1,y.fill=P1,y.filter=BN,y.flatMap=EN,y.flatMapDeep=RN,y.flatMapDepth=zN,y.flatten=Tm,y.flattenDeep=D1,y.flattenDepth=B1,y.flip=iC,y.flow=QL,y.flowRight=e_,y.fromPairs=G1,y.functions=eL,y.functionsIn=tL,y.groupBy=FN,y.initial=E1,y.intersection=R1,y.intersectionBy=z1,y.intersectionWith=F1,y.invert=nL,y.invertBy=iL,y.invokeMap=UN,y.iteratee=Wf,y.keyBy=kN,y.keys=nr,y.keysIn=Dr,y.map=Dl,y.mapKeys=sL,y.mapValues=aL,y.matches=t_,y.matchesProperty=r_,y.memoize=Gl,y.merge=lL,y.mergeWith=Km,y.method=n_,y.methodOf=i_,y.mixin=qf,y.negate=jl,y.nthArg=s_,y.omit=cL,y.omitBy=uL,y.once=oC,y.orderBy=HN,y.over=a_,y.overArgs=sC,y.overEvery=l_,y.overSome=c_,y.partial=Rf,y.partialRight=Fm,y.partition=WN,y.pick=fL,y.pickBy=Xm,y.property=ng,y.propertyOf=u_,y.pull=H1,y.pullAll=Mm,y.pullAllBy=W1,y.pullAllWith=q1,y.pullAt=$1,y.range=f_,y.rangeRight=h_,y.rearg=aC,y.reject=JN,y.remove=J1,y.rest=lC,y.reverse=Gf,y.sampleSize=XN,y.set=pL,y.setWith=dL,y.shuffle=ZN,y.slice=K1,y.sortBy=eC,y.sortedUniq=rN,y.sortedUniqBy=nN,y.split=EL,y.spread=cC,y.tail=iN,y.take=oN,y.takeRight=sN,y.takeRightWhile=aN,y.takeWhile=lN,y.tap=NN,y.throttle=uC,y.thru=Pl,y.toArray=Wm,y.toPairs=Zm,y.toPairsIn=Ym,y.toPath=y_,y.toPlainObject=$m,y.transform=mL,y.unary=fC,y.union=cN,y.unionBy=uN,y.unionWith=fN,y.uniq=hN,y.uniqBy=pN,y.uniqWith=dN,y.unset=gL,y.unzip=jf,y.unzipWith=Am,y.update=yL,y.updateWith=xL,y.values=$o,y.valuesIn=vL,y.without=mN,y.words=tg,y.wrap=hC,y.xor=gN,y.xorBy=yN,y.xorWith=xN,y.zip=vN,y.zipObject=bN,y.zipObjectDeep=SN,y.zipWith=wN,y.entries=Zm,y.entriesIn=Ym,y.extend=Jm,y.extendWith=zl,qf(y,y),y.add=v_,y.attempt=rg,y.camelCase=NL,y.capitalize=Qm,y.ceil=b_,y.clamp=bL,y.clone=dC,y.cloneDeep=gC,y.cloneDeepWith=yC,y.cloneWith=mC,y.conformsTo=xC,y.deburr=eg,y.defaultTo=YL,y.divide=S_,y.endsWith=CL,y.eq=In,y.escape=LL,y.escapeRegExp=_L,y.every=DN,y.find=GN,y.findIndex=Lm,y.findKey=JC,y.findLast=jN,y.findLastIndex=_m,y.findLastKey=KC,y.floor=w_,y.forEach=Pm,y.forEachRight=Dm,y.forIn=XC,y.forInRight=ZC,y.forOwn=YC,y.forOwnRight=QC,y.get=Vf,y.gt=vC,y.gte=bC,y.has=rL,y.hasIn=Uf,y.head=Im,y.identity=Br,y.includes=VN,y.indexOf=j1,y.inRange=SL,y.invoke=oL,y.isArguments=po,y.isArray=ke,y.isArrayBuffer=SC,y.isArrayLike=Pr,y.isArrayLikeObject=zt,y.isBoolean=wC,y.isBuffer=Di,y.isDate=NC,y.isElement=CC,y.isEmpty=LC,y.isEqual=_C,y.isEqualWith=TC,y.isError=zf,y.isFinite=IC,y.isFunction=li,y.isInteger=Vm,y.isLength=El,y.isMap=Um,y.isMatch=MC,y.isMatchWith=AC,y.isNaN=OC,y.isNative=PC,y.isNil=BC,y.isNull=DC,y.isNumber=km,y.isObject=Dt,y.isObjectLike=Gt,y.isPlainObject=ta,y.isRegExp=Ff,y.isSafeInteger=GC,y.isSet=Hm,y.isString=Rl,y.isSymbol=$r,y.isTypedArray=qo,y.isUndefined=jC,y.isWeakMap=EC,y.isWeakSet=RC,y.join=V1,y.kebabCase=TL,y.last=fn,y.lastIndexOf=U1,y.lowerCase=IL,y.lowerFirst=ML,y.lt=zC,y.lte=FC,y.max=N_,y.maxBy=C_,y.mean=L_,y.meanBy=__,y.min=T_,y.minBy=I_,y.stubArray=Jf,y.stubFalse=Kf,y.stubObject=p_,y.stubString=d_,y.stubTrue=m_,y.multiply=M_,y.nth=k1,y.noConflict=o_,y.noop=$f,y.now=Bl,y.pad=AL,y.padEnd=OL,y.padStart=PL,y.parseInt=DL,y.random=wL,y.reduce=qN,y.reduceRight=$N,y.repeat=BL,y.replace=GL,y.result=hL,y.round=A_,y.runInContext=O,y.sample=KN,y.size=YN,y.snakeCase=jL,y.some=QN,y.sortedIndex=X1,y.sortedIndexBy=Z1,y.sortedIndexOf=Y1,y.sortedLastIndex=Q1,y.sortedLastIndexBy=eN,y.sortedLastIndexOf=tN,y.startCase=RL,y.startsWith=zL,y.subtract=O_,y.sum=P_,y.sumBy=D_,y.template=FL,y.times=g_,y.toFinite=ci,y.toInteger=We,y.toLength=qm,y.toLower=VL,y.toNumber=hn,y.toSafeInteger=VC,y.toString=ut,y.toUpper=UL,y.trim=kL,y.trimEnd=HL,y.trimStart=WL,y.truncate=qL,y.unescape=$L,y.uniqueId=x_,y.upperCase=JL,y.upperFirst=kf,y.each=Pm,y.eachRight=Dm,y.first=Im,qf(y,function(){var o={};return zn(y,function(a,u){pt.call(y.prototype,u)||(o[u]=a)}),o}(),{chain:!1}),y.VERSION=e,sn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){y[o].placeholder=y}),sn(["drop","take"],function(o,a){rt.prototype[o]=function(u){u=u===i?1:Xt(We(u),0);var p=this.__filtered__&&!a?new rt(this):this.clone();return p.__filtered__?p.__takeCount__=dr(u,p.__takeCount__):p.__views__.push({size:dr(u,Me),type:o+(p.__dir__<0?"Right":"")}),p},rt.prototype[o+"Right"]=function(u){return this.reverse()[o](u).reverse()}}),sn(["filter","map","takeWhile"],function(o,a){var u=a+1,p=u==z||u==$;rt.prototype[o]=function(m){var v=this.clone();return v.__iteratees__.push({iteratee:De(m,3),type:u}),v.__filtered__=v.__filtered__||p,v}}),sn(["head","last"],function(o,a){var u="take"+(a?"Right":"");rt.prototype[o]=function(){return this[u](1).value()[0]}}),sn(["initial","tail"],function(o,a){var u="drop"+(a?"":"Right");rt.prototype[o]=function(){return this.__filtered__?new rt(this):this[u](1)}}),rt.prototype.compact=function(){return this.filter(Br)},rt.prototype.find=function(o){return this.filter(o).head()},rt.prototype.findLast=function(o){return this.reverse().find(o)},rt.prototype.invokeMap=Ze(function(o,a){return typeof o=="function"?new rt(this):this.map(function(u){return Ks(u,o,a)})}),rt.prototype.reject=function(o){return this.filter(jl(De(o)))},rt.prototype.slice=function(o,a){o=We(o);var u=this;return u.__filtered__&&(o>0||a<0)?new rt(u):(o<0?u=u.takeRight(-o):o&&(u=u.drop(o)),a!==i&&(a=We(a),u=a<0?u.dropRight(-a):u.take(a-o)),u)},rt.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},rt.prototype.toArray=function(){return this.take(Me)},zn(rt.prototype,function(o,a){var u=/^(?:filter|find|map|reject)|While$/.test(a),p=/^(?:head|last)$/.test(a),m=y[p?"take"+(a=="last"?"Right":""):a],v=p||/^find/.test(a);!m||(y.prototype[a]=function(){var N=this.__wrapped__,L=p?[1]:arguments,I=N instanceof rt,Q=L[0],te=I||ke(N),ie=function(et){var nt=m.apply(y,Li([et],L));return p&&me?nt[0]:nt};te&&u&&typeof Q=="function"&&Q.length!=1&&(I=te=!1);var me=this.__chain__,Le=!!this.__actions__.length,Re=v&&!me,Je=I&&!Le;if(!v&&te){N=Je?N:new rt(this);var je=o.apply(N,L);return je.__actions__.push({func:Pl,args:[ie],thisArg:i}),new ln(je,me)}return Re&&Je?o.apply(this,L):(je=this.thru(ie),Re?p?je.value()[0]:je.value():je)})}),sn(["pop","push","shift","sort","splice","unshift"],function(o){var a=il[o],u=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",p=/^(?:pop|shift)$/.test(o);y.prototype[o]=function(){var m=arguments;if(p&&!this.__chain__){var v=this.value();return a.apply(ke(v)?v:[],m)}return this[u](function(N){return a.apply(ke(N)?N:[],m)})}}),zn(rt.prototype,function(o,a){var u=y[a];if(u){var p=u.name+"";pt.call(Vo,p)||(Vo[p]=[]),Vo[p].push({name:a,func:u})}}),Vo[Ll(i,S).name]=[{name:"wrapper",func:i}],rt.prototype.clone=$S,rt.prototype.reverse=JS,rt.prototype.value=KS,y.prototype.at=CN,y.prototype.chain=LN,y.prototype.commit=_N,y.prototype.next=TN,y.prototype.plant=MN,y.prototype.reverse=AN,y.prototype.toJSON=y.prototype.valueOf=y.prototype.value=ON,y.prototype.first=y.prototype.head,Us&&(y.prototype[Us]=IN),y},Ti=_S();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(rr._=Ti,define(function(){return Ti})):oo?((oo.exports=Ti)._=Ti,Hu._=Ti):rr._=Ti}).call(Fs)});import{FileLoader as tB,Loader as rB}from"three";function fg(i){return Array.isArray(i)?i:[i]}var k_=typeof global=="object"&&global&&global.Object===Object&&global,Fl=k_;var H_=typeof self=="object"&&self&&self.Object===Object&&self,W_=Fl||H_||Function("return this")(),qt=W_;var q_=qt.Symbol,Nr=q_;var hg=Object.prototype,$_=hg.hasOwnProperty,J_=hg.toString,na=Nr?Nr.toStringTag:void 0;function K_(i){var e=$_.call(i,na),t=i[na];try{i[na]=void 0;var r=!0}catch(s){}var n=J_.call(i);return r&&(e?i[na]=t:delete i[na]),n}var pg=K_;var X_=Object.prototype,Z_=X_.toString;function Y_(i){return Z_.call(i)}var dg=Y_;var Q_="[object Null]",eT="[object Undefined]",mg=Nr?Nr.toStringTag:void 0;function tT(i){return i==null?i===void 0?eT:Q_:mg&&mg in Object(i)?pg(i):dg(i)}var Xr=tT;function rT(i){return i!=null&&typeof i=="object"}var gr=rT;var nT="[object Symbol]";function iT(i){return typeof i=="symbol"||gr(i)&&Xr(i)==nT}var Jo=iT;function oT(i,e){for(var t=-1,r=i==null?0:i.length,n=Array(r);++t<r;)n[t]=e(i[t],t,i);return n}var Vl=oT;var sT=Array.isArray,cr=sT;var aT=1/0,gg=Nr?Nr.prototype:void 0,yg=gg?gg.toString:void 0;function xg(i){if(typeof i=="string")return i;if(cr(i))return Vl(i,xg)+"";if(Jo(i))return yg?yg.call(i):"";var e=i+"";return e=="0"&&1/i==-aT?"-0":e}var vg=xg;function lT(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var yr=lT;function cT(i){return i}var Ul=cT;var uT="[object AsyncFunction]",fT="[object Function]",hT="[object GeneratorFunction]",pT="[object Proxy]";function dT(i){if(!yr(i))return!1;var e=Xr(i);return e==fT||e==hT||e==uT||e==pT}var Ko=dT;var mT=qt["__core-js_shared__"],kl=mT;var bg=function(){var i=/[^.]+$/.exec(kl&&kl.keys&&kl.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function gT(i){return!!bg&&bg in i}var Sg=gT;var yT=Function.prototype,xT=yT.toString;function vT(i){if(i!=null){try{return xT.call(i)}catch(e){}try{return i+""}catch(e){}}return""}var fi=vT;var bT=/[\\^$.*+?()[\]{}|]/g,ST=/^\[object .+?Constructor\]$/,wT=Function.prototype,NT=Object.prototype,CT=wT.toString,LT=NT.hasOwnProperty,_T=RegExp("^"+CT.call(LT).replace(bT,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function TT(i){if(!yr(i)||Sg(i))return!1;var e=Ko(i)?_T:ST;return e.test(fi(i))}var wg=TT;function IT(i,e){return i==null?void 0:i[e]}var Ng=IT;function MT(i,e){var t=Ng(i,e);return wg(t)?t:void 0}var Gr=MT;var AT=Gr(qt,"WeakMap"),Hl=AT;var Cg=Object.create,OT=function(){function i(){}return function(e){if(!yr(e))return{};if(Cg)return Cg(e);i.prototype=e;var t=new i;return i.prototype=void 0,t}}(),Lg=OT;function PT(i,e,t){switch(t.length){case 0:return i.call(e);case 1:return i.call(e,t[0]);case 2:return i.call(e,t[0],t[1]);case 3:return i.call(e,t[0],t[1],t[2])}return i.apply(e,t)}var _g=PT;function DT(i,e){var t=-1,r=i.length;for(e||(e=Array(r));++t<r;)e[t]=i[t];return e}var Wl=DT;var BT=800,GT=16,jT=Date.now;function ET(i){var e=0,t=0;return function(){var r=jT(),n=GT-(r-t);if(t=r,n>0){if(++e>=BT)return arguments[0]}else e=0;return i.apply(void 0,arguments)}}var Tg=ET;function RT(i){return function(){return i}}var Ig=RT;var zT=function(){try{var i=Gr(Object,"defineProperty");return i({},"",{}),i}catch(e){}}(),Xo=zT;var FT=Xo?function(i,e){return Xo(i,"toString",{configurable:!0,enumerable:!1,value:Ig(e),writable:!0})}:Ul,Mg=FT;var VT=Tg(Mg),ql=VT;function UT(i,e){for(var t=-1,r=i==null?0:i.length;++t<r&&e(i[t],t,i)!==!1;);return i}var Ag=UT;var kT=9007199254740991,HT=/^(?:0|[1-9]\d*)$/;function WT(i,e){var t=typeof i;return e=e==null?kT:e,!!e&&(t=="number"||t!="symbol"&&HT.test(i))&&i>-1&&i%1==0&&i<e}var $l=WT;function qT(i,e,t){e=="__proto__"&&Xo?Xo(i,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):i[e]=t}var Zo=qT;function $T(i,e){return i===e||i!==i&&e!==e}var Bi=$T;var JT=Object.prototype,KT=JT.hasOwnProperty;function XT(i,e,t){var r=i[e];(!(KT.call(i,e)&&Bi(r,t))||t===void 0&&!(e in i))&&Zo(i,e,t)}var Jl=XT;function ZT(i,e,t,r){var n=!t;t||(t={});for(var s=-1,l=e.length;++s<l;){var c=e[s],f=r?r(t[c],i[c],c,t,i):void 0;f===void 0&&(f=i[c]),n?Zo(t,c,f):Jl(t,c,f)}return t}var pn=ZT;var Og=Math.max;function YT(i,e,t){return e=Og(e===void 0?i.length-1:e,0),function(){for(var r=arguments,n=-1,s=Og(r.length-e,0),l=Array(s);++n<s;)l[n]=r[e+n];n=-1;for(var c=Array(e+1);++n<e;)c[n]=r[n];return c[e]=t(l),_g(i,this,c)}}var Kl=YT;function QT(i,e){return ql(Kl(i,e,Ul),i+"")}var Pg=QT;var eI=9007199254740991;function tI(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=eI}var Xl=tI;function rI(i){return i!=null&&Xl(i.length)&&!Ko(i)}var Gi=rI;function nI(i,e,t){if(!yr(t))return!1;var r=typeof e;return(r=="number"?Gi(t)&&$l(e,t.length):r=="string"&&e in t)?Bi(t[e],i):!1}var Dg=nI;function iI(i){return Pg(function(e,t){var r=-1,n=t.length,s=n>1?t[n-1]:void 0,l=n>2?t[2]:void 0;for(s=i.length>3&&typeof s=="function"?(n--,s):void 0,l&&Dg(t[0],t[1],l)&&(s=n<3?void 0:s,n=1),e=Object(e);++r<n;){var c=t[r];c&&i(e,c,r,s)}return e})}var Bg=iI;var oI=Object.prototype;function sI(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||oI;return i===t}var Yo=sI;function aI(i,e){for(var t=-1,r=Array(i);++t<i;)r[t]=e(t);return r}var Gg=aI;var lI="[object Arguments]";function cI(i){return gr(i)&&Xr(i)==lI}var Xf=cI;var jg=Object.prototype,uI=jg.hasOwnProperty,fI=jg.propertyIsEnumerable,hI=Xf(function(){return arguments}())?Xf:function(i){return gr(i)&&uI.call(i,"callee")&&!fI.call(i,"callee")},mo=hI;function pI(){return!1}var Eg=pI;var Rg=typeof exports=="object"&&exports&&!exports.nodeType&&exports,zg=Rg&&typeof module=="object"&&module&&!module.nodeType&&module,dI=zg&&zg.exports===Rg,Fg=dI?qt.Buffer:void 0,mI=Fg?Fg.isBuffer:void 0,gI=mI||Eg,Qo=gI;var yI="[object Arguments]",xI="[object Array]",vI="[object Boolean]",bI="[object Date]",SI="[object Error]",wI="[object Function]",NI="[object Map]",CI="[object Number]",LI="[object Object]",_I="[object RegExp]",TI="[object Set]",II="[object String]",MI="[object WeakMap]",AI="[object ArrayBuffer]",OI="[object DataView]",PI="[object Float32Array]",DI="[object Float64Array]",BI="[object Int8Array]",GI="[object Int16Array]",jI="[object Int32Array]",EI="[object Uint8Array]",RI="[object Uint8ClampedArray]",zI="[object Uint16Array]",FI="[object Uint32Array]",Tt={};Tt[PI]=Tt[DI]=Tt[BI]=Tt[GI]=Tt[jI]=Tt[EI]=Tt[RI]=Tt[zI]=Tt[FI]=!0;Tt[yI]=Tt[xI]=Tt[AI]=Tt[vI]=Tt[OI]=Tt[bI]=Tt[SI]=Tt[wI]=Tt[NI]=Tt[CI]=Tt[LI]=Tt[_I]=Tt[TI]=Tt[II]=Tt[MI]=!1;function VI(i){return gr(i)&&Xl(i.length)&&!!Tt[Xr(i)]}var Vg=VI;function UI(i){return function(e){return i(e)}}var es=UI;var Ug=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ia=Ug&&typeof module=="object"&&module&&!module.nodeType&&module,kI=ia&&ia.exports===Ug,Zf=kI&&Fl.process,HI=function(){try{var i=ia&&ia.require&&ia.require("util").types;return i||Zf&&Zf.binding&&Zf.binding("util")}catch(e){}}(),hi=HI;var kg=hi&&hi.isTypedArray,WI=kg?es(kg):Vg,Zl=WI;var qI=Object.prototype,$I=qI.hasOwnProperty;function JI(i,e){var t=cr(i),r=!t&&mo(i),n=!t&&!r&&Qo(i),s=!t&&!r&&!n&&Zl(i),l=t||r||n||s,c=l?Gg(i.length,String):[],f=c.length;for(var h in i)(e||$I.call(i,h))&&!(l&&(h=="length"||n&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||$l(h,f)))&&c.push(h);return c}var Yl=JI;function KI(i,e){return function(t){return i(e(t))}}var Ql=KI;var XI=Ql(Object.keys,Object),Hg=XI;var ZI=Object.prototype,YI=ZI.hasOwnProperty;function QI(i){if(!Yo(i))return Hg(i);var e=[];for(var t in Object(i))YI.call(i,t)&&t!="constructor"&&e.push(t);return e}var Wg=QI;function eM(i){return Gi(i)?Yl(i):Wg(i)}var ts=eM;function tM(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e}var qg=tM;var rM=Object.prototype,nM=rM.hasOwnProperty;function iM(i){if(!yr(i))return qg(i);var e=Yo(i),t=[];for(var r in i)r=="constructor"&&(e||!nM.call(i,r))||t.push(r);return t}var $g=iM;function oM(i){return Gi(i)?Yl(i,!0):$g(i)}var Un=oM;var sM=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,aM=/^\w*$/;function lM(i,e){if(cr(i))return!1;var t=typeof i;return t=="number"||t=="symbol"||t=="boolean"||i==null||Jo(i)?!0:aM.test(i)||!sM.test(i)||e!=null&&i in Object(e)}var Jg=lM;var cM=Gr(Object,"create"),pi=cM;function uM(){this.__data__=pi?pi(null):{},this.size=0}var Kg=uM;function fM(i){var e=this.has(i)&&delete this.__data__[i];return this.size-=e?1:0,e}var Xg=fM;var hM="__lodash_hash_undefined__",pM=Object.prototype,dM=pM.hasOwnProperty;function mM(i){var e=this.__data__;if(pi){var t=e[i];return t===hM?void 0:t}return dM.call(e,i)?e[i]:void 0}var Zg=mM;var gM=Object.prototype,yM=gM.hasOwnProperty;function xM(i){var e=this.__data__;return pi?e[i]!==void 0:yM.call(e,i)}var Yg=xM;var vM="__lodash_hash_undefined__";function bM(i,e){var t=this.__data__;return this.size+=this.has(i)?0:1,t[i]=pi&&e===void 0?vM:e,this}var Qg=bM;function rs(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}rs.prototype.clear=Kg;rs.prototype.delete=Xg;rs.prototype.get=Zg;rs.prototype.has=Yg;rs.prototype.set=Qg;var Yf=rs;function SM(){this.__data__=[],this.size=0}var ey=SM;function wM(i,e){for(var t=i.length;t--;)if(Bi(i[t][0],e))return t;return-1}var ji=wM;var NM=Array.prototype,CM=NM.splice;function LM(i){var e=this.__data__,t=ji(e,i);if(t<0)return!1;var r=e.length-1;return t==r?e.pop():CM.call(e,t,1),--this.size,!0}var ty=LM;function _M(i){var e=this.__data__,t=ji(e,i);return t<0?void 0:e[t][1]}var ry=_M;function TM(i){return ji(this.__data__,i)>-1}var ny=TM;function IM(i,e){var t=this.__data__,r=ji(t,i);return r<0?(++this.size,t.push([i,e])):t[r][1]=e,this}var iy=IM;function ns(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}ns.prototype.clear=ey;ns.prototype.delete=ty;ns.prototype.get=ry;ns.prototype.has=ny;ns.prototype.set=iy;var Ei=ns;var MM=Gr(qt,"Map"),Ri=MM;function AM(){this.size=0,this.__data__={hash:new Yf,map:new(Ri||Ei),string:new Yf}}var oy=AM;function OM(i){var e=typeof i;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?i!=="__proto__":i===null}var sy=OM;function PM(i,e){var t=i.__data__;return sy(e)?t[typeof e=="string"?"string":"hash"]:t.map}var zi=PM;function DM(i){var e=zi(this,i).delete(i);return this.size-=e?1:0,e}var ay=DM;function BM(i){return zi(this,i).get(i)}var ly=BM;function GM(i){return zi(this,i).has(i)}var cy=GM;function jM(i,e){var t=zi(this,i),r=t.size;return t.set(i,e),this.size+=t.size==r?0:1,this}var uy=jM;function is(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}is.prototype.clear=oy;is.prototype.delete=ay;is.prototype.get=ly;is.prototype.has=cy;is.prototype.set=uy;var oa=is;var EM="Expected a function";function Qf(i,e){if(typeof i!="function"||e!=null&&typeof e!="function")throw new TypeError(EM);var t=function(){var r=arguments,n=e?e.apply(this,r):r[0],s=t.cache;if(s.has(n))return s.get(n);var l=i.apply(this,r);return t.cache=s.set(n,l)||s,l};return t.cache=new(Qf.Cache||oa),t}Qf.Cache=oa;var fy=Qf;var RM=500;function zM(i){var e=fy(i,function(r){return t.size===RM&&t.clear(),r}),t=e.cache;return e}var hy=zM;var FM=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,VM=/\\(\\)?/g,UM=hy(function(i){var e=[];return i.charCodeAt(0)===46&&e.push(""),i.replace(FM,function(t,r,n,s){e.push(n?s.replace(VM,"$1"):r||t)}),e}),py=UM;function kM(i){return i==null?"":vg(i)}var dy=kM;function HM(i,e){return cr(i)?i:Jg(i,e)?[i]:py(dy(i))}var os=HM;var WM=1/0;function qM(i){if(typeof i=="string"||Jo(i))return i;var e=i+"";return e=="0"&&1/i==-WM?"-0":e}var ec=qM;function $M(i,e){e=os(e,i);for(var t=0,r=e.length;i!=null&&t<r;)i=i[ec(e[t++])];return t&&t==r?i:void 0}var my=$M;function JM(i,e){for(var t=-1,r=e.length,n=i.length;++t<r;)i[n+t]=e[t];return i}var ss=JM;var gy=Nr?Nr.isConcatSpreadable:void 0;function KM(i){return cr(i)||mo(i)||!!(gy&&i&&i[gy])}var yy=KM;function xy(i,e,t,r,n){var s=-1,l=i.length;for(t||(t=yy),n||(n=[]);++s<l;){var c=i[s];e>0&&t(c)?e>1?xy(c,e-1,t,r,n):ss(n,c):r||(n[n.length]=c)}return n}var vy=xy;function XM(i){var e=i==null?0:i.length;return e?vy(i,1):[]}var by=XM;function ZM(i){return ql(Kl(i,void 0,by),i+"")}var Sy=ZM;var YM=Ql(Object.getPrototypeOf,Object),as=YM;var QM="[object Object]",eA=Function.prototype,tA=Object.prototype,wy=eA.toString,rA=tA.hasOwnProperty,nA=wy.call(Object);function iA(i){if(!gr(i)||Xr(i)!=QM)return!1;var e=as(i);if(e===null)return!0;var t=rA.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&wy.call(t)==nA}var tc=iA;function oA(i,e,t){var r=-1,n=i.length;e<0&&(e=-e>n?0:n+e),t=t>n?n:t,t<0&&(t+=n),n=e>t?0:t-e>>>0,e>>>=0;for(var s=Array(n);++r<n;)s[r]=i[r+e];return s}var Ny=oA;function sA(){this.__data__=new Ei,this.size=0}var Cy=sA;function aA(i){var e=this.__data__,t=e.delete(i);return this.size=e.size,t}var Ly=aA;function lA(i){return this.__data__.get(i)}var _y=lA;function cA(i){return this.__data__.has(i)}var Ty=cA;var uA=200;function fA(i,e){var t=this.__data__;if(t instanceof Ei){var r=t.__data__;if(!Ri||r.length<uA-1)return r.push([i,e]),this.size=++t.size,this;t=this.__data__=new oa(r)}return t.set(i,e),this.size=t.size,this}var Iy=fA;function ls(i){var e=this.__data__=new Ei(i);this.size=e.size}ls.prototype.clear=Cy;ls.prototype.delete=Ly;ls.prototype.get=_y;ls.prototype.has=Ty;ls.prototype.set=Iy;var rc=ls;function hA(i,e){return i&&pn(e,ts(e),i)}var My=hA;function pA(i,e){return i&&pn(e,Un(e),i)}var Ay=pA;var Oy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Py=Oy&&typeof module=="object"&&module&&!module.nodeType&&module,dA=Py&&Py.exports===Oy,Dy=dA?qt.Buffer:void 0,By=Dy?Dy.allocUnsafe:void 0;function mA(i,e){if(e)return i.slice();var t=i.length,r=By?By(t):new i.constructor(t);return i.copy(r),r}var nc=mA;function gA(i,e){for(var t=-1,r=i==null?0:i.length,n=0,s=[];++t<r;){var l=i[t];e(l,t,i)&&(s[n++]=l)}return s}var Gy=gA;function yA(){return[]}var ic=yA;var xA=Object.prototype,vA=xA.propertyIsEnumerable,jy=Object.getOwnPropertySymbols,bA=jy?function(i){return i==null?[]:(i=Object(i),Gy(jy(i),function(e){return vA.call(i,e)}))}:ic,cs=bA;function SA(i,e){return pn(i,cs(i),e)}var Ey=SA;var wA=Object.getOwnPropertySymbols,NA=wA?function(i){for(var e=[];i;)ss(e,cs(i)),i=as(i);return e}:ic,oc=NA;function CA(i,e){return pn(i,oc(i),e)}var Ry=CA;function LA(i,e,t){var r=e(i);return cr(i)?r:ss(r,t(i))}var sc=LA;function _A(i){return sc(i,ts,cs)}var zy=_A;function TA(i){return sc(i,Un,oc)}var ac=TA;var IA=Gr(qt,"DataView"),lc=IA;var MA=Gr(qt,"Promise"),cc=MA;var AA=Gr(qt,"Set"),uc=AA;var Fy="[object Map]",OA="[object Object]",Vy="[object Promise]",Uy="[object Set]",ky="[object WeakMap]",Hy="[object DataView]",PA=fi(lc),DA=fi(Ri),BA=fi(cc),GA=fi(uc),jA=fi(Hl),go=Xr;(lc&&go(new lc(new ArrayBuffer(1)))!=Hy||Ri&&go(new Ri)!=Fy||cc&&go(cc.resolve())!=Vy||uc&&go(new uc)!=Uy||Hl&&go(new Hl)!=ky)&&(go=function(i){var e=Xr(i),t=e==OA?i.constructor:void 0,r=t?fi(t):"";if(r)switch(r){case PA:return Hy;case DA:return Fy;case BA:return Vy;case GA:return Uy;case jA:return ky}return e});var us=go;var EA=Object.prototype,RA=EA.hasOwnProperty;function zA(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&RA.call(i,"index")&&(t.index=i.index,t.input=i.input),t}var Wy=zA;var FA=qt.Uint8Array,eh=FA;function VA(i){var e=new i.constructor(i.byteLength);return new eh(e).set(new eh(i)),e}var fs=VA;function UA(i,e){var t=e?fs(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength)}var qy=UA;var kA=/\w*$/;function HA(i){var e=new i.constructor(i.source,kA.exec(i));return e.lastIndex=i.lastIndex,e}var $y=HA;var Jy=Nr?Nr.prototype:void 0,Ky=Jy?Jy.valueOf:void 0;function WA(i){return Ky?Object(Ky.call(i)):{}}var Xy=WA;function qA(i,e){var t=e?fs(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length)}var fc=qA;var $A="[object Boolean]",JA="[object Date]",KA="[object Map]",XA="[object Number]",ZA="[object RegExp]",YA="[object Set]",QA="[object String]",eO="[object Symbol]",tO="[object ArrayBuffer]",rO="[object DataView]",nO="[object Float32Array]",iO="[object Float64Array]",oO="[object Int8Array]",sO="[object Int16Array]",aO="[object Int32Array]",lO="[object Uint8Array]",cO="[object Uint8ClampedArray]",uO="[object Uint16Array]",fO="[object Uint32Array]";function hO(i,e,t){var r=i.constructor;switch(e){case tO:return fs(i);case $A:case JA:return new r(+i);case rO:return qy(i,t);case nO:case iO:case oO:case sO:case aO:case lO:case cO:case uO:case fO:return fc(i,t);case KA:return new r;case XA:case QA:return new r(i);case ZA:return $y(i);case YA:return new r;case eO:return Xy(i)}}var Zy=hO;function pO(i){return typeof i.constructor=="function"&&!Yo(i)?Lg(as(i)):{}}var hc=pO;var dO="[object Map]";function mO(i){return gr(i)&&us(i)==dO}var Yy=mO;var Qy=hi&&hi.isMap,gO=Qy?es(Qy):Yy,ex=gO;var yO="[object Set]";function xO(i){return gr(i)&&us(i)==yO}var tx=xO;var rx=hi&&hi.isSet,vO=rx?es(rx):tx,nx=vO;var bO=1,SO=2,wO=4,ix="[object Arguments]",NO="[object Array]",CO="[object Boolean]",LO="[object Date]",_O="[object Error]",ox="[object Function]",TO="[object GeneratorFunction]",IO="[object Map]",MO="[object Number]",sx="[object Object]",AO="[object RegExp]",OO="[object Set]",PO="[object String]",DO="[object Symbol]",BO="[object WeakMap]",GO="[object ArrayBuffer]",jO="[object DataView]",EO="[object Float32Array]",RO="[object Float64Array]",zO="[object Int8Array]",FO="[object Int16Array]",VO="[object Int32Array]",UO="[object Uint8Array]",kO="[object Uint8ClampedArray]",HO="[object Uint16Array]",WO="[object Uint32Array]",Nt={};Nt[ix]=Nt[NO]=Nt[GO]=Nt[jO]=Nt[CO]=Nt[LO]=Nt[EO]=Nt[RO]=Nt[zO]=Nt[FO]=Nt[VO]=Nt[IO]=Nt[MO]=Nt[sx]=Nt[AO]=Nt[OO]=Nt[PO]=Nt[DO]=Nt[UO]=Nt[kO]=Nt[HO]=Nt[WO]=!0;Nt[_O]=Nt[ox]=Nt[BO]=!1;function pc(i,e,t,r,n,s){var l,c=e&bO,f=e&SO,h=e&wO;if(t&&(l=n?t(i,r,n,s):t(i)),l!==void 0)return l;if(!yr(i))return i;var d=cr(i);if(d){if(l=Wy(i),!c)return Wl(i,l)}else{var x=us(i),g=x==ox||x==TO;if(Qo(i))return nc(i,c);if(x==sx||x==ix||g&&!n){if(l=f||g?{}:hc(i),!c)return f?Ry(i,Ay(l,i)):Ey(i,My(l,i))}else{if(!Nt[x])return n?i:{};l=Zy(i,x,c)}}s||(s=new rc);var w=s.get(i);if(w)return w;s.set(i,l),nx(i)?i.forEach(function(C){l.add(pc(C,e,t,C,i,s))}):ex(i)&&i.forEach(function(C,G){l.set(G,pc(C,e,t,G,i,s))});var S=h?f?ac:zy:f?Un:ts,D=d?void 0:S(i);return Ag(D||i,function(C,G){D&&(G=C,C=i[G]),Jl(l,G,pc(C,e,t,G,i,s))}),l}var dc=pc;var qO=1,$O=4;function JO(i){return dc(i,qO|$O)}var sa=JO;function KO(i){return function(e,t,r){for(var n=-1,s=Object(e),l=r(e),c=l.length;c--;){var f=l[i?c:++n];if(t(s[f],f,s)===!1)break}return e}}var ax=KO;var XO=ax(),lx=XO;function ZO(i,e,t){(t!==void 0&&!Bi(i[e],t)||t===void 0&&!(e in i))&&Zo(i,e,t)}var aa=ZO;function YO(i){return gr(i)&&Gi(i)}var cx=YO;function QO(i,e){if(!(e==="constructor"&&typeof i[e]=="function")&&e!="__proto__")return i[e]}var la=QO;function eP(i){return pn(i,Un(i))}var ux=eP;function tP(i,e,t,r,n,s,l){var c=la(i,t),f=la(e,t),h=l.get(f);if(h){aa(i,t,h);return}var d=s?s(c,f,t+"",i,e,l):void 0,x=d===void 0;if(x){var g=cr(f),w=!g&&Qo(f),S=!g&&!w&&Zl(f);d=f,g||w||S?cr(c)?d=c:cx(c)?d=Wl(c):w?(x=!1,d=nc(f,!0)):S?(x=!1,d=fc(f,!0)):d=[]:tc(f)||mo(f)?(d=c,mo(c)?d=ux(c):(!yr(c)||Ko(c))&&(d=hc(f))):x=!1}x&&(l.set(f,d),n(d,f,r,s,l),l.delete(f)),aa(i,t,d)}var fx=tP;function hx(i,e,t,r,n){i!==e&&lx(e,function(s,l){if(n||(n=new rc),yr(s))fx(i,e,l,t,hx,r,n);else{var c=r?r(la(i,l),s,l+"",i,e,n):void 0;c===void 0&&(c=s),aa(i,l,c)}},Un)}var px=hx;function rP(i){var e=i==null?0:i.length;return e?i[e-1]:void 0}var dx=rP;function nP(i,e){return e.length<2?i:my(i,Ny(e,0,-1))}var mx=nP;var iP=Bg(function(i,e,t){px(i,e,t)}),yo=iP;function oP(i,e){return e=os(e,i),i=mx(i,e),i==null||delete i[ec(dx(e))]}var gx=oP;function sP(i){return tc(i)?void 0:i}var yx=sP;var aP=1,lP=2,cP=4,uP=Sy(function(i,e){var t={};if(i==null)return t;var r=!1;e=Vl(e,function(s){return s=os(s,i),r||(r=s.length>1),s}),pn(i,ac(i),t),r&&(t=dc(t,aP|lP|cP,yx));for(var n=e.length;n--;)gx(t,e[n]);return t}),hs=uP;var ps;(function(t){t.all=["PerspectiveCamera","OrthographicCamera"];function e(r){return t.all.includes(r)}t.is=e})(ps||(ps={}));var xo;(function(n){n.DefaultUp=[0,1,0],n.DefaultTargetOffset=1e3,n.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:n.DefaultUp,isUpVectorFlipped:!1,targetOffset:n.DefaultTargetOffset};function r(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}n.getZoom=r})(xo||(xo={}));var ds;(function(r){r.x="x",r.y="y",r.z="z"})(ds||(ds={}));var xx;(function(s){s.Top="top",s.Right="right",s.Bottom="bottom",s.Left="left",s.Center="center"})(xx||(xx={}));var vx;(function(t){function i(r,n){return r[0]===n[0]&&r[1]===n[1]}t.isEqual=i;function e(r,n,s){return[r[0]+(n[0]-r[0])*s,r[1]+(n[1]-r[1])*s]}t.lerp=e})(vx||(vx={}));var ms;(function(n){function i(s,l){return s[0]===l[0]&&s[1]===l[1]&&s[2]===l[2]}n.isEqual=i;function e(s,l){return[s[0]+l[0],s[1]+l[1],s[2]+l[2]]}n.add=e;function t(s,l){return[s[0]-l[0],s[1]-l[1],s[2]-l[2]]}n.sub=t;function r(s,l,c){return[s[0]+(l[0]-s[0])*c,s[1]+(l[1]-s[1])*c,s[2]+(l[2]-s[2])*c]}n.lerp=r})(ms||(ms={}));var bx;(function(t){function i(r,n){return r[0]===n[0]&&r[1]===n[1]&&r[2]===n[2]&&r[3]===n[3]}t.isEqual=i;function e(r,n,s){return[r[0]+(n[0]-r[0])*s,r[1]+(n[1]-r[1])*s,r[2]+(n[2]-r[2])*s,r[3]+(n[3]-r[3])*s]}t.lerp=e})(bx||(bx={}));var Fi;(function(s){s.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function e(l,c){for(let f=0;f<16;f++)if(l[f]!==c[f])return!1;return!0}s.isEqual=e;function t(l){return l!=null?l:s.identity}s.simplify=t;function r(l,c){let f=c.slice(0);for(var h=0,d=c.length;h<d;h+=3){let x=1/(l[3]*c[h]+l[7]*c[h+1]+l[11]*c[h+2]+l[15]);f[h]=(l[0]*c[h]+l[4]*c[h+1]+l[8]*c[h+2]+l[12])*x,f[h+1]=(l[1]*c[h]+l[5]*c[h+1]+l[9]*c[h+2]+l[13])*x,f[h+2]=(l[2]*c[h]+l[6]*c[h+1]+l[10]*c[h+2]+l[14])*x}return f}s.applyMatrix4=r;function n(l,c){let f=c.slice(0);for(var h=0,d=c.length;h<d;h+=3)f[h]=l[0]*c[h]+l[4]*c[h+1]+l[8]*c[h+2],f[h+1]=l[1]*c[h]+l[5]*c[h+1]+l[9]*c[h+2],f[h+2]=l[2]*c[h]+l[6]*c[h+1]+l[10]*c[h+2];return f}s.applyMatrix3Components=n})(Fi||(Fi={}));var Zr;(function(f){f.white={r:1,g:1,b:1},f.red={r:1,g:0,b:0},f.black={r:0,g:0,b:0};function r(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}f.toRgb255a1=r;function n(h){return{r:h.r,g:h.g,b:h.b}}f.clone=n;function s(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}f.fromHex=s;function l(h,d){return h.r===d.r&&h.g===d.g&&h.b===d.b}f.equals=l;function c(h,d,x){return{r:h.r+(d.r-h.r)*x,g:h.g+(d.g-h.g)*x,b:h.b+(d.b-h.b)*x}}f.lerp=c})(Zr||(Zr={}));var kn;(function(l){l.white=fe(U({},Zr.white),{a:1});function e(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}l.from0to1=e;function t(c,f){return fe(U({},Zr.fromHex(c)),{a:f})}l.fromHexAndA=t;function r(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:c.a}}l.toRgb255a1=r;function n(c,f){return Zr.equals(c,f)&&c.a===f.a}l.equals=n;function s(c,f,h){return{r:c.r+(f.r-c.r)*h,g:c.g+(f.g-c.g)*h,b:c.b+(f.b-c.b)*h,a:c.a+(f.a-c.a)*h}}l.lerp=s})(kn||(kn={}));var mc;(function(e){e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]}})(mc||(mc={}));var Sx;(function(P){P[P.SKIP=0]="SKIP",P[P.ADD=1]="ADD",P[P.ALPHA=2]="ALPHA",P[P.AVERAGE=3]="AVERAGE",P[P.COLOR_BURN=4]="COLOR_BURN",P[P.COLOR_DODGE=5]="COLOR_DODGE",P[P.DARKEN=6]="DARKEN",P[P.DIFFERENCE=7]="DIFFERENCE",P[P.EXCLUSION=8]="EXCLUSION",P[P.LIGHTEN=9]="LIGHTEN",P[P.MULTIPLY=10]="MULTIPLY",P[P.DIVIDE=11]="DIVIDE",P[P.NEGATION=12]="NEGATION",P[P.NORMAL=13]="NORMAL",P[P.OVERLAY=14]="OVERLAY",P[P.REFLECT=15]="REFLECT",P[P.SCREEN=16]="SCREEN",P[P.SOFT_LIGHT=17]="SOFT_LIGHT",P[P.SUBTRACT=18]="SUBTRACT"})(Sx||(Sx={}));var wx;(function(c){c[c.LINEAR=0]="LINEAR",c[c.EASE=1]="EASE",c[c.EASE_IN=2]="EASE_IN",c[c.EASE_OUT=3]="EASE_OUT",c[c.EASE_IN_OUT=4]="EASE_IN_OUT",c[c.CUBIC=5]="CUBIC",c[c.SPRING=6]="SPRING"})(wx||(wx={}));var Nx;(function(e){e.defaultData={mass:1,stiffness:80,damping:10,velocity:0}})(Nx||(Nx={}));var Cx;(function(e){e.defaultData={control1:[.5,.05],control2:[.1,.3]}})(Cx||(Cx={}));var gc;(function(e){function i(t,r=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:ds.y,scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[t[0]+t[0]*r,0,0]},grid:{count:[2,2,2],size:t.map(n=>n*(1+r)),useCenter:!0}}}e.defaultData=i})(gc||(gc={}));var Hn;(function(e){e[e.Update=0]="Update"})(Hn||(Hn={}));var dn;(function(r){r[r.Add=1]="Add",r[r.Delete=2]="Delete",r[r.Unlink=3]="Unlink"})(dn||(dn={}));var Yr;(function(r){r[r.Add=4]="Add",r[r.Delete=5]="Delete",r[r.Move=6]="Move"})(Yr||(Yr={}));var jr;(function(r){r[r.Add=7]="Add",r[r.Delete=8]="Delete",r[r.Move=9]="Move"})(jr||(jr={}));var An=class{modifyById(e,t){let r=this;if(r[e]===void 0)throw new Error("not expected");{let s=fe(U({},r),{[e]:t});return Object.setPrototypeOf(s,An.prototype),s}}add(e,t){var n;let r=this.runOp({type:dn.Add,id:e,data:t});return(n=r==null?void 0:r.data)!=null?n:this}runOp(e){let t=this;if(e.type===dn.Add){let r=t[e.id],n;r===void 0?n={type:dn.Delete,id:e.id}:n={type:dn.Add,id:e.id,data:r};let{id:s,data:l}=e,c=fe(U({},t),{[s]:l});return Object.setPrototypeOf(c,An.prototype),{data:c,actual:e,reverse:n}}else if(e.type===dn.Delete){let{id:r}=e,n=t[r];if(n===void 0)return null;{let s=U({},t);return Object.setPrototypeOf(s,An.prototype),delete s[r],{data:s,actual:e,reverse:{type:dn.Add,id:r,data:n}}}}throw new Error("illegal arg")}};function ca(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let e=Object.getOwnPropertyNames(i);for(let t of e){let r=i[t];r&&typeof r=="object"&&ca(r)}return Object.freeze(i)}function Lx(i,e){let t=0;for(;t<i.length&&t<e.length;){if(i[t]<e[t])return-1;if(i[t]>e[t])return 1;t+=1}return t!==e.length?-1:t!==i.length?1:0}var th=class extends Error{};function Wn(i,e,t){if(i===void 0?e===void 0?(i=0,e=10):i=e-10:e===void 0&&(e=i+10),i>e){let s=i;i=e,e=s}let r=[],n=1/(t+1);for(let s=0;s<t;s++){let l=i+(e-i)*(s+.75+Math.random()*.5)*n;r.push(l)}return r}function _x(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function Tx(){return typeof process!="undefined"}function Ix(i,e){for(let t of i)e(t.id,t.data),Ix(t.children,e)}function Mx(i,e){e(i.id,i.data);for(let t of i.children)Mx(t,e)}var On=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,On.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ca(this[e]),e++}fillCaches0(e,t){var r;if((r=this.objCaches)==null?void 0:r.has(e.id))throw new Error("duplicated item");this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let n of e.children)this.fillCaches0(n,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)]}isDescendantOf(e,t){for(;e;){let r=this.parent(e);if(r===t)return!0;e=r}return!1}data(e){var t;return(t=this.get(e))==null?void 0:t.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){var t;return e===null?this:(t=this.get(e))==null?void 0:t.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let r=this.get(e);r&&Mx(r,t)}}traverse(e){Ix(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let n=this.parent(e),s=this.childrenArray(n),l=s.findIndex(h=>h.id===e);if(l<0)throw new Error("not expected");let c=s[l];return s=[...s],s[l]=fe(U({},c),{data:t}),this.modifyArrayBy(n,s)}}modifyArrayBy(e,t){let r=e,n=t;for(;r!==null;){let l=n,c=r;if(r=this.parent(r),r===void 0)throw new Error;n=this.childrenArray(r);let f=n.findIndex(h=>h.id===c);if(f<0)throw new Error;n=[...n],n[f]=fe(U({},n[f]),{children:l})}Object.setPrototypeOf(n,On.prototype);let s=n;return s.fillCaches(),s}runOp(e){switch(e.type){case jr.Add:return this.addOp(e);case jr.Delete:return this.deleteOp(e);case jr.Move:return this.moveOp(e)}}addOp(e){let{parent:t,fi:r,id:n,data:s,children:l}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.get(n)!==void 0)return null;{let c=t,f=this.childrenArray(c),h={fi:r,id:n,data:s,children:l};return f=[...f,h],f.sort((x,g)=>x.fi-g.fi),e.localIndex=f.indexOf(h),{data:this.modifyArrayBy(c,f),actual:e,reverse:{type:jr.Delete,id:n}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let r=this.parent(t);if(r===void 0)return null;let n=this.childrenArray(r),s=n.findIndex(f=>f.id===t);e.localIndex=s,n=[...n];let l=n.splice(s,1)[0];return{data:this.modifyArrayBy(r,n),actual:e,reverse:fe(U({type:jr.Add},l),{parent:r})}}}moveOp(e){let{parent:t,fi:r,id:n}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:jr.Delete,id:n});if(t!==null){let g=t;for(;g!==null;){if(g===void 0)throw new Error;if(g===n)throw new th("cyclic tree");g=this.parent(g)}}let s=this.parent(n);if(s===void 0)return null;let l=s,c=this.childrenArray(s),f=c.findIndex(g=>g.id===n);c=[...c];let h=c.splice(f,1)[0],d=this.modifyArrayBy(s,c);s=t,c=d.childrenArray(s);let x=h.fi;return h=fe(U({},h),{fi:r}),c=[...c,h],c.sort((g,w)=>g.fi-w.fi),e.localIndex=c.indexOf(h),d=d.modifyArrayBy(s,c),{data:d,actual:e,reverse:{type:jr.Move,parent:l,fi:x,id:n}}}previous(e,t){if(t===null){let n=this.childrenArray(e);return n.length===0?null:n[n.length-1].id}let r=null;for(let n of this.childrenArray(e)){if(n.id===t)return r;r=n.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let r=this.childrenArray(t),n=r.findIndex(s=>s.id===e)+1;if(n<r.length)return r[n].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let r=this.childrenArray(t),n=r.findIndex(s=>s.id===e)-1;return n>=0?this.traverseSortPrevious(r[n].id):t}}getAllSorted(e){let t=[];for(let r of e){let n=this.getWithSortKey(r.id);n!==void 0&&t.push(U(U({},r),n))}t.sort((r,n)=>Lx(r.sortKey,n.sortKey));for(let r of t)delete r.sortKey;return t}getWithSortKey(e){var t=e;let r=[],n=this.get(t),s=n;if(n!==void 0){for(;t;)r.splice(0,0,n.fi),t=this.parent(t),t!==null&&(n=this.get(t));return fe(U({},s),{sortKey:r})}}insertBeforeHelper(e,t,r){return this.insertAfterHelper(e,this.previous(e,t),r)}insertAfterHelper(e,t,r){let n=this.childrenArray(e);if(t===null){if(n.length===0)return Wn(0,r,r);{let s=n[0].fi;return Wn(s-r,s,r)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let l=n.find(c=>c.fi>s.fi);if(l===void 0){let c=n[n.length-1].fi;return Wn(c,c+r,r)}else return Wn(s.fi,l.fi,r)}}};var yc;(function(e){function i(t,r){if(Array.isArray(t)){let n=r.props,s={},l=[...t],c=!1;if(n)for(let f of Object.keys(n)){let h=parseInt(f);if(isNaN(h))throw new Error("wrong index");s[f]=l[h],l[h]=n[f],c=!0}return c?{data:l,actual:r,reverse:{type:Hn.Update,props:s}}:null}else{let n=r.props,s={},l=U({},t),c=!1;if(n)for(let f of Object.keys(n)){s[f]=l[f];let h=n[f];h===void 0?delete l[f]:l[f]=h,c=!0}return c?{data:l,actual:r,reverse:{type:Hn.Update,props:s}}:null}}e.runOp=i})(yc||(yc={}));var jt=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,jt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ca(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){var t;return(t=this.get(e))==null?void 0:t.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let n=this,s=n.findIndex(f=>f.id===e);if(s<0)throw new Error("not expected");let l=n[s];return n=[...n],n[s]=fe(U({},l),{data:t}),this.modifyArrayBy(n)}}modifyArrayBy(e){Object.setPrototypeOf(e,jt.prototype);let t=e;return Tx()||t.fillCaches(),t}runOp(e){switch(e.type){case Yr.Add:return this.addOp(e);case Yr.Delete:return this.deleteOp(e);case Yr.Move:return this.moveOp(e)}}addOp(e){let{fi:t,id:r,data:n}=e,s=this,l={fi:t,id:r,data:n};return s=[...s,l],s.sort((f,h)=>f.fi-h.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:Yr.Delete,id:r}}}deleteOp(e){let{id:t}=e,r=this,n=r.findIndex(c=>c.id===t);if(n===-1)return null;e.localIndex=n,r=[...r];let s=r.splice(n,1)[0];return{data:this.modifyArrayBy(r),actual:e,reverse:U({type:Yr.Add},s)}}moveOp(e){let{fi:t,id:r}=e,n=this;n=[...n];let s=n.findIndex(h=>h.id===r);if(s===-1)return null;let l=n[s].fi,c=fe(U({},n[s]),{fi:t});return n[s]=c,n.sort((h,d)=>h.fi-d.fi),e.localIndex=n.indexOf(c),{data:this.modifyArrayBy(n),actual:e,reverse:{type:Yr.Move,fi:l,id:r}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let r of this){if(r.id===e)return t;t=r.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let r=this;if(e===null){if(r.length===0)return Wn(0,t,t);{let n=r[0].fi;return Wn(n-t,n,t)}}else{let n=this.get(e);if(n===void 0)throw new Error("illegal args");let s=r.find(l=>l.fi>n.fi);if(s===void 0){let l=r[r.length-1].fi;return Wn(l,l+t,t)}else return Wn(n.fi,s.fi,t)}}};var Ax=Symbol(),xc=Symbol(),ua=class{reportOp(e,t){let r=this;if(t===null)return;r._current=t.data;let n=[];for(;!(r instanceof nh);){let s=r._path,l=r._current;if(s!==""&&n.splice(0,0,s),r=r._parent,r===null)return;r.update(s,l)}r.push(n,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let r=t[xc];r&&r(),delete this._children[e]}}}},Ox=class extends ua{constructor(e,t,r){super();this._parent=e,this._path=t,this._current=r}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current=fe(U({},this._current),{[e]:t})}runOp(e){this.reportOp(e,yc.runOp(this._current,e))}},Px=class extends ua{constructor(e,t,r){super();this._parent=e,this._path=t,this._current=r}update(e,t){this._current=fe(U({},this._current),{[e]:t}),Object.setPrototypeOf(this._current,An.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},Dx={get(i,e){if(e===xc)return()=>{i._parent=null};if(e===Ax)return i._current;let{_current:t,_children:r}=i;if(e==="push"&&Array.isArray(t))throw new Error("not supported to expand array");let n=r===void 0?void 0:r[e];if(n!==void 0)return n;let s=t[e],l=vc(i,e,s);return l!==s?(r===void 0&&(r={},i._children=r),r[e]=l,l):s},has(i,e){return e in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,e){let t=i._current,r=Reflect.getOwnPropertyDescriptor(t,e);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:t[e]}}},fP=fe(U({},Dx),{set(i,e,t){var n;let r={type:Hn.Update,props:{[e]:(n=sh(t))!=null?n:t}};return i.deleteChildren(e),i.runOp(r),!0},deleteProperty(i,e){let t={type:Hn.Update,props:{[e]:void 0}};return i.deleteChildren(e),i.runOp(t),!0}}),hP=fe(U({},Dx),{set(i,e,t){return t===void 0?this.deleteProperty(i,e):(i.deleteChildren(e),i.runOp({type:dn.Add,id:e,data:t})),!0},deleteProperty(i,e){return i.runOp({type:dn.Delete,id:e}),!0}}),fa=class extends ua{constructor(e,t,r){super();this._children={},this._parent=e,this._path=t,this._current=r,this[xc]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,r)=>{e(t,this.data(t))})}data(e){var c;let{_current:t,_children:r}=this,n=r===void 0?void 0:r[e];if(n!==void 0)return n;let s=(c=t.get(e))==null?void 0:c.data,l=vc(this,e,s);return l!==s?(r===void 0&&(r={},this._children=r),r[e]=l,l):s}add(e,t,r,n,s){this.runOp({type:jr.Add,parent:e,fi:t,id:r,data:n,children:s})}move(e,t,r){this.runOp({type:jr.Move,parent:e,fi:t,id:r})}insertAfter(e,t,r){let n=this._current.insertAfterHelper(e,t,r.length);for(let s=0;s<r.length;s++){let l=r[s];this.add(e,n[s],l.id,l.data,l.children)}}insertBefore(e,t,r){let n=this._current.insertBeforeHelper(e,t,r.length);for(let s=0;s<r.length;s++){let l=r[s];this.add(e,n[s],l.id,l.data,l.children)}}moveAfter(e,t,r){let n=this._current.insertAfterHelper(e,t,r.length);for(let s=0;s<r.length;s++){let l=r[s];this.move(e,n[s],l)}}moveBefore(e,t,r){let n=this._current.insertBeforeHelper(e,t,r.length);for(let s=0;s<r.length;s++){let l=r[s];this.move(e,n[s],l)}}delete(e){this.deleteChildren(e),this.runOp({type:jr.Delete,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},ha=class extends ua{constructor(e,t,r){super();this._children={},this._parent=e,this._path=t,this._current=r,this[xc]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let r=0;r<t;r++){let n=this._current[r].id;e(this.data(this._current[r].id),n)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return fe(U({},this._current.get(e)),{data:this.data(e)})}data(e){var c;let{_current:t,_children:r}=this,n=r===void 0?void 0:r[e];if(n!==void 0)return n;let s=(c=t.get(e))==null?void 0:c.data,l=vc(this,e,s);return l!==s?(r===void 0&&(r={},this._children=r),r[e]=l,l):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,r){this.runOp({type:Yr.Add,fi:e,id:t,data:r})}move(e,t){this.runOp({type:Yr.Move,fi:e,id:t})}insertAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let n=0;n<t.length;n++){let s=t[n];this.add(r[n],s.id,s.data)}}insertBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let n=0;n<t.length;n++){let s=t[n];this.add(r[n],s.id,s.data)}}moveAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let n=0;n<t.length;n++){let s=t[n];this.move(r[n],s)}}moveBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let n=0;n<t.length;n++){let s=t[n];this.move(r[n],s)}}delete(e){this.deleteChildren(e),this.runOp({type:Yr.Delete,id:e})}};function rh(i,e,t){if(i.length>0){let r=i[i.length-1];if(r.type===Hn.Update&&e.type===Hn.Update&&bc.equal(r.path,t)){Object.assign(r.props,e.props);return}}i.push(fe(U({},e),{path:t}))}var nh=class{constructor(e){this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,r,n){rh(this.ts,t,e),rh(this.actual,r,e),rh(this.reverse,n,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function vc(i,e,t){return t instanceof On?new fa(i,e,t):t instanceof jt?new ha(i,e,t):t instanceof An?new Proxy(new Px(i,e,t),hP):t!==null&&typeof t=="object"?_x(t)?t:new Proxy(new Ox(i,e,t),fP):t}function ih(i){let e=new nh(i);return[vc(e,"",i),e]}function oh(i,e){let[t,r]=ih(i);return e(t),r.result()}function sh(i){return i instanceof fa||i instanceof ha?i._current:i!==null&&typeof i=="object"?i[Ax]:i}var bc;(function(r){function i(n,s){if(s.length===n.length)for(var l=0;l<n.length;){if(n[l]!==s[l])return!1;l+=1}else return!1;return!0}r.equal=i;function e(n,s,l){let c=t(l,n);if(c!==void 0&&typeof c=="object"&&c!==null){let f=U({},s);return Object.keys(c).forEach(h=>{delete f[h]}),f}else return s}r.removeOverridden=e;function t(n,s,l=0){if(s.length<=l)return n;if((n instanceof On||n instanceof fa)&&typeof s[l]=="string")return t(n.data(s[l]),s,l+1);if((n instanceof jt||n instanceof ha)&&typeof s[l]=="string")return t(n.data(s[l]),s,l+1);if(typeof s[l]=="number"&&Array.isArray(n))return t(n[s[l]],s,l+1);if(typeof s[l]=="string"&&typeof n=="object")return t(n[s[l]],s,l+1)}r.zoom=t})(bc||(bc={}));var ah=class{},Sc=class extends ah{constructor(e){super();this.id=e}},wc=class extends ah{constructor(e){super();this.data=e}};"use strict";var lh;try{lh=new TextDecoder}catch(i){}var ge,Vi,j=0;var Bx=[],ch=Bx,uh=0,Er={},ot,Ui,mn=0,qn=0,Qr,di,Cr=[],ft,Gx={useRecords:!1,mapsAsObjects:!0},Nc=class{},fh=new Nc;fh.name="MessagePack 0xC1";var gs=!1,mi=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(ge)return qx(()=>(_c(),this?this.unpack(e,t):mi.prototype.unpack.call(Gx,e,t)));Vi=t>-1?t:e.length,j=0,uh=0,qn=0,Ui=null,ch=Bx,Qr=null,ge=e;try{ft=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(r){throw ge=null,e instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof mi){if(Er=this,this.structures)return ot=this.structures,Cc();(!ot||ot.length>0)&&(ot=[])}else Er=Gx,(!ot||ot.length>0)&&(ot=[]);return Cc()}unpackMultiple(e,t){let r,n=0;try{gs=!0;let s=e.length,l=this?this.unpack(e,s):Ic.unpack(e,s);if(t){for(t(l);j<s;)if(n=j,t(Cc())===!1)return}else{for(r=[l];j<s;)n=j,r.push(Cc());return r}}catch(s){throw s.lastPosition=n,s.values=r,s}finally{gs=!1,_c()}}_mergeStructures(e,t){e=e||[];for(let r=0,n=e.length;r<n;r++){let s=e[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}e.sharedLength=e.length;for(let r in t||[])if(r>=0){let n=e[r],s=t[r];s&&(n&&((e.restoreStructures||(e.restoreStructures=[]))[r]=n),e[r]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Cc(){try{if(!Er.trusted&&!gs){let e=ot.sharedLength||0;e<ot.length&&(ot.length=e)}let i=Et();if(j==Vi)ot.restoreStructures&&jx(),ot=null,ge=null,di&&(di=null);else if(j>Vi){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}else if(!gs)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw ot.restoreStructures&&jx(),_c(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function jx(){for(let i in ot.restoreStructures)ot[i]=ot.restoreStructures[i];ot.restoreStructures=null}function Et(){let i=ge[j++];if(i<160)if(i<128){if(i<64)return i;{let e=ot[i&63]||Er.getStructures&&Rx()[i&63];return e?(e.read||(e.read=hh(e,i&63)),e.read()):i}}else if(i<144)if(i-=128,Er.mapsAsObjects){let e={};for(let t=0;t<i;t++)e[kx()]=Et();return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(Et(),Et());return e}else{i-=144;let e=new Array(i);for(let t=0;t<i;t++)e[t]=Et();return e}else if(i<192){let e=i-160;if(qn>=j)return Ui.slice(j-mn,(j+=e)-mn);if(qn==0&&Vi<140){let t=e<16?dh(e):Vx(e);if(t!=null)return t}return ph(e)}else{let e;switch(i){case 192:return null;case 193:return Qr?(e=Et(),e>0?Qr[1].slice(Qr.position1,Qr.position1+=e):Qr[0].slice(Qr.position0,Qr.position0-=e)):fh;case 194:return!1;case 195:return!0;case 196:return mh(ge[j++]);case 197:return e=ft.getUint16(j),j+=2,mh(e);case 198:return e=ft.getUint32(j),j+=4,mh(e);case 199:return vo(ge[j++]);case 200:return e=ft.getUint16(j),j+=2,vo(e);case 201:return e=ft.getUint32(j),j+=4,vo(e);case 202:if(e=ft.getFloat32(j),Er.useFloat32>2){let t=Tc[(ge[j]&127)<<1|ge[j+1]>>7];return j+=4,(t*e+(e>0?.5:-.5)>>0)/t}return j+=4,e;case 203:return e=ft.getFloat64(j),j+=8,e;case 204:return ge[j++];case 205:return e=ft.getUint16(j),j+=2,e;case 206:return e=ft.getUint32(j),j+=4,e;case 207:return Er.int64AsNumber?(e=ft.getUint32(j)*4294967296,e+=ft.getUint32(j+4)):e=ft.getBigUint64(j),j+=8,e;case 208:return ft.getInt8(j++);case 209:return e=ft.getInt16(j),j+=2,e;case 210:return e=ft.getInt32(j),j+=4,e;case 211:return Er.int64AsNumber?(e=ft.getInt32(j)*4294967296,e+=ft.getUint32(j+4)):e=ft.getBigInt64(j),j+=8,e;case 212:if(e=ge[j++],e==114)return Hx(ge[j++]&63);{let t=Cr[e];if(t)return t.read?(j++,t.read(Et())):t.noBuffer?(j++,t()):t(ge.subarray(j,++j));throw new Error("Unknown extension "+e)}case 213:return e=ge[j],e==114?(j++,Hx(ge[j++]&63,ge[j++])):vo(2);case 214:return vo(4);case 215:return vo(8);case 216:return vo(16);case 217:return e=ge[j++],qn>=j?Ui.slice(j-mn,(j+=e)-mn):dP(e);case 218:return e=ft.getUint16(j),j+=2,qn>=j?Ui.slice(j-mn,(j+=e)-mn):mP(e);case 219:return e=ft.getUint32(j),j+=4,qn>=j?Ui.slice(j-mn,(j+=e)-mn):gP(e);case 220:return e=ft.getUint16(j),j+=2,zx(e);case 221:return e=ft.getUint32(j),j+=4,zx(e);case 222:return e=ft.getUint16(j),j+=2,Fx(e);case 223:return e=ft.getUint32(j),j+=4,Fx(e);default:if(i>=224)return i-256;if(i===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+i)}}}var pP=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function hh(i,e){function t(){if(t.count++>2){let n=i.read=new Function("r","return function(){return {"+i.map(s=>pP.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Et);return i.highByte===0&&(i.read=Ex(e,i.read)),n()}let r={};for(let n=0,s=i.length;n<s;n++){let l=i[n];r[l]=Et()}return r}return t.count=0,i.highByte===0?Ex(e,t):t}var Ex=(i,e)=>function(){let t=ge[j++];if(t===0)return e();let r=i<32?-(i+(t<<5)):i+(t<<5),n=ot[r]||Rx()[r];if(!n)throw new Error("Record id is not defined for "+r);return n.read||(n.read=hh(n,i)),n.read()};function Rx(){let i=qx(()=>(ge=null,Er.getStructures()));return ot=Er._mergeStructures(i,ot)}var ph=Lc,dP=Lc,mP=Lc,gP=Lc;function Lc(i){let e;if(i<16&&(e=dh(i)))return e;if(i>64&&lh)return lh.decode(ge.subarray(j,j+=i));let t=j+i,r=[];for(e="";j<t;){let n=ge[j++];if((n&128)==0)r.push(n);else if((n&224)==192){let s=ge[j++]&63;r.push((n&31)<<6|s)}else if((n&240)==224){let s=ge[j++]&63,l=ge[j++]&63;r.push((n&31)<<12|s<<6|l)}else if((n&248)==240){let s=ge[j++]&63,l=ge[j++]&63,c=ge[j++]&63,f=(n&7)<<18|s<<12|l<<6|c;f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|f&1023),r.push(f)}else r.push(n);r.length>=4096&&(e+=ir.apply(String,r),r.length=0)}return r.length>0&&(e+=ir.apply(String,r)),e}function zx(i){let e=new Array(i);for(let t=0;t<i;t++)e[t]=Et();return e}function Fx(i){if(Er.mapsAsObjects){let e={};for(let t=0;t<i;t++)e[kx()]=Et();return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(Et(),Et());return e}}var ir=String.fromCharCode;function Vx(i){let e=j,t=new Array(i);for(let r=0;r<i;r++){let n=ge[j++];if((n&128)>0){j=e;return}t[r]=n}return ir.apply(String,t)}function dh(i){if(i<4)if(i<2){if(i===0)return"";{let e=ge[j++];if((e&128)>1){j-=1;return}return ir(e)}}else{let e=ge[j++],t=ge[j++];if((e&128)>0||(t&128)>0){j-=2;return}if(i<3)return ir(e,t);let r=ge[j++];if((r&128)>0){j-=3;return}return ir(e,t,r)}else{let e=ge[j++],t=ge[j++],r=ge[j++],n=ge[j++];if((e&128)>0||(t&128)>0||(r&128)>0||(n&128)>0){j-=4;return}if(i<6){if(i===4)return ir(e,t,r,n);{let s=ge[j++];if((s&128)>0){j-=5;return}return ir(e,t,r,n,s)}}else if(i<8){let s=ge[j++],l=ge[j++];if((s&128)>0||(l&128)>0){j-=6;return}if(i<7)return ir(e,t,r,n,s,l);let c=ge[j++];if((c&128)>0){j-=7;return}return ir(e,t,r,n,s,l,c)}else{let s=ge[j++],l=ge[j++],c=ge[j++],f=ge[j++];if((s&128)>0||(l&128)>0||(c&128)>0||(f&128)>0){j-=8;return}if(i<10){if(i===8)return ir(e,t,r,n,s,l,c,f);{let h=ge[j++];if((h&128)>0){j-=9;return}return ir(e,t,r,n,s,l,c,f,h)}}else if(i<12){let h=ge[j++],d=ge[j++];if((h&128)>0||(d&128)>0){j-=10;return}if(i<11)return ir(e,t,r,n,s,l,c,f,h,d);let x=ge[j++];if((x&128)>0){j-=11;return}return ir(e,t,r,n,s,l,c,f,h,d,x)}else{let h=ge[j++],d=ge[j++],x=ge[j++],g=ge[j++];if((h&128)>0||(d&128)>0||(x&128)>0||(g&128)>0){j-=12;return}if(i<14){if(i===12)return ir(e,t,r,n,s,l,c,f,h,d,x,g);{let w=ge[j++];if((w&128)>0){j-=13;return}return ir(e,t,r,n,s,l,c,f,h,d,x,g,w)}}else{let w=ge[j++],S=ge[j++];if((w&128)>0||(S&128)>0){j-=14;return}if(i<15)return ir(e,t,r,n,s,l,c,f,h,d,x,g,w,S);let D=ge[j++];if((D&128)>0){j-=15;return}return ir(e,t,r,n,s,l,c,f,h,d,x,g,w,S,D)}}}}}function mh(i){return Er.copyBuffers?Uint8Array.prototype.slice.call(ge,j,j+=i):ge.subarray(j,j+=i)}function vo(i){let e=ge[j++];if(Cr[e])return Cr[e](ge.subarray(j,j+=i));throw new Error("Unknown extension type "+e)}var Ux=new Array(4096);function kx(){let i=ge[j++];if(i>=160&&i<192){if(i=i-160,qn>=j)return Ui.slice(j-mn,(j+=i)-mn);if(!(qn==0&&Vi<180))return ph(i)}else return j--,Et();let e=(i<<5^(i>1?ft.getUint16(j):i>0?ge[j]:0))&4095,t=Ux[e],r=j,n=j+i-3,s,l=0;if(t&&t.bytes==i){for(;r<n;){if(s=ft.getUint32(r),s!=t[l++]){r=1879048192;break}r+=4}for(n+=3;r<n;)if(s=ge[r++],s!=t[l++]){r=1879048192;break}if(r===n)return j=r,t.string;n-=3,r=j}for(t=[],Ux[e]=t,t.bytes=i;r<n;)s=ft.getUint32(r),t.push(s),r+=4;for(n+=3;r<n;)s=ge[r++],t.push(s);let c=i<16?dh(i):Vx(i);return c!=null?t.string=c:t.string=ph(i)}var Hx=(i,e)=>{var t=Et();let r=i;e!==void 0&&(i=i<32?-((e<<5)+i):(e<<5)+i,t.highByte=e);let n=ot[i];return n&&n.isShared&&((ot.restoreStructures||(ot.restoreStructures=[]))[i]=n),ot[i]=t,t.read=hh(t,r),t.read()},Wx=typeof self=="object"?self:global;Cr[0]=()=>{};Cr[0].noBuffer=!0;Cr[101]=()=>{let i=Et();return(Wx[i[0]]||Error)(i[1])};Cr[105]=i=>{let e=ft.getUint32(j-4);di||(di=new Map);let t=ge[j],r;t>=144&&t<160||t==220||t==221?r=[]:r={};let n={target:r};di.set(e,n);let s=Et();return n.used?Object.assign(r,s):(n.target=s,s)};Cr[112]=i=>{let e=ft.getUint32(j-4),t=di.get(e);return t.used=!0,t.target};Cr[115]=()=>new Set(Et());var gh=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");Cr[116]=i=>{let e=i[0],t=gh[e];if(!t)throw new Error("Could not find typed array for code "+e);return new Wx[t](Uint8Array.prototype.slice.call(i,1).buffer)};Cr[120]=()=>{let i=Et();return new RegExp(i[0],i[1])};Cr[98]=i=>{let e=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],t=j;j+=e-4,Qr=[Et(),Et()],Qr.position0=0,Qr.position1=0;let r=j;j=t;try{return Et()}finally{j=r}};Cr[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function qx(i){let e=Vi,t=j,r=uh,n=mn,s=qn,l=Ui,c=ch,f=di,h=Qr,d=new Uint8Array(ge.slice(0,Vi)),x=ot,g=ot.slice(0,ot.length),w=Er,S=gs,D=i();return Vi=e,j=t,uh=r,mn=n,qn=s,Ui=l,ch=c,di=f,Qr=h,ge=d,gs=S,ot=x,ot.splice(0,ot.length,...g),Er=w,ft=new DataView(ge.buffer,ge.byteOffset,ge.byteLength),D}function _c(){ge=null,di=null,ot=null}function $x(i){i.unpack?Cr[i.type]=i.unpack:Cr[i.type]=i}var Tc=new Array(147);for(let i=0;i<256;i++)Tc[i]=+("1e"+Math.floor(45.15-i*.30103));var Ic=new mi({useRecords:!1}),yP=Ic.unpack,xP=Ic.unpackMultiple,vP=Ic.unpack;var bP=new Float32Array(1),zU=new Uint8Array(bP.buffer,0,4);"use strict";var Mc;try{Mc=new TextEncoder}catch(i){}var Ac,yh,Oc=typeof Buffer!="undefined",xh=Oc?Buffer.allocUnsafeSlow:Uint8Array,Kx=Oc?Buffer:Uint8Array,Xx=Oc?4294967296:2144337920,Z,Vt,F=0,$n,Jn=null,SP=/[\u0080-\uFFFF]/,pa=Symbol("record-id"),ys=class extends mi{constructor(e){super(e);this.offset=0;let t,r,n,s,l,c,f=0,h=Kx.prototype.utf8Write?function(b,R,T){return Z.utf8Write(b,R,T)}:Mc&&Mc.encodeInto?function(b,R){return Mc.encodeInto(b,Z.subarray(R)).written}:!1,d=this;e||(e={});let x=e&&e.sequential,g=e.structures||e.saveStructures,w=e.maxSharedStructures;if(w==null&&(w=g?32:0),w>8160)throw new Error("Maximum maxSharedStructure is 8160");let S=e.maxOwnStructures;S==null&&(S=g?32:64),x&&!e.saveStructures&&(this.structures=[]);let D=w>32||S+w>64,C=w+64,G=w+S+64;if(G>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let B=[],P=0,W=0;this.pack=this.encode=function(b,R){if(Z||(Z=new xh(8192),Vt=new DataView(Z.buffer,0,8192),F=0),$n=Z.length-10,$n-F<2048?(Z=new xh(Z.length),Vt=new DataView(Z.buffer,0,Z.length),$n=Z.length-10,F=0):F=F+7&2147483640,r=F,c=d.structuredClone?new Map:null,d.bundleStrings?(Jn=["",""],Z[F++]=214,Z[F++]=98,Jn.position=F-r,F+=4):Jn=null,n=d.structures,n){n.uninitialized&&(n=d._mergeStructures(d.getStructures()));let T=n.sharedLength||0;if(T>w)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+n.sharedLength);if(!n.transitions){n.transitions=Object.create(null);for(let z=0;z<T;z++){let A=n[z];if(!A)continue;let $,he=n.transitions;for(let re=0,Ne=A.length;re<Ne;re++){let ye=A[re];$=he[ye],$||($=he[ye]=Object.create(null)),he=$}he[pa]=z+64}f=T}x||(n.nextId=T+64)}s&&(s=!1),l=n||[];try{if(M(b),Jn){Vt.setUint32(Jn.position+r,F-Jn.position-r);let T=Jn;Jn=null,M(T[0]),M(T[1])}if(d.offset=F,c&&c.idsToInsert){F+=c.idsToInsert.length*6,F>$n&&E(F),d.offset=F;let T=NP(Z.subarray(r,F),c.idsToInsert);return c=null,T}return R&e0?(Z.start=r,Z.end=F,Z):Z.subarray(r,F)}finally{if(n){if(W<10&&W++,P>1e4)n.transitions=null,W=0,P=0,B.length>0&&(B=[]);else if(B.length>0&&!x){for(let T=0,z=B.length;T<z;T++)B[T][pa]=0;B=[]}if(s&&d.saveStructures){let T=n.sharedLength||w;n.length>T&&(n=n.slice(0,T));let z=Z.subarray(r,F);return d.saveStructures(n,f)===!1?(d._mergeStructures(d.getStructures()),d.pack(b)):(f=T,z)}}R&_P&&(F=r)}};let M=b=>{F>$n&&(Z=E(F));var R=typeof b,T;if(R==="string"){let z=b.length;if(Jn&&z>=8&&z<4096){let he=SP.test(b);Jn[he?0:1]+=b,Z[F++]=193,M(he?-z:z);return}let A;z<32?A=1:z<256?A=2:z<65536?A=3:A=5;let $=z*3;if(F+$>$n&&(Z=E(F+$)),z<64||!h){let he,re,Ne,ye=F+A;for(he=0;he<z;he++)re=b.charCodeAt(he),re<128?Z[ye++]=re:re<2048?(Z[ye++]=re>>6|192,Z[ye++]=re&63|128):(re&64512)==55296&&((Ne=b.charCodeAt(he+1))&64512)==56320?(re=65536+((re&1023)<<10)+(Ne&1023),he++,Z[ye++]=re>>18|240,Z[ye++]=re>>12&63|128,Z[ye++]=re>>6&63|128,Z[ye++]=re&63|128):(Z[ye++]=re>>12|224,Z[ye++]=re>>6&63|128,Z[ye++]=re&63|128);T=ye-F-A}else T=h(b,F+A,$);T<32?Z[F++]=160|T:T<256?(A<2&&Z.copyWithin(F+2,F+1,F+1+T),Z[F++]=217,Z[F++]=T):T<65536?(A<3&&Z.copyWithin(F+3,F+2,F+2+T),Z[F++]=218,Z[F++]=T>>8,Z[F++]=T&255):(A<5&&Z.copyWithin(F+5,F+3,F+3+T),Z[F++]=219,Vt.setUint32(F,T),F+=4),F+=T}else if(R==="number")if(b>>>0===b)b<64?Z[F++]=b:b<256?(Z[F++]=204,Z[F++]=b):b<65536?(Z[F++]=205,Z[F++]=b>>8,Z[F++]=b&255):(Z[F++]=206,Vt.setUint32(F,b),F+=4);else if(b>>0===b)b>=-32?Z[F++]=256+b:b>=-128?(Z[F++]=208,Z[F++]=b+256):b>=-32768?(Z[F++]=209,Vt.setInt16(F,b),F+=2):(Z[F++]=210,Vt.setInt32(F,b),F+=4);else{let z;if((z=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){Z[F++]=202,Vt.setFloat32(F,b);let A;if(z<4||(A=b*Tc[(Z[F]&127)<<1|Z[F+1]>>7])>>0===A){F+=4;return}else F--}Z[F++]=203,Vt.setFloat64(F,b),F+=8}else if(R==="object")if(!b)Z[F++]=192;else{if(c){let A=c.get(b);if(A){if(!A.id){let $=c.idsToInsert||(c.idsToInsert=[]);A.id=$.push(A)}Z[F++]=214,Z[F++]=112,Vt.setUint32(F,A.id),F+=4;return}else c.set(b,{offset:F-r})}let z=b.constructor;if(z===Object)q(b,!0);else if(z===Array){T=b.length,T<16?Z[F++]=144|T:T<65536?(Z[F++]=220,Z[F++]=T>>8,Z[F++]=T&255):(Z[F++]=221,Vt.setUint32(F,T),F+=4);for(let A=0;A<T;A++)M(b[A])}else if(z===Map){T=b.size,T<16?Z[F++]=128|T:T<65536?(Z[F++]=222,Z[F++]=T>>8,Z[F++]=T&255):(Z[F++]=223,Vt.setUint32(F,T),F+=4);for(let[A,$]of b)M(A),M($)}else{for(let A=0,$=Ac.length;A<$;A++){let he=yh[A];if(b instanceof he){let re=Ac[A];if(re.write){re.type&&(Z[F++]=212,Z[F++]=re.type,Z[F++]=0),M(re.write.call(this,b));return}let Ne=Z,ye=Vt,Me=F;Z=null;let Fe;try{Fe=re.pack.call(this,b,k=>(Z=Ne,Ne=null,F+=k,F>$n&&E(F),{target:Z,targetView:Vt,position:F-k}),M)}finally{Ne&&(Z=Ne,Vt=ye,F=Me,$n=Z.length-10)}Fe&&(Fe.length+F>$n&&E(Fe.length+F),F=wP(Fe,Z,F,re.type));return}}q(b,!b.hasOwnProperty)}}else if(R==="boolean")Z[F++]=b?195:194;else if(R==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))Z[F++]=211,Vt.setBigInt64(F,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)Z[F++]=207,Vt.setBigUint64(F,b);else if(this.largeBigIntToFloat)Z[F++]=203,Vt.setFloat64(F,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");F+=8}else if(R==="undefined")this.encodeUndefinedAsNil?Z[F++]=192:(Z[F++]=212,Z[F++]=0,Z[F++]=0);else if(R==="function")M(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+R)},q=this.useRecords===!1?this.variableMapSize?b=>{let R=Object.keys(b),T=R.length;T<16?Z[F++]=128|T:T<65536?(Z[F++]=222,Z[F++]=T>>8,Z[F++]=T&255):(Z[F++]=223,Vt.setUint32(F,T),F+=4);let z;for(let A=0;A<T;A++)M(z=R[A]),M(b[z])}:(b,R)=>{Z[F++]=222;let T=F-r;F+=2;let z=0;for(let A in b)(R||b.hasOwnProperty(A))&&(M(A),M(b[A]),z++);Z[T+++r]=z>>8,Z[T+r]=z&255}:b=>{let R=Object.keys(b),T,z=l.transitions||(l.transitions=Object.create(null)),A=0;for(let he=0,re=R.length;he<re;he++){let Ne=R[he];T=z[Ne],T||(T=z[Ne]=Object.create(null),A++),z=T}let $=z[pa];if($)$>=96&&D?(Z[F++]=(($-=96)&31)+96,Z[F++]=$>>5):Z[F++]=$;else{$=l.nextId,$||($=64),$<C&&this.shouldShareStructure&&!this.shouldShareStructure(R)?($=l.nextOwnId,$<G||($=C),l.nextOwnId=$+1):($>=G&&($=C),l.nextId=$+1);let he=R.highByte=$>=96&&D?$-96>>5:-1;z[pa]=$,l[$-64]=R,$<C?(R.isShared=!0,l.sharedLength=$-63,s=!0,he>=0?(Z[F++]=($&31)+96,Z[F++]=he):Z[F++]=$):(he>=0?(Z[F++]=213,Z[F++]=114,Z[F++]=($&31)+96,Z[F++]=he):(Z[F++]=212,Z[F++]=114,Z[F++]=$),A&&(P+=W*A),B.length>=S&&(B.shift()[pa]=0),B.push(z),M(R))}for(let he=0,re=R.length;he<re;he++)M(b[R[he]])},E=b=>{let R;if(b>16777216){if(b-r>Xx)throw new Error("Packed buffer would be larger than maximum buffer size");R=Math.min(Xx,Math.round(Math.max((b-r)*(b>67108864?1.25:2),4194304)/4096)*4096)}else R=(Math.max(b-r<<2,Z.length-1)>>12)+1<<12;let T=new xh(R);return Vt=new DataView(T.buffer,0,R),Z.copy?Z.copy(T,0,r,b):T.set(Z.slice(r,b)),F-=r,r=0,$n=T.length-10,Z=T}}useBuffer(e){Z=e,Vt=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),F=0}};yh=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Nc];Ac=[{pack(i,e,t){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:n,targetView:s,position:l}=e(6);n[l++]=214,n[l++]=255,s.setUint32(l,r)}else if(r>0&&r<17179869184){let{target:n,targetView:s,position:l}=e(10);n[l++]=215,n[l++]=255,s.setUint32(l,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(l+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:n,targetView:s,position:l}=e(3);n[l++]=212,n[l++]=255,n[l++]=255}else{let{target:n,targetView:s,position:l}=e(15);n[l++]=199,n[l++]=12,n[l++]=255,s.setUint32(l,i.getMilliseconds()*1e6),s.setBigInt64(l+4,BigInt(Math.floor(r)))}}},{pack(i,e,t){let r=Array.from(i),{target:n,position:s}=e(this.structuredClone?3:0);this.structuredClone&&(n[s++]=212,n[s++]=115,n[s++]=0),t(r)}},{pack(i,e,t){let{target:r,position:n}=e(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=101,r[n++]=0),t([i.name,i.message])}},{pack(i,e,t){let{target:r,position:n}=e(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=120,r[n++]=0),t([i.source,i.flags])}},{pack(i,e){this.structuredClone?Zx(i,16,e):Yx(Oc?Buffer.from(i):new Uint8Array(i),e)}},{pack(i,e){let t=i.constructor;t!==Kx&&this.structuredClone?Zx(i,gh.indexOf(t.name),e):Yx(i,e)}},{pack(i,e){let{target:t,position:r}=e(1);t[r]=193}}];function Zx(i,e,t,r){let n=i.byteLength;if(n+1<256){var{target:s,position:l}=t(4+n);s[l++]=199,s[l++]=n+1}else if(n+1<65536){var{target:s,position:l}=t(5+n);s[l++]=200,s[l++]=n+1>>8,s[l++]=n+1&255}else{var{target:s,position:l,targetView:c}=t(7+n);s[l++]=201,c.setUint32(l,n+1),l+=4}s[l++]=116,s[l++]=e,s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),l)}function Yx(i,e){let t=i.byteLength;var r,n;if(t<256){var{target:r,position:n}=e(t+2);r[n++]=196,r[n++]=t}else if(t<65536){var{target:r,position:n}=e(t+3);r[n++]=197,r[n++]=t>>8,r[n++]=t&255}else{var{target:r,position:n,targetView:s}=e(t+5);r[n++]=198,s.setUint32(n,t),n+=4}r.set(i,n)}function wP(i,e,t,r){let n=i.length;switch(n){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:n<256?(e[t++]=199,e[t++]=n):n<65536?(e[t++]=200,e[t++]=n>>8,e[t++]=n&255):(e[t++]=201,e[t++]=n>>24,e[t++]=n>>16&255,e[t++]=n>>8&255,e[t++]=n&255)}return e[t++]=r,e.set(i,t),t+=n,t}function NP(i,e){let t,r=e.length*6,n=i.length-r;for(e.sort((s,l)=>s.offset>l.offset?1:-1);t=e.pop();){let s=t.offset,l=t.id;i.copyWithin(s+r,s,n),r-=6;let c=s+r;i[c++]=214,i[c++]=105,i[c++]=l>>24,i[c++]=l>>16&255,i[c++]=l>>8&255,i[c++]=l&255,n=s}return i}function bo(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");yh.unshift(i.Class),Ac.unshift(i)}$x(i)}var Qx=new ys({useRecords:!1}),CP=Qx.pack,LP=Qx.pack;var e0=512,_P=1024;var t0=new ys({structuredClone:!0});bo({Class:An.prototype.constructor,type:1,write(i){return U({},i)},read(i){return Object.setPrototypeOf(i,An.prototype),i}});bo({Class:jt.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,jt.prototype),i}});bo({Class:On.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,On.prototype),i}});bo({Class:Sc.prototype.constructor,type:4,write(i){return i.id},read(i){return new Sc(i)}});bo({Class:wc.prototype.constructor,type:5,write(i){return i.data},read(i){return new wc(i)}});function TP(i){var e=0;if(i.length===0)return e;for(let t=0;t<i.length;t++){let r=i[t];e=(e<<5)-e+r,e=e&e}return e}var Pc;(function(r){function i(n){return t0.pack(n)}r.serialize=i;function e(n){return t0.unpack(n)}r.deserialize=e;function t(n){return TP(i(n)).toString()}r.checksum=t})(Pc||(Pc={}));var Dc;(function(t){t.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function e(r){return t.all.includes(r)}t.is=e})(Dc||(Dc={}));var Bc;(function(t){function i(r){return e(r)}t.defaultData=i;function e(r){if(r==="PointLight")return{type:r,color:kn.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:2500,helper:!0};if(r==="SpotLight")return{type:r,color:kn.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:2500,helper:!0};if(r==="DirectionalLight")return{type:r,color:kn.white,intensity:1,shadows:!0,size:2500,depth:2500,helper:!0};throw new Error("not implemented")}})(Bc||(Bc={}));var xs;(function(r){r[r.Front=0]="Front",r[r.Back=1]="Back",r[r.Double=2]="Double"})(xs||(xs={}));var vh;(function(t){t.defaultData={castShadow:!0,receiveShadow:!0};function e(r,n){return r.castShadow===n.castShadow&&r.receiveShadow===n.receiveShadow}t.equals=e})(vh||(vh={}));var bh;(function(t){t.defaultData={flatShading:!1,wireframe:!1,side:0};function e(r,n){return r.flatShading===n.flatShading&&r.side===n.side&&r.wireframe===n.wireframe}t.equals=e})(bh||(bh={}));var Gc;(function(e){e.defaultData=fe(U(U({},bh.defaultData),vh.defaultData),{cloner:null})})(Gc||(Gc={}));var Lr;(function(n){n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.Center=3]="Center",n[n.Justify=4]="Justify"})(Lr||(Lr={}));var gi;(function(r){r[r.Top=1]="Top",r[r.Center=2]="Center",r[r.Bottom=3]="Bottom"})(gi||(gi={}));var ki;(function(r){r[r.None=1]="None",r[r.Upper=2]="Upper",r[r.Lower=3]="Lower"})(ki||(ki={}));var jc;(function(e){e.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:kn.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"}})(jc||(jc={}));var Zt;(function(n){n[n.Normal=0]="Normal",n[n.Multiply=1]="Multiply",n[n.Screen=2]="Screen",n[n.Overlay=3]="Overlay"})(Zt||(Zt={}));var vs;(function(r){r[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar"})(vs||(vs={}));var Ec;(function(r){r[r.RepeatWrapping=1e3]="RepeatWrapping",r[r.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",r[r.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping"})(Ec||(Ec={}));var Rc;(function(n){n[n.UV=0]="UV",n[n.Planar=1]="Planar",n[n.Spherical=2]="Spherical",n[n.Cylindrical=3]="Cylindrical"})(Rc||(Rc={}));var zc;(function(s){s[s.Simplex=0]="Simplex",s[s.SimplexFractal=1]="SimplexFractal",s[s.Ashima=2]="Ashima",s[s.Fbm=3]="Fbm",s[s.Perlin=4]="Perlin"})(zc||(zc={}));var bs;(function(r){function i(n,s){return n==="light"&&s?e(s):t(n)}r.defaultData=i;function e(n){switch(n){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:.2,g:.2,b:.2,a:1},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function t(n){switch(n){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:ds.x,type:"texture",projection:0,texture:{image:"image_0",wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:Zr.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,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],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,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{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:fe(U({},Zr.fromHex(6710886)),{a:1}),colorB:fe(U({},Zr.fromHex(6710886)),{a:1}),colorC:fe(U({},Zr.fromHex(16777215)),{a:1}),colorD:fe(U({},Zr.fromHex(16777215)),{a:1}),distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:kn.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(bs||(bs={}));var Ss;(function(c){function i(f){return!f.layers.some(d=>{if(d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")return!0})&&!t(f)}c.isMergable=i;function e(f){let h="";return f.layers.forEach(d=>{Object.entries(d.data).forEach(([x,g])=>{h+=`${x}${g}`,Array.isArray(g)?g.forEach(w=>h+=`${w}`):typeof g=="object"?Object.values(g).forEach(w=>{typeof w=="number"?h+=`${w.toFixed(4)}`:h+=`${w}`}):h+=`${g}`})}),h}c.getHash=e;function t(f){let h=0;for(let d of f.layers)"alpha"in d.data&&d.data.type!=="light"&&d.data.type!=="fresnel"&&(h+=(1-h)*d.data.alpha);return h<1}c.isTransparent=t;function r(){return{layers:new jt}}c.defaultEmptyData=r;function n(f="layer1",h="layer2"){return s("phong",f,h)}c.defaultData=n;function s(f,h="layer1",d="layer2"){let x=new jt;return x.push({fi:0,data:bs.defaultData("light",f),id:h}),x.push({fi:1,data:bs.defaultData("color"),id:d}),{layers:x}}c.defaultTwoLayerData=s;function l(f,h="basic",d="layer1",x="layer2"){let g=bs.defaultData("texture");Object.assign(g.texture,{image:f});let w=new jt;return w.push({fi:0,data:g,id:d}),w.push({fi:1,data:bs.defaultData("light",h),id:x}),{layers:w}}c.defaultTwoLayerTextureData=l})(Ss||(Ss={}));var ws;(function(r){function i(){return{points:new jt,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=i;function e(n,s){let{points:l}=s;if(l){for(let c of l)if(c.data.position[0]===n[0]&&c.data.position[1]===n[1])return!0}return!1}r.isOverlappingExistingPoint=e;function t(n,s){let l=n.controlNext,c=s.controlPrevious;return n.position[0]===l.position[0]&&n.position[1]===l.position[1]&&s.position[0]===c.position[0]&&s.position[1]===c.position[1]}r.isStraightLine=t})(ws||(ws={}));var Fc;(function(e){function i(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=i})(Fc||(Fc={}));var Vc;(function(e){function i(t){if(t==="RectangleGeometry")return{width:320,height:320,type:t,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};if(t==="VectorGeometry")return{width:100,height:100,type:t,subdivisions:12,shape:ws.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};throw new Error("not implemented")}e.defaultData=i})(Vc||(Vc={}));var da;(function(n){n.identity=fe(U({},mc.identity),{hiddenMatrix:Fi.identity});function e(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}n.fromObject=e;function t(s,l){return{position:(l==null?void 0:l.position)||s.position,rotation:(l==null?void 0:l.rotation)||s.rotation,scale:(l==null?void 0:l.scale)||s.scale,hiddenMatrix:(l==null?void 0:l.hiddenMatrix)||s.hiddenMatrix}}n.merge=t;function r(s,l){return{position:ms.isEqual(s.position,l.position)?null:l.position,rotation:ms.isEqual(s.rotation,l.rotation)?null:l.rotation,scale:ms.isEqual(s.scale,l.scale)?null:l.scale,hiddenMatrix:Fi.isEqual(s.hiddenMatrix,l.hiddenMatrix)?null:l.hiddenMatrix}}n.diff=r})(da||(da={}));var Hi;(function(e){e.defaultData=U({states:new jt,events:new jt,visible:!0,raycastLock:!1},da.identity)})(Hi||(Hi={}));var r0;(function(e){e.defaultData=U({type:"Empty"},Hi.defaultData)})(r0||(r0={}));var Sh;(function(e){e.defaultData=U(U({type:"Mesh"},Hi.defaultData),Gc.defaultData)})(Sh||(Sh={}));var n0;(function(e){e.defaultData=U(U({type:"TextFrame"},Hi.defaultData),jc.defaultData)})(n0||(n0={}));var Uc;(function(e){e.defaultData=U(U(U({},Hi.defaultData),da.identity),xo.defaultData)})(Uc||(Uc={}));var i0;(function(e){function i(t){return U(U({},Hi.defaultData),Bc.defaultData(t))}e.defaultData=i})(i0||(i0={}));var o0;(function(t){t.defaultCamera=U({position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Fi.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new jt,events:new jt},xo.defaultData),t.defaultMeshObject=fe(U(U({name:"Rectangle"},Hi.defaultData),Sh.defaultData),{geometry:Vc.defaultData("RectangleGeometry"),material:Ss.defaultTwoLayerData("basic","layer1","layer2")})})(o0||(o0={}));var s0;(function(t){function i(r,n){if(n===void 0)return r;let s=U({},r);return"material"in s&&"material"in n&&n.material&&(s.material=oh(s.material,l=>{if(typeof l!="string")for(let[c,f]of Object.entries(n.material.layers)){let h=l.layers.data(c);h&&yo(h,f)}}).data),s.materials&&n.materials&&(s.materials=oh(s.materials,l=>{var c,f;for(let h=0;h<s.materials.length;h++){let d=n.materials[h];if(typeof d!="string")for(let[x,g]of Object.entries(d.layers)){let w=(f=(c=l[h])==null?void 0:c.layers)==null?void 0:f.data(x);w&&yo(w,g)}}}).data),s}t.patchMaterialState=i;function e(r,n){var l,c;if(n===void 0)return r;let s=U({},r);if(Object.assign(s,da.merge(s,n)),ps.is(r.type)){s.orthographic=U({},s.orthographic),s.perspective=U({},s.perspective);let f=n;((l=f.orthographic)==null?void 0:l.zoom)!==void 0&&(s.orthographic.zoom=f.orthographic.zoom),((c=f.perspective)==null?void 0:c.zoom)!==void 0&&(s.perspective.zoom=f.perspective.zoom)}else if(r.type==="Mesh")s.geometry=U({},s.geometry),Object.assign(s.geometry,n.geometry),s=i(s,n);else if(Dc.is(r.type)){let f=n;s.intensity!==void 0&&(s.intensity=f.intensity),f.color!==void 0&&(typeof f.color=="string"?s.color=f.color:s.color=Zr.clone(f.color))}return s}t.patch=e})(s0||(s0={}));var Yt=5855577;var a0=2857471;var wh=15711266;import{DoubleSide as IP,Mesh as MP,MeshBasicMaterial as AP,ShapeBufferGeometry as OP,Vector2 as PP,Vector3 as DP}from"three";import{FontLoader as BP}from"three/examples/jsm/loaders/FontLoader.js";var Ut=class extends MP{constructor({char:e,originalChar:t,fontFamily:r,letterSpacing:n,fontSize:s,LOD:l=16},c=new AP({color:0,opacity:1,visible:!0,transparent:!0,side:IP})){let f=Ut.loadChar(e,r,l);super(f.geometry,c);this.char=e,this.originalChar=t!=null?t:e,this.fontFamily=r,this.letterSpacing=n,this.fontSize=s,this.LOD=l,this.resolution=f.resolution,this.glyphsHa=f.glyphsHa,this.localPosition=new PP,this.charSize=0,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}static get FONTS_PATH(){return Ut._fontPath}static set FONTS_PATH(e){Ut._fontPath=e}updatePosition(e,t){this.localPosition.copy(e);let r=new DP(this.localPosition.x,-this.localPosition.y,0);this.position.copy(r).add(t)}updateFontSize(e){let t=e/this.resolution;this.fontSize=e,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*t*this.letterSpacing}updateFontFamily(e){if(this.fontFamily===e)return;this.fontFamily=e;let t=Ut.loadChar(this.char,e,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateChar(e){if(this.char===e)return;this.char=e;let t=Ut.loadChar(e,this.fontFamily,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateLetterSpacing(e){this.letterSpacing!==e&&(this.letterSpacing=e,this.updateFontSize(this.fontSize))}updateLOD(e){if(this.LOD===e)return;this.LOD=e;let t=Ut.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}clone(){let e={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new Ut(e).copy(this)}static loadFont(e){return new Promise(function(t,r){Ut.fontCache[e]?t(Ut.fontCache[e]):new BP().load(Ut.FONTS_PATH+e+".json",s=>{Ut.fontCache[e]=s,t(s)},void 0,r)})}static loadChar(e,t,r){if(Ut.charCache[e]){if(Ut.charCache[e][r]&&Ut.charCache[e][r].fontFamily===t)return Ut.charCache[e][r]}else Ut.charCache[e]={};let n=Ut.fontCache[t],s=n.generateShapes(e,1);return Ut.charCache[e][r]={geometry:new OP(s,r),fontFamily:t,resolution:n.data.resolution,glyphsHa:n.data.glyphs[e].ha},Ut.charCache[e][r]}},Rr=Ut;Rr.charCache={},Rr.fontCache={},Rr._fontPath="/_assets/_fonts/";import{DoubleSide as ju,MeshBasicMaterial as Xv,Vector3 as Zv,Object3D as L3}from"three";import{Mesh as nD}from"three";import{BufferGeometry as lk,ConeBufferGeometry as EP,Float32BufferAttribute as ck,Vector2 as uk,Vector3 as fk}from"three";import{BufferGeometry as GP,CylinderBufferGeometry as jP,Float32BufferAttribute as Nh,Vector2 as Pn,Vector3 as kc}from"three";var l0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var l,c,f,h,d;let t=Object.assign({},(l=e==null?void 0:e.parameters)!=null?l:{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},i.parameters),r=t.width/2,n=(c=t.radiusTop)!=null?c:r,s=(f=t.radiusBottom)!=null?f:r;return n===s?(n=r,s=r):n>s?(n=r,s=s*r/n):(n=n*r/s,s=r),{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((h=t.height)!=null?h:t.width),depth:Math.abs((d=t.depth)!=null?d:t.width),radiusTop:n,radiusBottom:s})}}static build(i){let{width:e,depth:t,height:r,radialSegments:n,heightSegments:s,openEnded:l,thetaStart:c,thetaLength:f,radiusTop:h,radiusBottom:d,cornerRadius:x,cornerSegments:g,hollow:w}=i.parameters,S;return x||w?S=new Hc(h,d,r,n,s,l,c,f*Math.PI/180,x,x,g,w):S=new jP(h,d,r,n,s,l,c,f*Math.PI/180),S.scale(1,1,t/e),Object.assign(S,{userData:fe(U({},i),{type:"CylinderGeometry"})})}};function Wi(i,e,t){t.x=i.x*e.x,t.y=i.y,t.z=i.x*e.y}function c0(i){return new Pn(i.y,-i.x)}var Hc=class extends GP{constructor(e,t,r,n,s,l,c,f,h,d,x,g,w=!1){super();this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,r=r||1,n=Math.floor(n)||8,s=Math.floor(s)||1,l=l!==void 0?l:!1,c=c!==void 0?c:0,f=f!==void 0?f:Math.PI*2,l&&(h=0,d=0);let S=[],D=[],C=[],G=[],B=0,P=r/2,W=new kc,M=new kc;w&&e==0&&(e=h),w&&t==0&&(t=d);let q=new Pn(e,P),E=new Pn(t,-P),b=null,R=null,T=null,z=null,A=q.clone().sub(E),$=0,he=0,re=0;g>0&&($=Math.min(e,t)*(1-g),he=e-$,re=t-$);let Ne=q.clone();Ne.x-=$;let ye=Math.PI-A.angle(),Me=A.angle(),Fe=Math.tan(Me/2),k=Math.tan(ye/2),H=Fe+k,_=g?H:k,J=g?H:Fe;if(h=Math.min(h,(e-he)/_,A.length()/H),d=Math.min(d,(t-re)/J,A.length()/H),h>0){let K=h/Fe;b=q.clone().sub(new Pn(K,h)),g&&(T=b.clone(),T.x-=$-H*h),q.sub(A.clone().setLength(K))}if(d>0){let K=d/k;R=E.clone().sub(new Pn(K,-d)),E.add(A.clone().setLength(K)),g&&(z=R.clone(),z.x-=$-H*d,Ne.sub(A.clone().setLength(K)))}A=q.clone().sub(E);let ee=A.length()<.5,oe=[];for(let K=0;K<=n;K++){let ae=[],ne=K/n,Ce=ne*f+c,Y=new Pn(Math.sin(Ce),Math.cos(Ce));z&&R?(se(ae,ne,Y,ye,d,z,-1,!0),se(ae,ne,Y,Me,d,R,-1,!1)):R?(ce(ae,Y,R.x,0,-1),se(ae,ne,Y,Me,d,R,-1,!1)):l||ce(ae,Y,t,re,-1);let le=c0(A).normalize();if(Wi(le,Y,W),!ee)for(let pe=0;pe<=s;pe++){let xe=pe/s,_e=A.clone().multiplyScalar(xe).add(E);Wi(_e,Y,M),D.push(M.x,M.y,M.z),C.push(W.x,W.y,W.z),G.push(ne,.5+M.y/r),ae.push(B++)}if(T&&b?(se(ae,ne,Y,ye,h,b,1,!1),se(ae,ne,Y,Me,h,T,1,!0)):b?(se(ae,ne,Y,ye,h,b,1,!1),ce(ae,Y,b.x,0,1)):l||ce(ae,Y,e,he,1),g&&!ee){let pe=c0(A).multiplyScalar(-1).normalize();Wi(pe,Y,W);for(let xe=0;xe<=s;xe++){let _e=xe/s,de=A.clone().multiplyScalar(-_e).add(Ne);Wi(de,Y,M),D.push(M.x,M.y,M.z),C.push(W.x,W.y,W.z),G.push(ne,.5+M.y/r),ae.push(B++)}}g&&!l&&ae.push(ae[0]),oe.push(ae)}for(let K=0;K<oe.length-1;K++)for(let ae=0;ae<oe[0].length-1;ae++){if(l&&g&&ae==s)continue;let ne=oe[K][ae],Ce=oe[K+1][ae],Y=oe[K+1][ae+1],le=oe[K][ae+1],pe=D[Y*3+0],xe=D[Y*3+2];S.push(ne,Ce,le),(pe!=0||xe!=0)&&S.push(Ce,Y,le)}f<Math.PI*2&&(ue(-1,oe[0],c),ue(1,oe[oe.length-1],c+f)),this.setIndex(S),this.setAttribute("position",new Nh(D,3)),this.setAttribute("normal",new Nh(C,3)),this.setAttribute("uv",new Nh(G,2));function se(K,ae,ne,Ce,Y,le,pe,xe){for(let _e=0;_e<x+1;_e++){let de=_e/x,we=pe<0?de:1-de;xe&&(we-=1),we*=Ce;let Ve=new Pn(Math.sin(we),Math.cos(we)*pe),Ge=Ve.clone().multiplyScalar(Y).add(le);Wi(Ge,ne,M),D.push(M.x,M.y,M.z),Wi(Ve,ne,W),C.push(W.x,W.y,W.z),G.push(ae,.5+M.y/r),K.push(B++)}}function ce(K,ae,ne,Ce,Y){let le=new kc,pe=new Pn,xe=[ne,Ce];Y<0&&xe.reverse();for(let _e of xe)pe.set(_e,P*Y),Wi(pe,ae,le),D.push(le.x,le.y,le.z),C.push(0,Y,0),G.push(.5,.5),K.push(B++)}function ue(K,ae,ne){let Ce=new Pn(Math.sin(ne),Math.cos(ne)),Y=new Pn(-Math.cos(ne),Math.sin(ne)),le=new kc,pe=K<0?(de,we,Ve)=>S.push(de,we,Ve):(de,we,Ve)=>S.push(de,Ve,we),xe=new Pn((e+t+he+re)/4,0);Wi(xe,Ce,le),D.push(le.x,le.y,le.z),C.push(Y.x,0,Y.y),G.push(.5,.5);let _e=B++;for(let de of ae){let we=D.slice(de*3,de*3+3);D.push(...we),C.push(Y.x,0,Y.y);let Ve=G.slice(de*2,de*2+2);G.push(...Ve),B++}for(let de=_e+1;de<B-1;de++)pe(_e,de,de+1);pe(_e,B-1,_e+1)}}};var u0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,depth:t,height:r,radialSegments:n,heightSegments:s,openEnded:l,thetaStart:c,thetaLength:f,cornerRadiusTop:h,cornerRadiusBottom:d,cornerSegments:x}=i.parameters,g;return h>0||d>0||f<360?g=new Hc(0,e/2,r,n,s,l,c,f*Math.PI/180,h,d,x,0,!0):g=new EP(e/2,r,n,s,l),g.scale(1,1,t/e),Object.assign(g,{userData:fe(U({},i),{type:"ConeGeometry"})})}};import{BoxBufferGeometry as RP,BufferGeometry as zP,Float32BufferAttribute as Ch,Vector3 as ma}from"three";var f0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,height:t,depth:r,widthSegments:n,heightSegments:s,depthSegments:l,cornerRadius:c,cornerSegments:f}=i.parameters,h;return c==0?h=new RP(e,t,r,n,s,l):h=new h0(e,t,r,n,s,l,c,f),Object.assign(h,{userData:fe(U({},i),{type:"CubeGeometry"})})}},Lh=Math.PI/2,h0=class extends zP{constructor(e=1,t=1,r=1,n=1,s=1,l=1,c=0,f=4){super();this.type="BoxBufferGeometry";let h=this;n=Math.floor(n),s=Math.floor(s),l=Math.floor(l),f=Math.floor(f),c=Math.min(c,e/2,t/2,r/2);let d=[],x=[],g=[],w=[],S=0,D=0;C("z","y","x",-1,-1,r,t,e,l,s,0),C("z","y","x",1,-1,r,t,-e,l,s,1),C("x","z","y",1,1,e,r,t,n,l,2),C("x","z","y",1,-1,e,r,-t,n,l,3),C("x","y","z",1,-1,e,t,r,n,s,4),C("x","y","z",-1,-1,e,t,-r,n,s,5),c>0&&(G("z","y","x",-1,-1,1,r,t,e,l,0),G("z","y","x",1,-1,-1,r,t,e,l,1),G("z","y","x",-1,1,-1,r,t,e,l,1),G("z","y","x",1,1,1,r,t,e,l,0),G("x","y","z",-1,-1,-1,e,t,r,n,0),G("x","y","z",1,-1,1,e,t,r,n,1),G("x","y","z",-1,1,1,e,t,r,n,0),G("x","y","z",1,1,-1,e,t,r,n,1),G("y","x","z",-1,-1,1,t,e,r,s,0),G("y","x","z",1,-1,-1,t,e,r,s,1),G("y","x","z",1,1,1,t,e,r,s,1),G("y","x","z",-1,1,-1,t,e,r,s,0),B(1,1,1),B(-1,1,1),B(1,-1,1),B(-1,-1,1),B(1,1,-1),B(-1,1,-1),B(1,-1,-1),B(-1,-1,-1)),this.setIndex(d),this.setAttribute("position",new Ch(x,3)),this.setAttribute("normal",new Ch(g,3)),this.setAttribute("uv",new Ch(w,2));function C(P,W,M,q,E,b,R,T,z,A,$){let he=(b-2*c)/z,re=(R-2*c)/A,Ne=b/2-c,ye=R/2-c,Me=T/2,Fe=z+1,k=A+1,H=0,_=0,J=new ma;for(let ee=0;ee<k;ee++){let oe=ee*re-ye;for(let se=0;se<Fe;se++){let ce=se*he-Ne;J[P]=ce*q,J[W]=oe*E,J[M]=Me,x.push(J.x,J.y,J.z),J[P]=0,J[W]=0,J[M]=T>0?1:-1,g.push(J.x,J.y,J.z),w.push(se/z),w.push(1-ee/A),H+=1}}for(let ee=0;ee<A;ee++)for(let oe=0;oe<z;oe++){let se=S+oe+Fe*ee,ce=S+oe+Fe*(ee+1),ue=S+(oe+1)+Fe*(ee+1),K=S+(oe+1)+Fe*ee;d.push(se,ce,K),d.push(ce,ue,K),_+=6}h.addGroup(D,_,$),D+=_,S+=H}function G(P,W,M,q,E,b,R,T,z,A,$){let he=(R-2*c)/A,re=R/2-c,Ne=T/2-c,ye=z/2,Me=A+1,Fe=0,k=0,H=new ma,_=new ma;for(let J=0;J<f+1;J++){let ee=J/f*Lh,oe=Math.sin(ee)*c,se=(1-Math.cos(ee))*c,ce=Math.sin(ee),ue=Math.cos(ee);H[W]=(Ne+oe)*E,H[M]=(ye-se)*b,_[P]=0,_[W]=ce*Math.sign(H[W]),_[M]=ue*Math.sign(H[M]);for(let K=0;K<Me;K++){let ae=K*he-re;H[P]=ae*q,x.push(H.x,H.y,H.z),g.push(_.x,_.y,_.z),w.push(K/A),w.push(0),Fe+=1}}for(let J=0;J<f;J++)for(let ee=0;ee<A;ee++){let oe=S+ee+Me*J,se=S+ee+Me*(J+1),ce=S+(ee+1)+Me*(J+1),ue=S+(ee+1)+Me*J;d.push(oe,se,ue),d.push(se,ce,ue),k+=6}h.addGroup(D,k,$),D+=k,S+=Fe}function B(P,W,M){let q=new ma,E=new ma(e/2,t/2,r/2);E.subScalar(c);let b=[],R=P*W*M>0?(z,A,$)=>d.push(z,A,$):(z,A,$)=>d.push(z,$,A);for(let z=0;z<=f;z++){let A=[],$=Lh*(1-z/f),he=Math.cos($),re=Math.sin($),Ne=0;for(let ye=0;ye<=z;ye++){let Me=Math.cos(Ne),Fe=Math.sin(Ne);q.x=he*Me,q.y=re,q.z=he*Fe;let k=E.clone().addScaledVector(q,c);x.push(P*k.x,W*k.y,M*k.z),g.push(P*q.x,W*q.y,M*q.z),w.push(0,0),A.push(S++),Ne+=Lh/z}b.push(A)}let T=b.length-1;for(let z=0;z<T;z++){let A=b[z],$=b[z+1],he=A.length-1;R(A[0],$[1],$[0]);for(let re=1;re<=he;re++)R(A[re-1],A[re],$[re]),R(A[re],$[re+1],$[re])}}}};import{BufferGeometry as FP,Float32BufferAttribute as _h,Triangle as VP,Vector3 as yi,Vector2 as Th}from"three";var So=class extends FP{constructor(e=[],t=[],r="",n=1,s=.2,l=4){super();this.type="PolyhedronGeometryRound";let c=[],f=[],h=[];d(),x(),this.setAttribute("position",new _h(c,3)),this.setAttribute("normal",new _h(h,3)),this.setAttribute("uv",new _h(f,2));return;function d(){var Fe;s=Math.min(1-1e-5,s),s==0&&(l=0);let w={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],S=new yi,D=S.clone(),C=new VP,G=s*n,B=n-G,P=l+1,W=new yi,M=(k,H)=>W.subVectors(k,H).normalize(),q=(k,H)=>Array(k).fill(void 0).map(H),E=q(e.length/3,(k,H)=>new yi().fromArray(e,H*3).setLength(n)),b=[],R=1e6;for(let k=0;k<E.length;k++){let H=E[k],_=[],J,ee,oe,se=1e10,ce=-1;for(;(ce=t.indexOf(k,ce+1))!=-1;){let ne=ce-ce%3;J=t[ne+(ce+1)%3],ee=t[ne+(ce+2)%3],oe=H.distanceToSquared(E[J]),se=Math.min(se,oe),_.push([J,ee,oe])}se+=1e-6;let ue=[],K=0,ae=_.length;for(let ne=0;ne<ae;ne++){[J,ee,oe]=_[K];let Ce=((Fe=b[J])==null?void 0:Fe.includes(k))==!0;oe<=se&&ue.push(J+ +Ce*R),K=_.findIndex(Y=>Y[0]==ee)}b.push(ue)}let T=[];{let k=0,H=0,_,J,ee=w==3;for(let oe=0;oe<=l;oe++){_=oe*(oe+1)/2,J=(oe+1)*(oe+2)/2;for(let se=0;se<l-oe;se++)[k,H]=[_+se+oe+2,J+se+oe+3],T.push(_,J,...ee?[H,_]:[k,J],H,k),[_,J]=[k,H];T.push(_,J,_+l+2)}}let z=S.clone(),A=S.clone(),$=S.clone(),he=S.clone(),re=S.clone(),Ne=[],ye=q(E.length,()=>q(w,()=>S.clone()));for(let k=0;k<E.length;k++){S.copy(E[k]).normalize(),z.copy(S).multiplyScalar(B);let H=b[k];for(let ue=0;ue<H.length;ue++){let K=H[ue],ae=H[(ue+1)%w];C.setFromPointsAndIndices(E,k,K%R,ae%R),C.b.sub(C.a).setLength(1e10).add(C.a),C.c.sub(C.a).setLength(1e10).add(C.a),C.closestPointToPoint(z,ye[k][ue])}let _=[],J=[],ee=[],oe=new yi;l==0&&[...ye[k]].reduce((ue,K)=>ue.add(K),oe).multiplyScalar(1/w);for(let ue=0;ue<w;ue++){let K=[],ae=(ue-1+w)%w,ne=ye[k][ae],Ce=ye[k][ue];S.copy(ne).sub(z),D.copy(Ce).sub(z);let Y=z.angleTo(S),le=S.angleTo(D),pe=Math.cos(Y)*G;l==0?A.copy(oe):A.copy(z).setLength(B+pe),J.push(pe);let xe=[A,ne,Ce];for(let _e=0;_e<2;_e++){let de=xe[_e],we=xe[_e+1];he.subVectors(de,z),re.subVectors(we,z),$.crossVectors(he,re).normalize();for(let Ve=0;Ve<P;Ve++){let Ge=[Y,le][_e]*Ve/P;S.copy(he).applyAxisAngle($,Ge).add(z),_.push(S.clone()),_e&&(M(S,z),K.push([Ve==0?de:S.clone(),W.clone()]))}_e&&(M(we,z),K.push([we,W.clone()]))}ee.push(K)}Ne.push(ee);let se=2*P,ce=2;for(let ue=0;ue<w;ue++){let K=se*ue,ae=se*((ue+1)%w),ne=[_[K]];for(let Y=1;Y<P;Y++){he=_[K+Y],re=_[ae+Y],ne.push(he);for(let le=1,pe=Y-ce+1;le<=pe;le++)S.lerpVectors(he,re,le/(pe+1)),S.sub(z).setLength(J[ue]).add(z),ne.push(S.clone());ne.push(re)}for(let Y=0;Y<P;Y++)ne.push(_[Y+P+K]);ne.push(_[ae+P]);let Ce=T.map(Y=>ne[Y]);c.push(...Ce.map(Y=>[Y.x,Y.y,Y.z]).flat()),h.push(...Ce.map(Y=>(M(Y,z),[W.x,W.y,W.z])).flat())}}let Me=[];for(let k=0;k<b.length;k++)for(let H=0;H<w;H++){let _=b[k][H];if(_<R){let J=b[_].findIndex(se=>se%R==k),ee=Ne[k][H],oe=Ne[_][J];for(let se=0;se<P;se++){let ce=ee[se],ue=oe[P-se],K=ee[se+1],ae=oe[P-(se+1)];[ce,ue,K,K,ue,ae].forEach(ne=>{c.push(ne[0].x,ne[0].y,ne[0].z),h.push(ne[1].x,ne[1].y,ne[1].z)})}Me.push(ee[0][0],oe[P][0],ee[P][0],oe[0][0])}}for(;Me.length;){let k,H,_,J;[k,H]=Me.splice(0,2);let ee=[k];for(;k!=H;)ee.push(H),_=Me.indexOf(H),J=_%2,H=Me.splice(_-J,2)[1-J];W.subVectors(ee[0],ee[1]).cross(S.subVectors(ee[0],ee[2])).normalize();let oe=W.dot(ee[0])<0;oe&&W.negate();for(let se=1;se<=ee.length-2;se++)[ee[se+ +oe],ee[se+1-+oe],ee[0]].forEach(ce=>{c.push(ce.x,ce.y,ce.z),h.push(W.x,W.y,W.z)})}}function x(){let g=new yi;for(let E=0;E<c.length;E+=3){g.x=c[E+0],g.y=c[E+1],g.z=c[E+2];let b=M(g)/2/Math.PI+.5,R=q(g)/Math.PI+.5;f.push(b,1-R)}let w=new yi,S=new yi,D=new yi,C=new yi,G=new Th,B=new Th,P=new Th,W=(E,b,R,T)=>{T<0&&E.x===1&&(f[b]=E.x-1),R.x===0&&R.z===0&&(f[b]=T/2/Math.PI+.5)};for(let E=0,b=0;E<c.length;E+=9,b+=6){w.set(c[E+0],c[E+1],c[E+2]),S.set(c[E+3],c[E+4],c[E+5]),D.set(c[E+6],c[E+7],c[E+8]),G.set(f[b+0],f[b+1]),B.set(f[b+2],f[b+3]),P.set(f[b+4],f[b+5]),C.copy(w).add(S).add(D).divideScalar(3);let R=M(C);W(G,b+0,w,R),W(B,b+2,S,R),W(P,b+4,D,R)}for(let E=0;E<f.length;E+=6){let b=f[E+0],R=f[E+2],T=f[E+4],z=Math.max(b,R,T),A=Math.min(b,R,T);z>.9&&A<.1&&(b<.2&&(f[E+0]+=1),R<.2&&(f[E+2]+=1),T<.2&&(f[E+4]+=1))}function M(E){return Math.atan2(E.z,-E.x)}function q(E){return Math.atan2(-E.y,Math.sqrt(E.x*E.x+E.z*E.z))}}}static fromJSON(e){return new So(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};import{DodecahedronBufferGeometry as UP}from"three";var p0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,height:t,depth:r,detail:n,corner:s,cornerSides:l}=i.parameters,c=n===0&&s!==0?new Wc(e*.5,s,l):new UP(e*.5,n);return c.scale(1,t/e,r/e),Object.assign(c,{userData:fe(U({},i),{type:"DodecahedronGeometry"})})}},Wc=class extends So{constructor(e=1,t=.2,r=4){let n=(1+Math.sqrt(5))/2,s=1/n,l=[-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,-s,-n,0,-s,n,0,s,-n,0,s,n,-s,-n,0,-s,n,0,s,-n,0,s,n,0,-n,0,-s,n,0,-s,-n,0,s,n,0,s],c=[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],f="DodecahedronGeometry";super(l,c,f,e,t,r);this.type=f}static fromJSON(e){return new Wc(e.radius,e.corner,e.cornerSides)}};import{EventDispatcher as QP,Plane as e2,Shape as L0,Vector2 as xi,Vector3 as t2,MathUtils as Bh,LineCurve as Gh,QuadraticBezierCurve as _0,CubicBezierCurve as Jc}from"three";import{CubicBezierCurve as qc,EllipseCurve as kP,LineCurve as $c,LineCurve3 as HP,MathUtils as WP,QuadraticBezierCurve as Ih,SplineCurve as qP,Vector2 as Dn,Vector3 as d0}from"three";var ga=1e-12,ya=class{constructor(e){this.position=new Dn;this.startPosition=new Dn;this.uuid=WP.generateUUID();this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new ya(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},xa=class extends ya{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new xa(this.parent).copy(this)}},Kn=class extends ya{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new xa(this),new xa(this))}static create(e,t){let r=new Kn(e,new Dn(...t.position));return r.controls[0].position.set(...t.controlPrevious.position),r.controls[1].position.set(...t.controlNext.position),r.roundness=t.roundness,r.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,r}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let r=0,n=this.controls.length;r<n;r++){let s=this.controls[r];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.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 Kn(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}},Mh=i=>i,va=new Dn,Ah=new Dn,$P=new Dn,JP=new Dn,KP=new Dn,XP=new Dn,m0=new d0,g0=new d0;function y0(i){let e=new Dn;e.addVectors(i.v0,va.subVectors(i.v1,i.v0).multiplyScalar(2/3));let t=new Dn;return t.addVectors(i.v2,Ah.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new qc(i.v0,e,t,i.v2)}function ba(i,e,t=Number.EPSILON){return Math.abs(i-e)<t}function ZP(i,e,t=Number.EPSILON){return i.distanceTo(e)<t}function YP(i,e,t=Number.EPSILON){return i.distanceTo(e)<t}function Oh(i,e,t){let r=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2));return Math.acos((n*n+r*r-s*s)/(2*n*r))}function x0(i,e,t,r,n){let s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),l=(i.y+e.y)/2,c=(i.x+e.x)/2,f=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(i.y-e.y)/s,h=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(e.x-i.x)/s;return r.set(c+f,l+h),n.set(c-f,l-h),[r,n]}function v0(i,e,t){let r=i.distanceTo(t),n=e.distanceTo(t);return r<n?e:i}function b0(i,e,t,r,n,s){let l=e.x-i.x,c=e.y-i.y,f=t.x-i.x,h=t.y-i.y,d=Math.sqrt((l+f)*(l+f)+(c+h)*(c+h)),x;return Oh(e,i,t)>Math.PI&&(d*=-1),ba(h,c)?x=(c+h)*(r/d-.5)*8/3/(l-f):x=(l+f)*(r/d-.5)*8/3/(h-c),n.set(e.x-x*c,e.y+x*l),s.set(t.x+x*h,t.y-x*f),[n,s]}function Ph(i,e){return i.position.equals(i.controls[1].position)&&e.position.equals(e.controls[0].position)}function S0(i,e,t,r,n=.5){let s=va.subVectors(e,i).multiplyScalar(n).add(i),l=Ah.subVectors(t,e).multiplyScalar(n).add(e),c=$P.subVectors(r,t).multiplyScalar(n).add(t),f=s,h=JP.subVectors(l,s).multiplyScalar(n).add(s),d=KP.subVectors(c,l).multiplyScalar(n).add(l),x=c,g=XP.subVectors(d,h).multiplyScalar(n).add(h);return[i.x,i.y,f.x,f.y,h.x,h.y,g.x,g.y,d.x,d.y,x.x,x.y,r.x,r.y]}function w0(i,e,t=12,r=!0){let n=g0.set(0,0,0),s,l=0,c=[];for(let f=0;f<e.length;f++){let h=Mh(e[f]),d=va,x=qi(h,t);c.push(x);for(let g=0;g<=x;g++)if(h instanceof qc||h instanceof Ih||h instanceof $c){if(h.getPoint(g/x,d),n.set(d.x,d.y,0),s!==void 0&&YP(s,n))continue;s===void 0&&(s=m0),s.copy(n),i.setXYZ(l,n.x,n.y,n.z),l++}}return r&&l>1&&!(i.getX(l-1)===i.getX(0)&&i.getY(l-1)===i.getY(0)&&i.getZ(l-1)===i.getZ(0))&&(i.setXYZ(l,i.getX(0),i.getY(0),i.getZ(0)),l++),i}function N0(i,e,t,r=12,n=!0){let s=g0.set(0,0,0),l=0,c=[];for(let f=0;f<e.length;f++){if(t[f]===!1)continue;let h,d=Mh(e[f]),x=va,g=qi(d,r);c.push(g);for(let w=0;w<=g;w++)if(d instanceof qc||d instanceof Ih||d instanceof $c){if(d.getPoint(w/g,x),s.set(x.x,x.y,0),h==null?void 0:h.equals(s))continue;h===void 0?h=m0:(i.setXYZ(l,h.x,h.y,h.z),l++,i.setXYZ(l,s.x,s.y,s.z),l++),h.copy(s)}}return n&&l>1&&!(i.getX(l-1)===i.getX(0)&&i.getY(l-1)===i.getY(0)&&i.getZ(l-1)===i.getZ(0))&&(i.setXYZ(l,i.getX(0),i.getY(0),i.getZ(0)),l++),c}function Dh(i,e=12,t=!1){let r=[];for(let n=0,s=i.length;n<s;n++){let l=i[n],c=0;if(t&&l.roundedCurveCorner!==void 0){let f=qi(l.roundedCurveCorner,e)*.5;n>0&&(r[n-1]+=f),c+=f}l.curveAfter!==void 0&&(c+=qi(l.curveAfter,e)),r.push(c)}return i.length>0&&t&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=qi(i[0].roundedCurveCorner,e)*.5),r}function qi(i,e=12){return i&&i instanceof kP?e*2:i&&(i instanceof $c||i instanceof HP)?1:i&&i instanceof qP?e*i.points.length:e}function C0(i,e,t=12,r=!0){let n,s=0;for(let l=0;l<e.length;l++){let c=Mh(e[l]),f=qi(c,t),h=va;for(let d=0;d<=f;d++)if(c instanceof qc||c instanceof Ih||c instanceof $c){if(c.getPoint(d/f,h),n!==void 0&&ZP(n,h,ga))continue;n===void 0&&(n=Ah),n.copy(h),i.push(h.x,h.y),s++}}return ba(i[0],i[i.length-2],ga)&&ba(i[1],i[i.length-1],ga)&&(i.pop(),i.pop()),r&&s>1&&!(ba(i[s-1],i[1],ga)&&ba(i[s-2],i[0],ga))&&(i.push(i[0],i[1]),s++),i}var jh=new xi,r2=new xi,n2=new xi,i2=new xi,o2=new xi,s2=new xi,st=class extends L0{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new QP;this.plane=new e2(new t2(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Bh.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,r){let n=new st;return n.isClosed=e.isClosed,n.points=e.points.map(s=>Kn.create(s.id,s.data)),typeof e.roundness=="number"&&(n.roundness=e.roundness),n.shapeHoles=e.shapeHoles.map(s=>st.createFromState(s)),t!==void 0&&r!==void 0&&n.applySize(t,r),n.update(),n}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,r=this.points.length;t<r;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){return this.points.findIndex(t=>t.uuid===e)}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0)for(let t=0,r=this.shapeHoles.length;t<r;t++){let n=this.shapeHoles[t],s=e-this.points.length;if(s<=n.points.length-1)return n.points[s]}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let r=0,n=this.shapeHoles.length;r<n;r++){let s=this.shapeHoles[r],l=s.points.indexOf(e);if(l>=0)return t+l;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let r=jh.set(e,t);for(let n=0,s=this.points.length;n<s;n++){let l=this.points[n];l.position.multiply(r),l.controls[0].position.multiply(r),l.controls[1].position.multiply(r)}for(let n=0,s=this.shapeHoles.length;n<s;n++)this.shapeHoles[n].applyScale(e,t);this._update(!1)}createPoint(e,t=0,r=Bh.generateUUID()){let n;e instanceof xi?n=e:n=new xi(e,t);let s=new Kn(r,n);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,r=this.points.length;t<r;t++){let n=this.points[t];if(n.uuid===e)return n}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(r=>r.uuid===e);t&&this.removePoint(t)}update(e=!0){for(let t=0,r=this.shapeHoles.length;t<r;t++)this.shapeHoles[t].update(!1);this._update(e)}extractShapePointsToBuffer(e,t=12,r=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let n=r?this.roundedCurveDivisions:this.curveDivisions;return w0(e,r?this.roundedCurves:this.curves,t,this.autoClose),n.reduce((s,l)=>s+l,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Dh(this.points,e,!1),this.roundedCurveDivisions=Dh(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,r=12){return N0(e,this.curves,t,r,this.autoClose).reduce((s,l)=>s+l,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),C0(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let r=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let n=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=qi(this.points[0].roundedCurveCorner,this.subdivision)*.5);let l=e-s;l<0&&(l+=n.reduce((c,f)=>c+f,0));for(let c=0,f=n.length;c<f;c++){let h=n[c];if(l<r+h)return[c,(l-r+1)/h];r+=h}return[0,1]}getCurveT(e,t,r){let n=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],l=this.curveDivisions,c=l[e];if(Ph(n,s)){let d=n.position.distanceTo(s.position);return n.position.distanceTo(jh.set(r.x,r.y))/d}let f=0;for(let d=0;d<e;d++)f+=l[d];return(t-f)/c}dispose(){this.eventDispatcher=null}_applyCurveForPoint(e,t){Ph(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let r=this.curves[this.curves.length-1];e.curveBefore=r,t.curveAfter=r;let n=r.clone();e.roundedCurveBefore=n,t.roundedCurveAfter=n,e.roundedCurveCorner=void 0,this.roundedCurves.push(n)}_update(e=!0){var r;if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let n=0,s=this.points.length;n<s;n++){let l=this.points[n];if(n===0)this.moveTo(l.position.x,l.position.y);else{let c=this.points[n-1];this._applyCurveForPoint(l,c)}}let t=this.getLastPoint();if((t==null?void 0:t.curveAfter)&&(t.curveAfter=void 0),this.isClosed){let n=this.points[0],s=this.points[this.points.length-1];this._applyCurveForPoint(n,s)}if(this.points.length>2){let n=0;for(let s=0,l=this.points.length;s<l;s++){let c=this.points[s],f=c.roundness;if(!c.controlsMoved()&&f>0){let h=c.curveBefore,d=c.curveAfter;if(h===void 0||d===void 0)continue;let x=c.roundedCurveBefore,g=c.roundedCurveAfter,w=h.getLength(),S=d.getLength(),D=Math.min(f,w*.499),C=Math.min(f,S*.499),G=Math.min(D,C),B=1-G/w,P=G/S,W=h.getPointAt(B,jh),M=d.getPointAt(P,r2);this._subSplitCurve(h,x,B,W,void 0),this._subSplitCurve(d,g,P,void 0,M);let q;if(this.useCubicForRoundedCorners){let E=Oh(W,c.position,M)/2,b=Math.tan(E)*W.distanceTo(c.position),[R,T]=x0(W,M,b,n2,i2),z=v0(R,T,c.position),[A,$]=b0(z,W,M,b,o2,s2);q=new Jc(W.clone(),A.clone(),$.clone(),M.clone())}else q=new _0(W.clone(),c.position.clone(),M.clone());c.roundedCurveCorner=q,this.roundedCurves.splice(s+n,0,q),n++}}}e&&((r=this.eventDispatcher)==null||r.dispatchEvent({type:"update"}))}_subSplitCurve(e,t,r,n,s){if(e instanceof Gh)n!==void 0&&t.v2.copy(n),s!==void 0&&t.v1.copy(s);else{let l=e,c=t,f=l.getUtoTmapping(r,0),h=S0(l.v0,l.v1,l.v2,l.v3,f);return n!==void 0&&(c.v0.set(h[0],h[1]),c.v1.set(h[2],h[3]),c.v2.set(h[4],h[5]),c.v3.set(h[6],h[7])),s!==void 0&&(c.v0.set(h[6],h[7]),c.v1.set(h[8],h[9]),c.v2.set(h[10],h[11]),c.v3.set(h[12],h[13])),c}return t}clone(){let e=new st(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){var r;this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let n=0;n<t;n++){let s=n*7,l=e.points[s+0],c=e.points[s+1],f=e.points[s+2],h=e.points[s+3],d=e.points[s+4],x=e.points[s+5],g=e.points[s+6],w=new Kn(Bh.generateUUID(),new xi(l,c));w.controls[0].position.set(f,h),w.controls[1].position.set(d,x),w.roundness=g,this.points.push(w)}return this.shapeHoles=((r=e.shapeHoles)==null?void 0:r.length)?e.shapeHoles.map(n=>{let s=new st;return s.fromJSON(n),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(n,s)=>{s instanceof Jc&&s.v3.equals(n.position)&&n.controls[0].position.copy(s.v2)},r=n=>{let s=[],l,c;for(l=0,c=n.length;l<c;l++)n[l]instanceof _0&&(n[l]=y0(n[l]));for(l=0,c=n.length;l<c;l++){let d=n[l],x=l>0?n[l-1]:null,g;d instanceof Jc?(g=this.createPoint(d.v0),g.controls[1].position.copy(d.v1)):d instanceof Gh&&(g=this.createPoint(d.v1)),g!==void 0&&(x!==null&&t(g,x),s.push(g))}let f=n[n.length-1],h=!1;return f instanceof Jc?f.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(f.v2),h=!0):f instanceof Gh&&f.v2.equals(s[0].position)&&(h=!0),this.isClosed=h,s};return this.points=r(e.curves),e instanceof L0&&(this.shapeHoles=e.holes.map(n=>{let s=new st;return s.fromShape(n),s})),this.update(),this}};var Eh=Math.PI*2;function Rh({x:i,y:e},t,r,n,s){return{x:i*t+n,y:e*r+s}}function a2(i,e){let t=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:4/3*Math.tan(e/4),r=Math.cos(i),n=Math.sin(i),s=Math.cos(i+e),l=Math.sin(i+e);return[{x:r-n*t,y:n+r*t},{x:s+l*t,y:l-s*t},{x:s,y:l}]}function T0(i,e,t,r){let n=i*r-e*t<0?-1:1,s=Math.min(1,Math.max(-1,i*t+e*r));return n*Math.acos(s)}function l2(i,e,t,r,n,s,l,c,f,h){let d=Math.pow(n,2),x=Math.pow(s,2),g=Math.pow(l,2),w=Math.pow(c,2),S=d*x-d*w-x*g;S<0&&(S=0),S/=d*w+x*g,S=Math.sqrt(S)*(f===h?-1:1);let D=S*n/s*c,C=S*-s/n*l,G=D+(i+t)/2,B=C+(e+r)/2,P=(l-D)/n,W=(c-C)/s,M=(-l-D)/n,q=(-c-C)/s,E=T0(1,0,P,W),b=T0(P,W,M,q);return!h&&b>0&&(b-=Eh),h&&b<0&&(b+=Eh),{centerx:G,centery:B,ang1:E,ang2:b}}function I0({px:i,py:e,cx:t,cy:r,rx:n,ry:s,largeArcFlag:l,sweepFlag:c}){let f=[];if(n===0||s===0)return[];let h=(i-t)/2,d=(e-r)/2;if(h===0&&d===0)return[];n=Math.abs(n),s=Math.abs(s);let x=Math.pow(h,2)/Math.pow(n,2)+Math.pow(d,2)/Math.pow(s,2);x>1&&(n*=Math.sqrt(x),s*=Math.sqrt(x));let g=l2(i,e,t,r,n,s,h,d,l,c),{ang1:w,ang2:S}=g,{centerx:D,centery:C}=g,G=Math.abs(S)/(Eh/4);Math.abs(1-G)<1e-7&&(G=1);let B=Math.max(Math.ceil(G),1);S/=B;for(let P=0;P<B;P++)f.push(a2(w,S)),w+=S;return f.map(P=>{let{x:W,y:M}=Rh(P[0],n,s,D,C),{x:q,y:E}=Rh(P[1],n,s,D,C),{x:b,y:R}=Rh(P[2],n,s,D,C);return{x1:W,y1:M,x2:q,y2:E,x:b,y:R}})}import{BufferAttribute as Xc,BufferGeometry as p2}from"three";var Pt;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Pt||(Pt={}));var Qt;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Qt||(Qt={}));function Ae(i,e){if(!i)throw e||"Assertion Failed!"}var Te=function(){function i(){}return i.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},i.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},i.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},i.edgeGoesLeft=function(e){return i.vertLeq(e.Dst,e.Org)},i.edgeGoesRight=function(e){return i.vertLeq(e.Org,e.Dst)},i.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},i.edgeEval=function(e,t,r){Ae(i.vertLeq(e,t)&&i.vertLeq(t,r));var n=t.s-e.s,s=r.s-t.s;return n+s>0?n<s?t.t-e.t+(e.t-r.t)*(n/(n+s)):t.t-r.t+(r.t-e.t)*(s/(n+s)):0},i.edgeSign=function(e,t,r){Ae(i.vertLeq(e,t)&&i.vertLeq(t,r));var n=t.s-e.s,s=r.s-t.s;return n+s>0?(t.t-r.t)*n+(t.t-e.t)*s:0},i.transEval=function(e,t,r){Ae(i.transLeq(e,t)&&i.transLeq(t,r));var n=t.t-e.t,s=r.t-t.t;return n+s>0?n<s?t.s-e.s+(e.s-r.s)*(n/(n+s)):t.s-r.s+(r.s-e.s)*(s/(n+s)):0},i.transSign=function(e,t,r){Ae(i.transLeq(e,t)&&i.transLeq(t,r));var n=t.t-e.t,s=r.t-t.t;return n+s>0?(t.s-r.s)*n+(t.s-e.s)*s:0},i.vertCCW=function(e,t,r){return e.s*(t.t-r.t)+t.s*(r.t-e.t)+r.s*(e.t-t.t)>=0},i.interpolate=function(e,t,r,n){return e=e<0?0:e,r=r<0?0:r,e<=r?r===0?(t+n)/2:t+(n-t)*(e/(e+r)):n+(t-n)*(r/(e+r))},i.intersect=function(e,t,r,n,s){var l,c,f;i.vertLeq(e,t)||(f=e,e=t,t=f),i.vertLeq(r,n)||(f=r,r=n,n=f),i.vertLeq(e,r)||(f=e,e=r,r=f,f=t,t=n,n=f),i.vertLeq(r,t)?i.vertLeq(t,n)?(l=i.edgeEval(e,r,t),c=i.edgeEval(r,t,n),l+c<0&&(l=-l,c=-c),s.s=i.interpolate(l,r.s,c,t.s)):(l=i.edgeSign(e,r,t),c=-i.edgeSign(e,n,t),l+c<0&&(l=-l,c=-c),s.s=i.interpolate(l,r.s,c,n.s)):s.s=(r.s+t.s)/2,i.transLeq(e,t)||(f=e,e=t,t=f),i.transLeq(r,n)||(f=r,r=n,n=f),i.transLeq(e,r)||(f=e,e=r,r=f,f=t,t=n,n=f),i.transLeq(r,t)?i.transLeq(t,n)?(l=i.transEval(e,r,t),c=i.transEval(r,t,n),l+c<0&&(l=-l,c=-c),s.t=i.interpolate(l,r.t,c,t.t)):(l=i.transSign(e,r,t),c=-i.transSign(e,n,t),l+c<0&&(l=-l,c=-c),s.t=i.interpolate(l,r.t,c,n.t)):s.t=(r.t+t.t)/2},i}(),Sa=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),Kc=function(){function i(e){this.side=e,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),i}(),Ns=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return i}(),M0=function(){function i(){var e=new Ns,t=new Sa,r=new Kc(0),n=new Kc(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,r.next=r,r.Sym=n,n.next=n,n.Sym=r,this.vHead=e,this.fHead=t,this.eHead=r,this.eHeadSym=n}return i.prototype.makeEdge_=function(e){var t=new Kc(0),r=new Kc(1);e.Sym.side<e.side&&(e=e.Sym);var n=e.Sym.next;return r.next=n,n.Sym.next=t,t.next=e,e.Sym.next=r,t.Sym=r,t.Onext=t,t.Lnext=r,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,r.Sym=t,r.Onext=r,r.Lnext=t,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,t},i.prototype.splice_=function(e,t){var r=e.Onext,n=t.Onext;r.Sym.Lnext=t,n.Sym.Lnext=e,e.Onext=n,t.Onext=r},i.prototype.makeVertex_=function(e,t,r){var n=e;Ae(n,"Vertex can't be null!");var s=r.prev;n.prev=s,s.next=n,n.next=r,r.prev=n,n.anEdge=t;var l=t;do l.Org=n,l=l.Onext;while(l!==t)},i.prototype.makeFace_=function(e,t,r){var n=e;Ae(n,"Face can't be null");var s=r.prev;n.prev=s,s.next=n,n.next=r,r.prev=n,n.anEdge=t,n.trail=null,n.marked=!1,n.inside=r.inside;var l=t;do l.Lface=n,l=l.Lnext;while(l!==t)},i.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,r=e.Sym.next;t.Sym.next=r,r.Sym.next=t},i.prototype.killVertex_=function(e,t){var r=e.anEdge,n=r;do n.Org=t,n=n.Onext;while(n!==r);var s=e.prev,l=e.next;l.prev=s,s.next=l},i.prototype.killFace_=function(e,t){var r=e.anEdge,n=r;do n.Lface=t,n=n.Lnext;while(n!==r);var s=e.prev,l=e.next;l.prev=s,s.next=l},i.prototype.makeEdge=function(){var e=new Ns,t=new Ns,r=new Sa,n=this.makeEdge_(this.eHead);return this.makeVertex_(e,n,this.vHead),this.makeVertex_(t,n.Sym,this.vHead),this.makeFace_(r,n,this.fHead),n},i.prototype.splice=function(e,t){var r=!1,n=!1;if(e!==t){if(t.Org!==e.Org&&(n=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!n){var s=new Ns;this.makeVertex_(s,t,e.Org),e.Org.anEdge=e}if(!r){var l=new Sa;this.makeFace_(l,t,e.Lface),e.Lface.anEdge=e}}},i.prototype.delete=function(e){var t=e.Sym,r=!1;if(e.Lface!==e.Rface&&(r=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!r){var n=new Sa;this.makeFace_(n,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},i.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),r=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var n=new Ns;return this.makeVertex_(n,r,t.Org),t.Lface=r.Lface=e.Lface,t},i.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e),r=t.Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,r),e.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=e.Rface,r.winding=e.winding,r.Sym.winding=e.Sym.winding,r.idx=e.idx,r.Sym.idx=e.Sym.idx,r},i.prototype.connect=function(e,t){var r=!1,n=this.makeEdge_(e),s=n.Sym;if(t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(n,e.Lnext),this.splice_(s,t),n.Org=e.Dst,s.Org=t.Org,n.Lface=s.Lface=e.Lface,e.Lface.anEdge=s,!r){var l=new Sa;this.makeFace_(l,n,e.Lface)}return n},i.prototype.zapFace=function(e){var t=e.anEdge,r,n,s,l,c;n=t.Lnext;do r=n,n=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)),s=r.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=t);l=e.prev,c=e.next,c.prev=l,l.next=c},i.prototype.countFaceVerts_=function(e){var t=e.anEdge,r=0;do r++,t=t.Lnext;while(t!==e.anEdge);return r},i.prototype.mergeConvexFaces=function(e){var t,r,n,s,l,c,f;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(!!t.inside)for(r=t.anEdge,l=r.Org;n=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(c=this.countFaceVerts_(t),f=this.countFaceVerts_(s.Lface),c+f-2<=e&&Te.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&Te.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(n=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===l);)r=n;return!0},i.prototype.check=function(){var e=this.fHead,t=this.vHead,r=this.eHead,n,s,l,c,f,h;for(s=e,s=e;(n=s.next)!==e;s=n){Ae(n.prev===s),f=n.anEdge;do Ae(f.Sym!==f),Ae(f.Sym.Sym===f),Ae(f.Lnext.Onext.Sym===f),Ae(f.Onext.Sym.Lnext===f),Ae(f.Lface===n),f=f.Lnext;while(f!==n.anEdge)}for(Ae(n.prev===s&&n.anEdge===null),c=t,c=t;(l=c.next)!==t;c=l){Ae(l.prev===c),f=l.anEdge;do Ae(f.Sym!==f),Ae(f.Sym.Sym===f),Ae(f.Lnext.Onext.Sym===f),Ae(f.Onext.Sym.Lnext===f),Ae(f.Org===l),f=f.Onext;while(f!==l.anEdge)}for(Ae(l.prev===c&&l.anEdge===null),h=r,h=r;(f=h.next)!==r;h=f)Ae(f.Sym.next===h.Sym),Ae(f.Sym!==f),Ae(f.Sym.Sym===f),Ae(f.Org!==null),Ae(f.Dst!==null),Ae(f.Lnext.Onext.Sym===f),Ae(f.Onext.Sym.Lnext===f);Ae(f.Sym.next===h.Sym&&f.Sym===this.eHeadSym&&f.Sym.Sym===f&&f.Org===null&&f.Dst===null&&f.Lface===null&&f.Rface===null)},i}(),A0=function(){function i(){this.handle=null}return i}(),O0=function(){function i(){this.key=null,this.node=0}return i}(),c2=function(){function i(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var r=0;r<e+1;r++)this.nodes[r]=new A0,this.handles[r]=new O0;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(e){var t=this.nodes,r=this.handles,n,s,l;for(n=t[e].handle;;){if(l=e<<1,l<this.size&&this.leq(r[t[l+1].handle].key,r[t[l].handle].key)&&++l,Ae(l<=this.max),s=t[l].handle,l>this.size||this.leq(r[n].key,r[s].key)){t[e].handle=n,r[n].node=e;break}t[e].handle=s,r[s].node=e,e=l}},i.prototype.floatUp_=function(e){var t=this.nodes,r=this.handles,n,s,l;for(n=t[e].handle;;){if(l=e>>1,s=t[l].handle,l===0||this.leq(r[s].key,r[n].key)){t[e].handle=n,r[n].node=e;break}t[e].handle=s,r[s].node=e,e=l}},i.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(e){var t,r;if(t=++this.size,t*2>this.max){this.max*=2;var n,s;for(s=this.nodes.length,this.nodes.length=this.max+1,n=s;n<this.nodes.length;n++)this.nodes[n]=new A0;for(s=this.handles.length,this.handles.length=this.max+1,n=s;n<this.handles.length;n++)this.handles[n]=new O0}return this.freeList===0?r=t:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[t].handle=r,this.handles[r].node=t,this.handles[r].key=e,this.initialized&&this.floatUp_(t),r},i.prototype.extractMin=function(){var e=this.nodes,t=this.handles,r=e[1].handle,n=t[r].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[r].key=null,t[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),n},i.prototype.delete=function(e){var t=this.nodes,r=this.handles,n;Ae(e>=1&&e<=this.max&&r[e].key!==null),n=r[e].node,t[n].handle=t[this.size].handle,r[t[n].handle].node=n,--this.size,n<=this.size&&(n<=1||this.leq(r[t[n>>1].handle].key,r[t[n].handle].key)?this.floatDown_(n):this.floatUp_(n)),r[e].key=null,r[e].node=this.freeList,this.freeList=e},i}(),zh=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),P0=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),u2=function(){function i(e,t){this.frame=e,this.leq=t,this.head=new P0,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(e){return this.insertBefore(this.head,e)},i.prototype.search=function(e){var t=this.head;do t=t.next;while(t.key!==null&&!this.leq(this.frame,e,t.key));return t},i.prototype.insertBefore=function(e,t){do e=e.prev;while(e.key!==null&&!this.leq(this.frame,e.key,t));var r=new P0;return r.key=t,r.next=e.next,e.next.prev=r,r.prev=e,e.next=r,r},i.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},i}(),f2=function(){function i(){}return i.regionBelow=function(e){return e.nodeUp.prev.key},i.regionAbove=function(e){return e.nodeUp.next.key},i.debugEvent=function(e){},i.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},i.edgeLeq=function(e,t,r){var n=e.event,s=t.eUp,l=r.eUp;if(s.Dst===n)return l.Dst===n?Te.vertLeq(s.Org,l.Org)?Te.edgeSign(l.Dst,s.Org,l.Org)<=0:Te.edgeSign(s.Dst,l.Org,s.Org)>=0:Te.edgeSign(l.Dst,n,l.Org)<=0;if(l.Dst===n)return Te.edgeSign(s.Dst,n,s.Org)>=0;var c=Te.edgeEval(s.Dst,n,s.Org),f=Te.edgeEval(l.Dst,n,l.Org);return c>=f},i.deleteRegion=function(e,t){t.fixUpperEdge&&Ae(t.eUp.winding===0),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},i.fixUpperEdge=function(e,t,r){Ae(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=r,r.activeRegion=t},i.topLeftRegion=function(e,t){var r=t.eUp.Org,n;do t=i.regionAbove(t);while(t.eUp.Org===r);if(t.fixUpperEdge){if(n=e.mesh.connect(i.regionBelow(t).eUp.Sym,t.eUp.Lnext),n===null)return null;i.fixUpperEdge(e,t,n),t=i.regionAbove(t)}return t},i.topRightRegion=function(e){var t=e.eUp.Dst;do e=i.regionAbove(e);while(e.eUp.Dst===t);return e},i.addRegionBelow=function(e,t,r){var n=new zh;return n.eUp=r,n.nodeUp=e.dict.insertBefore(t.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,r.activeRegion=n,n},i.isWindingInside=function(e,t){switch(e.windingRule){case Pt.ODD:return(t&1)!=0;case Pt.NONZERO:return t!==0;case Pt.POSITIVE:return t>0;case Pt.NEGATIVE:return t<0;case Pt.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(e,t){t.windingNumber=i.regionAbove(t).windingNumber+t.eUp.winding,t.inside=i.isWindingInside(e,t.windingNumber)},i.finishRegion=function(e,t){var r=t.eUp,n=r.Lface;n.inside=t.inside,n.anEdge=r,i.deleteRegion(e,t)},i.finishLeftRegions=function(e,t,r){for(var n,s=null,l=t,c=t.eUp;l!==r;){if(l.fixUpperEdge=!1,s=i.regionBelow(l),n=s.eUp,n.Org!=c.Org){if(!s.fixUpperEdge){i.finishRegion(e,l);break}n=e.mesh.connect(c.Lprev,n.Sym),i.fixUpperEdge(e,s,n)}c.Onext!==n&&(e.mesh.splice(n.Oprev,n),e.mesh.splice(c,n)),i.finishRegion(e,l),c=s.eUp,l=s}return c},i.addRightEdges=function(e,t,r,n,s,l){var c,f,h,d,x=!0;h=r;do Ae(Te.vertLeq(h.Org,h.Dst)),i.addRegionBelow(e,t,h.Sym),h=h.Onext;while(h!==n);for(s===null&&(s=i.regionBelow(t).eUp.Rprev),f=t,d=s;c=i.regionBelow(f),h=c.eUp.Sym,h.Org===d.Org;)h.Onext!==d&&(e.mesh.splice(h.Oprev,h),e.mesh.splice(d.Oprev,h)),c.windingNumber=f.windingNumber-h.winding,c.inside=i.isWindingInside(e,c.windingNumber),f.dirty=!0,!x&&i.checkForRightSplice(e,f)&&(i.addWinding(h,d),i.deleteRegion(e,f),e.mesh.delete(d)),x=!1,f=c,d=h;f.dirty=!0,Ae(f.windingNumber-h.winding===c.windingNumber),l&&i.walkDirtyRegions(e,f)},i.spliceMergeVertices=function(e,t,r){e.mesh.splice(t,r)},i.vertexWeights=function(e,t,r){var n=Te.vertL1dist(t,e),s=Te.vertL1dist(r,e),l=.5*s/(n+s),c=.5*n/(n+s);e.coords[0]+=l*t.coords[0]+c*r.coords[0],e.coords[1]+=l*t.coords[1]+c*r.coords[1],e.coords[2]+=l*t.coords[2]+c*r.coords[2]},i.getIntersectData=function(e,t,r,n,s,l){t.coords[0]=t.coords[1]=t.coords[2]=0,t.idx=-1,i.vertexWeights(t,r,n),i.vertexWeights(t,s,l)},i.checkForRightSplice=function(e,t){var r=i.regionBelow(t),n=t.eUp,s=r.eUp;if(Te.vertLeq(n.Org,s.Org)){if(Te.edgeSign(s.Dst,n.Org,s.Org)>0)return!1;Te.vertEq(n.Org,s.Org)?n.Org!==s.Org&&(e.pq.delete(n.Org.pqHandle),i.spliceMergeVertices(e,s.Oprev,n)):(e.mesh.splitEdge(s.Sym),e.mesh.splice(n,s.Oprev),t.dirty=r.dirty=!0)}else{if(Te.edgeSign(n.Dst,s.Org,n.Org)<0)return!1;i.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(n.Sym),e.mesh.splice(s.Oprev,n)}return!0},i.checkForLeftSplice=function(e,t){var r=i.regionBelow(t),n=t.eUp,s=r.eUp,l;if(Ae(!Te.vertEq(n.Dst,s.Dst)),Te.vertLeq(n.Dst,s.Dst)){if(Te.edgeSign(n.Dst,s.Dst,n.Org)<0)return!1;i.regionAbove(t).dirty=t.dirty=!0,l=e.mesh.splitEdge(n),e.mesh.splice(s.Sym,l),l.Lface.inside=t.inside}else{if(Te.edgeSign(s.Dst,n.Dst,s.Org)>0)return!1;t.dirty=r.dirty=!0,l=e.mesh.splitEdge(s),e.mesh.splice(n.Lnext,s.Sym),l.Rface.inside=t.inside}return!0},i.checkForIntersect=function(e,t){var r=i.regionBelow(t),n=t.eUp,s=r.eUp,l=n.Org,c=s.Org,f=n.Dst,h=s.Dst,d,x,g=new Ns,w,S;if(Ae(!Te.vertEq(h,f)),Ae(Te.edgeSign(f,e.event,l)<=0),Ae(Te.edgeSign(h,e.event,c)>=0),Ae(l!==e.event&&c!==e.event),Ae(!t.fixUpperEdge&&!r.fixUpperEdge),l===c||(d=Math.min(l.t,f.t),x=Math.max(c.t,h.t),d>x))return!1;if(Te.vertLeq(l,c)){if(Te.edgeSign(h,l,c)>0)return!1}else if(Te.edgeSign(f,c,l)<0)return!1;return i.debugEvent(e),Te.intersect(f,l,h,c,g),Ae(Math.min(l.t,f.t)<=g.t),Ae(g.t<=Math.max(c.t,h.t)),Ae(Math.min(h.s,f.s)<=g.s),Ae(g.s<=Math.max(c.s,l.s)),Te.vertLeq(g,e.event)&&(g.s=e.event.s,g.t=e.event.t),w=Te.vertLeq(l,c)?l:c,Te.vertLeq(w,g)&&(g.s=w.s,g.t=w.t),Te.vertEq(g,l)||Te.vertEq(g,c)?(i.checkForRightSplice(e,t),!1):!Te.vertEq(f,e.event)&&Te.edgeSign(f,e.event,g)>=0||!Te.vertEq(h,e.event)&&Te.edgeSign(h,e.event,g)<=0?h===e.event?(e.mesh.splitEdge(n.Sym),e.mesh.splice(s.Sym,n),t=i.topLeftRegion(e,t),n=i.regionBelow(t).eUp,i.finishLeftRegions(e,i.regionBelow(t),r),i.addRightEdges(e,t,n.Oprev,n,n,!0),!0):f===e.event?(e.mesh.splitEdge(s.Sym),e.mesh.splice(n.Lnext,s.Oprev),r=t,t=i.topRightRegion(t),S=i.regionBelow(t).eUp.Rprev,r.eUp=s.Oprev,s=i.finishLeftRegions(e,r,null),i.addRightEdges(e,t,s.Onext,n.Rprev,S,!0),!0):(Te.edgeSign(f,e.event,g)>=0&&(i.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(n.Sym),n.Org.s=e.event.s,n.Org.t=e.event.t),Te.edgeSign(h,e.event,g)<=0&&(t.dirty=r.dirty=!0,e.mesh.splitEdge(s.Sym),s.Org.s=e.event.s,s.Org.t=e.event.t),!1):(e.mesh.splitEdge(n.Sym),e.mesh.splitEdge(s.Sym),e.mesh.splice(s.Oprev,n),n.Org.s=g.s,n.Org.t=g.t,n.Org.pqHandle=e.pq.insert(n.Org),i.getIntersectData(e,n.Org,l,f,c,h),i.regionAbove(t).dirty=t.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(e,t){for(var r=i.regionBelow(t),n,s;;){for(;r.dirty;)t=r,r=i.regionBelow(r);if(!t.dirty&&(r=t,t=i.regionAbove(t),t===null||!t.dirty))return;if(t.dirty=!1,n=t.eUp,s=r.eUp,n.Dst!==s.Dst&&i.checkForLeftSplice(e,t)&&(r.fixUpperEdge?(i.deleteRegion(e,r),e.mesh.delete(s),r=i.regionBelow(t),s=r.eUp):t.fixUpperEdge&&(i.deleteRegion(e,t),e.mesh.delete(n),t=i.regionAbove(r),n=t.eUp)),n.Org!==s.Org)if(n.Dst!==s.Dst&&!t.fixUpperEdge&&!r.fixUpperEdge&&(n.Dst===e.event||s.Dst===e.event)){if(i.checkForIntersect(e,t))return}else i.checkForRightSplice(e,t);n.Org===s.Org&&n.Dst===s.Dst&&(i.addWinding(s,n),i.deleteRegion(e,t),e.mesh.delete(n),t=i.regionAbove(r))}},i.connectRightVertex=function(e,t,r){var n,s=r.Onext,l=i.regionBelow(t),c=t.eUp,f=l.eUp,h=!1;if(c.Dst!==f.Dst&&i.checkForIntersect(e,t),Te.vertEq(c.Org,e.event)&&(e.mesh.splice(s.Oprev,c),t=i.topLeftRegion(e,t),s=i.regionBelow(t).eUp,i.finishLeftRegions(e,i.regionBelow(t),l),h=!0),Te.vertEq(f.Org,e.event)&&(e.mesh.splice(r,f.Oprev),r=i.finishLeftRegions(e,l,null),h=!0),h){i.addRightEdges(e,t,r.Onext,s,s,!0);return}Te.vertLeq(f.Org,c.Org)?n=f.Oprev:n=c,n=e.mesh.connect(r.Lprev,n),i.addRightEdges(e,t,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(e,t)},i.connectLeftDegenerate=function(e,t,r){var n,s,l,c,f;if(n=t.eUp,Te.vertEq(n.Org,r)){Ae(!1),i.spliceMergeVertices(e,n,r.anEdge);return}if(!Te.vertEq(n.Dst,r)){e.mesh.splitEdge(n.Sym),t.fixUpperEdge&&(e.mesh.delete(n.Onext),t.fixUpperEdge=!1),e.mesh.splice(r.anEdge,n),i.sweepEvent(e,r);return}Ae(!1),t=i.topRightRegion(t),f=i.regionBelow(t),l=f.eUp.Sym,s=c=l.Onext,f.fixUpperEdge&&(Ae(s!==l),i.deleteRegion(e,f),e.mesh.delete(l),l=s.Oprev),e.mesh.splice(r.anEdge,l),Te.edgeGoesLeft(s)||(s=null),i.addRightEdges(e,t,l.Onext,c,s,!0)},i.connectLeftVertex=function(e,t){var r,n,s,l,c,f,h=new zh;if(h.eUp=t.anEdge.Sym,r=e.dict.search(h).key,n=i.regionBelow(r),!!n){if(l=r.eUp,c=n.eUp,Te.edgeSign(l.Dst,t,l.Org)===0){i.connectLeftDegenerate(e,r,t);return}if(s=Te.vertLeq(c.Dst,l.Dst)?r:n,r.inside||s.fixUpperEdge){if(s===r)f=e.mesh.connect(t.anEdge.Sym,l.Lnext);else{var d=e.mesh.connect(c.Dnext,t.anEdge);f=d.Sym}s.fixUpperEdge?i.fixUpperEdge(e,s,f):i.computeWinding(e,i.addRegionBelow(e,r,f)),i.sweepEvent(e,t)}else i.addRightEdges(e,r,t.anEdge,t.anEdge,null,!0)}},i.sweepEvent=function(e,t){e.event=t,i.debugEvent(e);for(var r=t.anEdge;r.activeRegion===null;)if(r=r.Onext,r===t.anEdge){i.connectLeftVertex(e,t);return}var n=i.topLeftRegion(e,r.activeRegion);Ae(n!==null);var s=i.regionBelow(n),l=s.eUp,c=i.finishLeftRegions(e,s,null);c.Onext===l?i.connectRightVertex(e,n,c):i.addRightEdges(e,n,c.Onext,l,l,!0)},i.addSentinel=function(e,t,r,n){var s=new zh,l=e.mesh.makeEdge();l.Org.s=r,l.Org.t=n,l.Dst.s=t,l.Dst.t=n,e.event=l.Dst,s.eUp=l,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=e.dict.insert(s)},i.initEdgeDict=function(e){e.dict=new u2(e,i.edgeLeq);var t=e.bmax[0]-e.bmin[0],r=e.bmax[1]-e.bmin[1],n=e.bmin[0]-t,s=e.bmax[0]+t,l=e.bmin[1]-r,c=e.bmax[1]+r;i.addSentinel(e,n,s,l),i.addSentinel(e,n,s,c)},i.doneEdgeDict=function(e){for(var t,r=0;(t=e.dict.min().key)!==null;)t.sentinel||(Ae(t.fixUpperEdge),Ae(++r==1)),Ae(t.windingNumber===0),i.deleteRegion(e,t)},i.removeDegenerateEdges=function(e){var t,r,n,s=e.mesh.eHead;for(t=s.next;t!==s;t=r)r=t.next,n=t.Lnext,Te.vertEq(t.Org,t.Dst)&&t.Lnext.Lnext!==t&&(i.spliceMergeVertices(e,n,t),e.mesh.delete(t),t=n,n=t.Lnext),n.Lnext===t&&(n!==t&&((n===r||n===r.Sym)&&(r=r.next),e.mesh.delete(n)),(t===r||t===r.Sym)&&(r=r.next),e.mesh.delete(t))},i.initPriorityQ=function(e){var t,r,n,s=0;for(n=e.mesh.vHead,r=n.next;r!==n;r=r.next)s++;for(s+=8,t=e.pq=new c2(s,Te.vertLeq),n=e.mesh.vHead,r=n.next;r!==n;r=r.next)r.pqHandle=t.insert(r);return r!==n?!1:(t.init(),!0)},i.donePriorityQ=function(e){e.pq=null},i.removeDegenerateFaces=function(e,t){var r,n,s;for(r=t.fHead.next;r!==t.fHead;r=n)n=r.next,s=r.anEdge,Ae(s.Lnext!==s),s.Lnext.Lnext===s&&(i.addWinding(s.Onext,s),e.mesh.delete(s));return!0},i.computeInterior=function(e,t){t===void 0&&(t=!0);var r,n;if(i.removeDegenerateEdges(e),!i.initPriorityQ(e))return!1;for(i.initEdgeDict(e);(r=e.pq.extractMin())!==null;){for(;n=e.pq.min(),!(n===null||!Te.vertEq(n,r));)n=e.pq.extractMin(),i.spliceMergeVertices(e,r.anEdge,n.anEdge);i.sweepEvent(e,r)}return e.event=e.dict.min().key.eUp.Org,i.debugEvent(e),i.doneEdgeDict(e),i.donePriorityQ(e),i.removeDegenerateFaces(e,e.mesh)?(t&&e.mesh.check(),!0):!1},i}(),h2=function(){function i(){this.mesh=new M0,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=Pt.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},i.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},i.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},i.prototype.computeNormal_=function(e){var t,r,n,s,l,c,f=[0,0,0],h=[0,0,0],d=[0,0,0],x=[0,0,0],g=[0,0,0],w=[null,null,null],S=[null,null,null],D=this.mesh.vHead;t=D.next;for(var C=0;C<3;++C)s=t.coords[C],h[C]=s,S[C]=t,f[C]=s,w[C]=t;for(t=D.next;t!==D;t=t.next)for(var G=0;G<3;++G)s=t.coords[G],s<h[G]&&(h[G]=s,S[G]=t),s>f[G]&&(f[G]=s,w[G]=t);var B=0;if(f[1]-h[1]>f[0]-h[0]&&(B=1),f[2]-h[2]>f[B]-h[B]&&(B=2),h[B]>=f[B]){e[0]=0,e[1]=0,e[2]=1;return}for(c=0,r=S[B],n=w[B],d[0]=r.coords[0]-n.coords[0],d[1]=r.coords[1]-n.coords[1],d[2]=r.coords[2]-n.coords[2],t=D.next;t!==D;t=t.next)x[0]=t.coords[0]-n.coords[0],x[1]=t.coords[1]-n.coords[1],x[2]=t.coords[2]-n.coords[2],g[0]=d[1]*x[2]-d[2]*x[1],g[1]=d[2]*x[0]-d[0]*x[2],g[2]=d[0]*x[1]-d[1]*x[0],l=g[0]*g[0]+g[1]*g[1]+g[2]*g[2],l>c&&(c=l,e[0]=g[0],e[1]=g[1],e[2]=g[2]);c<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(d)]=1)},i.prototype.checkOrientation_=function(){for(var e=this.mesh.fHead,t,r=this.mesh.vHead,n,s=0,l=e.next;l!==e;l=l.next)if(n=l.anEdge,!(n.winding<=0))do s+=(n.Org.s-n.Dst.s)*(n.Org.t+n.Dst.t),n=n.Lnext;while(n!==l.anEdge);if(s<0){for(t=r.next;t!==r;t=t.next)t.t=-t.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var e=this.mesh.vHead,t=[0,0,0],r,n,s=!1;t[0]=this.normal[0],t[1]=this.normal[1],t[2]=this.normal[2],!t[0]&&!t[1]&&!t[2]&&(this.computeNormal_(t),s=!0),r=this.sUnit,n=this.tUnit;var l=this.longAxis_(t);r[l]=0,r[(l+1)%3]=1,r[(l+2)%3]=0,n[l]=0,n[(l+1)%3]=0,n[(l+2)%3]=t[l]>0?1:-1;for(var c=e.next;c!==e;c=c.next)c.s=this.dot_(c.coords,r),c.t=this.dot_(c.coords,n);s&&this.checkOrientation_();for(var f=!0,h=e.next;h!==e;h=h.next)f?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,f=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},i.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},i.prototype.tessellateMonoRegion_=function(e,t){var r,n;if(r=t.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Te.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Te.vertLeq(r.Org,r.Dst);r=r.Lnext);n=r.Lprev;for(var s=void 0;r.Lnext!==n;)if(Te.vertLeq(r.Dst,n.Org)){for(;n.Lnext!==r&&(Te.edgeGoesLeft(n.Lnext)||Te.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)s=e.connect(n.Lnext,n),n=s.Sym;n=n.Lprev}else{for(;n.Lnext!==r&&(Te.edgeGoesRight(r.Lprev)||Te.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=e.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(n.Lnext===r)throw"Mono region invalid";for(;n.Lnext.Lnext!==r;)s=e.connect(n.Lnext,n),n=s.Sym;return!0},i.prototype.tessellateInterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)if(t=r.next,r.inside&&!this.tessellateMonoRegion_(e,r))return!1;return!0},i.prototype.discardExterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)t=r.next,r.inside||e.zapFace(r)},i.prototype.setWindingNumber_=function(e,t,r){for(var n,s=e.eHead.next;s!==e.eHead;s=n)n=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?t:-t:r?e.delete(s):s.winding=0},i.prototype.getNeighbourFace_=function(e){return!e.Rface||!e.Rface.inside?-1:e.Rface.n},i.prototype.outputPolymesh_=function(e,t,r,n){var s,l=0,c=0,f;r>3&&e.mergeConvexFaces(r);for(var h=e.vHead.next;h!==e.vHead;h=h.next)h.n=-1;for(var d=e.fHead.next;d!==e.fHead;d=d.next)if(d.n=-1,!!d.inside){s=d.anEdge,f=0;do{var h=s.Org;h.n===-1&&(h.n=c,c++),f++,s=s.Lnext}while(s!==d.anEdge);if(f>r)throw"Face vertex greater that support polygon";d.n=l,++l}this.elementCount=l,t===Qt.CONNECTED_POLYGONS&&(l*=2),this.elements=[],this.elements.length=l*r,this.vertexCount=c,this.vertices=[],this.vertices.length=c*n,this.vertexIndices=[],this.vertexIndices.length=c;for(var h=e.vHead.next;h!==e.vHead;h=h.next)if(h.n!==-1){var x=h.n*n;this.vertices[x+0]=h.coords[0],this.vertices[x+1]=h.coords[1],n>2&&(this.vertices[x+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var g=0,d=e.fHead.next;d!==e.fHead;d=d.next)if(!!d.inside){s=d.anEdge,f=0;do{var h=s.Org;this.elements[g++]=h.n,f++,s=s.Lnext}while(s!==d.anEdge);for(var w=f;w<r;++w)this.elements[g++]=-1;if(t===Qt.CONNECTED_POLYGONS){s=d.anEdge;do this.elements[g++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==d.anEdge);for(var S=f;S<r;++S)this.elements[g++]=-1}}},i.prototype.outputContours_=function(e,t){var r,n,s=0,l=0;this.vertexCount=0,this.elementCount=0;for(var c=e.fHead.next;c!==e.fHead;c=c.next)if(!!c.inside){n=r=c.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==n);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var f=0,h=0,d=0;s=0;for(var c=e.fHead.next;c!==e.fHead;c=c.next)if(!!c.inside){l=0,n=r=c.anEdge;do this.vertices[f++]=r.Org.coords[0],this.vertices[f++]=r.Org.coords[1],t>2&&(this.vertices[f++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,l++,r=r.Lnext;while(r!==n);this.elements[d++]=s,this.elements[d++]=l,s+=l}},i.prototype.addContour=function(e,t){this.mesh===null&&(this.mesh=new M0),e<2&&(e=2),e>3&&(e=3);for(var r=null,n=0;n<t.length;n+=e)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=t[n+0],r.Org.coords[1]=t[n+1],e>2?r.Org.coords[2]=t[n+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(e,t,r,n,s,l){if(e===void 0&&(e=Pt.ODD),t===void 0&&(t=Qt.POLYGONS),l===void 0&&(l=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=e,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),f2.computeInterior(this,l);var c=this.mesh;return t===Qt.BOUNDARY_CONTOURS?this.setWindingNumber_(c,1,!0):this.tessellateInterior_(c),l&&c.check(),t===Qt.BOUNDARY_CONTOURS?this.outputContours_(c,n):this.outputPolymesh_(c,t,r,n),!0},i}();function wo(i){var e=i.windingRule,t=e===void 0?Pt.ODD:e,r=i.elementType,n=r===void 0?Qt.POLYGONS:r,s=i.polySize,l=s===void 0?3:s,c=i.vertexSize,f=c===void 0?2:c,h=i.normal,d=h===void 0?[0,0,1]:h,x=i.contours,g=x===void 0?[]:x,w=i.strict,S=w===void 0?!0:w,D=i.debug,C=D===void 0?!1:D;if(!g&&S)throw new Error("Contours can't be empty");if(!!g){var G=new h2;i.edgeCreateCallback&&(G.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(G.vertexIdCallback=i.vertexIdCallback);for(var B=0;B<g.length;B++)G.addContour(f||2,g[B]);return G.tesselate(t,n,l,f,d,S),{vertices:G.vertices,vertexIndices:G.vertexIndices,vertexCount:G.vertexCount,elements:G.elements,elementCount:G.elementCount,mesh:C?G.mesh:void 0}}}var Pk=Pt.ODD,Dk=Pt.NONZERO,Bk=Pt.POSITIVE,Gk=Pt.NEGATIVE,jk=Pt.ABS_GEQ_TWO,Ek=Qt.POLYGONS,Rk=Qt.CONNECTED_POLYGONS,zk=Qt.BOUNDARY_CONTOURS;var No=class extends p2{constructor(e,t=12,r=100,n={}){super();this.type="ShapeGeometry";this.windingRule=Pt.ODD;this.elementType=Qt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._drawCount=0,this._shape=e,this._curveSegments=t,this._maxCount=r,this._maxDrawCount=r*3,this._triangulationOptions=Object.assign({windingRule:Pt.ODD,elementType:Qt.POLYGONS,polySize:3,vertexSize:2,strict:!0},n),this._positionAttribute=new Xc(new Float32Array(r*3),3),this._normalAttribute=new Xc(new Float32Array(r*3),3),this._uvAttribute=new Xc(new Float32Array(r*2),2),this._indexAttribute=new Xc(new Uint32Array(r*3),1),this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.updateFromShape()}copy(e){return this._drawCount=e.drawCount,this._maxDrawCount=e._maxDrawCount,this._maxCount=e.maxCount,super.copy(e)}get curveSegments(){return this._curveSegments}set curveSegments(e){this._curveSegments=e,this.updateFromShape()}get drawCount(){return this._drawCount}get maxDrawCount(){return this._maxDrawCount}get maxCount(){return this._maxCount}updateFromShape(){let e=this._shape.extractShapePointsToFlatArray([],this._curveSegments),t=this._shape.shapeHoles.map(f=>f.extractShapePointsToFlatArray([],this._curveSegments)),r,n=!0,s=!0,l,c;for(let f=0,h=e.length/2;f<h;f++){let d=f*2,x=e[d+0],g=e[d+1];if(l!==void 0&&x!==l&&(n=!1),c!==void 0&&g!==c&&(s=!1),l=x,c=g,!n&&!s)break}if(!n&&!s&&(r=wo({contours:[e,...t],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})),this._positionAttribute.array.fill(0),this._normalAttribute.array.fill(0),this._uvAttribute.array.fill(0),this._indexAttribute.array.fill(0),this._drawCount=0,r){let f=1/0,h=-1/0,d=1/0,x=-1/0;for(let S=0,D=r.vertexCount;S<D;S++){let C=S*2,G=r.vertices[C+0],B=r.vertices[C+1];G<f&&(f=G),G>h&&(h=G),B<d&&(d=B),B>x&&(x=B)}let g=h-f,w=x-d;for(let S=0,D=r.vertexCount;S<D;S++){let C=S*2,G=r.vertices[C+0],B=r.vertices[C+1],P=(G-f)/g,W=(B-d)/w;this._positionAttribute.setXYZ(S,G,B,0),this._normalAttribute.setXYZ(S,0,0,1),this._uvAttribute.setXY(S,P,W)}for(let S=0,D=r.elementCount;S<D;S++){let C=S*3,G=r.elements[C+0],B=r.elements[C+1],P=r.elements[C+2];this._indexAttribute.setX(C+0,G),this._indexAttribute.setX(C+1,B),this._indexAttribute.setX(C+2,P),this._drawCount+=3}}return this._positionAttribute.needsUpdate=!0,this._normalAttribute.needsUpdate=!0,this._uvAttribute.needsUpdate=!0,this._indexAttribute.needsUpdate=!0,this.setDrawRange(0,this._drawCount),this._drawCount>this._maxDrawCount}clone(){let e=new No(this._shape,this._curveSegments,this._maxCount);return e.userData=sa(this.userData),e}};import{BufferAttribute as Qc,BufferGeometry as d2}from"three";var Yc=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let r=e*Yc.eSize;this.buffer=new ArrayBuffer(r);let n=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*n,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*n,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*n,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let r=e*Yc.eSize,n=new ArrayBuffer(r),s=Float32Array.BYTES_PER_ELEMENT,l=0,c=new Float32Array(n,l*s,3*e);l+=3*e;let f=new Float32Array(n,l*s,3*e);l+=3*e;let h=new Float32Array(n,l*s,2*e);c.set(this.positions.slice(0,this.size*3)),f.set(this.normals.slice(0,this.size*3)),h.set(this.uvs.slice(0,this.size*2)),this.buffer=n,this.positions=c,this.normals=f,this.uvs=h,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let n=this.capacity;for(;t>n;)n*=2;this.realloc(n)}let r=this.size;return this.size=t,r}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Zc=Yc;Zc.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Fh=(i,e)=>([t,r])=>(r<t&&(r+=e),(i>=t?i:i+e)<=r),wa=class extends d2{constructor(e,t,r=0,n=12,s=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._bevel=r,this._curveSegments=n,this._bevelSegmentsInput=s,r<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(r,t/2-1e-12),this._bevelSegments=Math.floor(s));let l=this._shape.extractShapePointsToFlatArray([],n),c=this._shape.shapeHoles.map(q=>{let E=q.extractShapePointsToFlatArray([],n),b=[];for(let R=E.length-1;R>=1;R-=2){let T=E[R-1],z=E[R-0];b.push(T,z)}return b}),f=wo({windingRule:Pt.ODD,elementType:Qt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[l]}),h=wo({windingRule:Pt.ODD,elementType:Qt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]});if(!f)throw new Error("error generating geometry");let d=f.elementCount;if(h){f.elementCount+=h.elementCount;for(let q=0;q<h.elements.length;q++){let E=h.elements[q],b=q%2==0?f.vertexCount:0;f.elements.push(E+b)}for(let q=0;q<h.vertexIndices.length;q++){let E=h.vertexIndices[q],b=f.vertexCount;f.vertexIndices.push(E+b)}for(let q=0;q<h.vertices.length;q++){let E=h.vertices[q];f.vertices.push(E)}}let x=1/0,g=-1/0,w=1/0,S=-1/0;for(let q=0,E=f.vertexCount;q<E;q++){let b=q*2,R=f.vertices[b+0],T=f.vertices[b+1];R<x&&(x=R),R>g&&(g=R),T<w&&(w=T),T>S&&(S=T)}this._minX=x,this._minY=w,this._width=g-x,this._height=S-w;let D=f.vertexCount*2*(2+this._bevelSegments);this._buffer=new Zc(D);let C=[],G=[];for(let q=f.elementCount-1;q>=0;q--){let E=q>=d,b=q*2,R=f.elements[b+0],T=f.elements[b+1],z=R+T,A={start:R,count:T,normals:[],continuous:[],concave:[]},$=R,he=z-1,re=R+1,Ne=this._shape.roundedCurves.length;do{let k=$-R,H=f.vertices[he*2+0],_=f.vertices[he*2+1],J=f.vertices[$*2+0],ee=f.vertices[$*2+1],oe=f.vertices[re*2+0],se=f.vertices[re*2+1],ce=J-H,ue=ee-_,K=Math.sqrt(ce*ce+ue*ue);ce/=K,ue/=K;let ae=J-oe,ne=ee-se,Ce=Math.sqrt(ae*ae+ne*ne);ae/=Ce,ne/=Ce,A.normals[k*2+0]=-ne,A.normals[k*2+1]=ae,A.concave[k]=ce*ne-ue*ae>0;let Y=f.vertexIndices[$];if(Array.isArray(Y))A.continuous[k]=!1;else{let[le,pe]=this._shape.getCurveIndexFromVertexId(Y-1,!0);if(pe>0&&pe<1)A.continuous[k]=!0;else{let xe=pe===1?le+1:le-1;xe=(xe+Ne)%Ne;let _e=pe===1?0:1,de=this._shape.roundedCurves[le].getTangent(pe),we=this._shape.roundedCurves[xe].getTangent(_e);A.continuous[k]=de.dot(we)>.95}}E&&(A.normals[k*2+0]*=-1,A.normals[k*2+1]*=-1),[he,$,re]=[$,re,re+1],re>=z&&(re-=T)}while(re!==R+1);let ye=[];ye.push({bevelI:0,angle:0,size:0,boundary:{vertices:f.vertices.slice(R*2,z*2),vertexCount:T,vertexIndices:new Array(T).fill(!0).map((k,H)=>[H,H]),elements:[0,T],elementCount:1,mesh:null},reverseMap:[],insetPoints:f.vertices.slice(R*2,z*2)});for(let k=1;k<=this._bevelSegments;k++){let H=k/this._bevelSegments*Math.PI/2,_=(1-Math.cos(H))*this._bevelSize,J=[],ee=[],oe=[],se=[],ce=0;for(let K=0;K<T;K++){let ae=K*2,ne=(K-1+T)%T*2,Ce=f.vertices[A.start*2+ae+0],Y=f.vertices[A.start*2+ae+1],le=-A.normals[ne+0]*_,pe=-A.normals[ne+1]*_,xe=-A.normals[ae+0]*_,_e=-A.normals[ae+1]*_;if(A.concave[K]||!A.concave[K]&&E){let de=Math.atan2(pe,le),we=Math.atan2(_e,xe);we>de&&(we-=Math.PI*2);let Ve=we-de;if(A.continuous[K]||E){let Ge=de+Ve/2,Qe=Math.cos(Ge)*_,bt=Math.sin(Ge)*_;J[2*ce+0]=Ce+Qe*(E?-1:1),J[2*ce+1]=Y+bt*(E?-1:1),se[ce]=K,ce++}else{let Ge=Math.max(1,Math.floor(n/4*Math.abs(Ve)/Math.PI));for(let Qe=0;Qe<=Ge;Qe++){let bt=de+Ve*(Qe/Ge),Lt=Math.cos(bt)*_,At=Math.sin(bt)*_;J[2*ce+0]=Ce+Lt,J[2*ce+1]=Y+At,se[ce]=K,ce++}}}else J[2*ce+0]=Ce+le,J[2*ce+1]=Y+pe,se[ce]=K,ee[K]=ce,ce++,J[2*ce+0]=Ce,J[2*ce+1]=Y,se[ce]=K,ce++,J[2*ce+0]=Ce+xe,J[2*ce+1]=Y+_e,se[ce]=K,oe[K]=ce,ce++}let ue=wo({windingRule:Pt.POSITIVE,elementType:Qt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[J],edgeCreateCallback:K=>{let ne=K.Org.idx,Ce=se[ne],Y=se[(ne+1)%se.length];K.idx=[Ce,Y],K.Sym.idx=[Y,Ce]},vertexIdCallback:K=>{let ae=K.Lprev.idx;return[ae?ae[1]:0,K.idx[0]]}});if(!ue)throw console.log("Error"),new Error(`error generating bevel geometry for ${k}'th loop`);if(!ue.vertexCount)break;for(let K=0;K<ue.vertexIndices.length;K++){let[ae,ne]=ue.vertexIndices[K];if(ae===ne)continue;let Ce=ne;ne<ae&&(Ce+=T);for(let Y=ae;Y<Ce;Y++){let le=Y%T,pe=(Y+1)%T;if(!A.continuous[le]||!A.continuous[pe]){ue.vertexIndices[K]=[ae,le],ue.vertexIndices.splice(K+1,0,[pe,ne]),ue.vertices.splice((K+1)*2,0,ue.vertices[K*2],ue.vertices[K*2+1]);break}}}ye.push({bevelI:k,angle:H,size:_,boundary:ue,reverseMap:se,insetPoints:J})}let Me=(k,H,_)=>{let J=0,ee=k.boundary.vertexIndices.length;for(;J<ee&&_(k.boundary.vertexIndices[H]);)H=(H+1)%ee,J++;return J},Fe=C.length;for(let k=1;k<ye.length;k++){let H=ye[k-1],_=ye[k],J=H.boundary.vertexIndices.length,ee=_.boundary.vertexIndices.length;if(!J||!ee)break;let oe=A.concave.length,se=0,ce=Fh(se,T);for(;!H.boundary.vertexIndices.filter(ce).length||!_.boundary.vertexIndices.filter(ce).length;)se++,ce=Fh(se,T);let ue=H.boundary.vertexIndices.findIndex(ce),K=_.boundary.vertexIndices.findIndex(ce);do ue=(ue+1)%J;while(ce(H.boundary.vertexIndices[ue]));do K=(K+1)%ee;while(ce(_.boundary.vertexIndices[K]));se=(se+1)%T;let ae=se,ne=this.buildBevelVert(A,H,(ue-1+J)%J),Ce=this.buildBevelVert(A,_,(K-1+ee)%ee),Y=ne,le=Ce,pe,xe,_e=!1;do{ce=Fh(se,T);let de=Me(H,ue,ce),we=Me(_,K,ce),Ve=_e;if(_e=!1,de&&!we){for(let Ge=0;Ge<de;Ge++)pe=this.buildBevelVert(A,H,(ue+Ge)%J,Ge/(de-1)),C.push(Y.topN,pe.topP,le.topN),C.push(pe.bottomP,Y.bottomN,le.bottomN),Y=pe;_e=!0}else if(!de&&we)for(let Ge=0;Ge<we;Ge++)xe=this.buildBevelVert(A,_,(K+Ge)%ee,Ge/(we-1)),C.push(le.topN,Y.topP,xe.topP),C.push(Y.bottomP,le.bottomN,xe.bottomP),le=xe;else if(de&&we)if(pe=this.buildBevelVert(A,H,ue,0),xe=this.buildBevelVert(A,_,K,0),Ve?(C.push(Y.topN,xe.topP,le.topN),C.push(Y.topN,pe.topP,xe.topP),C.push(xe.bottomP,Y.bottomN,le.bottomN),C.push(pe.bottomP,Y.bottomN,xe.bottomP)):(C.push(Y.topN,pe.topP,le.topN),C.push(le.topN,pe.topP,xe.topP),C.push(pe.bottomP,Y.bottomN,le.bottomN),C.push(pe.bottomP,le.bottomN,xe.bottomP)),Y=pe,le=xe,de===we)for(let Ge=1;Ge<de;Ge++)pe=this.buildBevelVert(A,H,(ue+Ge)%J,Ge/(de-1)),xe=this.buildBevelVert(A,_,(K+Ge)%ee,Ge/(we-1)),C.push(Y.topN,pe.topP,le.topN),C.push(le.topN,pe.topP,xe.topP),C.push(pe.bottomP,Y.bottomN,le.bottomN),C.push(pe.bottomP,le.bottomN,xe.bottomP),Y=pe,le=xe;else if(de>we){let Ge=de/we,Qe=0;for(let bt=1;bt<de;bt++)pe=this.buildBevelVert(A,H,(ue+bt)%J,bt/(de-1)),C.push(Y.topN,pe.topP,le.topN),C.push(pe.bottomP,Y.bottomN,le.bottomN),Y=pe,bt>(Qe+1)*Ge&&(Qe++,xe=this.buildBevelVert(A,_,(K+Qe)%ee,Qe/(we-1)),C.push(le.topN,pe.topP,xe.topP),C.push(pe.bottomP,le.bottomN,xe.bottomP),le=xe)}else{let Ge=we/de,Qe=0;for(let bt=1;bt<we;bt++)xe=this.buildBevelVert(A,_,(K+bt)%ee,bt/(we-1)),C.push(le.topN,pe.topP,xe.topP),C.push(pe.bottomP,le.bottomN,xe.bottomP),le=xe,bt>(Qe+1)*Ge&&(Qe++,pe=this.buildBevelVert(A,H,(ue+Qe)%J,Qe/(de-1)),C.push(Y.topN,pe.topP,le.topN),C.push(pe.bottomP,Y.bottomN,le.bottomN),Y=pe)}ue=(ue+de)%J,K=(K+we)%ee,se=(se+1)%oe}while(se!==ae)}{let k=ye[0];for(let H=0,_=k.boundary.vertexCount;H<_;H++){let J=this.buildBevelVert(A,k,H),ee=this.buildBevelVert(A,k,(H+1)%_);C.push(ee.topP,J.topN,J.bottomN),C.push(ee.topP,J.bottomN,ee.bottomP)}}if(E){let k=[];for(let H=C.length-1;H>=Fe+2;H-=3){let _=C[H-2],J=C[H-1],ee=C[H-0];k.push(ee,J,_)}C.splice(Fe,C.length-Fe,...k)}if(E){let k=[];for(let H=ye[ye.length-1].boundary.vertices.length-1;H>=1;H-=2){let _=ye[ye.length-1].boundary.vertices[H-1],J=ye[ye.length-1].boundary.vertices[H-0];k.push(_,J)}G.push(k)}if(!E){let k=ye[ye.length-1],H=wo({windingRule:ye.length>1?Pt.POSITIVE:Pt.ODD,elementType:Qt.POLYGONS,vertexSize:2,strict:!0,contours:[k.insetPoints,...G]});if(!H)throw new Error("Error generating geometry for surface");for(let _=0;_<H.elementCount*3;_+=3){let J=this.buildSurfaceVert(H,H.elements[_+0]),ee=this.buildSurfaceVert(H,H.elements[_+1]),oe=this.buildSurfaceVert(H,H.elements[_+2]);C.push(J.top,ee.top,oe.top),C.push(oe.bottom,ee.bottom,J.bottom)}}this.vertexCache={}}this._buffer.shrink();let B=new Qc(Uint32Array.from(C),1),P=new Qc(this._buffer.positions,3),W=new Qc(this._buffer.normals,3),M=new Qc(this._buffer.uvs,2);P.needsUpdate=!0,W.needsUpdate=!0,M.needsUpdate=!0,B.needsUpdate=!0,this.setAttribute("position",P),this.setAttribute("normal",W),this.setAttribute("uv",M),this.setIndex(B)}buildSurfaceVert(e,t){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let n=e.vertices[t*2+0],s=e.vertices[t*2+1],l=(n-this._minX)/this._width,c=(s-this._minY)/this._height,f=this._buffer.get(2),h=f*3,d=f*2,x={top:f+0,bottom:f+1};return this._buffer.positions[h+0]=n,this._buffer.positions[h+1]=s,this._buffer.positions[h+2]=this._depth,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=c,this._buffer.positions[h+3]=n,this._buffer.positions[h+4]=s,this._buffer.positions[h+5]=0,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=c,this.vertexCache[r]=x,x}buildBevelVert(e,t,r,n=1){let s=`${t.bevelI}:${r}`;if(s in this.vertexCache)return this.vertexCache[s];let[l,c]=t.boundary.vertexIndices[r],f,h,d,x;l!==c?(h=l,f=c,x=!1,d=e.continuous[h]&&e.continuous[f]):(f=l,h=(f-1+e.count)%e.count,x=e.concave[f]&&t.bevelI>0,d=e.continuous[f]||x);let g=Math.cos(t.angle),w=Math.sin(t.angle),S=r*2,D=f*2,C=h*2,G=t.boundary.vertices[S+0],B=t.boundary.vertices[S+1],P=(1-w)*this._bevelSize,W=(G-this._minX)/this._width,M=(B-this._minY)/this._height,q=e.normals[D+0],E=e.normals[D+1],b=e.normals[C+0],R=e.normals[C+1];if(x){let he=b-q,re=R-E;q=q+he*(1-n),E=E+re*(1-n);let Ne=Math.sqrt(q*q+E*E);q/=Ne,E/=Ne}let T=this._buffer.get(d?2:4),z=T*3,A=T*2,$={i:r,fi:f,topP:T+0,topN:T+0,bottomP:T+1,bottomN:T+1};return this._buffer.positions[z+0]=G,this._buffer.positions[z+1]=B,this._buffer.positions[z+2]=this._depth-P,this._buffer.normals[z+0]=q*g,this._buffer.normals[z+1]=E*g,this._buffer.normals[z+2]=w,this._buffer.uvs[A+0]=W,this._buffer.uvs[A+1]=M,this._buffer.positions[z+3]=G,this._buffer.positions[z+4]=B,this._buffer.positions[z+5]=P,this._buffer.normals[z+3]=q*g,this._buffer.normals[z+4]=E*g,this._buffer.normals[z+5]=-w,this._buffer.uvs[A+2]=M,this._buffer.uvs[A+3]=W,d||(T+=2,z+=6,A+=4,$.topP=T+0,$.bottomP=T+1,this._buffer.positions[z+0]=G,this._buffer.positions[z+1]=B,this._buffer.positions[z+2]=this._depth-P,this._buffer.normals[z+0]=b*g,this._buffer.normals[z+1]=R*g,this._buffer.normals[z+2]=w,this._buffer.uvs[A+0]=W,this._buffer.uvs[A+1]=M,this._buffer.positions[z+3]=G,this._buffer.positions[z+4]=B,this._buffer.positions[z+5]=P,this._buffer.normals[z+3]=b*g,this._buffer.normals[z+4]=R*g,this._buffer.normals[z+5]=-w,this._buffer.uvs[A+2]=M,this._buffer.uvs[A+3]=W),this.vertexCache[s]=$,$}clone(){let e=new wa(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=sa(this.userData),e}};var ur=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var h,d,x,g,w,S,D;let t=Object.assign({},(h=e==null?void 0:e.parameters)!=null?h:{width:100,subdivisions:40,roundness:0,extrudeDepth:0,surfaceMaxCount:100,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(t.width),n=Math.abs((d=t.height)!=null?d:t.width),s=Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(x=t.depth)!=null?x:0),l=(g=i.shape)!=null?g:e==null?void 0:e.shape,c=(w=l==null?void 0:l.roundness)!=null?w:t.roundness;l!==void 0&&(l instanceof st?(l.width!==r||l.height!==n)&&l.applySize(r,n):l=new st(r,n).fromJSON(l),((S=i.parameters)==null?void 0:S.roundness)!==void 0&&((D=i.parameters)==null?void 0:D.roundness)>0&&l.update(!1));let f=l!=null?l:new st(r,n);return{parameters:Object.assign(t,{width:r,height:n,depth:s,extrudeDepth:s,roundness:c}),shape:f}}static build(i){let{extrudeDepth:e,extrudeBevelSize:t,extrudeBevelSegments:r,subdivisions:n,roundness:s,surfaceMaxCount:l}=i.parameters;i.shape.roundness=s;let c;return e<=0?c=new No(i.shape,n,l):c=new wa(i.shape,e,t,n,r),Object.assign(c,{userData:fe(U({},i),{type:"VectorGeometry"})})}};import{MathUtils as D0,Vector2 as B0}from"three";var G0=Math.PI*2,j0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,s,l;let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1e3},i.parameters);return{shape:i.shape&&i.shape instanceof st?i.shape:new st,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(l=t.depth)!=null?l:0)})}}static build(i){let{width:e,height:t,spikes:r,angle:n,innerRadius:s,depth:l,extrudeBevelSize:c,extrudeBevelSegments:f,surfaceMaxCount:h}=i.parameters,d=i.shape,x=e*.5,g=t*.5,w=m2(d,x,g,n*Math.PI/180,r,s);d.isClosed=!0,d.update();let S=ur.create({shape:d,parameters:{subdivisions:w,surfaceMaxCount:h,depth:l,extrudeBevelSize:c,extrudeBevelSegments:f}});return Object.assign(S,{userData:fe(U({},i),{type:"EllipseGeometry"})})}};function m2(i,e,t,r,n,s){if(r>=G0)return n>30||n%4==0?(y2(i,e,t,s),Math.round(n/4)):E0(i,r,n,e,t,s);let l={x:0,y:t},c=r+Math.PI*.5,f={x:Math.cos(c)*e,y:Math.sin(c)*t},h=I0({px:l.x,py:l.y,cx:f.x,cy:f.y,rx:e,ry:t,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%h.length==0?g2(i,l.x,l.y,h,n,e,t,s):E0(i,r,n,e,t,s)}function g2(i,e,t,r,n,s,l,c){let f=Math.round(n/r.length);i.addPoint(Cs(e,t));for(let h=0,d=r.length;h<d;h++){let x=r[h],g=i.points[h],w=Cs(x.x,x.y);g.controls[1].position.set(x.x1,x.y1),w.controls[0].position.set(x.x2,x.y2),i.addPoint(w)}return c>0?R0(i,s,l,c):i.addPoint(Cs(0,0)),f}function E0(i,e,t,r,n,s){let l=-e/t;for(let c=0;c<=t;c++){let f=l*c,h=Math.sin(f)*r,d=Math.cos(f)*n;i.addPoint(Cs(h,d))}return e<G0?s>0?R0(i,r,n,s):i.addPoint(Cs(0,0)):(i.removePoint(i.points[i.points.length-1]),s>0&&z0(i,r,n,s)),1}function y2(i,e,t,r=0,n=0,s=0){let l=.5522847498,c=e*l,f=t*l;i.addPoint(eu(n-e,s,n-e,s-f,n-e,s+f)),i.addPoint(eu(n,s+t,n-c,s+t,n+c,s+t)),i.addPoint(eu(n+e,s,n+e,s+f,n+e,s-f)),i.addPoint(eu(n,s-t,n+c,s-t,n-c,s-t)),r>0&&z0(i,e,t,r)}function Cs(i,e){return new Kn(D0.generateUUID(),new B0(i,e))}function eu(i,e,t,r,n,s){let l=Cs(i,e);return l.controls[0].position.set(t,r),l.controls[1].position.set(n,s),l}function R0(i,e,t,r){F0(i,e,t,r).forEach(s=>i.addPoint(s))}function z0(i,e,t,r){let n=F0(i,e,t,r),s=new st;n.forEach(l=>s.addPoint(l)),s.isClosed=!0,i.shapeHoles.push(s)}function F0(i,e,t,r){let n=r*e/100,s=n*(Math.abs(t)/Math.abs(e)),l=new B0(n/e,s/t),c=i.points.map(f=>{let h=f.clone();return h.uuid=D0.generateUUID(),h}).reverse();return c.forEach(f=>{f.position.multiply(l);let h=f.controls[0].position.clone().multiply(l),d=f.controls[1].position.clone().multiply(l);f.controls[0].position.copy(d),f.controls[1].position.copy(h)}),c}import{BufferGeometry as x2,Float32BufferAttribute as Vh,Vector3 as V0}from"three";var U0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var c,f,h;let t=Object.assign({},(c=e==null?void 0:e.parameters)!=null?c:{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(t.width),n=Math.abs((f=t.height)!=null?f:r),s=Math.abs((h=t.depth)!=null?h:r),l=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(t,{width:r,height:n,depth:s,radius:l,segments:Math.round(t.segments),pathSegments:Math.round(t.pathSegments),cornerSegments:Math.round(t.cornerSegments)})}}static build(i){let{width:e,height:t,depth:r,radius:n,revolutions:s,segments:l,pathRadius:c,pathType:f,pathSegments:h,cornerRadius:d,cornerSegments:x}=i.parameters,g=new tu(!1,e,t,r,n,s,l,c,f,h,d,x);return Object.assign(g,{userData:fe(U({},i),{type:"HelixGeometry"})})}},tu=class extends x2{constructor(e=!0,t=1,r=1,n=1,s=1,l=1,c=1,f=1,h=1,d=1,x=1,g=1){super();let w=e&&l===1;w&&(g=0),x>100&&(x=100);let S=()=>new V0,D=new V0,C=S(),G=S(),B=S(),P,W,M,q,E,b,R,T,z=S(),A=S(),$=S(),he=S(),re=S(),Ne=S(),ye=S(),Me=S(),Fe=r-2*f+.001,k=Fe/l,H=Math.ceil(c*l),_=H+1,J=Fe/H,ee=-Fe/2,oe=d+1,se=2*Math.PI/d,ce=Math.PI/2/g,ue=.01,K=Math.min((1-x/100)*f,f-ue),ae=f-K,ne=0,Ce=2,Y=g*Ce+Ce,le=oe*Y/Ce,pe=le+oe*_,xe=oe*(_+Y),[_e,de,we]=[3,3,2].map(dt=>Array(xe*dt).fill(0)),Ve=[],Ge=s-f;function Qe(dt,Wt){let ar=Math.PI/2;b=Wt*J,T=2*Math.PI*(b%k)/k+ar,b+=ee,R=Math.sin(T)*Ge,E=Math.cos(T)*Ge,e?dt.set(E,R,b):dt.set(E,b,R)}Qe(D,-1e-10),Qe(C,0),z.copy(D),Qe(D,1);let bt=D.distanceTo(C),Lt=ae+K,At=bt*H+2*Lt,sr=K,Ur=At-Lt;for(let dt=0;dt<=H;dt++){Qe(G,dt),Me.subVectors(G,z).normalize(),z.copy(G),Ne.copy(G).setComponent(+e+1,0).normalize(),ye.crossVectors(Me,Ne).normalize();let Wt=dt===0,ar=dt===H,Ao=Wt?3*Math.PI/2:ce,Oo=Wt?sr:Ur,Po=Wt?oe:pe,ro=Wt?0:xe-oe,no=Me.clone().multiplyScalar(Wt?-ae:ae).add(G),Do=Me.clone().multiplyScalar(Wt?-1:1).normalize();for(let Mr=0;Mr<oe;Mr++){let io=Mr*se;if(A.addVectors(D.copy(Ne).multiplyScalar(f*Math.cos(io)),C.copy(ye).multiplyScalar(f*Math.sin(io))),$.copy(A).normalize(),Wt||ar){w||(ne=ro+Mr,[0,1,2].forEach(Jt=>{_e[ne*3+Jt]=no.getComponent(Jt),de[ne*3+Jt]=Do.getComponent(Jt)}),we[ne*2]=+ar,we[ne*2+1]=Mr/d),C.copy($).multiplyScalar(K),B.addVectors(G,C);for(let Jt=0;Jt<g;Jt++){let ti=Jt*ce+Ao;he.addVectors(D.copy(Me).multiplyScalar(ae*Math.sin(ti)),C.copy($).multiplyScalar(ae*Math.cos(ti))),re.copy(he).normalize(),C.addVectors(B,he),he.normalize(),ne=Po+Jt*oe+Mr,[0,1,2].forEach(Ee=>{_e[ne*3+Ee]=C.getComponent(Ee),de[ne*3+Ee]=re.getComponent(Ee)});let Bo=+Wt+Math.sin(ti);we[ne*2]=(Oo+ae*Bo)/At,we[ne*2+1]=Mr/d}}C.addVectors(G,A),ne=le+dt*oe+Mr,[0,1,2].forEach(Jt=>{_e[ne*3+Jt]=C.getComponent(Jt),de[ne*3+Jt]=$.getComponent(Jt)}),we[ne*2]=(Lt+dt*bt)/At,we[ne*2+1]=Mr/d}}let Ht=_+2*g+Ce,kr=1,[wn,Nn]=w?[kr,kr+_-1]:[0,Ht-1];for(let dt=wn;dt<=Nn-1;dt++){let Wt=w&&dt===Nn-1;for(let ar=0;ar<oe-1;ar++)P=dt*oe+ar,W=P+1,M=(Wt?ar:P)+oe,q=(Wt?ar+1:W)+oe,dt===0?Ve.push(W,q,M):dt===Ht-2?Ve.push(P,W,M):Ve.push(P,W,M,W,q,M)}this.setIndex(Ve),this.setAttribute("position",new Vh(_e,3)),this.setAttribute("normal",new Vh(de,3)),this.setAttribute("uv",new Vh(we,2))}};import{IcosahedronBufferGeometry as v2}from"three";var k0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,height:t,depth:r,detail:n,corner:s,cornerSides:l}=i.parameters,c=n===0&&s!==0?new ru(e*.5,s,l):new v2(e*.5,n);return c.scale(1,t/e,r/e),Object.assign(c,{userData:fe(U({},i),{type:"IcosahedronGeometry"})})}},ru=class extends So{constructor(e=1,t=.2,r=4){let n=(1+Math.sqrt(5))/2,s=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],l=[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],c="IcosahedronGeometry";super(s,l,c,e,t,r);this.type=c}static fromJSON(e){return new ru(e.radius,e.corner,e.cornerSides)}};import{LatheBufferGeometry as b2,Shape as S2}from"three";var H0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s,l,c;((n=(r=i.parameters)==null?void 0:r.points)!=null?n:[]).forEach(f=>{Array.isArray(f)&&(f.x=f[0],f.y=f[1])});let t=Object.assign({},(s=e==null?void 0:e.parameters)!=null?s:{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((l=t.height)!=null?l:t.width),depth:Math.abs((c=t.depth)!=null?c:t.width)})}}static build(i){let{points:e,segments:t,verticalSegments:r}=i.parameters,n=new S2;n.moveTo(e[0].x,e[0].y),n.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let s=new b2(n.extractPoints(r).shape,t);return s.rotateZ(Math.PI),Object.assign(s,{userData:fe(U({},i),{type:"LatheGeometry"})})}};import{BufferGeometry as q0,BufferGeometryLoader as I2,Vector3 as M2,BoxBufferGeometry as $0}from"three";import{BufferGeometry as w2,Vector2 as Uh,Vector3 as W0}from"three";import{Geometry as N2,Face3 as C2}from"three/examples/jsm/deprecated/Geometry.js";var L2=["a","b","c"];function _2(i,e){switch(e){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function kh(i,e,t){let r=Math.min(i,e),n=Math.max(i,e),s=r+"_"+n;return t.get(s)}function Hh(i,e,t,r,n,s){let l=Math.min(i,e),c=Math.max(i,e),f=l+"_"+c,h;if(r.has(f))h=r.get(f);else{let d=t[l],x=t[c];h={a:d,b:x,newEdge:null,faces:[]},r.set(f,h)}h.faces.push(n),s[i].edges.push(h),s[e].edges.push(h)}function T2(i,e,t,r){let n,s,l;for(n=0,s=i.length;n<s;n++)t[n]={edges:[]};for(n=0,s=e.length;n<s;n++)l=e[n],Hh(l.a,l.b,i,r,l,t),Hh(l.b,l.c,i,r,l,t),Hh(l.c,l.a,i,r,l,t)}function nu(i,e,t,r,n){i.push(new C2(e,t,r,void 0,void 0,n))}function Ls(i,e){return Math.abs(e-i)/2+Math.min(i,e)}function iu(i,e,t,r){i.push([e.clone(),t.clone(),r.clone()])}var Wh=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof w2?e=new N2().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new W0,r,n,s,l,c,f=e.vertices,h=e.faces,d=e.faceVertexUvs[0],x=d!==void 0&&d.length>0,g=[],w=new Map;T2(f,h,g,w);let S=[],D,C,G,B,P,W,M;for(let ue of Array.from(w.keys())){for(C=w.get(ue),G=new W0,P=3/8,W=1/8,M=C.faces.length,M!=2&&(P=.5,W=0,M!=1),G.addVectors(C.a,C.b).multiplyScalar(P),t.set(0,0,0),l=0;l<M;l++){for(B=C.faces[l],c=0;c<3&&(D=f[_2(B,L2[c])],!(D!==C.a&&D!==C.b));c++);D&&t.add(D)}t.multiplyScalar(W),G.add(t),C.newEdge=S.length,S.push(G)}let q,E,b,R,T,z,A,$=[];for(n=0,s=f.length;n<s;n++){for(z=f[n],T=g[n].edges,r=T.length,r==3?q=3/16:r>3&&(q=3/(8*r)),E=1-r*Number(q),b=q,r<=2&&(r==2?(E=3/4,b=1/8):r==1||r==0),A=z.clone().multiplyScalar(E),t.set(0,0,0),l=0;l<r;l++)R=T[l],D=R.a!==z?R.a:R.b,t.add(D);t.multiplyScalar(Number(b)),A.add(t),$.push(A)}let he=$.concat(S),re=$.length,Ne,ye,Me,Fe=[],k=[],H,_,J,ee,oe=new Uh,se=new Uh,ce=new Uh;for(n=0,s=h.length;n<s;n++)B=h[n],Ne=Number(kh(B.a,B.b,w).newEdge)+re,ye=Number(kh(B.b,B.c,w).newEdge)+re,Me=Number(kh(B.c,B.a,w).newEdge)+re,nu(Fe,Ne,ye,Me,B.materialIndex),nu(Fe,B.a,Ne,Me,B.materialIndex),nu(Fe,B.b,ye,Ne,B.materialIndex),nu(Fe,B.c,Me,ye,B.materialIndex),x&&(H=d[n],_=H[0],J=H[1],ee=H[2],oe.set(Ls(_.x,J.x),Ls(_.y,J.y)),se.set(Ls(J.x,ee.x),Ls(J.y,ee.y)),ce.set(Ls(_.x,ee.x),Ls(_.y,ee.y)),iu(k,oe,se,ce),iu(k,_,oe,ce),iu(k,J,se,oe),iu(k,ee,ce,se));e.vertices=he,e.faces=Fe,x&&(e.faceVertexUvs[0]=k)}};var er=new M2,J0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var s,l;let t=(l=(s=i.geometry)!=null?s:e==null?void 0:e.geometry)!=null?l:new q0().copy(new $0(100,100,100)),r;e===void 0?(t.computeBoundingBox(),t.boundingBox.getSize(er),r={width:er.x,height:er.y,depth:er.z,subdivisions:0}):r=e.parameters;let n=U(U({},r),i.parameters);return{parameters:{width:Math.abs(n.width),height:Math.abs(n.height),depth:Math.abs(n.depth),subdivisions:Math.abs(n.subdivisions)},geometry:t}}static build(i){var f;let{width:e,height:t,depth:r,subdivisions:n}=i.parameters,s=(f=i.geometry)!=null?f:new q0().copy(new $0(100,100,100)),l=s.userData.parameters;l===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(er)):er.set(l.width,l.height,l.depth),(e!==er.x||t!==er.y||r!==er.z)&&s.scale(er.x===0?1:e/er.x,er.y===0?1:t/er.y,er.z===0?1:r/er.z);let c=s.originalGeometry;return n>0?(c===void 0||(l==null?void 0:l.subdivisions)!==n)&&(c===void 0&&(c=s),s=new Wh(n).modify(c).toBufferGeometry()):(c!==void 0&&(s=c),c=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()),c!==void 0&&Object.assign(s,{originalGeometry:c}),delete i.geometry,Object.assign(s,{userData:fe(U({},i),{type:"NonParametricGeometry"})})}static loadFromUrl(i,e,t){new I2(t).load(i,n=>{let s=this.normalizeInputs({geometry:n});n.boundingBox.getSize(er);let l=100/er.x;Object.assign(s.parameters,{width:100,height:er.y*l,depth:er.z*l}),e(this.build(s))})}};var K0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,s,l,c;let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof st?i.shape:new st,parameters:Object.assign(t,{surfaceMaxCount:((s=t.surfaceMaxCount)!=null?s:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((l=t.height)!=null?l:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(c=t.depth)!=null?c:0)})}}static build(i){let{width:e,height:t,spikes:r,cornerRadius:n,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,surfaceMaxCount:f}=i.parameters,h=i.shape,d=e*.5,x=t*.5,g=0,w=0,S=2*Math.PI/r;for(let C=0;C<r;C++){let G=S*C,B=g+Math.sin(G)*d,P=w+Math.cos(G)*x;h.addPoint(h.createPoint(B,P))}h.isClosed=!0;for(let C=0,G=h.points.length;C<G;C++)h.points[C].roundness=n;h.roundness=n,h.update();let D=ur.create({shape:h,parameters:{surfaceMaxCount:f,roundness:n,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(D,{userData:fe(U({},i),{type:"PolygonGeometry"})})}};import{BufferGeometry as A2,Float32BufferAttribute as qh,Vector2 as Xn,Vector3 as or}from"three";var X0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,height:t,depth:r,radialSegments:n,heightSegments:s,openEnded:l,cornerRadius:c,cornerSegments:f}=i.parameters,h=new Z0(e*.5,t,n,s,l,c,f);return h.scale(1,1,r/e),Object.assign(h,{userData:fe(U({},i),{type:"PyramidGeometry"})})}};function Na(i,e,t){t.x=i.x*e.x,t.y=i.y,t.z=i.x*e.y}function $h(i,e,t,r,n,s){let l=e.clone().sub(i),c=t.clone().sub(i),f=l.angleTo(c);if(l.normalize(),c.normalize(),r===n){let h=l.add(c).normalize();s.copy(i).addScaledVector(h,r/Math.sin(f/2))}else{let h=l.angleTo(c);s.copy(i),s.addScaledVector(l,n/Math.sin(h)),s.addScaledVector(c,r/Math.sin(h))}}function O2(i,e,t){let r=i.clone().sub(e),n=t.clone().sub(e);return r.projectOnVector(n),r.add(e)}var Z0=class extends A2{constructor(e=.5,t=1,r=4,n=1,s=!1,l=0,c=4){super();r=Math.floor(Math.max(3,r)),n=Math.floor(n),c=Math.floor(c);let f=[],h=[],d=[],x=[],g=0,w=t/2,S=Math.PI/r,D=e*Math.cos(Math.PI/r),C=2*Math.PI/r,G=(r-2)*Math.PI/r,B=Math.PI-G,P=new or(0,-w,0),W=new or(0,w,0),M=new Xn(e,-w),q=new Xn(D,-w),E=new Xn(0,W.y).sub(q),b=new Xn(0,W.y).sub(M),R=new Xn(E.y,-E.x).normalize(),T=new Xn(b.y,-b.x).normalize(),A=e*Math.cos(Math.PI/r)*Math.tan((Math.PI-E.angle())/2)-1e-8;l=Math.min(l,A);let $;{let k=new or(R.x,R.y,0),H=new or(Math.cos(C)*k.x,k.y,Math.sin(C)*k.x);$=k.angleTo(H)}let he=l/Math.tan((Math.PI-E.angle())/2),re=l/Math.tan((Math.PI-$)/2),Ne=new or;if(!s){h.push(P.x,P.y,P.z),d.push(0,-1,0),x.push(0,0);let k=g++,H=[],_=M.clone(),J=he/Math.cos(Math.PI/r);_.x-=J;for(let ee=0;ee<r;ee++){let oe=ee/r*Math.PI*2+S,se=new Xn(Math.sin(oe),Math.cos(oe));Na(_,se,Ne),h.push(Ne.x,Ne.y,Ne.z),d.push(0,-1,0),x.push(0,0),H.push(g++)}for(let ee=0;ee<H.length;ee++)f.push(H[ee],k,H[(ee+1)%H.length])}let ye=[];{let k=new or,H=new or,_=new or,J=new or,ee=new or,oe=new or;for(let se=0;se<r;se++){let ce=se/r*Math.PI*2+S,ue=(se+.5)/r*Math.PI*2+S,K=(se+1)/r*Math.PI*2+S,ae=new Xn(Math.sin(ce),Math.cos(ce)),ne=new Xn(Math.sin(ue),Math.cos(ue)),Ce=new Xn(Math.sin(K),Math.cos(K));Na(M,ae,H),Na(M,Ce,_),Na(R,ne,k),$h(W,H,_,re,re,J),h.push(J.x,J.y,J.z),$h(H,W,_,re,he,ee),h.push(ee.x,ee.y,ee.z),$h(_,H,W,he,re,oe),h.push(oe.x,oe.y,oe.z),d.push(k.x,k.y,k.z),d.push(k.x,k.y,k.z),d.push(k.x,k.y,k.z),x.push(0,0),x.push(0,0),x.push(0,0);let Y=g++,le=g++,pe=g++;if(f.push(Y,le,pe),l>0){{let de=H.clone().add(_).multiplyScalar(.5),we=W.clone().sub(de).normalize(),Ge=P.clone().sub(de).normalize().add(we).normalize().multiplyScalar(-1),Qe=oe.clone().sub(ee);Me(de,Qe,Ge,E.angle())}let xe,_e;{let de=new or;Na(T,Ce,de);let we=oe.clone().add(J).multiplyScalar(.5);we=O2(we,_,W);let Ve=oe.clone().sub(J);[xe,_e]=Me(we,Ve,de,$,J.y)}{let de=xe,we=de.clone().setY(0).normalize(),Ve=new or(0,-1,0),Ge=we.clone().cross(Ve);Fe(de,we,Ve,Ge)}ye.concat(_e);{let de=E.angle(),we=Math.PI-de,Ve=W.clone();Ve.y-=l/Math.sin(de-Math.PI/2);let Ge=new or,Qe=[];for(let Lt=0;Lt<c;Lt++){let At=[],sr=Math.PI/2-we*Lt/c,Ur=Math.cos(sr),Ht=Math.sin(sr),kr=ue;for(let wn=0;wn<=Lt;wn++){let Nn=Math.cos(kr),dt=Math.sin(kr);k.x=Ur*dt,k.y=Ht,k.z=Ur*Nn,Ge.copy(Ve).addScaledVector(k,l),h.push(Ge.x,Ge.y,Ge.z),d.push(k.x,k.y,k.z),x.push(0,0),At.push(g++),kr+=Math.PI*2/Lt/r}Qe.push(At)}_e.reverse(),Qe.push(_e);let bt=Qe.length-1;for(let Lt=0;Lt<bt;Lt++){let At=Qe[Lt],sr=Qe[Lt+1],Ur=At.length-1;f.push(sr[1],At[0],sr[0]);for(let Ht=1;Ht<=Ur;Ht++)f.push(At[Ht],At[Ht-1],sr[Ht]),f.push(sr[Ht+1],At[Ht],sr[Ht])}}}}}this.setIndex(f),this.setAttribute("position",new qh(h,3)),this.setAttribute("normal",new qh(d,3)),this.setAttribute("uv",new qh(x,2));function Me(k,H,_,J,ee){let oe=-J/2,se=(Math.PI-J)/2,ce=H.clone().normalize().cross(_);k.addScaledVector(_,-l/Math.sin(se));let ue=new or,K=new or,ae=1,ne=g,Ce=[];for(let Y=0;Y<=c;Y++){let le=oe+Y/c*J;K.set(0,0,0),K.addScaledVector(ce,Math.sin(le)),K.addScaledVector(_,Math.cos(le));for(let pe=0;pe<=ae;pe++){let xe=pe/ae-.5;if(ue.copy(k),ue.addScaledVector(H,xe),ue.addScaledVector(K,l),ee!=null){let _e=Math.max(0,ue.y-ee);ue.addScaledVector(H,-_e/H.y)}h.push(ue.x,ue.y,ue.z),d.push(K.x,K.y,K.z),x.push(0,0),pe===0&&Ce.push(g),g++}}for(let Y=0;Y<c;Y++)for(let le=0;le<ae;le++){let pe=ne+le+(ae+1)*Y,xe=pe+(ae+1),_e=xe+1,de=pe+1;f.push(pe,xe,de),f.push(xe,_e,de)}return[k.clone().addScaledVector(H,.5),Ce]}function Fe(k,H,_,J){let ee=Math.PI/2,oe=b.angle()-ee,se=[],ce=new or,ue=new or;for(let ae=0;ae<=c;ae++){let ne=[],Ce=ae/c;for(let Y=0;Y<=ae;Y++){let pe=((ae?Y/ae:0)-.5)*B,xe=Math.cos(pe),_e=Math.sin(pe),de=Math.atan(Math.tan(oe)*xe),we=(ee+de)*Ce,Ve=Math.cos(we),Ge=Math.sin(we);ce.set(0,0,0),ce.addScaledVector(H,Ge*xe),ce.addScaledVector(_,Ve),ce.addScaledVector(J,Ge*_e),ue.copy(k).addScaledVector(ce,l),h.push(ue.x,ue.y,ue.z),d.push(ce.x,ce.y,ce.z),x.push(0,0),ne.push(g++)}se.push(ne)}let K=se.length-1;for(let ae=0;ae<K;ae++){let ne=se[ae],Ce=se[ae+1],Y=ne.length-1;f.push(ne[0],Ce[1],Ce[0]);for(let le=1;le<=Y;le++)f.push(ne[le-1],ne[le],Ce[le]),f.push(ne[le],Ce[le+1],Ce[le])}}}};var ou=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var l,c,f,h,d;let t=Object.assign({},(l=e==null?void 0:e.parameters)!=null?l:{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign((c=e==null?void 0:e.ui)!=null?c:{enabledIndieCorners:!1},i.ui),n=t.cornerRadius.reduce((x,g)=>x+g,0);return{shape:i.shape&&i.shape instanceof st?i.shape:new st,parameters:Object.assign(t,{surfaceMaxCount:((f=t.surfaceMaxCount)!=null?f:n>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((h=t.height)!=null?h:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(d=t.depth)!=null?d:0)}),ui:r}}static build(i){let e=i.shape,{width:t,height:r,cornerRadius:n,cornerType:s,depth:l,extrudeBevelSize:c,extrudeBevelSegments:f,surfaceMaxCount:h}=i.parameters,d={x:t*.5,y:r*.5},x={x:-d.x,y:-d.y},g={x:d.x,y:d.y};function w(M,q,E){return q>t&&E>r?Math.min(M*t/q,M*r/E):q>t?M*t/q:E>r?M*r/E:M}let S=[];S[0]=n[0]===0?0:w(n[0],n[0]+n[3],n[0]+n[1]),S[1]=n[1]===0?0:w(n[1],n[1]+n[2],n[1]+n[0]),S[2]=n[2]===0?0:w(n[2],n[2]+n[1],n[2]+n[3]),S[3]=n[3]===0?0:w(n[3],n[3]+n[0],n[3]+n[2]);let D=x.x,C=g.x,G=g.y,B=x.y;e.addPoint(e.createPoint(D,G)),e.addPoint(e.createPoint(C,G)),e.addPoint(e.createPoint(C,B)),e.addPoint(e.createPoint(D,B)),e.isClosed=!0;let P=!0;for(let M=0,q=e.points.length;M<q;M++)e.points[M].roundness=S[M],M>0&&S[M]!==S[M-1]&&(P=!1);P&&(e.roundness=S[0]),e.useCubicForRoundedCorners=s!==1,e.update();let W=ur.create({shape:e,parameters:{surfaceMaxCount:h,depth:l,extrudeBevelSize:c,extrudeBevelSegments:f}});return Object.assign(W,{userData:fe(U({},i),{type:"RectangleGeometry"})})}};import{SphereBufferGeometry as P2}from"three";var Y0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e=100,height:t=e,depth:r=e,widthSegments:n=64,heightSegments:s=64,phiStart:l,phiLength:c,thetaStart:f,thetaLength:h}=i.parameters,d=new P2(.5*e,n,s,l,c,f,h);return d.scale(1,t/e,r/e),Object.assign(d,{userData:fe(U({},i),{type:"SphereGeometry"})})}};import{PlaneBufferGeometry as D2}from"three";var Q0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:0})}}static build(i){let{width:e=100,height:t=e,widthSegments:r=8,heightSegments:n=8}=i.parameters,s=new D2(e,t,r,n);return s.scale(1,1,1),Object.assign(s,{userData:fe(U({},i),{type:"PlaneGeometry"})})}};var ev=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,s,l,c;let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof st?i.shape:new st,parameters:Object.assign(t,{surfaceMaxCount:((s=t.surfaceMaxCount)!=null?s:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((l=t.height)!=null?l:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(c=t.depth)!=null?c:0)})}}static build(i){let{width:e,height:t,innerRadiusPercent:r,spikes:n,cornerRadius:s,angle:l,depth:c,extrudeBevelSize:f,extrudeBevelSegments:h,surfaceMaxCount:d}=i.parameters,x=i.shape,g=e*.5,w=t*.5,S=0,D=0,C=l*Math.PI/360/n,G=Math.PI/2*3*-1,B=g*r/100,P=w*r/100;if(n==3&&r==50){C=2*Math.PI/n;for(let M=0;M<n;M++){let q=C*M,E=S+Math.sin(q)*g,b=D+Math.cos(q)*w;x.addPoint(x.createPoint(E,b))}}else for(let M=0;M<n;M++){let q=S+Math.cos(G)*g,E=D+Math.sin(G)*w;x.addPoint(x.createPoint(q,E)),G+=C,q=S+Math.cos(G)*B,E=D+Math.sin(G)*P,M<=n,x.addPoint(x.createPoint(q,E)),G+=C}x.isClosed=!0;for(let M=0,q=x.points.length;M<q;M++)x.points[M].roundness=s;x.roundness=s,x.update();let W=ur.create({shape:x,parameters:{surfaceMaxCount:d,roundness:s,depth:c,extrudeBevelSize:f,extrudeBevelSegments:h}});return Object.assign(W,{userData:fe(U({},i),{type:"StarGeometry"})})}};import{PlaneBufferGeometry as B2}from"three";var su=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,depth:0},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:0)})}}static build(i){let{width:e,height:t}=i.parameters,r=new B2(e,t);return Object.assign(r,{userData:fe(U({},i),{type:"TextFrameGeometry"})})}};var tv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var l,c,f;let t=Object.assign({},(l=e==null?void 0:e.parameters)!=null?l:{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(t.width),n=Math.abs((c=t.height)!=null?c:t.width),s=Math.abs((f=t.depth)!=null?f:t.width*.25);return{parameters:Object.assign(t,{width:r,height:n,depth:s})}}static build(i){let{width:e,height:t,depth:r,radialSegments:n,tubularSegments:s,arc:l,cornerRadius:c,cornerSegments:f}=i.parameters,h=G2(e,t,r,e*.5,l,s,0,0,n,c,f);return h.scale(1,t/e,1),Object.assign(h,{userData:fe(U({},i),{type:"TorusGeometry"})})}};function G2(i,e,t,r,n,s,l,c,f,h,d){return[e,t]=[t,e],l=e/2,n/=2*Math.PI,n==1&&(h=0),new tu(!0,i,e,t,r,n,s,l,c,f,h,d)}import{TorusKnotBufferGeometry as j2}from"three";var rv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,n,s,l;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width),tube:(l=t.tube)!=null?l:t.width*.125})}}static build(i){let{width:e,tube:t,tubularSegments:r,radialSegments:n,p:s,q:l}=i.parameters,c=e*.5;c!==t&&(c-=t);let f=new j2(c,t,r,n,s,l);return Object.assign(f,{userData:fe(U({},i),{type:"TorusKnotGeometry"})})}};var nv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,s,l,c;let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof st?i.shape:new st,parameters:Object.assign(t,{surfaceMaxCount:((s=t.surfaceMaxCount)!=null?s:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((l=t.height)!=null?l:t.width*(t.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(c=t.depth)!=null?c:0)})}}static build(i){let{width:e=100,height:t,cornerRadius:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:l,isRect:c,surfaceMaxCount:f}=i.parameters,h=i.shape,d=e*.5,x=t*.5;c?(h.addPoint(h.createPoint(-d,x)),h.addPoint(h.createPoint(d,-x)),h.addPoint(h.createPoint(-d,-x))):(h.addPoint(h.createPoint(0,x)),h.addPoint(h.createPoint(d,-x)),h.addPoint(h.createPoint(-d,-x))),h.isClosed=!0;for(let w=0,S=h.points.length;w<S;w++)h.points[w].roundness=r;h.roundness=r,h.update();let g=ur.create({shape:h,parameters:{surfaceMaxCount:f,roundness:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(g,{userData:fe(U({},i),{type:"TriangleGeometry"})})}};var Ca={};V_(Ca,{addBarycentricAttribute:()=>V2,fixUvs:()=>k2,loadFromUrl:()=>U2,resizeGeometry:()=>F2,roundShapePolygon:()=>z2});import{BufferGeometryLoader as E2,Float32BufferAttribute as R2,Vector3 as Jh}from"three";var iv=function(i,e){let t=e.x-i.x,r=e.y-i.y,n=Math.sqrt(t*t+r*r),s=t/n,l=r/n,c=Math.atan2(l,s);return{x:t,y:r,len:n,nx:s,ny:l,ang:c}},z2=(i,e,t)=>{let r,n,s,l,c,f,h,d,x,g,w,S,D,C,G=e.length;for(l=e[G-2],i.curves=[],r=1;r<G-1;r++){c=e[r%G],f=e[(r+1)%G];let B=iv(c,l),P=iv(c,f);h=B.nx*P.ny-B.ny*P.nx,d=B.nx*P.nx-B.ny*-P.ny,w=Math.asin(h),x=1,g=!1,d<0?w<0?w=Math.PI+w:(w=Math.PI-w,x=-1,g=!0):w>0&&(x=-1,g=!0),S=w/2,C=Math.abs(Math.cos(S)*t/Math.sin(S)),C>Math.min(B.len/2,P.len/2)?(C=Math.min(B.len/2,P.len/2),D=Math.abs(C*Math.sin(S)/Math.cos(S))):D=t,n=c.x+P.nx*C,s=c.y+P.ny*C,n+=-P.ny*D*x,s+=P.nx*D*x,i.absarc(n,s,D,B.ang+Math.PI/2*x,P.ang-Math.PI/2*x,g),l=c,c=f}i.closePath()},F2=(i,{width:e,height:t,depth:r})=>{e=Math.abs(e),t=Math.abs(t),r=Math.abs(r);let n=i.userData.parameters,s,l,c;e===0?(e=n.width,s=1):s=e/n.width,t===0?(t=n.height,l=1):l=t/n.height,r===0?(r=n.depth,c=1):c=r/n.depth,i.scale(s,l,c),n.width=e,n.height=t,n.depth=r},V2=(i,e)=>{let t=[new Jh(1,0,0),new Jh(0,1,0),new Jh(0,0,1)],r=i.attributes.position,n=new Float32Array(r.count*3);for(let s=0,l=r.count;s<l;s++)t[s%3].toArray(n,s*3);i.setAttribute(e,new R2(n,3))},U2=i=>new Promise(e=>{new E2().load(i,r=>e(r))}),k2=(i,e,t)=>{let r=i.getAttribute("uv");if(r)for(let n=0;n<r.count;n++){let s=r.getX(n),l=r.getY(n);r.setXY(n,(s+e/2)/e,1-(l-t/2)/t*-1)}};import{BufferGeometry as ov,BufferAttribute as sv,Uint32BufferAttribute as Kh,Float32BufferAttribute as Xh,Matrix4 as W2}from"three";import{mergeVertices as q2}from"three/examples/jsm/utils/BufferGeometryUtils.js";var H2,au=new Promise(i=>{H2=i});var Oe;au.then(i=>{Oe=i});var av=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),lv=new Uint32Array([0,1,2,3]),cv=new Uint8Array([4]),en=class{static build(i,e,t,r,n){let s,l,c;if(i===void 0)s=en.allocate(n,t),Oe.set_destination_refinement_level(s,0),l=en.buildLevel(s,!0,r);else if(i.positionWASM!==void 0){e&&e!==0&&(Oe.free_bvh(e),Oe.free_subdivision_surface(e));try{s=en.allocate(n,void 0,i)}catch(f){console.error(f,i),s=en.allocate(n,void 0,{positionWASM:av,indexWASM:lv,verticesPerFaceWASM:cv})}Oe.set_destination_refinement_level(s,0),l=en.buildLevel(s,!0,r)}else s=e;if(i!==void 0&&i.subdivisions!==void 0){let f=$2(i.subdivisions,i.positionWASM.length);Oe.set_destination_refinement_level(s,f),f>0?c=en.buildLevel(s,!1,r):c=null}return{subdivPointer:s,originalGeometry:l,subdividedGeometry:c}}static allocate(i,e,t){var M;let r,n,s,l=[],c=[];if(t)t.positionWASM&&t.positionWASM.length>0?(r=t.positionWASM,n=t.indexWASM,s=t.verticesPerFaceWASM):(r=av,n=lv,s=cv);else{e.deleteAttribute("normal"),e.deleteAttribute("uv");let q=q2(e);r=q.attributes.position.array;let E=q.getIndex().array,b=E.length;switch(e.userData.type==="TorusGeometry"&&(e==null?void 0:e.userData.parameters.arc)===Math.PI*2&&(e.userData.type="ClosedTorusGeometry"),e.userData.type){case"ClosedTorusGeometry":case"PlaneGeometry":case"TorusKnotGeometry":case"CubeGeometry":n=new Uint32Array(b/3*2),s=new Uint8Array(b/6).fill(4);for(let re=0,Ne=0;re<b;re+=6)n[Ne++]=E[re],n[Ne++]=E[re+1],n[Ne++]=E[re+4],n[Ne++]=E[re+5];break;case"TorusGeometry":case"SphereGeometry":case"HelixGeometry":case"CylinderGeometry":case"ConeGeometry":let R,T,z;if(e.userData.type==="SphereGeometry")T=e.parameters.heightSegments,R=e.parameters.widthSegments,e.parameters.thetaLength!==Math.PI&&(z=!0);else if(e.userData.type==="CylinderGeometry")T=e.parameters.heightSegments+2,R=e.parameters.radialSegments;else if(e.userData.type==="ConeGeometry")T=e.parameters.heightSegments+1,R=e.parameters.radialSegments;else if(e.userData.type==="TorusGeometry"){let re=e.userData.parameters;T=Math.ceil(re.tubularSegments*re.arc/(2*Math.PI))+2,R=re.radialSegments}else{let{pathSegments:re,segments:Ne,revolutions:ye}=e.userData.parameters;T=Math.ceil(Ne*ye)+2,R=re}z?(n=new Uint32Array(1*R*3+(T-1)*R*4),s=new Uint8Array(1*R+(T-1)*R)):(n=new Uint32Array(2*R*3+(T-2)*R*4),s=new Uint8Array(2*R+(T-2)*R));let A=0,$=0,he=0;if(e.userData.type==="SphereGeometry"||e.userData.type==="HelixGeometry"||e.userData.type==="TorusGeometry"){for(;$<3*R;)n[$++]=E[A++],n[$++]=E[A++],n[$++]=E[A++],s[he++]=3;let re=z?n.length:3*R+4*(T-2)*R;for(;$<re;A+=6)n[$++]=E[A],n[$++]=E[A+1],n[$++]=E[A+4],n[$++]=E[A+5],s[he++]=4}else for(;$<4*(T-2)*R;A+=6)n[$++]=E[A],n[$++]=E[A+1],n[$++]=E[A+4],n[$++]=E[A+5],s[he++]=4;for(;$<n.length;)n[$++]=E[A++],n[$++]=E[A++],n[$++]=E[A++],s[he++]=3;break;default:n=E,s=new Uint8Array(b/3).fill(3);break}}let f=r.length,h=n.length,d=s.length,x=r.length+l.length+c.length,g=n.length+s.length,w=x*Float32Array.BYTES_PER_ELEMENT+g*Uint32Array.BYTES_PER_ELEMENT,S=x*Float32Array.BYTES_PER_ELEMENT,D=g*Uint32Array.BYTES_PER_ELEMENT,C=Oe._malloc(w),G=new Float32Array(Oe.HEAPF32.buffer,C,x),B=new Uint32Array(Oe.HEAPU32.buffer,C+S,g);G.set(r,0),G.set(l,r.length),G.set(c,r.length+l.length),B.set(n,0),B.set(s,n.length);let P;((M=t==null?void 0:t.scaleBaked)==null?void 0:M.some(q=>q!==1))&&(P=new W2().makeScale(...t.scaleBaked)),i&&(P?P.premultiply(i):P=i);let W=P?Oe.alloc_subdivision_surface2(C,f,C+S,h,C+S+n.length*Uint32Array.BYTES_PER_ELEMENT,d,P.elements):Oe.alloc_subdivision_surface(C,f,C+S,h,C+S+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return Oe._free(C),W}static buildLevel(i,e,t,r,n){let s=n?Oe.get_mesh_data2(i,e?Oe.Level.CONTROL:Oe.Level.REFINED,t!=null?t:!e,n.elements):Oe.get_mesh_data(i,e?Oe.Level.CONTROL:Oe.Level.REFINED,t!=null?t:!e),l=8,c=Oe.HEAPU32.subarray(s>>2,(s>>2)+l),f=c.subarray(4,4+4),h=0,d=Oe.HEAPU32[c[h]>>2],x=Oe.HEAPF32.subarray(d>>2,(d>>2)+f[h]);h++;let g=Oe.HEAPU32[c[h]>>2],w=Oe.HEAPF32.subarray(g>>2,(g>>2)+f[h]);h++;let S=Oe.HEAPU32[c[h]>>2],D=Oe.HEAPU32.subarray(S>>2,(S>>2)+f[h]);h++;let C=Oe.HEAPU32[c[h]>>2],G=Oe.HEAPU32.subarray(C>>2,(C>>2)+f[h]);if(h++,r===void 0){let B=new ov;if(B.setIndex(new Kh(G,1)),B.setAttribute("position",new Xh(x,3)),B.setAttribute("normal",new Xh(w,3)),e){B.setAttribute("faceMap",new Kh(D,1));let P=new Float32Array(w.length/3*4).fill(0);B.setAttribute("color",new sv(P,4))}return Oe.free_mesh_data(s),B.userData.type="SubdivGeometry",B}r.getAttribute("position").copyArray(x),r.getAttribute("normal").copyArray(w),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,Oe.free_mesh_data(s)}static buildControlCageWireframe(i,e,t){let r=Oe.get_wireframe_data_for_base_level(i),n=4,s=Oe.HEAPU32.subarray(r>>2,(r>>2)+n),l=s.subarray(2,2+2),c=0,f=Oe.HEAPU32[s[c]>>2],h=Oe.HEAPF32.subarray(f>>2,(f>>2)+l[c]);c++;let d=Oe.HEAPU32[s[c]>>2],x=Oe.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(e===void 0){let g=new ov;g.setAttribute("position",new Xh(h,3));let w=new Float32Array(h.length);for(let S=0,D=h.length;S<D;)w[S++]=t.r,w[S++]=t.g,w[S++]=t.b;return g.setAttribute("color",new sv(w,3)),g.setIndex(new Kh(x,1)),Oe.free_wireframe_data_for_base_level(r),g}e.getAttribute("position").copyArray(h),e.attributes.position.needsUpdate=!0,Oe.free_wireframe_data_for_base_level(r)}static updateCollabMesh(i,e,t){e||Oe.set_destination_refinement_level(i,1);let r=t?Oe.get_topological_data2(i,e?Oe.Level.CONTROL:Oe.Level.REFINED,t.elements):Oe.get_topological_data(i,e?Oe.Level.CONTROL:Oe.Level.REFINED),n=6,s=Oe.HEAPU32.subarray(r>>2,(r>>2)+n),l=s.subarray(3,3+3),c=0,f=Oe.HEAPU32[s[c]>>2],h=new Float32Array(Oe.HEAPF32.subarray(f>>2,(f>>2)+l[c]));c++;let d=Oe.HEAPU32[s[c]>>2],x=new Uint32Array(Oe.HEAPU32.subarray(d>>2,(d>>2)+l[c]));c++;let g=Oe.HEAPU32[s[c]>>2],w=new Uint8Array(Oe.HEAPU32.subarray(g>>2,(g>>2)+l[c]));return Oe.free_topological_data(r),{positions:h,indices:x,verticesPerFace:w}}};function $2(i,e){let t=i;return t=Math.min(t,3-Math.ceil(Math.log(e/172e3)/Math.log(4))),Math.max(t,0)}var Zh={ConeGeometry:u0,CubeGeometry:f0,CylinderGeometry:l0,DodecahedronGeometry:p0,EllipseGeometry:j0,HelixGeometry:U0,IcosahedronGeometry:k0,LatheGeometry:H0,NonParametricGeometry:J0,PolygonGeometry:K0,PyramidGeometry:X0,RectangleGeometry:ou,SphereGeometry:Y0,PlaneGeometry:Q0,StarGeometry:ev,TextFrameGeometry:su,TorusGeometry:tv,TorusKnotGeometry:rv,TriangleGeometry:nv,VectorGeometry:ur},La=i=>Zh[i.type].create(i);import{Matrix4 as Qh}from"three";import{Box3 as pv,Line3 as gn,Matrix4 as Yh,Vector3 as Ct}from"three";import{HemisphereLight as uv}from"three";import{Color as J2}from"three";var tn=class extends J2{constructor(e,t,r,n){super(e,t,r);this.isColorA=!0;this.a=n}setRGBA(e,t,r,n){super.setRGB(e,t,r),this.a=n}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}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}};function kt(i,e){let t;if(typeof i=="string"){let r=e==null?void 0:e.getColor(i);r?t=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new tn(0,0,0,0))}else return"a"in i?new tn(i.r,i.g,i.b,i.a):new tn(i.r,i.g,i.b,1);return t}var lu=i=>"isEntity"in i,_s=i=>"isAbstractMesh"in i;var vi=i=>"objectHelper"in i;function K2(i,e){var r;let t=!1;e.position&&(i.position.fromArray(e.position),t=!0),e.rotation&&(i.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,i.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in i&&(t=!0,i.hiddenMatrix.fromArray((r=e.hiddenMatrix)!=null?r:Fi.identity)),t&&i.updateMatrix(),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&i.updateWorldMatrix(!1,!0),i.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(i.isUpVectorFlipped=e.isUpVectorFlipped),i.updateUp())}function X2(i,e){K2(i,e),e.name!==void 0&&(i.name=e.name),e.visible!==void 0&&(i.isEntity?i.visibility=e.visible:i.visible=e.visible)}function fv(i,e,t){X2(i,e),e.color!==void 0&&(i.color=kt(e.color,t)),e.intensity!==void 0&&(i.intensity=e.intensity),e.shadows!==void 0&&!(i instanceof uv)&&(i.castShadow=e.shadows),i.shadow&&!(i instanceof uv)&&e.depth!==void 0&&(i.shadow.camera.far=e.depth,i.shadow.needsUpdate=!0),e.helper!==void 0&&vi(i)&&(i.enableHelper=e.helper,i.gizmos.shadowmap.visible=e.helper)}function hv(i,e){i.shadow.camera.right=e/2,i.shadow.camera.left=-e/2,i.shadow.camera.top=e/2,i.shadow.camera.bottom=-e/2,i.shadow.needsUpdate=!0}var Ts=new pv,fr=new Ct,Ie=new Ct,$t=new Yh;function Z2(i,e,t=0,r=e.count){let n=1/0,s=1/0,l=1/0,c=-1/0,f=-1/0,h=-1/0;for(let d=t;d<r;d++){let x=e.getX(d),g=e.getY(d),w=e.getZ(d);x<n&&(n=x),g<s&&(s=g),w<l&&(l=w),x>c&&(c=x),g>f&&(f=g),w>h&&(h=w)}return i.min.set(n,s,l),i.max.set(c,f,h),i}var dv=(i,e,t,r)=>{var n;if(_s(i)){let s=i.geometry.userData.parameters,l=i.geometry.getAttribute("position");i.geometry.userData.type==="SubdivGeometry"?fr.copy(i.originalGeometry.boundingSphere.center):(Z2(Ts,l,i.geometry.drawRange.start,i.geometry.drawRange.count<1/0?i.geometry.drawRange.count:l.count),Ts.getCenter(fr)),i.forceComputeSize?Ts.getSize(Ie).multiplyScalar(.5):Ie.set(s.width,s.height,(n=s.depth)!=null?n:0).multiplyScalar(.5)}else if(vi(i)&&r===!0){let s=i.geometryHelper.getAttribute("position");Ts.setFromArray(s.array),Ts.getCenter(fr),Ts.getSize(Ie).multiplyScalar(.5)}else fr.setScalar(0),Ie.setScalar(0);$t.copy(e).multiply(i.matrixWorld),Ie.x===0&&Ie.y===0&&Ie.z===0?t.push(new Ct(fr.x,fr.y,fr.z).applyMatrix4($t)):t.push(new Ct(-Ie.x,Ie.y,Ie.z).add(fr).applyMatrix4($t),new Ct(-Ie.x,-Ie.y,Ie.z).add(fr).applyMatrix4($t),new Ct(Ie.x,-Ie.y,Ie.z).add(fr).applyMatrix4($t),new Ct(Ie.x,Ie.y,Ie.z).add(fr).applyMatrix4($t),new Ct(-Ie.x,Ie.y,-Ie.z).add(fr).applyMatrix4($t),new Ct(-Ie.x,-Ie.y,-Ie.z).add(fr).applyMatrix4($t),new Ct(Ie.x,-Ie.y,-Ie.z).add(fr).applyMatrix4($t),new Ct(Ie.x,Ie.y,-Ie.z).add(fr).applyMatrix4($t))},cu=class extends pv{constructor(){super(...arguments);this.matrix=new Yh;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let r=new Yh().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,r,t)}expandByObjectSize(e,t,r=!1){let n=[];return r===!0?e.traverseEntity(s=>dv(s,t,n,e.enableHelper===!0)):dv(e,t,n,e.enableHelper===!0),this.setFromPoints(n)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4($t.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Ie).multiplyScalar(.5),this.getCenter(fr),$t.copy(this.matrix).setPosition(fr),this.vertices=[new Ct(-Ie.x,Ie.y,Ie.z).applyMatrix4($t),new Ct(-Ie.x,-Ie.y,Ie.z).applyMatrix4($t),new Ct(Ie.x,-Ie.y,Ie.z).applyMatrix4($t),new Ct(Ie.x,Ie.y,Ie.z).applyMatrix4($t),new Ct(-Ie.x,Ie.y,-Ie.z).applyMatrix4($t),new Ct(-Ie.x,-Ie.y,-Ie.z).applyMatrix4($t),new Ct(Ie.x,-Ie.y,-Ie.z).applyMatrix4($t),new Ct(Ie.x,Ie.y,-Ie.z).applyMatrix4($t)]}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=[new gn(this.vertices[0],this.vertices[3]),new gn(this.vertices[1],this.vertices[2]),new gn(this.vertices[5],this.vertices[6]),new gn(this.vertices[4],this.vertices[7]),new gn(this.vertices[0],this.vertices[1]),new gn(this.vertices[3],this.vertices[2]),new gn(this.vertices[7],this.vertices[6]),new gn(this.vertices[4],this.vertices[5]),new gn(this.vertices[0],this.vertices[4]),new gn(this.vertices[1],this.vertices[5]),new gn(this.vertices[2],this.vertices[6]),new gn(this.vertices[3],this.vertices[7])],this.centerEdges=this.edges.map(e=>e.getCenter(new Ct))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=[new Ct().copy(this.vertices[0]).sub(this.vertices[2]).multiplyScalar(.5).add(this.vertices[2]),new Ct().copy(this.vertices[7]).sub(this.vertices[5]).multiplyScalar(.5).add(this.vertices[5]),new Ct().copy(this.vertices[4]).sub(this.vertices[1]).multiplyScalar(.5).add(this.vertices[1]),new Ct().copy(this.vertices[3]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6]),new Ct().copy(this.vertices[4]).sub(this.vertices[3]).multiplyScalar(.5).add(this.vertices[3]),new Ct().copy(this.vertices[1]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6])]}};import{Object3D as Y2,Matrix4 as Q2,Light as eD}from"three";function _a(i){let e=[];for(let t in i){let r=i[t];delete r.metadata,e.push(r)}return e}function tD(i){let e=[];for(let t in i)e.push(i[t]);return e}var uu=i=>class extends i{hasEntityChild(){return this.children.some(t=>lu(t))}isDescendantOf(t){t instanceof Y2&&(t=t.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===t)return!0;r=r.parent}return!1}attach(t,r){this.updateWorldMatrix(!0,!1);let n=new Q2().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),n.multiply(t.parent.matrixWorld)),lu(t)?t.hiddenMatrix.premultiply(n):t.applyMatrix4(n),t.updateWorldMatrix(!1,!1),this.add(t),r!==void 0&&(this.children.pop(),this.children.splice(r,0,t)),this}copy(t,r=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),r===!0)for(let n=0;n<t.children.length;n++){let s=t.children[n];this.add(s.clone())}return this}toJSON(t){let r=t===void 0,n={object:{uuid:"",objectType:""}};t===void 0&&(t={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},n.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let s={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(s.name=this.name),s.matrix=this.matrix.toArray(),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),s.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(s.userData=this.userData),this.children.length>0){s.children=[];for(let l of this.children)(lu(l)||l instanceof eD)&&s.children.push(l.toJSON(t).object)}if(r){let l=_a(t.geometries),c=_a(t.materials),f=_a(t.textures),h=_a(t.images),d=_a(t.interactionStates),x=tD(t.nodes);l.length>0&&(n.geometries=l),c.length>0&&(n.materials=c),f.length>0&&(n.textures=f),h.length>0&&(n.images=h),d.length>0&&(n.interactionStates=d),x.length>0&&(n.nodes=x)}return n.object=s,n}fromJSON(t){return this.uuid=t.uuid,t.name!==void 0&&(this.name=t.name),t.matrix!==void 0?(this.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=t.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(t.position!==void 0&&this.position.fromArray(t.position),t.rotation!==void 0&&this.rotation.fromArray(t.rotation),t.quaternion!==void 0&&this.quaternion.fromArray(t.quaternion),t.scale!==void 0&&this.scale.fromArray(t.scale)),this.castShadow=t.castShadow!==void 0,this.receiveShadow=t.receiveShadow!==void 0,t.visible!==void 0&&(this.visible=t.visible),t.frustumCulled!==void 0&&(this.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(this.renderOrder=t.renderOrder),t.layers!==void 0&&(this.layers.mask=t.layers),t.userData!==void 0&&(this.userData=t.userData),this}};var yn=i=>"isEntity"in i;var xn=i=>class extends uu(i){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Qh;this._singleBBox=new cu;this._recursiveBBox=new cu;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(t){this.visible=t;for(let r of this.children)yn(r)&&r.traverseEntity(n=>{vi(n)&&n.visible&&(n.objectHelper.visible=t)})}get visibility(){return this.visible}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}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(t=>{yn(t)&&(t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(t=>{t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0})}traverseEntity(t){t(this);for(let r of this.children)yn(r)&&r.traverseEntity(t)}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let r of this.children)r.updateMatrixWorld(t)}updateWorldMatrix(t,r){let n=this.parent;if(t&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),r)for(let s of this.children)s.updateWorldMatrix(!1,!0)}shallowClone(t){return new this.constructor().shallowCopy(this,t)}shallowCopy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),r===!0)for(let n of t.children)yn(n)&&this.add(n.shallowClone());return this}clone(t){return new this.constructor().copy(this,t)}copy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),r===!0)for(let n of t.children)yn(n)&&this.add(n.clone());return this}keepChildrenMatrixWorld(){let t=new Qh,r=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),t.copy(this.matrixWorld).invert(),t.multiply(r);for(let n of this.children)yn(n)&&n.hiddenMatrix.premultiply(t)}toJSON(t){let r=super.toJSON(t),n=r.object;return this.raycastLock===!0&&(n.raycastLock=!0),this.scaleLock===!0&&(n.scaleLock=!0),n.hiddenMatrix=this.hiddenMatrix.toArray(),r}fromJSON(t){return super.fromJSON(t),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.scaleLock!==void 0&&(this.scaleLock=t.scaleLock),this.hiddenMatrix.fromArray(t.hiddenMatrix),this}fromObject3D(t){let r=t.children;return t.children=[],Object.assign(t,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new Qh}),this.copy(t),t.children=r,this}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let r={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return hs(r,t)}fromObjectTransformState(t){return t.position&&this.position.fromArray(t.position),t.rotation&&this.rotation.fromArray(t.rotation),t.scale&&this.scale.fromArray(t.scale),t.hiddenMatrix&&this.hiddenMatrix.fromArray(t.hiddenMatrix),this.updateMatrix(),this}toState(t=[]){let r=U({name:this.name,visible:this.visible,raycastLock:this.raycastLock},this.toObjectTransformState(t));return hs(r,t)}fromState(t,r){return t.name&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.type!=="OrthographicCamera"&&t.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),t.visible!==void 0&&(this.visibility=t.visible),this.fromObjectTransformState(t),this}};import{Object3D as rD,Vector3 as Ta,Euler as mv,MathUtils as $i}from"three";var fu=class extends rD{constructor(e,t={}){super();this.object=e;let r=e.recursiveBBox.getSize(new Ta),n=.1;this.parameters=gc.defaultData(r.toArray(),n),yo(this.parameters,t),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let e of this.children)e.material=this.object.material}setHideBase(e){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let t of this.object.material)t.visible=!0;if(e){let t=this.object.material.map(r=>r.clone());for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material}for(let t of this.object.material)t.visible=!e}else{if(this.children.length>0)if(this.object.material.visible=!0,e){let t=this.object.material.clone();for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material;this.object.material.visible=!e}this.parameters.hideBase=e}}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}this.children.forEach(e=>e.updateMatrix())}_updateCount(){let e=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==e)if(this.children.length<e)for(let t=0,r=e-this.children.length;t<r;++t){let n=this.object.shallowClone(!1);n.visible=!0,this.add(n),this.parameters.hideBase&&this.setHideBase(!0)}else for(let t=0,r=this.children.length-e;t<r;++t)this.remove(this.children[0])}_updateRadial(e){let t=e.radial,r=t.start*$i.DEG2RAD,n=t.end*$i.DEG2RAD,s=r-n,l=new mv(t.rotation[0]*$i.DEG2RAD,t.rotation[1]*$i.DEG2RAD,t.rotation[2]*$i.DEG2RAD),c;switch(t.axis){case"z":c=new Ta(0,0,1);break;case"y":c=new Ta(0,1,0);break;default:case"x":c=new Ta(1,0,0);break}for(let[f,h]of this.children.entries()){h.hiddenMatrix.identity(),h.scale.x=t.scale[0],h.scale.y=t.scale[1],h.scale.z=t.scale[2],h.position.setScalar(0);let d=s/e.count*f-r;switch(t.axis){case"x":h.rotation.set(0,d,0);break;case"y":h.rotation.set(0,0,d);break;case"z":h.rotation.set(d,0,0);break}h.translateOnAxis(c,t.radius),h.position.x+=t.position[0],h.position.y+=t.position[1],h.position.z+=t.position[2],t.alignment===!0?(h.rotation.x+=l.x,h.rotation.y+=l.y,h.rotation.z+=l.z):h.rotation.copy(l)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,r=new mv(t.rotation[0]*$i.DEG2RAD,t.rotation[1]*$i.DEG2RAD,t.rotation[2]*$i.DEG2RAD);for(let[n,s]of this.children.entries())s.hiddenMatrix.identity(),s.scale.x=1+(t.scale[0]-1)*n,s.scale.y=1+(t.scale[1]-1)*n,s.scale.z=1+(t.scale[2]-1)*n,s.rotation.x=r.x*n,s.rotation.y=r.y*n,s.rotation.z=r.z*n,s.position.x=t.position[0]*n,s.position.y=t.position[1]*n,s.position.z=t.position[2]*n}_updateGrid(e){let t=0,r=e.grid;if(r.useCenter===!0){let n={x:r.count[0]%2==0?2:1,y:r.count[1]%2==0?2:1,z:r.count[2]%2==0?2:1},s=new Ta(r.size[0]*(r.count[0]-n.x)*.5,r.size[1]*(r.count[1]-n.y)*.5,r.size[2]*(r.count[2]-n.z)*.5);for(let l=0;l<r.count[0];l++)for(let c=0;c<r.count[1];c++)for(let f=0;f<r.count[2];f++){let h=this.children[t++];h.hiddenMatrix.identity(),h.scale.setScalar(1),h.rotation.set(0,0,0),h.position.x=r.size[0]*l-s.x,h.position.y=r.size[1]*c-s.y,h.position.z=r.size[2]*f-s.z}}else for(let n=0;n<r.count[0];n++)for(let s=0;s<r.count[1];s++)for(let l=0;l<r.count[2];l++){let c=this.children[t++];c.hiddenMatrix.identity(),c.scale.setScalar(1),c.rotation.set(0,0,0),c.position.x=r.size[0]*n,c.position.y=-r.size[1]*s,c.position.z=-r.size[2]*l}}fromJSON(e){return this}toJSON(){return{}}fromClonerState(e){return e.hideBase!==void 0&&this.setHideBase(e.hideBase),yo(this.parameters,e),this.update(),this}};var hr=class extends xn(nD){constructor(e,t){super(e,t);this.isAbstractMesh=!0;Array.isArray(t)&&(this.selectedMaterial=0,e.groups.length===0&&e.addGroup(0,e.getAttribute("position").count,0))}get cloner(){return this._cloner}set cloner(e){this._cloner&&this.remove(this._cloner),e&&this.add(e),this._cloner=e}getSelectedMaterial(e){return Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=e!=null?e:0),this.material[e!=null?e:this.selectedMaterial]):this.material}setSelectedMaterial(e,t){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=t!=null?t:0),t=t!=null?t:this.selectedMaterial,this.material[t].dispose(),this.material[t]=e):(this.material.dispose(),this.material=e)}updateGeometry(e){let t=this.geometry,r=Zh[t.userData.type],n=this.objectType==="NonParametric"?Object.assign({},t.userData,{geometry:t}):t.userData,s=r.build(r.normalizeInputs(e,n)),l=t.uuid;if(this.geometry.dispose(),this.geometry=s,this.geometry.uuid=l,this.geometry.computeBoundingSphere(),this.cloner)for(let c of this.cloner.children)c.geometry=this.geometry}resizeGeometry(e,t,r){Ca.resizeGeometry(this.geometry,{width:e,height:t,depth:r})}shallowClone(e){return new this.constructor(this.geometry,this.material).shallowCopy(this,e)}clone(e){let t=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,r=La(t),n=Array.isArray(this.material)?this.material.map(s=>s.clone()):this.material.clone();return new this.constructor(r,n).copy(this,e)}copy(e,t=!0){return super.copy(e,t),e.cloner&&(this.cloner=new fu(e,e.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new fu(this)),this.cloner.fromClonerState(e))}fromState(e,t){var r,n;return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=(r=e.castShadow)!=null?r:!0,this.receiveShadow=(n=e.receiveShadow)!=null?n:!0),this}};import{NormalBlending as CD,ShaderMaterial as LD,FrontSide as _D}from"three";import{CubeReflectionMapping as mD,CubeRefractionMapping as gD,CubeUVReflectionMapping as yD,LinearEncoding as Sv,sRGBEncoding as xD}from"three";var hu=class{constructor(e){e=e!=null?e:{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}};import{MathUtils as iD}from"three";var Pe=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=iD.generateUUID(),this.type=e,this.name="",this.userData={}}analyze(e,t){t=t!=null?t:{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,r){return r=r!=null?r:{},this.analyze(e,r),this.flow(e,t,r)}flow(e,t,r){r=r!=null?r:{},e.addFlow(r.slot,r.cache,r.context);let n={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),n}build(e,t,r){t=t!=null?t:this.getType(e,t);let n=e.getNodeData(r!=null?r:this);return e.analyzing&&this.appendDepsNode(e,n,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,r)}updateFrame(e){}generateReadonly(e,t,r,n,s,l){return""}generate(e,t,r,n,s){return""}parse(e,t,r,n){}appendDepsNode(e,t,r){t.deps=(t.deps||0)+1;let n=e.getTypeLength(r);(n>(t.outputMax||0)||this.getType(e,r))&&(t.outputMax=n,t.output=r)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getJSONNode(e){if((e==null?void 0:e.materials)&&(e==null?void 0:e.materials[this.uuid])!==void 0)return e.materials[this.uuid]}getHash(){let e="{",t,r;for(t in this)r=this[t],r instanceof Pe&&(e+='"'+t+'":'+r.getHash()+",");if(this.hashProperties)for(let n=0;n<this.hashProperties.length;n++)t=this.hashProperties[n],r=this[t],e+='"'+t+'":"'+String(r)+'",';return e+='"id":"'+this.uuid+'"}',e}copy(e){return this.name=e.name,e.type&&(this.type=e.type),e.frameId&&(this.frameId=e.frameId),e.hashProperties&&(this.hashProperties=e.hashProperties.map(t=>t)),this.userData=JSON.parse(JSON.stringify(e.userData)),this.shortcuts=JSON.parse(JSON.stringify(e.shortcuts)),this}clone(){return new this.constructor().copy(this)}createJSONNode(e){let t=e===void 0||typeof e=="string";if(typeof this.type!="string")throw new Error("Node does not allow serialization.");let r={};return r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),JSON.stringify(this.userData)!=="{}"&&(r.userData=this.userData),!t&&e&&(e.nodes[this.uuid]=r),r}toJSON(e){var t;return(t=this.getJSONNode(e))!=null?t:this.createJSONNode(e)}fromJSON(e,t){return this.uuid=e.uuid,this.type=e.type,e.name&&(this.name=e.name),e.userData&&(this.userData=e.userData),this}};var gv=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,r){r=r!==void 0?r:!0,this.keywords[e]={callback:t,cache:r}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},tr=new gv;import{Vector2 as yv}from"three";import{MathUtils as oD}from"three";var Be=class extends Pe{constructor(e,t){super(e);this.scope="";t=t!=null?t:{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,r,n){if(t=t!=null?t:this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=oD.generateUUID()),r=e.getUUID(r!=null?r:this.getUUID(),!s);let l=e.getNodeData(r),c=l.output||this.getType(e);if(e.analyzing)return(l.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,l,t),this.generate(e,t,r)):super.build(e,t,r);if(s)return l.name=l.name||super.build(e,t,r),l.name;if(!this.getLabel()&&(!this.getShared(e,c)||e.context.ignoreCache||l.deps===1))return super.build(e,t,r);r=this.getUUID(!1);let f=this.getTemp(e,r);if(f)return e.format(f,c,t);{f=super.generate(e,t,r,l.output,n);let h=this.generate(e,c,r);return e.addNodeCode(f+" = "+h+";"),e.format(f,c,t)}}return super.build(e,t,r)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let r=e.getVars()[t];return r?r.name:void 0}generate(e,t,r,n,s){return this.getShared(e,t)||console.error("TempNode is not shared"),r=r!=null?r:this.uuid,e.getTempVar(r,n!=null?n:this.getType(e),s,this.getLabel()).name}};var It=class extends Be{constructor(e,t){t=t!=null?t:{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}createJSONNode(e){let t=super.createJSONNode(e);return this.readonly===!0&&(t.readonly=this.readonly),t}fromJSON(e,t){return super.fromJSON(e,t),e.readonly!==void 0&&this.setReadonly(e.readonly),this}generate(e,t,r,n,s,l){r=e.getUUID(r!=null?r:this.getUUID()),n=n!=null?n:this.getType(e);let c=e.getNodeData(r);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,r,n,s,l):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(n,this,s,l,this.getLabel())),e.format(c.vertex.name,n,t)):(c.fragment||(c.fragment=e.createFragmentUniform(n,this,s,l,this.getLabel())),e.format(c.fragment.name,n,t))}copy(e){return super.copy(e),this.readonly=e.readonly,this}};var _r=class extends It{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof yv?e:new yv(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,r,n,s,l){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};import{Vector3 as xv}from"three";var Tr=class extends It{constructor(e=0,t,r){super("v3");this.nodeType="Vector3";this.value=e instanceof xv?e:new xv(e,t,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}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,r,n,s,l){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var Ji=class extends It{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof tn?e:new tn(e.r,e.g,e.b,e.a)}generateReadonly(e,t,r,n,s,l){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var sD=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,vv=/[a-z_0-9]+/gi,Se=class extends Be{constructor(e,t,r,n,s){super(s);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,r,n)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,r,n,s){let l,c=0,f=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let h=[];for(;l=vv.exec(this.src);)h.push(l);for(let d=0;d<h.length;d++){let x=h[d],g=x[0],w=this.isMethod?!this.getInputByName(g):!0,S=g;if(this.keywords[g]||this.useKeywords&&w&&tr.containsKeyword(g)){let D=this.keywords[g];if(!D){let C=tr.getKeywordData(g);C.cache&&(D=e.keywords[g]),D=D||tr.getKeyword(g,e),C.cache&&(e.keywords[g]=D)}S=D.build(e)}g!==S&&(f=f.substring(0,x.index+c)+S+f.substring(x.index+g.length+c),c+=S.length-g.length),this.getIncludeByName(S)===void 0&&tr.contains(S)&&e.include(tr.get(S))}return t==="source"?f:this.isMethod?(this.isInterface||e.include(this,void 0,f),this.name):e.format("( "+f+" )",this.getType(e),t)}parse(e,t,r,n){if(this.src=e||"",this.includes=t!=null?t:[],this.extensions=r!=null?r:{},this.keywords=n!=null?n:{},this.isMethod){let s=sD.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let l=s[3].match(vv);if(l){let c=0;for(;c<l.length;){let f=l[c++],h;f==="in"||f==="out"||f==="inout"?h=l[c++]:(h=f,f="");let d=l[c++];this.inputs.push({name:d,type:h,qualifier:f})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}copy(e){return super.copy(e),this.isMethod=e.isMethod,this.useKeywords=e.useKeywords,e.type!==void 0&&(this.type=e.type),this.parse(e.src,e.includes,e.extensions,e.keywords),this}toJSON(e){var r;let t=this.getJSONNode(e);if(!t){t=this.createJSONNode(e),t.src=this.src,t.isMethod=this.isMethod,t.useKeywords=this.useKeywords,this.isMethod||(t.type=this.type),t.extensions=JSON.parse(JSON.stringify(this.extensions));let n={};for(let s in this.keywords)n[s]=this.keywords[s].toJSON(e).uuid;if(t.keywords=n,(r=this.includes)==null?void 0:r.length){let s=[];for(let l=0;l<this.includes.length;l++)s.push(this.includes[l].toJSON(e).uuid);t.includes=s}t.isMethod=this.isMethod,t.inputs=this.inputs}return t.nodeType=this.nodeType,t}fromJSON(e,t){if(super.fromJSON(e,t),e.inputs!==void 0&&(this.inputs=e.inputs),e.isMethod!==void 0&&(this.isMethod=e.isMethod),e.src&&(this.src=e.src),e.isMethod&&(this.isMethod=e.isMethod),e.useKeywords&&(this.useKeywords=e.useKeywords),e.type&&(this.type=e.type),e.extensions&&(this.extensions=e.extensions),e.keywords&&t){this.keywords={};for(let r in e.keywords)this.keywords[r]=t.getNode(e.keywords[r])}return e.includes&&t&&(this.includes=e.includes.map(r=>t.getNode(r))),this}};var aD=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,ep=class extends Be{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||ep.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,r,n,s){this.src=e||"";let l,c,f="",h=aD.exec(e);this.useDefine=s!=null?s:this.src.charAt(0)==="#",h&&h.length>1?(c=h[1],l=h[2],f=h[3]):(l=this.src,c="f"),this.name=l,this.type=c,this.value=f}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,r,n,s){return e.format(this.name,this.getType(e),t)}copy(e){return super.copy(e),this.parse(e.src,void 0,void 0,void 0,e.useDefine),this}},it=ep;it.PI="PI",it.PI2="PI2",it.RECIPROCAL_PI="RECIPROCAL_PI",it.RECIPROCAL_PI2="RECIPROCAL_PI2",it.LOG2="LOG2",it.EPSILON="EPSILON";var lD=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
21
21
|
)*?)}`,"gim"),cD=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Ia=class extends Be{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,r,n,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=lD.exec(e);if(t){let r=t[2],n;for(;n=cD.exec(r);)this.inputs.push({type:n[1],name:n[2]});this.name=t[1]}else this.name="";this.type=this.name}};var Ma=class extends Be{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e!=null?e:0}generate(e,t){e.requires.uv[this.index]=!0;let r=this.index>0?this.index+1:"",n=e.isShader("vertex")?"uv"+r:"vUv"+r;return e.format(n,this.getType(e),t)}copy(e){return super.copy(e),this.index=e.index,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.index=this.index),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.index&&(this.index=e.index),this}};tr.addKeyword("uv",function(){return new Ma});tr.addKeyword("uv2",function(){return new Ma(1)});import{LinearEncoding as uD,sRGBEncoding as fD}from"three";var Co=class extends Be{constructor(e=new Pe,t){super("v4");this.nodeType="ColorSpace";this.factor=new Pe;this.input=e,this.method=t!=null?t:Co.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case uD:return["Linear"];case fD:return["sRGB"];default:return[]}}generate(e,t){var c;let r=this.input.build(e,"v4"),n=this.getType(e),s=Co.Nodes[this.method],l=e.include(s);if(l===Co.LINEAR_TO_LINEAR)return e.format(r,n,t);if(((c=s.inputs)==null?void 0:c.length)===2){let f=this.factor.build(e,"f");return e.format(l+"( "+r+", "+f+" )",n,t)}else return e.format(l+"( "+r+" )",n,t)}fromEncoding(e){let t=Co.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Co.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}copy(e){return super.copy(e),this.input.copy(e.input),this.method=e.method,this.factor.copy(e.factor),this}},zr=Co;zr.Nodes={LinearToLinear:new Se(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
22
22
|
`)),sRGBToLinear:new Se(["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(`
|
|
23
23
|
`)),LinearTosRGB:new Se(["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(`
|
|
@@ -100,7 +100,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
100
100
|
mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
|
|
101
101
|
}
|
|
102
102
|
return mip;
|
|
103
|
-
}`,b);return{bilinearCubeUV:f,roughnessToMip:R,m0:x,cubeUV_maxMipLevel:t}}();var Lo=class extends Be{constructor(e){super("v3");this.nodeType="Normal";this.scope=e!=null?e:Lo.VIEW}getShared(){return this.scope===Lo.WORLD}build(e,t,r,n){let s=e.context[this.scope+"Normal"];return s?s.build(e,t,r,n):super.build(e,t,r)}generate(e,t,r,n,s){let l;switch(this.scope){case Lo.VIEW:e.isShader("vertex")?l="transformedNormal":l="geometryNormal";break;case Lo.LOCAL:e.isShader("vertex")?l="objectNormal":(e.requires.normal=!0,l="vObjectNormal");break;case Lo.WORLD:e.isShader("vertex")?l="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,l="vWNormal");break}return e.format(l,this.getType(e),t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},pr=Lo;pr.LOCAL="local",pr.WORLD="world",pr.VIEW="view",pr.NORMAL="normal";tr.addKeyword("viewNormal",function(){return new pr(pr.VIEW)});tr.addKeyword("localNormal",function(){return new pr(pr.NORMAL)});tr.addKeyword("worldNormal",function(){return new pr(pr.WORLD)});var Zn=class extends Be{constructor(e){super("v3");this.nodeType="Position";this.scope=e!=null?e:Zn.LOCAL}getType(){switch(this.scope){case Zn.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Zn.LOCAL:case Zn.WORLD:return!1}return!0}generate(e,t,r,n,s){let l;switch(this.scope){case Zn.LOCAL:e.isShader("vertex")?l="transformed":(e.requires.position=!0,l="vPosition");break;case Zn.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,l="vWPosition";break;case Zn.VIEW:l=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Zn.PROJECTION:l=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(l,this.getType(),t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},xr=Zn;xr.LOCAL="local",xr.WORLD="world",xr.VIEW="view",xr.PROJECTION="projection";tr.addKeyword("position",function(){return new xr});tr.addKeyword("worldPosition",function(){return new xr(xr.WORLD)});tr.addKeyword("viewPosition",function(){return new xr(xr.VIEW)});var Bn=class extends Be{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e!=null?e:Bn.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case Bn.SPHERE:return"v2"}return this.type}generate(e,t){let r=this.getUnique(e);if(e.isShader("fragment")){let n;switch(this.scope){case Bn.VECTOR:{let s=new pr(pr.VIEW),l=e.context.roughness,c=s.build(e,"v3"),f=new xr(xr.VIEW).build(e,"v3"),h=l?l.build(e,"f"):void 0,d=`reflect( -normalize( ${f} ), ${c} )`;h&&(d=`normalize( mix( ${d}, ${c}, ${h} * ${h} ) )`);let x=`inverseTransformDirection( ${d}, viewMatrix )`;r?(e.addNodeCode(`vec3 reflectVec = ${x};`),n="reflectVec"):n=x;break}case Bn.CUBE:{let s=new Bn(Bn.VECTOR).build(e,"v3"),l="vec3( -"+s+".x, "+s+".yz )";r?(e.addNodeCode(`vec3 reflectCubeVec = ${l};`),n="reflectCubeVec"):n=l;break}case Bn.SPHERE:{let s=new Bn(Bn.VECTOR).build(e,"v3"),l="normalize( ( viewMatrix * vec4( "+s+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";r?(e.addNodeCode(`vec2 reflectSphereVec = ${l};`),n="reflectSphereVec"):n=l;break}}return e.format(n,this.getType(),t)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},Si=Bn;Si.CUBE="cube",Si.SPHERE="sphere",Si.VECTOR="vector";var rp=class extends Be{constructor(e=new Fr,t,r){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Aa(this.value,t!=null?t:new Si(Si.VECTOR),r),this.irradianceNode=new Aa(this.value,new pr(pr.WORLD),new ve(1).setReadonly(!0))}generate(e,t){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}copy(e){return super.copy(e),this.value.copy(e.value),this.radianceNode.copy(e.radianceNode),this.irradianceNode.copy(e.irradianceNode),this}};import{CubeTexture as dD}from"three";var np=class extends It{constructor(e=new dD,t,r){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t!=null?t:new Si,this.bias=r}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){var h,d;if(t==="samplerCube")return this.getTexture(e,t);let r=this.getTexture(e,t),n=(h=this.uv)==null?void 0:h.build(e,"v3"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let l;s?l="texCubeBias( "+r+", "+n+", "+s+" )":l="texCube( "+r+", "+n+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},f=this.getType(e);return e.addContext(c),this.colorSpace=(d=this.colorSpace)!=null?d:new zr(new xt("",f)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,f),e.removeContext(),e.format(l,f,t)}copy(e){return super.copy(e),this.value.copy(e.value),e.uv?this.uv?this.uv.copy(e.uv):this.uv=e.uv.clone():this.uv=void 0,e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,this}};var wv=["x","y","z","w"],
|
|
103
|
+
}`,b);return{bilinearCubeUV:f,roughnessToMip:R,m0:x,cubeUV_maxMipLevel:t}}();var Lo=class extends Be{constructor(e){super("v3");this.nodeType="Normal";this.scope=e!=null?e:Lo.VIEW}getShared(){return this.scope===Lo.WORLD}build(e,t,r,n){let s=e.context[this.scope+"Normal"];return s?s.build(e,t,r,n):super.build(e,t,r)}generate(e,t,r,n,s){let l;switch(this.scope){case Lo.VIEW:e.isShader("vertex")?l="transformedNormal":l="geometryNormal";break;case Lo.LOCAL:e.isShader("vertex")?l="objectNormal":(e.requires.normal=!0,l="vObjectNormal");break;case Lo.WORLD:e.isShader("vertex")?l="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,l="vWNormal");break}return e.format(l,this.getType(e),t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},pr=Lo;pr.LOCAL="local",pr.WORLD="world",pr.VIEW="view",pr.NORMAL="normal";tr.addKeyword("viewNormal",function(){return new pr(pr.VIEW)});tr.addKeyword("localNormal",function(){return new pr(pr.NORMAL)});tr.addKeyword("worldNormal",function(){return new pr(pr.WORLD)});var Zn=class extends Be{constructor(e){super("v3");this.nodeType="Position";this.scope=e!=null?e:Zn.LOCAL}getType(){switch(this.scope){case Zn.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Zn.LOCAL:case Zn.WORLD:return!1}return!0}generate(e,t,r,n,s){let l;switch(this.scope){case Zn.LOCAL:e.isShader("vertex")?l="transformed":(e.requires.position=!0,l="vPosition");break;case Zn.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,l="vWPosition";break;case Zn.VIEW:l=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Zn.PROJECTION:l=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(l,this.getType(),t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},xr=Zn;xr.LOCAL="local",xr.WORLD="world",xr.VIEW="view",xr.PROJECTION="projection";tr.addKeyword("position",function(){return new xr});tr.addKeyword("worldPosition",function(){return new xr(xr.WORLD)});tr.addKeyword("viewPosition",function(){return new xr(xr.VIEW)});var Bn=class extends Be{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e!=null?e:Bn.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case Bn.SPHERE:return"v2"}return this.type}generate(e,t){let r=this.getUnique(e);if(e.isShader("fragment")){let n;switch(this.scope){case Bn.VECTOR:{let s=new pr(pr.VIEW),l=e.context.roughness,c=s.build(e,"v3"),f=new xr(xr.VIEW).build(e,"v3"),h=l?l.build(e,"f"):void 0,d=`reflect( -normalize( ${f} ), ${c} )`;h&&(d=`normalize( mix( ${d}, ${c}, ${h} * ${h} ) )`);let x=`inverseTransformDirection( ${d}, viewMatrix )`;r?(e.addNodeCode(`vec3 reflectVec = ${x};`),n="reflectVec"):n=x;break}case Bn.CUBE:{let s=new Bn(Bn.VECTOR).build(e,"v3"),l="vec3( -"+s+".x, "+s+".yz )";r?(e.addNodeCode(`vec3 reflectCubeVec = ${l};`),n="reflectCubeVec"):n=l;break}case Bn.SPHERE:{let s=new Bn(Bn.VECTOR).build(e,"v3"),l="normalize( ( viewMatrix * vec4( "+s+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";r?(e.addNodeCode(`vec2 reflectSphereVec = ${l};`),n="reflectSphereVec"):n=l;break}}return e.format(n,this.getType(),t)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},Si=Bn;Si.CUBE="cube",Si.SPHERE="sphere",Si.VECTOR="vector";var rp=class extends Be{constructor(e=new Fr,t,r){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Aa(this.value,t!=null?t:new Si(Si.VECTOR),r),this.irradianceNode=new Aa(this.value,new pr(pr.WORLD),new ve(1).setReadonly(!0))}generate(e,t){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}copy(e){return super.copy(e),this.value.copy(e.value),this.radianceNode.copy(e.radianceNode),this.irradianceNode.copy(e.irradianceNode),this}};import{CubeTexture as dD}from"three";var np=class extends It{constructor(e=new dD,t,r){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t!=null?t:new Si,this.bias=r}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){var h,d;if(t==="samplerCube")return this.getTexture(e,t);let r=this.getTexture(e,t),n=(h=this.uv)==null?void 0:h.build(e,"v3"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let l;s?l="texCubeBias( "+r+", "+n+", "+s+" )":l="texCube( "+r+", "+n+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},f=this.getType(e);return e.addContext(c),this.colorSpace=(d=this.colorSpace)!=null?d:new zr(new xt("",f)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,f),e.removeContext(),e.format(l,f,t)}copy(e){return super.copy(e),this.value.copy(e.value),e.uv?this.uv?this.uv.copy(e.uv):this.uv=e.uv.clone():this.uv=void 0,e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,this}};var wv=["x","y","z","w"],vD=["float","vec2","vec3","vec4"],bD={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},SD={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},ip=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.getIncludesCode=function(){function e(t,r){return t.deps.length-r.deps.length}return function(r,n){let s=this.getIncludes(r,n);if(!s)return"";let l="";s=s.sort(e);for(let c=0;c<s.length;c++)s[c].src&&(l+=s[c].src+`
|
|
104
104
|
`);return l}}();this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.requires={uv:[],color:[],lights:!1,fog:!1,transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,modelMatrix:!1,viewMatrix:!1,projectionMatrix:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCube(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2D(a, b, c)","#endif",`
|
|
105
105
|
// NOTE: Include Spline's blending modes. This could be part of BlendNode
|
|
106
106
|
#define SPE_BLENDING_NORMAL 0
|
|
@@ -145,8 +145,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
145
145
|
`}addVaryCode(e){this.addVertexParsCode(e),this.addFragmentParsCode(e)}isCache(e){return this.caches.indexOf(e)!==-1}isSlot(e){return this.slots.indexOf(e)!==-1}define(e,t){this.defines[e]=t===void 0?1:t}require(e){this.requires[e]=!0}isDefined(e){return this.defines[e]!==void 0}getVar(e,t,r,n="varying",s="V",l=""){let c=this.getVars(n),f=c[e];if(!f){let h=c.length;f={name:r||"node"+s+h+(l?"_"+l:""),type:t},c.push(f),c[e]=f}return f}getTempVar(e,t,r,n){return this.getVar(e,t,r,this.shader,"T",n)}getAttribute(e,t){if(!this.attributes[e]){let r=this.getVar(e,t);this.addVertexParsCode("attribute "+t+" "+e+";"),this.addVertexFinalCode(r.name+" = "+e+";"),this.attributes[e]={varying:r,name:e,type:t}}return this.attributes[e]}getCode(e){return[this.prefixCode,this.parsCode[e],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[e],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[e],"uniform"),this.getIncludesCode("consts",e),this.getIncludesCode("structs",e),this.getIncludesCode("functions",e),"void main() {",this.getVarListCode(this.getVars(e)),this.code[e],this.resultCode[e],this.finalCode[e],"}"].join(`
|
|
146
146
|
`)}getVarListCode(e,t){t=t!=null?t:"";let r="";for(let n=0,s=e.length;n<s;++n){let l=e[n],c=l.type,f=l.name,h=l.size,d=this.getFormatByType(c);if(d===void 0)throw new Error("Node pars "+d+" not found.");d.includes("[]")?r+=t+" "+d.substring(0,d.length-2)+" "+f+`[${h}];
|
|
147
147
|
`:r+=t+" "+d+" "+f+`;
|
|
148
|
-
`}return r}getVars(e){return this.inputs.vars[e!=null?e:this.shader]}getNodeData(e){let t=e instanceof Pe?e.uuid:e;return this.nodeData[t]=this.nodeData[t]||{}}createUniform(e,t,r,n,s,l){if(t.includes("[]")){let c=this.inputs.arrayUniforms,f=c.list.length,h=new hu({type:t,size:r.size,name:n||"nodeUA"+f+(l?"_"+l:""),node:r,needsUpdate:s});return c.list.push(h),c[e].push(h),c[e][h.name]=h,this.uniforms[h.name]=h,h}else{let c=this.inputs.uniforms,f=c.list.length,h=new hu({type:t,name:n||"nodeU"+f+(l?"_"+l:""),node:r,needsUpdate:s});return c.list.push(h),c[e].push(h),c[e][h.name]=h,this.uniforms[h.name]=h,h}}createVertexUniform(e,t,r,n,s){return this.createUniform("vertex",e,t,r,n,s)}createFragmentUniform(e,t,r,n,s){return this.createUniform("fragment",e,t,r,n,s)}include(e,t,r){var l;let n;if(e=typeof e=="string"?tr.get(e):e,this.context.include===!1)return e.name;e instanceof Se?n=this.includes.functions:e instanceof it?n=this.includes.consts:e instanceof Ia&&(n=this.includes.structs);let s=n[this.shader]=n[this.shader]||[];if(e){let c=s[e.name];if(c||(c=s[e.name]={node:e,deps:[]},s.push(c),c.src=e.build(this,"source")),e instanceof Se&&t&&s[t.name]&&s[t.name].deps.indexOf(e)===-1&&(s[t.name].deps.push(e),(l=e.includes)==null?void 0:l.length)){let f=0;do this.include(e.includes[f++],t);while(f<e.includes.length)}return r&&(c.src=r),e.name}else throw new Error("Include not found.")}colorToVectorProperties(e){return e.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(e){return e.replace(/c/g,"v3")}getIncludes(e,t){return this.includes[e][t||this.shader]}getConstructorFromLength(e){return
|
|
149
|
-
`;return e.isShader("vertex")?r+="gl_Position = "+t.result+";":r+="gl_FragColor = "+t.result+";",r}copy(e){return super.copy(e),this.value.copy(e.value),this}};var vt=class extends It{constructor(e=0,t,r,n){super("c");this.nodeType="Color";this.value=e instanceof tn?e:new tn(e||0,t,r,n)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,r,n,s,l){r=e.getUUID(r!=null?r:this.getUUID()),n=n!=null?n:this.getType(e);let c=e.getNodeData(r),f=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let h=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${h};`)}return f?this.generateReadonly(e,t,r,n,s,l):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(n,this,s,l,this.getLabel())),e.format(c.vertex.name,n,t)):(c.fragment||(c.fragment=e.createFragmentUniform(n,this,s,l,this.getLabel())),e.format(c.fragment.name,n,t))}generateReadonly(e,t,r,n,s,l){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",n,t)}};import{MathUtils as wi,Vector2 as Ki,Vector3 as Xi,Vector4 as _u}from"three";import{Texture as
|
|
148
|
+
`}return r}getVars(e){return this.inputs.vars[e!=null?e:this.shader]}getNodeData(e){let t=e instanceof Pe?e.uuid:e;return this.nodeData[t]=this.nodeData[t]||{}}createUniform(e,t,r,n,s,l){if(t.includes("[]")){let c=this.inputs.arrayUniforms,f=c.list.length,h=new hu({type:t,size:r.size,name:n||"nodeUA"+f+(l?"_"+l:""),node:r,needsUpdate:s});return c.list.push(h),c[e].push(h),c[e][h.name]=h,this.uniforms[h.name]=h,h}else{let c=this.inputs.uniforms,f=c.list.length,h=new hu({type:t,name:n||"nodeU"+f+(l?"_"+l:""),node:r,needsUpdate:s});return c.list.push(h),c[e].push(h),c[e][h.name]=h,this.uniforms[h.name]=h,h}}createVertexUniform(e,t,r,n,s){return this.createUniform("vertex",e,t,r,n,s)}createFragmentUniform(e,t,r,n,s){return this.createUniform("fragment",e,t,r,n,s)}include(e,t,r){var l;let n;if(e=typeof e=="string"?tr.get(e):e,this.context.include===!1)return e.name;e instanceof Se?n=this.includes.functions:e instanceof it?n=this.includes.consts:e instanceof Ia&&(n=this.includes.structs);let s=n[this.shader]=n[this.shader]||[];if(e){let c=s[e.name];if(c||(c=s[e.name]={node:e,deps:[]},s.push(c),c.src=e.build(this,"source")),e instanceof Se&&t&&s[t.name]&&s[t.name].deps.indexOf(e)===-1&&(s[t.name].deps.push(e),(l=e.includes)==null?void 0:l.length)){let f=0;do this.include(e.includes[f++],t);while(f<e.includes.length)}return r&&(c.src=r),e.name}else throw new Error("Include not found.")}colorToVectorProperties(e){return e.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(e){return e.replace(/c/g,"v3")}getIncludes(e,t){return this.includes[e][t||this.shader]}getConstructorFromLength(e){return vD[e-1]}isTypeMatrix(e){return/^m/.test(e)}getTypeLength(e){return e==="f"?1:parseInt(this.colorToVector(e).substr(1))}getTypeFromLength(e){return e===1?"f":"v"+e}findNode(...e){for(let t=0;t<arguments.length;t++){let r=e[t];if(r==null?void 0:r.isNode)return r}}resolve(...e){for(let t=0;t<arguments.length;t++){let r=e[t];if(r!==void 0){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case mD:case gD:return new np(r);case yD:return new rp(new Fr(r));default:return new Fr(r)}else{if(r.isVector2)return new _r(r);if(r.isVector3)return new Tr(r);if(r.isVector4)return new Ji(r)}}}}format(e,t,r){switch(this.colorToVector(r+" <- "+t)){case"f <- v2":return e+".x";case"f <- v3":return e+".x";case"f <- v4":return e+".x";case"f <- i":case"f <- b":return"float( "+e+" )";case"v2 <- f":return"vec2( "+e+" )";case"v2 <- v3":return e+".xy";case"v2 <- v4":return e+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+e+" ) )";case"v3 <- f":return"vec3( "+e+" )";case"v3 <- v2":return"vec3( "+e+", 0.0 )";case"v3 <- v4":return e+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+e+" ) )";case"v4 <- f":return"vec4( "+e+" )";case"v4 <- v2":return"vec4( "+e+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+e+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+e+" ) )";case"i <- f":case"i <- b":return"int( "+e+" )";case"i <- v2":return"int( "+e+".x )";case"i <- v3":return"int( "+e+".x )";case"i <- v4":return"int( "+e+".x )";case"b <- f":return"( "+e+" != 0.0 )";case"b <- v2":return"( "+e+" != vec2( 0.0 ) )";case"b <- v3":return"( "+e+" != vec3( 0.0 ) )";case"b <- v4":return"( "+e+" != vec4( 0.0 ) )";case"b <- i":return"( "+e+" != 0 )"}return e}getTypeByFormat(e){return bD[e]||e}getFormatByType(e){return SD[e]||e}getUUID(e,t){return t=t!==void 0?t:!0,t&&this.cache&&(e=this.cache+"-"+e),e}getElementByIndex(e){return wv[e]}getIndexByElement(e){return wv.indexOf(e)}isShader(e){return this.shader===e}setShader(e){return this.shader=e,this}mergeDefines(e){for(let t in e)this.defines[t]=e[t];return this.defines}mergeUniform(e){for(let t in e)this.uniforms[t]=e[t];return this.uniforms}getTextureEncodingFromMap(e){let t;return e?e.isTexture&&(t=e.encoding):t=Sv,t===Sv&&this.context.gamma&&(t=xD),t}};var du=class extends Pe{constructor(e=new Pe){super("v4");this.nodeType="Raw";this.value=e}generate(e){let t=this.value.analyzeAndFlow(e,this.type),r=t.code+`
|
|
149
|
+
`;return e.isShader("vertex")?r+="gl_Position = "+t.result+";":r+="gl_FragColor = "+t.result+";",r}copy(e){return super.copy(e),this.value.copy(e.value),this}};var vt=class extends It{constructor(e=0,t,r,n){super("c");this.nodeType="Color";this.value=e instanceof tn?e:new tn(e||0,t,r,n)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,r,n,s,l){r=e.getUUID(r!=null?r:this.getUUID()),n=n!=null?n:this.getType(e);let c=e.getNodeData(r),f=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let h=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${h};`)}return f?this.generateReadonly(e,t,r,n,s,l):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(n,this,s,l,this.getLabel())),e.format(c.vertex.name,n,t)):(c.fragment||(c.fragment=e.createFragmentUniform(n,this,s,l,this.getLabel())),e.format(c.fragment.name,n,t))}generateReadonly(e,t,r,n,s,l){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",n,t)}};import{MathUtils as wi,Vector2 as Ki,Vector3 as Xi,Vector4 as _u}from"three";import{Texture as wD}from"three";var Ye=class extends It{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e!=null?e:0)}generateReadonly(e,t,r,n,s,l){return e.format(this.value.toString(),n,t)}copy(e){return super.copy(e),this.value=e.value,this}};var qe;(function(D){D.POSITION="position",D.LIGHTING="light",D.COLOR="color",D.GRADIENT="gradient",D.NORMAL="normal",D.DEPTH="depth",D.TEXTURE="texture",D.NOISE="noise",D.FRESNEL="fresnel",D.RAINBOW="rainbow",D.TRANSMISSION="transmission",D.POINTS="points",D.MATCAP="matcap",D.LINES="lines",D.DISPLACE="displace"})(qe||(qe={}));var Mt;(function(r){r.POSITION="position",r.LIGHTING="light",r.COLOR="color"})(Mt||(Mt={}));var Bt=class{constructor(e,t,r,n){this.next=void 0;this.uniforms={};this.textures={};this.defines={};if(this.id=e,this.uuid=t,r){this.type=r.type;for(let s in r)s!=="type"&&s!=="calpha"&&(this.uniforms[`f${this.id}_${s}`]=r[s]);for(let s in n)this.defines[s]=n[s]}}copy(e){this.id=e.id,this.type=e.type,this.defines=U({},e.defines);for(let t in e.uniforms)this.getName(t)==="transmissionSamplerMap"||this.getName(t)==="transmissionDepthMap"||(this.uniforms[t]?this.uniforms[t].copy(e.uniforms[t]):this.uniforms[t]=e.uniforms[t].clone());return this}clone(){return new Bt(this.id).copy(this)}fromJSON(e,t){this.id=e.id,this.defines=U({},e.defines);for(let r in e.uniforms)this.uniforms[r]=t.getNode(e.uniforms[r]);if(e.type===qe.TEXTURE){if(!(`f${this.id}_textureSize`in this.uniforms)){let r=this.uniforms[`f${this.id}_texture`].value.image;this.uniforms[`f${e.id}_textureSize`]=new Tr(r.width,r.height)}`f${this.id}_size`in this.uniforms||(this.uniforms[`f${e.id}_size`]=new _r(200,200)),`f${e.id}_axis`in this.uniforms||(this.uniforms[`f${e.id}_axis`]=new Ye(0)),`f${e.id}_projection`in this.uniforms||(this.uniforms[`f${e.id}_projection`]=new Ye(0))}else e.type===qe.NOISE?(`f${e.id}_noiseType`in this.uniforms||(this.uniforms[`f${e.id}_noiseType`]=new Ye(0)),`f${e.id}_size`in this.uniforms||(this.uniforms[`f${e.id}_size`]=new Tr(-1,-1,-1))):e.type===qe.DEPTH&&(`f${e.id}_isWorldSpace`in this.uniforms||(this.uniforms[`f${e.id}_isWorldSpace`]=new ve(1)));return this}toJSON(e){let t={};for(let n in this.uniforms)t[n]=this.uniforms[n].toJSON(e).uuid;return{id:this.id,type:this.type,defines:JSON.parse(JSON.stringify(this.defines)),uniforms:t,next:this.next==null?void 0:this.next.toJSON(e)}}copyUniforms(e){for(let t in this.uniforms){let r=this.getName(t);r!==void 0&&e.uniforms[`f${e.id}_${r}`]&&r!=="transmissionDepthMap"&&r!=="transmissionSamplerMap"&&this.uniforms[t].copy(e.uniforms[`f${e.id}_${r}`])}return this}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let r=`f${this.id}_${e}`;this.hasValueByKey(r)&&t!==void 0&&(this.uniforms[r].value=t)}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getValues(){let e={type:this.type};for(let t in this.uniforms){let r=this.getName(t);if(r===void 0)continue;let s=this.uniforms[`f${this.id}_${r}`].value;s!==void 0&&(Array.isArray(s)?e[r]=s.map(l=>l.clone?l.clone():l):e[r]=s.clone?s.clone():s)}return e}getName(e){let r=/f\d+_(.*)/.exec(e);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let r=this.getName(t);r&&e.push(r)}return e}isEqual(e){for(let t in e.uniforms){let r=e.getName(t);if(!r)return!1;let n=this.getValue(r),s=e.uniforms[t].value;if(s.value instanceof wD){if(n.image!==s.image)return!1}else if(Array.isArray(s)){let l=n;for(let c=0,f=l.length;c<f;++c)if(l[c]!==s[c])return!1}else{let l=n;if(l.equals){if(!l.equals(s))return!1}else if(n!==s)return!1}}return!0}dispose(){}};function Nv(i){let e=i instanceof Bt?i.type:i;return e==="texture"||e==="displace_map"||e==="matcap"}var mu=class extends It{constructor(e){super("b");this.nodeType="Bool";this.value=e!=null?e:!1}generateReadonly(e,t,r,n){return e.format(this.value?"true":"false",n,t)}copy(e){return super.copy(e),this.value=e.value,this}};import{Vector4 as Cv}from"three";var Os=class extends It{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof Cv?new Array(e).fill(t):new Array(e).fill(new Cv(0))}copy(e){return super.copy(e),this.value=e.value.map(t=>t.clone()),this}};var Ps=class extends It{constructor(e=1,t){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(t)?t:typeof t=="number"?new Array(e).fill(t):new Array(e).fill(0)}copy(e){return super.copy(e),this.size=e.size,this.value=[...e.value],this}};import{Matrix3 as ND}from"three";var Oa=class extends It{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e!=null?e:new ND}generateReadonly(e,t,r,n,s,l){return e.format("mat3("+this.value.elements.join(", ")+")",n,t)}copy(e){return super.copy(e),this.elements=e.elements,this}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Ds;(function(n){n[n.UV=0]="UV",n[n.PLANAR=1]="PLANAR",n[n.SPHERICAL=2]="SPHERICAL",n[n.CYLINDRICAL=3]="CYLINDRICAL"})(Ds||(Ds={}));var Pa=class extends Be{constructor(e=new Fr,t,r,n,s,l,c,f){super("v3");this.nodeType="CustomTexture";this.firstTime=!0,this.texture=e,this.textureSize=t,this.crop=r,this.projection=n,this.axis=s,this.size=l,this.mat=new Oa(this.texture.value.matrix),this.alpha=c,this.mode=f,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let r;switch(this.projection.value){case 3:r=e.include(Pa.Nodes.cylindrical);break;case 2:r=e.include(Pa.Nodes.spherical);break;case 1:let s=new Se(`
|
|
150
150
|
vec3 g${this.uuid.toString().replace(/-/g,"")}_planarTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
|
|
151
151
|
|
|
152
152
|
vec2 uvs = ( mat * vec3( (g${this.uuid.toString().replace(/-/g,"")}_vCustomUv * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
|
|
@@ -725,7 +725,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
725
725
|
|
|
726
726
|
return matcapColor.rgb;
|
|
727
727
|
}
|
|
728
|
-
`)}}();var Ir=class{constructor(e){this.id=2,this.layerCount=2,this.uuid=wi.generateUUID(),this.needsUpdate=!1,this._material=e,this._layerNodes=[];let t=this._createLayer({id:0,type:qe.COLOR});this._material.color=t.color,this._material.alpha===void 0&&(this._material.alpha=new ve(1));let r=new ve(1),n=new Ye(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=r,this._material.shadingBlend=n),this._layerNodes.push({id:0,type:Mt.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),this._layerNodes.push({id:1,type:Mt.LIGHTING,alpha:r,mode:n}),this.head=t.layer,this.head.next=new Bt(1,void 0,{type:qe.LIGHTING,alpha:r,mode:n}),this.attachLightNodes(this.getLightLayer())}get material(){return this._material}set material(e){var s;this._material=e;let t,r,n=this.head;for(;n!==void 0;){if(n.type===qe.LIGHTING){t=n.uniforms[`f${n.id}_alpha`],r=n.uniforms[`f${n.id}_mode`];break}n=n.next}"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=t,this._material.shadingBlend=r),this.attachLightNodes((s=e.userData.layers)==null?void 0:s.getLightLayer()),this.blendColors(),this.blendAfterColors(),this.blendPositions()}getLayersOfType(e){let t=[],r=this.head;for(;r;)r.type===e&&t.push(r),r=r.next;return t}addLayer(e){var n;if(e.id=(n=e.id)!=null?n:++this.id,this.layerCount++,e.type===qe.LIGHTING){let s=this.createLightLayer(e);return this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}let t=this._createLayer(e),r=t.layer;if(this.head===void 0)this.head=r;else{let s=this.head;for(;s.next!=null;)s=s.next;s.next=r}return t.color&&this._layerNodes.push({id:r.id,type:Mt.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),t.position&&this._layerNodes.push({id:r.id,type:Mt.POSITION,position:t.position}),this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),r}addLayerBeforeAt(e,t){var c;let r=this.head;e.id=(c=e.id)!=null?c:++this.id,this.layerCount++;let n=this._createLayer(e),s=n.layer;s.next=t;let l=0;if(r===t)this.head=s,n.color&&this._layerNodes.splice(0,0,{id:s.id,type:Mt.COLOR,color:n.color,alpha:n.alpha,mode:n.mode}),n.position&&this._layerNodes.splice(0,0,{id:s.id,type:Mt.POSITION,position:n.position});else{for(l=1;(r==null?void 0:r.next)!==t;)r=r==null?void 0:r.next,l++;r.next=s,n.color&&this._layerNodes.splice(l,0,{id:s.id,type:Mt.COLOR,color:n.color,alpha:n.alpha,mode:n.mode}),n.position&&this._layerNodes.splice(l,0,{id:s.id,type:Mt.POSITION,position:n.position})}return this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}addLayerAt(e,t){var s;t.id=(s=t.id)!=null?s:++this.id,this.layerCount++;let r=this._createLayer(t),n=r.layer;if(r.color&&this._layerNodes.splice(e,0,{id:n.id,type:Mt.COLOR,color:r.color,alpha:r.alpha,mode:r.mode}),r.position&&this._layerNodes.splice(e,0,{id:n.id,type:Mt.POSITION,position:r.position}),e==0)n.next=this.head,this.head=n;else{let l=this.head,c=this.head.next;for(let f=0;f<e-1;f++)l=c,c=c.next;n.next=c,l.next=n}return this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}removeLayer(e){let t=this.head,r,n=0;if((t==null?void 0:t.id)==e)this.head=t.next;else for(n=1,r=t,t=t==null?void 0:t.next;t!=null;){if(t.id==e){r.next=t.next;break}n++,r=t,t=t.next}return this.cleanupChangedLayer(t),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.uuid=wi.generateUUID(),this.layerCount--,n}changeLayer(e,t){let r,n=this.head,s;if((n==null?void 0:n.id)==e){let l=this._createLayer(U({id:e,uuid:n.uuid},t));s=l.layer,s.next=n.next,this.head=s,l.color&&(this._layerNodes[0]={id:s.id,type:Mt.COLOR,color:l.color,alpha:l.alpha,mode:l.mode}),l.position&&(this._layerNodes[0]={id:s.id,type:Mt.POSITION,position:l.position}),s.uniforms[`f${e}_mode`].value=n.uniforms[`f${e}_mode`].value,s.uniforms[`f${e}_alpha`].value=n.uniforms[`f${e}_alpha`].value}else{r=n,n=n.next;let l=1;for(;n!=null;){if(n.id==e){let c=this._createLayer(U({id:e,uuid:n.uuid},t));s=c.layer,r.next=s,s.next=n.next,c.color&&(this._layerNodes[l]={id:e,type:Mt.COLOR,color:c.color,alpha:c.alpha,mode:c.mode}),c.position&&(this._layerNodes[l]={id:e,type:Mt.POSITION,position:c.position}),s.uniforms[`f${e}_mode`].value=n.uniforms[`f${e}_mode`].value,s.uniforms[`f${e}_alpha`].value=n.uniforms[`f${e}_alpha`].value;break}r=n,n=n.next,l++}}return this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}getLayer(e){let t=this.head;for(;t!=null&&t.id!=e;)t=t.next;return t}getLayerByUuid(e){let t=this.head;for(;t!==void 0;){if(t.uuid===e)return t;t=t.next}}getLayers(){let e=[],t=this.head;for(;t!=null;)e.push(t),t=t.next;return e}getLayerPosition(e){let t=this.head,r=0;for(;t!==void 0&&t.id!=e;)r++,t=t.next;return r}getDefines(){}getBeforeProgram(){}getLightingProgram(){}getAfterProgram(){}getVarPrograms(){}getUniforms(){}moveLayer(e,t){let r,n=this.head,s;if(e==0)r=this.head,this.head=r.next;else{for(let c=0;c<e;c++)s=n,n=n.next;s.next=n.next,r=n}if(n=this.head,s=void 0,t==0)r.next=this.head,this.head=r;else{for(let c=0;c<t-1;c++)n=n.next;r.next=n==null?void 0:n.next,n.next=r}let l=this._layerNodes.splice(e,1)[0];this._layerNodes.splice(t,0,l),this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors()}updateLayerUniform(){this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors()}copy(e){this.needsUpdate=!1,this.layerCount=e.layerCount,this._layerNodes=[],this.layerCount=0,this.head=void 0,this.rebuildLayerNodes(this.head,e.head);let t=e.head,r=this.head;for(;t.next!=null;)this.rebuildLayerNodes(r,t.next),r=r.next,t=t.next;return this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}createLightLayer(e){let t=new ve(e.alpha),r=new Ye(e.mode);this._material.shadingAlpha=t,this._material.shadingBlend=r,this._layerNodes.push({id:e.id,type:Mt.LIGHTING,alpha:t,mode:r});let n=new Bt(e.id,void 0,{type:qe.LIGHTING,alpha:t,mode:r});if(this.head===void 0)this.head=n;else{let s=this.head;for(;s.next!=null;)s=s.next;s.next=n}return this.attachLightNodes(this.getLightLayer()),n}rebuildLayerNodes(e,t,r=!1){if(t.type===qe.LIGHTING){let n=r?t.uniforms[`f${t.id}_alpha`]:new ve(t.uniforms[`f${t.id}_alpha`].value),s=r?t.uniforms[`f${t.id}_mode`]:new Ye(t.uniforms[`f${t.id}_mode`].value);this._material.shadingAlpha=n,this._material.shadingBlend=s,this._layerNodes.push({id:t.id,type:Mt.LIGHTING,alpha:n,mode:s}),this.head===void 0?this.head=new Bt(t.id,t.uuid,{type:qe.LIGHTING,alpha:n,mode:s}):e&&(e.next=new Bt(t.id,t.uuid,{type:qe.LIGHTING,alpha:n,mode:s})),this.attachLightNodes(t)}else{let n={type:t.type,id:t.id};for(let s in t.uniforms){let l=t.getName(s);if(!l)continue;let c=`f${t.id}_${l}`;if(Array.isArray(t.uniforms[c].value))n[l]=t.uniforms[c].value.map(f=>f.clone&&!r?f.clone():f);else{let f=t.uniforms[c].value;if(l==="transmissionDepthMap"){n[l]=f;continue}f!=null&&(n[l]=f.clone&&!r&&!f.isRenderTargetTexture?f.clone():f)}}this.addLayer(n)}}attachLightNodes(e){var n,s,l,c,f,h,d,x,g,w,S;let t={},r=this.getLightLayer();switch(this._material.userData.category){case"Lambert":t.emissive=new vt((s=(n=e==null?void 0:e.getValue("emissive"))==null?void 0:n.clone())!=null?s:0);break;case"Phong":t.shininess=new ve((l=e==null?void 0:e.getValue("shininess"))!=null?l:30),t.specular=new vt((f=(c=e==null?void 0:e.getValue("specular"))==null?void 0:c.clone())!=null?f:1118481);break;case"Toon":t.shininess=new ve((h=e==null?void 0:e.getValue("shininess"))!=null?h:30),t.specular=new vt((x=(d=e==null?void 0:e.getValue("specular"))==null?void 0:d.clone())!=null?x:1118481);break;case"Physical":t.roughness=new ve((g=e==null?void 0:e.getValue("roughness"))!=null?g:.3),t.metalness=new ve((w=e==null?void 0:e.getValue("metalness"))!=null?w:0),t.reflectivity=new ve((S=e==null?void 0:e.getValue("reflectivity"))!=null?S:.5);break;default:break}Object.keys(t).forEach(D=>{this._material[D]=t[D],r.uniforms[`f${r.id}_${D}`]=t[D]})}clone(e){return new Ir(e).copy(this)}toJSON(e){return{id:this.id,uuid:this.uuid,head:this.head.toJSON(e)}}fromJSON(e,t,r){let n=new Bt(e.head.id,void 0,{type:e.head.type}).fromJSON(e.head,t),s=e.head.next,l=n;for(;s!=null;)l.next=new Bt(s.id,void 0,{type:s.type}).fromJSON(s,t),s=s.next,l=l.next;this._layerNodes=[],this.head=void 0,this.rebuildLayerNodes(this.head,n,!0);let c=n;for(l=this.head;c.next!=null;)this.rebuildLayerNodes(l,c.next,!0),l=l.next,c=c.next;return this._material=r,this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}getLightLayer(){var t;let e=this.head;for(;e!==void 0&&e.type!=="light";)e=(t=e.next)!=null?t:e;return e}dispose(){let e=this.head;for(this._layerNodes=[],this.layerCount=0;e!==void 0;)e.hasOwnProperty("dispose")===!0&&e.dispose(),e=e.next;this.head=void 0}_createLayer(e){var r,n,s,l,c,f,h,d,x,g,w,S,D,C,G,B,P,W,M,q,E,b,R,T,z,A,$,he,re,Ne,ye,Me,Fe,k,H,_,J,ee,oe,se,ce,ue,K,ae,ne,Ce,Y,le,pe,xe,_e,de,we,Ve,Ge,Qe,bt,Lt,At,sr,Ur,Ht,kr,wn,Nn,dt,Wt,ar,Ao,Oo,Po,ro,no,Do,Mr,io,Jt,ti,Bo;let t=e.type;switch(t){case qe.COLOR:{let Ee=new vt((r=e.color)!=null?r:Yt),Xe=new ve((n=e.alpha)!=null?n:1),He=new xt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");He.keywords.alpha=Xe;let $e=new Ye((s=e.mode)!=null?s:0);return Ee.alpha=Xe,{layer:new Bt(e.id,e.uuid,{type:t,color:Ee,alpha:Xe,calpha:He,mode:$e}),color:Ee,alpha:He,mode:$e}}case qe.TEXTURE:{let Ee=(l=e.texture)!=null?l:new bi,Xe=Ee.matrix;e.mat&&Xe.copy(e.mat),Ee.needsUpdate=!0;let He=new ve((c=e.crop)!=null?c:0),$e=new Ye((f=e.projection)!=null?f:0),tt=new Ye((h=e.axis)!=null?h:0),at=new _r(e.size?new Ki(e.size[0],e.size[1]):new Ki(100,100)),mt=new ve((d=e.alpha)!=null?d:1),gt=new Ye((x=e.mode)!=null?x:0),ct=new Fr(Ee),St=new Tr((g=e.textureSize)!=null?g:new Xi(Ee.image?Ee.image.width:0,Ee.image?Ee.image.height:0)),Rt=new gu(ct,St,He,$e,tt,at,mt,gt),Ar=new xt(Rt.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,texture:ct,textureSize:St,crop:He,projection:$e,axis:tt,size:at,mat:Rt.mat,alpha:mt,calpha:Ar,mode:gt}),color:Rt,alpha:Ar,mode:gt}}case qe.MATCAP:{let Ee=(w=e.texture)!=null?w:new bi;Ee.needsUpdate=!0;let Xe=new ve((S=e.alpha)!=null?S:1),He=new Fr(Ee),$e=new Ye((D=e.mode)!=null?D:0),tt=new Lu(He,Xe,$e),at=new xt(tt.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,texture:He,alpha:Xe,calpha:at,mode:$e}),color:tt,alpha:at,mode:$e}}case qe.FRESNEL:{let Ee=new vt((C=e.color)!=null?C:16777215),Xe=new ve((G=e.bias)!=null?G:.1),He=new ve((B=e.scale)!=null?B:1),$e=new ve((P=e.intensity)!=null?P:2),tt=new ve((W=e.factor)!=null?W:1),at=new ve((M=e.alpha)!=null?M:1),mt=new Ye((q=e.mode)!=null?q:0),gt=new yu(Ee,Xe,He,$e,tt,at,mt),ct=new xt(gt.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,color:Ee,bias:Xe,scale:He,intensity:$e,factor:tt,alpha:at,calpha:ct,mode:mt}),color:gt,alpha:ct,mode:mt}}case qe.RAINBOW:{let Ee=new ve((E=e.filmThickness)!=null?E:30),Xe=new ve((b=e.movement)!=null?b:0),He=new Tr((R=e.wavelengths)!=null?R:new Xi(0,0,0)),$e=new ve((T=e.noiseStrength)!=null?T:0),tt=new ve((z=e.noiseScale)!=null?z:1),at=new Tr((A=e.offset)!=null?A:new Xi(0,0,0)),mt=new ve(($=e.alpha)!=null?$:1),gt=new xu(Ee,Xe,He,$e,tt,at,mt),ct=new xt(gt.calpha,"f"),St=new Ye((he=e.mode)!=null?he:0);return{layer:new Bt(e.id,e.uuid,{type:t,filmThickness:Ee,movement:Xe,wavelengths:He,noiseStrength:$e,noiseScale:tt,offset:at,alpha:mt,calpha:ct,mode:St}),color:gt,alpha:ct,mode:St}}case qe.TRANSMISSION:{let Ee=new ve((re=e.thickness)!=null?re:10),Xe=new ve((Ne=e.ior)!=null?Ne:1.5),He=new ve((ye=e.roughness)!=null?ye:.5),$e=new _r((Me=e.transmissionSamplerSize)!=null?Me:new Ki(2048,2048)),tt=(Fe=e.transmissionSamplerMap)!=null?Fe:new bi,at=(k=e.transmissionDepthMap)!=null?k:new bi,mt=new Fr(tt),gt=new Fr(at),ct=window.innerWidth,St=window.innerHeight,Rt=ct>=St?new _r(St/ct,1):new _r(1,ct/St),Ar=new ve((H=e.alpha)!=null?H:1),Cn=new vu(Ee,Xe,He,$e,mt,gt,Rt,Ar),Ln=new xt(Cn.calpha,"f"),Rn=new Ye((_=e.mode)!=null?_:0);return{layer:new Bt(e.id,e.uuid,{type:t,thickness:Ee,ior:Xe,roughness:He,transmissionSamplerSize:$e,transmissionSamplerMap:mt,transmissionDepthMap:gt,aspectRatio:Rt,alpha:Ar,calpha:Ln,mode:Rn}),color:Cn,alpha:Ln,mode:Rn}}case qe.DEPTH:{let Ee=new Ye((J=e.gradientType)!=null?J:0),Xe=new mu((ee=e.smooth)!=null?ee:!1),He=new ve((oe=e.near)!=null?oe:50),$e=new ve((se=e.far)!=null?se:200),tt=new ve((ce=e.isVector)!=null?ce:1),at=new ve((ue=e.isWorldSpace)!=null?ue:0),mt=new Tr((K=e.origin)!=null?K:new Xi),gt=new Tr((ae=e.direction)!=null?ae:new Xi),ct=new Ye((ne=e.num)!=null?ne:0),St;e.colors?St=new Os(ct.value+1,e.colors):(St=new Os(ct.value+1,new _u(0,0,0,1)),St.value[1]=new _u(1,1,1,1));let Rt;e.steps?Rt=new Ps(e.steps.length,e.steps):(Rt=new Ps(10,1),Rt.value[0]=0);let Ar=new ve((Ce=e.alpha)!=null?Ce:1),Cn=new Ye((Y=e.mode)!=null?Y:0),Ln=new Cu(Ee,Xe,He,$e,tt,at,mt,gt,St,Rt,ct,Ar),Rn=new xt(Ln.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,gradientType:Ee,smooth:Xe,near:He,far:$e,isVector:tt,isWorldSpace:at,origin:mt,direction:gt,colors:St,steps:Rt,num:ct,alpha:Ar,calpha:Rn,mode:Cn}),color:Ln,alpha:Rn,mode:Cn}}case qe.NOISE:{let Ee=new ve((le=e.scale)!=null?le:1),Xe=new Tr((pe=e.size)!=null?pe:new Xi(100,100,100)),He=new ve((xe=e.move)!=null?xe:1),$e=new _r((_e=e.fA)!=null?_e:new Ki(1.7,9.2)),tt=new _r((de=e.fB)!=null?de:new Ki(8.3,2.8)),at=new _r((we=e.distortion)!=null?we:new Ki(1,1)),mt=new Ji(e.colorA),gt=new Ji(e.colorB),ct=new Ji(e.colorC),St=new Ji(e.colorD),Rt=new ve((Ve=e.alpha)!=null?Ve:1),Ar=new Ye((Ge=e.mode)!=null?Ge:0),Cn=new Ye((Qe=e.noiseType)!=null?Qe:0),Ln=new wu(Ee,Xe,He,$e,tt,at,mt,gt,ct,St,Rt,Cn),Rn=new xt(Ln.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,scale:Ee,size:Xe,move:He,fA:$e,fB:tt,distortion:at,colorA:mt,colorB:gt,colorC:ct,colorD:St,alpha:Rt,calpha:Rn,mode:Ar,noiseType:Cn}),color:Ln,alpha:Rn,mode:Ar}}case qe.NORMAL:{let Ee=new Tr((bt=e.cnormal)!=null?bt:new Xi(1,1,1)),Xe=new ve((Lt=e.alpha)!=null?Lt:1),He=new Ye((At=e.mode)!=null?At:0),$e=new bu(Ee,Xe),tt=new xt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return tt.keywords.alpha=Xe,{layer:new Bt(e.id,e.uuid,{type:t,cnormal:Ee,alpha:Xe,calpha:tt,mode:He}),color:$e,alpha:tt,mode:He}}case qe.GRADIENT:{let Ee=new Ye((sr=e.gradientType)!=null?sr:0),Xe=new mu((Ur=e.smooth)!=null?Ur:!1),He;e.colors?He=new Os(e.colors.length,e.colors):(He=new Os(10,new _u(0,0,0,1)),He.value[1]=new _u(1,1,1,1));let $e;e.steps?$e=new Ps(e.steps.length,e.steps):($e=new Ps(10,1),$e.value[0]=0);let tt=new _r((Ht=e.offset)!=null?Ht:new Ki(0,0)),at=new _r((kr=e.morph)!=null?kr:new Ki(0,0)),mt=new ve((wn=e.angle)!=null?wn:0),gt=new ve((Nn=e.alpha)!=null?Nn:1),ct=new Ye((dt=e.mode)!=null?dt:0),St=new Su(Ee,Xe,He,$e,tt,at,mt,gt),Rt=new xt(St.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,gradientType:Ee,smooth:Xe,colors:He,steps:$e,offset:tt,morph:at,angle:mt,alpha:gt,calpha:Rt,mode:ct}),color:St,alpha:Rt,mode:ct}}case qe.DISPLACE:{let Ee=new Ye((Wt=e.displacementType)!=null?Wt:0);if(Ee.value===0){let Xe=new Tr((ar=e.offset)!=null?ar:new Xi(0,0,0)),He=new ve((Ao=e.scale)!=null?Ao:10),$e=new ve((Oo=e.intensity)!=null?Oo:8),tt=new ve((Po=e.movement)!=null?Po:1),at=new ve((ro=e.alpha)!=null?ro:1),mt=new Ye((no=e.mode)!=null?no:0),gt=new Ye((Do=e.noiseType)!=null?Do:0),ct=new Da(Ee,$e,tt,Xe,He,gt);return{layer:new Bt(e.id,e.uuid,{displacementType:Ee,type:t,offset:Xe,scale:He,intensity:$e,movement:tt,alpha:at,mode:mt,noiseType:gt}),position:ct}}else if(Ee.value===1){let Xe=(Mr=e.texture)!=null?Mr:new bi,He=Xe.matrix;e.mat&&He.copy(e.mat),Xe.needsUpdate=!0;let $e=new ve((io=e.intensity)!=null?io:8),tt=new Fr(Xe),at=new ve((Jt=e.crop)!=null?Jt:0),mt=new ve((ti=e.alpha)!=null?ti:1),gt=new Ye((Bo=e.mode)!=null?Bo:0),ct=new Da(Ee,$e,tt,at);return{layer:new Bt(e.id,e.uuid,{displacementType:Ee,type:t,intensity:$e,texture:tt,crop:at,mat:ct.mat,alpha:mt,mode:gt}),position:ct}}return{}}}return{}}blendColors(){let e=this._layerNodes.findIndex(r=>r.type===Mt.COLOR),t=this._layerNodes.findIndex(r=>r.type===Mt.LIGHTING);if(e!==-1&&e<t){let r=this._layerNodes[e].color;for(let n=e+1;n<t;++n){let s=this._layerNodes[n];s.type===Mt.COLOR&&(r=new Nu(r,s.color,s.alpha,s.mode))}this._material.color=r}else this._material.color=void 0}blendAfterColors(){let e=new xt("outgoingLight","f"),t=this._layerNodes.findIndex(r=>r.type===Mt.LIGHTING);if(this._layerNodes.length>t+1){for(let r=t+1;r<this._layerNodes.length;++r){let n=this._layerNodes[r];n.type===Mt.COLOR&&(e=new Nu(e,n.color,n.alpha,n.mode))}"afterColor"in this._material&&(this._material.afterColor=e)}else"afterColor"in this._material&&(this._material.afterColor=void 0)}blendPositions(){let e=this._layerNodes.filter(t=>t.type===Mt.POSITION);if(e.length>0){let t=e[0].position;for(let r=1;r<e.length;++r)e[r]&&(t=new rn(t,e[r].position,rn.ADD),t=new rn(t,new ve(.5).setReadonly(!0),rn.MUL));this._material.position=t}else this._material.position=void 0}cleanupChangedLayer(e){switch(this._layerNodes=this._layerNodes.filter(t=>t.id!==e.id),e.type){case qe.DISPLACE:{this.blendPositions();break}default:{this.blendColors(),this.blendAfterColors();break}}}};var vn=class extends _D{constructor(e,t,r){super(r);this.isNodeMaterial=!0;this.type="NodeMaterial";this.wireframeLinecap="";this.wireframeLinejoin="";this.uniformsBackup={};this.userData={type:"",category:"",nodeType:""};this.fog=!0,this.vertex=e!=null?e:new du(new xr(xr.PROJECTION)),this.fragment=t!=null?t:new du(new vt(Yt)),this.updaters=[],this.isDetached=!0,this.dithering=!0,this.onBeforeCompile=this._onBeforeCompile}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}_onBeforeCompile(e,t){this.build({renderer:t}),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}_getLayerStack(e){let t=new Ir(this);return e&&(async()=>{for(;e.image===void 0;)await new Promise(r=>requestAnimationFrame(r));t.addLayerAt(1,{type:qe.TEXTURE,texture:e}),this.dispose()})(),t}clampUniformsForPreview(e,t){let r=(n,s,l)=>Math.min(Math.max(n,s),l);if(this.userData.layers){for(let n of this.userData.layers.getLayers())if(n.type==qe.DISPLACE){this.uniformsBackup[`f${n.id}_intensity`]=n.uniforms[`f${n.id}_intensity`].value;let s=r(n.uniforms[`f${n.id}_intensity`].value,e,t);n.uniforms[`f${n.id}_intensity`].value=s}}}restoreClampedUniforms(){if(this.userData.layers)for(let e of this.userData.layers.getLayers())e.type==qe.DISPLACE&&(e.uniforms[`f${e.id}_intensity`].value=this.uniformsBackup[`f${e.id}_intensity`])}customProgramCacheKey(){return this.getHash()}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(e){var r;e=e!=null?e:{};let t=(r=e.builder)!=null?r:new ip;return t.setMaterial(this,e.renderer),t.build(this.vertex,this.fragment),this.vertexShader=t.getCode("vertex"),this.fragmentShader=t.getCode("fragment"),this.defines=t.defines,this.uniforms=t.uniforms,this.extensions=t.extensions,this.updaters=t.updaters,this.fog=t.requires.fog,this.lights=t.requires.lights,this.transparent=t.requires.transparent||this.blending>LD,this}getHash(){let e="{";return e+='"vertex":'+this.vertex.getHash()+",",e+='"fragment":'+this.fragment.getHash(),e+="}",e}copy(e){let t=this.uuid;for(let r in e)this[r]=e[r];return this.uuid=t,e.userData!==void 0&&(this.userData=JSON.parse(JSON.stringify(e.userData))),this}toJSON(e){let t=this.userData.layers;this.userData.layers=void 0;let r=super.toJSON(e);return r.type="ShaderMaterial",r.userData={type:this.userData.type,category:this.userData.category,nodeType:this.type,layers:t.toJSON(e)},r.vertex=this.vertex.toJSON(e).uuid,r.fragment=this.fragment.toJSON(e).uuid,delete r.vertexShader,delete r.fragmentShader,delete r.color,delete r.shininess,delete r.specular,delete r.roughness,delete r.metalness,delete r.uniforms,e&&!e.materials[this.uuid]&&(e.materials[this.uuid]=r),this.userData.layers=t,r}fromJSON(e,t){var r;this.defines=(r=e.defines)!=null?r:{},this.depthFunc=e.depthFunc,this.depthWrite=e.depthWrite,this.side=e.side!==void 0?e.side:TD,this.transparent=e.transparent,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.wireframe=e.wireframe,this.userData.layers.fromJSON(e.userData.layers,t,this)}};Object.defineProperties(vn.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(i){i===!0&&this.version++,this.needsCompile=i},get:function(){return this.needsCompile}}});import{UniformsLib as ID,UniformsUtils as MD}from"three";var hp=class extends Pe{constructor(){super("basic");this.nodeType="Basic";this.color=new vt(Yt)}generate(e){let t;if(e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(MD.merge([ID.fog])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
|
|
728
|
+
`)}}();var Ir=class{constructor(e){this.id=2,this.layerCount=2,this.uuid=wi.generateUUID(),this.needsUpdate=!1,this._material=e,this._layerNodes=[];let t=this._createLayer({id:0,type:qe.COLOR});this._material.color=t.color,this._material.alpha===void 0&&(this._material.alpha=new ve(1));let r=new ve(1),n=new Ye(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=r,this._material.shadingBlend=n),this._layerNodes.push({id:0,type:Mt.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),this._layerNodes.push({id:1,type:Mt.LIGHTING,alpha:r,mode:n}),this.head=t.layer,this.head.next=new Bt(1,void 0,{type:qe.LIGHTING,alpha:r,mode:n}),this.attachLightNodes(this.getLightLayer())}get material(){return this._material}set material(e){var s;this._material=e;let t,r,n=this.head;for(;n!==void 0;){if(n.type===qe.LIGHTING){t=n.uniforms[`f${n.id}_alpha`],r=n.uniforms[`f${n.id}_mode`];break}n=n.next}"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=t,this._material.shadingBlend=r),this.attachLightNodes((s=e.userData.layers)==null?void 0:s.getLightLayer()),this.blendColors(),this.blendAfterColors(),this.blendPositions()}getLayersOfType(e){let t=[],r=this.head;for(;r;)r.type===e&&t.push(r),r=r.next;return t}addLayer(e){var n;if(e.id=(n=e.id)!=null?n:++this.id,this.layerCount++,e.type===qe.LIGHTING){let s=this.createLightLayer(e);return this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}let t=this._createLayer(e),r=t.layer;if(this.head===void 0)this.head=r;else{let s=this.head;for(;s.next!=null;)s=s.next;s.next=r}return t.color&&this._layerNodes.push({id:r.id,type:Mt.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),t.position&&this._layerNodes.push({id:r.id,type:Mt.POSITION,position:t.position}),this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),r}addLayerBeforeAt(e,t){var c;let r=this.head;e.id=(c=e.id)!=null?c:++this.id,this.layerCount++;let n=this._createLayer(e),s=n.layer;s.next=t;let l=0;if(r===t)this.head=s,n.color&&this._layerNodes.splice(0,0,{id:s.id,type:Mt.COLOR,color:n.color,alpha:n.alpha,mode:n.mode}),n.position&&this._layerNodes.splice(0,0,{id:s.id,type:Mt.POSITION,position:n.position});else{for(l=1;(r==null?void 0:r.next)!==t;)r=r==null?void 0:r.next,l++;r.next=s,n.color&&this._layerNodes.splice(l,0,{id:s.id,type:Mt.COLOR,color:n.color,alpha:n.alpha,mode:n.mode}),n.position&&this._layerNodes.splice(l,0,{id:s.id,type:Mt.POSITION,position:n.position})}return this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}addLayerAt(e,t){var s;t.id=(s=t.id)!=null?s:++this.id,this.layerCount++;let r=this._createLayer(t),n=r.layer;if(r.color&&this._layerNodes.splice(e,0,{id:n.id,type:Mt.COLOR,color:r.color,alpha:r.alpha,mode:r.mode}),r.position&&this._layerNodes.splice(e,0,{id:n.id,type:Mt.POSITION,position:r.position}),e==0)n.next=this.head,this.head=n;else{let l=this.head,c=this.head.next;for(let f=0;f<e-1;f++)l=c,c=c.next;n.next=c,l.next=n}return this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}removeLayer(e){let t=this.head,r,n=0;if((t==null?void 0:t.id)==e)this.head=t.next;else for(n=1,r=t,t=t==null?void 0:t.next;t!=null;){if(t.id==e){r.next=t.next;break}n++,r=t,t=t.next}return this.cleanupChangedLayer(t),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.uuid=wi.generateUUID(),this.layerCount--,n}changeLayer(e,t){let r,n=this.head,s;if((n==null?void 0:n.id)==e){let l=this._createLayer(U({id:e,uuid:n.uuid},t));s=l.layer,s.next=n.next,this.head=s,l.color&&(this._layerNodes[0]={id:s.id,type:Mt.COLOR,color:l.color,alpha:l.alpha,mode:l.mode}),l.position&&(this._layerNodes[0]={id:s.id,type:Mt.POSITION,position:l.position}),s.uniforms[`f${e}_mode`].value=n.uniforms[`f${e}_mode`].value,s.uniforms[`f${e}_alpha`].value=n.uniforms[`f${e}_alpha`].value}else{r=n,n=n.next;let l=1;for(;n!=null;){if(n.id==e){let c=this._createLayer(U({id:e,uuid:n.uuid},t));s=c.layer,r.next=s,s.next=n.next,c.color&&(this._layerNodes[l]={id:e,type:Mt.COLOR,color:c.color,alpha:c.alpha,mode:c.mode}),c.position&&(this._layerNodes[l]={id:e,type:Mt.POSITION,position:c.position}),s.uniforms[`f${e}_mode`].value=n.uniforms[`f${e}_mode`].value,s.uniforms[`f${e}_alpha`].value=n.uniforms[`f${e}_alpha`].value;break}r=n,n=n.next,l++}}return this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}getLayer(e){let t=this.head;for(;t!=null&&t.id!=e;)t=t.next;return t}getLayerByUuid(e){let t=this.head;for(;t!==void 0;){if(t.uuid===e)return t;t=t.next}}getLayers(){let e=[],t=this.head;for(;t!=null;)e.push(t),t=t.next;return e}getLayerPosition(e){let t=this.head,r=0;for(;t!==void 0&&t.id!=e;)r++,t=t.next;return r}getDefines(){}getBeforeProgram(){}getLightingProgram(){}getAfterProgram(){}getVarPrograms(){}getUniforms(){}moveLayer(e,t){let r,n=this.head,s;if(e==0)r=this.head,this.head=r.next;else{for(let c=0;c<e;c++)s=n,n=n.next;s.next=n.next,r=n}if(n=this.head,s=void 0,t==0)r.next=this.head,this.head=r;else{for(let c=0;c<t-1;c++)n=n.next;r.next=n==null?void 0:n.next,n.next=r}let l=this._layerNodes.splice(e,1)[0];this._layerNodes.splice(t,0,l),this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors()}updateLayerUniform(){this.uuid=wi.generateUUID(),this.blendColors(),this.blendAfterColors()}copy(e){this.needsUpdate=!1,this.layerCount=e.layerCount,this._layerNodes=[],this.layerCount=0,this.head=void 0,this.rebuildLayerNodes(this.head,e.head);let t=e.head,r=this.head;for(;t.next!=null;)this.rebuildLayerNodes(r,t.next),r=r.next,t=t.next;return this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}createLightLayer(e){let t=new ve(e.alpha),r=new Ye(e.mode);this._material.shadingAlpha=t,this._material.shadingBlend=r,this._layerNodes.push({id:e.id,type:Mt.LIGHTING,alpha:t,mode:r});let n=new Bt(e.id,void 0,{type:qe.LIGHTING,alpha:t,mode:r});if(this.head===void 0)this.head=n;else{let s=this.head;for(;s.next!=null;)s=s.next;s.next=n}return this.attachLightNodes(this.getLightLayer()),n}rebuildLayerNodes(e,t,r=!1){if(t.type===qe.LIGHTING){let n=r?t.uniforms[`f${t.id}_alpha`]:new ve(t.uniforms[`f${t.id}_alpha`].value),s=r?t.uniforms[`f${t.id}_mode`]:new Ye(t.uniforms[`f${t.id}_mode`].value);this._material.shadingAlpha=n,this._material.shadingBlend=s,this._layerNodes.push({id:t.id,type:Mt.LIGHTING,alpha:n,mode:s}),this.head===void 0?this.head=new Bt(t.id,t.uuid,{type:qe.LIGHTING,alpha:n,mode:s}):e&&(e.next=new Bt(t.id,t.uuid,{type:qe.LIGHTING,alpha:n,mode:s})),this.attachLightNodes(t)}else{let n={type:t.type,id:t.id};for(let s in t.uniforms){let l=t.getName(s);if(!l)continue;let c=`f${t.id}_${l}`;if(Array.isArray(t.uniforms[c].value))n[l]=t.uniforms[c].value.map(f=>f.clone&&!r?f.clone():f);else{let f=t.uniforms[c].value;if(l==="transmissionDepthMap"){n[l]=f;continue}f!=null&&(n[l]=f.clone&&!r&&!f.isRenderTargetTexture?f.clone():f)}}this.addLayer(n)}}attachLightNodes(e){var n,s,l,c,f,h,d,x,g,w,S;let t={},r=this.getLightLayer();switch(this._material.userData.category){case"Lambert":t.emissive=new vt((s=(n=e==null?void 0:e.getValue("emissive"))==null?void 0:n.clone())!=null?s:0);break;case"Phong":t.shininess=new ve((l=e==null?void 0:e.getValue("shininess"))!=null?l:30),t.specular=new vt((f=(c=e==null?void 0:e.getValue("specular"))==null?void 0:c.clone())!=null?f:1118481);break;case"Toon":t.shininess=new ve((h=e==null?void 0:e.getValue("shininess"))!=null?h:30),t.specular=new vt((x=(d=e==null?void 0:e.getValue("specular"))==null?void 0:d.clone())!=null?x:1118481);break;case"Physical":t.roughness=new ve((g=e==null?void 0:e.getValue("roughness"))!=null?g:.3),t.metalness=new ve((w=e==null?void 0:e.getValue("metalness"))!=null?w:0),t.reflectivity=new ve((S=e==null?void 0:e.getValue("reflectivity"))!=null?S:.5);break;default:break}Object.keys(t).forEach(D=>{this._material[D]=t[D],r.uniforms[`f${r.id}_${D}`]=t[D]})}clone(e){return new Ir(e).copy(this)}toJSON(e){return{id:this.id,uuid:this.uuid,head:this.head.toJSON(e)}}fromJSON(e,t,r){let n=new Bt(e.head.id,void 0,{type:e.head.type}).fromJSON(e.head,t),s=e.head.next,l=n;for(;s!=null;)l.next=new Bt(s.id,void 0,{type:s.type}).fromJSON(s,t),s=s.next,l=l.next;this._layerNodes=[],this.head=void 0,this.rebuildLayerNodes(this.head,n,!0);let c=n;for(l=this.head;c.next!=null;)this.rebuildLayerNodes(l,c.next,!0),l=l.next,c=c.next;return this._material=r,this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}getLightLayer(){var t;let e=this.head;for(;e!==void 0&&e.type!=="light";)e=(t=e.next)!=null?t:e;return e}dispose(){let e=this.head;for(this._layerNodes=[],this.layerCount=0;e!==void 0;)e.hasOwnProperty("dispose")===!0&&e.dispose(),e=e.next;this.head=void 0}_createLayer(e){var r,n,s,l,c,f,h,d,x,g,w,S,D,C,G,B,P,W,M,q,E,b,R,T,z,A,$,he,re,Ne,ye,Me,Fe,k,H,_,J,ee,oe,se,ce,ue,K,ae,ne,Ce,Y,le,pe,xe,_e,de,we,Ve,Ge,Qe,bt,Lt,At,sr,Ur,Ht,kr,wn,Nn,dt,Wt,ar,Ao,Oo,Po,ro,no,Do,Mr,io,Jt,ti,Bo;let t=e.type;switch(t){case qe.COLOR:{let Ee=new vt((r=e.color)!=null?r:Yt),Xe=new ve((n=e.alpha)!=null?n:1),He=new xt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");He.keywords.alpha=Xe;let $e=new Ye((s=e.mode)!=null?s:0);return Ee.alpha=Xe,{layer:new Bt(e.id,e.uuid,{type:t,color:Ee,alpha:Xe,calpha:He,mode:$e}),color:Ee,alpha:He,mode:$e}}case qe.TEXTURE:{let Ee=(l=e.texture)!=null?l:new bi,Xe=Ee.matrix;e.mat&&Xe.copy(e.mat),Ee.needsUpdate=!0;let He=new ve((c=e.crop)!=null?c:0),$e=new Ye((f=e.projection)!=null?f:0),tt=new Ye((h=e.axis)!=null?h:0),at=new _r(e.size?new Ki(e.size[0],e.size[1]):new Ki(100,100)),mt=new ve((d=e.alpha)!=null?d:1),gt=new Ye((x=e.mode)!=null?x:0),ct=new Fr(Ee),St=new Tr((g=e.textureSize)!=null?g:new Xi(Ee.image?Ee.image.width:0,Ee.image?Ee.image.height:0)),Rt=new gu(ct,St,He,$e,tt,at,mt,gt),Ar=new xt(Rt.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,texture:ct,textureSize:St,crop:He,projection:$e,axis:tt,size:at,mat:Rt.mat,alpha:mt,calpha:Ar,mode:gt}),color:Rt,alpha:Ar,mode:gt}}case qe.MATCAP:{let Ee=(w=e.texture)!=null?w:new bi;Ee.needsUpdate=!0;let Xe=new ve((S=e.alpha)!=null?S:1),He=new Fr(Ee),$e=new Ye((D=e.mode)!=null?D:0),tt=new Lu(He,Xe,$e),at=new xt(tt.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,texture:He,alpha:Xe,calpha:at,mode:$e}),color:tt,alpha:at,mode:$e}}case qe.FRESNEL:{let Ee=new vt((C=e.color)!=null?C:16777215),Xe=new ve((G=e.bias)!=null?G:.1),He=new ve((B=e.scale)!=null?B:1),$e=new ve((P=e.intensity)!=null?P:2),tt=new ve((W=e.factor)!=null?W:1),at=new ve((M=e.alpha)!=null?M:1),mt=new Ye((q=e.mode)!=null?q:0),gt=new yu(Ee,Xe,He,$e,tt,at,mt),ct=new xt(gt.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,color:Ee,bias:Xe,scale:He,intensity:$e,factor:tt,alpha:at,calpha:ct,mode:mt}),color:gt,alpha:ct,mode:mt}}case qe.RAINBOW:{let Ee=new ve((E=e.filmThickness)!=null?E:30),Xe=new ve((b=e.movement)!=null?b:0),He=new Tr((R=e.wavelengths)!=null?R:new Xi(0,0,0)),$e=new ve((T=e.noiseStrength)!=null?T:0),tt=new ve((z=e.noiseScale)!=null?z:1),at=new Tr((A=e.offset)!=null?A:new Xi(0,0,0)),mt=new ve(($=e.alpha)!=null?$:1),gt=new xu(Ee,Xe,He,$e,tt,at,mt),ct=new xt(gt.calpha,"f"),St=new Ye((he=e.mode)!=null?he:0);return{layer:new Bt(e.id,e.uuid,{type:t,filmThickness:Ee,movement:Xe,wavelengths:He,noiseStrength:$e,noiseScale:tt,offset:at,alpha:mt,calpha:ct,mode:St}),color:gt,alpha:ct,mode:St}}case qe.TRANSMISSION:{let Ee=new ve((re=e.thickness)!=null?re:10),Xe=new ve((Ne=e.ior)!=null?Ne:1.5),He=new ve((ye=e.roughness)!=null?ye:.5),$e=new _r((Me=e.transmissionSamplerSize)!=null?Me:new Ki(2048,2048)),tt=(Fe=e.transmissionSamplerMap)!=null?Fe:new bi,at=(k=e.transmissionDepthMap)!=null?k:new bi,mt=new Fr(tt),gt=new Fr(at),ct=window.innerWidth,St=window.innerHeight,Rt=ct>=St?new _r(St/ct,1):new _r(1,ct/St),Ar=new ve((H=e.alpha)!=null?H:1),Cn=new vu(Ee,Xe,He,$e,mt,gt,Rt,Ar),Ln=new xt(Cn.calpha,"f"),Rn=new Ye((_=e.mode)!=null?_:0);return{layer:new Bt(e.id,e.uuid,{type:t,thickness:Ee,ior:Xe,roughness:He,transmissionSamplerSize:$e,transmissionSamplerMap:mt,transmissionDepthMap:gt,aspectRatio:Rt,alpha:Ar,calpha:Ln,mode:Rn}),color:Cn,alpha:Ln,mode:Rn}}case qe.DEPTH:{let Ee=new Ye((J=e.gradientType)!=null?J:0),Xe=new mu((ee=e.smooth)!=null?ee:!1),He=new ve((oe=e.near)!=null?oe:50),$e=new ve((se=e.far)!=null?se:200),tt=new ve((ce=e.isVector)!=null?ce:1),at=new ve((ue=e.isWorldSpace)!=null?ue:0),mt=new Tr((K=e.origin)!=null?K:new Xi),gt=new Tr((ae=e.direction)!=null?ae:new Xi),ct=new Ye((ne=e.num)!=null?ne:0),St;e.colors?St=new Os(ct.value+1,e.colors):(St=new Os(ct.value+1,new _u(0,0,0,1)),St.value[1]=new _u(1,1,1,1));let Rt;e.steps?Rt=new Ps(e.steps.length,e.steps):(Rt=new Ps(10,1),Rt.value[0]=0);let Ar=new ve((Ce=e.alpha)!=null?Ce:1),Cn=new Ye((Y=e.mode)!=null?Y:0),Ln=new Cu(Ee,Xe,He,$e,tt,at,mt,gt,St,Rt,ct,Ar),Rn=new xt(Ln.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,gradientType:Ee,smooth:Xe,near:He,far:$e,isVector:tt,isWorldSpace:at,origin:mt,direction:gt,colors:St,steps:Rt,num:ct,alpha:Ar,calpha:Rn,mode:Cn}),color:Ln,alpha:Rn,mode:Cn}}case qe.NOISE:{let Ee=new ve((le=e.scale)!=null?le:1),Xe=new Tr((pe=e.size)!=null?pe:new Xi(100,100,100)),He=new ve((xe=e.move)!=null?xe:1),$e=new _r((_e=e.fA)!=null?_e:new Ki(1.7,9.2)),tt=new _r((de=e.fB)!=null?de:new Ki(8.3,2.8)),at=new _r((we=e.distortion)!=null?we:new Ki(1,1)),mt=new Ji(e.colorA),gt=new Ji(e.colorB),ct=new Ji(e.colorC),St=new Ji(e.colorD),Rt=new ve((Ve=e.alpha)!=null?Ve:1),Ar=new Ye((Ge=e.mode)!=null?Ge:0),Cn=new Ye((Qe=e.noiseType)!=null?Qe:0),Ln=new wu(Ee,Xe,He,$e,tt,at,mt,gt,ct,St,Rt,Cn),Rn=new xt(Ln.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,scale:Ee,size:Xe,move:He,fA:$e,fB:tt,distortion:at,colorA:mt,colorB:gt,colorC:ct,colorD:St,alpha:Rt,calpha:Rn,mode:Ar,noiseType:Cn}),color:Ln,alpha:Rn,mode:Ar}}case qe.NORMAL:{let Ee=new Tr((bt=e.cnormal)!=null?bt:new Xi(1,1,1)),Xe=new ve((Lt=e.alpha)!=null?Lt:1),He=new Ye((At=e.mode)!=null?At:0),$e=new bu(Ee,Xe),tt=new xt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return tt.keywords.alpha=Xe,{layer:new Bt(e.id,e.uuid,{type:t,cnormal:Ee,alpha:Xe,calpha:tt,mode:He}),color:$e,alpha:tt,mode:He}}case qe.GRADIENT:{let Ee=new Ye((sr=e.gradientType)!=null?sr:0),Xe=new mu((Ur=e.smooth)!=null?Ur:!1),He;e.colors?He=new Os(e.colors.length,e.colors):(He=new Os(10,new _u(0,0,0,1)),He.value[1]=new _u(1,1,1,1));let $e;e.steps?$e=new Ps(e.steps.length,e.steps):($e=new Ps(10,1),$e.value[0]=0);let tt=new _r((Ht=e.offset)!=null?Ht:new Ki(0,0)),at=new _r((kr=e.morph)!=null?kr:new Ki(0,0)),mt=new ve((wn=e.angle)!=null?wn:0),gt=new ve((Nn=e.alpha)!=null?Nn:1),ct=new Ye((dt=e.mode)!=null?dt:0),St=new Su(Ee,Xe,He,$e,tt,at,mt,gt),Rt=new xt(St.calpha,"f");return{layer:new Bt(e.id,e.uuid,{type:t,gradientType:Ee,smooth:Xe,colors:He,steps:$e,offset:tt,morph:at,angle:mt,alpha:gt,calpha:Rt,mode:ct}),color:St,alpha:Rt,mode:ct}}case qe.DISPLACE:{let Ee=new Ye((Wt=e.displacementType)!=null?Wt:0);if(Ee.value===0){let Xe=new Tr((ar=e.offset)!=null?ar:new Xi(0,0,0)),He=new ve((Ao=e.scale)!=null?Ao:10),$e=new ve((Oo=e.intensity)!=null?Oo:8),tt=new ve((Po=e.movement)!=null?Po:1),at=new ve((ro=e.alpha)!=null?ro:1),mt=new Ye((no=e.mode)!=null?no:0),gt=new Ye((Do=e.noiseType)!=null?Do:0),ct=new Da(Ee,$e,tt,Xe,He,gt);return{layer:new Bt(e.id,e.uuid,{displacementType:Ee,type:t,offset:Xe,scale:He,intensity:$e,movement:tt,alpha:at,mode:mt,noiseType:gt}),position:ct}}else if(Ee.value===1){let Xe=(Mr=e.texture)!=null?Mr:new bi,He=Xe.matrix;e.mat&&He.copy(e.mat),Xe.needsUpdate=!0;let $e=new ve((io=e.intensity)!=null?io:8),tt=new Fr(Xe),at=new ve((Jt=e.crop)!=null?Jt:0),mt=new ve((ti=e.alpha)!=null?ti:1),gt=new Ye((Bo=e.mode)!=null?Bo:0),ct=new Da(Ee,$e,tt,at);return{layer:new Bt(e.id,e.uuid,{displacementType:Ee,type:t,intensity:$e,texture:tt,crop:at,mat:ct.mat,alpha:mt,mode:gt}),position:ct}}return{}}}return{}}blendColors(){let e=this._layerNodes.findIndex(r=>r.type===Mt.COLOR),t=this._layerNodes.findIndex(r=>r.type===Mt.LIGHTING);if(e!==-1&&e<t){let r=this._layerNodes[e].color;for(let n=e+1;n<t;++n){let s=this._layerNodes[n];s.type===Mt.COLOR&&(r=new Nu(r,s.color,s.alpha,s.mode))}this._material.color=r}else this._material.color=void 0}blendAfterColors(){let e=new xt("outgoingLight","f"),t=this._layerNodes.findIndex(r=>r.type===Mt.LIGHTING);if(this._layerNodes.length>t+1){for(let r=t+1;r<this._layerNodes.length;++r){let n=this._layerNodes[r];n.type===Mt.COLOR&&(e=new Nu(e,n.color,n.alpha,n.mode))}"afterColor"in this._material&&(this._material.afterColor=e)}else"afterColor"in this._material&&(this._material.afterColor=void 0)}blendPositions(){let e=this._layerNodes.filter(t=>t.type===Mt.POSITION);if(e.length>0){let t=e[0].position;for(let r=1;r<e.length;++r)e[r]&&(t=new rn(t,e[r].position,rn.ADD),t=new rn(t,new ve(.5).setReadonly(!0),rn.MUL));this._material.position=t}else this._material.position=void 0}cleanupChangedLayer(e){switch(this._layerNodes=this._layerNodes.filter(t=>t.id!==e.id),e.type){case qe.DISPLACE:{this.blendPositions();break}default:{this.blendColors(),this.blendAfterColors();break}}}};var vn=class extends LD{constructor(e,t,r){super(r);this.isNodeMaterial=!0;this.type="NodeMaterial";this.wireframeLinecap="";this.wireframeLinejoin="";this.uniformsBackup={};this.userData={type:"",category:"",nodeType:""};this.fog=!0,this.vertex=e!=null?e:new du(new xr(xr.PROJECTION)),this.fragment=t!=null?t:new du(new vt(Yt)),this.updaters=[],this.isDetached=!0,this.dithering=!0,this.onBeforeCompile=this._onBeforeCompile}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}_onBeforeCompile(e,t){this.build({renderer:t}),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}_getLayerStack(e){let t=new Ir(this);return e&&(async()=>{for(;e.image===void 0;)await new Promise(r=>requestAnimationFrame(r));t.addLayerAt(1,{type:qe.TEXTURE,texture:e}),this.dispose()})(),t}clampUniformsForPreview(e,t){let r=(n,s,l)=>Math.min(Math.max(n,s),l);if(this.userData.layers){for(let n of this.userData.layers.getLayers())if(n.type==qe.DISPLACE){this.uniformsBackup[`f${n.id}_intensity`]=n.uniforms[`f${n.id}_intensity`].value;let s=r(n.uniforms[`f${n.id}_intensity`].value,e,t);n.uniforms[`f${n.id}_intensity`].value=s}}}restoreClampedUniforms(){if(this.userData.layers)for(let e of this.userData.layers.getLayers())e.type==qe.DISPLACE&&(e.uniforms[`f${e.id}_intensity`].value=this.uniformsBackup[`f${e.id}_intensity`])}customProgramCacheKey(){return this.getHash()}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(e){var r;e=e!=null?e:{};let t=(r=e.builder)!=null?r:new ip;return t.setMaterial(this,e.renderer),t.build(this.vertex,this.fragment),this.vertexShader=t.getCode("vertex"),this.fragmentShader=t.getCode("fragment"),this.defines=t.defines,this.uniforms=t.uniforms,this.extensions=t.extensions,this.updaters=t.updaters,this.fog=t.requires.fog,this.lights=t.requires.lights,this.transparent=t.requires.transparent||this.blending>CD,this}getHash(){let e="{";return e+='"vertex":'+this.vertex.getHash()+",",e+='"fragment":'+this.fragment.getHash(),e+="}",e}copy(e){let t=this.uuid;for(let r in e)this[r]=e[r];return this.uuid=t,e.userData!==void 0&&(this.userData=JSON.parse(JSON.stringify(e.userData))),this}toJSON(e){let t=this.userData.layers;this.userData.layers=void 0;let r=super.toJSON(e);return r.type="ShaderMaterial",r.userData={type:this.userData.type,category:this.userData.category,nodeType:this.type,layers:t.toJSON(e)},r.vertex=this.vertex.toJSON(e).uuid,r.fragment=this.fragment.toJSON(e).uuid,delete r.vertexShader,delete r.fragmentShader,delete r.color,delete r.shininess,delete r.specular,delete r.roughness,delete r.metalness,delete r.uniforms,e&&!e.materials[this.uuid]&&(e.materials[this.uuid]=r),this.userData.layers=t,r}fromJSON(e,t){var r;this.defines=(r=e.defines)!=null?r:{},this.depthFunc=e.depthFunc,this.depthWrite=e.depthWrite,this.side=e.side!==void 0?e.side:_D,this.transparent=e.transparent,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.wireframe=e.wireframe,this.userData.layers.fromJSON(e.userData.layers,t,this)}};Object.defineProperties(vn.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(i){i===!0&&this.version++,this.needsCompile=i},get:function(){return this.needsCompile}}});import{UniformsLib as TD,UniformsUtils as ID}from"three";var hp=class extends Pe{constructor(){super("basic");this.nodeType="Basic";this.color=new vt(Yt)}generate(e){let t;if(e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(ID.merge([TD.fog])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
|
|
729
729
|
`));let n=["#include <beginnormal_vertex>",`
|
|
730
730
|
#if !defined( USE_LAYER_DISPLACE )
|
|
731
731
|
#include <defaultnormal_vertex>
|
|
@@ -745,7 +745,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
745
745
|
`];r&&n.push(r.code,r.result?"displaced_position = "+r.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),t=n.join(`
|
|
746
746
|
`)}else{this.color===void 0&&(this.color=new vt(Yt)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let r=this.color.flow(e,"c",{slot:"color"}),n=this.alpha?this.alpha.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=n!==void 0,e.addParsCode(["#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
|
|
747
747
|
`));let l=["#include <normal_fragment_begin>",r.code];n&&l.push(n.code,"#ifdef ALPHATEST"," if ( "+n.result+" <= ALPHATEST ) discard;","#endif"),s?l.push(s.code,`vec3 outgoingLight = ${r.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):l.push(`vec3 finalColor = ${r.result};`),n?l.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${n.result} );`):l.push("gl_FragColor = vec4("+r.result+", 1.0 );"),l.push("#include <fog_fragment>","#include <dithering_fragment>"),t=l.join(`
|
|
748
|
-
`)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var pp=class extends vn{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}constructor(e=new hp,t){super(e,e,t);this.type="BasicNodeMaterial",this.fragment=e}};var vr=class extends pp{constructor(e,t,r){super(t,e);this.userData.type="BasicMaterial",this.userData.category="Basic",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Ir){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new vr(void 0,n);return s.fromJSON(t,r),s}static fromMaterial(e){let t=new vr(e.map?{map:e.map}:{}),r=t.fragment;return r.color.value.copy(e.color),r.alpha.value=e.opacity,t}dispose(){super.dispose()}};import{UniformsLib as Lv,UniformsUtils as
|
|
748
|
+
`)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var pp=class extends vn{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}constructor(e=new hp,t){super(e,e,t);this.type="BasicNodeMaterial",this.fragment=e}};var vr=class extends pp{constructor(e,t,r){super(t,e);this.userData.type="BasicMaterial",this.userData.category="Basic",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Ir){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new vr(void 0,n);return s.fromJSON(t,r),s}static fromMaterial(e){let t=new vr(e.map?{map:e.map}:{}),r=t.fragment;return r.color.value.copy(e.color),r.alpha.value=e.opacity,t}dispose(){super.dispose()}};import{UniformsLib as Lv,UniformsUtils as MD}from"three";var dp=class extends Pe{constructor(){super("phong");this.nodeType="Phong";this.color=new vt(Yt),this.specular=new vt(1118481),this.shininess=new ve(30),this.shadingAlpha=new ve(1),this.shadingBlend=new Ye(0)}build(e){let t;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(MD.merge([Lv.fog,Lv.lights])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
|
|
749
749
|
`));let n=["#include <beginnormal_vertex>",`
|
|
750
750
|
#ifndef USE_LAYER_DISPLACE
|
|
751
751
|
#include <defaultnormal_vertex>
|
|
@@ -779,7 +779,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
779
779
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result}, ${c.result} );
|
|
780
780
|
}
|
|
781
781
|
`),f&&d.push(f.code,`outgoingLight = spe_blend(outgoingLight, ${f.result}, 1.0, SPE_BLENDING_NORMAL);`),h?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
|
|
782
|
-
`)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var mp=class extends vn{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}constructor(e=new dp,t){super(e,e,t);this.type="PhongNodeMaterial",this.fragment=e}};var bn=class extends mp{constructor(e,t,r){super(t,e);this.userData.type="PhongMaterial",this.userData.category="Phong",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Ir){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new bn(void 0,n);return s.fromJSON(t,r),s}static fromMaterial(e){let t=new bn(e.map?{map:e.map}:{}),r=t.fragment;return r.color.value.copy(e.color),r.alpha.value=e.opacity,t}dispose(){super.dispose()}};import{UniformsLib as _v,UniformsUtils as
|
|
782
|
+
`)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var mp=class extends vn{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}constructor(e=new dp,t){super(e,e,t);this.type="PhongNodeMaterial",this.fragment=e}};var bn=class extends mp{constructor(e,t,r){super(t,e);this.userData.type="PhongMaterial",this.userData.category="Phong",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Ir){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new bn(void 0,n);return s.fromJSON(t,r),s}static fromMaterial(e){let t=new bn(e.map?{map:e.map}:{}),r=t.fragment;return r.color.value.copy(e.color),r.alpha.value=e.opacity,t}dispose(){super.dispose()}};import{UniformsLib as _v,UniformsUtils as AD}from"three";var gp=class extends Pe{constructor(){super("lambert");this.nodeType="Lambert";this.color=new vt(Yt),this.emissive=new vt(0),this.emissiveIntensity=new ve(1),this.shadingAlpha=new ve(1),this.shadingBlend=new Ye(0)}build(e){let t;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(AD.merge([_v.fog,_v.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
|
|
783
783
|
`));let n=["#include <beginnormal_vertex>",`
|
|
784
784
|
#ifndef USE_LAYER_DISPLACE
|
|
785
785
|
#include <defaultnormal_vertex>
|
|
@@ -885,7 +885,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
885
885
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result}, ${c.result} );
|
|
886
886
|
}
|
|
887
887
|
`),f&&d.push(f.code,`outgoingLight = spe_blend(outgoingLight, ${f.result}, 1.0, SPE_BLENDING_NORMAL);`),h?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
|
|
888
|
-
`)}return t}copy(e){return super.copy(e),this.emissiveIntensity=e.emissiveIntensity.clone(),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),e.emissive&&(this.emissive=e.emissive.clone()),this}};var yp=class extends vn{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get emissive(){return this.fragment.emissive}set emissive(e){this.fragment.emissive=e}get emissiveIntensity(){return this.fragment.emissiveIntensity}set emissiveIntensity(e){this.fragment.emissiveIntensity=e}constructor(e=new gp,t){super(e,e,t);this.type="LambertNodeMaterial",this.fragment=e}};var Ba=class extends yp{constructor(e,t,r){super(t,e);this.userData.type="LambertMaterial",this.userData.category="Lambert",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Ir){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new Ba(void 0,n);return s.fromJSON(t,r),s}dispose(){super.dispose()}};import{UniformsLib as Tv,UniformsUtils as
|
|
888
|
+
`)}return t}copy(e){return super.copy(e),this.emissiveIntensity=e.emissiveIntensity.clone(),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),e.emissive&&(this.emissive=e.emissive.clone()),this}};var yp=class extends vn{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get emissive(){return this.fragment.emissive}set emissive(e){this.fragment.emissive=e}get emissiveIntensity(){return this.fragment.emissiveIntensity}set emissiveIntensity(e){this.fragment.emissiveIntensity=e}constructor(e=new gp,t){super(e,e,t);this.type="LambertNodeMaterial",this.fragment=e}};var Ba=class extends yp{constructor(e,t,r){super(t,e);this.userData.type="LambertMaterial",this.userData.category="Lambert",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Ir){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new Ba(void 0,n);return s.fromJSON(t,r),s}dispose(){super.dispose()}};import{UniformsLib as Tv,UniformsUtils as OD}from"three";var xp=class extends Pe{constructor(){super("toon");this.nodeType="Toon";this.color=new vt(Yt),this.specular=new vt(1118481),this.shininess=new ve(30),this.shadingAlpha=new ve(1),this.shadingBlend=new Ye(0)}build(e){let t;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(OD.merge([Tv.fog,Tv.lights])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
|
|
889
889
|
`));let n=["#include <beginnormal_vertex>",`
|
|
890
890
|
#ifndef USE_LAYER_DISPLACE
|
|
891
891
|
#include <defaultnormal_vertex>
|
|
@@ -939,7 +939,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
939
939
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result}, ${c.result} );
|
|
940
940
|
}
|
|
941
941
|
`),f&&d.push(f.code,`outgoingLight = spe_blend(outgoingLight, ${f.result}, 1.0, SPE_BLENDING_NORMAL);`),h?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
|
|
942
|
-
`)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var vp=class extends vn{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}constructor(e=new xp,t){super(e,e,t);this.type="ToonNodeMaterial",this.fragment=e}};var Ga=class extends vp{constructor(e,t,r){super(t,e);this.userData.type="ToonMaterial",this.userData.category="Toon",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Ir){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new Ga(void 0,n);return s.fromJSON(t,r),s}dispose(){super.dispose()}};import{UniformsLib as bp,UniformsUtils as
|
|
942
|
+
`)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var vp=class extends vn{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}constructor(e=new xp,t){super(e,e,t);this.type="ToonNodeMaterial",this.fragment=e}};var Ga=class extends vp{constructor(e,t,r){super(t,e);this.userData.type="ToonMaterial",this.userData.category="Toon",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Ir){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new Ga(void 0,n);return s.fromJSON(t,r),s}dispose(){super.dispose()}};import{UniformsLib as bp,UniformsUtils as PD}from"three";var Sp=class extends Pe{constructor(){super("standard");this.nodeType="Standard";this.color=new vt(Yt),this.roughness=new ve(.3),this.metalness=new ve(0),this.reflectivity=new ve(.5),this.shadingAlpha=new ve(1),this.shadingBlend=new Ye(0)}build(e){let t;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(PD.merge([bp.fog,bp.lights])),bp.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
|
|
943
943
|
`));let n=["#include <beginnormal_vertex>",`
|
|
944
944
|
#if !defined( USE_LAYER_DISPLACE )
|
|
945
945
|
#include <defaultnormal_vertex>
|
|
@@ -973,5 +973,5 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
973
973
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${c.result}, ${f.result} );
|
|
974
974
|
}
|
|
975
975
|
`),h&&g.push(h.code,`outgoingLight = spe_blend(outgoingLight, ${h.result}, 1.0, SPE_BLENDING_NORMAL);`),d?g.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):g.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),g.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=g.join(`
|
|
976
|
-
`)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.roughness=e.roughness.clone(),this.metalness=e.metalness.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.reflectivity&&(this.reflectivity=e.reflectivity.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var wp=class extends vn{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get roughness(){return this.fragment.roughness}set roughness(e){this.fragment.roughness=e}get metalness(){return this.fragment.metalness}set metalness(e){this.fragment.metalness=e}get reflectivity(){return this.fragment.reflectivity}set reflectivity(e){this.fragment.reflectivity=e}constructor(e=new Sp,t){super(e,e,t);this.type="StandardNodeMaterial",this.fragment=e}};var ja=class extends wp{constructor(e,t,r){super(t,e);this.userData.type="PhysicalMaterial",this.userData.category="Physical",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Ir){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new ja(void 0,n);return s.fromJSON(t,r),s}dispose(){super.dispose()}};import{Color as Cp}from"three";import{Matrix3 as Iv,Texture as Np,Vector2 as Ea,Vector3 as Zi,Vector4 as Mv}from"three";function Av(i,e){switch(i.data.type){case"light":return Gn(i);case"fresnel":return GD(i,e);case"gradient":return jD(i);case"depth":return ED(i);case"normal":return RD(i);case"noise":return zD(i,e);case"texture":return FD(i,e);case"rainbow":return VD(i);case"transmission":return UD(i,e);case"matcap":return kD(i,e);case"displace":return HD(i);case"color":default:return BD(i,e)}}function Ov(i){return{type:i.data.type}}function Gn(i){let{alpha:e,mode:t}=i.data;return fe(U({},Ov(i)),{alpha:e,mode:t})}function BD(i,e){return fe(U({},Gn(i)),{color:kt(i.data.color,e)})}function GD(i,e){let{bias:t,scale:r,intensity:n,factor:s,color:l}=i.data;return fe(U({},Gn(i)),{color:kt(l,e),bias:t,scale:r,intensity:n,factor:s})}function jD(i){let{gradientType:e,smooth:t,colors:r,steps:n,angle:s,offset:l,morph:c}=i.data;return fe(U({},Gn(i)),{gradientType:e,smooth:t,colors:r.map(f=>new Mv(f[0],f[1],f[2],f[3])),num:r.length,steps:n,offset:new Ea(...l),morph:new Ea(...c),angle:s})}function ED(i){let{gradientType:e,near:t,far:r,isVector:n,isWorldSpace:s,origin:l,direction:c,colors:f,steps:h,smooth:d,num:x}=i.data;return fe(U({},Gn(i)),{gradientType:e,near:t,far:r,isVector:n,isWorldSpace:s,origin:new Zi(...l),direction:c?new Zi(...c):new Zi(1,0,0),num:x,colors:f.map(g=>new Mv(g[0],g[1],g[2],g[3])),steps:h,smooth:d})}function RD(i){let{cnormal:e}=i.data;return fe(U({},Gn(i)),{cnormal:new Zi(e[0],e[1],e[2])})}function zD(i,e){let{data:t}=i;return fe(U({},Gn(i)),{scale:t.scale,move:t.move,fA:new Ea(...t.fA),fB:new Ea(...t.fB),size:new Zi(...t.size),distortion:new Ea(...t.distortion),colorA:kt(t.colorA,e),colorB:kt(t.colorB,e),colorC:kt(t.colorC,e),colorD:kt(t.colorD,e),noiseType:t.noiseType})}function FD(i,e){let{projection:t,axis:r,crop:n,size:s}=i.data,{image:l,wrapping:c,repeat:f,offset:h}=i.data.texture,d=new Np,x;if(typeof l=="string")x=e==null?void 0:e.getImage(l);else{let g=new Image;g.src=l.data,g.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(l.data))},x=g}return d.image=x,d.repeat.set(f[0],f[1]),d.offset.set(h[0],h[1]),d.wrapS=d.wrapT=c,fe(U({},Gn(i)),{texture:d,mat:new Iv().setUvTransform(h[0],h[1],f[0],f[1],0,0,0),crop:n,projection:t,axis:["x","y","z"].indexOf(r),size:s})}function VD(i){let{data:e}=i;return fe(U({},Gn(i)),{filmThickness:e.filmThickness,movement:e.movement,wavelengths:new Zi(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new Zi(...e.offset)})}function UD(i,e){let{data:t}=i;return fe(U({},Gn(i)),{thickness:t.thickness,ior:t.ior,roughness:t.roughness,transmissionSamplerMap:e.transmissionSamplerMap,transmissionDepthMap:e.transmissionDepthMap})}function kD(i,e){let t=new Np,{image:r}=i.data.texture,n;if(typeof r=="string")n=e==null?void 0:e.getImage(r);else{let l=new Image;l.src=r.data,l.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(r.data))},n=l}t.image=n;let s=16777215;return fe(U({},Gn(i)),{color:s,texture:t})}function HD(i){let{data:e}=i,t=fe(U({},Ov(i)),{intensity:e.intensity});if(e.displacementType==="noise")return fe(U({},t),{offset:new Zi(...e.offset),scale:e.scale,movement:e.movement,noiseType:e.noiseType});{let r=new Np,n=new Iv().setUvTransform(0,0,1,1,0,0,0);return fe(U({},t),{texture:r,mat:n,crop:e.crop})}}function Pv(i,e,t){if(t.type==="displace"&&(i==="intensity"||i==="visible")){let r=e.uniforms[`f${e.id}_intensity`];return r?(r.value=t.intensity*(t.visible?1:0),r):void 0}if(t.type!=="displace"&&(i==="alpha"||i==="visible")){let r=e.uniforms[`f${e.id}_alpha`];return r?(r.value=t.alpha*(t.visible?1:0),r):void 0}}import{Color as Dv,Vector4 as WD}from"three";var js;(function(e){function i(t){return new Dv(t.x,t.y,t.z).getHex()}e.getHex=i})(js||(js={}));var Bv;(function(e){function i(t){return new WD(t.r,t.g,t.b,t.a)}e.getThreeVector4=i})(Bv||(Bv={}));var Gv;(function(t){function i(r,n){r.setRGB(n.r,n.g,n.b)}t.setThreeColor=i;function e(r){return new Dv(r.r,r.g,r.b).getHex()}t.getHex=e})(Gv||(Gv={}));function Ra(i,e){return typeof i=="string"?e.getMaterialOrDeletedPlaceholder(i):Lp(i,e)}function jv(i,e){return i.map(t=>Ra(t,e))}function Lp(i,e){var l,c;let t=(l=i.layers)!=null?l:Ss.defaultTwoLayerData("phong").layers,r=qD(t),n;switch(r.category){case"basic":n=new vr;break;case"lambert":{n=new Ba;break}case"toon":{n=new Ga;break}case"physical":n=new ja;break;case"phong":default:{n=new bn;break}}n.name=(c=i.name)!=null?c:"Untitled Material";let s=n.userData.layers;$D(s);for(let f=t.length-1;f>=0;f--)JD(s,t[f],e);switch(r.category){case"basic":break;case"lambert":{let d=n,g=kt(r.emissive,e);g instanceof Cp?d.emissive.value=g:d.emissive.value.setHex(js.getHex(g));break}case"toon":{let d=n,x=r;d.shininess.value=x.shininess;let g=kt(x.specular,e);g instanceof Cp?d.specular.value=g:d.specular.value.setHex(js.getHex(g));break}case"physical":let f=n,h=r;f.metalness.value=h.metalness,f.roughness.value=h.roughness,f.reflectivity.value=h.reflectivity;break;case"phong":default:{let d=n,x=r;d.shininess.value=x.shininess;let g=kt(x.specular,e);g instanceof Cp?d.specular.value=g:d.specular.value.setHex(js.getHex(g));break}}return s.blendColors(),s.blendAfterColors(),s.blendPositions(),n}function qD(i){for(let e of i)if(e.data.type==="light")return e.data;return{type:"light",category:"basic",visible:!0,alpha:1,mode:Zt.Normal}}function $D(i){for(let e of i.getLayers())i.removeLayer(e.id)}function JD(i,e,t){let r=Av(e,t);r.type==="transmission"&&(r.transmissionSamplerMap=t==null?void 0:t.transmissionSamplerMap,r.transmissionDepthMap=t==null?void 0:t.transmissionDepthMap);let n=i.addLayer(r);n.uuid=e.id;for(let s in e.data)Pv(s,n,e.data)}import{Vector2 as Ev}from"three";var Tu=new Ev,To=class{constructor(e,t,r){this.message=[];this.endLine=!0;this.yLinePos=e,this.lineHeight=t,this.maxCharSize=r,this.nextChar3DPos=new Ev(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=Lr.Left}addChar3D(e,t,r=this.message.length){this.message.splice(r,0,e),e.fontSize>this.maxCharSize?(this.maxCharSize=e.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(t)):(e.updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=e.charSize)}deleteChar3D(e=this.message.length-1){let t=this.message[e];if(t)return this.message.splice(e,1),this.nextChar3DPos.x-=t.charSize,t}isEndLine(e){this.endLine=e}fullUpdate(e,t=0){this.nextChar3DPos.x=0;for(let r=t,n=this.message.length;r<n;r+=1)this.message[r].updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(e){let t,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){t=this.message[r];break}r-=1}return!!(r>=0&&t&&t.localPosition.x+t.charSize>e)}containSpaceOverFlow(e=this.message.length-1){for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}containSpace(e=this.message.length-1){if(this.endLine)return!0;for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}popWord(e=this.message.length-1){let t=[],r=!0,n;for(n=e;n>=0;n-=1)if(this.message[n].char===" "){r=!1,t.length===0&&(n-=1,t.splice(0,0,this.message[n]));break}else t.splice(0,0,this.message[n]);return r?t=[]:this.message.splice(n+1,t.length),t}getWord(e=0,t=1){let r=[],n=e;for(n=e;;n+=t){if(!this.message[n]||this.message[n].char===" "){r.length===0&&this.message[n]&&(r.push(this.message[n]),this.message.splice(n,1));break}t>0?(r.push(this.message[n]),this.message.splice(n,1),n-=t):(r.splice(0,0,this.message[n]),this.message.splice(n,1))}return r}getWordAtIndex(e){let t=[];for(let r=e;r<this.message.length&&this.message[r].char!==" ";r++)t.push(this.message[r]);for(let r=e-1;r>=0&&this.message[r].char!==" ";r--)t.splice(0,0,this.message[r]);return t}wordSize(e=0,t=-1){let r=0,n=e;for(;n>=0&&n<this.message.length;){if(this.message[n].char===" "){r===0&&(r=this.message[n].charSize);break}r+=this.message[n].charSize,n+=t}return(n<0||n>=this.message.length)&&!this.endLine?this.message[e]?this.message[e].charSize:999999999:r===0?999999999:r}spaceLeft(e){return e-this.nextChar3DPos.x}popChar(e=this.message.length-1){return this.nextChar3DPos.x-=this.message[e].charSize,this.message.splice(e,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(e){this.yLinePos=e,this.updateNextCharPosY()}updatelineHeight(e){this.lineHeight=e,this.updateNextCharPosY()}updateFontSize(e,t=0,r=this.message.length-1){for(let n=t;n<=r;n+=1)this.message[n].updateFontSize(e);this.maxCharSize=e,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let e=0;for(let t=0;t<this.message.length;t++)this.message[t].char===" "&&(e+=1);return e}alignText(e,t,r,n,s){switch(r){case Lr.Left:this.leftAlign(e,s);break;case Lr.Center:this.centerAlign(this.spaceLeft(t),e,s);break;case Lr.Right:this.rightAlign(this.spaceLeft(t),e,s);break;case Lr.Justify:this.justifyAlign(this.spaceLeft(t),e,s);break}}offsetCharacters(e,t,r){Tu.set(t,r);let n=this.message.length;for(let s=0;s<n;s++)this.message[s].updatePosition(this.message[s].localPosition.add(Tu),e)}leftAlign(e,t){this.align=Lr.Left,this.offsetCharacters(e,0,t)}centerAlign(e,t,r){this.align=Lr.Center,this.offsetCharacters(t,e/2,r)}rightAlign(e,t,r){this.align=Lr.Right,this.offsetCharacters(t,e,r)}justifyAlign(e,t,r){if(this.align=Lr.Justify,this.endLine){this.offsetCharacters(t,0,r);return}let n=this.countSpaces();if(n===0){this.offsetCharacters(t,0,r);return}let s=e/n,l=0;for(let c=0;c<this.message.length;c++)this.message[c].char===" "&&(l+=s),Tu.set(l,r),this.message[c].updatePosition(this.message[c].localPosition.add(Tu),t)}clone(){let e=new To(this.yLinePos,this.lineHeight,this.maxCharSize);e.nextChar3DPos=this.nextChar3DPos.clone(),e.align=this.align,e.endLine=this.endLine;for(let t=0;t<this.message.length;t++)e.message.push(this.message[t].clone());return e}};import{DoubleSide as KD,EventDispatcher as XD,Matrix3 as ZD,Vector3 as _p}from"three";var YD=new _p(0,0,1),Rv=new _p,zv=new _p,Fv=new ZD,Io=class extends hr{constructor(e=ur.create({}),t=new vr({side:KD})){super(e,t);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new XD;this._onShapeUpdate=()=>{if(this.geometry instanceof No){if(this.geometry.updateFromShape()){let e=this.geometry.drawCount,t=this.geometry.userData;this.updateGeometry(Object.assign(this.geometry.userData,{parameters:Object.assign(t.parameters,{surfaceMaxCount:e+1e3})}))}}else this.updateGeometry({});this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};var r;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="VectorObject",t}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let t=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:t})}}setShape(e){var t,r;this.shape&&((t=this.shape.eventDispatcher)==null||t.removeEventListener("update",this._onShapeUpdate)),this.shape=e,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),Fv.getNormalMatrix(this.matrixWorld),Rv.copy(YD).applyMatrix3(Fv).normalize(),zv.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(Rv,zv)}clone(e){let t=this.shape.clone(),r=this.material.clone(),n=this.geometry.userData,s=ur.create(Object.assign({},n,{shape:t})),l=new Io(s,r).copy(this,e);return l.shape=t,t.update(),l}raycast(e,t){hr.prototype.raycast.call(this,e,t)}};import{Camera as p3,OrthographicCamera as d3,PerspectiveCamera as m3,Vector3 as nn,Object3D as Hv,Quaternion as g3}from"three";import{BoxBufferGeometry as QD}from"three";var Yn=i=>{var e;return e=class extends i{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new QD(30,30,30),e};import{Camera as n3,LineSegments as i3,BufferGeometry as o3,LineBasicMaterial as s3,Color as Ip,Vector3 as a3,Float32BufferAttribute as Uv}from"three";import{Ray as e3,Sphere as t3,Matrix4 as r3,Vector3 as Ni}from"three";var Iu=new e3,Tp=new t3,Vv=new r3,Qn=(i,e,t,r,n=!1)=>{let s=e,l=i.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),Tp.copy(s.boundingSphere),Tp.applyMatrix4(l),t.ray.intersectsSphere(Tp)===!1||(Vv.copy(l).invert(),Iu.copy(t.ray).applyMatrix4(Vv),s.boundingBox!==null&&Iu.intersectsBox(s.boundingBox)===!1))return;let c,f,h,d,x=s.index,g=s.attributes.position,w=s.drawRange,S,D;if(n===!1){let G=Math.max(0,w.start),B=Math.min(x.count,w.start+w.count);for(S=G,D=B;S<D;S+=3)if(f=x.getX(S),h=x.getX(S+1),d=x.getX(S+2),c=C(i,t,Iu,g,f,h,d),c){c.faceIndex=Math.floor(S/3),r.push(c);return}}else{let B=s.attributes.position,P=new Ni,W=new Ni,M=new Ni,q=new Ni,E=2,R=1/((i.scale.x+i.scale.y+i.scale.z)/3),T=R*R,z=Math.max(0,w.start),A=Math.min(B.count,w.start+w.count);for(let $=z,he=A-1;$<he;$+=E){if(P.fromBufferAttribute(B,$),W.fromBufferAttribute(B,$+1),Iu.distanceSqToSegment(P,W,q,M)>T)continue;q.applyMatrix4(i.matrixWorld);let Ne=t.ray.origin.distanceTo(q);Ne<t.near||Ne>t.far||r.push({distance:Ne,point:M.clone().applyMatrix4(i.matrixWorld),object:i})}}function C(G,B,P,W,M,q,E){let b=new Ni,R=new Ni,T=new Ni,z=new Ni,A=new Ni;if(b.fromBufferAttribute(W,M),R.fromBufferAttribute(W,q),T.fromBufferAttribute(W,E),P.intersectTriangle(b,R,T,!1,z)===null)return null;A.copy(z),A.applyMatrix4(G.matrixWorld);let he=B.ray.origin.distanceTo(A);return he<B.near||he>B.far?null:{faceIndex:1,distance:he,point:A.clone(),object:G}}};var Mu=new a3,Sn=new n3,kv=class extends i3{constructor(e){let t=new o3,r=new s3({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],l={},c=new Ip(wh),f=new Ip(wh),h=new Ip(a0);d("n1","n2",c),d("n2","n4",c),d("n4","n3",c),d("n3","n1",c),d("f1","f2",c),d("f2","f4",c),d("f4","f3",c),d("f3","f1",c),d("n1","f1",c),d("n2","f2",c),d("n3","f3",c),d("n4","f4",c),d("p","n1",f),d("p","n2",f),d("p","n3",f),d("p","n4",f),d("u1","u2",h),d("u2","u3",h),d("u3","u1",h);function d(g,w,S){x(g,S),x(w,S)}function x(g,w){n.push(0,0,0),s.push(w.r,w.g,w.b),l[g]===void 0&&(l[g]=[]),l[g].push(n.length/3-1)}t.setAttribute("position",new Uv(n,3)),t.setAttribute("color",new Uv(s,3));super(t,r);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=l,this.update()}update(){let e=this.geometry,t=this.pointMap,r=!0;Sn.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let n=1,s=1,l=r?.8:1e-4;jn("n1",t,e,Sn,-n,-s,l),jn("n2",t,e,Sn,n,-s,l),jn("n3",t,e,Sn,-n,s,l),jn("n4",t,e,Sn,n,s,l);let c=l;jn("f1",t,e,Sn,-n,-s,c),jn("f2",t,e,Sn,n,-s,c),jn("f3",t,e,Sn,-n,s,c),jn("f4",t,e,Sn,n,s,c);let f=c,h=.5;jn("u1",t,e,Sn,n*.7*h,s*1.1,f),jn("u2",t,e,Sn,-n*.7*h,s*1.1,f),jn("u3",t,e,Sn,0,s*(1.1+.9*h),f),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function jn(i,e,t,r,n,s,l){Mu.set(n,s,l).unproject(r);let c=e[i];if(c!==void 0){let f=t.getAttribute("position");for(let h=0,d=c.length;h<d;h++)f.setXYZ(c[h],Mu.x,Mu.y,Mu.z)}}var Mp=class extends Yn(kv){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,t){Qn(this.object,this.geometry,e,t,!0)}};import{DirectionalLightHelper as l3}from"three";var za=class extends Yn(l3){constructor(e,t=15,r=10066329){super(e,t,r);this.object=e;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Qn(this.object,za.geometryHelper,e,t)}};import{AxesHelper as c3}from"three";var Fa=class extends Yn(c3){constructor(e,t=15){super(t);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,t){Qn(this.object,Fa.geometryHelper,e,t)}update(){}};import{PointLightHelper as u3}from"three";var Va=class extends Yn(u3){constructor(e,t=15,r=6710886){super(e,t,r);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Qn(this.object,Va.geometryHelper,e,t)}};import{SpotLightHelper as f3,Vector3 as h3}from"three";var Ou=class extends Yn(f3){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Qn(this.object,Ou.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=Ou._vector,t=this.object.distance?this.object.distance:1e3,r=t*Math.tan(this.object.angle);this.cone.scale.set(r,r,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,l=this.cone.material.length;s<l;s++)this.cone.material[s].color.set(n);else this.cone.material.color.set(n)}}},Au=Ou;Au._vector=new h3;var ei=(i,e)=>class extends i{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(r){this.visible=r,this.setHelperVisibility(r),this.setHelperChildrenVisibility(r)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(r){this.objectHelper.visible=r}setHelperChildrenVisibility(r){for(let n of this.children)yn(n)&&n.traverseEntity(s=>{vi(s)&&s.visible&&(s.objectHelper.visible=r)})}raycast(r,n){this.objectHelper.raycast(r,n)}copy(r,n=!0){return super.copy(r,n),r.enableHelper!==void 0&&(this.enableHelper=r.enableHelper),r.objectHelper!==void 0&&(this.objectHelper.visible=r.objectHelper.visible),this}toJSON(r){let n=super.toJSON(r),s=n.object;return s.enableHelper=this.enableHelper,n}fromJSON(r){return super.fromJSON(r),r.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(r,n){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let s=this;r.color!==void 0&&(s.color=kt(r.color,n)),r.intensity!==void 0&&(s.intensity=r.intensity),r.depth!==void 0&&(s.shadow.camera.far=r.depth,s.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows),r.helper!==void 0&&(this.enableHelper=r.helper,s.gizmos.shadowmap.visible=r.helper)}return this}};var Es=new nn,Ap=new nn,Yi=class extends ei(xn(p3),Mp){constructor(e=window.innerWidth,t=window.innerHeight,r=45,n,s=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=xo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=t,this.orthoCamera=new d3(e*-.5,e*.5,t*.5,t*-.5,n!=null?n:-5e4,s),this.perspCamera=new m3(r,e/t,n!=null?n:50,s),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(e,t){let r=new Yi().fromState(t);return r.enableHelper=!0,r.objectHelper.update(),r.uuid=e,r}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e){super.lookAt(e),this.getWorldPosition(Es),this.targetOffset=Es.distanceTo(e)}getTarget(e=new nn){return this.getWorldDirection(Ap),this.getWorldPosition(Es),Ap.multiplyScalar(this.targetOffset),e.copy(Es).add(Ap),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Es),Es.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new g3),t=new nn(0,0,1).applyQuaternion(e),r=new nn().copy(Hv.DefaultUp);this.isUpVectorFlipped&&r.negate(),r.applyQuaternion(e);let n=new nn().copy(Hv.DefaultUp).projectOnPlane(t),s=new nn().crossVectors(n,r).dot(t)>=0?1:-1;this.angleOffsetFromUp=n.angleTo(r)*s}getViewFrontToObject(e){let t=e.getWorldPosition(new nn),n=e.getWorldDirection(new nn).multiplyScalar(this.targetOffset);return{position:t.clone().add(n),target:t}}getViewToObject(e){let t=e.getWorldPosition(new nn),n=this.getWorldDirection(new nn).multiplyScalar(this.targetOffset);return{position:t.clone().sub(n),target:t}}setViewplaneSize(e,t){this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5,this.aspect=e/t,this.updateProjectionMatrix()}toOrthographic(e){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}toPerspective(e){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,t,r,n,s,l){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,r,n,s,l):this.orthoCamera.setViewOffset(e,t,r,n,s,l)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(e){this._cameraType==="PerspectiveCamera"?this.toPerspective(e):this._cameraType==="OrthographicCamera"&&this.toOrthographic(e)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}fromCameraRender(e){let t={near:this.orthoCamera.near,far:this.orthoCamera.far},r={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(e),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=t.near,this.orthoCamera.far=t.far,this.perspCamera.near=r.near,this.perspCamera.far=r.far,this.updateProjectionMatrix(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="CombinedCamera",r.cameraType=this.cameraType,r.targetOffset=this.targetOffset,r.isUpVectorFlipped=this.isUpVectorFlipped,r.angleOffsetFromUp=this.angleOffsetFromUp,r.left=this.left,r.right=this.right,r.top=this.top,r.bottom=this.bottom,this.view!==null&&(r.view=Object.assign({},this.view)),r.zoomOrtho=this.orthoCamera.zoom,r.nearOrtho=this.orthoCamera.near,r.far=this.far,r.aspect=this.aspect,r.fov=this.fov,r.focus=this.focus,r.filmGauge=this.filmGauge,r.filmOffset=this.filmOffset,r.zoomPersp=this.perspCamera.zoom,r.nearPersp=this.perspCamera.near,t}fromJSON(e){var t;if(super.fromJSON(e),this.cameraType=e.cameraType,e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.orbitControlsTarget!==void 0){let r=this.getWorldPosition(new nn),n=new nn().fromArray(e.orbitControlsTarget);this.targetOffset=n.distanceTo(r)}else e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=(t=e.angleOffsetFromUp)!=null?t:0,e.left!==void 0&&(this.left=e.left),e.right!==void 0&&(this.right=e.right),e.top!==void 0&&(this.top=e.top),e.bottom!==void 0&&(this.bottom=e.bottom),e.view!==void 0&&(this.view=Object.assign({},e.view)),e.zoomOrtho!==void 0&&(this.orthoCamera.zoom=e.zoomOrtho),e.nearOrtho!==void 0&&(this.orthoCamera.near=e.nearOrtho),e.far!==void 0&&(this.far=e.far),e.aspect!==void 0&&(this.aspect=e.aspect),e.fov!==void 0&&(this.fov=e.fov),e.focus!==void 0&&(this.focus=e.focus),e.filmGauge!==void 0&&(this.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(this.filmOffset=e.filmOffset),e.zoomPersp!==void 0&&(this.perspCamera.zoom=e.zoomPersp),e.nearPersp!==void 0&&(this.perspCamera.near=e.nearPersp),this.updateProjectionMatrix(),this}toCameraState(e=[]){let t={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return hs(t,e)}fromCameraState(e){let{orthographic:t,perspective:r}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),t!==void 0&&(t.near!==void 0&&(this.orthoCamera.near=t.near),t.zoom!==void 0&&(this.orthoCamera.zoom=t.zoom)),r!==void 0&&(r.near!==void 0&&(this.perspCamera.near=r.near),r.fov!==void 0&&(this.perspCamera.fov=r.fov),r.zoom!==void 0&&(this.perspCamera.zoom=r.zoom)),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(e){return fe(U(U({},super.toState(e)),this.toCameraState(e)),{type:this.cameraType})}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};import{Group as y3}from"three";var Qi=class extends ei(xn(y3),Fa){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,t){let r=new Qi().fromState(t);return r.uuid=e,r.enableHelper=!0,r.objectHelper.update(),r}toJSON(e){let t=super.toJSON(e);return t.object.objectType="EmptyObject",t}};import{DirectionalLight as x3,CameraHelper as Pu}from"three";var Ua=class extends ei(xn(x3),za){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=1,r.far=2500;let n=new Pu(this.shadow.camera);n.visible=!1,this._gizmos.shadowmap=n,this.update()}static createFromState(e,t,r){let n=new Ua().fromState(t,r);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Pu&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Pu&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Pu&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightDirectional",r.color=this.color.getHex(),r.intensity=this.intensity,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var n;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.shadow.normalBias=(n=e.shadow.normalBias)!=null?n:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.left=r.left,t.right=r.right,t.top=r.top,t.bottom=r.bottom,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromDirectionalLightState(e,t){let r=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;return super.fromLightState(e,t),e.size!==void 0&&hv(this,e.size),r&&this.update(),this}fromState(e,t){return super.fromState(e),this.fromDirectionalLightState(e,t),this}};import{PointLight as v3,Vector3 as Du,Box3 as b3,Box3Helper as Bu,Color as S3}from"three";var ka=class extends ei(xn(v3),Va){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let n=new Du(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new Du(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),l=new b3(n,s),c=new Bu(l,new S3(16755200));c.visible=!1,this._gizmos.shadowmap=c,this.update()}static createFromState(e,t,r){let n=new ka().fromState(t,r);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Bu&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Bu&&(t.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let t=this._gizmos[e];if(t instanceof Bu){let r=this.shadow.camera,n=new Du(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new Du(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);t.box.set(n,s),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightPoint",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.decay=this.decay,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var n,s;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow.normalBias=(n=e.shadow.normalBias)!=null?n:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray((s=e.shadow.mapSize)!=null?s:[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromPointLightState(e,t){return super.fromLightState(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(e,t){return super.fromState(e),this.fromPointLightState(e,t),this}};import{SpotLight as w3,CameraHelper as Gu,MathUtils as N3,Vector3 as Wv,Quaternion as C3}from"three";var qv=new Wv,$v=new Wv,Jv=new C3,Ha=class extends ei(xn(w3),Au){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=N3.RAD2DEG*2*this.angle,r.aspect=1,r.near=100,r.far=2500;let n=new Gu(this.shadow.camera);n.visible=!1,this._gizmos.shadowmap=n,this.update()}static createFromState(e,t,r){let n=new Ha().fromState(t,r);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Gu&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Gu&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Gu&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),$v.setFromMatrixPosition(this.matrixWorld),Jv.setFromRotationMatrix(this.matrixWorld),qv.copy(this.up).applyQuaternion(Jv).negate().multiplyScalar(this.distance),this.target.position.copy($v).add(qv),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightSpot",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.angle=this.angle,r.decay=this.decay,r.penumbra=this.penumbra,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var n;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.decay=e.decay,this.penumbra=e.penumbra,this.shadow.normalBias=(n=e.shadow.normalBias)!=null?n:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromSpotLightState(e,t){return super.fromLightState(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),this}fromState(e,t){return super.fromState(e),this.fromSpotLightState(e,t),this}};import{VideoTexture as L3}from"three";var Kv=i=>i.tagName==="VIDEO",Rs=class{static resize(e,t,r){let n=e/t,s;if(!r.image)return;let l=r.image;Kv(l)?s=l.videoWidth/l.videoHeight:s=l.width/l.height,n>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/n):r.repeat.set(1,1*s/n)),n<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*n/s*-1,1):r.repeat.set(1*n/s,1)),n==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(e,t,r){let n=e/t,s=r.image!==void 0?r.image.width/r.image.height:1,l;n>s?l={x:1,y:s/n}:n<s?l={x:n/s,y:1}:l={x:1,y:1},r.repeat.set(l.x,l.y),r.updateMatrix()}static resizeTextureLayers(e,t,r){let n=r.userData.layers,s=n.getLayers();for(let l=0;l<s.length;l++){let c=s[l];Nv(c)&&(Rs.resizeTextureLayer(e,t,c.uniforms[`f${c.id}_texture`].value),n.updateLayerUniform())}}static resizeComplex(e,t,r,n){let s=e/t,l,c=r.image;Kv(c)?l=c.videoWidth/c.videoHeight:l=c.width/c.height,n.geometry.type.includes("Shape")?(s>l&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t*l/s):r.repeat.set(1/e,1/t*l/s)),s<l&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*s/l*-1,1/t):r.repeat.set(1/e*s/l,1/t)),s==l&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t):r.repeat.set(1/e,1/t))):(s>l&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*l/s):r.repeat.set(1,1*l/s)),s<l&&(r.imageType=="WEBCAM"?r.repeat.set(1*s/l*-1,1):r.repeat.set(1*s/l,1)),s==l&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var Wa=class extends hr{constructor(e,t=new vr){super(e,t);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.userData.layers&&Rs.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(e,t){super.resizeGeometry(e,t,0),this.material.userData.layers&&Rs.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh2D",t}clone(){let e=super.clone();return e.updateGeometry({}),e}static fromTexture(e){let t,r;if(e instanceof L3){let l=e.image;t=l.videoWidth*.5,r=l.videoHeight*.5}else{let l=e.image;t=l.width*.5,r=l.height*.5}let n=ou.create({parameters:{width:t,height:r}}),s=new vr;return s.layersList.changeLayer(0,{type:qe.TEXTURE,texture:e}),s.layersList.moveLayer(0,1),s.dispose(),new Wa(n,s)}};var qa=class extends hr{constructor(e,t=new bn){super(e,t);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh3D",t}};var $a=class extends qa{constructor(e,t=new bn){super(e,t);this.objectType="NonParametric"}toJSON(e){let t=super.toJSON(e);return t.object.objectType="NonParametric",t}};var Ja;(function(t){t[t.TO_RIGHT=1]="TO_RIGHT",t[t.TO_LEFT=-1]="TO_LEFT"})(Ja||(Ja={}));var Op=class extends hr{constructor(e,t=new vr({transparent:!0,opacity:1,visible:!1,side:ju})){super(e,t);this.objectType="TextFrame";this.charContainer=new _3,this.add(this.charContainer),this.material.visible=!1,this._geometryUserData=e.userData,this.userData.textFrame={hexColor:null,opacity:1,visible:!0,text:"",fontSize:16,lineHeight:1.5,letterSpacing:1,fontFamily:"roboto_regular",textTransform:ki.None,horizontalAlignment:1,verticalAlignment:gi.Top,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new Zv(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,t,r){let n=su.create({parameters:{width:t.width,height:t.height}}),s=new Op(n).fromState(t,r);return s.uuid=e,s}async updateText(e){this.clearText();let t=this.userData.textFrame,r=t.fontFamily;await Rr.loadFont(r),t.text=e;let n=t.textOrigin,s=new Xv({visible:t.visible,transparent:!0,side:ju}),l=e.split(`
|
|
977
|
-
`),c=0;this.userData.textFrame.textLines=l.map((f,h)=>{let d=new To(c,t.lineHeight,t.fontSize);return d.message=f.split("").map(x=>{let g={char:x,fontFamily:r,letterSpacing:t.letterSpacing,fontSize:t.fontSize,LOD:16},w=s.clone();w.color=t.hexColor,w.opacity=t.opacity;let S=new Rr(g,w);return d.addChar3D(S,n),this.charContainer.add(S),S}),c+=d.maxCharSize*d.lineHeight,d}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let t=this.charContainer.children[0];this.charContainer.remove(t)}for(;e.length;)e.pop()}raycast(e,t){let r=[];if(super.raycast(e,r),r.length>0){t.push(r[0]);return}let n=[];for(let s=0,l=this.charContainer.children.length;s<l;++s)if(this.charContainer.children[s]instanceof Rr&&(e.intersectObject(this.charContainer.children[s],!1,n),n.length>0)){n[0].object=this,t.push(n[0]);return}}updateGeometry(e){var h,d,x,g;let t=this.userData,r=this.geometry.userData,n=r.parameters.width,s=r.parameters.height,l=(d=(h=e.parameters)==null?void 0:h.width)!=null?d:n,c=(g=(x=e.parameters)==null?void 0:x.height)!=null?g:s,f=t.textFrame;super.updateGeometry(e),f.maxLineSize=l,f.textOrigin.set(-.5*l,.5*c,0),c!==s?(this.checkOverFlow(),this.checkCapacity()):l!==n&&(n<l?this.checkCapacity():n>l&&this.checkOverFlow())}checkOverFlow(e=0){let t=this.userData,r=t.textFrame.textOrigin,n=t.textFrame.textLines;for(let s=e;s<n.length;s++){n[s].updateYLinePos(this.getNewLinePosition(s)),n[s].fullUpdate(r);let l=[];for(;n[s].checkOverFlow(t.textFrame.maxLineSize);)n[s].containSpaceOverFlow()?l.unshift(n[s].getWord(n[s].message.length-1,-1)):l.unshift(n[s].popChar());if(l.length>0){n[s+1]===void 0?(n[s].isEndLine(!1),this.createTextLine()):n[s].endLine&&(this.createTextLine(s+1),n[s].isEndLine(!1),n[s+1].isEndLine(!0));let c=0;for(let f=0;f<l.length;f+=1)for(let h=0;h<l[f].length;h+=1)n[s+1].addChar3D(l[f][h],r,c),c+=1;n[s+1].fullUpdate(r)}n[s].fullUpdate(r)}this.textFullUpdate(e)}checkCapacity(e=0){let t=this.userData,r=t.textFrame.textOrigin,n=t.textFrame.maxLineSize,s=t.textFrame.textLines;for(let l=e;l<s.length;l+=1)if(s[l].updateYLinePos(this.getNewLinePosition(l)),s[l].fullUpdate(r),!!s[l-1])for(;!s[l-1].endLine;){let c,f=s[l-1].spaceLeft(n);if(s[l].wordSize(0,1)<=f){s[l].containSpace()?c=s[l].getWord(0,1):c=s[l].popChar(0);for(let h=0;h<c.length;h+=1)c[h]&&s[l-1].addChar3D(c[h],r)}else{s[l].isEmpty()?(s[l].endLine&&s[l-1].isEndLine(!0),s.splice(l,1),l-=1):(s[l].updateYLinePos(this.getNewLinePosition(l)),s[l].fullUpdate(r));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let r=this.userData.textFrame;r.textLines.splice(e,0,new To(this.getNewLinePosition(e),r.lineHeight,r.fontSize))}textFullUpdate(e=0){let r=this.userData.textFrame,n=r.textLines,s=this.getVerticalAlignmentOffSet();for(let l=e;l<n.length;l++)n[l].updateYLinePos(this.getNewLinePosition(l)),n[l].fullUpdate(r.textOrigin),n[l].alignText(r.textOrigin,r.maxLineSize,r.horizontalAlignment,r.verticalAlignment,s)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case gi.Top:return 0;case gi.Center:return this.getRemainingVerticalSpace()/2;case gi.Bottom:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let t=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(t.length)}getNewLinePosition(e){let r=this.userData.textFrame.textLines,n=0;for(let s=0;s<e;s+=1)n+=r[s].maxCharSize*r[s].lineHeight;return n}updateColor(e){var n;let t=this.userData;t.textFrame.hexColor=e;let r=t.textFrame.textLines;for(let s=0;s<r.length;s++){let l=r[s].message;for(let c=0;c<l.length;c++){let f=l[c].material;((n=f.color)==null?void 0:n.isColor)&&(f.color=e)}}}updateOpacity(e){let t=this.userData;t.textFrame.opacity=e;let r=t.textFrame.textLines;for(let n=0;n<r.length;n++){let s=r[n].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.opacity=e}}}updateVisible(e){let t=this.userData;t.textFrame.visible=e;let r=t.textFrame.textLines;for(let n=0;n<r.length;n++){let s=r[n].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.visible=e}}}async updateFontFamily(e){await Rr.loadFont(e);let r=this.userData.textFrame,n=r.textLines;r.fontFamily=e;for(let s=0;s<n.length;s++){let l=n[s].message;for(let c=0;c<l.length;c++)l[c].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let r=this.userData.textFrame,n=r.textLines,s=r.fontSize;r.fontSize=e;for(let l=0;l<n.length;l++)n[l].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let r=this.userData.textFrame;await Rr.loadFont(r.fontFamily);let n=r.textLines;switch(r.textTransform=e,e){case ki.Upper:for(let s=0;s<n.length;s++){let l=n[s].message;for(let c=0;c<l.length;c++)n[s].message[c].updateChar(l[c].char.toUpperCase())}break;case ki.Lower:for(let s=0;s<n.length;s++){let l=n[s].message;for(let c=0;c<l.length;c++)n[s].message[c].updateChar(l[c].char.toLowerCase())}break;default:for(let s=0;s<n.length;s++){let l=n[s].message;for(let c=0;c<l.length;c++)n[s].message[c].updateChar(l[c].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let t=this.userData,r=t.textFrame.textLines;t.textFrame.letterSpacing=e;for(let n=0;n<r.length;n++){let s=r[n].message;for(let l=0;l<s.length;l++)s[l].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let t=this.userData;t.textFrame.LOD=e;let r=t.textFrame.textLines;for(let n=0;n<r.length;n++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let t=this.userData,r=t.textFrame.textLines;t.textFrame.lineHeight=e;for(let n=0;n<r.length;n++)r[n].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let t=this.userData;t.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let t=this.userData;t.textFrame.horizontalAlignment=e,this.textFullUpdate()}toJSON(e){let t=super.toJSON(e),r=t.object;r.objectType="TextFrame";let s=this.userData.textFrame.textLines.map(l=>{let c=l.message.map(f=>({char:f.char,originalChar:f.originalChar,fontFamily:f.fontFamily,letterSpacing:f.letterSpacing,fontSize:f.fontSize,LOD:f.LOD}));return{align:l.align,endLine:l.endLine,lineHeight:l.lineHeight,maxCharSize:l.maxCharSize,yLinePos:l.yLinePos,message:c}});return r.userData.textFrame.textLinesData=s,t}async fromJSONasync(e){if(super.fromJSON(e),e.userData!==void 0){let t=e.userData.textFrame;await Rr.loadFont(t.fontFamily),t.textOrigin=new Zv(t.textOrigin.x,t.textOrigin.y,t.textOrigin.z);let r=new Xv({color:t.hexColor,opacity:t.opacity,visible:t.visible,transparent:!0,side:ju});t.textLinesData&&(t.textLines=t.textLinesData.map((n,s)=>{let l=new To(Number(n.yLinePos),Number(n.lineHeight),Number(n.maxCharSize)),c=n.message.map((f,h)=>{if(f.char===void 0){let g=t.textLines[s].message[h];if("geometries"in g){let w=g.geometries[0].userData.parameters;Object.assign(f,{LOD:w.lod,char:w.char,fontFamily:w.fontFamily,fontSize:w.fontSize,letterSpacing:w.letterSpacing,originalChar:w.char})}}let d={char:f.char,fontFamily:f.fontFamily,letterSpacing:Number(f.letterSpacing),fontSize:Number(f.fontSize),LOD:f.LOD},x=new Rr(d,r.clone());return l.addChar3D(x,t.textOrigin),this.charContainer.add(x),x});return l.message=c,l}),this.userData.textFrame=t),this.textFullUpdate()}return this}fromTextFrameData(e,t){if(e.color!==void 0){let r=kt(e.color,t);this.updateColor(r),this.updateOpacity(r.a)}e.alpha!==void 0&&this.updateOpacity(e.alpha),e.font!==void 0&&this.updateFontFamily(e.font),e.horizontalAlign!==void 0&&this.updateHorizontalAlignment(e.horizontalAlign),e.verticalAlign!==void 0&&this.updateVerticalAlignment(e.verticalAlign),e.textTransform!==void 0&&this.updateTextTransform(e.textTransform),e.fontSize!==void 0&&this.updateFontSize(e.fontSize),e.lineHeight!==void 0&&this.updateLineHeight(e.lineHeight),e.letterSpacing!==void 0&&this.updateLetterSpacing(e.letterSpacing),e.text!==void 0&&e.text!==""&&this.updateText(e.text),(e.width!==void 0||e.height!==void 0)&&this.updateGeometry({parameters:{width:e.width,height:e.height}})}fromState(e,t){return super.fromState(e),this.fromTextFrameData(e,t),this}convertToVector(){let{fontFamily:e,hexColor:t}=this.userData.textFrame,r=new Qi;r.name="Text Shape";let n=Rr.fontCache[e];for(let s of this.charContainer.children)s instanceof Rr&&n.generateShapes(s.char,1).forEach(l=>{let c=new st().fromShape(l);c.applyScale(s.scale.x,s.scale.y);let f=ur.create({shape:c}),h=new vr({side:ju});h.color=t;let d=new Io(f,h);d.name=s.char,d.position.copy(s.position),d.rotation.copy(s.rotation),r.attach(d)});return r}},zs=Op;zs.VerticalAlign=gi,zs.HorizontalAlign=Lr,zs.TextTransform=ki;import{HemisphereLight as V3,Scene as U3,Vector3 as k3,Color as fb,Fog as H3,Box3 as W3}from"three";import{BufferGeometryLoader as T3}from"three";function Yv(i,e){return I3(i)}function I3(i){let e={parameters:i,type:i.type};if(i.type==="VectorGeometry"){let r=st.createFromState(i.shape,i.width,i.height);e.shape=r}else i.type==="NonParametricGeometry"&&(i.data.groups&&i.data.groups.forEach(r=>{var n;return r.materialIndex=Math.max((n=r.materialIndex)!=null?n:0,0)}),e.geometry=new T3().parse(i));let t;try{t=La(e)}catch(r){console.error(r)}if(!t){let r=st.createFromState(ws.defaultData(),100,100);e.shape=r,t=La(e)}return t}import{Box3 as M3,Matrix4 as Mo,Sphere as tb,Vector3 as A3}from"three";var rb=ug(eb());var Pp;au.then(i=>{Pp=i});var nb=new Mo,O3=new Mo,P3=new Mo,En=new M3,eo=new A3,D3=new Mo,B3=new Mo,Ka=class extends hr{constructor(e,t,r,n=new bn){super(r!=null?r:t,n);this.subdivPointer=e;this.originalGeometry=t;this.subdividedGeometry=r;this.objectType="SubdivObject";this.hiddenMatrixOld=new Mo;this.smoothShading=!0;this.matrixWorldRigid=new Mo;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,t,r){let{subdivPointer:n,originalGeometry:s,subdividedGeometry:l}=en.build(t.geometry,void 0,void 0,!t.flatShading),c=Ra(t.material,r),f=new Ka(n,s,l||void 0,c);return f.calcBoundingBox(),f.freeSubdivPointer(),f.uuid=e,f.fromState(t),f}shallowClone(e){return new $a(this.geometry,this.material).shallowCopy(this,e)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="SubdivObject",t}buildFromStore(e){var s,l,c;let{originalGeometry:t,subdividedGeometry:r,subdivPointer:n}=en.build(e,this.subdivPointer,void 0,this.smoothShading,this.shearScale);if(this.subdivPointer=n,t!==void 0&&((s=this.originalGeometry)==null||s.dispose(),this.originalGeometry=t),r!==void 0&&((l=this.subdividedGeometry)==null||l.dispose(),this.subdividedGeometry=r!=null?r:void 0),this.geometry=(c=this.subdividedGeometry)!=null?c:this.originalGeometry,this.cloner)for(let f of this.cloner.children)f.geometry=this.geometry;e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){en.buildLevel(this.subdivPointer,!0,this.smoothShading,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&en.buildLevel(this.subdivPointer,!1,this.smoothShading,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){var e;this.originalGeometry.dispose(),this.originalGeometry=en.buildLevel(this.subdivPointer,!0,this.smoothShading),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=en.buildLevel(this.subdivPointer,!1,this.smoothShading)),this.geometry=(e=this.subdividedGeometry)!=null?e:this.originalGeometry}raycast(e,t){var r;this.geometry=this.originalGeometry,hr.prototype.raycast.call(this,e,t),this.geometry=(r=this.subdividedGeometry)!=null?r:this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,t=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:r,v:n,q:s}=(0,rb.SVD)(t),l=nb.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),c=O3.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1),f=P3.copy(c).transpose();this.shearScale=D3.makeScale(s[0],s[1],s[2]).multiply(f).premultiply(c),this.shearScaleInv=B3.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,f),s.every(h=>Math.abs(s[0]-h)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new tb);let t=e.attributes.position,r=e.boundingSphere.center;En.setFromBufferAttribute(t),En.getCenter(r),e.boundingSphere.radius=r.distanceTo(En.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),En.getSize(eo);let n={width:eo.x,height:eo.y,depth:eo.z};return this.geometry.userData.parameters=n,n}updateBoundingBox(e){let t=this.originalGeometry;En.min.set(e[0],e[2],e[4]),En.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(En.min.applyMatrix4(this.shearScaleInv),En.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new tb);let r=t.boundingSphere.center;En.getCenter(r),t.boundingSphere.radius=r.distanceTo(En.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),En.getSize(eo);let n={width:eo.x,height:eo.y,depth:eo.z};return this.geometry.userData.parameters=n,n}freeSubdivPointer(){this.subdivPointer&&(Pp.free_bvh(this.subdivPointer),Pp.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(e){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:e.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:e.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:e.parameters.depth/this.geometry.userData.parameters.depth,ib(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(ib(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters=U({},e.parameters)}};function ib(i,e,t,r){let n=i.position.array,s=i.normal.array,l=nb.makeScale(e,t,r).invert().elements,c,f,h;for(var d=0,x=n.length;d<x;d+=3)n[d]*=e,n[d+1]*=t,n[d+2]*=r,c=s[d],f=s[d+1],h=s[d+2],s[d]=l[0]*c+l[4]*f+l[8]*h,s[d+1]=l[1]*c+l[5]*f+l[9]*h,s[d+2]=l[2]*c+l[6]*f+l[10]*h}import{BackSide as G3,DoubleSide as j3,FrontSide as E3}from"three";function ob(i,e){e.flatShading!==void 0&&(i.flatShading=e.flatShading,i.needsUpdate=!0),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.side!==void 0&&(e.side===xs.Front?i.side=E3:e.side===xs.Back?i.side=G3:i.side=j3)}function R3(i,e){if(Array.isArray(i.material))for(let t of i.material)ob(t,e);else{let t=i.material;ob(t,e)}i.objectType==="SubdivObject"&&e.flatShading!==void 0&&(i.material.flatShading=!1,i.smoothShading=!e.flatShading,i.updateMesh())}function sb(i,e,t){let r;if(e.geometry.type==="SubdivGeometry")r=Ka.createFromState(i,e,t);else{let n=Yv(e.geometry,t),s="materials"in e?jv(e.materials,t):Ra(e.material,t);Fc.is2DParametricMesh(n.userData.type)?r=new Wa(n,s):(n==null?void 0:n.userData.type)==="VectorGeometry"?r=new Io(n,s):e.geometry.type==="NonParametricGeometry"?r=new $a(n,s):r=new qa(n,s),r.uuid=i,r.fromState(e)}return R3(r,e),r}function ab(i,e,t){return e.type==="Mesh"?sb(i,e,t):e.type==="TextFrame"?zs.createFromState(i,e,t):e.type==="Empty"?Qi.createFromState(i,e):e.type==="PointLight"?ka.createFromState(i,e,t):e.type==="SpotLight"?Ha.createFromState(i,e,t):e.type==="DirectionalLight"?Ua.createFromState(i,e,t):ps.is(e.type)?Yi.createFromState(i,e):(console.error(e),new Qi)}function z3(i,e){e.uniforms[`f${e.id}_transmissionSamplerMap`].value=i.texture,e.uniforms[`f${e.id}_transmissionDepthMap`].value=i.depthTexture}function lb(i,e,t){if(!t.userData.layers)return!1;let r=!1,n=t.userData.layers.getLayersOfType(qe.TRANSMISSION);return n.length>0?(e.layers.set(3),r=!0,i!==void 0&&n.forEach(s=>z3(i,s))):e.layers.set(0),r}function cb(i,e){let t=!1;return e.traverseEntity(r=>{if(r instanceof hr)if(Array.isArray(r.material))for(let n=0;n<r.material.length;n++)lb(i,r,r.material[n])&&(t=!0);else lb(i,r,r.material)&&(t=!0)}),t}function ub(i,e){"material"in i&&F3(i.material,e),"geometry"in i&&i.geometry.dispose()}function F3(i,e){fg(i).forEach(t=>{e.isSharedMaterial(t)||t.dispose()})}var hb=new k3,Dp=class extends uu(U3){constructor(e,t){super();this.objectType="Scene";this.alpha=1;this.backupFog=new H3(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new fb(1,0,0);this.bgColor=new fb(1,1,1);this.entityByUuid={};this.ambientLight=new V3(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.sharedAssetManager=t,this.init(e,t)}needsTransmission(e){return this.needsTransmissionDirty&&(this._needsTransmission=cb(e,this),e!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}find(e){if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}get color(){return this._color}set color(e){this.fogUseBGColor===!0&&this.backupFog.color.copy(e),this._color.copy(e)}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){if(this.createChildrenObjects(e.objects,this,t),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(kt(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let r=this.find(e.publish.playCamera);r instanceof Yi&&this.switchActiveCamera(r)}}clearScene(e){this.traverseEntity(t=>{ub(t,e)});for(let t of this.children)yn(t)&&t.removeFromParent()}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=Yi.createFromState(Dp.PERSONAL_CAMERA_ID,fe(U({},Uc.defaultData),{name:"Personal Camera"}));return e.enableHelper=!1,e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],r=n=>{for(let s of n.children)yn(s)&&!s.raycastLock&&s.visible&&((_s(s)||vi(s)&&s.enableHelper&&s.objectHelper.parent)&&e.intersectObject(s,!1,t),r(s))};return r(this),t}traverseEntity(e){for(let t of this.children)yn(t)&&t.traverseEntity(e)}updateFog(e,t){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=kt(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}toJSON(e){return{}}fromJSON(e){return this}dispose(){this.clearScene(this.sharedAssetManager),this.sharedAssetManager.dispose()}updateAmbientLight(e,t){fv(this.ambientLight,e,t),e.groundColor!==void 0&&(this.ambientLight.groundColor=kt(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=e,e.enableHelper=!1}setBackgroundColor(e){this.bgColor=e,this.alpha=e.a}createChildrenObjects(e,t,r){for(let n of e)this.createChildObject(n.id,n.data,n.children,t,r)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createChildObject(e,t,r,n,s){let l=ab(e,t,s);return l&&(this.entityByUuid[e]=l,n.add(l),this.createChildrenObjects(r,l,s)),l}getCenter(e){let t=[];for(let n=0,s=e.length;n<s;++n){let{id:l,recursive:c}=e[n],f=this.find(l),h=c?f.recursiveBBox:f.singleBBox;t.push(...h.vertices)}let r=new W3;return r.setFromPoints(t),r.getCenter(hb),hb}copyMatrixWorld(e,t){if(e===null){t.identity();return}let r=this.find(e);r?t.copy(r.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){var n;if(e===null){t.identity();return}let r=(n=this.find(e))==null?void 0:n.parent;r?t.copy(r.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof hr)if(Array.isArray(t.material))for(let r=0;r<t.material.length;r++)e(t.material[r]);else e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let r,n;e>=t?(r=t/e,n=1):(r=1,n=e/t),this.traverseMaterial(s=>{s.layersList.getLayersOfType(qe.TRANSMISSION).forEach(c=>{c.uniforms[`f${c.id}_aspectRatio`].value.x=r,c.uniforms[`f${c.id}_aspectRatio`].value.y=n})})}},Ru=Dp;Ru.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{DRACOLoader as q3}from"three/examples/jsm/loaders/DRACOLoader.js";var to;function $3(){return to||(to=new q3,to.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),to.decoderPending}async function J3(i){if(to){let e={attributeIDs:to.defaultAttributeIDs,attributeTypes:to.defaultAttributeTypes,useUniqueIDs:!1},t;try{t=await to.decodeGeometry(new Int8Array(i).buffer,e)}catch(r){console.error(r)}if(t)return{index:t.index?{array:t.index.array}:void 0,attributes:Object.entries(t.attributes).map(([r,n])=>({name:r,itemSize:n.itemSize,array:n.array}))}}return null}async function pb(i){let[e,t]=ih(Pc.deserialize(new Uint8Array(i))),r=[];e.scene.objects.traverse((n,s)=>{s.type==="Mesh"&&s.geometry.type==="NonParametricGeometry"&&s.geometry.data.draco!==void 0&&r.push(s)}),r.length&&await $3();for(let n of r){let s=await J3(sh(n.geometry.data.draco));if(s){s.index&&(n.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let l={};s.attributes.forEach(({name:c,array:f,itemSize:h})=>{l[c]={array:f,itemSize:h,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=l,n.geometry.data.draco=void 0}}return t.result().data}import{WebGLRenderTarget as K3,LinearMipmapLinearFilter as X3,LinearFilter as Z3,ClampToEdgeWrapping as db,DepthTexture as Y3}from"three";var mb=new vr,Bp=class extends tn{},Gp=class{constructor(e){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new K3(2048,2048,{generateMipmaps:!0,minFilter:X3,magFilter:Z3,wrapS:db,wrapT:db}),this.transmissionRenderTarget.depthTexture=new Y3(2048,2048),this.reset(e)}reset(e){for(let[t,r]of Object.entries(e.images))this.addImage(t,r.data);for(let[t,r]of Object.entries(e.colors))this.addColor(t,r);for(let[t,r]of Object.entries(e.materials))this.addMaterial(t,Lp(r,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}addMaterial(e,t){t.uuid=e,this.materials[e]=t}deleteMaterial(e){this.materials[e]&&(this.materials[e].dispose(),delete this.materials[e])}isSharedMaterial(e){return e.uuid in this.materials||e===mb}getMaterial(e){let t=this.materials[e];return t}getMaterialOrDeletedPlaceholder(e){var t;return(t=this.materials[e])!=null?t:mb}getMaterials(){return this.materials}addImage(e,t){if(this.images[e])return this.images[e].onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e].src=t,!0;{let r=new Image;return r.src=t,r.onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e]=r,!1}}deleteImage(e){this.images[e]&&delete this.images[e]}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]}getImages(){return this.images}addColor(e,t){return this.colors[e]?("a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):("a"in t?this.colors[e]=new Bp(t.r,t.g,t.b,t.a):this.colors[e]=new Bp(t.r,t.g,t.b,1),!1)}updateColor(e,t){var r,n,s,l;if(this.colors[e]){let c=this.colors[e];return this.colors[e].r=(r=t.r)!=null?r:c.r,this.colors[e].g=(n=t.g)!=null?n:c.g,this.colors[e].b=(s=t.b)!=null?s:c.b,this.colors[e].a=(l=t.a)!=null?l:c.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this.onImageLoad=void 0}};import{Color as yb,ShaderLib as Q3}from"three";var xb=ug(gb());function vb(i){let e=new Set;return i.traverse(t=>{if(_s(t))if((0,xb.isArray)(t.material))t.material.forEach(r=>{let n=r;e.has(n)||e.add(n)});else{let r=t.material;e.has(r)||e.add(r)}}),e.forEach(t=>{let r=t.onBeforeCompile.bind(t);eB(t)?(Object.assign(t,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new yb,specularColor:new yb}),t.onBeforeCompile=(n,s)=>{r&&r(n,s),n.uniforms=Object.assign(Q3.physical.uniforms,n.uniforms),t.userData.layers.getLayersOfType(qe.TRANSMISSION).forEach(l=>{n.uniforms.transmissionSamplerMap.value&&(l.uniforms["f"+l.id+"_transmissionSamplerMap"].value=n.uniforms.transmissionSamplerMap.value,l.uniforms["f"+l.id+"_transmissionSamplerSize"].value=n.uniforms.transmissionSamplerSize.value)})}):tB(t)||(t.onBeforeCompile=(n,s)=>{r&&r(n,s),t.transparent=!1})}),i}function eB(i){return i.userData.layers.getLayersOfType(qe.TRANSMISSION).length>0}function tB(i){let e=i.userData.layers.head,t=0;for(;e!==void 0;){if(e.type!==qe.LIGHTING&&e.type!==qe.FRESNEL){let r=e.uniforms["f"+e.id+"_alpha"];r&&(t+=(1-t)*r.value)}e=e.next}return t<1}function bb(i){return i.traverse(e=>{if(e.type==="Camera"){let t=e;t.type=t.cameraType}}),i}var Sb=class extends nB{load(e,t,r,n=console.error){let s=new rB(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,async l=>{try{if(typeof l=="string")throw new Error("The .spline file is not binary!");let c=await this.parse(l);t(c)}catch(c){n(c)}},r,n)}async parse(e){let t=await pb(e),r=new Gp(t.shared),n=new Ru(t.scene,r);return bb(vb(n))}};export{Sb as default};
|
|
976
|
+
`)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.roughness=e.roughness.clone(),this.metalness=e.metalness.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.reflectivity&&(this.reflectivity=e.reflectivity.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var wp=class extends vn{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get roughness(){return this.fragment.roughness}set roughness(e){this.fragment.roughness=e}get metalness(){return this.fragment.metalness}set metalness(e){this.fragment.metalness=e}get reflectivity(){return this.fragment.reflectivity}set reflectivity(e){this.fragment.reflectivity=e}constructor(e=new Sp,t){super(e,e,t);this.type="StandardNodeMaterial",this.fragment=e}};var ja=class extends wp{constructor(e,t,r){super(t,e);this.userData.type="PhysicalMaterial",this.userData.category="Physical",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Ir){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new ja(void 0,n);return s.fromJSON(t,r),s}dispose(){super.dispose()}};import{Color as Cp}from"three";import{Matrix3 as Iv,Texture as Np,Vector2 as Ea,Vector3 as Zi,Vector4 as Mv}from"three";function Av(i,e){switch(i.data.type){case"light":return Gn(i);case"fresnel":return BD(i,e);case"gradient":return GD(i);case"depth":return jD(i);case"normal":return ED(i);case"noise":return RD(i,e);case"texture":return zD(i,e);case"rainbow":return FD(i);case"transmission":return VD(i,e);case"matcap":return UD(i,e);case"displace":return kD(i);case"color":default:return DD(i,e)}}function Ov(i){return{type:i.data.type}}function Gn(i){let{alpha:e,mode:t}=i.data;return fe(U({},Ov(i)),{alpha:e,mode:t})}function DD(i,e){return fe(U({},Gn(i)),{color:kt(i.data.color,e)})}function BD(i,e){let{bias:t,scale:r,intensity:n,factor:s,color:l}=i.data;return fe(U({},Gn(i)),{color:kt(l,e),bias:t,scale:r,intensity:n,factor:s})}function GD(i){let{gradientType:e,smooth:t,colors:r,steps:n,angle:s,offset:l,morph:c}=i.data;return fe(U({},Gn(i)),{gradientType:e,smooth:t,colors:r.map(f=>new Mv(f[0],f[1],f[2],f[3])),num:r.length,steps:n,offset:new Ea(...l),morph:new Ea(...c),angle:s})}function jD(i){let{gradientType:e,near:t,far:r,isVector:n,isWorldSpace:s,origin:l,direction:c,colors:f,steps:h,smooth:d,num:x}=i.data;return fe(U({},Gn(i)),{gradientType:e,near:t,far:r,isVector:n,isWorldSpace:s,origin:new Zi(...l),direction:c?new Zi(...c):new Zi(1,0,0),num:x,colors:f.map(g=>new Mv(g[0],g[1],g[2],g[3])),steps:h,smooth:d})}function ED(i){let{cnormal:e}=i.data;return fe(U({},Gn(i)),{cnormal:new Zi(e[0],e[1],e[2])})}function RD(i,e){let{data:t}=i;return fe(U({},Gn(i)),{scale:t.scale,move:t.move,fA:new Ea(...t.fA),fB:new Ea(...t.fB),size:new Zi(...t.size),distortion:new Ea(...t.distortion),colorA:kt(t.colorA,e),colorB:kt(t.colorB,e),colorC:kt(t.colorC,e),colorD:kt(t.colorD,e),noiseType:t.noiseType})}function zD(i,e){let{projection:t,axis:r,crop:n,size:s}=i.data,{image:l,wrapping:c,repeat:f,offset:h}=i.data.texture,d=new Np,x;if(typeof l=="string")x=e==null?void 0:e.getImage(l);else{let g=new Image;g.src=l.data,g.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(l.data))},x=g}return d.image=x,d.repeat.set(f[0],f[1]),d.offset.set(h[0],h[1]),d.wrapS=d.wrapT=c,fe(U({},Gn(i)),{texture:d,mat:new Iv().setUvTransform(h[0],h[1],f[0],f[1],0,0,0),crop:n,projection:t,axis:["x","y","z"].indexOf(r),size:s})}function FD(i){let{data:e}=i;return fe(U({},Gn(i)),{filmThickness:e.filmThickness,movement:e.movement,wavelengths:new Zi(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new Zi(...e.offset)})}function VD(i,e){let{data:t}=i;return fe(U({},Gn(i)),{thickness:t.thickness,ior:t.ior,roughness:t.roughness,transmissionSamplerMap:e.transmissionSamplerMap,transmissionDepthMap:e.transmissionDepthMap})}function UD(i,e){let t=new Np,{image:r}=i.data.texture,n;if(typeof r=="string")n=e==null?void 0:e.getImage(r);else{let l=new Image;l.src=r.data,l.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(r.data))},n=l}t.image=n;let s=16777215;return fe(U({},Gn(i)),{color:s,texture:t})}function kD(i){let{data:e}=i,t=fe(U({},Ov(i)),{intensity:e.intensity});if(e.displacementType==="noise")return fe(U({},t),{offset:new Zi(...e.offset),scale:e.scale,movement:e.movement,noiseType:e.noiseType});{let r=new Np,n=new Iv().setUvTransform(0,0,1,1,0,0,0);return fe(U({},t),{texture:r,mat:n,crop:e.crop})}}function Pv(i,e,t){if(t.type==="displace"&&(i==="intensity"||i==="visible")){let r=e.uniforms[`f${e.id}_intensity`];return r?(r.value=t.intensity*(t.visible?1:0),r):void 0}if(t.type!=="displace"&&(i==="alpha"||i==="visible")){let r=e.uniforms[`f${e.id}_alpha`];return r?(r.value=t.alpha*(t.visible?1:0),r):void 0}}import{Color as Dv,Vector4 as HD}from"three";var js;(function(e){function i(t){return new Dv(t.x,t.y,t.z).getHex()}e.getHex=i})(js||(js={}));var Bv;(function(e){function i(t){return new HD(t.r,t.g,t.b,t.a)}e.getThreeVector4=i})(Bv||(Bv={}));var Gv;(function(t){function i(r,n){r.setRGB(n.r,n.g,n.b)}t.setThreeColor=i;function e(r){return new Dv(r.r,r.g,r.b).getHex()}t.getHex=e})(Gv||(Gv={}));function Ra(i,e){return typeof i=="string"?e.getMaterialOrDeletedPlaceholder(i):Lp(i,e)}function jv(i,e){return i.map(t=>Ra(t,e))}function Lp(i,e){var l,c;let t=(l=i.layers)!=null?l:Ss.defaultTwoLayerData("phong").layers,r=WD(t),n;switch(r.category){case"basic":n=new vr;break;case"lambert":{n=new Ba;break}case"toon":{n=new Ga;break}case"physical":n=new ja;break;case"phong":default:{n=new bn;break}}n.name=(c=i.name)!=null?c:"Untitled Material";let s=n.userData.layers;qD(s);for(let f=t.length-1;f>=0;f--)$D(s,t[f],e);switch(r.category){case"basic":break;case"lambert":{let d=n,g=kt(r.emissive,e);g instanceof Cp?d.emissive.value=g:d.emissive.value.setHex(js.getHex(g));break}case"toon":{let d=n,x=r;d.shininess.value=x.shininess;let g=kt(x.specular,e);g instanceof Cp?d.specular.value=g:d.specular.value.setHex(js.getHex(g));break}case"physical":let f=n,h=r;f.metalness.value=h.metalness,f.roughness.value=h.roughness,f.reflectivity.value=h.reflectivity;break;case"phong":default:{let d=n,x=r;d.shininess.value=x.shininess;let g=kt(x.specular,e);g instanceof Cp?d.specular.value=g:d.specular.value.setHex(js.getHex(g));break}}return s.blendColors(),s.blendAfterColors(),s.blendPositions(),n}function WD(i){for(let e of i)if(e.data.type==="light")return e.data;return{type:"light",category:"basic",visible:!0,alpha:1,mode:Zt.Normal}}function qD(i){for(let e of i.getLayers())i.removeLayer(e.id)}function $D(i,e,t){let r=Av(e,t);r.type==="transmission"&&(r.transmissionSamplerMap=t==null?void 0:t.transmissionSamplerMap,r.transmissionDepthMap=t==null?void 0:t.transmissionDepthMap);let n=i.addLayer(r);n.uuid=e.id;for(let s in e.data)Pv(s,n,e.data)}import{Vector2 as Ev}from"three";var Tu=new Ev,To=class{constructor(e,t,r){this.message=[];this.endLine=!0;this.yLinePos=e,this.lineHeight=t,this.maxCharSize=r,this.nextChar3DPos=new Ev(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=Lr.Left}addChar3D(e,t,r=this.message.length){this.message.splice(r,0,e),e.fontSize>this.maxCharSize?(this.maxCharSize=e.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(t)):(e.updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=e.charSize)}deleteChar3D(e=this.message.length-1){let t=this.message[e];if(t)return this.message.splice(e,1),this.nextChar3DPos.x-=t.charSize,t}isEndLine(e){this.endLine=e}fullUpdate(e,t=0){this.nextChar3DPos.x=0;for(let r=t,n=this.message.length;r<n;r+=1)this.message[r].updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(e){let t,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){t=this.message[r];break}r-=1}return!!(r>=0&&t&&t.localPosition.x+t.charSize>e)}containSpaceOverFlow(e=this.message.length-1){for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}containSpace(e=this.message.length-1){if(this.endLine)return!0;for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}popWord(e=this.message.length-1){let t=[],r=!0,n;for(n=e;n>=0;n-=1)if(this.message[n].char===" "){r=!1,t.length===0&&(n-=1,t.splice(0,0,this.message[n]));break}else t.splice(0,0,this.message[n]);return r?t=[]:this.message.splice(n+1,t.length),t}getWord(e=0,t=1){let r=[],n=e;for(n=e;;n+=t){if(!this.message[n]||this.message[n].char===" "){r.length===0&&this.message[n]&&(r.push(this.message[n]),this.message.splice(n,1));break}t>0?(r.push(this.message[n]),this.message.splice(n,1),n-=t):(r.splice(0,0,this.message[n]),this.message.splice(n,1))}return r}getWordAtIndex(e){let t=[];for(let r=e;r<this.message.length&&this.message[r].char!==" ";r++)t.push(this.message[r]);for(let r=e-1;r>=0&&this.message[r].char!==" ";r--)t.splice(0,0,this.message[r]);return t}wordSize(e=0,t=-1){let r=0,n=e;for(;n>=0&&n<this.message.length;){if(this.message[n].char===" "){r===0&&(r=this.message[n].charSize);break}r+=this.message[n].charSize,n+=t}return(n<0||n>=this.message.length)&&!this.endLine?this.message[e]?this.message[e].charSize:999999999:r===0?999999999:r}spaceLeft(e){return e-this.nextChar3DPos.x}popChar(e=this.message.length-1){return this.nextChar3DPos.x-=this.message[e].charSize,this.message.splice(e,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(e){this.yLinePos=e,this.updateNextCharPosY()}updatelineHeight(e){this.lineHeight=e,this.updateNextCharPosY()}updateFontSize(e,t=0,r=this.message.length-1){for(let n=t;n<=r;n+=1)this.message[n].updateFontSize(e);this.maxCharSize=e,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let e=0;for(let t=0;t<this.message.length;t++)this.message[t].char===" "&&(e+=1);return e}alignText(e,t,r,n,s){switch(r){case Lr.Left:this.leftAlign(e,s);break;case Lr.Center:this.centerAlign(this.spaceLeft(t),e,s);break;case Lr.Right:this.rightAlign(this.spaceLeft(t),e,s);break;case Lr.Justify:this.justifyAlign(this.spaceLeft(t),e,s);break}}offsetCharacters(e,t,r){Tu.set(t,r);let n=this.message.length;for(let s=0;s<n;s++)this.message[s].updatePosition(this.message[s].localPosition.add(Tu),e)}leftAlign(e,t){this.align=Lr.Left,this.offsetCharacters(e,0,t)}centerAlign(e,t,r){this.align=Lr.Center,this.offsetCharacters(t,e/2,r)}rightAlign(e,t,r){this.align=Lr.Right,this.offsetCharacters(t,e,r)}justifyAlign(e,t,r){if(this.align=Lr.Justify,this.endLine){this.offsetCharacters(t,0,r);return}let n=this.countSpaces();if(n===0){this.offsetCharacters(t,0,r);return}let s=e/n,l=0;for(let c=0;c<this.message.length;c++)this.message[c].char===" "&&(l+=s),Tu.set(l,r),this.message[c].updatePosition(this.message[c].localPosition.add(Tu),t)}clone(){let e=new To(this.yLinePos,this.lineHeight,this.maxCharSize);e.nextChar3DPos=this.nextChar3DPos.clone(),e.align=this.align,e.endLine=this.endLine;for(let t=0;t<this.message.length;t++)e.message.push(this.message[t].clone());return e}};import{DoubleSide as JD,EventDispatcher as KD,Matrix3 as XD,Vector3 as _p}from"three";var ZD=new _p(0,0,1),Rv=new _p,zv=new _p,Fv=new XD,Io=class extends hr{constructor(e=ur.create({}),t=new vr({side:JD})){super(e,t);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new KD;this._onShapeUpdate=()=>{if(this.geometry instanceof No){if(this.geometry.updateFromShape()){let e=this.geometry.drawCount,t=this.geometry.userData;this.updateGeometry(Object.assign(this.geometry.userData,{parameters:Object.assign(t.parameters,{surfaceMaxCount:e+1e3})}))}}else this.updateGeometry({});this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};var r;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="VectorObject",t}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let t=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:t})}}setShape(e){var t,r;this.shape&&((t=this.shape.eventDispatcher)==null||t.removeEventListener("update",this._onShapeUpdate)),this.shape=e,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),Fv.getNormalMatrix(this.matrixWorld),Rv.copy(ZD).applyMatrix3(Fv).normalize(),zv.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(Rv,zv)}clone(e){let t=this.shape.clone(),r=this.material.clone(),n=this.geometry.userData,s=ur.create(Object.assign({},n,{shape:t})),l=new Io(s,r).copy(this,e);return l.shape=t,t.update(),l}raycast(e,t){hr.prototype.raycast.call(this,e,t)}};import{Camera as h3,OrthographicCamera as p3,PerspectiveCamera as d3,Vector3 as nn,Object3D as Hv,Quaternion as m3}from"three";import{BoxBufferGeometry as YD}from"three";var Yn=i=>{var e;return e=class extends i{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new YD(30,30,30),e};import{Camera as r3,LineSegments as n3,BufferGeometry as i3,LineBasicMaterial as o3,Color as Ip,Vector3 as s3,Float32BufferAttribute as Uv}from"three";import{Ray as QD,Sphere as e3,Matrix4 as t3,Vector3 as Ni}from"three";var Iu=new QD,Tp=new e3,Vv=new t3,Qn=(i,e,t,r,n=!1)=>{let s=e,l=i.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),Tp.copy(s.boundingSphere),Tp.applyMatrix4(l),t.ray.intersectsSphere(Tp)===!1||(Vv.copy(l).invert(),Iu.copy(t.ray).applyMatrix4(Vv),s.boundingBox!==null&&Iu.intersectsBox(s.boundingBox)===!1))return;let c,f,h,d,x=s.index,g=s.attributes.position,w=s.drawRange,S,D;if(n===!1){let G=Math.max(0,w.start),B=Math.min(x.count,w.start+w.count);for(S=G,D=B;S<D;S+=3)if(f=x.getX(S),h=x.getX(S+1),d=x.getX(S+2),c=C(i,t,Iu,g,f,h,d),c){c.faceIndex=Math.floor(S/3),r.push(c);return}}else{let B=s.attributes.position,P=new Ni,W=new Ni,M=new Ni,q=new Ni,E=2,R=1/((i.scale.x+i.scale.y+i.scale.z)/3),T=R*R,z=Math.max(0,w.start),A=Math.min(B.count,w.start+w.count);for(let $=z,he=A-1;$<he;$+=E){if(P.fromBufferAttribute(B,$),W.fromBufferAttribute(B,$+1),Iu.distanceSqToSegment(P,W,q,M)>T)continue;q.applyMatrix4(i.matrixWorld);let Ne=t.ray.origin.distanceTo(q);Ne<t.near||Ne>t.far||r.push({distance:Ne,point:M.clone().applyMatrix4(i.matrixWorld),object:i})}}function C(G,B,P,W,M,q,E){let b=new Ni,R=new Ni,T=new Ni,z=new Ni,A=new Ni;if(b.fromBufferAttribute(W,M),R.fromBufferAttribute(W,q),T.fromBufferAttribute(W,E),P.intersectTriangle(b,R,T,!1,z)===null)return null;A.copy(z),A.applyMatrix4(G.matrixWorld);let he=B.ray.origin.distanceTo(A);return he<B.near||he>B.far?null:{faceIndex:1,distance:he,point:A.clone(),object:G}}};var Mu=new s3,Sn=new r3,kv=class extends n3{constructor(e){let t=new i3,r=new o3({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],l={},c=new Ip(wh),f=new Ip(wh),h=new Ip(a0);d("n1","n2",c),d("n2","n4",c),d("n4","n3",c),d("n3","n1",c),d("f1","f2",c),d("f2","f4",c),d("f4","f3",c),d("f3","f1",c),d("n1","f1",c),d("n2","f2",c),d("n3","f3",c),d("n4","f4",c),d("p","n1",f),d("p","n2",f),d("p","n3",f),d("p","n4",f),d("u1","u2",h),d("u2","u3",h),d("u3","u1",h);function d(g,w,S){x(g,S),x(w,S)}function x(g,w){n.push(0,0,0),s.push(w.r,w.g,w.b),l[g]===void 0&&(l[g]=[]),l[g].push(n.length/3-1)}t.setAttribute("position",new Uv(n,3)),t.setAttribute("color",new Uv(s,3));super(t,r);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=l,this.update()}update(){let e=this.geometry,t=this.pointMap,r=!0;Sn.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let n=1,s=1,l=r?.8:1e-4;jn("n1",t,e,Sn,-n,-s,l),jn("n2",t,e,Sn,n,-s,l),jn("n3",t,e,Sn,-n,s,l),jn("n4",t,e,Sn,n,s,l);let c=l;jn("f1",t,e,Sn,-n,-s,c),jn("f2",t,e,Sn,n,-s,c),jn("f3",t,e,Sn,-n,s,c),jn("f4",t,e,Sn,n,s,c);let f=c,h=.5;jn("u1",t,e,Sn,n*.7*h,s*1.1,f),jn("u2",t,e,Sn,-n*.7*h,s*1.1,f),jn("u3",t,e,Sn,0,s*(1.1+.9*h),f),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function jn(i,e,t,r,n,s,l){Mu.set(n,s,l).unproject(r);let c=e[i];if(c!==void 0){let f=t.getAttribute("position");for(let h=0,d=c.length;h<d;h++)f.setXYZ(c[h],Mu.x,Mu.y,Mu.z)}}var Mp=class extends Yn(kv){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,t){Qn(this.object,this.geometry,e,t,!0)}};import{DirectionalLightHelper as a3}from"three";var za=class extends Yn(a3){constructor(e,t=15,r=10066329){super(e,t,r);this.object=e;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Qn(this.object,za.geometryHelper,e,t)}};import{AxesHelper as l3}from"three";var Fa=class extends Yn(l3){constructor(e,t=15){super(t);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,t){Qn(this.object,Fa.geometryHelper,e,t)}update(){}};import{PointLightHelper as c3}from"three";var Va=class extends Yn(c3){constructor(e,t=15,r=6710886){super(e,t,r);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Qn(this.object,Va.geometryHelper,e,t)}};import{SpotLightHelper as u3,Vector3 as f3}from"three";var Ou=class extends Yn(u3){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Qn(this.object,Ou.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=Ou._vector,t=this.object.distance?this.object.distance:1e3,r=t*Math.tan(this.object.angle);this.cone.scale.set(r,r,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,l=this.cone.material.length;s<l;s++)this.cone.material[s].color.set(n);else this.cone.material.color.set(n)}}},Au=Ou;Au._vector=new f3;var ei=(i,e)=>class extends i{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(r){this.visible=r,this.setHelperVisibility(r),this.setHelperChildrenVisibility(r)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(r){this.objectHelper.visible=r}setHelperChildrenVisibility(r){for(let n of this.children)yn(n)&&n.traverseEntity(s=>{vi(s)&&s.visible&&(s.objectHelper.visible=r)})}raycast(r,n){this.objectHelper.raycast(r,n)}copy(r,n=!0){return super.copy(r,n),r.enableHelper!==void 0&&(this.enableHelper=r.enableHelper),r.objectHelper!==void 0&&(this.objectHelper.visible=r.objectHelper.visible),this}toJSON(r){let n=super.toJSON(r),s=n.object;return s.enableHelper=this.enableHelper,n}fromJSON(r){return super.fromJSON(r),r.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(r,n){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let s=this;r.color!==void 0&&(s.color=kt(r.color,n)),r.intensity!==void 0&&(s.intensity=r.intensity),r.depth!==void 0&&(s.shadow.camera.far=r.depth,s.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows),r.helper!==void 0&&(this.enableHelper=r.helper,s.gizmos.shadowmap.visible=r.helper)}return this}};var Es=new nn,Ap=new nn,Yi=class extends ei(xn(h3),Mp){constructor(e=window.innerWidth,t=window.innerHeight,r=45,n,s=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=xo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=t,this.orthoCamera=new p3(e*-.5,e*.5,t*.5,t*-.5,n!=null?n:-5e4,s),this.perspCamera=new d3(r,e/t,n!=null?n:50,s),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(e,t){let r=new Yi().fromState(t);return r.enableHelper=!0,r.objectHelper.update(),r.uuid=e,r}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e){super.lookAt(e),this.getWorldPosition(Es),this.targetOffset=Es.distanceTo(e)}getTarget(e=new nn){return this.getWorldDirection(Ap),this.getWorldPosition(Es),Ap.multiplyScalar(this.targetOffset),e.copy(Es).add(Ap),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Es),Es.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new m3),t=new nn(0,0,1).applyQuaternion(e),r=new nn().copy(Hv.DefaultUp);this.isUpVectorFlipped&&r.negate(),r.applyQuaternion(e);let n=new nn().copy(Hv.DefaultUp).projectOnPlane(t),s=new nn().crossVectors(n,r).dot(t)>=0?1:-1;this.angleOffsetFromUp=n.angleTo(r)*s}getViewFrontToObject(e){let t=e.getWorldPosition(new nn),n=e.getWorldDirection(new nn).multiplyScalar(this.targetOffset);return{position:t.clone().add(n),target:t}}getViewToObject(e){let t=e.getWorldPosition(new nn),n=this.getWorldDirection(new nn).multiplyScalar(this.targetOffset);return{position:t.clone().sub(n),target:t}}setViewplaneSize(e,t){this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5,this.aspect=e/t,this.updateProjectionMatrix()}toOrthographic(e){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}toPerspective(e){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,t,r,n,s,l){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,r,n,s,l):this.orthoCamera.setViewOffset(e,t,r,n,s,l)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(e){this._cameraType==="PerspectiveCamera"?this.toPerspective(e):this._cameraType==="OrthographicCamera"&&this.toOrthographic(e)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}fromCameraRender(e){let t={near:this.orthoCamera.near,far:this.orthoCamera.far},r={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(e),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=t.near,this.orthoCamera.far=t.far,this.perspCamera.near=r.near,this.perspCamera.far=r.far,this.updateProjectionMatrix(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="CombinedCamera",r.cameraType=this.cameraType,r.targetOffset=this.targetOffset,r.isUpVectorFlipped=this.isUpVectorFlipped,r.angleOffsetFromUp=this.angleOffsetFromUp,r.left=this.left,r.right=this.right,r.top=this.top,r.bottom=this.bottom,this.view!==null&&(r.view=Object.assign({},this.view)),r.zoomOrtho=this.orthoCamera.zoom,r.nearOrtho=this.orthoCamera.near,r.far=this.far,r.aspect=this.aspect,r.fov=this.fov,r.focus=this.focus,r.filmGauge=this.filmGauge,r.filmOffset=this.filmOffset,r.zoomPersp=this.perspCamera.zoom,r.nearPersp=this.perspCamera.near,t}fromJSON(e){var t;if(super.fromJSON(e),this.cameraType=e.cameraType,e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.orbitControlsTarget!==void 0){let r=this.getWorldPosition(new nn),n=new nn().fromArray(e.orbitControlsTarget);this.targetOffset=n.distanceTo(r)}else e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=(t=e.angleOffsetFromUp)!=null?t:0,e.left!==void 0&&(this.left=e.left),e.right!==void 0&&(this.right=e.right),e.top!==void 0&&(this.top=e.top),e.bottom!==void 0&&(this.bottom=e.bottom),e.view!==void 0&&(this.view=Object.assign({},e.view)),e.zoomOrtho!==void 0&&(this.orthoCamera.zoom=e.zoomOrtho),e.nearOrtho!==void 0&&(this.orthoCamera.near=e.nearOrtho),e.far!==void 0&&(this.far=e.far),e.aspect!==void 0&&(this.aspect=e.aspect),e.fov!==void 0&&(this.fov=e.fov),e.focus!==void 0&&(this.focus=e.focus),e.filmGauge!==void 0&&(this.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(this.filmOffset=e.filmOffset),e.zoomPersp!==void 0&&(this.perspCamera.zoom=e.zoomPersp),e.nearPersp!==void 0&&(this.perspCamera.near=e.nearPersp),this.updateProjectionMatrix(),this}toCameraState(e=[]){let t={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return hs(t,e)}fromCameraState(e){let{orthographic:t,perspective:r}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),t!==void 0&&(t.near!==void 0&&(this.orthoCamera.near=t.near),t.zoom!==void 0&&(this.orthoCamera.zoom=t.zoom)),r!==void 0&&(r.near!==void 0&&(this.perspCamera.near=r.near),r.fov!==void 0&&(this.perspCamera.fov=r.fov),r.zoom!==void 0&&(this.perspCamera.zoom=r.zoom)),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(e){return fe(U(U({},super.toState(e)),this.toCameraState(e)),{type:this.cameraType})}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};import{Group as g3}from"three";var Qi=class extends ei(xn(g3),Fa){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,t){let r=new Qi().fromState(t);return r.uuid=e,r.enableHelper=!0,r.objectHelper.update(),r}toJSON(e){let t=super.toJSON(e);return t.object.objectType="EmptyObject",t}};import{DirectionalLight as y3,CameraHelper as Pu}from"three";var Ua=class extends ei(xn(y3),za){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=1,r.far=2500;let n=new Pu(this.shadow.camera);n.visible=!1,this._gizmos.shadowmap=n,this.update()}static createFromState(e,t,r){let n=new Ua().fromState(t,r);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Pu&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Pu&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Pu&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightDirectional",r.color=this.color.getHex(),r.intensity=this.intensity,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var n;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.shadow.normalBias=(n=e.shadow.normalBias)!=null?n:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.left=r.left,t.right=r.right,t.top=r.top,t.bottom=r.bottom,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromDirectionalLightState(e,t){let r=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;return super.fromLightState(e,t),e.size!==void 0&&hv(this,e.size),r&&this.update(),this}fromState(e,t){return super.fromState(e),this.fromDirectionalLightState(e,t),this}};import{PointLight as x3,Vector3 as Du,Box3 as v3,Box3Helper as Bu,Color as b3}from"three";var ka=class extends ei(xn(x3),Va){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let n=new Du(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new Du(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),l=new v3(n,s),c=new Bu(l,new b3(16755200));c.visible=!1,this._gizmos.shadowmap=c,this.update()}static createFromState(e,t,r){let n=new ka().fromState(t,r);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Bu&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Bu&&(t.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let t=this._gizmos[e];if(t instanceof Bu){let r=this.shadow.camera,n=new Du(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new Du(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);t.box.set(n,s),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightPoint",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.decay=this.decay,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var n,s;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow.normalBias=(n=e.shadow.normalBias)!=null?n:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray((s=e.shadow.mapSize)!=null?s:[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromPointLightState(e,t){return super.fromLightState(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(e,t){return super.fromState(e),this.fromPointLightState(e,t),this}};import{SpotLight as S3,CameraHelper as Gu,MathUtils as w3,Vector3 as Wv,Quaternion as N3}from"three";var qv=new Wv,$v=new Wv,Jv=new N3,Ha=class extends ei(xn(S3),Au){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=w3.RAD2DEG*2*this.angle,r.aspect=1,r.near=100,r.far=2500;let n=new Gu(this.shadow.camera);n.visible=!1,this._gizmos.shadowmap=n,this.update()}static createFromState(e,t,r){let n=new Ha().fromState(t,r);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Gu&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Gu&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Gu&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),$v.setFromMatrixPosition(this.matrixWorld),Jv.setFromRotationMatrix(this.matrixWorld),qv.copy(this.up).applyQuaternion(Jv).negate().multiplyScalar(this.distance),this.target.position.copy($v).add(qv),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightSpot",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.angle=this.angle,r.decay=this.decay,r.penumbra=this.penumbra,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var n;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.decay=e.decay,this.penumbra=e.penumbra,this.shadow.normalBias=(n=e.shadow.normalBias)!=null?n:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromSpotLightState(e,t){return super.fromLightState(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),this}fromState(e,t){return super.fromState(e),this.fromSpotLightState(e,t),this}};import{VideoTexture as C3}from"three";var Kv=i=>i.tagName==="VIDEO",Rs=class{static resize(e,t,r){let n=e/t,s;if(!r.image)return;let l=r.image;Kv(l)?s=l.videoWidth/l.videoHeight:s=l.width/l.height,n>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/n):r.repeat.set(1,1*s/n)),n<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*n/s*-1,1):r.repeat.set(1*n/s,1)),n==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(e,t,r){let n=e/t,s=r.image!==void 0?r.image.width/r.image.height:1,l;n>s?l={x:1,y:s/n}:n<s?l={x:n/s,y:1}:l={x:1,y:1},r.repeat.set(l.x,l.y),r.updateMatrix()}static resizeTextureLayers(e,t,r){let n=r.userData.layers,s=n.getLayers();for(let l=0;l<s.length;l++){let c=s[l];Nv(c)&&(Rs.resizeTextureLayer(e,t,c.uniforms[`f${c.id}_texture`].value),n.updateLayerUniform())}}static resizeComplex(e,t,r,n){let s=e/t,l,c=r.image;Kv(c)?l=c.videoWidth/c.videoHeight:l=c.width/c.height,n.geometry.type.includes("Shape")?(s>l&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t*l/s):r.repeat.set(1/e,1/t*l/s)),s<l&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*s/l*-1,1/t):r.repeat.set(1/e*s/l,1/t)),s==l&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t):r.repeat.set(1/e,1/t))):(s>l&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*l/s):r.repeat.set(1,1*l/s)),s<l&&(r.imageType=="WEBCAM"?r.repeat.set(1*s/l*-1,1):r.repeat.set(1*s/l,1)),s==l&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var Wa=class extends hr{constructor(e,t=new vr){super(e,t);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.userData.layers&&Rs.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(e,t){super.resizeGeometry(e,t,0),this.material.userData.layers&&Rs.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh2D",t}clone(){let e=super.clone();return e.updateGeometry({}),e}static fromTexture(e){let t,r;if(e instanceof C3){let l=e.image;t=l.videoWidth*.5,r=l.videoHeight*.5}else{let l=e.image;t=l.width*.5,r=l.height*.5}let n=ou.create({parameters:{width:t,height:r}}),s=new vr;return s.layersList.changeLayer(0,{type:qe.TEXTURE,texture:e}),s.layersList.moveLayer(0,1),s.dispose(),new Wa(n,s)}};var qa=class extends hr{constructor(e,t=new bn){super(e,t);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh3D",t}};var $a=class extends qa{constructor(e,t=new bn){super(e,t);this.objectType="NonParametric"}toJSON(e){let t=super.toJSON(e);return t.object.objectType="NonParametric",t}};var Ja;(function(t){t[t.TO_RIGHT=1]="TO_RIGHT",t[t.TO_LEFT=-1]="TO_LEFT"})(Ja||(Ja={}));var Op=class extends hr{constructor(e,t=new vr({transparent:!0,opacity:1,visible:!1,side:ju})){super(e,t);this.objectType="TextFrame";this.charContainer=new L3,this.add(this.charContainer),this.material.visible=!1,this._geometryUserData=e.userData,this.userData.textFrame={hexColor:null,opacity:1,visible:!0,text:"",fontSize:16,lineHeight:1.5,letterSpacing:1,fontFamily:"roboto_regular",textTransform:ki.None,horizontalAlignment:1,verticalAlignment:gi.Top,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new Zv(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,t,r){let n=su.create({parameters:{width:t.width,height:t.height}}),s=new Op(n).fromState(t,r);return s.uuid=e,s}async updateText(e){this.clearText();let t=this.userData.textFrame,r=t.fontFamily;await Rr.loadFont(r),t.text=e;let n=t.textOrigin,s=new Xv({visible:t.visible,transparent:!0,side:ju}),l=e.split(`
|
|
977
|
+
`),c=0;this.userData.textFrame.textLines=l.map((f,h)=>{let d=new To(c,t.lineHeight,t.fontSize);return d.message=f.split("").map(x=>{let g={char:x,fontFamily:r,letterSpacing:t.letterSpacing,fontSize:t.fontSize,LOD:16},w=s.clone();w.color=t.hexColor,w.opacity=t.opacity;let S=new Rr(g,w);return d.addChar3D(S,n),this.charContainer.add(S),S}),c+=d.maxCharSize*d.lineHeight,d}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let t=this.charContainer.children[0];this.charContainer.remove(t)}for(;e.length;)e.pop()}raycast(e,t){let r=[];if(super.raycast(e,r),r.length>0){t.push(r[0]);return}let n=[];for(let s=0,l=this.charContainer.children.length;s<l;++s)if(this.charContainer.children[s]instanceof Rr&&(e.intersectObject(this.charContainer.children[s],!1,n),n.length>0)){n[0].object=this,t.push(n[0]);return}}updateGeometry(e){var h,d,x,g;let t=this.userData,r=this.geometry.userData,n=r.parameters.width,s=r.parameters.height,l=(d=(h=e.parameters)==null?void 0:h.width)!=null?d:n,c=(g=(x=e.parameters)==null?void 0:x.height)!=null?g:s,f=t.textFrame;super.updateGeometry(e),f.maxLineSize=l,f.textOrigin.set(-.5*l,.5*c,0),c!==s?(this.checkOverFlow(),this.checkCapacity()):l!==n&&(n<l?this.checkCapacity():n>l&&this.checkOverFlow())}checkOverFlow(e=0){let t=this.userData,r=t.textFrame.textOrigin,n=t.textFrame.textLines;for(let s=e;s<n.length;s++){n[s].updateYLinePos(this.getNewLinePosition(s)),n[s].fullUpdate(r);let l=[];for(;n[s].checkOverFlow(t.textFrame.maxLineSize);)n[s].containSpaceOverFlow()?l.unshift(n[s].getWord(n[s].message.length-1,-1)):l.unshift(n[s].popChar());if(l.length>0){n[s+1]===void 0?(n[s].isEndLine(!1),this.createTextLine()):n[s].endLine&&(this.createTextLine(s+1),n[s].isEndLine(!1),n[s+1].isEndLine(!0));let c=0;for(let f=0;f<l.length;f+=1)for(let h=0;h<l[f].length;h+=1)n[s+1].addChar3D(l[f][h],r,c),c+=1;n[s+1].fullUpdate(r)}n[s].fullUpdate(r)}this.textFullUpdate(e)}checkCapacity(e=0){let t=this.userData,r=t.textFrame.textOrigin,n=t.textFrame.maxLineSize,s=t.textFrame.textLines;for(let l=e;l<s.length;l+=1)if(s[l].updateYLinePos(this.getNewLinePosition(l)),s[l].fullUpdate(r),!!s[l-1])for(;!s[l-1].endLine;){let c,f=s[l-1].spaceLeft(n);if(s[l].wordSize(0,1)<=f){s[l].containSpace()?c=s[l].getWord(0,1):c=s[l].popChar(0);for(let h=0;h<c.length;h+=1)c[h]&&s[l-1].addChar3D(c[h],r)}else{s[l].isEmpty()?(s[l].endLine&&s[l-1].isEndLine(!0),s.splice(l,1),l-=1):(s[l].updateYLinePos(this.getNewLinePosition(l)),s[l].fullUpdate(r));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let r=this.userData.textFrame;r.textLines.splice(e,0,new To(this.getNewLinePosition(e),r.lineHeight,r.fontSize))}textFullUpdate(e=0){let r=this.userData.textFrame,n=r.textLines,s=this.getVerticalAlignmentOffSet();for(let l=e;l<n.length;l++)n[l].updateYLinePos(this.getNewLinePosition(l)),n[l].fullUpdate(r.textOrigin),n[l].alignText(r.textOrigin,r.maxLineSize,r.horizontalAlignment,r.verticalAlignment,s)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case gi.Top:return 0;case gi.Center:return this.getRemainingVerticalSpace()/2;case gi.Bottom:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let t=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(t.length)}getNewLinePosition(e){let r=this.userData.textFrame.textLines,n=0;for(let s=0;s<e;s+=1)n+=r[s].maxCharSize*r[s].lineHeight;return n}updateColor(e){var n;let t=this.userData;t.textFrame.hexColor=e;let r=t.textFrame.textLines;for(let s=0;s<r.length;s++){let l=r[s].message;for(let c=0;c<l.length;c++){let f=l[c].material;((n=f.color)==null?void 0:n.isColor)&&(f.color=e)}}}updateOpacity(e){let t=this.userData;t.textFrame.opacity=e;let r=t.textFrame.textLines;for(let n=0;n<r.length;n++){let s=r[n].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.opacity=e}}}updateVisible(e){let t=this.userData;t.textFrame.visible=e;let r=t.textFrame.textLines;for(let n=0;n<r.length;n++){let s=r[n].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.visible=e}}}async updateFontFamily(e){await Rr.loadFont(e);let r=this.userData.textFrame,n=r.textLines;r.fontFamily=e;for(let s=0;s<n.length;s++){let l=n[s].message;for(let c=0;c<l.length;c++)l[c].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let r=this.userData.textFrame,n=r.textLines,s=r.fontSize;r.fontSize=e;for(let l=0;l<n.length;l++)n[l].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let r=this.userData.textFrame;await Rr.loadFont(r.fontFamily);let n=r.textLines;switch(r.textTransform=e,e){case ki.Upper:for(let s=0;s<n.length;s++){let l=n[s].message;for(let c=0;c<l.length;c++)n[s].message[c].updateChar(l[c].char.toUpperCase())}break;case ki.Lower:for(let s=0;s<n.length;s++){let l=n[s].message;for(let c=0;c<l.length;c++)n[s].message[c].updateChar(l[c].char.toLowerCase())}break;default:for(let s=0;s<n.length;s++){let l=n[s].message;for(let c=0;c<l.length;c++)n[s].message[c].updateChar(l[c].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let t=this.userData,r=t.textFrame.textLines;t.textFrame.letterSpacing=e;for(let n=0;n<r.length;n++){let s=r[n].message;for(let l=0;l<s.length;l++)s[l].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let t=this.userData;t.textFrame.LOD=e;let r=t.textFrame.textLines;for(let n=0;n<r.length;n++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let t=this.userData,r=t.textFrame.textLines;t.textFrame.lineHeight=e;for(let n=0;n<r.length;n++)r[n].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let t=this.userData;t.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let t=this.userData;t.textFrame.horizontalAlignment=e,this.textFullUpdate()}toJSON(e){let t=super.toJSON(e),r=t.object;r.objectType="TextFrame";let s=this.userData.textFrame.textLines.map(l=>{let c=l.message.map(f=>({char:f.char,originalChar:f.originalChar,fontFamily:f.fontFamily,letterSpacing:f.letterSpacing,fontSize:f.fontSize,LOD:f.LOD}));return{align:l.align,endLine:l.endLine,lineHeight:l.lineHeight,maxCharSize:l.maxCharSize,yLinePos:l.yLinePos,message:c}});return r.userData.textFrame.textLinesData=s,t}async fromJSONasync(e){if(super.fromJSON(e),e.userData!==void 0){let t=e.userData.textFrame;await Rr.loadFont(t.fontFamily),t.textOrigin=new Zv(t.textOrigin.x,t.textOrigin.y,t.textOrigin.z);let r=new Xv({color:t.hexColor,opacity:t.opacity,visible:t.visible,transparent:!0,side:ju});t.textLinesData&&(t.textLines=t.textLinesData.map((n,s)=>{let l=new To(Number(n.yLinePos),Number(n.lineHeight),Number(n.maxCharSize)),c=n.message.map((f,h)=>{if(f.char===void 0){let g=t.textLines[s].message[h];if("geometries"in g){let w=g.geometries[0].userData.parameters;Object.assign(f,{LOD:w.lod,char:w.char,fontFamily:w.fontFamily,fontSize:w.fontSize,letterSpacing:w.letterSpacing,originalChar:w.char})}}let d={char:f.char,fontFamily:f.fontFamily,letterSpacing:Number(f.letterSpacing),fontSize:Number(f.fontSize),LOD:f.LOD},x=new Rr(d,r.clone());return l.addChar3D(x,t.textOrigin),this.charContainer.add(x),x});return l.message=c,l}),this.userData.textFrame=t),this.textFullUpdate()}return this}fromTextFrameData(e,t){if(e.color!==void 0){let r=kt(e.color,t);this.updateColor(r),this.updateOpacity(r.a)}e.alpha!==void 0&&this.updateOpacity(e.alpha),e.font!==void 0&&this.updateFontFamily(e.font),e.horizontalAlign!==void 0&&this.updateHorizontalAlignment(e.horizontalAlign),e.verticalAlign!==void 0&&this.updateVerticalAlignment(e.verticalAlign),e.textTransform!==void 0&&this.updateTextTransform(e.textTransform),e.fontSize!==void 0&&this.updateFontSize(e.fontSize),e.lineHeight!==void 0&&this.updateLineHeight(e.lineHeight),e.letterSpacing!==void 0&&this.updateLetterSpacing(e.letterSpacing),e.text!==void 0&&e.text!==""&&this.updateText(e.text),(e.width!==void 0||e.height!==void 0)&&this.updateGeometry({parameters:{width:e.width,height:e.height}})}fromState(e,t){return super.fromState(e),this.fromTextFrameData(e,t),this}convertToVector(){let{fontFamily:e,hexColor:t}=this.userData.textFrame,r=new Qi;r.name="Text Shape";let n=Rr.fontCache[e];for(let s of this.charContainer.children)s instanceof Rr&&n.generateShapes(s.char,1).forEach(l=>{let c=new st().fromShape(l);c.applyScale(s.scale.x,s.scale.y);let f=ur.create({shape:c}),h=new vr({side:ju});h.color=t;let d=new Io(f,h);d.name=s.char,d.position.copy(s.position),d.rotation.copy(s.rotation),r.attach(d)});return r}},zs=Op;zs.VerticalAlign=gi,zs.HorizontalAlign=Lr,zs.TextTransform=ki;import{HemisphereLight as F3,Scene as V3,Vector3 as U3,Color as fb,Fog as k3,Box3 as H3}from"three";import{BufferGeometryLoader as _3}from"three";function Yv(i,e){return T3(i)}function T3(i){let e={parameters:i,type:i.type};if(i.type==="VectorGeometry"){let r=st.createFromState(i.shape,i.width,i.height);e.shape=r}else i.type==="NonParametricGeometry"&&(i.data.groups&&i.data.groups.forEach(r=>{var n;return r.materialIndex=Math.max((n=r.materialIndex)!=null?n:0,0)}),e.geometry=new _3().parse(i));let t;try{t=La(e)}catch(r){console.error(r)}if(!t){let r=st.createFromState(ws.defaultData(),100,100);e.shape=r,t=La(e)}return t}import{Box3 as I3,Matrix4 as Mo,Sphere as tb,Vector3 as M3}from"three";var rb=ug(eb());var Pp;au.then(i=>{Pp=i});var nb=new Mo,A3=new Mo,O3=new Mo,En=new I3,eo=new M3,P3=new Mo,D3=new Mo,Ka=class extends hr{constructor(e,t,r,n=new bn){super(r!=null?r:t,n);this.subdivPointer=e;this.originalGeometry=t;this.subdividedGeometry=r;this.objectType="SubdivObject";this.hiddenMatrixOld=new Mo;this.smoothShading=!0;this.matrixWorldRigid=new Mo;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,t,r){let{subdivPointer:n,originalGeometry:s,subdividedGeometry:l}=en.build(t.geometry,void 0,void 0,!t.flatShading),c=Ra(t.material,r),f=new Ka(n,s,l||void 0,c);return f.calcBoundingBox(),f.freeSubdivPointer(),f.uuid=e,f.fromState(t),f}shallowClone(e){return new $a(this.geometry,this.material).shallowCopy(this,e)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="SubdivObject",t}buildFromStore(e){var s,l,c;let{originalGeometry:t,subdividedGeometry:r,subdivPointer:n}=en.build(e,this.subdivPointer,void 0,this.smoothShading,this.shearScale);if(this.subdivPointer=n,t!==void 0&&((s=this.originalGeometry)==null||s.dispose(),this.originalGeometry=t),r!==void 0&&((l=this.subdividedGeometry)==null||l.dispose(),this.subdividedGeometry=r!=null?r:void 0),this.geometry=(c=this.subdividedGeometry)!=null?c:this.originalGeometry,this.cloner)for(let f of this.cloner.children)f.geometry=this.geometry;e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){en.buildLevel(this.subdivPointer,!0,this.smoothShading,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&en.buildLevel(this.subdivPointer,!1,this.smoothShading,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){var e;this.originalGeometry.dispose(),this.originalGeometry=en.buildLevel(this.subdivPointer,!0,this.smoothShading),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=en.buildLevel(this.subdivPointer,!1,this.smoothShading)),this.geometry=(e=this.subdividedGeometry)!=null?e:this.originalGeometry}raycast(e,t){var r;this.geometry=this.originalGeometry,hr.prototype.raycast.call(this,e,t),this.geometry=(r=this.subdividedGeometry)!=null?r:this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,t=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:r,v:n,q:s}=(0,rb.SVD)(t),l=nb.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),c=A3.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1),f=O3.copy(c).transpose();this.shearScale=P3.makeScale(s[0],s[1],s[2]).multiply(f).premultiply(c),this.shearScaleInv=D3.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,f),s.every(h=>Math.abs(s[0]-h)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new tb);let t=e.attributes.position,r=e.boundingSphere.center;En.setFromBufferAttribute(t),En.getCenter(r),e.boundingSphere.radius=r.distanceTo(En.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),En.getSize(eo);let n={width:eo.x,height:eo.y,depth:eo.z};return this.geometry.userData.parameters=n,n}updateBoundingBox(e){let t=this.originalGeometry;En.min.set(e[0],e[2],e[4]),En.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(En.min.applyMatrix4(this.shearScaleInv),En.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new tb);let r=t.boundingSphere.center;En.getCenter(r),t.boundingSphere.radius=r.distanceTo(En.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),En.getSize(eo);let n={width:eo.x,height:eo.y,depth:eo.z};return this.geometry.userData.parameters=n,n}freeSubdivPointer(){this.subdivPointer&&(Pp.free_bvh(this.subdivPointer),Pp.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(e){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:e.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:e.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:e.parameters.depth/this.geometry.userData.parameters.depth,ib(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(ib(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters=U({},e.parameters)}};function ib(i,e,t,r){let n=i.position.array,s=i.normal.array,l=nb.makeScale(e,t,r).invert().elements,c,f,h;for(var d=0,x=n.length;d<x;d+=3)n[d]*=e,n[d+1]*=t,n[d+2]*=r,c=s[d],f=s[d+1],h=s[d+2],s[d]=l[0]*c+l[4]*f+l[8]*h,s[d+1]=l[1]*c+l[5]*f+l[9]*h,s[d+2]=l[2]*c+l[6]*f+l[10]*h}import{BackSide as B3,DoubleSide as G3,FrontSide as j3}from"three";function ob(i,e){e.flatShading!==void 0&&(i.flatShading=e.flatShading,i.needsUpdate=!0),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.side!==void 0&&(e.side===xs.Front?i.side=j3:e.side===xs.Back?i.side=B3:i.side=G3)}function E3(i,e){if(Array.isArray(i.material))for(let t of i.material)ob(t,e);else{let t=i.material;ob(t,e)}i.objectType==="SubdivObject"&&e.flatShading!==void 0&&(i.material.flatShading=!1,i.smoothShading=!e.flatShading,i.updateMesh())}function sb(i,e,t){let r;if(e.geometry.type==="SubdivGeometry")r=Ka.createFromState(i,e,t);else{let n=Yv(e.geometry,t),s="materials"in e?jv(e.materials,t):Ra(e.material,t);Fc.is2DParametricMesh(n.userData.type)?r=new Wa(n,s):(n==null?void 0:n.userData.type)==="VectorGeometry"?r=new Io(n,s):e.geometry.type==="NonParametricGeometry"?r=new $a(n,s):r=new qa(n,s),r.uuid=i,r.fromState(e)}return E3(r,e),r}function ab(i,e,t){return e.type==="Mesh"?sb(i,e,t):e.type==="TextFrame"?zs.createFromState(i,e,t):e.type==="Empty"?Qi.createFromState(i,e):e.type==="PointLight"?ka.createFromState(i,e,t):e.type==="SpotLight"?Ha.createFromState(i,e,t):e.type==="DirectionalLight"?Ua.createFromState(i,e,t):ps.is(e.type)?Yi.createFromState(i,e):(console.error(e),new Qi)}function R3(i,e){e.uniforms[`f${e.id}_transmissionSamplerMap`].value=i.texture,e.uniforms[`f${e.id}_transmissionDepthMap`].value=i.depthTexture}function lb(i,e,t){if(!t.userData.layers)return!1;let r=!1,n=t.userData.layers.getLayersOfType(qe.TRANSMISSION);return n.length>0?(e.layers.set(3),r=!0,i!==void 0&&n.forEach(s=>R3(i,s))):e.layers.set(0),r}function cb(i,e){let t=!1;return e.traverseEntity(r=>{if(r instanceof hr)if(Array.isArray(r.material))for(let n=0;n<r.material.length;n++)lb(i,r,r.material[n])&&(t=!0);else lb(i,r,r.material)&&(t=!0)}),t}function ub(i,e){"material"in i&&z3(i.material,e),"geometry"in i&&i.geometry.dispose()}function z3(i,e){fg(i).forEach(t=>{e.isSharedMaterial(t)||t.dispose()})}var hb=new U3,Dp=class extends uu(V3){constructor(e,t){super();this.objectType="Scene";this.alpha=1;this.backupFog=new k3(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new fb(1,0,0);this.bgColor=new fb(1,1,1);this.entityByUuid={};this.ambientLight=new F3(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.sharedAssetManager=t,this.init(e,t)}needsTransmission(e){return this.needsTransmissionDirty&&(this._needsTransmission=cb(e,this),e!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}find(e){if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}get color(){return this._color}set color(e){this.fogUseBGColor===!0&&this.backupFog.color.copy(e),this._color.copy(e)}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){if(this.createChildrenObjects(e.objects,this,t),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(kt(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let r=this.find(e.publish.playCamera);r instanceof Yi&&this.switchActiveCamera(r)}}clearScene(e){this.traverseEntity(t=>{ub(t,e)});for(let t of this.children)yn(t)&&t.removeFromParent()}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=Yi.createFromState(Dp.PERSONAL_CAMERA_ID,fe(U({},Uc.defaultData),{name:"Personal Camera"}));return e.enableHelper=!1,e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],r=n=>{for(let s of n.children)yn(s)&&!s.raycastLock&&s.visible&&((_s(s)||vi(s)&&s.enableHelper&&s.objectHelper.parent)&&e.intersectObject(s,!1,t),r(s))};return r(this),t}traverseEntity(e){for(let t of this.children)yn(t)&&t.traverseEntity(e)}updateFog(e,t){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=kt(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}toJSON(e){return{}}fromJSON(e){return this}dispose(){this.clearScene(this.sharedAssetManager),this.sharedAssetManager.dispose()}updateAmbientLight(e,t){fv(this.ambientLight,e,t),e.groundColor!==void 0&&(this.ambientLight.groundColor=kt(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=e,e.enableHelper=!1}setBackgroundColor(e){this.bgColor=e,this.alpha=e.a}createChildrenObjects(e,t,r){for(let n of e)this.createChildObject(n.id,n.data,n.children,t,r)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createChildObject(e,t,r,n,s){let l=ab(e,t,s);return l&&(this.entityByUuid[e]=l,n.add(l),this.createChildrenObjects(r,l,s)),l}getCenter(e){let t=[];for(let n=0,s=e.length;n<s;++n){let{id:l,recursive:c}=e[n],f=this.find(l),h=c?f.recursiveBBox:f.singleBBox;t.push(...h.vertices)}let r=new H3;return r.setFromPoints(t),r.getCenter(hb),hb}copyMatrixWorld(e,t){if(e===null){t.identity();return}let r=this.find(e);r?t.copy(r.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){var n;if(e===null){t.identity();return}let r=(n=this.find(e))==null?void 0:n.parent;r?t.copy(r.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof hr)if(Array.isArray(t.material))for(let r=0;r<t.material.length;r++)e(t.material[r]);else e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let r,n;e>=t?(r=t/e,n=1):(r=1,n=e/t),this.traverseMaterial(s=>{s.layersList.getLayersOfType(qe.TRANSMISSION).forEach(c=>{c.uniforms[`f${c.id}_aspectRatio`].value.x=r,c.uniforms[`f${c.id}_aspectRatio`].value.y=n})})}},Ru=Dp;Ru.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{DRACOLoader as W3}from"three/examples/jsm/loaders/DRACOLoader.js";var to;function q3(){return to||(to=new W3,to.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),to.decoderPending}async function $3(i){if(to){let e={attributeIDs:to.defaultAttributeIDs,attributeTypes:to.defaultAttributeTypes,useUniqueIDs:!1},t;try{t=await to.decodeGeometry(new Int8Array(i).buffer,e)}catch(r){console.error(r)}if(t)return{index:t.index?{array:t.index.array}:void 0,attributes:Object.entries(t.attributes).map(([r,n])=>({name:r,itemSize:n.itemSize,array:n.array}))}}return null}async function pb(i){let[e,t]=ih(Pc.deserialize(new Uint8Array(i))),r=[];e.scene.objects.traverse((n,s)=>{s.type==="Mesh"&&s.geometry.type==="NonParametricGeometry"&&s.geometry.data.draco!==void 0&&r.push(s)}),r.length&&await q3();for(let n of r){let s=await $3(sh(n.geometry.data.draco));if(s){s.index&&(n.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let l={};s.attributes.forEach(({name:c,array:f,itemSize:h})=>{l[c]={array:f,itemSize:h,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=l,n.geometry.data.draco=void 0}}return t.result().data}import{WebGLRenderTarget as J3,LinearMipmapLinearFilter as K3,LinearFilter as X3,ClampToEdgeWrapping as db,DepthTexture as Z3}from"three";var mb=new vr,Bp=class extends tn{},Gp=class{constructor(e){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new J3(2048,2048,{generateMipmaps:!0,minFilter:K3,magFilter:X3,wrapS:db,wrapT:db}),this.transmissionRenderTarget.depthTexture=new Z3(2048,2048),this.reset(e)}reset(e){for(let[t,r]of Object.entries(e.images))this.addImage(t,r.data);for(let[t,r]of Object.entries(e.colors))this.addColor(t,r);for(let[t,r]of Object.entries(e.materials))this.addMaterial(t,Lp(r,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}addMaterial(e,t){t.uuid=e,this.materials[e]=t}deleteMaterial(e){this.materials[e]&&(this.materials[e].dispose(),delete this.materials[e])}isSharedMaterial(e){return e.uuid in this.materials||e===mb}getMaterial(e){let t=this.materials[e];return t}getMaterialOrDeletedPlaceholder(e){var t;return(t=this.materials[e])!=null?t:mb}getMaterials(){return this.materials}addImage(e,t){if(this.images[e])return this.images[e].onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e].src=t,!0;{let r=new Image;return r.src=t,r.onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e]=r,!1}}deleteImage(e){this.images[e]&&delete this.images[e]}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]}getImages(){return this.images}addColor(e,t){return this.colors[e]?("a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):("a"in t?this.colors[e]=new Bp(t.r,t.g,t.b,t.a):this.colors[e]=new Bp(t.r,t.g,t.b,1),!1)}updateColor(e,t){var r,n,s,l;if(this.colors[e]){let c=this.colors[e];return this.colors[e].r=(r=t.r)!=null?r:c.r,this.colors[e].g=(n=t.g)!=null?n:c.g,this.colors[e].b=(s=t.b)!=null?s:c.b,this.colors[e].a=(l=t.a)!=null?l:c.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this.onImageLoad=void 0}};import{Color as yb,ShaderLib as Y3}from"three";var xb=ug(gb());function vb(i){let e=new Set;return i.traverse(t=>{if(_s(t))if((0,xb.isArray)(t.material))t.material.forEach(r=>{let n=r;e.has(n)||e.add(n)});else{let r=t.material;e.has(r)||e.add(r)}}),e.forEach(t=>{let r=t.onBeforeCompile.bind(t);Q3(t)?(Object.assign(t,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new yb,specularColor:new yb}),t.onBeforeCompile=(n,s)=>{r&&r(n,s),n.uniforms=Object.assign(Y3.physical.uniforms,n.uniforms),t.userData.layers.getLayersOfType(qe.TRANSMISSION).forEach(l=>{n.uniforms.transmissionSamplerMap.value&&(l.uniforms["f"+l.id+"_transmissionSamplerMap"].value=n.uniforms.transmissionSamplerMap.value,l.uniforms["f"+l.id+"_transmissionSamplerSize"].value=n.uniforms.transmissionSamplerSize.value)})}):eB(t)||(t.onBeforeCompile=(n,s)=>{r&&r(n,s),t.transparent=!1})}),i}function Q3(i){return i.userData.layers.getLayersOfType(qe.TRANSMISSION).length>0}function eB(i){let e=i.userData.layers.head,t=0;for(;e!==void 0;){if(e.type!==qe.LIGHTING&&e.type!==qe.FRESNEL){let r=e.uniforms["f"+e.id+"_alpha"];r&&(t+=(1-t)*r.value)}e=e.next}return t<1}function bb(i){return i.traverse(e=>{if(e.type==="Camera"){let t=e;t.type=t.cameraType}}),i}var Sb=class extends rB{load(e,t,r,n=console.error){let s=new tB(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,async l=>{try{if(typeof l=="string")throw new Error("The .spline file is not binary!");let c=await this.parse(l);t(c)}catch(c){n(c)}},r,n)}async parse(e){let t=await pb(e),r=new Gp(t.shared),n=new Ru(t.scene,r);return bb(vb(n))}};export{Sb as default};
|