@splinetool/loader 1.0.21 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,30 +1,31 @@
1
- "use strict";var MS=Object.create;var Fs=Object.defineProperty;var IS=Object.getOwnPropertyDescriptor;var NS=Object.getOwnPropertyNames;var DS=Object.getPrototypeOf,ES=Object.prototype.hasOwnProperty;var BS=(n,t,e)=>t in n?Fs(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var fr=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),lh=(n,t)=>{for(var e in t)Fs(n,e,{get:t[e],enumerable:!0})},ch=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of NS(t))!ES.call(n,o)&&o!==e&&Fs(n,o,{get:()=>t[o],enumerable:!(r=IS(t,o))||r.enumerable});return n};var nr=(n,t,e)=>(e=n!=null?MS(DS(n)):{},ch(t||!n||!n.__esModule?Fs(e,"default",{value:n,enumerable:!0}):e,n)),LS=n=>ch(Fs({},"__esModule",{value:!0}),n);var Gt=(n,t,e)=>(BS(n,typeof t!="symbol"?t+"":t,e),e);var Hg=fr((gp,Ug)=>{(function(n,t){typeof gp=="object"?Ug.exports=t():typeof define=="function"&&define.amd?define(t):n.Alea=t()})(gp,function(){"use strict";return n.importState=function(e){var r=new n;return r.importState(e),r},n;function n(){return function(e){var r=0,o=0,i=0,a=1;e.length==0&&(e=[+new Date]);var s=t();r=s(" "),o=s(" "),i=s(" ");for(var l=0;l<e.length;l++)r-=s(e[l]),r<0&&(r+=1),o-=s(e[l]),o<0&&(o+=1),i-=s(e[l]),i<0&&(i+=1);s=null;var u=function(){var c=2091639*r+a*23283064365386963e-26;return r=o,o=i,i=c-(a=c|0)};return u.next=u,u.uint32=function(){return u()*4294967296},u.fract53=function(){return u()+(u()*2097152|0)*11102230246251565e-32},u.version="Alea 0.9",u.args=e,u.exportState=function(){return[r,o,i,a]},u.importState=function(c){r=+c[0]||0,o=+c[1]||0,i=+c[2]||0,a=+c[3]||0},u}(Array.prototype.slice.call(arguments))}function t(){var e=4022871197,r=function(o){o=o.toString();for(var i=0;i<o.length;i++){e+=o.charCodeAt(i);var a=.02519603282416938*e;e=a>>>0,a-=e,a*=e,e=a>>>0,a-=e,e+=a*4294967296}return(e>>>0)*23283064365386963e-26};return r.version="Mash 0.9",r}})});var Qg=fr((hu,Xg)=>{(function(n,t){typeof hu=="object"&&typeof Xg<"u"?t(hu):typeof define=="function"&&define.amd?define(["exports"],t):t((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(hu,function(n){"use strict";n.SVD=function(t,e,r,o,i){if(e=e===void 0||e,r=r===void 0||r,i=1e-64/(o=o||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var a,s,l,u,c,d,p,f,h,m,y,g,b=t[0].length,S=t.length;if(S<b)throw new TypeError("Invalid matrix: m < n");for(var w=[],v=[],_=[],A=e==="f"?S:b,x=m=p=0;x<S;x++)v[x]=new Array(A).fill(0);for(x=0;x<b;x++)_[x]=new Array(b).fill(0);var T,C=new Array(b).fill(0);for(x=0;x<S;x++)for(a=0;a<b;a++)v[x][a]=t[x][a];for(x=0;x<b;x++){for(w[x]=p,h=0,l=x+1,a=x;a<S;a++)h+=Math.pow(v[a][x],2);if(h<i)p=0;else for(f=(d=v[x][x])*(p=d<0?Math.sqrt(h):-Math.sqrt(h))-h,v[x][x]=d-p,a=l;a<b;a++){for(h=0,s=x;s<S;s++)h+=v[s][x]*v[s][a];for(d=h/f,s=x;s<S;s++)v[s][a]=v[s][a]+d*v[s][x]}for(C[x]=p,h=0,a=l;a<b;a++)h+=Math.pow(v[x][a],2);if(h<i)p=0;else{for(f=(d=v[x][x+1])*(p=d<0?Math.sqrt(h):-Math.sqrt(h))-h,v[x][x+1]=d-p,a=l;a<b;a++)w[a]=v[x][a]/f;for(a=l;a<S;a++){for(h=0,s=l;s<b;s++)h+=v[a][s]*v[x][s];for(s=l;s<b;s++)v[a][s]=v[a][s]+h*w[s]}}m<(y=Math.abs(C[x])+Math.abs(w[x]))&&(m=y)}if(r)for(x=b-1;0<=x;x--){if(p!==0){for(f=v[x][x+1]*p,a=l;a<b;a++)_[a][x]=v[x][a]/f;for(a=l;a<b;a++){for(h=0,s=l;s<b;s++)h+=v[x][s]*_[s][a];for(s=l;s<b;s++)_[s][a]=_[s][a]+h*_[s][x]}}for(a=l;a<b;a++)_[x][a]=0,_[a][x]=0;_[x][x]=1,p=w[x],l=x}if(e){if(e==="f")for(x=b;x<S;x++){for(a=b;a<S;a++)v[x][a]=0;v[x][x]=1}for(x=b-1;0<=x;x--){for(l=x+1,p=C[x],a=l;a<A;a++)v[x][a]=0;if(p!==0){for(f=v[x][x]*p,a=l;a<A;a++){for(h=0,s=l;s<S;s++)h+=v[s][x]*v[s][a];for(d=h/f,s=x;s<S;s++)v[s][a]=v[s][a]+d*v[s][x]}for(a=x;a<S;a++)v[a][x]=v[a][x]/p}else for(a=x;a<S;a++)v[a][x]=0;v[x][x]=v[x][x]+1}}for(o*=m,s=b-1;0<=s;s--)for(var P=0;P<50;P++){for(T=!1,l=s;0<=l;l--){if(Math.abs(w[l])<=o){T=!0;break}if(Math.abs(C[l-1])<=o)break}if(!T){for(c=0,u=l-(h=1),x=l;x<s+1&&(d=h*w[x],w[x]=c*w[x],!(Math.abs(d)<=o));x++)if(p=C[x],C[x]=Math.sqrt(d*d+p*p),c=p/(f=C[x]),h=-d/f,e)for(a=0;a<S;a++)y=v[a][u],g=v[a][x],v[a][u]=y*c+g*h,v[a][x]=-y*h+g*c}if(g=C[s],l===s){if(g<0&&(C[s]=-g,r))for(a=0;a<b;a++)_[a][s]=-_[a][s];break}for(m=C[l],d=(((y=C[s-1])-g)*(y+g)+((p=w[s-1])-(f=w[s]))*(p+f))/(2*f*y),p=Math.sqrt(d*d+1),d=((m-g)*(m+g)+f*(y/(d<0?d-p:d+p)-f))/m,x=l+(h=c=1);x<s+1;x++){if(p=w[x],y=C[x],f=h*p,p*=c,g=Math.sqrt(d*d+f*f),d=m*(c=d/(w[x-1]=g))+p*(h=f/g),p=-m*h+p*c,f=y*h,y*=c,r)for(a=0;a<b;a++)m=_[a][x-1],g=_[a][x],_[a][x-1]=m*c+g*h,_[a][x]=-m*h+g*c;if(g=Math.sqrt(d*d+f*f),d=(c=d/(C[x-1]=g))*p+(h=f/g)*y,m=-h*p+c*y,e)for(a=0;a<S;a++)y=v[a][x-1],g=v[a][x],v[a][x-1]=y*c+g*h,v[a][x]=-y*h+g*c}w[l]=0,w[s]=d,C[s]=m}for(x=0;x<b;x++)C[x]<o&&(C[x]=0);return{u:v,q:C,v:_}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var O0=fr((Rp,Vp)=>{(function(n,t){typeof Rp=="object"&&typeof Vp<"u"?Vp.exports=t():typeof define=="function"&&define.amd?define(t):(n=n||self,n.TinyQueue=t())})(Rp,function(){"use strict";var n=function(r,o){if(r===void 0&&(r=[]),o===void 0&&(o=t),this.data=r,this.length=this.data.length,this.compare=o,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)};n.prototype.push=function(r){this.data.push(r),this.length++,this._up(this.length-1)},n.prototype.pop=function(){if(this.length!==0){var r=this.data[0],o=this.data.pop();return this.length--,this.length>0&&(this.data[0]=o,this._down(0)),r}},n.prototype.peek=function(){return this.data[0]},n.prototype._up=function(r){for(var o=this,i=o.data,a=o.compare,s=i[r];r>0;){var l=r-1>>1,u=i[l];if(a(s,u)>=0)break;i[r]=u,r=l}i[r]=s},n.prototype._down=function(r){for(var o=this,i=o.data,a=o.compare,s=this.length>>1,l=i[r];r<s;){var u=(r<<1)+1,c=i[u],d=u+1;if(d<this.length&&a(i[d],c)<0&&(u=d,c=i[d]),a(c,l)>=0)break;i[r]=c,r=u}i[r]=l};function t(e,r){return e<r?-1:e>r?1:0}return n})});var T0=fr((EU,zp)=>{"use strict";var bu=O0();bu.default&&(bu=bu.default);zp.exports=C0;zp.exports.default=C0;function C0(n,t,e){t=t||1;for(var r,o,i,a,s=0;s<n[0].length;s++){var l=n[0][s];(!s||l[0]<r)&&(r=l[0]),(!s||l[1]<o)&&(o=l[1]),(!s||l[0]>i)&&(i=l[0]),(!s||l[1]>a)&&(a=l[1])}var u=i-r,c=a-o,d=Math.min(u,c),p=d/2;if(d===0){var f=[r,o];return f.distance=0,f}for(var h=new bu(void 0,CC),m=r;m<i;m+=d)for(var y=o;y<a;y+=d)h.push(new Vn(m+p,y+p,p,n));var g=MC(n),b=new Vn(r+u/2,o+c/2,0,n);b.d>g.d&&(g=b);for(var S=h.length;h.length;){var w=h.pop();w.d>g.d&&(g=w,e&&console.log("found best %d after %d probes",Math.round(1e4*w.d)/1e4,S)),!(w.max-g.d<=t)&&(p=w.h/2,h.push(new Vn(w.x-p,w.y-p,p,n)),h.push(new Vn(w.x+p,w.y-p,p,n)),h.push(new Vn(w.x-p,w.y+p,p,n)),h.push(new Vn(w.x+p,w.y+p,p,n)),S+=4)}e&&(console.log("num probes: "+S),console.log("best distance: "+g.d));var v=[g.x,g.y];return v.distance=g.d,v}function CC(n,t){return t.max-n.max}function Vn(n,t,e,r){this.x=n,this.y=t,this.h=e,this.d=TC(n,t,r),this.max=this.d+this.h*Math.SQRT2}function TC(n,t,e){for(var r=!1,o=1/0,i=0;i<e.length;i++)for(var a=e[i],s=0,l=a.length,u=l-1;s<l;u=s++){var c=a[s],d=a[u];c[1]>t!=d[1]>t&&n<(d[0]-c[0])*(t-c[1])/(d[1]-c[1])+c[0]&&(r=!r),o=Math.min(o,IC(n,t,c,d))}return o===0?0:(r?1:-1)*Math.sqrt(o)}function MC(n){for(var t=0,e=0,r=0,o=n[0],i=0,a=o.length,s=a-1;i<a;s=i++){var l=o[i],u=o[s],c=l[0]*u[1]-u[0]*l[1];e+=(l[0]+u[0])*c,r+=(l[1]+u[1])*c,t+=c*3}return t===0?new Vn(o[0][0],o[0][1],0,n):new Vn(e/t,r/t,0,n)}function IC(n,t,e,r){var o=e[0],i=e[1],a=r[0]-o,s=r[1]-i;if(a!==0||s!==0){var l=((n-o)*a+(t-i)*s)/(a*a+s*s);l>1?(o=r[0],i=r[1]):l>0&&(o+=a*l,i+=s*l)}return a=n-o,s=t-i,a*a+s*s}});var jx=fr(Wu=>{(function(){"use strict";var n=function(){this.init()};n.prototype={init:function(){var c=this||t;return c._counter=1e3,c._html5AudioPool=[],c.html5PoolSize=10,c._codecs={},c._howls=[],c._muted=!1,c._volume=1,c._canPlayEvent="canplaythrough",c._navigator=typeof window<"u"&&window.navigator?window.navigator:null,c.masterGain=null,c.noAudio=!1,c.usingWebAudio=!0,c.autoSuspend=!0,c.ctx=null,c.autoUnlock=!0,c._setup(),c},volume:function(c){var d=this||t;if(c=parseFloat(c),d.ctx||u(),typeof c<"u"&&c>=0&&c<=1){if(d._volume=c,d._muted)return d;d.usingWebAudio&&d.masterGain.gain.setValueAtTime(c,t.ctx.currentTime);for(var p=0;p<d._howls.length;p++)if(!d._howls[p]._webAudio)for(var f=d._howls[p]._getSoundIds(),h=0;h<f.length;h++){var m=d._howls[p]._soundById(f[h]);m&&m._node&&(m._node.volume=m._volume*c)}return d}return d._volume},mute:function(c){var d=this||t;d.ctx||u(),d._muted=c,d.usingWebAudio&&d.masterGain.gain.setValueAtTime(c?0:d._volume,t.ctx.currentTime);for(var p=0;p<d._howls.length;p++)if(!d._howls[p]._webAudio)for(var f=d._howls[p]._getSoundIds(),h=0;h<f.length;h++){var m=d._howls[p]._soundById(f[h]);m&&m._node&&(m._node.muted=c?!0:m._muted)}return d},stop:function(){for(var c=this||t,d=0;d<c._howls.length;d++)c._howls[d].stop();return c},unload:function(){for(var c=this||t,d=c._howls.length-1;d>=0;d--)c._howls[d].unload();return c.usingWebAudio&&c.ctx&&typeof c.ctx.close<"u"&&(c.ctx.close(),c.ctx=null,u()),c},codecs:function(c){return(this||t)._codecs[c.replace(/^x-/,"")]},_setup:function(){var c=this||t;if(c.state=c.ctx&&c.ctx.state||"suspended",c._autoSuspend(),!c.usingWebAudio)if(typeof Audio<"u")try{var d=new Audio;typeof d.oncanplaythrough>"u"&&(c._canPlayEvent="canplay")}catch{c.noAudio=!0}else c.noAudio=!0;try{var d=new Audio;d.muted&&(c.noAudio=!0)}catch{}return c.noAudio||c._setupCodecs(),c},_setupCodecs:function(){var c=this||t,d=null;try{d=typeof Audio<"u"?new Audio:null}catch{return c}if(!d||typeof d.canPlayType!="function")return c;var p=d.canPlayType("audio/mpeg;").replace(/^no$/,""),f=c._navigator?c._navigator.userAgent:"",h=f.match(/OPR\/([0-6].)/g),m=h&&parseInt(h[0].split("/")[1],10)<33,y=f.indexOf("Safari")!==-1&&f.indexOf("Chrome")===-1,g=f.match(/Version\/(.*?) /),b=y&&g&&parseInt(g[1],10)<15;return c._codecs={mp3:!!(!m&&(p||d.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!p,opus:!!d.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(d.canPlayType('audio/wav; codecs="1"')||d.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!d.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!d.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(d.canPlayType("audio/x-m4a;")||d.canPlayType("audio/m4a;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(d.canPlayType("audio/x-m4b;")||d.canPlayType("audio/m4b;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(d.canPlayType("audio/x-mp4;")||d.canPlayType("audio/mp4;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!b&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!b&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!d.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(d.canPlayType("audio/x-flac;")||d.canPlayType("audio/flac;")).replace(/^no$/,"")},c},_unlockAudio:function(){var c=this||t;if(!(c._audioUnlocked||!c.ctx)){c._audioUnlocked=!1,c.autoUnlock=!1,!c._mobileUnloaded&&c.ctx.sampleRate!==44100&&(c._mobileUnloaded=!0,c.unload()),c._scratchBuffer=c.ctx.createBuffer(1,1,22050);var d=function(p){for(;c._html5AudioPool.length<c.html5PoolSize;)try{var f=new Audio;f._unlocked=!0,c._releaseHtml5Audio(f)}catch{c.noAudio=!0;break}for(var h=0;h<c._howls.length;h++)if(!c._howls[h]._webAudio)for(var m=c._howls[h]._getSoundIds(),y=0;y<m.length;y++){var g=c._howls[h]._soundById(m[y]);g&&g._node&&!g._node._unlocked&&(g._node._unlocked=!0,g._node.load())}c._autoResume();var b=c.ctx.createBufferSource();b.buffer=c._scratchBuffer,b.connect(c.ctx.destination),typeof b.start>"u"?b.noteOn(0):b.start(0),typeof c.ctx.resume=="function"&&c.ctx.resume(),b.onended=function(){b.disconnect(0),c._audioUnlocked=!0,document.removeEventListener("touchstart",d,!0),document.removeEventListener("touchend",d,!0),document.removeEventListener("click",d,!0),document.removeEventListener("keydown",d,!0);for(var S=0;S<c._howls.length;S++)c._howls[S]._emit("unlock")}};return document.addEventListener("touchstart",d,!0),document.addEventListener("touchend",d,!0),document.addEventListener("click",d,!0),document.addEventListener("keydown",d,!0),c}},_obtainHtml5Audio:function(){var c=this||t;if(c._html5AudioPool.length)return c._html5AudioPool.pop();var d=new Audio().play();return d&&typeof Promise<"u"&&(d instanceof Promise||typeof d.then=="function")&&d.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(c){var d=this||t;return c._unlocked&&d._html5AudioPool.push(c),d},_autoSuspend:function(){var c=this;if(!(!c.autoSuspend||!c.ctx||typeof c.ctx.suspend>"u"||!t.usingWebAudio)){for(var d=0;d<c._howls.length;d++)if(c._howls[d]._webAudio){for(var p=0;p<c._howls[d]._sounds.length;p++)if(!c._howls[d]._sounds[p]._paused)return c}return c._suspendTimer&&clearTimeout(c._suspendTimer),c._suspendTimer=setTimeout(function(){if(!!c.autoSuspend){c._suspendTimer=null,c.state="suspending";var f=function(){c.state="suspended",c._resumeAfterSuspend&&(delete c._resumeAfterSuspend,c._autoResume())};c.ctx.suspend().then(f,f)}},3e4),c}},_autoResume:function(){var c=this;if(!(!c.ctx||typeof c.ctx.resume>"u"||!t.usingWebAudio))return c.state==="running"&&c.ctx.state!=="interrupted"&&c._suspendTimer?(clearTimeout(c._suspendTimer),c._suspendTimer=null):c.state==="suspended"||c.state==="running"&&c.ctx.state==="interrupted"?(c.ctx.resume().then(function(){c.state="running";for(var d=0;d<c._howls.length;d++)c._howls[d]._emit("resume")}),c._suspendTimer&&(clearTimeout(c._suspendTimer),c._suspendTimer=null)):c.state==="suspending"&&(c._resumeAfterSuspend=!0),c}};var t=new n,e=function(c){var d=this;if(!c.src||c.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}d.init(c)};e.prototype={init:function(c){var d=this;return t.ctx||u(),d._autoplay=c.autoplay||!1,d._format=typeof c.format!="string"?c.format:[c.format],d._html5=c.html5||!1,d._muted=c.mute||!1,d._loop=c.loop||!1,d._pool=c.pool||5,d._preload=typeof c.preload=="boolean"||c.preload==="metadata"?c.preload:!0,d._rate=c.rate||1,d._sprite=c.sprite||{},d._src=typeof c.src!="string"?c.src:[c.src],d._volume=c.volume!==void 0?c.volume:1,d._xhr={method:c.xhr&&c.xhr.method?c.xhr.method:"GET",headers:c.xhr&&c.xhr.headers?c.xhr.headers:null,withCredentials:c.xhr&&c.xhr.withCredentials?c.xhr.withCredentials:!1},d._duration=0,d._state="unloaded",d._sounds=[],d._endTimers={},d._queue=[],d._playLock=!1,d._onend=c.onend?[{fn:c.onend}]:[],d._onfade=c.onfade?[{fn:c.onfade}]:[],d._onload=c.onload?[{fn:c.onload}]:[],d._onloaderror=c.onloaderror?[{fn:c.onloaderror}]:[],d._onplayerror=c.onplayerror?[{fn:c.onplayerror}]:[],d._onpause=c.onpause?[{fn:c.onpause}]:[],d._onplay=c.onplay?[{fn:c.onplay}]:[],d._onstop=c.onstop?[{fn:c.onstop}]:[],d._onmute=c.onmute?[{fn:c.onmute}]:[],d._onvolume=c.onvolume?[{fn:c.onvolume}]:[],d._onrate=c.onrate?[{fn:c.onrate}]:[],d._onseek=c.onseek?[{fn:c.onseek}]:[],d._onunlock=c.onunlock?[{fn:c.onunlock}]:[],d._onresume=[],d._webAudio=t.usingWebAudio&&!d._html5,typeof t.ctx<"u"&&t.ctx&&t.autoUnlock&&t._unlockAudio(),t._howls.push(d),d._autoplay&&d._queue.push({event:"play",action:function(){d.play()}}),d._preload&&d._preload!=="none"&&d.load(),d},load:function(){var c=this,d=null;if(t.noAudio){c._emit("loaderror",null,"No audio support.");return}typeof c._src=="string"&&(c._src=[c._src]);for(var p=0;p<c._src.length;p++){var f,h;if(c._format&&c._format[p])f=c._format[p];else{if(h=c._src[p],typeof h!="string"){c._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}f=/^data:audio\/([^;,]+);/i.exec(h),f||(f=/\.([^.]+)$/.exec(h.split("?",1)[0])),f&&(f=f[1].toLowerCase())}if(f||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),f&&t.codecs(f)){d=c._src[p];break}}if(!d){c._emit("loaderror",null,"No codec support for selected audio sources.");return}return c._src=d,c._state="loading",window.location.protocol==="https:"&&d.slice(0,5)==="http:"&&(c._html5=!0,c._webAudio=!1),new r(c),c._webAudio&&i(c),c},play:function(c,d){var p=this,f=null;if(typeof c=="number")f=c,c=null;else{if(typeof c=="string"&&p._state==="loaded"&&!p._sprite[c])return null;if(typeof c>"u"&&(c="__default",!p._playLock)){for(var h=0,m=0;m<p._sounds.length;m++)p._sounds[m]._paused&&!p._sounds[m]._ended&&(h++,f=p._sounds[m]._id);h===1?c=null:f=null}}var y=f?p._soundById(f):p._inactiveSound();if(!y)return null;if(f&&!c&&(c=y._sprite||"__default"),p._state!=="loaded"){y._sprite=c,y._ended=!1;var g=y._id;return p._queue.push({event:"play",action:function(){p.play(g)}}),g}if(f&&!y._paused)return d||p._loadQueue("play"),y._id;p._webAudio&&t._autoResume();var b=Math.max(0,y._seek>0?y._seek:p._sprite[c][0]/1e3),S=Math.max(0,(p._sprite[c][0]+p._sprite[c][1])/1e3-b),w=S*1e3/Math.abs(y._rate),v=p._sprite[c][0]/1e3,_=(p._sprite[c][0]+p._sprite[c][1])/1e3;y._sprite=c,y._ended=!1;var A=function(){y._paused=!1,y._seek=b,y._start=v,y._stop=_,y._loop=!!(y._loop||p._sprite[c][2])};if(b>=_){p._ended(y);return}var x=y._node;if(p._webAudio){var T=function(){p._playLock=!1,A(),p._refreshBuffer(y);var M=y._muted||p._muted?0:y._volume;x.gain.setValueAtTime(M,t.ctx.currentTime),y._playStart=t.ctx.currentTime,typeof x.bufferSource.start>"u"?y._loop?x.bufferSource.noteGrainOn(0,b,86400):x.bufferSource.noteGrainOn(0,b,S):y._loop?x.bufferSource.start(0,b,86400):x.bufferSource.start(0,b,S),w!==1/0&&(p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),w)),d||setTimeout(function(){p._emit("play",y._id),p._loadQueue()},0)};t.state==="running"&&t.ctx.state!=="interrupted"?T():(p._playLock=!0,p.once("resume",T),p._clearTimer(y._id))}else{var C=function(){x.currentTime=b,x.muted=y._muted||p._muted||t._muted||x.muted,x.volume=y._volume*t.volume(),x.playbackRate=y._rate;try{var M=x.play();if(M&&typeof Promise<"u"&&(M instanceof Promise||typeof M.then=="function")?(p._playLock=!0,A(),M.then(function(){p._playLock=!1,x._unlocked=!0,d?p._loadQueue():p._emit("play",y._id)}).catch(function(){p._playLock=!1,p._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),y._ended=!0,y._paused=!0})):d||(p._playLock=!1,A(),p._emit("play",y._id)),x.playbackRate=y._rate,x.paused){p._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}c!=="__default"||y._loop?p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),w):(p._endTimers[y._id]=function(){p._ended(y),x.removeEventListener("ended",p._endTimers[y._id],!1)},x.addEventListener("ended",p._endTimers[y._id],!1))}catch(I){p._emit("playerror",y._id,I)}};x.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(x.src=p._src,x.load());var P=window&&window.ejecta||!x.readyState&&t._navigator.isCocoonJS;if(x.readyState>=3||P)C();else{p._playLock=!0,p._state="loading";var O=function(){p._state="loaded",C(),x.removeEventListener(t._canPlayEvent,O,!1)};x.addEventListener(t._canPlayEvent,O,!1),p._clearTimer(y._id)}}return y._id},pause:function(c){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"pause",action:function(){d.pause(c)}}),d;for(var p=d._getSoundIds(c),f=0;f<p.length;f++){d._clearTimer(p[f]);var h=d._soundById(p[f]);if(h&&!h._paused&&(h._seek=d.seek(p[f]),h._rateSeek=0,h._paused=!0,d._stopFade(p[f]),h._node))if(d._webAudio){if(!h._node.bufferSource)continue;typeof h._node.bufferSource.stop>"u"?h._node.bufferSource.noteOff(0):h._node.bufferSource.stop(0),d._cleanBuffer(h._node)}else(!isNaN(h._node.duration)||h._node.duration===1/0)&&h._node.pause();arguments[1]||d._emit("pause",h?h._id:null)}return d},stop:function(c,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"stop",action:function(){p.stop(c)}}),p;for(var f=p._getSoundIds(c),h=0;h<f.length;h++){p._clearTimer(f[h]);var m=p._soundById(f[h]);m&&(m._seek=m._start||0,m._rateSeek=0,m._paused=!0,m._ended=!0,p._stopFade(f[h]),m._node&&(p._webAudio?m._node.bufferSource&&(typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),p._cleanBuffer(m._node)):(!isNaN(m._node.duration)||m._node.duration===1/0)&&(m._node.currentTime=m._start||0,m._node.pause(),m._node.duration===1/0&&p._clearSound(m._node))),d||p._emit("stop",m._id))}return p},mute:function(c,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"mute",action:function(){p.mute(c,d)}}),p;if(typeof d>"u")if(typeof c=="boolean")p._muted=c;else return p._muted;for(var f=p._getSoundIds(d),h=0;h<f.length;h++){var m=p._soundById(f[h]);m&&(m._muted=c,m._interval&&p._stopFade(m._id),p._webAudio&&m._node?m._node.gain.setValueAtTime(c?0:m._volume,t.ctx.currentTime):m._node&&(m._node.muted=t._muted?!0:c),p._emit("mute",m._id))}return p},volume:function(){var c=this,d=arguments,p,f;if(d.length===0)return c._volume;if(d.length===1||d.length===2&&typeof d[1]>"u"){var h=c._getSoundIds(),m=h.indexOf(d[0]);m>=0?f=parseInt(d[0],10):p=parseFloat(d[0])}else d.length>=2&&(p=parseFloat(d[0]),f=parseInt(d[1],10));var y;if(typeof p<"u"&&p>=0&&p<=1){if(c._state!=="loaded"||c._playLock)return c._queue.push({event:"volume",action:function(){c.volume.apply(c,d)}}),c;typeof f>"u"&&(c._volume=p),f=c._getSoundIds(f);for(var g=0;g<f.length;g++)y=c._soundById(f[g]),y&&(y._volume=p,d[2]||c._stopFade(f[g]),c._webAudio&&y._node&&!y._muted?y._node.gain.setValueAtTime(p,t.ctx.currentTime):y._node&&!y._muted&&(y._node.volume=p*t.volume()),c._emit("volume",y._id))}else return y=f?c._soundById(f):c._sounds[0],y?y._volume:0;return c},fade:function(c,d,p,f){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"fade",action:function(){h.fade(c,d,p,f)}}),h;c=Math.min(Math.max(0,parseFloat(c)),1),d=Math.min(Math.max(0,parseFloat(d)),1),p=parseFloat(p),h.volume(c,f);for(var m=h._getSoundIds(f),y=0;y<m.length;y++){var g=h._soundById(m[y]);if(g){if(f||h._stopFade(m[y]),h._webAudio&&!g._muted){var b=t.ctx.currentTime,S=b+p/1e3;g._volume=c,g._node.gain.setValueAtTime(c,b),g._node.gain.linearRampToValueAtTime(d,S)}h._startFadeInterval(g,c,d,p,m[y],typeof f>"u")}}return h},_startFadeInterval:function(c,d,p,f,h,m){var y=this,g=d,b=p-d,S=Math.abs(b/.01),w=Math.max(4,S>0?f/S:f),v=Date.now();c._fadeTo=p,c._interval=setInterval(function(){var _=(Date.now()-v)/f;v=Date.now(),g+=b*_,g=Math.round(g*100)/100,b<0?g=Math.max(p,g):g=Math.min(p,g),y._webAudio?c._volume=g:y.volume(g,c._id,!0),m&&(y._volume=g),(p<d&&g<=p||p>d&&g>=p)&&(clearInterval(c._interval),c._interval=null,c._fadeTo=null,y.volume(p,c._id),y._emit("fade",c._id))},w)},_stopFade:function(c){var d=this,p=d._soundById(c);return p&&p._interval&&(d._webAudio&&p._node.gain.cancelScheduledValues(t.ctx.currentTime),clearInterval(p._interval),p._interval=null,d.volume(p._fadeTo,c),p._fadeTo=null,d._emit("fade",c)),d},loop:function(){var c=this,d=arguments,p,f,h;if(d.length===0)return c._loop;if(d.length===1)if(typeof d[0]=="boolean")p=d[0],c._loop=p;else return h=c._soundById(parseInt(d[0],10)),h?h._loop:!1;else d.length===2&&(p=d[0],f=parseInt(d[1],10));for(var m=c._getSoundIds(f),y=0;y<m.length;y++)h=c._soundById(m[y]),h&&(h._loop=p,c._webAudio&&h._node&&h._node.bufferSource&&(h._node.bufferSource.loop=p,p&&(h._node.bufferSource.loopStart=h._start||0,h._node.bufferSource.loopEnd=h._stop,c.playing(m[y])&&(c.pause(m[y],!0),c.play(m[y],!0)))));return c},rate:function(){var c=this,d=arguments,p,f;if(d.length===0)f=c._sounds[0]._id;else if(d.length===1){var h=c._getSoundIds(),m=h.indexOf(d[0]);m>=0?f=parseInt(d[0],10):p=parseFloat(d[0])}else d.length===2&&(p=parseFloat(d[0]),f=parseInt(d[1],10));var y;if(typeof p=="number"){if(c._state!=="loaded"||c._playLock)return c._queue.push({event:"rate",action:function(){c.rate.apply(c,d)}}),c;typeof f>"u"&&(c._rate=p),f=c._getSoundIds(f);for(var g=0;g<f.length;g++)if(y=c._soundById(f[g]),y){c.playing(f[g])&&(y._rateSeek=c.seek(f[g]),y._playStart=c._webAudio?t.ctx.currentTime:y._playStart),y._rate=p,c._webAudio&&y._node&&y._node.bufferSource?y._node.bufferSource.playbackRate.setValueAtTime(p,t.ctx.currentTime):y._node&&(y._node.playbackRate=p);var b=c.seek(f[g]),S=(c._sprite[y._sprite][0]+c._sprite[y._sprite][1])/1e3-b,w=S*1e3/Math.abs(y._rate);(c._endTimers[f[g]]||!y._paused)&&(c._clearTimer(f[g]),c._endTimers[f[g]]=setTimeout(c._ended.bind(c,y),w)),c._emit("rate",y._id)}}else return y=c._soundById(f),y?y._rate:c._rate;return c},seek:function(){var c=this,d=arguments,p,f;if(d.length===0)c._sounds.length&&(f=c._sounds[0]._id);else if(d.length===1){var h=c._getSoundIds(),m=h.indexOf(d[0]);m>=0?f=parseInt(d[0],10):c._sounds.length&&(f=c._sounds[0]._id,p=parseFloat(d[0]))}else d.length===2&&(p=parseFloat(d[0]),f=parseInt(d[1],10));if(typeof f>"u")return 0;if(typeof p=="number"&&(c._state!=="loaded"||c._playLock))return c._queue.push({event:"seek",action:function(){c.seek.apply(c,d)}}),c;var y=c._soundById(f);if(y)if(typeof p=="number"&&p>=0){var g=c.playing(f);g&&c.pause(f,!0),y._seek=p,y._ended=!1,c._clearTimer(f),!c._webAudio&&y._node&&!isNaN(y._node.duration)&&(y._node.currentTime=p);var b=function(){g&&c.play(f,!0),c._emit("seek",f)};if(g&&!c._webAudio){var S=function(){c._playLock?setTimeout(S,0):b()};setTimeout(S,0)}else b()}else if(c._webAudio){var w=c.playing(f)?t.ctx.currentTime-y._playStart:0,v=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(v+w*Math.abs(y._rate))}else return y._node.currentTime;return c},playing:function(c){var d=this;if(typeof c=="number"){var p=d._soundById(c);return p?!p._paused:!1}for(var f=0;f<d._sounds.length;f++)if(!d._sounds[f]._paused)return!0;return!1},duration:function(c){var d=this,p=d._duration,f=d._soundById(c);return f&&(p=d._sprite[f._sprite][1]/1e3),p},state:function(){return this._state},unload:function(){for(var c=this,d=c._sounds,p=0;p<d.length;p++)d[p]._paused||c.stop(d[p]._id),c._webAudio||(c._clearSound(d[p]._node),d[p]._node.removeEventListener("error",d[p]._errorFn,!1),d[p]._node.removeEventListener(t._canPlayEvent,d[p]._loadFn,!1),d[p]._node.removeEventListener("ended",d[p]._endFn,!1),t._releaseHtml5Audio(d[p]._node)),delete d[p]._node,c._clearTimer(d[p]._id);var f=t._howls.indexOf(c);f>=0&&t._howls.splice(f,1);var h=!0;for(p=0;p<t._howls.length;p++)if(t._howls[p]._src===c._src||c._src.indexOf(t._howls[p]._src)>=0){h=!1;break}return o&&h&&delete o[c._src],t.noAudio=!1,c._state="unloaded",c._sounds=[],c=null,null},on:function(c,d,p,f){var h=this,m=h["_on"+c];return typeof d=="function"&&m.push(f?{id:p,fn:d,once:f}:{id:p,fn:d}),h},off:function(c,d,p){var f=this,h=f["_on"+c],m=0;if(typeof d=="number"&&(p=d,d=null),d||p)for(m=0;m<h.length;m++){var y=p===h[m].id;if(d===h[m].fn&&y||!d&&y){h.splice(m,1);break}}else if(c)f["_on"+c]=[];else{var g=Object.keys(f);for(m=0;m<g.length;m++)g[m].indexOf("_on")===0&&Array.isArray(f[g[m]])&&(f[g[m]]=[])}return f},once:function(c,d,p){var f=this;return f.on(c,d,p,1),f},_emit:function(c,d,p){for(var f=this,h=f["_on"+c],m=h.length-1;m>=0;m--)(!h[m].id||h[m].id===d||c==="load")&&(setTimeout(function(y){y.call(this,d,p)}.bind(f,h[m].fn),0),h[m].once&&f.off(c,h[m].fn,h[m].id));return f._loadQueue(c),f},_loadQueue:function(c){var d=this;if(d._queue.length>0){var p=d._queue[0];p.event===c&&(d._queue.shift(),d._loadQueue()),c||p.action()}return d},_ended:function(c){var d=this,p=c._sprite;if(!d._webAudio&&c._node&&!c._node.paused&&!c._node.ended&&c._node.currentTime<c._stop)return setTimeout(d._ended.bind(d,c),100),d;var f=!!(c._loop||d._sprite[p][2]);if(d._emit("end",c._id),!d._webAudio&&f&&d.stop(c._id,!0).play(c._id),d._webAudio&&f){d._emit("play",c._id),c._seek=c._start||0,c._rateSeek=0,c._playStart=t.ctx.currentTime;var h=(c._stop-c._start)*1e3/Math.abs(c._rate);d._endTimers[c._id]=setTimeout(d._ended.bind(d,c),h)}return d._webAudio&&!f&&(c._paused=!0,c._ended=!0,c._seek=c._start||0,c._rateSeek=0,d._clearTimer(c._id),d._cleanBuffer(c._node),t._autoSuspend()),!d._webAudio&&!f&&d.stop(c._id,!0),d},_clearTimer:function(c){var d=this;if(d._endTimers[c]){if(typeof d._endTimers[c]!="function")clearTimeout(d._endTimers[c]);else{var p=d._soundById(c);p&&p._node&&p._node.removeEventListener("ended",d._endTimers[c],!1)}delete d._endTimers[c]}return d},_soundById:function(c){for(var d=this,p=0;p<d._sounds.length;p++)if(c===d._sounds[p]._id)return d._sounds[p];return null},_inactiveSound:function(){var c=this;c._drain();for(var d=0;d<c._sounds.length;d++)if(c._sounds[d]._ended)return c._sounds[d].reset();return new r(c)},_drain:function(){var c=this,d=c._pool,p=0,f=0;if(!(c._sounds.length<d)){for(f=0;f<c._sounds.length;f++)c._sounds[f]._ended&&p++;for(f=c._sounds.length-1;f>=0;f--){if(p<=d)return;c._sounds[f]._ended&&(c._webAudio&&c._sounds[f]._node&&c._sounds[f]._node.disconnect(0),c._sounds.splice(f,1),p--)}}},_getSoundIds:function(c){var d=this;if(typeof c>"u"){for(var p=[],f=0;f<d._sounds.length;f++)p.push(d._sounds[f]._id);return p}else return[c]},_refreshBuffer:function(c){var d=this;return c._node.bufferSource=t.ctx.createBufferSource(),c._node.bufferSource.buffer=o[d._src],c._panner?c._node.bufferSource.connect(c._panner):c._node.bufferSource.connect(c._node),c._node.bufferSource.loop=c._loop,c._loop&&(c._node.bufferSource.loopStart=c._start||0,c._node.bufferSource.loopEnd=c._stop||0),c._node.bufferSource.playbackRate.setValueAtTime(c._rate,t.ctx.currentTime),d},_cleanBuffer:function(c){var d=this,p=t._navigator&&t._navigator.vendor.indexOf("Apple")>=0;if(t._scratchBuffer&&c.bufferSource&&(c.bufferSource.onended=null,c.bufferSource.disconnect(0),p))try{c.bufferSource.buffer=t._scratchBuffer}catch{}return c.bufferSource=null,d},_clearSound:function(c){var d=/MSIE |Trident\//.test(t._navigator&&t._navigator.userAgent);d||(c.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var r=function(c){this._parent=c,this.init()};r.prototype={init:function(){var c=this,d=c._parent;return c._muted=d._muted,c._loop=d._loop,c._volume=d._volume,c._rate=d._rate,c._seek=0,c._paused=!0,c._ended=!0,c._sprite="__default",c._id=++t._counter,d._sounds.push(c),c.create(),c},create:function(){var c=this,d=c._parent,p=t._muted||c._muted||c._parent._muted?0:c._volume;return d._webAudio?(c._node=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),c._node.gain.setValueAtTime(p,t.ctx.currentTime),c._node.paused=!0,c._node.connect(t.masterGain)):t.noAudio||(c._node=t._obtainHtml5Audio(),c._errorFn=c._errorListener.bind(c),c._node.addEventListener("error",c._errorFn,!1),c._loadFn=c._loadListener.bind(c),c._node.addEventListener(t._canPlayEvent,c._loadFn,!1),c._endFn=c._endListener.bind(c),c._node.addEventListener("ended",c._endFn,!1),c._node.src=d._src,c._node.preload=d._preload===!0?"auto":d._preload,c._node.volume=p*t.volume(),c._node.load()),c},reset:function(){var c=this,d=c._parent;return c._muted=d._muted,c._loop=d._loop,c._volume=d._volume,c._rate=d._rate,c._seek=0,c._rateSeek=0,c._paused=!0,c._ended=!0,c._sprite="__default",c._id=++t._counter,c},_errorListener:function(){var c=this;c._parent._emit("loaderror",c._id,c._node.error?c._node.error.code:0),c._node.removeEventListener("error",c._errorFn,!1)},_loadListener:function(){var c=this,d=c._parent;d._duration=Math.ceil(c._node.duration*10)/10,Object.keys(d._sprite).length===0&&(d._sprite={__default:[0,d._duration*1e3]}),d._state!=="loaded"&&(d._state="loaded",d._emit("load"),d._loadQueue()),c._node.removeEventListener(t._canPlayEvent,c._loadFn,!1)},_endListener:function(){var c=this,d=c._parent;d._duration===1/0&&(d._duration=Math.ceil(c._node.duration*10)/10,d._sprite.__default[1]===1/0&&(d._sprite.__default[1]=d._duration*1e3),d._ended(c)),c._node.removeEventListener("ended",c._endFn,!1)}};var o={},i=function(c){var d=c._src;if(o[d]){c._duration=o[d].duration,l(c);return}if(/^data:[^;]+;base64,/.test(d)){for(var p=atob(d.split(",")[1]),f=new Uint8Array(p.length),h=0;h<p.length;++h)f[h]=p.charCodeAt(h);s(f.buffer,c)}else{var m=new XMLHttpRequest;m.open(c._xhr.method,d,!0),m.withCredentials=c._xhr.withCredentials,m.responseType="arraybuffer",c._xhr.headers&&Object.keys(c._xhr.headers).forEach(function(y){m.setRequestHeader(y,c._xhr.headers[y])}),m.onload=function(){var y=(m.status+"")[0];if(y!=="0"&&y!=="2"&&y!=="3"){c._emit("loaderror",null,"Failed loading audio file with status: "+m.status+".");return}s(m.response,c)},m.onerror=function(){c._webAudio&&(c._html5=!0,c._webAudio=!1,c._sounds=[],delete o[d],c.load())},a(m)}},a=function(c){try{c.send()}catch{c.onerror()}},s=function(c,d){var p=function(){d._emit("loaderror",null,"Decoding audio data failed.")},f=function(h){h&&d._sounds.length>0?(o[d._src]=h,l(d,h)):p()};typeof Promise<"u"&&t.ctx.decodeAudioData.length===1?t.ctx.decodeAudioData(c).then(f).catch(p):t.ctx.decodeAudioData(c,f,p)},l=function(c,d){d&&!c._duration&&(c._duration=d.duration),Object.keys(c._sprite).length===0&&(c._sprite={__default:[0,c._duration*1e3]}),c._state!=="loaded"&&(c._state="loaded",c._emit("load"),c._loadQueue())},u=function(){if(!!t.usingWebAudio){try{typeof AudioContext<"u"?t.ctx=new AudioContext:typeof webkitAudioContext<"u"?t.ctx=new webkitAudioContext:t.usingWebAudio=!1}catch{t.usingWebAudio=!1}t.ctx||(t.usingWebAudio=!1);var c=/iP(hone|od|ad)/.test(t._navigator&&t._navigator.platform),d=t._navigator&&t._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),p=d?parseInt(d[1],10):null;if(c&&p&&p<9){var f=/safari/.test(t._navigator&&t._navigator.userAgent.toLowerCase());t._navigator&&!f&&(t.usingWebAudio=!1)}t.usingWebAudio&&(t.masterGain=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),t.masterGain.gain.setValueAtTime(t._muted?0:t._volume,t.ctx.currentTime),t.masterGain.connect(t.ctx.destination)),t._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:t,Howl:e}}),typeof Wu<"u"&&(Wu.Howler=t,Wu.Howl=e),typeof global<"u"?(global.HowlerGlobal=n,global.Howler=t,global.Howl=e,global.Sound=r):typeof window<"u"&&(window.HowlerGlobal=n,window.Howler=t,window.Howl=e,window.Sound=r)})();(function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var r=e._howls.length-1;r>=0;r--)e._howls[r].stereo(t);return e},HowlerGlobal.prototype.pos=function(t,e,r){var o=this;if(!o.ctx||!o.ctx.listener)return o;if(e=typeof e!="number"?o._pos[1]:e,r=typeof r!="number"?o._pos[2]:r,typeof t=="number")o._pos=[t,e,r],typeof o.ctx.listener.positionX<"u"?(o.ctx.listener.positionX.setTargetAtTime(o._pos[0],Howler.ctx.currentTime,.1),o.ctx.listener.positionY.setTargetAtTime(o._pos[1],Howler.ctx.currentTime,.1),o.ctx.listener.positionZ.setTargetAtTime(o._pos[2],Howler.ctx.currentTime,.1)):o.ctx.listener.setPosition(o._pos[0],o._pos[1],o._pos[2]);else return o._pos;return o},HowlerGlobal.prototype.orientation=function(t,e,r,o,i,a){var s=this;if(!s.ctx||!s.ctx.listener)return s;var l=s._orientation;if(e=typeof e!="number"?l[1]:e,r=typeof r!="number"?l[2]:r,o=typeof o!="number"?l[3]:o,i=typeof i!="number"?l[4]:i,a=typeof a!="number"?l[5]:a,typeof t=="number")s._orientation=[t,e,r,o,i,a],typeof s.ctx.listener.forwardX<"u"?(s.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),s.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),s.ctx.listener.forwardZ.setTargetAtTime(r,Howler.ctx.currentTime,.1),s.ctx.listener.upX.setTargetAtTime(o,Howler.ctx.currentTime,.1),s.ctx.listener.upY.setTargetAtTime(i,Howler.ctx.currentTime,.1),s.ctx.listener.upZ.setTargetAtTime(a,Howler.ctx.currentTime,.1)):s.ctx.listener.setOrientation(t,e,r,o,i,a);else return l;return s},Howl.prototype.init=function(t){return function(e){var r=this;return r._orientation=e.orientation||[1,0,0],r._stereo=e.stereo||null,r._pos=e.pos||null,r._pannerAttr={coneInnerAngle:typeof e.coneInnerAngle<"u"?e.coneInnerAngle:360,coneOuterAngle:typeof e.coneOuterAngle<"u"?e.coneOuterAngle:360,coneOuterGain:typeof e.coneOuterGain<"u"?e.coneOuterGain:0,distanceModel:typeof e.distanceModel<"u"?e.distanceModel:"inverse",maxDistance:typeof e.maxDistance<"u"?e.maxDistance:1e4,panningModel:typeof e.panningModel<"u"?e.panningModel:"HRTF",refDistance:typeof e.refDistance<"u"?e.refDistance:1,rolloffFactor:typeof e.rolloffFactor<"u"?e.rolloffFactor:1},r._onstereo=e.onstereo?[{fn:e.onstereo}]:[],r._onpos=e.onpos?[{fn:e.onpos}]:[],r._onorientation=e.onorientation?[{fn:e.onorientation}]:[],t.call(this,e)}}(Howl.prototype.init),Howl.prototype.stereo=function(t,e){var r=this;if(!r._webAudio)return r;if(r._state!=="loaded")return r._queue.push({event:"stereo",action:function(){r.stereo(t,e)}}),r;var o=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof e>"u")if(typeof t=="number")r._stereo=t,r._pos=[t,0,0];else return r._stereo;for(var i=r._getSoundIds(e),a=0;a<i.length;a++){var s=r._soundById(i[a]);if(s)if(typeof t=="number")s._stereo=t,s._pos=[t,0,0],s._node&&(s._pannerAttr.panningModel="equalpower",(!s._panner||!s._panner.pan)&&n(s,o),o==="spatial"?typeof s._panner.positionX<"u"?(s._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),s._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),s._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):s._panner.setPosition(t,0,0):s._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),r._emit("stereo",s._id);else return s._stereo}return r},Howl.prototype.pos=function(t,e,r,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"pos",action:function(){i.pos(t,e,r,o)}}),i;if(e=typeof e!="number"?0:e,r=typeof r!="number"?-.5:r,typeof o>"u")if(typeof t=="number")i._pos=[t,e,r];else return i._pos;for(var a=i._getSoundIds(o),s=0;s<a.length;s++){var l=i._soundById(a[s]);if(l)if(typeof t=="number")l._pos=[t,e,r],l._node&&((!l._panner||l._panner.pan)&&n(l,"spatial"),typeof l._panner.positionX<"u"?(l._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),l._panner.positionY.setValueAtTime(e,Howler.ctx.currentTime),l._panner.positionZ.setValueAtTime(r,Howler.ctx.currentTime)):l._panner.setPosition(t,e,r)),i._emit("pos",l._id);else return l._pos}return i},Howl.prototype.orientation=function(t,e,r,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"orientation",action:function(){i.orientation(t,e,r,o)}}),i;if(e=typeof e!="number"?i._orientation[1]:e,r=typeof r!="number"?i._orientation[2]:r,typeof o>"u")if(typeof t=="number")i._orientation=[t,e,r];else return i._orientation;for(var a=i._getSoundIds(o),s=0;s<a.length;s++){var l=i._soundById(a[s]);if(l)if(typeof t=="number")l._orientation=[t,e,r],l._node&&(l._panner||(l._pos||(l._pos=i._pos||[0,0,-.5]),n(l,"spatial")),typeof l._panner.orientationX<"u"?(l._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),l._panner.orientationY.setValueAtTime(e,Howler.ctx.currentTime),l._panner.orientationZ.setValueAtTime(r,Howler.ctx.currentTime)):l._panner.setOrientation(t,e,r)),i._emit("orientation",l._id);else return l._orientation}return i},Howl.prototype.pannerAttr=function(){var t=this,e=arguments,r,o,i;if(!t._webAudio)return t;if(e.length===0)return t._pannerAttr;if(e.length===1)if(typeof e[0]=="object")r=e[0],typeof o>"u"&&(r.pannerAttr||(r.pannerAttr={coneInnerAngle:r.coneInnerAngle,coneOuterAngle:r.coneOuterAngle,coneOuterGain:r.coneOuterGain,distanceModel:r.distanceModel,maxDistance:r.maxDistance,refDistance:r.refDistance,rolloffFactor:r.rolloffFactor,panningModel:r.panningModel}),t._pannerAttr={coneInnerAngle:typeof r.pannerAttr.coneInnerAngle<"u"?r.pannerAttr.coneInnerAngle:t._coneInnerAngle,coneOuterAngle:typeof r.pannerAttr.coneOuterAngle<"u"?r.pannerAttr.coneOuterAngle:t._coneOuterAngle,coneOuterGain:typeof r.pannerAttr.coneOuterGain<"u"?r.pannerAttr.coneOuterGain:t._coneOuterGain,distanceModel:typeof r.pannerAttr.distanceModel<"u"?r.pannerAttr.distanceModel:t._distanceModel,maxDistance:typeof r.pannerAttr.maxDistance<"u"?r.pannerAttr.maxDistance:t._maxDistance,refDistance:typeof r.pannerAttr.refDistance<"u"?r.pannerAttr.refDistance:t._refDistance,rolloffFactor:typeof r.pannerAttr.rolloffFactor<"u"?r.pannerAttr.rolloffFactor:t._rolloffFactor,panningModel:typeof r.pannerAttr.panningModel<"u"?r.pannerAttr.panningModel:t._panningModel});else return i=t._soundById(parseInt(e[0],10)),i?i._pannerAttr:t._pannerAttr;else e.length===2&&(r=e[0],o=parseInt(e[1],10));for(var a=t._getSoundIds(o),s=0;s<a.length;s++)if(i=t._soundById(a[s]),i){var l=i._pannerAttr;l={coneInnerAngle:typeof r.coneInnerAngle<"u"?r.coneInnerAngle:l.coneInnerAngle,coneOuterAngle:typeof r.coneOuterAngle<"u"?r.coneOuterAngle:l.coneOuterAngle,coneOuterGain:typeof r.coneOuterGain<"u"?r.coneOuterGain:l.coneOuterGain,distanceModel:typeof r.distanceModel<"u"?r.distanceModel:l.distanceModel,maxDistance:typeof r.maxDistance<"u"?r.maxDistance:l.maxDistance,refDistance:typeof r.refDistance<"u"?r.refDistance:l.refDistance,rolloffFactor:typeof r.rolloffFactor<"u"?r.rolloffFactor:l.rolloffFactor,panningModel:typeof r.panningModel<"u"?r.panningModel:l.panningModel};var u=i._panner;u?(u.coneInnerAngle=l.coneInnerAngle,u.coneOuterAngle=l.coneOuterAngle,u.coneOuterGain=l.coneOuterGain,u.distanceModel=l.distanceModel,u.maxDistance=l.maxDistance,u.refDistance=l.refDistance,u.rolloffFactor=l.rolloffFactor,u.panningModel=l.panningModel):(i._pos||(i._pos=t._pos||[0,0,-.5]),n(i,"spatial"))}return t},Sound.prototype.init=function(t){return function(){var e=this,r=e._parent;e._orientation=r._orientation,e._stereo=r._stereo,e._pos=r._pos,e._pannerAttr=r._pannerAttr,t.call(this),e._stereo?r.stereo(e._stereo):e._pos&&r.pos(e._pos[0],e._pos[1],e._pos[2],e._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var e=this,r=e._parent;return e._orientation=r._orientation,e._stereo=r._stereo,e._pos=r._pos,e._pannerAttr=r._pannerAttr,e._stereo?r.stereo(e._stereo):e._pos?r.pos(e._pos[0],e._pos[1],e._pos[2],e._id):e._panner&&(e._panner.disconnect(0),e._panner=void 0,r._refreshBuffer(e)),t.call(this)}}(Sound.prototype.reset);var n=function(t,e){e=e||"spatial",e==="spatial"?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,typeof t._panner.positionX<"u"?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),typeof t._panner.orientationX<"u"?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}})()});var Mv=fr((Foe,Tv)=>{"use strict";function mM(n){for(var t=new Array(n),e=0;e<n;++e)t[e]=e;return t}Tv.exports=mM});var Dv=fr((joe,Nv)=>{Nv.exports=function(n){return n!=null&&(Iv(n)||yM(n)||!!n._isBuffer)};function Iv(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function yM(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&Iv(n.slice(0,0))}});var Gs=fr((Uoe,Ev)=>{var gM=Mv(),xM=Dv(),bM=typeof Float64Array<"u";function vM(n,t){return n[0]-t[0]}function SM(){var n=this.stride,t=new Array(n.length),e;for(e=0;e<t.length;++e)t[e]=[Math.abs(n[e]),e];t.sort(vM);var r=new Array(t.length);for(e=0;e<r.length;++e)r[e]=t[e][1];return r}function wM(n,t){var e=["View",t,"d",n].join("");t<0&&(e="View_Nil"+n);var r=n==="generic";if(t===-1){var o="function "+e+"(a){this.data=a;};var proto="+e+".prototype;proto.dtype='"+n+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+e+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+e+"(a){return new "+e+"(a);}",m=new Function(o);return m()}else if(t===0){var o="function "+e+"(a,d) {this.data = a;this.offset = d};var proto="+e+".prototype;proto.dtype='"+n+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+e+"_copy() {return new "+e+"(this.data,this.offset)};proto.pick=function "+e+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+e+"_get(){return "+(r?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+e+"_set(v){return "+(r?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+e+"(a,b,c,d){return new "+e+"(a,d)}",m=new Function("TrivialArray",o);return m(_d[n][0])}var o=["'use strict'"],i=gM(t),a=i.map(function(y){return"i"+y}),s="this.offset+"+i.map(function(y){return"this.stride["+y+"]*i"+y}).join("+"),l=i.map(function(y){return"b"+y}).join(","),u=i.map(function(y){return"c"+y}).join(",");o.push("function "+e+"(a,"+l+","+u+",d){this.data=a","this.shape=["+l+"]","this.stride=["+u+"]","this.offset=d|0}","var proto="+e+".prototype","proto.dtype='"+n+"'","proto.dimension="+t),o.push("Object.defineProperty(proto,'size',{get:function "+e+"_size(){return "+i.map(function(y){return"this.shape["+y+"]"}).join("*"),"}})"),t===1?o.push("proto.order=[0]"):(o.push("Object.defineProperty(proto,'order',{get:"),t<4?(o.push("function "+e+"_order(){"),t===2?o.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):t===3&&o.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):o.push("ORDER})")),o.push("proto.set=function "+e+"_set("+a.join(",")+",v){"),r?o.push("return this.data.set("+s+",v)}"):o.push("return this.data["+s+"]=v}"),o.push("proto.get=function "+e+"_get("+a.join(",")+"){"),r?o.push("return this.data.get("+s+")}"):o.push("return this.data["+s+"]}"),o.push("proto.index=function "+e+"_index(",a.join(),"){return "+s+"}"),o.push("proto.hi=function "+e+"_hi("+a.join(",")+"){return new "+e+"(this.data,"+i.map(function(y){return["(typeof i",y,"!=='number'||i",y,"<0)?this.shape[",y,"]:i",y,"|0"].join("")}).join(",")+","+i.map(function(y){return"this.stride["+y+"]"}).join(",")+",this.offset)}");var c=i.map(function(y){return"a"+y+"=this.shape["+y+"]"}),d=i.map(function(y){return"c"+y+"=this.stride["+y+"]"});o.push("proto.lo=function "+e+"_lo("+a.join(",")+"){var b=this.offset,d=0,"+c.join(",")+","+d.join(","));for(var p=0;p<t;++p)o.push("if(typeof i"+p+"==='number'&&i"+p+">=0){d=i"+p+"|0;b+=c"+p+"*d;a"+p+"-=d}");o.push("return new "+e+"(this.data,"+i.map(function(y){return"a"+y}).join(",")+","+i.map(function(y){return"c"+y}).join(",")+",b)}"),o.push("proto.step=function "+e+"_step("+a.join(",")+"){var "+i.map(function(y){return"a"+y+"=this.shape["+y+"]"}).join(",")+","+i.map(function(y){return"b"+y+"=this.stride["+y+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var p=0;p<t;++p)o.push("if(typeof i"+p+"==='number'){d=i"+p+"|0;if(d<0){c+=b"+p+"*(a"+p+"-1);a"+p+"=ceil(-a"+p+"/d)}else{a"+p+"=ceil(a"+p+"/d)}b"+p+"*=d}");o.push("return new "+e+"(this.data,"+i.map(function(y){return"a"+y}).join(",")+","+i.map(function(y){return"b"+y}).join(",")+",c)}");for(var f=new Array(t),h=new Array(t),p=0;p<t;++p)f[p]="a[i"+p+"]",h[p]="b[i"+p+"]";o.push("proto.transpose=function "+e+"_transpose("+a+"){"+a.map(function(y,g){return y+"=("+y+"===undefined?"+g+":"+y+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+e+"(this.data,"+f.join(",")+","+h.join(",")+",this.offset)}"),o.push("proto.pick=function "+e+"_pick("+a+"){var a=[],b=[],c=this.offset");for(var p=0;p<t;++p)o.push("if(typeof i"+p+"==='number'&&i"+p+">=0){c=(c+this.stride["+p+"]*i"+p+")|0}else{a.push(this.shape["+p+"]);b.push(this.stride["+p+"])}");o.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),o.push("return function construct_"+e+"(data,shape,stride,offset){return new "+e+"(data,"+i.map(function(y){return"shape["+y+"]"}).join(",")+","+i.map(function(y){return"stride["+y+"]"}).join(",")+",offset)}");var m=new Function("CTOR_LIST","ORDER",o.join(`
2
- `));return m(_d[n],SM)}function _M(n){if(xM(n))return"buffer";if(bM)switch(Object.prototype.toString.call(n)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(n)?"array":"generic"}var _d={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function AM(n,t,e,r){if(n===void 0){var u=_d.array[0];return u([])}else typeof n=="number"&&(n=[n]);t===void 0&&(t=[n.length]);var o=t.length;if(e===void 0){e=new Array(o);for(var i=o-1,a=1;i>=0;--i)e[i]=a,a*=t[i]}if(r===void 0){r=0;for(var i=0;i<o;++i)e[i]<0&&(r-=(t[i]-1)*e[i])}for(var s=_M(n),l=_d[s];l.length<=o+1;)l.push(wM(s,l.length-1));var u=l[o+1];return u(n,t,e,r)}Ev.exports=AM});var Lv=fr((Hoe,Bv)=>{"use strict";function PM(n,t){for(var e=1,r=n.length,o=n[0],i=n[0],a=1;a<r;++a)if(i=o,o=n[a],t(o,i)){if(a===e){e++;continue}n[e++]=o}return n.length=e,n}function OM(n){for(var t=1,e=n.length,r=n[0],o=n[0],i=1;i<e;++i,o=r)if(o=r,r=n[i],r!==o){if(i===t){t++;continue}n[t++]=r}return n.length=t,n}function CM(n,t,e){return n.length===0?n:t?(e||n.sort(t),PM(n,t)):(e||n.sort(),OM(n))}Bv.exports=CM});var zv=fr((qoe,Vv)=>{"use strict";var TM=Lv();function Rv(n,t,e){var r=n.length,o=t.arrayArgs.length,i=t.indexArgs.length>0,a=[],s=[],l=0,u=0,c,d;for(c=0;c<r;++c)s.push(["i",c,"=0"].join(""));for(d=0;d<o;++d)for(c=0;c<r;++c)u=l,l=n[c],c===0?s.push(["d",d,"s",c,"=t",d,"p",l].join("")):s.push(["d",d,"s",c,"=(t",d,"p",l,"-s",u,"*t",d,"p",u,")"].join(""));for(s.length>0&&a.push("var "+s.join(",")),c=r-1;c>=0;--c)l=n[c],a.push(["for(i",c,"=0;i",c,"<s",l,";++i",c,"){"].join(""));for(a.push(e),c=0;c<r;++c){for(u=l,l=n[c],d=0;d<o;++d)a.push(["p",d,"+=d",d,"s",c].join(""));i&&(c>0&&a.push(["index[",u,"]-=s",u].join("")),a.push(["++index[",l,"]"].join(""))),a.push("}")}return a.join(`
3
- `)}function MM(n,t,e,r){for(var o=t.length,i=e.arrayArgs.length,a=e.blockSize,s=e.indexArgs.length>0,l=[],u=0;u<i;++u)l.push(["var offset",u,"=p",u].join(""));for(var u=n;u<o;++u)l.push(["for(var j"+u+"=SS[",t[u],"]|0;j",u,">0;){"].join("")),l.push(["if(j",u,"<",a,"){"].join("")),l.push(["s",t[u],"=j",u].join("")),l.push(["j",u,"=0"].join("")),l.push(["}else{s",t[u],"=",a].join("")),l.push(["j",u,"-=",a,"}"].join("")),s&&l.push(["index[",t[u],"]=j",u].join(""));for(var u=0;u<i;++u){for(var c=["offset"+u],d=n;d<o;++d)c.push(["j",d,"*t",u,"p",t[d]].join(""));l.push(["p",u,"=(",c.join("+"),")"].join(""))}l.push(Rv(t,e,r));for(var u=n;u<o;++u)l.push("}");return l.join(`
4
- `)}function IM(n){for(var t=0,e=n[0].length;t<e;){for(var r=1;r<n.length;++r)if(n[r][t]!==n[0][t])return t;++t}return t}function Jf(n,t,e){for(var r=n.body,o=[],i=[],a=0;a<n.args.length;++a){var s=n.args[a];if(!(s.count<=0)){var l=new RegExp(s.name,"g"),u="",c=t.arrayArgs.indexOf(a);switch(t.argTypes[a]){case"offset":var d=t.offsetArgIndex.indexOf(a),p=t.offsetArgs[d];c=p.array,u="+q"+d;case"array":u="p"+c+u;var f="l"+a,h="a"+c;if(t.arrayBlockIndices[c]===0)s.count===1?e[c]==="generic"?s.lvalue?(o.push(["var ",f,"=",h,".get(",u,")"].join("")),r=r.replace(l,f),i.push([h,".set(",u,",",f,")"].join(""))):r=r.replace(l,[h,".get(",u,")"].join("")):r=r.replace(l,[h,"[",u,"]"].join("")):e[c]==="generic"?(o.push(["var ",f,"=",h,".get(",u,")"].join("")),r=r.replace(l,f),s.lvalue&&i.push([h,".set(",u,",",f,")"].join(""))):(o.push(["var ",f,"=",h,"[",u,"]"].join("")),r=r.replace(l,f),s.lvalue&&i.push([h,"[",u,"]=",f].join("")));else{for(var m=[s.name],y=[u],g=0;g<Math.abs(t.arrayBlockIndices[c]);g++)m.push("\\s*\\[([^\\]]+)\\]"),y.push("$"+(g+1)+"*t"+c+"b"+g);if(l=new RegExp(m.join(""),"g"),u=y.join("+"),e[c]==="generic")throw new Error("cwise: Generic arrays not supported in combination with blocks!");r=r.replace(l,[h,"[",u,"]"].join(""))}break;case"scalar":r=r.replace(l,"Y"+t.scalarArgs.indexOf(a));break;case"index":r=r.replace(l,"index");break;case"shape":r=r.replace(l,"shape");break}}}return[o.join(`
1
+ "use strict";var N1=Object.create;var cl=Object.defineProperty;var D1=Object.getOwnPropertyDescriptor;var E1=Object.getOwnPropertyNames;var B1=Object.getPrototypeOf,L1=Object.prototype.hasOwnProperty;var R1=(n,t,e)=>t in n?cl(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var fr=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),Kh=(n,t)=>{for(var e in t)cl(n,e,{get:t[e],enumerable:!0})},Zh=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of E1(t))!L1.call(n,o)&&o!==e&&cl(n,o,{get:()=>t[o],enumerable:!(r=D1(t,o))||r.enumerable});return n};var hr=(n,t,e)=>(e=n!=null?N1(B1(n)):{},Zh(t||!n||!n.__esModule?cl(e,"default",{value:n,enumerable:!0}):e,n)),V1=n=>Zh(cl({},"__esModule",{value:!0}),n);var Kt=(n,t,e)=>(R1(n,typeof t!="symbol"?t+"":t,e),e);var E0=fr((Jp,D0)=>{(function(n,t){typeof Jp=="object"?D0.exports=t():typeof define=="function"&&define.amd?define(t):n.Alea=t()})(Jp,function(){"use strict";return n.importState=function(e){var r=new n;return r.importState(e),r},n;function n(){return function(e){var r=0,o=0,i=0,a=1;e.length==0&&(e=[+new Date]);var s=t();r=s(" "),o=s(" "),i=s(" ");for(var l=0;l<e.length;l++)r-=s(e[l]),r<0&&(r+=1),o-=s(e[l]),o<0&&(o+=1),i-=s(e[l]),i<0&&(i+=1);s=null;var u=function(){var c=2091639*r+a*23283064365386963e-26;return r=o,o=i,i=c-(a=c|0)};return u.next=u,u.uint32=function(){return u()*4294967296},u.fract53=function(){return u()+(u()*2097152|0)*11102230246251565e-32},u.version="Alea 0.9",u.args=e,u.exportState=function(){return[r,o,i,a]},u.importState=function(c){r=+c[0]||0,o=+c[1]||0,i=+c[2]||0,a=+c[3]||0},u}(Array.prototype.slice.call(arguments))}function t(){var e=4022871197,r=function(o){o=o.toString();for(var i=0;i<o.length;i++){e+=o.charCodeAt(i);var a=.02519603282416938*e;e=a>>>0,a-=e,a*=e,e=a>>>0,a-=e,e+=a*4294967296}return(e>>>0)*23283064365386963e-26};return r.version="Mash 0.9",r}})});var G0=fr((Gu,z0)=>{(function(n,t){typeof Gu=="object"&&typeof z0<"u"?t(Gu):typeof define=="function"&&define.amd?define(["exports"],t):t((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(Gu,function(n){"use strict";n.SVD=function(t,e,r,o,i){if(e=e===void 0||e,r=r===void 0||r,i=1e-64/(o=o||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var a,s,l,u,c,d,p,f,h,m,y,g,b=t[0].length,w=t.length;if(w<b)throw new TypeError("Invalid matrix: m < n");for(var _=[],S=[],P=[],O=e==="f"?w:b,x=m=p=0;x<w;x++)S[x]=new Array(O).fill(0);for(x=0;x<b;x++)P[x]=new Array(b).fill(0);var D,N=new Array(b).fill(0);for(x=0;x<w;x++)for(a=0;a<b;a++)S[x][a]=t[x][a];for(x=0;x<b;x++){for(_[x]=p,h=0,l=x+1,a=x;a<w;a++)h+=Math.pow(S[a][x],2);if(h<i)p=0;else for(f=(d=S[x][x])*(p=d<0?Math.sqrt(h):-Math.sqrt(h))-h,S[x][x]=d-p,a=l;a<b;a++){for(h=0,s=x;s<w;s++)h+=S[s][x]*S[s][a];for(d=h/f,s=x;s<w;s++)S[s][a]=S[s][a]+d*S[s][x]}for(N[x]=p,h=0,a=l;a<b;a++)h+=Math.pow(S[x][a],2);if(h<i)p=0;else{for(f=(d=S[x][x+1])*(p=d<0?Math.sqrt(h):-Math.sqrt(h))-h,S[x][x+1]=d-p,a=l;a<b;a++)_[a]=S[x][a]/f;for(a=l;a<w;a++){for(h=0,s=l;s<b;s++)h+=S[a][s]*S[x][s];for(s=l;s<b;s++)S[a][s]=S[a][s]+h*_[s]}}m<(y=Math.abs(N[x])+Math.abs(_[x]))&&(m=y)}if(r)for(x=b-1;0<=x;x--){if(p!==0){for(f=S[x][x+1]*p,a=l;a<b;a++)P[a][x]=S[x][a]/f;for(a=l;a<b;a++){for(h=0,s=l;s<b;s++)h+=S[x][s]*P[s][a];for(s=l;s<b;s++)P[s][a]=P[s][a]+h*P[s][x]}}for(a=l;a<b;a++)P[x][a]=0,P[a][x]=0;P[x][x]=1,p=_[x],l=x}if(e){if(e==="f")for(x=b;x<w;x++){for(a=b;a<w;a++)S[x][a]=0;S[x][x]=1}for(x=b-1;0<=x;x--){for(l=x+1,p=N[x],a=l;a<O;a++)S[x][a]=0;if(p!==0){for(f=S[x][x]*p,a=l;a<O;a++){for(h=0,s=l;s<w;s++)h+=S[s][x]*S[s][a];for(d=h/f,s=x;s<w;s++)S[s][a]=S[s][a]+d*S[s][x]}for(a=x;a<w;a++)S[a][x]=S[a][x]/p}else for(a=x;a<w;a++)S[a][x]=0;S[x][x]=S[x][x]+1}}for(o*=m,s=b-1;0<=s;s--)for(var T=0;T<50;T++){for(D=!1,l=s;0<=l;l--){if(Math.abs(_[l])<=o){D=!0;break}if(Math.abs(N[l-1])<=o)break}if(!D){for(c=0,u=l-(h=1),x=l;x<s+1&&(d=h*_[x],_[x]=c*_[x],!(Math.abs(d)<=o));x++)if(p=N[x],N[x]=Math.sqrt(d*d+p*p),c=p/(f=N[x]),h=-d/f,e)for(a=0;a<w;a++)y=S[a][u],g=S[a][x],S[a][u]=y*c+g*h,S[a][x]=-y*h+g*c}if(g=N[s],l===s){if(g<0&&(N[s]=-g,r))for(a=0;a<b;a++)P[a][s]=-P[a][s];break}for(m=N[l],d=(((y=N[s-1])-g)*(y+g)+((p=_[s-1])-(f=_[s]))*(p+f))/(2*f*y),p=Math.sqrt(d*d+1),d=((m-g)*(m+g)+f*(y/(d<0?d-p:d+p)-f))/m,x=l+(h=c=1);x<s+1;x++){if(p=_[x],y=N[x],f=h*p,p*=c,g=Math.sqrt(d*d+f*f),d=m*(c=d/(_[x-1]=g))+p*(h=f/g),p=-m*h+p*c,f=y*h,y*=c,r)for(a=0;a<b;a++)m=P[a][x-1],g=P[a][x],P[a][x-1]=m*c+g*h,P[a][x]=-m*h+g*c;if(g=Math.sqrt(d*d+f*f),d=(c=d/(N[x-1]=g))*p+(h=f/g)*y,m=-h*p+c*y,e)for(a=0;a<w;a++)y=S[a][x-1],g=S[a][x],S[a][x-1]=y*c+g*h,S[a][x]=-y*h+g*c}_[l]=0,_[s]=d,N[s]=m}for(x=0;x<b;x++)N[x]<o&&(N[x]=0);return{u:S,q:N,v:P}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var mx=fr((bf,vf)=>{(function(n,t){typeof bf=="object"&&typeof vf<"u"?vf.exports=t():typeof define=="function"&&define.amd?define(t):(n=n||self,n.TinyQueue=t())})(bf,function(){"use strict";var n=function(r,o){if(r===void 0&&(r=[]),o===void 0&&(o=t),this.data=r,this.length=this.data.length,this.compare=o,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)};n.prototype.push=function(r){this.data.push(r),this.length++,this._up(this.length-1)},n.prototype.pop=function(){if(this.length!==0){var r=this.data[0],o=this.data.pop();return this.length--,this.length>0&&(this.data[0]=o,this._down(0)),r}},n.prototype.peek=function(){return this.data[0]},n.prototype._up=function(r){for(var o=this,i=o.data,a=o.compare,s=i[r];r>0;){var l=r-1>>1,u=i[l];if(a(s,u)>=0)break;i[r]=u,r=l}i[r]=s},n.prototype._down=function(r){for(var o=this,i=o.data,a=o.compare,s=this.length>>1,l=i[r];r<s;){var u=(r<<1)+1,c=i[u],d=u+1;if(d<this.length&&a(i[d],c)<0&&(u=d,c=i[d]),a(c,l)>=0)break;i[r]=c,r=u}i[r]=l};function t(e,r){return e<r?-1:e>r?1:0}return n})});var gx=fr((G4,Sf)=>{"use strict";var Hu=mx();Hu.default&&(Hu=Hu.default);Sf.exports=yx;Sf.exports.default=yx;function yx(n,t,e){t=t||1;for(var r,o,i,a,s=0;s<n[0].length;s++){var l=n[0][s];(!s||l[0]<r)&&(r=l[0]),(!s||l[1]<o)&&(o=l[1]),(!s||l[0]>i)&&(i=l[0]),(!s||l[1]>a)&&(a=l[1])}var u=i-r,c=a-o,d=Math.min(u,c),p=d/2;if(d===0){var f=[r,o];return f.distance=0,f}for(var h=new Hu(void 0,MT),m=r;m<i;m+=d)for(var y=o;y<a;y+=d)h.push(new $n(m+p,y+p,p,n));var g=NT(n),b=new $n(r+u/2,o+c/2,0,n);b.d>g.d&&(g=b);for(var w=h.length;h.length;){var _=h.pop();_.d>g.d&&(g=_,e&&console.log("found best %d after %d probes",Math.round(1e4*_.d)/1e4,w)),!(_.max-g.d<=t)&&(p=_.h/2,h.push(new $n(_.x-p,_.y-p,p,n)),h.push(new $n(_.x+p,_.y-p,p,n)),h.push(new $n(_.x-p,_.y+p,p,n)),h.push(new $n(_.x+p,_.y+p,p,n)),w+=4)}e&&(console.log("num probes: "+w),console.log("best distance: "+g.d));var S=[g.x,g.y];return S.distance=g.d,S}function MT(n,t){return t.max-n.max}function $n(n,t,e,r){this.x=n,this.y=t,this.h=e,this.d=IT(n,t,r),this.max=this.d+this.h*Math.SQRT2}function IT(n,t,e){for(var r=!1,o=1/0,i=0;i<e.length;i++)for(var a=e[i],s=0,l=a.length,u=l-1;s<l;u=s++){var c=a[s],d=a[u];c[1]>t!=d[1]>t&&n<(d[0]-c[0])*(t-c[1])/(d[1]-c[1])+c[0]&&(r=!r),o=Math.min(o,DT(n,t,c,d))}return o===0?0:(r?1:-1)*Math.sqrt(o)}function NT(n){for(var t=0,e=0,r=0,o=n[0],i=0,a=o.length,s=a-1;i<a;s=i++){var l=o[i],u=o[s],c=l[0]*u[1]-u[0]*l[1];e+=(l[0]+u[0])*c,r+=(l[1]+u[1])*c,t+=c*3}return t===0?new $n(o[0][0],o[0][1],0,n):new $n(e/t,r/t,0,n)}function DT(n,t,e,r){var o=e[0],i=e[1],a=r[0]-o,s=r[1]-i;if(a!==0||s!==0){var l=((n-o)*a+(t-i)*s)/(a*a+s*s);l>1?(o=r[0],i=r[1]):l>0&&(o+=a*l,i+=s*l)}return a=n-o,s=t-i,a*a+s*s}});var Nb=fr(gd=>{(function(){"use strict";var n=function(){this.init()};n.prototype={init:function(){var c=this||t;return c._counter=1e3,c._html5AudioPool=[],c.html5PoolSize=10,c._codecs={},c._howls=[],c._muted=!1,c._volume=1,c._canPlayEvent="canplaythrough",c._navigator=typeof window<"u"&&window.navigator?window.navigator:null,c.masterGain=null,c.noAudio=!1,c.usingWebAudio=!0,c.autoSuspend=!0,c.ctx=null,c.autoUnlock=!0,c._setup(),c},volume:function(c){var d=this||t;if(c=parseFloat(c),d.ctx||u(),typeof c<"u"&&c>=0&&c<=1){if(d._volume=c,d._muted)return d;d.usingWebAudio&&d.masterGain.gain.setValueAtTime(c,t.ctx.currentTime);for(var p=0;p<d._howls.length;p++)if(!d._howls[p]._webAudio)for(var f=d._howls[p]._getSoundIds(),h=0;h<f.length;h++){var m=d._howls[p]._soundById(f[h]);m&&m._node&&(m._node.volume=m._volume*c)}return d}return d._volume},mute:function(c){var d=this||t;d.ctx||u(),d._muted=c,d.usingWebAudio&&d.masterGain.gain.setValueAtTime(c?0:d._volume,t.ctx.currentTime);for(var p=0;p<d._howls.length;p++)if(!d._howls[p]._webAudio)for(var f=d._howls[p]._getSoundIds(),h=0;h<f.length;h++){var m=d._howls[p]._soundById(f[h]);m&&m._node&&(m._node.muted=c?!0:m._muted)}return d},stop:function(){for(var c=this||t,d=0;d<c._howls.length;d++)c._howls[d].stop();return c},unload:function(){for(var c=this||t,d=c._howls.length-1;d>=0;d--)c._howls[d].unload();return c.usingWebAudio&&c.ctx&&typeof c.ctx.close<"u"&&(c.ctx.close(),c.ctx=null,u()),c},codecs:function(c){return(this||t)._codecs[c.replace(/^x-/,"")]},_setup:function(){var c=this||t;if(c.state=c.ctx&&c.ctx.state||"suspended",c._autoSuspend(),!c.usingWebAudio)if(typeof Audio<"u")try{var d=new Audio;typeof d.oncanplaythrough>"u"&&(c._canPlayEvent="canplay")}catch{c.noAudio=!0}else c.noAudio=!0;try{var d=new Audio;d.muted&&(c.noAudio=!0)}catch{}return c.noAudio||c._setupCodecs(),c},_setupCodecs:function(){var c=this||t,d=null;try{d=typeof Audio<"u"?new Audio:null}catch{return c}if(!d||typeof d.canPlayType!="function")return c;var p=d.canPlayType("audio/mpeg;").replace(/^no$/,""),f=c._navigator?c._navigator.userAgent:"",h=f.match(/OPR\/([0-6].)/g),m=h&&parseInt(h[0].split("/")[1],10)<33,y=f.indexOf("Safari")!==-1&&f.indexOf("Chrome")===-1,g=f.match(/Version\/(.*?) /),b=y&&g&&parseInt(g[1],10)<15;return c._codecs={mp3:!!(!m&&(p||d.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!p,opus:!!d.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(d.canPlayType('audio/wav; codecs="1"')||d.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!d.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!d.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(d.canPlayType("audio/x-m4a;")||d.canPlayType("audio/m4a;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(d.canPlayType("audio/x-m4b;")||d.canPlayType("audio/m4b;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(d.canPlayType("audio/x-mp4;")||d.canPlayType("audio/mp4;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!b&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!b&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!d.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(d.canPlayType("audio/x-flac;")||d.canPlayType("audio/flac;")).replace(/^no$/,"")},c},_unlockAudio:function(){var c=this||t;if(!(c._audioUnlocked||!c.ctx)){c._audioUnlocked=!1,c.autoUnlock=!1,!c._mobileUnloaded&&c.ctx.sampleRate!==44100&&(c._mobileUnloaded=!0,c.unload()),c._scratchBuffer=c.ctx.createBuffer(1,1,22050);var d=function(p){for(;c._html5AudioPool.length<c.html5PoolSize;)try{var f=new Audio;f._unlocked=!0,c._releaseHtml5Audio(f)}catch{c.noAudio=!0;break}for(var h=0;h<c._howls.length;h++)if(!c._howls[h]._webAudio)for(var m=c._howls[h]._getSoundIds(),y=0;y<m.length;y++){var g=c._howls[h]._soundById(m[y]);g&&g._node&&!g._node._unlocked&&(g._node._unlocked=!0,g._node.load())}c._autoResume();var b=c.ctx.createBufferSource();b.buffer=c._scratchBuffer,b.connect(c.ctx.destination),typeof b.start>"u"?b.noteOn(0):b.start(0),typeof c.ctx.resume=="function"&&c.ctx.resume(),b.onended=function(){b.disconnect(0),c._audioUnlocked=!0,document.removeEventListener("touchstart",d,!0),document.removeEventListener("touchend",d,!0),document.removeEventListener("click",d,!0),document.removeEventListener("keydown",d,!0);for(var w=0;w<c._howls.length;w++)c._howls[w]._emit("unlock")}};return document.addEventListener("touchstart",d,!0),document.addEventListener("touchend",d,!0),document.addEventListener("click",d,!0),document.addEventListener("keydown",d,!0),c}},_obtainHtml5Audio:function(){var c=this||t;if(c._html5AudioPool.length)return c._html5AudioPool.pop();var d=new Audio().play();return d&&typeof Promise<"u"&&(d instanceof Promise||typeof d.then=="function")&&d.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(c){var d=this||t;return c._unlocked&&d._html5AudioPool.push(c),d},_autoSuspend:function(){var c=this;if(!(!c.autoSuspend||!c.ctx||typeof c.ctx.suspend>"u"||!t.usingWebAudio)){for(var d=0;d<c._howls.length;d++)if(c._howls[d]._webAudio){for(var p=0;p<c._howls[d]._sounds.length;p++)if(!c._howls[d]._sounds[p]._paused)return c}return c._suspendTimer&&clearTimeout(c._suspendTimer),c._suspendTimer=setTimeout(function(){if(!!c.autoSuspend){c._suspendTimer=null,c.state="suspending";var f=function(){c.state="suspended",c._resumeAfterSuspend&&(delete c._resumeAfterSuspend,c._autoResume())};c.ctx.suspend().then(f,f)}},3e4),c}},_autoResume:function(){var c=this;if(!(!c.ctx||typeof c.ctx.resume>"u"||!t.usingWebAudio))return c.state==="running"&&c.ctx.state!=="interrupted"&&c._suspendTimer?(clearTimeout(c._suspendTimer),c._suspendTimer=null):c.state==="suspended"||c.state==="running"&&c.ctx.state==="interrupted"?(c.ctx.resume().then(function(){c.state="running";for(var d=0;d<c._howls.length;d++)c._howls[d]._emit("resume")}),c._suspendTimer&&(clearTimeout(c._suspendTimer),c._suspendTimer=null)):c.state==="suspending"&&(c._resumeAfterSuspend=!0),c}};var t=new n,e=function(c){var d=this;if(!c.src||c.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}d.init(c)};e.prototype={init:function(c){var d=this;return t.ctx||u(),d._autoplay=c.autoplay||!1,d._format=typeof c.format!="string"?c.format:[c.format],d._html5=c.html5||!1,d._muted=c.mute||!1,d._loop=c.loop||!1,d._pool=c.pool||5,d._preload=typeof c.preload=="boolean"||c.preload==="metadata"?c.preload:!0,d._rate=c.rate||1,d._sprite=c.sprite||{},d._src=typeof c.src!="string"?c.src:[c.src],d._volume=c.volume!==void 0?c.volume:1,d._xhr={method:c.xhr&&c.xhr.method?c.xhr.method:"GET",headers:c.xhr&&c.xhr.headers?c.xhr.headers:null,withCredentials:c.xhr&&c.xhr.withCredentials?c.xhr.withCredentials:!1},d._duration=0,d._state="unloaded",d._sounds=[],d._endTimers={},d._queue=[],d._playLock=!1,d._onend=c.onend?[{fn:c.onend}]:[],d._onfade=c.onfade?[{fn:c.onfade}]:[],d._onload=c.onload?[{fn:c.onload}]:[],d._onloaderror=c.onloaderror?[{fn:c.onloaderror}]:[],d._onplayerror=c.onplayerror?[{fn:c.onplayerror}]:[],d._onpause=c.onpause?[{fn:c.onpause}]:[],d._onplay=c.onplay?[{fn:c.onplay}]:[],d._onstop=c.onstop?[{fn:c.onstop}]:[],d._onmute=c.onmute?[{fn:c.onmute}]:[],d._onvolume=c.onvolume?[{fn:c.onvolume}]:[],d._onrate=c.onrate?[{fn:c.onrate}]:[],d._onseek=c.onseek?[{fn:c.onseek}]:[],d._onunlock=c.onunlock?[{fn:c.onunlock}]:[],d._onresume=[],d._webAudio=t.usingWebAudio&&!d._html5,typeof t.ctx<"u"&&t.ctx&&t.autoUnlock&&t._unlockAudio(),t._howls.push(d),d._autoplay&&d._queue.push({event:"play",action:function(){d.play()}}),d._preload&&d._preload!=="none"&&d.load(),d},load:function(){var c=this,d=null;if(t.noAudio){c._emit("loaderror",null,"No audio support.");return}typeof c._src=="string"&&(c._src=[c._src]);for(var p=0;p<c._src.length;p++){var f,h;if(c._format&&c._format[p])f=c._format[p];else{if(h=c._src[p],typeof h!="string"){c._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}f=/^data:audio\/([^;,]+);/i.exec(h),f||(f=/\.([^.]+)$/.exec(h.split("?",1)[0])),f&&(f=f[1].toLowerCase())}if(f||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),f&&t.codecs(f)){d=c._src[p];break}}if(!d){c._emit("loaderror",null,"No codec support for selected audio sources.");return}return c._src=d,c._state="loading",window.location.protocol==="https:"&&d.slice(0,5)==="http:"&&(c._html5=!0,c._webAudio=!1),new r(c),c._webAudio&&i(c),c},play:function(c,d){var p=this,f=null;if(typeof c=="number")f=c,c=null;else{if(typeof c=="string"&&p._state==="loaded"&&!p._sprite[c])return null;if(typeof c>"u"&&(c="__default",!p._playLock)){for(var h=0,m=0;m<p._sounds.length;m++)p._sounds[m]._paused&&!p._sounds[m]._ended&&(h++,f=p._sounds[m]._id);h===1?c=null:f=null}}var y=f?p._soundById(f):p._inactiveSound();if(!y)return null;if(f&&!c&&(c=y._sprite||"__default"),p._state!=="loaded"){y._sprite=c,y._ended=!1;var g=y._id;return p._queue.push({event:"play",action:function(){p.play(g)}}),g}if(f&&!y._paused)return d||p._loadQueue("play"),y._id;p._webAudio&&t._autoResume();var b=Math.max(0,y._seek>0?y._seek:p._sprite[c][0]/1e3),w=Math.max(0,(p._sprite[c][0]+p._sprite[c][1])/1e3-b),_=w*1e3/Math.abs(y._rate),S=p._sprite[c][0]/1e3,P=(p._sprite[c][0]+p._sprite[c][1])/1e3;y._sprite=c,y._ended=!1;var O=function(){y._paused=!1,y._seek=b,y._start=S,y._stop=P,y._loop=!!(y._loop||p._sprite[c][2])};if(b>=P){p._ended(y);return}var x=y._node;if(p._webAudio){var D=function(){p._playLock=!1,O(),p._refreshBuffer(y);var E=y._muted||p._muted?0:y._volume;x.gain.setValueAtTime(E,t.ctx.currentTime),y._playStart=t.ctx.currentTime,typeof x.bufferSource.start>"u"?y._loop?x.bufferSource.noteGrainOn(0,b,86400):x.bufferSource.noteGrainOn(0,b,w):y._loop?x.bufferSource.start(0,b,86400):x.bufferSource.start(0,b,w),_!==1/0&&(p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),_)),d||setTimeout(function(){p._emit("play",y._id),p._loadQueue()},0)};t.state==="running"&&t.ctx.state!=="interrupted"?D():(p._playLock=!0,p.once("resume",D),p._clearTimer(y._id))}else{var N=function(){x.currentTime=b,x.muted=y._muted||p._muted||t._muted||x.muted,x.volume=y._volume*t.volume(),x.playbackRate=y._rate;try{var E=x.play();if(E&&typeof Promise<"u"&&(E instanceof Promise||typeof E.then=="function")?(p._playLock=!0,O(),E.then(function(){p._playLock=!1,x._unlocked=!0,d?p._loadQueue():p._emit("play",y._id)}).catch(function(){p._playLock=!1,p._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),y._ended=!0,y._paused=!0})):d||(p._playLock=!1,O(),p._emit("play",y._id)),x.playbackRate=y._rate,x.paused){p._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}c!=="__default"||y._loop?p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),_):(p._endTimers[y._id]=function(){p._ended(y),x.removeEventListener("ended",p._endTimers[y._id],!1)},x.addEventListener("ended",p._endTimers[y._id],!1))}catch(B){p._emit("playerror",y._id,B)}};x.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(x.src=p._src,x.load());var T=window&&window.ejecta||!x.readyState&&t._navigator.isCocoonJS;if(x.readyState>=3||T)N();else{p._playLock=!0,p._state="loading";var I=function(){p._state="loaded",N(),x.removeEventListener(t._canPlayEvent,I,!1)};x.addEventListener(t._canPlayEvent,I,!1),p._clearTimer(y._id)}}return y._id},pause:function(c){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"pause",action:function(){d.pause(c)}}),d;for(var p=d._getSoundIds(c),f=0;f<p.length;f++){d._clearTimer(p[f]);var h=d._soundById(p[f]);if(h&&!h._paused&&(h._seek=d.seek(p[f]),h._rateSeek=0,h._paused=!0,d._stopFade(p[f]),h._node))if(d._webAudio){if(!h._node.bufferSource)continue;typeof h._node.bufferSource.stop>"u"?h._node.bufferSource.noteOff(0):h._node.bufferSource.stop(0),d._cleanBuffer(h._node)}else(!isNaN(h._node.duration)||h._node.duration===1/0)&&h._node.pause();arguments[1]||d._emit("pause",h?h._id:null)}return d},stop:function(c,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"stop",action:function(){p.stop(c)}}),p;for(var f=p._getSoundIds(c),h=0;h<f.length;h++){p._clearTimer(f[h]);var m=p._soundById(f[h]);m&&(m._seek=m._start||0,m._rateSeek=0,m._paused=!0,m._ended=!0,p._stopFade(f[h]),m._node&&(p._webAudio?m._node.bufferSource&&(typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),p._cleanBuffer(m._node)):(!isNaN(m._node.duration)||m._node.duration===1/0)&&(m._node.currentTime=m._start||0,m._node.pause(),m._node.duration===1/0&&p._clearSound(m._node))),d||p._emit("stop",m._id))}return p},mute:function(c,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"mute",action:function(){p.mute(c,d)}}),p;if(typeof d>"u")if(typeof c=="boolean")p._muted=c;else return p._muted;for(var f=p._getSoundIds(d),h=0;h<f.length;h++){var m=p._soundById(f[h]);m&&(m._muted=c,m._interval&&p._stopFade(m._id),p._webAudio&&m._node?m._node.gain.setValueAtTime(c?0:m._volume,t.ctx.currentTime):m._node&&(m._node.muted=t._muted?!0:c),p._emit("mute",m._id))}return p},volume:function(){var c=this,d=arguments,p,f;if(d.length===0)return c._volume;if(d.length===1||d.length===2&&typeof d[1]>"u"){var h=c._getSoundIds(),m=h.indexOf(d[0]);m>=0?f=parseInt(d[0],10):p=parseFloat(d[0])}else d.length>=2&&(p=parseFloat(d[0]),f=parseInt(d[1],10));var y;if(typeof p<"u"&&p>=0&&p<=1){if(c._state!=="loaded"||c._playLock)return c._queue.push({event:"volume",action:function(){c.volume.apply(c,d)}}),c;typeof f>"u"&&(c._volume=p),f=c._getSoundIds(f);for(var g=0;g<f.length;g++)y=c._soundById(f[g]),y&&(y._volume=p,d[2]||c._stopFade(f[g]),c._webAudio&&y._node&&!y._muted?y._node.gain.setValueAtTime(p,t.ctx.currentTime):y._node&&!y._muted&&(y._node.volume=p*t.volume()),c._emit("volume",y._id))}else return y=f?c._soundById(f):c._sounds[0],y?y._volume:0;return c},fade:function(c,d,p,f){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"fade",action:function(){h.fade(c,d,p,f)}}),h;c=Math.min(Math.max(0,parseFloat(c)),1),d=Math.min(Math.max(0,parseFloat(d)),1),p=parseFloat(p),h.volume(c,f);for(var m=h._getSoundIds(f),y=0;y<m.length;y++){var g=h._soundById(m[y]);if(g){if(f||h._stopFade(m[y]),h._webAudio&&!g._muted){var b=t.ctx.currentTime,w=b+p/1e3;g._volume=c,g._node.gain.setValueAtTime(c,b),g._node.gain.linearRampToValueAtTime(d,w)}h._startFadeInterval(g,c,d,p,m[y],typeof f>"u")}}return h},_startFadeInterval:function(c,d,p,f,h,m){var y=this,g=d,b=p-d,w=Math.abs(b/.01),_=Math.max(4,w>0?f/w:f),S=Date.now();c._fadeTo=p,c._interval=setInterval(function(){var P=(Date.now()-S)/f;S=Date.now(),g+=b*P,g=Math.round(g*100)/100,b<0?g=Math.max(p,g):g=Math.min(p,g),y._webAudio?c._volume=g:y.volume(g,c._id,!0),m&&(y._volume=g),(p<d&&g<=p||p>d&&g>=p)&&(clearInterval(c._interval),c._interval=null,c._fadeTo=null,y.volume(p,c._id),y._emit("fade",c._id))},_)},_stopFade:function(c){var d=this,p=d._soundById(c);return p&&p._interval&&(d._webAudio&&p._node.gain.cancelScheduledValues(t.ctx.currentTime),clearInterval(p._interval),p._interval=null,d.volume(p._fadeTo,c),p._fadeTo=null,d._emit("fade",c)),d},loop:function(){var c=this,d=arguments,p,f,h;if(d.length===0)return c._loop;if(d.length===1)if(typeof d[0]=="boolean")p=d[0],c._loop=p;else return h=c._soundById(parseInt(d[0],10)),h?h._loop:!1;else d.length===2&&(p=d[0],f=parseInt(d[1],10));for(var m=c._getSoundIds(f),y=0;y<m.length;y++)h=c._soundById(m[y]),h&&(h._loop=p,c._webAudio&&h._node&&h._node.bufferSource&&(h._node.bufferSource.loop=p,p&&(h._node.bufferSource.loopStart=h._start||0,h._node.bufferSource.loopEnd=h._stop,c.playing(m[y])&&(c.pause(m[y],!0),c.play(m[y],!0)))));return c},rate:function(){var c=this,d=arguments,p,f;if(d.length===0)f=c._sounds[0]._id;else if(d.length===1){var h=c._getSoundIds(),m=h.indexOf(d[0]);m>=0?f=parseInt(d[0],10):p=parseFloat(d[0])}else d.length===2&&(p=parseFloat(d[0]),f=parseInt(d[1],10));var y;if(typeof p=="number"){if(c._state!=="loaded"||c._playLock)return c._queue.push({event:"rate",action:function(){c.rate.apply(c,d)}}),c;typeof f>"u"&&(c._rate=p),f=c._getSoundIds(f);for(var g=0;g<f.length;g++)if(y=c._soundById(f[g]),y){c.playing(f[g])&&(y._rateSeek=c.seek(f[g]),y._playStart=c._webAudio?t.ctx.currentTime:y._playStart),y._rate=p,c._webAudio&&y._node&&y._node.bufferSource?y._node.bufferSource.playbackRate.setValueAtTime(p,t.ctx.currentTime):y._node&&(y._node.playbackRate=p);var b=c.seek(f[g]),w=(c._sprite[y._sprite][0]+c._sprite[y._sprite][1])/1e3-b,_=w*1e3/Math.abs(y._rate);(c._endTimers[f[g]]||!y._paused)&&(c._clearTimer(f[g]),c._endTimers[f[g]]=setTimeout(c._ended.bind(c,y),_)),c._emit("rate",y._id)}}else return y=c._soundById(f),y?y._rate:c._rate;return c},seek:function(){var c=this,d=arguments,p,f;if(d.length===0)c._sounds.length&&(f=c._sounds[0]._id);else if(d.length===1){var h=c._getSoundIds(),m=h.indexOf(d[0]);m>=0?f=parseInt(d[0],10):c._sounds.length&&(f=c._sounds[0]._id,p=parseFloat(d[0]))}else d.length===2&&(p=parseFloat(d[0]),f=parseInt(d[1],10));if(typeof f>"u")return 0;if(typeof p=="number"&&(c._state!=="loaded"||c._playLock))return c._queue.push({event:"seek",action:function(){c.seek.apply(c,d)}}),c;var y=c._soundById(f);if(y)if(typeof p=="number"&&p>=0){var g=c.playing(f);g&&c.pause(f,!0),y._seek=p,y._ended=!1,c._clearTimer(f),!c._webAudio&&y._node&&!isNaN(y._node.duration)&&(y._node.currentTime=p);var b=function(){g&&c.play(f,!0),c._emit("seek",f)};if(g&&!c._webAudio){var w=function(){c._playLock?setTimeout(w,0):b()};setTimeout(w,0)}else b()}else if(c._webAudio){var _=c.playing(f)?t.ctx.currentTime-y._playStart:0,S=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(S+_*Math.abs(y._rate))}else return y._node.currentTime;return c},playing:function(c){var d=this;if(typeof c=="number"){var p=d._soundById(c);return p?!p._paused:!1}for(var f=0;f<d._sounds.length;f++)if(!d._sounds[f]._paused)return!0;return!1},duration:function(c){var d=this,p=d._duration,f=d._soundById(c);return f&&(p=d._sprite[f._sprite][1]/1e3),p},state:function(){return this._state},unload:function(){for(var c=this,d=c._sounds,p=0;p<d.length;p++)d[p]._paused||c.stop(d[p]._id),c._webAudio||(c._clearSound(d[p]._node),d[p]._node.removeEventListener("error",d[p]._errorFn,!1),d[p]._node.removeEventListener(t._canPlayEvent,d[p]._loadFn,!1),d[p]._node.removeEventListener("ended",d[p]._endFn,!1),t._releaseHtml5Audio(d[p]._node)),delete d[p]._node,c._clearTimer(d[p]._id);var f=t._howls.indexOf(c);f>=0&&t._howls.splice(f,1);var h=!0;for(p=0;p<t._howls.length;p++)if(t._howls[p]._src===c._src||c._src.indexOf(t._howls[p]._src)>=0){h=!1;break}return o&&h&&delete o[c._src],t.noAudio=!1,c._state="unloaded",c._sounds=[],c=null,null},on:function(c,d,p,f){var h=this,m=h["_on"+c];return typeof d=="function"&&m.push(f?{id:p,fn:d,once:f}:{id:p,fn:d}),h},off:function(c,d,p){var f=this,h=f["_on"+c],m=0;if(typeof d=="number"&&(p=d,d=null),d||p)for(m=0;m<h.length;m++){var y=p===h[m].id;if(d===h[m].fn&&y||!d&&y){h.splice(m,1);break}}else if(c)f["_on"+c]=[];else{var g=Object.keys(f);for(m=0;m<g.length;m++)g[m].indexOf("_on")===0&&Array.isArray(f[g[m]])&&(f[g[m]]=[])}return f},once:function(c,d,p){var f=this;return f.on(c,d,p,1),f},_emit:function(c,d,p){for(var f=this,h=f["_on"+c],m=h.length-1;m>=0;m--)(!h[m].id||h[m].id===d||c==="load")&&(setTimeout(function(y){y.call(this,d,p)}.bind(f,h[m].fn),0),h[m].once&&f.off(c,h[m].fn,h[m].id));return f._loadQueue(c),f},_loadQueue:function(c){var d=this;if(d._queue.length>0){var p=d._queue[0];p.event===c&&(d._queue.shift(),d._loadQueue()),c||p.action()}return d},_ended:function(c){var d=this,p=c._sprite;if(!d._webAudio&&c._node&&!c._node.paused&&!c._node.ended&&c._node.currentTime<c._stop)return setTimeout(d._ended.bind(d,c),100),d;var f=!!(c._loop||d._sprite[p][2]);if(d._emit("end",c._id),!d._webAudio&&f&&d.stop(c._id,!0).play(c._id),d._webAudio&&f){d._emit("play",c._id),c._seek=c._start||0,c._rateSeek=0,c._playStart=t.ctx.currentTime;var h=(c._stop-c._start)*1e3/Math.abs(c._rate);d._endTimers[c._id]=setTimeout(d._ended.bind(d,c),h)}return d._webAudio&&!f&&(c._paused=!0,c._ended=!0,c._seek=c._start||0,c._rateSeek=0,d._clearTimer(c._id),d._cleanBuffer(c._node),t._autoSuspend()),!d._webAudio&&!f&&d.stop(c._id,!0),d},_clearTimer:function(c){var d=this;if(d._endTimers[c]){if(typeof d._endTimers[c]!="function")clearTimeout(d._endTimers[c]);else{var p=d._soundById(c);p&&p._node&&p._node.removeEventListener("ended",d._endTimers[c],!1)}delete d._endTimers[c]}return d},_soundById:function(c){for(var d=this,p=0;p<d._sounds.length;p++)if(c===d._sounds[p]._id)return d._sounds[p];return null},_inactiveSound:function(){var c=this;c._drain();for(var d=0;d<c._sounds.length;d++)if(c._sounds[d]._ended)return c._sounds[d].reset();return new r(c)},_drain:function(){var c=this,d=c._pool,p=0,f=0;if(!(c._sounds.length<d)){for(f=0;f<c._sounds.length;f++)c._sounds[f]._ended&&p++;for(f=c._sounds.length-1;f>=0;f--){if(p<=d)return;c._sounds[f]._ended&&(c._webAudio&&c._sounds[f]._node&&c._sounds[f]._node.disconnect(0),c._sounds.splice(f,1),p--)}}},_getSoundIds:function(c){var d=this;if(typeof c>"u"){for(var p=[],f=0;f<d._sounds.length;f++)p.push(d._sounds[f]._id);return p}else return[c]},_refreshBuffer:function(c){var d=this;return c._node.bufferSource=t.ctx.createBufferSource(),c._node.bufferSource.buffer=o[d._src],c._panner?c._node.bufferSource.connect(c._panner):c._node.bufferSource.connect(c._node),c._node.bufferSource.loop=c._loop,c._loop&&(c._node.bufferSource.loopStart=c._start||0,c._node.bufferSource.loopEnd=c._stop||0),c._node.bufferSource.playbackRate.setValueAtTime(c._rate,t.ctx.currentTime),d},_cleanBuffer:function(c){var d=this,p=t._navigator&&t._navigator.vendor.indexOf("Apple")>=0;if(t._scratchBuffer&&c.bufferSource&&(c.bufferSource.onended=null,c.bufferSource.disconnect(0),p))try{c.bufferSource.buffer=t._scratchBuffer}catch{}return c.bufferSource=null,d},_clearSound:function(c){var d=/MSIE |Trident\//.test(t._navigator&&t._navigator.userAgent);d||(c.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var r=function(c){this._parent=c,this.init()};r.prototype={init:function(){var c=this,d=c._parent;return c._muted=d._muted,c._loop=d._loop,c._volume=d._volume,c._rate=d._rate,c._seek=0,c._paused=!0,c._ended=!0,c._sprite="__default",c._id=++t._counter,d._sounds.push(c),c.create(),c},create:function(){var c=this,d=c._parent,p=t._muted||c._muted||c._parent._muted?0:c._volume;return d._webAudio?(c._node=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),c._node.gain.setValueAtTime(p,t.ctx.currentTime),c._node.paused=!0,c._node.connect(t.masterGain)):t.noAudio||(c._node=t._obtainHtml5Audio(),c._errorFn=c._errorListener.bind(c),c._node.addEventListener("error",c._errorFn,!1),c._loadFn=c._loadListener.bind(c),c._node.addEventListener(t._canPlayEvent,c._loadFn,!1),c._endFn=c._endListener.bind(c),c._node.addEventListener("ended",c._endFn,!1),c._node.src=d._src,c._node.preload=d._preload===!0?"auto":d._preload,c._node.volume=p*t.volume(),c._node.load()),c},reset:function(){var c=this,d=c._parent;return c._muted=d._muted,c._loop=d._loop,c._volume=d._volume,c._rate=d._rate,c._seek=0,c._rateSeek=0,c._paused=!0,c._ended=!0,c._sprite="__default",c._id=++t._counter,c},_errorListener:function(){var c=this;c._parent._emit("loaderror",c._id,c._node.error?c._node.error.code:0),c._node.removeEventListener("error",c._errorFn,!1)},_loadListener:function(){var c=this,d=c._parent;d._duration=Math.ceil(c._node.duration*10)/10,Object.keys(d._sprite).length===0&&(d._sprite={__default:[0,d._duration*1e3]}),d._state!=="loaded"&&(d._state="loaded",d._emit("load"),d._loadQueue()),c._node.removeEventListener(t._canPlayEvent,c._loadFn,!1)},_endListener:function(){var c=this,d=c._parent;d._duration===1/0&&(d._duration=Math.ceil(c._node.duration*10)/10,d._sprite.__default[1]===1/0&&(d._sprite.__default[1]=d._duration*1e3),d._ended(c)),c._node.removeEventListener("ended",c._endFn,!1)}};var o={},i=function(c){var d=c._src;if(o[d]){c._duration=o[d].duration,l(c);return}if(/^data:[^;]+;base64,/.test(d)){for(var p=atob(d.split(",")[1]),f=new Uint8Array(p.length),h=0;h<p.length;++h)f[h]=p.charCodeAt(h);s(f.buffer,c)}else{var m=new XMLHttpRequest;m.open(c._xhr.method,d,!0),m.withCredentials=c._xhr.withCredentials,m.responseType="arraybuffer",c._xhr.headers&&Object.keys(c._xhr.headers).forEach(function(y){m.setRequestHeader(y,c._xhr.headers[y])}),m.onload=function(){var y=(m.status+"")[0];if(y!=="0"&&y!=="2"&&y!=="3"){c._emit("loaderror",null,"Failed loading audio file with status: "+m.status+".");return}s(m.response,c)},m.onerror=function(){c._webAudio&&(c._html5=!0,c._webAudio=!1,c._sounds=[],delete o[d],c.load())},a(m)}},a=function(c){try{c.send()}catch{c.onerror()}},s=function(c,d){var p=function(){d._emit("loaderror",null,"Decoding audio data failed.")},f=function(h){h&&d._sounds.length>0?(o[d._src]=h,l(d,h)):p()};typeof Promise<"u"&&t.ctx.decodeAudioData.length===1?t.ctx.decodeAudioData(c).then(f).catch(p):t.ctx.decodeAudioData(c,f,p)},l=function(c,d){d&&!c._duration&&(c._duration=d.duration),Object.keys(c._sprite).length===0&&(c._sprite={__default:[0,c._duration*1e3]}),c._state!=="loaded"&&(c._state="loaded",c._emit("load"),c._loadQueue())},u=function(){if(!!t.usingWebAudio){try{typeof AudioContext<"u"?t.ctx=new AudioContext:typeof webkitAudioContext<"u"?t.ctx=new webkitAudioContext:t.usingWebAudio=!1}catch{t.usingWebAudio=!1}t.ctx||(t.usingWebAudio=!1);var c=/iP(hone|od|ad)/.test(t._navigator&&t._navigator.platform),d=t._navigator&&t._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),p=d?parseInt(d[1],10):null;if(c&&p&&p<9){var f=/safari/.test(t._navigator&&t._navigator.userAgent.toLowerCase());t._navigator&&!f&&(t.usingWebAudio=!1)}t.usingWebAudio&&(t.masterGain=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),t.masterGain.gain.setValueAtTime(t._muted?0:t._volume,t.ctx.currentTime),t.masterGain.connect(t.ctx.destination)),t._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:t,Howl:e}}),typeof gd<"u"&&(gd.Howler=t,gd.Howl=e),typeof global<"u"?(global.HowlerGlobal=n,global.Howler=t,global.Howl=e,global.Sound=r):typeof window<"u"&&(window.HowlerGlobal=n,window.Howler=t,window.Howl=e,window.Sound=r)})();(function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var r=e._howls.length-1;r>=0;r--)e._howls[r].stereo(t);return e},HowlerGlobal.prototype.pos=function(t,e,r){var o=this;if(!o.ctx||!o.ctx.listener)return o;if(e=typeof e!="number"?o._pos[1]:e,r=typeof r!="number"?o._pos[2]:r,typeof t=="number")o._pos=[t,e,r],typeof o.ctx.listener.positionX<"u"?(o.ctx.listener.positionX.setTargetAtTime(o._pos[0],Howler.ctx.currentTime,.1),o.ctx.listener.positionY.setTargetAtTime(o._pos[1],Howler.ctx.currentTime,.1),o.ctx.listener.positionZ.setTargetAtTime(o._pos[2],Howler.ctx.currentTime,.1)):o.ctx.listener.setPosition(o._pos[0],o._pos[1],o._pos[2]);else return o._pos;return o},HowlerGlobal.prototype.orientation=function(t,e,r,o,i,a){var s=this;if(!s.ctx||!s.ctx.listener)return s;var l=s._orientation;if(e=typeof e!="number"?l[1]:e,r=typeof r!="number"?l[2]:r,o=typeof o!="number"?l[3]:o,i=typeof i!="number"?l[4]:i,a=typeof a!="number"?l[5]:a,typeof t=="number")s._orientation=[t,e,r,o,i,a],typeof s.ctx.listener.forwardX<"u"?(s.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),s.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),s.ctx.listener.forwardZ.setTargetAtTime(r,Howler.ctx.currentTime,.1),s.ctx.listener.upX.setTargetAtTime(o,Howler.ctx.currentTime,.1),s.ctx.listener.upY.setTargetAtTime(i,Howler.ctx.currentTime,.1),s.ctx.listener.upZ.setTargetAtTime(a,Howler.ctx.currentTime,.1)):s.ctx.listener.setOrientation(t,e,r,o,i,a);else return l;return s},Howl.prototype.init=function(t){return function(e){var r=this;return r._orientation=e.orientation||[1,0,0],r._stereo=e.stereo||null,r._pos=e.pos||null,r._pannerAttr={coneInnerAngle:typeof e.coneInnerAngle<"u"?e.coneInnerAngle:360,coneOuterAngle:typeof e.coneOuterAngle<"u"?e.coneOuterAngle:360,coneOuterGain:typeof e.coneOuterGain<"u"?e.coneOuterGain:0,distanceModel:typeof e.distanceModel<"u"?e.distanceModel:"inverse",maxDistance:typeof e.maxDistance<"u"?e.maxDistance:1e4,panningModel:typeof e.panningModel<"u"?e.panningModel:"HRTF",refDistance:typeof e.refDistance<"u"?e.refDistance:1,rolloffFactor:typeof e.rolloffFactor<"u"?e.rolloffFactor:1},r._onstereo=e.onstereo?[{fn:e.onstereo}]:[],r._onpos=e.onpos?[{fn:e.onpos}]:[],r._onorientation=e.onorientation?[{fn:e.onorientation}]:[],t.call(this,e)}}(Howl.prototype.init),Howl.prototype.stereo=function(t,e){var r=this;if(!r._webAudio)return r;if(r._state!=="loaded")return r._queue.push({event:"stereo",action:function(){r.stereo(t,e)}}),r;var o=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof e>"u")if(typeof t=="number")r._stereo=t,r._pos=[t,0,0];else return r._stereo;for(var i=r._getSoundIds(e),a=0;a<i.length;a++){var s=r._soundById(i[a]);if(s)if(typeof t=="number")s._stereo=t,s._pos=[t,0,0],s._node&&(s._pannerAttr.panningModel="equalpower",(!s._panner||!s._panner.pan)&&n(s,o),o==="spatial"?typeof s._panner.positionX<"u"?(s._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),s._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),s._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):s._panner.setPosition(t,0,0):s._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),r._emit("stereo",s._id);else return s._stereo}return r},Howl.prototype.pos=function(t,e,r,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"pos",action:function(){i.pos(t,e,r,o)}}),i;if(e=typeof e!="number"?0:e,r=typeof r!="number"?-.5:r,typeof o>"u")if(typeof t=="number")i._pos=[t,e,r];else return i._pos;for(var a=i._getSoundIds(o),s=0;s<a.length;s++){var l=i._soundById(a[s]);if(l)if(typeof t=="number")l._pos=[t,e,r],l._node&&((!l._panner||l._panner.pan)&&n(l,"spatial"),typeof l._panner.positionX<"u"?(l._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),l._panner.positionY.setValueAtTime(e,Howler.ctx.currentTime),l._panner.positionZ.setValueAtTime(r,Howler.ctx.currentTime)):l._panner.setPosition(t,e,r)),i._emit("pos",l._id);else return l._pos}return i},Howl.prototype.orientation=function(t,e,r,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"orientation",action:function(){i.orientation(t,e,r,o)}}),i;if(e=typeof e!="number"?i._orientation[1]:e,r=typeof r!="number"?i._orientation[2]:r,typeof o>"u")if(typeof t=="number")i._orientation=[t,e,r];else return i._orientation;for(var a=i._getSoundIds(o),s=0;s<a.length;s++){var l=i._soundById(a[s]);if(l)if(typeof t=="number")l._orientation=[t,e,r],l._node&&(l._panner||(l._pos||(l._pos=i._pos||[0,0,-.5]),n(l,"spatial")),typeof l._panner.orientationX<"u"?(l._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),l._panner.orientationY.setValueAtTime(e,Howler.ctx.currentTime),l._panner.orientationZ.setValueAtTime(r,Howler.ctx.currentTime)):l._panner.setOrientation(t,e,r)),i._emit("orientation",l._id);else return l._orientation}return i},Howl.prototype.pannerAttr=function(){var t=this,e=arguments,r,o,i;if(!t._webAudio)return t;if(e.length===0)return t._pannerAttr;if(e.length===1)if(typeof e[0]=="object")r=e[0],typeof o>"u"&&(r.pannerAttr||(r.pannerAttr={coneInnerAngle:r.coneInnerAngle,coneOuterAngle:r.coneOuterAngle,coneOuterGain:r.coneOuterGain,distanceModel:r.distanceModel,maxDistance:r.maxDistance,refDistance:r.refDistance,rolloffFactor:r.rolloffFactor,panningModel:r.panningModel}),t._pannerAttr={coneInnerAngle:typeof r.pannerAttr.coneInnerAngle<"u"?r.pannerAttr.coneInnerAngle:t._coneInnerAngle,coneOuterAngle:typeof r.pannerAttr.coneOuterAngle<"u"?r.pannerAttr.coneOuterAngle:t._coneOuterAngle,coneOuterGain:typeof r.pannerAttr.coneOuterGain<"u"?r.pannerAttr.coneOuterGain:t._coneOuterGain,distanceModel:typeof r.pannerAttr.distanceModel<"u"?r.pannerAttr.distanceModel:t._distanceModel,maxDistance:typeof r.pannerAttr.maxDistance<"u"?r.pannerAttr.maxDistance:t._maxDistance,refDistance:typeof r.pannerAttr.refDistance<"u"?r.pannerAttr.refDistance:t._refDistance,rolloffFactor:typeof r.pannerAttr.rolloffFactor<"u"?r.pannerAttr.rolloffFactor:t._rolloffFactor,panningModel:typeof r.pannerAttr.panningModel<"u"?r.pannerAttr.panningModel:t._panningModel});else return i=t._soundById(parseInt(e[0],10)),i?i._pannerAttr:t._pannerAttr;else e.length===2&&(r=e[0],o=parseInt(e[1],10));for(var a=t._getSoundIds(o),s=0;s<a.length;s++)if(i=t._soundById(a[s]),i){var l=i._pannerAttr;l={coneInnerAngle:typeof r.coneInnerAngle<"u"?r.coneInnerAngle:l.coneInnerAngle,coneOuterAngle:typeof r.coneOuterAngle<"u"?r.coneOuterAngle:l.coneOuterAngle,coneOuterGain:typeof r.coneOuterGain<"u"?r.coneOuterGain:l.coneOuterGain,distanceModel:typeof r.distanceModel<"u"?r.distanceModel:l.distanceModel,maxDistance:typeof r.maxDistance<"u"?r.maxDistance:l.maxDistance,refDistance:typeof r.refDistance<"u"?r.refDistance:l.refDistance,rolloffFactor:typeof r.rolloffFactor<"u"?r.rolloffFactor:l.rolloffFactor,panningModel:typeof r.panningModel<"u"?r.panningModel:l.panningModel};var u=i._panner;u?(u.coneInnerAngle=l.coneInnerAngle,u.coneOuterAngle=l.coneOuterAngle,u.coneOuterGain=l.coneOuterGain,u.distanceModel=l.distanceModel,u.maxDistance=l.maxDistance,u.refDistance=l.refDistance,u.rolloffFactor=l.rolloffFactor,u.panningModel=l.panningModel):(i._pos||(i._pos=t._pos||[0,0,-.5]),n(i,"spatial"))}return t},Sound.prototype.init=function(t){return function(){var e=this,r=e._parent;e._orientation=r._orientation,e._stereo=r._stereo,e._pos=r._pos,e._pannerAttr=r._pannerAttr,t.call(this),e._stereo?r.stereo(e._stereo):e._pos&&r.pos(e._pos[0],e._pos[1],e._pos[2],e._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var e=this,r=e._parent;return e._orientation=r._orientation,e._stereo=r._stereo,e._pos=r._pos,e._pannerAttr=r._pannerAttr,e._stereo?r.stereo(e._stereo):e._pos?r.pos(e._pos[0],e._pos[1],e._pos[2],e._id):e._panner&&(e._panner.disconnect(0),e._panner=void 0,r._refreshBuffer(e)),t.call(this)}}(Sound.prototype.reset);var n=function(t,e){e=e||"spatial",e==="spatial"?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,typeof t._panner.positionX<"u"?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),typeof t._panner.orientationX<"u"?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}})()});var Rv=fr((Gte,Lv)=>{"use strict";function sI(n,t){function e(){this.constructor=n}e.prototype=t.prototype,n.prototype=new e}function Hi(n,t,e,r){this.message=n,this.expected=t,this.found=e,this.location=r,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Hi)}sI(Hi,Error);Hi.buildMessage=function(n,t){var e={literal:function(u){return'"'+o(u.text)+'"'},class:function(u){var c="",d;for(d=0;d<u.parts.length;d++)c+=u.parts[d]instanceof Array?i(u.parts[d][0])+"-"+i(u.parts[d][1]):i(u.parts[d]);return"["+(u.inverted?"^":"")+c+"]"},any:function(u){return"any character"},end:function(u){return"end of input"},other:function(u){return u.description}};function r(u){return u.charCodeAt(0).toString(16).toUpperCase()}function o(u){return u.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(c){return"\\x0"+r(c)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(c){return"\\x"+r(c)})}function i(u){return u.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(c){return"\\x0"+r(c)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(c){return"\\x"+r(c)})}function a(u){return e[u.type](u)}function s(u){var c=new Array(u.length),d,p;for(d=0;d<u.length;d++)c[d]=a(u[d]);if(c.sort(),c.length>0){for(d=1,p=1;d<c.length;d++)c[d-1]!==c[d]&&(c[p]=c[d],p++);c.length=p}switch(c.length){case 1:return c[0];case 2:return c[0]+" or "+c[1];default:return c.slice(0,-1).join(", ")+", or "+c[c.length-1]}}function l(u){return u?'"'+o(u)+'"':"end of input"}return"Expected "+s(n)+" but "+l(t)+" found."};function lI(n,t){t=t!==void 0?t:{};var e={},r={svg_path:ll},o=ll,i=function(v){if(!v)return[];for(var A=[],L=0;L<v.length;L++)A=A.concat.apply(A,v[L]);var M=A[0];return M&&M.code=="m"&&(delete M.relative,M.code="M"),A},a=function(v,A){return I1(v,A)},s=/^[Mm]/,l=at(["M","m"],!1,!1),u=function(v,A,L){var M=Zi(v,[A]);return L&&(M=M.concat(Zi(v=="M"?"L":"l",L[1]))),M},c=/^[Zz]/,d=at(["Z","z"],!1,!1),p=function(){return Zi("Z")},f=/^[Ll]/,h=at(["L","l"],!1,!1),m=function(v,A){return Zi(v,A)},y=/^[Hh]/,g=at(["H","h"],!1,!1),b=function(v,A){return Zi(v,A.map(function(L){return{x:L}}))},w=/^[Vv]/,_=at(["V","v"],!1,!1),S=function(v,A){return Zi(v,A.map(function(L){return{y:L}}))},P=/^[Cc]/,O=at(["C","c"],!1,!1),x=function(v,A,L){return{x1:v.x,y1:v.y,x2:A.x,y2:A.y,x:L.x,y:L.y}},D=/^[Ss]/,N=at(["S","s"],!1,!1),T=function(v,A){return{x2:v.x,y2:v.y,x:A.x,y:A.y}},I=/^[Qq]/,E=at(["Q","q"],!1,!1),B=function(v,A){return{x1:v.x,y1:v.y,x:A.x,y:A.y}},R=/^[Tt]/,k=at(["T","t"],!1,!1),V=/^[Aa]/,q=at(["A","a"],!1,!1),F=function(v,A,L,M,z,oe){return{rx:v,ry:A,xAxisRotation:L,largeArc:M,sweep:z,x:oe.x,y:oe.y}},U=function(v,A){return{x:v,y:A}},H=function(v){return v*1},$=function(v){return v.join("")*1},J=/^[01]/,K=at(["0","1"],!1,!1),X=function(v){return v=="1"},te=function(){return""},Y=",",ee=vt(",",!1),Q=function(v){return v.join("")},W=".",ue=vt(".",!1),le=/^[eE]/,ne=at(["e","E"],!1,!1),ce=/^[+\-]/,ae=at(["+","-"],!1,!1),me=/^[0-9]/,fe=at([["0","9"]],!1,!1),he=function(v){return v.join("")},xe=/^[ \t\n\r]/,ye=at([" "," ",`
2
+ `,"\r"],!1,!1),C=0,ie=0,Ve=[{line:1,column:1}],He=0,ze=[],Oe=0,jt;if("startRule"in t){if(!(t.startRule in r))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');o=r[t.startRule]}function Ee(){return n.substring(ie,C)}function zt(){return hi(ie,C)}function Ut(v,A){throw A=A!==void 0?A:hi(ie,C),Wr([rp(v)],n.substring(ie,C),A)}function fi(v,A){throw A=A!==void 0?A:hi(ie,C),op(v,A)}function vt(v,A){return{type:"literal",text:v,ignoreCase:A}}function at(v,A,L){return{type:"class",parts:v,inverted:A,ignoreCase:L}}function co(){return{type:"any"}}function tp(){return{type:"end"}}function rp(v){return{type:"other",description:v}}function bc(v){var A=Ve[v],L;if(A)return A;for(L=v-1;!Ve[L];)L--;for(A=Ve[L],A={line:A.line,column:A.column};L<v;)n.charCodeAt(L)===10?(A.line++,A.column=1):A.column++,L++;return Ve[v]=A,A}function hi(v,A){var L=bc(v),M=bc(A);return{start:{offset:v,line:L.line,column:L.column},end:{offset:A,line:M.line,column:M.column}}}function Tt(v){C<He||(C>He&&(He=C,ze=[]),ze.push(v))}function op(v,A){return new Hi(v,null,null,A)}function Wr(v,A,L){return new Hi(Hi.buildMessage(v,A),v,A,L)}function ll(){var v,A,L,M,z;for(v=C,A=[],L=qe();L!==e;)A.push(L),L=qe();if(A!==e)if(L=pr(),L===e&&(L=null),L!==e){for(M=[],z=qe();z!==e;)M.push(z),z=qe();M!==e?(ie=v,A=i(L),v=A):(C=v,v=e)}else C=v,v=e;else C=v,v=e;return v}function pr(){var v,A,L,M,z,oe;if(v=C,A=mi(),A!==e){for(L=[],M=C,z=[],oe=qe();oe!==e;)z.push(oe),oe=qe();for(z!==e?(oe=mi(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;){for(L.push(M),M=C,z=[],oe=qe();oe!==e;)z.push(oe),oe=qe();z!==e?(oe=mi(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e)}L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function mi(){var v,A,L,M,z,oe;if(v=C,A=Qi(),A!==e){for(L=[],M=C,z=[],oe=qe();oe!==e;)z.push(oe),oe=qe();for(z!==e?(oe=vc(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;){for(L.push(M),M=C,z=[],oe=qe();oe!==e;)z.push(oe),oe=qe();z!==e?(oe=vc(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e)}L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function vc(){var v;return v=m1(),v===e&&(v=y1(),v===e&&(v=g1(),v===e&&(v=x1(),v===e&&(v=b1(),v===e&&(v=S1(),v===e&&(v=A1(),v===e&&(v=P1(),v===e&&(v=C1())))))))),v}function Qi(){var v,A,L,M,z,oe,Ji;if(v=C,s.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,Oe===0&&Tt(l)),A!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=xr(),M!==e?(z=C,oe=yt(),oe===e&&(oe=null),oe!==e?(Ji=Uh(),Ji!==e?(oe=[oe,Ji],z=oe):(C=z,z=e)):(C=z,z=e),z===e&&(z=null),z!==e?(ie=v,A=u(A,M,z),v=A):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function m1(){var v,A;return v=C,c.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,Oe===0&&Tt(d)),A!==e&&(ie=v,A=p()),v=A,v}function y1(){var v,A,L,M;if(v=C,f.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,Oe===0&&Tt(h)),A!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=Uh(),M!==e?(ie=v,A=m(A,M),v=A):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function Uh(){var v,A,L,M,z,oe;if(v=C,A=xr(),A!==e){for(L=[],M=C,z=yt(),z===e&&(z=null),z!==e?(oe=xr(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=yt(),z===e&&(z=null),z!==e?(oe=xr(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function g1(){var v,A,L,M;if(v=C,y.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,Oe===0&&Tt(g)),A!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=Hh(),M!==e?(ie=v,A=b(A,M),v=A):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function Hh(){var v,A,L,M,z,oe;if(v=C,A=Ki(),A!==e){for(L=[],M=C,z=yt(),z===e&&(z=null),z!==e?(oe=Ki(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=yt(),z===e&&(z=null),z!==e?(oe=Ki(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function x1(){var v,A,L,M;if(v=C,w.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,Oe===0&&Tt(_)),A!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=Hh(),M!==e?(ie=v,A=S(A,M),v=A):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function b1(){var v,A,L,M;if(v=C,P.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,Oe===0&&Tt(O)),A!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=v1(),M!==e?(ie=v,A=m(A,M),v=A):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function v1(){var v,A,L,M,z,oe;if(v=C,A=np(),A!==e){for(L=[],M=C,z=yt(),z===e&&(z=null),z!==e?(oe=np(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=yt(),z===e&&(z=null),z!==e?(oe=np(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function np(){var v,A,L,M,z,oe;return v=C,A=xr(),A!==e?(L=yt(),L===e&&(L=null),L!==e?(M=xr(),M!==e?(z=yt(),z===e&&(z=null),z!==e?(oe=xr(),oe!==e?(ie=v,A=x(A,M,oe),v=A):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function S1(){var v,A,L,M;if(v=C,D.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,Oe===0&&Tt(N)),A!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=w1(),M!==e?(ie=v,A=m(A,M),v=A):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function w1(){var v,A,L,M,z,oe;if(v=C,A=ip(),A!==e){for(L=[],M=C,z=yt(),z===e&&(z=null),z!==e?(oe=ip(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=yt(),z===e&&(z=null),z!==e?(oe=ip(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function ip(){var v,A,L,M;return v=C,A=xr(),A!==e?(L=yt(),L===e&&(L=null),L!==e?(M=xr(),M!==e?(ie=v,A=T(A,M),v=A):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function A1(){var v,A,L,M;if(v=C,I.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,Oe===0&&Tt(E)),A!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=_1(),M!==e?(ie=v,A=m(A,M),v=A):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function _1(){var v,A,L,M,z,oe;if(v=C,A=ap(),A!==e){for(L=[],M=C,z=yt(),z===e&&(z=null),z!==e?(oe=ap(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=yt(),z===e&&(z=null),z!==e?(oe=ap(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function ap(){var v,A,L,M;return v=C,A=xr(),A!==e?(L=yt(),L===e&&(L=null),L!==e?(M=xr(),M!==e?(ie=v,A=B(A,M),v=A):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function P1(){var v,A,L,M;if(v=C,R.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,Oe===0&&Tt(k)),A!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=O1(),M!==e?(ie=v,A=m(A,M),v=A):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function O1(){var v,A,L,M,z,oe;if(v=C,A=xr(),A!==e){for(L=[],M=C,z=yt(),z===e&&(z=null),z!==e?(oe=xr(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=yt(),z===e&&(z=null),z!==e?(oe=xr(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function C1(){var v,A,L,M;if(v=C,V.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,Oe===0&&Tt(q)),A!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=T1(),M!==e?(ie=v,A=m(A,M),v=A):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function T1(){var v,A,L,M,z,oe;if(v=C,A=sp(),A!==e){for(L=[],M=C,z=yt(),z===e&&(z=null),z!==e?(oe=sp(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=yt(),z===e&&(z=null),z!==e?(oe=sp(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function sp(){var v,A,L,M,z,oe,Ji,cp,wc,up,Ac,dp;return v=C,A=qh(),A!==e?(L=yt(),L===e&&(L=null),L!==e?(M=qh(),M!==e?(z=yt(),z===e&&(z=null),z!==e?(oe=Ki(),oe!==e?(Ji=yt(),Ji!==e?(cp=Wh(),cp!==e?(wc=yt(),wc===e&&(wc=null),wc!==e?(up=Wh(),up!==e?(Ac=yt(),Ac===e&&(Ac=null),Ac!==e?(dp=xr(),dp!==e?(ie=v,A=F(A,M,oe,cp,up,dp),v=A):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function xr(){var v,A,L,M;return v=C,A=Ki(),A!==e?(L=yt(),L===e&&(L=null),L!==e?(M=Ki(),M!==e?(ie=v,A=U(A,M),v=A):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function qh(){var v,A;return v=C,A=Yh(),A===e&&(A=yi()),A!==e&&(ie=v,A=H(A)),v=A,v}function Ki(){var v,A,L,M;return v=C,A=C,L=lp(),L===e&&(L=null),L!==e?(M=Yh(),M!==e?(L=[L,M],A=L):(C=A,A=e)):(C=A,A=e),A===e&&(A=C,L=lp(),L===e&&(L=null),L!==e?(M=yi(),M!==e?(L=[L,M],A=L):(C=A,A=e)):(C=A,A=e)),A!==e&&(ie=v,A=$(A)),v=A,v}function Wh(){var v,A;return v=C,J.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,Oe===0&&Tt(K)),A!==e&&(ie=v,A=X(A)),v=A,v}function yt(){var v,A,L,M,z;if(v=C,A=[],L=qe(),L!==e)for(;L!==e;)A.push(L),L=qe();else A=e;if(A!==e)if(L=$h(),L===e&&(L=null),L!==e){for(M=[],z=qe();z!==e;)M.push(z),z=qe();M!==e?(A=[A,L,M],v=A):(C=v,v=e)}else C=v,v=e;else C=v,v=e;if(v===e){if(v=C,A=C,L=$h(),L!==e){for(M=[],z=qe();z!==e;)M.push(z),z=qe();M!==e?(L=[L,M],A=L):(C=A,A=e)}else C=A,A=e;A!==e&&(ie=v,A=te()),v=A}return v}function $h(){var v;return n.charCodeAt(C)===44?(v=Y,C++):(v=e,Oe===0&&Tt(ee)),v}function Yh(){var v,A,L,M;return v=C,A=C,L=M1(),L!==e?(M=Xh(),M===e&&(M=null),M!==e?(L=[L,M],A=L):(C=A,A=e)):(C=A,A=e),A===e&&(A=C,L=yi(),L!==e?(M=Xh(),M!==e?(L=[L,M],A=L):(C=A,A=e)):(C=A,A=e)),A!==e&&(ie=v,A=Q(A)),v=A,v}function M1(){var v,A,L,M,z;return v=C,A=C,L=yi(),L===e&&(L=null),L!==e?(n.charCodeAt(C)===46?(M=W,C++):(M=e,Oe===0&&Tt(ue)),M!==e?(z=yi(),z!==e?(L=[L,M,z],A=L):(C=A,A=e)):(C=A,A=e)):(C=A,A=e),A===e&&(A=C,L=yi(),L!==e?(n.charCodeAt(C)===46?(M=W,C++):(M=e,Oe===0&&Tt(ue)),M!==e?(L=[L,M],A=L):(C=A,A=e)):(C=A,A=e)),A!==e&&(ie=v,A=Q(A)),v=A,v}function Xh(){var v,A,L,M,z;return v=C,A=C,le.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Oe===0&&Tt(ne)),L!==e?(M=lp(),M===e&&(M=null),M!==e?(z=yi(),z!==e?(L=[L,M,z],A=L):(C=A,A=e)):(C=A,A=e)):(C=A,A=e),A!==e&&(ie=v,A=Q(A)),v=A,v}function lp(){var v;return ce.test(n.charAt(C))?(v=n.charAt(C),C++):(v=e,Oe===0&&Tt(ae)),v}function yi(){var v,A,L;if(v=C,A=[],me.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Oe===0&&Tt(fe)),L!==e)for(;L!==e;)A.push(L),me.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Oe===0&&Tt(fe));else A=e;return A!==e&&(ie=v,A=he(A)),v=A,v}function qe(){var v,A;return v=C,xe.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,Oe===0&&Tt(ye)),A!==e&&(ie=v,A=te()),v=A,v}function I1(v,A){if(!A)return[v];for(var L=[v],M=0,z=A.length;M<z;M++)L[M+1]=A[M][1];return L}var Sc={m:"moveto",l:"lineto",h:"horizontal lineto",v:"vertical lineto",c:"curveto",s:"smooth curveto",q:"quadratic curveto",t:"smooth quadratic curveto",a:"elliptical arc",z:"closepath"};for(var Qh in Sc)Sc[Qh.toUpperCase()]=Sc[Qh];function Zi(v,A){A||(A=[{}]);for(var L=A.length;L--;){var M={code:v,command:Sc[v]};v==v.toLowerCase()&&(M.relative=!0);for(var z in A[L])M[z]=A[L][z];A[L]=M}return A}if(jt=o(),jt!==e&&C===n.length)return jt;throw jt!==e&&C<n.length&&Tt(tp()),Wr(ze,He<n.length?n.charAt(He):null,He<n.length?hi(He,He+1):hi(He,He))}Lv.exports={SyntaxError:Hi,parse:lI}});var zv=fr((kte,Vv)=>{var zd=Rv().parse;zd.parseSVG=zd;zd.makeAbsolute=cI;Vv.exports=zd;function cI(n){var t,e={x:0,y:0},r={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return n.forEach(function(o){o.command==="moveto"&&(t=o),o.x0=e.x,o.y0=e.y;for(var i in r)i in o&&(o[i]+=o.relative?o[r[i]]:0);"x"in o||(o.x=e.x),"y"in o||(o.y=e.y),o.relative=!1,o.code=o.code.toUpperCase(),o.command=="closepath"&&(o.x=t.x,o.y=t.y),e=o}),n}});var wS=fr((pie,SS)=>{"use strict";function SI(n){for(var t=new Array(n),e=0;e<n;++e)t[e]=e;return t}SS.exports=SI});var PS=fr((fie,_S)=>{_S.exports=function(n){return n!=null&&(AS(n)||wI(n)||!!n._isBuffer)};function AS(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function wI(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&AS(n.slice(0,0))}});var al=fr((hie,OS)=>{var AI=wS(),_I=PS(),PI=typeof Float64Array<"u";function OI(n,t){return n[0]-t[0]}function CI(){var n=this.stride,t=new Array(n.length),e;for(e=0;e<t.length;++e)t[e]=[Math.abs(n[e]),e];t.sort(OI);var r=new Array(t.length);for(e=0;e<r.length;++e)r[e]=t[e][1];return r}function TI(n,t){var e=["View",t,"d",n].join("");t<0&&(e="View_Nil"+n);var r=n==="generic";if(t===-1){var o="function "+e+"(a){this.data=a;};var proto="+e+".prototype;proto.dtype='"+n+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+e+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+e+"(a){return new "+e+"(a);}",m=new Function(o);return m()}else if(t===0){var o="function "+e+"(a,d) {this.data = a;this.offset = d};var proto="+e+".prototype;proto.dtype='"+n+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+e+"_copy() {return new "+e+"(this.data,this.offset)};proto.pick=function "+e+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+e+"_get(){return "+(r?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+e+"_set(v){return "+(r?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+e+"(a,b,c,d){return new "+e+"(a,d)}",m=new Function("TrivialArray",o);return m(Yd[n][0])}var o=["'use strict'"],i=AI(t),a=i.map(function(y){return"i"+y}),s="this.offset+"+i.map(function(y){return"this.stride["+y+"]*i"+y}).join("+"),l=i.map(function(y){return"b"+y}).join(","),u=i.map(function(y){return"c"+y}).join(",");o.push("function "+e+"(a,"+l+","+u+",d){this.data=a","this.shape=["+l+"]","this.stride=["+u+"]","this.offset=d|0}","var proto="+e+".prototype","proto.dtype='"+n+"'","proto.dimension="+t),o.push("Object.defineProperty(proto,'size',{get:function "+e+"_size(){return "+i.map(function(y){return"this.shape["+y+"]"}).join("*"),"}})"),t===1?o.push("proto.order=[0]"):(o.push("Object.defineProperty(proto,'order',{get:"),t<4?(o.push("function "+e+"_order(){"),t===2?o.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):t===3&&o.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):o.push("ORDER})")),o.push("proto.set=function "+e+"_set("+a.join(",")+",v){"),r?o.push("return this.data.set("+s+",v)}"):o.push("return this.data["+s+"]=v}"),o.push("proto.get=function "+e+"_get("+a.join(",")+"){"),r?o.push("return this.data.get("+s+")}"):o.push("return this.data["+s+"]}"),o.push("proto.index=function "+e+"_index(",a.join(),"){return "+s+"}"),o.push("proto.hi=function "+e+"_hi("+a.join(",")+"){return new "+e+"(this.data,"+i.map(function(y){return["(typeof i",y,"!=='number'||i",y,"<0)?this.shape[",y,"]:i",y,"|0"].join("")}).join(",")+","+i.map(function(y){return"this.stride["+y+"]"}).join(",")+",this.offset)}");var c=i.map(function(y){return"a"+y+"=this.shape["+y+"]"}),d=i.map(function(y){return"c"+y+"=this.stride["+y+"]"});o.push("proto.lo=function "+e+"_lo("+a.join(",")+"){var b=this.offset,d=0,"+c.join(",")+","+d.join(","));for(var p=0;p<t;++p)o.push("if(typeof i"+p+"==='number'&&i"+p+">=0){d=i"+p+"|0;b+=c"+p+"*d;a"+p+"-=d}");o.push("return new "+e+"(this.data,"+i.map(function(y){return"a"+y}).join(",")+","+i.map(function(y){return"c"+y}).join(",")+",b)}"),o.push("proto.step=function "+e+"_step("+a.join(",")+"){var "+i.map(function(y){return"a"+y+"=this.shape["+y+"]"}).join(",")+","+i.map(function(y){return"b"+y+"=this.stride["+y+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var p=0;p<t;++p)o.push("if(typeof i"+p+"==='number'){d=i"+p+"|0;if(d<0){c+=b"+p+"*(a"+p+"-1);a"+p+"=ceil(-a"+p+"/d)}else{a"+p+"=ceil(a"+p+"/d)}b"+p+"*=d}");o.push("return new "+e+"(this.data,"+i.map(function(y){return"a"+y}).join(",")+","+i.map(function(y){return"b"+y}).join(",")+",c)}");for(var f=new Array(t),h=new Array(t),p=0;p<t;++p)f[p]="a[i"+p+"]",h[p]="b[i"+p+"]";o.push("proto.transpose=function "+e+"_transpose("+a+"){"+a.map(function(y,g){return y+"=("+y+"===undefined?"+g+":"+y+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+e+"(this.data,"+f.join(",")+","+h.join(",")+",this.offset)}"),o.push("proto.pick=function "+e+"_pick("+a+"){var a=[],b=[],c=this.offset");for(var p=0;p<t;++p)o.push("if(typeof i"+p+"==='number'&&i"+p+">=0){c=(c+this.stride["+p+"]*i"+p+")|0}else{a.push(this.shape["+p+"]);b.push(this.stride["+p+"])}");o.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),o.push("return function construct_"+e+"(data,shape,stride,offset){return new "+e+"(data,"+i.map(function(y){return"shape["+y+"]"}).join(",")+","+i.map(function(y){return"stride["+y+"]"}).join(",")+",offset)}");var m=new Function("CTOR_LIST","ORDER",o.join(`
3
+ `));return m(Yd[n],CI)}function MI(n){if(_I(n))return"buffer";if(PI)switch(Object.prototype.toString.call(n)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(n)?"array":"generic"}var Yd={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function II(n,t,e,r){if(n===void 0){var u=Yd.array[0];return u([])}else typeof n=="number"&&(n=[n]);t===void 0&&(t=[n.length]);var o=t.length;if(e===void 0){e=new Array(o);for(var i=o-1,a=1;i>=0;--i)e[i]=a,a*=t[i]}if(r===void 0){r=0;for(var i=0;i<o;++i)e[i]<0&&(r-=(t[i]-1)*e[i])}for(var s=MI(n),l=Yd[s];l.length<=o+1;)l.push(TI(s,l.length-1));var u=l[o+1];return u(n,t,e,r)}OS.exports=II});var TS=fr((mie,CS)=>{"use strict";function NI(n,t){for(var e=1,r=n.length,o=n[0],i=n[0],a=1;a<r;++a)if(i=o,o=n[a],t(o,i)){if(a===e){e++;continue}n[e++]=o}return n.length=e,n}function DI(n){for(var t=1,e=n.length,r=n[0],o=n[0],i=1;i<e;++i,o=r)if(o=r,r=n[i],r!==o){if(i===t){t++;continue}n[t++]=r}return n.length=t,n}function EI(n,t,e){return n.length===0?n:t?(e||n.sort(t),NI(n,t)):(e||n.sort(),DI(n))}CS.exports=EI});var NS=fr((yie,IS)=>{"use strict";var BI=TS();function MS(n,t,e){var r=n.length,o=t.arrayArgs.length,i=t.indexArgs.length>0,a=[],s=[],l=0,u=0,c,d;for(c=0;c<r;++c)s.push(["i",c,"=0"].join(""));for(d=0;d<o;++d)for(c=0;c<r;++c)u=l,l=n[c],c===0?s.push(["d",d,"s",c,"=t",d,"p",l].join("")):s.push(["d",d,"s",c,"=(t",d,"p",l,"-s",u,"*t",d,"p",u,")"].join(""));for(s.length>0&&a.push("var "+s.join(",")),c=r-1;c>=0;--c)l=n[c],a.push(["for(i",c,"=0;i",c,"<s",l,";++i",c,"){"].join(""));for(a.push(e),c=0;c<r;++c){for(u=l,l=n[c],d=0;d<o;++d)a.push(["p",d,"+=d",d,"s",c].join(""));i&&(c>0&&a.push(["index[",u,"]-=s",u].join("")),a.push(["++index[",l,"]"].join(""))),a.push("}")}return a.join(`
4
+ `)}function LI(n,t,e,r){for(var o=t.length,i=e.arrayArgs.length,a=e.blockSize,s=e.indexArgs.length>0,l=[],u=0;u<i;++u)l.push(["var offset",u,"=p",u].join(""));for(var u=n;u<o;++u)l.push(["for(var j"+u+"=SS[",t[u],"]|0;j",u,">0;){"].join("")),l.push(["if(j",u,"<",a,"){"].join("")),l.push(["s",t[u],"=j",u].join("")),l.push(["j",u,"=0"].join("")),l.push(["}else{s",t[u],"=",a].join("")),l.push(["j",u,"-=",a,"}"].join("")),s&&l.push(["index[",t[u],"]=j",u].join(""));for(var u=0;u<i;++u){for(var c=["offset"+u],d=n;d<o;++d)c.push(["j",d,"*t",u,"p",t[d]].join(""));l.push(["p",u,"=(",c.join("+"),")"].join(""))}l.push(MS(t,e,r));for(var u=n;u<o;++u)l.push("}");return l.join(`
5
+ `)}function RI(n){for(var t=0,e=n[0].length;t<e;){for(var r=1;r<n.length;++r)if(n[r][t]!==n[0][t])return t;++t}return t}function Lh(n,t,e){for(var r=n.body,o=[],i=[],a=0;a<n.args.length;++a){var s=n.args[a];if(!(s.count<=0)){var l=new RegExp(s.name,"g"),u="",c=t.arrayArgs.indexOf(a);switch(t.argTypes[a]){case"offset":var d=t.offsetArgIndex.indexOf(a),p=t.offsetArgs[d];c=p.array,u="+q"+d;case"array":u="p"+c+u;var f="l"+a,h="a"+c;if(t.arrayBlockIndices[c]===0)s.count===1?e[c]==="generic"?s.lvalue?(o.push(["var ",f,"=",h,".get(",u,")"].join("")),r=r.replace(l,f),i.push([h,".set(",u,",",f,")"].join(""))):r=r.replace(l,[h,".get(",u,")"].join("")):r=r.replace(l,[h,"[",u,"]"].join("")):e[c]==="generic"?(o.push(["var ",f,"=",h,".get(",u,")"].join("")),r=r.replace(l,f),s.lvalue&&i.push([h,".set(",u,",",f,")"].join(""))):(o.push(["var ",f,"=",h,"[",u,"]"].join("")),r=r.replace(l,f),s.lvalue&&i.push([h,"[",u,"]=",f].join("")));else{for(var m=[s.name],y=[u],g=0;g<Math.abs(t.arrayBlockIndices[c]);g++)m.push("\\s*\\[([^\\]]+)\\]"),y.push("$"+(g+1)+"*t"+c+"b"+g);if(l=new RegExp(m.join(""),"g"),u=y.join("+"),e[c]==="generic")throw new Error("cwise: Generic arrays not supported in combination with blocks!");r=r.replace(l,[h,"[",u,"]"].join(""))}break;case"scalar":r=r.replace(l,"Y"+t.scalarArgs.indexOf(a));break;case"index":r=r.replace(l,"index");break;case"shape":r=r.replace(l,"shape");break}}}return[o.join(`
5
6
  `),r,i.join(`
6
7
  `)].join(`
7
- `).trim()}function NM(n){for(var t=new Array(n.length),e=!0,r=0;r<n.length;++r){var o=n[r],i=o.match(/\d+/);i?i=i[0]:i="",o.charAt(0)===0?t[r]="u"+o.charAt(1)+i:t[r]=o.charAt(0)+i,r>0&&(e=e&&t[r]===t[r-1])}return e?t[0]:t.join("")}function DM(n,t){for(var e=t[1].length-Math.abs(n.arrayBlockIndices[0])|0,r=new Array(n.arrayArgs.length),o=new Array(n.arrayArgs.length),i=0;i<n.arrayArgs.length;++i)o[i]=t[2*i],r[i]=t[2*i+1];for(var a=[],s=[],l=[],u=[],c=[],i=0;i<n.arrayArgs.length;++i){n.arrayBlockIndices[i]<0?(l.push(0),u.push(e),a.push(e),s.push(e+n.arrayBlockIndices[i])):(l.push(n.arrayBlockIndices[i]),u.push(n.arrayBlockIndices[i]+e),a.push(0),s.push(n.arrayBlockIndices[i]));for(var d=[],p=0;p<r[i].length;p++)l[i]<=r[i][p]&&r[i][p]<u[i]&&d.push(r[i][p]-l[i]);c.push(d)}for(var f=["SS"],h=["'use strict'"],m=[],p=0;p<e;++p)m.push(["s",p,"=SS[",p,"]"].join(""));for(var i=0;i<n.arrayArgs.length;++i){f.push("a"+i),f.push("t"+i),f.push("p"+i);for(var p=0;p<e;++p)m.push(["t",i,"p",p,"=t",i,"[",l[i]+p,"]"].join(""));for(var p=0;p<Math.abs(n.arrayBlockIndices[i]);++p)m.push(["t",i,"b",p,"=t",i,"[",a[i]+p,"]"].join(""))}for(var i=0;i<n.scalarArgs.length;++i)f.push("Y"+i);if(n.shapeArgs.length>0&&m.push("shape=SS.slice(0)"),n.indexArgs.length>0){for(var y=new Array(e),i=0;i<e;++i)y[i]="0";m.push(["index=[",y.join(","),"]"].join(""))}for(var i=0;i<n.offsetArgs.length;++i){for(var g=n.offsetArgs[i],b=[],p=0;p<g.offset.length;++p)g.offset[p]!==0&&(g.offset[p]===1?b.push(["t",g.array,"p",p].join("")):b.push([g.offset[p],"*t",g.array,"p",p].join("")));b.length===0?m.push("q"+i+"=0"):m.push(["q",i,"=",b.join("+")].join(""))}var S=TM([].concat(n.pre.thisVars).concat(n.body.thisVars).concat(n.post.thisVars));m=m.concat(S),m.length>0&&h.push("var "+m.join(","));for(var i=0;i<n.arrayArgs.length;++i)h.push("p"+i+"|=0");n.pre.body.length>3&&h.push(Jf(n.pre,n,o));var w=Jf(n.body,n,o),v=IM(c);v<e?h.push(MM(v,c[0],n,w)):h.push(Rv(c[0],n,w)),n.post.body.length>3&&h.push(Jf(n.post,n,o)),n.debug&&console.log("-----Generated cwise routine for ",t,`:
8
+ `).trim()}function VI(n){for(var t=new Array(n.length),e=!0,r=0;r<n.length;++r){var o=n[r],i=o.match(/\d+/);i?i=i[0]:i="",o.charAt(0)===0?t[r]="u"+o.charAt(1)+i:t[r]=o.charAt(0)+i,r>0&&(e=e&&t[r]===t[r-1])}return e?t[0]:t.join("")}function zI(n,t){for(var e=t[1].length-Math.abs(n.arrayBlockIndices[0])|0,r=new Array(n.arrayArgs.length),o=new Array(n.arrayArgs.length),i=0;i<n.arrayArgs.length;++i)o[i]=t[2*i],r[i]=t[2*i+1];for(var a=[],s=[],l=[],u=[],c=[],i=0;i<n.arrayArgs.length;++i){n.arrayBlockIndices[i]<0?(l.push(0),u.push(e),a.push(e),s.push(e+n.arrayBlockIndices[i])):(l.push(n.arrayBlockIndices[i]),u.push(n.arrayBlockIndices[i]+e),a.push(0),s.push(n.arrayBlockIndices[i]));for(var d=[],p=0;p<r[i].length;p++)l[i]<=r[i][p]&&r[i][p]<u[i]&&d.push(r[i][p]-l[i]);c.push(d)}for(var f=["SS"],h=["'use strict'"],m=[],p=0;p<e;++p)m.push(["s",p,"=SS[",p,"]"].join(""));for(var i=0;i<n.arrayArgs.length;++i){f.push("a"+i),f.push("t"+i),f.push("p"+i);for(var p=0;p<e;++p)m.push(["t",i,"p",p,"=t",i,"[",l[i]+p,"]"].join(""));for(var p=0;p<Math.abs(n.arrayBlockIndices[i]);++p)m.push(["t",i,"b",p,"=t",i,"[",a[i]+p,"]"].join(""))}for(var i=0;i<n.scalarArgs.length;++i)f.push("Y"+i);if(n.shapeArgs.length>0&&m.push("shape=SS.slice(0)"),n.indexArgs.length>0){for(var y=new Array(e),i=0;i<e;++i)y[i]="0";m.push(["index=[",y.join(","),"]"].join(""))}for(var i=0;i<n.offsetArgs.length;++i){for(var g=n.offsetArgs[i],b=[],p=0;p<g.offset.length;++p)g.offset[p]!==0&&(g.offset[p]===1?b.push(["t",g.array,"p",p].join("")):b.push([g.offset[p],"*t",g.array,"p",p].join("")));b.length===0?m.push("q"+i+"=0"):m.push(["q",i,"=",b.join("+")].join(""))}var w=BI([].concat(n.pre.thisVars).concat(n.body.thisVars).concat(n.post.thisVars));m=m.concat(w),m.length>0&&h.push("var "+m.join(","));for(var i=0;i<n.arrayArgs.length;++i)h.push("p"+i+"|=0");n.pre.body.length>3&&h.push(Lh(n.pre,n,o));var _=Lh(n.body,n,o),S=RI(c);S<e?h.push(LI(S,c[0],n,_)):h.push(MS(c[0],n,_)),n.post.body.length>3&&h.push(Lh(n.post,n,o)),n.debug&&console.log("-----Generated cwise routine for ",t,`:
8
9
  `+h.join(`
9
10
  `)+`
10
- ----------`);var _=[n.funcName||"unnamed","_cwise_loop_",r[0].join("s"),"m",v,NM(o)].join(""),A=new Function(["function ",_,"(",f.join(","),"){",h.join(`
11
- `),"} return ",_].join(""));return A()}Vv.exports=DM});var kv=fr((Woe,Gv)=>{"use strict";var EM=zv();function BM(n){var t=["'use strict'","var CACHED={}"],e=[],r=n.funcName+"_cwise_thunk";t.push(["return function ",r,"(",n.shimArgs.join(","),"){"].join(""));for(var o=[],i=[],a=[["array",n.arrayArgs[0],".shape.slice(",Math.max(0,n.arrayBlockIndices[0]),n.arrayBlockIndices[0]<0?","+n.arrayBlockIndices[0]+")":")"].join("")],s=[],l=[],u=0;u<n.arrayArgs.length;++u){var c=n.arrayArgs[u];e.push(["t",c,"=array",c,".dtype,","r",c,"=array",c,".order"].join("")),o.push("t"+c),o.push("r"+c),i.push("t"+c),i.push("r"+c+".join()"),a.push("array"+c+".data"),a.push("array"+c+".stride"),a.push("array"+c+".offset|0"),u>0&&(s.push("array"+n.arrayArgs[0]+".shape.length===array"+c+".shape.length+"+(Math.abs(n.arrayBlockIndices[0])-Math.abs(n.arrayBlockIndices[u]))),l.push("array"+n.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,n.arrayBlockIndices[0])+"]===array"+c+".shape[shapeIndex+"+Math.max(0,n.arrayBlockIndices[u])+"]"))}n.arrayArgs.length>1&&(t.push("if (!("+s.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),t.push("for(var shapeIndex=array"+n.arrayArgs[0]+".shape.length-"+Math.abs(n.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),t.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),t.push("}"));for(var u=0;u<n.scalarArgs.length;++u)a.push("scalar"+n.scalarArgs[u]);e.push(["type=[",i.join(","),"].join()"].join("")),e.push("proc=CACHED[type]"),t.push("var "+e.join(",")),t.push(["if(!proc){","CACHED[type]=proc=compile([",o.join(","),"])}","return proc(",a.join(","),")}"].join("")),n.debug&&console.log(`-----Generated thunk:
11
+ ----------`);var P=[n.funcName||"unnamed","_cwise_loop_",r[0].join("s"),"m",S,VI(o)].join(""),O=new Function(["function ",P,"(",f.join(","),"){",h.join(`
12
+ `),"} return ",P].join(""));return O()}IS.exports=zI});var ES=fr((gie,DS)=>{"use strict";var GI=NS();function kI(n){var t=["'use strict'","var CACHED={}"],e=[],r=n.funcName+"_cwise_thunk";t.push(["return function ",r,"(",n.shimArgs.join(","),"){"].join(""));for(var o=[],i=[],a=[["array",n.arrayArgs[0],".shape.slice(",Math.max(0,n.arrayBlockIndices[0]),n.arrayBlockIndices[0]<0?","+n.arrayBlockIndices[0]+")":")"].join("")],s=[],l=[],u=0;u<n.arrayArgs.length;++u){var c=n.arrayArgs[u];e.push(["t",c,"=array",c,".dtype,","r",c,"=array",c,".order"].join("")),o.push("t"+c),o.push("r"+c),i.push("t"+c),i.push("r"+c+".join()"),a.push("array"+c+".data"),a.push("array"+c+".stride"),a.push("array"+c+".offset|0"),u>0&&(s.push("array"+n.arrayArgs[0]+".shape.length===array"+c+".shape.length+"+(Math.abs(n.arrayBlockIndices[0])-Math.abs(n.arrayBlockIndices[u]))),l.push("array"+n.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,n.arrayBlockIndices[0])+"]===array"+c+".shape[shapeIndex+"+Math.max(0,n.arrayBlockIndices[u])+"]"))}n.arrayArgs.length>1&&(t.push("if (!("+s.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),t.push("for(var shapeIndex=array"+n.arrayArgs[0]+".shape.length-"+Math.abs(n.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),t.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),t.push("}"));for(var u=0;u<n.scalarArgs.length;++u)a.push("scalar"+n.scalarArgs[u]);e.push(["type=[",i.join(","),"].join()"].join("")),e.push("proc=CACHED[type]"),t.push("var "+e.join(",")),t.push(["if(!proc){","CACHED[type]=proc=compile([",o.join(","),"])}","return proc(",a.join(","),")}"].join("")),n.debug&&console.log(`-----Generated thunk:
12
13
  `+t.join(`
13
14
  `)+`
14
15
  ----------`);var d=new Function("compile",t.join(`
15
- `));return d(EM.bind(void 0,n))}Gv.exports=BM});var jv=fr(($oe,Fv)=>{"use strict";var LM=kv();function RM(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function VM(n){var t=new RM;t.pre=n.pre,t.body=n.body,t.post=n.post;var e=n.args.slice(0);t.argTypes=e;for(var r=0;r<e.length;++r){var o=e[r];if(o==="array"||typeof o=="object"&&o.blockIndices){if(t.argTypes[r]="array",t.arrayArgs.push(r),t.arrayBlockIndices.push(o.blockIndices?o.blockIndices:0),t.shimArgs.push("array"+r),r<t.pre.args.length&&t.pre.args[r].count>0)throw new Error("cwise: pre() block may not reference array args");if(r<t.post.args.length&&t.post.args[r].count>0)throw new Error("cwise: post() block may not reference array args")}else if(o==="scalar")t.scalarArgs.push(r),t.shimArgs.push("scalar"+r);else if(o==="index"){if(t.indexArgs.push(r),r<t.pre.args.length&&t.pre.args[r].count>0)throw new Error("cwise: pre() block may not reference array index");if(r<t.body.args.length&&t.body.args[r].lvalue)throw new Error("cwise: body() block may not write to array index");if(r<t.post.args.length&&t.post.args[r].count>0)throw new Error("cwise: post() block may not reference array index")}else if(o==="shape"){if(t.shapeArgs.push(r),r<t.pre.args.length&&t.pre.args[r].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(r<t.body.args.length&&t.body.args[r].lvalue)throw new Error("cwise: body() block may not write to array shape");if(r<t.post.args.length&&t.post.args[r].lvalue)throw new Error("cwise: post() block may not write to array shape")}else if(typeof o=="object"&&o.offset)t.argTypes[r]="offset",t.offsetArgs.push({array:o.array,offset:o.offset}),t.offsetArgIndex.push(r);else throw new Error("cwise: Unknown argument type "+e[r])}if(t.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(t.pre.args.length>e.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>e.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>e.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!n.printCode||!!n.debug,t.funcName=n.funcName||"cwise",t.blockSize=n.blockSize||64,LM(t)}Fv.exports=VM});var ks=fr(Ee=>{"use strict";var Ar=jv(),Ad={body:"",args:[],thisVars:[],localVars:[]};function eh(n){if(!n)return Ad;for(var t=0;t<n.args.length;++t){var e=n.args[t];t===0?n.args[t]={name:e,lvalue:!0,rvalue:!!n.rvalue,count:n.count||1}:n.args[t]={name:e,lvalue:!1,rvalue:!0,count:1}}return n.thisVars||(n.thisVars=[]),n.localVars||(n.localVars=[]),n}function zM(n){return Ar({args:n.args,pre:eh(n.pre),body:eh(n.body),post:eh(n.proc),funcName:n.funcName})}function gt(n){for(var t=[],e=0;e<n.args.length;++e)t.push("a"+e);var r=new Function("P",["return function ",n.funcName,"_ndarrayops(",t.join(","),") {P(",t.join(","),");return a0}"].join(""));return r(zM(n))}var Uv={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var n in Uv){var t=Uv[n];Ee[n]=gt({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:n}),Ee[n+"eq"]=gt({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:n+"eq"}),Ee[n+"s"]=gt({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:n+"s"}),Ee[n+"seq"]=gt({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:n+"seq"})}})();var Hv={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var n in Hv){var t=Hv[n];Ee[n]=gt({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:n}),Ee[n+"eq"]=gt({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:n+"eq"})}})();var qv={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var n in qv){var t=qv[n];Ee[n]=gt({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:n}),Ee[n+"s"]=gt({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:n+"s"}),Ee[n+"eq"]=gt({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:n+"eq"}),Ee[n+"seq"]=gt({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:n+"seq"})}})();var Wv=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var n=0;n<Wv.length;++n){var t=Wv[n];Ee[t]=gt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:t}),Ee[t+"eq"]=gt({args:["array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"})}})();var $v=["max","min","atan2","pow"];(function(){for(var n=0;n<$v.length;++n){var t=$v[n];Ee[t]=gt({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t}),Ee[t+"s"]=gt({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t+"s"}),Ee[t+"eq"]=gt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"}),Ee[t+"seq"]=gt({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"seq"})}})();var Yv=["atan2","pow"];(function(){for(var n=0;n<Yv.length;++n){var t=Yv[n];Ee[t+"op"]=gt({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"op"}),Ee[t+"ops"]=gt({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"ops"}),Ee[t+"opeq"]=gt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opeq"}),Ee[t+"opseq"]=gt({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opseq"})}})();Ee.any=Ar({args:["array"],pre:Ad,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"});Ee.all=Ar({args:["array"],pre:Ad,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"});Ee.sum=Ar({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"});Ee.prod=Ar({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"});Ee.norm2squared=Ar({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"});Ee.norm2=Ar({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"});Ee.norminf=Ar({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});Ee.norm1=Ar({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});Ee.sup=Ar({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});Ee.inf=Ar({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});Ee.argmin=Ar({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});Ee.argmax=Ar({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});Ee.random=gt({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});Ee.assign=gt({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});Ee.assigns=gt({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});Ee.equals=Ar({args:["array","array"],pre:Ad,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})});var xS=fr((_ae,gS)=>{gS.exports=function(t,e){for(var r=t.split("."),o=e.split("."),i=0;i<3;i++){var a=Number(r[i]),s=Number(o[i]);if(a>s)return 1;if(s>a)return-1;if(!isNaN(a)&&isNaN(s))return 1;if(isNaN(a)&&!isNaN(s))return-1}return 0}});var QM={};lh(QM,{default:()=>Td});module.exports=LS(QM);var Md=require("three");function Jl(n){for(let t of Object.keys(n))n[t]===void 0&&delete n[t];return n}function ir(n,t){return Object.setPrototypeOf(n,t),n}function ec(n){return Array.isArray(n)?n:[n]}function tc(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var RS=typeof global=="object"&&global&&global.Object===Object&&global,rc=RS;var VS=typeof self=="object"&&self&&self.Object===Object&&self,zS=rc||VS||Function("return this")(),Tt=zS;var GS=Tt.Symbol,kt=GS;var uh=Object.prototype,kS=uh.hasOwnProperty,FS=uh.toString,js=kt?kt.toStringTag:void 0;function jS(n){var t=kS.call(n,js),e=n[js];try{n[js]=void 0;var r=!0}catch{}var o=FS.call(n);return r&&(t?n[js]=e:delete n[js]),o}var dh=jS;var US=Object.prototype,HS=US.toString;function qS(n){return HS.call(n)}var ph=qS;var WS="[object Null]",$S="[object Undefined]",fh=kt?kt.toStringTag:void 0;function YS(n){return n==null?n===void 0?$S:WS:fh&&fh in Object(n)?dh(n):ph(n)}var Cr=YS;function XS(n){return n!=null&&typeof n=="object"}var Xt=XS;var QS="[object Symbol]";function KS(n){return typeof n=="symbol"||Xt(n)&&Cr(n)==QS}var Ri=KS;function ZS(n,t){for(var e=-1,r=n==null?0:n.length,o=Array(r);++e<r;)o[e]=t(n[e],e,n);return o}var oc=ZS;var JS=Array.isArray,xt=JS;var e1=1/0,hh=kt?kt.prototype:void 0,mh=hh?hh.toString:void 0;function yh(n){if(typeof n=="string")return n;if(xt(n))return oc(n,yh)+"";if(Ri(n))return mh?mh.call(n):"";var t=n+"";return t=="0"&&1/n==-e1?"-0":t}var gh=yh;function t1(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var Tr=t1;function r1(n){return n}var xh=r1;var o1="[object AsyncFunction]",n1="[object Function]",i1="[object GeneratorFunction]",a1="[object Proxy]";function s1(n){if(!Tr(n))return!1;var t=Cr(n);return t==n1||t==i1||t==o1||t==a1}var nc=s1;var l1=Tt["__core-js_shared__"],ic=l1;var bh=function(){var n=/[^.]+$/.exec(ic&&ic.keys&&ic.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function c1(n){return!!bh&&bh in n}var vh=c1;var u1=Function.prototype,d1=u1.toString;function p1(n){if(n!=null){try{return d1.call(n)}catch{}try{return n+""}catch{}}return""}var Uo=p1;var f1=/[\\^$.*+?()[\]{}|]/g,h1=/^\[object .+?Constructor\]$/,m1=Function.prototype,y1=Object.prototype,g1=m1.toString,x1=y1.hasOwnProperty,b1=RegExp("^"+g1.call(x1).replace(f1,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function v1(n){if(!Tr(n)||vh(n))return!1;var t=nc(n)?b1:h1;return t.test(Uo(n))}var Sh=v1;function S1(n,t){return n?.[t]}var wh=S1;function w1(n,t){var e=wh(n,t);return Sh(e)?e:void 0}var hr=w1;var _1=hr(Tt,"WeakMap"),ac=_1;var _h=Object.create,A1=function(){function n(){}return function(t){if(!Tr(t))return{};if(_h)return _h(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),Ah=A1;function P1(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var Ph=P1;function O1(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}var Oh=O1;var C1=800,T1=16,M1=Date.now;function I1(n){var t=0,e=0;return function(){var r=M1(),o=T1-(r-e);if(e=r,o>0){if(++t>=C1)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var Ch=I1;function N1(n){return function(){return n}}var Th=N1;var D1=function(){try{var n=hr(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Vi=D1;var E1=Vi?function(n,t){return Vi(n,"toString",{configurable:!0,enumerable:!1,value:Th(t),writable:!0})}:xh,Mh=E1;var B1=Ch(Mh),Ih=B1;function L1(n,t){for(var e=-1,r=n==null?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}var Nh=L1;var R1=9007199254740991,V1=/^(?:0|[1-9]\d*)$/;function z1(n,t){var e=typeof n;return t=t??R1,!!t&&(e=="number"||e!="symbol"&&V1.test(n))&&n>-1&&n%1==0&&n<t}var zi=z1;function G1(n,t,e){t=="__proto__"&&Vi?Vi(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}var sc=G1;function k1(n,t){return n===t||n!==n&&t!==t}var Gi=k1;var F1=Object.prototype,j1=F1.hasOwnProperty;function U1(n,t,e){var r=n[t];(!(j1.call(n,t)&&Gi(r,e))||e===void 0&&!(t in n))&&sc(n,t,e)}var ki=U1;function H1(n,t,e,r){var o=!e;e||(e={});for(var i=-1,a=t.length;++i<a;){var s=t[i],l=r?r(e[s],n[s],s,e,n):void 0;l===void 0&&(l=n[s]),o?sc(e,s,l):ki(e,s,l)}return e}var go=H1;var Dh=Math.max;function q1(n,t,e){return t=Dh(t===void 0?n.length-1:t,0),function(){for(var r=arguments,o=-1,i=Dh(r.length-t,0),a=Array(i);++o<i;)a[o]=r[t+o];o=-1;for(var s=Array(t+1);++o<t;)s[o]=r[o];return s[t]=e(a),Ph(n,this,s)}}var Eh=q1;var W1=9007199254740991;function $1(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=W1}var Fi=$1;function Y1(n){return n!=null&&Fi(n.length)&&!nc(n)}var lc=Y1;var X1=Object.prototype;function Q1(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||X1;return n===e}var ji=Q1;function K1(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var Bh=K1;var Z1="[object Arguments]";function J1(n){return Xt(n)&&Cr(n)==Z1}var Nd=J1;var Lh=Object.prototype,ew=Lh.hasOwnProperty,tw=Lh.propertyIsEnumerable,rw=Nd(function(){return arguments}())?Nd:function(n){return Xt(n)&&ew.call(n,"callee")&&!tw.call(n,"callee")},Ui=rw;function ow(){return!1}var Rh=ow;var Gh=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vh=Gh&&typeof module=="object"&&module&&!module.nodeType&&module,nw=Vh&&Vh.exports===Gh,zh=nw?Tt.Buffer:void 0,iw=zh?zh.isBuffer:void 0,aw=iw||Rh,oi=aw;var sw="[object Arguments]",lw="[object Array]",cw="[object Boolean]",uw="[object Date]",dw="[object Error]",pw="[object Function]",fw="[object Map]",hw="[object Number]",mw="[object Object]",yw="[object RegExp]",gw="[object Set]",xw="[object String]",bw="[object WeakMap]",vw="[object ArrayBuffer]",Sw="[object DataView]",ww="[object Float32Array]",_w="[object Float64Array]",Aw="[object Int8Array]",Pw="[object Int16Array]",Ow="[object Int32Array]",Cw="[object Uint8Array]",Tw="[object Uint8ClampedArray]",Mw="[object Uint16Array]",Iw="[object Uint32Array]",lt={};lt[ww]=lt[_w]=lt[Aw]=lt[Pw]=lt[Ow]=lt[Cw]=lt[Tw]=lt[Mw]=lt[Iw]=!0;lt[sw]=lt[lw]=lt[vw]=lt[cw]=lt[Sw]=lt[uw]=lt[dw]=lt[pw]=lt[fw]=lt[hw]=lt[mw]=lt[yw]=lt[gw]=lt[xw]=lt[bw]=!1;function Nw(n){return Xt(n)&&Fi(n.length)&&!!lt[Cr(n)]}var kh=Nw;function Dw(n){return function(t){return n(t)}}var Hi=Dw;var Fh=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Us=Fh&&typeof module=="object"&&module&&!module.nodeType&&module,Ew=Us&&Us.exports===Fh,Dd=Ew&&rc.process,Bw=function(){try{var n=Us&&Us.require&&Us.require("util").types;return n||Dd&&Dd.binding&&Dd.binding("util")}catch{}}(),Ho=Bw;var jh=Ho&&Ho.isTypedArray,Lw=jh?Hi(jh):kh,cc=Lw;var Rw=Object.prototype,Vw=Rw.hasOwnProperty;function zw(n,t){var e=xt(n),r=!e&&Ui(n),o=!e&&!r&&oi(n),i=!e&&!r&&!o&&cc(n),a=e||r||o||i,s=a?Bh(n.length,String):[],l=s.length;for(var u in n)(t||Vw.call(n,u))&&!(a&&(u=="length"||o&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||zi(u,l)))&&s.push(u);return s}var uc=zw;function Gw(n,t){return function(e){return n(t(e))}}var dc=Gw;var kw=dc(Object.keys,Object),Uh=kw;var Fw=Object.prototype,jw=Fw.hasOwnProperty;function Uw(n){if(!ji(n))return Uh(n);var t=[];for(var e in Object(n))jw.call(n,e)&&e!="constructor"&&t.push(e);return t}var Hh=Uw;function Hw(n){return lc(n)?uc(n):Hh(n)}var qi=Hw;function qw(n){var t=[];if(n!=null)for(var e in Object(n))t.push(e);return t}var qh=qw;var Ww=Object.prototype,$w=Ww.hasOwnProperty;function Yw(n){if(!Tr(n))return qh(n);var t=ji(n),e=[];for(var r in n)r=="constructor"&&(t||!$w.call(n,r))||e.push(r);return e}var Wh=Yw;function Xw(n){return lc(n)?uc(n,!0):Wh(n)}var Wi=Xw;var Qw=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Kw=/^\w*$/;function Zw(n,t){if(xt(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||Ri(n)?!0:Kw.test(n)||!Qw.test(n)||t!=null&&n in Object(t)}var $h=Zw;var Jw=hr(Object,"create"),qo=Jw;function e2(){this.__data__=qo?qo(null):{},this.size=0}var Yh=e2;function t2(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var Xh=t2;var r2="__lodash_hash_undefined__",o2=Object.prototype,n2=o2.hasOwnProperty;function i2(n){var t=this.__data__;if(qo){var e=t[n];return e===r2?void 0:e}return n2.call(t,n)?t[n]:void 0}var Qh=i2;var a2=Object.prototype,s2=a2.hasOwnProperty;function l2(n){var t=this.__data__;return qo?t[n]!==void 0:s2.call(t,n)}var Kh=l2;var c2="__lodash_hash_undefined__";function u2(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=qo&&t===void 0?c2:t,this}var Zh=u2;function $i(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}$i.prototype.clear=Yh;$i.prototype.delete=Xh;$i.prototype.get=Qh;$i.prototype.has=Kh;$i.prototype.set=Zh;var Ed=$i;function d2(){this.__data__=[],this.size=0}var Jh=d2;function p2(n,t){for(var e=n.length;e--;)if(Gi(n[e][0],t))return e;return-1}var gn=p2;var f2=Array.prototype,h2=f2.splice;function m2(n){var t=this.__data__,e=gn(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():h2.call(t,e,1),--this.size,!0}var em=m2;function y2(n){var t=this.__data__,e=gn(t,n);return e<0?void 0:t[e][1]}var tm=y2;function g2(n){return gn(this.__data__,n)>-1}var rm=g2;function x2(n,t){var e=this.__data__,r=gn(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var om=x2;function Yi(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Yi.prototype.clear=Jh;Yi.prototype.delete=em;Yi.prototype.get=tm;Yi.prototype.has=rm;Yi.prototype.set=om;var xn=Yi;var b2=hr(Tt,"Map"),bn=b2;function v2(){this.size=0,this.__data__={hash:new Ed,map:new(bn||xn),string:new Ed}}var nm=v2;function S2(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var im=S2;function w2(n,t){var e=n.__data__;return im(t)?e[typeof t=="string"?"string":"hash"]:e.map}var vn=w2;function _2(n){var t=vn(this,n).delete(n);return this.size-=t?1:0,t}var am=_2;function A2(n){return vn(this,n).get(n)}var sm=A2;function P2(n){return vn(this,n).has(n)}var lm=P2;function O2(n,t){var e=vn(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var cm=O2;function Xi(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Xi.prototype.clear=nm;Xi.prototype.delete=am;Xi.prototype.get=sm;Xi.prototype.has=lm;Xi.prototype.set=cm;var ni=Xi;var C2="Expected a function";function Bd(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(C2);var e=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=e.cache;if(i.has(o))return i.get(o);var a=n.apply(this,r);return e.cache=i.set(o,a)||i,a};return e.cache=new(Bd.Cache||ni),e}Bd.Cache=ni;var um=Bd;var T2=500;function M2(n){var t=um(n,function(r){return e.size===T2&&e.clear(),r}),e=t.cache;return t}var dm=M2;var I2=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,N2=/\\(\\)?/g,D2=dm(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(I2,function(e,r,o,i){t.push(o?i.replace(N2,"$1"):r||e)}),t}),pm=D2;function E2(n){return n==null?"":gh(n)}var fm=E2;function B2(n,t){return xt(n)?n:$h(n,t)?[n]:pm(fm(n))}var Lr=B2;var L2=1/0;function R2(n){if(typeof n=="string"||Ri(n))return n;var t=n+"";return t=="0"&&1/n==-L2?"-0":t}var Sn=R2;function V2(n,t){t=Lr(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[Sn(t[e++])];return e&&e==r?n:void 0}var pc=V2;function z2(n,t){for(var e=-1,r=t.length,o=n.length;++e<r;)n[o+e]=t[e];return n}var Qi=z2;var hm=kt?kt.isConcatSpreadable:void 0;function G2(n){return xt(n)||Ui(n)||!!(hm&&n&&n[hm])}var mm=G2;function ym(n,t,e,r,o){var i=-1,a=n.length;for(e||(e=mm),o||(o=[]);++i<a;){var s=n[i];t>0&&e(s)?t>1?ym(s,t-1,e,r,o):Qi(o,s):r||(o[o.length]=s)}return o}var gm=ym;function k2(n){var t=n==null?0:n.length;return t?gm(n,1):[]}var xm=k2;function F2(n){return Ih(Eh(n,void 0,xm),n+"")}var fc=F2;var j2=dc(Object.getPrototypeOf,Object),Ki=j2;var U2="[object Object]",H2=Function.prototype,q2=Object.prototype,bm=H2.toString,W2=q2.hasOwnProperty,$2=bm.call(Object);function Y2(n){if(!Xt(n)||Cr(n)!=U2)return!1;var t=Ki(n);if(t===null)return!0;var e=W2.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&bm.call(e)==$2}var vm=Y2;function X2(n,t,e){var r=-1,o=n.length;t<0&&(t=-t>o?0:o+t),e=e>o?o:e,e<0&&(e+=o),o=t>e?0:e-t>>>0,t>>>=0;for(var i=Array(o);++r<o;)i[r]=n[r+t];return i}var Sm=X2;function Q2(){this.__data__=new xn,this.size=0}var wm=Q2;function K2(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var _m=K2;function Z2(n){return this.__data__.get(n)}var Am=Z2;function J2(n){return this.__data__.has(n)}var Pm=J2;var e_=200;function t_(n,t){var e=this.__data__;if(e instanceof xn){var r=e.__data__;if(!bn||r.length<e_-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new ni(r)}return e.set(n,t),this.size=e.size,this}var Om=t_;function Zi(n){var t=this.__data__=new xn(n);this.size=t.size}Zi.prototype.clear=wm;Zi.prototype.delete=_m;Zi.prototype.get=Am;Zi.prototype.has=Pm;Zi.prototype.set=Om;var Ji=Zi;function r_(n,t){return n&&go(t,qi(t),n)}var Cm=r_;function o_(n,t){return n&&go(t,Wi(t),n)}var Tm=o_;var Dm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mm=Dm&&typeof module=="object"&&module&&!module.nodeType&&module,n_=Mm&&Mm.exports===Dm,Im=n_?Tt.Buffer:void 0,Nm=Im?Im.allocUnsafe:void 0;function i_(n,t){if(t)return n.slice();var e=n.length,r=Nm?Nm(e):new n.constructor(e);return n.copy(r),r}var Em=i_;function a_(n,t){for(var e=-1,r=n==null?0:n.length,o=0,i=[];++e<r;){var a=n[e];t(a,e,n)&&(i[o++]=a)}return i}var Bm=a_;function s_(){return[]}var hc=s_;var l_=Object.prototype,c_=l_.propertyIsEnumerable,Lm=Object.getOwnPropertySymbols,u_=Lm?function(n){return n==null?[]:(n=Object(n),Bm(Lm(n),function(t){return c_.call(n,t)}))}:hc,ea=u_;function d_(n,t){return go(n,ea(n),t)}var Rm=d_;var p_=Object.getOwnPropertySymbols,f_=p_?function(n){for(var t=[];n;)Qi(t,ea(n)),n=Ki(n);return t}:hc,mc=f_;function h_(n,t){return go(n,mc(n),t)}var Vm=h_;function m_(n,t,e){var r=t(n);return xt(n)?r:Qi(r,e(n))}var yc=m_;function y_(n){return yc(n,qi,ea)}var Hs=y_;function g_(n){return yc(n,Wi,mc)}var gc=g_;var x_=hr(Tt,"DataView"),xc=x_;var b_=hr(Tt,"Promise"),bc=b_;var v_=hr(Tt,"Set"),vc=v_;var zm="[object Map]",S_="[object Object]",Gm="[object Promise]",km="[object Set]",Fm="[object WeakMap]",jm="[object DataView]",w_=Uo(xc),__=Uo(bn),A_=Uo(bc),P_=Uo(vc),O_=Uo(ac),ii=Cr;(xc&&ii(new xc(new ArrayBuffer(1)))!=jm||bn&&ii(new bn)!=zm||bc&&ii(bc.resolve())!=Gm||vc&&ii(new vc)!=km||ac&&ii(new ac)!=Fm)&&(ii=function(n){var t=Cr(n),e=t==S_?n.constructor:void 0,r=e?Uo(e):"";if(r)switch(r){case w_:return jm;case __:return zm;case A_:return Gm;case P_:return km;case O_:return Fm}return t});var Wo=ii;var C_=Object.prototype,T_=C_.hasOwnProperty;function M_(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&T_.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Um=M_;var I_=Tt.Uint8Array,ta=I_;function N_(n){var t=new n.constructor(n.byteLength);return new ta(t).set(new ta(n)),t}var ra=N_;function D_(n,t){var e=t?ra(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Hm=D_;var E_=/\w*$/;function B_(n){var t=new n.constructor(n.source,E_.exec(n));return t.lastIndex=n.lastIndex,t}var qm=B_;var Wm=kt?kt.prototype:void 0,$m=Wm?Wm.valueOf:void 0;function L_(n){return $m?Object($m.call(n)):{}}var Ym=L_;function R_(n,t){var e=t?ra(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var Xm=R_;var V_="[object Boolean]",z_="[object Date]",G_="[object Map]",k_="[object Number]",F_="[object RegExp]",j_="[object Set]",U_="[object String]",H_="[object Symbol]",q_="[object ArrayBuffer]",W_="[object DataView]",$_="[object Float32Array]",Y_="[object Float64Array]",X_="[object Int8Array]",Q_="[object Int16Array]",K_="[object Int32Array]",Z_="[object Uint8Array]",J_="[object Uint8ClampedArray]",eA="[object Uint16Array]",tA="[object Uint32Array]";function rA(n,t,e){var r=n.constructor;switch(t){case q_:return ra(n);case V_:case z_:return new r(+n);case W_:return Hm(n,e);case $_:case Y_:case X_:case Q_:case K_:case Z_:case J_:case eA:case tA:return Xm(n,e);case G_:return new r;case k_:case U_:return new r(n);case F_:return qm(n);case j_:return new r;case H_:return Ym(n)}}var Qm=rA;function oA(n){return typeof n.constructor=="function"&&!ji(n)?Ah(Ki(n)):{}}var Km=oA;var nA="[object Map]";function iA(n){return Xt(n)&&Wo(n)==nA}var Zm=iA;var Jm=Ho&&Ho.isMap,aA=Jm?Hi(Jm):Zm,ey=aA;var sA="[object Set]";function lA(n){return Xt(n)&&Wo(n)==sA}var ty=lA;var ry=Ho&&Ho.isSet,cA=ry?Hi(ry):ty,oy=cA;var uA=1,dA=2,pA=4,ny="[object Arguments]",fA="[object Array]",hA="[object Boolean]",mA="[object Date]",yA="[object Error]",iy="[object Function]",gA="[object GeneratorFunction]",xA="[object Map]",bA="[object Number]",ay="[object Object]",vA="[object RegExp]",SA="[object Set]",wA="[object String]",_A="[object Symbol]",AA="[object WeakMap]",PA="[object ArrayBuffer]",OA="[object DataView]",CA="[object Float32Array]",TA="[object Float64Array]",MA="[object Int8Array]",IA="[object Int16Array]",NA="[object Int32Array]",DA="[object Uint8Array]",EA="[object Uint8ClampedArray]",BA="[object Uint16Array]",LA="[object Uint32Array]",it={};it[ny]=it[fA]=it[PA]=it[OA]=it[hA]=it[mA]=it[CA]=it[TA]=it[MA]=it[IA]=it[NA]=it[xA]=it[bA]=it[ay]=it[vA]=it[SA]=it[wA]=it[_A]=it[DA]=it[EA]=it[BA]=it[LA]=!0;it[yA]=it[iy]=it[AA]=!1;function Sc(n,t,e,r,o,i){var a,s=t&uA,l=t&dA,u=t&pA;if(e&&(a=o?e(n,r,o,i):e(n)),a!==void 0)return a;if(!Tr(n))return n;var c=xt(n);if(c){if(a=Um(n),!s)return Oh(n,a)}else{var d=Wo(n),p=d==iy||d==gA;if(oi(n))return Em(n,s);if(d==ay||d==ny||p&&!o){if(a=l||p?{}:Km(n),!s)return l?Vm(n,Tm(a,n)):Rm(n,Cm(a,n))}else{if(!it[d])return o?n:{};a=Qm(n,d,s)}}i||(i=new Ji);var f=i.get(n);if(f)return f;i.set(n,a),oy(n)?n.forEach(function(y){a.add(Sc(y,t,e,y,n,i))}):ey(n)&&n.forEach(function(y,g){a.set(g,Sc(y,t,e,g,n,i))});var h=u?l?gc:Hs:l?Wi:qi,m=c?void 0:h(n);return Nh(m||n,function(y,g){m&&(g=y,y=n[g]),ki(a,g,Sc(y,t,e,g,n,i))}),a}var wc=Sc;var RA=1,VA=4;function zA(n){return wc(n,RA|VA)}var $o=zA;var GA="__lodash_hash_undefined__";function kA(n){return this.__data__.set(n,GA),this}var sy=kA;function FA(n){return this.__data__.has(n)}var ly=FA;function _c(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new ni;++t<e;)this.add(n[t])}_c.prototype.add=_c.prototype.push=sy;_c.prototype.has=ly;var cy=_c;function jA(n,t){for(var e=-1,r=n==null?0:n.length;++e<r;)if(t(n[e],e,n))return!0;return!1}var uy=jA;function UA(n,t){return n.has(t)}var dy=UA;var HA=1,qA=2;function WA(n,t,e,r,o,i){var a=e&HA,s=n.length,l=t.length;if(s!=l&&!(a&&l>s))return!1;var u=i.get(n),c=i.get(t);if(u&&c)return u==t&&c==n;var d=-1,p=!0,f=e&qA?new cy:void 0;for(i.set(n,t),i.set(t,n);++d<s;){var h=n[d],m=t[d];if(r)var y=a?r(m,h,d,t,n,i):r(h,m,d,n,t,i);if(y!==void 0){if(y)continue;p=!1;break}if(f){if(!uy(t,function(g,b){if(!dy(f,b)&&(h===g||o(h,g,e,r,i)))return f.push(b)})){p=!1;break}}else if(!(h===m||o(h,m,e,r,i))){p=!1;break}}return i.delete(n),i.delete(t),p}var Ac=WA;function $A(n){var t=-1,e=Array(n.size);return n.forEach(function(r,o){e[++t]=[o,r]}),e}var py=$A;function YA(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var fy=YA;var XA=1,QA=2,KA="[object Boolean]",ZA="[object Date]",JA="[object Error]",eP="[object Map]",tP="[object Number]",rP="[object RegExp]",oP="[object Set]",nP="[object String]",iP="[object Symbol]",aP="[object ArrayBuffer]",sP="[object DataView]",hy=kt?kt.prototype:void 0,Ld=hy?hy.valueOf:void 0;function lP(n,t,e,r,o,i,a){switch(e){case sP:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case aP:return!(n.byteLength!=t.byteLength||!i(new ta(n),new ta(t)));case KA:case ZA:case tP:return Gi(+n,+t);case JA:return n.name==t.name&&n.message==t.message;case rP:case nP:return n==t+"";case eP:var s=py;case oP:var l=r&XA;if(s||(s=fy),n.size!=t.size&&!l)return!1;var u=a.get(n);if(u)return u==t;r|=QA,a.set(n,t);var c=Ac(s(n),s(t),r,o,i,a);return a.delete(n),c;case iP:if(Ld)return Ld.call(n)==Ld.call(t)}return!1}var my=lP;var cP=1,uP=Object.prototype,dP=uP.hasOwnProperty;function pP(n,t,e,r,o,i){var a=e&cP,s=Hs(n),l=s.length,u=Hs(t),c=u.length;if(l!=c&&!a)return!1;for(var d=l;d--;){var p=s[d];if(!(a?p in t:dP.call(t,p)))return!1}var f=i.get(n),h=i.get(t);if(f&&h)return f==t&&h==n;var m=!0;i.set(n,t),i.set(t,n);for(var y=a;++d<l;){p=s[d];var g=n[p],b=t[p];if(r)var S=a?r(b,g,p,t,n,i):r(g,b,p,n,t,i);if(!(S===void 0?g===b||o(g,b,e,r,i):S)){m=!1;break}y||(y=p=="constructor")}if(m&&!y){var w=n.constructor,v=t.constructor;w!=v&&"constructor"in n&&"constructor"in t&&!(typeof w=="function"&&w instanceof w&&typeof v=="function"&&v instanceof v)&&(m=!1)}return i.delete(n),i.delete(t),m}var yy=pP;var fP=1,gy="[object Arguments]",xy="[object Array]",Pc="[object Object]",hP=Object.prototype,by=hP.hasOwnProperty;function mP(n,t,e,r,o,i){var a=xt(n),s=xt(t),l=a?xy:Wo(n),u=s?xy:Wo(t);l=l==gy?Pc:l,u=u==gy?Pc:u;var c=l==Pc,d=u==Pc,p=l==u;if(p&&oi(n)){if(!oi(t))return!1;a=!0,c=!1}if(p&&!c)return i||(i=new Ji),a||cc(n)?Ac(n,t,e,r,o,i):my(n,t,l,e,r,o,i);if(!(e&fP)){var f=c&&by.call(n,"__wrapped__"),h=d&&by.call(t,"__wrapped__");if(f||h){var m=f?n.value():n,y=h?t.value():t;return i||(i=new Ji),o(m,y,e,r,i)}}return p?(i||(i=new Ji),yy(n,t,e,r,o,i)):!1}var vy=mP;function Sy(n,t,e,r,o){return n===t?!0:n==null||t==null||!Xt(n)&&!Xt(t)?n!==n&&t!==t:vy(n,t,e,r,Sy,o)}var wy=Sy;function yP(n,t){return n!=null&&t in Object(n)}var _y=yP;function gP(n,t,e){t=Lr(t,n);for(var r=-1,o=t.length,i=!1;++r<o;){var a=Sn(t[r]);if(!(i=n!=null&&e(n,a)))break;n=n[a]}return i||++r!=o?i:(o=n==null?0:n.length,!!o&&Fi(o)&&zi(a,o)&&(xt(n)||Ui(n)))}var Ay=gP;function xP(n,t){return n!=null&&Ay(n,t,_y)}var Py=xP;function bP(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var Oy=bP;function vP(n,t){return t.length<2?n:pc(n,Sm(t,0,-1))}var Cy=vP;function SP(n,t){return wy(n,t)}var Rd=SP;function wP(n,t){return t=Lr(t,n),n=Cy(n,t),n==null||delete n[Sn(Oy(t))]}var Ty=wP;function _P(n){return vm(n)?void 0:n}var My=_P;var AP=1,PP=2,OP=4,CP=fc(function(n,t){var e={};if(n==null)return e;var r=!1;t=oc(t,function(i){return i=Lr(i,n),r||(r=i.length>1),i}),go(n,gc(n),e),r&&(e=wc(e,AP|PP|OP,My));for(var o=t.length;o--;)Ty(e,t[o]);return e}),oa=CP;function TP(n,t,e,r){if(!Tr(n))return n;t=Lr(t,n);for(var o=-1,i=t.length,a=i-1,s=n;s!=null&&++o<i;){var l=Sn(t[o]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return n;if(o!=a){var c=s[l];u=r?r(c,l,s):void 0,u===void 0&&(u=Tr(c)?c:zi(t[o+1])?[]:{})}ki(s,l,u),s=s[l]}return n}var Iy=TP;function MP(n,t,e){for(var r=-1,o=t.length,i={};++r<o;){var a=t[r],s=pc(n,a);e(s,a)&&Iy(i,Lr(a,n),s)}return i}var Ny=MP;function IP(n,t){return Ny(n,t,function(e,r){return Py(n,r)})}var Dy=IP;var NP=fc(function(n,t){return n==null?{}:Dy(n,t)}),Zr=NP;var ue=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let i={...r,[t]:e};return Object.setPrototypeOf(i,ue.prototype),i}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],o;r===void 0?o={type:2,id:t.id}:o={type:1,id:t.id,data:r};let{id:i,data:a}=t,s={...e,[i]:a};return Object.setPrototypeOf(s,ue.prototype),{data:s,actual:t,reverse:o}}else if(t.type===2){let{id:r}=t,o=e[r];if(o===void 0)return null;{let i={...e};return Object.setPrototypeOf(i,ue.prototype),delete i[r],{data:i,actual:t,reverse:{type:1,id:r,data:o}}}}return null}};function qs(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let t=Object.getOwnPropertyNames(n);for(let e of t){let r=n[e];r&&typeof r=="object"&&qs(r)}return Object.freeze(n)}function Ey(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var na=class extends Error{};function Oc(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function xo(n,t,e){if(n===void 0?t===void 0?(n=0,t=10):n=t-10:t===void 0&&(t=n+10),n>t){let i=n;n=t,t=i}let r=[],o=1/(e+1);for(let i=0;i<e;i++){let a=n+(t-n)*(i+.75+Math.random()*.5)*o;r.push(a)}return r}function ia(n){return n instanceof Uint8Array||n instanceof Uint16Array||n instanceof Uint32Array||n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof Float64Array}function By(){return typeof process<"u"}function Ly(n,t){for(let e of n)t(e.id,e.data)!==!0&&Ly(e.children,t)}function Ry(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)Ry(e,t)}var tt=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,tt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)qs(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,r){if(!this.has(e))return!0;for(;e;){let o=this.parent(e);if(o===r)return!0;e=o}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let o=this.parent(e);if(o===r)return!0;e=o}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,r){if(e===null)this.traverse(r);else{let o=this.get(e);o&&Ry(o,r)}}traverse(e){Ly(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),a=this.childrenArray(i),s=a.findIndex(c=>c.id===e);if(s<0)throw new Error("not expected");let l=a[s];return a=[...a],a[s]={...l,data:r},this.modifyArrayBy(i,a)}}modifyArrayBy(e,r){let o=e,i=r;for(;o!==null;){let s=i,l=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let u=i.findIndex(c=>c.id===l);if(u<0)throw new Error;i=[...i],i[u]={...i[u],children:s}}Object.setPrototypeOf(i,tt.prototype);let a=i;return a.fillCaches(),a}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:r}){if(this.get(e)!==void 0)return!0;for(let o of r)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:r,fi:o,id:i,data:a,children:s}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,u=this.childrenArray(l),c={fi:o,id:i,data:a,children:s};return u=[...u,c],u.sort((p,f)=>p.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:i}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let o=this.parent(r);if(o===void 0)return null;let i=this.childrenArray(o),a=i.findIndex(u=>u.id===r);e.localIndex=a,i=[...i];let s=i.splice(a,1)[0];return{data:this.modifyArrayBy(o,i),actual:e,reverse:{type:7,...s,parent:o}}}}moveOp(e){let{parent:r,fi:o,id:i}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:i});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===i)throw new na("cyclic tree");f=this.parent(f)}}let a=this.parent(i);if(a===void 0)return null;let s=a,l=this.childrenArray(a),u=l.findIndex(f=>f.id===i);l=[...l];let c=l.splice(u,1)[0],d=this.modifyArrayBy(a,l);a=r,l=d.childrenArray(a);let p=c.fi;return c={...c,fi:o},l=[...l,c],l.sort((f,h)=>f.fi-h.fi),e.localIndex=l.indexOf(c),d=d.modifyArrayBy(a,l),{data:d,actual:e,reverse:{type:9,parent:s,fi:p,id:i}}}previous(e,r){if(r===null){let i=this.childrenArray(e);return i.length===0?null:i[i.length-1].id}let o=null;for(let i of this.childrenArray(e)){if(i.id===r)return o;o=i.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),i=o.findIndex(a=>a.id===e)+1;if(i<o.length)return o[i].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),i=o.findIndex(a=>a.id===e)-1;return i>=0?this.traverseSortPrevious(o[i].id):r}}getAllSorted(e){let r=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&r.push({...o,...i})}r.sort((o,i)=>Ey(o.sortKey,i.sortKey));for(let o of r)delete o.sortKey;return r}getWithSortKey(e){var r=e;let o=[],i=this.get(r),a=i;if(i!==void 0){for(;r;)o.splice(0,0,i.fi),r=this.parent(r),r!==null&&(i=this.get(r));return{...a,sortKey:o}}}insertBeforeHelper(e,r,o){return this.insertAfterHelper(e,this.previous(e,r),o)}insertAfterHelper(e,r,o){let i=this.childrenArray(e);if(r===null){if(i.length===0)return xo(0,o,o);{let a=i[0].fi;return xo(a-o,a,o)}}else{let a=this.get(r);if(a===void 0||this.parent(r)!==e)throw new Error("illegal args");let s=i.find(l=>l.fi>a.fi);if(s===void 0){let l=i[i.length-1].fi;return xo(l,l+o,o)}else return xo(a.fi,s.fi,o)}}};var aa;(t=>{function n(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let o=r.props,i={},a=[...e],s=!1;if(o)for(let l of Object.keys(o)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");i[l]=a[u],a[u]=o[l],s=!0}return s?{data:a,actual:r,reverse:{type:0,props:i}}:null}else{let o=r.props,i={},a={...e},s=!1;if(o)for(let l of Object.keys(o)){i[l]=a[l];let u=o[l];u===void 0?delete a[l]:a[l]=u,s=!0}return s?{data:a,actual:r,reverse:{type:0,props:i}}:null}}t.runOp=n})(aa||(aa={}));var me=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,me.prototype)}deepFreeze(){let e=0;for(;e<this.length;)qs(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,a=i.findIndex(u=>u.id===e);if(a<0)throw new Error("not expected");let s=i[a];return i=[...i],i[a]={...s,data:r},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,me.prototype);let r=e;return By()||r.fillCaches(),r}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:r,id:o,data:i}=e,a=this,s={fi:r,id:o,data:i};return a=[...a,s],a.sort((u,c)=>u.fi-c.fi),e.localIndex=a.indexOf(s),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:o}}}deleteOp(e){let{id:r}=e,o=this,i=o.findIndex(l=>l.id===r);if(i===-1)return null;e.localIndex=i,o=[...o];let a=o.splice(i,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:r,id:o}=e,i=this;i=[...i];let a=i.findIndex(c=>c.id===o);if(a===-1)return null;let s=i[a].fi,l={...i[a],fi:r};return i[a]=l,i.sort((c,d)=>c.fi-d.fi),e.localIndex=i.indexOf(l),{data:this.modifyArrayBy(i),actual:e,reverse:{type:6,fi:s,id:o}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let o of this){if(o.id===e)return r;r=o.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let o=this;if(e===null){if(o.length===0)return xo(0,r,r);{let i=o[0].fi;return xo(i-r,i,r)}}else{let i=this.get(e);if(i===void 0)throw new Error("illegal args");let a=o.find(s=>s.fi>i.fi);if(a===void 0){let s=o[o.length-1].fi;return xo(s,s+r,r)}else return xo(i.fi,a.fi,r)}}};function sa(n){return n&&typeof n=="object"&&n instanceof rt}var rt=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,o=0,i={};for(;o<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[o]],r!==void 0&&!sa(r))return null;o+=1}r=r?Oc(r):new rt;for(let[l,u]of Object.entries(t.props)){let c=r[l];i[l]=c,u===void 0?delete r[l]:r[l]=u}for(;o>0;){if(Object.keys(r).length===0){let l=e[o-1];l&&(r=Oc(l),delete r[t.path[o-1]])}else{let l=e[o-1];if(l){let u=Oc(l);u[t.path[o-1]]=r,r=u}else{let u=new rt;u[t.path[o-1]]=r,r=u}}o-=1}let a=Object.setPrototypeOf(r,rt.prototype),s={...t,props:i};return{data:a,actual:t,reverse:s}}},bo;(r=>{function n(o,i){return Ws(o,i)??o}r.apply=n;function t(o,i){return zd(o,i)}r.merge=t;function e(o,i){let a=0,s=i.path,l=o;for(;a<s.length&&l!==void 0;){if(l=dt.zoomOnce(l,s[a]),l===void 0)return i;if(!sa(l))return;a+=1}if(l===void 0)return i;if(!!sa(l))if(i.type===0){let u={...i.props};for(let c of Object.keys(l))delete u[c];return{...i,props:u}}else if(i.type===1||i.type===4||i.type===7){let u=Vd([i],l);return u?(console.log(u),u):i}else return i}r.filterOp=e})(bo||(bo={}));function Vd(n,t){if(t===void 0)return;let e=!1,r=n.map(o=>{let i=o.id,a=Ws(o.data,t[i]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=Vd(o.children,t);return s!==void 0?e=!0:s=o.children,{...o,id:i,data:a,children:s}}else return{...o,id:i,data:a}});if(e)return r}function DP(n,t){if(t===void 0)return;let e=!1,r=n.map(o=>{let i=o.id,a=Ws(o.data,t[i]);return e=e||a!==void 0,a===void 0&&(a=o.data),{...o,id:i,data:a}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function Ws(n,t){if(!sa(t))return t;if(n instanceof tt){let e=Vd(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof me)return DP(n,t);if(Array.isArray(n)){let e=!1,r=n.map((o,i)=>{let a=Ws(o,t[i]);return e=e||a!==void 0,a===void 0&&(a=o),a});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else{if(n instanceof rt)return zd(n,t);if(n&&typeof n=="object"){let e={},r=!1;for(let[o,i]of Object.entries(n)){let a=Ws(i,t[o]);r=r||a!==void 0,a===void 0&&(a=i),e[o]=a}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function zd(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!sa(t))return t;if(!sa(n))return bo.apply(n,t);let e=new Set;for(let o of Object.keys(n))e.add(o);for(let o of Object.keys(t))e.add(o);let r=new rt;for(let o of e){let i=zd(n===void 0?void 0:n[o],t===void 0?void 0:t[o]);r[o]=i}return r}function Vy(n,t){let e={cur:[],result:[],len:0};return n=$s(n,t,e)??n,[n,e.result]}function Cc(n,t){return n===null?null:(n.cur[n.len]=t,n.len+=1,n)}function Tc(n){n&&(n.len-=1)}function EP(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function zy(n,t,e){let r=!1,o=n.map(i=>{let a=i.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=$s(i.data,t,Cc(e,a));Tc(e),r=r||l!==void 0,l===void 0&&(l=i.data);let u=zy(i.children,t,e);return u!==void 0?r=!0:u=i.children,{...i,id:a,data:l,children:u}});if(r)return o}function BP(n,t,e){let r=!1,o=n.map(i=>{let a=i.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=$s(i.data,t,Cc(e,a));return Tc(e),r=r||l!==void 0,l===void 0&&(l=i.data),{...i,id:a,data:l}});if(r)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}function $s(n,t,e){if(n instanceof tt){let r=zy(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof me)return BP(n,t,e);if(Array.isArray(n)){let r=!1,o=n.map((i,a)=>{let s=$s(i,t,Cc(e,a));return Tc(e),r=r||s!==void 0,s===void 0&&(s=i),s});return r?(Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o):void 0}else if(n&&typeof n=="object"&&!ia(n)){let r={},o=!1;for(let[i,a]of Object.entries(n))if(i!=="name"){let s=t[i];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,i=s}let l=$s(a,t,Cc(e,i));Tc(e),o=o||l!==void 0,l===void 0&&(l=a),r[i]=l}else r[i]=a;return o?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else if(typeof n=="string"){let r=t[n];return r!==void 0&&EP(e),r}else return}}var la;(t=>{function n(e,r){let o=dt.zoom(r,e.path);if(typeof o=="object"){let i={};for(let a of Object.keys(e.props))i[a]=o[a];return{...e,props:i}}else return{...e,props:{}}}t.replaceProps=n})(la||(la={}));var pt;(s=>{function n(l,u){return{...l,path:l.path.slice(u)}}s.drop=n;function t(l,u){return e(l,u)?.data??l}s.applySimple=t;function e(l,u){let c=u.path;for(var d=[];;){let p;if(l instanceof rt&&u.type===0&&(p=l.runOp({...u,path:c.slice(d.length)}),p===null&&(p=void 0)),p===void 0&&d.length===c.length&&(l instanceof tt||l instanceof me||l instanceof ue?p=l.runOp(u):p=aa.runOp(l,u)),p!==void 0)if(p!==null){let m=p.data;for(let y=d.length-1;y>=0;y--){let g=c[y],b=d[y];if(b instanceof tt){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof me){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof ue){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof rt){let S={...b,[g]:m};m=Object.setPrototypeOf(S,rt.prototype)}else if(typeof b=="object")if(Array.isArray(b)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let S=m;m=[...b],m[g]=S}else m={...b,[g]:m};else return null}return{data:m,actual:{...p.actual,path:c},reverse:{...p.reverse,path:c}}}else return null;let f=c[d.length],h;if(l instanceof tt){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else if(l instanceof me){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else l!==null&&(h=l[f]);if(h!==void 0)d.push(l),l=h;else return null}}s.apply=e;function r(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}s.pathDisjoint=r;function o(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}s.pathEq=o;function i(l,u){return r(l.path,u.path)}s.commutative=i;function a(l,u){return l.type===0&&u.type===0&&o(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}s.subsumed=a})(pt||(pt={}));var Ys;(l=>{function n(){return[]}l.empty=n;function t(u,c){let d=[];for(let p of u){let[f,...h]=p.path;f===c&&d.push({...p,path:h})}return d}l.removePrefix=t;function e(u,c){return u.map(d=>({...d,path:[c,...d.path]}))}l.addPrefix=e;function r(u,c){return[...u,...c]}l.concat=r;function o(u,c){return[...u.filter(p=>!c.some(f=>pt.subsumed(p,f))),...c]}l.compress=o;function i(u,c){return u.every(d=>c.every(p=>pt.commutative(d,p)))}l.commutative=i;function a(u,c){for(let d of c){let p=s(u,d);p!==null&&(u=p.data)}return u}l.applyAll=a;function s(u,c){var d=u;let p=[],f=[];for(let h of c)try{if(h.type===3||h.type===5&&h.path[h.path.length-1]==="variables"){let m,y,g;if(h.type===3?(m=dt.zoom(d,[...h.path,h.id]),g=pt.apply(d,{...h,type:2})):(m=dt.zoom(d,[...h.path,h.id,"value"]),g=pt.apply(d,h)),g!==null){d=g.data;let[b,S]=Vy(d,{[h.id]:m});d=b;for(let w=0;w<S.length;w++){let v=S[w],_=v.pop();if(typeof _=="number"){let A=[_];for(let T=w+1;T<S.length;T++){let C=S[T],P=C[C.length-1];if(typeof P=="number"&&dt.equal(v,C.slice(0,C.length-1)))A.push(P),S.splice(T,1);else break}let x=dt.zoom(d,v);y=x.map((T,C)=>A.includes(C)?h.id:T),m=x,_=v.pop()}else{if(_==="alphaOverride"||_==="alpha"){m/=100;let A=m,x=dt.zoom(d,v.slice(0,v.length-2)),T=x.layers.map(C=>C.id===v[v.length-1]?{...C,data:{...C.data,[_]:A}}:C);Object.setPrototypeOf(T,Object.getPrototypeOf(x.layers)),x.layers=T}y=h.id}p.push({type:0,path:v,props:{[_]:m}}),f.push({type:0,path:v,props:{[_]:y}})}f.push(g.reverse),p.push(g.actual)}}else{let m=pt.apply(d,h);m!==null&&(p.push(m.actual),d=m.data,f.push(m.reverse))}}catch(m){if(m instanceof na)return null;throw m}return{data:d,actual:p,reverse:f.reverse()}}l.apply=s})(Ys||(Ys={}));var Gy=Symbol(),LP=Symbol(),Ic=Symbol(),ai=class{reportOp(t,e,r=[]){let o=this;if(e===null)return;o._current=e.data;let i=r;for(;!(o instanceof Mc);){let a=o._path,s=o._current;if(a!==""&&i.splice(0,0,a),o=o._parent,o===null)return;o.update(a,s)}o.push(i,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[Ic];r&&r(),delete this._children[t]}}}},kd=class extends ai{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,aa.runOp(this._current,t),t.path)}},Fd=class extends ai{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,ue.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},ky={get(n,t){if(t===Ic)return()=>{n._parent=null};if(t===Gy)return n._current;if(t===LP)return n;let{_current:e,_children:r}=n;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let o=r===void 0?void 0:r[t];if(o!==void 0)return o;let i=e[t],a=Nc(n,t,i);return a!==i?(r===void 0&&(r={},n._children=r),r[t]=a,a):i},has(n,t){return t in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,t){let e=n._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},RP={...ky,set(n,t,e){let r={type:0,props:{[t]:ft(e)??e}};return n.deleteChildren(t),n.runOp(r),!0},deleteProperty(n,t){let e={type:0,props:{[t]:void 0}};return n.deleteChildren(t),n.runOp(e),!0}},VP={...ky,set(n,t,e){return e===void 0?this.deleteProperty(n,t):(n.deleteChildren(t),n.runOp({type:1,id:t,data:e})),!0},deleteProperty(n,t){return n.runOp({type:2,id:t}),!0}},ca=class extends ai{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Ic]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let i=e.get(t)?.data,a=Nc(this,t,i);return a!==i?(r===void 0&&(r={},this._children=r),r[t]=a,a):i}add(t,e,r,o,i){this.runOp({type:7,parent:t,fi:e,id:r,data:o,children:i})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.add(t,o[i],a.id,a.data,a.children)}}insertBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.add(t,o[i],a.id,a.data,a.children)}}moveAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.move(t,o[i],a)}}moveBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.move(t,o[i],a)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},ua=class extends ai{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Ic]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id,i=this._current[r].fi;t(this.data(this._current[r].id),o,i)}}find(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id;if(t(this.data(o),o))return this.get(o)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let i=e.get(t)?.data,a=Nc(this,t,i);return a!==i?(r===void 0&&(r={},this._children=r),r[t]=a,a):i}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(r[o],i.id,i.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(r[o],i.id,i.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(r[o],i)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(r[o],i)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Gd(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&dt.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push({...t,path:e})}var Mc=class extends ai{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,o){Gd(this.ts,e,t),Gd(this.actual,r,t),Gd(this.reverse,o,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Nc(n,t,e){return e instanceof tt?new ca(n,t,e):e instanceof me?new ua(n,t,e):e instanceof ue?new Proxy(new Fd(n,t,e),VP):e!==null&&typeof e=="object"?ia(e)?e:new Proxy(new kd(n,t,e),RP):e}function jd(n){let t=new Mc(n);return[Nc(t,"",n),t]}function wn(n,t){let[e,r]=jd(n);return t(e),r.result()}function ft(n){return n instanceof ca||n instanceof ua?n._current:n!==null&&typeof n=="object"?n[Gy]:n}var dt;(o=>{function n(i,a){if(a.length===i.length)for(var s=0;s<i.length;){if(i[s]!==a[s])return!1;s+=1}else return!1;return!0}o.equal=n;function t(i,a,s){let l=r(s,i);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...a};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return a}o.removeOverridden=t;function e(i,a){if((i instanceof tt||i instanceof ca)&&typeof a=="string")return i.data(a);if((i instanceof me||i instanceof ua)&&typeof a=="string")return i.data(a);if(typeof a=="number"&&Array.isArray(i))return i[a];if(typeof a=="string"&&typeof i=="object"&&i!==null)return i[a]}o.zoomOnce=e;function r(i,a,s=0){for(;s<a.length&&i!==void 0;)i=e(i,a[s]),s+=1;return i}o.zoom=r})(dt||(dt={}));function Fy(n,t){let e=[];if(t.length===n.length)for(var r=0;r<n.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}function Ne(n,t){let e=[];if(t.length<=n.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}var Dc=class{},Xs=class extends Dc{constructor(e){super();this.id=e}},Qs=class extends Dc{constructor(e){super();this.data=e}};var Hd;try{Hd=new TextDecoder}catch{}var re,An,E=0;var Xy=[],qd=Xy,Wd=0,mr={},He,_n,Rr=0,vo=0,Mr,Yo,ar=[],$e,jy={useRecords:!1,mapsAsObjects:!0},Ks=class{},Yd=new Ks;Yd.name="MessagePack 0xC1";var da=!1,So=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(re)return eg(()=>(Bc(),this?this.unpack(t,e):So.prototype.unpack.call(jy,t,e)));An=e>-1?e:t.length,E=0,Wd=0,vo=0,_n=null,qd=Xy,Mr=null,re=t;try{$e=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw re=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof So){if(mr=this,this.structures)return He=this.structures,Ec();(!He||He.length>0)&&(He=[])}else mr=jy,(!He||He.length>0)&&(He=[]);return Ec()}unpackMultiple(t,e){let r,o=0;try{da=!0;let i=t.length,a=this?this.unpack(t,i):Vc.unpack(t,i);if(e){for(e(a);E<i;)if(o=E,e(Ec())===!1)return}else{for(r=[a];E<i;)o=E,r.push(Ec());return r}}catch(i){throw i.lastPosition=o,i.values=r,i}finally{da=!1,Bc()}}_mergeStructures(t,e){t=t||[];for(let r=0,o=t.length;r<o;r++){let i=t[r];i&&(i.isShared=!0,r>=32&&(i.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let o=t[r],i=e[r];i&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[r]=o),t[r]=i)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Ec(){try{if(!mr.trusted&&!da){let t=He.sharedLength||0;t<He.length&&(He.length=t)}let n=bt();if(E==An)He.restoreStructures&&Uy(),He=null,re=null,Yo&&(Yo=null);else if(E>An){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!da)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw He.restoreStructures&&Uy(),Bc(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Uy(){for(let n in He.restoreStructures)He[n]=He.restoreStructures[n];He.restoreStructures=null}function bt(){let n=re[E++];if(n<160)if(n<128){if(n<64)return n;{let t=He[n&63]||mr.getStructures&&Qy()[n&63];return t?(t.read||(t.read=Xd(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,mr.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Zy()]=bt();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(bt(),bt());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=bt();return t}else if(n<192){let t=n-160;if(vo>=E)return _n.slice(E-Rr,(E+=t)-Rr);if(vo==0&&An<140){let e=t<16?Qd(t):Ky(t);if(e!=null)return e}return $d(t)}else{let t;switch(n){case 192:return null;case 193:return Mr?(t=bt(),t>0?Mr[1].slice(Mr.position1,Mr.position1+=t):Mr[0].slice(Mr.position0,Mr.position0-=t)):Yd;case 194:return!1;case 195:return!0;case 196:return Ud(re[E++]);case 197:return t=$e.getUint16(E),E+=2,Ud(t);case 198:return t=$e.getUint32(E),E+=4,Ud(t);case 199:return si(re[E++]);case 200:return t=$e.getUint16(E),E+=2,si(t);case 201:return t=$e.getUint32(E),E+=4,si(t);case 202:if(t=$e.getFloat32(E),mr.useFloat32>2){let e=Rc[(re[E]&127)<<1|re[E+1]>>7];return E+=4,(e*t+(t>0?.5:-.5)>>0)/e}return E+=4,t;case 203:return t=$e.getFloat64(E),E+=8,t;case 204:return re[E++];case 205:return t=$e.getUint16(E),E+=2,t;case 206:return t=$e.getUint32(E),E+=4,t;case 207:return mr.int64AsNumber?(t=$e.getUint32(E)*4294967296,t+=$e.getUint32(E+4)):t=$e.getBigUint64(E),E+=8,t;case 208:return $e.getInt8(E++);case 209:return t=$e.getInt16(E),E+=2,t;case 210:return t=$e.getInt32(E),E+=4,t;case 211:return mr.int64AsNumber?(t=$e.getInt32(E)*4294967296,t+=$e.getUint32(E+4)):t=$e.getBigInt64(E),E+=8,t;case 212:if(t=re[E++],t==114)return Yy(re[E++]&63);{let e=ar[t];if(e)return e.read?(E++,e.read(bt())):e.noBuffer?(E++,e()):e(re.subarray(E,++E));throw new Error("Unknown extension "+t)}case 213:return t=re[E],t==114?(E++,Yy(re[E++]&63,re[E++])):si(2);case 214:return si(4);case 215:return si(8);case 216:return si(16);case 217:return t=re[E++],vo>=E?_n.slice(E-Rr,(E+=t)-Rr):GP(t);case 218:return t=$e.getUint16(E),E+=2,vo>=E?_n.slice(E-Rr,(E+=t)-Rr):kP(t);case 219:return t=$e.getUint32(E),E+=4,vo>=E?_n.slice(E-Rr,(E+=t)-Rr):FP(t);case 220:return t=$e.getUint16(E),E+=2,qy(t);case 221:return t=$e.getUint32(E),E+=4,qy(t);case 222:return t=$e.getUint16(E),E+=2,Wy(t);case 223:return t=$e.getUint32(E),E+=4,Wy(t);default:if(n>=224)return n-256;if(n===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+n)}}}var zP=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Xd(n,t){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>zP.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(bt);return n.highByte===0&&(n.read=Hy(t,n.read)),o()}let r={};for(let o=0,i=n.length;o<i;o++){let a=n[o];r[a]=bt()}return r}return e.count=0,n.highByte===0?Hy(t,e):e}var Hy=(n,t)=>function(){let e=re[E++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),o=He[r]||Qy()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=Xd(o,n)),o.read()};function Qy(){let n=eg(()=>(re=null,mr.getStructures()));return He=mr._mergeStructures(n,He)}var $d=Lc,GP=Lc,kP=Lc,FP=Lc;function Lc(n){let t;if(n<16&&(t=Qd(n)))return t;if(n>64&&Hd)return Hd.decode(re.subarray(E,E+=n));let e=E+n,r=[];for(t="";E<e;){let o=re[E++];if((o&128)===0)r.push(o);else if((o&224)===192){let i=re[E++]&63;r.push((o&31)<<6|i)}else if((o&240)===224){let i=re[E++]&63,a=re[E++]&63;r.push((o&31)<<12|i<<6|a)}else if((o&248)===240){let i=re[E++]&63,a=re[E++]&63,s=re[E++]&63,l=(o&7)<<18|i<<12|a<<6|s;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(o);r.length>=4096&&(t+=Ft.apply(String,r),r.length=0)}return r.length>0&&(t+=Ft.apply(String,r)),t}function qy(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=bt();return t}function Wy(n){if(mr.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Zy()]=bt();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(bt(),bt());return t}}var Ft=String.fromCharCode;function Ky(n){let t=E,e=new Array(n);for(let r=0;r<n;r++){let o=re[E++];if((o&128)>0){E=t;return}e[r]=o}return Ft.apply(String,e)}function Qd(n){if(n<4)if(n<2){if(n===0)return"";{let t=re[E++];if((t&128)>1){E-=1;return}return Ft(t)}}else{let t=re[E++],e=re[E++];if((t&128)>0||(e&128)>0){E-=2;return}if(n<3)return Ft(t,e);let r=re[E++];if((r&128)>0){E-=3;return}return Ft(t,e,r)}else{let t=re[E++],e=re[E++],r=re[E++],o=re[E++];if((t&128)>0||(e&128)>0||(r&128)>0||(o&128)>0){E-=4;return}if(n<6){if(n===4)return Ft(t,e,r,o);{let i=re[E++];if((i&128)>0){E-=5;return}return Ft(t,e,r,o,i)}}else if(n<8){let i=re[E++],a=re[E++];if((i&128)>0||(a&128)>0){E-=6;return}if(n<7)return Ft(t,e,r,o,i,a);let s=re[E++];if((s&128)>0){E-=7;return}return Ft(t,e,r,o,i,a,s)}else{let i=re[E++],a=re[E++],s=re[E++],l=re[E++];if((i&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){E-=8;return}if(n<10){if(n===8)return Ft(t,e,r,o,i,a,s,l);{let u=re[E++];if((u&128)>0){E-=9;return}return Ft(t,e,r,o,i,a,s,l,u)}}else if(n<12){let u=re[E++],c=re[E++];if((u&128)>0||(c&128)>0){E-=10;return}if(n<11)return Ft(t,e,r,o,i,a,s,l,u,c);let d=re[E++];if((d&128)>0){E-=11;return}return Ft(t,e,r,o,i,a,s,l,u,c,d)}else{let u=re[E++],c=re[E++],d=re[E++],p=re[E++];if((u&128)>0||(c&128)>0||(d&128)>0||(p&128)>0){E-=12;return}if(n<14){if(n===12)return Ft(t,e,r,o,i,a,s,l,u,c,d,p);{let f=re[E++];if((f&128)>0){E-=13;return}return Ft(t,e,r,o,i,a,s,l,u,c,d,p,f)}}else{let f=re[E++],h=re[E++];if((f&128)>0||(h&128)>0){E-=14;return}if(n<15)return Ft(t,e,r,o,i,a,s,l,u,c,d,p,f,h);let m=re[E++];if((m&128)>0){E-=15;return}return Ft(t,e,r,o,i,a,s,l,u,c,d,p,f,h,m)}}}}}function Ud(n){return mr.copyBuffers?Uint8Array.prototype.slice.call(re,E,E+=n):re.subarray(E,E+=n)}function si(n){let t=re[E++];if(ar[t])return ar[t](re.subarray(E,E+=n));throw new Error("Unknown extension type "+t)}var $y=new Array(4096);function Zy(){let n=re[E++];if(n>=160&&n<192){if(n=n-160,vo>=E)return _n.slice(E-Rr,(E+=n)-Rr);if(!(vo==0&&An<180))return $d(n)}else return E--,bt();let t=(n<<5^(n>1?$e.getUint16(E):n>0?re[E]:0))&4095,e=$y[t],r=E,o=E+n-3,i,a=0;if(e&&e.bytes==n){for(;r<o;){if(i=$e.getUint32(r),i!=e[a++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(i=re[r++],i!=e[a++]){r=1879048192;break}if(r===o)return E=r,e.string;o-=3,r=E}for(e=[],$y[t]=e,e.bytes=n;r<o;)i=$e.getUint32(r),e.push(i),r+=4;for(o+=3;r<o;)i=re[r++],e.push(i);let s=n<16?Qd(n):Ky(n);return s!=null?e.string=s:e.string=$d(n)}var Yy=(n,t)=>{var e=bt();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let o=He[n];return o&&o.isShared&&((He.restoreStructures||(He.restoreStructures=[]))[n]=o),He[n]=e,e.read=Xd(e,r),e.read()},Jy=typeof self=="object"?self:global;ar[0]=()=>{};ar[0].noBuffer=!0;ar[101]=()=>{let n=bt();return(Jy[n[0]]||Error)(n[1])};ar[105]=n=>{let t=$e.getUint32(E-4);Yo||(Yo=new Map);let e=re[E],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let o={target:r};Yo.set(t,o);let i=bt();return o.used?Object.assign(r,i):(o.target=i,i)};ar[112]=n=>{let t=$e.getUint32(E-4),e=Yo.get(t);return e.used=!0,e.target};ar[115]=()=>new Set(bt());var Kd=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");ar[116]=n=>{let t=n[0],e=Kd[t];if(!e)throw new Error("Could not find typed array for code "+t);return new Jy[e](Uint8Array.prototype.slice.call(n,1).buffer)};ar[120]=()=>{let n=bt();return new RegExp(n[0],n[1])};ar[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=E;E+=t-4,Mr=[bt(),bt()],Mr.position0=0,Mr.position1=0;let r=E;E=e;try{return bt()}finally{E=r}};ar[255]=n=>n.length==4?new Date((n[0]*16777216+(n[1]<<16)+(n[2]<<8)+n[3])*1e3):n.length==8?new Date(((n[0]<<22)+(n[1]<<14)+(n[2]<<6)+(n[3]>>2))/1e6+((n[3]&3)*4294967296+n[4]*16777216+(n[5]<<16)+(n[6]<<8)+n[7])*1e3):n.length==12?new Date(((n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3])/1e6+((n[4]&128?-281474976710656:0)+n[6]*1099511627776+n[7]*4294967296+n[8]*16777216+(n[9]<<16)+(n[10]<<8)+n[11])*1e3):new Date("invalid");function eg(n){let t=An,e=E,r=Wd,o=Rr,i=vo,a=_n,s=qd,l=Yo,u=Mr,c=new Uint8Array(re.slice(0,An)),d=He,p=He.slice(0,He.length),f=mr,h=da,m=n();return An=t,E=e,Wd=r,Rr=o,vo=i,_n=a,qd=s,Yo=l,Mr=u,re=c,da=h,He=d,He.splice(0,He.length,...p),mr=f,$e=new DataView(re.buffer,re.byteOffset,re.byteLength),m}function Bc(){re=null,Yo=null,He=null}function tg(n){n.unpack?ar[n.type]=n.unpack:ar[n.type]=n}var Rc=new Array(147);for(let n=0;n<256;n++)Rc[n]=+("1e"+Math.floor(45.15-n*.30103));var Vc=new So({useRecords:!1}),jP=Vc.unpack,UP=Vc.unpackMultiple,HP=Vc.unpack,zc={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},qP=new Float32Array(1),mz=new Uint8Array(qP.buffer,0,4);var Gc;try{Gc=new TextEncoder}catch{}var kc,Jd,Fc=typeof Buffer<"u",Zd=Fc?Buffer.allocUnsafeSlow:Uint8Array,ig=Fc?Buffer:Uint8Array,rg=Fc?4294967296:2144337920,U,Pt,R=0,wo,_o=null,WP=/[\u0080-\uFFFF]/,Zs=Symbol("record-id"),li=class extends So{constructor(t){super(t),this.offset=0;let e,r,o,i,a,s,l=0,u=ig.prototype.utf8Write?function(x,T,C){return U.utf8Write(x,T,C)}:Gc&&Gc.encodeInto?function(x,T){return Gc.encodeInto(x,U.subarray(T)).written}:!1,c=this;t||(t={});let d=t&&t.sequential,p=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=p?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let h=t.maxOwnStructures;h==null&&(h=p?32:64),d&&!t.saveStructures&&(this.structures=[]);let m=f>32||h+f>64,y=f+64,g=f+h+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let b=[],S=0,w=0;this.pack=this.encode=function(x,T){if(U||(U=new Zd(8192),Pt=new DataView(U.buffer,0,8192),R=0),wo=U.length-10,wo-R<2048?(U=new Zd(U.length),Pt=new DataView(U.buffer,0,U.length),wo=U.length-10,R=0):R=R+7&2147483640,r=R,s=c.structuredClone?new Map:null,c.bundleStrings?(_o=["",""],U[R++]=214,U[R++]=98,_o.position=R-r,R+=4):_o=null,o=c.structures,o){o.uninitialized&&(o=c._mergeStructures(c.getStructures()));let C=o.sharedLength||0;if(C>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+o.sharedLength);if(!o.transitions){o.transitions=Object.create(null);for(let P=0;P<C;P++){let O=o[P];if(!O)continue;let M,I=o.transitions;for(let N=0,B=O.length;N<B;N++){let D=O[N];M=I[D],M||(M=I[D]=Object.create(null)),I=M}I[Zs]=P+64}l=C}d||(o.nextId=C+64)}i&&(i=!1),a=o||[];try{if(v(x),_o){Pt.setUint32(_o.position+r,R-_o.position-r);let C=_o;_o=null,v(C[0]),v(C[1])}if(c.offset=R,s&&s.idsToInsert){R+=s.idsToInsert.length*6,R>wo&&A(R),c.offset=R;let C=YP(U.subarray(r,R),s.idsToInsert);return s=null,C}return T&sg?(U.start=r,U.end=R,U):U.subarray(r,R)}finally{if(o){if(w<10&&w++,S>1e4)o.transitions=null,w=0,S=0,b.length>0&&(b=[]);else if(b.length>0&&!d){for(let C=0,P=b.length;C<P;C++)b[C][Zs]=0;b=[]}if(i&&c.saveStructures){let C=o.sharedLength||f;o.length>C&&(o=o.slice(0,C));let P=U.subarray(r,R);return c.saveStructures(o,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(x)):(l=C,P)}}T&tO&&(R=r)}};let v=x=>{R>wo&&(U=A(R));var T=typeof x,C;if(T==="string"){let P=x.length;if(_o&&P>=8&&P<4096){let I=WP.test(x);_o[I?0:1]+=x,U[R++]=193,v(I?-P:P);return}let O;P<32?O=1:P<256?O=2:P<65536?O=3:O=5;let M=P*3;if(R+M>wo&&(U=A(R+M)),P<64||!u){let I,N,B,D=R+O;for(I=0;I<P;I++)N=x.charCodeAt(I),N<128?U[D++]=N:N<2048?(U[D++]=N>>6|192,U[D++]=N&63|128):(N&64512)===55296&&((B=x.charCodeAt(I+1))&64512)===56320?(N=65536+((N&1023)<<10)+(B&1023),I++,U[D++]=N>>18|240,U[D++]=N>>12&63|128,U[D++]=N>>6&63|128,U[D++]=N&63|128):(U[D++]=N>>12|224,U[D++]=N>>6&63|128,U[D++]=N&63|128);C=D-R-O}else C=u(x,R+O,M);C<32?U[R++]=160|C:C<256?(O<2&&U.copyWithin(R+2,R+1,R+1+C),U[R++]=217,U[R++]=C):C<65536?(O<3&&U.copyWithin(R+3,R+2,R+2+C),U[R++]=218,U[R++]=C>>8,U[R++]=C&255):(O<5&&U.copyWithin(R+5,R+3,R+3+C),U[R++]=219,Pt.setUint32(R,C),R+=4),R+=C}else if(T==="number")if(x>>>0===x)x<64?U[R++]=x:x<256?(U[R++]=204,U[R++]=x):x<65536?(U[R++]=205,U[R++]=x>>8,U[R++]=x&255):(U[R++]=206,Pt.setUint32(R,x),R+=4);else if(x>>0===x)x>=-32?U[R++]=256+x:x>=-128?(U[R++]=208,U[R++]=x+256):x>=-32768?(U[R++]=209,Pt.setInt16(R,x),R+=2):(U[R++]=210,Pt.setInt32(R,x),R+=4);else{let P;if((P=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){U[R++]=202,Pt.setFloat32(R,x);let O;if(P<4||(O=x*Rc[(U[R]&127)<<1|U[R+1]>>7])>>0===O){R+=4;return}else R--}U[R++]=203,Pt.setFloat64(R,x),R+=8}else if(T==="object")if(!x)U[R++]=192;else{if(s){let O=s.get(x);if(O){if(!O.id){let M=s.idsToInsert||(s.idsToInsert=[]);O.id=M.push(O)}U[R++]=214,U[R++]=112,Pt.setUint32(R,O.id),R+=4;return}else s.set(x,{offset:R-r})}let P=x.constructor;if(P===Object)_(x,!0);else if(P===Array){C=x.length,C<16?U[R++]=144|C:C<65536?(U[R++]=220,U[R++]=C>>8,U[R++]=C&255):(U[R++]=221,Pt.setUint32(R,C),R+=4);for(let O=0;O<C;O++)v(x[O])}else if(P===Map){C=x.size,C<16?U[R++]=128|C:C<65536?(U[R++]=222,U[R++]=C>>8,U[R++]=C&255):(U[R++]=223,Pt.setUint32(R,C),R+=4);for(let[O,M]of x)v(O),v(M)}else{for(let O=0,M=kc.length;O<M;O++){let I=Jd[O];if(x instanceof I){let N=kc[O];if(N.write){N.type&&(U[R++]=212,U[R++]=N.type,U[R++]=0),v(N.write.call(this,x));return}let B=U,D=Pt,G=R;U=null;let L;try{L=N.pack.call(this,x,V=>(U=B,B=null,R+=V,R>wo&&A(R),{target:U,targetView:Pt,position:R-V}),v)}finally{B&&(U=B,Pt=D,R=G,wo=U.length-10)}L&&(L.length+R>wo&&A(L.length+R),R=$P(L,U,R,N.type));return}}_(x,!x.hasOwnProperty)}}else if(T==="boolean")U[R++]=x?195:194;else if(T==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))U[R++]=211,Pt.setBigInt64(R,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)U[R++]=207,Pt.setBigUint64(R,x);else if(this.largeBigIntToFloat)U[R++]=203,Pt.setFloat64(R,Number(x));else throw new RangeError(x+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");R+=8}else if(T==="undefined")this.encodeUndefinedAsNil?U[R++]=192:(U[R++]=212,U[R++]=0,U[R++]=0);else if(T==="function")v(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},_=this.useRecords===!1?this.variableMapSize?x=>{let T=Object.keys(x),C=T.length;C<16?U[R++]=128|C:C<65536?(U[R++]=222,U[R++]=C>>8,U[R++]=C&255):(U[R++]=223,Pt.setUint32(R,C),R+=4);let P;for(let O=0;O<C;O++)v(P=T[O]),v(x[P])}:(x,T)=>{U[R++]=222;let C=R-r;R+=2;let P=0;for(let O in x)(T||x.hasOwnProperty(O))&&(v(O),v(x[O]),P++);U[C+++r]=P>>8,U[C+r]=P&255}:x=>{let T=Object.keys(x),C,P=a.transitions||(a.transitions=Object.create(null)),O=0;for(let I=0,N=T.length;I<N;I++){let B=T[I];C=P[B],C||(C=P[B]=Object.create(null),O++),P=C}let M=P[Zs];if(M)M>=96&&m?(U[R++]=((M-=96)&31)+96,U[R++]=M>>5):U[R++]=M;else{M=a.nextId,M||(M=64),M<y&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(M=a.nextOwnId,M<g||(M=y),a.nextOwnId=M+1):(M>=g&&(M=y),a.nextId=M+1);let I=T.highByte=M>=96&&m?M-96>>5:-1;P[Zs]=M,a[M-64]=T,M<y?(T.isShared=!0,a.sharedLength=M-63,i=!0,I>=0?(U[R++]=(M&31)+96,U[R++]=I):U[R++]=M):(I>=0?(U[R++]=213,U[R++]=114,U[R++]=(M&31)+96,U[R++]=I):(U[R++]=212,U[R++]=114,U[R++]=M),O&&(S+=w*O),b.length>=h&&(b.shift()[Zs]=0),b.push(P),v(T))}for(let I=0,N=T.length;I<N;I++)v(x[T[I]])},A=x=>{let T;if(x>16777216){if(x-r>rg)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(rg,Math.round(Math.max((x-r)*(x>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(x-r<<2,U.length-1)>>12)+1<<12;let C=new Zd(T);return Pt=new DataView(C.buffer,0,T),U.copy?U.copy(C,0,r,x):C.set(U.slice(r,x)),R-=r,r=0,wo=C.length-10,U=C}}useBuffer(t){U=t,Pt=new DataView(U.buffer,U.byteOffset,U.byteLength),R=0}};Jd=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Ks];kc=[{pack(n,t,e){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:i,position:a}=t(6);o[a++]=214,o[a++]=255,i.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:o,targetView:i,position:a}=t(10);o[a++]=215,o[a++]=255,i.setUint32(a,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:o,targetView:i,position:a}=t(3);o[a++]=212,o[a++]=255,o[a++]=255}else{let{target:o,targetView:i,position:a}=t(15);o[a++]=199,o[a++]=12,o[a++]=255,i.setUint32(a,n.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(n,t,e){let r=Array.from(n),{target:o,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(o[i++]=212,o[i++]=115,o[i++]=0),e(r)}},{pack(n,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=101,r[o++]=0),e([n.name,n.message])}},{pack(n,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=120,r[o++]=0),e([n.source,n.flags])}},{pack(n,t){this.structuredClone?og(n,16,t):ng(Fc?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==ig&&this.structuredClone?og(n,Kd.indexOf(e.name),t):ng(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function og(n,t,e,r){let o=n.byteLength;if(o+1<256){var{target:i,position:a}=e(4+o);i[a++]=199,i[a++]=o+1}else if(o+1<65536){var{target:i,position:a}=e(5+o);i[a++]=200,i[a++]=o+1>>8,i[a++]=o+1&255}else{var{target:i,position:a,targetView:s}=e(7+o);i[a++]=201,s.setUint32(a,o+1),a+=4}i[a++]=116,i[a++]=t,i.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),a)}function ng(n,t){let e=n.byteLength;var r,o;if(e<256){var{target:r,position:o}=t(e+2);r[o++]=196,r[o++]=e}else if(e<65536){var{target:r,position:o}=t(e+3);r[o++]=197,r[o++]=e>>8,r[o++]=e&255}else{var{target:r,position:o,targetView:i}=t(e+5);r[o++]=198,i.setUint32(o,e),o+=4}r.set(n,o)}function $P(n,t,e,r){let o=n.length;switch(o){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:o<256?(t[e++]=199,t[e++]=o):o<65536?(t[e++]=200,t[e++]=o>>8,t[e++]=o&255):(t[e++]=201,t[e++]=o>>24,t[e++]=o>>16&255,t[e++]=o>>8&255,t[e++]=o&255)}return t[e++]=r,t.set(n,e),e+=o,e}function YP(n,t){let e,r=t.length*6,o=n.length-r;for(t.sort((i,a)=>i.offset>a.offset?1:-1);e=t.pop();){let i=e.offset,a=e.id;n.copyWithin(i+r,i,o),r-=6;let s=i+r;n[s++]=214,n[s++]=105,n[s++]=a>>24,n[s++]=a>>16&255,n[s++]=a>>8&255,n[s++]=a&255,o=i}return n}function Pn(n){if(n.Class){if(!n.pack&&!n.write)throw new Error("Extension has no pack or write function");if(n.pack&&!n.type)throw new Error("Extension has no type (numeric code to identify the extension)");Jd.unshift(n.Class),kc.unshift(n)}tg(n)}var ag=new li({useRecords:!1}),XP=ag.pack,QP=ag.pack;var{NEVER:KP,ALWAYS:ZP,DECIMAL_ROUND:JP,DECIMAL_FIT:eO}=zc,sg=512,tO=1024;var lg=new li({structuredClone:!0});Pn({Class:ue.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,ue.prototype),n}});Pn({Class:me.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,me.prototype),n}});Pn({Class:tt.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,tt.prototype),n}});Pn({Class:Xs.prototype.constructor,type:4,write(n){return n.id},read(n){return new Xs(n)}});Pn({Class:Qs.prototype.constructor,type:5,write(n){return n.data},read(n){return new Qs(n)}});Pn({Class:rt.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,rt.prototype),n}});function rO(n){var t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){let r=n[e];t=(t<<5)-t+r,t=t&t}return t}function ep(n){if(ia(n))return n;if(Array.isArray(n))return n.map(ep);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=ep(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var jc;(r=>{function n(o){return lg.pack(o)}r.serialize=n;function t(o){return lg.unpack(o)}r.deserialize=t;function e(o){return rO(n(ep(o))).toString()}r.checksum=e})(jc||(jc={}));var Tn="personal camera",Mn="a218fcc3-276b-49b9-b485-49037fd14f5f",fg=2960946,Ot=5526619;var Js;(d=>{function n(p,f){return p[0]===f[0]&&p[1]===f[1]}d.isEqual=n;function t(p,f,h){return[p[0]+(f[0]-p[0])*h,p[1]+(f[1]-p[1])*h]}d.lerp=t;function e(p,f){return[p[0]+f[0],p[1]+f[1]]}d.add=e;function r(p,f){return[p[0]-f[0],p[1]-f[1]]}d.sub=r;function o(p,f){return Math.pow(f[0]-p[0],2)+Math.pow(f[1]-p[1],2)}d.distanceSquared=o;function i(p,f){return Math.sqrt(o(p,f))}d.distance=i;function a(p,f){return p[0]*f[0]+p[1]*f[1]}d.dot=a;function s(p,f){return[p[0]*f,p[1]*f]}d.scalarMultiply=s;function l(p,f,h){let m=d.sub(f,p),y=d.sub(h,p),g=d.dot(m,y)/d.dot(m,m),b=d.scalarMultiply(m,g);return d.add(p,b)}d.projectionOnto=l;function u(p,f,h){return i(p,l(p,f,h))}d.projectionOntoDistance=u;function c(p,f){return[(p[0]+f[0])*.5,(p[1]+f[1])*.5]}d.center=c})(Js||(Js={}));var On;(s=>{function n(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}s.isEqual=n;function t(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]}s.add=t;function e(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]}s.sub=e;function r(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}s.div=r;function o(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}s.mul=o;function i(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])}s.dist=i;function a(l,u,c){return[l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c]}s.lerp=a})(On||(On={}));var cg;(e=>{function n(r,o){return r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]}e.isEqual=n;function t(r,o,i){return[r[0]+(o[0]-r[0])*i,r[1]+(o[1]-r[1])*i,r[2]+(o[2]-r[2])*i,r[3]+(o[3]-r[3])*i]}e.lerp=t})(cg||(cg={}));var Cn;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(i,a){for(let s=0;s<16;s++)if(i[s]!==a[s])return!1;return!0}o.isEqual=t;function e(i){return i??o.identity}o.simplify=e;function r(i,a){let s=a.slice(0);for(var l=0,u=a.length;l<u;l+=3){let c=i[3]*a[l]+i[7]*a[l+1]+i[11]*a[l+2]+i[15];s[l]=(i[0]*a[l]+i[4]*a[l+1]+i[8]*a[l+2]+i[12])/c,s[l+1]=(i[1]*a[l]+i[5]*a[l+1]+i[9]*a[l+2]+i[13])/c,s[l+2]=(i[2]*a[l]+i[6]*a[l+1]+i[10]*a[l+2]+i[14])/c}return s}o.applyMatrix4=r})(Cn||(Cn={}));var jt;(c=>{function n(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}c.isRGB=n,c.white={r:1,g:1,b:1},c.red={r:1,g:0,b:0},c.black={r:0,g:0,b:0};function o(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}c.toRgb255a1=o;function i(d){return{r:d.r,g:d.g,b:d.b}}c.clone=i;function a(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}c.fromHex=a;function s(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}c.toHex=s;function l(d,p){return d.r===p.r&&d.g===p.g&&d.b===p.b}c.equals=l;function u(d,p,f){return{r:d.r+(p.r-d.r)*f,g:d.g+(p.g-d.g)*f,b:d.b+(p.b-d.b)*f}}c.lerp=u})(jt||(jt={}));var Oe;(l=>{l.white={...jt.white,a:1},l.transparent={...jt.white,a:0};function e(u){return{r:u[0],g:u[1],b:u[2],a:u[3]}}l.from0to1=e;function r(u,c){return{...jt.fromHex(u),a:c}}l.fromHexAndA=r;function o(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:u.a}}l.toRgb255a1=o;function i(u,c){return jt.equals(u,c)&&u.a===c.a}l.equals=i;function a(u,c,d){return{r:u.r+(c.r-u.r)*d,g:u.g+(c.g-u.g)*d,b:u.b+(c.b-u.b)*d,a:u.a+(c.a-u.a)*d}}l.lerp=a;function s({r:u,g:c,b:d,a:p}=l.white){return`rgba(${u*255}, ${c*255}, ${d*255}, ${p})`}l.toStyle=s})(Oe||(Oe={}));var Uc;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Uc||(Uc={}));var ug;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(ug||(ug={}));var dg;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(dg||(dg={}));var pg;(i=>(i.linear=[0,0,1,1],i.ease=[.25,.1,.25,1],i.easeIn=[.42,0,1,1],i.easeOut=[0,0,.58,1],i.easeInOut=[.42,0,.58,1]))(pg||(pg={}));function tp(n){return typeof n=="string"&&n.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n):!1}var Jr;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(Jr||(Jr={}));var In;(o=>{o.DefaultUp=[0,1,0],o.DefaultTargetOffset=1e3,o.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function r(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}o.getZoom=r})(In||(In={}));var Ao;(e=>{function n(r,o=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*o,0,0]},grid:{count:[2,2,2],size:r.map(i=>i*(1+o)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=n;function t(r,o){let i={...r};if(oO.forEach(a=>{Object.assign(i,{[a]:o[a]??r[a]})}),i.radial={...r.radial},o.radial){let a=r.radial,s=o.radial;nO.forEach(l=>{Object.assign(i.radial,{[l]:s[l]??a[l]})})}if(i.linear={...r.linear},o.linear){let a=r.linear,s=o.linear;iO.forEach(l=>{Object.assign(i.linear,{[l]:s[l]??a[l]})})}if(i.grid={...r.grid},o.grid){let a=r.grid,s=o.grid;aO.forEach(l=>{Object.assign(i.grid,{[l]:s[l]??a[l]})})}if(i.toObject={...r.toObject},o.toObject){let a=r.toObject,s=o.toObject;sO.forEach(l=>{Object.assign(i.toObject,{[l]:s[l]??a[l]})})}if(i.randomnessObject={...r.randomnessObject},o.randomnessObject){let a=r.randomnessObject,s=o.randomnessObject;lO.forEach(l=>{Object.assign(i.randomnessObject,{[l]:s[l]??a[l]})})}return i}e.merge=t})(Ao||(Ao={}));var Hc;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(o,i){let a=[];o.count!==void 0&&a.push({type:0,path:i,props:{count:o.count}});for(let s of t){let l=o[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...i,s],props:l})}return a}r.toOps=e})(Hc||(Hc={}));var oO=["count"],nO=["radius","start","end","position","scale","rotation"],iO=["position","scale","rotation"],aO=["count","size"],sO=["count","position","scale","rotation"],lO=["strength","scale","rotation","position","movement","seed","freqScale"];var qc;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(qc||(qc={}));var Wc;(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:Oe.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Oe.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:Oe.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Wc||(Wc={}));var pa;(r=>(r.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},r.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},r.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:r.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeLoopDelayStart:"end",emitTimeDuration:1,...r.defaultCollisionData}))(pa||(pa={}));var Nn;(t=>t.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(Nn||(Nn={}));var rp;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}e.equals=t})(rp||(rp={}));var op;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,o){return r.flatShading===o.flatShading&&r.side===o.side&&r.wireframe===o.wireframe}e.equals=t})(op||(op={}));var $c;(t=>t.defaultData={...op.defaultData,...rp.defaultData})($c||($c={}));var hg;(t=>{function n(e,r){let o=[];if("material"in e){let i=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;i&&o.push(i)}else if("materials"in e)for(let i of e.materials){let a=typeof i=="string"?r.materials[i]??r.lib.materials[i]?.asset:i;a&&o.push(a)}return o}t.getMaterialData=n})(hg||(hg={}));var fa;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(fa||(fa={}));var mg;(t=>{function n(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="particle"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=n})(mg||(mg={}));function gg(n){return n.type!=="displace"}var yg;(t=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=n})(yg||(yg={}));var xg=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],bg=["wrapping","image","video","name"],Mt;(o=>{function n(i,a){let{texture:s,...l}=a;if(Object.assign(i,l),s){let u=i.texture;u&&Object.assign(u,s)}}o.patch=n;function t(i,a){return i==="light"&&a?e(a):r(i)}o.defaultData=t;function e(i){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(i){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(i){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(i){case"texture":return{...a,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:fa.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...a,type:"color",color:jt.fromHex(Ot)};case"depth":return{...a,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...jt.fromHex(6710886),a:1},colorB:{...jt.fromHex(6710886),a:1},colorC:{...jt.fromHex(16777215),a:1},colorD:{...jt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:Oe.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Oe.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:Oe.fromHexAndA(0,1),contourColor:Oe.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...a,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...jt.fromHex(0),a:1},colorB:{...jt.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(Mt||(Mt={}));var Qt;(u=>{function n(c){return!c.layers.some(p=>p.data.type==="texture"&&p.data.projection!==0||p.data.type==="depth"&&!p.data.isWorldSpace||p.data.type==="noise"||p.data.type==="displace")}u.isMergable=n;function t(c){let d="";return c.layers.forEach(p=>{Object.entries(p.data).forEach(([f,h])=>{d+=`${f}${h}`,Array.isArray(h)?h.forEach(m=>d+=`${m}`):typeof h=="object"?Object.values(h).forEach(m=>{typeof m=="number"?d+=`${m.toFixed(4)}`:d+=`${m}`}):d+=`${h}`})}),d}u.getHash=t;function e(){return{layers:new me}}u.defaultEmptyData=e;function r(c="layer1",d="layer2"){return i("phong",c,d)}u.defaultData=r;function o(c,d){return{...c,name:d}}u.withName=o;function i(c,d="layer1",p="layer2"){let f=new me;return f.push({fi:0,data:Mt.defaultData("light",c),id:d}),f.push({fi:1,data:Mt.defaultData("color"),id:p}),{layers:f}}u.defaultTwoLayerData=i;function a(c){let d=Mt.defaultData("texture");c&&Object.assign(d.texture,{image:c});let p=new me;return p.push({fi:0,data:d,id:"layer1"}),p.push({fi:1,data:{...Mt.defaultData("transmission"),alpha:1},id:"layer2"}),p.push({fi:2,data:{...Mt.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:p}}u.defaultUIObjectMaterial=a;function s(c,d="phong",p="layer1",f="layer2"){let h=Mt.defaultData("texture");Object.assign(h.texture,{image:c});let m=new me;return m.push({fi:0,data:h,id:p}),m.push({fi:1,data:Mt.defaultData("light",d),id:f}),{layers:m}}u.defaultTwoLayerTextureData=s;function l(c,d="phong",p="layer1",f="layer2"){let h=Mt.defaultData("video");Object.assign(h.texture,{video:c});let m=new me;return m.push({fi:0,data:h,id:p}),m.push({fi:1,data:Mt.defaultData("light",d),id:f}),{layers:m}}u.defaultTwoLayerVideoTextureData=l})(Qt||(Qt={}));var ha;(t=>{function n(){return{points:new me,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(ha||(ha={}));var ma;(t=>{function n(){return{points:new me,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=n})(ma||(ma={}));var np={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Yc;(t=>{function n(e,r){let o={...e};return cO.forEach(i=>{Object.assign(o,{[i]:r[i]??e[i]})}),o}t.merge=n})(Yc||(Yc={}));var Xc={shape:np,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},cO=["depth","offset","angle","twist","startScale","endScale"];var el;(e=>{function n(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=n;function t(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=t})(el||(el={}));var Qc;(t=>{function n(e,r){let o={...e};return Object.assign(o,r),o.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(o.extrusion={...e.extrusion},Object.assign(o.extrusion,Yc.merge(o.extrusion,r.extrusion))),o}t.merge=n})(Qc||(Qc={}));var Dn;(t=>{function n(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="UIGeometry")return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:ma.defaultData(),extrusion:Xc};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:ha.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}t.defaultData=n})(Dn||(Dn={}));var Kc;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:jt.white,near:.1,far:2e3})(Kc||(Kc={}));var Zc;(e=>{let n={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...n,blendFunction:16,granularity:15},bloom:{...n,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...n,offset:[2,2]},vignette:{...n,darkness:1,offset:0},hueSaturation:{...n,hue:3,saturation:0},brightnessContrast:{...n,brightness:.25,contrast:0},depthOfField:{...n,focalLength:2,focusDistance:2,bokehScale:2},noise:{...n,blendFunction:16}}})(Zc||(Zc={}));var ip;(t=>t.defaultData={softShadowQuality:"low"})(ip||(ip={}));var ap;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(ap||(ap={}));var sp;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(sp||(sp={}));var tl;(t=>t.defaultData={usePhysics:!1,gravity:-10})(tl||(tl={}));var lp;(t=>t.defaultData={playCamera:Tn,gameControlObject:null})(lp||(lp={}));var Jc;(t=>t.defaultData={backgroundColor:Oe.fromHexAndA(fg,1),postprocessing:Zc.defaultData,fog:Kc.defaultData,globalPhysics:tl.defaultData,ambient:ap.defaultData,ao:sp.defaultData,shadow:ip.defaultData,publish:lp.defaultData})(Jc||(Jc={}));var eu;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(eu||(eu={}));var vg;(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(vg||(vg={}));var ya;(o=>{o.identity={...Uc.identity,hiddenMatrix:Cn.identity};function t(i){return{position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix}}o.fromObject=t;function e(i,a){return{position:a?.position||i.position,rotation:a?.rotation||i.rotation,scale:a?.scale||i.scale,hiddenMatrix:a?.hiddenMatrix||i.hiddenMatrix}}o.merge=e;function r(i,a){return Jl({position:On.isEqual(i.position,a.position)?void 0:a.position,rotation:On.isEqual(i.rotation,a.rotation)?void 0:a.rotation,scale:On.isEqual(i.scale,a.scale)?null:a.scale,hiddenMatrix:Cn.isEqual(i.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=r})(ya||(ya={}));var Dt;(t=>t.defaultData={states:new me,events:new me,visible:!0,raycastLock:!1,physics:Nn.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...ya.identity,cloner:null})(Dt||(Dt={}));var tu;(t=>t.defaultData={type:"Empty",...Dt.defaultData})(tu||(tu={}));var Sg;(t=>t.defaultData={type:"ParticleCollider",...eu.defaultData,...Dt.defaultData})(Sg||(Sg={}));var wg;(t=>t.defaultData={type:"Component",...Dt.defaultData})(wg||(wg={}));var _g;(t=>t.defaultData={type:"Particle",...Dt.defaultData,...pa.defaultData})(_g||(_g={}));var ci;(t=>t.defaultData={type:"Mesh",...Dt.defaultData,...$c.defaultData})(ci||(ci={}));var ui;(t=>t.defaultData={...Dt.defaultData,...ya.identity,position:[0,0,In.DefaultTargetOffset],...In.defaultData})(ui||(ui={}));var ru;(e=>{function n(r){return{...Dt.defaultData,...Wc.defaultData(r)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(ru||(ru={}));var ga;(e=>{function n(r,o,i=0){for(;i<o.length;){let a=r?r[o[i]]:void 0;if(o.length===i+1)return a;if(a)r=a.descendants,i+=1;else return}}e.resolveWithDes=n;function t(r,o,i=0){let a=n(r,o,i);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=t})(ga||(ga={}));var Po;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function r(a,s){return{...Dt.defaultData,...s,component:a,overrides:new rt,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=r;function o(a){let s=ya.fromObject(a.data);return r(a.id,s)}i.fromComponentData=o})(Po||(Po={}));var Xo;(e=>{e.defaultData={type:"Page",...Dt.defaultData,physics:{...Nn.defaultData,fusedBody:!1},...Jc.defaultData,camera:ui.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(Xo||(Xo={}));var ou;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Cn.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Nn.defaultData,states:new me,events:new me,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...In.defaultData},i.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},i.defaultMeshObject={name:"Rectangle",...Dt.defaultData,...ci.defaultData,geometry:Dn.defaultData("RectangleGeometry"),material:Qt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...Dt.defaultData,...ci.defaultData,geometry:Dn.defaultData("BooleanGeometry"),material:Qt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...Dt.defaultData,...ci.defaultData,geometry:Dn.defaultData("TextGeometry"),material:Qt.defaultTwoLayerData("phong","layer1","layer2")}))(ou||(ou={}));var di;(o=>{function n(i,a){let s={name:a};return i.type==="Mesh"?(s.geometry={},"material"in i&&(s.material={layers:new rt}),"materials"in i&&(s.materials=i.materials.map(l=>({layers:new rt})))):Jr.is(i.type)&&(s.perspective={},s.orthographic={}),s}o.newEmpty=n;function t(i,a){if(a===void 0)return i;let s={...i};return"material"in s&&"material"in a&&a.material&&(s.material=wn(s.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(a.material.layers)){let d=l.layers.data(u);d&&Mt.patch(d,c)}}).data),s.materials&&a.materials&&(s.materials=wn(s.materials,l=>{for(let u=0;u<s.materials.length;u++){let c=a.materials[u];if(typeof c!="string")for(let[d,p]of Object.entries(c.layers)){let f=l[u]?.layers?.data(d);f&&Mt.patch(f,p)}}}).data),s}function e(i,a){let s,l=[],u={orthographic:0,perspective:0,geometry:0};function c(d,p){for(let[f,h]of Object.entries(p.layers)){let{texture:m,...y}=h;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...d,"layers",f,"texture"],props:m,type:0};l.push(g)}if(Object.keys(y).length>0){let g={path:[...d,"layers",f],props:y,type:0};l.push(g)}}}for(let[d,p]of Object.entries(a))if(d!=="name")if(d==="cloner")l.push(...Hc.toOps(p,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:p.slide,offset:p.offset},type:0});else if(d==="material")c(["material"],p);else if(d==="materials")for(let[f,h]of Object.entries(p))c(["materials",f],h);else if(u[d]===0){if(d==="geometry"&&p.extrusion!==void 0){let f={path:[d,"extrusion"],props:p.extrusion,type:0};l.push(f),p={...p},delete p.extrusion}if(Object.keys(p).length>0){let f={path:[d],props:p,type:0};l.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[d]=p;return l}o.toOps=e;function r(i,a){if(a===void 0)return i;let s={...i};if(Object.assign(s,ya.merge(s,a)),Object.assign(s,{pathSnapping:Object.assign({},s.pathSnapping,{slide:a.pathSnapping?.slide??s.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??s.pathSnapping?.offset??0})}),Jr.is(i.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let l=a;l.orthographic?.zoom!==void 0&&(s.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(s.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(s.targetOffset=l.targetOffset)}else if(i.type==="Mesh")"geometry"in a&&Object.assign(s,{geometry:Qc.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=t(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Ao.merge(s.cloner,a.cloner)});else if(i.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Ao.merge(s.cloner,a.cloner)});else if(qc.is(i.type)){let l=a;l.intensity!==void 0&&(s.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?s.color=l.color:s.color=jt.clone(l.color))}return s}o.patch=r})(di||(di={}));var xa;(t=>t.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(xa||(xa={}));var eo;(t=>t.defaultData={orbitControls:xa.defaultData,playPage:Mn,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let o=0,i=0;return r<5?i=-30:r<10&&(i=30),r===0||r===10||r===5?o=30:(r===4||r===11||r===9)&&(o=-30),[120,[o,i],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(eo||(eo={}));var cp;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(cp||(cp={}));var up;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(up||(up={}));var Qo;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...cp.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:up.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Qo||(Qo={}));var Ag;(e=>{function n(r){return r.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=n;function t(r,o,i){r.scene.objects.traverseFrom(o,(a,s)=>{if(s.type==="Instance"){let l=ba.getComponentData(r,s.component)?.data;l&&i(a,s,l.events)}else i(a,s,s.events)})}e.traverseModuleInstances=t})(Ag||(Ag={}));var Ko;(l=>{l.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(u={withLight:!0,withSquare:!0}){let c=[],d=ou.defaultMeshObject;u.withLight===!0&&c.push({fi:-1,data:ru.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),u.withSquare===!0&&c.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:d,children:[]});let p=new tt;return p.push({fi:1,id:Mn,data:{...Xo.defaultData,name:"Scene 1"},children:c}),p}l.defaultData={objects:t(),publish:eo.defaultData,styles:Qo.defaultData()},l.emptyDataWithoutPage=function(){return{objects:new tt,publish:eo.defaultData,styles:Qo.defaultData()}},l.emptyDataWithPage=function(u){return{objects:t(u),publish:eo.defaultData,styles:Qo.defaultData()}},l.emptyData=function(){return{objects:new tt,publish:{...eo.defaultData},styles:Qo.defaultData()}};function a(u){return{...l.defaultData,objects:ir(u,tt.prototype)}}l.withObjs=a;function s(u,c){return a([{id:u,data:c,children:[],fi:0}])}l.withObj=s})(Ko||(Ko={}));var va;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(va||(va={}));var Sa;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Sa||(Sa={}));var nu;(i=>{function n(a){return a.textValue!==void 0}i.isTextValue=n;function t(a){return typeof a=="number"}i.isNumber=t;function e(a){return typeof a=="boolean"}i.isBoolean=e;function r(a){return n(a)?"string":e(a)?"boolean":"number"}i.typeOfVariable=r;function o(a){return i.isTextValue(a)?Array.isArray(a.textValue)?a.textValue.map(s=>s.toString().padStart(a.padding??2,"0")).join(a.deliminator??":")+(a.suffix!==void 0?" "+a.suffix:""):a.textValue.toString():i.isBoolean(a)?a?"True":"False":i.isNumber(a)?parseFloat(a.toFixed(3)).toString():a.toString()}i.getDisplayedValue=o})(nu||(nu={}));var dp;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(dp||(dp={}));var Pg;(t=>t.all=[...dp.all,"components"])(Pg||(Pg={}));var Og;(t=>{function n(){return{images:new ue,videos:new ue,colors:new ue,audios:new ue,particles:new ue,fonts:new ue,materials:new ue,components:new ue,variables:new ue}}t.defaultData=n})(Og||(Og={}));var Zo;(t=>{function n(){return{images:new ue,videos:new ue,colors:new ue,audios:new ue,particles:new ue,fonts:new ue,materials:new ue,components:new ue,variables:new ue}}t.defaultData=n})(Zo||(Zo={}));var zr;(i=>{function n(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},ir(a,ue.prototype)}i.defaultColors=n;function t(a){let s={};return a?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Sa.emptyImage,name:"AI generated image"}),ir(s,ue.prototype)}i.defaultImages=t;function e(){return{catelogs:new ue,materials:new ue,images:new ue,videos:new ue,colors:new ue,audios:new ue,particles:new ue,fonts:new ue,variables:new me,lib:Zo.defaultData()}}i.emptyData=e;function r(a){switch(a){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let s=[0,0,0];return{name:"Time",value:{textValue:s,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:s,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",a)}}i.defaultVariables=r;function o(a,s){if(s.format==="HH:mm:ss"){let l=Math.floor(a/3600),u=Math.floor((a-l*3600)/60),c=Math.round(a-l*3600-u*60);return{textValue:[l,u,c]}}else if(s.format==="mm:ss"){let l=Math.floor(a/60),u=Math.round(a-l*60);return{textValue:[l,u]}}else return s.format==="number"?a=Math.round(a):a=Math.round(a*1e3)/1e3,a}i.getFormattedTimerTime=o})(zr||(zr={}));var rl=require("three");var iu;(t=>t.list=["idle","move","jump","run"])(iu||(iu={}));var au;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new me,move:new me,jump:new me,run:new me},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Oe.fromHexAndA(3728051,1)}}))(au||(au={}));function Cg(n){n.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,o=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],i=[0,1];for(let s=2;s<10;s++)o.push(o[1]),i.push(1);let a={...Zr(ft(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:o,steps:i,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...ft(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Jo(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function en(n,t){n.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((o,i)=>{o===void 0&&(r.materials[i]=Qt.defaultData(),o=r.materials[i]),typeof o!="string"&&t(o)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Qt.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Qt.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&Object.getPrototypeOf(o.material)!==rt.prototype&&t(o.material)})})}function uO(n){Object.assign(n.scene.publish,{orbitControls:{...xa.defaultData,...ft(n.scene.publish.orbitControls)}})}function dO(n){Object.assign(n.scene.publish.settings,{video:{...eo.defaultData.settings.video,...ft(n.scene.publish.settings.video)}})}function pO(n){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[o,i]of Object.entries(r))if((xg.includes(o)||typeof i=="boolean")&&delete r[o],o==="texture")for(let[a,s]of Object.entries(i))(bg.includes(a)||typeof s=="boolean")&&delete i[a]}}}n.scene.objects.traverse((e,r)=>{r.states.forEach(o=>{let i=o;i.material?t(i.material):i.materials&&i.materials.forEach(a=>{t(a)})})})}function fO(n){n.scene.publish.withBackground=!0}function hO(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function mO(n){n.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(o=>o+1),r.linear.scale=r.linear.scale.map(o=>o+1))})}function yO(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function gO(n){n.scene.objects.traverse((t,e)=>{let r=n.scene.objects.unproxy().parent(t);if(r){let o=ft(n.scene.objects.data(r));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=ft(e).booleanExclude!==!0)}})}function xO(n){n.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function bO(n){function t(r){Object.setPrototypeOf(r,rt.prototype),r.texture&&Object.setPrototypeOf(r.texture,rt.prototype)}function e(r){Object.setPrototypeOf(r,rt.prototype);for(let o in r)t(r[o])}n.scene.objects.traverse((r,o)=>{o.states.forEach(i=>{let a=i;if(a.material){let s=ft(a.material).layers;e(s),a.material.layers=s}if(a.materials)for(let s=0;s<a.materials.length;s++){let l=a.materials[s],u=ft(l).layers;e(u),l.layers=u}})})}function Tg(n){n.layers===void 0&&Object.assign(n,Qt.defaultTwoLayerData("lambert"))}function pp(n){!n.layers||n.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let o={...ft(t),colors:e,steps:r};Object.assign(t,o)}})}function vO(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function Mg(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&pp(r)}):"material"in e&&typeof e.material!="string"&&pp(e.material)}),Object.values(n.shared.materials).forEach(t=>pp(t))}function SO(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}function wO(n){n.shared.audios=ir({},ue.prototype)}function _O(n){n.shared.videos=ir({},ue.prototype)}function AO(n){let t=n.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.layers){let o={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:o})}})}function PO(n){Object.entries(ft(n.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.images[r]}),Object.entries(ft(n.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.audios[r]})}function OO(n){n.scene.publish.settings.web.preload=!1}function Ig(n){n.layers&&n.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function Ng(n){n.layers&&n.layers.forEach(t=>{gg(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function CO(n){n.shared.fonts=ir({},ue.prototype)}function TO(n){return n.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function MO(n){let t=[];n.scene.objects.traverse((e,r)=>{let o=r;if(o.type==="TextFrame"){let i=Qt.defaultTwoLayerData("phong"),a=typeof o.color=="string"?n.shared.colors[o.color]:o.color;i.layers[1].data.color={r:a.r,g:a.g,b:a.b},i.layers[1].data.alpha=o.alpha;let s=TO(o.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let l={name:o.name,...Dt.defaultData,...ci.defaultData,flatShading:!1,wireframe:!1,geometry:{...Dn.defaultData("TextGeometry"),width:o.width,height:o.height,font:s,depth:0,horizontalAlign:o.horizontalAlign,verticalAlign:o.verticalAlign,fontSize:o.fontSize*1.40625,lineHeight:o.lineHeight/1.40625,letterSpacing:o.letterSpacing-1,text:o.text,textTransform:o.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:i,states:ft(o.states),events:ft(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},u=ft(n.scene.objects).parent(e);n.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{n.scene.objects.delete(e)})}function IO(n){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};n.scene.objects.traverse((e,r)=>{r.events.forEach(o=>{if(!!t[Number(o.type)])if(Object.assign(o,{type:t[Number(o.type)]}),o.type==="Audio"&&"audioEvent"in o&&(Object.assign(o,{playAudio:o.audioEvent}),delete o.audioEvent),o.type==="GameControl")Object.assign(o,{gameActions:{idle:new me,move:new me,jump:new me}});else{let i=new me;Object.assign(o,{actions:i}),(o.type==="MouseDown"||o.type==="MouseUp"||o.type==="KeyDown"||o.type==="KeyUp")&&"url"in o&&i.push({fi:0,id:rl.MathUtils.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((a,s,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(c,Zr(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(c,{control1:{...a.control1},control2:{...a.control2}});let d={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},p={state:a.state,...d,...c},f={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new me({fi:0,id:rl.MathUtils.generateUUID(),data:u},{fi:1,id:rl.MathUtils.generateUUID(),data:p})};i.push({fi:l,id:s,data:f})}),delete o.targets)}})})}function NO(n){n.scene.objects.traverse((t,e)=>{function r(o,i){let a=new me,s=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===i){let d;s.push(u),l.interaction==="play"?d={...Zr(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(d={...Zr(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&a.push({fi:c,id:u,data:d})}}),s.forEach(l=>e.events.delete(l)),a.length){let l=e.events.find(u=>u.type===o)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):e.events.insertBefore(null,[{id:rl.MathUtils.generateUUID(),data:{type:o,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function Dg(n){let t=n.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Mt.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function Eg(n){Jo(n,Dg),en(n,Dg)}function DO(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function EO(n){n.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function BO(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Qt.defaultTwoLayerData("phong"))})}function LO(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function RO(n){n.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function VO(n){n.scene.publish.mouseEventTarget===void 0&&(n.scene.publish.mouseEventTarget="canvas"),n.scene.publish.settings.web.hint===void 0&&(n.scene.publish.settings.web.hint=!1)}function zO(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function GO(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function kO(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function FO(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=au.defaultDataThirdPerson.navmesh)})})}function jO(n){n.scene.styles||(n.scene.styles=Qo.defaultData())}function Bg(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function UO(n){n.scene.environment.ambientLight.occlusion===void 0&&(n.scene.environment.ambientLight.occlusion=!1),n.scene.environment.ambientLight.aoFullRes===void 0&&(n.scene.environment.ambientLight.aoFullRes=!1),n.scene.environment.ambientLight.radius===void 0&&(n.scene.environment.ambientLight.radius=256),n.scene.environment.ambientLight.bias===void 0&&(n.scene.environment.ambientLight.bias=.5),n.scene.environment.ambientLight.aoColor===void 0&&(n.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),en(n,Bg),Jo(n,Bg)}function HO(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new me})})})}function qO(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function Lg(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function Rg(n,t){if(t<1&&(en(n,Cg),Jo(n,Cg),n.schema=1),t<2&&(uO(n),n.schema=2),t<3&&(pO(n),n.schema=3),t<4&&(fO(n),n.schema=4),t<5&&(hO(n),n.schema=5),t<6&&(mO(n),n.schema=6),t<7&&(yO(n),n.schema=7),t<8&&(n.schema=8),t<9&&(Mg(n),n.schema=9),t<10&&(vO(n),n.schema=10),t<11&&(SO(n),n.schema=11),t<12&&(Mg(n),n.schema=12),t<13&&(wO(n),n.schema=13),t<14&&(AO(n),n.schema=14),t<15&&(PO(n),n.schema=15),t<16&&(OO(n),n.schema=16),t<17&&(en(n,Ig),Jo(n,Ig),n.schema=17),t<18&&(en(n,Tg),Jo(n,Tg),n.schema=18),t<19&&(dO(n),n.schema=19),t<20&&(CO(n),MO(n),n.schema=20),t<21&&(IO(n),NO(n),n.schema=21),t<22&&(Eg(n),n.schema=22),t<23&&(DO(n),n.schema=23),t<24&&(EO(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(_O(n),t<25&&(n.schema=25)),t<26&&(gO(n),n.schema=26),t<27&&(xO(n),n.schema=27),t<28&&(Eg(n),n.schema=28),t<29&&(bO(n),n.schema=29),t<30&&(BO(n),n.schema=30),t<31&&(LO(n),n.schema=31),t<33&&(RO(n),n.schema=33),t<34&&(VO(n),n.schema=34),t<35&&(zO(n),n.schema=35),t<36&&(GO(n),n.schema=36),t<37&&(kO(n),n.schema=37),t<38&&(en(n,Ng),Jo(n,Ng),n.schema=38),t<39&&(FO(n),n.schema=39),t<40&&(jO(n),n.schema=40),t<41&&(UO(n),n.schema=41),t<42&&(HO(n),n.schema=42),t<43&&(qO(n),n.schema=43),t<99){en(n,Lg),Jo(n,Lg),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=Tn);let e=ft(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=Mn,r.insertBefore(null,null,[{id:Mn,data:{...Xo.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:Zr(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:Zr(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...tl.defaultData,...Zr(n.scene.environment,"usePhysics","gravity")},camera:ft(n.scene.ownerCamera)??Xo.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==Ko.TRASH_CAN_ID&&r.move(Mn,a.fi,a.id);let o=0,i=0;n.shared.penumbraSize&&n.scene.objects.traverse((a,s)=>{s.type==="DirectionalLight"?(s.penumbraSize=n.shared.penumbraSize[Math.min(o,2)],o+=1):s.type==="SpotLight"&&(s.penumbraSize=n.shared.penumbraSize[3+Math.min(i,1)],i+=1),(s.physics===void 0||s.physics===null)&&s.type!=="Instance"&&(s.physics={},Object.assign(s.physics,Nn.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),n.schema=99}}function Vg(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function WO(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function $O(n){Array.isArray(ft(n.events))&&n.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var wa=180/Math.PI;function zg(n){n.rotation=n.rotation.slice(0,3).map(t=>t*wa)}function Gg(n){zg(n),n.type==="Page"&&zg(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*wa))});let t=n.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*wa),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*wa),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=wa,t.extrusion.twist*=wa),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(ft(n.events))&&n.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Repeat")})}function YO(n){n.shared.variables=ir({},ue.prototype)}function XO(n){let t=ft(n.shared.variables);n.shared.variables=ir(Object.entries(t??{}).map(([e,r],o)=>({fi:o,id:e,data:r})),me.prototype)}var Oo=111;function kg(n,t){t(n.data);for(let e of n.children)kg(e,t)}function QO(n){let t=n.schema??104;t!==Oo&&t<105&&(kg(n.asset,Gg),n.schema=105)}function KO(n){n.shared.particles=ir({},ue.prototype),n.shared.lib&&(n.shared.lib.particles=Zo.defaultData().particles)}function ZO(n){n.scene.objects.traverse((t,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function su(n){let t=n.schema??0;if(t!==Oo){console.warn("updating from ",t,"to ",Oo),Rg(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=eo.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(en(n,Vg),Jo(n,Vg),n.schema=101),t<102&&(WO(n),n.schema=102),t<104&&(n.shared.catelogs=new ue,n.shared.lib=Zo.defaultData(),n.schema=104),t<105&&(YO(n),n.scene.objects.traverse((e,r)=>{Gg(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))QO(e);t<106&&(XO(n),n.schema=106),t<107&&(n.shared.lib.variables=Zo.defaultData().variables,n.schema=107),t<109&&(KO(n),n.schema=109),t<110&&(ZO(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{$O(r)}),n.schema=111)}}var ba;(l=>{l.defaultData={schema:Oo,scene:Ko.defaultData,frames:new ue().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",va.defaultData),shared:{...zr.emptyData(),colors:zr.defaultColors()}},l.emptyDataForImports=function(u){let c=Ko.emptyDataWithPage(u);return{schema:Oo,scene:c,frames:new ue().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",va.defaultData),shared:{...zr.emptyData(),colors:zr.defaultColors(),images:zr.defaultImages(u)}}},l.emptyData=function(){return{schema:Oo,scene:Ko.emptyDataWithPage(),frames:new ue().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",va.defaultData),shared:zr.emptyData()}},l.clipboard2dData=function(){return{schema:Oo,scene:Ko.emptyData(),frames:new ue,shared:zr.emptyData()}},l.collabHelper={...Ys,updateSchema(u){return(u.schema??0)<Oo?wn(u,su):(u.schema??0)-Oo}};function i(u){let c=l.collabHelper.updateSchema(u);return typeof c=="number"?c===0?u:null:c.data}l.updateSchemaDirectly=i;function a(u){return{...u,shared:{...u.shared,lib:Zo.defaultData()}}}l.withoutLib=a;function s(u,c){let d=u.scene.objects.get(c);if(d&&d.data.type==="Component")return d;{let p=u.shared.lib.components[c];if(p)return p.asset}}l.getComponentData=s})(ba||(ba={}));var Fg;(t=>{function n(e){return!0}t.is=n})(Fg||(Fg={}));var lu;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0};function t(o,i){return{position:i?.position??o.position,rotation:i?.rotation??o.rotation,scale:i?.scale??o.scale}}r.merge=t;function e(o,i){return Jl({position:Js.isEqual(o.position,i.position)?void 0:i.position,rotation:o.rotation===i.rotation?void 0:i.rotation,scale:Js.isEqual(o.scale,i.scale)?void 0:i.scale})}r.diff=e})(lu||(lu={}));var fp;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(fp||(fp={}));var cu;(t=>t.defaultData={opacity:1,fill:{color:Oe.white,enabled:!0},stroke:{color:Oe.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Oe.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Oe.from0to1([0,0,0,1]),enabled:!1,spread:0}})(cu||(cu={}));var pi;(i=>{function n(a,s){return{name:s}}i.newEmpty=n;function t(a,s){if(s===void 0)return a;let l={...a},u=["width","height","cornerRadius"];for(let c of u)c in l&&c in s&&s[c]!==void 0&&Object.assign(l,{[c]:s[c]});return l}function e(a,s){if(s===void 0)return a;let l={...a};return"fill"in l&&"fill"in s&&s.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...s.fill}}),"stroke"in l&&"stroke"in s&&s.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...s.stroke}}),"layerBlur"in l&&"layerBlur"in s&&s.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...s.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in s&&s.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...s.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in s&&s.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...s.dropShadow}}),"innerShadow"in l&&"innerShadow"in s&&s.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...s.innerShadow}}),l}function r(a,s){if(s===void 0)return a;let l={...a};return Object.assign(l,lu.merge(l,s)),l=t(l,s),l=e(l,s),l}i.patch=r;function o(a,s){let l,u=[];for(let[c,d]of Object.entries(s))c!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},u.push(l)),l.props[c]=d);return u}i.toOps=o})(pi||(pi={}));var ol;(t=>t.defaultData={...lu.defaultData,...fp.defaultData,states:new me,events:new me,visible:!0,raycastLock:!1})(ol||(ol={}));var nl;(t=>t.defaultData={...ol.defaultData,...cu.defaultData})(nl||(nl={}));var uu;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(uu||(uu={}));var hp;(t=>t.defaultData={...nl.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(hp||(hp={}));var _a;(t=>t.defaultData={...nl.defaultData,...uu.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(_a||(_a={}));var mp;(t=>t.defaultData={...nl.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(mp||(mp={}));var jg;(t=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"}t.is=n})(jg||(jg={}));var il;(t=>t.defaultData={...ol.defaultData,name:"Group",type:"group2d"})(il||(il={}));var yp;(t=>t.defaultData={...ol.defaultData,...uu.defaultData,...cu.defaultData,name:"Frame",type:"frame2d",width:200,height:200,fill:{color:Oe.fromHexAndA(Ot,1),enabled:!0},stroke:{color:Oe.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}})(yp||(yp={}));var tn;(o=>{function n(i){switch(i){case"rectangle2d":return{..._a.defaultData};case"ellipse2d":return{...hp.defaultData};case"text2d":return{...mp.defaultData};case"vector2d":return{..._a.defaultData};case"frame2d":return{...yp.defaultData};case"group2d":return{...il.defaultData}}}o.defaultData=n;function t(i){return"width"in i&&"height"in i?[typeof i.width=="number"?i.width*.5:0,typeof i.height=="number"?i.height*.5:0]:[0,0]}o.getPivot=t;function e(i){return i.type==="rectangle2d"||i.type==="ellipse2d"||i.type==="text2d"||i.type==="frame2d"}o.isResizeable=e;function r(i){return i.type==="rectangle2d"||i.type==="frame2d"}o.hasCorners=r})(tn||(tn={}));var du;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new tt},e.emptyData=function(){return{type:"scene2d",objects:new tt}}))(du||(du={}));var We=require("three"),ws=nr(Hg());var JO=.5*(Math.sqrt(3)-1),al=(3-Math.sqrt(3))/6,eC=1/3,Co=1/6,sj=(Math.sqrt(5)-1)/4,lj=(5-Math.sqrt(5))/20,sl=n=>Math.floor(n)|0,qg=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),xp=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function pu(n=Math.random){let t=$g(n),e=new Float64Array(t).map(o=>qg[o%12*2]),r=new Float64Array(t).map(o=>qg[o%12*2+1]);return function(i,a){let s=0,l=0,u=0,c=(i+a)*JO,d=sl(i+c),p=sl(a+c),f=(d+p)*al,h=d-f,m=p-f,y=i-h,g=a-m,b,S;y>g?(b=1,S=0):(b=0,S=1);let w=y-b+al,v=g-S+al,_=y-1+2*al,A=g-1+2*al,x=d&255,T=p&255,C=.5-y*y-g*g;if(C>=0){let M=x+t[T],I=e[M],N=r[M];C*=C,s=C*C*(I*y+N*g)}let P=.5-w*w-v*v;if(P>=0){let M=x+b+t[T+S],I=e[M],N=r[M];P*=P,l=P*P*(I*w+N*v)}let O=.5-_*_-A*A;if(O>=0){let M=x+1+t[T+1],I=e[M],N=r[M];O*=O,u=O*O*(I*_+N*A)}return 70*(s+l+u)}}function Wg(n=Math.random){let t=$g(n),e=new Float64Array(t).map(i=>xp[i%12*3]),r=new Float64Array(t).map(i=>xp[i%12*3+1]),o=new Float64Array(t).map(i=>xp[i%12*3+2]);return function(a,s,l){let u,c,d,p,f=(a+s+l)*eC,h=sl(a+f),m=sl(s+f),y=sl(l+f),g=(h+m+y)*Co,b=h-g,S=m-g,w=y-g,v=a-b,_=s-S,A=l-w,x,T,C,P,O,M;v>=_?_>=A?(x=1,T=0,C=0,P=1,O=1,M=0):v>=A?(x=1,T=0,C=0,P=1,O=0,M=1):(x=0,T=0,C=1,P=1,O=0,M=1):_<A?(x=0,T=0,C=1,P=0,O=1,M=1):v<A?(x=0,T=1,C=0,P=0,O=1,M=1):(x=0,T=1,C=0,P=1,O=1,M=0);let I=v-x+Co,N=_-T+Co,B=A-C+Co,D=v-P+2*Co,G=_-O+2*Co,L=A-M+2*Co,V=v-1+3*Co,z=_-1+3*Co,F=A-1+3*Co,$=h&255,q=m&255,H=y&255,X=.6-v*v-_*_-A*A;if(X<0)u=0;else{let k=$+t[q+t[H]];X*=X,u=X*X*(e[k]*v+r[k]*_+o[k]*A)}let j=.6-I*I-N*N-B*B;if(j<0)c=0;else{let k=$+x+t[q+T+t[H+C]];j*=j,c=j*j*(e[k]*I+r[k]*N+o[k]*B)}let Y=.6-D*D-G*G-L*L;if(Y<0)d=0;else{let k=$+P+t[q+O+t[H+M]];Y*=Y,d=Y*Y*(e[k]*D+r[k]*G+o[k]*L)}let W=.6-V*V-z*z-F*F;if(W<0)p=0;else{let k=$+1+t[q+1+t[H+1]];W*=W,p=W*W*(e[k]*V+r[k]*z+o[k]*F)}return 32*(u+c+d+p)}}function $g(n){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let o=r+~~(n()*(256-r)),i=e[r];e[r]=e[o],e[o]=i}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var Yg=require("three"),to=new Yg.Triangle,fu=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let o=0;o<t.count;o+=3){let i=1;to.a.fromBufferAttribute(t,o),to.b.fromBufferAttribute(t,o+1),to.c.fromBufferAttribute(t,o+2),i*=to.getArea(),e[o/3]=i}this.distribution=new Float32Array(t.count/3);let r=0;for(let o=0;o<e.length;o++)r+=e[o],this.distribution[o]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],o=this.binarySearch(this.randomFunction()*r);return this.sampleFace(o,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,o=e.length-1,i=-1;for(;r<=o;){let a=Math.ceil((r+o)/2);if(a===0||e[a-1]<=t&&e[a]>t){i=a;break}else t<e[a]?o=a-1:r=a+1}return i}sampleFace(t,e,r){let o=this.randomFunction(),i=this.randomFunction();return o+i>1&&(o=1-o,i=1-i),to.a.fromBufferAttribute(this.positionAttribute,t*3),to.b.fromBufferAttribute(this.positionAttribute,t*3+1),to.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(to.a,o).addScaledVector(to.b,i).addScaledVector(to.c,1-(o+i)),to.getNormal(r),this}};var Zg=require("three");var Ir=require("three"),Kg=nr(Qg()),tC=new Ir.Matrix4,rC=new Ir.Matrix4,oC=new Ir.Matrix4,Aa;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(Aa||(Aa={}));var Pa=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new Ir.Matrix4;this.copyPreviousMatrix=!0;this.hiddenMatrix=new Ir.Matrix4;this.matrixWorldRigid=new Ir.Matrix4;this.shearScale=new Ir.Matrix4;this.shearScaleInv=new Ir.Matrix4}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof Ir.Object3D&&(r=r.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===r)return!0;o=o.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let o of this.children)o.updateMatrixWorld(r)}updateWorldMatrix(r,o){let i=this.parent;if(r&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),o)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(r,o=0){for(let i of this.children)Aa.is(i)&&i.traverseObject(r,o+1)}traverseObject(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Aa.is(a)&&a.traverseObject(r,o+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,o=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:i,v:a,q:s}=(0,Kg.SVD)(o),l=tC.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),u=rC.set(a[0][0],a[0][1],a[0][2],0,a[1][0],a[1][1],a[1][2],0,a[2][0],a[2][1],a[2][2],0,0,0,0,1),c=oC.copy(u).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),s.every(d=>Math.abs(s[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,o){this.updateWorldMatrix(!0,!1);let i=new Ir.Matrix4().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),i.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof Ir.Matrix4?r.hiddenMatrix.premultiply(i):r.applyMatrix4(i),r.updateWorldMatrix(!1,!1),this.add(r),o!==void 0&&(this.children.pop(),this.children.splice(o,0,r)),this}copy(r,o=!1){return super.copy(r,o),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,o,i,a,s,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var bp=class extends Pa(Zg.Object3D){},nC=n=>n.type==="Mesh",rn=class extends bp{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let o=this.children[e];o?.object!==r&&(o&&this.remove(o),o=new rn(r),this.add(o),this.children.splice(e,0,this.children.pop()),o.matrixWorldNeedsUpdate=!0,o.matrixAutoUpdate=!1,o.matrix=r.matrix,o.hiddenMatrix=r.hiddenMatrix),o.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return nC(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var Wa=require("three");var Eu=require("three");var tr=require("three");var vt=require("three"),fi=new vt.Vector3,hi=new vt.Vector3,Oa=new vt.Matrix4,e0=[new vt.Vector3(-1,1,1),new vt.Vector3(-1,-1,1),new vt.Vector3(1,-1,1),new vt.Vector3(1,1,1),new vt.Vector3(-1,1,-1),new vt.Vector3(-1,-1,-1),new vt.Vector3(1,-1,-1),new vt.Vector3(1,1,-1)],iC=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],aC=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Jg=(n,t,e)=>{n.updateEntityBoxSize(fi,hi),Oa.copy(t).multiply(n.matrixWorld),hi.x===0&&hi.y===0&&hi.z===0?e.push(new vt.Vector3(fi.x,fi.y,fi.z).applyMatrix4(Oa)):e0.forEach(r=>{e.push(r.clone().multiply(hi).add(fi).applyMatrix4(Oa))})},ll=class extends vt.Box3{constructor(){super(...arguments);this.matrix=new vt.Matrix4;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let o=new vt.Matrix4().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,r)}expandByObjectSize(e,r,o=!1){let i=[];return o===!0?e.traverseEntity(a=>{if(a.visible||a.cloner&&a.data.visible){if(!("geometry"in a)){i.push(new vt.Vector3);return}Jg(a,r,i)}}):Jg(e,r,i),this.setFromPoints(i)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(Oa.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(hi).multiplyScalar(.5),this.getCenter(fi),Oa.copy(this.matrix).setPosition(fi),this.vertices=e0.map(e=>e.clone().multiply(hi).applyMatrix4(Oa))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=iC.map(([e,r])=>new vt.Line3(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new vt.Vector3))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=aC.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var ro={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var Ut=require("three"),Sp=class extends Ut.CurvePath{constructor(){super()}getPoints(t=12){let e=[],r,o=this.getCurveLengths(),a=o[o.length-1]/o.length;for(let s=0,l=this.curves;s<l.length;s++){let u=l[s],c=s===0?o[s]:o[s]-o[s-1],d=Math.ceil(t*c/a),p=u.getPoints(d);for(let f=0;f<p.length;f++){let h=p[f];r&&r.equals(h)||(e.push(h),r=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var wp=.001;function _p(n,t,e){return t.clone().sub(n).cross(t.clone().sub(e)).length()<=wp}function vp(n,t){let e=new Ut.Vector3(...n.position),r=new Ut.Vector3(...n.controlNext.position),o=new Ut.Vector3(...t.controlPrevious.position),i=new Ut.Vector3(...t.position);return _p(e,r,i)&&_p(e,o,i)}function mu(n){let t=n.points.map(c=>new Ut.Vector3(...c.data.position)),e=[n.points[0]],r=new Ut.Vector3(...e[0].data.position);for(let c=0;c<n.points.length-1;c++)_p(r,t[c],t[c+1])||(e.push(n.points[c]),r=t[c]);e.push(n.points[n.points.length-1]);let o=n.isClosed,i=e.length-(o?0:1),a=e.length,s=[];for(let c=0;c<a;c++){let d=e[c].data,p=new Ut.Vector3(...d.position),f=new Ut.Vector3(...d.controlPrevious.position),h=new Ut.Vector3(...d.controlNext.position),m={position:p,baseRoundness:d.roundness,controlPrevious:f,controlNext:h};if(d.roundness===0||!n.isClosed&&(c===0||c===a-1)){s[c]={...m,removedLength:0};continue}let y=o&&c==0?a-1:c-1,g=o&&c==a-1?0:c+1,b=e[y].data,S=e[g].data,w=new Ut.Vector3(...b.position),v=new Ut.Vector3(...S.position),_=w.clone().sub(p).normalize(),A=v.clone().sub(p).normalize();Object.assign(m,{prevDir:_,nextDir:A});let x=vp(b,d),T=vp(d,S);if(!x||!T)s[c]={...m,removedLength:0};else{let C=_.clone().add(A).normalize(),P=C.clone().cross(_).length()/_.dot(C);s[c]={...m,tan:P,removedLength:d.roundness/P}}}for(let c=0;c<i;c++){let d=c,p=o&&c===a-1?0:c+1,f=s[d],h=s[p];if(f.removedLength!==0||h.removedLength!==0){let m=f.position.distanceTo(h.position);f.removedLength=Math.min(f.removedLength,m/2),h.removedLength=Math.min(h.removedLength,m/2)}}let l=[];for(let c=0;c<i;c++){let d=c,p=o&&c===a-1?0:c+1,f=s[d],h=s[p],m=null;if(!vp(e[d].data,e[p].data))f.position.distanceTo(h.position)>wp&&(m=new Ut.CubicBezierCurve3(f.position,f.controlNext,h.controlPrevious,h.position));else{let y=f.position.clone(),g=h.position.clone();(f.removedLength!==0||h.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),h.prevDir&&g.add(h.prevDir.clone().setLength(h.removedLength))),y.distanceTo(g)>wp&&(m=new Ut.CubicBezierCurve3(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}l[2*c+1]=m}for(let c=0;c<a;c++){let d=s[c];if(d.removedLength===0){l[2*c]=null;continue}let p=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(p),h=d.nextDir.clone().multiplyScalar(d.removedLength).add(p),m=d.tan*d.removedLength,y=d.prevDir.clone().add(d.nextDir).normalize(),g=f.clone().lerp(h,.5),b=f.distanceTo(h)/2,S=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(b,2))).add(g),w=y.clone().multiplyScalar(-m).add(S),v=p.distanceTo(w)/p.distanceTo(g),_=d.prevDir.clone().multiplyScalar(v*p.distanceTo(f)).add(p),A=_.clone().lerp(w,2),x=f.clone().lerp(_,4/3),T=h.clone().lerp(A,4/3);l[2*c]=new Ut.CubicBezierCurve3(f,x,T,h)}let u=new Sp;return l.forEach(c=>{c&&u.add(c)}),u}var De;(t=>{function n(e){return e&&e.__isEntity}t.is=n})(De||(De={}));var Ca=n=>De.is(n),sC={type:"completeState",isfromEntity:!0},lC=["x","y","z"],Ap=new tr.Vector3,cC=new tr.Vector3().set(0,1,0),Ta=n=>class extends Pa(n){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.destroyedInAction=!1;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new ll;this._recursiveBBox=new ll;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let o=this.children[r];if(De.is(o))return o}entityChildrenCount(){let r=this.children.length;for(;r--;)if(De.is(this.children[r]))return r+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let r=this;for(;r.data.type!=="Instance";){let o=r.parent;if(De.is(o))r=o;else return}return r}forInstancesRec(r){this.instances.forEach(o=>{o.disposed||r(o),o.forInstancesRec(r)})}super_Entity(r,o){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=o,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,o,i=!1){if(!(this.data.states.length===0&&!i)){for(let a of this.data.states)di.toOps(this.data,a.data).forEach(l=>{let u=la.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,o)});if(r!==null){let a=this.data.states.data(r);a&&(this.dataPatched=di.patch(this.data,a),di.toOps(this.data,a).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,o)}))}i&&this.updateTransformState(this.dataPatched,o),this.stateSelection=r,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(r,o){r.setScalar(0),o.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{Ca(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let o;return this.traverseEntity(i=>{i.uuid===r&&(o=i)}),o}traverseSortNextHelper(){let r=this.parent;if(r){let o=r.children,i=o.indexOf(this)+1;if(De.is(o[i]))return o[i];if(De.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&De.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let o=this;for(;r>0&&o!==null;)o=o.parent,r-=1;return o}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let o=this.parent;for(;o;){if(r===o)return!0;o=o.parent}return!1}countToAccestor(r){let o=0,i=this;for(;i!==r;){if(i===null)return-1;i=i.parent,o+=1}return o}forEachEntity(r){for(let o of this.children)Ca(o)&&r(o)}traverseEntityAncestors(r){this.traverseAncestors(o=>{De.is(o)&&r(o)})}traverseConcreteEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Ca(a)&&a.isConcreteEntity&&a.traverseEntity(r,o+1)}traverseEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Ca(a)&&a.traverseEntity(r,o+1)}traverseVisibleEntity(r){r(this);for(let o of this.children)Ca(o)&&o.visible&&o.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,o=!1){return super.copy(r,o),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>Ca(r))}isAncestorOf(r){if(this.uuid===r)return!1;let o=!1;return this.traverseEntity(i=>{i.uuid===r&&(o=!0)}),o}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x*tr.MathUtils.RAD2DEG,this.rotation.y*tr.MathUtils.RAD2DEG,this.rotation.z*tr.MathUtils.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return oa(o,r)}getTransformValues(r,o,i){return o[r].map((a,s)=>i?.shared.getVariable(a,[this.uuid,r,lC[s]])??a)}updateTransformState(r,o){let i=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,o)),i=!0),r.rotation&&(Ap.fromArray(this.getTransformValues("rotation",r,o)).multiplyScalar(tr.MathUtils.DEG2RAD),this.rotation.setFromVector3(Ap),i=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,o)),i=!0),r.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??Cn.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(a=>{a.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)De.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{De.is(r)&&r.disposeRecursively()})}toState(r=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return oa(o,r)}updateByObjUpdateOp(r,o){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},o,!1)}updateByOp(r,o,i,a){let s=this.data;this.data=o;let l=r,u=Ne(r.path,["states","*"]);if(u!==null){if(r.type===0){let[c]=u;if(this?.stateSelection===c){let d={...r.props};if(delete d.name,Object.values(r.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=dt.zoom(p,r.path.slice(2));if(f)for(let h in r.props)r.props[h]===void 0&&h in f&&(d[h]=f[h])}}l={...r,props:d,path:r.path.slice(2)}}}}else if(r.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(r.props.name!==void 0&&c.name){let{name:p,...f}=c;c=f}if(r.props.material!==void 0&&"material"in c){let{material:p,...f}=c;c=f}let d=dt.removeOverridden(r.path,r.props,c);l={...r,props:d}}}if(this.updateByPatchedOpBase(l,di.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),Ne(r.path,["overrides"])){let c=[],d=[...r.path];for(c.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)c.push(d[1]),d.splice(0,2);if(c[c.length-1]===void 0){if(r.type===0)for(let p of Object.keys(r.props)){c[c.length-1]=p;let f=i.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=r.props[p],f.updateState(bo.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...c]);if(p){let f=dt.zoom(p.component.data,d);if(r={...r,path:d},r.type===0){let h=r.props;if(f)for(let[m,y]of Object.entries(r.props))y===void 0&&(h===r.props&&(h={...r.props}),h[m]=f[m]);r={...r,props:h}}p.overrideData=ga.resolve(o.overrides,c),p.updateByOp(r,pt.applySimple(p.data,r),i,!1)}}}else if(this.instances.length>0){let c;if(r.path.length===0&&r.type===0){let d;for(let p of Po.rootOverrideProps)p in r.props&&(d===void 0&&(d={}),d[p]=r.props[p]);d&&(c={...r,props:d})}else for(let d of Po.rootOverrideProps)if(Ne(r.path,[d])){c=r;break}c!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=bo.filterOp(d.overrideData,c);p&&d.updateByOp(p,pt.applySimple(d.data,p),i,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=bo.filterOp(d.overrideData,r);if(p){let f;s===d.data&&r===p?f=o:f=pt.applySimple(d.data,p),d.updateByOp(p,f,i,!0)}}})}}updateByPatchedOpBase(r,o,i){if(this.dataPatched=o,r.path.length===0&&r.type===0)r.props.type!==void 0&&!Jr.is(r.props.type)&&ro.changeEntityProptotype(this,o,i);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){ro.changeEntityProptotype(this,o,i);for(let a of this.children)De.is(a)&&a.updateVisible(i.scene)}this.updateByPatchedOp(r,o,i)}updateByPatchedOp(r,o,i){if(r.path.length===0&&r.type===0&&this.updateState(r.props,i),Ne(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Ne(r.path,["cloner"])!==null){let a=pt.drop(r,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,i):this.cloner?this.cloner.updateState(o.cloner,i.scene):(this.setFromClonerState(o.cloner,i),this.expandCloner(i.scene)),this.updateVisible(i.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){let o=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,i=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,a=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(o===null)return;let l=r.find(o);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data;if(u.geometry.path.points.length<=1)return;let c=mu(u.geometry.path),d=(i+a)%1;i+a===1&&d===0&&(d=1);let p=c.getPointAt(d);if(p===null)return;let f=this.parent?this.parent?.matrixWorld:new tr.Matrix4;l.updateMatrixWorld();let h=new tr.Matrix4().multiplyMatrices(f.clone().invert(),l.matrixWorld);p.applyMatrix4(h);let m={position:p.toArray(),rotation:u.rotation};if(s==="tangential"){let y=new tr.Matrix4().extractRotation(l.matrixWorld),g=c.getTangentAt(d).applyMatrix4(y).add(p),b=new tr.Matrix4().lookAt(p,g,cC),S=Ap.setFromEuler(new tr.Euler().setFromRotationMatrix(b)).multiplyScalar(tr.MathUtils.RAD2DEG);m={...m,rotation:S.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(sC)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let o=!1;this.traverseEntity(i=>{if(i.data.type==="Splat")return o=!0,!0}),o&&r.reloadSplats()}updateState_Entity(r,o){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(o?.scene),this.resetBBoxNeedsUpdate()),o&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,o),this.updateVisible(o.scene)),this.updateTransformState(r,o)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof ro.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,o){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new ro.Cloner(this,r),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,o.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};var Bn=require("three");var Ze=require("three"),r0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);e.thetaLength=Ze.MathUtils.clamp(e.thetaLength,0,360);let r=e.width/2,o=e.radiusTop??r,i=e.radiusBottom??r;return o===i?(o=r,i=r):o>i?(o=r,i=i*r/o):(o=o*r/i,i=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:o,radiusBottom:i})}}static build(n){let{width:t,depth:e,height:r,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:d,cornerSegments:p,hollow:f}=n.parameters,h;return l===0?(h=new Ze.BufferGeometry,h.setAttribute("position",new Ze.Float32BufferAttribute([],3))):d||f?h=new cl(u,c,r,o,i,a,s,l*Math.PI/180,d,d,p,f):h=new Ze.CylinderGeometry(u,c,r,o,i,a,s,l*Math.PI/180),h.scale(1,1,e/t),Object.assign(h,{userData:{...n,type:"CylinderGeometry"}})}};function En(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function t0(n){return new Ze.Vector2(n.y,-n.x)}var cl=class extends Ze.BufferGeometry{constructor(t,e,r,o,i,a,s,l,u,c,d,p,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,o=Math.floor(o)||8,i=Math.floor(i)||1,a=a!==void 0?a:!1,s=s!==void 0?s:0,l=l!==void 0?l:Math.PI*2,a&&(u=0,c=0);let h=[],m=[],y=[],g=[],b=0,S=r/2,w=new Ze.Vector3,v=new Ze.Vector3;f&&t==0&&(t=u),f&&e==0&&(e=c);let _=new Ze.Vector2(t,S),A=new Ze.Vector2(e,-S),x=null,T=null,C=null,P=null,O=_.clone().sub(A),M=0,I=0,N=0;p>0&&(M=Math.min(t,e)*(1-p),I=t-M,N=e-M);let B=_.clone();B.x-=M;let D=Math.PI-O.angle(),G=O.angle(),L=Math.tan(G/2),V=Math.tan(D/2),z=L+V,F=p?z:V,$=p?z:L;if(u=Math.min(u,(t-I)/F,O.length()/z),c=Math.min(c,(e-N)/$,O.length()/z),u>0){let W=u/L;x=_.clone().sub(new Ze.Vector2(W,u)),p&&(C=x.clone(),C.x-=M-z*u),_.sub(O.clone().setLength(W))}if(c>0){let W=c/V;T=A.clone().sub(new Ze.Vector2(W,-c)),A.add(O.clone().setLength(W)),p&&(P=T.clone(),P.x-=M-z*c,B.sub(O.clone().setLength(W)))}O=_.clone().sub(A);let q=O.length()<.5,H=[];for(let W=0;W<=o;W++){let k=[],ne=W/o,ee=ne*l+s,K=new Ze.Vector2(Math.sin(ee),Math.cos(ee));P&&T?(X(k,ne,K,D,c,P,-1,!0),X(k,ne,K,G,c,T,-1,!1)):T?(j(k,K,T.x,0,-1),X(k,ne,K,G,c,T,-1,!1)):a||j(k,K,e,N,-1);let te=t0(O).normalize();if(En(te,K,w),!q)for(let Z=0;Z<=i;Z++){let le=Z/i,ie=O.clone().multiplyScalar(le).add(A);En(ie,K,v),m.push(v.x,v.y,v.z),y.push(w.x,w.y,w.z),g.push(ne,.5+v.y/r),k.push(b++)}if(C&&x?(X(k,ne,K,D,u,x,1,!1),X(k,ne,K,G,u,C,1,!0)):x?(X(k,ne,K,D,u,x,1,!1),j(k,K,x.x,0,1)):a||j(k,K,t,I,1),p&&!q){let Z=t0(O).multiplyScalar(-1).normalize();En(Z,K,w);for(let le=0;le<=i;le++){let ie=le/i,ae=O.clone().multiplyScalar(-ie).add(B);En(ae,K,v),m.push(v.x,v.y,v.z),y.push(w.x,w.y,w.z),g.push(ne,.5+v.y/r),k.push(b++)}}p&&!a&&k.push(k[0]),H.push(k)}for(let W=0;W<H.length-1;W++)for(let k=0;k<H[0].length-1;k++){if(a&&p&&k==i)continue;let ne=H[W][k],ee=H[W+1][k],K=H[W+1][k+1],te=H[W][k+1],Z=m[K*3+0],le=m[K*3+2];h.push(ne,ee,te),(Z!=0||le!=0)&&h.push(ee,K,te)}l<Math.PI*2&&(Y(-1,H[0],s),Y(1,H[H.length-1],s+l)),this.setIndex(h),this.setAttribute("position",new Ze.Float32BufferAttribute(m,3)),this.setAttribute("normal",new Ze.Float32BufferAttribute(y,3)),this.setAttribute("uv",new Ze.Float32BufferAttribute(g,2));function X(W,k,ne,ee,K,te,Z,le){for(let ie=0;ie<d+1;ie++){let ae=ie/d,pe=Z<0?ae:1-ae;le&&(pe-=1),pe*=ee;let ce=new Ze.Vector2(Math.sin(pe),Math.cos(pe)*Z),fe=ce.clone().multiplyScalar(K).add(te);En(fe,ne,v),m.push(v.x,v.y,v.z),En(ce,ne,w),y.push(w.x,w.y,w.z),g.push(k,.5+v.y/r),W.push(b++)}}function j(W,k,ne,ee,K){let te=new Ze.Vector3,Z=new Ze.Vector2,le=[ne,ee];K<0&&le.reverse();for(let ie of le)Z.set(ie,S*K),En(Z,k,te),m.push(te.x,te.y,te.z),y.push(0,K,0),g.push(.5,.5),W.push(b++)}function Y(W,k,ne){let ee=new Ze.Vector2(Math.sin(ne),Math.cos(ne)),K=new Ze.Vector2(-Math.cos(ne),Math.sin(ne)),te=new Ze.Vector3,Z=W<0?(ae,pe,ce)=>h.push(ae,pe,ce):(ae,pe,ce)=>h.push(ae,ce,pe),le=new Ze.Vector2((t+e+I+N)/4,0);En(le,ee,te),m.push(te.x,te.y,te.z),y.push(K.x,0,K.y),g.push(.5,.5);let ie=b++;for(let ae of k){let pe=m.slice(ae*3,ae*3+3);m.push(...pe),y.push(K.x,0,K.y);let ce=g.slice(ae*2,ae*2+2);g.push(...ce),b++}for(let ae=ie+1;ae<b-1;ae++)Z(ie,ae,ae+1);Z(ie,b-1,ie+1)}}};var o0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},n.parameters);return e.thetaLength=Bn.MathUtils.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,depth:e,height:r,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:d}=n.parameters,p;return l===0?(p=new Bn.BufferGeometry,p.setAttribute("position",new Bn.Float32BufferAttribute([],3))):u>0||c>0||l<360?p=new cl(0,t/2,r,o,i,a,s,l*Math.PI/180,u,c,d,0,!0):p=new Bn.ConeGeometry(t/2,r,o,i,a),p.scale(1,1,e/t),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};var yr=require("three"),n0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,widthSegments:o,heightSegments:i,depthSegments:a,cornerRadius:s,cornerSegments:l}=n.parameters,u;return s==0?u=new yr.BoxGeometry(t,e,r,o,i,a):u=new Op(t,e,r,o,i,a,s,l),Object.assign(u,{userData:{...n,type:"CubeGeometry"}})}},Pp=Math.PI/2,Op=class extends yr.BufferGeometry{constructor(t=1,e=1,r=1,o=1,i=1,a=1,s=0,l=4){super(),this.type="BoxGeometry";let u=this;o=Math.floor(o),i=Math.floor(i),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,t/2,e/2,r/2);let c=[],d=[],p=[],f=[],h=0,m=0;y("z","y","x",-1,-1,r,e,t,a,i,0),y("z","y","x",1,-1,r,e,-t,a,i,1),y("x","z","y",1,1,t,r,e,o,a,2),y("x","z","y",1,-1,t,r,-e,o,a,3),y("x","y","z",1,-1,t,e,r,o,i,4),y("x","y","z",-1,-1,t,e,-r,o,i,5),s>0&&(g("z","y","x",-1,-1,1,r,e,t,a,0),g("z","y","x",1,-1,-1,r,e,t,a,1),g("z","y","x",-1,1,-1,r,e,t,a,1),g("z","y","x",1,1,1,r,e,t,a,0),g("x","y","z",-1,-1,-1,t,e,r,o,0),g("x","y","z",1,-1,1,t,e,r,o,1),g("x","y","z",-1,1,1,t,e,r,o,0),g("x","y","z",1,1,-1,t,e,r,o,1),g("y","x","z",-1,-1,1,e,t,r,i,0),g("y","x","z",1,-1,-1,e,t,r,i,1),g("y","x","z",1,1,1,e,t,r,i,1),g("y","x","z",-1,1,-1,e,t,r,i,0),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(c),this.setAttribute("position",new yr.Float32BufferAttribute(d,3)),this.setAttribute("normal",new yr.Float32BufferAttribute(p,3)),this.setAttribute("uv",new yr.Float32BufferAttribute(f,2));function y(S,w,v,_,A,x,T,C,P,O,M){let I=(x-2*s)/P,N=(T-2*s)/O,B=x/2-s,D=T/2-s,G=C/2,L=P+1,V=O+1,z=0,F=0,$=new yr.Vector3;for(let q=0;q<V;q++){let H=q*N-D;for(let X=0;X<L;X++){let j=X*I-B;$[S]=j*_,$[w]=H*A,$[v]=G,d.push($.x,$.y,$.z),$[S]=0,$[w]=0,$[v]=C>0?1:-1,p.push($.x,$.y,$.z),f.push(X/P),f.push(1-q/O),z+=1}}for(let q=0;q<O;q++)for(let H=0;H<P;H++){let X=h+H+L*q,j=h+H+L*(q+1),Y=h+(H+1)+L*(q+1),W=h+(H+1)+L*q;c.push(X,j,W),c.push(j,Y,W),F+=6}u.addGroup(m,F,M),m+=F,h+=z}function g(S,w,v,_,A,x,T,C,P,O,M){let I=(T-2*s)/O,N=T/2-s,B=C/2-s,D=P/2,G=O+1,L=0,V=0,z=new yr.Vector3,F=new yr.Vector3;for(let $=0;$<l+1;$++){let q=$/l*Pp,H=Math.sin(q)*s,X=(1-Math.cos(q))*s,j=Math.sin(q),Y=Math.cos(q);z[w]=(B+H)*A,z[v]=(D-X)*x,F[S]=0,F[w]=j*Math.sign(z[w]),F[v]=Y*Math.sign(z[v]);for(let W=0;W<G;W++){let k=W*I-N;z[S]=k*_,d.push(z.x,z.y,z.z),p.push(F.x,F.y,F.z),f.push(W/O),f.push(0),L+=1}}for(let $=0;$<l;$++)for(let q=0;q<O;q++){let H=h+q+G*$,X=h+q+G*($+1),j=h+(q+1)+G*($+1),Y=h+(q+1)+G*$;c.push(H,X,Y),c.push(X,j,Y),V+=6}u.addGroup(m,V,M),m+=V,h+=L}function b(S,w,v){let _=new yr.Vector3,A=new yr.Vector3(t/2,e/2,r/2);A.subScalar(s);let x=[],T=S*w*v>0?(P,O,M)=>c.push(P,O,M):(P,O,M)=>c.push(P,M,O);for(let P=0;P<=l;P++){let O=[],M=Pp*(1-P/l),I=Math.cos(M),N=Math.sin(M),B=0;for(let D=0;D<=P;D++){let G=Math.cos(B),L=Math.sin(B);_.x=I*G,_.y=N,_.z=I*L;let V=A.clone().addScaledVector(_,s);d.push(S*V.x,w*V.y,v*V.z),p.push(S*_.x,w*_.y,v*_.z),f.push(0,0),O.push(h++),B+=Pp/P}x.push(O)}let C=x.length-1;for(let P=0;P<C;P++){let O=x[P],M=x[P+1],I=O.length-1;T(O[0],M[1],M[0]);for(let N=1;N<=I;N++)T(O[N-1],O[N],M[N]),T(O[N],M[N+1],M[N])}}}};var St=require("three"),Ln=class extends St.BufferGeometry{constructor(t=[],e=[],r="",o=1,i=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],u=[];c(),d(),this.setAttribute("position",new St.Float32BufferAttribute(s,3)),this.setAttribute("normal",new St.Float32BufferAttribute(u,3)),this.setAttribute("uv",new St.Float32BufferAttribute(l,2));return;function c(){i=Math.min(1-1e-5,i),i==0&&(a=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],h=new St.Vector3,m=h.clone(),y=new St.Triangle,g=i*o,b=o-g,S=a+1,w=new St.Vector3,v=(L,V)=>w.subVectors(L,V).normalize(),_=(L,V)=>Array(L).fill(void 0).map(V),A=_(t.length/3,(L,V)=>new St.Vector3().fromArray(t,V*3).setLength(o)),x=[],T=1e6;for(let L=0;L<A.length;L++){let V=A[L],z=[],F,$,q,H=1e10,X=-1;for(;(X=e.indexOf(L,X+1))!=-1;){let k=X-X%3;F=e[k+(X+1)%3],$=e[k+(X+2)%3],q=V.distanceToSquared(A[F]),H=Math.min(H,q),z.push([F,$,q])}H+=1e-6;let j=[],Y=0,W=z.length;for(let k=0;k<W;k++){[F,$,q]=z[Y];let ne=x[F]?.includes(L)==!0;q<=H&&j.push(F+ +ne*T),Y=z.findIndex(ee=>ee[0]==$)}x.push(j)}let C=[];{let L=0,V=0,z,F,$=f==3;for(let q=0;q<=a;q++){z=q*(q+1)/2,F=(q+1)*(q+2)/2;for(let H=0;H<a-q;H++)[L,V]=[z+H+q+2,F+H+q+3],C.push(z,F,...$?[V,z]:[L,F],V,L),[z,F]=[L,V];C.push(z,F,z+a+2)}}let P=h.clone(),O=h.clone(),M=h.clone(),I=h.clone(),N=h.clone(),B=[],D=_(A.length,()=>_(f,()=>h.clone()));for(let L=0;L<A.length;L++){h.copy(A[L]).normalize(),P.copy(h).multiplyScalar(b);let V=x[L];for(let j=0;j<V.length;j++){let Y=V[j],W=V[(j+1)%f];y.setFromPointsAndIndices(A,L,Y%T,W%T),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(P,D[L][j])}let z=[],F=[],$=[],q=new St.Vector3;a==0&&[...D[L]].reduce((j,Y)=>j.add(Y),q).multiplyScalar(1/f);for(let j=0;j<f;j++){let Y=[],W=(j-1+f)%f,k=D[L][W],ne=D[L][j];h.copy(k).sub(P),m.copy(ne).sub(P);let ee=P.angleTo(h),K=h.angleTo(m),te=Math.cos(ee)*g;a==0?O.copy(q):O.copy(P).setLength(b+te),F.push(te);let Z=[O,k,ne];for(let le=0;le<2;le++){let ie=Z[le],ae=Z[le+1];I.subVectors(ie,P),N.subVectors(ae,P),M.crossVectors(I,N).normalize();for(let pe=0;pe<S;pe++){let ce=[ee,K][le]*pe/S;h.copy(I).applyAxisAngle(M,ce).add(P),z.push(h.clone()),le&&(v(h,P),Y.push([pe==0?ie:h.clone(),w.clone()]))}le&&(v(ae,P),Y.push([ae,w.clone()]))}$.push(Y)}B.push($);let H=2*S,X=2;for(let j=0;j<f;j++){let Y=H*j,W=H*((j+1)%f),k=[z[Y]];for(let ee=1;ee<S;ee++){I=z[Y+ee],N=z[W+ee],k.push(I);for(let K=1,te=ee-X+1;K<=te;K++)h.lerpVectors(I,N,K/(te+1)),h.sub(P).setLength(F[j]).add(P),k.push(h.clone());k.push(N)}for(let ee=0;ee<S;ee++)k.push(z[ee+S+Y]);k.push(z[W+S]);let ne=C.map(ee=>k[ee]);s.push(...ne.map(ee=>[ee.x,ee.y,ee.z]).flat()),u.push(...ne.map(ee=>(v(ee,P),[w.x,w.y,w.z])).flat())}}let G=[];for(let L=0;L<x.length;L++)for(let V=0;V<f;V++){let z=x[L][V];if(z<T){let F=x[z].findIndex(H=>H%T==L),$=B[L][V],q=B[z][F];for(let H=0;H<S;H++){let X=$[H],j=q[S-H],Y=$[H+1],W=q[S-(H+1)];[X,j,Y,Y,j,W].forEach(k=>{s.push(k[0].x,k[0].y,k[0].z),u.push(k[1].x,k[1].y,k[1].z)})}G.push($[0][0],q[S][0],$[S][0],q[0][0])}}for(;G.length;){let L,V,z,F;[L,V]=G.splice(0,2);let $=[L];for(;L!=V;)$.push(V),z=G.indexOf(V),F=z%2,V=G.splice(z-F,2)[1-F];w.subVectors($[0],$[1]).cross(h.subVectors($[0],$[2])).normalize();let q=w.dot($[0])<0;q&&w.negate();for(let H=1;H<=$.length-2;H++)[$[H+ +q],$[H+1-+q],$[0]].forEach(X=>{s.push(X.x,X.y,X.z),u.push(w.x,w.y,w.z)})}}function d(){let p=new St.Vector3;for(let A=0;A<s.length;A+=3){p.x=s[A+0],p.y=s[A+1],p.z=s[A+2];let x=v(p)/2/Math.PI+.5,T=_(p)/Math.PI+.5;l.push(x,1-T)}let f=new St.Vector3,h=new St.Vector3,m=new St.Vector3,y=new St.Vector3,g=new St.Vector2,b=new St.Vector2,S=new St.Vector2,w=(A,x,T,C)=>{C<0&&A.x===1&&(l[x]=A.x-1),T.x===0&&T.z===0&&(l[x]=C/2/Math.PI+.5)};for(let A=0,x=0;A<s.length;A+=9,x+=6){f.set(s[A+0],s[A+1],s[A+2]),h.set(s[A+3],s[A+4],s[A+5]),m.set(s[A+6],s[A+7],s[A+8]),g.set(l[x+0],l[x+1]),b.set(l[x+2],l[x+3]),S.set(l[x+4],l[x+5]),y.copy(f).add(h).add(m).divideScalar(3);let T=v(y);w(g,x+0,f,T),w(b,x+2,h,T),w(S,x+4,m,T)}for(let A=0;A<l.length;A+=6){let x=l[A+0],T=l[A+2],C=l[A+4],P=Math.max(x,T,C),O=Math.min(x,T,C);P>.9&&O<.1&&(x<.2&&(l[A+0]+=1),T<.2&&(l[A+2]+=1),C<.2&&(l[A+4]+=1))}function v(A){return Math.atan2(A.z,-A.x)}function _(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(t){return new Ln(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var i0=require("three"),a0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new ul(t*.5,i,a):new i0.DodecahedronGeometry(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},ul=class extends Ln{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,i=1/o,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-o,0,-i,o,0,i,-o,0,i,o,-i,-o,0,-i,o,0,i,-o,0,i,o,0,-o,0,-i,o,0,-i,-o,0,i,o,0,i],s=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(a,s,l,t,e,r),this.type=l}static fromJSON(t){return new ul(t.radius,t.corner,t.cornerSides)}};var je=require("three");var Ae=require("three"),dl=1e-12,Ma=class{constructor(t){this.position=new Ae.Vector2;this.startPosition=new Ae.Vector2;this.uuid=Ae.MathUtils.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Ma(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Ia=class extends Ma{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Ia(this.parent).copy(this)}},oo=class extends Ma{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Ia(this),new Ia(this))}static create(e,r){let o=new oo(e,new Ae.Vector2(...r.position));return o.controls[0].position.set(...r.controlPrevious.position),o.controls[1].position.set(...r.controlNext.position),o.roundness=r.roundness,o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,o}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let o=0,i=this.controls.length;o<i;o++){let a=this.controls[o];this.position.distanceTo(a.position)<=r?a.position.copy(this.position):a.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new oo(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new Ae.Vector2,r=new Ae.Vector2){let[o,i]=this.computeTangents();return o&&i&&(s0(o,e),s0(i,r)),[e,r]}computeTangent(e=new Ae.Vector2){let[r,o]=this.computeTangents();return r&&o&&e.copy(r).add(o).normalize(),e}computeNormal(e=new Ae.Vector2){let[r,o]=this.computeNormals();return e.copy(r).add(o).normalize(),e}};function s0(n,t=new Ae.Vector2){let e=n.length();return t.set(-n.y/e,n.x/e)}var Tp=n=>n,Na=new Ae.Vector2,yu=new Ae.Vector2,uC=new Ae.Vector2,dC=new Ae.Vector2,pC=new Ae.Vector2,fC=new Ae.Vector2,c0=new Ae.Vector3,u0=new Ae.Vector3;function d0(n){let t=new Ae.Vector2;t.addVectors(n.v0,Na.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Ae.Vector2;return e.addVectors(n.v2,yu.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new Ae.CubicBezierCurve(n.v0,t,e,n.v2)}function pl(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function hC(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function mC(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function Mp(n,t,e){let r=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),o=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),i=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((o*o+r*r-i*i)/(2*o*r))}function p0(n,t,e){return l0(n,t)&&l0(t,e)&&Cp(n.position,t.position,e.position)}function Cp(n,t,e){return Na.copy(t).sub(n).cross(yu.copy(e).sub(n))===0}function f0(n,t,e,r,o){let i=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),a=(n.y+t.y)/2,s=(n.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(n.y-t.y)/i,u=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(t.x-n.x)/i;return r.set(s+l,a+u),o.set(s-l,a-u),[r,o]}function h0(n,t,e){let r=n.distanceTo(e),o=t.distanceTo(e);return r<o?t:n}function m0(n,t,e,r,o,i){let a=t.x-n.x,s=t.y-n.y,l=e.x-n.x,u=e.y-n.y,c=Math.sqrt((a+l)*(a+l)+(s+u)*(s+u)),d;return Mp(t,n,e)>Math.PI&&(c*=-1),pl(u,s)?d=(s+u)*(r/c-.5)*8/3/(a-l):d=(a+l)*(r/c-.5)*8/3/(u-s),o.set(t.x-d*s,t.y+d*a),i.set(e.x+d*u,e.y-d*l),[o,i]}function Ip(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function l0(n,t){return Cp(n.position,n.controls[1].position,t.position)&&Cp(n.position,t.controls[0].position,t.position)}function y0(n,t,e,r,o=.5){let i=Na.subVectors(t,n).multiplyScalar(o).add(n),a=yu.subVectors(e,t).multiplyScalar(o).add(t),s=uC.subVectors(r,e).multiplyScalar(o).add(e),l=i,u=dC.subVectors(a,i).multiplyScalar(o).add(i),c=pC.subVectors(s,a).multiplyScalar(o).add(a),d=s,p=fC.subVectors(c,u).multiplyScalar(o).add(u);return[n.x,n.y,l.x,l.y,u.x,u.y,p.x,p.y,c.x,c.y,d.x,d.y,r.x,r.y]}function g0(n,t,e=12,r=!0){let o=u0.set(0,0,0),i,a=0,s=[];for(let l=0;l<t.length;l++){let u=Tp(t[l]),c=Na,d=Rn(u,e);s.push(d);for(let p=0;p<=d;p++)if(u instanceof Ae.CubicBezierCurve||u instanceof Ae.QuadraticBezierCurve||u instanceof Ae.LineCurve){if(u.getPoint(p/d,c),o.set(c.x,c.y,0),i!==void 0&&mC(i,o))continue;i===void 0&&(i=c0),i.copy(o),n.setXYZ(a,o.x,o.y,o.z),a++}}return r&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),n}function x0(n,t,e,r=12,o=!0){let i=u0.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=Tp(t[l]),d=Na,p=Rn(c,r);s.push(p);for(let f=0;f<=p;f++)if(c instanceof Ae.CubicBezierCurve||c instanceof Ae.QuadraticBezierCurve||c instanceof Ae.LineCurve){if(c.getPoint(f/p,d),i.set(d.x,d.y,0),u?.equals(i))continue;u===void 0?u=c0:(n.setXYZ(a,u.x,u.y,u.z),a++,n.setXYZ(a,i.x,i.y,i.z),a++),u.copy(i)}}return o&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),s}function Np(n,t=12,e=!1){let r=[];for(let o=0,i=n.length;o<i;o++){let a=n[o],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=Rn(a.roundedCurveCorner,t)*.5;o>0&&(r[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=Rn(a.curveAfter,t)),r.push(s)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=Rn(n[0].roundedCurveCorner,t)*.5),r}function Rn(n,t=12){return n&&n instanceof Ae.EllipseCurve?t*2:n&&(n instanceof Ae.LineCurve||n instanceof Ae.LineCurve3)?1:n&&n instanceof Ae.SplineCurve?t*n.points.length:t}function b0(n,t,e=12,r=!0){let o,i=0;for(let a=0;a<t.length;a++){let s=Tp(t[a]),l=Rn(s,e),u=Na;for(let c=0;c<=l;c++)if(s instanceof Ae.CubicBezierCurve||s instanceof Ae.QuadraticBezierCurve||s instanceof Ae.LineCurve){if(s.getPoint(c/l,u),o!==void 0&&hC(o,u,dl))continue;o===void 0&&(o=yu),o.copy(u),n.push(u.x,u.y),i++}}return pl(n[0],n[n.length-2],dl)&&pl(n[1],n[n.length-1],dl)&&(n.pop(),n.pop()),r&&i>1&&!(pl(n[i-1],n[1],dl)&&pl(n[i-2],n[0],dl))&&(n.push(n[0],n[1]),i++),n}var Dp=new je.Vector2,yC=new je.Vector2,gC=new je.Vector2,xC=new je.Vector2,bC=new je.Vector2,vC=new je.Vector2,Fe=class extends je.Shape{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new je.Plane(new je.Vector3(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this.isText=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=je.MathUtils.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,o){let i=new Fe;return i.isClosed=e.isClosed,i.points=e.points.map(a=>oo.create(a.id,a.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(a=>Fe.createFromState(a)),r!==void 0&&o!==void 0&&i.applySize(r,o),i.update(),i}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let r=0,o=this.points.length;r<o;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,o=this.points.findIndex(i=>i.uuid===e);if(o<0){let i=r;for(let a=0,s=this.shapeHoles.length;a<s;a++){let l=this.shapeHoles[a],u=l.points.length,c=l.getPointIndexById(e);if(c<0)i+=u;else return c+i}}return o}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let r=this.points.length;for(let o=0,i=this.shapeHoles.length;o<i;o++){let a=this.shapeHoles[o],s=e-r;if(s<=a.points.length-1)return a.points[s];r+=a.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let o=0,i=this.shapeHoles.length;o<i;o++){let a=this.shapeHoles[o],s=a.points.indexOf(e);if(s>=0)return r+s;r+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let o=Dp.set(e,r);for(let i=0,a=this.points.length;i<a;i++){let s=this.points[i];s.position.multiply(o),s.controls[0].position.multiply(o),s.controls[1].position.multiply(o)}for(let i=0,a=this.shapeHoles.length;i<a;i++)this.shapeHoles[i].applyScale(e,r);this._update()}createPoint(e,r=0,o=je.MathUtils.generateUUID()){let i;e instanceof je.Vector2?i=e:i=new je.Vector2(e,r);let a=new oo(o,i);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,o=this.points.length;r<o;r++){let i=this.points[r];if(i.uuid===e)return i}for(let r=0,o=this.shapeHoles.length;r<o;r++){let a=this.shapeHoles[r].getPointByUuid(e);if(a)return a}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(o=>o.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,o=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let i=o?this.roundedCurveDivisions:this.curveDivisions;return g0(e,o?this.roundedCurves:this.curves,r,this.autoClose),i.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Np(this.points,e,!1),this.roundedCurveDivisions=Np(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,o=12){return x0(e,this.curves,r,o,this.autoClose).reduce((a,s)=>a+s,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),b0(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let i=r?this.roundedCurveDivisions:this.curveDivisions,a=0;r&&this.points[0].roundedCurveCorner!==void 0&&(a=Rn(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=i.reduce((l,u)=>l+u,0));for(let l=0,u=i.length;l<u;l++){let c=i[l];if(s<o+c)return[l,(s-o+1)/c];o+=c}return[0,1]}getCurveT(e,r,o){let i=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(Ip(i,a)){let d=i.position.distanceTo(a.position);return i.position.distanceTo(Dp.set(o.x,o.y))/d}let u=0;for(let d=0;d<e;d++)u+=s[d];return(r-u)/l}dispose(){}_applyCurveForPoint(e,r){Ip(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let o=this.curves[this.curves.length-1];e.curveBefore=o,r.curveAfter=o;let i=o.clone();e.roundedCurveBefore=i,r.roundedCurveAfter=i,e.roundedCurveCorner=void 0,this.roundedCurves.push(i)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,o=this.points.length;r<o;r++){let i=this.points[r];if(r===0)this.moveTo(i.position.x,i.position.y);else{let a=this.points[r-1];this._applyCurveForPoint(i,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],o=this.points[this.points.length-1];this._applyCurveForPoint(r,o)}if(this.points.length>2){let r=0;for(let o=0,i=this.points.length;o<i;o++){let a=this.points[o],s=this.points[o-1]??this.points[this.points.length-1],l=this.points[o+1]??this.points[0],u=a.roundness,c=s&&l&&p0(s,a,l);if(!a.controlsMoved()&&u>0&&!c){let d=a.curveBefore,p=a.curveAfter;if(d===void 0||p===void 0)continue;let f=a.roundedCurveBefore,h=a.roundedCurveAfter,m=d.getLength(),y=p.getLength(),g=Math.min(u,m*.499),b=Math.min(u,y*.499),S=Math.min(g,b),w=1-S/m,v=S/y,_=d.getPointAt(w,Dp),A=p.getPointAt(v,yC);this._subSplitCurve(d,f,w,_,void 0),this._subSplitCurve(p,h,v,void 0,A);let x;if(this.useCubicForRoundedCorners){let T=Mp(_,a.position,A)/2,C=Math.tan(T)*_.distanceTo(a.position),[P,O]=f0(_,A,C,gC,xC),M=h0(P,O,a.position),[I,N]=m0(M,_,A,C,bC,vC);x=new je.CubicBezierCurve(_.clone(),I.clone(),N.clone(),A.clone())}else x=new je.QuadraticBezierCurve(_.clone(),a.position.clone(),A.clone());a.roundedCurveCorner=x,this.roundedCurves.splice(o+r,0,x),r++}}}}_subSplitCurve(e,r,o,i,a){if(e instanceof je.LineCurve)i!==void 0&&r.v2.copy(i),a!==void 0&&r.v1.copy(a);else{let s=e,l=r,u=s.getUtoTmapping(o,0),c=y0(s.v0,s.v1,s.v2,s.v3,u);return i!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),a!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return r}clone(){let e=new Fe(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let o=0;o<r;o++){let i=o*7,a=e.points[i+0],s=e.points[i+1],l=e.points[i+2],u=e.points[i+3],c=e.points[i+4],d=e.points[i+5],p=e.points[i+6],f=new oo(je.MathUtils.generateUUID(),new je.Vector2(a,s));f.controls[0].position.set(l,u),f.controls[1].position.set(c,d),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new Fe;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let o=(a,s)=>{s instanceof je.CubicBezierCurve&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},i=a=>{let s=[],l,u;for(l=0,u=a.length;l<u;l++)a[l]instanceof je.QuadraticBezierCurve&&(a[l]=d0(a[l]));for(l=0,u=a.length;l<u;l++){let p=a[l],f=l>0?a[l-1]:null,h;p instanceof je.CubicBezierCurve?(h=this.createPoint(p.v0),h.controls[1].position.copy(p.v1)):p instanceof je.LineCurve&&(h=this.createPoint(p.v1)),h!==void 0&&(f!==null&&o(h,f),s.push(h))}let c=a[a.length-1],d=!1;return c instanceof je.CubicBezierCurve?c.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(c.v2),d=!0):c instanceof je.LineCurve&&c.v2.equals(s[0].position)&&(d=!0),this.isClosed=d,s};return this.points=i(e.curves),e instanceof je.Shape&&(this.shapeHoles=e.holes.map(a=>{let s=new Fe;return s.fromShape(a),s})),this.update(),this}updatePoint(e,r){let o=this.getPointByUuid(e);o&&(r.position!==void 0&&o.position.fromArray(r.position),r.roundness!==void 0&&(o.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let i=this.getPointByUuid(e)?.controls[0];i&&(r.position&&i.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let i=this.getPointByUuid(e)?.controls[1];i&&(r.position&&i.position.fromArray(r.position),this.needsUpdate=!0)}};var Bp=Math.PI*2;function Ep({x:n,y:t},e,r,o,i){return{x:n*e+o,y:t*r+i}}function SC(n,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(n),o=Math.sin(n),i=Math.cos(n+t),a=Math.sin(n+t);return[{x:r-o*e,y:o+r*e},{x:i+a*e,y:a-i*e},{x:i,y:a}]}function v0(n,t,e,r){let o=n*r-t*e<0?-1:1,i=Math.min(1,Math.max(-1,n*e+t*r));return o*Math.acos(i)}function wC(n,t,e,r,o,i,a,s,l,u){let c=Math.pow(o,2),d=Math.pow(i,2),p=Math.pow(a,2),f=Math.pow(s,2),h=c*d-c*f-d*p;h<0&&(h=0),h/=c*f+d*p,h=Math.sqrt(h)*(l===u?-1:1);let m=h*o/i*s,y=h*-i/o*a,g=m+(n+e)/2,b=y+(t+r)/2,S=(a-m)/o,w=(s-y)/i,v=(-a-m)/o,_=(-s-y)/i,A=v0(1,0,S,w),x=v0(S,w,v,_);return!u&&x>0&&(x-=Bp),u&&x<0&&(x+=Bp),{centerx:g,centery:b,ang1:A,ang2:x}}function S0({px:n,py:t,cx:e,cy:r,rx:o,ry:i,largeArcFlag:a,sweepFlag:s}){let l=[];if(o===0||i===0)return[];let u=(n-e)/2,c=(t-r)/2;if(u===0&&c===0)return[];o=Math.abs(o),i=Math.abs(i);let d=Math.pow(u,2)/Math.pow(o,2)+Math.pow(c,2)/Math.pow(i,2);d>1&&(o*=Math.sqrt(d),i*=Math.sqrt(d));let p=wC(n,t,e,r,o,i,u,c,a,s),{ang1:f,ang2:h}=p,{centerx:m,centery:y}=p,g=Math.abs(h)/(Bp/4);Math.abs(1-g)<1e-7&&(g=1);let b=Math.max(Math.ceil(g),1);h/=b;for(let S=0;S<b;S++)l.push(SC(f,h)),f+=h;return l.map(S=>{let{x:w,y:v}=Ep(S[0],o,i,m,y),{x:_,y:A}=Ep(S[1],o,i,m,y),{x,y:T}=Ep(S[2],o,i,m,y);return{x1:w,y1:v,x2:_,y2:A,x,y:T}})}var mi=require("three");var Re;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Re||(Re={}));var ht;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(ht||(ht={}));function ge(n,t){if(!n)throw t||"Assertion Failed!"}var he=function(){function n(){}return n.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},n.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},n.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},n.edgeGoesLeft=function(t){return n.vertLeq(t.Dst,t.Org)},n.edgeGoesRight=function(t){return n.vertLeq(t.Org,t.Dst)},n.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},n.edgeEval=function(t,e,r){ge(n.vertLeq(t,e)&&n.vertLeq(e,r));var o=e.s-t.s,i=r.s-e.s;return o+i>0?o<i?e.t-t.t+(t.t-r.t)*(o/(o+i)):e.t-r.t+(r.t-t.t)*(i/(o+i)):0},n.edgeSign=function(t,e,r){ge(n.vertLeq(t,e)&&n.vertLeq(e,r));var o=e.s-t.s,i=r.s-e.s;return o+i>0?(e.t-r.t)*o+(e.t-t.t)*i:0},n.transEval=function(t,e,r){ge(n.transLeq(t,e)&&n.transLeq(e,r));var o=e.t-t.t,i=r.t-e.t;return o+i>0?o<i?e.s-t.s+(t.s-r.s)*(o/(o+i)):e.s-r.s+(r.s-t.s)*(i/(o+i)):0},n.transSign=function(t,e,r){ge(n.transLeq(t,e)&&n.transLeq(e,r));var o=e.t-t.t,i=r.t-e.t;return o+i>0?(e.s-r.s)*o+(e.s-t.s)*i:0},n.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},n.interpolate=function(t,e,r,o){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+o)/2:e+(o-e)*(t/(t+r)):o+(e-o)*(r/(t+r))},n.intersect=function(t,e,r,o,i){var a,s,l;n.vertLeq(t,e)||(l=t,t=e,e=l),n.vertLeq(r,o)||(l=r,r=o,o=l),n.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),n.vertLeq(r,e)?n.vertLeq(e,o)?(a=n.edgeEval(t,r,e),s=n.edgeEval(r,e,o),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,r.s,s,e.s)):(a=n.edgeSign(t,r,e),s=-n.edgeSign(t,o,e),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,r.s,s,o.s)):i.s=(r.s+e.s)/2,n.transLeq(t,e)||(l=t,t=e,e=l),n.transLeq(r,o)||(l=r,r=o,o=l),n.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),n.transLeq(r,e)?n.transLeq(e,o)?(a=n.transEval(t,r,e),s=n.transEval(r,e,o),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,r.t,s,e.t)):(a=n.transSign(t,r,e),s=-n.transSign(t,o,e),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,r.t,s,o.t)):i.t=(r.t+e.t)/2},n}(),fl=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return n}(),gu=function(){function n(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),n}(),Da=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return n}(),w0=function(){function n(){var t=new Da,e=new fl,r=new gu(0),o=new gu(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=o,o.next=o,o.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=o}return n.prototype.makeEdge_=function(t){var e=new gu(0),r=new gu(1);t.Sym.side<t.side&&(t=t.Sym);var o=t.Sym.next;return r.next=o,o.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},n.prototype.splice_=function(t,e){var r=t.Onext,o=e.Onext;r.Sym.Lnext=e,o.Sym.Lnext=t,t.Onext=o,e.Onext=r},n.prototype.makeVertex_=function(t,e,r){var o=t;ge(o,"Vertex can't be null!");var i=r.prev;o.prev=i,i.next=o,o.next=r,r.prev=o,o.anEdge=e;var a=e;do a.Org=o,a=a.Onext;while(a!==e)},n.prototype.makeFace_=function(t,e,r){var o=t;ge(o,"Face can't be null");var i=r.prev;o.prev=i,i.next=o,o.next=r,r.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=r.inside;var a=e;do a.Lface=o,a=a.Lnext;while(a!==e)},n.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},n.prototype.killVertex_=function(t,e){var r=t.anEdge,o=r;do o.Org=e,o=o.Onext;while(o!==r);var i=t.prev,a=t.next;a.prev=i,i.next=a},n.prototype.killFace_=function(t,e){var r=t.anEdge,o=r;do o.Lface=e,o=o.Lnext;while(o!==r);var i=t.prev,a=t.next;a.prev=i,i.next=a},n.prototype.makeEdge=function(){var t=new Da,e=new Da,r=new fl,o=this.makeEdge_(this.eHead);return this.makeVertex_(t,o,this.vHead),this.makeVertex_(e,o.Sym,this.vHead),this.makeFace_(r,o,this.fHead),o},n.prototype.splice=function(t,e){var r=!1,o=!1;if(t!==e){if(e.Org!==t.Org&&(o=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!o){var i=new Da;this.makeVertex_(i,e,t.Org),t.Org.anEdge=t}if(!r){var a=new fl;this.makeFace_(a,e,t.Lface),t.Lface.anEdge=t}}},n.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var o=new fl;this.makeFace_(o,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},n.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var o=new Da;return this.makeVertex_(o,r,e.Org),e.Lface=r.Lface=t.Lface,e},n.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},n.prototype.connect=function(t,e){var r=!1,o=this.makeEdge_(t),i=o.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(o,t.Lnext),this.splice_(i,e),o.Org=t.Dst,i.Org=e.Org,o.Lface=i.Lface=t.Lface,t.Lface.anEdge=i,!r){var a=new fl;this.makeFace_(a,o,t.Lface)}return o},n.prototype.zapFace=function(t){var e=t.anEdge,r,o,i,a,s;o=e.Lnext;do r=o,o=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),i=r.Sym,i.Onext===i?this.killVertex_(i.Org,null):(i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(r));while(r!=e);a=t.prev,s=t.next,s.prev=a,a.next=s},n.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},n.prototype.mergeConvexFaces=function(t){var e,r,o,i,a,s,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,a=r.Org;o=r.Lnext,i=r.Sym,i&&i.Lface&&i.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(i.Lface),s+l-2<=t&&he.vertCCW(r.Lprev.Org,r.Org,i.Lnext.Lnext.Org)&&he.vertCCW(i.Lprev.Org,i.Org,r.Lnext.Lnext.Org)&&(o=i.Lnext,this.delete(i),r=null,i=null)),!(r&&r.Lnext.Org===a);)r=o;return!0},n.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,o,i,a,s,l,u;for(i=t,i=t;(o=i.next)!==t;i=o){ge(o.prev===i),l=o.anEdge;do ge(l.Sym!==l),ge(l.Sym.Sym===l),ge(l.Lnext.Onext.Sym===l),ge(l.Onext.Sym.Lnext===l),ge(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(ge(o.prev===i&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){ge(a.prev===s),l=a.anEdge;do ge(l.Sym!==l),ge(l.Sym.Sym===l),ge(l.Lnext.Onext.Sym===l),ge(l.Onext.Sym.Lnext===l),ge(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(ge(a.prev===s&&a.anEdge===null),u=r,u=r;(l=u.next)!==r;u=l)ge(l.Sym.next===u.Sym),ge(l.Sym!==l),ge(l.Sym.Sym===l),ge(l.Org!==null),ge(l.Dst!==null),ge(l.Lnext.Onext.Sym===l),ge(l.Onext.Sym.Lnext===l);ge(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},n}(),_0=function(){function n(){this.handle=null}return n}(),A0=function(){function n(){this.key=null,this.node=0}return n}(),_C=function(){function n(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new _0,this.handles[r]=new A0;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,o,i,a;for(o=e[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[e[a+1].handle].key,r[e[a].handle].key)&&++a,ge(a<=this.max),i=e[a].handle,a>this.size||this.leq(r[o].key,r[i].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=i,r[i].node=t,t=a}},n.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,o,i,a;for(o=e[t].handle;;){if(a=t>>1,i=e[a].handle,a===0||this.leq(r[i].key,r[o].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=i,r[i].node=t,t=a}},n.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var o,i;for(i=this.nodes.length,this.nodes.length=this.max+1,o=i;o<this.nodes.length;o++)this.nodes[o]=new _0;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new A0}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},n.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,o=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),o},n.prototype.delete=function(t){var e=this.nodes,r=this.handles,o;ge(t>=1&&t<=this.max&&r[t].key!==null),o=r[t].node,e[o].handle=e[this.size].handle,r[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(r[e[o>>1].handle].key,r[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},n}(),Lp=function(){function n(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return n}(),P0=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),AC=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new P0,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(t){return this.insertBefore(this.head,t)},n.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},n.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new P0;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},n.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},n}(),PC=function(){function n(){}return n.regionBelow=function(t){return t.nodeUp.prev.key},n.regionAbove=function(t){return t.nodeUp.next.key},n.debugEvent=function(t){},n.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.edgeLeq=function(t,e,r){var o=t.event,i=e.eUp,a=r.eUp;if(i.Dst===o)return a.Dst===o?he.vertLeq(i.Org,a.Org)?he.edgeSign(a.Dst,i.Org,a.Org)<=0:he.edgeSign(i.Dst,a.Org,i.Org)>=0:he.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return he.edgeSign(i.Dst,o,i.Org)>=0;var s=he.edgeEval(i.Dst,o,i.Org),l=he.edgeEval(a.Dst,o,a.Org);return s>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&ge(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){ge(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},n.topLeftRegion=function(t,e){var r=e.eUp.Org,o;do e=n.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(o=t.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;n.fixUpperEdge(t,e,o),e=n.regionAbove(e)}return e},n.topRightRegion=function(t){var e=t.eUp.Dst;do t=n.regionAbove(t);while(t.eUp.Dst===e);return t},n.addRegionBelow=function(t,e,r){var o=new Lp;return o.eUp=r,o.nodeUp=t.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,r.activeRegion=o,o},n.isWindingInside=function(t,e){switch(t.windingRule){case Re.ODD:return(e&1)!==0;case Re.NONZERO:return e!==0;case Re.POSITIVE:return e>0;case Re.NEGATIVE:return e<0;case Re.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(t,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(t,e.windingNumber)},n.finishRegion=function(t,e){var r=e.eUp,o=r.Lface;o.inside=e.inside,o.anEdge=r,n.deleteRegion(t,e)},n.finishLeftRegions=function(t,e,r){for(var o,i=null,a=e,s=e.eUp;a!==r;){if(a.fixUpperEdge=!1,i=n.regionBelow(a),o=i.eUp,o.Org!=s.Org){if(!i.fixUpperEdge){n.finishRegion(t,a);break}o=t.mesh.connect(s.Lprev,o.Sym),n.fixUpperEdge(t,i,o)}s.Onext!==o&&(t.mesh.splice(o.Oprev,o),t.mesh.splice(s,o)),n.finishRegion(t,a),s=i.eUp,a=i}return s},n.addRightEdges=function(t,e,r,o,i,a){var s,l,u,c,d=!0;u=r;do ge(he.vertLeq(u.Org,u.Dst)),n.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==o);for(i===null&&(i=n.regionBelow(e).eUp.Rprev),l=e,c=i;s=n.regionBelow(l),u=s.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(t.mesh.splice(u.Oprev,u),t.mesh.splice(c.Oprev,u)),s.windingNumber=l.windingNumber-u.winding,s.inside=n.isWindingInside(t,s.windingNumber),l.dirty=!0,!d&&n.checkForRightSplice(t,l)&&(n.addWinding(u,c),n.deleteRegion(t,l),t.mesh.delete(c)),d=!1,l=s,c=u;l.dirty=!0,ge(l.windingNumber-u.winding===s.windingNumber),a&&n.walkDirtyRegions(t,l)},n.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},n.vertexWeights=function(t,e,r){var o=he.vertL1dist(e,t),i=he.vertL1dist(r,t),a=.5*i/(o+i),s=.5*o/(o+i);t.coords[0]+=a*e.coords[0]+s*r.coords[0],t.coords[1]+=a*e.coords[1]+s*r.coords[1],t.coords[2]+=a*e.coords[2]+s*r.coords[2]},n.getIntersectData=function(t,e,r,o,i,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,r,o),n.vertexWeights(e,i,a)},n.checkForRightSplice=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp;if(he.vertLeq(o.Org,i.Org)){if(he.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;he.vertEq(o.Org,i.Org)?o.Org!==i.Org&&(t.pq.delete(o.Org.pqHandle),n.spliceMergeVertices(t,i.Oprev,o)):(t.mesh.splitEdge(i.Sym),t.mesh.splice(o,i.Oprev),e.dirty=r.dirty=!0)}else{if(he.edgeSign(o.Dst,i.Org,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Oprev,o)}return!0},n.checkForLeftSplice=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp,a;if(ge(!he.vertEq(o.Dst,i.Dst)),he.vertLeq(o.Dst,i.Dst)){if(he.edgeSign(o.Dst,i.Dst,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,a=t.mesh.splitEdge(o),t.mesh.splice(i.Sym,a),a.Lface.inside=e.inside}else{if(he.edgeSign(i.Dst,o.Dst,i.Org)>0)return!1;e.dirty=r.dirty=!0,a=t.mesh.splitEdge(i),t.mesh.splice(o.Lnext,i.Sym),a.Rface.inside=e.inside}return!0},n.checkForIntersect=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp,a=o.Org,s=i.Org,l=o.Dst,u=i.Dst,c,d,p=new Da,f,h;if(ge(!he.vertEq(u,l)),ge(he.edgeSign(l,t.event,a)<=0),ge(he.edgeSign(u,t.event,s)>=0),ge(a!==t.event&&s!==t.event),ge(!e.fixUpperEdge&&!r.fixUpperEdge),a===s||(c=Math.min(a.t,l.t),d=Math.max(s.t,u.t),c>d))return!1;if(he.vertLeq(a,s)){if(he.edgeSign(u,a,s)>0)return!1}else if(he.edgeSign(l,s,a)<0)return!1;return n.debugEvent(t),he.intersect(l,a,u,s,p),ge(Math.min(a.t,l.t)<=p.t),ge(p.t<=Math.max(s.t,u.t)),ge(Math.min(u.s,l.s)<=p.s),ge(p.s<=Math.max(s.s,a.s)),he.vertLeq(p,t.event)&&(p.s=t.event.s,p.t=t.event.t),f=he.vertLeq(a,s)?a:s,he.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),he.vertEq(p,a)||he.vertEq(p,s)?(n.checkForRightSplice(t,e),!1):!he.vertEq(l,t.event)&&he.edgeSign(l,t.event,p)>=0||!he.vertEq(u,t.event)&&he.edgeSign(u,t.event,p)<=0?u===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Sym,o),e=n.topLeftRegion(t,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),r),n.addRightEdges(t,e,o.Oprev,o,o,!0),!0):l===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(o.Lnext,i.Oprev),r=e,e=n.topRightRegion(e),h=n.regionBelow(e).eUp.Rprev,r.eUp=i.Oprev,i=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,i.Onext,o.Rprev,h,!0),!0):(he.edgeSign(l,t.event,p)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),he.edgeSign(u,t.event,p)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),!1):(t.mesh.splitEdge(o.Sym),t.mesh.splitEdge(i.Sym),t.mesh.splice(i.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=t.pq.insert(o.Org),n.getIntersectData(t,o.Org,a,l,s,u),n.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(t,e){for(var r=n.regionBelow(e),o,i;;){for(;r.dirty;)e=r,r=n.regionBelow(r);if(!e.dirty&&(r=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,i=r.eUp,o.Dst!==i.Dst&&n.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(n.deleteRegion(t,r),t.mesh.delete(i),r=n.regionBelow(e),i=r.eUp):e.fixUpperEdge&&(n.deleteRegion(t,e),t.mesh.delete(o),e=n.regionAbove(r),o=e.eUp)),o.Org!==i.Org)if(o.Dst!==i.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(o.Dst===t.event||i.Dst===t.event)){if(n.checkForIntersect(t,e))return}else n.checkForRightSplice(t,e);o.Org===i.Org&&o.Dst===i.Dst&&(n.addWinding(i,o),n.deleteRegion(t,e),t.mesh.delete(o),e=n.regionAbove(r))}},n.connectRightVertex=function(t,e,r){var o,i=r.Onext,a=n.regionBelow(e),s=e.eUp,l=a.eUp,u=!1;if(s.Dst!==l.Dst&&n.checkForIntersect(t,e),he.vertEq(s.Org,t.event)&&(t.mesh.splice(i.Oprev,s),e=n.topLeftRegion(t,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),a),u=!0),he.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(t,a,null),u=!0),u){n.addRightEdges(t,e,r.Onext,i,i,!0);return}he.vertLeq(l.Org,s.Org)?o=l.Oprev:o=s,o=t.mesh.connect(r.Lprev,o),n.addRightEdges(t,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(t,e)},n.connectLeftDegenerate=function(t,e,r){var o,i,a,s,l;if(o=e.eUp,he.vertEq(o.Org,r)){ge(!1),n.spliceMergeVertices(t,o,r.anEdge);return}if(!he.vertEq(o.Dst,r)){t.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(t.mesh.delete(o.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,o),n.sweepEvent(t,r);return}ge(!1),e=n.topRightRegion(e),l=n.regionBelow(e),a=l.eUp.Sym,i=s=a.Onext,l.fixUpperEdge&&(ge(i!==a),n.deleteRegion(t,l),t.mesh.delete(a),a=i.Oprev),t.mesh.splice(r.anEdge,a),he.edgeGoesLeft(i)||(i=null),n.addRightEdges(t,e,a.Onext,s,i,!0)},n.connectLeftVertex=function(t,e){var r,o,i,a,s,l,u=new Lp;if(u.eUp=e.anEdge.Sym,r=t.dict.search(u).key,o=n.regionBelow(r),!!o){if(a=r.eUp,s=o.eUp,he.edgeSign(a.Dst,e,a.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(i=he.vertLeq(s.Dst,a.Dst)?r:o,r.inside||i.fixUpperEdge){if(i===r)l=t.mesh.connect(e.anEdge.Sym,a.Lnext);else{var c=t.mesh.connect(s.Dnext,e.anEdge);l=c.Sym}i.fixUpperEdge?n.fixUpperEdge(t,i,l):n.computeWinding(t,n.addRegionBelow(t,r,l)),n.sweepEvent(t,e)}else n.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(t,e){t.event=e,n.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){n.connectLeftVertex(t,e);return}var o=n.topLeftRegion(t,r.activeRegion);ge(o!==null);var i=n.regionBelow(o),a=i.eUp,s=n.finishLeftRegions(t,i,null);s.Onext===a?n.connectRightVertex(t,o,s):n.addRightEdges(t,o,s.Onext,a,a,!0)},n.addSentinel=function(t,e,r,o){var i=new Lp,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=o,a.Dst.s=e,a.Dst.t=o,t.event=a.Dst,i.eUp=a,i.windingNumber=0,i.inside=!1,i.fixUpperEdge=!1,i.sentinel=!0,i.dirty=!1,i.nodeUp=t.dict.insert(i)},n.initEdgeDict=function(t){t.dict=new AC(t,n.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],o=t.bmin[0]-e,i=t.bmax[0]+e,a=t.bmin[1]-r,s=t.bmax[1]+r;n.addSentinel(t,o,i,a),n.addSentinel(t,o,i,s)},n.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(ge(e.fixUpperEdge),ge(++r===1)),ge(e.windingNumber===0),n.deleteRegion(t,e)},n.removeDegenerateEdges=function(t){var e,r,o,i=t.mesh.eHead;for(e=i.next;e!==i;e=r)r=e.next,o=e.Lnext,he.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(t,o,e),t.mesh.delete(e),e=o,o=e.Lnext),o.Lnext===e&&(o!==e&&((o===r||o===r.Sym)&&(r=r.next),t.mesh.delete(o)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},n.initPriorityQ=function(t){var e,r,o,i=0;for(o=t.mesh.vHead,r=o.next;r!==o;r=r.next)i++;for(i+=8,e=t.pq=new _C(i,he.vertLeq),o=t.mesh.vHead,r=o.next;r!==o;r=r.next)r.pqHandle=e.insert(r);return r!==o?!1:(e.init(),!0)},n.donePriorityQ=function(t){t.pq=null},n.removeDegenerateFaces=function(t,e){var r,o,i;for(r=e.fHead.next;r!==e.fHead;r=o)o=r.next,i=r.anEdge,ge(i.Lnext!==i),i.Lnext.Lnext===i&&(n.addWinding(i.Onext,i),t.mesh.delete(i));return!0},n.computeInterior=function(t,e){e===void 0&&(e=!0);var r,o;if(n.removeDegenerateEdges(t),!n.initPriorityQ(t))return!1;for(n.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;o=t.pq.min(),!(o===null||!he.vertEq(o,r));)o=t.pq.extractMin(),n.spliceMergeVertices(t,r.anEdge,o.anEdge);n.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,n.debugEvent(t),n.doneEdgeDict(t),n.donePriorityQ(t),n.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},n}(),OC=function(){function n(){this.mesh=new w0,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=Re.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return n.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},n.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},n.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},n.prototype.computeNormal_=function(t){var e,r,o,i,a,s,l=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],p=[0,0,0],f=[null,null,null],h=[null,null,null],m=this.mesh.vHead;e=m.next;for(var y=0;y<3;++y)i=e.coords[y],u[y]=i,h[y]=e,l[y]=i,f[y]=e;for(e=m.next;e!==m;e=e.next)for(var g=0;g<3;++g)i=e.coords[g],i<u[g]&&(u[g]=i,h[g]=e),i>l[g]&&(l[g]=i,f[g]=e);var b=0;if(l[1]-u[1]>l[0]-u[0]&&(b=1),l[2]-u[2]>l[b]-u[b]&&(b=2),u[b]>=l[b]){t[0]=0,t[1]=0,t[2]=1;return}for(s=0,r=h[b],o=f[b],c[0]=r.coords[0]-o.coords[0],c[1]=r.coords[1]-o.coords[1],c[2]=r.coords[2]-o.coords[2],e=m.next;e!==m;e=e.next)d[0]=e.coords[0]-o.coords[0],d[1]=e.coords[1]-o.coords[1],d[2]=e.coords[2]-o.coords[2],p[0]=c[1]*d[2]-c[2]*d[1],p[1]=c[2]*d[0]-c[0]*d[2],p[2]=c[0]*d[1]-c[1]*d[0],a=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],a>s&&(s=a,t[0]=p[0],t[1]=p[1],t[2]=p[2]);s<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},n.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,o,i=0,a=t.next;a!==t;a=a.next)if(o=a.anEdge,!(o.winding<=0))do i+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==a.anEdge);if(i<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},n.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,o,i=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),i=!0),r=this.sUnit,o=this.tUnit;var a=this.longAxis_(e);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,o[a]=0,o[(a+1)%3]=0,o[(a+2)%3]=e[a]>0?1:-1;for(var s=t.next;s!==t;s=s.next)s.s=this.dot_(s.coords,r),s.t=this.dot_(s.coords,o);i&&this.checkOrientation_();for(var l=!0,u=t.next;u!==t;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},n.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(t,e){var r,o;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;he.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;he.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var i=void 0;r.Lnext!==o;)if(he.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(he.edgeGoesLeft(o.Lnext)||he.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)i=t.connect(o.Lnext,o),o=i.Sym;o=o.Lprev}else{for(;o.Lnext!==r&&(he.edgeGoesRight(r.Lprev)||he.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)i=t.connect(r,r.Lprev),r=i.Sym;r=r.Lnext}if(o.Lnext===r)throw"Mono region invalid";for(;o.Lnext.Lnext!==r;)i=t.connect(o.Lnext,o),o=i.Sym;return!0},n.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},n.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},n.prototype.setWindingNumber_=function(t,e,r){for(var o,i=t.eHead.next;i!==t.eHead;i=o)o=i.next,i.Rface.inside!==i.Lface.inside?i.winding=i.Lface.inside?e:-e:r?t.delete(i):i.winding=0},n.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},n.prototype.outputPolymesh_=function(t,e,r,o){var i,a=0,s=0,l;r>3&&t.mergeConvexFaces(r);for(var u=t.vHead.next;u!==t.vHead;u=u.next)u.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){i=c.anEdge,l=0;do{var u=i.Org;u.n===-1&&(u.n=s,s++),l++,i=i.Lnext}while(i!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=a,++a}this.elementCount=a,e===ht.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=s,this.vertices=[],this.vertices.length=s*o,this.vertexIndices=[],this.vertexIndices.length=s;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var d=u.n*o;this.vertices[d+0]=u.coords[0],this.vertices[d+1]=u.coords[1],o>2&&(this.vertices[d+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var p=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){i=c.anEdge,l=0;do{var u=i.Org;this.elements[p++]=u.n,l++,i=i.Lnext}while(i!==c.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1;if(e===ht.CONNECTED_POLYGONS){i=c.anEdge;do this.elements[p++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==c.anEdge);for(var h=l;h<r;++h)this.elements[p++]=-1}}},n.prototype.outputContours_=function(t,e){var r,o,i=0,a=0;this.vertexCount=0,this.elementCount=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){o=r=s.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==o);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,u=0,c=0;i=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){a=0,o=r=s.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==o);this.elements[c++]=i,this.elements[c++]=a,i+=a}},n.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new w0),t<2&&(t=2),t>3&&(t=3);for(var r=null,o=0;o<e.length;o+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[o+0],r.Org.coords[1]=e[o+1],t>2?r.Org.coords[2]=e[o+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},n.prototype.tesselate=function(t,e,r,o,i,a){if(t===void 0&&(t=Re.ODD),e===void 0&&(e=ht.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,i&&(this.normal[0]=i[0],this.normal[1]=i[1],this.normal[2]=i[2]),this.windingRule=t,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),PC.computeInterior(this,a);var s=this.mesh;return e===ht.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===ht.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,r,o),!0},n}();function no(n){var t=n.windingRule,e=t===void 0?Re.ODD:t,r=n.elementType,o=r===void 0?ht.POLYGONS:r,i=n.polySize,a=i===void 0?3:i,s=n.vertexSize,l=s===void 0?2:s,u=n.normal,c=u===void 0?[0,0,1]:u,d=n.contours,p=d===void 0?[]:d,f=n.strict,h=f===void 0?!0:f,m=n.debug,y=m===void 0?!1:m;if(!p&&h)throw new Error("Contours can't be empty");if(!!p){var g=new OC;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var b=0;b<p.length;b++)g.addContour(l||2,p[b]);return g.tesselate(e,o,a,l,c,h),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var _U=Re.ODD,AU=Re.NONZERO,PU=Re.POSITIVE,OU=Re.NEGATIVE,CU=Re.ABS_GEQ_TWO,TU=ht.POLYGONS,MU=ht.CONNECTED_POLYGONS,IU=ht.BOUNDARY_CONTOURS;var io=require("three");var xu=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*xu.eSize;this.buffer=new ArrayBuffer(r);let o=Float32Array.BYTES_PER_ELEMENT,i=0;this.positions=new Float32Array(this.buffer,i*o,3*t),i+=3*t,this.normals=new Float32Array(this.buffer,i*o,3*t),i+=3*t,this.uvs=new Float32Array(this.buffer,i*o,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*xu.eSize,o=new ArrayBuffer(r),i=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*i,3*t);a+=3*t;let l=new Float32Array(o,a*i,3*t);a+=3*t;let u=new Float32Array(o,a*i,2*t);e?(s.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),u.set(this.uvs.subarray(0,this.size*2))):(s.set(this.positions),l.set(this.normals),u.set(this.uvs)),this.buffer=o,this.positions=s,this.normals=l,this.uvs=u,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let o=this.capacity;for(;e>o;)o*=2;this.realloc(o)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},hl=xu;hl.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var M0=nr(T0()),ml={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},kp={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Fp={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},Gp=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),zn=class extends io.BufferGeometry{constructor(e,r,o=0,i=12,a=3,s=Re.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=i,this._bevelSegmentsInput=a;let u=this._shape.extractShapePointsToFlatArray([],i),c=this._shape.shapeHoles.map(P=>{let O=P.extractShapePointsToFlatArray([],i),M=[];for(let I=O.length-1;I>=1;I-=2){let N=O[I-1],B=O[I-0];M.push(N,B)}return M}),d=[],p=[];for(let P=0;P<u.length;P+=2)p.push([u[P],u[P+1]]);d.push(p);for(let P=0;P<c.length;P++){let O=c[P],M=[];for(let I=0;I<O.length;I+=2)M.push([O[I],O[I+1]]);d.push(M)}let f;e.isText?f=new io.Box2().setFromPoints(e.points.map(O=>O.position)).getSize(new io.Vector2).length()*.1:d[0].length===0?f=o:f=(0,M0.default)(d).distance,o<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(o,f,r/2),this._bevelSegments=Math.floor(a));let h;try{h=no({windingRule:s,elementType:ht.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{h=ml}let m;try{m=no({windingRule:Re.ODD,elementType:ht.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]})}catch{m=kp}if(!h)throw new Error("error generating geometry");let y=h.elementCount;if(m){h.elementCount+=m.elementCount;for(let P=0;P<m.elements.length;P++){let O=m.elements[P],M=P%2===0?h.vertexCount:0;h.elements.push(O+M)}for(let P=0;P<m.vertexIndices.length;P++){let O=m.vertexIndices[P],M=h.vertexCount;h.vertexIndices.push(O+M)}for(let P=0;P<m.vertices.length;P++){let O=m.vertices[P];h.vertices.push(O)}}let g=1/0,b=-1/0,S=1/0,w=-1/0;for(let P=0,O=h.vertexCount;P<O;P++){let M=P*2,I=h.vertices[M+0],N=h.vertices[M+1];I<g&&(g=I),I>b&&(b=I),N<S&&(S=N),N>w&&(w=N)}this._minX=g,this._minY=S,this._width=b-g,this._height=w-S,this._buffer=new hl(this._computeBufferEstimatedSize(h));let v=[],_=[];for(let P=h.elementCount-1;P>=0;P--){let O=P>=y,M=P*2,I=h.elements[M+0],N=h.elements[M+1],B=I+N,D={start:I,count:N,normals:[],continuous:[],concave:[]},G=I,L=B-1,V=I+1,z=this._shape.roundedCurves.length;do{let X=G-I,j=h.vertices[L*2+0],Y=h.vertices[L*2+1],W=h.vertices[G*2+0],k=h.vertices[G*2+1],ne=h.vertices[V*2+0],ee=h.vertices[V*2+1],K=W-j,te=k-Y,Z=Math.sqrt(K*K+te*te);K/=Z,te/=Z;let le=W-ne,ie=k-ee,ae=Math.sqrt(le*le+ie*ie);le/=ae,ie/=ae,D.normals[X*2+0]=-ie,D.normals[X*2+1]=le,D.concave[X]=K*ie-te*le>0;let pe=h.vertexIndices[G];if(Array.isArray(pe))D.continuous[X]=!1;else{let[ce,fe]=this._shape.getCurveIndexFromVertexId(pe-1,!0);if(fe>0&&fe<1)D.continuous[X]=!0;else{let xe=fe===1?ce+1:ce-1;xe=(xe+z)%z;let ze=fe===1?0:1,st=this._shape.roundedCurves[ce].getTangent(fe),Ge=this._shape.roundedCurves[xe].getTangent(ze);D.continuous[X]=st.dot(Ge)>.95}}O&&(D.normals[X*2+0]*=-1,D.normals[X*2+1]*=-1),[L,G,V]=[G,V,V+1],V>=B&&(V-=N)}while(V!==I+1);let F=[];F.push({bevelI:0,angle:0,size:0,boundary:{vertices:h.vertices.slice(I*2,B*2),vertexCount:N,vertexIndices:new Array(N).fill(!0).map((X,j)=>[j,j]),elements:[0,N],elementCount:1,mesh:null},reverseMap:[],insetPoints:h.vertices.slice(I*2,B*2)});let $=0;for(let X=1;X<=this._bevelSegments;X++){let j=X/this._bevelSegments*Math.PI/2,Y=(1-Math.cos(j))*this._bevel,W=[],k=[],ne=[],ee=[],K=0;for(let Z=0;Z<N;Z++){let le=Z*2,ie=(Z-1+N)%N*2,ae=h.vertices[D.start*2+le+0],pe=h.vertices[D.start*2+le+1],ce=-D.normals[ie+0]*Y,fe=-D.normals[ie+1]*Y,xe=-D.normals[le+0]*Y,ze=-D.normals[le+1]*Y;if(D.concave[Z]||!D.concave[Z]&&O){let st=Math.atan2(fe,ce),Ge=Math.atan2(ze,xe);Ge>st&&(Ge-=Math.PI*2);let Ke=Ge-st;if(D.continuous[Z]||O){let dr=st+Ke/2,Te=Math.cos(dr)*Y,Nt=Math.sin(dr)*Y;W[2*K+0]=ae+Te*(O?-1:1),W[2*K+1]=pe+Nt*(O?-1:1),ee[K]=Z,K++}else{let dr=Math.max(1,Math.floor(i/4*Math.abs(Ke)/Math.PI));for(let Te=0;Te<=dr;Te++){let Nt=st+Ke*(Te/dr),zt=Math.cos(Nt)*Y,Li=Math.sin(Nt)*Y;W[2*K+0]=ae+zt,W[2*K+1]=pe+Li,ee[K]=Z,K++}}}else W[2*K+0]=ae+ce,W[2*K+1]=pe+fe,ee[K]=Z,k[Z]=K,K++,W[2*K+0]=ae,W[2*K+1]=pe,ee[K]=Z,K++,W[2*K+0]=ae+xe,W[2*K+1]=pe+ze,ee[K]=Z,ne[Z]=K,K++}let te=no({windingRule:Re.POSITIVE,elementType:ht.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[W],edgeCreateCallback:Z=>{let ie=Z.Org.idx,ae=ee[ie],pe=ee[(ie+1)%ee.length];Z.idx=[ae,pe],Z.Sym.idx=[pe,ae]},vertexIdCallback:Z=>{let le=Z.Lprev.idx;return[le?le[1]:0,Z.idx?Z.idx[0]:0]}});if(!te)throw console.log("Error"),new Error(`error generating bevel geometry for ${X}'th loop`);if(!te.vertexCount){let Z=(X-1)/this._bevelSegments*Math.PI/2;$=(1-Math.sin(Z))*this._bevel;break}for(let Z=0;Z<te.vertexIndices.length;Z++){let[le,ie]=te.vertexIndices[Z];if(le===ie)continue;let ae=ie;ie<le&&(ae+=N);for(let pe=le;pe<ae;pe++){let ce=pe%N,fe=(pe+1)%N;if(!D.continuous[ce]||!D.continuous[fe]){te.vertexIndices[Z]=[le,ce],te.vertexIndices.splice(Z+1,0,[fe,ie]),te.vertices.splice((Z+1)*2,0,te.vertices[Z*2],te.vertices[Z*2+1]);break}}}F.push({bevelI:X,angle:j,size:Y,boundary:te,reverseMap:ee,insetPoints:W})}let q=(X,j,Y)=>{let W=0,k=X.boundary.vertexIndices.length;for(;W<k&&Y(X.boundary.vertexIndices[j]);)j=(j+1)%k,W++;return W},H=v.length;for(let X=1;X<F.length;X++){let j=F[X-1],Y=F[X],W=j.boundary.vertexIndices.length,k=Y.boundary.vertexIndices.length;if(!W||!k)break;let ne=D.concave.length,ee=0,K=Gp(ee,N);for(;!j.boundary.vertexIndices.filter(K).length||!Y.boundary.vertexIndices.filter(K).length;)ee++,K=Gp(ee,N);let te=j.boundary.vertexIndices.findIndex(K),Z=Y.boundary.vertexIndices.findIndex(K);do te=(te+1)%W;while(K(j.boundary.vertexIndices[te]));do Z=(Z+1)%k;while(K(Y.boundary.vertexIndices[Z]));ee=(ee+1)%N;let le=ee,ie=0,ae=this._buildBevelVert(D,j,(te-1+W)%W,void 0,ie),pe=this._buildBevelVert(D,Y,(Z-1+k)%k,void 0,ie),ce=ae,fe=pe,xe,ze,st=!1;do{ie=(ee||ne)/ne,K=Gp(ee,N);let Ge=q(j,te,K),Ke=q(Y,Z,K),dr=st;if(st=!1,Ge&&!Ke){for(let Te=0;Te<Ge;Te++)xe=this._buildBevelVert(D,j,(te+Te)%W,Te/(Ge-1),ie),v.push(ce.topN,xe.topP,fe.topN),l===!1&&v.push(xe.bottomP,ce.bottomN,fe.bottomN),ce=xe;st=!0}else if(!Ge&&Ke)for(let Te=0;Te<Ke;Te++)ze=this._buildBevelVert(D,Y,(Z+Te)%k,Te/(Ke-1),ie),v.push(fe.topN,ce.topP,ze.topP),l===!1&&v.push(ce.bottomP,fe.bottomN,ze.bottomP),fe=ze;else if(Ge&&Ke)if(xe=this._buildBevelVert(D,j,te,0,ie),ze=this._buildBevelVert(D,Y,Z,0,ie),dr?(v.push(ce.topN,ze.topP,fe.topN),v.push(ce.topN,xe.topP,ze.topP),l===!1&&(v.push(ze.bottomP,ce.bottomN,fe.bottomN),v.push(ze.bottomP,xe.bottomP,ce.bottomN))):(v.push(fe.topN,ce.topN,xe.topP),v.push(fe.topN,xe.topP,ze.topP),l===!1&&(v.push(xe.bottomP,ce.bottomN,fe.bottomN),v.push(xe.bottomP,fe.bottomN,ze.bottomP))),ce=xe,fe=ze,Ge===Ke)for(let Te=1;Te<Ge;Te++)xe=this._buildBevelVert(D,j,(te+Te)%W,Te/(Ge-1),ie),ze=this._buildBevelVert(D,Y,(Z+Te)%k,Te/(Ke-1),ie),v.push(ce.topN,xe.topP,fe.topN),v.push(fe.topN,xe.topP,ze.topP),l===!1&&(v.push(xe.bottomP,ce.bottomN,fe.bottomN),v.push(xe.bottomP,fe.bottomN,ze.bottomP)),ce=xe,fe=ze;else if(Ge>Ke){let Te=Ge/Ke,Nt=0;for(let zt=1;zt<Ge;zt++)xe=this._buildBevelVert(D,j,(te+zt)%W,zt/(Ge-1),ie),v.push(ce.topN,xe.topP,fe.topN),l===!1&&v.push(xe.bottomP,ce.bottomN,fe.bottomN),ce=xe,zt>(Nt+1)*Te&&(Nt++,ze=this._buildBevelVert(D,Y,(Z+Nt)%k,Nt/(Ke-1),ie),v.push(fe.topN,xe.topP,ze.topP),l===!1&&v.push(xe.bottomP,fe.bottomN,ze.bottomP),fe=ze)}else{let Te=Ke/Ge,Nt=0;for(let zt=1;zt<Ke;zt++)ze=this._buildBevelVert(D,Y,(Z+zt)%k,zt/(Ke-1),ie),v.push(fe.topN,xe.topP,ze.topP),l===!1&&v.push(xe.bottomP,fe.bottomN,ze.bottomP),fe=ze,zt>(Nt+1)*Te&&(Nt++,xe=this._buildBevelVert(D,j,(te+Nt)%W,Nt/(Ge-1),ie),v.push(ce.topN,xe.topP,fe.topN),l===!1&&v.push(xe.bottomP,ce.bottomN,fe.bottomN),ce=xe)}te=(te+Ge)%W,Z=(Z+Ke)%k,ee=(ee+1)%ne}while(ee!==le)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(F,D,v),O){let X=[];for(let j=v.length-1;j>=H+2;j-=3){let Y=v[j-2],W=v[j-1],k=v[j-0];X.push(k,W,Y)}v.splice(H,v.length-H,...X)}if(O){let X=[];for(let j=F[F.length-1].boundary.vertices.length-1;j>=1;j-=2){let Y=F[F.length-1].boundary.vertices[j-1],W=F[F.length-1].boundary.vertices[j-0];X.push(Y,W)}_.push(X)}if(!O){let X=F[F.length-1],j;try{j=no({windingRule:F.length>1?Re.POSITIVE:Re.ODD,elementType:ht.POLYGONS,vertexSize:2,strict:!0,contours:[X.insetPoints,..._]})}catch{j=Fp}if(!j)throw new Error("Error generating geometry for surface");c.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let Y=0;Y<j.elementCount*3;Y+=3){let W=this._buildSurfaceVert(j,j.elements[Y+0],$),k=this._buildSurfaceVert(j,j.elements[Y+1],$),ne=this._buildSurfaceVert(j,j.elements[Y+2],$);v.push(W.top,k.top,ne.top),l===!1&&v.push(ne.bottom,k.bottom,W.bottom)}}this.vertexCache={}}this._buffer.shrink();let A=new io.BufferAttribute(Uint32Array.from(v),1),x=new io.BufferAttribute(this._buffer.positions,3),T=new io.BufferAttribute(this._buffer.normals,3),C=new io.BufferAttribute(this._buffer.uvs,2);x.needsUpdate=!0,T.needsUpdate=!0,C.needsUpdate=!0,A.needsUpdate=!0,this.setAttribute("position",x),this.setAttribute("normal",T),this.setAttribute("uv",C),this.setIndex(A)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,i,a),u=this._buildBevelVert(r,i,(a+1)%s);o.push(u.topP,l.topN,l.bottomN),o.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,r,o){let i=r.toString();if(i in this.vertexCache)return this.vertexCache[i];let a=e.vertices[r*2+0],s=e.vertices[r*2+1],l=(a-this._minX)/this._width,u=(s-this._minY)/this._height;this.forPathBevel&&(u=1);let c=this._buffer.get(this.forPathBevel?1:2),d=c*3,p=c*2,f={top:c+0,bottom:c+1};return this._buffer.positions[d+0]=a,this._buffer.positions[d+1]=s,this._buffer.positions[d+2]=this.forPathBevel?this._bevel:this._depth-o,this._buffer.normals[d+0]=0,this._buffer.normals[d+1]=0,this._buffer.normals[d+2]=1,this._buffer.uvs[p+0]=l,this._buffer.uvs[p+1]=u,this.forPathBevel===!1&&(this._buffer.positions[d+3]=a,this._buffer.positions[d+4]=s,this._buffer.positions[d+5]=o,this._buffer.normals[d+3]=0,this._buffer.normals[d+4]=0,this._buffer.normals[d+5]=-1,this._buffer.uvs[p+2]=l,this._buffer.uvs[p+3]=u),this.vertexCache[i]=f,f}_buildBevelVert(e,r,o,i=1,a){let s=`${r.bevelI}:${o}`;if(s in this.vertexCache&&a!==0&&a!==1&&(!a||a===this.vertexCache[s].pathBevelUCoord))return this.vertexCache[s];let[l,u]=r.boundary.vertexIndices[o],c,d,p,f;l!==u?(d=l,c=u,f=!1,p=e.continuous[d]&&e.continuous[c]):(c=l,d=(c-1+e.count)%e.count,f=e.concave[c]&&r.bevelI>0,p=e.continuous[c]||f);let h=Math.cos(r.angle),m=Math.sin(r.angle),y=o*2,g=c*2,b=d*2,S=r.boundary.vertices[y+0],w=r.boundary.vertices[y+1],v=(1-m)*this._bevel,_=(S-this._minX)/this._width,A=(w-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(_=a),A=1);let x=e.normals[g+0],T=e.normals[g+1],C=e.normals[b+0],P=e.normals[b+1];if(f){let B=C-x,D=P-T;x=x+B*(1-i),T=T+D*(1-i);let G=Math.sqrt(x*x+T*T);x/=G,T/=G}let O=this.forPathBevel?this._buffer.get(p?1:2):this._buffer.get(p?2:4),M=O*3,I=O*2,N={i:o,fi:c,topP:O+0,topN:O+0,bottomP:O+1,bottomN:O+1,pathBevelUCoord:a};return this._buffer.positions[M+0]=S,this._buffer.positions[M+1]=w,this._buffer.positions[M+2]=(this.forPathBevel?this._bevel:this._depth)-v,this._buffer.normals[M+0]=x*h,this._buffer.normals[M+1]=T*h,this._buffer.normals[M+2]=m,this._buffer.uvs[I+0]=_,this._buffer.uvs[I+1]=A,this.forPathBevel===!1&&(this._buffer.positions[M+3]=S,this._buffer.positions[M+4]=w,this._buffer.positions[M+5]=v,this._buffer.normals[M+3]=x*h,this._buffer.normals[M+4]=T*h,this._buffer.normals[M+5]=-m,this._buffer.uvs[I+2]=A,this._buffer.uvs[I+3]=_),p||(this.forPathBevel?(O+=1,M+=3,I+=2):(O+=2,M+=6,I+=4),N.topP=O+0,N.bottomP=O+1,this._buffer.positions[M+0]=S,this._buffer.positions[M+1]=w,this._buffer.positions[M+2]=(this.forPathBevel?this._bevel:this._depth)-v,this._buffer.normals[M+0]=C*h,this._buffer.normals[M+1]=P*h,this._buffer.normals[M+2]=m,this._buffer.uvs[I+0]=_,this._buffer.uvs[I+1]=A,this.forPathBevel===!1&&(this._buffer.positions[M+3]=S,this._buffer.positions[M+4]=w,this._buffer.positions[M+5]=v,this._buffer.normals[M+3]=C*h,this._buffer.normals[M+4]=P*h,this._buffer.normals[M+5]=-m,this._buffer.uvs[I+2]=A,this._buffer.uvs[I+3]=_)),this.vertexCache[s]=N,N}clone(){let e=new zn(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=$o(this.userData),e}};var Ea=class extends mi.BufferGeometry{constructor(e,r=12,o={}){super();this.type="ShapeGeometry";this.windingRule=Re.ODD;this.elementType=ht.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:Re.ODD,elementType:ht.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let i=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(h=>h.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,u=!0,c,d;for(let h=0,m=i.length/2;h<m;h++){let y=h*2,g=i[y+0],b=i[y+1];if(c!==void 0&&g!==c&&(l=!1),d!==void 0&&b!==d&&(u=!1),c=g,d=b,!l&&!u)break}if(!l&&!u)try{s=no({contours:[i,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=ml}let p=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new mi.BufferAttribute(new Float32Array(p*3),3),this._normalAttribute=new mi.BufferAttribute(new Float32Array(p*3),3),this._uvAttribute=new mi.BufferAttribute(new Float32Array(p*2),2),this._indexAttribute=new mi.BufferAttribute(new Uint32Array(f*3),1),s){let h=1/0,m=-1/0,y=1/0,g=-1/0;for(let w=0,v=p;w<v;w++){let _=w*2,A=s.vertices[_+0],x=s.vertices[_+1];A<h&&(h=A),A>m&&(m=A),x<y&&(y=x),x>g&&(g=x)}let b=m-h,S=g-y;for(let w=0,v=p;w<v;w++){let _=w*2,A=s.vertices[_+0],x=s.vertices[_+1],T=(A-h)/b,C=(x-y)/S;this._positionAttribute.setXYZ(w,A,x,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,T,C)}for(let w=0,v=f;w<v;w++){let _=w*3,A=s.elements[_+0],x=s.elements[_+1],T=s.elements[_+2];this._indexAttribute.setX(_+0,A),this._indexAttribute.setX(_+1,x),this._indexAttribute.setX(_+2,T)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(s?.elementCount??1)*3)}clone(){let e=new Ea(this._shape,this._curveSegments);return e.userData=$o(this.userData),e}};var Ba=class extends zn{constructor(e,r,o=0,i=12,a=3,s=Re.ODD){super(e,r,o,i,a,s);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,i,a),u=this._buildBevelVert(r,i,(a+1)%s);o.push(u.topP,l.topN,l.bottomN),o.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new Ba(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=$o(this.userData),e}};var gr=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Re.ODD},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=n.shape??t?.shape,s=a?.roundness??e.roundness;a!==void 0&&(a instanceof Fe?(a.width!==r||a.height!==o)&&a.applySize(r,o):a=new Fe(r,o).fromJSON(a),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&a.update());let l=a??new Fe(r,o);return{parameters:Object.assign(e,{width:r,height:o,depth:i,roundness:s}),shape:l}}static build(n){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:o,roundness:i,windingRule:a}=n.parameters;n.shape.roundness=i;let s;return t<=0?s=new Ea(n.shape,o,{windingRule:a}):s=new Ba(n.shape,t,e,o,r,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};var ao=require("three"),N0=Math.PI*2,Ra=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return e.angle=ao.MathUtils.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof Fe?n.shape:new Fe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,angle:o,innerRadius:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,u=n.shape,c=t*.5,d=e*.5,p=NC(u,c,d,o*Math.PI/180,r,i);u.isClosed=!0,u.update();let f;return o===0?(f=new ao.BufferGeometry,f.setAttribute("position",new ao.Float32BufferAttribute([],3))):f=gr.create({shape:u,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function NC(n,t,e,r,o,i){if(r>=N0)return o>30||o%4===0?(EC(n,t,e,i),Math.round(o/4)):I0(n,r,o,t,e,i);r=Math.max(r,.001);let a={x:0,y:e},s=r+Math.PI*.5,l={x:Math.cos(s)*t,y:Math.sin(s)*e},u=S0({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return o>30||o%u.length===0?DC(n,a.x,a.y,u,o,t,e,i):I0(n,r,o,t,e,i)}function DC(n,t,e,r,o,i,a,s){let l=Math.round(o/r.length);n.addPoint(La(t,e));for(let u=0,c=r.length;u<c;u++){let d=r[u],p=n.points[u],f=La(d.x,d.y);p.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),n.addPoint(f)}return s>0?D0(n,i,a,s):n.addPoint(La(0,0)),l}function I0(n,t,e,r,o,i){let a=-t/e;for(let s=0;s<=e;s++){let l=a*s,u=Math.sin(l)*r,c=Math.cos(l)*o;n.addPoint(La(u,c))}return t<N0?i>0?D0(n,r,o,i):n.addPoint(La(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&E0(n,r,o,i)),1}function EC(n,t,e,r=0,o=0,i=0){let a=.5522847498,s=t*a,l=e*a;n.addPoint(vu(o-t,i,o-t,i-l,o-t,i+l)),n.addPoint(vu(o,i+e,o-s,i+e,o+s,i+e)),n.addPoint(vu(o+t,i,o+t,i+l,o+t,i-l)),n.addPoint(vu(o,i-e,o+s,i-e,o-s,i-e)),r>0&&E0(n,t,e,r)}function La(n,t){return new oo(ao.MathUtils.generateUUID(),new ao.Vector2(n,t))}function vu(n,t,e,r,o,i){let a=La(n,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(o,i),a}function D0(n,t,e,r){B0(n,t,e,r).forEach(i=>n.addPoint(i))}function E0(n,t,e,r){let o=B0(n,t,e,r),i=new Fe;o.forEach(a=>i.addPoint(a)),i.isClosed=!0,n.shapeHoles.push(i)}function B0(n,t,e,r){let o=r*t/100,i=o*(Math.abs(e)/Math.abs(t)),a=new ao.Vector2(o/t,i/e),s=n.points.map(l=>{let u=l.clone();return u.uuid=ao.MathUtils.generateUUID(),u}).reverse();return s.forEach(l=>{l.position.multiply(a);let u=l.controls[0].position.clone().multiply(a),c=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),s}var so=require("three"),L0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??r),i=Math.abs(e.depth??r),a=Math.abs(Math.min(r,i))/2;return{parameters:Object.assign(e,{width:r,height:o,depth:i,radius:a,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:t,height:e,depth:r,radius:o,revolutions:i,segments:a,pathRadius:s,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:d}=n.parameters,p=new yl(!1,t,e,r,o,i,a,s,l,u,c,d);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},jp=new so.Uint32BufferAttribute([0,0,0],1),yl=class extends so.BufferGeometry{constructor(t=!0,e=1,r=1,o=1,i=1,a=1,s=1,l=1,u=1,c=1,d=1,p=1){if(super(),a===0)return;let f=t&&a===1;f&&(p=0),d>100&&(d=100),d===0&&(p=0);let h=()=>new so.Vector3,m=new so.Vector3,y=h(),g=h(),b=h(),S,w,v,_,A,x,T,C,P=h(),O=h(),M=h(),I=h(),N=h(),B=h(),D=h(),G=h(),L=r-2*l+.001,V=L/a,z=Math.ceil(s*a),F=z+1,$=L/z,q=-L/2,H=c+1,X=2*Math.PI/c,j=Math.PI/2/p,Y=.01,W=Math.min((1-d/100)*l,l-Y),k=l-W,ne=0,ee=2,K=p*ee+ee,te=H*K/ee,Z=te+H*F,le=Math.max(0,H*(F+K)),[ie,ae,pe]=[3,3,2].map(At=>Array(le*At).fill(0)),ce=[],fe=i-l;function xe(At,Or){let yo=Math.PI/2;x=Or*$,C=2*Math.PI*(x%V)/V+yo,x+=q,T=Math.sin(C)*fe,A=Math.cos(C)*fe,t?At.set(A,T,x):At.set(A,x,T)}xe(m,-1e-10),xe(y,0),P.copy(m),xe(m,1);let ze=m.distanceTo(y),st=f?0:k+W,Ge=ze*z+2*st,Ke=W,dr=Ge-st;for(let At=0;At<=z;At++){xe(g,At),G.subVectors(g,P).normalize(),P.copy(g),B.copy(g).setComponent(+t+1,0).normalize(),D.crossVectors(G,B).normalize();let Or=At===0,yo=At===z,wS=Or?3*Math.PI/2:j,_S=Or?Ke:dr,AS=Or?H:Z,PS=Or?0:le-H,OS=G.clone().multiplyScalar(Or?-k:k).add(g),CS=G.clone().multiplyScalar(Or?-1:1).normalize();for(let jo=0;jo<H;jo++){let sh=jo*X;if(O.addVectors(m.copy(B).multiplyScalar(l*Math.cos(sh)),y.copy(D).multiplyScalar(l*Math.sin(sh))),M.copy(O).normalize(),Or||yo){f||(ne=PS+jo,[0,1,2].forEach(pr=>{ie[ne*3+pr]=OS.getComponent(pr),ae[ne*3+pr]=CS.getComponent(pr)}),pe[ne*2]=+yo,pe[ne*2+1]=jo/c),y.copy(M).multiplyScalar(W),b.addVectors(g,y);for(let pr=0;pr<p;pr++){let Id=pr*j+wS;I.addVectors(m.copy(G).multiplyScalar(k*Math.sin(Id)),y.copy(M).multiplyScalar(k*Math.cos(Id))),N.copy(I).normalize(),y.addVectors(b,I),I.normalize(),ne=AS+pr*H+jo,[0,1,2].forEach(Zl=>{ie[ne*3+Zl]=y.getComponent(Zl),ae[ne*3+Zl]=N.getComponent(Zl)});let TS=+Or+Math.sin(Id);pe[ne*2]=(_S+k*TS)/Ge,pe[ne*2+1]=jo/c}}y.addVectors(g,O),ne=te+At*H+jo,[0,1,2].forEach(pr=>{ie[ne*3+pr]=y.getComponent(pr),ae[ne*3+pr]=M.getComponent(pr)}),pe[ne*2]=(st+At*ze)/Ge,pe[ne*2+1]=jo/c}}let Te=F+2*p+ee,Nt=1,[zt,Li]=[+f,Te-1];for(let At=zt;At<=Li-1;At++){let Or=f&&At===Li-1;for(let yo=0;yo<H-1;yo++)S=At*H+yo,w=S+1,v=(Or?yo:S)+H,_=(Or?yo+1:w)+H,At===0?ce.push(w,_,v):At===Te-2?ce.push(S,w,v):ce.push(S,w,v,w,_,v)}this.setIndex(ce),this.setAttribute("position",new so.Float32BufferAttribute(ie,3)),this.setAttribute("normal",new so.Float32BufferAttribute(ae,3)),this.setAttribute("uv",new so.Float32BufferAttribute(pe,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,o=Array.from(this.getIndex().array),i,a,s,l,u=6*(e-1)*t.radialSegments,c=e,d=c===e;for(let p=0;p<t.radialSegments;p++)i=c*r+p,a=i+1,s=(d?p:i)+r,l=(d?p+1:a)+r,o[u++]=i,o[u++]=a,o[u++]=s,o[u++]=a,o[u++]=l,o[u++]=s;return o.length=u,jp.array=o,jp.count=o.length,jp}};var R0=require("three");var V0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new gl(t*.5,i,a):new R0.IcosahedronGeometry(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},gl=class extends Ln{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,i=[-1,o,0,1,o,0,-1,-o,0,1,-o,0,0,-1,o,0,1,o,0,-1,-o,0,1,-o,o,0,-1,o,0,1,-o,0,-1,-o,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],s="IcosahedronGeometry";super(i,a,s,t,e,r),this.type=s}static fromJSON(t){return new gl(t.radius,t.corner,t.cornerSides)}};var Su=require("three"),z0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){(n.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{points:t,segments:e,verticalSegments:r}=n.parameters,o=new Su.Shape;o.moveTo(t[0].x,t[0].y),o.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let i=new Su.LatheGeometry(o.extractPoints(r).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};var Mo=require("three");var on=require("three");var oe=require("three"),To=new oe.Matrix4,Up=new oe.Object3D,wu=new oe.Vector3,Gn=class extends oe.EventDispatcher{constructor(){super(),this.uuid=oe.MathUtils.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new oe.Matrix3().getNormalMatrix(t);for(let r=0,o=this.vertices.length;r<o;r++)this.vertices[r].applyMatrix4(t);for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r];i.normal.applyMatrix3(e).normalize();for(let a=0,s=i.vertexNormals.length;a<s;a++)i.vertexNormals[a].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return To.makeRotationX(t),this.applyMatrix4(To),this}rotateY(t){return To.makeRotationY(t),this.applyMatrix4(To),this}rotateZ(t){return To.makeRotationZ(t),this.applyMatrix4(To),this}translate(t,e,r){return To.makeTranslation(t,e,r),this.applyMatrix4(To),this}scale(t,e,r){return To.makeScale(t,e,r),this.applyMatrix4(To),this}lookAt(t){return Up.lookAt(t),Up.updateMatrix(),this.applyMatrix4(Up.matrix),this}fromBufferGeometry(t){let e=this,r=t.index!==null?t.index:void 0,o=t.attributes;if(o.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let i=o.position,a=o.normal,s=o.color,l=o.uv,u=o.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let p=0;p<i.count;p++)e.vertices.push(new oe.Vector3().fromBufferAttribute(i,p)),s!==void 0&&e.colors.push(new oe.Color().fromBufferAttribute(s,p));function c(p,f,h,m){let y=s===void 0?[]:[e.colors[p].clone(),e.colors[f].clone(),e.colors[h].clone()],g=a===void 0?[]:[new oe.Vector3().fromBufferAttribute(a,p),new oe.Vector3().fromBufferAttribute(a,f),new oe.Vector3().fromBufferAttribute(a,h)],b=new Va(p,f,h,g,y,m);e.faces.push(b),l!==void 0&&e.faceVertexUvs[0].push([new oe.Vector2().fromBufferAttribute(l,p),new oe.Vector2().fromBufferAttribute(l,f),new oe.Vector2().fromBufferAttribute(l,h)]),u!==void 0&&e.faceVertexUvs[1].push([new oe.Vector2().fromBufferAttribute(u,p),new oe.Vector2().fromBufferAttribute(u,f),new oe.Vector2().fromBufferAttribute(u,h)])}let d=t.groups;if(d.length>0)for(let p=0;p<d.length;p++){let f=d[p],h=f.start,m=f.count;for(let y=h,g=h+m;y<g;y+=3)r!==void 0?c(r.getX(y),r.getX(y+1),r.getX(y+2),f.materialIndex):c(y,y+1,y+2,f.materialIndex)}else if(r!==void 0)for(let p=0;p<r.count;p+=3)c(r.getX(p),r.getX(p+1),r.getX(p+2));else for(let p=0;p<i.count;p+=3)c(p,p+1,p+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(wu).negate(),this.translate(wu.x,wu.y,wu.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,o=new oe.Matrix4;return o.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let t=new oe.Vector3,e=new oe.Vector3;for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r],a=this.vertices[i.a],s=this.vertices[i.b],l=this.vertices[i.c];t.subVectors(l,s),e.subVectors(a,s),t.cross(e),t.normalize(),i.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let r=0,o=this.vertices.length;r<o;r++)e[r]=new oe.Vector3;if(t){let r=new oe.Vector3,o=new oe.Vector3;for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=this.vertices[s.a],u=this.vertices[s.b],c=this.vertices[s.c];r.subVectors(c,u),o.subVectors(l,u),r.cross(o),e[s.a].add(r),e[s.b].add(r),e[s.c].add(r)}}else{this.computeFaceNormals();for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r];e[i.a].add(i.normal),e[i.b].add(i.normal),e[i.c].add(i.normal)}}for(let r=0,o=this.vertices.length;r<o;r++)e[r].normalize();for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r],a=i.vertexNormals;a.length===3?(a[0].copy(e[i.a]),a[1].copy(e[i.b]),a[2].copy(e[i.c])):(a[0]=e[i.a].clone(),a[1]=e[i.b].clone(),a[2]=e[i.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let r=this.faces[t],o=r.vertexNormals;o.length===3?(o[0].copy(r.normal),o[1].copy(r.normal),o[2].copy(r.normal)):(o[0]=r.normal.clone(),o[1]=r.normal.clone(),o[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e<r;e++){let o=this.faces[e];o.__originalFaceNormal?o.__originalFaceNormal.copy(o.normal):o.__originalFaceNormal=o.normal.clone(),o.__originalVertexNormals||(o.__originalVertexNormals=[]);for(let i=0,a=o.vertexNormals.length;i<a;i++)o.__originalVertexNormals[i]?o.__originalVertexNormals[i].copy(o.vertexNormals[i]):o.__originalVertexNormals[i]=o.vertexNormals[i].clone()}let t=new Gn;t.faces=this.faces;for(let e=0,r=this.morphTargets.length;e<r;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let i=this.morphNormals[e].faceNormals,a=this.morphNormals[e].vertexNormals;for(let s=0,l=this.faces.length;s<l;s++){let u=new oe.Vector3,c={a:new oe.Vector3,b:new oe.Vector3,c:new oe.Vector3};i.push(u),a.push(c)}}let o=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=o.faceNormals[i],u=o.vertexNormals[i];l.copy(s.normal),u.a.copy(s.vertexNormals[0]),u.b.copy(s.vertexNormals[1]),u.c.copy(s.vertexNormals[2])}}for(let e=0,r=this.faces.length;e<r;e++){let o=this.faces[e];o.normal=o.__originalFaceNormal,o.vertexNormals=o.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new oe.Box3),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new oe.Sphere),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,r=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let o,i=this.vertices.length,a=this.vertices,s=t.vertices,l=this.faces,u=t.faces,c=this.colors,d=t.colors;e!==void 0&&(o=new oe.Matrix3().getNormalMatrix(e));for(let p=0,f=s.length;p<f;p++){let m=s[p].clone();e!==void 0&&m.applyMatrix4(e),a.push(m)}for(let p=0,f=d.length;p<f;p++)c.push(d[p].clone());for(let p=0,f=u.length;p<f;p++){let h=u[p],m,y,g=h.vertexNormals,b=h.vertexColors,S=new Va(h.a+i,h.b+i,h.c+i);S.normal.copy(h.normal),o!==void 0&&S.normal.applyMatrix3(o).normalize();for(let w=0,v=g.length;w<v;w++)m=g[w].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),S.vertexNormals.push(m);S.color.copy(h.color);for(let w=0,v=b.length;w<v;w++)y=b[w],S.vertexColors.push(y.clone());S.materialIndex=h.materialIndex+r,l.push(S)}for(let p=0,f=t.faceVertexUvs.length;p<f;p++){let h=t.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let m=0,y=h.length;m<y;m++){let g=h[m],b=[];for(let S=0,w=g.length;S<w;S++)b.push(g[S].clone());this.faceVertexUvs[p].push(b)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},r=[],o=[],i=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],d=Math.round(c.x*i)+"_"+Math.round(c.y*i)+"_"+Math.round(c.z*i);e[d]===void 0?(e[d]=l,r.push(this.vertices[l]),o[l]=r.length-1):o[l]=o[e[d]]}let a=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=o[c.a],c.b=o[c.b],c.c=o[c.c];let d=[c.a,c.b,c.c];for(let p=0;p<3;p++)if(d[p]===d[(p+1)%3]){a.push(l);break}}for(let l=a.length-1;l>=0;l--){let u=a[l];this.faces.splice(u,1);for(let c=0,d=this.faceVertexUvs.length;c<d;c++)this.faceVertexUvs[c].splice(u,1)}let s=this.vertices.length-r.length;return this.vertices=r,s}setFromPoints(t){this.vertices=[];for(let e=0,r=t.length;e<r;e++){let o=t[e];this.vertices.push(new oe.Vector3(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function r(l,u){return l.materialIndex-u.materialIndex}t.sort(r);let o=this.faceVertexUvs[0],i=this.faceVertexUvs[1],a,s;o&&o.length===e&&(a=[]),i&&i.length===e&&(s=[]);for(let l=0;l<e;l++){let u=t[l]._id;a&&a.push(o[u]),s&&s.push(i[u])}a&&(this.faceVertexUvs[0]=a),s&&(this.faceVertexUvs[1]=s)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let h=this.parameters;for(let m in h)h[m]!==void 0&&(t[m]=h[m]);return t}let e=[];for(let h=0;h<this.vertices.length;h++){let m=this.vertices[h];e.push(m.x,m.y,m.z)}let r=[],o=[],i={},a=[],s={},l=[],u={};for(let h=0;h<this.faces.length;h++){let m=this.faces[h],y=!0,g=!1,b=this.faceVertexUvs[0][h]!==void 0,S=m.normal.length()>0,w=m.vertexNormals.length>0,v=m.color.r!==1||m.color.g!==1||m.color.b!==1,_=m.vertexColors.length>0,A=0;if(A=c(A,0,0),A=c(A,1,y),A=c(A,2,g),A=c(A,3,b),A=c(A,4,S),A=c(A,5,w),A=c(A,6,v),A=c(A,7,_),r.push(A),r.push(m.a,m.b,m.c),r.push(m.materialIndex),b){let x=this.faceVertexUvs[0][h];r.push(f(x[0]),f(x[1]),f(x[2]))}if(S&&r.push(d(m.normal)),w){let x=m.vertexNormals;r.push(d(x[0]),d(x[1]),d(x[2]))}if(v&&r.push(p(m.color)),_){let x=m.vertexColors;r.push(p(x[0]),p(x[1]),p(x[2]))}}function c(h,m,y){return y?h|1<<m:h&~(1<<m)}function d(h){let m=h.x.toString()+h.y.toString()+h.z.toString();return i[m]!==void 0||(i[m]=o.length/3,o.push(h.x,h.y,h.z)),i[m]}function p(h){let m=h.r.toString()+h.g.toString()+h.b.toString();return s[m]!==void 0||(s[m]=a.length,a.push(h.getHex())),s[m]}function f(h){let m=h.x.toString()+h.y.toString();return u[m]!==void 0||(u[m]=l.length/2,l.push(h.x,h.y)),u[m]}return t.data={},t.data.vertices=e,t.data.normals=o,a.length>0&&(t.data.colors=a),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new Gn().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let p=0,f=e.length;p<f;p++)this.vertices.push(e[p].clone());let r=t.colors;for(let p=0,f=r.length;p<f;p++)this.colors.push(r[p].clone());let o=t.faces;for(let p=0,f=o.length;p<f;p++)this.faces.push(o[p].clone());for(let p=0,f=t.faceVertexUvs.length;p<f;p++){let h=t.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let m=0,y=h.length;m<y;m++){let g=h[m],b=[];for(let S=0,w=g.length;S<w;S++){let v=g[S];b.push(v.clone())}this.faceVertexUvs[p].push(b)}}let i=t.morphTargets;for(let p=0,f=i.length;p<f;p++){let h={};if(h.name=i[p].name,i[p].vertices!==void 0){h.vertices=[];for(let m=0,y=i[p].vertices.length;m<y;m++)h.vertices.push(i[p].vertices[m].clone())}if(i[p].normals!==void 0){h.normals=[];for(let m=0,y=i[p].normals.length;m<y;m++)h.normals.push(i[p].normals[m].clone())}this.morphTargets.push(h)}let a=t.morphNormals;for(let p=0,f=a.length;p<f;p++){let h={};if(a[p].vertexNormals!==void 0){h.vertexNormals=[];for(let m=0,y=a[p].vertexNormals.length;m<y;m++){let g=a[p].vertexNormals[m],b={};b.a=g.a.clone(),b.b=g.b.clone(),b.c=g.c.clone(),h.vertexNormals.push(b)}}if(a[p].faceNormals!==void 0){h.faceNormals=[];for(let m=0,y=a[p].faceNormals.length;m<y;m++)h.faceNormals.push(a[p].faceNormals[m].clone())}this.morphNormals.push(h)}let s=t.skinWeights;for(let p=0,f=s.length;p<f;p++)this.skinWeights.push(s[p].clone());let l=t.skinIndices;for(let p=0,f=l.length;p<f;p++)this.skinIndices.push(l[p].clone());let u=t.lineDistances;for(let p=0,f=u.length;p<f;p++)this.lineDistances.push(u[p]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new Hp().fromGeometry(this),e=new oe.BufferGeometry,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",_u.call(new oe.BufferAttribute(r,3),t.vertices)),t.normals.length>0){let o=new Float32Array(t.normals.length*3);e.setAttribute("normal",_u.call(new oe.BufferAttribute(o,3),t.normals))}if(t.colors.length>0){let o=new Float32Array(t.colors.length*3);e.setAttribute("color",G0.call(new oe.BufferAttribute(o,3),t.colors))}if(t.uvs.length>0){let o=new Float32Array(t.uvs.length*2);e.setAttribute("uv",k0.call(new oe.BufferAttribute(o,2),t.uvs))}if(t.uvs2.length>0){let o=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",k0.call(new oe.BufferAttribute(o,2),t.uvs2))}e.groups=t.groups;for(let o in t.morphTargets){let i=[],a=t.morphTargets[o];for(let s=0,l=a.length;s<l;s++){let u=a[s],c=new oe.Float32BufferAttribute(u.data.length*3,3);c.name=u.name,i.push(_u.call(c,u.data))}e.morphAttributes[o]=i}if(t.skinIndices.length>0){let o=new oe.Float32BufferAttribute(t.skinIndices.length*4,4);e.setAttribute("skinIndex",F0.call(o,t.skinIndices))}if(t.skinWeights.length>0){let o=new oe.Float32BufferAttribute(t.skinWeights.length*4,4);e.setAttribute("skinWeight",F0.call(o,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new oe.BufferGeometry,r=t.geometry;if(t.isPoints||t.isLine){let o=new oe.Float32BufferAttribute(r.vertices.length*3,3),i=new oe.Float32BufferAttribute(r.colors.length*3,3);if(e.setAttribute("position",_u.call(o,r.vertices)),e.setAttribute("color",G0.call(i,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let a=new oe.Float32BufferAttribute(r.lineDistances.length,1);e.setAttribute("lineDistance",BC.call(a,r.lineDistances))}r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone())}else t.isMesh&&(e=r.toBufferGeometry());return e}};Gn.prototype.isGeometry=!0;var Hp=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],r,o,i,a=t.faces;for(o=0;o<a.length;o++){let s=a[o];s.materialIndex!==i&&(i=s.materialIndex,r!==void 0&&(r.count=o*3-r.start,e.push(r)),r={start:o*3,materialIndex:i})}r!==void 0&&(r.count=o*3-r.start,e.push(r)),this.groups=e}fromGeometry(t){let e=t.faces,r=t.vertices,o=t.faceVertexUvs,i=o[0]&&o[0].length>0,a=o[1]&&o[1].length>0,s=t.morphTargets,l=s.length,u;if(l>0){u=[];for(let g=0;g<l;g++)u[g]={name:s[g].name,data:[]};this.morphTargets.position=u}let c=t.morphNormals,d=c.length,p;if(d>0){p=[];for(let g=0;g<d;g++)p[g]={name:c[g].name,data:[]};this.morphTargets.normal=p}let f=t.skinIndices,h=t.skinWeights,m=f.length===r.length,y=h.length===r.length;r.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<e.length;g++){let b=e[g];this.vertices.push(r[b.a],r[b.b],r[b.c]);let S=b.vertexNormals;if(S.length===3)this.normals.push(S[0],S[1],S[2]);else{let v=b.normal;this.normals.push(v,v,v)}let w=b.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[2]);else{let v=b.color;this.colors.push(v,v,v)}if(i===!0){let v=o[0][g];v!==void 0?this.uvs.push(v[0],v[1],v[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new oe.Vector2,new oe.Vector2,new oe.Vector2))}if(a===!0){let v=o[1][g];v!==void 0?this.uvs2.push(v[0],v[1],v[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new oe.Vector2,new oe.Vector2,new oe.Vector2))}for(let v=0;v<l;v++){let _=s[v].vertices;u[v].data.push(_[b.a],_[b.b],_[b.c])}for(let v=0;v<d;v++){let _=c[v].vertexNormals[g];p[v].data.push(_.a,_.b,_.c)}m&&this.skinIndices.push(f[b.a],f[b.b],f[b.c]),y&&this.skinWeights.push(h[b.a],h[b.b],h[b.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},Va=class{constructor(t,e,r,o,i,a=0){this.a=t,this.b=e,this.c=r,this.normal=o&&o.isVector3?o:new oe.Vector3,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new oe.Color,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=a}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,r=t.vertexNormals.length;e<r;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,r=t.vertexColors.length;e<r;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function BC(n){return this.array.set(n),this}function G0(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),i=new oe.Color),t[e++]=i.r,t[e++]=i.g,t[e++]=i.b}return this}function k0(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),i=new oe.Vector2),t[e++]=i.x,t[e++]=i.y}return this}function _u(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),i=new oe.Vector3),t[e++]=i.x,t[e++]=i.y,t[e++]=i.z}return this}function F0(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),i=new oe.Vector4),t[e++]=i.x,t[e++]=i.y,t[e++]=i.z,t[e++]=i.w}return this}var LC=["a","b","c"];function RC(n,t){switch(t){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function qp(n,t,e){let r=Math.min(n,t),o=Math.max(n,t),i=r+"_"+o;return e.get(i)}function Wp(n,t,e,r,o,i){let a=Math.min(n,t),s=Math.max(n,t),l=a+"_"+s,u;if(r.has(l))u=r.get(l);else{let c=e[a],d=e[s];u={a:c,b:d,newEdge:null,faces:[]},r.set(l,u)}u.faces.push(o),i[n].edges.push(u),i[t].edges.push(u)}function VC(n,t,e,r){let o,i,a;for(o=0,i=n.length;o<i;o++)e[o]={edges:[]};for(o=0,i=t.length;o<i;o++)a=t[o],Wp(a.a,a.b,n,r,a,e),Wp(a.b,a.c,n,r,a,e),Wp(a.c,a.a,n,r,a,e)}function Au(n,t,e,r,o){n.push(new Va(t,e,r,void 0,void 0,o))}function za(n,t){return Math.abs(t-n)/2+Math.min(n,t)}function Pu(n,t,e,r){n.push([t.clone(),e.clone(),r.clone()])}var Ou=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof on.BufferGeometry?t=new Gn().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new on.Vector3,r,o,i,a,s,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],d=c!==void 0&&c.length>0,p=[],f=new Map;VC(l,u,p,f);let h=[],m,y,g,b,S,w,v;for(let Y of Array.from(f.keys())){for(y=f.get(Y),g=new on.Vector3,S=3/8,w=1/8,v=y.faces.length,v!=2&&(S=.5,w=0,v!=1),g.addVectors(y.a,y.b).multiplyScalar(S),e.set(0,0,0),a=0;a<v;a++){for(b=y.faces[a],s=0;s<3&&(m=l[RC(b,LC[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(w),g.add(e),y.newEdge=h.length,h.push(g)}let _,A,x,T,C,P,O,M=[];for(o=0,i=l.length;o<i;o++){for(P=l[o],C=p[o].edges,r=C.length,r==3?_=3/16:r>3&&(_=3/(8*r)),A=1-r*Number(_),x=_,r<=2&&(r==2?(A=3/4,x=1/8):r==1||r==0),O=P.clone().multiplyScalar(A),e.set(0,0,0),a=0;a<r;a++)T=C[a],m=T.a!==P?T.a:T.b,e.add(m);e.multiplyScalar(Number(x)),O.add(e),M.push(O)}let I=M.concat(h),N=M.length,B,D,G,L=[],V=[],z,F,$,q,H=new on.Vector2,X=new on.Vector2,j=new on.Vector2;for(o=0,i=u.length;o<i;o++)b=u[o],B=Number(qp(b.a,b.b,f).newEdge)+N,D=Number(qp(b.b,b.c,f).newEdge)+N,G=Number(qp(b.c,b.a,f).newEdge)+N,Au(L,B,D,G,b.materialIndex),Au(L,b.a,B,G,b.materialIndex),Au(L,b.b,D,B,b.materialIndex),Au(L,b.c,G,D,b.materialIndex),d&&(z=c[o],F=z[0],$=z[1],q=z[2],H.set(za(F.x,$.x),za(F.y,$.y)),X.set(za($.x,q.x),za($.y,q.y)),j.set(za(F.x,q.x),za(F.y,q.y)),Pu(V,H,X,j),Pu(V,F,H,j),Pu(V,$,X,H),Pu(V,q,j,X));t.vertices=I,t.faces=L,d&&(t.faceVertexUvs[0]=V)}};var Et=new Mo.Vector3,j0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.geometry??t?.geometry??new Mo.BufferGeometry().copy(new Mo.BoxGeometry(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Et),r={width:Et.x,height:Et.y,depth:Et.z,subdivisions:0}):r=t.parameters;let o={...r,...n.parameters};return{parameters:{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth),subdivisions:Math.abs(o.subdivisions)},geometry:e}}static build(n){let{width:t,height:e,depth:r,subdivisions:o}=n.parameters,i=n.geometry??new Mo.BufferGeometry().copy(new Mo.BoxGeometry(100,100,100)),a=i.userData.parameters;a===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(Et)):Et.set(a.width,a.height,a.depth),(t!==Et.x||e!==Et.y||r!==Et.z)&&i.scale(Et.x===0?1:t/Et.x,Et.y===0?1:e/Et.y,Et.z===0?1:r/Et.z);let s=i.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=i),i=new Ou(o).modify(s).toBufferGeometry()):(s!==void 0&&(i=s),s=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals())}catch{s!==void 0&&(i=s),s=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals()}return s!==void 0&&Object.assign(i,{originalGeometry:s}),delete n.geometry,Object.assign(i,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,t,e){new Mo.BufferGeometryLoader(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(Et);let a=100/Et.x;Object.assign(i.parameters,{width:100,height:Et.y*a,depth:Et.z*a}),t(this.build(i))})}};var Cu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof Fe?n.shape:new Fe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,cornerRadius:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}=n.parameters,l=n.shape,u=t*.5,c=e*.5,d=0,p=0,f=2*Math.PI/r;for(let m=0;m<r;m++){let y=f*m,g=d+Math.sin(y)*u,b=p+Math.cos(y)*c;l.addPoint(l.createPoint(g,b))}l.isClosed=!0;for(let m=0,y=l.points.length;m<y;m++)l.points[m].roundness=o;l.roundness=o,l.update();let h=gr.create({shape:l,parameters:{roundness:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(h,{userData:{...n,type:"PolygonGeometry"}})}};var Le=require("three"),U0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,radialSegments:o,heightSegments:i,openEnded:a,cornerRadius:s,cornerSegments:l}=n.parameters,u=new Yp(t*.5,e,o,i,a,s,l);return u.scale(1,1,r/t),Object.assign(u,{userData:{...n,type:"PyramidGeometry"}})}};function xl(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function $p(n,t,e,r,o,i){let a=t.clone().sub(n),s=e.clone().sub(n),l=a.angleTo(s);if(a.normalize(),s.normalize(),r===o){let u=a.add(s).normalize();i.copy(n).addScaledVector(u,r/Math.sin(l/2))}else{let u=a.angleTo(s);i.copy(n),i.addScaledVector(a,o/Math.sin(u)),i.addScaledVector(s,r/Math.sin(u))}}function zC(n,t,e){let r=n.clone().sub(t),o=e.clone().sub(t);return r.projectOnVector(o),r.add(t)}var Yp=class extends Le.BufferGeometry{constructor(t=.5,e=1,r=4,o=1,i=!1,a=0,s=4){super(),r=Math.floor(Math.max(3,r)),o=Math.floor(o),s=Math.floor(s);let l=[],u=[],c=[],d=[],p=0,f=e/2,h=Math.PI/r,m=t*Math.cos(Math.PI/r),y=2*Math.PI/r,g=(r-2)*Math.PI/r,b=Math.PI-g,S=new Le.Vector3(0,-f,0),w=new Le.Vector3(0,f,0),v=new Le.Vector2(t,-f),_=new Le.Vector2(m,-f),A=new Le.Vector2(0,w.y).sub(_),x=new Le.Vector2(0,w.y).sub(v),T=new Le.Vector2(A.y,-A.x).normalize(),C=new Le.Vector2(x.y,-x.x).normalize(),O=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-A.angle())/2)-1e-8;a=Math.min(a,O);let M;{let V=new Le.Vector3(T.x,T.y,0),z=new Le.Vector3(Math.cos(y)*V.x,V.y,Math.sin(y)*V.x);M=V.angleTo(z)}let I=a/Math.tan((Math.PI-A.angle())/2),N=a/Math.tan((Math.PI-M)/2),B=new Le.Vector3;if(!i){u.push(S.x,S.y,S.z),c.push(0,-1,0),d.push(0,0);let V=p++,z=[],F=v.clone(),$=I/Math.cos(Math.PI/r);F.x-=$;for(let q=0;q<r;q++){let H=q/r*Math.PI*2+h,X=new Le.Vector2(Math.sin(H),Math.cos(H));xl(F,X,B),u.push(B.x,B.y,B.z),c.push(0,-1,0),d.push(0,0),z.push(p++)}for(let q=0;q<z.length;q++)l.push(z[q],V,z[(q+1)%z.length])}let D=[];{let V=new Le.Vector3,z=new Le.Vector3,F=new Le.Vector3,$=new Le.Vector3,q=new Le.Vector3,H=new Le.Vector3;for(let X=0;X<r;X++){let j=X/r*Math.PI*2+h,Y=(X+.5)/r*Math.PI*2+h,W=(X+1)/r*Math.PI*2+h,k=new Le.Vector2(Math.sin(j),Math.cos(j)),ne=new Le.Vector2(Math.sin(Y),Math.cos(Y)),ee=new Le.Vector2(Math.sin(W),Math.cos(W));xl(v,k,z),xl(v,ee,F),xl(T,ne,V),$p(w,z,F,N,N,$),u.push($.x,$.y,$.z),$p(z,w,F,N,I,q),u.push(q.x,q.y,q.z),$p(F,z,w,I,N,H),u.push(H.x,H.y,H.z),c.push(V.x,V.y,V.z),c.push(V.x,V.y,V.z),c.push(V.x,V.y,V.z),d.push(0,0),d.push(0,0),d.push(0,0);let K=p++,te=p++,Z=p++;if(l.push(K,te,Z),a>0){{let ae=z.clone().add(F).multiplyScalar(.5),pe=w.clone().sub(ae).normalize(),fe=S.clone().sub(ae).normalize().add(pe).normalize().multiplyScalar(-1),xe=H.clone().sub(q);G(ae,xe,fe,A.angle())}let le,ie;{let ae=new Le.Vector3;xl(C,ee,ae);let pe=H.clone().add($).multiplyScalar(.5);pe=zC(pe,F,w);let ce=H.clone().sub($);[le,ie]=G(pe,ce,ae,M,$.y)}{let ae=le,pe=ae.clone().setY(0).normalize(),ce=new Le.Vector3(0,-1,0),fe=pe.clone().cross(ce);L(ae,pe,ce,fe)}D.concat(ie);{let ae=A.angle(),pe=Math.PI-ae,ce=w.clone();ce.y-=a/Math.sin(ae-Math.PI/2);let fe=new Le.Vector3,xe=[];for(let st=0;st<s;st++){let Ge=[],Ke=Math.PI/2-pe*st/s,dr=Math.cos(Ke),Te=Math.sin(Ke),Nt=Y;for(let zt=0;zt<=st;zt++){let Li=Math.cos(Nt),At=Math.sin(Nt);V.x=dr*At,V.y=Te,V.z=dr*Li,fe.copy(ce).addScaledVector(V,a),u.push(fe.x,fe.y,fe.z),c.push(V.x,V.y,V.z),d.push(0,0),Ge.push(p++),Nt+=Math.PI*2/st/r}xe.push(Ge)}ie.reverse(),xe.push(ie);let ze=xe.length-1;for(let st=0;st<ze;st++){let Ge=xe[st],Ke=xe[st+1],dr=Ge.length-1;l.push(Ke[1],Ge[0],Ke[0]);for(let Te=1;Te<=dr;Te++)l.push(Ge[Te],Ge[Te-1],Ke[Te]),l.push(Ke[Te+1],Ge[Te],Ke[Te])}}}}}this.setIndex(l),this.setAttribute("position",new Le.Float32BufferAttribute(u,3)),this.setAttribute("normal",new Le.Float32BufferAttribute(c,3)),this.setAttribute("uv",new Le.Float32BufferAttribute(d,2));function G(V,z,F,$,q){let H=-$/2,X=(Math.PI-$)/2,j=z.clone().normalize().cross(F);V.addScaledVector(F,-a/Math.sin(X));let Y=new Le.Vector3,W=new Le.Vector3,k=1,ne=p,ee=[];for(let K=0;K<=s;K++){let te=H+K/s*$;W.set(0,0,0),W.addScaledVector(j,Math.sin(te)),W.addScaledVector(F,Math.cos(te));for(let Z=0;Z<=k;Z++){let le=Z/k-.5;if(Y.copy(V),Y.addScaledVector(z,le),Y.addScaledVector(W,a),q!=null){let ie=Math.max(0,Y.y-q);Y.addScaledVector(z,-ie/z.y)}u.push(Y.x,Y.y,Y.z),c.push(W.x,W.y,W.z),d.push(0,0),Z===0&&ee.push(p),p++}}for(let K=0;K<s;K++)for(let te=0;te<k;te++){let Z=ne+te+(k+1)*K,le=Z+(k+1),ie=le+1,ae=Z+1;l.push(Z,le,ae),l.push(le,ie,ae)}return[V.clone().addScaledVector(z,.5),ee]}function L(V,z,F,$){let q=Math.PI/2,H=x.angle()-q,X=[],j=new Le.Vector3,Y=new Le.Vector3;for(let k=0;k<=s;k++){let ne=[],ee=k/s;for(let K=0;K<=k;K++){let Z=((k?K/k:0)-.5)*b,le=Math.cos(Z),ie=Math.sin(Z),ae=Math.atan(Math.tan(H)*le),pe=(q+ae)*ee,ce=Math.cos(pe),fe=Math.sin(pe);j.set(0,0,0),j.addScaledVector(z,fe*le),j.addScaledVector(F,ce),j.addScaledVector($,fe*ie),Y.copy(V).addScaledVector(j,a),u.push(Y.x,Y.y,Y.z),c.push(j.x,j.y,j.z),d.push(0,0),ne.push(p++)}X.push(ne)}let W=X.length-1;for(let k=0;k<W;k++){let ne=X[k],ee=X[k+1],K=ne.length-1;l.push(ne[0],ee[1],ee[0]);for(let te=1;te<=K;te++)l.push(ne[te-1],ne[te],ee[te]),l.push(ne[te],ee[te+1],ee[te])}}}};var Ga=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof Fe?n.shape:new Fe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(n){let t=n.shape,{width:e,height:r,cornerRadius:o,cornerType:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,u={x:e*.5,y:r*.5},c={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function p(w,v,_){return v>e&&_>r?Math.min(w*e/v,w*r/_):v>e?w*e/v:_>r?w*r/_:w}let f=[];f[0]=o[0]===0?0:p(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:p(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:p(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:p(o[3],o[3]+o[0],o[3]+o[2]);let h=c.x,m=d.x,y=d.y,g=c.y;t.addPoint(t.createPoint(h,y)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(h,g)),t.isClosed=!0;let b=!0;for(let w=0,v=t.points.length;w<v;w++)t.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(b=!1);b&&(t.roundness=f[0]),t.useCubicForRoundedCorners=i!==1,t.update();let S=gr.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(S,{userData:{...n,type:"RectangleGeometry"}})}};var nn=require("three"),H0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},n.parameters);return e.thetaLength=nn.MathUtils.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t=100,height:e=t,depth:r=t,widthSegments:o=64,heightSegments:i=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:u}=n.parameters,c;return u===0?(c=new nn.BufferGeometry,c.setAttribute("position",new nn.Float32BufferAttribute([],3))):c=new nn.SphereGeometry(.5*t,o,i,a,s,l,u*nn.MathUtils.DEG2RAD),c.scale(1,e/t,r/t),Object.assign(c,{userData:{...n,type:"SphereGeometry"}})}};var q0=require("three"),W0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(n){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:o=8}=n.parameters,i=new q0.PlaneGeometry(t,e,r,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};var kn=require("three"),$0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,angle:o,cornerRadius:i,cornerSegments:a}=n.parameters,s=new Xp(t,e,r,o,i,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},Xp=class extends kn.BufferGeometry{constructor(t=1,e=1,r=1,o=90,i=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],u=[],c=.001;i==0&&(a=1),a=Math.max(1,Math.floor(a)),i=Math.min(i,100),o=Math.min(180-c,o),o*=Math.PI/180;let d=[],p=Math.PI/2,f=(Y=0,W=0,k=0)=>new kn.Vector3(Y,W,k),h=f(),m=f(),[y,g,b]=[e/2,t/2,r/2],S=-g,w=+g,[v,_,A]=[f(S,-y,+b),f(S,-y,-b),f(S,+y,-b)],x=(Y,W=!1)=>Math.sin(Y-Math.PI/(1+ +W)),T=(Y,W=!1)=>Math.cos(Y-Math.PI/(1+ +W));A.y=Math.sin(o)*e-y;let C=Math.cos(o)*e-b,P=v.z-c;o<=p?(A.z=Math.min(C,P),A.z==P&&(A.y-=(C-P)/Math.tan(p-o))):_.z=Math.min(_.z-C-b,v.z-c),h.subVectors(v,_),m.subVectors(A,_);let O=Math.min(h.length(),m.length())*i/100,M=O*Math.tan(o/2),I=O/Math.cos(o/2),N=h.clone().normalize().add(m.normalize()).setLength(I).add(_);h.set(0,x(o,!0),T(o,!0)),d.push([A,h.clone()]);let B=(Math.PI-o)/a;for(let Y=0;Y<=a;Y++){let W=p+o+Y*B;h.set(0,Math.sin(W)*M,Math.cos(W)*M),h.add(N),m.set(0,x(W),T(W)),d.push([h.clone(),m.clone()])}d.push([v,f(0,1,0)]);let D=Math.sin(B/2)*M*2,G=d.length-1,L=d[0][0].distanceTo(d[1][0]),V=d[G-1][0].distanceTo(d[G][0]),z=L+D*a+V;d[0].push(1);for(let Y=0;Y<=a;Y++)d[Y+1].push(1-(L+Y*D)/z);d[G].push(0);let[F,$,q]=d[0],H,X,j;for(let Y=1;Y<d.length;Y++)[H,X,j]=d[Y],s.push(S,F.y,F.z,S,H.y,H.z,w,F.y,F.z,w,F.y,F.z,S,H.y,H.z,w,H.y,H.z),l.push(0,$.y,$.z,0,X.y,X.z,0,$.y,$.z,0,$.y,$.z,0,X.y,X.z,0,X.y,X.z),u.push(0,q,0,j,1,q,1,q,0,j,1,j),[F,$,q]=[H,X,j];this.setAttribute("position",new kn.Float32BufferAttribute(s,3)),this.setAttribute("normal",new kn.Float32BufferAttribute(l,3)),this.setAttribute("uv",new kn.Float32BufferAttribute(u,2))}};var Tu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Fe?n.shape:new Fe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,innerRadiusPercent:r,spikes:o,cornerRadius:i,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:u}=n.parameters,c=n.shape,d=t*.5,p=e*.5,f=0,h=0,m=a*Math.PI/360/o,y=Math.PI/2*3*-1,g=d*r/100,b=p*r/100;if(o===3&&r===50){m=2*Math.PI/o;for(let w=0;w<o;w++){let v=m*w,_=f+Math.sin(v)*d,A=h+Math.cos(v)*p;c.addPoint(c.createPoint(_,A))}}else for(let w=0;w<o;w++){let v=f+Math.cos(y)*d,_=h+Math.sin(y)*p;c.addPoint(c.createPoint(v,_)),y+=m,v=f+Math.cos(y)*g,_=h+Math.sin(y)*b,w<=o,c.addPoint(c.createPoint(v,_)),y+=m}c.isClosed=!0;for(let w=0,v=c.points.length;w<v;w++)c.points[w].roundness=i;c.roundness=i,c.update();let S=gr.create({shape:c,parameters:{roundness:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(S,{userData:{...n,type:"StarGeometry"}})}};var Y0=require("three"),X0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e}=n.parameters,r=new Y0.PlaneGeometry(t,e);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};var ka=require("three");var Q0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:o,depth:i})}}static build(n){let{width:t,height:e,depth:r,radialSegments:o,tubularSegments:i,arc:a,cornerRadius:s,cornerSegments:l}=n.parameters,u=GC(t,e,r,t*.5,a,i,0,0,o,s,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...n,type:"TorusGeometry"}})}};function GC(n,t,e,r,o,i,a,s,l,u,c){[t,e]=[e,t],a=t/2;let d=ka.MathUtils.clamp(o/360,0,1);if(d===0){let p=new ka.BufferGeometry;return p.setAttribute("position",new ka.Float32BufferAttribute([],3)),p}return d===1&&(u=0),new yl(!0,n,t,e,r,d,i,a,s,l,u,c)}var K0=require("three"),Z0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(n){let{width:t,tube:e,tubularSegments:r,radialSegments:o,p:i,q:a}=n.parameters,s=t*.5;s!==e&&(s-=e);let l=new K0.TorusKnotGeometry(s,e,r,o,i,a);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var J0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof Fe?n.shape:new Fe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t=100,height:e,cornerRadius:r,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a,isRect:s}=n.parameters,l=n.shape,u=t*.5,c=e*.5;s?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let p=0,f=l.points.length;p<f;p++)l.points[p].roundness=r;l.roundness=r,l.update();let d=gr.create({shape:l,parameters:{roundness:r,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a}});return Object.assign(d,{userData:{...n,type:"TriangleGeometry"}})}};var Se=require("three");function ex(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var kC=new Se.Matrix4,FC=new Se.Matrix4;function jC(n,t,e){let r=[new Se.Vector3,new Se.Vector3,new Se.Vector3],o=[new Se.Vector3,new Se.Vector3,new Se.Vector3];return n.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((i,a)=>{let s=o[a],l=Se.MathUtils.lerp(i.length(),s.length(),e);i.lerp(s,e).setLength(l)}),new Se.Matrix4().makeBasis(r[0],r[1],r[2])}var tx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=t?.shapeData??Ra.create({parameters:np}).userData.shape;return{path:n.path??ma.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:i,extrusion:{...Xc,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new Qp(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new Se.BufferGeometry,{userData:{...n,type:"PathGeometry"}})}},Qp=class extends Se.BufferGeometry{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!ex(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:o,offset:i}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),i=Math.max(0,Math.min(i,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(i*a),l=this.inputs.path.isClosed?Math.ceil((o+i)*a):Math.ceil(Math.min(1,o+i)*a),u=Math.min(Math.max(2,l-s+1),a+2),c=[],d=[];for(let L=0;L<u;L++){let V=this.inputs.path.isClosed?(L+s)%e.length:Math.min(L+s,e.length-1);c.push(e[V].clone()),d.push(r[V].clone())}let p=(L,V,z)=>{c[L]=c[L].clone().lerp(c[V],z),d[L]=jC(d[L],d[V],z)},f=0,h=i*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||i===0)&&(f=h,p(0,1,f));let m=0,y=(i+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&i+o<1)&&y&&(m=y,p(c.length-1,c.length-2,1-m)),o===0){let L=c.length-1;c[L].copy(c[0]),d[L].copy(d[0])}this._applyPathModifiers(d,f,m);let{bevel:g,bevelSides:b}=this.inputs.parameters.extrusion,S=g>0?this.inputs.parameters.extrusion.capType:"flat",w=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(w=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:v,infos:_,vertices:A}=this._computeShapePoints(w),x=0,T;S==="round"&&(T=new zn(this.inputs.shapeData,2*g,g,w,b,void 0,!0),x=T.getAttribute("position").count);let C=0,P=0;_.sort((L,V)=>L.start-V.start),_.forEach(L=>{L.verticesStart=C,L.verticesCount=L.continuous.reduce((V,z,F)=>V+(F===0||!z?2:1),0),P+=L.verticesCount,C=P});let O=P*u,M,I=0;if(this._isOpenEnded()&&S==="flat"){try{M=no({windingRule:Re.ODD,elementType:ht.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:v})}catch{M=Fp}I=M.vertexCount}let N=O+2*I+x*2,B=O+2*I,D={positions:new Float32Array(N*3),normals:new Float32Array(N*3),uvs:new Float32Array(N*2)},G=[];if(_.forEach(L=>{this._extrudeRegion(L,A,d,c,D,G,this._isGeometryClosed()&&!this._isOpenEnded())}),M&&(this._closeEnd(M,O,G,D,d[0],c[0],!1),this._closeEnd(M,O+I,G,D,d[d.length-1],c[c.length-1],!0)),T){D.positions.set(T.getAttribute("position").array,B*3),D.normals.set(T.getAttribute("normal").array,B*3),D.uvs.set(T.getAttribute("uv").array,B*2);let L=G.length;G.push(...T.getIndex().array.map(F=>F+B)),B+=x,D.positions.set(T.getAttribute("position").array,B*3),D.normals.set(T.getAttribute("normal").array,B*3),D.uvs.set(T.getAttribute("uv").array,B*2);let V=G.length;G.push(...T.getIndex().array.map(F=>F+B)),this.setAttribute("position",new Se.BufferAttribute(D.positions,3)),this.setAttribute("normal",new Se.BufferAttribute(D.normals,3)),this.setAttribute("uv",new Se.BufferAttribute(D.uvs,2)),this.setIndex(G);let z=kC;z.copy(d[d.length-1]).setPosition(c[c.length-1]),this.applyMatrix4OnRange(z,B,N),z.copy(d[0]).setPosition(c[0]).multiply(FC.makeScale(1,1,-1)),this.applyMatrix4OnRange(z,B-x,B),this.reverseIndicesOnRange(L,V)}else this.setAttribute("position",new Se.BufferAttribute(D.positions,3)),this.setAttribute("normal",new Se.BufferAttribute(D.normals,3)),this.setAttribute("uv",new Se.BufferAttribute(D.uvs,2)),this.setIndex(G)}_extractPathPoints(){let r=mu(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let o=[r[0]];return r.forEach(a=>{o[o.length-1].distanceToSquared(a)>.001&&o.push(a)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],o=e.length,i=this.inputs.path.isClosed,a=new Se.Vector3,s=new Se.Vector3,l=new Se.Vector3,u=new Se.Vector3,c=new Se.Vector3(0,1,0);for(let y=0;y<o;y++){let g=e[y],b;y===0?b=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):b=e[y-1];let S;y===o-1?S=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):S=e[y+1];let w=g.clone().sub(b).normalize(),v=S.clone().sub(g).normalize(),_=w.clone().add(v).normalize();l.copy(_),y===0&&(_.equals(c)||_.clone().negate().equals(c))&&c.set(0,0,1);let A=c.clone().cross(_).normalize(),x=_.clone().cross(A).normalize();c.copy(x),u.copy(A),y===0&&(a.copy(x),s.copy(_));let T=new Se.Matrix4().makeBasis(A,x,_);r.push(T)}let d=i?s:l,p=i?a:new Se.Vector3(0,1,0),f=d.clone().cross(u).normalize(),h=Math.acos(p.dot(f));if(isNaN(h))return r;let m=p.clone().cross(f);d.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let g=new Se.Matrix4().makeRotationZ(h*y/r.length);r[y].multiply(g)}return r}_applyPathModifiers(e,r,o){let i=e.length,{angle:a,twist:s,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new Se.Matrix4,d=new Se.Matrix4;return e.forEach((p,f)=>{let h=f===0?0:f===i-1?1:(f-r)/(i-(o===0?0:1)-(r+(1-o)));c.makeRotationZ(Se.MathUtils.lerp(a,a+s,h)*Se.MathUtils.DEG2RAD);let m=Se.MathUtils.lerp(l,u,h);d.makeScale(m,m,m),p.multiply(c).multiply(d)}),e}_computeShapePoints(e=12,r=Re.ODD){let o=this.inputs.shapeData,i=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let b=y.length-1;b>=1;b-=2){let S=y[b-1],w=y[b-0];g.push(S,w)}return g}),s;try{s=no({windingRule:r,elementType:ht.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{s=ml}let l;try{l=no({windingRule:Re.ODD,elementType:ht.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=kp}if(!s)throw new Error("error generating geometry");let u=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let c=1/0,d=-1/0,p=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,b=s.vertices[g+0],S=s.vertices[g+1];b<c&&(c=b),b>d&&(d=b),S<p&&(p=S),S>f&&(f=S)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=u,g=m*2,b=s.elements[g+0],S=s.elements[g+1],w=b+S,v={start:b,count:S,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(v);let _=b,A=w-1,x=b+1,T=o.roundedCurves.length;do{let C=_-b,P=s.vertices[A*2+0],O=s.vertices[A*2+1],M=s.vertices[_*2+0],I=s.vertices[_*2+1],N=s.vertices[x*2+0],B=s.vertices[x*2+1],D=M-P,G=I-O,L=Math.sqrt(D*D+G*G);D/=L,G/=L;let V=M-N,z=I-B,F=Math.sqrt(V*V+z*z);V/=F,z/=F,v.normals[C*2+0]=-z,v.normals[C*2+1]=V;let $=s.vertexIndices[_];if(Array.isArray($))v.continuous[C]=!1;else{let[q,H]=o.getCurveIndexFromVertexId($-1,!0);if(H>0&&H<1)v.continuous[C]=!0;else{let X=H===1?q+1:q-1;X=(X+T)%T;let j=H===1?0:1,Y=o.roundedCurves[q].getTangent(H),W=o.roundedCurves[X].getTangent(j);v.continuous[C]=Y.dot(W)>.95}}y&&(v.normals[C*2+0]*=-1,v.normals[C*2+1]*=-1),[A,_,x]=[_,x,x+1],x>=w&&(x-=S)}while(x!==b+1)}return{regions:[i,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,i,a){let s=r*2,l=r*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=i.x,e.normals[l+1]=i.y,e.normals[l+2]=i.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,o,i,a,s,l){let u=new Se.Vector3,c=new Se.Vector3,d=new Se.Vector3,p=new Se.Vector3,f=new Se.Vector2;o.forEach((m,y)=>{let g=i[y],b=e.verticesStart*o.length+e.verticesCount*y;for(let S=0;S<e.count;S++){let w=(e.start+S)*2;if(u.set(r[w+0],r[w+1],0),d.copy(u).applyMatrix4(m).add(g),e.continuous[S])p.set(e.normals[S*2+0],e.normals[S*2+1],0);else{let v=S===0?(e.start+e.count-1)*2:w-2;c.set(r[v+0],r[v+1],0),p.copy(u).sub(c),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(m).normalize(),f.set(S===0?1:S/e.count,y/(o.length-1)),this._insertVertex(a,b,d,p,f),b++,!e.continuous[S]||S===0){if(S===0)p.set(e.normals[S*2+0],e.normals[S*2+1],0),f.set(0,y/(o.length-1));else{let v=S===e.count-1?e.start*2:w+2;c.set(r[v+0],r[v+1],0),p.copy(c).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(m).normalize(),this._insertVertex(a,b,d,p,f),b++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,g=e.verticesStart*o.length+e.verticesCount*(m+1),b=0;for(let S=0;S<e.count;S++){(!e.continuous[S]||S===0)&&b++;let w=S===e.count-1?0:b+1,v=y+b,_=y+w,A=g+w,x=g+b;e.isHole?s.push(v,A,_,v,x,A):s.push(v,_,A,v,A,x),b++}}}_closeEnd(e,r,o,i,a,s,l){let u=e.vertexCount,c=new Se.Vector3(0,0,l?-1:1).applyMatrix4(a),d=new Se.Vector3,p=new Se.Vector2;for(let h=0;h<u;h++){let m=2*h;d.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(i,r+h,d,c,p)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+r,g=f[m+(l?1:2)]+r,b=f[m+(l?2:1)]+r;o.push(y,g,b)}}applyMatrix4OnRange(e,r,o){let i=e.elements,a=new Se.Matrix3().getNormalMatrix(e).elements,s,l,u,c,d=this.attributes.position,p=this.attributes.normal;if(!d||!p)return;let f=d.array,h=p.array,m=d.itemSize;for(let y=r*m,g=o*m;y<g;y+=m){if(y===r)debugger;s=f[y+0],l=f[y+1],u=f[y+2],c=1/(i[3]*s+i[7]*l+i[11]*u+i[15]),f[y+0]=(i[0]*s+i[4]*l+i[8]*u+i[12])*c,f[y+1]=(i[1]*s+i[5]*l+i[9]*u+i[13])*c,f[y+2]=(i[2]*s+i[6]*l+i[10]*u+i[14])*c,s=h[y+0],l=h[y+1],u=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*u,h[y+1]=a[1]*s+a[4]*l+a[7]*u,h[y+2]=a[2]*s+a[5]*l+a[8]*u}d.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,r){let o=this.index;if(o){for(let i=e;i<r;i+=3){let a=o.getX(i),s=o.getX(i+1),l=o.getX(i+2);o.setXYZ(i,l,s,a)}o.needsUpdate=!0}}};var yi=require("three"),rx=require("three/examples/jsm/utils/BufferGeometryUtils.js");function ox(){let n=new yi.BufferGeometry;return n.setAttribute("position",new yi.BufferAttribute(new Float32Array([]),3)),n.setIndex(new yi.BufferAttribute(new Uint16Array([]),1)),n}var HC=ox().attributes,qC=12,WC=1,Fa=class extends yi.BufferGeometry{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,HC),this.userData={parameters:e,type:"TextGeometry"};let o=r.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e)):this.updateFont(e.font,r).then(()=>{this.update(e),r?.requestRender()})}async updateFont(e,r){let o=r.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e){let r=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!r?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l,text:u,textTransform:c}=e,d=nu.getDisplayedValue(u),p=c===2?d.toUpperCase():c===3?d.toLowerCase():d,f=$C(e,r,p),{shapes:h,charWidths:m,charCoords:y}=r.generateShapes(f,e),g=(typeof o=="number"?o:1)*.5,b=(typeof i=="number"?i:1)*.5,S=h.map(_=>new Fe().fromShape(_,!0));this.vectorShapes=S;let w=S.map(_=>gr.create({shape:_,parameters:{depth:a,extrudeBevelSegments:l,extrudeBevelSize:s,windingRule:a<=0?Re.NONZERO:Re.ODD,subdivisions:this.isLowResolution&&a>0?WC:qC}})),v=w.length?(0,rx.mergeBufferGeometries)(w):ox();v.translate(-g,b,0),this.dispose(),this.wrappedText=f,this.charCoords=y,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(v.attributes).forEach(([_,A])=>{this.setAttribute(_,A)}),this.setIndex(v.index),this.computeBoundingSphere()}clone(){let e=ir(new yi.BufferGeometry,Fa.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,o])=>{this.setAttribute(r,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function $C(n,t,e){let r=[""],o="";for(let i of e)o+=i,i===" "||i===`
16
+ `));return d(GI.bind(void 0,n))}DS.exports=kI});var LS=fr((xie,BS)=>{"use strict";var FI=ES();function jI(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function UI(n){var t=new jI;t.pre=n.pre,t.body=n.body,t.post=n.post;var e=n.args.slice(0);t.argTypes=e;for(var r=0;r<e.length;++r){var o=e[r];if(o==="array"||typeof o=="object"&&o.blockIndices){if(t.argTypes[r]="array",t.arrayArgs.push(r),t.arrayBlockIndices.push(o.blockIndices?o.blockIndices:0),t.shimArgs.push("array"+r),r<t.pre.args.length&&t.pre.args[r].count>0)throw new Error("cwise: pre() block may not reference array args");if(r<t.post.args.length&&t.post.args[r].count>0)throw new Error("cwise: post() block may not reference array args")}else if(o==="scalar")t.scalarArgs.push(r),t.shimArgs.push("scalar"+r);else if(o==="index"){if(t.indexArgs.push(r),r<t.pre.args.length&&t.pre.args[r].count>0)throw new Error("cwise: pre() block may not reference array index");if(r<t.body.args.length&&t.body.args[r].lvalue)throw new Error("cwise: body() block may not write to array index");if(r<t.post.args.length&&t.post.args[r].count>0)throw new Error("cwise: post() block may not reference array index")}else if(o==="shape"){if(t.shapeArgs.push(r),r<t.pre.args.length&&t.pre.args[r].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(r<t.body.args.length&&t.body.args[r].lvalue)throw new Error("cwise: body() block may not write to array shape");if(r<t.post.args.length&&t.post.args[r].lvalue)throw new Error("cwise: post() block may not write to array shape")}else if(typeof o=="object"&&o.offset)t.argTypes[r]="offset",t.offsetArgs.push({array:o.array,offset:o.offset}),t.offsetArgIndex.push(r);else throw new Error("cwise: Unknown argument type "+e[r])}if(t.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(t.pre.args.length>e.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>e.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>e.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!n.printCode||!!n.debug,t.funcName=n.funcName||"cwise",t.blockSize=n.blockSize||64,FI(t)}BS.exports=UI});var sl=fr(je=>{"use strict";var Rr=LS(),Xd={body:"",args:[],thisVars:[],localVars:[]};function Rh(n){if(!n)return Xd;for(var t=0;t<n.args.length;++t){var e=n.args[t];t===0?n.args[t]={name:e,lvalue:!0,rvalue:!!n.rvalue,count:n.count||1}:n.args[t]={name:e,lvalue:!1,rvalue:!0,count:1}}return n.thisVars||(n.thisVars=[]),n.localVars||(n.localVars=[]),n}function HI(n){return Rr({args:n.args,pre:Rh(n.pre),body:Rh(n.body),post:Rh(n.proc),funcName:n.funcName})}function Ct(n){for(var t=[],e=0;e<n.args.length;++e)t.push("a"+e);var r=new Function("P",["return function ",n.funcName,"_ndarrayops(",t.join(","),") {P(",t.join(","),");return a0}"].join(""));return r(HI(n))}var RS={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var n in RS){var t=RS[n];je[n]=Ct({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:n}),je[n+"eq"]=Ct({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:n+"eq"}),je[n+"s"]=Ct({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:n+"s"}),je[n+"seq"]=Ct({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:n+"seq"})}})();var VS={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var n in VS){var t=VS[n];je[n]=Ct({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:n}),je[n+"eq"]=Ct({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:n+"eq"})}})();var zS={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var n in zS){var t=zS[n];je[n]=Ct({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:n}),je[n+"s"]=Ct({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:n+"s"}),je[n+"eq"]=Ct({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:n+"eq"}),je[n+"seq"]=Ct({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:n+"seq"})}})();var GS=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var n=0;n<GS.length;++n){var t=GS[n];je[t]=Ct({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:t}),je[t+"eq"]=Ct({args:["array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"})}})();var kS=["max","min","atan2","pow"];(function(){for(var n=0;n<kS.length;++n){var t=kS[n];je[t]=Ct({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t}),je[t+"s"]=Ct({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t+"s"}),je[t+"eq"]=Ct({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"}),je[t+"seq"]=Ct({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"seq"})}})();var FS=["atan2","pow"];(function(){for(var n=0;n<FS.length;++n){var t=FS[n];je[t+"op"]=Ct({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"op"}),je[t+"ops"]=Ct({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"ops"}),je[t+"opeq"]=Ct({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opeq"}),je[t+"opseq"]=Ct({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opseq"})}})();je.any=Rr({args:["array"],pre:Xd,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"});je.all=Rr({args:["array"],pre:Xd,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"});je.sum=Rr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"});je.prod=Rr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"});je.norm2squared=Rr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"});je.norm2=Rr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"});je.norminf=Rr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});je.norm1=Rr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});je.sup=Rr({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});je.inf=Rr({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});je.argmin=Rr({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});je.argmax=Rr({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});je.random=Ct({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});je.assign=Ct({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});je.assigns=Ct({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});je.equals=Rr({args:["array","array"],pre:Xd,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})});var d1=fr((Yse,u1)=>{u1.exports=function(t,e){for(var r=t.split("."),o=e.split("."),i=0;i<3;i++){var a=Number(r[i]),s=Number(o[i]);if(a>s)return 1;if(s>a)return-1;if(!isNaN(a)&&isNaN(s))return 1;if(isNaN(a)&&!isNaN(s))return-1}return 0}});var r3={};Kh(r3,{default:()=>Jd});module.exports=V1(r3);var ep=require("three");function _c(n){for(let t of Object.keys(n))n[t]===void 0&&delete n[t];return n}function br(n,t){return Object.setPrototypeOf(n,t),n}function Pc(n){return Array.isArray(n)?n:[n]}function Oc(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var z1=typeof global=="object"&&global&&global.Object===Object&&global,Cc=z1;var G1=typeof self=="object"&&self&&self.Object===Object&&self,k1=Cc||G1||Function("return this")(),Gt=k1;var F1=Gt.Symbol,Zt=F1;var Jh=Object.prototype,j1=Jh.hasOwnProperty,U1=Jh.toString,ul=Zt?Zt.toStringTag:void 0;function H1(n){var t=j1.call(n,ul),e=n[ul];try{n[ul]=void 0;var r=!0}catch{}var o=U1.call(n);return r&&(t?n[ul]=e:delete n[ul]),o}var em=H1;var q1=Object.prototype,W1=q1.toString;function $1(n){return W1.call(n)}var tm=$1;var Y1="[object Null]",X1="[object Undefined]",rm=Zt?Zt.toStringTag:void 0;function Q1(n){return n==null?n===void 0?X1:Y1:rm&&rm in Object(n)?em(n):tm(n)}var zr=Q1;function K1(n){return n!=null&&typeof n=="object"}var ar=K1;var Z1="[object Symbol]";function J1(n){return typeof n=="symbol"||ar(n)&&zr(n)==Z1}var ea=J1;function ew(n,t){for(var e=-1,r=n==null?0:n.length,o=Array(r);++e<r;)o[e]=t(n[e],e,n);return o}var Tc=ew;var tw=Array.isArray,Mt=tw;var rw=1/0,om=Zt?Zt.prototype:void 0,nm=om?om.toString:void 0;function im(n){if(typeof n=="string")return n;if(Mt(n))return Tc(n,im)+"";if(ea(n))return nm?nm.call(n):"";var t=n+"";return t=="0"&&1/n==-rw?"-0":t}var am=im;function ow(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var Gr=ow;function nw(n){return n}var sm=nw;var iw="[object AsyncFunction]",aw="[object Function]",sw="[object GeneratorFunction]",lw="[object Proxy]";function cw(n){if(!Gr(n))return!1;var t=zr(n);return t==aw||t==sw||t==iw||t==lw}var Mc=cw;var uw=Gt["__core-js_shared__"],Ic=uw;var lm=function(){var n=/[^.]+$/.exec(Ic&&Ic.keys&&Ic.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function dw(n){return!!lm&&lm in n}var cm=dw;var pw=Function.prototype,fw=pw.toString;function hw(n){if(n!=null){try{return fw.call(n)}catch{}try{return n+""}catch{}}return""}var Jo=hw;var mw=/[\\^$.*+?()[\]{}|]/g,yw=/^\[object .+?Constructor\]$/,gw=Function.prototype,xw=Object.prototype,bw=gw.toString,vw=xw.hasOwnProperty,Sw=RegExp("^"+bw.call(vw).replace(mw,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ww(n){if(!Gr(n)||cm(n))return!1;var t=Mc(n)?Sw:yw;return t.test(Jo(n))}var um=ww;function Aw(n,t){return n?.[t]}var dm=Aw;function _w(n,t){var e=dm(n,t);return um(e)?e:void 0}var Pr=_w;var Pw=Pr(Gt,"WeakMap"),Nc=Pw;var pm=Object.create,Ow=function(){function n(){}return function(t){if(!Gr(t))return{};if(pm)return pm(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),fm=Ow;function Cw(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var hm=Cw;function Tw(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}var mm=Tw;var Mw=800,Iw=16,Nw=Date.now;function Dw(n){var t=0,e=0;return function(){var r=Nw(),o=Iw-(r-e);if(e=r,o>0){if(++t>=Mw)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var ym=Dw;function Ew(n){return function(){return n}}var gm=Ew;var Bw=function(){try{var n=Pr(Object,"defineProperty");return n({},"",{}),n}catch{}}(),ta=Bw;var Lw=ta?function(n,t){return ta(n,"toString",{configurable:!0,enumerable:!1,value:gm(t),writable:!0})}:sm,xm=Lw;var Rw=ym(xm),bm=Rw;function Vw(n,t){for(var e=-1,r=n==null?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}var vm=Vw;var zw=9007199254740991,Gw=/^(?:0|[1-9]\d*)$/;function kw(n,t){var e=typeof n;return t=t??zw,!!t&&(e=="number"||e!="symbol"&&Gw.test(n))&&n>-1&&n%1==0&&n<t}var ra=kw;function Fw(n,t,e){t=="__proto__"&&ta?ta(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}var Dc=Fw;function jw(n,t){return n===t||n!==n&&t!==t}var oa=jw;var Uw=Object.prototype,Hw=Uw.hasOwnProperty;function qw(n,t,e){var r=n[t];(!(Hw.call(n,t)&&oa(r,e))||e===void 0&&!(t in n))&&Dc(n,t,e)}var na=qw;function Ww(n,t,e,r){var o=!e;e||(e={});for(var i=-1,a=t.length;++i<a;){var s=t[i],l=r?r(e[s],n[s],s,e,n):void 0;l===void 0&&(l=n[s]),o?Dc(e,s,l):na(e,s,l)}return e}var To=Ww;var Sm=Math.max;function $w(n,t,e){return t=Sm(t===void 0?n.length-1:t,0),function(){for(var r=arguments,o=-1,i=Sm(r.length-t,0),a=Array(i);++o<i;)a[o]=r[t+o];o=-1;for(var s=Array(t+1);++o<t;)s[o]=r[o];return s[t]=e(a),hm(n,this,s)}}var wm=$w;var Yw=9007199254740991;function Xw(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=Yw}var ia=Xw;function Qw(n){return n!=null&&ia(n.length)&&!Mc(n)}var Ec=Qw;var Kw=Object.prototype;function Zw(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||Kw;return n===e}var aa=Zw;function Jw(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var Am=Jw;var e2="[object Arguments]";function t2(n){return ar(n)&&zr(n)==e2}var pp=t2;var _m=Object.prototype,r2=_m.hasOwnProperty,o2=_m.propertyIsEnumerable,n2=pp(function(){return arguments}())?pp:function(n){return ar(n)&&r2.call(n,"callee")&&!o2.call(n,"callee")},sa=n2;function i2(){return!1}var Pm=i2;var Tm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Om=Tm&&typeof module=="object"&&module&&!module.nodeType&&module,a2=Om&&Om.exports===Tm,Cm=a2?Gt.Buffer:void 0,s2=Cm?Cm.isBuffer:void 0,l2=s2||Pm,gi=l2;var c2="[object Arguments]",u2="[object Array]",d2="[object Boolean]",p2="[object Date]",f2="[object Error]",h2="[object Function]",m2="[object Map]",y2="[object Number]",g2="[object Object]",x2="[object RegExp]",b2="[object Set]",v2="[object String]",S2="[object WeakMap]",w2="[object ArrayBuffer]",A2="[object DataView]",_2="[object Float32Array]",P2="[object Float64Array]",O2="[object Int8Array]",C2="[object Int16Array]",T2="[object Int32Array]",M2="[object Uint8Array]",I2="[object Uint8ClampedArray]",N2="[object Uint16Array]",D2="[object Uint32Array]",gt={};gt[_2]=gt[P2]=gt[O2]=gt[C2]=gt[T2]=gt[M2]=gt[I2]=gt[N2]=gt[D2]=!0;gt[c2]=gt[u2]=gt[w2]=gt[d2]=gt[A2]=gt[p2]=gt[f2]=gt[h2]=gt[m2]=gt[y2]=gt[g2]=gt[x2]=gt[b2]=gt[v2]=gt[S2]=!1;function E2(n){return ar(n)&&ia(n.length)&&!!gt[zr(n)]}var Mm=E2;function B2(n){return function(t){return n(t)}}var la=B2;var Im=typeof exports=="object"&&exports&&!exports.nodeType&&exports,dl=Im&&typeof module=="object"&&module&&!module.nodeType&&module,L2=dl&&dl.exports===Im,fp=L2&&Cc.process,R2=function(){try{var n=dl&&dl.require&&dl.require("util").types;return n||fp&&fp.binding&&fp.binding("util")}catch{}}(),en=R2;var Nm=en&&en.isTypedArray,V2=Nm?la(Nm):Mm,Bc=V2;var z2=Object.prototype,G2=z2.hasOwnProperty;function k2(n,t){var e=Mt(n),r=!e&&sa(n),o=!e&&!r&&gi(n),i=!e&&!r&&!o&&Bc(n),a=e||r||o||i,s=a?Am(n.length,String):[],l=s.length;for(var u in n)(t||G2.call(n,u))&&!(a&&(u=="length"||o&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||ra(u,l)))&&s.push(u);return s}var Lc=k2;function F2(n,t){return function(e){return n(t(e))}}var Rc=F2;var j2=Rc(Object.keys,Object),Dm=j2;var U2=Object.prototype,H2=U2.hasOwnProperty;function q2(n){if(!aa(n))return Dm(n);var t=[];for(var e in Object(n))H2.call(n,e)&&e!="constructor"&&t.push(e);return t}var Em=q2;function W2(n){return Ec(n)?Lc(n):Em(n)}var ca=W2;function $2(n){var t=[];if(n!=null)for(var e in Object(n))t.push(e);return t}var Bm=$2;var Y2=Object.prototype,X2=Y2.hasOwnProperty;function Q2(n){if(!Gr(n))return Bm(n);var t=aa(n),e=[];for(var r in n)r=="constructor"&&(t||!X2.call(n,r))||e.push(r);return e}var Lm=Q2;function K2(n){return Ec(n)?Lc(n,!0):Lm(n)}var ua=K2;var Z2=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,J2=/^\w*$/;function eA(n,t){if(Mt(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||ea(n)?!0:J2.test(n)||!Z2.test(n)||t!=null&&n in Object(t)}var Rm=eA;var tA=Pr(Object,"create"),tn=tA;function rA(){this.__data__=tn?tn(null):{},this.size=0}var Vm=rA;function oA(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var zm=oA;var nA="__lodash_hash_undefined__",iA=Object.prototype,aA=iA.hasOwnProperty;function sA(n){var t=this.__data__;if(tn){var e=t[n];return e===nA?void 0:e}return aA.call(t,n)?t[n]:void 0}var Gm=sA;var lA=Object.prototype,cA=lA.hasOwnProperty;function uA(n){var t=this.__data__;return tn?t[n]!==void 0:cA.call(t,n)}var km=uA;var dA="__lodash_hash_undefined__";function pA(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=tn&&t===void 0?dA:t,this}var Fm=pA;function da(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}da.prototype.clear=Vm;da.prototype.delete=zm;da.prototype.get=Gm;da.prototype.has=km;da.prototype.set=Fm;var hp=da;function fA(){this.__data__=[],this.size=0}var jm=fA;function hA(n,t){for(var e=n.length;e--;)if(oa(n[e][0],t))return e;return-1}var Cn=hA;var mA=Array.prototype,yA=mA.splice;function gA(n){var t=this.__data__,e=Cn(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():yA.call(t,e,1),--this.size,!0}var Um=gA;function xA(n){var t=this.__data__,e=Cn(t,n);return e<0?void 0:t[e][1]}var Hm=xA;function bA(n){return Cn(this.__data__,n)>-1}var qm=bA;function vA(n,t){var e=this.__data__,r=Cn(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var Wm=vA;function pa(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}pa.prototype.clear=jm;pa.prototype.delete=Um;pa.prototype.get=Hm;pa.prototype.has=qm;pa.prototype.set=Wm;var Tn=pa;var SA=Pr(Gt,"Map"),Mn=SA;function wA(){this.size=0,this.__data__={hash:new hp,map:new(Mn||Tn),string:new hp}}var $m=wA;function AA(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var Ym=AA;function _A(n,t){var e=n.__data__;return Ym(t)?e[typeof t=="string"?"string":"hash"]:e.map}var In=_A;function PA(n){var t=In(this,n).delete(n);return this.size-=t?1:0,t}var Xm=PA;function OA(n){return In(this,n).get(n)}var Qm=OA;function CA(n){return In(this,n).has(n)}var Km=CA;function TA(n,t){var e=In(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var Zm=TA;function fa(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}fa.prototype.clear=$m;fa.prototype.delete=Xm;fa.prototype.get=Qm;fa.prototype.has=Km;fa.prototype.set=Zm;var xi=fa;var MA="Expected a function";function mp(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(MA);var e=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=e.cache;if(i.has(o))return i.get(o);var a=n.apply(this,r);return e.cache=i.set(o,a)||i,a};return e.cache=new(mp.Cache||xi),e}mp.Cache=xi;var Jm=mp;var IA=500;function NA(n){var t=Jm(n,function(r){return e.size===IA&&e.clear(),r}),e=t.cache;return t}var ey=NA;var DA=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,EA=/\\(\\)?/g,BA=ey(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(DA,function(e,r,o,i){t.push(o?i.replace(EA,"$1"):r||e)}),t}),ty=BA;function LA(n){return n==null?"":am(n)}var ry=LA;function RA(n,t){return Mt(n)?n:Rm(n,t)?[n]:ty(ry(n))}var $r=RA;var VA=1/0;function zA(n){if(typeof n=="string"||ea(n))return n;var t=n+"";return t=="0"&&1/n==-VA?"-0":t}var Nn=zA;function GA(n,t){t=$r(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[Nn(t[e++])];return e&&e==r?n:void 0}var Vc=GA;function kA(n,t){for(var e=-1,r=t.length,o=n.length;++e<r;)n[o+e]=t[e];return n}var ha=kA;var oy=Zt?Zt.isConcatSpreadable:void 0;function FA(n){return Mt(n)||sa(n)||!!(oy&&n&&n[oy])}var ny=FA;function iy(n,t,e,r,o){var i=-1,a=n.length;for(e||(e=ny),o||(o=[]);++i<a;){var s=n[i];t>0&&e(s)?t>1?iy(s,t-1,e,r,o):ha(o,s):r||(o[o.length]=s)}return o}var ay=iy;function jA(n){var t=n==null?0:n.length;return t?ay(n,1):[]}var sy=jA;function UA(n){return bm(wm(n,void 0,sy),n+"")}var zc=UA;var HA=Rc(Object.getPrototypeOf,Object),ma=HA;var qA="[object Object]",WA=Function.prototype,$A=Object.prototype,ly=WA.toString,YA=$A.hasOwnProperty,XA=ly.call(Object);function QA(n){if(!ar(n)||zr(n)!=qA)return!1;var t=ma(n);if(t===null)return!0;var e=YA.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&ly.call(e)==XA}var cy=QA;function KA(n,t,e){var r=-1,o=n.length;t<0&&(t=-t>o?0:o+t),e=e>o?o:e,e<0&&(e+=o),o=t>e?0:e-t>>>0,t>>>=0;for(var i=Array(o);++r<o;)i[r]=n[r+t];return i}var uy=KA;function ZA(){this.__data__=new Tn,this.size=0}var dy=ZA;function JA(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var py=JA;function e_(n){return this.__data__.get(n)}var fy=e_;function t_(n){return this.__data__.has(n)}var hy=t_;var r_=200;function o_(n,t){var e=this.__data__;if(e instanceof Tn){var r=e.__data__;if(!Mn||r.length<r_-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new xi(r)}return e.set(n,t),this.size=e.size,this}var my=o_;function ya(n){var t=this.__data__=new Tn(n);this.size=t.size}ya.prototype.clear=dy;ya.prototype.delete=py;ya.prototype.get=fy;ya.prototype.has=hy;ya.prototype.set=my;var ga=ya;function n_(n,t){return n&&To(t,ca(t),n)}var yy=n_;function i_(n,t){return n&&To(t,ua(t),n)}var gy=i_;var Sy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xy=Sy&&typeof module=="object"&&module&&!module.nodeType&&module,a_=xy&&xy.exports===Sy,by=a_?Gt.Buffer:void 0,vy=by?by.allocUnsafe:void 0;function s_(n,t){if(t)return n.slice();var e=n.length,r=vy?vy(e):new n.constructor(e);return n.copy(r),r}var wy=s_;function l_(n,t){for(var e=-1,r=n==null?0:n.length,o=0,i=[];++e<r;){var a=n[e];t(a,e,n)&&(i[o++]=a)}return i}var Ay=l_;function c_(){return[]}var Gc=c_;var u_=Object.prototype,d_=u_.propertyIsEnumerable,_y=Object.getOwnPropertySymbols,p_=_y?function(n){return n==null?[]:(n=Object(n),Ay(_y(n),function(t){return d_.call(n,t)}))}:Gc,xa=p_;function f_(n,t){return To(n,xa(n),t)}var Py=f_;var h_=Object.getOwnPropertySymbols,m_=h_?function(n){for(var t=[];n;)ha(t,xa(n)),n=ma(n);return t}:Gc,kc=m_;function y_(n,t){return To(n,kc(n),t)}var Oy=y_;function g_(n,t,e){var r=t(n);return Mt(n)?r:ha(r,e(n))}var Fc=g_;function x_(n){return Fc(n,ca,xa)}var pl=x_;function b_(n){return Fc(n,ua,kc)}var jc=b_;var v_=Pr(Gt,"DataView"),Uc=v_;var S_=Pr(Gt,"Promise"),Hc=S_;var w_=Pr(Gt,"Set"),qc=w_;var Cy="[object Map]",A_="[object Object]",Ty="[object Promise]",My="[object Set]",Iy="[object WeakMap]",Ny="[object DataView]",__=Jo(Uc),P_=Jo(Mn),O_=Jo(Hc),C_=Jo(qc),T_=Jo(Nc),bi=zr;(Uc&&bi(new Uc(new ArrayBuffer(1)))!=Ny||Mn&&bi(new Mn)!=Cy||Hc&&bi(Hc.resolve())!=Ty||qc&&bi(new qc)!=My||Nc&&bi(new Nc)!=Iy)&&(bi=function(n){var t=zr(n),e=t==A_?n.constructor:void 0,r=e?Jo(e):"";if(r)switch(r){case __:return Ny;case P_:return Cy;case O_:return Ty;case C_:return My;case T_:return Iy}return t});var rn=bi;var M_=Object.prototype,I_=M_.hasOwnProperty;function N_(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&I_.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Dy=N_;var D_=Gt.Uint8Array,ba=D_;function E_(n){var t=new n.constructor(n.byteLength);return new ba(t).set(new ba(n)),t}var va=E_;function B_(n,t){var e=t?va(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Ey=B_;var L_=/\w*$/;function R_(n){var t=new n.constructor(n.source,L_.exec(n));return t.lastIndex=n.lastIndex,t}var By=R_;var Ly=Zt?Zt.prototype:void 0,Ry=Ly?Ly.valueOf:void 0;function V_(n){return Ry?Object(Ry.call(n)):{}}var Vy=V_;function z_(n,t){var e=t?va(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var zy=z_;var G_="[object Boolean]",k_="[object Date]",F_="[object Map]",j_="[object Number]",U_="[object RegExp]",H_="[object Set]",q_="[object String]",W_="[object Symbol]",$_="[object ArrayBuffer]",Y_="[object DataView]",X_="[object Float32Array]",Q_="[object Float64Array]",K_="[object Int8Array]",Z_="[object Int16Array]",J_="[object Int32Array]",eP="[object Uint8Array]",tP="[object Uint8ClampedArray]",rP="[object Uint16Array]",oP="[object Uint32Array]";function nP(n,t,e){var r=n.constructor;switch(t){case $_:return va(n);case G_:case k_:return new r(+n);case Y_:return Ey(n,e);case X_:case Q_:case K_:case Z_:case J_:case eP:case tP:case rP:case oP:return zy(n,e);case F_:return new r;case j_:case q_:return new r(n);case U_:return By(n);case H_:return new r;case W_:return Vy(n)}}var Gy=nP;function iP(n){return typeof n.constructor=="function"&&!aa(n)?fm(ma(n)):{}}var ky=iP;var aP="[object Map]";function sP(n){return ar(n)&&rn(n)==aP}var Fy=sP;var jy=en&&en.isMap,lP=jy?la(jy):Fy,Uy=lP;var cP="[object Set]";function uP(n){return ar(n)&&rn(n)==cP}var Hy=uP;var qy=en&&en.isSet,dP=qy?la(qy):Hy,Wy=dP;var pP=1,fP=2,hP=4,$y="[object Arguments]",mP="[object Array]",yP="[object Boolean]",gP="[object Date]",xP="[object Error]",Yy="[object Function]",bP="[object GeneratorFunction]",vP="[object Map]",SP="[object Number]",Xy="[object Object]",wP="[object RegExp]",AP="[object Set]",_P="[object String]",PP="[object Symbol]",OP="[object WeakMap]",CP="[object ArrayBuffer]",TP="[object DataView]",MP="[object Float32Array]",IP="[object Float64Array]",NP="[object Int8Array]",DP="[object Int16Array]",EP="[object Int32Array]",BP="[object Uint8Array]",LP="[object Uint8ClampedArray]",RP="[object Uint16Array]",VP="[object Uint32Array]",ht={};ht[$y]=ht[mP]=ht[CP]=ht[TP]=ht[yP]=ht[gP]=ht[MP]=ht[IP]=ht[NP]=ht[DP]=ht[EP]=ht[vP]=ht[SP]=ht[Xy]=ht[wP]=ht[AP]=ht[_P]=ht[PP]=ht[BP]=ht[LP]=ht[RP]=ht[VP]=!0;ht[xP]=ht[Yy]=ht[OP]=!1;function Wc(n,t,e,r,o,i){var a,s=t&pP,l=t&fP,u=t&hP;if(e&&(a=o?e(n,r,o,i):e(n)),a!==void 0)return a;if(!Gr(n))return n;var c=Mt(n);if(c){if(a=Dy(n),!s)return mm(n,a)}else{var d=rn(n),p=d==Yy||d==bP;if(gi(n))return wy(n,s);if(d==Xy||d==$y||p&&!o){if(a=l||p?{}:ky(n),!s)return l?Oy(n,gy(a,n)):Py(n,yy(a,n))}else{if(!ht[d])return o?n:{};a=Gy(n,d,s)}}i||(i=new ga);var f=i.get(n);if(f)return f;i.set(n,a),Wy(n)?n.forEach(function(y){a.add(Wc(y,t,e,y,n,i))}):Uy(n)&&n.forEach(function(y,g){a.set(g,Wc(y,t,e,g,n,i))});var h=u?l?jc:pl:l?ua:ca,m=c?void 0:h(n);return vm(m||n,function(y,g){m&&(g=y,y=n[g]),na(a,g,Wc(y,t,e,g,n,i))}),a}var $c=Wc;var zP=1,GP=4;function kP(n){return $c(n,zP|GP)}var on=kP;var FP="__lodash_hash_undefined__";function jP(n){return this.__data__.set(n,FP),this}var Qy=jP;function UP(n){return this.__data__.has(n)}var Ky=UP;function Yc(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new xi;++t<e;)this.add(n[t])}Yc.prototype.add=Yc.prototype.push=Qy;Yc.prototype.has=Ky;var Zy=Yc;function HP(n,t){for(var e=-1,r=n==null?0:n.length;++e<r;)if(t(n[e],e,n))return!0;return!1}var Jy=HP;function qP(n,t){return n.has(t)}var eg=qP;var WP=1,$P=2;function YP(n,t,e,r,o,i){var a=e&WP,s=n.length,l=t.length;if(s!=l&&!(a&&l>s))return!1;var u=i.get(n),c=i.get(t);if(u&&c)return u==t&&c==n;var d=-1,p=!0,f=e&$P?new Zy:void 0;for(i.set(n,t),i.set(t,n);++d<s;){var h=n[d],m=t[d];if(r)var y=a?r(m,h,d,t,n,i):r(h,m,d,n,t,i);if(y!==void 0){if(y)continue;p=!1;break}if(f){if(!Jy(t,function(g,b){if(!eg(f,b)&&(h===g||o(h,g,e,r,i)))return f.push(b)})){p=!1;break}}else if(!(h===m||o(h,m,e,r,i))){p=!1;break}}return i.delete(n),i.delete(t),p}var Xc=YP;function XP(n){var t=-1,e=Array(n.size);return n.forEach(function(r,o){e[++t]=[o,r]}),e}var tg=XP;function QP(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var rg=QP;var KP=1,ZP=2,JP="[object Boolean]",eO="[object Date]",tO="[object Error]",rO="[object Map]",oO="[object Number]",nO="[object RegExp]",iO="[object Set]",aO="[object String]",sO="[object Symbol]",lO="[object ArrayBuffer]",cO="[object DataView]",og=Zt?Zt.prototype:void 0,yp=og?og.valueOf:void 0;function uO(n,t,e,r,o,i,a){switch(e){case cO:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case lO:return!(n.byteLength!=t.byteLength||!i(new ba(n),new ba(t)));case JP:case eO:case oO:return oa(+n,+t);case tO:return n.name==t.name&&n.message==t.message;case nO:case aO:return n==t+"";case rO:var s=tg;case iO:var l=r&KP;if(s||(s=rg),n.size!=t.size&&!l)return!1;var u=a.get(n);if(u)return u==t;r|=ZP,a.set(n,t);var c=Xc(s(n),s(t),r,o,i,a);return a.delete(n),c;case sO:if(yp)return yp.call(n)==yp.call(t)}return!1}var ng=uO;var dO=1,pO=Object.prototype,fO=pO.hasOwnProperty;function hO(n,t,e,r,o,i){var a=e&dO,s=pl(n),l=s.length,u=pl(t),c=u.length;if(l!=c&&!a)return!1;for(var d=l;d--;){var p=s[d];if(!(a?p in t:fO.call(t,p)))return!1}var f=i.get(n),h=i.get(t);if(f&&h)return f==t&&h==n;var m=!0;i.set(n,t),i.set(t,n);for(var y=a;++d<l;){p=s[d];var g=n[p],b=t[p];if(r)var w=a?r(b,g,p,t,n,i):r(g,b,p,n,t,i);if(!(w===void 0?g===b||o(g,b,e,r,i):w)){m=!1;break}y||(y=p=="constructor")}if(m&&!y){var _=n.constructor,S=t.constructor;_!=S&&"constructor"in n&&"constructor"in t&&!(typeof _=="function"&&_ instanceof _&&typeof S=="function"&&S instanceof S)&&(m=!1)}return i.delete(n),i.delete(t),m}var ig=hO;var mO=1,ag="[object Arguments]",sg="[object Array]",Qc="[object Object]",yO=Object.prototype,lg=yO.hasOwnProperty;function gO(n,t,e,r,o,i){var a=Mt(n),s=Mt(t),l=a?sg:rn(n),u=s?sg:rn(t);l=l==ag?Qc:l,u=u==ag?Qc:u;var c=l==Qc,d=u==Qc,p=l==u;if(p&&gi(n)){if(!gi(t))return!1;a=!0,c=!1}if(p&&!c)return i||(i=new ga),a||Bc(n)?Xc(n,t,e,r,o,i):ng(n,t,l,e,r,o,i);if(!(e&mO)){var f=c&&lg.call(n,"__wrapped__"),h=d&&lg.call(t,"__wrapped__");if(f||h){var m=f?n.value():n,y=h?t.value():t;return i||(i=new ga),o(m,y,e,r,i)}}return p?(i||(i=new ga),ig(n,t,e,r,o,i)):!1}var cg=gO;function ug(n,t,e,r,o){return n===t?!0:n==null||t==null||!ar(n)&&!ar(t)?n!==n&&t!==t:cg(n,t,e,r,ug,o)}var dg=ug;function xO(n,t){return n!=null&&t in Object(n)}var pg=xO;function bO(n,t,e){t=$r(t,n);for(var r=-1,o=t.length,i=!1;++r<o;){var a=Nn(t[r]);if(!(i=n!=null&&e(n,a)))break;n=n[a]}return i||++r!=o?i:(o=n==null?0:n.length,!!o&&ia(o)&&ra(a,o)&&(Mt(n)||sa(n)))}var fg=bO;function vO(n,t){return n!=null&&fg(n,t,pg)}var hg=vO;function SO(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var mg=SO;function wO(n,t){return t.length<2?n:Vc(n,uy(t,0,-1))}var yg=wO;function AO(n,t){return dg(n,t)}var gp=AO;function _O(n,t){return t=$r(t,n),n=yg(n,t),n==null||delete n[Nn(mg(t))]}var gg=_O;function PO(n){return cy(n)?void 0:n}var xg=PO;var OO=1,CO=2,TO=4,MO=zc(function(n,t){var e={};if(n==null)return e;var r=!1;t=Tc(t,function(i){return i=$r(i,n),r||(r=i.length>1),i}),To(n,jc(n),e),r&&(e=$c(e,OO|CO|TO,xg));for(var o=t.length;o--;)gg(e,t[o]);return e}),Sa=MO;function IO(n,t,e,r){if(!Gr(n))return n;t=$r(t,n);for(var o=-1,i=t.length,a=i-1,s=n;s!=null&&++o<i;){var l=Nn(t[o]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return n;if(o!=a){var c=s[l];u=r?r(c,l,s):void 0,u===void 0&&(u=Gr(c)?c:ra(t[o+1])?[]:{})}na(s,l,u),s=s[l]}return n}var bg=IO;function NO(n,t,e){for(var r=-1,o=t.length,i={};++r<o;){var a=t[r],s=Vc(n,a);e(s,a)&&bg(i,$r(a,n),s)}return i}var vg=NO;function DO(n,t){return vg(n,t,function(e,r){return hg(n,r)})}var Sg=DO;var EO=zc(function(n,t){return n==null?{}:Sg(n,t)}),uo=EO;var be=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let i={...r,[t]:e};return Object.setPrototypeOf(i,be.prototype),i}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],o;r===void 0?o={type:2,id:t.id}:o={type:1,id:t.id,data:r};let{id:i,data:a}=t,s={...e,[i]:a};return Object.setPrototypeOf(s,be.prototype),{data:s,actual:t,reverse:o}}else if(t.type===2){let{id:r}=t,o=e[r];if(o===void 0)return null;{let i={...e};return Object.setPrototypeOf(i,be.prototype),delete i[r],{data:i,actual:t,reverse:{type:1,id:r,data:o}}}}return null}};function fl(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let t=Object.getOwnPropertyNames(n);for(let e of t){let r=n[e];r&&typeof r=="object"&&fl(r)}return Object.freeze(n)}function wg(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var wa=class extends Error{};function Kc(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function Mo(n,t,e){if(n===void 0?t===void 0?(n=0,t=10):n=t-10:t===void 0&&(t=n+10),n>t){let i=n;n=t,t=i}let r=[],o=1/(e+1);for(let i=0;i<e;i++){let a=n+(t-n)*(i+.75+Math.random()*.5)*o;r.push(a)}return r}function Aa(n){return n instanceof Uint8Array||n instanceof Uint16Array||n instanceof Uint32Array||n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof Float64Array}function Ag(){return typeof process<"u"}function _g(n,t){for(let e of n)t(e.id,e.data)!==!0&&_g(e.children,t)}function Pg(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)Pg(e,t)}var ut=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ut.prototype)}deepFreeze(){let e=0;for(;e<this.length;)fl(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,r){if(!this.has(e))return!0;for(;e;){let o=this.parent(e);if(o===r)return!0;e=o}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let o=this.parent(e);if(o===r)return!0;e=o}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,r){if(e===null)this.traverse(r);else{let o=this.get(e);o&&Pg(o,r)}}traverse(e){_g(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),a=this.childrenArray(i),s=a.findIndex(c=>c.id===e);if(s<0)throw new Error("not expected");let l=a[s];return a=[...a],a[s]={...l,data:r},this.modifyArrayBy(i,a)}}modifyArrayBy(e,r){let o=e,i=r;for(;o!==null;){let s=i,l=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let u=i.findIndex(c=>c.id===l);if(u<0)throw new Error;i=[...i],i[u]={...i[u],children:s}}Object.setPrototypeOf(i,ut.prototype);let a=i;return a.fillCaches(),a}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:r}){if(this.get(e)!==void 0)return!0;for(let o of r)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:r,fi:o,id:i,data:a,children:s}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,u=this.childrenArray(l),c={fi:o,id:i,data:a,children:s};return u=[...u,c],u.sort((p,f)=>p.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:i}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let o=this.parent(r);if(o===void 0)return null;let i=this.childrenArray(o),a=i.findIndex(u=>u.id===r);e.localIndex=a,i=[...i];let s=i.splice(a,1)[0];return{data:this.modifyArrayBy(o,i),actual:e,reverse:{type:7,...s,parent:o}}}}moveOp(e){let{parent:r,fi:o,id:i}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:i});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===i)throw new wa("cyclic tree");f=this.parent(f)}}let a=this.parent(i);if(a===void 0)return null;let s=a,l=this.childrenArray(a),u=l.findIndex(f=>f.id===i);l=[...l];let c=l.splice(u,1)[0],d=this.modifyArrayBy(a,l);a=r,l=d.childrenArray(a);let p=c.fi;return c={...c,fi:o},l=[...l,c],l.sort((f,h)=>f.fi-h.fi),e.localIndex=l.indexOf(c),d=d.modifyArrayBy(a,l),{data:d,actual:e,reverse:{type:9,parent:s,fi:p,id:i}}}previous(e,r){if(r===null){let i=this.childrenArray(e);return i.length===0?null:i[i.length-1].id}let o=null;for(let i of this.childrenArray(e)){if(i.id===r)return o;o=i.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),i=o.findIndex(a=>a.id===e)+1;if(i<o.length)return o[i].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),i=o.findIndex(a=>a.id===e)-1;return i>=0?this.traverseSortPrevious(o[i].id):r}}getAllSorted(e){let r=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&r.push({...o,...i})}r.sort((o,i)=>wg(o.sortKey,i.sortKey));for(let o of r)delete o.sortKey;return r}getWithSortKey(e){var r=e;let o=[],i=this.get(r),a=i;if(i!==void 0){for(;r;)o.splice(0,0,i.fi),r=this.parent(r),r!==null&&(i=this.get(r));return{...a,sortKey:o}}}insertBeforeHelper(e,r,o){return this.insertAfterHelper(e,this.previous(e,r),o)}insertAfterHelper(e,r,o){let i=this.childrenArray(e);if(r===null){if(i.length===0)return Mo(0,o,o);{let a=i[0].fi;return Mo(a-o,a,o)}}else{let a=this.get(r);if(a===void 0||this.parent(r)!==e)throw new Error("illegal args");let s=i.find(l=>l.fi>a.fi);if(s===void 0){let l=i[i.length-1].fi;return Mo(l,l+o,o)}else return Mo(a.fi,s.fi,o)}}};var _a;(t=>{function n(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let o=r.props,i={},a=[...e],s=!1;if(o)for(let l of Object.keys(o)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");i[l]=a[u],a[u]=o[l],s=!0}return s?{data:a,actual:r,reverse:{type:0,props:i}}:null}else{let o=r.props,i={},a={...e},s=!1;if(o)for(let l of Object.keys(o)){i[l]=a[l];let u=o[l];u===void 0?delete a[l]:a[l]=u,s=!0}return s?{data:a,actual:r,reverse:{type:0,props:i}}:null}}t.runOp=n})(_a||(_a={}));var we=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,we.prototype)}deepFreeze(){let e=0;for(;e<this.length;)fl(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,a=i.findIndex(u=>u.id===e);if(a<0)throw new Error("not expected");let s=i[a];return i=[...i],i[a]={...s,data:r},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,we.prototype);let r=e;return Ag()||r.fillCaches(),r}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:r,id:o,data:i}=e,a=this,s={fi:r,id:o,data:i};return a=[...a,s],a.sort((u,c)=>u.fi-c.fi),e.localIndex=a.indexOf(s),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:o}}}deleteOp(e){let{id:r}=e,o=this,i=o.findIndex(l=>l.id===r);if(i===-1)return null;e.localIndex=i,o=[...o];let a=o.splice(i,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:r,id:o}=e,i=this;i=[...i];let a=i.findIndex(c=>c.id===o);if(a===-1)return null;let s=i[a].fi,l={...i[a],fi:r};return i[a]=l,i.sort((c,d)=>c.fi-d.fi),e.localIndex=i.indexOf(l),{data:this.modifyArrayBy(i),actual:e,reverse:{type:6,fi:s,id:o}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let o of this){if(o.id===e)return r;r=o.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let o=this;if(e===null){if(o.length===0)return Mo(0,r,r);{let i=o[0].fi;return Mo(i-r,i,r)}}else{let i=this.get(e);if(i===void 0)throw new Error("illegal args");let a=o.find(s=>s.fi>i.fi);if(a===void 0){let s=o[o.length-1].fi;return Mo(s,s+r,r)}else return Mo(i.fi,a.fi,r)}}};function Pa(n){return n&&typeof n=="object"&&n instanceof dt}var dt=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,o=0,i={};for(;o<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[o]],r!==void 0&&!Pa(r))return null;o+=1}r=r?Kc(r):new dt;for(let[l,u]of Object.entries(t.props)){let c=r[l];i[l]=c,u===void 0?delete r[l]:r[l]=u}for(;o>0;){if(Object.keys(r).length===0){let l=e[o-1];l&&(r=Kc(l),delete r[t.path[o-1]])}else{let l=e[o-1];if(l){let u=Kc(l);u[t.path[o-1]]=r,r=u}else{let u=new dt;u[t.path[o-1]]=r,r=u}}o-=1}let a=Object.setPrototypeOf(r,dt.prototype),s={...t,props:i};return{data:a,actual:t,reverse:s}}},Io;(r=>{function n(o,i){return hl(o,i)??o}r.apply=n;function t(o,i){return bp(o,i)}r.merge=t;function e(o,i){let a=0,s=i.path,l=o;for(;a<s.length&&l!==void 0;){if(l=St.zoomOnce(l,s[a]),l===void 0)return i;if(!Pa(l))return;a+=1}if(l===void 0)return i;if(!!Pa(l))if(i.type===0){let u={...i.props};for(let c of Object.keys(l))delete u[c];return{...i,props:u}}else if(i.type===1||i.type===4||i.type===7){let u=xp([i],l);return u?(console.log(u),u):i}else return i}r.filterOp=e})(Io||(Io={}));function xp(n,t){if(t===void 0)return;let e=!1,r=n.map(o=>{let i=o.id,a=hl(o.data,t[i]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=xp(o.children,t);return s!==void 0?e=!0:s=o.children,{...o,id:i,data:a,children:s}}else return{...o,id:i,data:a}});if(e)return r}function BO(n,t){if(t===void 0)return;let e=!1,r=n.map(o=>{let i=o.id,a=hl(o.data,t[i]);return e=e||a!==void 0,a===void 0&&(a=o.data),{...o,id:i,data:a}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function hl(n,t){if(!Pa(t))return t;if(n instanceof ut){let e=xp(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof we)return BO(n,t);if(Array.isArray(n)){let e=!1,r=n.map((o,i)=>{let a=hl(o,t[i]);return e=e||a!==void 0,a===void 0&&(a=o),a});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else{if(n instanceof dt)return bp(n,t);if(n&&typeof n=="object"){let e={},r=!1;for(let[o,i]of Object.entries(n)){let a=hl(i,t[o]);r=r||a!==void 0,a===void 0&&(a=i),e[o]=a}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function bp(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!Pa(t))return t;if(!Pa(n))return Io.apply(n,t);let e=new Set;for(let o of Object.keys(n))e.add(o);for(let o of Object.keys(t))e.add(o);let r=new dt;for(let o of e){let i=bp(n===void 0?void 0:n[o],t===void 0?void 0:t[o]);r[o]=i}return r}function Og(n,t){let e={cur:[],result:[],len:0};return n=ml(n,t,e)??n,[n,e.result]}function Zc(n,t){return n===null?null:(n.cur[n.len]=t,n.len+=1,n)}function Jc(n){n&&(n.len-=1)}function LO(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Cg(n,t,e){let r=!1,o=n.map(i=>{let a=i.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=ml(i.data,t,Zc(e,a));Jc(e),r=r||l!==void 0,l===void 0&&(l=i.data);let u=Cg(i.children,t,e);return u!==void 0?r=!0:u=i.children,{...i,id:a,data:l,children:u}});if(r)return o}function RO(n,t,e){let r=!1,o=n.map(i=>{let a=i.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=ml(i.data,t,Zc(e,a));return Jc(e),r=r||l!==void 0,l===void 0&&(l=i.data),{...i,id:a,data:l}});if(r)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}function ml(n,t,e){if(n instanceof ut){let r=Cg(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof we)return RO(n,t,e);if(Array.isArray(n)){let r=!1,o=n.map((i,a)=>{let s=ml(i,t,Zc(e,a));return Jc(e),r=r||s!==void 0,s===void 0&&(s=i),s});return r?(Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o):void 0}else if(n&&typeof n=="object"&&!Aa(n)){let r={},o=!1;for(let[i,a]of Object.entries(n))if(i!=="name"){let s=t[i];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,i=s}let l=ml(a,t,Zc(e,i));Jc(e),o=o||l!==void 0,l===void 0&&(l=a),r[i]=l}else r[i]=a;return o?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else if(typeof n=="string"){let r=t[n];return r!==void 0&&LO(e),r}else return}}var Oa;(t=>{function n(e,r){let o=St.zoom(r,e.path);if(typeof o=="object"){let i={};for(let a of Object.keys(e.props))i[a]=o[a];return{...e,props:i}}else return{...e,props:{}}}t.replaceProps=n})(Oa||(Oa={}));var wt;(s=>{function n(l,u){return{...l,path:l.path.slice(u)}}s.drop=n;function t(l,u){return e(l,u)?.data??l}s.applySimple=t;function e(l,u){let c=u.path;for(var d=[];;){let p;if(l instanceof dt&&u.type===0&&(p=l.runOp({...u,path:c.slice(d.length)}),p===null&&(p=void 0)),p===void 0&&d.length===c.length&&(l instanceof ut||l instanceof we||l instanceof be?p=l.runOp(u):p=_a.runOp(l,u)),p!==void 0)if(p!==null){let m=p.data;for(let y=d.length-1;y>=0;y--){let g=c[y],b=d[y];if(b instanceof ut){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof we){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof be){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof dt){let w={...b,[g]:m};m=Object.setPrototypeOf(w,dt.prototype)}else if(typeof b=="object")if(Array.isArray(b)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let w=m;m=[...b],m[g]=w}else m={...b,[g]:m};else return null}return{data:m,actual:{...p.actual,path:c},reverse:{...p.reverse,path:c}}}else return null;let f=c[d.length],h;if(l instanceof ut){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else if(l instanceof we){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else l!==null&&(h=l[f]);if(h!==void 0)d.push(l),l=h;else return null}}s.apply=e;function r(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}s.pathDisjoint=r;function o(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}s.pathEq=o;function i(l,u){return r(l.path,u.path)}s.commutative=i;function a(l,u){return l.type===0&&u.type===0&&o(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}s.subsumed=a})(wt||(wt={}));var yl;(l=>{function n(){return[]}l.empty=n;function t(u,c){let d=[];for(let p of u){let[f,...h]=p.path;f===c&&d.push({...p,path:h})}return d}l.removePrefix=t;function e(u,c){return u.map(d=>({...d,path:[c,...d.path]}))}l.addPrefix=e;function r(u,c){return[...u,...c]}l.concat=r;function o(u,c){return[...u.filter(p=>!c.some(f=>wt.subsumed(p,f))),...c]}l.compress=o;function i(u,c){return u.every(d=>c.every(p=>wt.commutative(d,p)))}l.commutative=i;function a(u,c){for(let d of c){let p=s(u,d);p!==null&&(u=p.data)}return u}l.applyAll=a;function s(u,c){var d=u;let p=[],f=[];for(let h of c)try{if(h.type===3||h.type===5&&h.path[h.path.length-1]==="variables"){let m,y,g;if(h.type===3?(m=St.zoom(d,[...h.path,h.id]),g=wt.apply(d,{...h,type:2})):(m=St.zoom(d,[...h.path,h.id,"value"]),g=wt.apply(d,h)),g!==null){d=g.data;let[b,w]=Og(d,{[h.id]:m});d=b;for(let _=0;_<w.length;_++){let S=w[_],P=S.pop();if(typeof P=="number"){let O=[P];for(let D=_+1;D<w.length;D++){let N=w[D],T=N[N.length-1];if(typeof T=="number"&&St.equal(S,N.slice(0,N.length-1)))O.push(T),w.splice(D,1);else break}let x=St.zoom(d,S);y=x.map((D,N)=>O.includes(N)?h.id:D),m=x,P=S.pop()}else{if(P==="alphaOverride"||P==="alpha"){m/=100;let O=m,x=St.zoom(d,S.slice(0,S.length-2)),D=x.layers.map(N=>N.id===S[S.length-1]?{...N,data:{...N.data,[P]:O}}:N);Object.setPrototypeOf(D,Object.getPrototypeOf(x.layers)),x.layers=D}y=h.id}p.push({type:0,path:S,props:{[P]:m}}),f.push({type:0,path:S,props:{[P]:y}})}f.push(g.reverse),p.push(g.actual)}}else{let m=wt.apply(d,h);m!==null&&(p.push(m.actual),d=m.data,f.push(m.reverse))}}catch(m){if(m instanceof wa)return null;throw m}return{data:d,actual:p,reverse:f.reverse()}}l.apply=s})(yl||(yl={}));var Tg=Symbol(),VO=Symbol(),tu=Symbol(),vi=class{reportOp(t,e,r=[]){let o=this;if(e===null)return;o._current=e.data;let i=r;for(;!(o instanceof eu);){let a=o._path,s=o._current;if(a!==""&&i.splice(0,0,a),o=o._parent,o===null)return;o.update(a,s)}o.push(i,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[tu];r&&r(),delete this._children[t]}}}},Sp=class extends vi{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,_a.runOp(this._current,t),t.path)}},wp=class extends vi{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,be.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},Mg={get(n,t){if(t===tu)return()=>{n._parent=null};if(t===Tg)return n._current;if(t===VO)return n;let{_current:e,_children:r}=n;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let o=r===void 0?void 0:r[t];if(o!==void 0)return o;let i=e[t],a=ru(n,t,i);return a!==i?(r===void 0&&(r={},n._children=r),r[t]=a,a):i},has(n,t){return t in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,t){let e=n._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},zO={...Mg,set(n,t,e){let r={type:0,props:{[t]:At(e)??e}};return n.deleteChildren(t),n.runOp(r),!0},deleteProperty(n,t){let e={type:0,props:{[t]:void 0}};return n.deleteChildren(t),n.runOp(e),!0}},GO={...Mg,set(n,t,e){return e===void 0?this.deleteProperty(n,t):(n.deleteChildren(t),n.runOp({type:1,id:t,data:e})),!0},deleteProperty(n,t){return n.runOp({type:2,id:t}),!0}},Ca=class extends vi{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[tu]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let i=e.get(t)?.data,a=ru(this,t,i);return a!==i?(r===void 0&&(r={},this._children=r),r[t]=a,a):i}add(t,e,r,o,i){this.runOp({type:7,parent:t,fi:e,id:r,data:o,children:i})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.add(t,o[i],a.id,a.data,a.children)}}insertBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.add(t,o[i],a.id,a.data,a.children)}}moveAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.move(t,o[i],a)}}moveBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.move(t,o[i],a)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},Ta=class extends vi{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[tu]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id,i=this._current[r].fi;t(this.data(this._current[r].id),o,i)}}find(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id;if(t(this.data(o),o))return this.get(o)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let i=e.get(t)?.data,a=ru(this,t,i);return a!==i?(r===void 0&&(r={},this._children=r),r[t]=a,a):i}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(r[o],i.id,i.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(r[o],i.id,i.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(r[o],i)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(r[o],i)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function vp(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&St.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push({...t,path:e})}var eu=class extends vi{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,o){vp(this.ts,e,t),vp(this.actual,r,t),vp(this.reverse,o,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function ru(n,t,e){return e instanceof ut?new Ca(n,t,e):e instanceof we?new Ta(n,t,e):e instanceof be?new Proxy(new wp(n,t,e),GO):e!==null&&typeof e=="object"?Aa(e)?e:new Proxy(new Sp(n,t,e),zO):e}function Ap(n){let t=new eu(n);return[ru(t,"",n),t]}function Dn(n,t){let[e,r]=Ap(n);return t(e),r.result()}function At(n){return n instanceof Ca||n instanceof Ta?n._current:n!==null&&typeof n=="object"?n[Tg]:n}var St;(o=>{function n(i,a){if(a.length===i.length)for(var s=0;s<i.length;){if(i[s]!==a[s])return!1;s+=1}else return!1;return!0}o.equal=n;function t(i,a,s){let l=r(s,i);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...a};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return a}o.removeOverridden=t;function e(i,a){if((i instanceof ut||i instanceof Ca)&&typeof a=="string")return i.data(a);if((i instanceof we||i instanceof Ta)&&typeof a=="string")return i.data(a);if(typeof a=="number"&&Array.isArray(i))return i[a];if(typeof a=="string"&&typeof i=="object"&&i!==null)return i[a]}o.zoomOnce=e;function r(i,a,s=0){for(;s<a.length&&i!==void 0;)i=e(i,a[s]),s+=1;return i}o.zoom=r})(St||(St={}));function Ig(n,t){let e=[];if(t.length===n.length)for(var r=0;r<n.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}function ke(n,t){let e=[];if(t.length<=n.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}var ou=class{},gl=class extends ou{constructor(e){super();this.id=e}},xl=class extends ou{constructor(e){super();this.data=e}};var Pp;try{Pp=new TextDecoder}catch{}var de,Bn,G=0;var zg=[],Op=zg,Cp=0,Or={},Je,En,Yr=0,No=0,kr,nn,vr=[],rt,Ng={useRecords:!1,mapsAsObjects:!0},bl=class{},Mp=new bl;Mp.name="MessagePack 0xC1";var Ma=!1,Do=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(de)return Ug(()=>(iu(),this?this.unpack(t,e):Do.prototype.unpack.call(Ng,t,e)));Bn=e>-1?e:t.length,G=0,Cp=0,No=0,En=null,Op=zg,kr=null,de=t;try{rt=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw de=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Do){if(Or=this,this.structures)return Je=this.structures,nu();(!Je||Je.length>0)&&(Je=[])}else Or=Ng,(!Je||Je.length>0)&&(Je=[]);return nu()}unpackMultiple(t,e){let r,o=0;try{Ma=!0;let i=t.length,a=this?this.unpack(t,i):lu.unpack(t,i);if(e){for(e(a);G<i;)if(o=G,e(nu())===!1)return}else{for(r=[a];G<i;)o=G,r.push(nu());return r}}catch(i){throw i.lastPosition=o,i.values=r,i}finally{Ma=!1,iu()}}_mergeStructures(t,e){t=t||[];for(let r=0,o=t.length;r<o;r++){let i=t[r];i&&(i.isShared=!0,r>=32&&(i.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let o=t[r],i=e[r];i&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[r]=o),t[r]=i)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function nu(){try{if(!Or.trusted&&!Ma){let t=Je.sharedLength||0;t<Je.length&&(Je.length=t)}let n=It();if(G==Bn)Je.restoreStructures&&Dg(),Je=null,de=null,nn&&(nn=null);else if(G>Bn){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Ma)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Je.restoreStructures&&Dg(),iu(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Dg(){for(let n in Je.restoreStructures)Je[n]=Je.restoreStructures[n];Je.restoreStructures=null}function It(){let n=de[G++];if(n<160)if(n<128){if(n<64)return n;{let t=Je[n&63]||Or.getStructures&&Gg()[n&63];return t?(t.read||(t.read=Ip(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,Or.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Fg()]=It();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(It(),It());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=It();return t}else if(n<192){let t=n-160;if(No>=G)return En.slice(G-Yr,(G+=t)-Yr);if(No==0&&Bn<140){let e=t<16?Np(t):kg(t);if(e!=null)return e}return Tp(t)}else{let t;switch(n){case 192:return null;case 193:return kr?(t=It(),t>0?kr[1].slice(kr.position1,kr.position1+=t):kr[0].slice(kr.position0,kr.position0-=t)):Mp;case 194:return!1;case 195:return!0;case 196:return _p(de[G++]);case 197:return t=rt.getUint16(G),G+=2,_p(t);case 198:return t=rt.getUint32(G),G+=4,_p(t);case 199:return Si(de[G++]);case 200:return t=rt.getUint16(G),G+=2,Si(t);case 201:return t=rt.getUint32(G),G+=4,Si(t);case 202:if(t=rt.getFloat32(G),Or.useFloat32>2){let e=su[(de[G]&127)<<1|de[G+1]>>7];return G+=4,(e*t+(t>0?.5:-.5)>>0)/e}return G+=4,t;case 203:return t=rt.getFloat64(G),G+=8,t;case 204:return de[G++];case 205:return t=rt.getUint16(G),G+=2,t;case 206:return t=rt.getUint32(G),G+=4,t;case 207:return Or.int64AsNumber?(t=rt.getUint32(G)*4294967296,t+=rt.getUint32(G+4)):t=rt.getBigUint64(G),G+=8,t;case 208:return rt.getInt8(G++);case 209:return t=rt.getInt16(G),G+=2,t;case 210:return t=rt.getInt32(G),G+=4,t;case 211:return Or.int64AsNumber?(t=rt.getInt32(G)*4294967296,t+=rt.getUint32(G+4)):t=rt.getBigInt64(G),G+=8,t;case 212:if(t=de[G++],t==114)return Vg(de[G++]&63);{let e=vr[t];if(e)return e.read?(G++,e.read(It())):e.noBuffer?(G++,e()):e(de.subarray(G,++G));throw new Error("Unknown extension "+t)}case 213:return t=de[G],t==114?(G++,Vg(de[G++]&63,de[G++])):Si(2);case 214:return Si(4);case 215:return Si(8);case 216:return Si(16);case 217:return t=de[G++],No>=G?En.slice(G-Yr,(G+=t)-Yr):FO(t);case 218:return t=rt.getUint16(G),G+=2,No>=G?En.slice(G-Yr,(G+=t)-Yr):jO(t);case 219:return t=rt.getUint32(G),G+=4,No>=G?En.slice(G-Yr,(G+=t)-Yr):UO(t);case 220:return t=rt.getUint16(G),G+=2,Bg(t);case 221:return t=rt.getUint32(G),G+=4,Bg(t);case 222:return t=rt.getUint16(G),G+=2,Lg(t);case 223:return t=rt.getUint32(G),G+=4,Lg(t);default:if(n>=224)return n-256;if(n===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+n)}}}var kO=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Ip(n,t){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>kO.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(It);return n.highByte===0&&(n.read=Eg(t,n.read)),o()}let r={};for(let o=0,i=n.length;o<i;o++){let a=n[o];r[a]=It()}return r}return e.count=0,n.highByte===0?Eg(t,e):e}var Eg=(n,t)=>function(){let e=de[G++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),o=Je[r]||Gg()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=Ip(o,n)),o.read()};function Gg(){let n=Ug(()=>(de=null,Or.getStructures()));return Je=Or._mergeStructures(n,Je)}var Tp=au,FO=au,jO=au,UO=au;function au(n){let t;if(n<16&&(t=Np(n)))return t;if(n>64&&Pp)return Pp.decode(de.subarray(G,G+=n));let e=G+n,r=[];for(t="";G<e;){let o=de[G++];if((o&128)===0)r.push(o);else if((o&224)===192){let i=de[G++]&63;r.push((o&31)<<6|i)}else if((o&240)===224){let i=de[G++]&63,a=de[G++]&63;r.push((o&31)<<12|i<<6|a)}else if((o&248)===240){let i=de[G++]&63,a=de[G++]&63,s=de[G++]&63,l=(o&7)<<18|i<<12|a<<6|s;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(o);r.length>=4096&&(t+=Jt.apply(String,r),r.length=0)}return r.length>0&&(t+=Jt.apply(String,r)),t}function Bg(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=It();return t}function Lg(n){if(Or.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Fg()]=It();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(It(),It());return t}}var Jt=String.fromCharCode;function kg(n){let t=G,e=new Array(n);for(let r=0;r<n;r++){let o=de[G++];if((o&128)>0){G=t;return}e[r]=o}return Jt.apply(String,e)}function Np(n){if(n<4)if(n<2){if(n===0)return"";{let t=de[G++];if((t&128)>1){G-=1;return}return Jt(t)}}else{let t=de[G++],e=de[G++];if((t&128)>0||(e&128)>0){G-=2;return}if(n<3)return Jt(t,e);let r=de[G++];if((r&128)>0){G-=3;return}return Jt(t,e,r)}else{let t=de[G++],e=de[G++],r=de[G++],o=de[G++];if((t&128)>0||(e&128)>0||(r&128)>0||(o&128)>0){G-=4;return}if(n<6){if(n===4)return Jt(t,e,r,o);{let i=de[G++];if((i&128)>0){G-=5;return}return Jt(t,e,r,o,i)}}else if(n<8){let i=de[G++],a=de[G++];if((i&128)>0||(a&128)>0){G-=6;return}if(n<7)return Jt(t,e,r,o,i,a);let s=de[G++];if((s&128)>0){G-=7;return}return Jt(t,e,r,o,i,a,s)}else{let i=de[G++],a=de[G++],s=de[G++],l=de[G++];if((i&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){G-=8;return}if(n<10){if(n===8)return Jt(t,e,r,o,i,a,s,l);{let u=de[G++];if((u&128)>0){G-=9;return}return Jt(t,e,r,o,i,a,s,l,u)}}else if(n<12){let u=de[G++],c=de[G++];if((u&128)>0||(c&128)>0){G-=10;return}if(n<11)return Jt(t,e,r,o,i,a,s,l,u,c);let d=de[G++];if((d&128)>0){G-=11;return}return Jt(t,e,r,o,i,a,s,l,u,c,d)}else{let u=de[G++],c=de[G++],d=de[G++],p=de[G++];if((u&128)>0||(c&128)>0||(d&128)>0||(p&128)>0){G-=12;return}if(n<14){if(n===12)return Jt(t,e,r,o,i,a,s,l,u,c,d,p);{let f=de[G++];if((f&128)>0){G-=13;return}return Jt(t,e,r,o,i,a,s,l,u,c,d,p,f)}}else{let f=de[G++],h=de[G++];if((f&128)>0||(h&128)>0){G-=14;return}if(n<15)return Jt(t,e,r,o,i,a,s,l,u,c,d,p,f,h);let m=de[G++];if((m&128)>0){G-=15;return}return Jt(t,e,r,o,i,a,s,l,u,c,d,p,f,h,m)}}}}}function _p(n){return Or.copyBuffers?Uint8Array.prototype.slice.call(de,G,G+=n):de.subarray(G,G+=n)}function Si(n){let t=de[G++];if(vr[t])return vr[t](de.subarray(G,G+=n));throw new Error("Unknown extension type "+t)}var Rg=new Array(4096);function Fg(){let n=de[G++];if(n>=160&&n<192){if(n=n-160,No>=G)return En.slice(G-Yr,(G+=n)-Yr);if(!(No==0&&Bn<180))return Tp(n)}else return G--,It();let t=(n<<5^(n>1?rt.getUint16(G):n>0?de[G]:0))&4095,e=Rg[t],r=G,o=G+n-3,i,a=0;if(e&&e.bytes==n){for(;r<o;){if(i=rt.getUint32(r),i!=e[a++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(i=de[r++],i!=e[a++]){r=1879048192;break}if(r===o)return G=r,e.string;o-=3,r=G}for(e=[],Rg[t]=e,e.bytes=n;r<o;)i=rt.getUint32(r),e.push(i),r+=4;for(o+=3;r<o;)i=de[r++],e.push(i);let s=n<16?Np(n):kg(n);return s!=null?e.string=s:e.string=Tp(n)}var Vg=(n,t)=>{var e=It();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let o=Je[n];return o&&o.isShared&&((Je.restoreStructures||(Je.restoreStructures=[]))[n]=o),Je[n]=e,e.read=Ip(e,r),e.read()},jg=typeof self=="object"?self:global;vr[0]=()=>{};vr[0].noBuffer=!0;vr[101]=()=>{let n=It();return(jg[n[0]]||Error)(n[1])};vr[105]=n=>{let t=rt.getUint32(G-4);nn||(nn=new Map);let e=de[G],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let o={target:r};nn.set(t,o);let i=It();return o.used?Object.assign(r,i):(o.target=i,i)};vr[112]=n=>{let t=rt.getUint32(G-4),e=nn.get(t);return e.used=!0,e.target};vr[115]=()=>new Set(It());var Dp=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");vr[116]=n=>{let t=n[0],e=Dp[t];if(!e)throw new Error("Could not find typed array for code "+t);return new jg[e](Uint8Array.prototype.slice.call(n,1).buffer)};vr[120]=()=>{let n=It();return new RegExp(n[0],n[1])};vr[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=G;G+=t-4,kr=[It(),It()],kr.position0=0,kr.position1=0;let r=G;G=e;try{return It()}finally{G=r}};vr[255]=n=>n.length==4?new Date((n[0]*16777216+(n[1]<<16)+(n[2]<<8)+n[3])*1e3):n.length==8?new Date(((n[0]<<22)+(n[1]<<14)+(n[2]<<6)+(n[3]>>2))/1e6+((n[3]&3)*4294967296+n[4]*16777216+(n[5]<<16)+(n[6]<<8)+n[7])*1e3):n.length==12?new Date(((n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3])/1e6+((n[4]&128?-281474976710656:0)+n[6]*1099511627776+n[7]*4294967296+n[8]*16777216+(n[9]<<16)+(n[10]<<8)+n[11])*1e3):new Date("invalid");function Ug(n){let t=Bn,e=G,r=Cp,o=Yr,i=No,a=En,s=Op,l=nn,u=kr,c=new Uint8Array(de.slice(0,Bn)),d=Je,p=Je.slice(0,Je.length),f=Or,h=Ma,m=n();return Bn=t,G=e,Cp=r,Yr=o,No=i,En=a,Op=s,nn=l,kr=u,de=c,Ma=h,Je=d,Je.splice(0,Je.length,...p),Or=f,rt=new DataView(de.buffer,de.byteOffset,de.byteLength),m}function iu(){de=null,nn=null,Je=null}function Hg(n){n.unpack?vr[n.type]=n.unpack:vr[n.type]=n}var su=new Array(147);for(let n=0;n<256;n++)su[n]=+("1e"+Math.floor(45.15-n*.30103));var lu=new Do({useRecords:!1}),HO=lu.unpack,qO=lu.unpackMultiple,WO=lu.unpack,cu={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},$O=new Float32Array(1),SG=new Uint8Array($O.buffer,0,4);var uu;try{uu=new TextEncoder}catch{}var du,Bp,pu=typeof Buffer<"u",Ep=pu?Buffer.allocUnsafeSlow:Uint8Array,Yg=pu?Buffer:Uint8Array,qg=pu?4294967296:2144337920,Z,Lt,j=0,Eo,Bo=null,YO=/[\u0080-\uFFFF]/,vl=Symbol("record-id"),wi=class extends Do{constructor(t){super(t),this.offset=0;let e,r,o,i,a,s,l=0,u=Yg.prototype.utf8Write?function(x,D,N){return Z.utf8Write(x,D,N)}:uu&&uu.encodeInto?function(x,D){return uu.encodeInto(x,Z.subarray(D)).written}:!1,c=this;t||(t={});let d=t&&t.sequential,p=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=p?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let h=t.maxOwnStructures;h==null&&(h=p?32:64),d&&!t.saveStructures&&(this.structures=[]);let m=f>32||h+f>64,y=f+64,g=f+h+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let b=[],w=0,_=0;this.pack=this.encode=function(x,D){if(Z||(Z=new Ep(8192),Lt=new DataView(Z.buffer,0,8192),j=0),Eo=Z.length-10,Eo-j<2048?(Z=new Ep(Z.length),Lt=new DataView(Z.buffer,0,Z.length),Eo=Z.length-10,j=0):j=j+7&2147483640,r=j,s=c.structuredClone?new Map:null,c.bundleStrings?(Bo=["",""],Z[j++]=214,Z[j++]=98,Bo.position=j-r,j+=4):Bo=null,o=c.structures,o){o.uninitialized&&(o=c._mergeStructures(c.getStructures()));let N=o.sharedLength||0;if(N>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+o.sharedLength);if(!o.transitions){o.transitions=Object.create(null);for(let T=0;T<N;T++){let I=o[T];if(!I)continue;let E,B=o.transitions;for(let R=0,k=I.length;R<k;R++){let V=I[R];E=B[V],E||(E=B[V]=Object.create(null)),B=E}B[vl]=T+64}l=N}d||(o.nextId=N+64)}i&&(i=!1),a=o||[];try{if(S(x),Bo){Lt.setUint32(Bo.position+r,j-Bo.position-r);let N=Bo;Bo=null,S(N[0]),S(N[1])}if(c.offset=j,s&&s.idsToInsert){j+=s.idsToInsert.length*6,j>Eo&&O(j),c.offset=j;let N=QO(Z.subarray(r,j),s.idsToInsert);return s=null,N}return D&Qg?(Z.start=r,Z.end=j,Z):Z.subarray(r,j)}finally{if(o){if(_<10&&_++,w>1e4)o.transitions=null,_=0,w=0,b.length>0&&(b=[]);else if(b.length>0&&!d){for(let N=0,T=b.length;N<T;N++)b[N][vl]=0;b=[]}if(i&&c.saveStructures){let N=o.sharedLength||f;o.length>N&&(o=o.slice(0,N));let T=Z.subarray(r,j);return c.saveStructures(o,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(x)):(l=N,T)}}D&oC&&(j=r)}};let S=x=>{j>Eo&&(Z=O(j));var D=typeof x,N;if(D==="string"){let T=x.length;if(Bo&&T>=8&&T<4096){let B=YO.test(x);Bo[B?0:1]+=x,Z[j++]=193,S(B?-T:T);return}let I;T<32?I=1:T<256?I=2:T<65536?I=3:I=5;let E=T*3;if(j+E>Eo&&(Z=O(j+E)),T<64||!u){let B,R,k,V=j+I;for(B=0;B<T;B++)R=x.charCodeAt(B),R<128?Z[V++]=R:R<2048?(Z[V++]=R>>6|192,Z[V++]=R&63|128):(R&64512)===55296&&((k=x.charCodeAt(B+1))&64512)===56320?(R=65536+((R&1023)<<10)+(k&1023),B++,Z[V++]=R>>18|240,Z[V++]=R>>12&63|128,Z[V++]=R>>6&63|128,Z[V++]=R&63|128):(Z[V++]=R>>12|224,Z[V++]=R>>6&63|128,Z[V++]=R&63|128);N=V-j-I}else N=u(x,j+I,E);N<32?Z[j++]=160|N:N<256?(I<2&&Z.copyWithin(j+2,j+1,j+1+N),Z[j++]=217,Z[j++]=N):N<65536?(I<3&&Z.copyWithin(j+3,j+2,j+2+N),Z[j++]=218,Z[j++]=N>>8,Z[j++]=N&255):(I<5&&Z.copyWithin(j+5,j+3,j+3+N),Z[j++]=219,Lt.setUint32(j,N),j+=4),j+=N}else if(D==="number")if(x>>>0===x)x<64?Z[j++]=x:x<256?(Z[j++]=204,Z[j++]=x):x<65536?(Z[j++]=205,Z[j++]=x>>8,Z[j++]=x&255):(Z[j++]=206,Lt.setUint32(j,x),j+=4);else if(x>>0===x)x>=-32?Z[j++]=256+x:x>=-128?(Z[j++]=208,Z[j++]=x+256):x>=-32768?(Z[j++]=209,Lt.setInt16(j,x),j+=2):(Z[j++]=210,Lt.setInt32(j,x),j+=4);else{let T;if((T=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){Z[j++]=202,Lt.setFloat32(j,x);let I;if(T<4||(I=x*su[(Z[j]&127)<<1|Z[j+1]>>7])>>0===I){j+=4;return}else j--}Z[j++]=203,Lt.setFloat64(j,x),j+=8}else if(D==="object")if(!x)Z[j++]=192;else{if(s){let I=s.get(x);if(I){if(!I.id){let E=s.idsToInsert||(s.idsToInsert=[]);I.id=E.push(I)}Z[j++]=214,Z[j++]=112,Lt.setUint32(j,I.id),j+=4;return}else s.set(x,{offset:j-r})}let T=x.constructor;if(T===Object)P(x,!0);else if(T===Array){N=x.length,N<16?Z[j++]=144|N:N<65536?(Z[j++]=220,Z[j++]=N>>8,Z[j++]=N&255):(Z[j++]=221,Lt.setUint32(j,N),j+=4);for(let I=0;I<N;I++)S(x[I])}else if(T===Map){N=x.size,N<16?Z[j++]=128|N:N<65536?(Z[j++]=222,Z[j++]=N>>8,Z[j++]=N&255):(Z[j++]=223,Lt.setUint32(j,N),j+=4);for(let[I,E]of x)S(I),S(E)}else{for(let I=0,E=du.length;I<E;I++){let B=Bp[I];if(x instanceof B){let R=du[I];if(R.write){R.type&&(Z[j++]=212,Z[j++]=R.type,Z[j++]=0),S(R.write.call(this,x));return}let k=Z,V=Lt,q=j;Z=null;let F;try{F=R.pack.call(this,x,U=>(Z=k,k=null,j+=U,j>Eo&&O(j),{target:Z,targetView:Lt,position:j-U}),S)}finally{k&&(Z=k,Lt=V,j=q,Eo=Z.length-10)}F&&(F.length+j>Eo&&O(F.length+j),j=XO(F,Z,j,R.type));return}}P(x,!x.hasOwnProperty)}}else if(D==="boolean")Z[j++]=x?195:194;else if(D==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))Z[j++]=211,Lt.setBigInt64(j,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)Z[j++]=207,Lt.setBigUint64(j,x);else if(this.largeBigIntToFloat)Z[j++]=203,Lt.setFloat64(j,Number(x));else throw new RangeError(x+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");j+=8}else if(D==="undefined")this.encodeUndefinedAsNil?Z[j++]=192:(Z[j++]=212,Z[j++]=0,Z[j++]=0);else if(D==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+D)},P=this.useRecords===!1?this.variableMapSize?x=>{let D=Object.keys(x),N=D.length;N<16?Z[j++]=128|N:N<65536?(Z[j++]=222,Z[j++]=N>>8,Z[j++]=N&255):(Z[j++]=223,Lt.setUint32(j,N),j+=4);let T;for(let I=0;I<N;I++)S(T=D[I]),S(x[T])}:(x,D)=>{Z[j++]=222;let N=j-r;j+=2;let T=0;for(let I in x)(D||x.hasOwnProperty(I))&&(S(I),S(x[I]),T++);Z[N+++r]=T>>8,Z[N+r]=T&255}:x=>{let D=Object.keys(x),N,T=a.transitions||(a.transitions=Object.create(null)),I=0;for(let B=0,R=D.length;B<R;B++){let k=D[B];N=T[k],N||(N=T[k]=Object.create(null),I++),T=N}let E=T[vl];if(E)E>=96&&m?(Z[j++]=((E-=96)&31)+96,Z[j++]=E>>5):Z[j++]=E;else{E=a.nextId,E||(E=64),E<y&&this.shouldShareStructure&&!this.shouldShareStructure(D)?(E=a.nextOwnId,E<g||(E=y),a.nextOwnId=E+1):(E>=g&&(E=y),a.nextId=E+1);let B=D.highByte=E>=96&&m?E-96>>5:-1;T[vl]=E,a[E-64]=D,E<y?(D.isShared=!0,a.sharedLength=E-63,i=!0,B>=0?(Z[j++]=(E&31)+96,Z[j++]=B):Z[j++]=E):(B>=0?(Z[j++]=213,Z[j++]=114,Z[j++]=(E&31)+96,Z[j++]=B):(Z[j++]=212,Z[j++]=114,Z[j++]=E),I&&(w+=_*I),b.length>=h&&(b.shift()[vl]=0),b.push(T),S(D))}for(let B=0,R=D.length;B<R;B++)S(x[D[B]])},O=x=>{let D;if(x>16777216){if(x-r>qg)throw new Error("Packed buffer would be larger than maximum buffer size");D=Math.min(qg,Math.round(Math.max((x-r)*(x>67108864?1.25:2),4194304)/4096)*4096)}else D=(Math.max(x-r<<2,Z.length-1)>>12)+1<<12;let N=new Ep(D);return Lt=new DataView(N.buffer,0,D),Z.copy?Z.copy(N,0,r,x):N.set(Z.slice(r,x)),j-=r,r=0,Eo=N.length-10,Z=N}}useBuffer(t){Z=t,Lt=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),j=0}};Bp=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,bl];du=[{pack(n,t,e){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:i,position:a}=t(6);o[a++]=214,o[a++]=255,i.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:o,targetView:i,position:a}=t(10);o[a++]=215,o[a++]=255,i.setUint32(a,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:o,targetView:i,position:a}=t(3);o[a++]=212,o[a++]=255,o[a++]=255}else{let{target:o,targetView:i,position:a}=t(15);o[a++]=199,o[a++]=12,o[a++]=255,i.setUint32(a,n.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(n,t,e){let r=Array.from(n),{target:o,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(o[i++]=212,o[i++]=115,o[i++]=0),e(r)}},{pack(n,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=101,r[o++]=0),e([n.name,n.message])}},{pack(n,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=120,r[o++]=0),e([n.source,n.flags])}},{pack(n,t){this.structuredClone?Wg(n,16,t):$g(pu?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==Yg&&this.structuredClone?Wg(n,Dp.indexOf(e.name),t):$g(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function Wg(n,t,e,r){let o=n.byteLength;if(o+1<256){var{target:i,position:a}=e(4+o);i[a++]=199,i[a++]=o+1}else if(o+1<65536){var{target:i,position:a}=e(5+o);i[a++]=200,i[a++]=o+1>>8,i[a++]=o+1&255}else{var{target:i,position:a,targetView:s}=e(7+o);i[a++]=201,s.setUint32(a,o+1),a+=4}i[a++]=116,i[a++]=t,i.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),a)}function $g(n,t){let e=n.byteLength;var r,o;if(e<256){var{target:r,position:o}=t(e+2);r[o++]=196,r[o++]=e}else if(e<65536){var{target:r,position:o}=t(e+3);r[o++]=197,r[o++]=e>>8,r[o++]=e&255}else{var{target:r,position:o,targetView:i}=t(e+5);r[o++]=198,i.setUint32(o,e),o+=4}r.set(n,o)}function XO(n,t,e,r){let o=n.length;switch(o){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:o<256?(t[e++]=199,t[e++]=o):o<65536?(t[e++]=200,t[e++]=o>>8,t[e++]=o&255):(t[e++]=201,t[e++]=o>>24,t[e++]=o>>16&255,t[e++]=o>>8&255,t[e++]=o&255)}return t[e++]=r,t.set(n,e),e+=o,e}function QO(n,t){let e,r=t.length*6,o=n.length-r;for(t.sort((i,a)=>i.offset>a.offset?1:-1);e=t.pop();){let i=e.offset,a=e.id;n.copyWithin(i+r,i,o),r-=6;let s=i+r;n[s++]=214,n[s++]=105,n[s++]=a>>24,n[s++]=a>>16&255,n[s++]=a>>8&255,n[s++]=a&255,o=i}return n}function Ln(n){if(n.Class){if(!n.pack&&!n.write)throw new Error("Extension has no pack or write function");if(n.pack&&!n.type)throw new Error("Extension has no type (numeric code to identify the extension)");Bp.unshift(n.Class),du.unshift(n)}Hg(n)}var Xg=new wi({useRecords:!1}),KO=Xg.pack,ZO=Xg.pack;var{NEVER:JO,ALWAYS:eC,DECIMAL_ROUND:tC,DECIMAL_FIT:rC}=cu,Qg=512,oC=1024;var Kg=new wi({structuredClone:!0});Ln({Class:be.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,be.prototype),n}});Ln({Class:we.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,we.prototype),n}});Ln({Class:ut.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,ut.prototype),n}});Ln({Class:gl.prototype.constructor,type:4,write(n){return n.id},read(n){return new gl(n)}});Ln({Class:xl.prototype.constructor,type:5,write(n){return n.data},read(n){return new xl(n)}});Ln({Class:dt.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,dt.prototype),n}});function nC(n){var t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){let r=n[e];t=(t<<5)-t+r,t=t&t}return t}function Lp(n){if(Aa(n))return n;if(Array.isArray(n))return n.map(Lp);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=Lp(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var fu;(r=>{function n(o){return Kg.pack(o)}r.serialize=n;function t(o){return Kg.unpack(o)}r.deserialize=t;function e(o){return nC(n(Lp(o))).toString()}r.checksum=e})(fu||(fu={}));var zn="personal camera",Gn="a218fcc3-276b-49b9-b485-49037fd14f5f",r0=2960946,Rt=5526619;var Sl;(d=>{function n(p,f){return p[0]===f[0]&&p[1]===f[1]}d.isEqual=n;function t(p,f,h){return[p[0]+(f[0]-p[0])*h,p[1]+(f[1]-p[1])*h]}d.lerp=t;function e(p,f){return[p[0]+f[0],p[1]+f[1]]}d.add=e;function r(p,f){return[p[0]-f[0],p[1]-f[1]]}d.sub=r;function o(p,f){return Math.pow(f[0]-p[0],2)+Math.pow(f[1]-p[1],2)}d.distanceSquared=o;function i(p,f){return Math.sqrt(o(p,f))}d.distance=i;function a(p,f){return p[0]*f[0]+p[1]*f[1]}d.dot=a;function s(p,f){return[p[0]*f,p[1]*f]}d.scalarMultiply=s;function l(p,f,h){let m=d.sub(f,p),y=d.sub(h,p),g=d.dot(m,y)/d.dot(m,m),b=d.scalarMultiply(m,g);return d.add(p,b)}d.projectionOnto=l;function u(p,f,h){return i(p,l(p,f,h))}d.projectionOntoDistance=u;function c(p,f){return[(p[0]+f[0])*.5,(p[1]+f[1])*.5]}d.center=c})(Sl||(Sl={}));var Rn;(s=>{function n(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}s.isEqual=n;function t(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]}s.add=t;function e(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]}s.sub=e;function r(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}s.div=r;function o(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}s.mul=o;function i(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])}s.dist=i;function a(l,u,c){return[l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c]}s.lerp=a})(Rn||(Rn={}));var Zg;(e=>{function n(r,o){return r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]}e.isEqual=n;function t(r,o,i){return[r[0]+(o[0]-r[0])*i,r[1]+(o[1]-r[1])*i,r[2]+(o[2]-r[2])*i,r[3]+(o[3]-r[3])*i]}e.lerp=t})(Zg||(Zg={}));var Vn;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(i,a){for(let s=0;s<16;s++)if(i[s]!==a[s])return!1;return!0}o.isEqual=t;function e(i){return i??o.identity}o.simplify=e;function r(i,a){let s=a.slice(0);for(var l=0,u=a.length;l<u;l+=3){let c=i[3]*a[l]+i[7]*a[l+1]+i[11]*a[l+2]+i[15];s[l]=(i[0]*a[l]+i[4]*a[l+1]+i[8]*a[l+2]+i[12])/c,s[l+1]=(i[1]*a[l]+i[5]*a[l+1]+i[9]*a[l+2]+i[13])/c,s[l+2]=(i[2]*a[l]+i[6]*a[l+1]+i[10]*a[l+2]+i[14])/c}return s}o.applyMatrix4=r})(Vn||(Vn={}));var er;(c=>{function n(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}c.isRGB=n,c.white={r:1,g:1,b:1},c.red={r:1,g:0,b:0},c.black={r:0,g:0,b:0};function o(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}c.toRgb255a1=o;function i(d){return{r:d.r,g:d.g,b:d.b}}c.clone=i;function a(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}c.fromHex=a;function s(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}c.toHex=s;function l(d,p){return d.r===p.r&&d.g===p.g&&d.b===p.b}c.equals=l;function u(d,p,f){return{r:d.r+(p.r-d.r)*f,g:d.g+(p.g-d.g)*f,b:d.b+(p.b-d.b)*f}}c.lerp=u})(er||(er={}));var Be;(l=>{l.white={...er.white,a:1},l.transparent={...er.white,a:0};function e(u){return{r:u[0],g:u[1],b:u[2],a:u[3]}}l.from0to1=e;function r(u,c){return{...er.fromHex(u),a:c}}l.fromHexAndA=r;function o(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:u.a}}l.toRgb255a1=o;function i(u,c){return er.equals(u,c)&&u.a===c.a}l.equals=i;function a(u,c,d){return{r:u.r+(c.r-u.r)*d,g:u.g+(c.g-u.g)*d,b:u.b+(c.b-u.b)*d,a:u.a+(c.a-u.a)*d}}l.lerp=a;function s({r:u,g:c,b:d,a:p}=l.white){return`rgba(${u*255}, ${c*255}, ${d*255}, ${p})`}l.toStyle=s})(Be||(Be={}));var hu;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(hu||(hu={}));var Jg;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(Jg||(Jg={}));var e0;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(e0||(e0={}));var t0;(i=>(i.linear=[0,0,1,1],i.ease=[.25,.1,.25,1],i.easeIn=[.42,0,1,1],i.easeOut=[0,0,.58,1],i.easeInOut=[.42,0,.58,1]))(t0||(t0={}));function Rp(n){return typeof n=="string"&&n.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n):!1}var po;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(po||(po={}));var kn;(o=>{o.DefaultUp=[0,1,0],o.DefaultTargetOffset=1e3,o.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function r(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}o.getZoom=r})(kn||(kn={}));var Lo;(e=>{function n(r,o=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*o,0,0]},grid:{count:[2,2,2],size:r.map(i=>i*(1+o)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=n;function t(r,o){let i={...r};if(iC.forEach(a=>{Object.assign(i,{[a]:o[a]??r[a]})}),i.radial={...r.radial},o.radial){let a=r.radial,s=o.radial;aC.forEach(l=>{Object.assign(i.radial,{[l]:s[l]??a[l]})})}if(i.linear={...r.linear},o.linear){let a=r.linear,s=o.linear;sC.forEach(l=>{Object.assign(i.linear,{[l]:s[l]??a[l]})})}if(i.grid={...r.grid},o.grid){let a=r.grid,s=o.grid;lC.forEach(l=>{Object.assign(i.grid,{[l]:s[l]??a[l]})})}if(i.toObject={...r.toObject},o.toObject){let a=r.toObject,s=o.toObject;cC.forEach(l=>{Object.assign(i.toObject,{[l]:s[l]??a[l]})})}if(i.randomnessObject={...r.randomnessObject},o.randomnessObject){let a=r.randomnessObject,s=o.randomnessObject;uC.forEach(l=>{Object.assign(i.randomnessObject,{[l]:s[l]??a[l]})})}return i}e.merge=t})(Lo||(Lo={}));var mu;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(o,i){let a=[];o.count!==void 0&&a.push({type:0,path:i,props:{count:o.count}});for(let s of t){let l=o[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...i,s],props:l})}return a}r.toOps=e})(mu||(mu={}));var iC=["count"],aC=["radius","start","end","position","scale","rotation"],sC=["position","scale","rotation"],lC=["count","size"],cC=["count","position","scale","rotation"],uC=["strength","scale","rotation","position","movement","seed","freqScale"];var yu;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(yu||(yu={}));var gu;(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:Be.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Be.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:Be.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(gu||(gu={}));var Ia;(r=>(r.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},r.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},r.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:r.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeLoopDelayStart:"end",emitTimeDuration:1,...r.defaultCollisionData}))(Ia||(Ia={}));var Fn;(t=>t.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(Fn||(Fn={}));var Vp;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}e.equals=t})(Vp||(Vp={}));var zp;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,o){return r.flatShading===o.flatShading&&r.side===o.side&&r.wireframe===o.wireframe}e.equals=t})(zp||(zp={}));var xu;(t=>t.defaultData={...zp.defaultData,...Vp.defaultData})(xu||(xu={}));var o0;(t=>{function n(e,r){let o=[];if("material"in e){let i=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;i&&o.push(i)}else if("materials"in e)for(let i of e.materials){let a=typeof i=="string"?r.materials[i]??r.lib.materials[i]?.asset:i;a&&o.push(a)}return o}t.getMaterialData=n})(o0||(o0={}));var Na;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Na||(Na={}));var n0;(t=>{function n(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="particle"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=n})(n0||(n0={}));function a0(n){return n.type!=="displace"}var i0;(t=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=n})(i0||(i0={}));var s0=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],l0=["wrapping","image","video","name","minFilter"],kt;(o=>{function n(i,a){let{texture:s,...l}=a;if(Object.assign(i,l),s){let u=i.texture;u&&Object.assign(u,s)}}o.patch=n;function t(i,a){return i==="light"&&a?e(a):r(i)}o.defaultData=t;function e(i){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(i){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(i){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(i){case"texture":return{...a,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],minFilter:1008},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Na.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],minFilter:1008},crop:!1};case"color":return{...a,type:"color",color:er.fromHex(Rt)};case"depth":return{...a,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...er.fromHex(6710886),a:1},colorB:{...er.fromHex(6710886),a:1},colorC:{...er.fromHex(16777215),a:1},colorD:{...er.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:Be.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Be.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:Be.fromHexAndA(0,1),contourColor:Be.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],minFilter:1008}};case"transmission":return{...a,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...er.fromHex(0),a:1},colorB:{...er.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(kt||(kt={}));var sr;(u=>{function n(c){return!c.layers.some(p=>p.data.type==="texture"&&p.data.projection!==0||p.data.type==="depth"&&!p.data.isWorldSpace||p.data.type==="noise"||p.data.type==="displace")}u.isMergable=n;function t(c){let d="";return c.layers.forEach(p=>{Object.entries(p.data).forEach(([f,h])=>{d+=`${f}${h}`,Array.isArray(h)?h.forEach(m=>d+=`${m}`):typeof h=="object"?Object.values(h).forEach(m=>{typeof m=="number"?d+=`${m.toFixed(4)}`:d+=`${m}`}):d+=`${h}`})}),d}u.getHash=t;function e(){return{layers:new we}}u.defaultEmptyData=e;function r(c="layer1",d="layer2"){return i("phong",c,d)}u.defaultData=r;function o(c,d){return{...c,name:d}}u.withName=o;function i(c,d="layer1",p="layer2"){let f=new we;return f.push({fi:0,data:kt.defaultData("light",c),id:d}),f.push({fi:1,data:kt.defaultData("color"),id:p}),{layers:f}}u.defaultTwoLayerData=i;function a(c){let d=kt.defaultData("texture");c&&Object.assign(d.texture,{image:c});let p=new we;return p.push({fi:0,data:d,id:"layer1"}),p.push({fi:1,data:{...kt.defaultData("transmission"),alpha:1},id:"layer2"}),p.push({fi:2,data:{...kt.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:p}}u.defaultUIObjectMaterial=a;function s(c,d="phong",p="layer1",f="layer2"){let h=kt.defaultData("texture");Object.assign(h.texture,{image:c});let m=new we;return m.push({fi:0,data:h,id:p}),m.push({fi:1,data:kt.defaultData("light",d),id:f}),{layers:m}}u.defaultTwoLayerTextureData=s;function l(c,d="phong",p="layer1",f="layer2"){let h=kt.defaultData("video");Object.assign(h.texture,{video:c});let m=new we;return m.push({fi:0,data:h,id:p}),m.push({fi:1,data:kt.defaultData("light",d),id:f}),{layers:m}}u.defaultTwoLayerVideoTextureData=l})(sr||(sr={}));var Da;(t=>{function n(){return{points:new we,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(Da||(Da={}));var Ea;(t=>{function n(){return{points:new we,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=n})(Ea||(Ea={}));var Gp={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var bu;(t=>{function n(e,r){let o={...e};return dC.forEach(i=>{Object.assign(o,{[i]:r[i]??e[i]})}),o}t.merge=n})(bu||(bu={}));var vu={shape:Gp,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},dC=["depth","offset","angle","twist","startScale","endScale"];var wl;(e=>{function n(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=n;function t(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=t})(wl||(wl={}));var Su;(t=>{function n(e,r){let o={...e};return Object.assign(o,r),o.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(o.extrusion={...e.extrusion},Object.assign(o.extrusion,bu.merge(o.extrusion,r.extrusion))),o}t.merge=n})(Su||(Su={}));var jn;(t=>{function n(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="UIGeometry")return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:Ea.defaultData(),extrusion:vu};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Da.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}t.defaultData=n})(jn||(jn={}));var wu;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:er.white,near:.1,far:2e3})(wu||(wu={}));var Au;(e=>{let n={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...n,blendFunction:16,granularity:15},bloom:{...n,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...n,offset:[2,2]},vignette:{...n,darkness:1,offset:0},hueSaturation:{...n,hue:3,saturation:0},brightnessContrast:{...n,brightness:.25,contrast:0},depthOfField:{...n,focalLength:2,focusDistance:2,bokehScale:2},noise:{...n,blendFunction:16}}})(Au||(Au={}));var kp;(t=>t.defaultData={softShadowQuality:"low"})(kp||(kp={}));var Fp;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Fp||(Fp={}));var jp;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(jp||(jp={}));var Al;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Al||(Al={}));var Up;(t=>t.defaultData={playCamera:zn,gameControlObject:null})(Up||(Up={}));var _u;(t=>t.defaultData={backgroundColor:Be.fromHexAndA(r0,1),postprocessing:Au.defaultData,fog:wu.defaultData,globalPhysics:Al.defaultData,ambient:Fp.defaultData,ao:jp.defaultData,shadow:kp.defaultData,publish:Up.defaultData})(_u||(_u={}));var Pu;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(Pu||(Pu={}));var c0;(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(c0||(c0={}));var Ba;(o=>{o.identity={...hu.identity,hiddenMatrix:Vn.identity};function t(i){return{position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix}}o.fromObject=t;function e(i,a){return{position:a?.position||i.position,rotation:a?.rotation||i.rotation,scale:a?.scale||i.scale,hiddenMatrix:a?.hiddenMatrix||i.hiddenMatrix}}o.merge=e;function r(i,a){return _c({position:Rn.isEqual(i.position,a.position)?void 0:a.position,rotation:Rn.isEqual(i.rotation,a.rotation)?void 0:a.rotation,scale:Rn.isEqual(i.scale,a.scale)?null:a.scale,hiddenMatrix:Vn.isEqual(i.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=r})(Ba||(Ba={}));var Ht;(t=>t.defaultData={states:new we,events:new we,visible:!0,raycastLock:!1,physics:Fn.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Ba.identity,cloner:null})(Ht||(Ht={}));var Ou;(t=>t.defaultData={type:"Empty",...Ht.defaultData})(Ou||(Ou={}));var u0;(t=>t.defaultData={type:"ParticleCollider",...Pu.defaultData,...Ht.defaultData})(u0||(u0={}));var d0;(t=>t.defaultData={type:"Component",...Ht.defaultData})(d0||(d0={}));var p0;(t=>t.defaultData={type:"Particle",...Ht.defaultData,...Ia.defaultData})(p0||(p0={}));var Ai;(t=>t.defaultData={type:"Mesh",...Ht.defaultData,...xu.defaultData})(Ai||(Ai={}));var _i;(t=>t.defaultData={...Ht.defaultData,...Ba.identity,position:[0,0,kn.DefaultTargetOffset],...kn.defaultData})(_i||(_i={}));var Cu;(e=>{function n(r){return{...Ht.defaultData,...gu.defaultData(r)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Cu||(Cu={}));var La;(e=>{function n(r,o,i=0){for(;i<o.length;){let a=r?r[o[i]]:void 0;if(o.length===i+1)return a;if(a)r=a.descendants,i+=1;else return}}e.resolveWithDes=n;function t(r,o,i=0){let a=n(r,o,i);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=t})(La||(La={}));var Ro;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function r(a,s){return{...Ht.defaultData,...s,component:a,overrides:new dt,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=r;function o(a){let s=Ba.fromObject(a.data);return r(a.id,s)}i.fromComponentData=o})(Ro||(Ro={}));var an;(e=>{e.defaultData={type:"Page",...Ht.defaultData,physics:{...Fn.defaultData,fusedBody:!1},..._u.defaultData,camera:_i.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(an||(an={}));var Tu;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Vn.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Fn.defaultData,states:new we,events:new we,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...kn.defaultData},i.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},i.defaultMeshObject={name:"Rectangle",...Ht.defaultData,...Ai.defaultData,geometry:jn.defaultData("RectangleGeometry"),material:sr.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...Ht.defaultData,...Ai.defaultData,geometry:jn.defaultData("BooleanGeometry"),material:sr.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...Ht.defaultData,...Ai.defaultData,geometry:jn.defaultData("TextGeometry"),material:sr.defaultTwoLayerData("phong","layer1","layer2")}))(Tu||(Tu={}));var Pi;(o=>{function n(i,a){let s={name:a};return i.type==="Mesh"?(s.geometry={},"material"in i&&(s.material={layers:new dt}),"materials"in i&&(s.materials=i.materials.map(l=>({layers:new dt})))):po.is(i.type)&&(s.perspective={},s.orthographic={}),s}o.newEmpty=n;function t(i,a){if(a===void 0)return i;let s={...i};return"material"in s&&"material"in a&&a.material&&(s.material=Dn(s.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(a.material.layers)){let d=l.layers.data(u);d&&kt.patch(d,c)}}).data),s.materials&&a.materials&&(s.materials=Dn(s.materials,l=>{for(let u=0;u<s.materials.length;u++){let c=a.materials[u];if(typeof c!="string")for(let[d,p]of Object.entries(c.layers)){let f=l[u]?.layers?.data(d);f&&kt.patch(f,p)}}}).data),s}function e(i,a){let s,l=[],u={orthographic:0,perspective:0,geometry:0};function c(d,p){for(let[f,h]of Object.entries(p.layers)){let{texture:m,...y}=h;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...d,"layers",f,"texture"],props:m,type:0};l.push(g)}if(Object.keys(y).length>0){let g={path:[...d,"layers",f],props:y,type:0};l.push(g)}}}for(let[d,p]of Object.entries(a))if(d!=="name")if(d==="cloner")l.push(...mu.toOps(p,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:p.slide,offset:p.offset},type:0});else if(d==="material")c(["material"],p);else if(d==="materials")for(let[f,h]of Object.entries(p))c(["materials",f],h);else if(u[d]===0){if(d==="geometry"&&p.extrusion!==void 0){let f={path:[d,"extrusion"],props:p.extrusion,type:0};l.push(f),p={...p},delete p.extrusion}if(Object.keys(p).length>0){let f={path:[d],props:p,type:0};l.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[d]=p;return l}o.toOps=e;function r(i,a){if(a===void 0)return i;let s={...i};if(Object.assign(s,Ba.merge(s,a)),Object.assign(s,{pathSnapping:Object.assign({},s.pathSnapping,{slide:a.pathSnapping?.slide??s.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??s.pathSnapping?.offset??0})}),po.is(i.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let l=a;l.orthographic?.zoom!==void 0&&(s.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(s.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(s.targetOffset=l.targetOffset)}else if(i.type==="Mesh")"geometry"in a&&Object.assign(s,{geometry:Su.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=t(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Lo.merge(s.cloner,a.cloner)});else if(i.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Lo.merge(s.cloner,a.cloner)});else if(yu.is(i.type)){let l=a;l.intensity!==void 0&&(s.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?s.color=l.color:s.color=er.clone(l.color))}return s}o.patch=r})(Pi||(Pi={}));var Ra;(t=>t.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Ra||(Ra={}));var fo;(t=>t.defaultData={orbitControls:Ra.defaultData,playPage:Gn,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let o=0,i=0;return r<5?i=-30:r<10&&(i=30),r===0||r===10||r===5?o=30:(r===4||r===11||r===9)&&(o=-30),[120,[o,i],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(fo||(fo={}));var Hp;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Hp||(Hp={}));var qp;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(qp||(qp={}));var sn;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Hp.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:qp.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(sn||(sn={}));var f0;(e=>{function n(r){return r.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=n;function t(r,o,i){r.scene.objects.traverseFrom(o,(a,s)=>{if(s.type==="Instance"){let l=Va.getComponentData(r,s.component)?.data;l&&i(a,s,l.events)}else i(a,s,s.events)})}e.traverseModuleInstances=t})(f0||(f0={}));var ln;(l=>{l.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(u={withLight:!0,withSquare:!0}){let c=[],d=Tu.defaultMeshObject;u.withLight===!0&&c.push({fi:-1,data:Cu.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),u.withSquare===!0&&c.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:d,children:[]});let p=new ut;return p.push({fi:1,id:Gn,data:{...an.defaultData,name:"Scene 1"},children:c}),p}l.defaultData={objects:t(),publish:fo.defaultData,styles:sn.defaultData()},l.emptyDataWithoutPage=function(){return{objects:new ut,publish:fo.defaultData,styles:sn.defaultData()}},l.emptyDataWithPage=function(u){return{objects:t(u),publish:fo.defaultData,styles:sn.defaultData()}},l.emptyData=function(){return{objects:new ut,publish:{...fo.defaultData},styles:sn.defaultData()}};function a(u){return{...l.defaultData,objects:br(u,ut.prototype)}}l.withObjs=a;function s(u,c){return a([{id:u,data:c,children:[],fi:0}])}l.withObj=s})(ln||(ln={}));var za;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(za||(za={}));var Ga;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Ga||(Ga={}));var Mu;(i=>{function n(a){return a.textValue!==void 0}i.isTextValue=n;function t(a){return typeof a=="number"}i.isNumber=t;function e(a){return typeof a=="boolean"}i.isBoolean=e;function r(a){return n(a)?"string":e(a)?"boolean":"number"}i.typeOfVariable=r;function o(a){return i.isTextValue(a)?Array.isArray(a.textValue)?a.textValue.map(s=>s.toString().padStart(a.padding??2,"0")).join(a.deliminator??":")+(a.suffix!==void 0?" "+a.suffix:""):a.textValue.toString():i.isBoolean(a)?a?"True":"False":i.isNumber(a)?parseFloat(a.toFixed(3)).toString():a.toString()}i.getDisplayedValue=o})(Mu||(Mu={}));var Wp;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(Wp||(Wp={}));var h0;(t=>t.all=[...Wp.all,"components"])(h0||(h0={}));var m0;(t=>{function n(){return{images:new be,videos:new be,colors:new be,audios:new be,particles:new be,fonts:new be,materials:new be,components:new be,variables:new be}}t.defaultData=n})(m0||(m0={}));var cn;(t=>{function n(){return{images:new be,videos:new be,colors:new be,audios:new be,particles:new be,fonts:new be,materials:new be,components:new be,variables:new be}}t.defaultData=n})(cn||(cn={}));var Qr;(i=>{function n(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},br(a,be.prototype)}i.defaultColors=n;function t(a){let s={};return a?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Ga.emptyImage,name:"AI generated image"}),br(s,be.prototype)}i.defaultImages=t;function e(){return{catelogs:new be,materials:new be,images:new be,videos:new be,colors:new be,audios:new be,particles:new be,fonts:new be,variables:new we,lib:cn.defaultData()}}i.emptyData=e;function r(a){switch(a){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let s=[0,0,0];return{name:"Time",value:{textValue:s,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:s,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",a)}}i.defaultVariables=r;function o(a,s){if(s.format==="HH:mm:ss"){let l=Math.floor(a/3600),u=Math.floor((a-l*3600)/60),c=Math.round(a-l*3600-u*60);return{textValue:[l,u,c]}}else if(s.format==="mm:ss"){let l=Math.floor(a/60),u=Math.round(a-l*60);return{textValue:[l,u]}}else return s.format==="number"?a=Math.round(a):a=Math.round(a*1e3)/1e3,a}i.getFormattedTimerTime=o})(Qr||(Qr={}));var _l=require("three");var Iu;(t=>t.list=["idle","move","jump","run"])(Iu||(Iu={}));var Nu;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new we,move:new we,jump:new we,run:new we},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Be.fromHexAndA(3728051,1)}}))(Nu||(Nu={}));function y0(n){n.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,o=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],i=[0,1];for(let s=2;s<10;s++)o.push(o[1]),i.push(1);let a={...uo(At(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:o,steps:i,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...At(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function un(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function dn(n,t){n.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((o,i)=>{o===void 0&&(r.materials[i]=sr.defaultData(),o=r.materials[i]),typeof o!="string"&&t(o)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=sr.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=sr.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&Object.getPrototypeOf(o.material)!==dt.prototype&&t(o.material)})})}function pC(n){Object.assign(n.scene.publish,{orbitControls:{...Ra.defaultData,...At(n.scene.publish.orbitControls)}})}function fC(n){Object.assign(n.scene.publish.settings,{video:{...fo.defaultData.settings.video,...At(n.scene.publish.settings.video)}})}function hC(n){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[o,i]of Object.entries(r))if((s0.includes(o)||typeof i=="boolean")&&delete r[o],o==="texture")for(let[a,s]of Object.entries(i))(l0.includes(a)||typeof s=="boolean")&&delete i[a]}}}n.scene.objects.traverse((e,r)=>{r.states.forEach(o=>{let i=o;i.material?t(i.material):i.materials&&i.materials.forEach(a=>{t(a)})})})}function mC(n){n.scene.publish.withBackground=!0}function yC(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function gC(n){n.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(o=>o+1),r.linear.scale=r.linear.scale.map(o=>o+1))})}function xC(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function bC(n){n.scene.objects.traverse((t,e)=>{let r=n.scene.objects.unproxy().parent(t);if(r){let o=At(n.scene.objects.data(r));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=At(e).booleanExclude!==!0)}})}function vC(n){n.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function SC(n){function t(r){Object.setPrototypeOf(r,dt.prototype),r.texture&&Object.setPrototypeOf(r.texture,dt.prototype)}function e(r){Object.setPrototypeOf(r,dt.prototype);for(let o in r)t(r[o])}n.scene.objects.traverse((r,o)=>{o.states.forEach(i=>{let a=i;if(a.material){let s=At(a.material).layers;e(s),a.material.layers=s}if(a.materials)for(let s=0;s<a.materials.length;s++){let l=a.materials[s],u=At(l).layers;e(u),l.layers=u}})})}function g0(n){n.layers===void 0&&Object.assign(n,sr.defaultTwoLayerData("lambert"))}function $p(n){!n.layers||n.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let o={...At(t),colors:e,steps:r};Object.assign(t,o)}})}function wC(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function x0(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&$p(r)}):"material"in e&&typeof e.material!="string"&&$p(e.material)}),Object.values(n.shared.materials).forEach(t=>$p(t))}function AC(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}function _C(n){n.shared.audios=br({},be.prototype)}function PC(n){n.shared.videos=br({},be.prototype)}function OC(n){let t=n.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.layers){let o={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:o})}})}function CC(n){Object.entries(At(n.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.images[r]}),Object.entries(At(n.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.audios[r]})}function TC(n){n.scene.publish.settings.web.preload=!1}function b0(n){n.layers&&n.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function v0(n){n.layers&&n.layers.forEach(t=>{a0(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function MC(n){n.shared.fonts=br({},be.prototype)}function IC(n){return n.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function NC(n){let t=[];n.scene.objects.traverse((e,r)=>{let o=r;if(o.type==="TextFrame"){let i=sr.defaultTwoLayerData("phong"),a=typeof o.color=="string"?n.shared.colors[o.color]:o.color;i.layers[1].data.color={r:a.r,g:a.g,b:a.b},i.layers[1].data.alpha=o.alpha;let s=IC(o.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let l={name:o.name,...Ht.defaultData,...Ai.defaultData,flatShading:!1,wireframe:!1,geometry:{...jn.defaultData("TextGeometry"),width:o.width,height:o.height,font:s,depth:0,horizontalAlign:o.horizontalAlign,verticalAlign:o.verticalAlign,fontSize:o.fontSize*1.40625,lineHeight:o.lineHeight/1.40625,letterSpacing:o.letterSpacing-1,text:o.text,textTransform:o.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:i,states:At(o.states),events:At(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},u=At(n.scene.objects).parent(e);n.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{n.scene.objects.delete(e)})}function DC(n){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};n.scene.objects.traverse((e,r)=>{r.events.forEach(o=>{if(!!t[Number(o.type)])if(Object.assign(o,{type:t[Number(o.type)]}),o.type==="Audio"&&"audioEvent"in o&&(Object.assign(o,{playAudio:o.audioEvent}),delete o.audioEvent),o.type==="GameControl")Object.assign(o,{gameActions:{idle:new we,move:new we,jump:new we}});else{let i=new we;Object.assign(o,{actions:i}),(o.type==="MouseDown"||o.type==="MouseUp"||o.type==="KeyDown"||o.type==="KeyUp")&&"url"in o&&i.push({fi:0,id:_l.MathUtils.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((a,s,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(c,uo(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(c,{control1:{...a.control1},control2:{...a.control2}});let d={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},p={state:a.state,...d,...c},f={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new we({fi:0,id:_l.MathUtils.generateUUID(),data:u},{fi:1,id:_l.MathUtils.generateUUID(),data:p})};i.push({fi:l,id:s,data:f})}),delete o.targets)}})})}function EC(n){n.scene.objects.traverse((t,e)=>{function r(o,i){let a=new we,s=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===i){let d;s.push(u),l.interaction==="play"?d={...uo(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(d={...uo(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&a.push({fi:c,id:u,data:d})}}),s.forEach(l=>e.events.delete(l)),a.length){let l=e.events.find(u=>u.type===o)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):e.events.insertBefore(null,[{id:_l.MathUtils.generateUUID(),data:{type:o,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function S0(n){let t=n.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=kt.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function w0(n){un(n,S0),dn(n,S0)}function BC(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function LC(n){n.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function RC(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=sr.defaultTwoLayerData("phong"))})}function VC(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function zC(n){n.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function GC(n){n.scene.publish.mouseEventTarget===void 0&&(n.scene.publish.mouseEventTarget="canvas"),n.scene.publish.settings.web.hint===void 0&&(n.scene.publish.settings.web.hint=!1)}function kC(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function FC(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function jC(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function UC(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Nu.defaultDataThirdPerson.navmesh)})})}function HC(n){n.scene.styles||(n.scene.styles=sn.defaultData())}function A0(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function qC(n){n.scene.environment.ambientLight.occlusion===void 0&&(n.scene.environment.ambientLight.occlusion=!1),n.scene.environment.ambientLight.aoFullRes===void 0&&(n.scene.environment.ambientLight.aoFullRes=!1),n.scene.environment.ambientLight.radius===void 0&&(n.scene.environment.ambientLight.radius=256),n.scene.environment.ambientLight.bias===void 0&&(n.scene.environment.ambientLight.bias=.5),n.scene.environment.ambientLight.aoColor===void 0&&(n.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),dn(n,A0),un(n,A0)}function WC(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new we})})})}function $C(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function _0(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function P0(n,t){if(t<1&&(dn(n,y0),un(n,y0),n.schema=1),t<2&&(pC(n),n.schema=2),t<3&&(hC(n),n.schema=3),t<4&&(mC(n),n.schema=4),t<5&&(yC(n),n.schema=5),t<6&&(gC(n),n.schema=6),t<7&&(xC(n),n.schema=7),t<8&&(n.schema=8),t<9&&(x0(n),n.schema=9),t<10&&(wC(n),n.schema=10),t<11&&(AC(n),n.schema=11),t<12&&(x0(n),n.schema=12),t<13&&(_C(n),n.schema=13),t<14&&(OC(n),n.schema=14),t<15&&(CC(n),n.schema=15),t<16&&(TC(n),n.schema=16),t<17&&(dn(n,b0),un(n,b0),n.schema=17),t<18&&(dn(n,g0),un(n,g0),n.schema=18),t<19&&(fC(n),n.schema=19),t<20&&(MC(n),NC(n),n.schema=20),t<21&&(DC(n),EC(n),n.schema=21),t<22&&(w0(n),n.schema=22),t<23&&(BC(n),n.schema=23),t<24&&(LC(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(PC(n),t<25&&(n.schema=25)),t<26&&(bC(n),n.schema=26),t<27&&(vC(n),n.schema=27),t<28&&(w0(n),n.schema=28),t<29&&(SC(n),n.schema=29),t<30&&(RC(n),n.schema=30),t<31&&(VC(n),n.schema=31),t<33&&(zC(n),n.schema=33),t<34&&(GC(n),n.schema=34),t<35&&(kC(n),n.schema=35),t<36&&(FC(n),n.schema=36),t<37&&(jC(n),n.schema=37),t<38&&(dn(n,v0),un(n,v0),n.schema=38),t<39&&(UC(n),n.schema=39),t<40&&(HC(n),n.schema=40),t<41&&(qC(n),n.schema=41),t<42&&(WC(n),n.schema=42),t<43&&($C(n),n.schema=43),t<99){dn(n,_0),un(n,_0),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=zn);let e=At(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=Gn,r.insertBefore(null,null,[{id:Gn,data:{...an.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:uo(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:uo(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Al.defaultData,...uo(n.scene.environment,"usePhysics","gravity")},camera:At(n.scene.ownerCamera)??an.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==ln.TRASH_CAN_ID&&r.move(Gn,a.fi,a.id);let o=0,i=0;n.shared.penumbraSize&&n.scene.objects.traverse((a,s)=>{s.type==="DirectionalLight"?(s.penumbraSize=n.shared.penumbraSize[Math.min(o,2)],o+=1):s.type==="SpotLight"&&(s.penumbraSize=n.shared.penumbraSize[3+Math.min(i,1)],i+=1),(s.physics===void 0||s.physics===null)&&s.type!=="Instance"&&(s.physics={},Object.assign(s.physics,Fn.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),n.schema=99}}function O0(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function YC(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function XC(n){Array.isArray(At(n.events))&&n.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var ka=180/Math.PI;function C0(n){n.rotation=n.rotation.slice(0,3).map(t=>t*ka)}function T0(n){C0(n),n.type==="Page"&&C0(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*ka))});let t=n.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*ka),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*ka),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=ka,t.extrusion.twist*=ka),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(At(n.events))&&n.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Repeat")})}function QC(n){n.shared.variables=br({},be.prototype)}function KC(n){let t=At(n.shared.variables);n.shared.variables=br(Object.entries(t??{}).map(([e,r],o)=>({fi:o,id:e,data:r})),we.prototype)}var Vo=111;function M0(n,t){t(n.data);for(let e of n.children)M0(e,t)}function ZC(n){let t=n.schema??104;t!==Vo&&t<105&&(M0(n.asset,T0),n.schema=105)}function JC(n){n.shared.particles=br({},be.prototype),n.shared.lib&&(n.shared.lib.particles=cn.defaultData().particles)}function eT(n){n.scene.objects.traverse((t,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function Du(n){let t=n.schema??0;if(t!==Vo){console.warn("updating from ",t,"to ",Vo),P0(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=fo.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(dn(n,O0),un(n,O0),n.schema=101),t<102&&(YC(n),n.schema=102),t<104&&(n.shared.catelogs=new be,n.shared.lib=cn.defaultData(),n.schema=104),t<105&&(QC(n),n.scene.objects.traverse((e,r)=>{T0(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))ZC(e);t<106&&(KC(n),n.schema=106),t<107&&(n.shared.lib.variables=cn.defaultData().variables,n.schema=107),t<109&&(JC(n),n.schema=109),t<110&&(eT(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{XC(r)}),n.schema=111)}}var Va;(l=>{l.defaultData={schema:Vo,scene:ln.defaultData,frames:new be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",za.defaultData),shared:{...Qr.emptyData(),colors:Qr.defaultColors()}},l.emptyDataForImports=function(u){let c=ln.emptyDataWithPage(u);return{schema:Vo,scene:c,frames:new be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",za.defaultData),shared:{...Qr.emptyData(),colors:Qr.defaultColors(),images:Qr.defaultImages(u)}}},l.emptyData=function(){return{schema:Vo,scene:ln.emptyDataWithPage(),frames:new be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",za.defaultData),shared:Qr.emptyData()}},l.clipboard2dData=function(){return{schema:Vo,scene:ln.emptyData(),frames:new be,shared:Qr.emptyData()}},l.collabHelper={...yl,updateSchema(u){return(u.schema??0)<Vo?Dn(u,Du):(u.schema??0)-Vo}};function i(u){let c=l.collabHelper.updateSchema(u);return typeof c=="number"?c===0?u:null:c.data}l.updateSchemaDirectly=i;function a(u){return{...u,shared:{...u.shared,lib:cn.defaultData()}}}l.withoutLib=a;function s(u,c){let d=u.scene.objects.get(c);if(d&&d.data.type==="Component")return d;{let p=u.shared.lib.components[c];if(p)return p.asset}}l.getComponentData=s})(Va||(Va={}));var I0;(t=>{function n(e){return!0}t.is=n})(I0||(I0={}));var Eu;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0};function t(o,i){return{position:i?.position??o.position,rotation:i?.rotation??o.rotation,scale:i?.scale??o.scale}}r.merge=t;function e(o,i){return _c({position:Sl.isEqual(o.position,i.position)?void 0:i.position,rotation:o.rotation===i.rotation?void 0:i.rotation,scale:Sl.isEqual(o.scale,i.scale)?void 0:i.scale})}r.diff=e})(Eu||(Eu={}));var Yp;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(Yp||(Yp={}));var Bu;(t=>t.defaultData={opacity:1,fill:{color:Be.white,enabled:!0},stroke:{color:Be.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Be.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Be.from0to1([0,0,0,1]),enabled:!1,spread:0}})(Bu||(Bu={}));var Oi;(i=>{function n(a,s){return{name:s}}i.newEmpty=n;function t(a,s){if(s===void 0)return a;let l={...a},u=["width","height","cornerRadius"];for(let c of u)c in l&&c in s&&s[c]!==void 0&&Object.assign(l,{[c]:s[c]});return l}function e(a,s){if(s===void 0)return a;let l={...a};return"fill"in l&&"fill"in s&&s.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...s.fill}}),"stroke"in l&&"stroke"in s&&s.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...s.stroke}}),"layerBlur"in l&&"layerBlur"in s&&s.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...s.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in s&&s.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...s.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in s&&s.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...s.dropShadow}}),"innerShadow"in l&&"innerShadow"in s&&s.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...s.innerShadow}}),l}function r(a,s){if(s===void 0)return a;let l={...a};return Object.assign(l,Eu.merge(l,s)),l=t(l,s),l=e(l,s),l}i.patch=r;function o(a,s){let l,u=[];for(let[c,d]of Object.entries(s))c!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},u.push(l)),l.props[c]=d);return u}i.toOps=o})(Oi||(Oi={}));var Pl;(t=>t.defaultData={...Eu.defaultData,...Yp.defaultData,states:new we,events:new we,visible:!0,raycastLock:!1})(Pl||(Pl={}));var Fa;(t=>t.defaultData={...Pl.defaultData,...Bu.defaultData})(Fa||(Fa={}));var Lu;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(Lu||(Lu={}));var Xp;(t=>t.defaultData={...Fa.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(Xp||(Xp={}));var ja;(t=>t.defaultData={...Fa.defaultData,...Lu.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(ja||(ja={}));var Qp;(t=>t.defaultData={...Fa.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(Qp||(Qp={}));var Kp;(t=>t.defaultData={...Fa.defaultData,type:"path2d",path:"",name:"Path"})(Kp||(Kp={}));var N0;(t=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=n})(N0||(N0={}));var Ol;(t=>t.defaultData={...Pl.defaultData,name:"Group",type:"group2d"})(Ol||(Ol={}));var Zp;(t=>t.defaultData={...Pl.defaultData,...Lu.defaultData,...Bu.defaultData,name:"Frame",type:"frame2d",width:200,height:200,fill:{color:Be.fromHexAndA(Rt,1),enabled:!0},stroke:{color:Be.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}})(Zp||(Zp={}));var pn;(o=>{function n(i){switch(i){case"rectangle2d":return{...ja.defaultData};case"ellipse2d":return{...Xp.defaultData};case"text2d":return{...Qp.defaultData};case"vector2d":return{...ja.defaultData};case"path2d":return{...Kp.defaultData};case"frame2d":return{...Zp.defaultData};case"group2d":return{...Ol.defaultData}}}o.defaultData=n;function t(i){return"width"in i&&"height"in i?[typeof i.width=="number"?i.width*.5:0,typeof i.height=="number"?i.height*.5:0]:[0,0]}o.getPivot=t;function e(i){return i.type==="rectangle2d"||i.type==="ellipse2d"||i.type==="text2d"||i.type==="frame2d"}o.isResizeable=e;function r(i){return i.type==="rectangle2d"||i.type==="frame2d"}o.hasCorners=r})(pn||(pn={}));var Ru;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new ut},e.emptyData=function(){return{type:"scene2d",objects:new ut}}))(Ru||(Ru={}));var tt=require("three"),Fs=hr(E0());var tT=.5*(Math.sqrt(3)-1),Cl=(3-Math.sqrt(3))/6,rT=1/3,zo=1/6,fU=(Math.sqrt(5)-1)/4,hU=(5-Math.sqrt(5))/20,Tl=n=>Math.floor(n)|0,B0=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),ef=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function Vu(n=Math.random){let t=R0(n),e=new Float64Array(t).map(o=>B0[o%12*2]),r=new Float64Array(t).map(o=>B0[o%12*2+1]);return function(i,a){let s=0,l=0,u=0,c=(i+a)*tT,d=Tl(i+c),p=Tl(a+c),f=(d+p)*Cl,h=d-f,m=p-f,y=i-h,g=a-m,b,w;y>g?(b=1,w=0):(b=0,w=1);let _=y-b+Cl,S=g-w+Cl,P=y-1+2*Cl,O=g-1+2*Cl,x=d&255,D=p&255,N=.5-y*y-g*g;if(N>=0){let E=x+t[D],B=e[E],R=r[E];N*=N,s=N*N*(B*y+R*g)}let T=.5-_*_-S*S;if(T>=0){let E=x+b+t[D+w],B=e[E],R=r[E];T*=T,l=T*T*(B*_+R*S)}let I=.5-P*P-O*O;if(I>=0){let E=x+1+t[D+1],B=e[E],R=r[E];I*=I,u=I*I*(B*P+R*O)}return 70*(s+l+u)}}function L0(n=Math.random){let t=R0(n),e=new Float64Array(t).map(i=>ef[i%12*3]),r=new Float64Array(t).map(i=>ef[i%12*3+1]),o=new Float64Array(t).map(i=>ef[i%12*3+2]);return function(a,s,l){let u,c,d,p,f=(a+s+l)*rT,h=Tl(a+f),m=Tl(s+f),y=Tl(l+f),g=(h+m+y)*zo,b=h-g,w=m-g,_=y-g,S=a-b,P=s-w,O=l-_,x,D,N,T,I,E;S>=P?P>=O?(x=1,D=0,N=0,T=1,I=1,E=0):S>=O?(x=1,D=0,N=0,T=1,I=0,E=1):(x=0,D=0,N=1,T=1,I=0,E=1):P<O?(x=0,D=0,N=1,T=0,I=1,E=1):S<O?(x=0,D=1,N=0,T=0,I=1,E=1):(x=0,D=1,N=0,T=1,I=1,E=0);let B=S-x+zo,R=P-D+zo,k=O-N+zo,V=S-T+2*zo,q=P-I+2*zo,F=O-E+2*zo,U=S-1+3*zo,H=P-1+3*zo,$=O-1+3*zo,J=h&255,K=m&255,X=y&255,te=.6-S*S-P*P-O*O;if(te<0)u=0;else{let W=J+t[K+t[X]];te*=te,u=te*te*(e[W]*S+r[W]*P+o[W]*O)}let Y=.6-B*B-R*R-k*k;if(Y<0)c=0;else{let W=J+x+t[K+D+t[X+N]];Y*=Y,c=Y*Y*(e[W]*B+r[W]*R+o[W]*k)}let ee=.6-V*V-q*q-F*F;if(ee<0)d=0;else{let W=J+T+t[K+I+t[X+E]];ee*=ee,d=ee*ee*(e[W]*V+r[W]*q+o[W]*F)}let Q=.6-U*U-H*H-$*$;if(Q<0)p=0;else{let W=J+1+t[K+1+t[X+1]];Q*=Q,p=Q*Q*(e[W]*U+r[W]*H+o[W]*$)}return 32*(u+c+d+p)}}function R0(n){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let o=r+~~(n()*(256-r)),i=e[r];e[r]=e[o],e[o]=i}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var V0=require("three"),ho=new V0.Triangle,zu=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let o=0;o<t.count;o+=3){let i=1;ho.a.fromBufferAttribute(t,o),ho.b.fromBufferAttribute(t,o+1),ho.c.fromBufferAttribute(t,o+2),i*=ho.getArea(),e[o/3]=i}this.distribution=new Float32Array(t.count/3);let r=0;for(let o=0;o<e.length;o++)r+=e[o],this.distribution[o]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],o=this.binarySearch(this.randomFunction()*r);return this.sampleFace(o,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,o=e.length-1,i=-1;for(;r<=o;){let a=Math.ceil((r+o)/2);if(a===0||e[a-1]<=t&&e[a]>t){i=a;break}else t<e[a]?o=a-1:r=a+1}return i}sampleFace(t,e,r){let o=this.randomFunction(),i=this.randomFunction();return o+i>1&&(o=1-o,i=1-i),ho.a.fromBufferAttribute(this.positionAttribute,t*3),ho.b.fromBufferAttribute(this.positionAttribute,t*3+1),ho.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(ho.a,o).addScaledVector(ho.b,i).addScaledVector(ho.c,1-(o+i)),ho.getNormal(r),this}};var F0=require("three");var Fr=require("three"),k0=hr(G0()),oT=new Fr.Matrix4,nT=new Fr.Matrix4,iT=new Fr.Matrix4,Ua;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(Ua||(Ua={}));var Ha=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new Fr.Matrix4;this.copyPreviousMatrix=!0;this.hiddenMatrix=new Fr.Matrix4;this.matrixWorldRigid=new Fr.Matrix4;this.shearScale=new Fr.Matrix4;this.shearScaleInv=new Fr.Matrix4}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof Fr.Object3D&&(r=r.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===r)return!0;o=o.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let o of this.children)o.updateMatrixWorld(r)}updateWorldMatrix(r,o){let i=this.parent;if(r&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),o)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(r,o=0){for(let i of this.children)Ua.is(i)&&i.traverseObject(r,o+1)}traverseObject(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Ua.is(a)&&a.traverseObject(r,o+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,o=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:i,v:a,q:s}=(0,k0.SVD)(o),l=oT.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),u=nT.set(a[0][0],a[0][1],a[0][2],0,a[1][0],a[1][1],a[1][2],0,a[2][0],a[2][1],a[2][2],0,0,0,0,1),c=iT.copy(u).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),s.every(d=>Math.abs(s[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,o){this.updateWorldMatrix(!0,!1);let i=new Fr.Matrix4().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),i.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof Fr.Matrix4?r.hiddenMatrix.premultiply(i):r.applyMatrix4(i),r.updateWorldMatrix(!1,!1),this.add(r),o!==void 0&&(this.children.pop(),this.children.splice(o,0,r)),this}copy(r,o=!1){return super.copy(r,o),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,o,i,a,s,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var tf=class extends Ha(F0.Object3D){},aT=n=>n.type==="Mesh",fn=class extends tf{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let o=this.children[e];o?.object!==r&&(o&&this.remove(o),o=new fn(r),this.add(o),this.children.splice(e,0,this.children.pop()),o.matrixWorldNeedsUpdate=!0,o.matrixAutoUpdate=!1,o.matrix=r.matrix,o.hiddenMatrix=r.hiddenMatrix),o.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return aT(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var ds=require("three");var nd=require("three");var mr=require("three");var Nt=require("three"),Ci=new Nt.Vector3,Ti=new Nt.Vector3,qa=new Nt.Matrix4,U0=[new Nt.Vector3(-1,1,1),new Nt.Vector3(-1,-1,1),new Nt.Vector3(1,-1,1),new Nt.Vector3(1,1,1),new Nt.Vector3(-1,1,-1),new Nt.Vector3(-1,-1,-1),new Nt.Vector3(1,-1,-1),new Nt.Vector3(1,1,-1)],sT=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],lT=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],j0=(n,t,e)=>{n.updateEntityBoxSize(Ci,Ti),qa.copy(t).multiply(n.matrixWorld),Ti.x===0&&Ti.y===0&&Ti.z===0?e.push(new Nt.Vector3(Ci.x,Ci.y,Ci.z).applyMatrix4(qa)):U0.forEach(r=>{e.push(r.clone().multiply(Ti).add(Ci).applyMatrix4(qa))})},Ml=class extends Nt.Box3{constructor(){super(...arguments);this.matrix=new Nt.Matrix4;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let o=new Nt.Matrix4().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,r)}expandByObjectSize(e,r,o=!1){let i=[];return o===!0?e.traverseEntity(a=>{if(a.visible||a.cloner&&a.data.visible){if(!("geometry"in a)){i.push(new Nt.Vector3);return}j0(a,r,i)}}):j0(e,r,i),this.setFromPoints(i)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(qa.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Ti).multiplyScalar(.5),this.getCenter(Ci),qa.copy(this.matrix).setPosition(Ci),this.vertices=U0.map(e=>e.clone().multiply(Ti).applyMatrix4(qa))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=sT.map(([e,r])=>new Nt.Line3(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new Nt.Vector3))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=lT.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var mo={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var tr=require("three"),of=class extends tr.CurvePath{constructor(){super()}getPoints(t=12){let e=[],r,o=this.getCurveLengths(),a=o[o.length-1]/o.length;for(let s=0,l=this.curves;s<l.length;s++){let u=l[s],c=s===0?o[s]:o[s]-o[s-1],d=Math.ceil(t*c/a),p=u.getPoints(d);for(let f=0;f<p.length;f++){let h=p[f];r&&r.equals(h)||(e.push(h),r=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var nf=.001;function af(n,t,e){return t.clone().sub(n).cross(t.clone().sub(e)).length()<=nf}function rf(n,t){let e=new tr.Vector3(...n.position),r=new tr.Vector3(...n.controlNext.position),o=new tr.Vector3(...t.controlPrevious.position),i=new tr.Vector3(...t.position);return af(e,r,i)&&af(e,o,i)}function ku(n){let t=n.points.map(c=>new tr.Vector3(...c.data.position)),e=[n.points[0]],r=new tr.Vector3(...e[0].data.position);for(let c=0;c<n.points.length-1;c++)af(r,t[c],t[c+1])||(e.push(n.points[c]),r=t[c]);e.push(n.points[n.points.length-1]);let o=n.isClosed,i=e.length-(o?0:1),a=e.length,s=[];for(let c=0;c<a;c++){let d=e[c].data,p=new tr.Vector3(...d.position),f=new tr.Vector3(...d.controlPrevious.position),h=new tr.Vector3(...d.controlNext.position),m={position:p,baseRoundness:d.roundness,controlPrevious:f,controlNext:h};if(d.roundness===0||!n.isClosed&&(c===0||c===a-1)){s[c]={...m,removedLength:0};continue}let y=o&&c==0?a-1:c-1,g=o&&c==a-1?0:c+1,b=e[y].data,w=e[g].data,_=new tr.Vector3(...b.position),S=new tr.Vector3(...w.position),P=_.clone().sub(p).normalize(),O=S.clone().sub(p).normalize();Object.assign(m,{prevDir:P,nextDir:O});let x=rf(b,d),D=rf(d,w);if(!x||!D)s[c]={...m,removedLength:0};else{let N=P.clone().add(O).normalize(),T=N.clone().cross(P).length()/P.dot(N);s[c]={...m,tan:T,removedLength:d.roundness/T}}}for(let c=0;c<i;c++){let d=c,p=o&&c===a-1?0:c+1,f=s[d],h=s[p];if(f.removedLength!==0||h.removedLength!==0){let m=f.position.distanceTo(h.position);f.removedLength=Math.min(f.removedLength,m/2),h.removedLength=Math.min(h.removedLength,m/2)}}let l=[];for(let c=0;c<i;c++){let d=c,p=o&&c===a-1?0:c+1,f=s[d],h=s[p],m=null;if(!rf(e[d].data,e[p].data))f.position.distanceTo(h.position)>nf&&(m=new tr.CubicBezierCurve3(f.position,f.controlNext,h.controlPrevious,h.position));else{let y=f.position.clone(),g=h.position.clone();(f.removedLength!==0||h.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),h.prevDir&&g.add(h.prevDir.clone().setLength(h.removedLength))),y.distanceTo(g)>nf&&(m=new tr.CubicBezierCurve3(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}l[2*c+1]=m}for(let c=0;c<a;c++){let d=s[c];if(d.removedLength===0){l[2*c]=null;continue}let p=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(p),h=d.nextDir.clone().multiplyScalar(d.removedLength).add(p),m=d.tan*d.removedLength,y=d.prevDir.clone().add(d.nextDir).normalize(),g=f.clone().lerp(h,.5),b=f.distanceTo(h)/2,w=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(b,2))).add(g),_=y.clone().multiplyScalar(-m).add(w),S=p.distanceTo(_)/p.distanceTo(g),P=d.prevDir.clone().multiplyScalar(S*p.distanceTo(f)).add(p),O=P.clone().lerp(_,2),x=f.clone().lerp(P,4/3),D=h.clone().lerp(O,4/3);l[2*c]=new tr.CubicBezierCurve3(f,x,D,h)}let u=new of;return l.forEach(c=>{c&&u.add(c)}),u}var Fe;(t=>{function n(e){return e&&e.__isEntity}t.is=n})(Fe||(Fe={}));var Wa=n=>Fe.is(n),cT={type:"completeState",isfromEntity:!0},uT=["x","y","z"],sf=new mr.Vector3,dT=new mr.Vector3().set(0,1,0),$a=n=>class extends Ha(n){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.destroyedInAction=!1;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Ml;this._recursiveBBox=new Ml;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let o=this.children[r];if(Fe.is(o))return o}entityChildrenCount(){let r=this.children.length;for(;r--;)if(Fe.is(this.children[r]))return r+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let r=this;for(;r.data.type!=="Instance";){let o=r.parent;if(Fe.is(o))r=o;else return}return r}forInstancesRec(r){this.instances.forEach(o=>{o.disposed||r(o),o.forInstancesRec(r)})}super_Entity(r,o){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=o,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,o,i=!1){if(!(this.data.states.length===0&&!i)){for(let a of this.data.states)Pi.toOps(this.data,a.data).forEach(l=>{let u=Oa.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,o)});if(r!==null){let a=this.data.states.data(r);a&&(this.dataPatched=Pi.patch(this.data,a),Pi.toOps(this.data,a).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,o)}))}i&&this.updateTransformState(this.dataPatched,o),this.stateSelection=r,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(r,o){r.setScalar(0),o.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{Wa(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let o;return this.traverseEntity(i=>{i.uuid===r&&(o=i)}),o}traverseSortNextHelper(){let r=this.parent;if(r){let o=r.children,i=o.indexOf(this)+1;if(Fe.is(o[i]))return o[i];if(Fe.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&Fe.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let o=this;for(;r>0&&o!==null;)o=o.parent,r-=1;return o}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let o=this.parent;for(;o;){if(r===o)return!0;o=o.parent}return!1}countToAccestor(r){let o=0,i=this;for(;i!==r;){if(i===null)return-1;i=i.parent,o+=1}return o}forEachEntity(r){for(let o of this.children)Wa(o)&&r(o)}traverseEntityAncestors(r){this.traverseAncestors(o=>{Fe.is(o)&&r(o)})}traverseConcreteEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Wa(a)&&a.isConcreteEntity&&a.traverseEntity(r,o+1)}traverseEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Wa(a)&&a.traverseEntity(r,o+1)}traverseVisibleEntity(r){r(this);for(let o of this.children)Wa(o)&&o.visible&&o.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,o=!1){return super.copy(r,o),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>Wa(r))}isAncestorOf(r){if(this.uuid===r)return!1;let o=!1;return this.traverseEntity(i=>{i.uuid===r&&(o=!0)}),o}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x*mr.MathUtils.RAD2DEG,this.rotation.y*mr.MathUtils.RAD2DEG,this.rotation.z*mr.MathUtils.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Sa(o,r)}getTransformValues(r,o,i){return o[r].map((a,s)=>i?.shared.getVariable(a,[this.uuid,r,uT[s]])??a)}updateTransformState(r,o){let i=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,o)),i=!0),r.rotation&&(sf.fromArray(this.getTransformValues("rotation",r,o)).multiplyScalar(mr.MathUtils.DEG2RAD),this.rotation.setFromVector3(sf),i=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,o)),i=!0),r.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??Vn.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(a=>{a.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)Fe.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{Fe.is(r)&&r.disposeRecursively()})}toState(r=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return Sa(o,r)}updateByObjUpdateOp(r,o){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},o,!1)}updateByOp(r,o,i,a){let s=this.data;this.data=o;let l=r,u=ke(r.path,["states","*"]);if(u!==null){if(r.type===0){let[c]=u;if(this?.stateSelection===c){let d={...r.props};if(delete d.name,Object.values(r.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=St.zoom(p,r.path.slice(2));if(f)for(let h in r.props)r.props[h]===void 0&&h in f&&(d[h]=f[h])}}l={...r,props:d,path:r.path.slice(2)}}}}else if(r.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(r.props.name!==void 0&&c.name){let{name:p,...f}=c;c=f}if(r.props.material!==void 0&&"material"in c){let{material:p,...f}=c;c=f}let d=St.removeOverridden(r.path,r.props,c);l={...r,props:d}}}if(this.updateByPatchedOpBase(l,Pi.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),ke(r.path,["overrides"])){let c=[],d=[...r.path];for(c.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)c.push(d[1]),d.splice(0,2);if(c[c.length-1]===void 0){if(r.type===0)for(let p of Object.keys(r.props)){c[c.length-1]=p;let f=i.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=r.props[p],f.updateState(Io.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...c]);if(p){let f=St.zoom(p.component.data,d);if(r={...r,path:d},r.type===0){let h=r.props;if(f)for(let[m,y]of Object.entries(r.props))y===void 0&&(h===r.props&&(h={...r.props}),h[m]=f[m]);r={...r,props:h}}p.overrideData=La.resolve(o.overrides,c),p.updateByOp(r,wt.applySimple(p.data,r),i,!1)}}}else if(this.instances.length>0){let c;if(r.path.length===0&&r.type===0){let d;for(let p of Ro.rootOverrideProps)p in r.props&&(d===void 0&&(d={}),d[p]=r.props[p]);d&&(c={...r,props:d})}else for(let d of Ro.rootOverrideProps)if(ke(r.path,[d])){c=r;break}c!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=Io.filterOp(d.overrideData,c);p&&d.updateByOp(p,wt.applySimple(d.data,p),i,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=Io.filterOp(d.overrideData,r);if(p){let f;s===d.data&&r===p?f=o:f=wt.applySimple(d.data,p),d.updateByOp(p,f,i,!0)}}})}}updateByPatchedOpBase(r,o,i){if(this.dataPatched=o,r.path.length===0&&r.type===0)r.props.type!==void 0&&!po.is(r.props.type)&&mo.changeEntityProptotype(this,o,i);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){mo.changeEntityProptotype(this,o,i);for(let a of this.children)Fe.is(a)&&a.updateVisible(i.scene)}this.updateByPatchedOp(r,o,i)}updateByPatchedOp(r,o,i){if(r.path.length===0&&r.type===0&&this.updateState(r.props,i),ke(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),ke(r.path,["cloner"])!==null){let a=wt.drop(r,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,i):this.cloner?this.cloner.updateState(o.cloner,i.scene):(this.setFromClonerState(o.cloner,i),this.expandCloner(i.scene)),this.updateVisible(i.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){let o=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,i=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,a=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(o===null)return;let l=r.find(o);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data;if(u.geometry.path.points.length<=1)return;let c=ku(u.geometry.path),d=(i+a)%1;i+a===1&&d===0&&(d=1);let p=c.getPointAt(d);if(p===null)return;let f=this.parent?this.parent?.matrixWorld:new mr.Matrix4;l.updateMatrixWorld();let h=new mr.Matrix4().multiplyMatrices(f.clone().invert(),l.matrixWorld);p.applyMatrix4(h);let m={position:p.toArray(),rotation:u.rotation};if(s==="tangential"){let y=new mr.Matrix4().extractRotation(l.matrixWorld),g=c.getTangentAt(d).applyMatrix4(y).add(p),b=new mr.Matrix4().lookAt(p,g,dT),w=sf.setFromEuler(new mr.Euler().setFromRotationMatrix(b)).multiplyScalar(mr.MathUtils.RAD2DEG);m={...m,rotation:w.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(cT)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let o=!1;this.traverseEntity(i=>{if(i.data.type==="Splat")return o=!0,!0}),o&&r.reloadSplats()}updateState_Entity(r,o){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(o?.scene),this.resetBBoxNeedsUpdate()),o&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,o),this.updateVisible(o.scene)),this.updateTransformState(r,o)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof mo.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,o){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new mo.Cloner(this,r),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,o.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};var Hn=require("three");var st=require("three"),q0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);e.thetaLength=st.MathUtils.clamp(e.thetaLength,0,360);let r=e.width/2,o=e.radiusTop??r,i=e.radiusBottom??r;return o===i?(o=r,i=r):o>i?(o=r,i=i*r/o):(o=o*r/i,i=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:o,radiusBottom:i})}}static build(n){let{width:t,depth:e,height:r,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:d,cornerSegments:p,hollow:f}=n.parameters,h;return l===0?(h=new st.BufferGeometry,h.setAttribute("position",new st.Float32BufferAttribute([],3))):d||f?h=new Il(u,c,r,o,i,a,s,l*Math.PI/180,d,d,p,f):h=new st.CylinderGeometry(u,c,r,o,i,a,s,l*Math.PI/180),h.scale(1,1,e/t),Object.assign(h,{userData:{...n,type:"CylinderGeometry"}})}};function Un(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function H0(n){return new st.Vector2(n.y,-n.x)}var Il=class extends st.BufferGeometry{constructor(t,e,r,o,i,a,s,l,u,c,d,p,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,o=Math.floor(o)||8,i=Math.floor(i)||1,a=a!==void 0?a:!1,s=s!==void 0?s:0,l=l!==void 0?l:Math.PI*2,a&&(u=0,c=0);let h=[],m=[],y=[],g=[],b=0,w=r/2,_=new st.Vector3,S=new st.Vector3;f&&t==0&&(t=u),f&&e==0&&(e=c);let P=new st.Vector2(t,w),O=new st.Vector2(e,-w),x=null,D=null,N=null,T=null,I=P.clone().sub(O),E=0,B=0,R=0;p>0&&(E=Math.min(t,e)*(1-p),B=t-E,R=e-E);let k=P.clone();k.x-=E;let V=Math.PI-I.angle(),q=I.angle(),F=Math.tan(q/2),U=Math.tan(V/2),H=F+U,$=p?H:U,J=p?H:F;if(u=Math.min(u,(t-B)/$,I.length()/H),c=Math.min(c,(e-R)/J,I.length()/H),u>0){let Q=u/F;x=P.clone().sub(new st.Vector2(Q,u)),p&&(N=x.clone(),N.x-=E-H*u),P.sub(I.clone().setLength(Q))}if(c>0){let Q=c/U;D=O.clone().sub(new st.Vector2(Q,-c)),O.add(I.clone().setLength(Q)),p&&(T=D.clone(),T.x-=E-H*c,k.sub(I.clone().setLength(Q)))}I=P.clone().sub(O);let K=I.length()<.5,X=[];for(let Q=0;Q<=o;Q++){let W=[],ue=Q/o,le=ue*l+s,ne=new st.Vector2(Math.sin(le),Math.cos(le));T&&D?(te(W,ue,ne,V,c,T,-1,!0),te(W,ue,ne,q,c,D,-1,!1)):D?(Y(W,ne,D.x,0,-1),te(W,ue,ne,q,c,D,-1,!1)):a||Y(W,ne,e,R,-1);let ce=H0(I).normalize();if(Un(ce,ne,_),!K)for(let ae=0;ae<=i;ae++){let me=ae/i,fe=I.clone().multiplyScalar(me).add(O);Un(fe,ne,S),m.push(S.x,S.y,S.z),y.push(_.x,_.y,_.z),g.push(ue,.5+S.y/r),W.push(b++)}if(N&&x?(te(W,ue,ne,V,u,x,1,!1),te(W,ue,ne,q,u,N,1,!0)):x?(te(W,ue,ne,V,u,x,1,!1),Y(W,ne,x.x,0,1)):a||Y(W,ne,t,B,1),p&&!K){let ae=H0(I).multiplyScalar(-1).normalize();Un(ae,ne,_);for(let me=0;me<=i;me++){let fe=me/i,he=I.clone().multiplyScalar(-fe).add(k);Un(he,ne,S),m.push(S.x,S.y,S.z),y.push(_.x,_.y,_.z),g.push(ue,.5+S.y/r),W.push(b++)}}p&&!a&&W.push(W[0]),X.push(W)}for(let Q=0;Q<X.length-1;Q++)for(let W=0;W<X[0].length-1;W++){if(a&&p&&W==i)continue;let ue=X[Q][W],le=X[Q+1][W],ne=X[Q+1][W+1],ce=X[Q][W+1],ae=m[ne*3+0],me=m[ne*3+2];h.push(ue,le,ce),(ae!=0||me!=0)&&h.push(le,ne,ce)}l<Math.PI*2&&(ee(-1,X[0],s),ee(1,X[X.length-1],s+l)),this.setIndex(h),this.setAttribute("position",new st.Float32BufferAttribute(m,3)),this.setAttribute("normal",new st.Float32BufferAttribute(y,3)),this.setAttribute("uv",new st.Float32BufferAttribute(g,2));function te(Q,W,ue,le,ne,ce,ae,me){for(let fe=0;fe<d+1;fe++){let he=fe/d,xe=ae<0?he:1-he;me&&(xe-=1),xe*=le;let ye=new st.Vector2(Math.sin(xe),Math.cos(xe)*ae),C=ye.clone().multiplyScalar(ne).add(ce);Un(C,ue,S),m.push(S.x,S.y,S.z),Un(ye,ue,_),y.push(_.x,_.y,_.z),g.push(W,.5+S.y/r),Q.push(b++)}}function Y(Q,W,ue,le,ne){let ce=new st.Vector3,ae=new st.Vector2,me=[ue,le];ne<0&&me.reverse();for(let fe of me)ae.set(fe,w*ne),Un(ae,W,ce),m.push(ce.x,ce.y,ce.z),y.push(0,ne,0),g.push(.5,.5),Q.push(b++)}function ee(Q,W,ue){let le=new st.Vector2(Math.sin(ue),Math.cos(ue)),ne=new st.Vector2(-Math.cos(ue),Math.sin(ue)),ce=new st.Vector3,ae=Q<0?(he,xe,ye)=>h.push(he,xe,ye):(he,xe,ye)=>h.push(he,ye,xe),me=new st.Vector2((t+e+B+R)/4,0);Un(me,le,ce),m.push(ce.x,ce.y,ce.z),y.push(ne.x,0,ne.y),g.push(.5,.5);let fe=b++;for(let he of W){let xe=m.slice(he*3,he*3+3);m.push(...xe),y.push(ne.x,0,ne.y);let ye=g.slice(he*2,he*2+2);g.push(...ye),b++}for(let he=fe+1;he<b-1;he++)ae(fe,he,he+1);ae(fe,b-1,fe+1)}}};var W0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},n.parameters);return e.thetaLength=Hn.MathUtils.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,depth:e,height:r,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:d}=n.parameters,p;return l===0?(p=new Hn.BufferGeometry,p.setAttribute("position",new Hn.Float32BufferAttribute([],3))):u>0||c>0||l<360?p=new Il(0,t/2,r,o,i,a,s,l*Math.PI/180,u,c,d,0,!0):p=new Hn.ConeGeometry(t/2,r,o,i,a),p.scale(1,1,e/t),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};var Cr=require("three"),$0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,widthSegments:o,heightSegments:i,depthSegments:a,cornerRadius:s,cornerSegments:l}=n.parameters,u;return s==0?u=new Cr.BoxGeometry(t,e,r,o,i,a):u=new cf(t,e,r,o,i,a,s,l),Object.assign(u,{userData:{...n,type:"CubeGeometry"}})}},lf=Math.PI/2,cf=class extends Cr.BufferGeometry{constructor(t=1,e=1,r=1,o=1,i=1,a=1,s=0,l=4){super(),this.type="BoxGeometry";let u=this;o=Math.floor(o),i=Math.floor(i),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,t/2,e/2,r/2);let c=[],d=[],p=[],f=[],h=0,m=0;y("z","y","x",-1,-1,r,e,t,a,i,0),y("z","y","x",1,-1,r,e,-t,a,i,1),y("x","z","y",1,1,t,r,e,o,a,2),y("x","z","y",1,-1,t,r,-e,o,a,3),y("x","y","z",1,-1,t,e,r,o,i,4),y("x","y","z",-1,-1,t,e,-r,o,i,5),s>0&&(g("z","y","x",-1,-1,1,r,e,t,a,0),g("z","y","x",1,-1,-1,r,e,t,a,1),g("z","y","x",-1,1,-1,r,e,t,a,1),g("z","y","x",1,1,1,r,e,t,a,0),g("x","y","z",-1,-1,-1,t,e,r,o,0),g("x","y","z",1,-1,1,t,e,r,o,1),g("x","y","z",-1,1,1,t,e,r,o,0),g("x","y","z",1,1,-1,t,e,r,o,1),g("y","x","z",-1,-1,1,e,t,r,i,0),g("y","x","z",1,-1,-1,e,t,r,i,1),g("y","x","z",1,1,1,e,t,r,i,1),g("y","x","z",-1,1,-1,e,t,r,i,0),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(c),this.setAttribute("position",new Cr.Float32BufferAttribute(d,3)),this.setAttribute("normal",new Cr.Float32BufferAttribute(p,3)),this.setAttribute("uv",new Cr.Float32BufferAttribute(f,2));function y(w,_,S,P,O,x,D,N,T,I,E){let B=(x-2*s)/T,R=(D-2*s)/I,k=x/2-s,V=D/2-s,q=N/2,F=T+1,U=I+1,H=0,$=0,J=new Cr.Vector3;for(let K=0;K<U;K++){let X=K*R-V;for(let te=0;te<F;te++){let Y=te*B-k;J[w]=Y*P,J[_]=X*O,J[S]=q,d.push(J.x,J.y,J.z),J[w]=0,J[_]=0,J[S]=N>0?1:-1,p.push(J.x,J.y,J.z),f.push(te/T),f.push(1-K/I),H+=1}}for(let K=0;K<I;K++)for(let X=0;X<T;X++){let te=h+X+F*K,Y=h+X+F*(K+1),ee=h+(X+1)+F*(K+1),Q=h+(X+1)+F*K;c.push(te,Y,Q),c.push(Y,ee,Q),$+=6}u.addGroup(m,$,E),m+=$,h+=H}function g(w,_,S,P,O,x,D,N,T,I,E){let B=(D-2*s)/I,R=D/2-s,k=N/2-s,V=T/2,q=I+1,F=0,U=0,H=new Cr.Vector3,$=new Cr.Vector3;for(let J=0;J<l+1;J++){let K=J/l*lf,X=Math.sin(K)*s,te=(1-Math.cos(K))*s,Y=Math.sin(K),ee=Math.cos(K);H[_]=(k+X)*O,H[S]=(V-te)*x,$[w]=0,$[_]=Y*Math.sign(H[_]),$[S]=ee*Math.sign(H[S]);for(let Q=0;Q<q;Q++){let W=Q*B-R;H[w]=W*P,d.push(H.x,H.y,H.z),p.push($.x,$.y,$.z),f.push(Q/I),f.push(0),F+=1}}for(let J=0;J<l;J++)for(let K=0;K<I;K++){let X=h+K+q*J,te=h+K+q*(J+1),Y=h+(K+1)+q*(J+1),ee=h+(K+1)+q*J;c.push(X,te,ee),c.push(te,Y,ee),U+=6}u.addGroup(m,U,E),m+=U,h+=F}function b(w,_,S){let P=new Cr.Vector3,O=new Cr.Vector3(t/2,e/2,r/2);O.subScalar(s);let x=[],D=w*_*S>0?(T,I,E)=>c.push(T,I,E):(T,I,E)=>c.push(T,E,I);for(let T=0;T<=l;T++){let I=[],E=lf*(1-T/l),B=Math.cos(E),R=Math.sin(E),k=0;for(let V=0;V<=T;V++){let q=Math.cos(k),F=Math.sin(k);P.x=B*q,P.y=R,P.z=B*F;let U=O.clone().addScaledVector(P,s);d.push(w*U.x,_*U.y,S*U.z),p.push(w*P.x,_*P.y,S*P.z),f.push(0,0),I.push(h++),k+=lf/T}x.push(I)}let N=x.length-1;for(let T=0;T<N;T++){let I=x[T],E=x[T+1],B=I.length-1;D(I[0],E[1],E[0]);for(let R=1;R<=B;R++)D(I[R-1],I[R],E[R]),D(I[R],E[R+1],E[R])}}}};var Dt=require("three"),qn=class extends Dt.BufferGeometry{constructor(t=[],e=[],r="",o=1,i=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],u=[];c(),d(),this.setAttribute("position",new Dt.Float32BufferAttribute(s,3)),this.setAttribute("normal",new Dt.Float32BufferAttribute(u,3)),this.setAttribute("uv",new Dt.Float32BufferAttribute(l,2));return;function c(){i=Math.min(1-1e-5,i),i==0&&(a=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],h=new Dt.Vector3,m=h.clone(),y=new Dt.Triangle,g=i*o,b=o-g,w=a+1,_=new Dt.Vector3,S=(F,U)=>_.subVectors(F,U).normalize(),P=(F,U)=>Array(F).fill(void 0).map(U),O=P(t.length/3,(F,U)=>new Dt.Vector3().fromArray(t,U*3).setLength(o)),x=[],D=1e6;for(let F=0;F<O.length;F++){let U=O[F],H=[],$,J,K,X=1e10,te=-1;for(;(te=e.indexOf(F,te+1))!=-1;){let W=te-te%3;$=e[W+(te+1)%3],J=e[W+(te+2)%3],K=U.distanceToSquared(O[$]),X=Math.min(X,K),H.push([$,J,K])}X+=1e-6;let Y=[],ee=0,Q=H.length;for(let W=0;W<Q;W++){[$,J,K]=H[ee];let ue=x[$]?.includes(F)==!0;K<=X&&Y.push($+ +ue*D),ee=H.findIndex(le=>le[0]==J)}x.push(Y)}let N=[];{let F=0,U=0,H,$,J=f==3;for(let K=0;K<=a;K++){H=K*(K+1)/2,$=(K+1)*(K+2)/2;for(let X=0;X<a-K;X++)[F,U]=[H+X+K+2,$+X+K+3],N.push(H,$,...J?[U,H]:[F,$],U,F),[H,$]=[F,U];N.push(H,$,H+a+2)}}let T=h.clone(),I=h.clone(),E=h.clone(),B=h.clone(),R=h.clone(),k=[],V=P(O.length,()=>P(f,()=>h.clone()));for(let F=0;F<O.length;F++){h.copy(O[F]).normalize(),T.copy(h).multiplyScalar(b);let U=x[F];for(let Y=0;Y<U.length;Y++){let ee=U[Y],Q=U[(Y+1)%f];y.setFromPointsAndIndices(O,F,ee%D,Q%D),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(T,V[F][Y])}let H=[],$=[],J=[],K=new Dt.Vector3;a==0&&[...V[F]].reduce((Y,ee)=>Y.add(ee),K).multiplyScalar(1/f);for(let Y=0;Y<f;Y++){let ee=[],Q=(Y-1+f)%f,W=V[F][Q],ue=V[F][Y];h.copy(W).sub(T),m.copy(ue).sub(T);let le=T.angleTo(h),ne=h.angleTo(m),ce=Math.cos(le)*g;a==0?I.copy(K):I.copy(T).setLength(b+ce),$.push(ce);let ae=[I,W,ue];for(let me=0;me<2;me++){let fe=ae[me],he=ae[me+1];B.subVectors(fe,T),R.subVectors(he,T),E.crossVectors(B,R).normalize();for(let xe=0;xe<w;xe++){let ye=[le,ne][me]*xe/w;h.copy(B).applyAxisAngle(E,ye).add(T),H.push(h.clone()),me&&(S(h,T),ee.push([xe==0?fe:h.clone(),_.clone()]))}me&&(S(he,T),ee.push([he,_.clone()]))}J.push(ee)}k.push(J);let X=2*w,te=2;for(let Y=0;Y<f;Y++){let ee=X*Y,Q=X*((Y+1)%f),W=[H[ee]];for(let le=1;le<w;le++){B=H[ee+le],R=H[Q+le],W.push(B);for(let ne=1,ce=le-te+1;ne<=ce;ne++)h.lerpVectors(B,R,ne/(ce+1)),h.sub(T).setLength($[Y]).add(T),W.push(h.clone());W.push(R)}for(let le=0;le<w;le++)W.push(H[le+w+ee]);W.push(H[Q+w]);let ue=N.map(le=>W[le]);s.push(...ue.map(le=>[le.x,le.y,le.z]).flat()),u.push(...ue.map(le=>(S(le,T),[_.x,_.y,_.z])).flat())}}let q=[];for(let F=0;F<x.length;F++)for(let U=0;U<f;U++){let H=x[F][U];if(H<D){let $=x[H].findIndex(X=>X%D==F),J=k[F][U],K=k[H][$];for(let X=0;X<w;X++){let te=J[X],Y=K[w-X],ee=J[X+1],Q=K[w-(X+1)];[te,Y,ee,ee,Y,Q].forEach(W=>{s.push(W[0].x,W[0].y,W[0].z),u.push(W[1].x,W[1].y,W[1].z)})}q.push(J[0][0],K[w][0],J[w][0],K[0][0])}}for(;q.length;){let F,U,H,$;[F,U]=q.splice(0,2);let J=[F];for(;F!=U;)J.push(U),H=q.indexOf(U),$=H%2,U=q.splice(H-$,2)[1-$];_.subVectors(J[0],J[1]).cross(h.subVectors(J[0],J[2])).normalize();let K=_.dot(J[0])<0;K&&_.negate();for(let X=1;X<=J.length-2;X++)[J[X+ +K],J[X+1-+K],J[0]].forEach(te=>{s.push(te.x,te.y,te.z),u.push(_.x,_.y,_.z)})}}function d(){let p=new Dt.Vector3;for(let O=0;O<s.length;O+=3){p.x=s[O+0],p.y=s[O+1],p.z=s[O+2];let x=S(p)/2/Math.PI+.5,D=P(p)/Math.PI+.5;l.push(x,1-D)}let f=new Dt.Vector3,h=new Dt.Vector3,m=new Dt.Vector3,y=new Dt.Vector3,g=new Dt.Vector2,b=new Dt.Vector2,w=new Dt.Vector2,_=(O,x,D,N)=>{N<0&&O.x===1&&(l[x]=O.x-1),D.x===0&&D.z===0&&(l[x]=N/2/Math.PI+.5)};for(let O=0,x=0;O<s.length;O+=9,x+=6){f.set(s[O+0],s[O+1],s[O+2]),h.set(s[O+3],s[O+4],s[O+5]),m.set(s[O+6],s[O+7],s[O+8]),g.set(l[x+0],l[x+1]),b.set(l[x+2],l[x+3]),w.set(l[x+4],l[x+5]),y.copy(f).add(h).add(m).divideScalar(3);let D=S(y);_(g,x+0,f,D),_(b,x+2,h,D),_(w,x+4,m,D)}for(let O=0;O<l.length;O+=6){let x=l[O+0],D=l[O+2],N=l[O+4],T=Math.max(x,D,N),I=Math.min(x,D,N);T>.9&&I<.1&&(x<.2&&(l[O+0]+=1),D<.2&&(l[O+2]+=1),N<.2&&(l[O+4]+=1))}function S(O){return Math.atan2(O.z,-O.x)}function P(O){return Math.atan2(-O.y,Math.sqrt(O.x*O.x+O.z*O.z))}}}static fromJSON(t){return new qn(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var Y0=require("three"),X0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new Nl(t*.5,i,a):new Y0.DodecahedronGeometry(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},Nl=class extends qn{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,i=1/o,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-o,0,-i,o,0,i,-o,0,i,o,-i,-o,0,-i,o,0,i,-o,0,i,o,0,-o,0,-i,o,0,-i,-o,0,i,o,0,i],s=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(a,s,l,t,e,r),this.type=l}static fromJSON(t){return new Nl(t.radius,t.corner,t.cornerSides)}};var Ke=require("three");var Ne=require("three"),Dl=1e-12,Ya=class{constructor(t){this.position=new Ne.Vector2;this.startPosition=new Ne.Vector2;this.uuid=Ne.MathUtils.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new 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)}},yo=class extends Ya{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Xa(this),new Xa(this))}static create(e,r){let o=new yo(e,new Ne.Vector2(...r.position));return o.controls[0].position.set(...r.controlPrevious.position),o.controls[1].position.set(...r.controlNext.position),o.roundness=r.roundness,o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,o}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let o=0,i=this.controls.length;o<i;o++){let a=this.controls[o];this.position.distanceTo(a.position)<=r?a.position.copy(this.position):a.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new yo(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new Ne.Vector2,r=new Ne.Vector2){let[o,i]=this.computeTangents();return o&&i&&(Q0(o,e),Q0(i,r)),[e,r]}computeTangent(e=new Ne.Vector2){let[r,o]=this.computeTangents();return r&&o&&e.copy(r).add(o).normalize(),e}computeNormal(e=new Ne.Vector2){let[r,o]=this.computeNormals();return e.copy(r).add(o).normalize(),e}};function Q0(n,t=new Ne.Vector2){let e=n.length();return t.set(-n.y/e,n.x/e)}var df=n=>n,Qa=new Ne.Vector2,Fu=new Ne.Vector2,pT=new Ne.Vector2,fT=new Ne.Vector2,hT=new Ne.Vector2,mT=new Ne.Vector2,Z0=new Ne.Vector3,J0=new Ne.Vector3;function ex(n){let t=new Ne.Vector2;t.addVectors(n.v0,Qa.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Ne.Vector2;return e.addVectors(n.v2,Fu.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new Ne.CubicBezierCurve(n.v0,t,e,n.v2)}function El(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function yT(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function gT(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function pf(n,t,e){let r=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),o=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),i=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((o*o+r*r-i*i)/(2*o*r))}function tx(n,t,e){return K0(n,t)&&K0(t,e)&&uf(n.position,t.position,e.position)}function uf(n,t,e){return Qa.copy(t).sub(n).cross(Fu.copy(e).sub(n))===0}function rx(n,t,e,r,o){let i=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),a=(n.y+t.y)/2,s=(n.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(n.y-t.y)/i,u=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(t.x-n.x)/i;return r.set(s+l,a+u),o.set(s-l,a-u),[r,o]}function ox(n,t,e){let r=n.distanceTo(e),o=t.distanceTo(e);return r<o?t:n}function nx(n,t,e,r,o,i){let a=t.x-n.x,s=t.y-n.y,l=e.x-n.x,u=e.y-n.y,c=Math.sqrt((a+l)*(a+l)+(s+u)*(s+u)),d;return pf(t,n,e)>Math.PI&&(c*=-1),El(u,s)?d=(s+u)*(r/c-.5)*8/3/(a-l):d=(a+l)*(r/c-.5)*8/3/(u-s),o.set(t.x-d*s,t.y+d*a),i.set(e.x+d*u,e.y-d*l),[o,i]}function ff(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function K0(n,t){return uf(n.position,n.controls[1].position,t.position)&&uf(n.position,t.controls[0].position,t.position)}function ix(n,t,e,r,o=.5){let i=Qa.subVectors(t,n).multiplyScalar(o).add(n),a=Fu.subVectors(e,t).multiplyScalar(o).add(t),s=pT.subVectors(r,e).multiplyScalar(o).add(e),l=i,u=fT.subVectors(a,i).multiplyScalar(o).add(i),c=hT.subVectors(s,a).multiplyScalar(o).add(a),d=s,p=mT.subVectors(c,u).multiplyScalar(o).add(u);return[n.x,n.y,l.x,l.y,u.x,u.y,p.x,p.y,c.x,c.y,d.x,d.y,r.x,r.y]}function ax(n,t,e=12,r=!0){let o=J0.set(0,0,0),i,a=0,s=[];for(let l=0;l<t.length;l++){let u=df(t[l]),c=Qa,d=Wn(u,e);s.push(d);for(let p=0;p<=d;p++)if(u instanceof Ne.CubicBezierCurve||u instanceof Ne.QuadraticBezierCurve||u instanceof Ne.LineCurve){if(u.getPoint(p/d,c),o.set(c.x,c.y,0),i!==void 0&&gT(i,o))continue;i===void 0&&(i=Z0),i.copy(o),n.setXYZ(a,o.x,o.y,o.z),a++}}return r&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),n}function sx(n,t,e,r=12,o=!0){let i=J0.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=df(t[l]),d=Qa,p=Wn(c,r);s.push(p);for(let f=0;f<=p;f++)if(c instanceof Ne.CubicBezierCurve||c instanceof Ne.QuadraticBezierCurve||c instanceof Ne.LineCurve){if(c.getPoint(f/p,d),i.set(d.x,d.y,0),u?.equals(i))continue;u===void 0?u=Z0:(n.setXYZ(a,u.x,u.y,u.z),a++,n.setXYZ(a,i.x,i.y,i.z),a++),u.copy(i)}}return o&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),s}function hf(n,t=12,e=!1){let r=[];for(let o=0,i=n.length;o<i;o++){let a=n[o],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=Wn(a.roundedCurveCorner,t)*.5;o>0&&(r[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=Wn(a.curveAfter,t)),r.push(s)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=Wn(n[0].roundedCurveCorner,t)*.5),r}function Wn(n,t=12){return n&&n instanceof Ne.EllipseCurve?t*2:n&&(n instanceof Ne.LineCurve||n instanceof Ne.LineCurve3)?1:n&&n instanceof Ne.SplineCurve?t*n.points.length:t}function lx(n,t,e=12,r=!0){let o,i=0;for(let a=0;a<t.length;a++){let s=df(t[a]),l=Wn(s,e),u=Qa;for(let c=0;c<=l;c++)if(s instanceof Ne.CubicBezierCurve||s instanceof Ne.QuadraticBezierCurve||s instanceof Ne.LineCurve){if(s.getPoint(c/l,u),o!==void 0&&yT(o,u,Dl))continue;o===void 0&&(o=Fu),o.copy(u),n.push(u.x,u.y),i++}}return El(n[0],n[n.length-2],Dl)&&El(n[1],n[n.length-1],Dl)&&(n.pop(),n.pop()),r&&i>1&&!(El(n[i-1],n[1],Dl)&&El(n[i-2],n[0],Dl))&&(n.push(n[0],n[1]),i++),n}var mf=new Ke.Vector2,xT=new Ke.Vector2,bT=new Ke.Vector2,vT=new Ke.Vector2,ST=new Ke.Vector2,wT=new Ke.Vector2,Qe=class extends Ke.Shape{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new Ke.Plane(new Ke.Vector3(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this.isText=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Ke.MathUtils.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,o){let i=new Qe;return i.isClosed=e.isClosed,i.points=e.points.map(a=>yo.create(a.id,a.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(a=>Qe.createFromState(a)),r!==void 0&&o!==void 0&&i.applySize(r,o),i.update(),i}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let r=0,o=this.points.length;r<o;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,o=this.points.findIndex(i=>i.uuid===e);if(o<0){let i=r;for(let a=0,s=this.shapeHoles.length;a<s;a++){let l=this.shapeHoles[a],u=l.points.length,c=l.getPointIndexById(e);if(c<0)i+=u;else return c+i}}return o}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let r=this.points.length;for(let o=0,i=this.shapeHoles.length;o<i;o++){let a=this.shapeHoles[o],s=e-r;if(s<=a.points.length-1)return a.points[s];r+=a.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let o=0,i=this.shapeHoles.length;o<i;o++){let a=this.shapeHoles[o],s=a.points.indexOf(e);if(s>=0)return r+s;r+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let o=mf.set(e,r);for(let i=0,a=this.points.length;i<a;i++){let s=this.points[i];s.position.multiply(o),s.controls[0].position.multiply(o),s.controls[1].position.multiply(o)}for(let i=0,a=this.shapeHoles.length;i<a;i++)this.shapeHoles[i].applyScale(e,r);this._update()}createPoint(e,r=0,o=Ke.MathUtils.generateUUID()){let i;e instanceof Ke.Vector2?i=e:i=new Ke.Vector2(e,r);let a=new yo(o,i);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,o=this.points.length;r<o;r++){let i=this.points[r];if(i.uuid===e)return i}for(let r=0,o=this.shapeHoles.length;r<o;r++){let a=this.shapeHoles[r].getPointByUuid(e);if(a)return a}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(o=>o.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,o=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let i=o?this.roundedCurveDivisions:this.curveDivisions;return ax(e,o?this.roundedCurves:this.curves,r,this.autoClose),i.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=hf(this.points,e,!1),this.roundedCurveDivisions=hf(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,o=12){return sx(e,this.curves,r,o,this.autoClose).reduce((a,s)=>a+s,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),lx(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let i=r?this.roundedCurveDivisions:this.curveDivisions,a=0;r&&this.points[0].roundedCurveCorner!==void 0&&(a=Wn(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=i.reduce((l,u)=>l+u,0));for(let l=0,u=i.length;l<u;l++){let c=i[l];if(s<o+c)return[l,(s-o+1)/c];o+=c}return[0,1]}getCurveT(e,r,o){let i=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(ff(i,a)){let d=i.position.distanceTo(a.position);return i.position.distanceTo(mf.set(o.x,o.y))/d}let u=0;for(let d=0;d<e;d++)u+=s[d];return(r-u)/l}dispose(){}_applyCurveForPoint(e,r){ff(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let o=this.curves[this.curves.length-1];e.curveBefore=o,r.curveAfter=o;let i=o.clone();e.roundedCurveBefore=i,r.roundedCurveAfter=i,e.roundedCurveCorner=void 0,this.roundedCurves.push(i)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,o=this.points.length;r<o;r++){let i=this.points[r];if(r===0)this.moveTo(i.position.x,i.position.y);else{let a=this.points[r-1];this._applyCurveForPoint(i,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],o=this.points[this.points.length-1];this._applyCurveForPoint(r,o)}if(this.points.length>2){let r=0;for(let o=0,i=this.points.length;o<i;o++){let a=this.points[o],s=this.points[o-1]??this.points[this.points.length-1],l=this.points[o+1]??this.points[0],u=a.roundness,c=s&&l&&tx(s,a,l);if(!a.controlsMoved()&&u>0&&!c){let d=a.curveBefore,p=a.curveAfter;if(d===void 0||p===void 0)continue;let f=a.roundedCurveBefore,h=a.roundedCurveAfter,m=d.getLength(),y=p.getLength(),g=Math.min(u,m*.499),b=Math.min(u,y*.499),w=Math.min(g,b),_=1-w/m,S=w/y,P=d.getPointAt(_,mf),O=p.getPointAt(S,xT);this._subSplitCurve(d,f,_,P,void 0),this._subSplitCurve(p,h,S,void 0,O);let x;if(this.useCubicForRoundedCorners){let D=pf(P,a.position,O)/2,N=Math.tan(D)*P.distanceTo(a.position),[T,I]=rx(P,O,N,bT,vT),E=ox(T,I,a.position),[B,R]=nx(E,P,O,N,ST,wT);x=new Ke.CubicBezierCurve(P.clone(),B.clone(),R.clone(),O.clone())}else x=new Ke.QuadraticBezierCurve(P.clone(),a.position.clone(),O.clone());a.roundedCurveCorner=x,this.roundedCurves.splice(o+r,0,x),r++}}}}_subSplitCurve(e,r,o,i,a){if(e instanceof Ke.LineCurve)i!==void 0&&r.v2.copy(i),a!==void 0&&r.v1.copy(a);else{let s=e,l=r,u=s.getUtoTmapping(o,0),c=ix(s.v0,s.v1,s.v2,s.v3,u);return i!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),a!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return r}clone(){let e=new Qe(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let o=0;o<r;o++){let i=o*7,a=e.points[i+0],s=e.points[i+1],l=e.points[i+2],u=e.points[i+3],c=e.points[i+4],d=e.points[i+5],p=e.points[i+6],f=new yo(Ke.MathUtils.generateUUID(),new Ke.Vector2(a,s));f.controls[0].position.set(l,u),f.controls[1].position.set(c,d),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new Qe;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let o=(a,s)=>{s instanceof Ke.CubicBezierCurve&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},i=a=>{let s=[],l,u;for(l=0,u=a.length;l<u;l++)a[l]instanceof Ke.QuadraticBezierCurve&&(a[l]=ex(a[l]));for(l=0,u=a.length;l<u;l++){let p=a[l],f=l>0?a[l-1]:null,h;p instanceof Ke.CubicBezierCurve?(h=this.createPoint(p.v0),h.controls[1].position.copy(p.v1)):p instanceof Ke.LineCurve&&(h=this.createPoint(p.v1)),h!==void 0&&(f!==null&&o(h,f),s.push(h))}let c=a[a.length-1],d=!1;return c instanceof Ke.CubicBezierCurve?c.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(c.v2),d=!0):c instanceof Ke.LineCurve&&c.v2.equals(s[0].position)&&(d=!0),this.isClosed=d,s};return this.points=i(e.curves),e instanceof Ke.Shape&&(this.shapeHoles=e.holes.map(a=>{let s=new Qe;return s.fromShape(a),s})),this.update(),this}updatePoint(e,r){let o=this.getPointByUuid(e);o&&(r.position!==void 0&&o.position.fromArray(r.position),r.roundness!==void 0&&(o.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let i=this.getPointByUuid(e)?.controls[0];i&&(r.position&&i.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let i=this.getPointByUuid(e)?.controls[1];i&&(r.position&&i.position.fromArray(r.position),this.needsUpdate=!0)}};var gf=Math.PI*2;function yf({x:n,y:t},e,r,o,i){return{x:n*e+o,y:t*r+i}}function AT(n,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(n),o=Math.sin(n),i=Math.cos(n+t),a=Math.sin(n+t);return[{x:r-o*e,y:o+r*e},{x:i+a*e,y:a-i*e},{x:i,y:a}]}function cx(n,t,e,r){let o=n*r-t*e<0?-1:1,i=Math.min(1,Math.max(-1,n*e+t*r));return o*Math.acos(i)}function _T(n,t,e,r,o,i,a,s,l,u){let c=Math.pow(o,2),d=Math.pow(i,2),p=Math.pow(a,2),f=Math.pow(s,2),h=c*d-c*f-d*p;h<0&&(h=0),h/=c*f+d*p,h=Math.sqrt(h)*(l===u?-1:1);let m=h*o/i*s,y=h*-i/o*a,g=m+(n+e)/2,b=y+(t+r)/2,w=(a-m)/o,_=(s-y)/i,S=(-a-m)/o,P=(-s-y)/i,O=cx(1,0,w,_),x=cx(w,_,S,P);return!u&&x>0&&(x-=gf),u&&x<0&&(x+=gf),{centerx:g,centery:b,ang1:O,ang2:x}}function ux({px:n,py:t,cx:e,cy:r,rx:o,ry:i,largeArcFlag:a,sweepFlag:s}){let l=[];if(o===0||i===0)return[];let u=(n-e)/2,c=(t-r)/2;if(u===0&&c===0)return[];o=Math.abs(o),i=Math.abs(i);let d=Math.pow(u,2)/Math.pow(o,2)+Math.pow(c,2)/Math.pow(i,2);d>1&&(o*=Math.sqrt(d),i*=Math.sqrt(d));let p=_T(n,t,e,r,o,i,u,c,a,s),{ang1:f,ang2:h}=p,{centerx:m,centery:y}=p,g=Math.abs(h)/(gf/4);Math.abs(1-g)<1e-7&&(g=1);let b=Math.max(Math.ceil(g),1);h/=b;for(let w=0;w<b;w++)l.push(AT(f,h)),f+=h;return l.map(w=>{let{x:_,y:S}=yf(w[0],o,i,m,y),{x:P,y:O}=yf(w[1],o,i,m,y),{x,y:D}=yf(w[2],o,i,m,y);return{x1:_,y1:S,x2:P,y2:O,x,y:D}})}var Mi=require("three");var Ye;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Ye||(Ye={}));var _t;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(_t||(_t={}));function _e(n,t){if(!n)throw t||"Assertion Failed!"}var Se=function(){function n(){}return n.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},n.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},n.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},n.edgeGoesLeft=function(t){return n.vertLeq(t.Dst,t.Org)},n.edgeGoesRight=function(t){return n.vertLeq(t.Org,t.Dst)},n.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},n.edgeEval=function(t,e,r){_e(n.vertLeq(t,e)&&n.vertLeq(e,r));var o=e.s-t.s,i=r.s-e.s;return o+i>0?o<i?e.t-t.t+(t.t-r.t)*(o/(o+i)):e.t-r.t+(r.t-t.t)*(i/(o+i)):0},n.edgeSign=function(t,e,r){_e(n.vertLeq(t,e)&&n.vertLeq(e,r));var o=e.s-t.s,i=r.s-e.s;return o+i>0?(e.t-r.t)*o+(e.t-t.t)*i:0},n.transEval=function(t,e,r){_e(n.transLeq(t,e)&&n.transLeq(e,r));var o=e.t-t.t,i=r.t-e.t;return o+i>0?o<i?e.s-t.s+(t.s-r.s)*(o/(o+i)):e.s-r.s+(r.s-t.s)*(i/(o+i)):0},n.transSign=function(t,e,r){_e(n.transLeq(t,e)&&n.transLeq(e,r));var o=e.t-t.t,i=r.t-e.t;return o+i>0?(e.s-r.s)*o+(e.s-t.s)*i:0},n.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},n.interpolate=function(t,e,r,o){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+o)/2:e+(o-e)*(t/(t+r)):o+(e-o)*(r/(t+r))},n.intersect=function(t,e,r,o,i){var a,s,l;n.vertLeq(t,e)||(l=t,t=e,e=l),n.vertLeq(r,o)||(l=r,r=o,o=l),n.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),n.vertLeq(r,e)?n.vertLeq(e,o)?(a=n.edgeEval(t,r,e),s=n.edgeEval(r,e,o),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,r.s,s,e.s)):(a=n.edgeSign(t,r,e),s=-n.edgeSign(t,o,e),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,r.s,s,o.s)):i.s=(r.s+e.s)/2,n.transLeq(t,e)||(l=t,t=e,e=l),n.transLeq(r,o)||(l=r,r=o,o=l),n.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),n.transLeq(r,e)?n.transLeq(e,o)?(a=n.transEval(t,r,e),s=n.transEval(r,e,o),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,r.t,s,e.t)):(a=n.transSign(t,r,e),s=-n.transSign(t,o,e),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,r.t,s,o.t)):i.t=(r.t+e.t)/2},n}(),Bl=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return n}(),ju=function(){function n(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),n}(),Ka=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return n}(),dx=function(){function n(){var t=new Ka,e=new Bl,r=new ju(0),o=new ju(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=o,o.next=o,o.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=o}return n.prototype.makeEdge_=function(t){var e=new ju(0),r=new ju(1);t.Sym.side<t.side&&(t=t.Sym);var o=t.Sym.next;return r.next=o,o.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},n.prototype.splice_=function(t,e){var r=t.Onext,o=e.Onext;r.Sym.Lnext=e,o.Sym.Lnext=t,t.Onext=o,e.Onext=r},n.prototype.makeVertex_=function(t,e,r){var o=t;_e(o,"Vertex can't be null!");var i=r.prev;o.prev=i,i.next=o,o.next=r,r.prev=o,o.anEdge=e;var a=e;do a.Org=o,a=a.Onext;while(a!==e)},n.prototype.makeFace_=function(t,e,r){var o=t;_e(o,"Face can't be null");var i=r.prev;o.prev=i,i.next=o,o.next=r,r.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=r.inside;var a=e;do a.Lface=o,a=a.Lnext;while(a!==e)},n.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},n.prototype.killVertex_=function(t,e){var r=t.anEdge,o=r;do o.Org=e,o=o.Onext;while(o!==r);var i=t.prev,a=t.next;a.prev=i,i.next=a},n.prototype.killFace_=function(t,e){var r=t.anEdge,o=r;do o.Lface=e,o=o.Lnext;while(o!==r);var i=t.prev,a=t.next;a.prev=i,i.next=a},n.prototype.makeEdge=function(){var t=new Ka,e=new Ka,r=new Bl,o=this.makeEdge_(this.eHead);return this.makeVertex_(t,o,this.vHead),this.makeVertex_(e,o.Sym,this.vHead),this.makeFace_(r,o,this.fHead),o},n.prototype.splice=function(t,e){var r=!1,o=!1;if(t!==e){if(e.Org!==t.Org&&(o=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!o){var i=new Ka;this.makeVertex_(i,e,t.Org),t.Org.anEdge=t}if(!r){var a=new Bl;this.makeFace_(a,e,t.Lface),t.Lface.anEdge=t}}},n.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var o=new Bl;this.makeFace_(o,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},n.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var o=new Ka;return this.makeVertex_(o,r,e.Org),e.Lface=r.Lface=t.Lface,e},n.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},n.prototype.connect=function(t,e){var r=!1,o=this.makeEdge_(t),i=o.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(o,t.Lnext),this.splice_(i,e),o.Org=t.Dst,i.Org=e.Org,o.Lface=i.Lface=t.Lface,t.Lface.anEdge=i,!r){var a=new Bl;this.makeFace_(a,o,t.Lface)}return o},n.prototype.zapFace=function(t){var e=t.anEdge,r,o,i,a,s;o=e.Lnext;do r=o,o=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),i=r.Sym,i.Onext===i?this.killVertex_(i.Org,null):(i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(r));while(r!=e);a=t.prev,s=t.next,s.prev=a,a.next=s},n.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},n.prototype.mergeConvexFaces=function(t){var e,r,o,i,a,s,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,a=r.Org;o=r.Lnext,i=r.Sym,i&&i.Lface&&i.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(i.Lface),s+l-2<=t&&Se.vertCCW(r.Lprev.Org,r.Org,i.Lnext.Lnext.Org)&&Se.vertCCW(i.Lprev.Org,i.Org,r.Lnext.Lnext.Org)&&(o=i.Lnext,this.delete(i),r=null,i=null)),!(r&&r.Lnext.Org===a);)r=o;return!0},n.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,o,i,a,s,l,u;for(i=t,i=t;(o=i.next)!==t;i=o){_e(o.prev===i),l=o.anEdge;do _e(l.Sym!==l),_e(l.Sym.Sym===l),_e(l.Lnext.Onext.Sym===l),_e(l.Onext.Sym.Lnext===l),_e(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(_e(o.prev===i&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){_e(a.prev===s),l=a.anEdge;do _e(l.Sym!==l),_e(l.Sym.Sym===l),_e(l.Lnext.Onext.Sym===l),_e(l.Onext.Sym.Lnext===l),_e(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(_e(a.prev===s&&a.anEdge===null),u=r,u=r;(l=u.next)!==r;u=l)_e(l.Sym.next===u.Sym),_e(l.Sym!==l),_e(l.Sym.Sym===l),_e(l.Org!==null),_e(l.Dst!==null),_e(l.Lnext.Onext.Sym===l),_e(l.Onext.Sym.Lnext===l);_e(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},n}(),px=function(){function n(){this.handle=null}return n}(),fx=function(){function n(){this.key=null,this.node=0}return n}(),PT=function(){function n(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new px,this.handles[r]=new fx;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,o,i,a;for(o=e[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[e[a+1].handle].key,r[e[a].handle].key)&&++a,_e(a<=this.max),i=e[a].handle,a>this.size||this.leq(r[o].key,r[i].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=i,r[i].node=t,t=a}},n.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,o,i,a;for(o=e[t].handle;;){if(a=t>>1,i=e[a].handle,a===0||this.leq(r[i].key,r[o].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=i,r[i].node=t,t=a}},n.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var o,i;for(i=this.nodes.length,this.nodes.length=this.max+1,o=i;o<this.nodes.length;o++)this.nodes[o]=new px;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new fx}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},n.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,o=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),o},n.prototype.delete=function(t){var e=this.nodes,r=this.handles,o;_e(t>=1&&t<=this.max&&r[t].key!==null),o=r[t].node,e[o].handle=e[this.size].handle,r[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(r[e[o>>1].handle].key,r[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},n}(),xf=function(){function n(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return n}(),hx=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),OT=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new hx,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(t){return this.insertBefore(this.head,t)},n.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},n.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new hx;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},n.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},n}(),CT=function(){function n(){}return n.regionBelow=function(t){return t.nodeUp.prev.key},n.regionAbove=function(t){return t.nodeUp.next.key},n.debugEvent=function(t){},n.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.edgeLeq=function(t,e,r){var o=t.event,i=e.eUp,a=r.eUp;if(i.Dst===o)return a.Dst===o?Se.vertLeq(i.Org,a.Org)?Se.edgeSign(a.Dst,i.Org,a.Org)<=0:Se.edgeSign(i.Dst,a.Org,i.Org)>=0:Se.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return Se.edgeSign(i.Dst,o,i.Org)>=0;var s=Se.edgeEval(i.Dst,o,i.Org),l=Se.edgeEval(a.Dst,o,a.Org);return s>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&_e(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){_e(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},n.topLeftRegion=function(t,e){var r=e.eUp.Org,o;do e=n.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(o=t.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;n.fixUpperEdge(t,e,o),e=n.regionAbove(e)}return e},n.topRightRegion=function(t){var e=t.eUp.Dst;do t=n.regionAbove(t);while(t.eUp.Dst===e);return t},n.addRegionBelow=function(t,e,r){var o=new xf;return o.eUp=r,o.nodeUp=t.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,r.activeRegion=o,o},n.isWindingInside=function(t,e){switch(t.windingRule){case Ye.ODD:return(e&1)!==0;case Ye.NONZERO:return e!==0;case Ye.POSITIVE:return e>0;case Ye.NEGATIVE:return e<0;case Ye.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(t,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(t,e.windingNumber)},n.finishRegion=function(t,e){var r=e.eUp,o=r.Lface;o.inside=e.inside,o.anEdge=r,n.deleteRegion(t,e)},n.finishLeftRegions=function(t,e,r){for(var o,i=null,a=e,s=e.eUp;a!==r;){if(a.fixUpperEdge=!1,i=n.regionBelow(a),o=i.eUp,o.Org!=s.Org){if(!i.fixUpperEdge){n.finishRegion(t,a);break}o=t.mesh.connect(s.Lprev,o.Sym),n.fixUpperEdge(t,i,o)}s.Onext!==o&&(t.mesh.splice(o.Oprev,o),t.mesh.splice(s,o)),n.finishRegion(t,a),s=i.eUp,a=i}return s},n.addRightEdges=function(t,e,r,o,i,a){var s,l,u,c,d=!0;u=r;do _e(Se.vertLeq(u.Org,u.Dst)),n.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==o);for(i===null&&(i=n.regionBelow(e).eUp.Rprev),l=e,c=i;s=n.regionBelow(l),u=s.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(t.mesh.splice(u.Oprev,u),t.mesh.splice(c.Oprev,u)),s.windingNumber=l.windingNumber-u.winding,s.inside=n.isWindingInside(t,s.windingNumber),l.dirty=!0,!d&&n.checkForRightSplice(t,l)&&(n.addWinding(u,c),n.deleteRegion(t,l),t.mesh.delete(c)),d=!1,l=s,c=u;l.dirty=!0,_e(l.windingNumber-u.winding===s.windingNumber),a&&n.walkDirtyRegions(t,l)},n.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},n.vertexWeights=function(t,e,r){var o=Se.vertL1dist(e,t),i=Se.vertL1dist(r,t),a=.5*i/(o+i),s=.5*o/(o+i);t.coords[0]+=a*e.coords[0]+s*r.coords[0],t.coords[1]+=a*e.coords[1]+s*r.coords[1],t.coords[2]+=a*e.coords[2]+s*r.coords[2]},n.getIntersectData=function(t,e,r,o,i,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,r,o),n.vertexWeights(e,i,a)},n.checkForRightSplice=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp;if(Se.vertLeq(o.Org,i.Org)){if(Se.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;Se.vertEq(o.Org,i.Org)?o.Org!==i.Org&&(t.pq.delete(o.Org.pqHandle),n.spliceMergeVertices(t,i.Oprev,o)):(t.mesh.splitEdge(i.Sym),t.mesh.splice(o,i.Oprev),e.dirty=r.dirty=!0)}else{if(Se.edgeSign(o.Dst,i.Org,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Oprev,o)}return!0},n.checkForLeftSplice=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp,a;if(_e(!Se.vertEq(o.Dst,i.Dst)),Se.vertLeq(o.Dst,i.Dst)){if(Se.edgeSign(o.Dst,i.Dst,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,a=t.mesh.splitEdge(o),t.mesh.splice(i.Sym,a),a.Lface.inside=e.inside}else{if(Se.edgeSign(i.Dst,o.Dst,i.Org)>0)return!1;e.dirty=r.dirty=!0,a=t.mesh.splitEdge(i),t.mesh.splice(o.Lnext,i.Sym),a.Rface.inside=e.inside}return!0},n.checkForIntersect=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp,a=o.Org,s=i.Org,l=o.Dst,u=i.Dst,c,d,p=new Ka,f,h;if(_e(!Se.vertEq(u,l)),_e(Se.edgeSign(l,t.event,a)<=0),_e(Se.edgeSign(u,t.event,s)>=0),_e(a!==t.event&&s!==t.event),_e(!e.fixUpperEdge&&!r.fixUpperEdge),a===s||(c=Math.min(a.t,l.t),d=Math.max(s.t,u.t),c>d))return!1;if(Se.vertLeq(a,s)){if(Se.edgeSign(u,a,s)>0)return!1}else if(Se.edgeSign(l,s,a)<0)return!1;return n.debugEvent(t),Se.intersect(l,a,u,s,p),_e(Math.min(a.t,l.t)<=p.t),_e(p.t<=Math.max(s.t,u.t)),_e(Math.min(u.s,l.s)<=p.s),_e(p.s<=Math.max(s.s,a.s)),Se.vertLeq(p,t.event)&&(p.s=t.event.s,p.t=t.event.t),f=Se.vertLeq(a,s)?a:s,Se.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),Se.vertEq(p,a)||Se.vertEq(p,s)?(n.checkForRightSplice(t,e),!1):!Se.vertEq(l,t.event)&&Se.edgeSign(l,t.event,p)>=0||!Se.vertEq(u,t.event)&&Se.edgeSign(u,t.event,p)<=0?u===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Sym,o),e=n.topLeftRegion(t,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),r),n.addRightEdges(t,e,o.Oprev,o,o,!0),!0):l===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(o.Lnext,i.Oprev),r=e,e=n.topRightRegion(e),h=n.regionBelow(e).eUp.Rprev,r.eUp=i.Oprev,i=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,i.Onext,o.Rprev,h,!0),!0):(Se.edgeSign(l,t.event,p)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),Se.edgeSign(u,t.event,p)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),!1):(t.mesh.splitEdge(o.Sym),t.mesh.splitEdge(i.Sym),t.mesh.splice(i.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=t.pq.insert(o.Org),n.getIntersectData(t,o.Org,a,l,s,u),n.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(t,e){for(var r=n.regionBelow(e),o,i;;){for(;r.dirty;)e=r,r=n.regionBelow(r);if(!e.dirty&&(r=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,i=r.eUp,o.Dst!==i.Dst&&n.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(n.deleteRegion(t,r),t.mesh.delete(i),r=n.regionBelow(e),i=r.eUp):e.fixUpperEdge&&(n.deleteRegion(t,e),t.mesh.delete(o),e=n.regionAbove(r),o=e.eUp)),o.Org!==i.Org)if(o.Dst!==i.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(o.Dst===t.event||i.Dst===t.event)){if(n.checkForIntersect(t,e))return}else n.checkForRightSplice(t,e);o.Org===i.Org&&o.Dst===i.Dst&&(n.addWinding(i,o),n.deleteRegion(t,e),t.mesh.delete(o),e=n.regionAbove(r))}},n.connectRightVertex=function(t,e,r){var o,i=r.Onext,a=n.regionBelow(e),s=e.eUp,l=a.eUp,u=!1;if(s.Dst!==l.Dst&&n.checkForIntersect(t,e),Se.vertEq(s.Org,t.event)&&(t.mesh.splice(i.Oprev,s),e=n.topLeftRegion(t,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),a),u=!0),Se.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(t,a,null),u=!0),u){n.addRightEdges(t,e,r.Onext,i,i,!0);return}Se.vertLeq(l.Org,s.Org)?o=l.Oprev:o=s,o=t.mesh.connect(r.Lprev,o),n.addRightEdges(t,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(t,e)},n.connectLeftDegenerate=function(t,e,r){var o,i,a,s,l;if(o=e.eUp,Se.vertEq(o.Org,r)){_e(!1),n.spliceMergeVertices(t,o,r.anEdge);return}if(!Se.vertEq(o.Dst,r)){t.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(t.mesh.delete(o.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,o),n.sweepEvent(t,r);return}_e(!1),e=n.topRightRegion(e),l=n.regionBelow(e),a=l.eUp.Sym,i=s=a.Onext,l.fixUpperEdge&&(_e(i!==a),n.deleteRegion(t,l),t.mesh.delete(a),a=i.Oprev),t.mesh.splice(r.anEdge,a),Se.edgeGoesLeft(i)||(i=null),n.addRightEdges(t,e,a.Onext,s,i,!0)},n.connectLeftVertex=function(t,e){var r,o,i,a,s,l,u=new xf;if(u.eUp=e.anEdge.Sym,r=t.dict.search(u).key,o=n.regionBelow(r),!!o){if(a=r.eUp,s=o.eUp,Se.edgeSign(a.Dst,e,a.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(i=Se.vertLeq(s.Dst,a.Dst)?r:o,r.inside||i.fixUpperEdge){if(i===r)l=t.mesh.connect(e.anEdge.Sym,a.Lnext);else{var c=t.mesh.connect(s.Dnext,e.anEdge);l=c.Sym}i.fixUpperEdge?n.fixUpperEdge(t,i,l):n.computeWinding(t,n.addRegionBelow(t,r,l)),n.sweepEvent(t,e)}else n.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(t,e){t.event=e,n.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){n.connectLeftVertex(t,e);return}var o=n.topLeftRegion(t,r.activeRegion);_e(o!==null);var i=n.regionBelow(o),a=i.eUp,s=n.finishLeftRegions(t,i,null);s.Onext===a?n.connectRightVertex(t,o,s):n.addRightEdges(t,o,s.Onext,a,a,!0)},n.addSentinel=function(t,e,r,o){var i=new xf,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=o,a.Dst.s=e,a.Dst.t=o,t.event=a.Dst,i.eUp=a,i.windingNumber=0,i.inside=!1,i.fixUpperEdge=!1,i.sentinel=!0,i.dirty=!1,i.nodeUp=t.dict.insert(i)},n.initEdgeDict=function(t){t.dict=new OT(t,n.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],o=t.bmin[0]-e,i=t.bmax[0]+e,a=t.bmin[1]-r,s=t.bmax[1]+r;n.addSentinel(t,o,i,a),n.addSentinel(t,o,i,s)},n.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(_e(e.fixUpperEdge),_e(++r===1)),_e(e.windingNumber===0),n.deleteRegion(t,e)},n.removeDegenerateEdges=function(t){var e,r,o,i=t.mesh.eHead;for(e=i.next;e!==i;e=r)r=e.next,o=e.Lnext,Se.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(t,o,e),t.mesh.delete(e),e=o,o=e.Lnext),o.Lnext===e&&(o!==e&&((o===r||o===r.Sym)&&(r=r.next),t.mesh.delete(o)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},n.initPriorityQ=function(t){var e,r,o,i=0;for(o=t.mesh.vHead,r=o.next;r!==o;r=r.next)i++;for(i+=8,e=t.pq=new PT(i,Se.vertLeq),o=t.mesh.vHead,r=o.next;r!==o;r=r.next)r.pqHandle=e.insert(r);return r!==o?!1:(e.init(),!0)},n.donePriorityQ=function(t){t.pq=null},n.removeDegenerateFaces=function(t,e){var r,o,i;for(r=e.fHead.next;r!==e.fHead;r=o)o=r.next,i=r.anEdge,_e(i.Lnext!==i),i.Lnext.Lnext===i&&(n.addWinding(i.Onext,i),t.mesh.delete(i));return!0},n.computeInterior=function(t,e){e===void 0&&(e=!0);var r,o;if(n.removeDegenerateEdges(t),!n.initPriorityQ(t))return!1;for(n.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;o=t.pq.min(),!(o===null||!Se.vertEq(o,r));)o=t.pq.extractMin(),n.spliceMergeVertices(t,r.anEdge,o.anEdge);n.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,n.debugEvent(t),n.doneEdgeDict(t),n.donePriorityQ(t),n.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},n}(),TT=function(){function n(){this.mesh=new dx,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=Ye.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return n.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},n.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},n.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},n.prototype.computeNormal_=function(t){var e,r,o,i,a,s,l=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],p=[0,0,0],f=[null,null,null],h=[null,null,null],m=this.mesh.vHead;e=m.next;for(var y=0;y<3;++y)i=e.coords[y],u[y]=i,h[y]=e,l[y]=i,f[y]=e;for(e=m.next;e!==m;e=e.next)for(var g=0;g<3;++g)i=e.coords[g],i<u[g]&&(u[g]=i,h[g]=e),i>l[g]&&(l[g]=i,f[g]=e);var b=0;if(l[1]-u[1]>l[0]-u[0]&&(b=1),l[2]-u[2]>l[b]-u[b]&&(b=2),u[b]>=l[b]){t[0]=0,t[1]=0,t[2]=1;return}for(s=0,r=h[b],o=f[b],c[0]=r.coords[0]-o.coords[0],c[1]=r.coords[1]-o.coords[1],c[2]=r.coords[2]-o.coords[2],e=m.next;e!==m;e=e.next)d[0]=e.coords[0]-o.coords[0],d[1]=e.coords[1]-o.coords[1],d[2]=e.coords[2]-o.coords[2],p[0]=c[1]*d[2]-c[2]*d[1],p[1]=c[2]*d[0]-c[0]*d[2],p[2]=c[0]*d[1]-c[1]*d[0],a=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],a>s&&(s=a,t[0]=p[0],t[1]=p[1],t[2]=p[2]);s<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},n.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,o,i=0,a=t.next;a!==t;a=a.next)if(o=a.anEdge,!(o.winding<=0))do i+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==a.anEdge);if(i<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},n.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,o,i=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),i=!0),r=this.sUnit,o=this.tUnit;var a=this.longAxis_(e);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,o[a]=0,o[(a+1)%3]=0,o[(a+2)%3]=e[a]>0?1:-1;for(var s=t.next;s!==t;s=s.next)s.s=this.dot_(s.coords,r),s.t=this.dot_(s.coords,o);i&&this.checkOrientation_();for(var l=!0,u=t.next;u!==t;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},n.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(t,e){var r,o;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Se.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Se.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var i=void 0;r.Lnext!==o;)if(Se.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(Se.edgeGoesLeft(o.Lnext)||Se.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)i=t.connect(o.Lnext,o),o=i.Sym;o=o.Lprev}else{for(;o.Lnext!==r&&(Se.edgeGoesRight(r.Lprev)||Se.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)i=t.connect(r,r.Lprev),r=i.Sym;r=r.Lnext}if(o.Lnext===r)throw"Mono region invalid";for(;o.Lnext.Lnext!==r;)i=t.connect(o.Lnext,o),o=i.Sym;return!0},n.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},n.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},n.prototype.setWindingNumber_=function(t,e,r){for(var o,i=t.eHead.next;i!==t.eHead;i=o)o=i.next,i.Rface.inside!==i.Lface.inside?i.winding=i.Lface.inside?e:-e:r?t.delete(i):i.winding=0},n.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},n.prototype.outputPolymesh_=function(t,e,r,o){var i,a=0,s=0,l;r>3&&t.mergeConvexFaces(r);for(var u=t.vHead.next;u!==t.vHead;u=u.next)u.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){i=c.anEdge,l=0;do{var u=i.Org;u.n===-1&&(u.n=s,s++),l++,i=i.Lnext}while(i!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=a,++a}this.elementCount=a,e===_t.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=s,this.vertices=[],this.vertices.length=s*o,this.vertexIndices=[],this.vertexIndices.length=s;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var d=u.n*o;this.vertices[d+0]=u.coords[0],this.vertices[d+1]=u.coords[1],o>2&&(this.vertices[d+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var p=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){i=c.anEdge,l=0;do{var u=i.Org;this.elements[p++]=u.n,l++,i=i.Lnext}while(i!==c.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1;if(e===_t.CONNECTED_POLYGONS){i=c.anEdge;do this.elements[p++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==c.anEdge);for(var h=l;h<r;++h)this.elements[p++]=-1}}},n.prototype.outputContours_=function(t,e){var r,o,i=0,a=0;this.vertexCount=0,this.elementCount=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){o=r=s.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==o);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,u=0,c=0;i=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){a=0,o=r=s.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==o);this.elements[c++]=i,this.elements[c++]=a,i+=a}},n.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new dx),t<2&&(t=2),t>3&&(t=3);for(var r=null,o=0;o<e.length;o+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[o+0],r.Org.coords[1]=e[o+1],t>2?r.Org.coords[2]=e[o+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},n.prototype.tesselate=function(t,e,r,o,i,a){if(t===void 0&&(t=Ye.ODD),e===void 0&&(e=_t.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,i&&(this.normal[0]=i[0],this.normal[1]=i[1],this.normal[2]=i[2]),this.windingRule=t,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),CT.computeInterior(this,a);var s=this.mesh;return e===_t.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===_t.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,r,o),!0},n}();function go(n){var t=n.windingRule,e=t===void 0?Ye.ODD:t,r=n.elementType,o=r===void 0?_t.POLYGONS:r,i=n.polySize,a=i===void 0?3:i,s=n.vertexSize,l=s===void 0?2:s,u=n.normal,c=u===void 0?[0,0,1]:u,d=n.contours,p=d===void 0?[]:d,f=n.strict,h=f===void 0?!0:f,m=n.debug,y=m===void 0?!1:m;if(!p&&h)throw new Error("Contours can't be empty");if(!!p){var g=new TT;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var b=0;b<p.length;b++)g.addContour(l||2,p[b]);return g.tesselate(e,o,a,l,c,h),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var M4=Ye.ODD,I4=Ye.NONZERO,N4=Ye.POSITIVE,D4=Ye.NEGATIVE,E4=Ye.ABS_GEQ_TWO,B4=_t.POLYGONS,L4=_t.CONNECTED_POLYGONS,R4=_t.BOUNDARY_CONTOURS;var xo=require("three");var Uu=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*Uu.eSize;this.buffer=new ArrayBuffer(r);let o=Float32Array.BYTES_PER_ELEMENT,i=0;this.positions=new Float32Array(this.buffer,i*o,3*t),i+=3*t,this.normals=new Float32Array(this.buffer,i*o,3*t),i+=3*t,this.uvs=new Float32Array(this.buffer,i*o,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*Uu.eSize,o=new ArrayBuffer(r),i=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*i,3*t);a+=3*t;let l=new Float32Array(o,a*i,3*t);a+=3*t;let u=new Float32Array(o,a*i,2*t);e?(s.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),u.set(this.uvs.subarray(0,this.size*2))):(s.set(this.positions),l.set(this.normals),u.set(this.uvs)),this.buffer=o,this.positions=s,this.normals=l,this.uvs=u,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let o=this.capacity;for(;e>o;)o*=2;this.realloc(o)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Ll=Uu;Ll.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var xx=hr(gx()),Rl={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Af={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},_f={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},wf=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),Yn=class extends xo.BufferGeometry{constructor(e,r,o=0,i=12,a=3,s=Ye.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=i,this._bevelSegmentsInput=a;let u=this._shape.extractShapePointsToFlatArray([],i),c=this._shape.shapeHoles.map(T=>{let I=T.extractShapePointsToFlatArray([],i),E=[];for(let B=I.length-1;B>=1;B-=2){let R=I[B-1],k=I[B-0];E.push(R,k)}return E}),d=[],p=[];for(let T=0;T<u.length;T+=2)p.push([u[T],u[T+1]]);d.push(p);for(let T=0;T<c.length;T++){let I=c[T],E=[];for(let B=0;B<I.length;B+=2)E.push([I[B],I[B+1]]);d.push(E)}let f;e.isText?f=new xo.Box2().setFromPoints(e.points.map(I=>I.position)).getSize(new xo.Vector2).length()*.1:d[0].length===0?f=o:f=(0,xx.default)(d).distance,o<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(o,f,r/2),this._bevelSegments=Math.floor(a));let h;try{h=go({windingRule:s,elementType:_t.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{h=Rl}let m;try{m=go({windingRule:Ye.ODD,elementType:_t.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]})}catch{m=Af}if(!h)throw new Error("error generating geometry");let y=h.elementCount;if(m){h.elementCount+=m.elementCount;for(let T=0;T<m.elements.length;T++){let I=m.elements[T],E=T%2===0?h.vertexCount:0;h.elements.push(I+E)}for(let T=0;T<m.vertexIndices.length;T++){let I=m.vertexIndices[T],E=h.vertexCount;h.vertexIndices.push(I+E)}for(let T=0;T<m.vertices.length;T++){let I=m.vertices[T];h.vertices.push(I)}}let g=1/0,b=-1/0,w=1/0,_=-1/0;for(let T=0,I=h.vertexCount;T<I;T++){let E=T*2,B=h.vertices[E+0],R=h.vertices[E+1];B<g&&(g=B),B>b&&(b=B),R<w&&(w=R),R>_&&(_=R)}this._minX=g,this._minY=w,this._width=b-g,this._height=_-w,this._buffer=new Ll(this._computeBufferEstimatedSize(h));let S=[],P=[];for(let T=h.elementCount-1;T>=0;T--){let I=T>=y,E=T*2,B=h.elements[E+0],R=h.elements[E+1],k=B+R,V={start:B,count:R,normals:[],continuous:[],concave:[]},q=B,F=k-1,U=B+1,H=this._shape.roundedCurves.length;do{let te=q-B,Y=h.vertices[F*2+0],ee=h.vertices[F*2+1],Q=h.vertices[q*2+0],W=h.vertices[q*2+1],ue=h.vertices[U*2+0],le=h.vertices[U*2+1],ne=Q-Y,ce=W-ee,ae=Math.sqrt(ne*ne+ce*ce);ne/=ae,ce/=ae;let me=Q-ue,fe=W-le,he=Math.sqrt(me*me+fe*fe);me/=he,fe/=he,V.normals[te*2+0]=-fe,V.normals[te*2+1]=me,V.concave[te]=ne*fe-ce*me>0;let xe=h.vertexIndices[q];if(Array.isArray(xe))V.continuous[te]=!1;else{let[ye,C]=this._shape.getCurveIndexFromVertexId(xe-1,!0);if(C>0&&C<1)V.continuous[te]=!0;else{let ie=C===1?ye+1:ye-1;ie=(ie+H)%H;let Ve=C===1?0:1,He=this._shape.roundedCurves[ye].getTangent(C),ze=this._shape.roundedCurves[ie].getTangent(Ve);V.continuous[te]=He.dot(ze)>.95}}I&&(V.normals[te*2+0]*=-1,V.normals[te*2+1]*=-1),[F,q,U]=[q,U,U+1],U>=k&&(U-=R)}while(U!==B+1);let $=[];$.push({bevelI:0,angle:0,size:0,boundary:{vertices:h.vertices.slice(B*2,k*2),vertexCount:R,vertexIndices:new Array(R).fill(!0).map((te,Y)=>[Y,Y]),elements:[0,R],elementCount:1,mesh:null},reverseMap:[],insetPoints:h.vertices.slice(B*2,k*2)});let J=0;for(let te=1;te<=this._bevelSegments;te++){let Y=te/this._bevelSegments*Math.PI/2,ee=(1-Math.cos(Y))*this._bevel,Q=[],W=[],ue=[],le=[],ne=0;for(let ae=0;ae<R;ae++){let me=ae*2,fe=(ae-1+R)%R*2,he=h.vertices[V.start*2+me+0],xe=h.vertices[V.start*2+me+1],ye=-V.normals[fe+0]*ee,C=-V.normals[fe+1]*ee,ie=-V.normals[me+0]*ee,Ve=-V.normals[me+1]*ee;if(V.concave[ae]||!V.concave[ae]&&I){let He=Math.atan2(C,ye),ze=Math.atan2(Ve,ie);ze>He&&(ze-=Math.PI*2);let Oe=ze-He;if(V.continuous[ae]||I){let jt=He+Oe/2,Ee=Math.cos(jt)*ee,zt=Math.sin(jt)*ee;Q[2*ne+0]=he+Ee*(I?-1:1),Q[2*ne+1]=xe+zt*(I?-1:1),le[ne]=ae,ne++}else{let jt=Math.max(1,Math.floor(i/4*Math.abs(Oe)/Math.PI));for(let Ee=0;Ee<=jt;Ee++){let zt=He+Oe*(Ee/jt),Ut=Math.cos(zt)*ee,fi=Math.sin(zt)*ee;Q[2*ne+0]=he+Ut,Q[2*ne+1]=xe+fi,le[ne]=ae,ne++}}}else Q[2*ne+0]=he+ye,Q[2*ne+1]=xe+C,le[ne]=ae,W[ae]=ne,ne++,Q[2*ne+0]=he,Q[2*ne+1]=xe,le[ne]=ae,ne++,Q[2*ne+0]=he+ie,Q[2*ne+1]=xe+Ve,le[ne]=ae,ue[ae]=ne,ne++}let ce=go({windingRule:Ye.POSITIVE,elementType:_t.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Q],edgeCreateCallback:ae=>{let fe=ae.Org.idx,he=le[fe],xe=le[(fe+1)%le.length];ae.idx=[he,xe],ae.Sym.idx=[xe,he]},vertexIdCallback:ae=>{let me=ae.Lprev.idx;return[me?me[1]:0,ae.idx?ae.idx[0]:0]}});if(!ce)throw console.log("Error"),new Error(`error generating bevel geometry for ${te}'th loop`);if(!ce.vertexCount){let ae=(te-1)/this._bevelSegments*Math.PI/2;J=(1-Math.sin(ae))*this._bevel;break}for(let ae=0;ae<ce.vertexIndices.length;ae++){let[me,fe]=ce.vertexIndices[ae];if(me===fe)continue;let he=fe;fe<me&&(he+=R);for(let xe=me;xe<he;xe++){let ye=xe%R,C=(xe+1)%R;if(!V.continuous[ye]||!V.continuous[C]){ce.vertexIndices[ae]=[me,ye],ce.vertexIndices.splice(ae+1,0,[C,fe]),ce.vertices.splice((ae+1)*2,0,ce.vertices[ae*2],ce.vertices[ae*2+1]);break}}}$.push({bevelI:te,angle:Y,size:ee,boundary:ce,reverseMap:le,insetPoints:Q})}let K=(te,Y,ee)=>{let Q=0,W=te.boundary.vertexIndices.length;for(;Q<W&&ee(te.boundary.vertexIndices[Y]);)Y=(Y+1)%W,Q++;return Q},X=S.length;for(let te=1;te<$.length;te++){let Y=$[te-1],ee=$[te],Q=Y.boundary.vertexIndices.length,W=ee.boundary.vertexIndices.length;if(!Q||!W)break;let ue=V.concave.length,le=0,ne=wf(le,R);for(;!Y.boundary.vertexIndices.filter(ne).length||!ee.boundary.vertexIndices.filter(ne).length;)le++,ne=wf(le,R);let ce=Y.boundary.vertexIndices.findIndex(ne),ae=ee.boundary.vertexIndices.findIndex(ne);do ce=(ce+1)%Q;while(ne(Y.boundary.vertexIndices[ce]));do ae=(ae+1)%W;while(ne(ee.boundary.vertexIndices[ae]));le=(le+1)%R;let me=le,fe=0,he=this._buildBevelVert(V,Y,(ce-1+Q)%Q,void 0,fe),xe=this._buildBevelVert(V,ee,(ae-1+W)%W,void 0,fe),ye=he,C=xe,ie,Ve,He=!1;do{fe=(le||ue)/ue,ne=wf(le,R);let ze=K(Y,ce,ne),Oe=K(ee,ae,ne),jt=He;if(He=!1,ze&&!Oe){for(let Ee=0;Ee<ze;Ee++)ie=this._buildBevelVert(V,Y,(ce+Ee)%Q,Ee/(ze-1),fe),S.push(ye.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,ye.bottomN,C.bottomN),ye=ie;He=!0}else if(!ze&&Oe)for(let Ee=0;Ee<Oe;Ee++)Ve=this._buildBevelVert(V,ee,(ae+Ee)%W,Ee/(Oe-1),fe),S.push(C.topN,ye.topP,Ve.topP),l===!1&&S.push(ye.bottomP,C.bottomN,Ve.bottomP),C=Ve;else if(ze&&Oe)if(ie=this._buildBevelVert(V,Y,ce,0,fe),Ve=this._buildBevelVert(V,ee,ae,0,fe),jt?(S.push(ye.topN,Ve.topP,C.topN),S.push(ye.topN,ie.topP,Ve.topP),l===!1&&(S.push(Ve.bottomP,ye.bottomN,C.bottomN),S.push(Ve.bottomP,ie.bottomP,ye.bottomN))):(S.push(C.topN,ye.topN,ie.topP),S.push(C.topN,ie.topP,Ve.topP),l===!1&&(S.push(ie.bottomP,ye.bottomN,C.bottomN),S.push(ie.bottomP,C.bottomN,Ve.bottomP))),ye=ie,C=Ve,ze===Oe)for(let Ee=1;Ee<ze;Ee++)ie=this._buildBevelVert(V,Y,(ce+Ee)%Q,Ee/(ze-1),fe),Ve=this._buildBevelVert(V,ee,(ae+Ee)%W,Ee/(Oe-1),fe),S.push(ye.topN,ie.topP,C.topN),S.push(C.topN,ie.topP,Ve.topP),l===!1&&(S.push(ie.bottomP,ye.bottomN,C.bottomN),S.push(ie.bottomP,C.bottomN,Ve.bottomP)),ye=ie,C=Ve;else if(ze>Oe){let Ee=ze/Oe,zt=0;for(let Ut=1;Ut<ze;Ut++)ie=this._buildBevelVert(V,Y,(ce+Ut)%Q,Ut/(ze-1),fe),S.push(ye.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,ye.bottomN,C.bottomN),ye=ie,Ut>(zt+1)*Ee&&(zt++,Ve=this._buildBevelVert(V,ee,(ae+zt)%W,zt/(Oe-1),fe),S.push(C.topN,ie.topP,Ve.topP),l===!1&&S.push(ie.bottomP,C.bottomN,Ve.bottomP),C=Ve)}else{let Ee=Oe/ze,zt=0;for(let Ut=1;Ut<Oe;Ut++)Ve=this._buildBevelVert(V,ee,(ae+Ut)%W,Ut/(Oe-1),fe),S.push(C.topN,ie.topP,Ve.topP),l===!1&&S.push(ie.bottomP,C.bottomN,Ve.bottomP),C=Ve,Ut>(zt+1)*Ee&&(zt++,ie=this._buildBevelVert(V,Y,(ce+zt)%Q,zt/(ze-1),fe),S.push(ye.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,ye.bottomN,C.bottomN),ye=ie)}ce=(ce+ze)%Q,ae=(ae+Oe)%W,le=(le+1)%ue}while(le!==me)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall($,V,S),I){let te=[];for(let Y=S.length-1;Y>=X+2;Y-=3){let ee=S[Y-2],Q=S[Y-1],W=S[Y-0];te.push(W,Q,ee)}S.splice(X,S.length-X,...te)}if(I){let te=[];for(let Y=$[$.length-1].boundary.vertices.length-1;Y>=1;Y-=2){let ee=$[$.length-1].boundary.vertices[Y-1],Q=$[$.length-1].boundary.vertices[Y-0];te.push(ee,Q)}P.push(te)}if(!I){let te=$[$.length-1],Y;try{Y=go({windingRule:$.length>1?Ye.POSITIVE:Ye.ODD,elementType:_t.POLYGONS,vertexSize:2,strict:!0,contours:[te.insetPoints,...P]})}catch{Y=_f}if(!Y)throw new Error("Error generating geometry for surface");c.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let ee=0;ee<Y.elementCount*3;ee+=3){let Q=this._buildSurfaceVert(Y,Y.elements[ee+0],J),W=this._buildSurfaceVert(Y,Y.elements[ee+1],J),ue=this._buildSurfaceVert(Y,Y.elements[ee+2],J);S.push(Q.top,W.top,ue.top),l===!1&&S.push(ue.bottom,W.bottom,Q.bottom)}}this.vertexCache={}}this._buffer.shrink();let O=new xo.BufferAttribute(Uint32Array.from(S),1),x=new xo.BufferAttribute(this._buffer.positions,3),D=new xo.BufferAttribute(this._buffer.normals,3),N=new xo.BufferAttribute(this._buffer.uvs,2);x.needsUpdate=!0,D.needsUpdate=!0,N.needsUpdate=!0,O.needsUpdate=!0,this.setAttribute("position",x),this.setAttribute("normal",D),this.setAttribute("uv",N),this.setIndex(O)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,i,a),u=this._buildBevelVert(r,i,(a+1)%s);o.push(u.topP,l.topN,l.bottomN),o.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,r,o){let i=r.toString();if(i in this.vertexCache)return this.vertexCache[i];let a=e.vertices[r*2+0],s=e.vertices[r*2+1],l=(a-this._minX)/this._width,u=(s-this._minY)/this._height;this.forPathBevel&&(u=1);let c=this._buffer.get(this.forPathBevel?1:2),d=c*3,p=c*2,f={top:c+0,bottom:c+1};return this._buffer.positions[d+0]=a,this._buffer.positions[d+1]=s,this._buffer.positions[d+2]=this.forPathBevel?this._bevel:this._depth-o,this._buffer.normals[d+0]=0,this._buffer.normals[d+1]=0,this._buffer.normals[d+2]=1,this._buffer.uvs[p+0]=l,this._buffer.uvs[p+1]=u,this.forPathBevel===!1&&(this._buffer.positions[d+3]=a,this._buffer.positions[d+4]=s,this._buffer.positions[d+5]=o,this._buffer.normals[d+3]=0,this._buffer.normals[d+4]=0,this._buffer.normals[d+5]=-1,this._buffer.uvs[p+2]=l,this._buffer.uvs[p+3]=u),this.vertexCache[i]=f,f}_buildBevelVert(e,r,o,i=1,a){let s=`${r.bevelI}:${o}`;if(s in this.vertexCache&&a!==0&&a!==1&&(!a||a===this.vertexCache[s].pathBevelUCoord))return this.vertexCache[s];let[l,u]=r.boundary.vertexIndices[o],c,d,p,f;l!==u?(d=l,c=u,f=!1,p=e.continuous[d]&&e.continuous[c]):(c=l,d=(c-1+e.count)%e.count,f=e.concave[c]&&r.bevelI>0,p=e.continuous[c]||f);let h=Math.cos(r.angle),m=Math.sin(r.angle),y=o*2,g=c*2,b=d*2,w=r.boundary.vertices[y+0],_=r.boundary.vertices[y+1],S=(1-m)*this._bevel,P=(w-this._minX)/this._width,O=(_-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(P=a),O=1);let x=e.normals[g+0],D=e.normals[g+1],N=e.normals[b+0],T=e.normals[b+1];if(f){let k=N-x,V=T-D;x=x+k*(1-i),D=D+V*(1-i);let q=Math.sqrt(x*x+D*D);x/=q,D/=q}let I=this.forPathBevel?this._buffer.get(p?1:2):this._buffer.get(p?2:4),E=I*3,B=I*2,R={i:o,fi:c,topP:I+0,topN:I+0,bottomP:I+1,bottomN:I+1,pathBevelUCoord:a};return this._buffer.positions[E+0]=w,this._buffer.positions[E+1]=_,this._buffer.positions[E+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[E+0]=x*h,this._buffer.normals[E+1]=D*h,this._buffer.normals[E+2]=m,this._buffer.uvs[B+0]=P,this._buffer.uvs[B+1]=O,this.forPathBevel===!1&&(this._buffer.positions[E+3]=w,this._buffer.positions[E+4]=_,this._buffer.positions[E+5]=S,this._buffer.normals[E+3]=x*h,this._buffer.normals[E+4]=D*h,this._buffer.normals[E+5]=-m,this._buffer.uvs[B+2]=O,this._buffer.uvs[B+3]=P),p||(this.forPathBevel?(I+=1,E+=3,B+=2):(I+=2,E+=6,B+=4),R.topP=I+0,R.bottomP=I+1,this._buffer.positions[E+0]=w,this._buffer.positions[E+1]=_,this._buffer.positions[E+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[E+0]=N*h,this._buffer.normals[E+1]=T*h,this._buffer.normals[E+2]=m,this._buffer.uvs[B+0]=P,this._buffer.uvs[B+1]=O,this.forPathBevel===!1&&(this._buffer.positions[E+3]=w,this._buffer.positions[E+4]=_,this._buffer.positions[E+5]=S,this._buffer.normals[E+3]=N*h,this._buffer.normals[E+4]=T*h,this._buffer.normals[E+5]=-m,this._buffer.uvs[B+2]=O,this._buffer.uvs[B+3]=P)),this.vertexCache[s]=R,R}clone(){let e=new Yn(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=on(this.userData),e}};var Za=class extends Mi.BufferGeometry{constructor(e,r=12,o={}){super();this.type="ShapeGeometry";this.windingRule=Ye.ODD;this.elementType=_t.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:Ye.ODD,elementType:_t.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let i=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(h=>h.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,u=!0,c,d;for(let h=0,m=i.length/2;h<m;h++){let y=h*2,g=i[y+0],b=i[y+1];if(c!==void 0&&g!==c&&(l=!1),d!==void 0&&b!==d&&(u=!1),c=g,d=b,!l&&!u)break}if(!l&&!u)try{s=go({contours:[i,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=Rl}let p=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new Mi.BufferAttribute(new Float32Array(p*3),3),this._normalAttribute=new Mi.BufferAttribute(new Float32Array(p*3),3),this._uvAttribute=new Mi.BufferAttribute(new Float32Array(p*2),2),this._indexAttribute=new Mi.BufferAttribute(new Uint32Array(f*3),1),s){let h=1/0,m=-1/0,y=1/0,g=-1/0;for(let _=0,S=p;_<S;_++){let P=_*2,O=s.vertices[P+0],x=s.vertices[P+1];O<h&&(h=O),O>m&&(m=O),x<y&&(y=x),x>g&&(g=x)}let b=m-h,w=g-y;for(let _=0,S=p;_<S;_++){let P=_*2,O=s.vertices[P+0],x=s.vertices[P+1],D=(O-h)/b,N=(x-y)/w;this._positionAttribute.setXYZ(_,O,x,0),this._normalAttribute.setXYZ(_,0,0,1),this._uvAttribute.setXY(_,D,N)}for(let _=0,S=f;_<S;_++){let P=_*3,O=s.elements[P+0],x=s.elements[P+1],D=s.elements[P+2];this._indexAttribute.setX(P+0,O),this._indexAttribute.setX(P+1,x),this._indexAttribute.setX(P+2,D)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(s?.elementCount??1)*3)}clone(){let e=new Za(this._shape,this._curveSegments);return e.userData=on(this.userData),e}};var Ja=class extends Yn{constructor(e,r,o=0,i=12,a=3,s=Ye.ODD){super(e,r,o,i,a,s);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,i,a),u=this._buildBevelVert(r,i,(a+1)%s);o.push(u.topP,l.topN,l.bottomN),o.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new Ja(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=on(this.userData),e}};var Tr=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Ye.ODD},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=n.shape??t?.shape,s=a?.roundness??e.roundness;a!==void 0&&(a instanceof Qe?(a.width!==r||a.height!==o)&&a.applySize(r,o):a=new Qe(r,o).fromJSON(a),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&a.update());let l=a??new Qe(r,o);return{parameters:Object.assign(e,{width:r,height:o,depth:i,roundness:s}),shape:l}}static build(n){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:o,roundness:i,windingRule:a}=n.parameters;n.shape.roundness=i;let s;return t<=0?s=new Za(n.shape,o,{windingRule:a}):s=new Ja(n.shape,t,e,o,r,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};var bo=require("three"),vx=Math.PI*2,ts=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return e.angle=bo.MathUtils.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof Qe?n.shape:new Qe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,angle:o,innerRadius:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,u=n.shape,c=t*.5,d=e*.5,p=ET(u,c,d,o*Math.PI/180,r,i);u.isClosed=!0,u.update();let f;return o===0?(f=new bo.BufferGeometry,f.setAttribute("position",new bo.Float32BufferAttribute([],3))):f=Tr.create({shape:u,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function ET(n,t,e,r,o,i){if(r>=vx)return o>30||o%4===0?(LT(n,t,e,i),Math.round(o/4)):bx(n,r,o,t,e,i);r=Math.max(r,.001);let a={x:0,y:e},s=r+Math.PI*.5,l={x:Math.cos(s)*t,y:Math.sin(s)*e},u=ux({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return o>30||o%u.length===0?BT(n,a.x,a.y,u,o,t,e,i):bx(n,r,o,t,e,i)}function BT(n,t,e,r,o,i,a,s){let l=Math.round(o/r.length);n.addPoint(es(t,e));for(let u=0,c=r.length;u<c;u++){let d=r[u],p=n.points[u],f=es(d.x,d.y);p.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),n.addPoint(f)}return s>0?Sx(n,i,a,s):n.addPoint(es(0,0)),l}function bx(n,t,e,r,o,i){let a=-t/e;for(let s=0;s<=e;s++){let l=a*s,u=Math.sin(l)*r,c=Math.cos(l)*o;n.addPoint(es(u,c))}return t<vx?i>0?Sx(n,r,o,i):n.addPoint(es(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&wx(n,r,o,i)),1}function LT(n,t,e,r=0,o=0,i=0){let a=.5522847498,s=t*a,l=e*a;n.addPoint(qu(o-t,i,o-t,i-l,o-t,i+l)),n.addPoint(qu(o,i+e,o-s,i+e,o+s,i+e)),n.addPoint(qu(o+t,i,o+t,i+l,o+t,i-l)),n.addPoint(qu(o,i-e,o+s,i-e,o-s,i-e)),r>0&&wx(n,t,e,r)}function es(n,t){return new yo(bo.MathUtils.generateUUID(),new bo.Vector2(n,t))}function qu(n,t,e,r,o,i){let a=es(n,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(o,i),a}function Sx(n,t,e,r){Ax(n,t,e,r).forEach(i=>n.addPoint(i))}function wx(n,t,e,r){let o=Ax(n,t,e,r),i=new Qe;o.forEach(a=>i.addPoint(a)),i.isClosed=!0,n.shapeHoles.push(i)}function Ax(n,t,e,r){let o=r*t/100,i=o*(Math.abs(e)/Math.abs(t)),a=new bo.Vector2(o/t,i/e),s=n.points.map(l=>{let u=l.clone();return u.uuid=bo.MathUtils.generateUUID(),u}).reverse();return s.forEach(l=>{l.position.multiply(a);let u=l.controls[0].position.clone().multiply(a),c=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),s}var vo=require("three"),_x=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??r),i=Math.abs(e.depth??r),a=Math.abs(Math.min(r,i))/2;return{parameters:Object.assign(e,{width:r,height:o,depth:i,radius:a,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:t,height:e,depth:r,radius:o,revolutions:i,segments:a,pathRadius:s,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:d}=n.parameters,p=new Vl(!1,t,e,r,o,i,a,s,l,u,c,d);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},Pf=new vo.Uint32BufferAttribute([0,0,0],1),Vl=class extends vo.BufferGeometry{constructor(t=!0,e=1,r=1,o=1,i=1,a=1,s=1,l=1,u=1,c=1,d=1,p=1){if(super(),a===0)return;let f=t&&a===1;f&&(p=0),d>100&&(d=100),d===0&&(p=0);let h=()=>new vo.Vector3,m=new vo.Vector3,y=h(),g=h(),b=h(),w,_,S,P,O,x,D,N,T=h(),I=h(),E=h(),B=h(),R=h(),k=h(),V=h(),q=h(),F=r-2*l+.001,U=F/a,H=Math.ceil(s*a),$=H+1,J=F/H,K=-F/2,X=c+1,te=2*Math.PI/c,Y=Math.PI/2/p,ee=.01,Q=Math.min((1-d/100)*l,l-ee),W=l-Q,ue=0,le=2,ne=p*le+le,ce=X*ne/le,ae=ce+X*$,me=Math.max(0,X*($+ne)),[fe,he,xe]=[3,3,2].map(vt=>Array(me*vt).fill(0)),ye=[],C=i-l;function ie(vt,at){let co=Math.PI/2;x=at*J,N=2*Math.PI*(x%U)/U+co,x+=K,D=Math.sin(N)*C,O=Math.cos(N)*C,t?vt.set(O,D,x):vt.set(O,x,D)}ie(m,-1e-10),ie(y,0),T.copy(m),ie(m,1);let Ve=m.distanceTo(y),He=f?0:W+Q,ze=Ve*H+2*He,Oe=Q,jt=ze-He;for(let vt=0;vt<=H;vt++){ie(g,vt),q.subVectors(g,T).normalize(),T.copy(g),k.copy(g).setComponent(+t+1,0).normalize(),V.crossVectors(q,k).normalize();let at=vt===0,co=vt===H,tp=at?3*Math.PI/2:Y,rp=at?Oe:jt,bc=at?X:ae,hi=at?0:me-X,Tt=q.clone().multiplyScalar(at?-W:W).add(g),op=q.clone().multiplyScalar(at?-1:1).normalize();for(let Wr=0;Wr<X;Wr++){let ll=Wr*te;if(I.addVectors(m.copy(k).multiplyScalar(l*Math.cos(ll)),y.copy(V).multiplyScalar(l*Math.sin(ll))),E.copy(I).normalize(),at||co){f||(ue=hi+Wr,[0,1,2].forEach(pr=>{fe[ue*3+pr]=Tt.getComponent(pr),he[ue*3+pr]=op.getComponent(pr)}),xe[ue*2]=+co,xe[ue*2+1]=Wr/c),y.copy(E).multiplyScalar(Q),b.addVectors(g,y);for(let pr=0;pr<p;pr++){let mi=pr*Y+tp;B.addVectors(m.copy(q).multiplyScalar(W*Math.sin(mi)),y.copy(E).multiplyScalar(W*Math.cos(mi))),R.copy(B).normalize(),y.addVectors(b,B),B.normalize(),ue=bc+pr*X+Wr,[0,1,2].forEach(Qi=>{fe[ue*3+Qi]=y.getComponent(Qi),he[ue*3+Qi]=R.getComponent(Qi)});let vc=+at+Math.sin(mi);xe[ue*2]=(rp+W*vc)/ze,xe[ue*2+1]=Wr/c}}y.addVectors(g,I),ue=ce+vt*X+Wr,[0,1,2].forEach(pr=>{fe[ue*3+pr]=y.getComponent(pr),he[ue*3+pr]=E.getComponent(pr)}),xe[ue*2]=(He+vt*Ve)/ze,xe[ue*2+1]=Wr/c}}let Ee=$+2*p+le,zt=1,[Ut,fi]=[+f,Ee-1];for(let vt=Ut;vt<=fi-1;vt++){let at=f&&vt===fi-1;for(let co=0;co<X-1;co++)w=vt*X+co,_=w+1,S=(at?co:w)+X,P=(at?co+1:_)+X,vt===0?ye.push(_,P,S):vt===Ee-2?ye.push(w,_,S):ye.push(w,_,S,_,P,S)}this.setIndex(ye),this.setAttribute("position",new vo.Float32BufferAttribute(fe,3)),this.setAttribute("normal",new vo.Float32BufferAttribute(he,3)),this.setAttribute("uv",new vo.Float32BufferAttribute(xe,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,o=Array.from(this.getIndex().array),i,a,s,l,u=6*(e-1)*t.radialSegments,c=e,d=c===e;for(let p=0;p<t.radialSegments;p++)i=c*r+p,a=i+1,s=(d?p:i)+r,l=(d?p+1:a)+r,o[u++]=i,o[u++]=a,o[u++]=s,o[u++]=a,o[u++]=l,o[u++]=s;return o.length=u,Pf.array=o,Pf.count=o.length,Pf}};var Px=require("three");var Ox=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new zl(t*.5,i,a):new Px.IcosahedronGeometry(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},zl=class extends qn{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,i=[-1,o,0,1,o,0,-1,-o,0,1,-o,0,0,-1,o,0,1,o,0,-1,-o,0,1,-o,o,0,-1,o,0,1,-o,0,-1,-o,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],s="IcosahedronGeometry";super(i,a,s,t,e,r),this.type=s}static fromJSON(t){return new zl(t.radius,t.corner,t.cornerSides)}};var Wu=require("three"),Cx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){(n.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{points:t,segments:e,verticalSegments:r}=n.parameters,o=new Wu.Shape;o.moveTo(t[0].x,t[0].y),o.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let i=new Wu.LatheGeometry(o.extractPoints(r).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};var ko=require("three");var hn=require("three");var pe=require("three"),Go=new pe.Matrix4,Of=new pe.Object3D,$u=new pe.Vector3,Xn=class extends pe.EventDispatcher{constructor(){super(),this.uuid=pe.MathUtils.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new pe.Matrix3().getNormalMatrix(t);for(let r=0,o=this.vertices.length;r<o;r++)this.vertices[r].applyMatrix4(t);for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r];i.normal.applyMatrix3(e).normalize();for(let a=0,s=i.vertexNormals.length;a<s;a++)i.vertexNormals[a].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return Go.makeRotationX(t),this.applyMatrix4(Go),this}rotateY(t){return Go.makeRotationY(t),this.applyMatrix4(Go),this}rotateZ(t){return Go.makeRotationZ(t),this.applyMatrix4(Go),this}translate(t,e,r){return Go.makeTranslation(t,e,r),this.applyMatrix4(Go),this}scale(t,e,r){return Go.makeScale(t,e,r),this.applyMatrix4(Go),this}lookAt(t){return Of.lookAt(t),Of.updateMatrix(),this.applyMatrix4(Of.matrix),this}fromBufferGeometry(t){let e=this,r=t.index!==null?t.index:void 0,o=t.attributes;if(o.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let i=o.position,a=o.normal,s=o.color,l=o.uv,u=o.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let p=0;p<i.count;p++)e.vertices.push(new pe.Vector3().fromBufferAttribute(i,p)),s!==void 0&&e.colors.push(new pe.Color().fromBufferAttribute(s,p));function c(p,f,h,m){let y=s===void 0?[]:[e.colors[p].clone(),e.colors[f].clone(),e.colors[h].clone()],g=a===void 0?[]:[new pe.Vector3().fromBufferAttribute(a,p),new pe.Vector3().fromBufferAttribute(a,f),new pe.Vector3().fromBufferAttribute(a,h)],b=new rs(p,f,h,g,y,m);e.faces.push(b),l!==void 0&&e.faceVertexUvs[0].push([new pe.Vector2().fromBufferAttribute(l,p),new pe.Vector2().fromBufferAttribute(l,f),new pe.Vector2().fromBufferAttribute(l,h)]),u!==void 0&&e.faceVertexUvs[1].push([new pe.Vector2().fromBufferAttribute(u,p),new pe.Vector2().fromBufferAttribute(u,f),new pe.Vector2().fromBufferAttribute(u,h)])}let d=t.groups;if(d.length>0)for(let p=0;p<d.length;p++){let f=d[p],h=f.start,m=f.count;for(let y=h,g=h+m;y<g;y+=3)r!==void 0?c(r.getX(y),r.getX(y+1),r.getX(y+2),f.materialIndex):c(y,y+1,y+2,f.materialIndex)}else if(r!==void 0)for(let p=0;p<r.count;p+=3)c(r.getX(p),r.getX(p+1),r.getX(p+2));else for(let p=0;p<i.count;p+=3)c(p,p+1,p+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter($u).negate(),this.translate($u.x,$u.y,$u.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,o=new pe.Matrix4;return o.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let t=new pe.Vector3,e=new pe.Vector3;for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r],a=this.vertices[i.a],s=this.vertices[i.b],l=this.vertices[i.c];t.subVectors(l,s),e.subVectors(a,s),t.cross(e),t.normalize(),i.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let r=0,o=this.vertices.length;r<o;r++)e[r]=new pe.Vector3;if(t){let r=new pe.Vector3,o=new pe.Vector3;for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=this.vertices[s.a],u=this.vertices[s.b],c=this.vertices[s.c];r.subVectors(c,u),o.subVectors(l,u),r.cross(o),e[s.a].add(r),e[s.b].add(r),e[s.c].add(r)}}else{this.computeFaceNormals();for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r];e[i.a].add(i.normal),e[i.b].add(i.normal),e[i.c].add(i.normal)}}for(let r=0,o=this.vertices.length;r<o;r++)e[r].normalize();for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r],a=i.vertexNormals;a.length===3?(a[0].copy(e[i.a]),a[1].copy(e[i.b]),a[2].copy(e[i.c])):(a[0]=e[i.a].clone(),a[1]=e[i.b].clone(),a[2]=e[i.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let r=this.faces[t],o=r.vertexNormals;o.length===3?(o[0].copy(r.normal),o[1].copy(r.normal),o[2].copy(r.normal)):(o[0]=r.normal.clone(),o[1]=r.normal.clone(),o[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e<r;e++){let o=this.faces[e];o.__originalFaceNormal?o.__originalFaceNormal.copy(o.normal):o.__originalFaceNormal=o.normal.clone(),o.__originalVertexNormals||(o.__originalVertexNormals=[]);for(let i=0,a=o.vertexNormals.length;i<a;i++)o.__originalVertexNormals[i]?o.__originalVertexNormals[i].copy(o.vertexNormals[i]):o.__originalVertexNormals[i]=o.vertexNormals[i].clone()}let t=new Xn;t.faces=this.faces;for(let e=0,r=this.morphTargets.length;e<r;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let i=this.morphNormals[e].faceNormals,a=this.morphNormals[e].vertexNormals;for(let s=0,l=this.faces.length;s<l;s++){let u=new pe.Vector3,c={a:new pe.Vector3,b:new pe.Vector3,c:new pe.Vector3};i.push(u),a.push(c)}}let o=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=o.faceNormals[i],u=o.vertexNormals[i];l.copy(s.normal),u.a.copy(s.vertexNormals[0]),u.b.copy(s.vertexNormals[1]),u.c.copy(s.vertexNormals[2])}}for(let e=0,r=this.faces.length;e<r;e++){let o=this.faces[e];o.normal=o.__originalFaceNormal,o.vertexNormals=o.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new pe.Box3),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new pe.Sphere),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,r=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let o,i=this.vertices.length,a=this.vertices,s=t.vertices,l=this.faces,u=t.faces,c=this.colors,d=t.colors;e!==void 0&&(o=new pe.Matrix3().getNormalMatrix(e));for(let p=0,f=s.length;p<f;p++){let m=s[p].clone();e!==void 0&&m.applyMatrix4(e),a.push(m)}for(let p=0,f=d.length;p<f;p++)c.push(d[p].clone());for(let p=0,f=u.length;p<f;p++){let h=u[p],m,y,g=h.vertexNormals,b=h.vertexColors,w=new rs(h.a+i,h.b+i,h.c+i);w.normal.copy(h.normal),o!==void 0&&w.normal.applyMatrix3(o).normalize();for(let _=0,S=g.length;_<S;_++)m=g[_].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),w.vertexNormals.push(m);w.color.copy(h.color);for(let _=0,S=b.length;_<S;_++)y=b[_],w.vertexColors.push(y.clone());w.materialIndex=h.materialIndex+r,l.push(w)}for(let p=0,f=t.faceVertexUvs.length;p<f;p++){let h=t.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let m=0,y=h.length;m<y;m++){let g=h[m],b=[];for(let w=0,_=g.length;w<_;w++)b.push(g[w].clone());this.faceVertexUvs[p].push(b)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},r=[],o=[],i=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],d=Math.round(c.x*i)+"_"+Math.round(c.y*i)+"_"+Math.round(c.z*i);e[d]===void 0?(e[d]=l,r.push(this.vertices[l]),o[l]=r.length-1):o[l]=o[e[d]]}let a=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=o[c.a],c.b=o[c.b],c.c=o[c.c];let d=[c.a,c.b,c.c];for(let p=0;p<3;p++)if(d[p]===d[(p+1)%3]){a.push(l);break}}for(let l=a.length-1;l>=0;l--){let u=a[l];this.faces.splice(u,1);for(let c=0,d=this.faceVertexUvs.length;c<d;c++)this.faceVertexUvs[c].splice(u,1)}let s=this.vertices.length-r.length;return this.vertices=r,s}setFromPoints(t){this.vertices=[];for(let e=0,r=t.length;e<r;e++){let o=t[e];this.vertices.push(new pe.Vector3(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function r(l,u){return l.materialIndex-u.materialIndex}t.sort(r);let o=this.faceVertexUvs[0],i=this.faceVertexUvs[1],a,s;o&&o.length===e&&(a=[]),i&&i.length===e&&(s=[]);for(let l=0;l<e;l++){let u=t[l]._id;a&&a.push(o[u]),s&&s.push(i[u])}a&&(this.faceVertexUvs[0]=a),s&&(this.faceVertexUvs[1]=s)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let h=this.parameters;for(let m in h)h[m]!==void 0&&(t[m]=h[m]);return t}let e=[];for(let h=0;h<this.vertices.length;h++){let m=this.vertices[h];e.push(m.x,m.y,m.z)}let r=[],o=[],i={},a=[],s={},l=[],u={};for(let h=0;h<this.faces.length;h++){let m=this.faces[h],y=!0,g=!1,b=this.faceVertexUvs[0][h]!==void 0,w=m.normal.length()>0,_=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,P=m.vertexColors.length>0,O=0;if(O=c(O,0,0),O=c(O,1,y),O=c(O,2,g),O=c(O,3,b),O=c(O,4,w),O=c(O,5,_),O=c(O,6,S),O=c(O,7,P),r.push(O),r.push(m.a,m.b,m.c),r.push(m.materialIndex),b){let x=this.faceVertexUvs[0][h];r.push(f(x[0]),f(x[1]),f(x[2]))}if(w&&r.push(d(m.normal)),_){let x=m.vertexNormals;r.push(d(x[0]),d(x[1]),d(x[2]))}if(S&&r.push(p(m.color)),P){let x=m.vertexColors;r.push(p(x[0]),p(x[1]),p(x[2]))}}function c(h,m,y){return y?h|1<<m:h&~(1<<m)}function d(h){let m=h.x.toString()+h.y.toString()+h.z.toString();return i[m]!==void 0||(i[m]=o.length/3,o.push(h.x,h.y,h.z)),i[m]}function p(h){let m=h.r.toString()+h.g.toString()+h.b.toString();return s[m]!==void 0||(s[m]=a.length,a.push(h.getHex())),s[m]}function f(h){let m=h.x.toString()+h.y.toString();return u[m]!==void 0||(u[m]=l.length/2,l.push(h.x,h.y)),u[m]}return t.data={},t.data.vertices=e,t.data.normals=o,a.length>0&&(t.data.colors=a),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new Xn().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let p=0,f=e.length;p<f;p++)this.vertices.push(e[p].clone());let r=t.colors;for(let p=0,f=r.length;p<f;p++)this.colors.push(r[p].clone());let o=t.faces;for(let p=0,f=o.length;p<f;p++)this.faces.push(o[p].clone());for(let p=0,f=t.faceVertexUvs.length;p<f;p++){let h=t.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let m=0,y=h.length;m<y;m++){let g=h[m],b=[];for(let w=0,_=g.length;w<_;w++){let S=g[w];b.push(S.clone())}this.faceVertexUvs[p].push(b)}}let i=t.morphTargets;for(let p=0,f=i.length;p<f;p++){let h={};if(h.name=i[p].name,i[p].vertices!==void 0){h.vertices=[];for(let m=0,y=i[p].vertices.length;m<y;m++)h.vertices.push(i[p].vertices[m].clone())}if(i[p].normals!==void 0){h.normals=[];for(let m=0,y=i[p].normals.length;m<y;m++)h.normals.push(i[p].normals[m].clone())}this.morphTargets.push(h)}let a=t.morphNormals;for(let p=0,f=a.length;p<f;p++){let h={};if(a[p].vertexNormals!==void 0){h.vertexNormals=[];for(let m=0,y=a[p].vertexNormals.length;m<y;m++){let g=a[p].vertexNormals[m],b={};b.a=g.a.clone(),b.b=g.b.clone(),b.c=g.c.clone(),h.vertexNormals.push(b)}}if(a[p].faceNormals!==void 0){h.faceNormals=[];for(let m=0,y=a[p].faceNormals.length;m<y;m++)h.faceNormals.push(a[p].faceNormals[m].clone())}this.morphNormals.push(h)}let s=t.skinWeights;for(let p=0,f=s.length;p<f;p++)this.skinWeights.push(s[p].clone());let l=t.skinIndices;for(let p=0,f=l.length;p<f;p++)this.skinIndices.push(l[p].clone());let u=t.lineDistances;for(let p=0,f=u.length;p<f;p++)this.lineDistances.push(u[p]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new Cf().fromGeometry(this),e=new pe.BufferGeometry,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Yu.call(new pe.BufferAttribute(r,3),t.vertices)),t.normals.length>0){let o=new Float32Array(t.normals.length*3);e.setAttribute("normal",Yu.call(new pe.BufferAttribute(o,3),t.normals))}if(t.colors.length>0){let o=new Float32Array(t.colors.length*3);e.setAttribute("color",Tx.call(new pe.BufferAttribute(o,3),t.colors))}if(t.uvs.length>0){let o=new Float32Array(t.uvs.length*2);e.setAttribute("uv",Mx.call(new pe.BufferAttribute(o,2),t.uvs))}if(t.uvs2.length>0){let o=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",Mx.call(new pe.BufferAttribute(o,2),t.uvs2))}e.groups=t.groups;for(let o in t.morphTargets){let i=[],a=t.morphTargets[o];for(let s=0,l=a.length;s<l;s++){let u=a[s],c=new pe.Float32BufferAttribute(u.data.length*3,3);c.name=u.name,i.push(Yu.call(c,u.data))}e.morphAttributes[o]=i}if(t.skinIndices.length>0){let o=new pe.Float32BufferAttribute(t.skinIndices.length*4,4);e.setAttribute("skinIndex",Ix.call(o,t.skinIndices))}if(t.skinWeights.length>0){let o=new pe.Float32BufferAttribute(t.skinWeights.length*4,4);e.setAttribute("skinWeight",Ix.call(o,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new pe.BufferGeometry,r=t.geometry;if(t.isPoints||t.isLine){let o=new pe.Float32BufferAttribute(r.vertices.length*3,3),i=new pe.Float32BufferAttribute(r.colors.length*3,3);if(e.setAttribute("position",Yu.call(o,r.vertices)),e.setAttribute("color",Tx.call(i,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let a=new pe.Float32BufferAttribute(r.lineDistances.length,1);e.setAttribute("lineDistance",RT.call(a,r.lineDistances))}r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone())}else t.isMesh&&(e=r.toBufferGeometry());return e}};Xn.prototype.isGeometry=!0;var Cf=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],r,o,i,a=t.faces;for(o=0;o<a.length;o++){let s=a[o];s.materialIndex!==i&&(i=s.materialIndex,r!==void 0&&(r.count=o*3-r.start,e.push(r)),r={start:o*3,materialIndex:i})}r!==void 0&&(r.count=o*3-r.start,e.push(r)),this.groups=e}fromGeometry(t){let e=t.faces,r=t.vertices,o=t.faceVertexUvs,i=o[0]&&o[0].length>0,a=o[1]&&o[1].length>0,s=t.morphTargets,l=s.length,u;if(l>0){u=[];for(let g=0;g<l;g++)u[g]={name:s[g].name,data:[]};this.morphTargets.position=u}let c=t.morphNormals,d=c.length,p;if(d>0){p=[];for(let g=0;g<d;g++)p[g]={name:c[g].name,data:[]};this.morphTargets.normal=p}let f=t.skinIndices,h=t.skinWeights,m=f.length===r.length,y=h.length===r.length;r.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<e.length;g++){let b=e[g];this.vertices.push(r[b.a],r[b.b],r[b.c]);let w=b.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[2]);else{let S=b.normal;this.normals.push(S,S,S)}let _=b.vertexColors;if(_.length===3)this.colors.push(_[0],_[1],_[2]);else{let S=b.color;this.colors.push(S,S,S)}if(i===!0){let S=o[0][g];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new pe.Vector2,new pe.Vector2,new pe.Vector2))}if(a===!0){let S=o[1][g];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new pe.Vector2,new pe.Vector2,new pe.Vector2))}for(let S=0;S<l;S++){let P=s[S].vertices;u[S].data.push(P[b.a],P[b.b],P[b.c])}for(let S=0;S<d;S++){let P=c[S].vertexNormals[g];p[S].data.push(P.a,P.b,P.c)}m&&this.skinIndices.push(f[b.a],f[b.b],f[b.c]),y&&this.skinWeights.push(h[b.a],h[b.b],h[b.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},rs=class{constructor(t,e,r,o,i,a=0){this.a=t,this.b=e,this.c=r,this.normal=o&&o.isVector3?o:new pe.Vector3,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new pe.Color,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=a}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,r=t.vertexNormals.length;e<r;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,r=t.vertexColors.length;e<r;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function RT(n){return this.array.set(n),this}function Tx(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),i=new pe.Color),t[e++]=i.r,t[e++]=i.g,t[e++]=i.b}return this}function Mx(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),i=new pe.Vector2),t[e++]=i.x,t[e++]=i.y}return this}function Yu(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),i=new pe.Vector3),t[e++]=i.x,t[e++]=i.y,t[e++]=i.z}return this}function Ix(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),i=new pe.Vector4),t[e++]=i.x,t[e++]=i.y,t[e++]=i.z,t[e++]=i.w}return this}var VT=["a","b","c"];function zT(n,t){switch(t){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function Tf(n,t,e){let r=Math.min(n,t),o=Math.max(n,t),i=r+"_"+o;return e.get(i)}function Mf(n,t,e,r,o,i){let a=Math.min(n,t),s=Math.max(n,t),l=a+"_"+s,u;if(r.has(l))u=r.get(l);else{let c=e[a],d=e[s];u={a:c,b:d,newEdge:null,faces:[]},r.set(l,u)}u.faces.push(o),i[n].edges.push(u),i[t].edges.push(u)}function GT(n,t,e,r){let o,i,a;for(o=0,i=n.length;o<i;o++)e[o]={edges:[]};for(o=0,i=t.length;o<i;o++)a=t[o],Mf(a.a,a.b,n,r,a,e),Mf(a.b,a.c,n,r,a,e),Mf(a.c,a.a,n,r,a,e)}function Xu(n,t,e,r,o){n.push(new rs(t,e,r,void 0,void 0,o))}function os(n,t){return Math.abs(t-n)/2+Math.min(n,t)}function Qu(n,t,e,r){n.push([t.clone(),e.clone(),r.clone()])}var Ku=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof hn.BufferGeometry?t=new Xn().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new hn.Vector3,r,o,i,a,s,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],d=c!==void 0&&c.length>0,p=[],f=new Map;GT(l,u,p,f);let h=[],m,y,g,b,w,_,S;for(let ee of Array.from(f.keys())){for(y=f.get(ee),g=new hn.Vector3,w=3/8,_=1/8,S=y.faces.length,S!=2&&(w=.5,_=0,S!=1),g.addVectors(y.a,y.b).multiplyScalar(w),e.set(0,0,0),a=0;a<S;a++){for(b=y.faces[a],s=0;s<3&&(m=l[zT(b,VT[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(_),g.add(e),y.newEdge=h.length,h.push(g)}let P,O,x,D,N,T,I,E=[];for(o=0,i=l.length;o<i;o++){for(T=l[o],N=p[o].edges,r=N.length,r==3?P=3/16:r>3&&(P=3/(8*r)),O=1-r*Number(P),x=P,r<=2&&(r==2?(O=3/4,x=1/8):r==1||r==0),I=T.clone().multiplyScalar(O),e.set(0,0,0),a=0;a<r;a++)D=N[a],m=D.a!==T?D.a:D.b,e.add(m);e.multiplyScalar(Number(x)),I.add(e),E.push(I)}let B=E.concat(h),R=E.length,k,V,q,F=[],U=[],H,$,J,K,X=new hn.Vector2,te=new hn.Vector2,Y=new hn.Vector2;for(o=0,i=u.length;o<i;o++)b=u[o],k=Number(Tf(b.a,b.b,f).newEdge)+R,V=Number(Tf(b.b,b.c,f).newEdge)+R,q=Number(Tf(b.c,b.a,f).newEdge)+R,Xu(F,k,V,q,b.materialIndex),Xu(F,b.a,k,q,b.materialIndex),Xu(F,b.b,V,k,b.materialIndex),Xu(F,b.c,q,V,b.materialIndex),d&&(H=c[o],$=H[0],J=H[1],K=H[2],X.set(os($.x,J.x),os($.y,J.y)),te.set(os(J.x,K.x),os(J.y,K.y)),Y.set(os($.x,K.x),os($.y,K.y)),Qu(U,X,te,Y),Qu(U,$,X,Y),Qu(U,J,te,X),Qu(U,K,Y,te));t.vertices=B,t.faces=F,d&&(t.faceVertexUvs[0]=U)}};var qt=new ko.Vector3,Nx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.geometry??t?.geometry??new ko.BufferGeometry().copy(new ko.BoxGeometry(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(qt),r={width:qt.x,height:qt.y,depth:qt.z,subdivisions:0}):r=t.parameters;let o={...r,...n.parameters};return{parameters:{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth),subdivisions:Math.abs(o.subdivisions)},geometry:e}}static build(n){let{width:t,height:e,depth:r,subdivisions:o}=n.parameters,i=n.geometry??new ko.BufferGeometry().copy(new ko.BoxGeometry(100,100,100)),a=i.userData.parameters;a===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(qt)):qt.set(a.width,a.height,a.depth),(t!==qt.x||e!==qt.y||r!==qt.z)&&i.scale(qt.x===0?1:t/qt.x,qt.y===0?1:e/qt.y,qt.z===0?1:r/qt.z);let s=i.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=i),i=new Ku(o).modify(s).toBufferGeometry()):(s!==void 0&&(i=s),s=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals())}catch{s!==void 0&&(i=s),s=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals()}return s!==void 0&&Object.assign(i,{originalGeometry:s}),delete n.geometry,Object.assign(i,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,t,e){new ko.BufferGeometryLoader(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(qt);let a=100/qt.x;Object.assign(i.parameters,{width:100,height:qt.y*a,depth:qt.z*a}),t(this.build(i))})}};var Zu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof Qe?n.shape:new Qe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,cornerRadius:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}=n.parameters,l=n.shape,u=t*.5,c=e*.5,d=0,p=0,f=2*Math.PI/r;for(let m=0;m<r;m++){let y=f*m,g=d+Math.sin(y)*u,b=p+Math.cos(y)*c;l.addPoint(l.createPoint(g,b))}l.isClosed=!0;for(let m=0,y=l.points.length;m<y;m++)l.points[m].roundness=o;l.roundness=o,l.update();let h=Tr.create({shape:l,parameters:{roundness:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(h,{userData:{...n,type:"PolygonGeometry"}})}};var We=require("three"),Dx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,radialSegments:o,heightSegments:i,openEnded:a,cornerRadius:s,cornerSegments:l}=n.parameters,u=new Nf(t*.5,e,o,i,a,s,l);return u.scale(1,1,r/t),Object.assign(u,{userData:{...n,type:"PyramidGeometry"}})}};function Gl(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function If(n,t,e,r,o,i){let a=t.clone().sub(n),s=e.clone().sub(n),l=a.angleTo(s);if(a.normalize(),s.normalize(),r===o){let u=a.add(s).normalize();i.copy(n).addScaledVector(u,r/Math.sin(l/2))}else{let u=a.angleTo(s);i.copy(n),i.addScaledVector(a,o/Math.sin(u)),i.addScaledVector(s,r/Math.sin(u))}}function kT(n,t,e){let r=n.clone().sub(t),o=e.clone().sub(t);return r.projectOnVector(o),r.add(t)}var Nf=class extends We.BufferGeometry{constructor(t=.5,e=1,r=4,o=1,i=!1,a=0,s=4){super(),r=Math.floor(Math.max(3,r)),o=Math.floor(o),s=Math.floor(s);let l=[],u=[],c=[],d=[],p=0,f=e/2,h=Math.PI/r,m=t*Math.cos(Math.PI/r),y=2*Math.PI/r,g=(r-2)*Math.PI/r,b=Math.PI-g,w=new We.Vector3(0,-f,0),_=new We.Vector3(0,f,0),S=new We.Vector2(t,-f),P=new We.Vector2(m,-f),O=new We.Vector2(0,_.y).sub(P),x=new We.Vector2(0,_.y).sub(S),D=new We.Vector2(O.y,-O.x).normalize(),N=new We.Vector2(x.y,-x.x).normalize(),I=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-O.angle())/2)-1e-8;a=Math.min(a,I);let E;{let U=new We.Vector3(D.x,D.y,0),H=new We.Vector3(Math.cos(y)*U.x,U.y,Math.sin(y)*U.x);E=U.angleTo(H)}let B=a/Math.tan((Math.PI-O.angle())/2),R=a/Math.tan((Math.PI-E)/2),k=new We.Vector3;if(!i){u.push(w.x,w.y,w.z),c.push(0,-1,0),d.push(0,0);let U=p++,H=[],$=S.clone(),J=B/Math.cos(Math.PI/r);$.x-=J;for(let K=0;K<r;K++){let X=K/r*Math.PI*2+h,te=new We.Vector2(Math.sin(X),Math.cos(X));Gl($,te,k),u.push(k.x,k.y,k.z),c.push(0,-1,0),d.push(0,0),H.push(p++)}for(let K=0;K<H.length;K++)l.push(H[K],U,H[(K+1)%H.length])}let V=[];{let U=new We.Vector3,H=new We.Vector3,$=new We.Vector3,J=new We.Vector3,K=new We.Vector3,X=new We.Vector3;for(let te=0;te<r;te++){let Y=te/r*Math.PI*2+h,ee=(te+.5)/r*Math.PI*2+h,Q=(te+1)/r*Math.PI*2+h,W=new We.Vector2(Math.sin(Y),Math.cos(Y)),ue=new We.Vector2(Math.sin(ee),Math.cos(ee)),le=new We.Vector2(Math.sin(Q),Math.cos(Q));Gl(S,W,H),Gl(S,le,$),Gl(D,ue,U),If(_,H,$,R,R,J),u.push(J.x,J.y,J.z),If(H,_,$,R,B,K),u.push(K.x,K.y,K.z),If($,H,_,B,R,X),u.push(X.x,X.y,X.z),c.push(U.x,U.y,U.z),c.push(U.x,U.y,U.z),c.push(U.x,U.y,U.z),d.push(0,0),d.push(0,0),d.push(0,0);let ne=p++,ce=p++,ae=p++;if(l.push(ne,ce,ae),a>0){{let he=H.clone().add($).multiplyScalar(.5),xe=_.clone().sub(he).normalize(),C=w.clone().sub(he).normalize().add(xe).normalize().multiplyScalar(-1),ie=X.clone().sub(K);q(he,ie,C,O.angle())}let me,fe;{let he=new We.Vector3;Gl(N,le,he);let xe=X.clone().add(J).multiplyScalar(.5);xe=kT(xe,$,_);let ye=X.clone().sub(J);[me,fe]=q(xe,ye,he,E,J.y)}{let he=me,xe=he.clone().setY(0).normalize(),ye=new We.Vector3(0,-1,0),C=xe.clone().cross(ye);F(he,xe,ye,C)}V.concat(fe);{let he=O.angle(),xe=Math.PI-he,ye=_.clone();ye.y-=a/Math.sin(he-Math.PI/2);let C=new We.Vector3,ie=[];for(let He=0;He<s;He++){let ze=[],Oe=Math.PI/2-xe*He/s,jt=Math.cos(Oe),Ee=Math.sin(Oe),zt=ee;for(let Ut=0;Ut<=He;Ut++){let fi=Math.cos(zt),vt=Math.sin(zt);U.x=jt*vt,U.y=Ee,U.z=jt*fi,C.copy(ye).addScaledVector(U,a),u.push(C.x,C.y,C.z),c.push(U.x,U.y,U.z),d.push(0,0),ze.push(p++),zt+=Math.PI*2/He/r}ie.push(ze)}fe.reverse(),ie.push(fe);let Ve=ie.length-1;for(let He=0;He<Ve;He++){let ze=ie[He],Oe=ie[He+1],jt=ze.length-1;l.push(Oe[1],ze[0],Oe[0]);for(let Ee=1;Ee<=jt;Ee++)l.push(ze[Ee],ze[Ee-1],Oe[Ee]),l.push(Oe[Ee+1],ze[Ee],Oe[Ee])}}}}}this.setIndex(l),this.setAttribute("position",new We.Float32BufferAttribute(u,3)),this.setAttribute("normal",new We.Float32BufferAttribute(c,3)),this.setAttribute("uv",new We.Float32BufferAttribute(d,2));function q(U,H,$,J,K){let X=-J/2,te=(Math.PI-J)/2,Y=H.clone().normalize().cross($);U.addScaledVector($,-a/Math.sin(te));let ee=new We.Vector3,Q=new We.Vector3,W=1,ue=p,le=[];for(let ne=0;ne<=s;ne++){let ce=X+ne/s*J;Q.set(0,0,0),Q.addScaledVector(Y,Math.sin(ce)),Q.addScaledVector($,Math.cos(ce));for(let ae=0;ae<=W;ae++){let me=ae/W-.5;if(ee.copy(U),ee.addScaledVector(H,me),ee.addScaledVector(Q,a),K!=null){let fe=Math.max(0,ee.y-K);ee.addScaledVector(H,-fe/H.y)}u.push(ee.x,ee.y,ee.z),c.push(Q.x,Q.y,Q.z),d.push(0,0),ae===0&&le.push(p),p++}}for(let ne=0;ne<s;ne++)for(let ce=0;ce<W;ce++){let ae=ue+ce+(W+1)*ne,me=ae+(W+1),fe=me+1,he=ae+1;l.push(ae,me,he),l.push(me,fe,he)}return[U.clone().addScaledVector(H,.5),le]}function F(U,H,$,J){let K=Math.PI/2,X=x.angle()-K,te=[],Y=new We.Vector3,ee=new We.Vector3;for(let W=0;W<=s;W++){let ue=[],le=W/s;for(let ne=0;ne<=W;ne++){let ae=((W?ne/W:0)-.5)*b,me=Math.cos(ae),fe=Math.sin(ae),he=Math.atan(Math.tan(X)*me),xe=(K+he)*le,ye=Math.cos(xe),C=Math.sin(xe);Y.set(0,0,0),Y.addScaledVector(H,C*me),Y.addScaledVector($,ye),Y.addScaledVector(J,C*fe),ee.copy(U).addScaledVector(Y,a),u.push(ee.x,ee.y,ee.z),c.push(Y.x,Y.y,Y.z),d.push(0,0),ue.push(p++)}te.push(ue)}let Q=te.length-1;for(let W=0;W<Q;W++){let ue=te[W],le=te[W+1],ne=ue.length-1;l.push(ue[0],le[1],le[0]);for(let ce=1;ce<=ne;ce++)l.push(ue[ce-1],ue[ce],le[ce]),l.push(ue[ce],le[ce+1],le[ce])}}}};var ns=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof Qe?n.shape:new Qe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(n){let t=n.shape,{width:e,height:r,cornerRadius:o,cornerType:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,u={x:e*.5,y:r*.5},c={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function p(_,S,P){return S>e&&P>r?Math.min(_*e/S,_*r/P):S>e?_*e/S:P>r?_*r/P:_}let f=[];f[0]=o[0]===0?0:p(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:p(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:p(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:p(o[3],o[3]+o[0],o[3]+o[2]);let h=c.x,m=d.x,y=d.y,g=c.y;t.addPoint(t.createPoint(h,y)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(h,g)),t.isClosed=!0;let b=!0;for(let _=0,S=t.points.length;_<S;_++)t.points[_].roundness=f[_],_>0&&f[_]!==f[_-1]&&(b=!1);b&&(t.roundness=f[0]),t.useCubicForRoundedCorners=i!==1,t.update();let w=Tr.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...n,type:"RectangleGeometry"}})}};var mn=require("three"),Ex=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},n.parameters);return e.thetaLength=mn.MathUtils.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t=100,height:e=t,depth:r=t,widthSegments:o=64,heightSegments:i=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:u}=n.parameters,c;return u===0?(c=new mn.BufferGeometry,c.setAttribute("position",new mn.Float32BufferAttribute([],3))):c=new mn.SphereGeometry(.5*t,o,i,a,s,l,u*mn.MathUtils.DEG2RAD),c.scale(1,e/t,r/t),Object.assign(c,{userData:{...n,type:"SphereGeometry"}})}};var Bx=require("three"),Lx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(n){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:o=8}=n.parameters,i=new Bx.PlaneGeometry(t,e,r,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};var Qn=require("three"),Rx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,angle:o,cornerRadius:i,cornerSegments:a}=n.parameters,s=new Df(t,e,r,o,i,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},Df=class extends Qn.BufferGeometry{constructor(t=1,e=1,r=1,o=90,i=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],u=[],c=.001;i==0&&(a=1),a=Math.max(1,Math.floor(a)),i=Math.min(i,100),o=Math.min(180-c,o),o*=Math.PI/180;let d=[],p=Math.PI/2,f=(ee=0,Q=0,W=0)=>new Qn.Vector3(ee,Q,W),h=f(),m=f(),[y,g,b]=[e/2,t/2,r/2],w=-g,_=+g,[S,P,O]=[f(w,-y,+b),f(w,-y,-b),f(w,+y,-b)],x=(ee,Q=!1)=>Math.sin(ee-Math.PI/(1+ +Q)),D=(ee,Q=!1)=>Math.cos(ee-Math.PI/(1+ +Q));O.y=Math.sin(o)*e-y;let N=Math.cos(o)*e-b,T=S.z-c;o<=p?(O.z=Math.min(N,T),O.z==T&&(O.y-=(N-T)/Math.tan(p-o))):P.z=Math.min(P.z-N-b,S.z-c),h.subVectors(S,P),m.subVectors(O,P);let I=Math.min(h.length(),m.length())*i/100,E=I*Math.tan(o/2),B=I/Math.cos(o/2),R=h.clone().normalize().add(m.normalize()).setLength(B).add(P);h.set(0,x(o,!0),D(o,!0)),d.push([O,h.clone()]);let k=(Math.PI-o)/a;for(let ee=0;ee<=a;ee++){let Q=p+o+ee*k;h.set(0,Math.sin(Q)*E,Math.cos(Q)*E),h.add(R),m.set(0,x(Q),D(Q)),d.push([h.clone(),m.clone()])}d.push([S,f(0,1,0)]);let V=Math.sin(k/2)*E*2,q=d.length-1,F=d[0][0].distanceTo(d[1][0]),U=d[q-1][0].distanceTo(d[q][0]),H=F+V*a+U;d[0].push(1);for(let ee=0;ee<=a;ee++)d[ee+1].push(1-(F+ee*V)/H);d[q].push(0);let[$,J,K]=d[0],X,te,Y;for(let ee=1;ee<d.length;ee++)[X,te,Y]=d[ee],s.push(w,$.y,$.z,w,X.y,X.z,_,$.y,$.z,_,$.y,$.z,w,X.y,X.z,_,X.y,X.z),l.push(0,J.y,J.z,0,te.y,te.z,0,J.y,J.z,0,J.y,J.z,0,te.y,te.z,0,te.y,te.z),u.push(0,K,0,Y,1,K,1,K,0,Y,1,Y),[$,J,K]=[X,te,Y];this.setAttribute("position",new Qn.Float32BufferAttribute(s,3)),this.setAttribute("normal",new Qn.Float32BufferAttribute(l,3)),this.setAttribute("uv",new Qn.Float32BufferAttribute(u,2))}};var Ju=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Qe?n.shape:new Qe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,innerRadiusPercent:r,spikes:o,cornerRadius:i,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:u}=n.parameters,c=n.shape,d=t*.5,p=e*.5,f=0,h=0,m=a*Math.PI/360/o,y=Math.PI/2*3*-1,g=d*r/100,b=p*r/100;if(o===3&&r===50){m=2*Math.PI/o;for(let _=0;_<o;_++){let S=m*_,P=f+Math.sin(S)*d,O=h+Math.cos(S)*p;c.addPoint(c.createPoint(P,O))}}else for(let _=0;_<o;_++){let S=f+Math.cos(y)*d,P=h+Math.sin(y)*p;c.addPoint(c.createPoint(S,P)),y+=m,S=f+Math.cos(y)*g,P=h+Math.sin(y)*b,_<=o,c.addPoint(c.createPoint(S,P)),y+=m}c.isClosed=!0;for(let _=0,S=c.points.length;_<S;_++)c.points[_].roundness=i;c.roundness=i,c.update();let w=Tr.create({shape:c,parameters:{roundness:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(w,{userData:{...n,type:"StarGeometry"}})}};var Vx=require("three"),zx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e}=n.parameters,r=new Vx.PlaneGeometry(t,e);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};var is=require("three");var Gx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:o,depth:i})}}static build(n){let{width:t,height:e,depth:r,radialSegments:o,tubularSegments:i,arc:a,cornerRadius:s,cornerSegments:l}=n.parameters,u=FT(t,e,r,t*.5,a,i,0,0,o,s,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...n,type:"TorusGeometry"}})}};function FT(n,t,e,r,o,i,a,s,l,u,c){[t,e]=[e,t],a=t/2;let d=is.MathUtils.clamp(o/360,0,1);if(d===0){let p=new is.BufferGeometry;return p.setAttribute("position",new is.Float32BufferAttribute([],3)),p}return d===1&&(u=0),new Vl(!0,n,t,e,r,d,i,a,s,l,u,c)}var kx=require("three"),Fx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(n){let{width:t,tube:e,tubularSegments:r,radialSegments:o,p:i,q:a}=n.parameters,s=t*.5;s!==e&&(s-=e);let l=new kx.TorusKnotGeometry(s,e,r,o,i,a);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var jx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof Qe?n.shape:new Qe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t=100,height:e,cornerRadius:r,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a,isRect:s}=n.parameters,l=n.shape,u=t*.5,c=e*.5;s?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let p=0,f=l.points.length;p<f;p++)l.points[p].roundness=r;l.roundness=r,l.update();let d=Tr.create({shape:l,parameters:{roundness:r,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a}});return Object.assign(d,{userData:{...n,type:"TriangleGeometry"}})}};var Me=require("three");function Ux(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var jT=new Me.Matrix4,UT=new Me.Matrix4;function HT(n,t,e){let r=[new Me.Vector3,new Me.Vector3,new Me.Vector3],o=[new Me.Vector3,new Me.Vector3,new Me.Vector3];return n.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((i,a)=>{let s=o[a],l=Me.MathUtils.lerp(i.length(),s.length(),e);i.lerp(s,e).setLength(l)}),new Me.Matrix4().makeBasis(r[0],r[1],r[2])}var Hx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=t?.shapeData??ts.create({parameters:Gp}).userData.shape;return{path:n.path??Ea.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:i,extrusion:{...vu,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new Ef(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new Me.BufferGeometry,{userData:{...n,type:"PathGeometry"}})}},Ef=class extends Me.BufferGeometry{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!Ux(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:o,offset:i}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),i=Math.max(0,Math.min(i,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(i*a),l=this.inputs.path.isClosed?Math.ceil((o+i)*a):Math.ceil(Math.min(1,o+i)*a),u=Math.min(Math.max(2,l-s+1),a+2),c=[],d=[];for(let F=0;F<u;F++){let U=this.inputs.path.isClosed?(F+s)%e.length:Math.min(F+s,e.length-1);c.push(e[U].clone()),d.push(r[U].clone())}let p=(F,U,H)=>{c[F]=c[F].clone().lerp(c[U],H),d[F]=HT(d[F],d[U],H)},f=0,h=i*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||i===0)&&(f=h,p(0,1,f));let m=0,y=(i+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&i+o<1)&&y&&(m=y,p(c.length-1,c.length-2,1-m)),o===0){let F=c.length-1;c[F].copy(c[0]),d[F].copy(d[0])}this._applyPathModifiers(d,f,m);let{bevel:g,bevelSides:b}=this.inputs.parameters.extrusion,w=g>0?this.inputs.parameters.extrusion.capType:"flat",_=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(_=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:P,vertices:O}=this._computeShapePoints(_),x=0,D;w==="round"&&(D=new Yn(this.inputs.shapeData,2*g,g,_,b,void 0,!0),x=D.getAttribute("position").count);let N=0,T=0;P.sort((F,U)=>F.start-U.start),P.forEach(F=>{F.verticesStart=N,F.verticesCount=F.continuous.reduce((U,H,$)=>U+($===0||!H?2:1),0),T+=F.verticesCount,N=T});let I=T*u,E,B=0;if(this._isOpenEnded()&&w==="flat"){try{E=go({windingRule:Ye.ODD,elementType:_t.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{E=_f}B=E.vertexCount}let R=I+2*B+x*2,k=I+2*B,V={positions:new Float32Array(R*3),normals:new Float32Array(R*3),uvs:new Float32Array(R*2)},q=[];if(P.forEach(F=>{this._extrudeRegion(F,O,d,c,V,q,this._isGeometryClosed()&&!this._isOpenEnded())}),E&&(this._closeEnd(E,I,q,V,d[0],c[0],!1),this._closeEnd(E,I+B,q,V,d[d.length-1],c[c.length-1],!0)),D){V.positions.set(D.getAttribute("position").array,k*3),V.normals.set(D.getAttribute("normal").array,k*3),V.uvs.set(D.getAttribute("uv").array,k*2);let F=q.length;q.push(...D.getIndex().array.map($=>$+k)),k+=x,V.positions.set(D.getAttribute("position").array,k*3),V.normals.set(D.getAttribute("normal").array,k*3),V.uvs.set(D.getAttribute("uv").array,k*2);let U=q.length;q.push(...D.getIndex().array.map($=>$+k)),this.setAttribute("position",new Me.BufferAttribute(V.positions,3)),this.setAttribute("normal",new Me.BufferAttribute(V.normals,3)),this.setAttribute("uv",new Me.BufferAttribute(V.uvs,2)),this.setIndex(q);let H=jT;H.copy(d[d.length-1]).setPosition(c[c.length-1]),this.applyMatrix4OnRange(H,k,R),H.copy(d[0]).setPosition(c[0]).multiply(UT.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,k-x,k),this.reverseIndicesOnRange(F,U)}else this.setAttribute("position",new Me.BufferAttribute(V.positions,3)),this.setAttribute("normal",new Me.BufferAttribute(V.normals,3)),this.setAttribute("uv",new Me.BufferAttribute(V.uvs,2)),this.setIndex(q)}_extractPathPoints(){let r=ku(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let o=[r[0]];return r.forEach(a=>{o[o.length-1].distanceToSquared(a)>.001&&o.push(a)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],o=e.length,i=this.inputs.path.isClosed,a=new Me.Vector3,s=new Me.Vector3,l=new Me.Vector3,u=new Me.Vector3,c=new Me.Vector3(0,1,0);for(let y=0;y<o;y++){let g=e[y],b;y===0?b=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):b=e[y-1];let w;y===o-1?w=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let _=g.clone().sub(b).normalize(),S=w.clone().sub(g).normalize(),P=_.clone().add(S).normalize();l.copy(P),y===0&&(P.equals(c)||P.clone().negate().equals(c))&&c.set(0,0,1);let O=c.clone().cross(P).normalize(),x=P.clone().cross(O).normalize();c.copy(x),u.copy(O),y===0&&(a.copy(x),s.copy(P));let D=new Me.Matrix4().makeBasis(O,x,P);r.push(D)}let d=i?s:l,p=i?a:new Me.Vector3(0,1,0),f=d.clone().cross(u).normalize(),h=Math.acos(p.dot(f));if(isNaN(h))return r;let m=p.clone().cross(f);d.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let g=new Me.Matrix4().makeRotationZ(h*y/r.length);r[y].multiply(g)}return r}_applyPathModifiers(e,r,o){let i=e.length,{angle:a,twist:s,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new Me.Matrix4,d=new Me.Matrix4;return e.forEach((p,f)=>{let h=f===0?0:f===i-1?1:(f-r)/(i-(o===0?0:1)-(r+(1-o)));c.makeRotationZ(Me.MathUtils.lerp(a,a+s,h)*Me.MathUtils.DEG2RAD);let m=Me.MathUtils.lerp(l,u,h);d.makeScale(m,m,m),p.multiply(c).multiply(d)}),e}_computeShapePoints(e=12,r=Ye.ODD){let o=this.inputs.shapeData,i=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let b=y.length-1;b>=1;b-=2){let w=y[b-1],_=y[b-0];g.push(w,_)}return g}),s;try{s=go({windingRule:r,elementType:_t.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{s=Rl}let l;try{l=go({windingRule:Ye.ODD,elementType:_t.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Af}if(!s)throw new Error("error generating geometry");let u=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let c=1/0,d=-1/0,p=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,b=s.vertices[g+0],w=s.vertices[g+1];b<c&&(c=b),b>d&&(d=b),w<p&&(p=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=u,g=m*2,b=s.elements[g+0],w=s.elements[g+1],_=b+w,S={start:b,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let P=b,O=_-1,x=b+1,D=o.roundedCurves.length;do{let N=P-b,T=s.vertices[O*2+0],I=s.vertices[O*2+1],E=s.vertices[P*2+0],B=s.vertices[P*2+1],R=s.vertices[x*2+0],k=s.vertices[x*2+1],V=E-T,q=B-I,F=Math.sqrt(V*V+q*q);V/=F,q/=F;let U=E-R,H=B-k,$=Math.sqrt(U*U+H*H);U/=$,H/=$,S.normals[N*2+0]=-H,S.normals[N*2+1]=U;let J=s.vertexIndices[P];if(Array.isArray(J))S.continuous[N]=!1;else{let[K,X]=o.getCurveIndexFromVertexId(J-1,!0);if(X>0&&X<1)S.continuous[N]=!0;else{let te=X===1?K+1:K-1;te=(te+D)%D;let Y=X===1?0:1,ee=o.roundedCurves[K].getTangent(X),Q=o.roundedCurves[te].getTangent(Y);S.continuous[N]=ee.dot(Q)>.95}}y&&(S.normals[N*2+0]*=-1,S.normals[N*2+1]*=-1),[O,P,x]=[P,x,x+1],x>=_&&(x-=w)}while(x!==b+1)}return{regions:[i,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,i,a){let s=r*2,l=r*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=i.x,e.normals[l+1]=i.y,e.normals[l+2]=i.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,o,i,a,s,l){let u=new Me.Vector3,c=new Me.Vector3,d=new Me.Vector3,p=new Me.Vector3,f=new Me.Vector2;o.forEach((m,y)=>{let g=i[y],b=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let _=(e.start+w)*2;if(u.set(r[_+0],r[_+1],0),d.copy(u).applyMatrix4(m).add(g),e.continuous[w])p.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===0?(e.start+e.count-1)*2:_-2;c.set(r[S+0],r[S+1],0),p.copy(u).sub(c),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(m).normalize(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,b,d,p,f),b++,!e.continuous[w]||w===0){if(w===0)p.set(e.normals[w*2+0],e.normals[w*2+1],0),f.set(0,y/(o.length-1));else{let S=w===e.count-1?e.start*2:_+2;c.set(r[S+0],r[S+1],0),p.copy(c).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(m).normalize(),this._insertVertex(a,b,d,p,f),b++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,g=e.verticesStart*o.length+e.verticesCount*(m+1),b=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&b++;let _=w===e.count-1?0:b+1,S=y+b,P=y+_,O=g+_,x=g+b;e.isHole?s.push(S,O,P,S,x,O):s.push(S,P,O,S,O,x),b++}}}_closeEnd(e,r,o,i,a,s,l){let u=e.vertexCount,c=new Me.Vector3(0,0,l?-1:1).applyMatrix4(a),d=new Me.Vector3,p=new Me.Vector2;for(let h=0;h<u;h++){let m=2*h;d.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(i,r+h,d,c,p)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+r,g=f[m+(l?1:2)]+r,b=f[m+(l?2:1)]+r;o.push(y,g,b)}}applyMatrix4OnRange(e,r,o){let i=e.elements,a=new Me.Matrix3().getNormalMatrix(e).elements,s,l,u,c,d=this.attributes.position,p=this.attributes.normal;if(!d||!p)return;let f=d.array,h=p.array,m=d.itemSize;for(let y=r*m,g=o*m;y<g;y+=m){if(y===r)debugger;s=f[y+0],l=f[y+1],u=f[y+2],c=1/(i[3]*s+i[7]*l+i[11]*u+i[15]),f[y+0]=(i[0]*s+i[4]*l+i[8]*u+i[12])*c,f[y+1]=(i[1]*s+i[5]*l+i[9]*u+i[13])*c,f[y+2]=(i[2]*s+i[6]*l+i[10]*u+i[14])*c,s=h[y+0],l=h[y+1],u=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*u,h[y+1]=a[1]*s+a[4]*l+a[7]*u,h[y+2]=a[2]*s+a[5]*l+a[8]*u}d.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,r){let o=this.index;if(o){for(let i=e;i<r;i+=3){let a=o.getX(i),s=o.getX(i+1),l=o.getX(i+2);o.setXYZ(i,l,s,a)}o.needsUpdate=!0}}};var Ii=require("three"),qx=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Wx(){let n=new Ii.BufferGeometry;return n.setAttribute("position",new Ii.BufferAttribute(new Float32Array([]),3)),n.setIndex(new Ii.BufferAttribute(new Uint16Array([]),1)),n}var WT=Wx().attributes,$T=12,YT=1,as=class extends Ii.BufferGeometry{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,WT),this.userData={parameters:e,type:"TextGeometry"};let o=r.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e)):this.updateFont(e.font,r).then(()=>{this.update(e),r?.requestRender()})}async updateFont(e,r){let o=r.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e){let r=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!r?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l,text:u,textTransform:c}=e,d=Mu.getDisplayedValue(u),p=c===2?d.toUpperCase():c===3?d.toLowerCase():d,f=XT(e,r,p),{shapes:h,charWidths:m,charCoords:y}=r.generateShapes(f,e),g=(typeof o=="number"?o:1)*.5,b=(typeof i=="number"?i:1)*.5,w=h.map(P=>new Qe().fromShape(P,!0));this.vectorShapes=w;let _=w.map(P=>Tr.create({shape:P,parameters:{depth:a,extrudeBevelSegments:l,extrudeBevelSize:s,windingRule:a<=0?Ye.NONZERO:Ye.ODD,subdivisions:this.isLowResolution&&a>0?YT:$T}})),S=_.length?(0,qx.mergeBufferGeometries)(_):Wx();S.translate(-g,b,0),this.dispose(),this.wrappedText=f,this.charCoords=y,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(S.attributes).forEach(([P,O])=>{this.setAttribute(P,O)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=br(new Ii.BufferGeometry,as.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,o])=>{this.setAttribute(r,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function XT(n,t,e){let r=[""],o="";for(let i of e)o+=i,i===" "||i===`
16
17
  `?(r[r.length-1]+=o,o="",i===`
17
- `&&r.push("")):t.getTextWidth(r[r.length-1]+o,n)>n.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+o,n)>n.width&&(o.length===1?(r[r.length-1]+=o,o=""):(r[r.length-1]+=o.slice(0,-1),o=o[o.length-1],r.push(""))));return r[r.length-1]+=o,r}var Je=require("three");var ix,Iu=new Promise(n=>{ix=n}),nx=!1;var Mu;function ax(){if(nx)return;if(Mu)return Mu;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.0.21/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(u=>u.arrayBuffer())]),s=i.default,l=await s({wasmBinary:a});ix(l),nx=!0}return Mu=n(),Mu}var sx=require("three");var YC=["font"];function sn(n,t,e,r){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let u of a){let c=i;for(let d of u)c=c[d];for(o in c){let d=c[o];tp(d)&&!YC.includes(o)&&(c[o]=t.getVariable(d,[r.uuid,"geometry",...u,o]),tp(c[o])&&(c[o]=1))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let u=Fe.createFromState(i.shape,i.width,i.height);s.shape=u}else if(i.type==="NonParametricGeometry")i.data.groups&&i.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),s.geometry=new sx.BufferGeometryLoader().parse(i);else if(i.type==="SubdivGeometry"){let u=new Ct(i,e);return u.data=n,u}else{if(i.type==="TextGeometry")return new Fa(i,t);if(i.type==="UIGeometry")return Ga.create({parameters:{width:i.width,height:i.height,cornerRadius:i.cornerRadius,cornerType:i.cornerType}})}let l;try{l=Kp(s)}catch(u){console.error(u)}if(!l){let u=Fe.createFromState(ha.defaultData(),100,100);s.shape=u,l=Kp(s)}return l}var lx=require("three"),XC=new lx.Matrix4;function bl(n,t,e,r){let o=n.position.array,i=n.normal.array,a=XC.makeScale(t,e,r).invert().elements,s,l,u;for(var c=0,d=o.length;c<d;c+=3)o[c]*=t,o[c+1]*=e,o[c+2]*=r,s=i[c],l=i[c+1],u=i[c+2],i[c]=a[0]*s+a[4]*l+a[8]*u,i[c+1]=a[1]*s+a[5]*l+a[9]*u,i[c+2]=a[2]*s+a[6]*l+a[10]*u;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var Nu=new Je.Box3,ja=new Je.Vector3,ye;Iu.then(n=>{ye=n});var cx=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),ux=new Uint32Array([0,1,2,3]),dx=new Uint8Array([4]),Ct=class extends Je.BufferGeometry{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,i=On.div(r,o);this.subdividedGeometry&&bl(this.subdividedGeometry.attributes,...i),this.originalGeometry&&bl(this.originalGeometry.attributes,...i),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*i[0],height:a.height*i[1],depth:a.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(ja.fromArray(i));let s=ja.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=Ct.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Je.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Ct.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Je.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Nu.setFromBufferAttribute(r),Nu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Nu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Nu.getSize(ja);let i={width:ja.x,height:ja.y,depth:ja.z};return this.userData.parameters=i,i}static build(e,r,o,i){let a,s,l,u=e?.phongAngle??35;o===!1&&(u=-1),r&&(ye.free_bvh(r),ye.free_subdivision_surface(r));try{a=Ct.allocate(e,i)}catch(c){console.error(c,e),a=Ct.allocate({positionWASM:cx,indexWASM:ux,verticesPerFaceWASM:dx},i)}if(ye.set_destination_refinement_level(a,0),s=Ct.buildLevel(a,!0,u),e.subdivisions>0)try{ye.set_destination_refinement_level(a,e.subdivisions),l=Ct.buildLevel(a,!1,u)}catch{try{ye.set_destination_refinement_level(a,e.subdivisions-1),l=Ct.buildLevel(a,!1,u)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let i=e.shape!==void 0||e.path!==void 0?r.geometry:sn(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,l,u,c;({positions:s,triIndices:c}=tf(i.getAttribute("position"),a));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;d=[p,f]}return{indices:l,verticesPerFace:u}=rf(s,c,i,d),{positions:s,indices:l,verticesPerFace:u}}static allocate(e,r){let o,i,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=cx,i=ux,a=dx);let u=o.length,c=i.length,d=a.length,p=o.length+s.length+l.length,f=i.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,g=ye._malloc(h),b=new Float32Array(ye.HEAPF32.buffer,g,p),S=new Uint32Array(ye.HEAPU32.buffer,g+m,f);b.set(o,0),b.set(s,o.length),b.set(l,o.length+s.length),S.set(i,0),S.set(a,i.length);let w;e?.scaleBaked?.some(_=>_!==1)&&(w=new Je.Matrix4().makeScale(...e.scaleBaked)),r&&(w?w.premultiply(r):w=r);let v=w?ye.alloc_subdivision_surface2(g,u,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):ye.alloc_subdivision_surface(g,u,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,d);return ye._free(g),v}static buildLevel(e,r,o,i,a){let s=a?ye.get_mesh_data2(e,r?ye.Level.CONTROL:ye.Level.REFINED,o,a.elements):ye.get_mesh_data(e,r?ye.Level.CONTROL:ye.Level.REFINED,o),l=8,u=ye.HEAPU32.subarray(s>>2,(s>>2)+l),c=u.subarray(4,4+4),d=0,p=ye.HEAPU32[u[d]>>2],f=ye.HEAPF32.subarray(p>>2,(p>>2)+c[d]);d++;let h=ye.HEAPU32[u[d]>>2],m=ye.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let y=ye.HEAPU32[u[d]>>2],g=ye.HEAPU32.subarray(y>>2,(y>>2)+c[d]);d++;let b=ye.HEAPU32[u[d]>>2],S=ye.HEAPU32.subarray(b>>2,(b>>2)+c[d]);if(d++,i===void 0){let w=new Je.BufferGeometry;if(w.setIndex(new Je.Uint32BufferAttribute(S,1)),w.setAttribute("position",new Je.Float32BufferAttribute(f,3)),w.setAttribute("normal",new Je.Float32BufferAttribute(m,3)),r){w.setAttribute("faceMap",new Je.Uint32BufferAttribute(g,1));let v=new Float32Array(m.length/3*4).fill(0);w.setAttribute("color",new Je.BufferAttribute(v,4))}return ye.free_mesh_data(s),w.userData.type="SubdivGeometry",w}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,ye.free_mesh_data(s)}static freeSubdivPointer(e){ye.free_bvh(e),ye.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let i=ye.get_wireframe_data_for_base_level(e),a=4,s=ye.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),u=0,c=ye.HEAPU32[s[u]>>2],d=ye.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let p=ye.HEAPU32[s[u]>>2],f=ye.HEAPU32.subarray(p>>2,(p>>2)+l[u]);if(r===void 0){let h=new Je.BufferGeometry;h.setAttribute("position",new Je.Float32BufferAttribute(d,3));let m=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new Je.BufferAttribute(m,3)),h.setIndex(new Je.Uint32BufferAttribute(f,1)),ye.free_wireframe_data_for_base_level(i),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,ye.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,r,o){let i=r===0;i||ye.set_destination_refinement_level(e,r);let a=o?ye.get_topological_data2(e,i?ye.Level.CONTROL:ye.Level.REFINED,o.elements):ye.get_topological_data(e,i?ye.Level.CONTROL:ye.Level.REFINED),s=6,l=ye.HEAPU32.subarray(a>>2,(a>>2)+s),u=l.subarray(3,3+3),c=0,d=ye.HEAPU32[l[c]>>2],p=new Float32Array(ye.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=ye.HEAPU32[l[c]>>2],h=new Uint32Array(ye.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let m=ye.HEAPU32[l[c]>>2],y=new Uint8Array(ye.HEAPU32.subarray(m>>2,(m>>2)+u[c]));return ye.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var px=["getX","getY","getZ"];function tf(n,t){let e={},r=t?t.count:n.count,o=0,i=[],a=[],s=1e4;for(let u=0;u<r;u++){let c=t?t.getX(u):u,d="";for(let p=0;p<3;p++)d+=`${~~(n[px[p]](c)*s)},`;if(d in e)i.push(e[d]);else{for(let p=0;p<3;p++)a.push(n[px[p]](c));e[d]=o,i.push(o),o++}}let l=[];for(let u=0;u<i.length;u+=3)i[u]===i[u+1]||i[u]===i[u+2]||i[u+1]===i[u+2]||l.push(i[u],i[u+1],i[u+2]);return{positions:a,triIndices:l}}var Du=new Je.Vector3,Zp=new Je.Vector3,Jp=new Je.Vector3,ef=new Je.Vector3;function rf(n,t,e,r){let o=[],i=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),u=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&u<=24&&u%4===0&&e.userData.parameters.angle>=360){let p=l.length/2/u;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let c=0;for(let p=0;p<l.length;p+=2)c+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);n.length=0;let d=0;if(c<0)for(let p=0;p<l.length;p+=2)n.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)n.push(l[p],l[p+1],0),o.push(d++);return i.push(d),{indices:o,verticesPerFace:i}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[t[s]*3+2]===a||n[t[s]*3+2]===0)&&l++,(n[t[s+1]*3+2]===a||n[t[s+1]*3+2]===0)&&l++,(n[t[s+2]*3+2]===a||n[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){Du.set(n[t[s]*3],n[t[s]*3+1],n[t[s]*3+2]),Zp.set(n[t[s+1]*3],n[t[s+1]*3+1],n[t[s+1]*3+2]),Jp.set(n[t[s+4]*3],n[t[s+4]*3+1],n[t[s+4]*3+2]),ef.set(n[t[s+5]*3],n[t[s+5]*3+1],n[t[s+5]*3+2]),Zp.sub(Du).normalize(),Jp.sub(Du).normalize(),ef.sub(Du).normalize();let l=Zp.cross(Jp).dot(ef);Math.abs(l)>.005||r&&r.some((u,c)=>c%2===1?!1:s>=r[c]&&s<r[c+1])?(o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),i.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],u=[],c=0;for(let d=0,p=0;d<n.length;d+=3,p++)n[d+2]===0&&(l.push(p),c++),n[d+2]===a&&u.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=u[0];u[0]=u[1],u[1]=d}l.reverse(),o.push(...l,...u),i.push(c,c)}return{indices:o,verticesPerFace:i}}var Gr={};lh(Gr,{calcBoolean:()=>JC,calcBooleanTopological:()=>ZC,freeMeshSet:()=>oT,getMeshSet:()=>eT,hasOpenEdges:()=>tT,transformMeshSet:()=>rT});var QC,fx=new Promise(n=>{QC=n});var vl=require("three");var Me,Ua;fx.then(n=>Me=n);function KC(n,t,e){let r,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:a}=tf(n.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:u}=rf(i,a,n);s=u.length,r=[];for(let c=0,d=0;c<s;c++){r.push(u[c]);for(let p=0;p<u[c];p++)r.push(l[d++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let u=0,c=0;c<r.length;)r[c++]=3,s++,r[c++]=a[u++],r[c++]=a[u++],r[c++]=a[u++]}return{positions:i,faceIndices:r,nFaces:s}}function hx(n){let t=n.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:r,i=Me._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Me.HEAPU32.buffer,i,t):new Float32Array(Me.HEAPF32.buffer,i,t)).set(n,0),i}function mx(n){switch(n){case 0:return Me.OP.UNION;case 1:return Me.OP.INTERSECTION;case 2:return Me.OP.A_MINUS_B;case 3:return Me.OP.B_MINUS_A;case 4:return Me.OP.SYMMETRIC_DIFFERENCE;case 5:return Me.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function ZC(n,t){Ua===void 0&&(Ua=Me.init_csg());let e=hx(n),r=Me.csg_calc_topological(Ua,e,n.length,mx(t));Me._free(e);let o=6,i=Me.HEAPU32.subarray(r>>2,(r>>2)+o),a=i.subarray(3,3+3),s=0,l=Me.HEAPU32[i[s]>>2],u=new Float32Array(Me.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let c=Me.HEAPU32[i[s]>>2],d=new Uint32Array(Me.HEAPU32.subarray(c>>2,(c>>2)+a[s]));s++;let p=Me.HEAPU32[i[s]>>2],f=new Uint8Array(Me.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Me.free_mesh_data(r),{positions:u,indices:d,verticesPerFace:f}}function JC(n,t,e,r){Ua===void 0&&(Ua=Me.init_csg());let o=hx(n),i=Me.csg_calc(Ua,o,n.length,r,mx(t));Me._free(o);let a=5,s=Me.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),u=0,c=Me.HEAPU32[s[u]>>2],d=Me.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let p=Me.HEAPU32[s[u]>>2],f=Me.HEAPF32.subarray(p>>2,(p>>2)+l[u]);u++;let h=l[u];e.setAttribute("position",new vl.Float32BufferAttribute(d,3)),e.setAttribute("normal",new vl.Float32BufferAttribute(f,3));let m=Me.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new vl.Sphere),e.boundingSphere.radius=-1,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Me.free_mesh_data(i),h}function eT(n,t,e){if(Me===void 0)return-1;let r,o,i;if(t&&n.userData.positions!==void 0){let g=n.userData;i=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,S)=>b+S,0)+i);for(let b=0,S=0,w=0;b<g.verticesPerFace.length;b++){o[w++]=g.verticesPerFace[b];for(let v=0;v<g.verticesPerFace[b];v++)o[w++]=g.indices[S++]}}else({positions:r,faceIndices:o,nFaces:i}=KC(n,t,e));let a=r.length,s=o.length,l=r.length,u=o.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,p=u*Uint32Array.BYTES_PER_ELEMENT,f=Me._malloc(c),h=new Float32Array(Me.HEAPF32.buffer,f,l),m=new Uint32Array(Me.HEAPU32.buffer,f+d,u);h.set(r,0),m.set(o,0);let y=Me.get_csg_mesh(f,a,f+d,s,i);return Me._free(f),y}function tT(n){return Me.has_open_edges(n)}function rT(n,t){Me.transform_csg_mesh(n,t.elements)}function oT(n){Me.free_csg_mesh(n)}var nT={ConeGeometry:o0,CubeGeometry:n0,CylinderGeometry:r0,DodecahedronGeometry:a0,EllipseGeometry:Ra,HelixGeometry:L0,IcosahedronGeometry:V0,LatheGeometry:z0,NonParametricGeometry:j0,PolygonGeometry:Cu,PyramidGeometry:U0,RectangleGeometry:Ga,SphereGeometry:H0,PlaneGeometry:W0,BackdropGeometry:$0,StarGeometry:Tu,TextFrameGeometry:X0,TorusGeometry:Q0,TorusKnotGeometry:Z0,TriangleGeometry:J0,PathGeometry:tx,VectorGeometry:gr},Kp=n=>nT[n.type].create(n);function Ha(n){return n!==null&&"booleanOp"in n}var qa=class extends Ta(Eu.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new Eu.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!Ha(this.parent)&&this.visible,Ha(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Gr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ha(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof qa&&(e.freeBooleanPointer(),Ha(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&Ha(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ha(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Bu=new Wa.Box3;function Sl(n,t=0,e=n.count,r,o){let i=1/0,a=1/0,s=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=t;d<e;d++){let p=n.getX(d),f=n.getY(d),h=n.getZ(d);p<i&&(i=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>u&&(u=f),h>c&&(c=h)}Bu.min.set(i,a,s),Bu.max.set(l,u,c),Bu.getCenter(r),Bu.getSize(o).multiplyScalar(.5)}var iT=new Wa.BufferGeometry,aT=new Wa.MeshBasicMaterial,Bt=class extends qa{constructor(t,e){super(iT,aT),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Sl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var un=require("three");var Er=require("three");var Fx=require("three");var co=require("three");var wl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var yx=require("three"),Ht=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=yx.MathUtils.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,i,a){return""}generate(t,e,r,o,i){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof Ht&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)e=this.hashProperties[o],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}};var of=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Lt=new of;var nf=require("three");var gx=require("three"),se=class extends Ht{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,i){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=gx.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let u=this.getTemp(e,o);if(u)return e.format(u,l,r);{u=super.generate(e,r,o,s.output,i);let c=this.generate(e,l,o);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,i,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),a,this.getLabel()).name}};var Ye=class extends se{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,r)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,r))}};var mt=class extends Ye{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof nf.Vector2?e:new nf.Vector2(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,i,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,r)}};var af=require("three");var Kt=class extends Ye{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof af.Vector3?e:new af.Vector3(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,i,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,r)}};var xx=require("three"),Rt=class extends xx.Color{constructor(e,r,o,i){super(e,r,o);this.isColorA=!0;this.a=i}setRGBA(e,r,o,i){super.setRGB(e,r,o),this.a=i}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,r="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let i,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(i[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(i[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var xr=class extends Ye{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Rt?e:new Rt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,i,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,r)}};var sT=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,bx=/[a-z_0-9]+/gi,Q=class extends se{constructor(e,r,o,i,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,i)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,i,a){let s,l=0,u=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 c=[];for(;s=bx.exec(this.src);)c.push(s);for(let d=0;d<c.length;d++){let p=c[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Lt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Lt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Lt.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&u[p.index+l-1]!=="."&&(u=u.substring(0,p.index+l)+m+u.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Lt.contains(m)&&e.include(Lt.get(m))}return r==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),r)}parse(e,r,o,i){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let a=sT.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(bx);if(s){let l=0;for(;l<s.length;){let u=s[l++],c;u==="in"||u==="out"||u==="inout"?c=s[l++]:(c=u,u="");let d=s[l++];this.inputs.push({name:d,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var lT=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,sf=class extends se{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||sf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,i,a){this.src=e||"";let s,l,u="",c=lT.exec(e);this.useDefine=a??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],s=c[2],u=c[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=u}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,i,a){return e.format(this.name,this.getType(e),r)}},ke=sf;ke.PI="PI",ke.PI2="PI2",ke.RECIPROCAL_PI="RECIPROCAL_PI",ke.RECIPROCAL_PI2="RECIPROCAL_PI2",ke.LOG2="LOG2",ke.EPSILON="EPSILON";var cT=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
18
- )*?)}`,"gim"),uT=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),$a=class extends se{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,o,i,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=cT.exec(e);if(r){let o=r[2],i;for(;i=uT.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=r[1]}else this.name="";this.type=this.name}};var Ya=class extends se{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",i=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(i,this.getType(e),r)}};Lt.addKeyword("uv",function(){return new Ya});Lt.addKeyword("uv2",function(){return new Ya(1)});var Lu=require("three");var gi=class extends se{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??gi.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Lu.LinearEncoding:return["Linear"];case Lu.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),i=this.getType(e),a=gi.Nodes[this.method],s=e.include(a);if(s===gi.LINEAR_TO_LINEAR)return e.format(o,i,r);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",i,r)}else return e.format(s+"( "+o+" )",i,r)}fromEncoding(e){let r=gi.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=gi.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},sr=gi;sr.Nodes={LinearToLinear:new Q(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
19
- `)),sRGBToLinear:new Q(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
20
- `)),LinearTosRGB:new Q(["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(`
21
- `))},sr.LINEAR_TO_LINEAR="LinearToLinear",sr.SRGB_TO_LINEAR="sRGBToLinear",sr.LINEAR_TO_SRGB="LinearTosRGB";var Ue=class extends Q{constructor(e="",r,o,i,a){super(e,a,i,o,r);this.nodeType="Expression"}};var vx=require("three"),lr=class extends Ye{constructor(e=new vx.Texture,r,o,i){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r??new Ya,this.bias=o,this.project=i!==void 0?i:!1}getTexture(e,r){return super.generate(e,r,this.value.uuid,"t")}generate(e,r){if(r==="sampler2D")return this.getTexture(e,r);let o=this.getTexture(e,r),i=this.uv.build(e,this.project?"v4":"v2"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s,l;this.project?s="texture2DProj":s=a?"tex2DBias":"tex2D",a?l=s+"( "+o+", "+i+", "+a+" )":l=s+"( "+o+", "+i+" )";let u={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(u),this.colorSpace=this.colorSpace??new sr(new Ue("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,c),e.removeContext(),e.format(l,c,r)}};var J=class extends Ye{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,r,o,i,a,s){return e.format(this.value+(this.value%1?"":".0"),i,r)}};var _l=class extends se{constructor(e,r){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=r??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,r,o,i,a){i=this.getType(e);let s=this.value,l=s.build(e,r)+"( ",u=[];if(s.inputs){for(let c=0;c<s.inputs.length;c++){let d=s.inputs[c],p=this.inputs[c]||this.inputs[d.name];u.push(p.build(e,e.getTypeByFormat(d.type)))}l+=u.join(", ")+" )"}return e.format(l,i,r)}};var lf=class extends se{constructor(e,r,o=lf.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=r,this.op=o}getType(e){let r=this.a.getType(e),o=this.b.getType(e);return e.isTypeMatrix(r)?"v4":e.getTypeLength(o)>e.getTypeLength(r)?o:r}generate(e,r){let o=this.getType(e);this.type=o;let i=this.a.build(e,o),a=this.b.build(e,o);return e.format("( "+i+" "+this.op+" "+a+" )",o,r)}},qt=lf;qt.ADD="+",qt.SUB="-",qt.MUL="*",qt.DIV="/";var Xe=class extends se{constructor(e,r=Xe.ABS,o,i){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:i=r,typeof o!="string"?this.c=o:i=o,this.method=i,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case Xe.MIX:case Xe.CLAMP:case Xe.REFRACT:case Xe.SMOOTHSTEP:case Xe.FACEFORWARD:return 3;case Xe.MIN:case Xe.MAX:case Xe.MOD:case Xe.STEP:case Xe.REFLECT:case Xe.DISTANCE:case Xe.DOT:case Xe.CROSS:case Xe.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),o=this.b?e.getTypeLength(this.b.getType(e)):0,i=this.c?e.getTypeLength(this.c.getType(e)):0;return r>o&&r>i?this.a.getType(e):o>i?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case Xe.LENGTH:case Xe.DISTANCE:case Xe.DOT:return"f";case Xe.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let o,i,a,s=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,u=this.c?e.getTypeLength(this.c.getType(e)):0,c=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case Xe.NEGATE:return e.format("( -"+this.a.build(e,c)+" )",c,r);case Xe.INVERT:return e.format("( 1.0 - "+this.a.build(e,c)+" )",c,r);case Xe.CROSS:o=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case Xe.STEP:o=this.a.build(e,s===1?"f":c),i=this.b.build(e,c);break;case Xe.MIN:case Xe.MAX:case Xe.MOD:o=this.a.build(e,c),i=this.b.build(e,l===1?"f":c);break;case Xe.REFRACT:o=this.a.build(e,c),i=this.b.build(e,c),a=this.c.build(e,"f");break;case Xe.MIX:o=this.a.build(e,c),i=this.b.build(e,c),a=this.c.build(e,u===1?"f":c);break;default:o=this.a.build(e,c),this.b&&(i=this.b.build(e,c)),this.c&&(a=this.c.build(e,c));break}let p=[];p.push(o),i&&p.push(i),a&&p.push(a);let f=this.getNumInputs(e);if(p.length!==f)throw Error(`Arguments not match used in "${this.method}". Require ${f}, currently ${p.length}.`);return e.format(this.method+"( "+p.join(", ")+" )",d,r)}},ve=Xe;ve.RAD="radians",ve.DEG="degrees",ve.EXP="exp",ve.EXP2="exp2",ve.LOG="log",ve.LOG2="log2",ve.SQRT="sqrt",ve.INV_SQRT="inversesqrt",ve.FLOOR="floor",ve.CEIL="ceil",ve.NORMALIZE="normalize",ve.FRACT="fract",ve.SATURATE="saturate",ve.SIN="sin",ve.COS="cos",ve.TAN="tan",ve.ASIN="asin",ve.ACOS="acos",ve.ARCTAN="atan",ve.ABS="abs",ve.SIGN="sign",ve.LENGTH="length",ve.NEGATE="negate",ve.INVERT="invert",ve.MIN="min",ve.MAX="max",ve.MOD="mod",ve.STEP="step",ve.REFLECT="reflect",ve.DISTANCE="distance",ve.DOT="dot",ve.CROSS="cross",ve.POW="pow",ve.MIX="mix",ve.CLAMP="clamp",ve.REFRACT="refract",ve.SMOOTHSTEP="smoothstep",ve.FACEFORWARD="faceforward";var Xa=class extends se{constructor(e,r,o){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=o}bilinearCubeUV(e,r,o,i){let a=new _l(Xa.Nodes.bilinearCubeUV,[r,o,i]);this.colorSpaceTL=this.colorSpaceTL??new sr(new Ue("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new sr(new Ue("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new sr(new Ue("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new sr(new Ue("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(a.build(e)+".br");let s={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(s),this.colorSpaceTLExp=new Ue(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Ue(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Ue(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Ue(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new Ue("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return l.keywords.cubeUV_TL=this.colorSpaceTLExp,l.keywords.cubeUV_TR=this.colorSpaceTRExp,l.keywords.cubeUV_BL=this.colorSpaceBLExp,l.keywords.cubeUV_BR=this.colorSpaceBRExp,l.keywords.cubeUV=a,l}generate(e,r){if(e.isShader("fragment")){let o=this.uv,i=this.bias||e.context.roughness,a=new _l(Xa.Nodes.roughnessToMip,[i]),s=new ve(a,Xa.Nodes.m0,Xa.Nodes.cubeUV_maxMipLevel,ve.CLAMP),l=new ve(s,ve.FLOOR),u=new ve(s,ve.FRACT),c=this.bilinearCubeUV(e,this.value,o,l),d=this.bilinearCubeUV(e,this.value,o,new qt(l,new J(1).setReadonly(!0),qt.ADD)),p=new ve(c,d,u,ve.MIX);return e.format(p.build(e),"v4",r)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r)}},Qa=Xa;Qa.Nodes=function(){let e=new $a(`struct TextureCubeUVData {
18
+ `&&r.push("")):t.getTextWidth(r[r.length-1]+o,n)>n.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+o,n)>n.width&&(o.length===1?(r[r.length-1]+=o,o=""):(r[r.length-1]+=o.slice(0,-1),o=o[o.length-1],r.push(""))));return r[r.length-1]+=o,r}var lt=require("three");var Yx,td=new Promise(n=>{Yx=n}),$x=!1;var ed;function Xx(){if($x)return;if(ed)return ed;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.0.23/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(u=>u.arrayBuffer())]),s=i.default,l=await s({wasmBinary:a});Yx(l),$x=!0}return ed=n(),ed}var Qx=require("three");var QT=["font"];function gn(n,t,e,r){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let u of a){let c=i;for(let d of u)c=c[d];for(o in c){let d=c[o];Rp(d)&&!QT.includes(o)&&(c[o]=t.getVariable(d,[r.uuid,"geometry",...u,o]),Rp(c[o])&&(c[o]=1))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let u=Qe.createFromState(i.shape,i.width,i.height);s.shape=u}else if(i.type==="NonParametricGeometry")i.data.groups&&i.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),s.geometry=new Qx.BufferGeometryLoader().parse(i);else if(i.type==="SubdivGeometry"){let u=new Vt(i,e);return u.data=n,u}else{if(i.type==="TextGeometry")return new as(i,t);if(i.type==="UIGeometry")return ns.create({parameters:{width:i.width,height:i.height,cornerRadius:i.cornerRadius,cornerType:i.cornerType}})}let l;try{l=Bf(s)}catch(u){console.error(u)}if(!l){let u=Qe.createFromState(Da.defaultData(),100,100);s.shape=u,l=Bf(s)}return l}var Kx=require("three"),KT=new Kx.Matrix4;function kl(n,t,e,r){let o=n.position.array,i=n.normal.array,a=KT.makeScale(t,e,r).invert().elements,s,l,u;for(var c=0,d=o.length;c<d;c+=3)o[c]*=t,o[c+1]*=e,o[c+2]*=r,s=i[c],l=i[c+1],u=i[c+2],i[c]=a[0]*s+a[4]*l+a[8]*u,i[c+1]=a[1]*s+a[5]*l+a[9]*u,i[c+2]=a[2]*s+a[6]*l+a[10]*u;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var rd=new lt.Box3,ss=new lt.Vector3,Ae;td.then(n=>{Ae=n});var Zx=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Jx=new Uint32Array([0,1,2,3]),eb=new Uint8Array([4]),Vt=class extends lt.BufferGeometry{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,i=Rn.div(r,o);this.subdividedGeometry&&kl(this.subdividedGeometry.attributes,...i),this.originalGeometry&&kl(this.originalGeometry.attributes,...i),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*i[0],height:a.height*i[1],depth:a.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(ss.fromArray(i));let s=ss.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=Vt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new lt.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Vt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new lt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;rd.setFromBufferAttribute(r),rd.getCenter(o),e.boundingSphere.radius=o.distanceTo(rd.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),rd.getSize(ss);let i={width:ss.x,height:ss.y,depth:ss.z};return this.userData.parameters=i,i}static build(e,r,o,i){let a,s,l,u=e?.phongAngle??35;o===!1&&(u=-1),r&&(Ae.free_bvh(r),Ae.free_subdivision_surface(r));try{a=Vt.allocate(e,i)}catch(c){console.error(c,e),a=Vt.allocate({positionWASM:Zx,indexWASM:Jx,verticesPerFaceWASM:eb},i)}if(Ae.set_destination_refinement_level(a,0),s=Vt.buildLevel(a,!0,u),e.subdivisions>0)try{Ae.set_destination_refinement_level(a,e.subdivisions),l=Vt.buildLevel(a,!1,u)}catch{try{Ae.set_destination_refinement_level(a,e.subdivisions-1),l=Vt.buildLevel(a,!1,u)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let i=e.shape!==void 0||e.path!==void 0?r.geometry:gn(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,l,u,c;({positions:s,triIndices:c}=zf(i.getAttribute("position"),a));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;d=[p,f]}return{indices:l,verticesPerFace:u}=Gf(s,c,i,d),{positions:s,indices:l,verticesPerFace:u}}static allocate(e,r){let o,i,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=Zx,i=Jx,a=eb);let u=o.length,c=i.length,d=a.length,p=o.length+s.length+l.length,f=i.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,g=Ae._malloc(h),b=new Float32Array(Ae.HEAPF32.buffer,g,p),w=new Uint32Array(Ae.HEAPU32.buffer,g+m,f);b.set(o,0),b.set(s,o.length),b.set(l,o.length+s.length),w.set(i,0),w.set(a,i.length);let _;e?.scaleBaked?.some(P=>P!==1)&&(_=new lt.Matrix4().makeScale(...e.scaleBaked)),r&&(_?_.premultiply(r):_=r);let S=_?Ae.alloc_subdivision_surface2(g,u,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,d,_.elements):Ae.alloc_subdivision_surface(g,u,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,d);return Ae._free(g),S}static buildLevel(e,r,o,i,a){let s=a?Ae.get_mesh_data2(e,r?Ae.Level.CONTROL:Ae.Level.REFINED,o,a.elements):Ae.get_mesh_data(e,r?Ae.Level.CONTROL:Ae.Level.REFINED,o),l=8,u=Ae.HEAPU32.subarray(s>>2,(s>>2)+l),c=u.subarray(4,4+4),d=0,p=Ae.HEAPU32[u[d]>>2],f=Ae.HEAPF32.subarray(p>>2,(p>>2)+c[d]);d++;let h=Ae.HEAPU32[u[d]>>2],m=Ae.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let y=Ae.HEAPU32[u[d]>>2],g=Ae.HEAPU32.subarray(y>>2,(y>>2)+c[d]);d++;let b=Ae.HEAPU32[u[d]>>2],w=Ae.HEAPU32.subarray(b>>2,(b>>2)+c[d]);if(d++,i===void 0){let _=new lt.BufferGeometry;if(_.setIndex(new lt.Uint32BufferAttribute(w,1)),_.setAttribute("position",new lt.Float32BufferAttribute(f,3)),_.setAttribute("normal",new lt.Float32BufferAttribute(m,3)),r){_.setAttribute("faceMap",new lt.Uint32BufferAttribute(g,1));let S=new Float32Array(m.length/3*4).fill(0);_.setAttribute("color",new lt.BufferAttribute(S,4))}return Ae.free_mesh_data(s),_.userData.type="SubdivGeometry",_}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,Ae.free_mesh_data(s)}static freeSubdivPointer(e){Ae.free_bvh(e),Ae.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let i=Ae.get_wireframe_data_for_base_level(e),a=4,s=Ae.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),u=0,c=Ae.HEAPU32[s[u]>>2],d=Ae.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let p=Ae.HEAPU32[s[u]>>2],f=Ae.HEAPU32.subarray(p>>2,(p>>2)+l[u]);if(r===void 0){let h=new lt.BufferGeometry;h.setAttribute("position",new lt.Float32BufferAttribute(d,3));let m=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new lt.BufferAttribute(m,3)),h.setIndex(new lt.Uint32BufferAttribute(f,1)),Ae.free_wireframe_data_for_base_level(i),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,Ae.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,r,o){let i=r===0;i||Ae.set_destination_refinement_level(e,r);let a=o?Ae.get_topological_data2(e,i?Ae.Level.CONTROL:Ae.Level.REFINED,o.elements):Ae.get_topological_data(e,i?Ae.Level.CONTROL:Ae.Level.REFINED),s=6,l=Ae.HEAPU32.subarray(a>>2,(a>>2)+s),u=l.subarray(3,3+3),c=0,d=Ae.HEAPU32[l[c]>>2],p=new Float32Array(Ae.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=Ae.HEAPU32[l[c]>>2],h=new Uint32Array(Ae.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let m=Ae.HEAPU32[l[c]>>2],y=new Uint8Array(Ae.HEAPU32.subarray(m>>2,(m>>2)+u[c]));return Ae.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var tb=["getX","getY","getZ"];function zf(n,t){let e={},r=t?t.count:n.count,o=0,i=[],a=[],s=1e4;for(let u=0;u<r;u++){let c=t?t.getX(u):u,d="";for(let p=0;p<3;p++)d+=`${~~(n[tb[p]](c)*s)},`;if(d in e)i.push(e[d]);else{for(let p=0;p<3;p++)a.push(n[tb[p]](c));e[d]=o,i.push(o),o++}}let l=[];for(let u=0;u<i.length;u+=3)i[u]===i[u+1]||i[u]===i[u+2]||i[u+1]===i[u+2]||l.push(i[u],i[u+1],i[u+2]);return{positions:a,triIndices:l}}var od=new lt.Vector3,Lf=new lt.Vector3,Rf=new lt.Vector3,Vf=new lt.Vector3;function Gf(n,t,e,r){let o=[],i=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),u=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&u<=24&&u%4===0&&e.userData.parameters.angle>=360){let p=l.length/2/u;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let c=0;for(let p=0;p<l.length;p+=2)c+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);n.length=0;let d=0;if(c<0)for(let p=0;p<l.length;p+=2)n.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)n.push(l[p],l[p+1],0),o.push(d++);return i.push(d),{indices:o,verticesPerFace:i}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[t[s]*3+2]===a||n[t[s]*3+2]===0)&&l++,(n[t[s+1]*3+2]===a||n[t[s+1]*3+2]===0)&&l++,(n[t[s+2]*3+2]===a||n[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){od.set(n[t[s]*3],n[t[s]*3+1],n[t[s]*3+2]),Lf.set(n[t[s+1]*3],n[t[s+1]*3+1],n[t[s+1]*3+2]),Rf.set(n[t[s+4]*3],n[t[s+4]*3+1],n[t[s+4]*3+2]),Vf.set(n[t[s+5]*3],n[t[s+5]*3+1],n[t[s+5]*3+2]),Lf.sub(od).normalize(),Rf.sub(od).normalize(),Vf.sub(od).normalize();let l=Lf.cross(Rf).dot(Vf);Math.abs(l)>.005||r&&r.some((u,c)=>c%2===1?!1:s>=r[c]&&s<r[c+1])?(o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),i.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],u=[],c=0;for(let d=0,p=0;d<n.length;d+=3,p++)n[d+2]===0&&(l.push(p),c++),n[d+2]===a&&u.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=u[0];u[0]=u[1],u[1]=d}l.reverse(),o.push(...l,...u),i.push(c,c)}return{indices:o,verticesPerFace:i}}var Kr={};Kh(Kr,{calcBoolean:()=>tM,calcBooleanTopological:()=>eM,freeMeshSet:()=>iM,getMeshSet:()=>rM,hasOpenEdges:()=>oM,transformMeshSet:()=>nM});var ZT,rb=new Promise(n=>{ZT=n});var Fl=require("three");var Re,ls;rb.then(n=>Re=n);function JT(n,t,e){let r,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:a}=zf(n.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:u}=Gf(i,a,n);s=u.length,r=[];for(let c=0,d=0;c<s;c++){r.push(u[c]);for(let p=0;p<u[c];p++)r.push(l[d++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let u=0,c=0;c<r.length;)r[c++]=3,s++,r[c++]=a[u++],r[c++]=a[u++],r[c++]=a[u++]}return{positions:i,faceIndices:r,nFaces:s}}function ob(n){let t=n.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:r,i=Re._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Re.HEAPU32.buffer,i,t):new Float32Array(Re.HEAPF32.buffer,i,t)).set(n,0),i}function nb(n){switch(n){case 0:return Re.OP.UNION;case 1:return Re.OP.INTERSECTION;case 2:return Re.OP.A_MINUS_B;case 3:return Re.OP.B_MINUS_A;case 4:return Re.OP.SYMMETRIC_DIFFERENCE;case 5:return Re.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function eM(n,t){ls===void 0&&(ls=Re.init_csg());let e=ob(n),r=Re.csg_calc_topological(ls,e,n.length,nb(t));Re._free(e);let o=6,i=Re.HEAPU32.subarray(r>>2,(r>>2)+o),a=i.subarray(3,3+3),s=0,l=Re.HEAPU32[i[s]>>2],u=new Float32Array(Re.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let c=Re.HEAPU32[i[s]>>2],d=new Uint32Array(Re.HEAPU32.subarray(c>>2,(c>>2)+a[s]));s++;let p=Re.HEAPU32[i[s]>>2],f=new Uint8Array(Re.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Re.free_mesh_data(r),{positions:u,indices:d,verticesPerFace:f}}function tM(n,t,e,r){ls===void 0&&(ls=Re.init_csg());let o=ob(n),i=Re.csg_calc(ls,o,n.length,r,nb(t));Re._free(o);let a=5,s=Re.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),u=0,c=Re.HEAPU32[s[u]>>2],d=Re.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let p=Re.HEAPU32[s[u]>>2],f=Re.HEAPF32.subarray(p>>2,(p>>2)+l[u]);u++;let h=l[u];e.setAttribute("position",new Fl.Float32BufferAttribute(d,3)),e.setAttribute("normal",new Fl.Float32BufferAttribute(f,3));let m=Re.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Fl.Sphere),e.boundingSphere.radius=-1,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Re.free_mesh_data(i),h}function rM(n,t,e){if(Re===void 0)return-1;let r,o,i;if(t&&n.userData.positions!==void 0){let g=n.userData;i=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+i);for(let b=0,w=0,_=0;b<g.verticesPerFace.length;b++){o[_++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[_++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:i}=JT(n,t,e));let a=r.length,s=o.length,l=r.length,u=o.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,p=u*Uint32Array.BYTES_PER_ELEMENT,f=Re._malloc(c),h=new Float32Array(Re.HEAPF32.buffer,f,l),m=new Uint32Array(Re.HEAPU32.buffer,f+d,u);h.set(r,0),m.set(o,0);let y=Re.get_csg_mesh(f,a,f+d,s,i);return Re._free(f),y}function oM(n){return Re.has_open_edges(n)}function nM(n,t){Re.transform_csg_mesh(n,t.elements)}function iM(n){Re.free_csg_mesh(n)}var aM={ConeGeometry:W0,CubeGeometry:$0,CylinderGeometry:q0,DodecahedronGeometry:X0,EllipseGeometry:ts,HelixGeometry:_x,IcosahedronGeometry:Ox,LatheGeometry:Cx,NonParametricGeometry:Nx,PolygonGeometry:Zu,PyramidGeometry:Dx,RectangleGeometry:ns,SphereGeometry:Ex,PlaneGeometry:Lx,BackdropGeometry:Rx,StarGeometry:Ju,TextFrameGeometry:zx,TorusGeometry:Gx,TorusKnotGeometry:Fx,TriangleGeometry:jx,PathGeometry:Hx,VectorGeometry:Tr},Bf=n=>aM[n.type].create(n);function cs(n){return n!==null&&"booleanOp"in n}var us=class extends $a(nd.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new nd.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!cs(this.parent)&&this.visible,cs(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Kr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),cs(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof us&&(e.freeBooleanPointer(),cs(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&cs(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),cs(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var id=new ds.Box3;function jl(n,t=0,e=n.count,r,o){let i=1/0,a=1/0,s=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=t;d<e;d++){let p=n.getX(d),f=n.getY(d),h=n.getZ(d);p<i&&(i=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>u&&(u=f),h>c&&(c=h)}id.min.set(i,a,s),id.max.set(l,u,c),id.getCenter(r),id.getSize(o).multiplyScalar(.5)}var sM=new ds.BufferGeometry,lM=new ds.MeshBasicMaterial,Wt=class extends us{constructor(t,e){super(sM,lM),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?jl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var vn=require("three");var Hr=require("three");var Ib=require("three");var wo=require("three");var Ul=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var ib=require("three"),rr=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=ib.MathUtils.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,i,a){return""}generate(t,e,r,o,i){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof rr&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)e=this.hashProperties[o],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}};var kf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},$t=new kf;var Ff=require("three");var ab=require("three"),ge=class extends rr{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,i){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=ab.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let u=this.getTemp(e,o);if(u)return e.format(u,l,r);{u=super.generate(e,r,o,s.output,i);let c=this.generate(e,l,o);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,i,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),a,this.getLabel()).name}};var ot=class extends ge{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,r)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,r))}};var Pt=class extends ot{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof Ff.Vector2?e:new Ff.Vector2(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,i,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,r)}};var jf=require("three");var lr=class extends ot{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof jf.Vector3?e:new jf.Vector3(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,i,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,r)}};var sb=require("three"),Yt=class extends sb.Color{constructor(e,r,o,i){super(e,r,o);this.isColorA=!0;this.a=i}setRGBA(e,r,o,i){super.setRGB(e,r,o),this.a=i}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,r="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let i,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(i[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(i[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Mr=class extends ot{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Yt?e:new Yt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,i,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,r)}};var cM=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,lb=/[a-z_0-9]+/gi,re=class extends ge{constructor(e,r,o,i,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,i)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,i,a){let s,l=0,u=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 c=[];for(;s=lb.exec(this.src);)c.push(s);for(let d=0;d<c.length;d++){let p=c[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&$t.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=$t.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||$t.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&u[p.index+l-1]!=="."&&(u=u.substring(0,p.index+l)+m+u.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&$t.contains(m)&&e.include($t.get(m))}return r==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),r)}parse(e,r,o,i){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let a=cM.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(lb);if(s){let l=0;for(;l<s.length;){let u=s[l++],c;u==="in"||u==="out"||u==="inout"?c=s[l++]:(c=u,u="");let d=s[l++];this.inputs.push({name:d,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var uM=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Uf=class extends ge{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Uf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,i,a){this.src=e||"";let s,l,u="",c=uM.exec(e);this.useDefine=a??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],s=c[2],u=c[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=u}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,i,a){return e.format(this.name,this.getType(e),r)}},Xe=Uf;Xe.PI="PI",Xe.PI2="PI2",Xe.RECIPROCAL_PI="RECIPROCAL_PI",Xe.RECIPROCAL_PI2="RECIPROCAL_PI2",Xe.LOG2="LOG2",Xe.EPSILON="EPSILON";var dM=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
19
+ )*?)}`,"gim"),pM=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),ps=class extends ge{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,o,i,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=dM.exec(e);if(r){let o=r[2],i;for(;i=pM.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=r[1]}else this.name="";this.type=this.name}};var fs=class extends ge{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",i=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(i,this.getType(e),r)}};$t.addKeyword("uv",function(){return new fs});$t.addKeyword("uv2",function(){return new fs(1)});var ad=require("three");var Ni=class extends ge{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??Ni.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case ad.LinearEncoding:return["Linear"];case ad.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),i=this.getType(e),a=Ni.Nodes[this.method],s=e.include(a);if(s===Ni.LINEAR_TO_LINEAR)return e.format(o,i,r);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",i,r)}else return e.format(s+"( "+o+" )",i,r)}fromEncoding(e){let r=Ni.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=Ni.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},Sr=Ni;Sr.Nodes={LinearToLinear:new re(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
20
+ `)),sRGBToLinear:new re(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
21
+ `)),LinearTosRGB:new re(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
22
+ `))},Sr.LINEAR_TO_LINEAR="LinearToLinear",Sr.SRGB_TO_LINEAR="sRGBToLinear",Sr.LINEAR_TO_SRGB="LinearTosRGB";var Ze=class extends re{constructor(e="",r,o,i,a){super(e,a,i,o,r);this.nodeType="Expression"}};var cb=require("three"),wr=class extends ot{constructor(e=new cb.Texture,r,o,i){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r??new fs,this.bias=o,this.project=i!==void 0?i:!1}getTexture(e,r){return super.generate(e,r,this.value.uuid,"t")}generate(e,r){if(r==="sampler2D")return this.getTexture(e,r);let o=this.getTexture(e,r),i=this.uv.build(e,this.project?"v4":"v2"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s,l;this.project?s="texture2DProj":s=a?"tex2DBias":"tex2D",a?l=s+"( "+o+", "+i+", "+a+" )":l=s+"( "+o+", "+i+" )";let u={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(u),this.colorSpace=this.colorSpace??new Sr(new Ze("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,c),e.removeContext(),e.format(l,c,r)}};var se=class extends ot{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,r,o,i,a,s){return e.format(this.value+(this.value%1?"":".0"),i,r)}};var Hl=class extends ge{constructor(e,r){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=r??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,r,o,i,a){i=this.getType(e);let s=this.value,l=s.build(e,r)+"( ",u=[];if(s.inputs){for(let c=0;c<s.inputs.length;c++){let d=s.inputs[c],p=this.inputs[c]||this.inputs[d.name];u.push(p.build(e,e.getTypeByFormat(d.type)))}l+=u.join(", ")+" )"}return e.format(l,i,r)}};var Hf=class extends ge{constructor(e,r,o=Hf.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=r,this.op=o}getType(e){let r=this.a.getType(e),o=this.b.getType(e);return e.isTypeMatrix(r)?"v4":e.getTypeLength(o)>e.getTypeLength(r)?o:r}generate(e,r){let o=this.getType(e);this.type=o;let i=this.a.build(e,o),a=this.b.build(e,o);return e.format("( "+i+" "+this.op+" "+a+" )",o,r)}},or=Hf;or.ADD="+",or.SUB="-",or.MUL="*",or.DIV="/";var nt=class extends ge{constructor(e,r=nt.ABS,o,i){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:i=r,typeof o!="string"?this.c=o:i=o,this.method=i,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case nt.MIX:case nt.CLAMP:case nt.REFRACT:case nt.SMOOTHSTEP:case nt.FACEFORWARD:return 3;case nt.MIN:case nt.MAX:case nt.MOD:case nt.STEP:case nt.REFLECT:case nt.DISTANCE:case nt.DOT:case nt.CROSS:case nt.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),o=this.b?e.getTypeLength(this.b.getType(e)):0,i=this.c?e.getTypeLength(this.c.getType(e)):0;return r>o&&r>i?this.a.getType(e):o>i?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case nt.LENGTH:case nt.DISTANCE:case nt.DOT:return"f";case nt.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let o,i,a,s=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,u=this.c?e.getTypeLength(this.c.getType(e)):0,c=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case nt.NEGATE:return e.format("( -"+this.a.build(e,c)+" )",c,r);case nt.INVERT:return e.format("( 1.0 - "+this.a.build(e,c)+" )",c,r);case nt.CROSS:o=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case nt.STEP:o=this.a.build(e,s===1?"f":c),i=this.b.build(e,c);break;case nt.MIN:case nt.MAX:case nt.MOD:o=this.a.build(e,c),i=this.b.build(e,l===1?"f":c);break;case nt.REFRACT:o=this.a.build(e,c),i=this.b.build(e,c),a=this.c.build(e,"f");break;case nt.MIX:o=this.a.build(e,c),i=this.b.build(e,c),a=this.c.build(e,u===1?"f":c);break;default:o=this.a.build(e,c),this.b&&(i=this.b.build(e,c)),this.c&&(a=this.c.build(e,c));break}let p=[];p.push(o),i&&p.push(i),a&&p.push(a);let f=this.getNumInputs(e);if(p.length!==f)throw Error(`Arguments not match used in "${this.method}". Require ${f}, currently ${p.length}.`);return e.format(this.method+"( "+p.join(", ")+" )",d,r)}},Ce=nt;Ce.RAD="radians",Ce.DEG="degrees",Ce.EXP="exp",Ce.EXP2="exp2",Ce.LOG="log",Ce.LOG2="log2",Ce.SQRT="sqrt",Ce.INV_SQRT="inversesqrt",Ce.FLOOR="floor",Ce.CEIL="ceil",Ce.NORMALIZE="normalize",Ce.FRACT="fract",Ce.SATURATE="saturate",Ce.SIN="sin",Ce.COS="cos",Ce.TAN="tan",Ce.ASIN="asin",Ce.ACOS="acos",Ce.ARCTAN="atan",Ce.ABS="abs",Ce.SIGN="sign",Ce.LENGTH="length",Ce.NEGATE="negate",Ce.INVERT="invert",Ce.MIN="min",Ce.MAX="max",Ce.MOD="mod",Ce.STEP="step",Ce.REFLECT="reflect",Ce.DISTANCE="distance",Ce.DOT="dot",Ce.CROSS="cross",Ce.POW="pow",Ce.MIX="mix",Ce.CLAMP="clamp",Ce.REFRACT="refract",Ce.SMOOTHSTEP="smoothstep",Ce.FACEFORWARD="faceforward";var hs=class extends ge{constructor(e,r,o){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=o}bilinearCubeUV(e,r,o,i){let a=new Hl(hs.Nodes.bilinearCubeUV,[r,o,i]);this.colorSpaceTL=this.colorSpaceTL??new Sr(new Ze("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new Sr(new Ze("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new Sr(new Ze("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new Sr(new Ze("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(a.build(e)+".br");let s={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(s),this.colorSpaceTLExp=new Ze(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Ze(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Ze(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Ze(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new Ze("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return l.keywords.cubeUV_TL=this.colorSpaceTLExp,l.keywords.cubeUV_TR=this.colorSpaceTRExp,l.keywords.cubeUV_BL=this.colorSpaceBLExp,l.keywords.cubeUV_BR=this.colorSpaceBRExp,l.keywords.cubeUV=a,l}generate(e,r){if(e.isShader("fragment")){let o=this.uv,i=this.bias||e.context.roughness,a=new Hl(hs.Nodes.roughnessToMip,[i]),s=new Ce(a,hs.Nodes.m0,hs.Nodes.cubeUV_maxMipLevel,Ce.CLAMP),l=new Ce(s,Ce.FLOOR),u=new Ce(s,Ce.FRACT),c=this.bilinearCubeUV(e,this.value,o,l),d=this.bilinearCubeUV(e,this.value,o,new or(l,new se(1).setReadonly(!0),or.ADD)),p=new Ce(c,d,u,Ce.MIX);return e.format(p.build(e),"v4",r)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r)}},ms=hs;ms.Nodes=function(){let e=new ps(`struct TextureCubeUVData {
22
23
  vec4 tl;
23
24
  vec4 tr;
24
25
  vec4 br;
25
26
  vec4 bl;
26
27
  vec2 f;
27
- }`),r=new ke("float cubeUV_maxMipLevel 8.0",!0),o=new ke("float cubeUV_minMipLevel 4.0",!0),i=new ke("float cubeUV_maxTileSize 256.0",!0),a=new ke("float cubeUV_minTileSize 16.0",!0),s=new Q(`float getFace(vec3 direction) {
28
+ }`),r=new Xe("float cubeUV_maxMipLevel 8.0",!0),o=new Xe("float cubeUV_minMipLevel 4.0",!0),i=new Xe("float cubeUV_maxTileSize 256.0",!0),a=new Xe("float cubeUV_minTileSize 16.0",!0),s=new re(`float getFace(vec3 direction) {
28
29
  vec3 absDirection = abs(direction);
29
30
  float face = -1.0;
30
31
  if (absDirection.x > absDirection.z) {
@@ -39,7 +40,7 @@
39
40
  face = direction.y > 0.0 ? 1.0 : 4.0;
40
41
  }
41
42
  return face;
42
- }`);s.useKeywords=!1;let l=new Q(`vec2 getUV(vec3 direction, float face) {
43
+ }`);s.useKeywords=!1;let l=new re(`vec2 getUV(vec3 direction, float face) {
43
44
  vec2 uv;
44
45
  if (face == 0.0) {
45
46
  uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x
@@ -55,7 +56,7 @@
55
56
  uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z
56
57
  }
57
58
  return 0.5 * (uv + 1.0);
58
- }`);l.useKeywords=!1;let u=new Q(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
59
+ }`);l.useKeywords=!1;let u=new re(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
59
60
  float face = getFace(direction);
60
61
  float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
61
62
  mipInt = max(mipInt, cubeUV_minMipLevel);
@@ -83,7 +84,7 @@
83
84
  uv.x -= texelSize;
84
85
  vec4 bl = texture2D(envMap, uv);
85
86
  return TextureCubeUVData( tl, tr, br, bl, f );
86
- }`,[e,s,l,r,o,i,a]);u.useKeywords=!1;let c=new ke("float r0 1.0",!0),d=new ke("float v0 0.339",!0),p=new ke("float m0 -2.0",!0),f=new ke("float r1 0.8",!0),h=new ke("float v1 0.276",!0),m=new ke("float m1 -1.0",!0),y=new ke("float r4 0.4",!0),g=new ke("float v4 0.046",!0),b=new ke("float m4 2.0",!0),S=new ke("float r5 0.305",!0),w=new ke("float v5 0.016",!0),v=new ke("float m5 3.0",!0),_=new ke("float r6 0.21",!0),A=new ke("float v6 0.0038",!0),x=new ke("float m6 4.0",!0),T=[c,d,p,f,h,m,y,g,b,S,w,v,_,A,x],C=new Q(`float roughnessToMip(float roughness) {
87
+ }`,[e,s,l,r,o,i,a]);u.useKeywords=!1;let c=new Xe("float r0 1.0",!0),d=new Xe("float v0 0.339",!0),p=new Xe("float m0 -2.0",!0),f=new Xe("float r1 0.8",!0),h=new Xe("float v1 0.276",!0),m=new Xe("float m1 -1.0",!0),y=new Xe("float r4 0.4",!0),g=new Xe("float v4 0.046",!0),b=new Xe("float m4 2.0",!0),w=new Xe("float r5 0.305",!0),_=new Xe("float v5 0.016",!0),S=new Xe("float m5 3.0",!0),P=new Xe("float r6 0.21",!0),O=new Xe("float v6 0.0038",!0),x=new Xe("float m6 4.0",!0),D=[c,d,p,f,h,m,y,g,b,w,_,S,P,O,x],N=new re(`float roughnessToMip(float roughness) {
87
88
  float mip = 0.0;
88
89
  if (roughness >= r1) {
89
90
  mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
@@ -97,7 +98,7 @@
97
98
  mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
98
99
  }
99
100
  return mip;
100
- }`,T);return{bilinearCubeUV:u,roughnessToMip:C,m0:p,cubeUV_maxMipLevel:r}}();var xi=class extends se{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??xi.VIEW}getShared(){return this.scope===xi.WORLD}build(e,r,o,i){let a=e.context[this.scope+"Normal"];return a?a.build(e,r,o,i):super.build(e,r,o)}generate(e,r,o,i,a){let s;switch(this.scope){case xi.VIEW:e.isShader("vertex")?s="transformedNormal":s="geometryNormal";break;case xi.LOCAL:e.isShader("vertex")?s="objectNormal":(e.requires.normal=!0,s="vObjectNormal");break;case xi.WORLD:e.isShader("vertex")?s="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,s="vWNormal");break}return e.format(s,this.getType(e),r)}},Wt=xi;Wt.LOCAL="local",Wt.WORLD="world",Wt.VIEW="view",Wt.NORMAL="normal";Lt.addKeyword("viewNormal",function(){return new Wt(Wt.VIEW)});Lt.addKeyword("localNormal",function(){return new Wt(Wt.NORMAL)});Lt.addKeyword("worldNormal",function(){return new Wt(Wt.WORLD)});var Io=class extends se{constructor(e){super("v3");this.nodeType="Position";this.scope=e??Io.LOCAL}getType(){switch(this.scope){case Io.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Io.LOCAL:case Io.WORLD:return!1}return!0}generate(e,r,o,i,a){let s;switch(this.scope){case Io.LOCAL:e.isShader("vertex")?s="transformed":(e.requires.position=!0,s="vPosition");break;case Io.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,s="vWPosition";break;case Io.VIEW:s=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Io.PROJECTION:s=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(s,this.getType(),r)}},br=Io;br.LOCAL="local",br.WORLD="world",br.VIEW="view",br.PROJECTION="projection";Lt.addKeyword("position",function(){return new br});Lt.addKeyword("worldPosition",function(){return new br(br.WORLD)});Lt.addKeyword("viewPosition",function(){return new br(br.VIEW)});var lo=class extends se{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??lo.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case lo.SPHERE:return"v2"}return this.type}generate(e,r){let o=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case lo.VECTOR:{let a=new Wt(Wt.VIEW),s=e.context.roughness,l=a.build(e,"v3"),u=new br(br.VIEW).build(e,"v3"),c=s?s.build(e,"f"):void 0,d=`reflect( -normalize( ${u} ), ${l} )`;c&&(d=`normalize( mix( ${d}, ${l}, ${c} * ${c} ) )`);let p=`inverseTransformDirection( ${d}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${p};`),i="reflectVec"):i=p;break}case lo.CUBE:{let a=new lo(lo.VECTOR).build(e,"v3"),s="vec3( -"+a+".x, "+a+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${s};`),i="reflectCubeVec"):i=s;break}case lo.SPHERE:{let s="normalize( ( viewMatrix * vec4( "+new lo(lo.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${s};`),i="reflectSphereVec"):i=s;break}}return e.format(i,this.getType(),r)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,r)}},No=lo;No.CUBE="cube",No.SPHERE="sphere",No.VECTOR="vector";var Ru=class extends se{constructor(e=new lr,r,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Qa(this.value,r??new No(No.VECTOR),o),this.irradianceNode=new Qa(this.value,new Wt(Wt.WORLD),new J(1).setReadonly(!0))}generate(e,r){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,r)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r))}};var Sx=require("three");var Vu=class extends Ye{constructor(e=new Sx.CubeTexture,r,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=r??new No,this.bias=o}getTexture(e,r){return super.generate(e,r,this.value.uuid,"tc")}generate(e,r){if(r==="samplerCube")return this.getTexture(e,r);let o=this.getTexture(e,r),i=this.uv?.build(e,"v3"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s;a?s="texCubeBias( "+o+", "+i+", "+a+" )":s="texCube( "+o+", "+i+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new sr(new Ue("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(s),s=this.colorSpace.build(e,u),e.removeContext(),e.format(s,u,r)}};var wx=`
101
+ }`,D);return{bilinearCubeUV:u,roughnessToMip:N,m0:p,cubeUV_maxMipLevel:r}}();var Di=class extends ge{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??Di.VIEW}getShared(){return this.scope===Di.WORLD}build(e,r,o,i){let a=e.context[this.scope+"Normal"];return a?a.build(e,r,o,i):super.build(e,r,o)}generate(e,r,o,i,a){let s;switch(this.scope){case Di.VIEW:e.isShader("vertex")?s="transformedNormal":s="geometryNormal";break;case Di.LOCAL:e.isShader("vertex")?s="objectNormal":(e.requires.normal=!0,s="vObjectNormal");break;case Di.WORLD:e.isShader("vertex")?s="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,s="vWNormal");break}return e.format(s,this.getType(e),r)}},nr=Di;nr.LOCAL="local",nr.WORLD="world",nr.VIEW="view",nr.NORMAL="normal";$t.addKeyword("viewNormal",function(){return new nr(nr.VIEW)});$t.addKeyword("localNormal",function(){return new nr(nr.NORMAL)});$t.addKeyword("worldNormal",function(){return new nr(nr.WORLD)});var Fo=class extends ge{constructor(e){super("v3");this.nodeType="Position";this.scope=e??Fo.LOCAL}getType(){switch(this.scope){case Fo.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Fo.LOCAL:case Fo.WORLD:return!1}return!0}generate(e,r,o,i,a){let s;switch(this.scope){case Fo.LOCAL:e.isShader("vertex")?s="transformed":(e.requires.position=!0,s="vPosition");break;case Fo.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,s="vWPosition";break;case Fo.VIEW:s=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Fo.PROJECTION:s=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(s,this.getType(),r)}},Ir=Fo;Ir.LOCAL="local",Ir.WORLD="world",Ir.VIEW="view",Ir.PROJECTION="projection";$t.addKeyword("position",function(){return new Ir});$t.addKeyword("worldPosition",function(){return new Ir(Ir.WORLD)});$t.addKeyword("viewPosition",function(){return new Ir(Ir.VIEW)});var So=class extends ge{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??So.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case So.SPHERE:return"v2"}return this.type}generate(e,r){let o=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case So.VECTOR:{let a=new nr(nr.VIEW),s=e.context.roughness,l=a.build(e,"v3"),u=new Ir(Ir.VIEW).build(e,"v3"),c=s?s.build(e,"f"):void 0,d=`reflect( -normalize( ${u} ), ${l} )`;c&&(d=`normalize( mix( ${d}, ${l}, ${c} * ${c} ) )`);let p=`inverseTransformDirection( ${d}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${p};`),i="reflectVec"):i=p;break}case So.CUBE:{let a=new So(So.VECTOR).build(e,"v3"),s="vec3( -"+a+".x, "+a+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${s};`),i="reflectCubeVec"):i=s;break}case So.SPHERE:{let s="normalize( ( viewMatrix * vec4( "+new So(So.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${s};`),i="reflectSphereVec"):i=s;break}}return e.format(i,this.getType(),r)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,r)}},jo=So;jo.CUBE="cube",jo.SPHERE="sphere",jo.VECTOR="vector";var sd=class extends ge{constructor(e=new wr,r,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new ms(this.value,r??new jo(jo.VECTOR),o),this.irradianceNode=new ms(this.value,new nr(nr.WORLD),new se(1).setReadonly(!0))}generate(e,r){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,r)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r))}};var ub=require("three");var ld=class extends ot{constructor(e=new ub.CubeTexture,r,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=r??new jo,this.bias=o}getTexture(e,r){return super.generate(e,r,this.value.uuid,"tc")}generate(e,r){if(r==="samplerCube")return this.getTexture(e,r);let o=this.getTexture(e,r),i=this.uv?.build(e,"v3"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s;a?s="texCubeBias( "+o+", "+i+", "+a+" )":s="texCube( "+o+", "+i+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new Sr(new Ze("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(s),s=this.colorSpace.build(e,u),e.removeContext(),e.format(s,u,r)}};var db=`
101
102
  uniform int frameIndex;
102
103
  uniform vec2 resolution;
103
104
  uniform mat4 previousModelViewMatrix;
@@ -105,7 +106,7 @@ uniform mat4 previousProjectionMatrix;
105
106
 
106
107
  varying vec4 vCurrentPosition;
107
108
  varying vec4 vPreviousPosition;
108
- `,_x=`
109
+ `,pb=`
109
110
  layout(location = 1) out vec4 gVelocity;
110
111
 
111
112
  uniform int frameIndex;
@@ -147,7 +148,7 @@ float getNoiseInterleavedGradient(vec2 screenPos) {
147
148
  return fract(magic.z * fract(dot(screenPos, magic.xy)));
148
149
  }
149
150
 
150
- `,Ax=`
151
+ `,fb=`
151
152
  // TODO: This could be generated CPU side and passed to the shader every frame
152
153
  const vec2 haltonSequence[16] = vec2[16](
153
154
  vec2( 0.000000,-0.333334),
@@ -184,7 +185,7 @@ vPreviousPosition.xy += OUTLINE_COMPENSATION;
184
185
  #endif
185
186
  gl_Position = currentPositionJittered;
186
187
 
187
- `,Px=`
188
+ `,hb=`
188
189
  vec2 oldPos = vPreviousPosition.xy;
189
190
  oldPos /= vPreviousPosition.w;
190
191
  oldPos.xy = (oldPos.xy+1.)/2.0;
@@ -199,14 +200,14 @@ vec2 velocity = (newPos - oldPos);
199
200
  if (gl_FragColor.a <= 0.0) discard;
200
201
 
201
202
  gVelocity = vec4(velocity, 0.0, 1.0);
202
- `,Ox=`
203
+ `,mb=`
203
204
  layout(location = 1) out vec4 gVelocity;
204
- `,Cx=`
205
+ `,yb=`
205
206
  // Discard fully transparent pixels
206
207
  if (gl_FragColor.a <= 0.0) discard;
207
208
 
208
209
  gVelocity = vec4(0.0, 0.0, 0.0, 1.0);
209
- `;var Tx=["x","y","z","w"],dT=["float","vec2","vec3","vec4"],pT={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},fT={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[]"},Ka=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.needsJitter=!0;this.getIncludesCode=function(){function t(e,r){return e.deps.length-r.deps.length}return function(r,o){let i=this.getIncludes(r,o);if(!i)return"";let a="";i=i.sort(t);for(let s=0;s<i.length;s++)i[s].src&&(a+=i[s].src+`
210
+ `;var gb=["x","y","z","w"],fM=["float","vec2","vec3","vec4"],hM={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},mM={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[]"},ys=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.needsJitter=!0;this.getIncludesCode=function(){function t(e,r){return e.deps.length-r.deps.length}return function(r,o){let i=this.getIncludes(r,o);if(!i)return"";let a="";i=i.sort(t);for(let s=0;s<i.length;s++)i[s].src&&(a+=i[s].src+`
210
211
  `);return a}}();this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.fragmentParsVariables={},this.vertexParsVariables={},this.requires={uv:[],color:[],transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,modelMatrix:!1,viewMatrix:!1,projectionMatrix:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCube(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2D(a, b, c)","#endif",`
211
212
  // NOTE: Include Spline's blending modes. This could be part of BlendNode
212
213
  #define SPE_BLENDING_NORMAL 0
@@ -244,20 +245,20 @@ layout(location = 1) out vec4 gVelocity;
244
245
  `),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
245
246
  accumAlpha += (1.0 - accumAlpha) * alpha;
246
247
  }`,""].join(`
247
- `)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(t,e){this.addVertexParsCode(wx),this.addFragmentParsCode(_x),this.buildShader("vertex",t),this.buildShader("fragment",e);for(let r=0;r<this.requires.uv.length;r++)if(this.requires.uv[r]){let o=r>0?r+1:"";this.addVaryCode("varying vec2 vUv"+o+";"),r>0&&this.addVertexParsCode("attribute vec2 uv"+o+";"),this.addVertexFinalCode("vUv"+o+" = uv"+o+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("vObjectNormal = normal;")),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.needsJitter&&(this.addVertexFinalCode(Ax),this.addFragmentFinalCode(Px)),this}buildShader(t,e){this.resultCode[t]=e.build(this.setShader(t),"v4")}setMaterial(t,e){return this.defines={},this}addFlow(t,e,r){return this.addSlot(t).addCache(e).addContext(r)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(t){return this.cache=t??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(t){return this.context=Object.assign({},this.context,t),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(t){return this.slot=t||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(t,e){this.fragmentVariables[t]===void 0&&(this.addFragmentCode(`${e} ${t};`),this.fragmentVariables[t]="")}addFragmentParsVariable(t,e){this.fragmentParsVariables[t]===void 0&&(this.addFragmentParsCode(`${e} ${t};`),this.fragmentParsVariables[t]="")}addVertexParsVariable(t,e){this.vertexParsVariables[t]===void 0&&(this.addVertexParsCode(`${e} ${t};`),this.vertexParsVariables[t]="")}addVertexCode(t){this.addCode(t,"vertex")}addFragmentCode(t){this.addCode(t,"fragment")}addCode(t,e){this.code[e??this.shader]+=t+`
248
+ `)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(t,e){this.addVertexParsCode(db),this.addFragmentParsCode(pb),this.buildShader("vertex",t),this.buildShader("fragment",e);for(let r=0;r<this.requires.uv.length;r++)if(this.requires.uv[r]){let o=r>0?r+1:"";this.addVaryCode("varying vec2 vUv"+o+";"),r>0&&this.addVertexParsCode("attribute vec2 uv"+o+";"),this.addVertexFinalCode("vUv"+o+" = uv"+o+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("vObjectNormal = normal;")),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.needsJitter&&(this.addVertexFinalCode(fb),this.addFragmentFinalCode(hb)),this}buildShader(t,e){this.resultCode[t]=e.build(this.setShader(t),"v4")}setMaterial(t,e){return this.defines={},this}addFlow(t,e,r){return this.addSlot(t).addCache(e).addContext(r)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(t){return this.cache=t??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(t){return this.context=Object.assign({},this.context,t),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(t){return this.slot=t||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(t,e){this.fragmentVariables[t]===void 0&&(this.addFragmentCode(`${e} ${t};`),this.fragmentVariables[t]="")}addFragmentParsVariable(t,e){this.fragmentParsVariables[t]===void 0&&(this.addFragmentParsCode(`${e} ${t};`),this.fragmentParsVariables[t]="")}addVertexParsVariable(t,e){this.vertexParsVariables[t]===void 0&&(this.addVertexParsCode(`${e} ${t};`),this.vertexParsVariables[t]="")}addVertexCode(t){this.addCode(t,"vertex")}addFragmentCode(t){this.addCode(t,"fragment")}addCode(t,e){this.code[e??this.shader]+=t+`
248
249
  `}addVertexNodeCode(t){this.addNodeCode(t,"vertex")}addFragmentNodeCode(t){this.addNodeCode(t,"fragment")}addNodeCode(t,e){this.nodeCode[e??this.shader]+=t+`
249
250
  `}clearNodeCode(t){t=t??this.shader;let e=this.nodeCode[t];return this.nodeCode[t]="",e}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(t){this.addFinalCode(t,"vertex")}addFragmentFinalCode(t){this.addFinalCode(t,"fragment")}addFinalCode(t,e){this.finalCode[e??this.shader]+=t+`
250
251
  `}addVertexParsCode(t){this.addParsCode(t,"vertex")}addFragmentParsCode(t){this.addParsCode(t,"fragment")}addParsCode(t,e){this.parsCode[e??this.shader]+=t+`
251
252
  `}addVaryCode(t){this.addVertexParsCode(t),this.addFragmentParsCode(t)}isCache(t){return this.caches.indexOf(t)!==-1}isSlot(t){return this.slots.indexOf(t)!==-1}define(t,e){this.defines[t]=e===void 0?1:e}require(t){this.requires[t]=!0}isDefined(t){return this.defines[t]!==void 0}getVar(t,e,r,o="varying",i="V",a=""){let s=this.getVars(o),l=s[t];if(!l){let u=s.length;l={name:r||"node"+i+u+(a?"_"+a:""),type:e},s.push(l),s[t]=l}return l}getTempVar(t,e,r,o){return this.getVar(t,e,r,this.shader,"T",o)}getAttribute(t,e){if(!this.attributes[t]){let r=this.getVar(t,e);this.addVertexParsCode("attribute "+e+" "+t+";"),this.addVertexFinalCode(r.name+" = "+t+";"),this.attributes[t]={varying:r,name:t,type:e}}return this.attributes[t]}getCode(t){return[this.prefixCode,this.parsCode[t],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[t],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[t],"uniform"),this.getIncludesCode("consts",t),this.getIncludesCode("structs",t),this.getIncludesCode("functions",t),"void main() {",this.getVarListCode(this.getVars(t)),this.code[t],this.resultCode[t],this.finalCode[t],"}"].join(`
252
253
  `)}getVarListCode(t,e){e=e??"";let r="";for(let o=0,i=t.length;o<i;++o){let a=t[o],s=a.type,l=a.name,u=a.size,c=this.getFormatByType(s);if(c===void 0)throw new Error("Node pars "+c+" not found.");c.includes("[]")?r+=e+" "+c.substring(0,c.length-2)+" "+l+`[${u}];
253
254
  `:r+=e+" "+c+" "+l+`;
254
- `}return r}getVars(t){return this.inputs.vars[t??this.shader]}getNodeData(t){let e=t instanceof Ht?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,r,o,i,a){if(e.includes("[]")){let s=this.inputs.arrayUniforms,l=s.list.length,u=new wl({type:e,size:r.size,name:o||"nodeUA"+l+(a?"_"+a:""),node:r,needsUpdate:i});return s.list.push(u),s[t].push(u),s[t][u.name]=u,this.uniforms[u.name]=u,u}else{let s=this.inputs.uniforms,l=s.list.length,u=new wl({type:e,name:o||"nodeU"+l+(a?"_"+a:""),node:r,needsUpdate:i});return s.list.push(u),s[t].push(u),s[t][u.name]=u,this.uniforms[u.name]=u,u}}createVertexUniform(t,e,r,o,i){return this.createUniform("vertex",t,e,r,o,i)}createFragmentUniform(t,e,r,o,i){return this.createUniform("fragment",t,e,r,o,i)}include(t,e,r){let o;if(t=typeof t=="string"?Lt.get(t):t,this.context.include===!1)return t.name;t instanceof Q?o=this.includes.functions:t instanceof ke?o=this.includes.consts:t instanceof $a&&(o=this.includes.structs);let i=o[this.shader]=o[this.shader]||[];if(t){let a=i[t.name];if(a||(a=i[t.name]={node:t,deps:[]},i.push(a),a.src=t.build(this,"source")),t instanceof Q&&e&&i[e.name]&&i[e.name].deps.indexOf(t)===-1&&(i[e.name].deps.push(t),t.includes?.length)){let s=0;do this.include(t.includes[s++],e);while(s<t.includes.length)}return r&&(a.src=r),t.name}else throw new Error("Include not found.")}colorToVectorProperties(t){return t.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(t){return t.replace(/c/g,"v3")}getIncludes(t,e){return this.includes[t][e||this.shader]}getConstructorFromLength(t){return dT[t-1]}isTypeMatrix(t){return/^m/.test(t)}getTypeLength(t){return t==="f"?1:parseInt(this.colorToVector(t).substr(1))}getTypeFromLength(t){return t===1?"f":"v"+t}findNode(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r?.isNode)return r}}resolve(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r!==void 0){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case co.CubeReflectionMapping:case co.CubeRefractionMapping:return new Vu(r);case co.CubeUVReflectionMapping:return new Ru(new lr(r));default:return new lr(r)}else{if(r.isVector2)return new mt(r);if(r.isVector3)return new Kt(r);if(r.isVector4)return new xr(r)}}}}format(t,e,r){switch(this.colorToVector(r+" <- "+e)){case"f <- v2":return t+".x";case"f <- v3":return t+".x";case"f <- v4":return t+".x";case"f <- i":case"f <- b":return"float( "+t+" )";case"v2 <- f":return"vec2( "+t+" )";case"v2 <- v3":return t+".xy";case"v2 <- v4":return t+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+t+" ) )";case"v3 <- f":return"vec3( "+t+" )";case"v3 <- v2":return"vec3( "+t+", 0.0 )";case"v3 <- v4":return t+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+t+" ) )";case"v4 <- f":return"vec4( "+t+" )";case"v4 <- v2":return"vec4( "+t+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+t+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+t+" ) )";case"i <- f":case"i <- b":return"int( "+t+" )";case"i <- v2":return"int( "+t+".x )";case"i <- v3":return"int( "+t+".x )";case"i <- v4":return"int( "+t+".x )";case"b <- f":return"( "+t+" != 0.0 )";case"b <- v2":return"( "+t+" != vec2( 0.0 ) )";case"b <- v3":return"( "+t+" != vec3( 0.0 ) )";case"b <- v4":return"( "+t+" != vec4( 0.0 ) )";case"b <- i":return"( "+t+" != 0 )"}return t}getTypeByFormat(t){return pT[t]||t}getFormatByType(t){return fT[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return Tx[t]}getIndexByElement(t){return Tx.indexOf(t)}isShader(t){return this.shader===t}setShader(t){return this.shader=t,this}mergeDefines(t){for(let e in t)this.defines[e]=t[e];return this.defines}mergeUniform(t){for(let e in t)this.uniforms[e]=t[e];return this.uniforms}getTextureEncodingFromMap(t){let e;return t?t.isTexture&&(e=t.encoding):e=co.LinearEncoding,e===co.LinearEncoding&&this.context.gamma&&(e=co.sRGBEncoding),e}};var Qe=require("three");var qe=class extends Ye{constructor(e=0,r,o,i){super("c");this.nodeType="Color";this.value=e instanceof Rt?e:new Rt(e||0,r,o,i)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,r,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o),u=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let c=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${c};`)}return u?this.generateReadonly(e,r,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,r)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,r))}generateReadonly(e,r,o,i,a,s){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",i,r)}};var Ie=class extends Ye{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,r,o,i,a,s){return e.format(this.value.toString(),i,r)}};var ku=require("three");var wt=class extends Ye{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,r,o,i){return e.format(this.value?"true":"false",i,r)}};var uo=class extends Ye{constructor(e=1,r){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(r)?r:typeof r=="number"?new Array(e).fill(r):new Array(e).fill(0)}};var Mx=require("three");var Fn=class extends Ye{};var zu=class extends Fn{constructor(e){super("v3");this.image=e;this._value=new Mx.Vector3}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}};var bi=class extends Fn{constructor(e,r){super("t");this.image=e;this.wrap=r}get value(){return this.image.getTexture(this.wrap)}};var Ix=require("three");var Za=class extends Ye{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new Ix.Matrix3}generateReadonly(e,r,o,i,a,s){return e.format("mat3("+this.value.elements.join(", ")+")",i,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Nx=require("three");var Zt=class extends Ye{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new Nx.Matrix4}generateReadonly(e,r,o,i,a,s){return e.format("mat4("+this.value.elements.join(", ")+")",i,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Ex=require("three");function Dx(n,t,e){n.setUvTransform(e[0],e[1],t[0],t[1],0,0,0)}var Gu=class extends Za{constructor(e,r){super(new Ex.Matrix3);this.repeat=e;this.offset=r;Dx(this.value,e,r)}updateMatrix(){Dx(this.value,this.repeat,this.offset)}};var cf=require("three");var po=class extends Ye{constructor(e=1,r){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(r)?r:r instanceof cf.Vector4?new Array(e).fill(r):new Array(e).fill(new cf.Vector4(0))}};var Ja=class extends se{constructor(e,r,o,i){super("v3");this.nodeType="Blend";this.a=e,this.b=r,this.alpha=o,this.mode=i}generate(e,r){if(e.isShader("fragment")){let o=[];return o.push(this.a.build(e,"c")),o.push(this.b.build(e,"c")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),e.format("spe_blend("+o.join(",")+")",this.getType(e),r)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}};var uf=class extends se{constructor(e,r){super("v3");this.nodeType="CustomColor";this.color=e,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){let o=e.include(uf.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.color.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},vi=uf;vi.Nodes=function(){return{customColor:new Q(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
255
+ `}return r}getVars(t){return this.inputs.vars[t??this.shader]}getNodeData(t){let e=t instanceof rr?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,r,o,i,a){if(e.includes("[]")){let s=this.inputs.arrayUniforms,l=s.list.length,u=new Ul({type:e,size:r.size,name:o||"nodeUA"+l+(a?"_"+a:""),node:r,needsUpdate:i});return s.list.push(u),s[t].push(u),s[t][u.name]=u,this.uniforms[u.name]=u,u}else{let s=this.inputs.uniforms,l=s.list.length,u=new Ul({type:e,name:o||"nodeU"+l+(a?"_"+a:""),node:r,needsUpdate:i});return s.list.push(u),s[t].push(u),s[t][u.name]=u,this.uniforms[u.name]=u,u}}createVertexUniform(t,e,r,o,i){return this.createUniform("vertex",t,e,r,o,i)}createFragmentUniform(t,e,r,o,i){return this.createUniform("fragment",t,e,r,o,i)}include(t,e,r){let o;if(t=typeof t=="string"?$t.get(t):t,this.context.include===!1)return t.name;t instanceof re?o=this.includes.functions:t instanceof Xe?o=this.includes.consts:t instanceof ps&&(o=this.includes.structs);let i=o[this.shader]=o[this.shader]||[];if(t){let a=i[t.name];if(a||(a=i[t.name]={node:t,deps:[]},i.push(a),a.src=t.build(this,"source")),t instanceof re&&e&&i[e.name]&&i[e.name].deps.indexOf(t)===-1&&(i[e.name].deps.push(t),t.includes?.length)){let s=0;do this.include(t.includes[s++],e);while(s<t.includes.length)}return r&&(a.src=r),t.name}else throw new Error("Include not found.")}colorToVectorProperties(t){return t.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(t){return t.replace(/c/g,"v3")}getIncludes(t,e){return this.includes[t][e||this.shader]}getConstructorFromLength(t){return fM[t-1]}isTypeMatrix(t){return/^m/.test(t)}getTypeLength(t){return t==="f"?1:parseInt(this.colorToVector(t).substr(1))}getTypeFromLength(t){return t===1?"f":"v"+t}findNode(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r?.isNode)return r}}resolve(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r!==void 0){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case wo.CubeReflectionMapping:case wo.CubeRefractionMapping:return new ld(r);case wo.CubeUVReflectionMapping:return new sd(new wr(r));default:return new wr(r)}else{if(r.isVector2)return new Pt(r);if(r.isVector3)return new lr(r);if(r.isVector4)return new Mr(r)}}}}format(t,e,r){switch(this.colorToVector(r+" <- "+e)){case"f <- v2":return t+".x";case"f <- v3":return t+".x";case"f <- v4":return t+".x";case"f <- i":case"f <- b":return"float( "+t+" )";case"v2 <- f":return"vec2( "+t+" )";case"v2 <- v3":return t+".xy";case"v2 <- v4":return t+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+t+" ) )";case"v3 <- f":return"vec3( "+t+" )";case"v3 <- v2":return"vec3( "+t+", 0.0 )";case"v3 <- v4":return t+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+t+" ) )";case"v4 <- f":return"vec4( "+t+" )";case"v4 <- v2":return"vec4( "+t+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+t+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+t+" ) )";case"i <- f":case"i <- b":return"int( "+t+" )";case"i <- v2":return"int( "+t+".x )";case"i <- v3":return"int( "+t+".x )";case"i <- v4":return"int( "+t+".x )";case"b <- f":return"( "+t+" != 0.0 )";case"b <- v2":return"( "+t+" != vec2( 0.0 ) )";case"b <- v3":return"( "+t+" != vec3( 0.0 ) )";case"b <- v4":return"( "+t+" != vec4( 0.0 ) )";case"b <- i":return"( "+t+" != 0 )"}return t}getTypeByFormat(t){return hM[t]||t}getFormatByType(t){return mM[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return gb[t]}getIndexByElement(t){return gb.indexOf(t)}isShader(t){return this.shader===t}setShader(t){return this.shader=t,this}mergeDefines(t){for(let e in t)this.defines[e]=t[e];return this.defines}mergeUniform(t){for(let e in t)this.uniforms[e]=t[e];return this.uniforms}getTextureEncodingFromMap(t){let e;return t?t.isTexture&&(e=t.encoding):e=wo.LinearEncoding,e===wo.LinearEncoding&&this.context.gamma&&(e=wo.sRGBEncoding),e}};var it=require("three");var et=class extends ot{constructor(e=0,r,o,i){super("c");this.nodeType="Color";this.value=e instanceof Yt?e:new Yt(e||0,r,o,i)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,r,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o),u=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let c=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${c};`)}return u?this.generateReadonly(e,r,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,r)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,r))}generateReadonly(e,r,o,i,a,s){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",i,r)}};var Ge=class extends ot{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,r,o,i,a,s){return e.format(this.value.toString(),i,r)}};var dd=require("three");var Et=class extends ot{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,r,o,i){return e.format(this.value?"true":"false",i,r)}};var Ao=class extends ot{constructor(e=1,r){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(r)?r:typeof r=="number"?new Array(e).fill(r):new Array(e).fill(0)}};var xb=require("three");var Kn=class extends ot{};var cd=class extends Kn{constructor(e){super("v3");this.image=e;this._value=new xb.Vector3}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}};var Ei=class extends Kn{constructor(e,r,o=1008){super("t");this.image=e;this.wrap=r;this.minFilter=o}get value(){return this.image.getTexture(this.wrap,this.minFilter)}};var bb=require("three");var gs=class extends ot{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new bb.Matrix3}generateReadonly(e,r,o,i,a,s){return e.format("mat3("+this.value.elements.join(", ")+")",i,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var vb=require("three");var cr=class extends ot{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new vb.Matrix4}generateReadonly(e,r,o,i,a,s){return e.format("mat4("+this.value.elements.join(", ")+")",i,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var wb=require("three");function Sb(n,t,e){n.setUvTransform(e[0],e[1],t[0],t[1],0,0,0)}var ud=class extends gs{constructor(e,r){super(new wb.Matrix3);this.repeat=e;this.offset=r;Sb(this.value,e,r)}updateMatrix(){Sb(this.value,this.repeat,this.offset)}};var qf=require("three");var _o=class extends ot{constructor(e=1,r){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(r)?r:r instanceof qf.Vector4?new Array(e).fill(r):new Array(e).fill(new qf.Vector4(0))}};var xs=class extends ge{constructor(e,r,o,i){super("v3");this.nodeType="Blend";this.a=e,this.b=r,this.alpha=o,this.mode=i}generate(e,r){if(e.isShader("fragment")){let o=[];return o.push(this.a.build(e,"c")),o.push(this.b.build(e,"c")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),e.format("spe_blend("+o.join(",")+")",this.getType(e),r)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}};var Wf=class extends ge{constructor(e,r){super("v3");this.nodeType="CustomColor";this.color=e,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){let o=e.include(Wf.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.color.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Bi=Wf;Bi.Nodes=function(){return{customColor:new re(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
255
256
  float lalpha = alpha * mask;
256
257
  calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
257
258
  accumAlpha += (1.0 - accumAlpha) * lalpha;
258
259
 
259
260
  return color;
260
- }`)}}();var df=class extends se{constructor(e,r){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){let o=e.include(df.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.cnormal.build(e,"v3")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},es=df;es.Nodes=function(){return{customNormal:new Q(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
261
+ }`)}}();var $f=class extends ge{constructor(e,r){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){let o=e.include($f.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.cnormal.build(e,"v3")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},bs=$f;bs.Nodes=function(){return{customNormal:new re(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
261
262
  vec3 normal = packNormalToRGB( norm ).rgb;
262
263
  normal *= step( vec3(0.5), cnormal );
263
264
 
@@ -266,7 +267,7 @@ layout(location = 1) out vec4 gVelocity;
266
267
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
267
268
 
268
269
  return normal;
269
- }`)}}();var ts=class extends se{constructor(e,r,o,i,a,s,l,u,c,d,p,f){super("v3");this.nodeType="CustomTexture";this.texture=e,this.textureSize=r,this.crop=o,this.projection=i,this.axis=a,this.side=s,this.size=l,this.blending=u,this.mat=c,this.isMask=f,this.alpha=d,this.mode=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){e.require("position"),e.require("normal"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let o=`g${this.uuid.toString().replace(/-/g,"")}`,i;switch(this.projection.value){case 3:i=e.include(ts.Nodes.cylindrical);break;case 2:i=e.include(ts.Nodes.spherical);break;case 1:let s=["vec3(1.0, 0.0, 0.0)","vec3(0.0, 1.0, 0.0)","vec3(0.0, 0.0, 1.0)"][this.axis.value],l=["zy","xz","xy"][this.axis.value],u=new Q(`
270
+ }`)}}();var vs=class extends ge{constructor(e,r,o,i,a,s,l,u,c,d,p,f){super("v3");this.nodeType="CustomTexture";this.texture=e,this.textureSize=r,this.crop=o,this.projection=i,this.axis=a,this.side=s,this.size=l,this.blending=u,this.mat=c,this.isMask=f,this.alpha=d,this.mode=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){e.require("position"),e.require("normal"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let o=`g${this.uuid.toString().replace(/-/g,"")}`,i;switch(this.projection.value){case 3:i=e.include(vs.Nodes.cylindrical);break;case 2:i=e.include(vs.Nodes.spherical);break;case 1:let s=["vec3(1.0, 0.0, 0.0)","vec3(0.0, 1.0, 0.0)","vec3(0.0, 0.0, 1.0)"][this.axis.value],l=["zy","xz","xy"][this.axis.value],u=new re(`
270
271
  vec3 ${o}_planarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
271
272
  vec2 projected = (1. + (position.${l})) / 2.;
272
273
  vec2 uvs = ( mat * vec3( (projected * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
@@ -290,7 +291,7 @@ layout(location = 1) out vec4 gVelocity;
290
291
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
291
292
 
292
293
  return col;
293
- }`);i=e.include(u);break;case 4:i=e.include(ts.Nodes.triplanar);break;default:i=e.include(ts.Nodes.uv);break}e.addFragmentVariable(this.calpha,"float");let a=[];if(a.push("normal"),a.push(this.texture.generate(e,"t")),a.push(this.textureSize.build(e,"v2")),a.push(this.crop.build(e,"f")),a.push(this.mat.build(e,"mat3")),a.push(this.size.build(e,"v2")),a.push(this.blending.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),this.projection.value===4){let s=`${o}_writeUvs`,l=s+"0",u=s+"1",c=s+"2",d=`${o}_triplanarWeights`;e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(u,"vec2"),e.addFragmentVariable(c,"vec2"),e.addFragmentVariable(d,"vec3"),a.push(l),a.push(u),a.push(c),a.push(d)}else{let s=`${o}_writeUvs`;e.addFragmentVariable(s,"vec2"),a.push(s)}return e.format(i+"("+a.join(",")+")",this.getType(e),r)}},jn=ts;jn.Nodes=function(){let e=new Q(`
294
+ }`);i=e.include(u);break;case 4:i=e.include(vs.Nodes.triplanar);break;default:i=e.include(vs.Nodes.uv);break}e.addFragmentVariable(this.calpha,"float");let a=[];if(a.push("normal"),a.push(this.texture.generate(e,"t")),a.push(this.textureSize.build(e,"v2")),a.push(this.crop.build(e,"f")),a.push(this.mat.build(e,"mat3")),a.push(this.size.build(e,"v2")),a.push(this.blending.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),this.projection.value===4){let s=`${o}_writeUvs`,l=s+"0",u=s+"1",c=s+"2",d=`${o}_triplanarWeights`;e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(u,"vec2"),e.addFragmentVariable(c,"vec2"),e.addFragmentVariable(d,"vec3"),a.push(l),a.push(u),a.push(c),a.push(d)}else{let s=`${o}_writeUvs`;e.addFragmentVariable(s,"vec2"),a.push(s)}return e.format(i+"("+a.join(",")+")",this.getType(e),r)}},Zn=vs;Zn.Nodes=function(){let e=new re(`
294
295
  vec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
295
296
  vec3 posN = normalize(position);
296
297
  float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
@@ -325,7 +326,7 @@ vec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop
325
326
 
326
327
  return col;
327
328
  }
328
- `),r=new Q(`
329
+ `),r=new re(`
329
330
  vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
330
331
  vec3 posN = normalize(vPosition);
331
332
  float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
@@ -358,7 +359,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
358
359
 
359
360
  return col;
360
361
  }
361
- `),o=new Q(`vec3 uvTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
362
+ `),o=new re(`vec3 uvTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
362
363
  vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
363
364
  writeUv = uvs;
364
365
 
@@ -379,7 +380,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
379
380
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
380
381
 
381
382
  return col;
382
- }`),i=new Q(`vec3 triplanarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUvs0, out vec2 writeUvs1, out vec2 writeUvs2, out vec3 writeWeights) {
383
+ }`),i=new re(`vec3 triplanarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUvs0, out vec2 writeUvs1, out vec2 writeUvs2, out vec3 writeWeights) {
383
384
  vec3 p = position;
384
385
  vec2 uv0 = (1.0 + p.xy) / 2.0;
385
386
  vec2 uv1 = (1.0 + p.zy) / 2.0;
@@ -445,7 +446,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
445
446
 
446
447
  return col;//n * 0.5 + 0.5;
447
448
  }
448
- `);return{cylindrical:e,spherical:r,uv:o,triplanar:i}}();var rs=class extends se{constructor(e,r,o,i,a,s,l,u,c,d,p,f){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=r,this.near=o,this.far=i,this.isVector=a,this.isWorldSpace=s,this.origin=l,this.direction=u,this.colors=c,this.steps=d,this.isMask=f,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let o=`g${this.uuid.toString().replace(/-/g,"")}`,i=new Q(`vec3 ${o}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${o}_MAX_COLORS], float steps[${o}_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) {
449
+ `);return{cylindrical:e,spherical:r,uv:o,triplanar:i}}();var Ss=class extends ge{constructor(e,r,o,i,a,s,l,u,c,d,p,f){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=r,this.near=o,this.far=i,this.isVector=a,this.isWorldSpace=s,this.origin=l,this.direction=u,this.colors=c,this.steps=d,this.isMask=f,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let o=`g${this.uuid.toString().replace(/-/g,"")}`,i=new re(`vec3 ${o}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${o}_MAX_COLORS], float steps[${o}_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) {
449
450
  vec4 color = colors[0];
450
451
  #ifdef ${o}_IS_VECTOR
451
452
  #ifdef ${o}_LINEAR
@@ -485,21 +486,21 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
485
486
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
486
487
 
487
488
  return color.rgb;
488
- }`,[rs.Nodes.vectorLinearWorldSpaceDepth,rs.Nodes.vectorLinearObjectSpaceDepth,rs.Nodes.vectorSphericalObjectSpaceDepth,rs.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${o}_MAX_COLORS`,this.colors.value.length),this.smooth.value&&e.define(`${o}_SMOOTH`),this.isVector.value>.5&&e.define(`${o}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${o}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${o}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let a=e.include(i),s=[];return s.push(this.near.build(e,"f")),s.push(this.far.build(e,"f")),s.push(this.origin.build(e,"v3")),s.push(this.direction.build(e,"v3")),s.push(this.colors.build(e,"v4[]")),s.push(this.steps.build(e,"f[]")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(a+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},os=rs;os.Nodes=function(){let e=new Q(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
489
+ }`,[Ss.Nodes.vectorLinearWorldSpaceDepth,Ss.Nodes.vectorLinearObjectSpaceDepth,Ss.Nodes.vectorSphericalObjectSpaceDepth,Ss.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${o}_MAX_COLORS`,this.colors.value.length),this.smooth.value&&e.define(`${o}_SMOOTH`),this.isVector.value>.5&&e.define(`${o}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${o}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${o}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let a=e.include(i),s=[];return s.push(this.near.build(e,"f")),s.push(this.far.build(e,"f")),s.push(this.origin.build(e,"v3")),s.push(this.direction.build(e,"v3")),s.push(this.colors.build(e,"v4[]")),s.push(this.steps.build(e,"f[]")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(a+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ws=Ss;ws.Nodes=function(){let e=new re(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
489
490
  vec3 n = normalize(direction);
490
491
  float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
491
492
  return ( dist - near ) / ( far - near );
492
- }`),r=new Q(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
493
+ }`),r=new re(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
493
494
  vec3 n = normalize(direction);
494
495
  float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));
495
496
  return ( dist - near ) / ( far - near );
496
- }`),o=new Q(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
497
+ }`),o=new re(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
497
498
  float dist = length(vWPosition - origin);
498
499
  return ( dist - near ) / ( far - near );
499
- }`),i=new Q(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
500
+ }`),i=new re(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
500
501
  float dist = length(position - origin);
501
502
  return ( dist - near ) / ( far - near );
502
- }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:r,vectorSphericalWorldSpaceDepth:o,vectorSphericalObjectSpaceDepth:i}}();var Al=class extends se{constructor(e,r,o,i,a,s,l,u){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=r,this.scale=o,this.intensity=i,this.factor=a,this.isMask=u,this.alpha=s,this.mode=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=new Q(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {
503
+ }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:r,vectorSphericalWorldSpaceDepth:o,vectorSphericalObjectSpaceDepth:i}}();var ql=class extends ge{constructor(e,r,o,i,a,s,l,u){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=r,this.scale=o,this.intensity=i,this.factor=a,this.isMask=u,this.alpha=s,this.mode=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=new re(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {
503
504
  float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );
504
505
 
505
506
  float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;
@@ -507,7 +508,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
507
508
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
508
509
 
509
510
  return color;
510
- }`),i=e.include(o),a=[];return a.push(this.color.build(e,"c")),a.push(this.bias.build(e,"f")),a.push(this.scale.build(e,"f")),a.push(this.intensity.build(e,"f")),a.push(this.factor.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),e.format(i+"("+a.join(",")+")",this.getType(e),r)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}};var pf=class extends se{constructor(e,r,o,i,a,s,l,u,c){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=r,this.colors=o,this.steps=i,this.offset=a,this.morph=s,this.angle=l,this.isMask=c,this.alpha=u,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(pf.Nodes.gradient),i=[];return i.push(this.gradientType.build(e,"i")),i.push(this.smooth.build(e,"b")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.offset.build(e,"v2")),i.push(this.morph.build(e,"v2")),i.push(this.angle.build(e,"f")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ns=pf;ns.Nodes=function(){return{gradient:new Q(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) {
511
+ }`),i=e.include(o),a=[];return a.push(this.color.build(e,"c")),a.push(this.bias.build(e,"f")),a.push(this.scale.build(e,"f")),a.push(this.intensity.build(e,"f")),a.push(this.factor.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),e.format(i+"("+a.join(",")+")",this.getType(e),r)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}};var Yf=class extends ge{constructor(e,r,o,i,a,s,l,u,c){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=r,this.colors=o,this.steps=i,this.offset=a,this.morph=s,this.angle=l,this.isMask=c,this.alpha=u,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(Yf.Nodes.gradient),i=[];return i.push(this.gradientType.build(e,"i")),i.push(this.smooth.build(e,"b")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.offset.build(e,"v2")),i.push(this.morph.build(e,"v2")),i.push(this.angle.build(e,"f")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},As=Yf;As.Nodes=function(){return{gradient:new re(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) {
511
512
  vec4 color = colors[0];
512
513
  vec2 m = morph / vUv.xy;
513
514
  vec2 rot = vec2( 0.5 + m.x, m.y );
@@ -549,7 +550,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
549
550
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
550
551
 
551
552
  return color.xyz;
552
- }`)}}();var ff=class extends se{constructor(e,r,o,i){super("v3");this.nodeType="Matcap";this.texture=e,this.isMask=i,this.alpha=r,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(ff.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let i=[];return i.push(this.texture.generate(e,"t")),i.push("normal"),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},is=ff;is.Nodes=function(){return{matcap:new Q(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha) {
553
+ }`)}}();var Xf=class extends ge{constructor(e,r,o,i){super("v3");this.nodeType="Matcap";this.texture=e,this.isMask=i,this.alpha=r,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(Xf.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let i=[];return i.push(this.texture.generate(e,"t")),i.push("normal"),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},_s=Xf;_s.Nodes=function(){return{matcap:new re(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha) {
553
554
  vec3 viewDir = normalize( vViewPosition );
554
555
  vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
555
556
  vec3 y = cross( viewDir, x );
@@ -561,7 +562,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
561
562
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
562
563
 
563
564
  return matcapColor.rgb;
564
- }`)}}();var Pl=(a=>(a.SIMPLEX="simplex3d",a.SIMPLEX_FRACTAL="simplex3dFractal",a.ASHIMA="simplexAshima",a.FBM="fbm",a.PERLIN="perlin",a.VORONOI="voronoi",a))(Pl||{}),$t=function(){let t=new Q(`vec3 random3(vec3 c) {
565
+ }`)}}();var Wl=(a=>(a.SIMPLEX="simplex3d",a.SIMPLEX_FRACTAL="simplex3dFractal",a.ASHIMA="simplexAshima",a.FBM="fbm",a.PERLIN="perlin",a.VORONOI="voronoi",a))(Wl||{}),ir=function(){let t=new re(`vec3 random3(vec3 c) {
565
566
  float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
566
567
  vec3 r;
567
568
  r.z = fract(512.0*j);
@@ -570,7 +571,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
570
571
  j *= .125;
571
572
  r.y = fract(512.0*j);
572
573
  return r-0.5;
573
- }`),e=new Q(`float simplex3d(vec3 p) {
574
+ }`),e=new re(`float simplex3d(vec3 p) {
574
575
  vec3 s = floor(p + dot(p, vec3(F3)));
575
576
  vec3 x = p - s + dot(s, vec3(G3));
576
577
 
@@ -601,7 +602,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
601
602
  d *= w;
602
603
 
603
604
  return dot(d, vec4(52.0));
604
- }`,[t]);e.keywords.F3=new ke("float F3 0.3333333"),e.keywords.G3=new ke("float G3 0.1666667");let r=new Q(`float simplex3dFractal(vec3 m) {
605
+ }`,[t]);e.keywords.F3=new Xe("float F3 0.3333333"),e.keywords.G3=new Xe("float G3 0.1666667");let r=new re(`float simplex3dFractal(vec3 m) {
605
606
  mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);
606
607
  mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);
607
608
  mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);
@@ -609,7 +610,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
609
610
  + 0.2666667 * simplex3d(2.0 * m * rot2)
610
611
  + 0.1333333 * simplex3d(4.0 * m * rot3)
611
612
  + 0.0666667 * simplex3d(8.0 * m);
612
- }`,[e]),o=new Q("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),i=new Q("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),a=new Q(`float simplexAshima(vec3 v) {
613
+ }`,[e]),o=new re("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),i=new re("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),a=new re(`float simplexAshima(vec3 v) {
613
614
  const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
614
615
  const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
615
616
  vec3 i = floor(v + dot(v, C.yyy) );
@@ -654,7 +655,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
654
655
  m = m * m;
655
656
  return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
656
657
  dot(p2,x2), dot(p3,x3) ) );
657
- }`,[o,i]),s=new Q("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new Q("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[s]),u=new Q(`float noise(vec3 p){
658
+ }`,[o,i]),s=new re("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new re("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[s]),u=new re(`float noise(vec3 p){
658
659
  vec3 a = floor(p);
659
660
  vec3 d = p - a;
660
661
  d = d * d * (3.0 - 2.0 * d);
@@ -669,7 +670,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
669
670
  vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
670
671
  vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
671
672
  return o4.y * d.y + o4.x * (1.0 - d.y);
672
- }`,[l]),c=new Q(`float fbm(vec3 x) {
673
+ }`,[l]),c=new re(`float fbm(vec3 x) {
673
674
  float v = 0.0;
674
675
  float a = 0.5;
675
676
  vec3 shift = vec3(100);
@@ -679,7 +680,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
679
680
  a *= 0.5;
680
681
  }
681
682
  return v;
682
- }`,[u]);c.keywords.NUM_OCTAVES=new ke(`int NUM_OCTAVES ${5}`);let d=new Q("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),p=new Q(`float perlin(vec3 P){
683
+ }`,[u]);c.keywords.NUM_OCTAVES=new Xe(`int NUM_OCTAVES ${5}`);let d=new re("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),p=new re(`float perlin(vec3 P){
683
684
  vec3 Pi0 = floor(P);
684
685
  vec3 Pi1 = Pi0 + vec3(1.0);
685
686
  Pi0 = mod(Pi0, 289.0);
@@ -738,17 +739,17 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
738
739
  vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
739
740
  float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
740
741
  return 2.2 * n_xyz;
741
- }`,[o,i,d]),f=new Q(`float hashwithoutsine13(vec3 p3)
742
+ }`,[o,i,d]),f=new re(`float hashwithoutsine13(vec3 p3)
742
743
  {
743
744
  p3 = fract(p3 * .1031);
744
745
  p3 += dot(p3, p3.yzx + 33.33);
745
746
  return fract((p3.x + p3.y) * p3.z);
746
- }`),h=new Q(`vec3 hashwithoutsine33(vec3 p3)
747
+ }`),h=new re(`vec3 hashwithoutsine33(vec3 p3)
747
748
  {
748
749
  p3 = fract(p3 * vec3(.1031, .1030, .0973));
749
750
  p3 += dot(p3, p3.yxz+33.33);
750
751
  return fract((p3.xxy + p3.yxx)*p3.zyx);
751
- }`),m=new Q(`float metric(in vec3 p)
752
+ }`),m=new re(`float metric(in vec3 p)
752
753
  {
753
754
  // L2
754
755
  return length(p);
@@ -756,17 +757,17 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
756
757
  // Chebyshev
757
758
  // vec3 a = abs(p);
758
759
  // return max(a.x, max(a.y, a.z));
759
- }`),y=new Q(`float smin( float a, float b, float k )
760
+ }`),y=new re(`float smin( float a, float b, float k )
760
761
  {
761
762
  float h = smoothstep(0.0, 1.0, 0.5 + 0.5 * (b - a) / k);
762
763
  float correction = k * h * (1.0 - h);
763
764
  return mix(b, a, h) - correction;
764
- }`),g=new Q(`float smax( float a, float b, float k )
765
+ }`),g=new re(`float smax( float a, float b, float k )
765
766
  {
766
767
  float h = smoothstep(1.0, 0.0, 0.5 + 0.5 * (a - b) / k);
767
768
  float correction = k * h * (1.0 - h);
768
769
  return mix(a, b, h) + correction;
769
- }`),b=new Q(`float remap(float value, float input_min, float input_max, float output_min, float output_max) {
770
+ }`),b=new re(`float remap(float value, float input_min, float input_max, float output_min, float output_max) {
770
771
  // Compute width of each interval
771
772
  float input_width = input_max - input_min;
772
773
  float output_width = output_max - output_min;
@@ -776,7 +777,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
776
777
 
777
778
  // Convert the 0-1 range into a value in output range
778
779
  return output_min + (scaled * output_width);
779
- }`),S=new Q(`float voronoi(in vec3 x, in int style, in float smoothness, in float seed, in int quality)
780
+ }`),w=new re(`float voronoi(in vec3 x, in int style, in float smoothness, in float seed, in int quality)
780
781
  {
781
782
  // Integer and fractional parts of this point's coordinates
782
783
  ivec3 p = ivec3(floor(x));
@@ -914,7 +915,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
914
915
  return hashwithoutsine13(vec3(p + mb) + seed);
915
916
  }
916
917
  }
917
- `,[f,h,m,y,g,b]);return{simplex:e,simplexFractal:r,simplexAshima:a,fbm:c,perlin:p,voronoi:S}}();var as=class extends se{constructor(e,r,o,i,a,s,l,u,c,d,p,f,h,m,y,g,b,S,w){super("v3");this.nodeType="Noise";this.scale=e,this.size=r,this.move=o,this.fA=i,this.fB=a,this.distortion=s,this.colorA=l,this.colorB=u,this.colorC=c,this.colorD=d,this.noiseType=f,this.voronoiStyle=m,this.highCut=y,this.lowCut=g,this.smoothness=b,this.seed=S,this.quality=w,this.isMask=h,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r,o,i,a){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let s=Object.values(Pl)[this.noiseType.value],l=s=="voronoi"?`
918
+ `,[f,h,m,y,g,b]);return{simplex:e,simplexFractal:r,simplexAshima:a,fbm:c,perlin:p,voronoi:w}}();var Ps=class extends ge{constructor(e,r,o,i,a,s,l,u,c,d,p,f,h,m,y,g,b,w,_){super("v3");this.nodeType="Noise";this.scale=e,this.size=r,this.move=o,this.fA=i,this.fB=a,this.distortion=s,this.colorA=l,this.colorB=u,this.colorC=c,this.colorD=d,this.noiseType=f,this.voronoiStyle=m,this.highCut=y,this.lowCut=g,this.smoothness=b,this.seed=w,this.quality=_,this.isMask=h,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r,o,i,a){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let s=Object.values(Wl)[this.noiseType.value],l=s=="voronoi"?`
918
919
  float v = ${s}(st + move, voronoiStyle, smoothness, seed, quality);
919
920
 
920
921
  // Apply clipping to colors
@@ -936,7 +937,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
936
937
  color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));
937
938
  color = mix(color, colorC, clamp(length(q), 0.0, 1.0));
938
939
  color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0));
939
- `,u=new Q(`vec3 ${s}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, int voronoiStyle, float highCut, float lowCut, float smoothness, float seed, int quality, bool isMask, float mask, float alpha, out float calpha)
940
+ `,u=new re(`vec3 ${s}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, int voronoiStyle, float highCut, float lowCut, float smoothness, float seed, int quality, bool isMask, float mask, float alpha, out float calpha)
940
941
  {
941
942
  // Prevent scale of zero
942
943
  scale = max(abs(scale), 0.001);
@@ -951,7 +952,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
951
952
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
952
953
 
953
954
  return clamp(color, 0.0, 1.0).rgb;
954
- }`,[$t.simplex,$t.simplexFractal,$t.simplexAshima,$t.fbm,$t.perlin,$t.voronoi]),c=e.include(u),d=[];return d.push(this.scale.build(e,"f")),d.push(this.size.build(e,"v3")),d.push(this.move.build(e,"f")),d.push(this.fA.build(e,"v2")),d.push(this.fB.build(e,"v2")),d.push(this.distortion.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.colorC.build(e,"v4")),d.push(this.colorD.build(e,"v4")),d.push(this.voronoiStyle.build(e,"i")),d.push(this.highCut.build(e,"f")),d.push(this.lowCut.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.seed.build(e,"f")),d.push(this.quality.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(c+"("+d.join(",")+")",this.getType(e),r)}};as.numOctaves=5;var hf=class extends se{constructor(e,r,o,i,a,s,l,u,c,d,p,f,h,m,y,g){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=r,this.outlineWidth=o,this.contourWidth=i,this.contourThreshold=a,this.outlineThreshold=s,this.contourFrequency=l,this.outlineSmoothing=u,this.contourDirection=c,this.positionalLines=d,this.compensation=p,this.resolution=f,this.normalMap=h,this.depthMap=m,this.pixelRatio=y,this.alpha=g,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let o=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${o}_offset`),this.firstTime){let i=this.outlineWidth.build(e,"f"),a=this.resolution.build(e,"v2"),s=this.compensation.build(e,"b"),l=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(i,"uniform float"),e.addVertexParsVariable(a,"uniform vec2"),e.addVertexParsVariable(s,"uniform bool"),e.addVertexParsVariable(l,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
955
+ }`,[ir.simplex,ir.simplexFractal,ir.simplexAshima,ir.fbm,ir.perlin,ir.voronoi]),c=e.include(u),d=[];return d.push(this.scale.build(e,"f")),d.push(this.size.build(e,"v3")),d.push(this.move.build(e,"f")),d.push(this.fA.build(e,"v2")),d.push(this.fB.build(e,"v2")),d.push(this.distortion.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.colorC.build(e,"v4")),d.push(this.colorD.build(e,"v4")),d.push(this.voronoiStyle.build(e,"i")),d.push(this.highCut.build(e,"f")),d.push(this.lowCut.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.seed.build(e,"f")),d.push(this.quality.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(c+"("+d.join(",")+")",this.getType(e),r)}};Ps.numOctaves=5;var Qf=class extends ge{constructor(e,r,o,i,a,s,l,u,c,d,p,f,h,m,y,g){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=r,this.outlineWidth=o,this.contourWidth=i,this.contourThreshold=a,this.outlineThreshold=s,this.contourFrequency=l,this.outlineSmoothing=u,this.contourDirection=c,this.positionalLines=d,this.compensation=p,this.resolution=f,this.normalMap=h,this.depthMap=m,this.pixelRatio=y,this.alpha=g,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let o=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${o}_offset`),this.firstTime){let i=this.outlineWidth.build(e,"f"),a=this.resolution.build(e,"v2"),s=this.compensation.build(e,"b"),l=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(i,"uniform float"),e.addVertexParsVariable(a,"uniform vec2"),e.addVertexParsVariable(s,"uniform bool"),e.addVertexParsVariable(l,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
955
956
  vID = randomColor.r;
956
957
  vec2 ${o}_offset = vec2(0.0);
957
958
  if (${s}) {
@@ -966,7 +967,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
966
967
  // if this offset is the biggest of all the potential offsets
967
968
  gl_Position = ${o}_clipPosition;
968
969
  }
969
- `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(hf.Nodes.outline),a=[];return a.push(this.outlineColor.build(e,"c")),a.push(this.contourColor.build(e,"c")),a.push(this.outlineWidth.build(e,"f")),a.push(this.contourWidth.build(e,"f")),a.push(this.contourThreshold.build(e,"f")),a.push(this.outlineThreshold.build(e,"f")),a.push(this.contourFrequency.build(e,"f")),a.push(this.outlineSmoothing.build(e,"f")),a.push(this.contourDirection.build(e,"v3")),a.push(this.positionalLines.build(e,"b")),a.push(this.resolution.build(e,"v2")),a.push(this.normalMap.getTexture(e,"t")),a.push(this.depthMap.getTexture(e,"t")),a.push(this.pixelRatio.build(e,"f")),a.push(this.compensation.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),this.firstTime=!this.firstTime,e.format(i+"("+a.join(",")+")",this.getType(e),r)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},ss=hf;ss.Nodes=function(){let e=new Q(`
970
+ `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(Qf.Nodes.outline),a=[];return a.push(this.outlineColor.build(e,"c")),a.push(this.contourColor.build(e,"c")),a.push(this.outlineWidth.build(e,"f")),a.push(this.contourWidth.build(e,"f")),a.push(this.contourThreshold.build(e,"f")),a.push(this.outlineThreshold.build(e,"f")),a.push(this.contourFrequency.build(e,"f")),a.push(this.outlineSmoothing.build(e,"f")),a.push(this.contourDirection.build(e,"v3")),a.push(this.positionalLines.build(e,"b")),a.push(this.resolution.build(e,"v2")),a.push(this.normalMap.getTexture(e,"t")),a.push(this.depthMap.getTexture(e,"t")),a.push(this.pixelRatio.build(e,"f")),a.push(this.compensation.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),this.firstTime=!this.firstTime,e.format(i+"("+a.join(",")+")",this.getType(e),r)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},Os=Qf;Os.Nodes=function(){let e=new re(`
970
971
  float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)
971
972
  {
972
973
  vec2 halton = haltonSequence[frameIndex];
@@ -1072,7 +1073,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1072
1073
  float edgeNormal = sqrt(dot(sobel_edge_h, sobel_edge_h) + dot(sobel_edge_v, sobel_edge_v));
1073
1074
  return edgeNormal;
1074
1075
  }
1075
- `);return{outline:new Q(`vec3 outline(vec3 outlineColor, vec3 contourColor, float outlineWidth, float contourWidth, float outlineThreshold, float contourThreshold, float outlineSmoothing, float contourFrequency, vec3 contourDirection, bool positionalLines, vec2 resolution, sampler2D normalMap, sampler2D depthMap, float pixelRatio, bool compensation, float mask, float alpha, out float calpha) {
1076
+ `);return{outline:new re(`vec3 outline(vec3 outlineColor, vec3 contourColor, float outlineWidth, float contourWidth, float outlineThreshold, float contourThreshold, float outlineSmoothing, float contourFrequency, vec3 contourDirection, bool positionalLines, vec2 resolution, sampler2D normalMap, sampler2D depthMap, float pixelRatio, bool compensation, float mask, float alpha, out float calpha) {
1076
1077
  vec3 result = outlineColor;
1077
1078
  float resultAlpha = 0.0;
1078
1079
 
@@ -1115,12 +1116,12 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1115
1116
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
1116
1117
 
1117
1118
  return result;
1118
- }`,[e])}}();var Do=class extends se{constructor(e,r,o,i,a,s,l,u,c,d,p,f,h,m,y,g,b,S){super("v3");this.nodeType="Pattern";this.style=e,this.projection=r,this.axis=o,this.blending=i,this.offset=a,this.colorA=s,this.colorB=l,this.frequency=u,this.size=c,this.variation=d,this.smoothness=p,this.zigzag=f,this.rotation=h,this.vertical=m,this.horizontal=y,this.sides=g,this.isMask=S,this.alpha=b,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float");let o;switch(this.style.value){case 0:o="circle";break;case 1:o="ring";break;case 2:o="polygon";break;case 3:o="xcross";break;case 4:o="diamond";break;case 5:o="checkerboard";break;case 6:o="line";break;case 7:o="wave";break;default:o="circle";break}let i=`g${this.uuid.toString().replace(/-/g,"")}`,a=new Q(`float hashwithoutsine12(vec2 p)
1119
+ }`,[e])}}();var Uo=class extends ge{constructor(e,r,o,i,a,s,l,u,c,d,p,f,h,m,y,g,b,w){super("v3");this.nodeType="Pattern";this.style=e,this.projection=r,this.axis=o,this.blending=i,this.offset=a,this.colorA=s,this.colorB=l,this.frequency=u,this.size=c,this.variation=d,this.smoothness=p,this.zigzag=f,this.rotation=h,this.vertical=m,this.horizontal=y,this.sides=g,this.isMask=w,this.alpha=b,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float");let o;switch(this.style.value){case 0:o="circle";break;case 1:o="ring";break;case 2:o="polygon";break;case 3:o="xcross";break;case 4:o="diamond";break;case 5:o="checkerboard";break;case 6:o="line";break;case 7:o="wave";break;default:o="circle";break}let i=`g${this.uuid.toString().replace(/-/g,"")}`,a=new re(`float hashwithoutsine12(vec2 p)
1119
1120
  {
1120
1121
  vec3 p3 = fract(vec3(p.xyx) * .1031);
1121
1122
  p3 += dot(p3, p3.yzx + 33.33);
1122
1123
  return fract((p3.x + p3.y) * p3.z);
1123
- }`),s=new Q(`vec2 rotate_uv(in vec2 uv, float a, bool repeat)
1124
+ }`),s=new re(`vec2 rotate_uv(in vec2 uv, float a, bool repeat)
1124
1125
  {
1125
1126
  const float mid = 0.5;
1126
1127
  float radians = a * (PI / 180.0);
@@ -1177,7 +1178,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1177
1178
  custom_uv = rotate_uv(custom_uv, rotation, true);
1178
1179
 
1179
1180
  float draw = ${p};
1180
- `}let u=new Q(`vec3 ${i}_pattern(vec3 normal, float blending, int style, vec2 offset, vec4 colorA, vec4 colorB, vec2 frequency, float size, float variation, float smoothness, float zigzag, float rotation, vec2 vertical, vec2 horizontal, int sides, bool isMask, float mask, float alpha, out float calpha) {
1181
+ `}let u=new re(`vec3 ${i}_pattern(vec3 normal, float blending, int style, vec2 offset, vec4 colorA, vec4 colorB, vec2 frequency, float size, float variation, float smoothness, float zigzag, float rotation, vec2 vertical, vec2 horizontal, int sides, bool isMask, float mask, float alpha, out float calpha) {
1181
1182
  const float TWO_PI = PI * 2.0;
1182
1183
  float smoothness_remapped = pow(smoothness, 5.0);
1183
1184
 
@@ -1201,11 +1202,11 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1201
1202
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
1202
1203
 
1203
1204
  return clamp(color, 0.0, 1.0).rgb;
1204
- }`,[s,a,Do.DrawFunctions.circle,Do.DrawFunctions.ring,Do.DrawFunctions.polygon,Do.DrawFunctions.cross,Do.DrawFunctions.diamond,Do.DrawFunctions.checkerboard,Do.DrawFunctions.line,Do.DrawFunctions.wave]),c=e.include(u),d=[];return d.push("normal"),d.push(this.blending.build(e,"f")),d.push(this.style.build(e,"i")),d.push(this.offset.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.frequency.build(e,"v2")),d.push(this.size.build(e,"f")),d.push(this.variation.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.zigzag.build(e,"f")),d.push(this.rotation.build(e,"f")),d.push(this.vertical.build(e,"v2")),d.push(this.horizontal.build(e,"v2")),d.push(this.sides.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(c+"("+d.join(",")+")",this.getType(e),r)}else return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),r)}},ls=Do;ls.DrawFunctions=function(){let e=new Q(`float hashwithoutsine12(vec2 p) {
1205
+ }`,[s,a,Uo.DrawFunctions.circle,Uo.DrawFunctions.ring,Uo.DrawFunctions.polygon,Uo.DrawFunctions.cross,Uo.DrawFunctions.diamond,Uo.DrawFunctions.checkerboard,Uo.DrawFunctions.line,Uo.DrawFunctions.wave]),c=e.include(u),d=[];return d.push("normal"),d.push(this.blending.build(e,"f")),d.push(this.style.build(e,"i")),d.push(this.offset.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.frequency.build(e,"v2")),d.push(this.size.build(e,"f")),d.push(this.variation.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.zigzag.build(e,"f")),d.push(this.rotation.build(e,"f")),d.push(this.vertical.build(e,"v2")),d.push(this.horizontal.build(e,"v2")),d.push(this.sides.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(c+"("+d.join(",")+")",this.getType(e),r)}else return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),r)}},Cs=Uo;Cs.DrawFunctions=function(){let e=new re(`float hashwithoutsine12(vec2 p) {
1205
1206
  vec3 p3 = fract(vec3(p.xyx) * 0.1031);
1206
1207
  p3 += dot(p3, p3.yzx + 33.33);
1207
1208
  return fract((p3.x + p3.y) * p3.z);
1208
- }`),r=new Q(`vec2 tile_and_center(in vec2 uv, in vec2 frequency, in float variation, in float zigzag, in float rotation) {
1209
+ }`),r=new re(`vec2 tile_and_center(in vec2 uv, in vec2 frequency, in float variation, in float zigzag, in float rotation) {
1209
1210
  // Create tiles in UV-space
1210
1211
  uv *= frequency;
1211
1212
 
@@ -1234,14 +1235,14 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1234
1235
  f *= jitter;
1235
1236
 
1236
1237
  return f;
1237
- }`,[e]),o=new Q(`float circle(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
1238
+ }`,[e]),o=new re(`float circle(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
1238
1239
  vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
1239
1240
  return smoothstep(
1240
1241
  -smoothness,
1241
1242
  smoothness,
1242
1243
  length(f) - size
1243
1244
  );
1244
- }`,[r]),i=new Q(`float ring(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
1245
+ }`,[r]),i=new re(`float ring(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
1245
1246
  vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
1246
1247
 
1247
1248
  float d = length(f);
@@ -1250,7 +1251,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1250
1251
  float outer = smoothstep(-smoothness, smoothness, d - size);
1251
1252
  float inner = smoothstep(-smoothness, smoothness, d - size * inner_width);
1252
1253
  return outer + (1.0 - inner);
1253
- }`,[r]),a=new Q(`float sdf_ngon(in vec2 p, in float r, in int n) {
1254
+ }`,[r]),a=new re(`float sdf_ngon(in vec2 p, in float r, in int n) {
1254
1255
  float an = (PI * 2.0) / float(n);
1255
1256
  float he = r * tan(0.5 * an);
1256
1257
 
@@ -1267,7 +1268,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1267
1268
  float polygon(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation, in int sides) {
1268
1269
  vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
1269
1270
  return smoothstep(-smoothness, smoothness, sdf_ngon(f, size, sides));
1270
- }`,[r]),s=new Q(`float sdf_cross(in vec2 p, in vec2 b, float r ) {
1271
+ }`,[r]),s=new re(`float sdf_cross(in vec2 p, in vec2 b, float r ) {
1271
1272
  p = abs(p);
1272
1273
  p = (p.y > p.x) ? p.yx : p.xy;
1273
1274
  vec2 q = p - b;
@@ -1280,7 +1281,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1280
1281
  float xcross(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
1281
1282
  vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
1282
1283
  return smoothstep(-smoothness, smoothness, sdf_cross(f, vec2(size, size * 0.25), smoothness));
1283
- }`,[r]),l=new Q(`float ndot(vec2 a, vec2 b) {
1284
+ }`,[r]),l=new re(`float ndot(vec2 a, vec2 b) {
1284
1285
  return a.x*b.x - a.y*b.y;
1285
1286
  }
1286
1287
 
@@ -1294,7 +1295,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1294
1295
  float diamond(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
1295
1296
  vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
1296
1297
  return smoothstep(-smoothness, smoothness, sdf_diamond(f, vec2(size)));
1297
- }`,[r]),u=new Q(`float checkerboard(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
1298
+ }`,[r]),u=new re(`float checkerboard(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
1298
1299
  uv *= frequency;
1299
1300
  vec2 i = floor(uv);
1300
1301
 
@@ -1304,7 +1305,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1304
1305
  float x = floor(uv.x);
1305
1306
 
1306
1307
  return mod(x, 2.0);
1307
- }`),c=new Q(`float line(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
1308
+ }`),c=new re(`float line(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
1308
1309
  vec2 f = tile_and_center(uv, frequency, 0.0, zigzag, rotation);
1309
1310
 
1310
1311
  // Different approach for variation param here
@@ -1317,7 +1318,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1317
1318
  s + smoothness,
1318
1319
  abs(f.y)
1319
1320
  );
1320
- }`,[r]),d=new Q(`// Uses bisection
1321
+ }`,[r]),d=new re(`// Uses bisection
1321
1322
  float udf_cos(in vec2 p, in float a, in float b, in float c, in float d) {
1322
1323
  // Convert all data to a primitive cosine wave
1323
1324
  p = c * (p - vec2(d, a));
@@ -1366,7 +1367,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1366
1367
  float s = mix(size, size * rand, variation);
1367
1368
 
1368
1369
  return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);
1369
- }`);return{tileAndCenter:r,circle:o,ring:i,polygon:a,cross:s,diamond:l,checkerboard:u,line:c,wave:d}}();var mf=class extends se{constructor(e,r,o,i,a,s,l,u){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=r,this.wavelengths=o,this.noiseStrength=i,this.noiseScale=a,this.offset=s,this.isMask=u,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(mf.Nodes.rainbow),i=[];return i.push(this.filmThickness.build(e,"f")),i.push(this.movement.build(e,"f")),i.push(this.wavelengths.build(e,"v3")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.offset.build(e,"v3")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},cs=mf;cs.Nodes=function(){let e=new Q(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
1370
+ }`);return{tileAndCenter:r,circle:o,ring:i,polygon:a,cross:s,diamond:l,checkerboard:u,line:c,wave:d}}();var Kf=class extends ge{constructor(e,r,o,i,a,s,l,u){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=r,this.wavelengths=o,this.noiseStrength=i,this.noiseScale=a,this.offset=s,this.isMask=u,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(Kf.Nodes.rainbow),i=[];return i.push(this.filmThickness.build(e,"f")),i.push(this.movement.build(e,"f")),i.push(this.wavelengths.build(e,"v3")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.offset.build(e,"v3")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Ts=Kf;Ts.Nodes=function(){let e=new re(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
1370
1371
  vec3 st = position / noiseScale;
1371
1372
  vec3 q = vec3(simplex3d(st),
1372
1373
  simplex3d(st + vec3(1.0)),
@@ -1379,7 +1380,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1379
1380
  float noise = simplex3d(st + r);
1380
1381
 
1381
1382
  return .5 + .5 * cos((((filmThickness + (noise * noiseStrength)) / (vec3(wavelengths.r * 1.0, wavelengths.g * 0.8, wavelengths.b * 0.6) + 1.0)) * dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal))) + movement);
1382
- }`,[$t.simplex]);return{rainbow:new Q(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {
1383
+ }`,[ir.simplex]);return{rainbow:new re(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {
1383
1384
  vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);
1384
1385
 
1385
1386
  float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);
@@ -1389,14 +1390,14 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1389
1390
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
1390
1391
 
1391
1392
  return res;
1392
- }`,[e])}}();var yf=class extends se{constructor(e,r,o,i,a,s,l,u,c,d){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=r,this.steps=o,this.source=i,this.isWorldSpace=a,this.noiseStrength=s,this.noiseScale=l,this.shadowColor=u,this.offset=c,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let o=e.include(yf.Nodes.toon),i=[];return i.push(this.positioning.build(e,"i")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.source.build(e,"v3")),i.push(this.isWorldSpace.build(e,"b")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.shadowColor.build(e,"v4")),i.push(this.offset.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},us=yf;us.Nodes=function(){let e=new Q(`float rand(float n) {
1393
+ }`,[e])}}();var Zf=class extends ge{constructor(e,r,o,i,a,s,l,u,c,d){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=r,this.steps=o,this.source=i,this.isWorldSpace=a,this.noiseStrength=s,this.noiseScale=l,this.shadowColor=u,this.offset=c,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let o=e.include(Zf.Nodes.toon),i=[];return i.push(this.positioning.build(e,"i")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.source.build(e,"v3")),i.push(this.isWorldSpace.build(e,"b")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.shadowColor.build(e,"v4")),i.push(this.offset.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Ms=Zf;Ms.Nodes=function(){let e=new re(`float rand(float n) {
1393
1394
  return fract(sin(n) * 43758.5453123);
1394
- }`),r=new Q(`float hash1(float p) {
1395
+ }`),r=new re(`float hash1(float p) {
1395
1396
  p = fract(p * 0.011);
1396
1397
  p *= p + 7.5;
1397
1398
  p *= p + p;
1398
1399
  return fract(p);
1399
- }`),o=new Q(`float valueNoise(vec3 x) {
1400
+ }`),o=new re(`float valueNoise(vec3 x) {
1400
1401
  const vec3 step = vec3(110, 241, 171);
1401
1402
 
1402
1403
  vec3 i = floor(x);
@@ -1411,13 +1412,13 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1411
1412
  mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y),
1412
1413
  mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x),
1413
1414
  mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);
1414
- }`,[r]),i=new Q(`vec3 hash3(vec3 x) {
1415
+ }`,[r]),i=new re(`vec3 hash3(vec3 x) {
1415
1416
  x = vec3(dot(x,vec3(127.1, 311.7, 74.7)),
1416
1417
  dot(x,vec3(269.5, 183.3, 246.1)),
1417
1418
  dot(x,vec3(113.5, 271.9, 124.6)));
1418
1419
 
1419
1420
  return fract(sin(x)*43758.5453123);
1420
- }`),a=new Q(`vec3 voronoiNoise(in vec3 x)
1421
+ }`),a=new re(`vec3 voronoiNoise(in vec3 x)
1421
1422
  {
1422
1423
  vec3 p = floor(x);
1423
1424
  vec3 f = fract(x);
@@ -1448,7 +1449,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1448
1449
 
1449
1450
  return vec3(sqrt(res), abs(id));
1450
1451
  }
1451
- `,[i]);return{toon:new Q(`vec3 toon(int positioning, vec4 colors[COLORS_MAX], float steps[COLORS_MAX], vec3 source, bool isWorldSpace, float noiseStrength, float noiseScale, vec4 shadowColor, vec3 offset, float mask, float alpha, out float calpha) {
1452
+ `,[i]);return{toon:new re(`vec3 toon(int positioning, vec4 colors[COLORS_MAX], float steps[COLORS_MAX], vec3 source, bool isWorldSpace, float noiseStrength, float noiseScale, vec4 shadowColor, vec3 offset, float mask, float alpha, out float calpha) {
1452
1453
  float t = 0.0;
1453
1454
  float shadow = 1.0;
1454
1455
 
@@ -1625,7 +1626,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1625
1626
 
1626
1627
  return color.xyz;
1627
1628
 
1628
- }`,[$t.simplex,e,o,a])}}();var gf=require("three");var Bx=function(){return{textureBicubic:new Q(`float w0( float a ) {
1629
+ }`,[ir.simplex,e,o,a])}}();var Jf=require("three");var Ab=function(){return{textureBicubic:new re(`float w0( float a ) {
1629
1630
  return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
1630
1631
  }
1631
1632
 
@@ -1689,7 +1690,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1689
1690
  vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
1690
1691
  vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
1691
1692
  return mix( fSample, cSample, fract( lod ) );
1692
- }`)}}();function Lx(n,t){return n>=t?new gf.Vector2(t/n,1):new gf.Vector2(1,n/t)}var xf=class extends se{constructor(e,r,o,i,a,s,l,u){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=r,this.roughness=o,this.transmissionSamplerSize=i,this.transmissionSamplerMap=a,this.transmissionDepthMap=s,this.aspectRatio=l,this.alpha=u,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",6),e.define("BLUR_SLOD",Math.pow(2,Pe.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let o=e.include(xf.Nodes.transmission),i=[];return i.push(this.thickness.build(e,"f")),i.push(this.ior.build(e,"f")),i.push(this.roughness.build(e,"f")),i.push(this.transmissionSamplerSize.build(e,"v2")),i.push(this.transmissionSamplerMap.getTexture(e,"t")),i.push(this.transmissionDepthMap.getTexture(e,"t")),i.push(this.aspectRatio.build(e,"v2")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ds=xf;ds.Nodes=function(){let e=new Q(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
1693
+ }`)}}();function _b(n,t){return n>=t?new Jf.Vector2(t/n,1):new Jf.Vector2(1,n/t)}var eh=class extends ge{constructor(e,r,o,i,a,s,l,u){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=r,this.roughness=o,this.transmissionSamplerSize=i,this.transmissionSamplerMap=a,this.transmissionDepthMap=s,this.aspectRatio=l,this.alpha=u,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",6),e.define("BLUR_SLOD",Math.pow(2,De.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let o=e.include(eh.Nodes.transmission),i=[];return i.push(this.thickness.build(e,"f")),i.push(this.ior.build(e,"f")),i.push(this.roughness.build(e,"f")),i.push(this.transmissionSamplerSize.build(e,"v2")),i.push(this.transmissionSamplerMap.getTexture(e,"t")),i.push(this.transmissionDepthMap.getTexture(e,"t")),i.push(this.aspectRatio.build(e,"v2")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Is=eh;Is.Nodes=function(){let e=new re(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
1693
1694
  // Slightly modified version of this:
1694
1695
  // https://www.shadertoy.com/view/ltScRG
1695
1696
 
@@ -1722,7 +1723,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1722
1723
  res += textureLod(sp, uv, lod).rgb;
1723
1724
  }
1724
1725
  return res / float(NUM_SAMPLES);
1725
- }`),r=new Q(`vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
1726
+ }`),r=new re(`vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
1726
1727
  // Direction of refracted light.
1727
1728
  vec3 refractionVector = refract( -v, n, 1.0 / ior );
1728
1729
 
@@ -1734,11 +1735,11 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1734
1735
 
1735
1736
  // The thickness is specified in local space
1736
1737
  return normalize( refractionVector ) * thickness * modelScale;
1737
- }`),o=new Q(`float applyIorToRoughness( float roughness, float ior ) {
1738
+ }`),o=new re(`float applyIorToRoughness( float roughness, float ior ) {
1738
1739
  // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
1739
1740
  // an IOR of 1.5 results in the default amount of microfacet refraction.
1740
1741
  return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
1741
- }`),i=new Q(`vec3 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {
1742
+ }`),i=new re(`vec3 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {
1742
1743
  // Threejs exports do not pass a depth map to this shader, so we have to fallback to the "Threejs method of blurring" - see
1743
1744
  // also the code in convertTransmission.ts, which runs during export
1744
1745
  #ifdef IS_THREEJS_EXPORT
@@ -1749,7 +1750,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1749
1750
  float lod = applyIorToRoughness(roughness, ior);
1750
1751
  return blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
1751
1752
  #endif
1752
- }`,[Bx.textureBicubic,o,e]),a=new Q(`vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) {
1753
+ }`,[Ab.textureBicubic,o,e]),a=new re(`vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) {
1753
1754
  vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
1754
1755
  vec3 refractedRayExit = position + transmissionRay;
1755
1756
 
@@ -1766,7 +1767,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1766
1767
 
1767
1768
  // Sample framebuffer to get pixel the refracted ray hits.
1768
1769
  return getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );
1769
- }`,[i,r]);return{transmission:new Q(`vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float mask, float alpha, out float calpha) {
1770
+ }`,[i,r]);return{transmission:new re(`vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float mask, float alpha, out float calpha) {
1770
1771
  vec3 v = vec3(0.);
1771
1772
  if (isOrthographic) {
1772
1773
  v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
@@ -1780,7 +1781,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1780
1781
  accumAlpha += ( 1.0 - accumAlpha ) * alpha;
1781
1782
 
1782
1783
  return transmission;
1783
- }`,[a])}}();var bf=(e=>(e.NOISE="noise",e.MAP="map",e))(bf||{}),vf=class extends se{constructor(e,r,o,i,a,s,l,u,c,d,p){super("v3");this.displacementTypeIndex=new Ie(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=r,Object.values(bf)[this.displacementTypeIndex.value]==="map"&&(this.mat=new Za(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=d,this.noiseFunctionIndex=p,this.voronoiStyle=i,this.smoothness=a,this.seed=s,this.highCut=l,this.lowCut=u,this.quality=c}generate(e,r){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let o,i=[];switch(i.push("displaced_position"),i.push("displaced_normal"),Object.values(bf)[this.displacementTypeIndex.value]){case"map":{o=e.include(vf.Nodes.map),i.push(this.movementOrTexture.getTexture(e,"t")),i.push("uv"),i.push(this.cropOrOffset.build(e,"f")),this.mat&&i.push(this.mat.build(e,"mat3"));break}case"noise":{let s=Object.values(Pl)[this.noiseFunctionIndex.value],l=new Q(`vec3 orthogonal(vec3 v) {
1784
+ }`,[a])}}();var th=(e=>(e.NOISE="noise",e.MAP="map",e))(th||{}),rh=class extends ge{constructor(e,r,o,i,a,s,l,u,c,d,p){super("v3");this.displacementTypeIndex=new Ge(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=r,Object.values(th)[this.displacementTypeIndex.value]==="map"&&(this.mat=new gs(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=d,this.noiseFunctionIndex=p,this.voronoiStyle=i,this.smoothness=a,this.seed=s,this.highCut=l,this.lowCut=u,this.quality=c}generate(e,r){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let o,i=[];switch(i.push("displaced_position"),i.push("displaced_normal"),Object.values(th)[this.displacementTypeIndex.value]){case"map":{o=e.include(rh.Nodes.map),i.push(this.movementOrTexture.getTexture(e,"t")),i.push("uv"),i.push(this.cropOrOffset.build(e,"f")),this.mat&&i.push(this.mat.build(e,"mat3"));break}case"noise":{let s=Object.values(Wl)[this.noiseFunctionIndex.value],l=new re(`vec3 orthogonal(vec3 v) {
1784
1785
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
1785
1786
  }`),u=s=="voronoi"?`
1786
1787
  float v = ${s}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);
@@ -1791,9 +1792,9 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1791
1792
  return p + n * v * intensity;
1792
1793
  `:`
1793
1794
  return p + n * ${s}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
1794
- `,c=new Q(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality) {
1795
+ `,c=new re(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality) {
1795
1796
  ${u}
1796
- }`,[$t.simplex,$t.simplexFractal,$t.simplexAshima,$t.fbm,$t.perlin,$t.voronoi]),d=new Q(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality, float intensity, out vec3 displaced_normal) {
1797
+ }`,[ir.simplex,ir.simplexFractal,ir.simplexAshima,ir.fbm,ir.perlin,ir.voronoi]),d=new re(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality, float intensity, out vec3 displaced_normal) {
1797
1798
  vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
1798
1799
  vec3 tangent1 = orthogonal(normal);
1799
1800
  vec3 tangent2 = normalize(cross(normal, tangent1));
@@ -1809,9 +1810,9 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1809
1810
  vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
1810
1811
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1811
1812
  return displaced_position;
1812
- }`,[c,l]);o=e.include(d),i.push(this.scale.build(e,"f")),i.push(this.cropOrOffset.build(e,"v3")),i.push(this.movementOrTexture.build(e,"f")),i.push(this.voronoiStyle.build(e,"i")),i.push(this.smoothness.build(e,"f")),i.push(this.seed.build(e,"f")),i.push(this.highCut.build(e,"f")),i.push(this.lowCut.build(e,"f")),i.push(this.quality.build(e,"i"));break}}return i.push(this.intensity.build(e,"f")),i.push("displaced_normal"),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ps=vf;ps.Nodes=function(){let e=new Q(`vec3 orthogonal(vec3 v) {
1813
+ }`,[c,l]);o=e.include(d),i.push(this.scale.build(e,"f")),i.push(this.cropOrOffset.build(e,"v3")),i.push(this.movementOrTexture.build(e,"f")),i.push(this.voronoiStyle.build(e,"i")),i.push(this.smoothness.build(e,"f")),i.push(this.seed.build(e,"f")),i.push(this.highCut.build(e,"f")),i.push(this.lowCut.build(e,"f")),i.push(this.quality.build(e,"i"));break}}return i.push(this.intensity.build(e,"f")),i.push("displaced_normal"),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Ns=rh;Ns.Nodes=function(){let e=new re(`vec3 orthogonal(vec3 v) {
1813
1814
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
1814
- }`),r=new Q(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
1815
+ }`),r=new re(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
1815
1816
  vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
1816
1817
  vec4 tmp = texture2D(tex, uvs);
1817
1818
  vec3 col = tmp.rgb;
@@ -1821,7 +1822,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1821
1822
  }
1822
1823
  }
1823
1824
  return col.r;
1824
- }`);return{map:new Q(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {
1825
+ }`);return{map:new re(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {
1825
1826
  vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity;
1826
1827
  vec3 tangent1 = normalize(orthogonal(normal));
1827
1828
  vec3 tangent2 = normalize(cross(normal, tangent1));
@@ -1831,7 +1832,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1831
1832
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
1832
1833
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1833
1834
  return displaced_position;
1834
- }`,[e,r])}}();var Pe={normalRenderTarget:new lr,normalRenderTargetDepth:new lr,transmissionRenderTarget:new lr,aspectRatio:new mt,transmissionSize:new mt(2048,2048),transmissionRenderTargetDepth:new lr,aoRenderTarget:new lr,aoEnabled:new wt,pixelRatioNode:new J(1),resolution:new mt,penumbraSize:new uo(5,.5),frameIndex:new Ie(0),transmissionLod:new Ie(2)};for(let n of Object.values(Pe))n.isRenderGlobal=!0;var Rx={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.0.21/build/ui.wasm"};var ln=class extends Ht{constructor(){super("basic");this.nodeType="Basic";this.color=new qe(Ot),this.shadingAlpha=new J(1),this.shadingBlend=new Ie(0),this.previousModelViewMatrix=new Zt,this.previouseProjectionMatrix=new Zt}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Pe.frameIndex}),e.mergeUniform({resolution:Pe.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(ku.UniformsUtils.merge([ku.UniformsLib.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
1835
+ }`,[e,r])}}();var De={normalRenderTarget:new wr,normalRenderTargetDepth:new wr,transmissionRenderTarget:new wr,aspectRatio:new Pt,transmissionSize:new Pt(2048,2048),transmissionRenderTargetDepth:new wr,aoRenderTarget:new wr,aoEnabled:new Et,pixelRatioNode:new se(1),resolution:new Pt,penumbraSize:new Ao(5,.5),frameIndex:new Ge(0),transmissionLod:new Ge(2)};for(let n of Object.values(De))n.isRenderGlobal=!0;var Pb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.0.23/build/ui.wasm"};var xn=class extends rr{constructor(){super("basic");this.nodeType="Basic";this.color=new et(Rt),this.shadingAlpha=new se(1),this.shadingBlend=new Ge(0),this.previousModelViewMatrix=new cr,this.previouseProjectionMatrix=new cr}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({resolution:De.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(dd.UniformsUtils.merge([dd.UniformsLib.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
1835
1836
  `));let i=["#include <beginnormal_vertex>",`
1836
1837
  #if !defined( USE_LAYER_DISPLACE )
1837
1838
  #include <defaultnormal_vertex>
@@ -1849,9 +1850,9 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1849
1850
  #include <begin_vertex>
1850
1851
  #endif /* !USE_LAYER_DISPLACE */
1851
1852
  `];o&&i.push(o.code,o.result?"displaced_position = "+o.result+";":""),i.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=i.join(`
1852
- `)}else{this.color===void 0&&(this.color=new qe(Ot)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let o=this.color.flow(e,"c",{slot:"color"}),i=this.alpha?this.alpha.flow(e,"f"):void 0,a=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=i!==void 0,e.addParsCode(["varying vec3 vWPosition;","#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
1853
+ `)}else{this.color===void 0&&(this.color=new et(Rt)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let o=this.color.flow(e,"c",{slot:"color"}),i=this.alpha?this.alpha.flow(e,"f"):void 0,a=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=i!==void 0,e.addParsCode(["varying vec3 vWPosition;","#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
1853
1854
  `));let l=["#include <normal_fragment_begin>",o.code];i&&l.push(i.code,"#ifdef ALPHATEST"," if ( "+i.result+" <= ALPHATEST ) discard;","#endif"),s?l.push(s.code,`vec3 outgoingLight = ${o.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):l.push(`vec3 finalColor = ${o.result};`);let u="1.0";this.mask&&(this.mask.analyze(e),u=`luminance(${this.mask.flow(e,"v3").result})`),i?l.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${i.result} * ${u} );`):l.push("gl_FragColor = vec4("+o.result+", 1.0 );"),a&&l.push(`gl_FragColor.a *= ${a.result};`),l.push("#include <fog_fragment>","#include <dithering_fragment>"),r=l.join(`
1854
- `)}return r}};var Ol=require("three");var Cl=class extends Ht{constructor(){super("lambert");this.nodeType="Lambert";this.color=new qe(Ot),this.emissive=new qe(0),this.emissiveIntensity=new J(1),this.previousModelViewMatrix=new Zt,this.previouseProjectionMatrix=new Zt,this.shadingAlpha=new J(1),this.shadingBlend=new Ie(0),this.occlusion=new wt(!0)}get category(){return"lambert"}build(e){let r;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Pe.frameIndex}),e.mergeUniform({resolution:Pe.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ol.UniformsUtils.merge([Ol.UniformsLib.fog,Ol.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1855
+ `)}return r}};var $l=require("three");var Yl=class extends rr{constructor(){super("lambert");this.nodeType="Lambert";this.color=new et(Rt),this.emissive=new et(0),this.emissiveIntensity=new se(1),this.previousModelViewMatrix=new cr,this.previouseProjectionMatrix=new cr,this.shadingAlpha=new se(1),this.shadingBlend=new Ge(0),this.occlusion=new Et(!0)}get category(){return"lambert"}build(e){let r;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({resolution:De.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform($l.UniformsUtils.merge([$l.UniformsLib.fog,$l.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1855
1856
  `));let i=["#include <beginnormal_vertex>",`
1856
1857
  #ifndef USE_LAYER_DISPLACE
1857
1858
  #include <defaultnormal_vertex>
@@ -1944,7 +1945,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1944
1945
  #pragma unroll_loop_end
1945
1946
  #endif
1946
1947
  `," #include <shadowmap_vertex>"," #include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=i.join(`
1947
- `)}else{e.mergeUniform({penumbraSize:Pe.penumbraSize}),e.mergeUniform({frameIndex:Pe.frameIndex}),e.mergeUniform({aoMap:Pe.aoRenderTarget}),e.mergeUniform({aoEnabled:Pe.aoEnabled}),this.color===void 0&&(this.color=new qe(Ot)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),i=this.emissive.flow(e,"c",{slot:"emissive"}),a=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),s=this.occlusion.flow(e,"b",{slot:"occlusion"}),l=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include <normal_pars_fragment>","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <fog_pars_fragment>","#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join(`
1948
+ `)}else{e.mergeUniform({penumbraSize:De.penumbraSize}),e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({aoMap:De.aoRenderTarget}),e.mergeUniform({aoEnabled:De.aoEnabled}),this.color===void 0&&(this.color=new et(Rt)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),i=this.emissive.flow(e,"c",{slot:"emissive"}),a=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),s=this.occlusion.flow(e,"b",{slot:"occlusion"}),l=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include <normal_pars_fragment>","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <fog_pars_fragment>","#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join(`
1948
1949
  `));let f=["#include <normal_fragment_begin>",`
1949
1950
  // NOTE: gl_FrontFacing alternative using face normal estimation.
1950
1951
  vec3 viewdx = dFdx(vViewPosition);
@@ -1960,7 +1961,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1960
1961
  outgoingLight *= ao;
1961
1962
  }
1962
1963
  `),c&&f.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),d?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p&&f.push(`gl_FragColor.a *= ${p.result};`),f.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=f.join(`
1963
- `)}return r}};var Tl=require("three");var cn=function(){let n=new Q(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {
1964
+ `)}return r}};var Xl=require("three");var bn=function(){let n=new re(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {
1964
1965
 
1965
1966
  // Gradient of UVs w.r.t. X coordinate (in screen-space)
1966
1967
  vec2 dSTdx = dFdx(bumpMapUv);
@@ -1974,7 +1975,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1974
1975
  float dBy = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdy).rgb) - Hll;
1975
1976
 
1976
1977
  return vec2( dBx, dBy );
1977
- }`),t=new Q(`vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
1978
+ }`),t=new re(`vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
1978
1979
  vec3 vSigmaX = dFdx( surf_pos.xyz );
1979
1980
  vec3 vSigmaY = dFdy( surf_pos.xyz );
1980
1981
  vec3 vN = surf_norm; // normalized
@@ -1991,7 +1992,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1991
1992
 
1992
1993
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
1993
1994
  return normalize( abs( fDet ) * vN - vGrad );
1994
- }`);return{dHdxy:n,perturbNormalArb:t}}();var Ml=class extends Ht{constructor(){super("phong");this.nodeType="Phong";this.color=new qe(Ot),this.specular=new qe(1118481),this.shininess=new J(30),this.previousModelViewMatrix=new Zt,this.previouseProjectionMatrix=new Zt,this.shadingAlpha=new J(1),this.shadingBlend=new Ie(0),this.occlusion=new wt(!0)}get category(){return"phong"}build(e){let r;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Pe.frameIndex}),e.mergeUniform({resolution:Pe.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Tl.UniformsUtils.merge([Tl.UniformsLib.fog,Tl.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1995
+ }`);return{dHdxy:n,perturbNormalArb:t}}();var Ql=class extends rr{constructor(){super("phong");this.nodeType="Phong";this.color=new et(Rt),this.specular=new et(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new cr,this.previouseProjectionMatrix=new cr,this.shadingAlpha=new se(1),this.shadingBlend=new Ge(0),this.occlusion=new Et(!0)}get category(){return"phong"}build(e){let r;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({resolution:De.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Xl.UniformsUtils.merge([Xl.UniformsLib.fog,Xl.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1995
1996
  `));let i=["#include <beginnormal_vertex>",`
1996
1997
  #include <skinbase_vertex>
1997
1998
  #include <skinnormal_vertex>
@@ -2012,7 +2013,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2012
2013
  #include <begin_vertex>
2013
2014
  #endif
2014
2015
  `];o&&i.push(o.code,o.result?"displaced_position = "+o.result+";":""),i.push("transformed = displaced_position;","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=i.join(`
2015
- `)}else{e.mergeUniform({penumbraSize:Pe.penumbraSize}),e.mergeUniform({frameIndex:Pe.frameIndex}),e.mergeUniform({aoMap:Pe.aoRenderTarget}),e.mergeUniform({aoEnabled:Pe.aoEnabled}),this.color===void 0&&(this.color=new qe(Ot)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e);let o=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let i=this.color.flow(e,"c",{slot:"color"}),a=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),l=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <dithering_pars_fragment>"].join(`
2016
+ `)}else{e.mergeUniform({penumbraSize:De.penumbraSize}),e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({aoMap:De.aoRenderTarget}),e.mergeUniform({aoEnabled:De.aoEnabled}),this.color===void 0&&(this.color=new et(Rt)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e);let o=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let i=this.color.flow(e,"c",{slot:"color"}),a=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),l=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <dithering_pars_fragment>"].join(`
2016
2017
  `));let f=["#include <normal_fragment_begin>",`
2017
2018
  // NOTE: gl_FrontFacing alternative using face normal estimation.
2018
2019
  vec3 viewdx = dFdx(vViewPosition);
@@ -2021,7 +2022,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2021
2022
  if (dot(normal, faceNormal) < 0.0) {
2022
2023
  normal *= -1.0;
2023
2024
  }
2024
- `," BlinnPhongMaterial material;"];if(this.bumpMap){e.include(cn.dHdxy),e.include(cn.perturbNormalArb);let m=this.bumpMap.texture.flow(e,"t"),y=this.bumpMap.flow(e,"v3"),g=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",b="";this.bumpMap.projection.value===4?b=`
2025
+ `," BlinnPhongMaterial material;"];if(this.bumpMap){e.include(bn.dHdxy),e.include(bn.perturbNormalArb);let m=this.bumpMap.texture.flow(e,"t"),y=this.bumpMap.flow(e,"v3"),g=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",b="";this.bumpMap.projection.value===4?b=`
2025
2026
  vec3 bumpNormal = vec3(0.0);
2026
2027
  {
2027
2028
  vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
@@ -2059,7 +2060,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2059
2060
  outgoingLight *= ao;
2060
2061
  }
2061
2062
  `),c&&f.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),d?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result});`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p&&f.push(`gl_FragColor.a *= ${p.result};`),f.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=f.join(`
2062
- `)}return r}};var fs=require("three");var Il=class extends Ht{constructor(){super("standard");this.nodeType="Standard";this.color=new qe(Ot),this.roughness=new J(.3),this.metalness=new J(0),this.reflectivity=new J(.5),this.previousModelViewMatrix=new Zt,this.previouseProjectionMatrix=new Zt,this.shadingAlpha=new J(1),this.shadingBlend=new Ie(0),this.occlusion=new wt(!0)}get category(){return"physical"}build(e){let r;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Pe.frameIndex}),e.mergeUniform({resolution:Pe.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(fs.UniformsUtils.merge([fs.UniformsLib.fog,fs.UniformsLib.lights])),fs.UniformsLib.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2063
+ `)}return r}};var Ds=require("three");var Kl=class extends rr{constructor(){super("standard");this.nodeType="Standard";this.color=new et(Rt),this.roughness=new se(.3),this.metalness=new se(0),this.reflectivity=new se(.5),this.previousModelViewMatrix=new cr,this.previouseProjectionMatrix=new cr,this.shadingAlpha=new se(1),this.shadingBlend=new Ge(0),this.occlusion=new Et(!0)}get category(){return"physical"}build(e){let r;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({resolution:De.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ds.UniformsUtils.merge([Ds.UniformsLib.fog,Ds.UniformsLib.lights])),Ds.UniformsLib.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2063
2064
  `));let i=["#include <beginnormal_vertex>",`
2064
2065
  #if !defined( USE_LAYER_DISPLACE )
2065
2066
  #include <defaultnormal_vertex>
@@ -2077,7 +2078,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2077
2078
  #include <begin_vertex>
2078
2079
  #endif /* !USE_LAYER_DISPLACE */
2079
2080
  `];o&&i.push(o.code,o.result?"displaced_position = "+o.result+";":""),i.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=i.join(`
2080
- `)}else{e.mergeUniform({penumbraSize:Pe.penumbraSize}),e.mergeUniform({frameIndex:Pe.frameIndex}),e.mergeUniform({aoMap:Pe.aoRenderTarget}),e.mergeUniform({aoEnabled:Pe.aoEnabled});let o={gamma:!0};this.color===void 0&&(this.color=new qe(Ot)),this.color.analyze(e,{slot:"color",context:o}),this.roughness.analyze(e),this.metalness.analyze(e);let i=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let a=this.color.flow(e,"c",{slot:"color",context:o}),s=this.roughness.flow(e,"f"),l=this.metalness.flow(e,"f"),u=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),d=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0,f=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,h=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=p!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>","#include <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join(`
2081
+ `)}else{e.mergeUniform({penumbraSize:De.penumbraSize}),e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({aoMap:De.aoRenderTarget}),e.mergeUniform({aoEnabled:De.aoEnabled});let o={gamma:!0};this.color===void 0&&(this.color=new et(Rt)),this.color.analyze(e,{slot:"color",context:o}),this.roughness.analyze(e),this.metalness.analyze(e);let i=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let a=this.color.flow(e,"c",{slot:"color",context:o}),s=this.roughness.flow(e,"f"),l=this.metalness.flow(e,"f"),u=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),d=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0,f=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,h=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=p!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>","#include <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join(`
2081
2082
  `));let m=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
2082
2083
  // NOTE: gl_FrontFacing alternative using face normal estimation.
2083
2084
  vec3 viewdx = dFdx(vViewPosition);
@@ -2086,7 +2087,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2086
2087
  if (dot(normal, faceNormal) < 0.0) {
2087
2088
  normal *= -1.0;
2088
2089
  }
2089
- `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(cn.dHdxy),e.include(cn.perturbNormalArb);let g=this.bumpMap.texture.flow(e,"t"),b=this.bumpMap.flow(e,"v3"),S=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",w="";this.bumpMap.projection.value===4?w=`
2090
+ `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(bn.dHdxy),e.include(bn.perturbNormalArb);let g=this.bumpMap.texture.flow(e,"t"),b=this.bumpMap.flow(e,"v3"),w=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",_="";this.bumpMap.projection.value===4?_=`
2090
2091
  vec3 bumpNormal = vec3(0.0);
2091
2092
  {
2092
2093
  vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
@@ -2094,13 +2095,13 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2094
2095
  vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
2095
2096
  vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
2096
2097
 
2097
- vec2 grad0 = dHdxy(${g.result}, uv0, ${S});
2098
+ vec2 grad0 = dHdxy(${g.result}, uv0, ${w});
2098
2099
  vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);
2099
2100
 
2100
- vec2 grad1 = dHdxy(${g.result}, uv1, ${S});
2101
+ vec2 grad1 = dHdxy(${g.result}, uv1, ${w});
2101
2102
  vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);
2102
2103
 
2103
- vec2 grad2 = dHdxy(${g.result}, uv2, ${S});
2104
+ vec2 grad2 = dHdxy(${g.result}, uv2, ${w});
2104
2105
  vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);
2105
2106
 
2106
2107
  bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;
@@ -2108,14 +2109,14 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2108
2109
  }
2109
2110
 
2110
2111
  normal = bumpNormal;
2111
- `:w=`
2112
+ `:_=`
2112
2113
  vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
2113
- vec2 grad = dHdxy(${g.result}, bumpMapCachedUv, ${S});
2114
+ vec2 grad = dHdxy(${g.result}, bumpMapCachedUv, ${w});
2114
2115
  normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
2115
2116
  `,m.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
2116
2117
  ${b.result};
2117
- ${w}
2118
- `)}if(m.push(a.code," vec3 diffuseColor = "+a.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",l.code," float metalnessFactor = "+l.result+";"),this.roughnessMap){let g=this.roughnessMap.texture.flow(e,"t"),b=this.roughnessMap.flow(e,"v3"),S="";this.roughnessMap.projection.value===4?S=`
2118
+ ${_}
2119
+ `)}if(m.push(a.code," vec3 diffuseColor = "+a.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",l.code," float metalnessFactor = "+l.result+";"),this.roughnessMap){let g=this.roughnessMap.texture.flow(e,"t"),b=this.roughnessMap.flow(e,"v3"),w="";this.roughnessMap.projection.value===4?w=`
2119
2120
  float roughnessChange = 1.0;
2120
2121
  {
2121
2122
  vec2 uv0 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
@@ -2130,7 +2131,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2130
2131
  roughnessChange = (r0 * weights.z + r1 * weights.x + r2 * weights.y);
2131
2132
  }
2132
2133
  float roughnessFactor = roughnessChange * ${s.result};
2133
- `:S=`
2134
+ `:w=`
2134
2135
  vec2 roughnessMapCachedUv = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs;
2135
2136
 
2136
2137
  vec4 vals = texture(${g.result}, roughnessMapCachedUv);
@@ -2140,7 +2141,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2140
2141
 
2141
2142
  const float roughnessScale = 1.0;
2142
2143
 
2143
- ${S}
2144
+ ${w}
2144
2145
  `)}else m.push(s.code," float roughnessFactor = "+s.result+";");p&&m.push(p.code,"#ifdef ALPHATEST"," if ( "+p.result+" <= ALPHATEST ) discard;","#endif"),m.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),m.push("material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),h?m.push(h.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+h.result+" ) ), diffuseColor, metalnessFactor );"):m.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),m.push("#include <lights_fragment_begin>"),m.push("#include <lights_fragment_end>"),m.push("vec3 ao = aoEnabled && "+i.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");let y="1.0";this.mask&&(this.mask.analyze(e),y=`luminance(${this.mask.flow(e,"v3").result})`),m.push(`
2145
2146
  if (outgoingLight != diffuseColor) {
2146
2147
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
@@ -2150,7 +2151,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2150
2151
  outgoingLight *= ao;
2151
2152
  }
2152
2153
  `),d&&m.push(d.code,`outgoingLight = spe_blend(outgoingLight, ${d.result}, 1.0, SPE_BLENDING_NORMAL);`),p?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),f&&m.push(`gl_FragColor.a *= ${f.result};`),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=m.join(`
2153
- `)}return r}};var Nl=require("three");var Dl=class extends Ht{constructor(){super("toon");this.nodeType="Toon";this.color=new qe(Ot),this.specular=new qe(1118481),this.shininess=new J(30),this.previousModelViewMatrix=new Zt,this.previouseProjectionMatrix=new Zt,this.shadingAlpha=new J(1),this.shadingBlend=new Ie(0)}get category(){return"toon"}build(e){let r;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Pe.frameIndex}),e.mergeUniform({resolution:Pe.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Nl.UniformsUtils.merge([Nl.UniformsLib.fog,Nl.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2154
+ `)}return r}};var Zl=require("three");var Jl=class extends rr{constructor(){super("toon");this.nodeType="Toon";this.color=new et(Rt),this.specular=new et(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new cr,this.previouseProjectionMatrix=new cr,this.shadingAlpha=new se(1),this.shadingBlend=new Ge(0)}get category(){return"toon"}build(e){let r;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({resolution:De.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Zl.UniformsUtils.merge([Zl.UniformsLib.fog,Zl.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2154
2155
  `));let i=["#include <beginnormal_vertex>",`
2155
2156
  #ifndef USE_LAYER_DISPLACE
2156
2157
  #include <defaultnormal_vertex>
@@ -2168,7 +2169,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2168
2169
  #include <begin_vertex>
2169
2170
  #endif
2170
2171
  `];o&&i.push(o.code,o.result?"displaced_position = "+o.result+";":""),i.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push(" #include <project_vertex>"," #include <fog_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=i.join(`
2171
- `)}else{e.mergeUniform({penumbraSize:Pe.penumbraSize}),e.mergeUniform({frameIndex:Pe.frameIndex}),e.mergeUniform({aoMap:Pe.aoRenderTarget}),e.mergeUniform({aoEnabled:Pe.aoEnabled}),this.color===void 0&&(this.color=new qe(Ot)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),i=this.specular.flow(e,"c"),a=this.shininess.flow(e,"f"),s=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=c!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vWPosition;","#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
2172
+ `)}else{e.mergeUniform({penumbraSize:De.penumbraSize}),e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({aoMap:De.aoRenderTarget}),e.mergeUniform({aoEnabled:De.aoEnabled}),this.color===void 0&&(this.color=new et(Rt)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),i=this.specular.flow(e,"c"),a=this.shininess.flow(e,"f"),s=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=c!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vWPosition;","#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
2172
2173
  varying vec3 vViewPosition;
2173
2174
  struct ToonMaterial {
2174
2175
  vec3 diffuseColor;
@@ -2197,7 +2198,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2197
2198
  if (dot(normal, faceNormal) < 0.0) {
2198
2199
  normal *= -1.0;
2199
2200
  }
2200
- `," ToonMaterial material;"];if(this.bumpMap){e.include(cn.dHdxy),e.include(cn.perturbNormalArb);let h=this.bumpMap.texture.flow(e,"t"),m=this.bumpMap.flow(e,"v3"),y=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",g="";this.bumpMap.projection.value===4?g=`
2201
+ `," ToonMaterial material;"];if(this.bumpMap){e.include(bn.dHdxy),e.include(bn.perturbNormalArb);let h=this.bumpMap.texture.flow(e,"t"),m=this.bumpMap.flow(e,"v3"),y=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",g="";this.bumpMap.projection.value===4?g=`
2201
2202
  vec3 bumpNormal = vec3(0.0);
2202
2203
  {
2203
2204
  vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
@@ -2233,11 +2234,11 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2233
2234
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result} * ${f}, ${l.result} );
2234
2235
  }
2235
2236
  `),u&&p.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),c?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&p.push(`gl_FragColor.a *= ${d.result};`),p.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=p.join(`
2236
- `)}return r}};var ms=require("three");var Fu=class{constructor(t=1e3*10){this.timeout=t;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}};var wf=class extends Fu{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},Sf;function Vx(n){return typeof n=="string"?n:(Sf||(Sf=new wf),Sf.load(n))}var ju=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},Uu=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var hs=class extends ju{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.loaded=!1;this.isVideo=!1;this.isCanvas=!1;this.isVideo=e.type==="video",this.isCanvas=e.nodeName==="CANVAS",this.updateSrc(this.isCanvas?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let r=()=>{this.loaded=!0;let i=[1e3,1001,1002];for(let a of i){let s=this[a];s&&(s.image=this.img,s.needsUpdate=!0)}this.shared.requestRender()};if(this.isCanvas)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var o=new FileReader;o.readAsDataURL(new Blob([e],{type:"video/mp4"}));let i;await new Promise(a=>{o.onloadend=s=>{i=s.target?.result,a(null)}}),this.img.src=i}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else this.img=new Image,this.img.src=Vx(e),this.img.onload=r}getTexture(e){let r=this[e];if(r)return r;{let o;return this.isCanvas&&(o=new ms.CanvasTexture(this.img,void 0,e,e)),this.isVideo?o=new ms.VideoTexture(this.img,void 0,e,e):o=new ms.Texture(this.img,void 0,e,e),this.loaded&&(o.needsUpdate=!0),this[e]=o,o}}setNeedsUpdate(e){let r=[1e3,1001,1002];for(let o of r){let i=this[o];i&&(i.needsUpdate=e)}}disposeTextures(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}dispose(){super.dispose(),this.disposeTextures()}};1e3,1001,1002;var Nr=class extends hs{};var at=require("three");function Jt(n,t){return t.color(n)}function zx(n,t){switch(n.type){case"fresnel":return yT(n,t);case"gradient":return gT(n,t);case"depth":return xT(n,t);case"normal":return bT(n,t);case"noise":return vT(n,t);case"rainbow":return ST(n,t);case"toon":return wT(n,t);case"outline":return _T(n,t);case"transmission":return AT(n,t);case"color":return mT(n,t);case"pattern":return PT(n,t)}}function hT(n){return{type:n.type}}function fo(n,t){let{alpha:e,mode:r,isMask:o}=n,i=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...hT(n),alpha:i,mode:r,isMask:o}}function mT(n,t){return{...fo(n,t),color:Jt(n.color,t)}}function yT(n,t){let{bias:e,scale:r,intensity:o,factor:i,color:a}=n;return{...fo(n,t),color:Jt(a,t),bias:e,scale:r,intensity:o,factor:i}}function gT(n,t){let{gradientType:e,smooth:r,colors:o,steps:i,angle:a,offset:s,morph:l}=n;return{...fo(n,t),gradientType:e,smooth:r,colors:o.map(u=>new at.Vector4(u[0],u[1],u[2],u[3])),num:o.length,steps:i,offset:new at.Vector2(...s),morph:new at.Vector2(...l),angle:a}}function xT(n,t){let{gradientType:e,near:r,far:o,isVector:i,isWorldSpace:a,origin:s,direction:l,colors:u,steps:c,smooth:d}=n;return{...fo(n,t),gradientType:e,near:r,far:o,isVector:i,isWorldSpace:a,origin:new at.Vector3(...s),direction:l?new at.Vector3(...l):new at.Vector3(1,0,0),colors:u.map(p=>p!==void 0?new at.Vector4(p[0],p[1],p[2],p[3]):new at.Vector4(0,0,0,0)),steps:c.slice(0,u.length),smooth:d}}function bT(n,t){let{cnormal:e}=n;return{...fo(n,t),cnormal:new at.Vector3(e[0],e[1],e[2])}}function vT(n,t){return{...fo(n,t),scale:n.scale,move:n.move,fA:new at.Vector2(...n.fA),fB:new at.Vector2(...n.fB),size:new at.Vector3(...n.size),distortion:new at.Vector2(...n.distortion),colorA:Jt(n.colorA,t),colorB:Jt(n.colorB,t),colorC:Jt(n.colorC,t),colorD:Jt(n.colorD,t),noiseType:n.noiseType,voronoiStyle:n.voronoiStyle,highCut:n.highCut,lowCut:n.lowCut,smoothness:n.smoothness,seed:n.seed,quality:n.quality}}function ST(n,t){return{...fo(n,t),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new at.Vector3(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new at.Vector3(...n.offset)}}function wT(n,t){return{...fo(n,t),positioning:n.positioning,colors:n.colors.map(e=>new at.Vector4(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new at.Vector3(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:Jt(n.shadowColor,t),offset:new at.Vector3(...n.offset)}}function _T(n,t){return{...fo(n,t),outlineColor:Jt(n.outlineColor,t),contourColor:Jt(n.contourColor,t),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new at.Vector3(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function AT(n,t){return{...fo(n,t),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function PT(n,t){return{...fo(n,t),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new at.Vector2(...n.offset),colorA:Jt(n.colorA,t),colorB:Jt(n.colorB,t),frequency:new at.Vector2(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new at.Vector2(...n.vertical),horizontal:new at.Vector2(...n.horizontal),sides:n.sides}}var Un=class extends Rt{};var Gx=require("three");var _f={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},Af={depth:["colors"]};function OT(n,t,e){if(t==="isMask")return!0;let r=_f[n.type],o=Af[n.type];if(o!==void 0){let i=n.color;if(o.includes(t)){let a=i[t]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return r!==void 0?r.includes(t):!1}function Pf(n,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let o=!1,i=n;if("image"in i){let a=i.image,s=t.image(a),l=r;l.image instanceof Nr||l.image.deref(),l.image=s}if("video"in i){let a=i.video,s=t.video(a),l=r;l.image instanceof Nr||l.image.deref(),l.image=s}if("wrapping"in i){let a=r;a.wrap=i.wrapping}if("repeat"in i||"offset"in i){let a="mat",s=e.uniforms[`f${e.id}_${a}`];"repeat"in i&&(s.repeat=i.repeat),"offset"in i&&(s.offset=i.offset),s.updateMatrix()}return o}function kx(n,t,e,r){let o=!1;for(let[i,a]of Object.entries(n)){if(i==="bumpMap"||i==="roughnessMap"){o=!0;continue}if(!i||a===void 0)continue;if(Of(i,e,r,t)){i==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=r.visible;let s=e.uniforms[`f${e.id}_${i}`];if(!!s&&!(s instanceof Fn))switch(o=o||OT(e,i,a),s.constructor){case qe:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Un?s.value=new Rt(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case xr:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Un?s.value=new Rt(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case mt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case Kt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case lr:{Pf(a,t,e);break}case po:{s.value=a.map(l=>new Gx.Vector4(...l));break}default:{s.value=a;break}}}return o}var Hn=(n,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof n=="number"?n*100:n,e)??100)/100))??1,Eo=class{constructor(t,e,r,o,i){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in r)Of(a,this,r,i)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return cr.createLigherLayer(t,e,r,o);if(r.type==="texture"||r.type==="video"){let i=r.type==="texture"?o.canvas(r.texture.image)??o.image(r.texture.image):o.video(r.texture.video),a=new bi(i,r.texture.wrapping),s=new zu(i),l=new Gu(r.texture.repeat,r.texture.offset),u=new J(r.crop?1:0),c=new Ie(r.projection??0),d=new Ie(["x","y","z"].indexOf(r.axis)??0),p=new Ie(r.side??0),f=new mt(r.size?new Qe.Vector2(r.size[0],r.size[1]):new Qe.Vector2(100,100)),h=new J(r.blending??0),m=new J(Hn(r.alpha,o)),y=new Ie(r.mode??0),g=new wt(r.isMask??!1),b=new jn(a,s,u,c,d,p,f,h,l,m,y,g),S=new Ue(b.calpha,"f");return new ct(t,e,r,{texture:a,textureSize:s,crop:u,projection:c,axis:d,side:p,size:f,blending:h,mat:l,alpha:m,mode:y,isMask:g},b,y,S,g,o)}else if(r.type==="matcap"){let i=o.image(r.texture.image),a=new bi(i,r.texture.wrapping),s=new J(Hn(r.alpha,o)),l=new Ie(r.mode??0),u=new wt(r.isMask??!1),c=new is(a,s,l,u),d=new Ue(c.calpha,"f");return new ct(t,e,r,{texture:a,alpha:s,mode:l,isMask:u},c,l,d,u,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let i=new Kt(new Qe.Vector3(...r.offset)),a=new J(r.scale??10),s=new J(r.intensity??8),l=new J(r.movement??1),u=new Ie(r.noiseType??0),c=new Ie(r.voronoiStyle??0),d=new J(r.smoothness??.5),p=new J(r.seed??0),f=new J(r.highCut??1),h=new J(r.lowCut??0),m=new Ie(r.quality??1),y=new ps(s,l,i,c,d,p,f,h,m,a,u);return new El(t,e,r,{offset:i,scale:a,intensity:s,movement:l,noiseType:u,voronoiStyle:c,smoothness:d,seed:p,highCut:f,lowCut:h,quality:m},y,o)}else throw new Error;else return MT(t,e,r,o)}updateByOp(t,e,r){let o=t;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props?(r.scene.markNeedsUpdateRendererDirty(),!0):kx(o.props,r.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Pf(o.props,r.shared,this):!0;return!1}dispose(){if(CT(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof Nr||e.image.deref()}}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}},ct=class extends Eo{constructor(e,r,o,i,a,s,l,u,c){super(e,r,o,i,c);this.params=i;this.color=a;this.mode=s;this.alpha=l;this.isMask=u}},El=class extends Eo{constructor(e,r,o,i,a,s){super(e,r,o,i,s);this.position=a}},cr=class extends Eo{constructor(e,r,o,i,a,s){super(e,r,o,a,s);this.node=i}static createLigherLayer(e,r,o,i){let a,s=new J(Hn(o.alpha,i)),l=new Ie(o.mode),u=new J(o.bumpMapIntensity),c=new J(Hn(o.alphaOverride,i)),d;if(!o.visible)a=new ln,d={};else if(o.category==="lambert"){a=new Cl;let p=new qe(i.color(o.emissive)??0),f=new wt(o.occlusion??!0);d={emissive:p,occlusion:f},a.emissive=p,a.occlusion=f}else if(o.category==="toon"){a=new Dl;let p=new J(o.shininess??30),f=new qe(i.color(o.specular)??1118481);d={shininess:p,specular:f},a.shininess=p,a.specular=f}else if(o.category==="physical"){a=new Il;let p=new J(o.roughness??.3),f=new J(o.metalness??0),h=new J(o.reflectivity??.5),m=new wt(o.occlusion??!0);d={roughness:p,metalness:f,reflectivity:h,occlusion:m},a.roughness=p,a.metalness=f,a.reflectivity=h,a.occlusion=m}else{a=new Ml;let p=new J(o.shininess??30),f=new qe(o.specular!==void 0?i.color(o.specular)??1118481:1118481),h=new wt(o.occlusion??!0);d={shininess:p,specular:f,occlusion:h},a.shininess=p,a.specular=f,a.occlusion=h}return a.alpha=new J(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=u,a.alphaOverride=c,d.alpha=a.shadingAlpha,d.mode=a.shadingBlend,d.bumpMapIntensity=a.bumpMapIntensity,d.alphaOverride=a.alphaOverride,new cr(e,r,o,a,d,i)}get category(){return this.node.category}};function CT(n){let t=n instanceof Eo?n.type:n;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function kr(n){return{alpha:new J(n.alpha??1),mode:new Ie(n.mode??0),isMask:new wt(n.isMask??!1)}}function TT(n,t,e,r,o){switch(n.type){case"color":{let i=new qe(r.color??Ot),a=kr(r),s=new vi(i,a.alpha),l=new Ue(s.calpha,"f");return new ct(t,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let i=new qe(r.color??16777215),a=new J(r.bias??.1),s=new J(r.scale??1),l=new J(r.intensity??2),u=new J(r.factor??1),c=kr(r),d=new Al(i,a,s,l,u,c.alpha,c.mode,c.isMask),p=new Ue(d.calpha,"f");return new ct(t,e,n,{color:i,bias:a,scale:s,intensity:l,factor:u,...c},d,c.mode,p,c.isMask,o)}case"rainbow":{let i=new J(r.filmThickness??30),a=new J(r.movement??0),s=new Kt(r.wavelengths??new Qe.Vector3(0,0,0)),l=new J(r.noiseStrength??0),u=new J(r.noiseScale??1),c=new Kt(r.offset??new Qe.Vector3(0,0,0)),d=kr(r),p=new cs(i,a,s,l,u,c,d.alpha,d.isMask),f=new Ue(p.calpha,"f");return new ct(t,e,n,{filmThickness:i,movement:a,wavelengths:s,noiseStrength:l,noiseScale:u,offset:c,...d},p,d.mode,f,d.isMask,o)}case"transmission":{let i=new J(r.thickness??10),a=new J(r.ior??1.5),s=new J(r.roughness??.5),l=Pe.transmissionSize,u=Pe.transmissionRenderTarget,c=Pe.transmissionRenderTargetDepth,d=window.innerWidth,p=window.innerHeight,f=d>=p?new mt(p/d,1):new mt(1,d/p),h=kr(r),m=new ds(i,a,s,l,u,c,f,h.alpha),y=new Ue(m.calpha,"f");return new ct(t,e,n,{thickness:i,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let i=new Ie(r.positioning??0),a;r.colors?a=new po(r.colors.length,r.colors):(a=new po(10,new Qe.Vector4(0,0,0,1)),a.value[1]=new Qe.Vector4(1,1,1,1));let s;r.steps?s=new uo(r.steps.length,r.steps):(s=new uo(10,1),s.value[0]=0);let l=new Kt(r.source??new Qe.Vector3(0,0,0)),u=new wt(r.isWorldSpace??!0),c=new J(r.noiseStrength??0),d=new J(r.noiseScale??1),p=new xr(r.shadowColor),f=new Kt(r.offset??new Qe.Vector3(0,0,0)),h=kr(r),m=new us(i,a,s,l,u,c,d,p,f,h.alpha),y=new Ue(m.calpha,"f");return new ct(t,e,n,{positioning:i,colors:a,steps:s,source:l,isWorldSpace:u,noiseStrength:c,noiseScale:d,shadowColor:p,offset:f,...h},m,h.mode,y,h.isMask,o)}case"outline":{let i=new qe(r.outlineColor??16777215),a=new qe(r.contourColor??16777215),s=new J(r.outlineWidth??.1),l=new J(r.contourWidth??.1),u=new J(r.outlineThreshold??.1),c=new J(r.contourThreshold??.1),d=new J(r.outlineSmoothing??.1),p=new J(r.contourFrequency??.1),f=new Kt(r.contourDirection??new Qe.Vector3(0,1,0)),h=new wt(r.positionalLines??!1),m=new wt(r.compensation??!0),y=Pe.normalRenderTarget,g=Pe.normalRenderTargetDepth,b=Pe.pixelRatioNode,S=Pe.resolution,w=kr(r),v=new ss(i,a,s,l,u,c,d,p,f,h,m,S,y,g,b,w.alpha),_=new Ue(v.calpha,"f");return new ct(t,e,n,{outlineColor:i,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:u,contourThreshold:c,outlineSmoothing:d,contourFrequency:p,contourDirection:f,positionalLines:h,compensation:m,...w},v,w.mode,_,w.isMask,o)}case"depth":{let i=new Ie(r.gradientType??0),a=new wt(r.smooth??!1),s=new J(r.near??50),l=new J(r.far??200),u=new J(r.isVector??1),c=new J(r.isWorldSpace??0),d=new Kt(r.origin??new Qe.Vector3),p=new Kt(r.direction??new Qe.Vector3),f;r.colors?f=new po(r.colors.length,r.colors):(f=new po(2,new Qe.Vector4(0,0,0,1)),f.value[1]=new Qe.Vector4(1,1,1,1));let h;r.steps?h=new uo(r.steps.length,r.steps):(h=new uo(2,1),h.value[0]=0);let m=kr(r),y=new os(i,a,s,l,u,c,d,p,f,h,m.alpha,m.isMask),g=new Ue(y.calpha,"f");return new ct(t,e,n,{gradientType:i,smooth:a,near:s,far:l,isVector:u,isWorldSpace:c,origin:d,direction:p,colors:f,steps:h,...m},y,m.mode,g,m.isMask,o)}case"noise":{let i=new J(r.scale??1),a=new Kt(r.size??new Qe.Vector3(100,100,100)),s=new J(r.move??1),l=new mt(r.fA??new Qe.Vector2(1.7,9.2)),u=new mt(r.fB??new Qe.Vector2(8.3,2.8)),c=new mt(r.distortion??new Qe.Vector2(1,1)),d=new xr(r.colorA),p=new xr(r.colorB),f=new xr(r.colorC),h=new xr(r.colorD),m=new Ie(r.noiseType??0),y=new Ie(r.voronoiStyle??0),g=new J(r.highCut??1),b=new J(r.lowCut??0),S=new J(r.smoothness??.5),w=new J(r.seed??.5),v=new Ie(r.quality??1),_=kr(r),A=new as(i,a,s,l,u,c,d,p,f,h,_.alpha,m,_.isMask,y,g,b,S,w,v),x=new Ue(A.calpha,"f");return new ct(t,e,n,{scale:i,size:a,move:s,fA:l,fB:u,distortion:c,colorA:d,colorB:p,colorC:f,colorD:h,noiseType:m,..._,voronoiStyle:y,highCut:g,lowCut:b,smoothness:S,seed:w,quality:v},A,_.mode,x,_.isMask,o)}case"normal":{let i=new Kt(r.cnormal??new Qe.Vector3(1,1,1)),a=kr(r),s=new es(i,a.alpha),l=new Ue(s.calpha,"f");return new ct(t,e,n,{cnormal:i,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let i=new Ie(r.gradientType??0),a=new wt(r.smooth??!1),s;r.colors?s=new po(r.colors.length,r.colors):(s=new po(10,new Qe.Vector4(0,0,0,1)),s.value[1]=new Qe.Vector4(1,1,1,1));let l;r.steps?l=new uo(r.steps.length,r.steps):(l=new uo(10,1),l.value[0]=0);let u=new mt(r.offset??new Qe.Vector2(0,0)),c=new mt(r.morph??new Qe.Vector2(0,0)),d=new J(r.angle??0),p=kr(r),f=new ns(i,a,s,l,u,c,d,p.alpha,p.isMask),h=new Ue(f.calpha,"f");return new ct(t,e,n,{gradientType:i,smooth:a,colors:s,steps:l,offset:u,morph:c,angle:d,...p},f,p.mode,h,p.isMask,o)}case"pattern":{let i=new Ie(r.style??0),a=new Ie(r.projection??0),s=new Ie(["x","y","z"].indexOf(r.axis)??0),l=new J(r.blending??0),u=new mt(r.offset??new Qe.Vector2(0,0)),c=new xr(r.colorA),d=new xr(r.colorB),p=new mt(r.frequency??new Qe.Vector2(10,10)),f=new J(r.size??.5),h=new J(r.variation??0),m=new J(r.smoothness??.5),y=new J(r.zigzag??0),g=new J(r.rotation??0),b=new mt(r.vertical??new Qe.Vector2(0,1)),S=new mt(r.horizontal??new Qe.Vector2(0,1)),w=new Ie(r.sides??6),v=kr(r),_=new ls(i,a,s,l,u,c,d,p,f,h,m,y,g,b,S,w,v.alpha,v.isMask),A=new Ue(_.calpha,"f");return new ct(t,e,n,{style:i,projection:a,axis:s,blending:l,offset:u,colorA:c,colorB:d,frequency:p,size:f,variation:h,smoothness:m,zigzag:y,rotation:g,vertical:b,horizontal:S,sides:w,...v},_,v.mode,A,v.isMask,o)}default:{let i=new qe(1,0,0,1),a=kr(r),s=new vi(i,a.alpha),l=new Ue(s.calpha,"f");return new ct(t,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}}}function MT(n,t,e,r){let o=zx(e,r);return TT(e,n,t,o,r)}function Of(n,t,e,r){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let o=t.uniforms[`f${t.id}_intensity`];return o?(o.value=e.intensity*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="visible")){let o=t.uniforms[`f${t.id}_alpha`];if(!o)return;if(o.value=Hn(e.alpha,r)*(e.visible?1:0),e.type==="outline"&&n==="visible"){let i=t.uniforms[`f${t.id}_compensation`];i&&(i.value=e.compensation&&e.visible)}return o}}function Hu(n,t){let e=0,r=n.layers.find(o=>o.data.type==="light");if(r){let o=r.data,i=Number(t.getVariable(o.alphaOverride));if((typeof o.alphaOverride=="string"?i/100:o.alphaOverride)<1)return!0}for(let o of n.layers){if(o.data.type!=="displace"&&o.data.isMask)return!0;if(o.data.type!=="displace"&&"alpha"in o.data&&o.data.type!=="light"&&o.data.type!=="fresnel"&&o.data.type!=="texture"&&o.data.type!=="matcap"&&o.data.type!=="rainbow"&&o.data.type!=="outline"&&o.data.type!=="pattern"){let i=o.data.visible?o.data.alpha:0;if(typeof i=="string"&&(i=Math.max(0,Math.min(1,Number(t.getVariable(i)??100)/100))),i===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let a of o.data.colors)if(a[3]<1){i=a[3];break}}else if(i===1&&o.data.type==="noise"){let a=t.color(o.data.colorA).a,s=t.color(o.data.colorB).a,l=t.color(o.data.colorC).a,u=t.color(o.data.colorD).a,c=Math.min(a,Math.min(s,Math.min(l,u)));c<1&&(i=c)}e+=(1-e)*i}}return e<1}var vr=class extends Fx.ShaderMaterial{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},qu=class extends vr{constructor(e,r,o,i){super();this.flatShading=e;this.side=r;this.wireframe=o;this.root=i}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,r){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,r,o){return this.root.getFlavor(e,r,o)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,r,o){this.root.updateByOp(e,r,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},wi=class extends vr{constructor(e,r,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.reset0(e,r)}get nodeMaterial(){return this}getFlavor(e,r,o){let i=o?6:(e?3:0)+r;if(i===0)return this;this.flavors===void 0&&(this.flavors=[]),i-=1;let a=this.flavors[i];return a===void 0&&(a=new qu(e,r,o,this),this.flavors[i]=a,a.flatShading=e,a.side=r,a.updateAfterBuild()),a}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,r,o=!1){(this.data!==e||o)&&this.reset0(e,r)}reset0(e,r){this.data=e;let o=e.layers??Qt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(i=>Eo.create(this.layerIdGen++,i.id,i.data,r.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r.shared),this.transparent=Hu(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=Hu(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(r)/100,1)));else if(e[0]==="layer"){let i=e[1],a=e[2];if(i&&a){let s=this.layers.find(l=>l.uuid===i);s?.hasValue(a)&&(a==="alpha"?(this.transparent=Hu(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(r)/100,1)))):s.setValue(a,r))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let r=this.data.layers.find(o=>o.data.type==="light");r&&e.shared.getVariable(r.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(o=>{"alpha"in o.data&&typeof o.data.alpha=="string"&&e.shared.getVariable(o.data.alpha,["material",this.uuid,"layer",o.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(r=>r instanceof cr),this.lightLayer===void 0&&(this.lightLayer=new cr(0,"",{...Mt.defaultData("light","phong"),visible:!1},new ln,{},e)),this.dispose();for(let r of this.flavors)r&&r.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(a=>a instanceof cr);if(!e)return;let r=e.data,o=r.bumpMap,i=r.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let a=0;a<this.layers.length;++a){let s=this.layers[a];s instanceof ct&&s.color instanceof jn&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===i&&(e.node.roughnessMap=s.color))}}updateByOp(e,r,o){if(r!==void 0?this.data=r:r=this.data,this.transparent=Hu(r,o.shared),e.path[0]==="layers"){this.data=r;let i=o.shared,a=e.path[1];if(a===void 0){if(this.layers.reverse(),e.type===4){let s=Eo.create(this.layerIdGen++,e.id,e.data,o.shared);this.layers.splice(e.localIndex,0,s),o.scene.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),o.scene.markNeedsUpdateRendererDirty();else if(e.type===6){let s=this.layers.findIndex(u=>u.uuid===e.id),l=this.layers[s];this.layers.splice(s,1),this.layers.splice(e.localIndex,0,l),o.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate(o.shared)}else{e.type===0&&e.props.occlusion!==void 0&&o.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(l=>l.uuid===a);if(s){let l=r.layers.data(a),u;if(e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?u={...e.props,alpha:Hn(e.props.alpha,i,["material",this.uuid,"layer",a,"alpha"])}:u={...e.props,alphaOverride:Hn(e.props.alphaOverride,i,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...u?{props:u}:{},path:e.path.slice(2)},l,o)){let d=Eo.create(this.layerIdGen++,a,l,i);this.layers.splice(this.layers.findIndex(p=>p.uuid===a),1,d),this.onUpdate(o.shared)}}}}else this.reset(r,o)}applyMasks(){for(let e=0;e<this.layers.length;++e){let r=this.layers[e];r instanceof ct?r.color.mask=void 0:r instanceof cr&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof ct&&r.isMask.value&&r.data.visible&&e>0){let o=e-1,i=this.layers[o];i instanceof cr?i.node.mask=new qt(r.color,r.alpha,qt.MUL):i instanceof ct&&(i.isMask.value||(i.color.mask=new qt(r.color,r.alpha,qt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof ct),r=this.layers.findIndex(o=>o instanceof cr);if(e!==-1&&e<r){let o=this.layers[e].color;for(let i=e+1;i<r;++i){let a=this.layers[i];if(a instanceof ct){if(a.isMask.value)continue;o=new Ja(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Ue("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof cr);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let i=this.layers[o];if(i instanceof ct){if(i.isMask.value)continue;e=new Ja(e,i.color,i.alpha,i.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof El);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new qt(r,e[o].position,qt.ADD),r=new qt(r,new J(.5).setReadonly(!0),qt.MUL));this.fragment.position=r}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.build(),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}clampUniformsForPreview(e,r){let o=(i,a,s)=>Math.min(Math.max(i,a),s);for(let i of this.layers)if(i.type==="displace"){let a=o(i.uniforms[`f${i.id}_intensity`].value,e,r);i.uniforms[`f${i.id}_intensity`].value=a}}computeCacheKey(){let e="[";for(let{data:r}of this.data.layers)if(r.type==="light")e+=`"${r.visible?r.category.toUpperCase():"Basic"}"`;else{let o=(_f[r.type]??[]).map(u=>r[u]),i=(Af[r.type]??[]).map(u=>r[u]?.length??0),a=[...o,...i],s="isMask"in r&&r.isMask,l=`"${r.type}-${r.visible}-${s}"`;a.length?e+=`[${l}, "${a.join('","')}"],`:e+=l}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(){let e=new Ka;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let r of this.flavors)r&&r.updateAfterBuild();return this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof ct){let r=e.params.texture;if(r instanceof bi&&!r.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(vr.prototype,{properties:{get:function(){return this.fragment.properties}}});var _i=class extends wi{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var qx=nr(jx());var Ux=new Map;function Hx(n){if(typeof n=="string")return n;let t=Ux.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},Ux.set(n,t)),t.url}var Ai=class{constructor({src:t,volume:e,delay:r,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let i;typeof t=="string"?i={src:t}:i={src:Hx(t),format:"wav"},this.sound=new qx.Howl(i),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var Vt=require("three"),$u=class{constructor(){this.type="ShapePath";this.color=new Vt.Color;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new Vt.Path,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,r,o){return this.currentPath?.quadraticCurveTo(t,e,r,o),this}bezierCurveTo(t,e,r,o,i,a){return this.currentPath?.bezierCurveTo(t,e,r,o,i,a),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},r={loc:e.ORIGIN,t:0};function o(m,y,g,b){let S=m.x,w=y.x,v=g.x,_=b.x,A=m.y,x=y.y,T=g.y,C=b.y,P=(_-v)*(A-T)-(C-T)*(S-v),O=(w-S)*(A-T)-(x-A)*(S-v),M=(C-T)*(w-S)-(_-v)*(x-A),I=P/M,N=O/M;if(M===0&&P!==0||I<=0||I>=1||N<0||N>1)return null;if(P===0&&M===0){for(let B=0;B<2;B++)if(i(B===0?g:b,m,y),r.loc===e.ORIGIN){let D=B===0?g:b;return{x:D.x,y:D.y,t:r.t}}else if(r.loc===e.BETWEEN){let D=+(S+r.t*(w-S)).toPrecision(10),G=+(A+r.t*(x-A)).toPrecision(10);return{x:D,y:G,t:r.t}}return null}else{for(let G=0;G<2;G++)if(i(G===0?g:b,m,y),r.loc===e.ORIGIN){let L=G===0?g:b;return{x:L.x,y:L.y,t:r.t}}let B=+(S+I*(w-S)).toPrecision(10),D=+(A+I*(x-A)).toPrecision(10);return{x:B,y:D,t:I}}}function i(m,y,g){let b=g.x-y.x,S=g.y-y.y,w=m.x-y.x,v=m.y-y.y,_=b*v-w*S;if(m.x===y.x&&m.y===y.y){r.loc=e.ORIGIN,r.t=0;return}if(m.x===g.x&&m.y===g.y){r.loc=e.DESTINATION,r.t=1;return}if(_<-Number.EPSILON){r.loc=e.LEFT;return}if(_>Number.EPSILON){r.loc=e.RIGHT;return}if(b*w<0||S*v<0){r.loc=e.BEHIND;return}if(Math.sqrt(b*b+S*S)<Math.sqrt(w*w+v*v)){r.loc=e.BEYOND;return}let A;b!==0?A=w/b:A=v/S,r.loc=e.BETWEEN,r.t=A}function a(m,y){let g=[],b=[];for(let S=1;S<m.length;S++){let w=m[S-1],v=m[S];for(let _=1;_<y.length;_++){let A=y[_-1],x=y[_],T=o(w,v,A,x);T!==null&&g.find(C=>C.t<=T.t+Number.EPSILON&&C.t>=T.t-Number.EPSILON)===void 0&&(g.push(T),b.push(new Vt.Vector2(T.x,T.y)))}}return b}function s(m,y,g){let b=new Vt.Vector2;y.getCenter(b);let S=[];return g.forEach(w=>{w.boundingBox.containsPoint(b)&&a(m,w.points).forEach(_=>{S.push({identifier:w.identifier,isCW:w.isCW,point:_})})}),S.sort((w,v)=>w.point.x-v.point.x),S}function l(m,y,g,b,S){(S==null||S==="")&&(S="nonzero");let w=new Vt.Vector2;m.boundingBox.getCenter(w);let v=[new Vt.Vector2(g,w.y),new Vt.Vector2(b,w.y)],_=s(v,m.boundingBox,y);_.sort((O,M)=>O.point.x-M.point.x);let A=[],x=[];_.forEach(O=>{O.identifier===m.identifier?A.push(O):x.push(O)});let T=A[0].point.x,C=[],P=0;for(;P<x.length&&x[P].point.x<T;)C.length>0&&C[C.length-1]===x[P].identifier?C.pop():C.push(x[P].identifier),P++;if(C.push(m.identifier),S==="evenodd"){let O=C.length%2===0,M=C[C.length-2];return{identifier:m.identifier,isHole:O,for:M}}else if(S==="nonzero"){let O=!0,M=null,I=null;for(let N=0;N<C.length;N++){let B=C[N];y[B]&&(O?(I=y[B].isCW,O=!1,M=B):I!==y[B].isCW&&(I=y[B].isCW,O=!0))}return{identifier:m.identifier,isHole:O,for:M}}else console.warn('fill-rule: "'+S+'" is currently not implemented.')}let u=0,c=999999999,d=-999999999,p=[];this.subPaths.forEach(m=>{let y=m.getPoints(),g=-999999999,b=999999999,S=-999999999,w=999999999;for(let v=0;v<y.length;v++){let _=y[v];_.y>g&&(g=_.y),_.y<b&&(b=_.y),_.x>S&&(S=_.x),_.x<w&&(w=_.x)}d<=S&&(d=S+1),c>=w&&(c=w-1),y.length&&p.push({curves:m.curves,points:y,isCW:Vt.ShapeUtils.isClockWise(y),identifier:u++,boundingBox:new Vt.Box2(new Vt.Vector2(w,b),new Vt.Vector2(S,g))})});let f=p.map(m=>l(m,p,c,d,this.userData?.style.fillRule)),h=[];return p.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let g=new Vt.Shape;g.curves=m.curves,f.filter(S=>S?.isHole&&S.for===m.identifier).forEach(S=>{if(S){let w=p[S.identifier],v=new Vt.Path;v.curves=w.curves,g.holes.push(v)}}),h.push(g)}}),h}};var Cf=!1,$x,Tf=new Promise(n=>{$x=n}),Wx=!1;var Yu;function Yx(){if(Cf=!0,Wx)return;if(Yu)return Yu;async function n(){let e=await import("./opentype.js");$x(e),Wx=!0}return Yu=n(),Yu}var Bl=class{async load(t,e,r=()=>{}){let{load:o}=await Tf;o(t,(i,a)=>{i||!a?r(i??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await Tf;try{let o=e(t),i=new r,a=s=>o.charToGlyphIndex(s.char);return i.registerModifier("glyphIndex",null,a),i.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:i}}catch(o){console.error(o)}}};async function IT(n){return await(await fetch(n)).arrayBuffer()}var NT=new Bl;async function Mf(n){let t,e,r=!1;if(n.url?(t=await IT(n.url),e=n.url,r=n.url.startsWith("/")):n.data&&(t=n.data.buffer.slice(n.data.byteOffset,n.data.byteOffset+n.data.byteLength)),t)if(Cf){let o=await NT.parse(t);if(o)return{font:o.font,url:e,intercepted:r,arr:t,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:r,arr:t,bidi:null}}var ys=require("three");function DT(n,t){return t.state.glyphIndex===n||t.state.fina===n||t.state.medi===n||t.state.init===n}var Xu=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=Mf(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=Mf(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,r){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let i=o.tokenizer.tokens,a=[],s=0,l=r.length===i.length;for(let u=0;u<r.length;u++){let c=r[u].index,d=String.fromCharCode(r[u].unicode),p=i[s];if(DT(c,p)||l)a.push({char:d,index:c,replacements:[p.state.glyphIndex],replacementChars:[p.char]}),s++;else{let f=p.char,h="",m=[p.state.glyphIndex],y=[],g=!1;for(;!g;)s++,h=e.charAt(s),f+=h,m.push(t.charToGlyphIndex(h)),y=t.stringToGlyphs(f),y.length===1&&y[0].index===c&&(g=!0),s>e.length&&(g=!0);a.push({char:d,index:c,replacements:m,replacementChars:Array.from(f)}),s++}}return a}generateShapes(t,e){if(!this._isLoaded)return;let r=this.font,o=e.fontSize/this.unitsPerEm,i=e.fontSize*e.lineHeight,a=t.map(b=>this.getTextWidth(b,e)),s=e.width,l=this.getCharWidth(`
2237
- `,e),u=e.horizontalAlign===1?l:0,c=this.computeSpaceWidthForLine(t,0,e),d=this.getLineInitialOffsetX(a[0],s,e.horizontalAlign,t[0],l),p=this.getLineInitialOffsetY(i,t.length,e.height,o,e.verticalAlign),f=[],h=t.map(b=>[]),m=t.map(b=>[]),y;for(let b=0;b<t.length;b++){let S=t[b],w={features:{liga:!0}},v=[];try{v=r.stringToGlyphs(S,w)}catch(A){console.warn(A)}d=this.getLineInitialOffsetX(a[b],s,e.horizontalAlign,S,l);let _=[];try{_=this.reverseLigaturesTable(r,S,v)}catch(A){console.warn(A)}c=this.computeSpaceWidthForLine(t,b,e);for(let A=0;A<v.length;A++){let x=v[A],T=x.index===0?`
2238
- `:x.unicode?String.fromCharCode(x.unicode):void 0,C=_[A],P=0,O=0;A===0&&e.horizontalAlign===2&&x.leftSideBearing!==void 0&&(O=-x.leftSideBearing*o),y&&(P=r.getKerningValue(x,y)*o),d+=O+P;let M=0;if(T===`
2239
- `)M=u;else if(T===" ")M=c;else{let I=this.createPath(x,o,d,p,e);I&&(M=I.offsetX-(P+O),f.push(I.path))}if(C.replacements.length===1)m[b].push([d,p]),h[b].push(M);else{let I=C.replacements.map(G=>(r.glyphs.get(G).advanceWidth??0)*o),N=I.reduce((G,L)=>G+=L,0),B=I.map(G=>G/N),D=d;for(let G=0;G<B.length;G++){let L=M*B[G];m[b].push([D,p]),h[b].push(L),D+=L}}d+=M,y=x}p-=i}let g=[];for(let b=0,S=f.length;b<S;b++)g.push(...f[b].toShapes());return{shapes:g,charWidths:h,lineWidths:a,charCoords:m}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,r,o,i){return(r===3||r===2)&&o.indexOf(`
2240
- `)>=0&&(t-=i),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,o,i){let a=e*t,s=Math.abs(this.ascender-this.descender)*o,l=t-s,u=-this.ascender*o-l/2;return i===3?-(r-a-u):i===2?-(r*.5-a*.5-u):u}createPath(t,e,r,o,i){let a=t.getPath(r,-o,i.fontSize,{kerning:!1,letterSpacing:i.letterSpacing});if(!a){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let s=new $u,l=(t.advanceWidth??1)*e;if(t)for(let u of a.commands){let c=s.currentPath?.currentPoint;if(!(c&&u.type!=="Z"&&c.x===u.x&&-c.y===u.y))switch(u.type){case"M":s.moveTo(u.x,-u.y);break;case"L":s.lineTo(u.x,-u.y);break;case"Q":s.quadraticCurveTo(u.x1,-u.y1,u.x,-u.y);break;case"C":s.bezierCurveTo(u.x1,-u.y1,u.x2,-u.y2,u.x,-u.y);break}}return s.subPaths.forEach(u=>{let c=ET(u.curves);c!==void 0&&u.currentPoint.distanceTo(c)>0&&u.lineTo(c.x,c.y)}),{offsetX:l+i.fontSize*i.letterSpacing,path:s}}getCharWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(t,e,r){let o=this.getCharWidth(" ",r),i=t[e];if(i){let a=this.countSpaces(i.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&a){let s=r.width,l=this.getTextWidth(i,r);return(s-(l-a*o))/a}}return o}countSpaces(t){return(t.match(/ /g)||[]).length}};function ET(n){if(n.length){let t=n[0];if(t instanceof ys.LineCurve)return t.v1;if(t instanceof ys.CubicBezierCurve||t instanceof ys.QuadraticBezierCurve)return t.v0}}var If=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let o=this.objects.get(t);return o===void 0?(o=this.createObject(t,e,r),this.objects.set(t,o)):o.isShared=!0,o}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},Ll=class extends If{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,o){let i=sn(e,r,this.flatShading,o);return i.computeBoundingSphere(),i}};var Xx={markNeedsUpdateRendererDirty:()=>{}};var Nf=require("three"),Df=class extends Uu{constructor(e){super();this.shared=e}create(e){return new hs(e,this.shared)}},Pi=class{constructor(t,e={}){this.data=t;this.geometryCache=new Ll(!0);this.geometryCache2=new Ll(!1);this.imageHolderCache=new Df(this);this.thisContext={scene:Xx,shared:this};this.deletedMaterial=new _i(Qt.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new Nr(Sa.emptyImage,this);this.deletedVideo=new Nr(fa.defaultVideo,this);this.materials={};this.images={};this.canvases={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.variables={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[r,o]of Object.entries(e.images))this.addImage(r,o);if(e.videos)for(let[r,o]of Object.entries(e.videos))this.addVideo(r,o);if(e.audios)for(let[r,o]of Object.entries(e.audios))this.addAudio(r,o);if(e.particles)for(let[r,o]of Object.entries(e.particles))this.addParticle(r,o);this.reset(t)}setRequestRender(t){this._requestRender=t}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1){this.resetLib(t.lib);for(let{id:r,data:o}of t.variables)this.addVariableHolder(r,o),e&&this.updateVariableHolder(r,o);for(let[r,o]of Object.entries(t.images))this.addImage(r,o);for(let[r,o]of Object.entries(t.videos))this.addVideo(r,o);for(let[r,o]of Object.entries(t.colors))this.addColor(r,o);for(let[r,o]of Object.entries(t.materials))this.addMaterial(r,o);for(let[r,o]of Object.entries(t.audios))this.addAudio(r,o);for(let[r,o]of Object.entries(t.particles))this.addParticle(r,o);for(let[r,o]of Object.entries(t.fonts))this.addFont(r,o)}addMaterial(t,e){if(this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=new _i(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):new wi(t,this.thisContext)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new Nr(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addCanvas(t,e){return this.canvases[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.canvases[t].updateSrc(e),!0):(this.canvases[t]=new Nr(e,this),!1)}canvas(t){return this.canvases[t]}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new Nr(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Un(e.r,e.g,e.b,e.a):this.colors[t]=new Un(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Rt(0,0,0,0))}else return"a"in t?new Rt(t.r,t.g,t.b,t.a):new Rt(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Ai)return e;{let r=new Ai({src:e.data});return this.audios[t]=r,r}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof Ai&&e.dispose(),delete this.audios[t])}addFont(t,e){this.fonts[t]=new Xu(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Ai&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){return this.variables[t]===void 0?(this.variables[t]={value:e.value,locations:[]},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0):(this.variables[t].value=e.value,!1)}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e;let r=e;for(;typeof r=="string";)r=this.variables[r].value;let o=this.entityOpContext.scene;for(let i=this.variables[t].locations.length-1;i>=0;i--){let a=this.variables[t].locations[i];if(a[0]==="material"){let s=a[1],l=r,u={scene:o,shared:this},c=a.slice(2);o.traverseMaterial(p=>{let f=p.root??p;f.uuid===s&&f.onVariableUpdate(c,l,u)});let d=this.materials[s];d&&d.onVariableUpdate(c,l,u)}else{let s=o.find(a[0]);if(s===void 0){this.variables[t].locations.splice(i,1);continue}if(a[1]!=="geometry"&&a[1]!=="particles"){for(let l=1;l<a.length-1;l++)s=s[a[l]];a[1]==="rotation"?s[a[a.length-1]]=r*Nf.MathUtils.DEG2RAD:s[a[a.length-1]]=r}if(s=o.find(a[0]),s.type==="ParticleEmitter"&&s.updateVariableState(r,a),De.is(s)){if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")s.onVariableUpdate();else if(a[1]==="geometry"){let l=s;s.component&&(l=s.component);let u=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(u.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.instances.forEach(c=>{let d=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(d.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0)})}}}}return!0}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];for(let o=1;o<t.length;o++)r=r[t[o]];return t[1]==="rotation"&&(r*=Nf.MathUtils.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let o=this.variables[r],i=o.locations?.findIndex(a=>dt.equal(a,e));i!==void 0&&i!==-1&&o.locations.splice(i,1)}if(typeof t=="string"){let r=t,o=t;do{if(o=r,this.variables[r]===void 0)break;r=this.variables[r].value}while(typeof r=="string");return e&&this.variables[o]!==void 0&&this.variables[o].locations.push(e),r}else return t}getVariables(){return this.variables}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.particles))this.addParticle(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){this.data=e,t.path[0]==="images"?t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(pt.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r}):t.path[0]==="fonts"?t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===2&&t.type===0&&"value"in t.props?this.updateVariable(t.path[1],t.props.value):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id):t.path[0]==="lib"&&this.updateLibByOp(pt.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let o=this.getFont(t),i={...this.data.fonts[t],url:e.props.url};o.update(i),o.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}},Qx=new Pi(zr.emptyData());var Sr=class extends Bt{updateByPatchedOp(e,r,o){if(super.updateByPatchedOp(e,r,o),Fy(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[i,a]of Object.entries(e.props)){let s=o.shared.material(a);this.material[Number(i)]=s}else if(Ne(e.path,["material"])&&this.material instanceof vr)"material"in r&&typeof r.material!="string"&&this.material.updateByOp(pt.drop(e,1),r.material,o);else if(Ne(e.path,["materials","*"])&&Array.isArray(this.material)){let i=e.path[1];if("materials"in r&&i<this.material.length){let a=r.materials[i];typeof a!="string"&&this.material[i].updateByOp(pt.drop(e,2),a,o)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let o=this.dataPatched;if(e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe),r.scene.markNeedsUpdateRendererDirty()),(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(i=>r.shared.material(i).getFlavor(o.flatShading,o.side,o.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe)],r.scene.markNeedsUpdateRendererDirty())),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let i=0;i<this.material.length;i++)this.material[i]=this.material[i].getFlavor(o.flatShading,o.side,o.wireframe);else this.material=this.material.getFlavor(o.flatShading,o.side,o.wireframe)}disposeMaterial(){this.material&&ec(this.material).forEach(e=>{e instanceof vr&&(e instanceof _i||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var Dr=require("three");var Kx=new Dr.Vector3,Zx=new Dr.Vector4,Jx=new Dr.Vector4,LT=new Dr.Vector3,eb=new Dr.Matrix4,yt=class extends Sr{constructor(e,r,o){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new Dr.Matrix4().fromArray(r.bindMatrix),this.bindMatrixInverse=new Dr.Matrix4)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof Dr.BufferGeometry&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Pi){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=r.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return el.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return el.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),Ne(e.path,["geometry"])&&this.updateByPatchedOpGeometry(pt.drop(e,1),r.geometry,o)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let o=this.data.geometry.type;if(o==="NonParametricGeometry"||o==="SubdivGeometry"){let i=e;if(this.localGeometry===void 0){let c={...this.data.geometry,...i};this.localGeometry=sn(c,r,this.data.flatShading,this)}let a,s,l;i.scaleBaked?[a,s,l]=i.scaleBaked:{width:a,height:s,depth:l}=i;let u=this.localGeometry.userData;u.sxPrev!==void 0&&bl(this.localGeometry.attributes,a/u.sxPrev,s/u.syPrev,l/u.szPrev),u.sxPrev=a,u.syPrev=s,u.szPrev=l}else{let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=sn(i,r,this.data.flatShading,this)}}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,o){let i=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof Ct&&this.chooseGeoemtryCache(o.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(i=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(o),this.refreshAttachedPaths(o)),i||(o.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(o)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r),super.updateState(e,r)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,r){let o=this.geometry.userData.parameters;this.is2DType?e.set(0,0,o.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)):e.setScalar(0),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new Dr.Vector4,o=this.geometry.attributes.skinWeight;for(let i=0,a=o.count;i<a;i++){r.fromBufferAttribute(o,i);let s=1/r.manhattanLength();s!==1/0?r.multiplyScalar(s):r.set(1,0,0,0),o.setXYZW(i,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let o=this.skeleton;if(o===void 0)return;let i=this.geometry;Zx.fromBufferAttribute(i.attributes.skinIndex,e),Jx.fromBufferAttribute(i.attributes.skinWeight,e),Kx.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let a=0;a<4;a++){let s=Jx.getComponent(a);if(s!==0){let l=Zx.getComponent(a);eb.multiplyMatrices(o.bones[l].matrixWorld,o.boneInverses[l]),r.addScaledVector(LT.copy(Kx).applyMatrix4(eb),s)}}return r.applyMatrix4(this.bindMatrixInverse)}};function RT(n){if(n.geometry.attributes.extrudeNormal||!n.geometry.attributes.position||!n.geometry.attributes.normal)return;let t=new Map,e=n.geometry.attributes,r=e.position.array,o=e.normal.array,i=new Float32Array(r.length);for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=new Er.Vector3(o[a],o[a+1],o[a+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new Er.Vector3})}t.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=t.get(s)?.result;l&&(i[a]=l.x,i[a+1]=l.y,i[a+2]=l.z)}n.geometry.setAttribute("extrudeNormal",new Er.Float32BufferAttribute(i,3))}function VT(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,r=new Float32Array(e.length),o=new Er.Vector3;for(let i=0;i<e.length;i+=3)o.set(e[i],e[i+1],e[i+2]).normalize(),r[i]=o.x,r[i+1]=o.y,r[i+2]=o.z;n.geometry.setAttribute("extrudeNormal",new Er.Float32BufferAttribute(r,3))}function gs(n){if(Array.isArray(n.material)){for(let t of n.material)if(t.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof vr)||n.material.getLayersOfType("outline").length===0)return;n instanceof yt&&n.is2DAndNoDepth?VT(n):RT(n)}function xs(n){if(!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,r=new Float32Array(e.length),o=parseInt(n.uuid.replace(/\D/g,"")),i=[Er.MathUtils.seededRandom(o),Er.MathUtils.seededRandom(o+1e4),Er.MathUtils.seededRandom(o+2e4)];for(let a=0;a<e.length;a++)r[a]=i[a%3];n.geometry.setAttribute("randomColor",new Er.BufferAttribute(r,3))}var Bo=new un.Box3,Rl=new un.Vector3;function tb(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Oi=class extends yt{constructor(e,r,o){super(e,r,o);this.data=r;this.hiddenMatrixOld=new un.Matrix4;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let o=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:o,subdividedGeometry:i,subdivPointer:a}=Ct.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,o!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=o),i!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,gs(this),xs(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let o=this.material;this.material=Array.isArray(o)?o.map(i=>i.getFlavor(!1,i.side,i.wireframe)):o.getFlavor(!1,o.side,o.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1){Ct.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&Ct.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Ct.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Ct.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){let o=this.localGeometry;this.localGeometry=this.originalGeometryNew,Bt.prototype.raycast.call(this,e,r),this.localGeometry=o}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new un.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Bo.setFromBufferAttribute(r),Bo.getCenter(o),e.boundingSphere.radius=o.distanceTo(Bo.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Bo.getSize(Rl),this.hasNonUniformScale&&Rl.divide(this.scale);let i={width:Rl.x,height:Rl.y,depth:Rl.z};return this.geometry.userData.parameters=i,i}updateBoundingSphere(e){let r=this.originalGeometry;Bo.min.set(e[0],e[2],e[4]),Bo.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Bo.min.applyMatrix4(this.shearScaleInv),Bo.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new un.Sphere);let o=r.boundingSphere.center;Bo.getCenter(o),r.boundingSphere.radius=o.distanceTo(Bo.max)}freeSubdivPointer(){this.subdivPointer&&(Ct.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,r,o){super.updateByPatchedOpGeometry(e,r,o),this.localGeometry&&this.createGeometryByControls(r)}};var Lo=require("three"),rb=-1,zT=1,ob={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},nb={polygon_center:0,edge:1,vertex:2},Vl=(n,t)=>(e,r)=>!t||e===0||n===0?0:n*r/100,_e=(n,t)=>{let e=Math.abs(t),r=e*-1;return(n-rb)*(e-r)/(zT-rb)+r};function ib(n){let t=[],e={};for(var r=0,o=n.length;r<o;r++){var i=JSON.stringify(n[r].pos.map(a=>Math.round(a*1e4)/1e4));e[i]||(t.push(n[r]),e[i]=!0)}return t}var GT=new Lo.Vector3,Qu=new Lo.Vector3,kT=new Lo.Vector3,FT=new Lo.Vector3;function bs(n,t){let e=kT.fromArray(n),r=FT.fromArray(t);Qu.copy(r).sub(e);let o=Qu.length();return Qu.normalize().multiplyScalar(o*.5),GT.copy(e).add(Qu).toArray()}var Fr=new Lo.Triangle,Ku=new Lo.Vector3,Zu=new Lo.Vector3,Ci=new Lo.Vector3;function ab(n){let t=[];for(let e=0;e<=n.index.count;e++)if(Ku.fromArray(n.index.array,e*3),Fr.setFromAttributeAndIndices(n.attributes.position,Ku.x,Ku.y,Ku.z),Fr.getNormal(Zu),Fr.getMidpoint(Ci),!(isNaN(Ci.x)||isNaN(Ci.y)||isNaN(Ci.z))){let{a:r,b:o,c:i}=Fr,a=r.toArray(),s=o.toArray(),l=i.toArray(),u=r.distanceTo(o),c=o.distanceTo(i),d=i.distanceTo(r),p=bs(a,s),f=bs(s,l),h=bs(l,a),m=[u,c,d],y=Math.max(...m),g=m.filter(w=>Math.round(w)===Math.round(y)).length>1,b=[],S=Fr.getMidpoint(Ci).toArray();y===u&&!g&&(b=[f,h,h],S=p),y===c&&!g&&(b=[p,h,h],S=f),y===d&&!g&&(b=[p,f,f],S=h),g&&(b=[p,f,h]),t.push({vertices:[a,s,l],faceCenters:b,midpoint:S,norm:Fr.getNormal(Zu).toArray()})}return t}function sb(n){let t=[],{position:e}=n.attributes;for(let r=0;r<e.count;r++){Fr.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),Fr.getNormal(Zu),Fr.getMidpoint(Ci);let o=Fr.a.toArray(),i=Fr.b.toArray(),a=Fr.c.toArray();t.push({vertices:[o,i,a],faceCenters:[bs(o,i),bs(i,a),bs(a,o)],midpoint:Ci.toArray(),norm:Zu.toArray()})}return t}var jT=4,UT=.5,Ef=n=>.5*(1-Math.cos(n*Math.PI)),Bf=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let o=Math.floor(t),i=Math.floor(e),a=Math.floor(r),s=t-o,l=e-i,u=r-a,c,d,p=0,f=.5,h,m,y;for(let g=0;g<jT;g++){let b=o+(i<<4)+(a<<8);c=Ef(s),d=Ef(l),h=this.perlin[b&4095],h+=c*(this.perlin[b+1&4095]-h),m=this.perlin[b+16&4095],m+=c*(this.perlin[b+16+1&4095]-m),h+=d*(m-h),b+=256,m=this.perlin[b&4095],m+=c*(this.perlin[b+1&4095]-m),y=this.perlin[b+16&4095],y+=c*(this.perlin[b+16+1&4095]-y),m+=d*(y-m),h+=Ef(u)*(m-h),p+=h*f,f*=UT,o<<=1,s*=2,i<<=1,l*=2,a<<=1,u*=2,s>=1&&(o++,s--),l>=1&&(i++,l--),u>=1&&(a++,u--)}return p}noiseSeed(t){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},lb=Bf;var Ss=require("three");var cb=new Ss.Vector3,ub=new Ss.Matrix4,db=new Ss.Ray;function pb(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="TextGeometry"&&(t=!0)}),t}var vs=class extends yt{constructor(e,r,o){super(e,r,o);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,e.geometry.height,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:o}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(ub.copy(o).invert(),db.copy(e.ray).applyMatrix4(ub),db.intersectBox(this.singleBBox,cb))){let i=cb.applyMatrix4(o),a=e.ray.origin.distanceTo(i);r.push({distance:a,point:i.clone(),object:this})}}};var ur=1e-4,Ro,mb,yb,gb,fb=new We.Vector3,hb=new We.Vector3;Iu.then(n=>{Ro=n,mb=[Ro.get_face_center,Ro.get_edge_midpoint,Ro.get_vertex_position],yb=[Ro.get_face_normal,Ro.get_edge_normal,Ro.get_vertex_normal],gb=[Ro.face_count,Ro.edge_count,Ro.vertex_count]});var HT=new We.Matrix4,qT=new We.Matrix4,qn=new We.Vector3,Ti=new We.Vector3,zl=new We.Vector3,Lf=new We.Vector3,WT=new We.Vector3,$T=new We.Vector3;var dn=new lb,_s=class extends Pa(We.Object3D){constructor(e,r){super();this.parameters=r;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let r of this.children)r instanceof rn&&r.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(r=>{r instanceof rn&&r.object===e&&(r.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let e of this.children)e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD())}_updateCount(e){let r;if(e!==void 0?r=e:r=this.parameters.type==="grid"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(r=0),this.parameters.type==="toObject"&&this.objectForSample){for(let i=0,a=this.children.length;i<a;++i)this.remove(this.children[0]);let o=this.children;if(o.length===r)return;if(o.length<r)for(let i=0,a=r-o.length;i<a;++i){let s=new rn(this.object);s.expand(),this.add(s)}else for(let i=0,a=o.length-r;i<a;++i)this.remove(o[i])}else{if(this.children.length===r)return;if(this.children.length<r)for(let o=0,i=r-this.children.length;o<i;++o){let a=new rn(this.object);a.expand(),this.add(a)}else for(let o=0,i=this.children.length-r;o<i;++o)this.remove(this.children[0])}}_updateRadial(e){let r=e.radial,o=r.start*We.MathUtils.DEG2RAD,i=r.end*We.MathUtils.DEG2RAD,a=o-i,s=new We.Euler(r.rotation[0],r.rotation[1],r.rotation[2]),l;switch(r.axis){case"z":l=new We.Vector3(0,0,1);break;case"y":l=new We.Vector3(0,1,0);break;default:case"x":l=new We.Vector3(1,0,0);break}let u=e.randomnessObject??Ao.defaultData([1,1,1]).randomnessObject,c=u.noiseType==="perlin";dn.noiseSeed(u.seed);let d=pu((0,ws.default)(u.seed)),p=Vl(u.strength,this.parameters.randomness);for(let[f,h]of this.children.entries()){let m=f*(u.freqScale/10)+u.movement,y=c?dn.noise(m):d(m,m),g=f+1;h.scale.x=r.scale[0]+p(g,_e(y,u.scale[0]))||ur,h.scale.y=r.scale[1]+p(g,_e(y,u.scale[1]))||ur,h.scale.z=r.scale[2]+p(g,_e(y,u.scale[2]))||ur,h.position.setScalar(0);let b=a/e.count*f-o;switch(r.axis){case"x":h.rotation.set(0,b,0);break;case"y":h.rotation.set(0,0,b);break;case"z":h.rotation.set(b,0,0);break}h.translateOnAxis(l,r.radius),h.position.x+=r.position[0]+p(g,_e(y,u.position[0])),h.position.y+=r.position[1]+p(g,_e(y,u.position[1])),h.position.z+=r.position[2]+p(g,_e(y,u.position[2]));let S=p(g,_e(y,u.rotation[0])),w=p(g,_e(y,u.rotation[1])),v=p(g,_e(y,u.rotation[2]));r.alignment===!0?(h.rotation.x+=s.x+S,h.rotation.y+=s.y+w,h.rotation.z+=s.z+v):h.rotation.set(s.x+S,s.y+w,s.z+v)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let r=e.linear,o=new We.Euler(r.rotation[0],r.rotation[1],r.rotation[2]),i=e.randomnessObject??Ao.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";dn.noiseSeed(i.seed);let s=pu((0,ws.default)(i.seed)),l=Vl(i.strength,this.parameters.randomness);for(let[u,c]of this.children.entries()){let d=u*(i.freqScale/10)+i.movement,p=a?dn.noise(d):s(d,d),f=u+1,h=l(f,_e(p,i.rotation[0])),m=l(f,_e(p,i.rotation[1])),y=l(f,_e(p,i.rotation[2]));c.scale.x=1+(r.scale[0]-1)*u+l(f,_e(p,i.scale[0]))||ur,c.scale.y=1+(r.scale[1]-1)*u+l(f,_e(p,i.scale[1]))||ur,c.scale.z=1+(r.scale[2]-1)*u+l(f,_e(p,i.scale[2]))||ur,c.rotation.x=o.x*u+h,c.rotation.y=o.y*u+m,c.rotation.z=o.z*u+y,c.position.x=r.position[0]*u+l(f,_e(p,i.position[0])),c.position.y=r.position[1]*u+l(f,_e(p,i.position[1])),c.position.z=r.position[2]*u+l(f,_e(p,i.position[2]))}}_updateGrid(e){let r=0,o=e.grid,i=e.randomnessObject??Ao.defaultData([1,1,1]).randomnessObject,a=Vl(i.strength,this.parameters.randomness),s=i.noiseType==="perlin";dn.noiseSeed(i.seed);let l=Wg((0,ws.default)(i.seed));if(o.useCenter===!0){let u={x:o.count[0]%2===0?2:1,y:o.count[1]%2===0?2:1,z:o.count[2]%2===0?2:1},c=new We.Vector3(o.size[0]*(o.count[0]-u.x)*.5,o.size[1]*(o.count[1]-u.y)*.5,o.size[2]*(o.count[2]-u.z)*.5);for(let d=0;d<o.count[0];d++)for(let p=0;p<o.count[1];p++)for(let f=0;f<o.count[2];f++){let h=[(d+1)*(i.freqScale/10)+i.movement,(p+1)*(i.freqScale/10)+i.movement,(f+1)*(i.freqScale/10)+i.movement],m=s?dn.noise(...h):l(...h),y=this.children[r++];y.scale.x=1+a(r,_e(m,i.scale[0]))||ur,y.scale.y=1+a(r,_e(m,i.scale[1]))||ur,y.scale.z=1+a(r,_e(m,i.scale[2]))||ur;let g=a(r,_e(m,i.rotation[0])),b=a(r,_e(m,i.rotation[1])),S=a(r,_e(m,i.rotation[2]));y.rotation.set(g,b,S),y.position.x=o.size[0]*d-c.x+a(r,_e(m,i.position[0])),y.position.y=o.size[1]*p-c.y+a(r,_e(m,i.position[1])),y.position.z=o.size[2]*f-c.z+a(r,_e(m,i.position[2]))}}else for(let u=0;u<o.count[0];u++)for(let c=0;c<o.count[1];c++)for(let d=0;d<o.count[2];d++){let p=[(u+1)*(i.freqScale/10)+i.movement,(c+1)*(i.freqScale/10)+i.movement,(d+1)*(i.freqScale/10)+i.movement],f=s?dn.noise(...p):l(...p),h=this.children[r++];h.scale.x=1+a(r,_e(f,i.scale[0]))||ur,h.scale.y=1+a(r,_e(f,i.scale[1]))||ur,h.scale.z=1+a(r,_e(f,i.scale[2]))||ur;let m=a(r,_e(f,i.rotation[0])),y=a(r,_e(f,i.rotation[1])),g=a(r,_e(f,i.rotation[2]));h.rotation.set(m,y,g),h.position.x=o.size[0]*u+a(r,_e(f,i.position[0])),h.position.y=-o.size[1]*c+a(r,_e(f,i.position[1])),h.position.z=-o.size[2]*d+a(r,_e(f,i.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:r}=e,o=new We.Euler(r.rotation[0],r.rotation[1],r.rotation[2]),i=e.randomnessObject??Ao.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";dn.noiseSeed(i.seed);let s=pu((0,ws.default)(i.seed)),l=Vl(i.strength,this.parameters.randomness);if(!r.object){for(let[,g]of this.children.entries())g.position.set(0,0,0),g.scale.setScalar(1),g.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof vs)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let u=this.getSubdivData(),c=[],d=g=>{let b=g.length,S=g.map(_=>_[0]).reduce((_,A)=>_+A,0),w=g.map(_=>_[1]).reduce((_,A)=>_+A,0),v=g.map(_=>_[2]).reduce((_,A)=>_+A,0);return[S/b,w/b,v/b]},p=g=>Math.round(g*1e6)/1e6;u.forEach(g=>{let b=u.filter(S=>p(g.pos[0])===p(S.pos[0])&&p(g.pos[1])===p(S.pos[1])&&p(g.pos[2])===p(S.pos[2]));b.length>1?c.push({pos:g.pos,norm:d(b.map(S=>S.norm))}):c.push(g)});let f=ib(c);if(f.length>0){let g=Math.round(f.length*r.count/100);this._updateCount(g)}else{let g=this.objectForSample.geometry.getAttribute("position");if(!g||isNaN(g.count)||g.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let h=new fu(this.objectForSample).build(),m=ob[r.axis],y=this.children;h.setRandomGenerator((0,ws.default)(this.object.uuid+r.seed));for(let[g,b]of y.entries()){let S=g*(i.freqScale/10)+i.movement,w=a?dn.noise(S):s(S,S),v=g+1,_=l(v,_e(w,i.rotation[0])),A=l(v,_e(w,i.rotation[1])),x=l(v,_e(w,i.rotation[2]));r.spreadType==="random"?h.sample(zl,Lf):(f.length&&(zl.fromArray(f[g].pos),Lf.fromArray(f[g].norm)),this.objectForSample instanceof Oi&&zl.applyMatrix4(HT.copy(this.objectForSample.matrixWorld).invert())),zl.applyMatrix4(this.object.hiddenMatrix.clone().invert()),b.position.copy(zl),qn.fromArray(m);let T=r.align==="normal"?Lf:this.object.getWorldDirection($T),C=Ti.fromArray(r.position);Ti.x+=Ti.x+l(v,_e(w,i.position[0])),Ti.y+=Ti.y+l(v,_e(w,i.position[1])),Ti.z+=Ti.z+l(v,_e(w,i.position[2]));let P=Math.acos(T.dot(qn)),O=WT.crossVectors(qn,T).normalize(),M=qT.makeRotationAxis(O,P),I=T.clone().cross(this.object.up).normalize(),N=I.clone().cross(T).normalize(),B=new We.Matrix4().makeBasis(I,T,N),D=new We.Vector3(qn.y,qn.z,qn.x).normalize(),G=D.clone().cross(qn).normalize(),L=new We.Matrix4().makeBasis(D,qn,G).invert(),V=new We.Matrix4().multiplyMatrices(B,L);b.rotation.setFromRotationMatrix(V),C.applyMatrix4(M),b.position.add(C),b.rotation.x=b.rotation.x+o.x+_,b.rotation.y=b.rotation.y+o.y+A,b.rotation.z=b.rotation.z+o.z+x,b.scale.setScalar(1),b.scale.x=b.scale.x+r.scale[0]+l(v,_e(w,i.scale[0]))||ur,b.scale.y=b.scale.y+r.scale[1]+l(v,_e(w,i.scale[1]))||ur,b.scale.z=b.scale.z+r.scale[2]+l(v,_e(w,i.scale[2]))||ur,b.scale.multiply(this.object.scale),b.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof Oi){let r=this.objectForSample,o=nb[e],i=gb[o],a=mb[o],s=yb[o],l=[],u=i(r.subdivPointerNew);for(let c=0;c<=u-1;c++){let d=a(r.subdivPointerNew,c),p=s(r.subdivPointerNew,c);fb.fromArray(d).applyMatrix4(r.matrixWorld),hb.fromArray(p),l.push({pos:fb.toArray(),norm:hb.toArray()})}return l}else return(this.objectForSample.geometry.index?ab(this.objectForSample.geometry):sb(this.objectForSample.geometry)).map((o,i)=>e==="polygon_center"?{pos:o.midpoint,norm:o.norm}:e==="vertex"?[{pos:o.vertices[0],norm:o.norm},{pos:o.vertices[1],norm:o.norm},{pos:o.vertices[2],norm:o.norm}]:e==="edge"?[{pos:o.faceCenters[0],norm:o.norm},{pos:o.faceCenters[1],norm:o.norm},{pos:o.faceCenters[2],norm:o.norm}]:[]).flat()}updateState(e,r){if(this.parameters=$o(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let o=r.find(this.parameters.toObject.object);o instanceof Bt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new We.Matrix4,this.hiddenMatrix=new We.Matrix4,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};var Kr=require("three");var ut=require("three");var er=require("three");var xb=require("three"),Vo=n=>{var t;return t=class extends n{},t.geometryHelper=new xb.BoxGeometry(30,30,30),t};var rr=require("three"),Ju=new rr.Ray,Rf=new rr.Sphere,bb=new rr.Matrix4,zo=(n,t,e,r,o=!1)=>{let i=t,a=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),Rf.copy(i.boundingSphere),Rf.applyMatrix4(a),e.ray.intersectsSphere(Rf)===!1||(bb.copy(a).invert(),Ju.copy(e.ray).applyMatrix4(bb),i.boundingBox!==null&&Ju.intersectsBox(i.boundingBox)===!1))return;let s,l,u,c,d=i.index,p=i.attributes.position,f=i.drawRange,h,m;if(o===!1){let g=Math.max(0,f.start),b=Math.min(d.count,f.start+f.count);for(h=g,m=b;h<m;h+=3)if(l=d.getX(h),u=d.getX(h+1),c=d.getX(h+2),s=y(n,e,Ju,p,l,u,c),s){s.faceIndex=Math.floor(h/3),r.push(s);return}}else{let b=i.attributes.position,S=new rr.Vector3,w=new rr.Vector3,v=new rr.Vector3,_=new rr.Vector3,A=2,T=1/((n.scale.x+n.scale.y+n.scale.z)/3),C=T*T,P=Math.max(0,f.start),O=Math.min(b.count,f.start+f.count);for(let M=P,I=O-1;M<I;M+=A){if(S.fromBufferAttribute(b,M),w.fromBufferAttribute(b,M+1),Ju.distanceSqToSegment(S,w,_,v)>C)continue;_.applyMatrix4(n.matrixWorld);let B=e.ray.origin.distanceTo(_);B<e.near||B>e.far||r.push({distance:B,point:v.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(g,b,S,w,v,_,A){let x=new rr.Vector3,T=new rr.Vector3,C=new rr.Vector3,P=new rr.Vector3,O=new rr.Vector3;if(x.fromBufferAttribute(w,v),T.fromBufferAttribute(w,_),C.fromBufferAttribute(w,A),S.intersectTriangle(x,T,C,!1,P)===null)return null;O.copy(P),O.applyMatrix4(g.matrixWorld);let I=b.ray.origin.distanceTo(O);return I<b.near||I>b.far?null:{faceIndex:1,distance:I,point:O.clone(),object:g}}};var ed=new er.Vector3,jr=new er.Camera,Vf=class extends er.LineSegments{constructor(e){let r=new er.BufferGeometry,o=new er.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],a=[],s={},l=new er.Color(15711266),u=new er.Color(15711266),c=new er.Color(2857471);d("n1","n2",l),d("n2","n4",l),d("n4","n3",l),d("n3","n1",l),d("f1","f2",l),d("f2","f4",l),d("f4","f3",l),d("f3","f1",l),d("n1","f1",l),d("n2","f2",l),d("n3","f3",l),d("n4","f4",l),d("p","n1",u),d("p","n2",u),d("p","n3",u),d("p","n4",u),d("u1","u2",c),d("u2","u3",c),d("u3","u1",c);function d(f,h,m){p(f,m),p(h,m)}function p(f,h){i.push(0,0,0),a.push(h.r,h.g,h.b),s[f]===void 0&&(s[f]=[]),s[f].push(i.length/3-1)}r.setAttribute("position",new er.Float32BufferAttribute(i,3)),r.setAttribute("color",new er.Float32BufferAttribute(a,3));super(r,o);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,r=this.pointMap,o=!0;jr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=1,a=1,s=o?.8:1e-4;ho("n1",r,e,jr,-i,-a,s),ho("n2",r,e,jr,i,-a,s),ho("n3",r,e,jr,-i,a,s),ho("n4",r,e,jr,i,a,s);let l=s;ho("f1",r,e,jr,-i,-a,l),ho("f2",r,e,jr,i,-a,l),ho("f3",r,e,jr,-i,a,l),ho("f4",r,e,jr,i,a,l);let u=l,c=.5;ho("u1",r,e,jr,i*.7*c,a*1.1,u),ho("u2",r,e,jr,-i*.7*c,a*1.1,u),ho("u3",r,e,jr,0,a*(1.1+.9*c),u),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function ho(n,t,e,r,o,i,a){ed.set(o,i,a).unproject(r);let s=t[n];if(s!==void 0){let l=e.getAttribute("position");for(let u=0,c=s.length;u<c;u++)l.setXYZ(s[u],ed.x,ed.y,ed.z)}}var td=class extends Vo(Vf){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,r){zo(this.object,this.geometry,e,r,!0)}};var Gl=require("three");var rd;(t=>t.is=e=>"objectHelper"in e)(rd||(rd={}));var Ur=(n,t)=>class extends Ta(n){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(o,i){this.objectHelper.raycast(o,i)}showGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof Gl.Box3Helper&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof Gl.BoxGeometry?(o.setScalar(0),i.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(o,i)}hideGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof Gl.Box3Helper&&(i.visible=!1)}}};var od=790,As=new ut.Vector3,zf=new ut.Vector3,Gf=new ut.Quaternion,kf=new ut.Vector3,kl=new ut.Vector3,Ff=new ut.Vector3,pn=class extends Ur(ut.Camera,td){constructor(e="",r={...ui.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=In.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,r),this.previousProjectionMatrix=new ut.Matrix4,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,i=this.height;this.orthoCamera=new ut.OrthographicCamera(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4),this.perspCamera=new ut.PerspectiveCamera(45,o/i,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}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,r,o){typeof e=="number"&&(e=new ut.Vector3(e,r,o)),super.lookAt(e),this.getWorldPosition(As),this.targetOffset=As.distanceTo(e)}getTarget(e=new ut.Vector3){return this.getWorldDirection(zf),this.getWorldPosition(As),zf.multiplyScalar(this.targetOffset),e.copy(As).add(zf),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(As),As.distanceTo(e)}updateUp(){this.getWorldQuaternion(Gf),kf.set(0,0,1).applyQuaternion(Gf),kl.copy(ut.Object3D.DEFAULT_UP),this.isUpVectorFlipped&&kl.negate(),kl.applyQuaternion(Gf),Ff.copy(ut.Object3D.DEFAULT_UP).projectOnPlane(kf),this.angleOffsetFromUp=Ff.angleTo(kl),this.angleOffsetFromUp*=Ff.cross(kl).dot(kf)>=0?1:-1}updateTransformState(e,r){let o=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),o}getViewFrontToObject(e){let r=e.getWorldPosition(new ut.Vector3),i=e.getWorldDirection(new ut.Vector3).multiplyScalar(this.targetOffset);return{position:r.clone().add(i),target:r}}getViewToTarget(e){let o=this.getWorldDirection(new ut.Vector3).multiplyScalar(this.targetOffset);return{position:e.clone().sub(o),target:e}}getViewToObject(e){let r=new ut.Vector3,o=e.getWorldPosition(r);return this.getViewToTarget(r)}setViewplaneSize(e,r,o=!1){if(this.aspect=e/r,o){let i=e>r?this.aspect:1,a=e>r?1:this.aspect;this.left=-od*.5*i,this.right=od*.5*i,this.top=od*.5*(1/a),this.bottom=-od*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,o,i,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,o,i,a,s):this.orthoCamera.setViewOffset(e,r,o,i,a,s)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let r={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 oa(r,e)}updateCameraSubtype(e,r){let o=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(o,r.zoom),r.near!==void 0&&this.setNear(o,r.near),r.fov!==void 0&&o==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}};var QT=require("three");var Hr=require("three");var Ps=new Hr.Matrix4,XT=new Hr.Matrix4,nd=new Hr.Matrix4,vb=new Hr.Vector3,Sb=new Hr.Vector3;var wr=class extends Sr{constructor(e,r,o){super(e,r);this.data=r;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new Hr.BufferGeometry;this.onAfterRender=(e,r,o,i,a,s)=>{super.onAfterRender(e,r,o,i,a,s),this.recomputeBoolean()};this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,r=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let i=0;i<this.children.length;i++){let a=this.children[i];a instanceof wr&&a.dataPatched.visible===!0&&a.recomputeBoolean(e===!0,r)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let a=this.children[i];if(a instanceof Bt&&a.dataPatched.visible===!0&&a.geometry.attributes.position?.count>0&&a.geometry.drawRange.count>0&&a.booleanMeshSetAddress!==0){Ps.multiplyMatrices(a.hiddenMatrix,a.matrix);try{if(a.booleanMeshSetAddress===-1){if((a.geometry.index??a.geometry.getAttribute("position")).count/3<15e5&&(a.booleanMeshSetAddress=Gr.getMeshSet(a.geometry,e===!0,r)),a.booleanMeshSetAddress===-1)return;Gr.transformMeshSet(a.booleanMeshSetAddress,Ps),a.booleanMatrixInvOld.copy(Ps).invert(),a.booleanWasTransformed=!1}else a instanceof wr&&a.needsTransformForDownstream===!0?(Gr.transformMeshSet(a.booleanMeshSetAddress,Ps),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(Gr.transformMeshSet(a.booleanMeshSetAddress,XT.multiplyMatrices(Ps,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(Ps).invert(),a.booleanWasTransformed=!1)}catch(s){console.error(s),a.booleanMeshSetAddress=0,a.geometry.userData.booleanOperationDidFail=!0;continue}Gr.hasOpenEdges(a.booleanMeshSetAddress)===!1||i===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(a.booleanMeshSetAddress),a.geometry.userData.booleanOperationDidFail=!1):a.geometry.userData.booleanOperationDidFail="openEdges"}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new Hr.Float32BufferAttribute([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Gr.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new Hr.BufferGeometry,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=Gr.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,gs(this),xs(this)}dispose(){super.dispose(),this.geometry.dispose()}get recursiveBBox(){let e=super.recursiveBBox;return this.geometry.boundingSphere?.radius===-1&&(e.getCenter(this.geometry.boundingSphere.center),nd.copy(this.matrixWorld).invert(),this.geometry.boundingSphere.center.applyMatrix4(nd),vb.copy(e.max).applyMatrix4(nd),Sb.copy(e.min).applyMatrix4(nd),this.geometry.boundingSphere.radius=vb.distanceTo(Sb)/2),e}};var _b=require("three");var wb;(t=>{function n(e){return De.is(e)&&e instanceof _b.Light}t.is=n})(wb||(wb={}));var Os=(n,t)=>class extends Ur(n,t){updateState_Light(r,o){this.updateState_Entity(r,o),r.color!==void 0&&(this.color=o.shared.color(r.color)),r.intensity!==void 0&&(this.intensity=r.intensity),r.depth!==void 0&&(this.shadow.camera.far=r.depth,this.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows)}};var Wn=n=>n instanceof Bt,Fl=n=>n!==null&&n instanceof wr;var jl=n=>rd.is(n);var Pb=require("three");var Ab=require("three");var qr=class extends Vo(Ab.AxesHelper){constructor(e,r=15){super(r);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){zo(this.object,qr.geometryHelper,e,r)}update(){}};var $n=class extends Ur(Pb.Group,qr){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update()}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&Object.keys(t).length===1&&e.scene.reloadSplats()}};var Ob=require("three");var id=class extends Ur(Ob.Group,qr){constructor(e,r,o){super();this.super_Entity(e,r),this.context=o,this.objectHelper.update()}updateState(e,r){this.updateState_Entity(e,r)}};var Bs=require("three");var Cs=require("three"),KT=n=>`
2237
+ `)}return r}};var Bs=require("three");var pd=class{constructor(t=1e3*10){this.timeout=t;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}};var nh=class extends pd{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},oh;function Ob(n){return typeof n=="string"?n:(oh||(oh=new nh),oh.load(n))}var fd=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},hd=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var Es=class extends fd{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.loaded=!1;this.isVideo=!1;this.isCanvas=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isCanvas=e.nodeName==="CANVAS",this.updateSrc(this.isCanvas?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let r=()=>{this.loaded=!0;for(let i of Object.values(this._cache))for(let a of Object.values(i))a&&(a.image=this.img,a.needsUpdate=!0);this.shared.requestRender()};if(this.isCanvas)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var o=new FileReader;o.readAsDataURL(new Blob([e],{type:"video/mp4"}));let i;await new Promise(a=>{o.onloadend=s=>{i=s.target?.result,a(null)}}),this.img.src=i}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else this.img=new Image,this.img.src=Ob(e),this.img.onload=r}getTexture(e,r=1008){let o=this._cache[e][r];if(o)return o;{let i;return this.isCanvas&&(i=new Bs.CanvasTexture(this.img,void 0,e,e,void 0,r)),this.isVideo?i=new Bs.VideoTexture(this.img,void 0,e,e):i=new Bs.Texture(this.img,void 0,e,e,void 0,r),this.loaded&&(i.needsUpdate=!0),this._cache[e][r]=i,i}}setNeedsUpdate(e){for(let r of Object.values(this._cache))for(let o of Object.values(r))o&&(o.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[o,i]of Object.entries(r))i?.dispose(),this._cache[e][o]=void 0}dispose(){super.dispose(),this.disposeTextures()}};var jr=class extends Es{};var mt=require("three");function ur(n,t){return t.color(n)}function Cb(n,t){switch(n.type){case"fresnel":return xM(n,t);case"gradient":return bM(n,t);case"depth":return vM(n,t);case"normal":return SM(n,t);case"noise":return wM(n,t);case"rainbow":return AM(n,t);case"toon":return _M(n,t);case"outline":return PM(n,t);case"transmission":return OM(n,t);case"color":return gM(n,t);case"pattern":return CM(n,t)}}function yM(n){return{type:n.type}}function Po(n,t){let{alpha:e,mode:r,isMask:o}=n,i=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...yM(n),alpha:i,mode:r,isMask:o}}function gM(n,t){return{...Po(n,t),color:ur(n.color,t)}}function xM(n,t){let{bias:e,scale:r,intensity:o,factor:i,color:a}=n;return{...Po(n,t),color:ur(a,t),bias:e,scale:r,intensity:o,factor:i}}function bM(n,t){let{gradientType:e,smooth:r,colors:o,steps:i,angle:a,offset:s,morph:l}=n;return{...Po(n,t),gradientType:e,smooth:r,colors:o.map(u=>new mt.Vector4(u[0],u[1],u[2],u[3])),num:o.length,steps:i,offset:new mt.Vector2(...s),morph:new mt.Vector2(...l),angle:a}}function vM(n,t){let{gradientType:e,near:r,far:o,isVector:i,isWorldSpace:a,origin:s,direction:l,colors:u,steps:c,smooth:d}=n;return{...Po(n,t),gradientType:e,near:r,far:o,isVector:i,isWorldSpace:a,origin:new mt.Vector3(...s),direction:l?new mt.Vector3(...l):new mt.Vector3(1,0,0),colors:u.map(p=>p!==void 0?new mt.Vector4(p[0],p[1],p[2],p[3]):new mt.Vector4(0,0,0,0)),steps:c.slice(0,u.length),smooth:d}}function SM(n,t){let{cnormal:e}=n;return{...Po(n,t),cnormal:new mt.Vector3(e[0],e[1],e[2])}}function wM(n,t){return{...Po(n,t),scale:n.scale,move:n.move,fA:new mt.Vector2(...n.fA),fB:new mt.Vector2(...n.fB),size:new mt.Vector3(...n.size),distortion:new mt.Vector2(...n.distortion),colorA:ur(n.colorA,t),colorB:ur(n.colorB,t),colorC:ur(n.colorC,t),colorD:ur(n.colorD,t),noiseType:n.noiseType,voronoiStyle:n.voronoiStyle,highCut:n.highCut,lowCut:n.lowCut,smoothness:n.smoothness,seed:n.seed,quality:n.quality}}function AM(n,t){return{...Po(n,t),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new mt.Vector3(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new mt.Vector3(...n.offset)}}function _M(n,t){return{...Po(n,t),positioning:n.positioning,colors:n.colors.map(e=>new mt.Vector4(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new mt.Vector3(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:ur(n.shadowColor,t),offset:new mt.Vector3(...n.offset)}}function PM(n,t){return{...Po(n,t),outlineColor:ur(n.outlineColor,t),contourColor:ur(n.contourColor,t),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new mt.Vector3(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function OM(n,t){return{...Po(n,t),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function CM(n,t){return{...Po(n,t),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new mt.Vector2(...n.offset),colorA:ur(n.colorA,t),colorB:ur(n.colorB,t),frequency:new mt.Vector2(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new mt.Vector2(...n.vertical),horizontal:new mt.Vector2(...n.horizontal),sides:n.sides}}var Jn=class extends Yt{};var Tb=require("three");var ih={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},ah={depth:["colors"]};function TM(n,t,e){if(t==="isMask")return!0;let r=ih[n.type],o=ah[n.type];if(o!==void 0){let i=n.color;if(o.includes(t)){let a=i[t]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return r!==void 0?r.includes(t):!1}function sh(n,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let o=!1,i=n;if("image"in i){let a=i.image,s=t.image(a),l=r;l.image instanceof jr||l.image.deref(),l.image=s}if("video"in i){let a=i.video,s=t.video(a),l=r;l.image instanceof jr||l.image.deref(),l.image=s}if("wrapping"in i){let a=r;a.wrap=i.wrapping}if("minFilter"in i){let a=r;a.minFilter=i.minFilter}if("repeat"in i||"offset"in i){let a="mat",s=e.uniforms[`f${e.id}_${a}`];"repeat"in i&&(s.repeat=i.repeat),"offset"in i&&(s.offset=i.offset),s.updateMatrix()}return o}function Mb(n,t,e,r){let o=!1;for(let[i,a]of Object.entries(n)){if(i==="bumpMap"||i==="roughnessMap"){o=!0;continue}if(!i||a===void 0)continue;if(lh(i,e,r,t)){i==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=r.visible;let s=e.uniforms[`f${e.id}_${i}`];if(!!s&&!(s instanceof Kn))switch(o=o||TM(e,i,a),s.constructor){case et:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Jn?s.value=new Yt(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case Mr:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Jn?s.value=new Yt(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case Pt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case lr:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case wr:{sh(a,t,e);break}case _o:{s.value=a.map(l=>new Tb.Vector4(...l));break}default:{s.value=a;break}}}return o}var ei=(n,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof n=="number"?n*100:n,e)??100)/100))??1,Ho=class{constructor(t,e,r,o,i){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in r)lh(a,this,r,i)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return Ar.createLigherLayer(t,e,r,o);if(r.type==="texture"||r.type==="video"){let i=r.type==="texture"?o.canvas(r.texture.image)??o.image(r.texture.image):o.video(r.texture.video),a=new Ei(i,r.texture.wrapping,r.texture.minFilter??1008),s=new cd(i),l=new ud(r.texture.repeat,r.texture.offset),u=new se(r.crop?1:0),c=new Ge(r.projection??0),d=new Ge(["x","y","z"].indexOf(r.axis)??0),p=new Ge(r.side??0),f=new Pt(r.size?new it.Vector2(r.size[0],r.size[1]):new it.Vector2(100,100)),h=new se(r.blending??0),m=new se(ei(r.alpha,o)),y=new Ge(r.mode??0),g=new Et(r.isMask??!1),b=new Zn(a,s,u,c,d,p,f,h,l,m,y,g),w=new Ze(b.calpha,"f");return new xt(t,e,r,{texture:a,textureSize:s,crop:u,projection:c,axis:d,side:p,size:f,blending:h,mat:l,alpha:m,mode:y,isMask:g},b,y,w,g,o)}else if(r.type==="matcap"){let i=o.image(r.texture.image),a=new Ei(i,r.texture.wrapping,r.texture.minFilter??1008),s=new se(ei(r.alpha,o)),l=new Ge(r.mode??0),u=new Et(r.isMask??!1),c=new _s(a,s,l,u),d=new Ze(c.calpha,"f");return new xt(t,e,r,{texture:a,alpha:s,mode:l,isMask:u},c,l,d,u,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let i=new lr(new it.Vector3(...r.offset)),a=new se(r.scale??10),s=new se(r.intensity??8),l=new se(r.movement??1),u=new Ge(r.noiseType??0),c=new Ge(r.voronoiStyle??0),d=new se(r.smoothness??.5),p=new se(r.seed??0),f=new se(r.highCut??1),h=new se(r.lowCut??0),m=new Ge(r.quality??1),y=new Ns(s,l,i,c,d,p,f,h,m,a,u);return new ec(t,e,r,{offset:i,scale:a,intensity:s,movement:l,noiseType:u,voronoiStyle:c,smoothness:d,seed:p,highCut:f,lowCut:h,quality:m},y,o)}else throw new Error;else return NM(t,e,r,o)}updateByOp(t,e,r){let o=t;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props?(r.scene.markNeedsUpdateRendererDirty(),!0):Mb(o.props,r.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?sh(o.props,r.shared,this):!0;return!1}dispose(){if(MM(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof jr||e.image.deref()}}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}},xt=class extends Ho{constructor(e,r,o,i,a,s,l,u,c){super(e,r,o,i,c);this.params=i;this.color=a;this.mode=s;this.alpha=l;this.isMask=u}},ec=class extends Ho{constructor(e,r,o,i,a,s){super(e,r,o,i,s);this.position=a}},Ar=class extends Ho{constructor(e,r,o,i,a,s){super(e,r,o,a,s);this.node=i}static createLigherLayer(e,r,o,i){let a,s=new se(ei(o.alpha,i)),l=new Ge(o.mode),u=new se(o.bumpMapIntensity),c=new se(ei(o.alphaOverride,i)),d;if(!o.visible)a=new xn,d={};else if(o.category==="lambert"){a=new Yl;let p=new et(i.color(o.emissive)??0),f=new Et(o.occlusion??!0);d={emissive:p,occlusion:f},a.emissive=p,a.occlusion=f}else if(o.category==="toon"){a=new Jl;let p=new se(o.shininess??30),f=new et(i.color(o.specular)??1118481);d={shininess:p,specular:f},a.shininess=p,a.specular=f}else if(o.category==="physical"){a=new Kl;let p=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new Et(o.occlusion??!0);d={roughness:p,metalness:f,reflectivity:h,occlusion:m},a.roughness=p,a.metalness=f,a.reflectivity=h,a.occlusion=m}else{a=new Ql;let p=new se(o.shininess??30),f=new et(o.specular!==void 0?i.color(o.specular)??1118481:1118481),h=new Et(o.occlusion??!0);d={shininess:p,specular:f,occlusion:h},a.shininess=p,a.specular=f,a.occlusion=h}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=u,a.alphaOverride=c,d.alpha=a.shadingAlpha,d.mode=a.shadingBlend,d.bumpMapIntensity=a.bumpMapIntensity,d.alphaOverride=a.alphaOverride,new Ar(e,r,o,a,d,i)}get category(){return this.node.category}};function MM(n){let t=n instanceof Ho?n.type:n;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Zr(n){return{alpha:new se(n.alpha??1),mode:new Ge(n.mode??0),isMask:new Et(n.isMask??!1)}}function IM(n,t,e,r,o){switch(n.type){case"color":{let i=new et(r.color??Rt),a=Zr(r),s=new Bi(i,a.alpha),l=new Ze(s.calpha,"f");return new xt(t,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let i=new et(r.color??16777215),a=new se(r.bias??.1),s=new se(r.scale??1),l=new se(r.intensity??2),u=new se(r.factor??1),c=Zr(r),d=new ql(i,a,s,l,u,c.alpha,c.mode,c.isMask),p=new Ze(d.calpha,"f");return new xt(t,e,n,{color:i,bias:a,scale:s,intensity:l,factor:u,...c},d,c.mode,p,c.isMask,o)}case"rainbow":{let i=new se(r.filmThickness??30),a=new se(r.movement??0),s=new lr(r.wavelengths??new it.Vector3(0,0,0)),l=new se(r.noiseStrength??0),u=new se(r.noiseScale??1),c=new lr(r.offset??new it.Vector3(0,0,0)),d=Zr(r),p=new Ts(i,a,s,l,u,c,d.alpha,d.isMask),f=new Ze(p.calpha,"f");return new xt(t,e,n,{filmThickness:i,movement:a,wavelengths:s,noiseStrength:l,noiseScale:u,offset:c,...d},p,d.mode,f,d.isMask,o)}case"transmission":{let i=new se(r.thickness??10),a=new se(r.ior??1.5),s=new se(r.roughness??.5),l=De.transmissionSize,u=De.transmissionRenderTarget,c=De.transmissionRenderTargetDepth,d=window.innerWidth,p=window.innerHeight,f=d>=p?new Pt(p/d,1):new Pt(1,d/p),h=Zr(r),m=new Is(i,a,s,l,u,c,f,h.alpha),y=new Ze(m.calpha,"f");return new xt(t,e,n,{thickness:i,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let i=new Ge(r.positioning??0),a;r.colors?a=new _o(r.colors.length,r.colors):(a=new _o(10,new it.Vector4(0,0,0,1)),a.value[1]=new it.Vector4(1,1,1,1));let s;r.steps?s=new Ao(r.steps.length,r.steps):(s=new Ao(10,1),s.value[0]=0);let l=new lr(r.source??new it.Vector3(0,0,0)),u=new Et(r.isWorldSpace??!0),c=new se(r.noiseStrength??0),d=new se(r.noiseScale??1),p=new Mr(r.shadowColor),f=new lr(r.offset??new it.Vector3(0,0,0)),h=Zr(r),m=new Ms(i,a,s,l,u,c,d,p,f,h.alpha),y=new Ze(m.calpha,"f");return new xt(t,e,n,{positioning:i,colors:a,steps:s,source:l,isWorldSpace:u,noiseStrength:c,noiseScale:d,shadowColor:p,offset:f,...h},m,h.mode,y,h.isMask,o)}case"outline":{let i=new et(r.outlineColor??16777215),a=new et(r.contourColor??16777215),s=new se(r.outlineWidth??.1),l=new se(r.contourWidth??.1),u=new se(r.outlineThreshold??.1),c=new se(r.contourThreshold??.1),d=new se(r.outlineSmoothing??.1),p=new se(r.contourFrequency??.1),f=new lr(r.contourDirection??new it.Vector3(0,1,0)),h=new Et(r.positionalLines??!1),m=new Et(r.compensation??!0),y=De.normalRenderTarget,g=De.normalRenderTargetDepth,b=De.pixelRatioNode,w=De.resolution,_=Zr(r),S=new Os(i,a,s,l,u,c,d,p,f,h,m,w,y,g,b,_.alpha),P=new Ze(S.calpha,"f");return new xt(t,e,n,{outlineColor:i,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:u,contourThreshold:c,outlineSmoothing:d,contourFrequency:p,contourDirection:f,positionalLines:h,compensation:m,..._},S,_.mode,P,_.isMask,o)}case"depth":{let i=new Ge(r.gradientType??0),a=new Et(r.smooth??!1),s=new se(r.near??50),l=new se(r.far??200),u=new se(r.isVector??1),c=new se(r.isWorldSpace??0),d=new lr(r.origin??new it.Vector3),p=new lr(r.direction??new it.Vector3),f;r.colors?f=new _o(r.colors.length,r.colors):(f=new _o(2,new it.Vector4(0,0,0,1)),f.value[1]=new it.Vector4(1,1,1,1));let h;r.steps?h=new Ao(r.steps.length,r.steps):(h=new Ao(2,1),h.value[0]=0);let m=Zr(r),y=new ws(i,a,s,l,u,c,d,p,f,h,m.alpha,m.isMask),g=new Ze(y.calpha,"f");return new xt(t,e,n,{gradientType:i,smooth:a,near:s,far:l,isVector:u,isWorldSpace:c,origin:d,direction:p,colors:f,steps:h,...m},y,m.mode,g,m.isMask,o)}case"noise":{let i=new se(r.scale??1),a=new lr(r.size??new it.Vector3(100,100,100)),s=new se(r.move??1),l=new Pt(r.fA??new it.Vector2(1.7,9.2)),u=new Pt(r.fB??new it.Vector2(8.3,2.8)),c=new Pt(r.distortion??new it.Vector2(1,1)),d=new Mr(r.colorA),p=new Mr(r.colorB),f=new Mr(r.colorC),h=new Mr(r.colorD),m=new Ge(r.noiseType??0),y=new Ge(r.voronoiStyle??0),g=new se(r.highCut??1),b=new se(r.lowCut??0),w=new se(r.smoothness??.5),_=new se(r.seed??.5),S=new Ge(r.quality??1),P=Zr(r),O=new Ps(i,a,s,l,u,c,d,p,f,h,P.alpha,m,P.isMask,y,g,b,w,_,S),x=new Ze(O.calpha,"f");return new xt(t,e,n,{scale:i,size:a,move:s,fA:l,fB:u,distortion:c,colorA:d,colorB:p,colorC:f,colorD:h,noiseType:m,...P,voronoiStyle:y,highCut:g,lowCut:b,smoothness:w,seed:_,quality:S},O,P.mode,x,P.isMask,o)}case"normal":{let i=new lr(r.cnormal??new it.Vector3(1,1,1)),a=Zr(r),s=new bs(i,a.alpha),l=new Ze(s.calpha,"f");return new xt(t,e,n,{cnormal:i,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let i=new Ge(r.gradientType??0),a=new Et(r.smooth??!1),s;r.colors?s=new _o(r.colors.length,r.colors):(s=new _o(10,new it.Vector4(0,0,0,1)),s.value[1]=new it.Vector4(1,1,1,1));let l;r.steps?l=new Ao(r.steps.length,r.steps):(l=new Ao(10,1),l.value[0]=0);let u=new Pt(r.offset??new it.Vector2(0,0)),c=new Pt(r.morph??new it.Vector2(0,0)),d=new se(r.angle??0),p=Zr(r),f=new As(i,a,s,l,u,c,d,p.alpha,p.isMask),h=new Ze(f.calpha,"f");return new xt(t,e,n,{gradientType:i,smooth:a,colors:s,steps:l,offset:u,morph:c,angle:d,...p},f,p.mode,h,p.isMask,o)}case"pattern":{let i=new Ge(r.style??0),a=new Ge(r.projection??0),s=new Ge(["x","y","z"].indexOf(r.axis)??0),l=new se(r.blending??0),u=new Pt(r.offset??new it.Vector2(0,0)),c=new Mr(r.colorA),d=new Mr(r.colorB),p=new Pt(r.frequency??new it.Vector2(10,10)),f=new se(r.size??.5),h=new se(r.variation??0),m=new se(r.smoothness??.5),y=new se(r.zigzag??0),g=new se(r.rotation??0),b=new Pt(r.vertical??new it.Vector2(0,1)),w=new Pt(r.horizontal??new it.Vector2(0,1)),_=new Ge(r.sides??6),S=Zr(r),P=new Cs(i,a,s,l,u,c,d,p,f,h,m,y,g,b,w,_,S.alpha,S.isMask),O=new Ze(P.calpha,"f");return new xt(t,e,n,{style:i,projection:a,axis:s,blending:l,offset:u,colorA:c,colorB:d,frequency:p,size:f,variation:h,smoothness:m,zigzag:y,rotation:g,vertical:b,horizontal:w,sides:_,...S},P,S.mode,O,S.isMask,o)}default:{let i=new et(1,0,0,1),a=Zr(r),s=new Bi(i,a.alpha),l=new Ze(s.calpha,"f");return new xt(t,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}}}function NM(n,t,e,r){let o=Cb(e,r);return IM(e,n,t,o,r)}function lh(n,t,e,r){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let o=t.uniforms[`f${t.id}_intensity`];return o?(o.value=e.intensity*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="visible")){let o=t.uniforms[`f${t.id}_alpha`];if(!o)return;if(o.value=ei(e.alpha,r)*(e.visible?1:0),e.type==="outline"&&n==="visible"){let i=t.uniforms[`f${t.id}_compensation`];i&&(i.value=e.compensation&&e.visible)}return o}}function md(n,t){let e=0,r=n.layers.find(o=>o.data.type==="light");if(r){let o=r.data,i=Number(t.getVariable(o.alphaOverride));if((typeof o.alphaOverride=="string"?i/100:o.alphaOverride)<1)return!0}for(let o of n.layers){if(o.data.type!=="displace"&&o.data.isMask)return!0;if(o.data.type!=="displace"&&"alpha"in o.data&&o.data.type!=="light"&&o.data.type!=="fresnel"&&o.data.type!=="texture"&&o.data.type!=="matcap"&&o.data.type!=="rainbow"&&o.data.type!=="outline"&&o.data.type!=="pattern"){let i=o.data.visible?o.data.alpha:0;if(typeof i=="string"&&(i=Math.max(0,Math.min(1,Number(t.getVariable(i)??100)/100))),i===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let a of o.data.colors)if(a[3]<1){i=a[3];break}}else if(i===1&&o.data.type==="noise"){let a=t.color(o.data.colorA).a,s=t.color(o.data.colorB).a,l=t.color(o.data.colorC).a,u=t.color(o.data.colorD).a,c=Math.min(a,Math.min(s,Math.min(l,u)));c<1&&(i=c)}e+=(1-e)*i}}return e<1}var Nr=class extends Ib.ShaderMaterial{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},yd=class extends Nr{constructor(e,r,o,i){super();this.flatShading=e;this.side=r;this.wireframe=o;this.root=i}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,r){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,r,o){return this.root.getFlavor(e,r,o)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,r,o){this.root.updateByOp(e,r,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},Ri=class extends Nr{constructor(e,r,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.reset0(e,r)}get nodeMaterial(){return this}getFlavor(e,r,o){let i=o?6:(e?3:0)+r;if(i===0)return this;this.flavors===void 0&&(this.flavors=[]),i-=1;let a=this.flavors[i];return a===void 0&&(a=new yd(e,r,o,this),this.flavors[i]=a,a.flatShading=e,a.side=r,a.updateAfterBuild()),a}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,r,o=!1){(this.data!==e||o)&&this.reset0(e,r)}reset0(e,r){this.data=e;let o=e.layers??sr.defaultTwoLayerData("phong").layers;try{this.layers=o.map(i=>Ho.create(this.layerIdGen++,i.id,i.data,r.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r.shared),this.transparent=md(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=md(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(r)/100,1)));else if(e[0]==="layer"){let i=e[1],a=e[2];if(i&&a){let s=this.layers.find(l=>l.uuid===i);s?.hasValue(a)&&(a==="alpha"?(this.transparent=md(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(r)/100,1)))):s.setValue(a,r))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let r=this.data.layers.find(o=>o.data.type==="light");r&&e.shared.getVariable(r.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(o=>{"alpha"in o.data&&typeof o.data.alpha=="string"&&e.shared.getVariable(o.data.alpha,["material",this.uuid,"layer",o.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(r=>r instanceof Ar),this.lightLayer===void 0&&(this.lightLayer=new Ar(0,"",{...kt.defaultData("light","phong"),visible:!1},new xn,{},e)),this.dispose();for(let r of this.flavors)r&&r.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(a=>a instanceof Ar);if(!e)return;let r=e.data,o=r.bumpMap,i=r.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let a=0;a<this.layers.length;++a){let s=this.layers[a];s instanceof xt&&s.color instanceof Zn&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===i&&(e.node.roughnessMap=s.color))}}updateByOp(e,r,o){if(r!==void 0?this.data=r:r=this.data,this.transparent=md(r,o.shared),e.path[0]==="layers"){this.data=r;let i=o.shared,a=e.path[1];if(a===void 0){if(this.layers.reverse(),e.type===4){let s=Ho.create(this.layerIdGen++,e.id,e.data,o.shared);this.layers.splice(e.localIndex,0,s),o.scene.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),o.scene.markNeedsUpdateRendererDirty();else if(e.type===6){let s=this.layers.findIndex(u=>u.uuid===e.id),l=this.layers[s];this.layers.splice(s,1),this.layers.splice(e.localIndex,0,l),o.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate(o.shared)}else{e.type===0&&e.props.occlusion!==void 0&&o.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(l=>l.uuid===a);if(s){let l=r.layers.data(a),u;if(e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?u={...e.props,alpha:ei(e.props.alpha,i,["material",this.uuid,"layer",a,"alpha"])}:u={...e.props,alphaOverride:ei(e.props.alphaOverride,i,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...u?{props:u}:{},path:e.path.slice(2)},l,o)){let d=Ho.create(this.layerIdGen++,a,l,i);this.layers.splice(this.layers.findIndex(p=>p.uuid===a),1,d),this.onUpdate(o.shared)}}}}else this.reset(r,o)}applyMasks(){for(let e=0;e<this.layers.length;++e){let r=this.layers[e];r instanceof xt?r.color.mask=void 0:r instanceof Ar&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof xt&&r.isMask.value&&r.data.visible&&e>0){let o=e-1,i=this.layers[o];i instanceof Ar?i.node.mask=new or(r.color,r.alpha,or.MUL):i instanceof xt&&(i.isMask.value||(i.color.mask=new or(r.color,r.alpha,or.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof xt),r=this.layers.findIndex(o=>o instanceof Ar);if(e!==-1&&e<r){let o=this.layers[e].color;for(let i=e+1;i<r;++i){let a=this.layers[i];if(a instanceof xt){if(a.isMask.value)continue;o=new xs(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Ze("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof Ar);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let i=this.layers[o];if(i instanceof xt){if(i.isMask.value)continue;e=new xs(e,i.color,i.alpha,i.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof ec);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new or(r,e[o].position,or.ADD),r=new or(r,new se(.5).setReadonly(!0),or.MUL));this.fragment.position=r}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.build(),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}clampUniformsForPreview(e,r){let o=(i,a,s)=>Math.min(Math.max(i,a),s);for(let i of this.layers)if(i.type==="displace"){let a=o(i.uniforms[`f${i.id}_intensity`].value,e,r);i.uniforms[`f${i.id}_intensity`].value=a}}computeCacheKey(){let e="[";for(let{data:r}of this.data.layers)if(r.type==="light")e+=`"${r.visible?r.category.toUpperCase():"Basic"}"`;else{let o=(ih[r.type]??[]).map(u=>r[u]),i=(ah[r.type]??[]).map(u=>r[u]?.length??0),a=[...o,...i],s="isMask"in r&&r.isMask,l=`"${r.type}-${r.visible}-${s}"`;a.length?e+=`[${l}, "${a.join('","')}"],`:e+=l}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(){let e=new ys;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let r of this.flavors)r&&r.updateAfterBuild();return this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof xt){let r=e.params.texture;if(r instanceof Ei&&!r.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(Nr.prototype,{properties:{get:function(){return this.fragment.properties}}});var Vi=class extends Ri{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var Bb=hr(Nb());var Db=new Map;function Eb(n){if(typeof n=="string")return n;let t=Db.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},Db.set(n,t)),t.url}var zi=class{constructor({src:t,volume:e,delay:r,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let i;typeof t=="string"?i={src:t}:i={src:Eb(t),format:"wav"},this.sound=new Bb.Howl(i),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var Xt=require("three"),xd=class{constructor(){this.type="ShapePath";this.color=new Xt.Color;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new Xt.Path,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,r,o){return this.currentPath?.quadraticCurveTo(t,e,r,o),this}bezierCurveTo(t,e,r,o,i,a){return this.currentPath?.bezierCurveTo(t,e,r,o,i,a),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},r={loc:e.ORIGIN,t:0};function o(m,y,g,b){let w=m.x,_=y.x,S=g.x,P=b.x,O=m.y,x=y.y,D=g.y,N=b.y,T=(P-S)*(O-D)-(N-D)*(w-S),I=(_-w)*(O-D)-(x-O)*(w-S),E=(N-D)*(_-w)-(P-S)*(x-O),B=T/E,R=I/E;if(E===0&&T!==0||B<=0||B>=1||R<0||R>1)return null;if(T===0&&E===0){for(let k=0;k<2;k++)if(i(k===0?g:b,m,y),r.loc===e.ORIGIN){let V=k===0?g:b;return{x:V.x,y:V.y,t:r.t}}else if(r.loc===e.BETWEEN){let V=+(w+r.t*(_-w)).toPrecision(10),q=+(O+r.t*(x-O)).toPrecision(10);return{x:V,y:q,t:r.t}}return null}else{for(let q=0;q<2;q++)if(i(q===0?g:b,m,y),r.loc===e.ORIGIN){let F=q===0?g:b;return{x:F.x,y:F.y,t:r.t}}let k=+(w+B*(_-w)).toPrecision(10),V=+(O+B*(x-O)).toPrecision(10);return{x:k,y:V,t:B}}}function i(m,y,g){let b=g.x-y.x,w=g.y-y.y,_=m.x-y.x,S=m.y-y.y,P=b*S-_*w;if(m.x===y.x&&m.y===y.y){r.loc=e.ORIGIN,r.t=0;return}if(m.x===g.x&&m.y===g.y){r.loc=e.DESTINATION,r.t=1;return}if(P<-Number.EPSILON){r.loc=e.LEFT;return}if(P>Number.EPSILON){r.loc=e.RIGHT;return}if(b*_<0||w*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(b*b+w*w)<Math.sqrt(_*_+S*S)){r.loc=e.BEYOND;return}let O;b!==0?O=_/b:O=S/w,r.loc=e.BETWEEN,r.t=O}function a(m,y){let g=[],b=[];for(let w=1;w<m.length;w++){let _=m[w-1],S=m[w];for(let P=1;P<y.length;P++){let O=y[P-1],x=y[P],D=o(_,S,O,x);D!==null&&g.find(N=>N.t<=D.t+Number.EPSILON&&N.t>=D.t-Number.EPSILON)===void 0&&(g.push(D),b.push(new Xt.Vector2(D.x,D.y)))}}return b}function s(m,y,g){let b=new Xt.Vector2;y.getCenter(b);let w=[];return g.forEach(_=>{_.boundingBox.containsPoint(b)&&a(m,_.points).forEach(P=>{w.push({identifier:_.identifier,isCW:_.isCW,point:P})})}),w.sort((_,S)=>_.point.x-S.point.x),w}function l(m,y,g,b,w){(w==null||w==="")&&(w="nonzero");let _=new Xt.Vector2;m.boundingBox.getCenter(_);let S=[new Xt.Vector2(g,_.y),new Xt.Vector2(b,_.y)],P=s(S,m.boundingBox,y);P.sort((I,E)=>I.point.x-E.point.x);let O=[],x=[];P.forEach(I=>{I.identifier===m.identifier?O.push(I):x.push(I)});let D=O[0].point.x,N=[],T=0;for(;T<x.length&&x[T].point.x<D;)N.length>0&&N[N.length-1]===x[T].identifier?N.pop():N.push(x[T].identifier),T++;if(N.push(m.identifier),w==="evenodd"){let I=N.length%2===0,E=N[N.length-2];return{identifier:m.identifier,isHole:I,for:E}}else if(w==="nonzero"){let I=!0,E=null,B=null;for(let R=0;R<N.length;R++){let k=N[R];y[k]&&(I?(B=y[k].isCW,I=!1,E=k):B!==y[k].isCW&&(B=y[k].isCW,I=!0))}return{identifier:m.identifier,isHole:I,for:E}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let u=0,c=999999999,d=-999999999,p=[];this.subPaths.forEach(m=>{let y=m.getPoints(),g=-999999999,b=999999999,w=-999999999,_=999999999;for(let S=0;S<y.length;S++){let P=y[S];P.y>g&&(g=P.y),P.y<b&&(b=P.y),P.x>w&&(w=P.x),P.x<_&&(_=P.x)}d<=w&&(d=w+1),c>=_&&(c=_-1),y.length&&p.push({curves:m.curves,points:y,isCW:Xt.ShapeUtils.isClockWise(y),identifier:u++,boundingBox:new Xt.Box2(new Xt.Vector2(_,b),new Xt.Vector2(w,g))})});let f=p.map(m=>l(m,p,c,d,this.userData?.style.fillRule)),h=[];return p.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let g=new Xt.Shape;g.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let _=p[w.identifier],S=new Xt.Path;S.curves=_.curves,g.holes.push(S)}}),h.push(g)}}),h}};var ch=!1,Rb,uh=new Promise(n=>{Rb=n}),Lb=!1;var bd;function Vb(){if(ch=!0,Lb)return;if(bd)return bd;async function n(){let e=await import("./opentype.js");Rb(e),Lb=!0}return bd=n(),bd}var tc=class{async load(t,e,r=()=>{}){let{load:o}=await uh;o(t,(i,a)=>{i||!a?r(i??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await uh;try{let o=e(t),i=new r,a=s=>o.charToGlyphIndex(s.char);return i.registerModifier("glyphIndex",null,a),i.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:i}}catch(o){console.error(o)}}};async function DM(n){return await(await fetch(n)).arrayBuffer()}var EM=new tc;async function dh(n){let t,e,r=!1;if(n.url?(t=await DM(n.url),e=n.url,r=n.url.startsWith("/")):n.data&&(t=n.data.buffer.slice(n.data.byteOffset,n.data.byteOffset+n.data.byteLength)),t)if(ch){let o=await EM.parse(t);if(o)return{font:o.font,url:e,intercepted:r,arr:t,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:r,arr:t,bidi:null}}var Ls=require("three");function BM(n,t){return t.state.glyphIndex===n||t.state.fina===n||t.state.medi===n||t.state.init===n}var vd=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=dh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=dh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,r){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let i=o.tokenizer.tokens,a=[],s=0,l=r.length===i.length;for(let u=0;u<r.length;u++){let c=r[u].index,d=String.fromCharCode(r[u].unicode),p=i[s];if(BM(c,p)||l)a.push({char:d,index:c,replacements:[p.state.glyphIndex],replacementChars:[p.char]}),s++;else{let f=p.char,h="",m=[p.state.glyphIndex],y=[],g=!1;for(;!g;)s++,h=e.charAt(s),f+=h,m.push(t.charToGlyphIndex(h)),y=t.stringToGlyphs(f),y.length===1&&y[0].index===c&&(g=!0),s>e.length&&(g=!0);a.push({char:d,index:c,replacements:m,replacementChars:Array.from(f)}),s++}}return a}generateShapes(t,e){if(!this._isLoaded)return;let r=this.font,o=e.fontSize/this.unitsPerEm,i=e.fontSize*e.lineHeight,a=t.map(b=>this.getTextWidth(b,e)),s=e.width,l=this.getCharWidth(`
2238
+ `,e),u=e.horizontalAlign===1?l:0,c=this.computeSpaceWidthForLine(t,0,e),d=this.getLineInitialOffsetX(a[0],s,e.horizontalAlign,t[0],l),p=this.getLineInitialOffsetY(i,t.length,e.height,o,e.verticalAlign),f=[],h=t.map(b=>[]),m=t.map(b=>[]),y;for(let b=0;b<t.length;b++){let w=t[b],_={features:{liga:!0}},S=[];try{S=r.stringToGlyphs(w,_)}catch(O){console.warn(O)}d=this.getLineInitialOffsetX(a[b],s,e.horizontalAlign,w,l);let P=[];try{P=this.reverseLigaturesTable(r,w,S)}catch(O){console.warn(O)}c=this.computeSpaceWidthForLine(t,b,e);for(let O=0;O<S.length;O++){let x=S[O],D=x.index===0?`
2239
+ `:x.unicode?String.fromCharCode(x.unicode):void 0,N=P[O],T=0,I=0;O===0&&e.horizontalAlign===2&&x.leftSideBearing!==void 0&&(I=-x.leftSideBearing*o),y&&(T=r.getKerningValue(x,y)*o),d+=I+T;let E=0;if(D===`
2240
+ `)E=u;else if(D===" ")E=c;else{let B=this.createPath(x,o,d,p,e);B&&(E=B.offsetX-(T+I),f.push(B.path))}if(N.replacements.length===1)m[b].push([d,p]),h[b].push(E);else{let B=N.replacements.map(q=>(r.glyphs.get(q).advanceWidth??0)*o),R=B.reduce((q,F)=>q+=F,0),k=B.map(q=>q/R),V=d;for(let q=0;q<k.length;q++){let F=E*k[q];m[b].push([V,p]),h[b].push(F),V+=F}}d+=E,y=x}p-=i}let g=[];for(let b=0,w=f.length;b<w;b++)g.push(...f[b].toShapes());return{shapes:g,charWidths:h,lineWidths:a,charCoords:m}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,r,o,i){return(r===3||r===2)&&o.indexOf(`
2241
+ `)>=0&&(t-=i),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,o,i){let a=e*t,s=Math.abs(this.ascender-this.descender)*o,l=t-s,u=-this.ascender*o-l/2;return i===3?-(r-a-u):i===2?-(r*.5-a*.5-u):u}createPath(t,e,r,o,i){let a=t.getPath(r,-o,i.fontSize,{kerning:!1,letterSpacing:i.letterSpacing});if(!a){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let s=new xd,l=(t.advanceWidth??1)*e;if(t)for(let u of a.commands){let c=s.currentPath?.currentPoint;if(!(c&&u.type!=="Z"&&c.x===u.x&&-c.y===u.y))switch(u.type){case"M":s.moveTo(u.x,-u.y);break;case"L":s.lineTo(u.x,-u.y);break;case"Q":s.quadraticCurveTo(u.x1,-u.y1,u.x,-u.y);break;case"C":s.bezierCurveTo(u.x1,-u.y1,u.x2,-u.y2,u.x,-u.y);break}}return s.subPaths.forEach(u=>{let c=LM(u.curves);c!==void 0&&u.currentPoint.distanceTo(c)>0&&u.lineTo(c.x,c.y)}),{offsetX:l+i.fontSize*i.letterSpacing,path:s}}getCharWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(t,e,r){let o=this.getCharWidth(" ",r),i=t[e];if(i){let a=this.countSpaces(i.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&a){let s=r.width,l=this.getTextWidth(i,r);return(s-(l-a*o))/a}}return o}countSpaces(t){return(t.match(/ /g)||[]).length}};function LM(n){if(n.length){let t=n[0];if(t instanceof Ls.LineCurve)return t.v1;if(t instanceof Ls.CubicBezierCurve||t instanceof Ls.QuadraticBezierCurve)return t.v0}}var ph=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let o=this.objects.get(t);return o===void 0?(o=this.createObject(t,e,r),this.objects.set(t,o)):o.isShared=!0,o}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},rc=class extends ph{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,o){let i=gn(e,r,this.flatShading,o);return i.computeBoundingSphere(),i}};var zb={markNeedsUpdateRendererDirty:()=>{}};var fh=require("three"),hh=class extends hd{constructor(e){super();this.shared=e}create(e){return new Es(e,this.shared)}},Gi=class{constructor(t,e={}){this.data=t;this.geometryCache=new rc(!0);this.geometryCache2=new rc(!1);this.imageHolderCache=new hh(this);this.thisContext={scene:zb,shared:this};this.deletedMaterial=new Vi(sr.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new jr(Ga.emptyImage,this);this.deletedVideo=new jr(Na.defaultVideo,this);this.materials={};this.images={};this.canvases={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.variables={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[r,o]of Object.entries(e.images))this.addImage(r,o);if(e.videos)for(let[r,o]of Object.entries(e.videos))this.addVideo(r,o);if(e.audios)for(let[r,o]of Object.entries(e.audios))this.addAudio(r,o);if(e.particles)for(let[r,o]of Object.entries(e.particles))this.addParticle(r,o);this.reset(t)}setRequestRender(t){this._requestRender=t}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1){this.resetLib(t.lib);for(let{id:r,data:o}of t.variables)this.addVariableHolder(r,o),e&&this.updateVariableHolder(r,o);for(let[r,o]of Object.entries(t.images))this.addImage(r,o);for(let[r,o]of Object.entries(t.videos))this.addVideo(r,o);for(let[r,o]of Object.entries(t.colors))this.addColor(r,o);for(let[r,o]of Object.entries(t.materials))this.addMaterial(r,o);for(let[r,o]of Object.entries(t.audios))this.addAudio(r,o);for(let[r,o]of Object.entries(t.particles))this.addParticle(r,o);for(let[r,o]of Object.entries(t.fonts))this.addFont(r,o)}addMaterial(t,e){if(this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=new Vi(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):new Ri(t,this.thisContext)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new jr(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addCanvas(t,e){return this.canvases[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.canvases[t].updateSrc(e),!0):(this.canvases[t]=new jr(e,this),!1)}canvas(t){return this.canvases[t]}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new jr(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Jn(e.r,e.g,e.b,e.a):this.colors[t]=new Jn(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Yt(0,0,0,0))}else return"a"in t?new Yt(t.r,t.g,t.b,t.a):new Yt(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof zi)return e;{let r=new zi({src:e.data});return this.audios[t]=r,r}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof zi&&e.dispose(),delete this.audios[t])}addFont(t,e){this.fonts[t]=new vd(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof zi&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){return this.variables[t]===void 0?(this.variables[t]={value:e.value,locations:[]},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0):(this.variables[t].value=e.value,!1)}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e;let r=e;for(;typeof r=="string";)r=this.variables[r].value;let o=this.entityOpContext.scene;for(let i=this.variables[t].locations.length-1;i>=0;i--){let a=this.variables[t].locations[i];if(a[0]==="material"){let s=a[1],l=r,u={scene:o,shared:this},c=a.slice(2);o.traverseMaterial(p=>{let f=p.root??p;f.uuid===s&&f.onVariableUpdate(c,l,u)});let d=this.materials[s];d&&d.onVariableUpdate(c,l,u)}else{let s=o.find(a[0]);if(s===void 0){this.variables[t].locations.splice(i,1);continue}if(a[1]!=="geometry"&&a[1]!=="particles"){for(let l=1;l<a.length-1;l++)s=s[a[l]];a[1]==="rotation"?s[a[a.length-1]]=r*fh.MathUtils.DEG2RAD:s[a[a.length-1]]=r}if(s=o.find(a[0]),s.type==="ParticleEmitter"&&s.updateVariableState(r,a),Fe.is(s)){if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")s.onVariableUpdate();else if(a[1]==="geometry"){let l=s;s.component&&(l=s.component);let u=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(u.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.instances.forEach(c=>{let d=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(d.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0)})}}}}return!0}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];for(let o=1;o<t.length;o++)r=r[t[o]];return t[1]==="rotation"&&(r*=fh.MathUtils.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let o=this.variables[r],i=o.locations?.findIndex(a=>St.equal(a,e));i!==void 0&&i!==-1&&o.locations.splice(i,1)}if(typeof t=="string"){let r=t,o=t;do{if(o=r,this.variables[r]===void 0)break;r=this.variables[r].value}while(typeof r=="string");return e&&this.variables[o]!==void 0&&this.variables[o].locations.push(e),r}else return t}getVariables(){return this.variables}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.particles))this.addParticle(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){this.data=e,t.path[0]==="images"?t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(wt.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r}):t.path[0]==="fonts"?t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===2&&t.type===0&&"value"in t.props?this.updateVariable(t.path[1],t.props.value):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id):t.path[0]==="lib"&&this.updateLibByOp(wt.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let o=this.getFont(t),i={...this.data.fonts[t],url:e.props.url};o.update(i),o.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}},Gb=new Gi(Qr.emptyData());var Dr=class extends Wt{updateByPatchedOp(e,r,o){if(super.updateByPatchedOp(e,r,o),Ig(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[i,a]of Object.entries(e.props)){let s=o.shared.material(a);this.material[Number(i)]=s}else if(ke(e.path,["material"])&&this.material instanceof Nr)"material"in r&&typeof r.material!="string"&&this.material.updateByOp(wt.drop(e,1),r.material,o);else if(ke(e.path,["materials","*"])&&Array.isArray(this.material)){let i=e.path[1];if("materials"in r&&i<this.material.length){let a=r.materials[i];typeof a!="string"&&this.material[i].updateByOp(wt.drop(e,2),a,o)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let o=this.dataPatched;if(e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe),r.scene.markNeedsUpdateRendererDirty()),(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(i=>r.shared.material(i).getFlavor(o.flatShading,o.side,o.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe)],r.scene.markNeedsUpdateRendererDirty())),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let i=0;i<this.material.length;i++)this.material[i]=this.material[i].getFlavor(o.flatShading,o.side,o.wireframe);else this.material=this.material.getFlavor(o.flatShading,o.side,o.wireframe)}disposeMaterial(){this.material&&Pc(this.material).forEach(e=>{e instanceof Nr&&(e instanceof Vi||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var Ur=require("three");var kb=new Ur.Vector3,Fb=new Ur.Vector4,jb=new Ur.Vector4,VM=new Ur.Vector3,Ub=new Ur.Matrix4,Ot=class extends Dr{constructor(e,r,o){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new Ur.Matrix4().fromArray(r.bindMatrix),this.bindMatrixInverse=new Ur.Matrix4)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof Ur.BufferGeometry&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Gi){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=r.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return wl.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return wl.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),ke(e.path,["geometry"])&&this.updateByPatchedOpGeometry(wt.drop(e,1),r.geometry,o)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let o=this.data.geometry.type;if(o==="NonParametricGeometry"||o==="SubdivGeometry"){let i=e;if(this.localGeometry===void 0){let c={...this.data.geometry,...i};this.localGeometry=gn(c,r,this.data.flatShading,this)}let a,s,l;i.scaleBaked?[a,s,l]=i.scaleBaked:{width:a,height:s,depth:l}=i;let u=this.localGeometry.userData;u.sxPrev!==void 0&&kl(this.localGeometry.attributes,a/u.sxPrev,s/u.syPrev,l/u.szPrev),u.sxPrev=a,u.syPrev=s,u.szPrev=l}else{let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=gn(i,r,this.data.flatShading,this)}}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,o){let i=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof Vt&&this.chooseGeoemtryCache(o.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(i=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(o),this.refreshAttachedPaths(o)),i||(o.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(o)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r),super.updateState(e,r)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,r){let o=this.geometry.userData.parameters;this.is2DType?e.set(0,0,o.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)):e.setScalar(0),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new Ur.Vector4,o=this.geometry.attributes.skinWeight;for(let i=0,a=o.count;i<a;i++){r.fromBufferAttribute(o,i);let s=1/r.manhattanLength();s!==1/0?r.multiplyScalar(s):r.set(1,0,0,0),o.setXYZW(i,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let o=this.skeleton;if(o===void 0)return;let i=this.geometry;Fb.fromBufferAttribute(i.attributes.skinIndex,e),jb.fromBufferAttribute(i.attributes.skinWeight,e),kb.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let a=0;a<4;a++){let s=jb.getComponent(a);if(s!==0){let l=Fb.getComponent(a);Ub.multiplyMatrices(o.bones[l].matrixWorld,o.boneInverses[l]),r.addScaledVector(VM.copy(kb).applyMatrix4(Ub),s)}}return r.applyMatrix4(this.bindMatrixInverse)}};function zM(n){if(n.geometry.attributes.extrudeNormal||!n.geometry.attributes.position||!n.geometry.attributes.normal)return;let t=new Map,e=n.geometry.attributes,r=e.position.array,o=e.normal.array,i=new Float32Array(r.length);for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=new Hr.Vector3(o[a],o[a+1],o[a+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new Hr.Vector3})}t.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=t.get(s)?.result;l&&(i[a]=l.x,i[a+1]=l.y,i[a+2]=l.z)}n.geometry.setAttribute("extrudeNormal",new Hr.Float32BufferAttribute(i,3))}function GM(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,r=new Float32Array(e.length),o=new Hr.Vector3;for(let i=0;i<e.length;i+=3)o.set(e[i],e[i+1],e[i+2]).normalize(),r[i]=o.x,r[i+1]=o.y,r[i+2]=o.z;n.geometry.setAttribute("extrudeNormal",new Hr.Float32BufferAttribute(r,3))}function Rs(n){if(Array.isArray(n.material)){for(let t of n.material)if(t.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof Nr)||n.material.getLayersOfType("outline").length===0)return;n instanceof Ot&&n.is2DAndNoDepth?GM(n):zM(n)}function Vs(n){if(!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,r=new Float32Array(e.length),o=parseInt(n.uuid.replace(/\D/g,"")),i=[Hr.MathUtils.seededRandom(o),Hr.MathUtils.seededRandom(o+1e4),Hr.MathUtils.seededRandom(o+2e4)];for(let a=0;a<e.length;a++)r[a]=i[a%3];n.geometry.setAttribute("randomColor",new Hr.BufferAttribute(r,3))}var qo=new vn.Box3,oc=new vn.Vector3;function Hb(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var ki=class extends Ot{constructor(e,r,o){super(e,r,o);this.data=r;this.hiddenMatrixOld=new vn.Matrix4;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let o=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:o,subdividedGeometry:i,subdivPointer:a}=Vt.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,o!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=o),i!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Rs(this),Vs(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let o=this.material;this.material=Array.isArray(o)?o.map(i=>i.getFlavor(!1,i.side,i.wireframe)):o.getFlavor(!1,o.side,o.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1){Vt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&Vt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Vt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Vt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){let o=this.localGeometry;this.localGeometry=this.originalGeometryNew,Wt.prototype.raycast.call(this,e,r),this.localGeometry=o}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new vn.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;qo.setFromBufferAttribute(r),qo.getCenter(o),e.boundingSphere.radius=o.distanceTo(qo.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),qo.getSize(oc),this.hasNonUniformScale&&oc.divide(this.scale);let i={width:oc.x,height:oc.y,depth:oc.z};return this.geometry.userData.parameters=i,i}updateBoundingSphere(e){let r=this.originalGeometry;qo.min.set(e[0],e[2],e[4]),qo.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(qo.min.applyMatrix4(this.shearScaleInv),qo.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new vn.Sphere);let o=r.boundingSphere.center;qo.getCenter(o),r.boundingSphere.radius=o.distanceTo(qo.max)}freeSubdivPointer(){this.subdivPointer&&(Vt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,r,o){super.updateByPatchedOpGeometry(e,r,o),this.localGeometry&&this.createGeometryByControls(r)}};var Wo=require("three"),qb=-1,kM=1,Wb={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},$b={polygon_center:0,edge:1,vertex:2},nc=(n,t)=>(e,r)=>!t||e===0||n===0?0:n*r/100,Ie=(n,t)=>{let e=Math.abs(t),r=e*-1;return(n-qb)*(e-r)/(kM-qb)+r};function Yb(n){let t=[],e={};for(var r=0,o=n.length;r<o;r++){var i=JSON.stringify(n[r].pos.map(a=>Math.round(a*1e4)/1e4));e[i]||(t.push(n[r]),e[i]=!0)}return t}var FM=new Wo.Vector3,Sd=new Wo.Vector3,jM=new Wo.Vector3,UM=new Wo.Vector3;function zs(n,t){let e=jM.fromArray(n),r=UM.fromArray(t);Sd.copy(r).sub(e);let o=Sd.length();return Sd.normalize().multiplyScalar(o*.5),FM.copy(e).add(Sd).toArray()}var Jr=new Wo.Triangle,wd=new Wo.Vector3,Ad=new Wo.Vector3,Fi=new Wo.Vector3;function Xb(n){let t=[];for(let e=0;e<=n.index.count;e++)if(wd.fromArray(n.index.array,e*3),Jr.setFromAttributeAndIndices(n.attributes.position,wd.x,wd.y,wd.z),Jr.getNormal(Ad),Jr.getMidpoint(Fi),!(isNaN(Fi.x)||isNaN(Fi.y)||isNaN(Fi.z))){let{a:r,b:o,c:i}=Jr,a=r.toArray(),s=o.toArray(),l=i.toArray(),u=r.distanceTo(o),c=o.distanceTo(i),d=i.distanceTo(r),p=zs(a,s),f=zs(s,l),h=zs(l,a),m=[u,c,d],y=Math.max(...m),g=m.filter(_=>Math.round(_)===Math.round(y)).length>1,b=[],w=Jr.getMidpoint(Fi).toArray();y===u&&!g&&(b=[f,h,h],w=p),y===c&&!g&&(b=[p,h,h],w=f),y===d&&!g&&(b=[p,f,f],w=h),g&&(b=[p,f,h]),t.push({vertices:[a,s,l],faceCenters:b,midpoint:w,norm:Jr.getNormal(Ad).toArray()})}return t}function Qb(n){let t=[],{position:e}=n.attributes;for(let r=0;r<e.count;r++){Jr.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),Jr.getNormal(Ad),Jr.getMidpoint(Fi);let o=Jr.a.toArray(),i=Jr.b.toArray(),a=Jr.c.toArray();t.push({vertices:[o,i,a],faceCenters:[zs(o,i),zs(i,a),zs(a,o)],midpoint:Fi.toArray(),norm:Ad.toArray()})}return t}var HM=4,qM=.5,mh=n=>.5*(1-Math.cos(n*Math.PI)),yh=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let o=Math.floor(t),i=Math.floor(e),a=Math.floor(r),s=t-o,l=e-i,u=r-a,c,d,p=0,f=.5,h,m,y;for(let g=0;g<HM;g++){let b=o+(i<<4)+(a<<8);c=mh(s),d=mh(l),h=this.perlin[b&4095],h+=c*(this.perlin[b+1&4095]-h),m=this.perlin[b+16&4095],m+=c*(this.perlin[b+16+1&4095]-m),h+=d*(m-h),b+=256,m=this.perlin[b&4095],m+=c*(this.perlin[b+1&4095]-m),y=this.perlin[b+16&4095],y+=c*(this.perlin[b+16+1&4095]-y),m+=d*(y-m),h+=mh(u)*(m-h),p+=h*f,f*=qM,o<<=1,s*=2,i<<=1,l*=2,a<<=1,u*=2,s>=1&&(o++,s--),l>=1&&(i++,l--),u>=1&&(a++,u--)}return p}noiseSeed(t){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},Kb=yh;var ks=require("three");var Zb=new ks.Vector3,Jb=new ks.Matrix4,ev=new ks.Ray;function tv(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="TextGeometry"&&(t=!0)}),t}var Gs=class extends Ot{constructor(e,r,o){super(e,r,o);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,e.geometry.height,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:o}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(Jb.copy(o).invert(),ev.copy(e.ray).applyMatrix4(Jb),ev.intersectBox(this.singleBBox,Zb))){let i=Zb.applyMatrix4(o),a=e.ray.origin.distanceTo(i);r.push({distance:a,point:i.clone(),object:this})}}};var _r=1e-4,$o,nv,iv,av,rv=new tt.Vector3,ov=new tt.Vector3;td.then(n=>{$o=n,nv=[$o.get_face_center,$o.get_edge_midpoint,$o.get_vertex_position],iv=[$o.get_face_normal,$o.get_edge_normal,$o.get_vertex_normal],av=[$o.face_count,$o.edge_count,$o.vertex_count]});var WM=new tt.Matrix4,$M=new tt.Matrix4,ti=new tt.Vector3,ji=new tt.Vector3,ic=new tt.Vector3,gh=new tt.Vector3,YM=new tt.Vector3,XM=new tt.Vector3;var Sn=new Kb,js=class extends Ha(tt.Object3D){constructor(e,r){super();this.parameters=r;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let r of this.children)r instanceof fn&&r.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(r=>{r instanceof fn&&r.object===e&&(r.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let e of this.children)e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD())}_updateCount(e){let r;if(e!==void 0?r=e:r=this.parameters.type==="grid"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(r=0),this.parameters.type==="toObject"&&this.objectForSample){for(let i=0,a=this.children.length;i<a;++i)this.remove(this.children[0]);let o=this.children;if(o.length===r)return;if(o.length<r)for(let i=0,a=r-o.length;i<a;++i){let s=new fn(this.object);s.expand(),this.add(s)}else for(let i=0,a=o.length-r;i<a;++i)this.remove(o[i])}else{if(this.children.length===r)return;if(this.children.length<r)for(let o=0,i=r-this.children.length;o<i;++o){let a=new fn(this.object);a.expand(),this.add(a)}else for(let o=0,i=this.children.length-r;o<i;++o)this.remove(this.children[0])}}_updateRadial(e){let r=e.radial,o=r.start*tt.MathUtils.DEG2RAD,i=r.end*tt.MathUtils.DEG2RAD,a=o-i,s=new tt.Euler(r.rotation[0],r.rotation[1],r.rotation[2]),l;switch(r.axis){case"z":l=new tt.Vector3(0,0,1);break;case"y":l=new tt.Vector3(0,1,0);break;default:case"x":l=new tt.Vector3(1,0,0);break}let u=e.randomnessObject??Lo.defaultData([1,1,1]).randomnessObject,c=u.noiseType==="perlin";Sn.noiseSeed(u.seed);let d=Vu((0,Fs.default)(u.seed)),p=nc(u.strength,this.parameters.randomness);for(let[f,h]of this.children.entries()){let m=f*(u.freqScale/10)+u.movement,y=c?Sn.noise(m):d(m,m),g=f+1;h.scale.x=r.scale[0]+p(g,Ie(y,u.scale[0]))||_r,h.scale.y=r.scale[1]+p(g,Ie(y,u.scale[1]))||_r,h.scale.z=r.scale[2]+p(g,Ie(y,u.scale[2]))||_r,h.position.setScalar(0);let b=a/e.count*f-o;switch(r.axis){case"x":h.rotation.set(0,b,0);break;case"y":h.rotation.set(0,0,b);break;case"z":h.rotation.set(b,0,0);break}h.translateOnAxis(l,r.radius),h.position.x+=r.position[0]+p(g,Ie(y,u.position[0])),h.position.y+=r.position[1]+p(g,Ie(y,u.position[1])),h.position.z+=r.position[2]+p(g,Ie(y,u.position[2]));let w=p(g,Ie(y,u.rotation[0])),_=p(g,Ie(y,u.rotation[1])),S=p(g,Ie(y,u.rotation[2]));r.alignment===!0?(h.rotation.x+=s.x+w,h.rotation.y+=s.y+_,h.rotation.z+=s.z+S):h.rotation.set(s.x+w,s.y+_,s.z+S)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let r=e.linear,o=new tt.Euler(r.rotation[0],r.rotation[1],r.rotation[2]),i=e.randomnessObject??Lo.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";Sn.noiseSeed(i.seed);let s=Vu((0,Fs.default)(i.seed)),l=nc(i.strength,this.parameters.randomness);for(let[u,c]of this.children.entries()){let d=u*(i.freqScale/10)+i.movement,p=a?Sn.noise(d):s(d,d),f=u+1,h=l(f,Ie(p,i.rotation[0])),m=l(f,Ie(p,i.rotation[1])),y=l(f,Ie(p,i.rotation[2]));c.scale.x=1+(r.scale[0]-1)*u+l(f,Ie(p,i.scale[0]))||_r,c.scale.y=1+(r.scale[1]-1)*u+l(f,Ie(p,i.scale[1]))||_r,c.scale.z=1+(r.scale[2]-1)*u+l(f,Ie(p,i.scale[2]))||_r,c.rotation.x=o.x*u+h,c.rotation.y=o.y*u+m,c.rotation.z=o.z*u+y,c.position.x=r.position[0]*u+l(f,Ie(p,i.position[0])),c.position.y=r.position[1]*u+l(f,Ie(p,i.position[1])),c.position.z=r.position[2]*u+l(f,Ie(p,i.position[2]))}}_updateGrid(e){let r=0,o=e.grid,i=e.randomnessObject??Lo.defaultData([1,1,1]).randomnessObject,a=nc(i.strength,this.parameters.randomness),s=i.noiseType==="perlin";Sn.noiseSeed(i.seed);let l=L0((0,Fs.default)(i.seed));if(o.useCenter===!0){let u={x:o.count[0]%2===0?2:1,y:o.count[1]%2===0?2:1,z:o.count[2]%2===0?2:1},c=new tt.Vector3(o.size[0]*(o.count[0]-u.x)*.5,o.size[1]*(o.count[1]-u.y)*.5,o.size[2]*(o.count[2]-u.z)*.5);for(let d=0;d<o.count[0];d++)for(let p=0;p<o.count[1];p++)for(let f=0;f<o.count[2];f++){let h=[(d+1)*(i.freqScale/10)+i.movement,(p+1)*(i.freqScale/10)+i.movement,(f+1)*(i.freqScale/10)+i.movement],m=s?Sn.noise(...h):l(...h),y=this.children[r++];y.scale.x=1+a(r,Ie(m,i.scale[0]))||_r,y.scale.y=1+a(r,Ie(m,i.scale[1]))||_r,y.scale.z=1+a(r,Ie(m,i.scale[2]))||_r;let g=a(r,Ie(m,i.rotation[0])),b=a(r,Ie(m,i.rotation[1])),w=a(r,Ie(m,i.rotation[2]));y.rotation.set(g,b,w),y.position.x=o.size[0]*d-c.x+a(r,Ie(m,i.position[0])),y.position.y=o.size[1]*p-c.y+a(r,Ie(m,i.position[1])),y.position.z=o.size[2]*f-c.z+a(r,Ie(m,i.position[2]))}}else for(let u=0;u<o.count[0];u++)for(let c=0;c<o.count[1];c++)for(let d=0;d<o.count[2];d++){let p=[(u+1)*(i.freqScale/10)+i.movement,(c+1)*(i.freqScale/10)+i.movement,(d+1)*(i.freqScale/10)+i.movement],f=s?Sn.noise(...p):l(...p),h=this.children[r++];h.scale.x=1+a(r,Ie(f,i.scale[0]))||_r,h.scale.y=1+a(r,Ie(f,i.scale[1]))||_r,h.scale.z=1+a(r,Ie(f,i.scale[2]))||_r;let m=a(r,Ie(f,i.rotation[0])),y=a(r,Ie(f,i.rotation[1])),g=a(r,Ie(f,i.rotation[2]));h.rotation.set(m,y,g),h.position.x=o.size[0]*u+a(r,Ie(f,i.position[0])),h.position.y=-o.size[1]*c+a(r,Ie(f,i.position[1])),h.position.z=-o.size[2]*d+a(r,Ie(f,i.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:r}=e,o=new tt.Euler(r.rotation[0],r.rotation[1],r.rotation[2]),i=e.randomnessObject??Lo.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";Sn.noiseSeed(i.seed);let s=Vu((0,Fs.default)(i.seed)),l=nc(i.strength,this.parameters.randomness);if(!r.object){for(let[,g]of this.children.entries())g.position.set(0,0,0),g.scale.setScalar(1),g.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof Gs)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let u=this.getSubdivData(),c=[],d=g=>{let b=g.length,w=g.map(P=>P[0]).reduce((P,O)=>P+O,0),_=g.map(P=>P[1]).reduce((P,O)=>P+O,0),S=g.map(P=>P[2]).reduce((P,O)=>P+O,0);return[w/b,_/b,S/b]},p=g=>Math.round(g*1e6)/1e6;u.forEach(g=>{let b=u.filter(w=>p(g.pos[0])===p(w.pos[0])&&p(g.pos[1])===p(w.pos[1])&&p(g.pos[2])===p(w.pos[2]));b.length>1?c.push({pos:g.pos,norm:d(b.map(w=>w.norm))}):c.push(g)});let f=Yb(c);if(f.length>0){let g=Math.round(f.length*r.count/100);this._updateCount(g)}else{let g=this.objectForSample.geometry.getAttribute("position");if(!g||isNaN(g.count)||g.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let h=new zu(this.objectForSample).build(),m=Wb[r.axis],y=this.children;h.setRandomGenerator((0,Fs.default)(this.object.uuid+r.seed));for(let[g,b]of y.entries()){let w=g*(i.freqScale/10)+i.movement,_=a?Sn.noise(w):s(w,w),S=g+1,P=l(S,Ie(_,i.rotation[0])),O=l(S,Ie(_,i.rotation[1])),x=l(S,Ie(_,i.rotation[2]));r.spreadType==="random"?h.sample(ic,gh):(f.length&&(ic.fromArray(f[g].pos),gh.fromArray(f[g].norm)),this.objectForSample instanceof ki&&ic.applyMatrix4(WM.copy(this.objectForSample.matrixWorld).invert())),ic.applyMatrix4(this.object.hiddenMatrix.clone().invert()),b.position.copy(ic),ti.fromArray(m);let D=r.align==="normal"?gh:this.object.getWorldDirection(XM),N=ji.fromArray(r.position);ji.x+=ji.x+l(S,Ie(_,i.position[0])),ji.y+=ji.y+l(S,Ie(_,i.position[1])),ji.z+=ji.z+l(S,Ie(_,i.position[2]));let T=Math.acos(D.dot(ti)),I=YM.crossVectors(ti,D).normalize(),E=$M.makeRotationAxis(I,T),B=D.clone().cross(this.object.up).normalize(),R=B.clone().cross(D).normalize(),k=new tt.Matrix4().makeBasis(B,D,R),V=new tt.Vector3(ti.y,ti.z,ti.x).normalize(),q=V.clone().cross(ti).normalize(),F=new tt.Matrix4().makeBasis(V,ti,q).invert(),U=new tt.Matrix4().multiplyMatrices(k,F);b.rotation.setFromRotationMatrix(U),N.applyMatrix4(E),b.position.add(N),b.rotation.x=b.rotation.x+o.x+P,b.rotation.y=b.rotation.y+o.y+O,b.rotation.z=b.rotation.z+o.z+x,b.scale.setScalar(1),b.scale.x=b.scale.x+r.scale[0]+l(S,Ie(_,i.scale[0]))||_r,b.scale.y=b.scale.y+r.scale[1]+l(S,Ie(_,i.scale[1]))||_r,b.scale.z=b.scale.z+r.scale[2]+l(S,Ie(_,i.scale[2]))||_r,b.scale.multiply(this.object.scale),b.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof ki){let r=this.objectForSample,o=$b[e],i=av[o],a=nv[o],s=iv[o],l=[],u=i(r.subdivPointerNew);for(let c=0;c<=u-1;c++){let d=a(r.subdivPointerNew,c),p=s(r.subdivPointerNew,c);rv.fromArray(d).applyMatrix4(r.matrixWorld),ov.fromArray(p),l.push({pos:rv.toArray(),norm:ov.toArray()})}return l}else return(this.objectForSample.geometry.index?Xb(this.objectForSample.geometry):Qb(this.objectForSample.geometry)).map((o,i)=>e==="polygon_center"?{pos:o.midpoint,norm:o.norm}:e==="vertex"?[{pos:o.vertices[0],norm:o.norm},{pos:o.vertices[1],norm:o.norm},{pos:o.vertices[2],norm:o.norm}]:e==="edge"?[{pos:o.faceCenters[0],norm:o.norm},{pos:o.faceCenters[1],norm:o.norm},{pos:o.faceCenters[2],norm:o.norm}]:[]).flat()}updateState(e,r){if(this.parameters=on(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let o=r.find(this.parameters.toObject.object);o instanceof Wt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new tt.Matrix4,this.hiddenMatrix=new tt.Matrix4,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};var lo=require("three");var bt=require("three");var dr=require("three");var sv=require("three"),Yo=n=>{var t;return t=class extends n{},t.geometryHelper=new sv.BoxGeometry(30,30,30),t};var yr=require("three"),_d=new yr.Ray,xh=new yr.Sphere,lv=new yr.Matrix4,Xo=(n,t,e,r,o=!1)=>{let i=t,a=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),xh.copy(i.boundingSphere),xh.applyMatrix4(a),e.ray.intersectsSphere(xh)===!1||(lv.copy(a).invert(),_d.copy(e.ray).applyMatrix4(lv),i.boundingBox!==null&&_d.intersectsBox(i.boundingBox)===!1))return;let s,l,u,c,d=i.index,p=i.attributes.position,f=i.drawRange,h,m;if(o===!1){let g=Math.max(0,f.start),b=Math.min(d.count,f.start+f.count);for(h=g,m=b;h<m;h+=3)if(l=d.getX(h),u=d.getX(h+1),c=d.getX(h+2),s=y(n,e,_d,p,l,u,c),s){s.faceIndex=Math.floor(h/3),r.push(s);return}}else{let b=i.attributes.position,w=new yr.Vector3,_=new yr.Vector3,S=new yr.Vector3,P=new yr.Vector3,O=2,D=1/((n.scale.x+n.scale.y+n.scale.z)/3),N=D*D,T=Math.max(0,f.start),I=Math.min(b.count,f.start+f.count);for(let E=T,B=I-1;E<B;E+=O){if(w.fromBufferAttribute(b,E),_.fromBufferAttribute(b,E+1),_d.distanceSqToSegment(w,_,P,S)>N)continue;P.applyMatrix4(n.matrixWorld);let k=e.ray.origin.distanceTo(P);k<e.near||k>e.far||r.push({distance:k,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(g,b,w,_,S,P,O){let x=new yr.Vector3,D=new yr.Vector3,N=new yr.Vector3,T=new yr.Vector3,I=new yr.Vector3;if(x.fromBufferAttribute(_,S),D.fromBufferAttribute(_,P),N.fromBufferAttribute(_,O),w.intersectTriangle(x,D,N,!1,T)===null)return null;I.copy(T),I.applyMatrix4(g.matrixWorld);let B=b.ray.origin.distanceTo(I);return B<b.near||B>b.far?null:{faceIndex:1,distance:B,point:I.clone(),object:g}}};var Pd=new dr.Vector3,eo=new dr.Camera,bh=class extends dr.LineSegments{constructor(e){let r=new dr.BufferGeometry,o=new dr.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],a=[],s={},l=new dr.Color(15711266),u=new dr.Color(15711266),c=new dr.Color(2857471);d("n1","n2",l),d("n2","n4",l),d("n4","n3",l),d("n3","n1",l),d("f1","f2",l),d("f2","f4",l),d("f4","f3",l),d("f3","f1",l),d("n1","f1",l),d("n2","f2",l),d("n3","f3",l),d("n4","f4",l),d("p","n1",u),d("p","n2",u),d("p","n3",u),d("p","n4",u),d("u1","u2",c),d("u2","u3",c),d("u3","u1",c);function d(f,h,m){p(f,m),p(h,m)}function p(f,h){i.push(0,0,0),a.push(h.r,h.g,h.b),s[f]===void 0&&(s[f]=[]),s[f].push(i.length/3-1)}r.setAttribute("position",new dr.Float32BufferAttribute(i,3)),r.setAttribute("color",new dr.Float32BufferAttribute(a,3));super(r,o);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,r=this.pointMap,o=!0;eo.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=1,a=1,s=o?.8:1e-4;Oo("n1",r,e,eo,-i,-a,s),Oo("n2",r,e,eo,i,-a,s),Oo("n3",r,e,eo,-i,a,s),Oo("n4",r,e,eo,i,a,s);let l=s;Oo("f1",r,e,eo,-i,-a,l),Oo("f2",r,e,eo,i,-a,l),Oo("f3",r,e,eo,-i,a,l),Oo("f4",r,e,eo,i,a,l);let u=l,c=.5;Oo("u1",r,e,eo,i*.7*c,a*1.1,u),Oo("u2",r,e,eo,-i*.7*c,a*1.1,u),Oo("u3",r,e,eo,0,a*(1.1+.9*c),u),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Oo(n,t,e,r,o,i,a){Pd.set(o,i,a).unproject(r);let s=t[n];if(s!==void 0){let l=e.getAttribute("position");for(let u=0,c=s.length;u<c;u++)l.setXYZ(s[u],Pd.x,Pd.y,Pd.z)}}var Od=class extends Yo(bh){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,r){Xo(this.object,this.geometry,e,r,!0)}};var ac=require("three");var Cd;(t=>t.is=e=>"objectHelper"in e)(Cd||(Cd={}));var to=(n,t)=>class extends $a(n){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(o,i){this.objectHelper.raycast(o,i)}showGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof ac.Box3Helper&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof ac.BoxGeometry?(o.setScalar(0),i.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(o,i)}hideGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof ac.Box3Helper&&(i.visible=!1)}}};var Td=790,Us=new bt.Vector3,vh=new bt.Vector3,Sh=new bt.Quaternion,wh=new bt.Vector3,sc=new bt.Vector3,Ah=new bt.Vector3,wn=class extends to(bt.Camera,Od){constructor(e="",r={..._i.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=kn.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,r),this.previousProjectionMatrix=new bt.Matrix4,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,i=this.height;this.orthoCamera=new bt.OrthographicCamera(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4),this.perspCamera=new bt.PerspectiveCamera(45,o/i,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}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,r,o){typeof e=="number"&&(e=new bt.Vector3(e,r,o)),super.lookAt(e),this.getWorldPosition(Us),this.targetOffset=Us.distanceTo(e)}getTarget(e=new bt.Vector3){return this.getWorldDirection(vh),this.getWorldPosition(Us),vh.multiplyScalar(this.targetOffset),e.copy(Us).add(vh),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Us),Us.distanceTo(e)}updateUp(){this.getWorldQuaternion(Sh),wh.set(0,0,1).applyQuaternion(Sh),sc.copy(bt.Object3D.DEFAULT_UP),this.isUpVectorFlipped&&sc.negate(),sc.applyQuaternion(Sh),Ah.copy(bt.Object3D.DEFAULT_UP).projectOnPlane(wh),this.angleOffsetFromUp=Ah.angleTo(sc),this.angleOffsetFromUp*=Ah.cross(sc).dot(wh)>=0?1:-1}updateTransformState(e,r){let o=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),o}getViewFrontToObject(e){let r=e.getWorldPosition(new bt.Vector3),i=e.getWorldDirection(new bt.Vector3).multiplyScalar(this.targetOffset);return{position:r.clone().add(i),target:r}}getViewToTarget(e){let o=this.getWorldDirection(new bt.Vector3).multiplyScalar(this.targetOffset);return{position:e.clone().sub(o),target:e}}getViewToObject(e){let r=new bt.Vector3,o=e.getWorldPosition(r);return this.getViewToTarget(r)}setViewplaneSize(e,r,o=!1){if(this.aspect=e/r,o){let i=e>r?this.aspect:1,a=e>r?1:this.aspect;this.left=-Td*.5*i,this.right=Td*.5*i,this.top=Td*.5*(1/a),this.bottom=-Td*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,o,i,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,o,i,a,s):this.orthoCamera.setViewOffset(e,r,o,i,a,s)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let r={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 Sa(r,e)}updateCameraSubtype(e,r){let o=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(o,r.zoom),r.near!==void 0&&this.setNear(o,r.near),r.fov!==void 0&&o==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}};var ZM=require("three");var ro=require("three");var Hs=new ro.Matrix4,KM=new ro.Matrix4,Md=new ro.Matrix4,cv=new ro.Vector3,uv=new ro.Vector3;var Er=class extends Dr{constructor(e,r,o){super(e,r);this.data=r;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new ro.BufferGeometry;this.onAfterRender=(e,r,o,i,a,s)=>{super.onAfterRender(e,r,o,i,a,s),this.recomputeBoolean()};this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,r=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let i=0;i<this.children.length;i++){let a=this.children[i];a instanceof Er&&a.dataPatched.visible===!0&&a.recomputeBoolean(e===!0,r)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let a=this.children[i];if(a instanceof Wt&&a.dataPatched.visible===!0&&a.geometry.attributes.position?.count>0&&a.geometry.drawRange.count>0&&a.booleanMeshSetAddress!==0){Hs.multiplyMatrices(a.hiddenMatrix,a.matrix);try{if(a.booleanMeshSetAddress===-1){if((a.geometry.index??a.geometry.getAttribute("position")).count/3<15e5&&(a.booleanMeshSetAddress=Kr.getMeshSet(a.geometry,e===!0,r)),a.booleanMeshSetAddress===-1)return;Kr.transformMeshSet(a.booleanMeshSetAddress,Hs),a.booleanMatrixInvOld.copy(Hs).invert(),a.booleanWasTransformed=!1}else a instanceof Er&&a.needsTransformForDownstream===!0?(Kr.transformMeshSet(a.booleanMeshSetAddress,Hs),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(Kr.transformMeshSet(a.booleanMeshSetAddress,KM.multiplyMatrices(Hs,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(Hs).invert(),a.booleanWasTransformed=!1)}catch(s){console.error(s),a.booleanMeshSetAddress=0,a.geometry.userData.booleanOperationDidFail=!0;continue}Kr.hasOpenEdges(a.booleanMeshSetAddress)===!1||i===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(a.booleanMeshSetAddress),a.geometry.userData.booleanOperationDidFail=!1):a.geometry.userData.booleanOperationDidFail="openEdges"}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new ro.Float32BufferAttribute([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Kr.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new ro.BufferGeometry,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=Kr.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,Rs(this),Vs(this)}dispose(){super.dispose(),this.geometry.dispose()}get recursiveBBox(){let e=super.recursiveBBox;return this.geometry.boundingSphere?.radius===-1&&(e.getCenter(this.geometry.boundingSphere.center),Md.copy(this.matrixWorld).invert(),this.geometry.boundingSphere.center.applyMatrix4(Md),cv.copy(e.max).applyMatrix4(Md),uv.copy(e.min).applyMatrix4(Md),this.geometry.boundingSphere.radius=cv.distanceTo(uv)/2),e}};var pv=require("three");var dv;(t=>{function n(e){return Fe.is(e)&&e instanceof pv.Light}t.is=n})(dv||(dv={}));var qs=(n,t)=>class extends to(n,t){updateState_Light(r,o){this.updateState_Entity(r,o),r.color!==void 0&&(this.color=o.shared.color(r.color)),r.intensity!==void 0&&(this.intensity=r.intensity),r.depth!==void 0&&(this.shadow.camera.far=r.depth,this.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows)}};var ri=n=>n instanceof Wt,lc=n=>n!==null&&n instanceof Er;var cc=n=>Cd.is(n);var hv=require("three");var fv=require("three");var oo=class extends Yo(fv.AxesHelper){constructor(e,r=15){super(r);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){Xo(this.object,oo.geometryHelper,e,r)}update(){}};var oi=class extends to(hv.Group,oo){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update()}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&Object.keys(t).length===1&&e.scene.reloadSplats()}};var mv=require("three");var Id=class extends to(mv.Group,oo){constructor(e,r,o){super();this.super_Entity(e,r),this.context=o,this.objectHelper.update()}updateState(e,r){this.updateState_Entity(e,r)}};var el=require("three");var Ws=require("three"),JM=n=>`
2241
2242
 
2242
2243
  // PCSS implementation based on:
2243
2244
  // https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
@@ -2611,7 +2612,7 @@ float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, floa
2611
2612
  }
2612
2613
 
2613
2614
  #endif
2614
- `,ZT=Cs.ShaderChunk.lights_fragment_begin,JT=Cs.ShaderChunk.shadowmask_pars_fragment,Cb=null,eM=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},Tb=(n="medium")=>{if(Cb===n)return!1;Cb=n;let t=eM(n);Cs.ShaderChunk.shadowmap_pars_fragment=KT(t);let e=ZT.slice();e=e.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),e=e.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),Cs.ShaderChunk.lights_fragment_begin=e;let r=JT.slice();return r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),Cs.ShaderChunk.shadowmask_pars_fragment=r,!0};var Hl=require("three");var Mb=require("three");var Ts=class extends Vo(Mb.DirectionalLightHelper){constructor(e,r=15,o=10066329){super(e,r,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){zo(this.object,Ts.geometryHelper,e,r)}};var Ib=require("three");var Ms=class extends Vo(Ib.PointLightHelper){constructor(e,r=15,o=6710886){super(e,r,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){zo(this.object,Ms.geometryHelper,e,r)}};var sd=require("three");var ad=class extends Vo(sd.SpotLightHelper){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){zo(this.object,ad.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=ad._vector,r=this.object.distance?this.object.distance:1e3,o=r*Math.tan(this.object.angle);this.cone.scale.set(o,o,r),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let i=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let a=0,s=this.cone.material.length;a<s;a++)this.cone.material[a].color.set(i);else this.cone.material.color.set(i)}}},Ul=ad;Ul._vector=new sd.Vector3;function tM(n,t){n.shadow.camera.right=t/2,n.shadow.camera.left=-t/2,n.shadow.camera.top=t/2,n.shadow.camera.bottom=-t/2,n.shadow.needsUpdate=!0}var Is=class extends Os(Hl.DirectionalLight,Ts){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let a=new Hl.CameraHelper(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof Hl.CameraHelper&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let r=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&tM(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),r&&this.update()}};var Yb=require("three");var Wr=require("three");var Nb=new Wr.Vector3,Db=new Wr.Vector3,Eb=new Wr.Quaternion,Ns=class extends Os(Wr.SpotLight,Ul){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=Wr.MathUtils.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let a=new Wr.CameraHelper(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof Wr.CameraHelper&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),Db.setFromMatrixPosition(this.matrixWorld),Eb.setFromRotationMatrix(this.matrixWorld),Nb.copy(this.up).applyQuaternion(Eb).negate().multiplyScalar(this.distance),this.target.position.copy(Db).add(Nb),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Ve;(v=>{function n(){return[1,0,0,0,1,0,0,0,1]}v.identity=n;function t(_,A=v.identity()){for(let x=0,T=_.length;x<T;x++)A[x]=_[x];return A}v.copy=t;function e(_,A,x,T,C,P){return v.setAbcdef(v.identity(),_,A,x,T,C,P)}v.create=e;function r(_,A,x,T,C,P,O){return _[0]=A,_[1]=T,_[2]=P,_[3]=x,_[4]=C,_[5]=O,_}v.setAbcdef=r;function o(_,A){let[x,T,C,P,O,M]=a(_),[I,N,B,D,G,L]=a(A),V=I*x+N*C,z=I*T+N*P,F=B*x+D*C,$=B*T+D*P,q=G*x+L*C+O,H=G*T+L*P+M;return v.create(V,z,F,$,q,H)}v.append=o;function i(_,A){let[x,T,C,P,O,M]=a(_),[I,N,B,D,G,L]=a(A),V=x,z=T,F=C,$=P;(I!==1||N!==0||B!==0||D!==1)&&(V=x*I+T*B,z=x*N+T*D,F=C*I+P*B,$=C*N+P*D);let q=O*I+M*B+G,H=O*N+M*D+L;return v.create(V,z,F,$,q,H)}v.prepend=i;function a(_){return[_[0],_[3],_[1],_[4],_[2],_[5]]}v.getAbcdef=a;function s(_){let[A,x,T,C,P,O]=v.getAbcdef(_),M=A*C-x*T,I=C/M,N=-x/M,B=-T/M,D=A/M,G=(T*O-C*P)/M,L=-(A*O-x*P)/M;return v.create(I,N,B,D,G,L)}v.invert=s;function l([_,A],x){let[T,C,P,O,M,I]=v.getAbcdef(x);return[T*_+P*A+M,C*_+O*A+I]}v.apply=l;function u(_,A){let[x,T,C,P,O,M]=v.getAbcdef(A),I=1/(x*P+C*-T),[N,B]=_;return[P*I*N+-C*I*B+(M*C-O*P)*I,x*I*B+-T*I*N+(-M*x+O*T)*I]}v.applyInverse=u;function c(_,A,x=A){let[T,C,P,O,M,I]=v.getAbcdef(_);return v.setAbcdef(_,T*A,C*x,P*A,O*x,M*A,I*x),_}v.scale=c;function d(_,A){let x=Math.cos(A),T=Math.sin(A),[C,P,O,M,I,N]=v.getAbcdef(_);return v.setAbcdef(_,C*x-P*T,C*T+P*x,O*x-M*T,O*T+M*x,I*x-N*T,I*T+N*x),_}v.rotate=d;function p(_,A,x){let[T,C]=x,P=v.translate(_,-T,-C);return P=v.rotate(P,A),P=v.translate(P,T,C),P}v.rotateAround=p;function f(_,A,x){let[T,C,P,O,M,I]=v.getAbcdef(_);return v.setAbcdef(_,T,C,P,O,M+A,I+x),_}v.translate=f;function h(_,A,x){let[T,C,P,O]=v.getAbcdef(_);return v.setAbcdef(_,T,C,P,O,A,x),_}v.setTranslate=h;function m(_,A,x){let[T,C,P,O]=v.getAbcdef(_);return v.setAbcdef(_,T,C,P,O,A,x),_}v.setPosition=m;function y(_){let[A,x,T,C]=v.getAbcdef(_),P=Math.sqrt(A*A+x*x),O=Math.sqrt(T*T+C*C);return[P,O]}v.getScale=y;function g(_){let[,,,,A,x]=v.getAbcdef(_);return[A,x]}v.getPosition=g;function b(_,A){return v.decompose(_,A).rotation}v.getRotation=b;function S(_,A){let[x,T,C,P,O,M]=v.getAbcdef(_),I=-Math.atan2(-C,P),N=Math.atan2(T,x),B=Math.abs(I+N),D=0,G=[0,0];B<1e-5||Math.abs(Math.PI*2-B)<1e-5?(D=N,G[0]=G[1]=0):(D=0,G[0]=I,G[1]=N);let L=[Math.sqrt(x*x+T*T),Math.sqrt(C*C+P*P)];return{position:[O+(A[0]*x+A[1]*C)-A[0],M+(A[0]*T+A[1]*P)-A[1]],scale:L,rotation:D,skew:G,pivot:A}}v.decompose=S;function w(_,A,x,T,C=[0,0]){let[P,O]=_,[M,I]=A,[N,B]=T,[D,G]=C,L=Math.cos(x+G)*M,V=Math.sin(x+G)*M,z=-Math.sin(x-D)*I,F=Math.cos(x-D)*I,$=P-(N*L+B*z)+N,q=O-(N*V+B*F)+B;return v.create(L,V,z,F,$,q)}v.compose=w})(Ve||(Ve={}));var rM=Math.PI/180,cZ=180/Math.PI;function Bb(n,t,e,r,o,i){let a=n-e,s=t-r;return a*a/(o*o)+s*s/(i*i)<=1}function Lb(n){return n*rM}function Uf(n){return{all:n=n||new Map,on:function(t,e){var r=n.get(t);r?r.push(e):n.set(t,[e])},off:function(t,e){var r=n.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):n.set(t,[]))},emit:function(t,e){var r=n.get(t);r&&r.slice().map(function(o){o(e)}),(r=n.get("*"))&&r.slice().map(function(o){o(t,e)})}}}var fn=class{constructor(t,e,r){this.uuid=t;this.data=e;this.localMatrix=Ve.identity();this.worldMatrix=Ve.identity();this.ignoreCameraZoom=!1;this.visible=!0;this._singleBBox=new Yn;this._recursiveBBox=new Yn;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.stateSelection=null;this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this.name="";this.position=[0,0];this.scale=[1,1];this.rotation=0;this.emitter=Uf();this.dpr=r.dpr??1,this.dataPatched=e}project(t,e){let r=this.worldMatrix;return e&&(r=Ve.append(e.worldMatrix,r)),Ve.applyInverse(t,r)}intersects(t,e,r){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:o}=this.singleBBox;return t>=r[0]&&t<=o[0]&&e>=r[1]&&e<=o[1]}applyTransforms(t){t.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=Ve.compose(this.position,this.scale,Lb(this.rotation),tn.getPivot(this.dataPatched))}updateWorldMatrix(t,e,r){let o=this.parent;e&&o!==null&&o!==void 0&&o.updateWorldMatrix(t,!0,!1),t&&this.updateLocalMatrix(),this.parent?this.worldMatrix=Ve.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=Ve.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return tn.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{t.resetBBoxNeedsUpdateSelf()})}updateTransformState(t){let e=!1;t.position!==void 0&&(e=!0,this.position=t.position),t.rotation!==void 0&&(e=!0,this.rotation=t.rotation),t.scale!==void 0&&(e=!0,this.scale=t.scale),e&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(t,e,r){t.type===0&&t.props.visible!==void 0&&(this.visible=t.props.visible),this.data=e,this.data=e;let o=t,i=Ne(t.path,["states","*"]);if(i!==null){if(t.type===0){let[a]=i;if(this?.stateSelection===a){let s={...t.props};if(delete s.name,Object.values(t.props).some(l=>l===void 0)){let l=this.data;if(l!==void 0){let u=dt.zoom(l,t.path.slice(2));if(u)for(let c in t.props)t.props[c]===void 0&&c in u&&(s[c]=u[c])}}o={...t,props:s,path:t.path.slice(2)}}}}else if(t.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(t.props.name!==void 0&&a.name){let{name:l,...u}=a;a=u}let s=dt.removeOverridden(t.path,t.props,a);o={...t,props:s}}}this.updateByPatchedOpBase(o,pi.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r)}changeSelectedState(t,e,r=!1){if(!(this.data.states.length===0&&!r)){for(let o of this.data.states)pi.toOps(this.data,o.data).forEach(a=>{let s=la.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,e)});if(t!==null){let o=this.data.states.data(t);o&&(this.dataPatched=pi.patch(this.data,o),pi.toOps(this.data,o).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,e)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t}}updateState(t,e){t.name!==void 0&&(this.name=t.name),t.visible!==void 0&&(this.visible=t.visible),this.updateTransformState(t)}updateByPatchedOpBase(t,e,r){this.dataPatched=e,this.updateByPatchedOp(t,e,r)}updateByPatchedOp(t,e,r){t.path.length===0&&t.type===0&&this.updateState(t.props,r),this.requestRender()}traverseFrameAncestors(t){this.traverseAncestors(e=>{e.data.type==="frame2d"&&t(e)})}traverseAncestors(t){let e=this.parent;for(;e;)t(e),e=e.parent}requestRender(){this.traverseFrameAncestors(t=>{t.requestRender()})}clone(t){let e=new fn(this.uuid,this.data,t);return e.parent=void 0,e}addEventListener(t,e){this.emitter.on(t,e)}removeEventListener(t,e){this.emitter.off(t,e)}dispatchEvent(t){this.emitter.emit(t.type,{...t,target:t.target??this})}traverseSortNextHelper(){let t=this.parent;if(t){let e=t.children;if(e){let r=e.indexOf(this)+1;return e[r]?e[r]:t.traverseSortNextHelper()}}}sortNext(){let t=this.children;return t&&t.length>0&&t[0]?t[0]:this.traverseSortNextHelper()}isDescendantOf(t){t instanceof fn&&(t=t.uuid);let e=this;for(;e.parent;){if(e.parent.uuid===t)return!0;e=e.parent}return!1}};var or=class extends fn{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.context=o;this.children=[]}add(e){e.parent&&e.parent instanceof or&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let r=this.children.indexOf(e);r>=0&&(this.children.splice(r,1),e.parent=void 0)}traverse(e){let r=e(this);if(r!==!0)for(let o of this.children)o instanceof or?o.traverse(e):r=e(o)}intersectsChildren(e,r,o,i=!1,a=[]){for(let s of this.children)if(s instanceof or&&s.intersectsChildren(e,r,o,i,a),s.intersects(e,r,o)&&(a.push(s),i))break;return a}updateWorldMatrix(e,r,o){if(super.updateWorldMatrix(e,r,o),o&&this.children)for(let i of this.children)i.updateWorldMatrix(e,!1,!0)}find(e){let r;return this.traverse(o=>{o.uuid===e&&(r=o)}),r}innerDrawChildren(e){for(let r=this.children.length-1;r>=0;r--)this.children[r].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let r=new or(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}},hn=class extends or{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.reset(r)}reset(e){this.data=e}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let r=new hn(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}};function oM(n,t){let[[e,r],[o,i]]=n,[[a,s],[l,u]]=t,c=(e-o)*(s-u)-(r-i)*(a-l);if(c===0)return!1;let d=((e-a)*(s-u)-(r-s)*(a-l))/c,p=-((e-o)*(r-s)-(r-i)*(e-a))/c;return d>=0&&d<=1&&p>=0&&p<=1}var Vb=[[-1,1],[-1,-1],[1,-1],[1,1]],Rb=(n,t,e)=>{let r=n.getCenter(),o=n.getHalfSize(),i=Ve.append(t,n.worldMatrix);o[0]===0&&o[1]===0?e.push(Ve.apply(r,i)):Vb.forEach(a=>{let s=[a[0]*o[0]+r[0],a[1]*o[1]+r[1]];e.push(Ve.apply(s,i))})},Yn=class{constructor(){this.matrix=Ve.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(t,e=!1){t.updateWorldMatrix(),this.makeEmpty(),Ve.copy(t.worldMatrix,this.matrix);let r=Ve.invert(t.worldMatrix);this.expandByObjectSize(t,r,e)}expandByObjectSize(t,e,r=!1){let o=[];r===!0&&t instanceof or?t.traverse(i=>{i.visible&&Rb(i,e,o)}):Rb(t,e,o),this.setFromPoints(o)}getCenter(){let[t,e]=this.min,[r,o]=this.getHalfSize();return Ve.apply([t+r,e+o],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(t){this.makeEmpty();for(let e of t)this.expandByPoint(e)}expandByPoint(t){this.min=[Math.min(this.min[0],t[0]),Math.min(this.min[1],t[1])],this.max=[Math.max(this.max[0],t[0]),Math.max(this.max[1],t[1])]}computeVertices(){let[t,e]=this.getHalfSize(),r=this.getCenter(),[o,i,a,s]=Ve.getAbcdef(this.matrix),l=Ve.create(o,i,a,s,r[0],r[1]);this.vertices=Vb.map(([u,c])=>Ve.apply([u*t,c*e],l))}computeEdges(){this.edges=[];for(let t=0,e=this.vertices.length;t<e;++t)this.edges.push([this.vertices[t],this.vertices[(t+1)%e]])}project(t,e){let r=this.matrix;return e&&(r=Ve.append(e.worldMatrix,r)),Ve.applyInverse(t,r)}intersects(t,e,r){return this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:o}=this;return t>=r[0]&&t<=o[0]&&e>=r[1]&&e<=o[1]}containsPoint(t){let[e,r]=t,[o,i]=this.min,[a,s]=this.max;return e>=o&&e<=a&&r>=i&&r<=s}intersectsBBox2D(t){for(let e=0,r=this.edges.length;e<r;e++){let o=this.edges[e];for(let i=0,a=t.edges.length;i<a;i++){let s=t.edges[i];if(oM(o,s))return!0}}for(let e=0,r=t.vertices.length;e<r;e++){let o=t.vertices[e];if(this.containsPoint(o))return!0}return!1}ensureMinMax(){let t=this.min,e=this.max;this.min=[Math.min(t[0],e[0]),Math.min(t[1],e[1])],this.max=[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}copy(t){this.min=[...t.min],this.max=[...t.max],Ve.copy(t.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let t=new Yn;return t.copy(this),t}};var Gb,kb=new Promise(n=>{Gb=n}),zb=!1;var ld;function Fb(){if(zb)return;if(ld)return ld;async function n(){let e=await import("./ui.js");Gb(e.default??e),zb=!0}return ld=n(),ld}function Hb(n){let t=!1;return n.scene.objects.traverse((e,r)=>{(r.type==="Mesh"&&r.geometry.type==="UIGeometry"||r.type==="Page"&&r.uiFrame!==void 0)&&(t=!0)}),t}var we,Hf;async function nM(n){let t=await kb;we||(Hf||(Hf=t({locateFile:()=>n})),we=await Hf)}var jb=Ve.identity(),Wl=class{constructor(t,e=1){this.canvas=t;this.dpr=e;this._width=0;this._height=0;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=Oe.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=Oe.transparent;this._fonts=new Map;try{let r=t.getBoundingClientRect();t.width=r.width*e,t.height=r.height*e}catch{console.log(t.width,e)}this._currentM3Transform=jb,this._currentTransform=new Float32Array(jb)}async init(){if(!this.wasmURL)throw Error("Your must set the wasm binary url with renderer.wasmURL = ... before you can call renderer.init");await nM(this.wasmURL),this._surface=we.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas(),this._paint=new we.Paint,this._paint.setAntiAlias(!0),this._paintFill=this._paint.copy(),this._paintFill.setStyle(we.PaintStyle.Fill),this._paintStroke=this._paint.copy(),this._paintStroke.setStyle(we.PaintStyle.Stroke),this.ctx?.scale(this.dpr,this.dpr)}get currentTransform(){return this._currentM3Transform}get currentTransformBuffer(){return this._currentTransform}set currentTransform(t){this._currentM3Transform=t,this._currentTransform.set(t)}async loadFont(t,e){let r=await(await fetch(t)).arrayBuffer();this.registerFont(r,e)}registerFont(t,e){if(this._fonts.has(e))return;let r=we.FontMgr.FromData(t);if(r)this._fonts.set(e,r);else throw new Error("Invalid font data for "+e)}get width(){return this._width}get height(){return this._height}set strokeColor(t){this._paintStroke&&this._paintStroke.setColor(cd(t),we.ColorSpace.DISPLAY_P3)}set fillColor(t){this._paintFill&&this._paintFill.setColor(cd(t),we.ColorSpace.DISPLAY_P3)}set lineWidth(t){this._paintStroke&&this._paintStroke.setStrokeWidth(this._strokeMode==="center"?t:t*2)}set strokeMode(t){this._strokeMode=t}set dropShadowBlur(t){this._dropShadowBlur=t}set dropShadowColor(t){this._dropShadowColor=t}set dropShadowOffsetX(t){this._dropShadowOffsetX=t}set dropShadowOffsetY(t){this._dropShadowOffsetY=t}set innerShadowBlur(t){this._innerShadowBlur=t}set innerShadowColor(t){this._innerShadowColor=t}set innerShadowOffsetX(t){this._innerShadowOffsetX=t}set innerShadowOffsetY(t){this._innerShadowOffsetY=t}set innerShadowSpread(t){this._innerShadowSpread=t}set layerBlur(t){this._layerBlur=t}set backgroundBlur(t){this._backgroundBlur=t}clear(){this.ctx?.clear(we.TRANSPARENT)}save(){this.ctx?.save()}restore(){this.ctx?.restore()}beginPath(){this._currentPath?.delete(),this._currentPath=new we.Path}closePath(){let t=this._currentPath;if(t){if(t.isEmpty())return;let e=t.getBounds();(e[3]-e[1]||e[2]-e[0])&&t.close()}}fill(){this._paintInner(this._paintFill,!0)}stroke(){this._paintInner(this._paintStroke,!1)}clipRect(t,e,r,o,i=0,a=0,s=0,l=0){let u=we.XYWHRect(t,e,r,o);if(i===0&&a===0&&l===0&&s===0)this.ctx?.clipRect(u,we.ClipOp.Intersect,!0);else{let c=we.RRectXY(u,i,i);c[4]=c[5]=i,c[6]=c[7]=a,c[8]=c[9]=s,c[10]=c[11]=l,this.ctx?.clipRRect(c,we.ClipOp.Intersect,!0)}}_applyShadowOffsetMatrix(){if(this.ctx){let t=Ve.invert(this.currentTransform);this.ctx.concat(t);let e=Ve.translate(Ve.identity(),this._dropShadowOffsetX,this._dropShadowOffsetY);this.ctx.concat(e),this.ctx.concat(this._currentTransform)}}_applyEffectsToPaint(t,e,r=!0){if(this.ctx&&this._currentPath){let o,i=!1;if(r&&this._hasDropShadow()){let a=t.copy();a.setColor(cd(this._dropShadowColor));let s;this._dropShadowBlur>0&&(s=we.MaskFilter.MakeBlur(we.BlurStyle.Normal,this._dropShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s)),this.ctx.save(),this.ctx.clipPath(this._currentPath,we.ClipOp.Difference,!0),this._applyShadowOffsetMatrix(),e(a),this.ctx.restore(),a.delete(),s?.delete()}if(this._backgroundBlur>0&&r){this.ctx.save(),this.ctx.clipPath(this._currentPath,we.ClipOp.Intersect,!0);let a=we.ImageFilter.MakeBlur(this._backgroundBlur,this._backgroundBlur,we.TileMode.Clamp,null),s=t.copy();s.setImageFilter(a),s.setAlphaf(1);let l=this._currentPath.computeTightBounds();this.ctx.saveLayer(s,l,null,we.SaveLayerInitWithPrevious),this.ctx.drawColor(t.getColor()),this.ctx.restore(),this.ctx.restore(),s.delete(),a.delete(),i=!0}if(this._layerBlur>0){let a=t.copy();o=we.MaskFilter.MakeBlur(we.BlurStyle.Normal,this._layerBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(o),e(a),a.delete(),o.delete(),i=!0}if(i||e(t),r&&this._hasInnerShadow()){let a=new we.Paint;a.setAntiAlias(!0),a.setStyle(we.PaintStyle.Fill),a.setColor(cd(this._innerShadowColor));let s;this._innerShadowBlur>0&&(s=we.MaskFilter.MakeBlur(we.BlurStyle.Normal,this._innerShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s));let l=this._currentPath.computeTightBounds(),[u,c,d,p]=l,f=d-u,h=p-c;this.ctx.save(),this.ctx.clipPath(this._currentPath,we.ClipOp.Intersect,!0),this.ctx.saveLayer(a,l,null,we.SaveLayerInitWithPrevious),this.ctx?.translate(this._innerShadowOffsetX,this._innerShadowOffsetY),this.ctx.drawRect(we.XYWHRect(-1e3-this._innerShadowOffsetX,-1e3-this._innerShadowOffsetY,2e3+f+Math.abs(this._innerShadowOffsetX*2),2e3+h+Math.abs(this._innerShadowOffsetY*2)),a),a.setBlendMode(we.BlendMode.Clear),this.ctx.drawPath(this._currentPath,a),this.ctx.restore(),this.ctx.restore(),a.delete(),s?.delete()}}}_paintInner(t,e=!0){if(this.ctx&&this._currentPath&&t){let r=this.ctx,o=this._currentPath;this._applyEffectsToPaint(t,i=>{let a=!1;!e&&this._strokeMode!=="center"&&(r.save(),r.clipPath(o,this._strokeMode==="outside"?we.ClipOp.Difference:we.ClipOp.Intersect,!0),a=!0),r.drawPath(o,i),a&&r.restore()},e)}}_hasDropShadow(){return this._dropShadowColor?.a>0}_hasInnerShadow(){return this._innerShadowColor?.a>0}ellipse(t,e,r,o,i,a,s,l){if(!Ub([t,e,r,o])||!this._currentPath)return;if(r<0||o<0)throw Error("radii cannot be negative");let u=we.XYWHRect(t-r,e-o,r*2,o*2);this._currentPath?.addOval(u)}rect(t,e,r,o,i=0,a=0,s=0,l=0){let u=we.XYWHRect(t,e,r,o);if(!!Ub(u))if(i===0&&a===0&&l===0&&s===0)this._currentPath?.addRect(u);else{let c=we.RRectXY(u,i,i);c[4]=c[5]=i,c[6]=c[7]=a,c[8]=c[9]=s,c[10]=c[11]=l,this._currentPath?.addRRect(c)}}getHorizontalAlign(t){switch(t){case 2:return we.TextAlign.Right;case 3:return we.TextAlign.Center;case 4:return we.TextAlign.Justify;case 1:default:return we.TextAlign.Left}}drawTextInner(t,e,r,[o,i,a,s],l,u,c=!0){let d=0,{ctx:p}=this;if(!p)return d;let f=u.copy(),h=u.copy();return h.setAlphaf(0),this._applyEffectsToPaint(f,m=>{e.pushPaintStyle(r,m,h),e.addText(t);let y=e.build();y.layout(a);let g=i;l===2?g+=(s-y.getHeight())/2:l===3&&(g+=s-y.getHeight()),p.drawParagraph(y,o,g),d=y.getHeight(),e.reset(),y.delete()},c),f.delete(),h.delete(),d}drawText(t,e){let r=0,o=this._fonts.get(e.font),{ctx:i,_paintFill:a,_paintStroke:s}=this;if(o&&i){let l=new we.TextStyle({fontFamilies:[e.font],fontSize:e.fontSize,heightMultiplier:e.lineHeight,letterSpacing:e.letterSpacing}),u=new we.ParagraphStyle({textStyle:l,textAlign:this.getHorizontalAlign(e.horizontalAlign)}),c=we.XYWHRect(e.x,e.y,e.width,e.height),d=we.ParagraphBuilder.Make(u,o);a&&(r=this.drawTextInner(t,d,l,c,e.verticalAlign,a,!0)),s&&(r=this.drawTextInner(t,d,l,c,e.verticalAlign,s,!1)),d.delete()}return{height:r}}render(){this._surface?.flush()}moveTo(t,e){this._currentPath?.moveTo(t,e)}lineTo(t,e){this._currentPath?.lineTo(t,e)}bezierCurveTo(t,e,r,o,i,a){this._currentPath?.cubicTo(t,e,r,o,i,a)}quadraticCurveTo(t,e,r,o){this._currentPath?.quadTo(t,e,r,o)}setTransform(t,e=!1){if(!this.ctx)return;let r=this.ctx.getTotalMatrix(),o=Ve.invert(r);if(o&&this.ctx.concat(o),this.ctx?.scale(this.dpr,this.dpr),this.camera?.enabled&&(this.ctx?.concat(this.camera.worldMatrix),e)){let i=Ve.getScale(this.camera.worldMatrix);this.ctx?.scale(1/i[0],1/i[1])}this.ctx?.concat(t),this.currentTransform=t}transform(t){this.ctx?.concat(t)}setSize(t,e){t===this._width&&e===this._height||(this._width=t,this._height=e,this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.canvas.width=t*this.dpr,this.canvas.height=e*this.dpr,this._surface&&(this._surface=we.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas()))}};function Ub(n){for(let t=0;t<n.length;t++)if(n[t]!==void 0&&!Number.isFinite(n[t]))return!1;return!0}function cd({r:n,g:t,b:e,a:r}){return we.Color4f(n,t,e,r)}var $l=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Oe.transparent;this.blurRadius=0;this.offset=[0,0];this.spread=0;this.update(e)}update(t){t.color!==void 0&&(this.color=t.color),t.enabled!==void 0&&(this.enabled=t.enabled),t.blurRadius!==void 0&&(this.blurRadius=t.blurRadius),t.offset!==void 0&&(this.offset=t.offset),t.spread!==void 0&&(this.spread=t.spread)}};var Yl=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.radius=0;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.radius!==void 0&&(this.radius=t.radius)}};var ud=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Oe.transparent;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color)}};var dd=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Oe.transparent;this.thickness=0;this.mode="inside";this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color),t.thickness!==void 0&&(this.thickness=t.thickness),t.mode!==void 0&&(this.mode=t.mode)}};var $r=class extends fn{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.fill=new ud(e+"-fill",r.fill,o),this.stroke=new dd(e+"-stroke",r.stroke,o),this.dropShadow=new $l(e+"-dropShadow",r.dropShadow,o),this.innerShadow=new $l(e+"-innerShadow",r.innerShadow,o),this.backgroundBlur=new Yl(e+"-backgroundBlur",r.backgroundBlur,o),this.layerBlur=new Yl(e+"-layerBlur",r.layerBlur,o)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Oe.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Oe.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=Oe.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=Oe.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.type===0&&(Ne(e.path,["fill"])?this.fill.update(e.props):Ne(e.path,["stroke"])?this.stroke.update(e.props):Ne(e.path,["dropShadow"])?this.dropShadow.update(e.props):Ne(e.path,["innerShadow"])?this.innerShadow.update(e.props):Ne(e.path,["layerBlur"])?this.layerBlur.update(e.props):Ne(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,r){super.updateState(e,r),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let r=new $r(this.uuid,this.data,e);return r.parent=void 0,r}};var Xn=class extends $r{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.width=0;this.height=0;this.updateState(r,o)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,r){return Bb(e,r,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e)}clone(e){let r=new Xn(this.uuid,this.data,e);return r.parent=void 0,r}};var Go=class extends $r{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.width=0;this.height=0;this.cornerRadius=[0,0,0,0];this.updateState(r,o)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let r=new Go(this.uuid,this.data,e);return r.parent=void 0,r}};var Qn=class extends $r{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this._textHeight=0;this._textHeightDirty=!0;this.width=0;this.height=0;this.updateState(r,o)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Oe.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Oe.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){this._fontHolder?.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let r=this.data.textTransform,o=this.data.text.textValue.toString(),i=r===2?o.toUpperCase():r===3?o.toLowerCase():o,{height:a}=e.drawText(i,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=a}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:r}){e.font!==void 0&&(this._fontHolder=r.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateFontState(e,r)}clone(e){let r=new Qn(this.uuid,this.data,e);return r.parent=void 0,r}};var Ds=class extends $r{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.curves=[];this.extremasBBox={min:[0,0],max:[0,0]};this.updateState(r,o)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(i=>pd.extremas(i)),r=[1/0,1/0],o=[-1/0,-1/0];for(let i=0,a=e.length;i<a;i++){let s=e[i];s[0][0]<r[0]&&(r[0]=s[0][0]),s[0][1]<r[1]&&(r[1]=s[0][1]),s[1][0]>o[0]&&(o[0]=s[1][0]),s[1][1]>o[1]&&(o[1]=s[1][1])}return this.extremasBBox.min=[r[0],r[1]],this.extremasBBox.max=[o[0],o[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let o=1,i=this.data.points.length;o<i;o++){let a=this.data.points[o].data,s=this.data.points[o-1].data,l={start:s.position,cp1:s.controlNext.position,cp2:a.controlPrevious.position,end:a.position};this.curves.push(l)}let e=this.data.points[0].data,r=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let o={start:r.position,cp1:r.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(o)}}getCenter(){let[e,r]=this.extremasBBox.min,[o,i]=this.getHalfSize();return[e+o,r+i]}getHalfSize(){let{min:e,max:r}=this.extremasBBox;return[(r[0]-e[0])*.5,(r[1]-e[1])*.5]}innerDraw(e){for(let i=0,a=this.data.points.length;i<a;i++){let s=this.data.points[i].data;if(i===0){let[l,u]=s.position;e.moveTo(l,u)}else{let l=this.data.points[i-1].data,[u,c]=l.controlNext.position,[d,p]=s.controlPrevious.position,[f,h]=s.position,m={start:l.position,cp1:l.controlNext.position,cp2:s.controlPrevious.position,end:s.position};pd.derive(m),e.bezierCurveTo(u,c,d,p,f,h)}}let r=this.data.points[0].data,o=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[i,a]=o.controlNext.position,[s,l]=r.controlPrevious.position,[u,c]=r.position;e.bezierCurveTo(i,a,s,l,u,c)}}updateState(e,r){super.updateState(e,r),this.computeExtremas()}clone(e){let r=new Ds(this.uuid,this.data,e);return r.parent=void 0,r}},pd;(i=>{function n(a){let s=a.start,l=a.cp1,u=a.cp2,c=a.end,d=[3*(l[0]-s[0]),3*(l[1]-s[1])],p=[3*(u[0]-l[0]),3*(u[1]-l[1])],f=[3*(c[0]-u[0]),3*(c[1]-u[1])],h={start:d,cp:p,end:f};return a.derivative=h,h.derivative=qf.derive(h),h}i.derive=n;function t(a,s,l,u=!1){let c=a-2*s+l;if(c!==0){let d=-Math.sqrt(Math.abs(s*s-a*l)),p=-a+s,f=-(d+p)/c,h=-(-d+p)/c;return[f,h]}else if(s!==l&&c===0)return[(2*s-l)/(2*(s-l))];return[]}function e(a){let s=a.derivative??i.derive(a),l=s.start,u=s.cp,c=s.end;return[t(l[0],u[0],c[0]),t(l[1],u[1],c[1])]}i.droot=e;function r(a){let[s,l]=i.droot(a),u=[a.start[0],a.end[0]],c=[a.start[1],a.end[1]];for(let d of s)u.push(i.compute(a,Math.min(1,Math.max(0,d)))[0]);for(let d of l)c.push(i.compute(a,Math.min(1,Math.max(0,d)))[1]);return u.sort((d,p)=>d-p),c.sort((d,p)=>d-p),[[u[0],c[0]],[u[u.length-1],c[c.length-1]]]}i.extremas=r;function o(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let l=1-s,u=l*l,c=s*s,d=u*l,p=u*s*3,f=l*c*3,h=s*c;return[d*a.start[0]+p*a.cp1[0]+f*a.cp2[0]+h*a.end[0],d*a.start[1]+p*a.cp1[1]+f*a.cp2[1]+h*a.end[1]]}i.compute=o})(pd||(pd={}));var qf;(r=>{function n(o){let i=o.start,a=o.cp,s=o.end,l=[2*(a[0]-i[0]),2*(a[1]-i[1])],u=[2*(s[0]-a[0]),2*(s[1]-a[1])],c={start:l,end:u};return c.derivative=Wf.derive(c),o.derivative=c,c}r.derive=n;function t(o){let i=o.derivative??r.derive(o),a=i.start,s=i.end;return[a[0]!==s[0]?a[0]/(a[0]-s[0]):0,a[1]!==s[1]?a[1]/(a[1]-s[1]):0]}r.droot=t;function e(o,i){if(i===0)return[...o.start];if(i===1)return[...o.end];let a=1-i,s=a*a,l=i*i,u=s,c=a*i*2,d=l;return[u*o.start[0]+c*o.cp[0]+d*o.end[0],u*o.start[1]+c*o.cp[1]+d*o.end[1]]}r.compute=e})(qf||(qf={}));var Wf;(e=>{function n(r){let o=r.start,i=r.end,a=[i[0]-o[0],i[1]-o[1]];return r.derivative=a,r.derivative}e.derive=n;function t(r,o){if(o===0)return[...r.start];if(o===1)return[...r.end];let i=r.start,a=r.end;return[i[0]+(a[0]-i[0])*o,i[1]+(a[1]-i[1])*o]}e.compute=t})(Wf||(Wf={}));var Br=class extends or{constructor(e,r,o){super(e,r,o);this.uuid=e;this.width=0;this.height=0;this.background=new Go(e+"-background",_a.defaultData,o),this.background.parent=this,this.updateState(r,o)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){super.updateLocalMatrix(),this.background?.updateLocalMatrix()}updateWorldMatrix(e,r,o){super.updateWorldMatrix(e,r,o),this.background?.updateWorldMatrix(e,r,o)}draw(e){if(!this.visible)return;e.save();let r=this.width,o=this.height;this.applyTransforms(e),this.background.width=r,this.background.height=o,this.background.draw(e),e.clipRect(0,0,r,o,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.type===0&&(Ne(e.path,["fill"])?this.fill.update(e.props):Ne(e.path,["stroke"])?this.stroke.update(e.props):Ne(e.path,["dropShadow"])?this.dropShadow.update(e.props):Ne(e.path,["innerShadow"])?this.innerShadow.update(e.props):Ne(e.path,["layerBlur"])?this.layerBlur.update(e.props):Ne(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let r=new Br(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}};function qb(n,t,e){switch(t.type){case"ellipse2d":return new Xn(n,t,e);case"rectangle2d":return new Go(n,t,e);case"text2d":return new Qn(n,t,e);case"vector2d":return new Ds(n,t,e);case"frame2d":return new Br(n,t,e);case"group2d":default:return new hn(n,t,e)}}var $f=class{constructor(t,e,r){this.uuid=t;this.data=e;this.group=new hn($f.GROUP_ID,{...il.defaultData},r),this.createChildrenObjects(e.objects,this.group,r)}createObject(t,e,r,o,i,a){let s=qb(t,e,a);s&&(o.add(s),o.children.splice(i,0,o.children.pop()),s.updateWorldMatrix(),r.length>0&&(s instanceof hn||s instanceof Br)&&this.createChildrenObjects(r,s,a))}createChildrenObjects(t,e,r){let o=0;for(let i of t)this.createObject(i.id,i.data,i.children,e,o,r),o+=1}draw(t){this.group.draw(t)}updateEntityByOp(t,e,r,o){let i=this.find(t);if(i)try{i.updateByOp(e,r,{shared:o})}catch(a){console.error(a)}}updateTreeByOp(t,e){if(t.path.length===0&&t.type===7){let r=t.parent===null?this.group:this.find(t.parent);r!==void 0&&r instanceof or&&(this.createObject(t.id,t.data,t.children,r,t.localIndex,e),r.requestRender())}else if(t.path.length===0&&t.type===8){let r=this.find(t.id);if(r!==void 0&&r.parent!==void 0&&r.parent instanceof or){let o=r.parent;r.resetBBoxNeedsUpdate(),o?.remove(r),o?.requestRender()}}else if(t.path.length===0&&t.type===9){let r=this.find(t.id);if(r!==void 0){let o=r.parent,i=t.parent===null?this:this.find(t.parent);if(i===void 0&&!1&&console.error("unexpected",i,t),i instanceof or||i===this){i.add(r);let a=t.localIndex;i.children.splice(a,0,i.children.pop()),r.updateWorldMatrix(!0,!1,!0),o?.requestRender(),r.requestRender()}r.resetBBoxNeedsUpdate()}}}add(t){this.group.add(t)}remove(t){this.group.remove(t)}traverse(t){this.group.traverse(e=>{e!==this.group&&t(e)})}intersectsChildren(t,e,r,o=!1,i=[]){return this.group.intersectsChildren(t,e,r,o,i)}find(t){return this.group.find(t)}get children(){return this.group.children}project(t,e){return this.group.project(t,e)}getWithSortKey(t){let e=this.find(t);if(e===void 0)return;let r=[],o=e;for(;o!==this.group;){let i=o;o=o.parent;let a=o.children.indexOf(i);r.splice(0,0,a)}return{entity:e,sortKey:r}}getAllSorted(t){let e=[];for(let r of t){let o=this.getWithSortKey(r.id);o!==void 0&&e.push(o)}return e.sort((r,o)=>tc(r.sortKey,o.sortKey)),e.map(r=>r.entity)}},Mi=$f;Mi.GROUP_ID="scene2d";function Yf({constraints:n,newParentWidth:t,newParentHeight:e,initialParentWidth:r,initialParentHeight:o,objectInitialWidth:i,objectInitialHeight:a,objectInitialPosition:s}){let{horizontalConstraint:l,verticalConstraint:u}=n,c=t-r,d=e-o,p=i,f=a,h=s[0],m=s[1];if(l!==0){if(l===1)h+=c;else if(l===3)h+=c/2;else if(l===2)p=Math.max(1,p+c);else if(l===4){let y=t/r;p*=y,h*=y}}if(u!==0){if(u===1)m+=d;else if(u===3)m+=d/2;else if(u===2)f=Math.max(1,f+d);else if(u===4){let y=e/o;f*=y,m*=y}}return{width:p,height:f,position:[h,m]}}var Wb=require("three"),iM=Ve.identity(),Es=class{constructor(t,e,r,o){this.uuid=t;this.width=e;this.height=r;this.context=o;this.enabled=!0;this.isScreenSpace=!1;this.isFrameDirty=!1;this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.context.shared.requestRender()};this.onFrameOverrideObjectEvent=t=>{if(t.target?.uuid!==void 0){let e=this.frameRoot?.find(t.target.uuid);e&&e.dispatchEvent({...t,target:e})}};this.scene2d=new Mi(Wb.MathUtils.generateUUID(),du.defaultData,{dpr:window.devicePixelRatio,shared:o.shared}),this.canvas=document.createElement("canvas"),this.renderer=new Wl(this.canvas),o.shared.addCanvas(this.uuid,this.canvas),this.textureHolder=o.shared.canvas(this.uuid),this.promise=this.init()}async init(){this.renderer instanceof Wl&&(this.renderer.wasmURL=Rx.skiaWasmUrl),await this.renderer.init()}render(){this.isFrameDirty&&(this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.textureHolder?.setNeedsUpdate(!0),this.isFrameDirty=!1)}updateEntity2DByOp(t,e,r,o){this.scene2d.updateEntityByOp(t,e,r,o),this.applySize()}updateTreeByOp(t,e){this.scene2d.updateTreeByOp(t,e),this.applySize()}applyOverrides(t){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=t?.width??this.width,r=t?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=r,this.frameOverride.localMatrix=iM,this.isScreenSpace&&(this.frameOverride.fill.color=Oe.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:r},$b({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(t){let e=t?.width??this.width,r=t?.height??this.height;this.width=e,this.height=r,this.renderer.dpr=this.isScreenSpace?window.devicePixelRatio:Math.floor(2048/Math.max(e,r)),this.renderer.setSize(e,r),this.textureHolder?.dispose(),this.applyOverrides(t),this.frameOverride?.requestRender()}applyFrame(t){let e=this.context.scene.find2D(t);if(!(!e||!(e instanceof Br)))return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.textureHolder?.dispose(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(r=>{r.addEventListener("beginState",this.onFrameOverrideObjectEvent)}),this.frameOverride.traverse(r=>{r.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(t){return this.scene2d.find(t)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(t=>{t.removeEventListener("beginStateChange",this.onFrameOverrideObjectEvent)}),this.frameOverride?.traverse(t=>{t.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function $b({objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i}){if(n instanceof Br&&t instanceof Br)for(let a=0,s=n.children.length;a<s;a++){let l=n.children[a],u=t.children[a];l&&u&&l.uuid===u.uuid&&aM({objectOverride:l,objectRoot:u,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i})}}function aM({objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i}){let{width:a,height:s,position:l}=Yf({constraints:n.data,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i,objectInitialWidth:Xf(t)?t.width:0,objectInitialHeight:Xf(t)?t.height:0,objectInitialPosition:t.position});if(n.position=l,n.data={...n.data,position:l},n.states)for(let u in n.states)sM({stateId:u,objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i});Xf(n)&&(n.width=a,n.height=s,n.data={...n.data,width:a,height:s},$b({objectOverride:n,objectRoot:t,newParentWidth:n.width,newParentHeight:n.height,initialParentWidth:t.width,initialParentHeight:t.height}))}function sM({stateId:n,objectOverride:t,objectRoot:e,newParentWidth:r,newParentHeight:o,initialParentWidth:i,initialParentHeight:a}){let s=t.states?.[n],l=e.states?.[n];if(s&&l){let{width:u,height:c,position:d}=Yf({constraints:t.data,newParentWidth:r,newParentHeight:o,initialParentWidth:i,initialParentHeight:a,objectInitialWidth:tn.isResizeable(l)?l.width:0,objectInitialHeight:tn.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(t.states[n],{position:d}),tn.isResizeable(s)&&Object.assign(t.states[n],{width:u,height:c})}}function Xf(n){return n instanceof Go||n instanceof Br||n instanceof Xn||n instanceof Qn}var Yr=class extends Ta(Yb.Scene){constructor(e,r,o){super();this.data=r;this.bgColor=new Rt(1,1,1,1);this.fog=null;this.backupFog=new Bs.Fog(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new Bs.Color;this.penumbraSizeArrayCache=null;this.super_Entity(e,r),this.personalCamera=new pn(Tn,{...ui.defaultData,...r.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new Bs.HemisphereLight(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),r.uiScene?this.uiScene=new Mi((Array.isArray(e)?e[0]:e)+"-ui",r.uiScene,{dpr:window.devicePixelRatio,shared:o.shared}):r.uiFrame&&this.createUICanvas(r.uiFrame,o)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(e,r){this.uiCanvas=new Es(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,r),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,r){e.color!==void 0&&(this.ambientLight.color=Jt(e.color,r)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(r=>{r instanceof wr&&r.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof Sr)if(Array.isArray(e.material))for(let r of e.material)r.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&Tb(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,r){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let o=this.scene;o.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Jt(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,r){e.aoColor!==void 0&&(this.aoColor=Jt(e.aoColor,r))}updateByOp(e,r,o,i){let a=this.data.uiFrame;super.updateByOp(e,r,o,i);let s=r;Ne(e.path,["fog"])?this.updateFog(s.fog,o.shared):Ne(e.path,["ao"])?this.updateAo(s.ao,o.shared):Ne(e.path,["ambient"])?this.updateAmbientLight(s.ambient,o.shared):Ne(e.path,["shadow"])?this.updateShadow(s.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||a!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,o)}updateUIFrame(e,r){e?(this.uiCanvas||this.createUICanvas(e,r),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,r){this.updateState_Entity(e,r),e.backgroundColor!==void 0&&this.setBackgroundColor(Jt(e.backgroundColor,r.shared)),e.fog!==void 0&&this.updateFog(e.fog,r.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,r.shared),e.ao!==void 0&&this.updateAo(e.ao,r.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,r){}raycast(e,r){super.raycast(e,r)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,r=0;this.traverseEntity(o=>{if(!o.visible)return!0;o instanceof Is&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize,e+=1),o instanceof Ns&&o.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+r]=o.data.penumbraSize,r+=1)})}raycastWithClones(e){let r=[],o=i=>{for(let a of i.children){let s=a.cloner;De.is(a)&&(a.visible||s?.object.data.visible)&&((Wn(a)||jl(a)&&this.scene.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Xl(a,e,r,!0)),o(a))}};return o(this),r}updateEntity2DByOp(e,r,o,i){this.uiCanvas?.updateEntity2DByOp(e,r,o,i)}};var _r=require("three");var fd=class extends Os(_r.PointLight,Ms){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let a=new _r.Vector3(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new _r.Vector3(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),l=new _r.Box3(a,s),u=new _r.Box3Helper(l,new _r.Color(16755200));u.visible=!1,this.gizmos.shadowmap=u,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let e=this.gizmos[t];if(e instanceof _r.Box3Helper){let r=this.shadow.camera,o=new _r.Vector3(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),i=new _r.Vector3(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);e.box.set(o,i),e.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var hd=class extends yt{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Sl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var Ls=class extends yt{constructor(e,r,o){super(e,r,o);this._shapeId=null;this._context=o}updateState(e,r){super.updateState(e,r),this.updateShape()}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let i in e)typeof e[i]=="string"&&(e[i]=this._context.shared.getVariable(e[i],[this.uuid,"geometry","extrusion","shape",i]));let r;if(e.type==="Custom"){let i=e.shapeId;if(i!==this._shapeId&&this.detachShape(),i){this._shapeId=i;let a=this._context.scene.find(i);a?.data&&(a.attachedPaths.add(this),r=a.geometry.userData?.shape),r||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let i;switch(e.type){case"Rectangle":i=Ga;break;case"Ellipse":i=Ra;break;case"Polygon":i=Cu;break;case"Star":i=Tu;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=i.create({parameters:e}).userData.shape}let o=this.geometry;r&&o.inputs&&(o.inputs.shapeData=r,o.build(),this.attachedSurfaceCloners.forEach(i=>i.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,r){return super.updateTransformState(e,r)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.updateShape()}updateEntityBoxSize(e,r){let o=this.geometry.getAttribute("position");o!==void 0?Sl(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,r):super.updateEntityBoxSize(e,r)}};var Rs=require("three");var mn=class extends Ur(Rs.Group,qr){constructor(e,r,o){super();r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,o)),this.super_Entity(e,r),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,r){let o=ba.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(o){let i,a;for(let s of Po.rootOverrideProps)e[s]===void 0?(i===void 0&&(i={...e}),i[s]=o.data[s]):(a===void 0&&(a={}),a[s]=e[s],i===void 0&&(i={...e}),i[s]=bo.apply(o.data[s],e[s]));return this.overrideData=a,i}else return{...Dt.defaultData,...e,...Zr(Dt.defaultData,Po.rootOverrideProps)}}updateByOp(e,r,o,i){let a;if(this.isInstanceRoot&&!i){if(r=this.transformAssignData(r,o),e.type===0&&e.path.length===0&&this.component)for(let s of Po.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&Po.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:r[s]}})}}super.updateByOp(a??e,r,o,i)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let o=e.scene.find(r.component)??null,i=!1;if(o!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(De.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),md(s),a+=1;else break;this.children.splice(0,a)}i=!0}if(o){let a={};Qb(e,[this.uuid],r.overrides,this,o,o,0,i,a);for(let s of this.children)if(De.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(u=>{if(u instanceof yt&&u.isSkinnedMesh){let c=u.dataPatched;if(c.bones&&c.boneInverses){let d=c.bones.map(h=>e.scene.find(a[h])),p=c.boneInverses.map(h=>new Rs.Matrix4().fromArray(h)),f=new Rs.Skeleton(d,p);u.bind(f,u.bindMatrix)}}else u.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function md(n){if(n.component){let t=n.component.instances.indexOf(n);t>=0&&n.component.instances.splice(t,1);for(let e of n.children)De.is(e)&&md(e)}}function Xb(n,t,e,r){return n.component===t&&Rd(n.identity,r)?n.overrideData===e?2:1:0}function Qb(n,t,e,r,o,i,a,s,l){if(a>50)return!1;if(r.component!==o){if(r.component){let c=r.component.instances.indexOf(r);c>=0&&r.component.instances.splice(c,1)}o.instances.push(r),r.component=o}o instanceof mn&&o.isInstanceRoot&&o.expandInstanceChildren(n);let u=0;for(let c of o.children)if(De.is(c)){let d=[...t,...typeof c.identity=="string"?[c.identity]:c.identity],p=ga.resolve(e,d,1);if(p!=null&&!(p instanceof rt)){if(!1)debugger;Object.setPrototypeOf(p,rt.prototype),console.error("wrong prototype")}let f=null,h;if(!s){let m=r.children[u];if(f=De.is(m)?m:null,f!==null){let y=Xb(f,c,p,d);h=y>=1?f.stateSelection:void 0,y!==2&&(f=null)}if(f===null&&(f=n.scene.findInstance(d)??null,f!==null)){let y=Xb(f,c,p,d);if(h=y>=1?f.stateSelection:void 0,y!==2)f=null;else{let g=f.parent.children.indexOf(f);f.parent.children.splice(g,1),r.children.splice(u,0,f),f.parent===r?(g<=u&&console.error("not possible"),void 0):(f.parent=r,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),n.pendingDeletes.delete(f),void 0)}}}if(f===null){let m=p?bo.apply(c.data,p):c.data;Jr.is(m.type)&&(m={...m,type:"Empty"}),f=ro.createEntity(d,m,n),f.overrideData=p,r.add(f),r.children.splice(r.children.length-1,1),r.children.splice(u,0,f),f.updateState(f.data,n),h&&f.changeSelectedState(h,n),n.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let m=f.identity[f.identity.length-1];l[m]=f.uuid}u+=1,Qb(n,t,e,f,c,i,a+1,s,l)}if(!s){let c=u;for(;;){let d=r.children[u];if(De.is(d))n.pendingDeletes.add(d);else break;u+=1}r.children.splice(c,u-c)}return!0}var Kb=require("three");var yd=class extends Ur(Kb.Bone,qr){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(t,e){this.updateState_Entity(t,e)}};var Ii=class extends yt{constructor(e,r,o){super(e,r,o);this.onBeforeRender=()=>{this.uiCanvas.render()};this.uiCanvas=new Es(e+"-canvas",r.geometry.width,r.geometry.height,o),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,o.shared)})}updateByPatchedOpGeometry(e,r,o){super.updateByPatchedOpGeometry(e,r,o),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,o.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,o.shared))}applySize(e,r){let o=e?.width??this.dataPatched.geometry.width,i=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:o,height:i}),this.applyGeometryParametersFromFrame(r)}applyFrame(e,r){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(r),this.applyMaterialParametersFromFrame({shared:r})}applyGeometryParametersFromFrame(e){let r=this.frame;r&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:r.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:r.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=sn(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let r=this.frame;if(r){let o=r.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),this.material.reset(this.dataPatched.material,e,!0)}}updateEntity2DByOp(e,r,o,i){this.uiCanvas.updateEntity2DByOp(e,r,o,i),e===this.frameId&&r.type===0&&(r.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(i):Ne(r.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:i}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.applySize({width:e.width,height:e.height},r)}};var Ce=require("three"),wv=require("three/examples/jsm/misc/GPUComputationRenderer.js");var Yt=require("three"),Zb=require("three/examples/jsm/math/MeshSurfaceSampler.js");function Jb(n){let t=new Float32Array(n*n*2);for(let e=0;e<n;e++)for(let r=0;r<n;r++){let o=e*n+r;t[o*2+0]=e/(n-1),t[o*2+1]=r/(n-1)}return t}function ev(n){let t=Math.ceil(Math.sqrt(n));return Math.max(t,1)}function tv(n,t){let e=[],r=[],o=new Yt.Vector3,i=new Yt.Vector3,a=new Zb.MeshSurfaceSampler(n).build();for(let u=0;u<t;u++)a.sample(o,i),e.push(o.x,o.y,o.z),r.push(i.x,i.y,i.z);let s=new Float32Array(e),l=new Float32Array(r);return{positions:s,normals:l}}function Qf(n,t){let e=n,r=new Float32Array(4*t*t);for(let i=0;i<t*t;i++)r[4*i]=e[3*i],r[4*i+1]=e[3*i+1],r[4*i+2]=e[3*i+2],r[4*i+3]=0;let o=new Yt.DataTexture(r,t,t,Yt.RGBAFormat,Yt.FloatType);return o.needsUpdate=!0,o}function rv({size:n}){let t=new Float32Array(4*n*n);for(let r=0;r<n*n;r++)t[4*r]=r,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let e=new Yt.DataTexture(t,n,n,Yt.RGBAFormat,Yt.FloatType);return e.needsUpdate=!0,e}function ov(n){let t=new Float32Array(4*n*n);for(let r=0;r<n*n;r++)t[4*r]=0,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let e=new Yt.DataTexture(t,n,n,Yt.RGBAFormat,Yt.FloatType);return e.needsUpdate=!0,e}var nv=`
2615
+ `,eI=Ws.ShaderChunk.lights_fragment_begin,tI=Ws.ShaderChunk.shadowmask_pars_fragment,yv=null,rI=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},gv=(n="medium")=>{if(yv===n)return!1;yv=n;let t=rI(n);Ws.ShaderChunk.shadowmap_pars_fragment=JM(t);let e=eI.slice();e=e.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),e=e.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),Ws.ShaderChunk.lights_fragment_begin=e;let r=tI.slice();return r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),Ws.ShaderChunk.shadowmask_pars_fragment=r,!0};var dc=require("three");var xv=require("three");var $s=class extends Yo(xv.DirectionalLightHelper){constructor(e,r=15,o=10066329){super(e,r,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){Xo(this.object,$s.geometryHelper,e,r)}};var bv=require("three");var Ys=class extends Yo(bv.PointLightHelper){constructor(e,r=15,o=6710886){super(e,r,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){Xo(this.object,Ys.geometryHelper,e,r)}};var Dd=require("three");var Nd=class extends Yo(Dd.SpotLightHelper){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){Xo(this.object,Nd.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=Nd._vector,r=this.object.distance?this.object.distance:1e3,o=r*Math.tan(this.object.angle);this.cone.scale.set(o,o,r),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let i=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let a=0,s=this.cone.material.length;a<s;a++)this.cone.material[a].color.set(i);else this.cone.material.color.set(i)}}},uc=Nd;uc._vector=new Dd.Vector3;function oI(n,t){n.shadow.camera.right=t/2,n.shadow.camera.left=-t/2,n.shadow.camera.top=t/2,n.shadow.camera.bottom=-t/2,n.shadow.needsUpdate=!0}var Xs=class extends qs(dc.DirectionalLight,$s){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let a=new dc.CameraHelper(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof dc.CameraHelper&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let r=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&oI(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),r&&this.update()}};var Fv=require("three");var no=require("three");var vv=new no.Vector3,Sv=new no.Vector3,wv=new no.Quaternion,Qs=class extends qs(no.SpotLight,uc){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=no.MathUtils.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let a=new no.CameraHelper(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof no.CameraHelper&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),Sv.setFromMatrixPosition(this.matrixWorld),wv.setFromRotationMatrix(this.matrixWorld),vv.copy(this.up).applyQuaternion(wv).negate().multiplyScalar(this.distance),this.target.position.copy(Sv).add(vv),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var $e;(S=>{function n(){return[1,0,0,0,1,0,0,0,1]}S.identity=n;function t(P,O=S.identity()){for(let x=0,D=P.length;x<D;x++)O[x]=P[x];return O}S.copy=t;function e(P,O,x,D,N,T){return S.setAbcdef(S.identity(),P,O,x,D,N,T)}S.create=e;function r(P,O,x,D,N,T,I){return P[0]=O,P[1]=D,P[2]=T,P[3]=x,P[4]=N,P[5]=I,P}S.setAbcdef=r;function o(P,O){let[x,D,N,T,I,E]=a(P),[B,R,k,V,q,F]=a(O),U=B*x+R*N,H=B*D+R*T,$=k*x+V*N,J=k*D+V*T,K=q*x+F*N+I,X=q*D+F*T+E;return S.create(U,H,$,J,K,X)}S.append=o;function i(P,O){let[x,D,N,T,I,E]=a(P),[B,R,k,V,q,F]=a(O),U=x,H=D,$=N,J=T;(B!==1||R!==0||k!==0||V!==1)&&(U=x*B+D*k,H=x*R+D*V,$=N*B+T*k,J=N*R+T*V);let K=I*B+E*k+q,X=I*R+E*V+F;return S.create(U,H,$,J,K,X)}S.prepend=i;function a(P){return[P[0],P[3],P[1],P[4],P[2],P[5]]}S.getAbcdef=a;function s(P){let[O,x,D,N,T,I]=S.getAbcdef(P),E=O*N-x*D,B=N/E,R=-x/E,k=-D/E,V=O/E,q=(D*I-N*T)/E,F=-(O*I-x*T)/E;return S.create(B,R,k,V,q,F)}S.invert=s;function l([P,O],x){let[D,N,T,I,E,B]=S.getAbcdef(x);return[D*P+T*O+E,N*P+I*O+B]}S.apply=l;function u(P,O){let[x,D,N,T,I,E]=S.getAbcdef(O),B=1/(x*T+N*-D),[R,k]=P;return[T*B*R+-N*B*k+(E*N-I*T)*B,x*B*k+-D*B*R+(-E*x+I*D)*B]}S.applyInverse=u;function c(P,O,x=O){let[D,N,T,I,E,B]=S.getAbcdef(P);return S.setAbcdef(P,D*O,N*x,T*O,I*x,E*O,B*x),P}S.scale=c;function d(P,O){let x=Math.cos(O),D=Math.sin(O),[N,T,I,E,B,R]=S.getAbcdef(P);return S.setAbcdef(P,N*x-T*D,N*D+T*x,I*x-E*D,I*D+E*x,B*x-R*D,B*D+R*x),P}S.rotate=d;function p(P,O,x){let[D,N]=x,T=S.translate(P,-D,-N);return T=S.rotate(T,O),T=S.translate(T,D,N),T}S.rotateAround=p;function f(P,O,x){let[D,N,T,I,E,B]=S.getAbcdef(P);return S.setAbcdef(P,D,N,T,I,E+O,B+x),P}S.translate=f;function h(P,O,x){let[D,N,T,I]=S.getAbcdef(P);return S.setAbcdef(P,D,N,T,I,O,x),P}S.setTranslate=h;function m(P,O,x){let[D,N,T,I]=S.getAbcdef(P);return S.setAbcdef(P,D,N,T,I,O,x),P}S.setPosition=m;function y(P){let[O,x,D,N]=S.getAbcdef(P),T=Math.sqrt(O*O+x*x),I=Math.sqrt(D*D+N*N);return[T,I]}S.getScale=y;function g(P){let[,,,,O,x]=S.getAbcdef(P);return[O,x]}S.getPosition=g;function b(P,O){return S.decompose(P,O).rotation}S.getRotation=b;function w(P,O){let[x,D,N,T,I,E]=S.getAbcdef(P),B=-Math.atan2(-N,T),R=Math.atan2(D,x),k=Math.abs(B+R),V=0,q=[0,0];k<1e-5||Math.abs(Math.PI*2-k)<1e-5?(V=R,q[0]=q[1]=0):(V=0,q[0]=B,q[1]=R);let F=[Math.sqrt(x*x+D*D),Math.sqrt(N*N+T*T)];return{position:[I+(O[0]*x+O[1]*N)-O[0],E+(O[0]*D+O[1]*T)-O[1]],scale:F,rotation:V,skew:q,pivot:O}}S.decompose=w;function _(P,O,x,D,N=[0,0]){let[T,I]=P,[E,B]=O,[R,k]=D,[V,q]=N,F=Math.cos(x+q)*E,U=Math.sin(x+q)*E,H=-Math.sin(x-V)*B,$=Math.cos(x-V)*B,J=T-(R*F+k*H)+R,K=I-(R*U+k*$)+k;return S.create(F,U,H,$,J,K)}S.compose=_})($e||($e={}));var nI=Math.PI/180,gJ=180/Math.PI;function Av(n,t,e,r,o,i){let a=n-e,s=t-r;return a*a/(o*o)+s*s/(i*i)<=1}function _v(n){return n*nI}function Ph(n){return{all:n=n||new Map,on:function(t,e){var r=n.get(t);r?r.push(e):n.set(t,[e])},off:function(t,e){var r=n.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):n.set(t,[]))},emit:function(t,e){var r=n.get(t);r&&r.slice().map(function(o){o(e)}),(r=n.get("*"))&&r.slice().map(function(o){o(t,e)})}}}var An=class{constructor(t,e,r){this.uuid=t;this.data=e;this.localMatrix=$e.identity();this.worldMatrix=$e.identity();this.ignoreCameraZoom=!1;this.visible=!0;this._singleBBox=new ni;this._recursiveBBox=new ni;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.stateSelection=null;this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this.name="";this.position=[0,0];this.scale=[1,1];this.rotation=0;this.emitter=Ph();this.dpr=r.dpr??1,this.dataPatched=e}project(t,e){let r=this.worldMatrix;return e&&(r=$e.append(e.worldMatrix,r)),$e.applyInverse(t,r)}intersects(t,e,r){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:o}=this.singleBBox;return t>=r[0]&&t<=o[0]&&e>=r[1]&&e<=o[1]}applyTransforms(t){t.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=$e.compose(this.position,this.scale,_v(this.rotation),pn.getPivot(this.dataPatched))}updateWorldMatrix(t,e,r){let o=this.parent;e&&o!==null&&o!==void 0&&o.updateWorldMatrix(t,!0,!1),t&&this.updateLocalMatrix(),this.parent?this.worldMatrix=$e.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=$e.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return pn.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{t.resetBBoxNeedsUpdateSelf()})}updateTransformState(t){let e=!1;t.position!==void 0&&(e=!0,this.position=t.position),t.rotation!==void 0&&(e=!0,this.rotation=t.rotation),t.scale!==void 0&&(e=!0,this.scale=t.scale),e&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(t,e,r){t.type===0&&t.props.visible!==void 0&&(this.visible=t.props.visible),this.data=e,this.data=e;let o=t,i=ke(t.path,["states","*"]);if(i!==null){if(t.type===0){let[a]=i;if(this?.stateSelection===a){let s={...t.props};if(delete s.name,Object.values(t.props).some(l=>l===void 0)){let l=this.data;if(l!==void 0){let u=St.zoom(l,t.path.slice(2));if(u)for(let c in t.props)t.props[c]===void 0&&c in u&&(s[c]=u[c])}}o={...t,props:s,path:t.path.slice(2)}}}}else if(t.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(t.props.name!==void 0&&a.name){let{name:l,...u}=a;a=u}let s=St.removeOverridden(t.path,t.props,a);o={...t,props:s}}}this.updateByPatchedOpBase(o,Oi.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r)}changeSelectedState(t,e,r=!1){if(!(this.data.states.length===0&&!r)){for(let o of this.data.states)Oi.toOps(this.data,o.data).forEach(a=>{let s=Oa.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,e)});if(t!==null){let o=this.data.states.data(t);o&&(this.dataPatched=Oi.patch(this.data,o),Oi.toOps(this.data,o).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,e)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t}}updateState(t,e){t.name!==void 0&&(this.name=t.name),t.visible!==void 0&&(this.visible=t.visible),this.updateTransformState(t)}updateByPatchedOpBase(t,e,r){this.dataPatched=e,this.updateByPatchedOp(t,e,r)}updateByPatchedOp(t,e,r){t.path.length===0&&t.type===0&&this.updateState(t.props,r),this.requestRender()}traverseFrameAncestors(t){this.traverseAncestors(e=>{e.data.type==="frame2d"&&t(e)})}traverseAncestors(t){let e=this.parent;for(;e;)t(e),e=e.parent}requestRender(){this.traverseFrameAncestors(t=>{t.requestRender()})}clone(t){let e=new An(this.uuid,this.data,t);return e.parent=void 0,e}addEventListener(t,e){this.emitter.on(t,e)}removeEventListener(t,e){this.emitter.off(t,e)}dispatchEvent(t){this.emitter.emit(t.type,{...t,target:t.target??this})}traverseSortNextHelper(){let t=this.parent;if(t){let e=t.children;if(e){let r=e.indexOf(this)+1;return e[r]?e[r]:t.traverseSortNextHelper()}}}sortNext(){let t=this.children;return t&&t.length>0&&t[0]?t[0]:this.traverseSortNextHelper()}isDescendantOf(t){t instanceof An&&(t=t.uuid);let e=this;for(;e.parent;){if(e.parent.uuid===t)return!0;e=e.parent}return!1}};var gr=class extends An{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.context=o;this.children=[]}add(e){e.parent&&e.parent instanceof gr&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let r=this.children.indexOf(e);r>=0&&(this.children.splice(r,1),e.parent=void 0)}traverse(e){let r=e(this);if(r!==!0)for(let o of this.children)o instanceof gr?o.traverse(e):r=e(o)}intersectsChildren(e,r,o,i=!1,a=[]){for(let s of this.children)if(s instanceof gr&&s.intersectsChildren(e,r,o,i,a),s.intersects(e,r,o)&&(a.push(s),i))break;return a}updateWorldMatrix(e,r,o){if(super.updateWorldMatrix(e,r,o),o&&this.children)for(let i of this.children)i.updateWorldMatrix(e,!1,!0)}find(e){let r;return this.traverse(o=>{o.uuid===e&&(r=o)}),r}innerDrawChildren(e){for(let r=this.children.length-1;r>=0;r--)this.children[r].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let r=new gr(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}},_n=class extends gr{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.updateState(r,o)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let r=new _n(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}};function iI(n,t){let[[e,r],[o,i]]=n,[[a,s],[l,u]]=t,c=(e-o)*(s-u)-(r-i)*(a-l);if(c===0)return!1;let d=((e-a)*(s-u)-(r-s)*(a-l))/c,p=-((e-o)*(r-s)-(r-i)*(e-a))/c;return d>=0&&d<=1&&p>=0&&p<=1}var Ov=[[-1,1],[-1,-1],[1,-1],[1,1]],Pv=(n,t,e)=>{let r=n.getCenter(),o=n.getHalfSize(),i=$e.append(t,n.worldMatrix);o[0]===0&&o[1]===0?e.push($e.apply(r,i)):Ov.forEach(a=>{let s=[a[0]*o[0]+r[0],a[1]*o[1]+r[1]];e.push($e.apply(s,i))})},ni=class{constructor(){this.matrix=$e.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(t,e=!1){t.updateWorldMatrix(),this.makeEmpty(),$e.copy(t.worldMatrix,this.matrix);let r=$e.invert(t.worldMatrix);this.expandByObjectSize(t,r,e)}expandByObjectSize(t,e,r=!1){let o=[];r===!0&&t instanceof gr?t.traverse(i=>{i.visible&&Pv(i,e,o)}):Pv(t,e,o),this.setFromPoints(o)}getCenter(){let[t,e]=this.min,[r,o]=this.getHalfSize();return $e.apply([t+r,e+o],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(t){this.makeEmpty();for(let e of t)this.expandByPoint(e)}expandByPoint(t){this.min=[Math.min(this.min[0],t[0]),Math.min(this.min[1],t[1])],this.max=[Math.max(this.max[0],t[0]),Math.max(this.max[1],t[1])]}computeVertices(){let[t,e]=this.getHalfSize(),r=this.getCenter(),[o,i,a,s]=$e.getAbcdef(this.matrix),l=$e.create(o,i,a,s,r[0],r[1]);this.vertices=Ov.map(([u,c])=>$e.apply([u*t,c*e],l))}computeEdges(){this.edges=[];for(let t=0,e=this.vertices.length;t<e;++t)this.edges.push([this.vertices[t],this.vertices[(t+1)%e]])}project(t,e){let r=this.matrix;return e&&(r=$e.append(e.worldMatrix,r)),$e.applyInverse(t,r)}intersects(t,e,r){return this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:o}=this;return t>=r[0]&&t<=o[0]&&e>=r[1]&&e<=o[1]}containsPoint(t){let[e,r]=t,[o,i]=this.min,[a,s]=this.max;return e>=o&&e<=a&&r>=i&&r<=s}intersectsBBox2D(t){for(let e=0,r=this.edges.length;e<r;e++){let o=this.edges[e];for(let i=0,a=t.edges.length;i<a;i++){let s=t.edges[i];if(iI(o,s))return!0}}for(let e=0,r=t.vertices.length;e<r;e++){let o=t.vertices[e];if(this.containsPoint(o))return!0}return!1}ensureMinMax(){let t=this.min,e=this.max;this.min=[Math.min(t[0],e[0]),Math.min(t[1],e[1])],this.max=[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}copy(t){this.min=[...t.min],this.max=[...t.max],$e.copy(t.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let t=new ni;return t.copy(this),t}};var Tv,Mv=new Promise(n=>{Tv=n}),Cv=!1;var Ed;function Iv(){if(Cv)return;if(Ed)return Ed;async function n(){let e=await import("./ui.js");Tv(e.default??e),Cv=!0}return Ed=n(),Ed}function Ev(n){let t=!1;return n.scene.objects.traverse((e,r)=>{(r.type==="Mesh"&&r.geometry.type==="UIGeometry"||r.type==="Page"&&r.uiFrame!==void 0)&&(t=!0)}),t}var Te,Oh;async function aI(n){let t=await Mv;Te||(Oh||(Oh=t({locateFile:()=>n})),Te=await Oh)}var Nv=$e.identity(),fc=class{constructor(t,e=1){this.canvas=t;this.dpr=e;this._width=0;this._height=0;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=Be.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=Be.transparent;this._fonts=new Map;try{let r=t.getBoundingClientRect();t.width=r.width*e,t.height=r.height*e}catch{console.log(t.width,e)}this._currentM3Transform=Nv,this._currentTransform=new Float32Array(Nv)}async init(){if(!this.wasmURL)throw Error("Your must set the wasm binary url with renderer.wasmURL = ... before you can call renderer.init");await aI(this.wasmURL),this._surface=Te.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas(),this._paint=new Te.Paint,this._paint.setAntiAlias(!0),this._paintFill=this._paint.copy(),this._paintFill.setStyle(Te.PaintStyle.Fill),this._paintStroke=this._paint.copy(),this._paintStroke.setStyle(Te.PaintStyle.Stroke),this.ctx?.scale(this.dpr,this.dpr)}get currentTransform(){return this._currentM3Transform}get currentTransformBuffer(){return this._currentTransform}set currentTransform(t){this._currentM3Transform=t,this._currentTransform.set(t)}async loadFont(t,e){let r=await(await fetch(t)).arrayBuffer();this.registerFont(r,e)}registerFont(t,e){if(this._fonts.has(e))return;let r=Te.FontMgr.FromData(t);if(r)this._fonts.set(e,r);else throw new Error("Invalid font data for "+e)}get width(){return this._width}get height(){return this._height}set strokeColor(t){this._paintStroke&&this._paintStroke.setColor(Bd(t),Te.ColorSpace.DISPLAY_P3)}set fillColor(t){this._paintFill&&this._paintFill.setColor(Bd(t),Te.ColorSpace.DISPLAY_P3)}set lineWidth(t){this._paintStroke&&this._paintStroke.setStrokeWidth(this._strokeMode==="center"?t:t*2)}set strokeMode(t){this._strokeMode=t}set dropShadowBlur(t){this._dropShadowBlur=t}set dropShadowColor(t){this._dropShadowColor=t}set dropShadowOffsetX(t){this._dropShadowOffsetX=t}set dropShadowOffsetY(t){this._dropShadowOffsetY=t}set innerShadowBlur(t){this._innerShadowBlur=t}set innerShadowColor(t){this._innerShadowColor=t}set innerShadowOffsetX(t){this._innerShadowOffsetX=t}set innerShadowOffsetY(t){this._innerShadowOffsetY=t}set innerShadowSpread(t){this._innerShadowSpread=t}set layerBlur(t){this._layerBlur=t}set backgroundBlur(t){this._backgroundBlur=t}clear(){this.ctx?.clear(Te.TRANSPARENT)}save(){this.ctx?.save()}restore(){this.ctx?.restore()}beginPath(){this._currentPath?.delete(),this._currentPath=new Te.Path}closePath(){let t=this._currentPath;if(t){if(t.isEmpty())return;let e=t.getBounds();(e[3]-e[1]||e[2]-e[0])&&t.close()}}fill(){this._paintInner(this._paintFill,!0)}stroke(){this._paintInner(this._paintStroke,!1)}clipRect(t,e,r,o,i=0,a=0,s=0,l=0){let u=Te.XYWHRect(t,e,r,o);if(i===0&&a===0&&l===0&&s===0)this.ctx?.clipRect(u,Te.ClipOp.Intersect,!0);else{let c=Te.RRectXY(u,i,i);c[4]=c[5]=i,c[6]=c[7]=a,c[8]=c[9]=s,c[10]=c[11]=l,this.ctx?.clipRRect(c,Te.ClipOp.Intersect,!0)}}_applyShadowOffsetMatrix(){if(this.ctx){let t=$e.invert(this.currentTransform);this.ctx.concat(t);let e=$e.translate($e.identity(),this._dropShadowOffsetX,this._dropShadowOffsetY);this.ctx.concat(e),this.ctx.concat(this._currentTransform)}}_applyEffectsToPaint(t,e,r=!0){if(this.ctx&&this._currentPath){let o,i=!1;if(r&&this._hasDropShadow()){let a=t.copy();a.setColor(Bd(this._dropShadowColor));let s;this._dropShadowBlur>0&&(s=Te.MaskFilter.MakeBlur(Te.BlurStyle.Normal,this._dropShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s)),this.ctx.save(),this.ctx.clipPath(this._currentPath,Te.ClipOp.Difference,!0),this._applyShadowOffsetMatrix(),e(a),this.ctx.restore(),a.delete(),s?.delete()}if(this._backgroundBlur>0&&r){this.ctx.save(),this.ctx.clipPath(this._currentPath,Te.ClipOp.Intersect,!0);let a=Te.ImageFilter.MakeBlur(this._backgroundBlur,this._backgroundBlur,Te.TileMode.Clamp,null),s=t.copy();s.setImageFilter(a),s.setAlphaf(1);let l=this._currentPath.computeTightBounds();this.ctx.saveLayer(s,l,null,Te.SaveLayerInitWithPrevious),this.ctx.drawColor(t.getColor()),this.ctx.restore(),this.ctx.restore(),s.delete(),a.delete(),i=!0}if(this._layerBlur>0){let a=t.copy();o=Te.MaskFilter.MakeBlur(Te.BlurStyle.Normal,this._layerBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(o),e(a),a.delete(),o.delete(),i=!0}if(i||e(t),r&&this._hasInnerShadow()){let a=new Te.Paint;a.setAntiAlias(!0),a.setStyle(Te.PaintStyle.Fill),a.setColor(Bd(this._innerShadowColor));let s;this._innerShadowBlur>0&&(s=Te.MaskFilter.MakeBlur(Te.BlurStyle.Normal,this._innerShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s));let l=this._currentPath.computeTightBounds(),[u,c,d,p]=l,f=d-u,h=p-c;this.ctx.save(),this.ctx.clipPath(this._currentPath,Te.ClipOp.Intersect,!0),this.ctx.saveLayer(a,l,null,Te.SaveLayerInitWithPrevious),this.ctx?.translate(this._innerShadowOffsetX,this._innerShadowOffsetY),this.ctx.drawRect(Te.XYWHRect(-1e3-this._innerShadowOffsetX,-1e3-this._innerShadowOffsetY,2e3+f+Math.abs(this._innerShadowOffsetX*2),2e3+h+Math.abs(this._innerShadowOffsetY*2)),a),a.setBlendMode(Te.BlendMode.Clear),this.ctx.drawPath(this._currentPath,a),this.ctx.restore(),this.ctx.restore(),a.delete(),s?.delete()}}}_paintInner(t,e=!0){if(this.ctx&&this._currentPath&&t){let r=this.ctx,o=this._currentPath;this._applyEffectsToPaint(t,i=>{let a=!1;!e&&this._strokeMode!=="center"&&(r.save(),r.clipPath(o,this._strokeMode==="outside"?Te.ClipOp.Difference:Te.ClipOp.Intersect,!0),a=!0),r.drawPath(o,i),a&&r.restore()},e)}}_hasDropShadow(){return this._dropShadowColor?.a>0}_hasInnerShadow(){return this._innerShadowColor?.a>0}path(t){this._currentPath?.addPath(Te.Path.MakeFromSVGString(t))}ellipse(t,e,r,o,i,a,s,l){if(!Dv([t,e,r,o])||!this._currentPath)return;if(r<0||o<0)throw Error("radii cannot be negative");let u=Te.XYWHRect(t-r,e-o,r*2,o*2);this._currentPath?.addOval(u)}rect(t,e,r,o,i=0,a=0,s=0,l=0){let u=Te.XYWHRect(t,e,r,o);if(!!Dv(u))if(i===0&&a===0&&l===0&&s===0)this._currentPath?.addRect(u);else{let c=Te.RRectXY(u,i,i);c[4]=c[5]=i,c[6]=c[7]=a,c[8]=c[9]=s,c[10]=c[11]=l,this._currentPath?.addRRect(c)}}getHorizontalAlign(t){switch(t){case 2:return Te.TextAlign.Right;case 3:return Te.TextAlign.Center;case 4:return Te.TextAlign.Justify;case 1:default:return Te.TextAlign.Left}}drawTextInner(t,e,r,[o,i,a,s],l,u,c=!0){let d=0,{ctx:p}=this;if(!p)return d;let f=u.copy(),h=u.copy();return h.setAlphaf(0),this._applyEffectsToPaint(f,m=>{e.pushPaintStyle(r,m,h),e.addText(t);let y=e.build();y.layout(a);let g=i;l===2?g+=(s-y.getHeight())/2:l===3&&(g+=s-y.getHeight()),p.drawParagraph(y,o,g),d=y.getHeight(),e.reset(),y.delete()},c),f.delete(),h.delete(),d}drawText(t,e){let r=0,o=this._fonts.get(e.font),{ctx:i,_paintFill:a,_paintStroke:s}=this;if(o&&i){let l=new Te.TextStyle({fontFamilies:[e.font],fontSize:e.fontSize,heightMultiplier:e.lineHeight,letterSpacing:e.letterSpacing}),u=new Te.ParagraphStyle({textStyle:l,textAlign:this.getHorizontalAlign(e.horizontalAlign)}),c=Te.XYWHRect(e.x,e.y,e.width,e.height),d=Te.ParagraphBuilder.Make(u,o);a&&(r=this.drawTextInner(t,d,l,c,e.verticalAlign,a,!0)),s&&(r=this.drawTextInner(t,d,l,c,e.verticalAlign,s,!1)),d.delete()}return{height:r}}render(){this._surface?.flush()}moveTo(t,e){this._currentPath?.moveTo(t,e)}lineTo(t,e){this._currentPath?.lineTo(t,e)}bezierCurveTo(t,e,r,o,i,a){this._currentPath?.cubicTo(t,e,r,o,i,a)}quadraticCurveTo(t,e,r,o){this._currentPath?.quadTo(t,e,r,o)}setTransform(t,e=!1){if(!this.ctx)return;let r=this.ctx.getTotalMatrix(),o=$e.invert(r);if(o&&this.ctx.concat(o),this.ctx?.scale(this.dpr,this.dpr),this.camera?.enabled&&(this.ctx?.concat(this.camera.worldMatrix),e)){let i=$e.getScale(this.camera.worldMatrix);this.ctx?.scale(1/i[0],1/i[1])}this.ctx?.concat(t),this.currentTransform=t}transform(t){this.ctx?.concat(t)}setSize(t,e){t===this._width&&e===this._height||(this._width=t,this._height=e,this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.canvas.width=t*this.dpr,this.canvas.height=e*this.dpr,this._surface&&(this._surface=Te.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas()))}};function Dv(n){for(let t=0;t<n.length;t++)if(n[t]!==void 0&&!Number.isFinite(n[t]))return!1;return!0}function Bd({r:n,g:t,b:e,a:r}){return Te.Color4f(n,t,e,r)}var hc=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Be.transparent;this.blurRadius=0;this.offset=[0,0];this.spread=0;this.update(e)}update(t){t.color!==void 0&&(this.color=t.color),t.enabled!==void 0&&(this.enabled=t.enabled),t.blurRadius!==void 0&&(this.blurRadius=t.blurRadius),t.offset!==void 0&&(this.offset=t.offset),t.spread!==void 0&&(this.spread=t.spread)}};var mc=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.radius=0;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.radius!==void 0&&(this.radius=t.radius)}};var Ld=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Be.transparent;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color)}};var Rd=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Be.transparent;this.thickness=0;this.mode="inside";this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color),t.thickness!==void 0&&(this.thickness=t.thickness),t.mode!==void 0&&(this.mode=t.mode)}};var Br=class extends An{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.autoClose=!0;this.fill=new Ld(e+"-fill",r.fill,o),this.stroke=new Rd(e+"-stroke",r.stroke,o),this.dropShadow=new hc(e+"-dropShadow",r.dropShadow,o),this.innerShadow=new hc(e+"-innerShadow",r.innerShadow,o),this.backgroundBlur=new mc(e+"-backgroundBlur",r.backgroundBlur,o),this.layerBlur=new mc(e+"-layerBlur",r.layerBlur,o)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Be.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Be.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=Be.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=Be.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.type===0&&(ke(e.path,["fill"])?this.fill.update(e.props):ke(e.path,["stroke"])?this.stroke.update(e.props):ke(e.path,["dropShadow"])?this.dropShadow.update(e.props):ke(e.path,["innerShadow"])?this.innerShadow.update(e.props):ke(e.path,["layerBlur"])?this.layerBlur.update(e.props):ke(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,r){super.updateState(e,r),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let r=new Br(this.uuid,this.data,e);return r.parent=void 0,r}};var ii=class extends Br{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.width=0;this.height=0;this.updateState(r,o)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,r){return Av(e,r,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e)}clone(e){let r=new ii(this.uuid,this.data,e);return r.parent=void 0,r}};var Qo=class extends Br{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.width=0;this.height=0;this.cornerRadius=[0,0,0,0];this.updateState(r,o)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let r=new Qo(this.uuid,this.data,e);return r.parent=void 0,r}};var ai=class extends Br{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this._textHeight=0;this._textHeightDirty=!0;this.width=0;this.height=0;this.updateState(r,o)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Be.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Be.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){this._fontHolder?.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let r=this.data.textTransform,o=this.data.text.textValue.toString(),i=r===2?o.toUpperCase():r===3?o.toLowerCase():o,{height:a}=e.drawText(i,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=a}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:r}){e.font!==void 0&&(this._fontHolder=r.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateFontState(e,r)}clone(e){let r=new ai(this.uuid,this.data,e);return r.parent=void 0,r}};var Ks=class extends Br{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.curves=[];this.extremasBBox={min:[0,0],max:[0,0]};this.updateState(r,o)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(i=>Vd.extremas(i)),r=[1/0,1/0],o=[-1/0,-1/0];for(let i=0,a=e.length;i<a;i++){let s=e[i];s[0][0]<r[0]&&(r[0]=s[0][0]),s[0][1]<r[1]&&(r[1]=s[0][1]),s[1][0]>o[0]&&(o[0]=s[1][0]),s[1][1]>o[1]&&(o[1]=s[1][1])}return this.extremasBBox.min=[r[0],r[1]],this.extremasBBox.max=[o[0],o[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let o=1,i=this.data.points.length;o<i;o++){let a=this.data.points[o].data,s=this.data.points[o-1].data,l={start:s.position,cp1:s.controlNext.position,cp2:a.controlPrevious.position,end:a.position};this.curves.push(l)}let e=this.data.points[0].data,r=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let o={start:r.position,cp1:r.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(o)}}getCenter(){let[e,r]=this.extremasBBox.min,[o,i]=this.getHalfSize();return[e+o,r+i]}getHalfSize(){let{min:e,max:r}=this.extremasBBox;return[(r[0]-e[0])*.5,(r[1]-e[1])*.5]}innerDraw(e){for(let i=0,a=this.data.points.length;i<a;i++){let s=this.data.points[i].data;if(i===0){let[l,u]=s.position;e.moveTo(l,u)}else{let l=this.data.points[i-1].data,[u,c]=l.controlNext.position,[d,p]=s.controlPrevious.position,[f,h]=s.position,m={start:l.position,cp1:l.controlNext.position,cp2:s.controlPrevious.position,end:s.position};Vd.derive(m),e.bezierCurveTo(u,c,d,p,f,h)}}let r=this.data.points[0].data,o=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[i,a]=o.controlNext.position,[s,l]=r.controlPrevious.position,[u,c]=r.position;e.bezierCurveTo(i,a,s,l,u,c)}}updateState(e,r){super.updateState(e,r),this.computeExtremas()}clone(e){let r=new Ks(this.uuid,this.data,e);return r.parent=void 0,r}},Vd;(i=>{function n(a){let s=a.start,l=a.cp1,u=a.cp2,c=a.end,d=[3*(l[0]-s[0]),3*(l[1]-s[1])],p=[3*(u[0]-l[0]),3*(u[1]-l[1])],f=[3*(c[0]-u[0]),3*(c[1]-u[1])],h={start:d,cp:p,end:f};return a.derivative=h,h.derivative=Ch.derive(h),h}i.derive=n;function t(a,s,l,u=!1){let c=a-2*s+l;if(c!==0){let d=-Math.sqrt(Math.abs(s*s-a*l)),p=-a+s,f=-(d+p)/c,h=-(-d+p)/c;return[f,h]}else if(s!==l&&c===0)return[(2*s-l)/(2*(s-l))];return[]}function e(a){let s=a.derivative??i.derive(a),l=s.start,u=s.cp,c=s.end;return[t(l[0],u[0],c[0]),t(l[1],u[1],c[1])]}i.droot=e;function r(a){let[s,l]=i.droot(a),u=[a.start[0],a.end[0]],c=[a.start[1],a.end[1]];for(let d of s)u.push(i.compute(a,Math.min(1,Math.max(0,d)))[0]);for(let d of l)c.push(i.compute(a,Math.min(1,Math.max(0,d)))[1]);return u.sort((d,p)=>d-p),c.sort((d,p)=>d-p),[[u[0],c[0]],[u[u.length-1],c[c.length-1]]]}i.extremas=r;function o(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let l=1-s,u=l*l,c=s*s,d=u*l,p=u*s*3,f=l*c*3,h=s*c;return[d*a.start[0]+p*a.cp1[0]+f*a.cp2[0]+h*a.end[0],d*a.start[1]+p*a.cp1[1]+f*a.cp2[1]+h*a.end[1]]}i.compute=o})(Vd||(Vd={}));var Ch;(r=>{function n(o){let i=o.start,a=o.cp,s=o.end,l=[2*(a[0]-i[0]),2*(a[1]-i[1])],u=[2*(s[0]-a[0]),2*(s[1]-a[1])],c={start:l,end:u};return c.derivative=Th.derive(c),o.derivative=c,c}r.derive=n;function t(o){let i=o.derivative??r.derive(o),a=i.start,s=i.end;return[a[0]!==s[0]?a[0]/(a[0]-s[0]):0,a[1]!==s[1]?a[1]/(a[1]-s[1]):0]}r.droot=t;function e(o,i){if(i===0)return[...o.start];if(i===1)return[...o.end];let a=1-i,s=a*a,l=i*i,u=s,c=a*i*2,d=l;return[u*o.start[0]+c*o.cp[0]+d*o.end[0],u*o.start[1]+c*o.cp[1]+d*o.end[1]]}r.compute=e})(Ch||(Ch={}));var Th;(e=>{function n(r){let o=r.start,i=r.end,a=[i[0]-o[0],i[1]-o[1]];return r.derivative=a,r.derivative}e.derive=n;function t(r,o){if(o===0)return[...r.start];if(o===1)return[...r.end];let i=r.start,a=r.end;return[i[0]+(a[0]-i[0])*o,i[1]+(a[1]-i[1])*o]}e.compute=t})(Th||(Th={}));var qr=class extends gr{constructor(e,r,o){super(e,r,o);this.uuid=e;this.width=0;this.height=0;this.background=new Qo(e+"-background",ja.defaultData,o),this.background.parent=this,this.updateState(r,o)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){super.updateLocalMatrix(),this.background?.updateLocalMatrix()}updateWorldMatrix(e,r,o){super.updateWorldMatrix(e,r,o),this.background?.updateWorldMatrix(e,r,o)}draw(e){if(!this.visible)return;e.save();let r=this.width,o=this.height;this.applyTransforms(e),this.background.width=r,this.background.height=o,this.background.draw(e),e.clipRect(0,0,r,o,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.type===0&&(ke(e.path,["fill"])?this.fill.update(e.props):ke(e.path,["stroke"])?this.stroke.update(e.props):ke(e.path,["dropShadow"])?this.dropShadow.update(e.props):ke(e.path,["innerShadow"])?this.innerShadow.update(e.props):ke(e.path,["layerBlur"])?this.layerBlur.update(e.props):ke(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let r=new qr(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}};var Zs=class extends Br{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this._pathBBox=new DOMRect;this.updateState(r,o),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg"),r=document.createElementNS("http://www.w3.org/2000/svg","path");document.body.appendChild(e),r.setAttribute("d",this.data.path),e.appendChild(r),this._pathBBox=r.getBBox(),e.remove()}innerDraw(e){e.path(this.data.path)}intersectsInLocalSpace(e,r){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&r>=this._pathBBox.y&&r<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,r){super.updateState(e,r),e.path!==void 0&&this.computeSVGBBox()}clone(e){let r=new Zs(this.uuid,this.data,e);return r.parent=void 0,r}};function Bv(n,t,e){switch(t.type){case"ellipse2d":return new ii(n,t,e);case"rectangle2d":return new Qo(n,t,e);case"text2d":return new ai(n,t,e);case"vector2d":return new Ks(n,t,e);case"path2d":return new Zs(n,t,e);case"frame2d":return new qr(n,t,e);case"group2d":default:return new _n(n,t,e)}}var Mh=class{constructor(t,e,r){this.uuid=t;this.data=e;this.group=new _n(Mh.GROUP_ID,{...Ol.defaultData},r),this.createChildrenObjects(e.objects,this.group,r)}createObject(t,e,r,o,i,a){let s=Bv(t,e,a);s&&(o.add(s),o.children.splice(i,0,o.children.pop()),s.updateWorldMatrix(),r.length>0&&(s instanceof _n||s instanceof qr)&&this.createChildrenObjects(r,s,a))}createChildrenObjects(t,e,r){let o=0;for(let i of t)this.createObject(i.id,i.data,i.children,e,o,r),o+=1}draw(t){this.group.draw(t)}updateEntityByOp(t,e,r,o){let i=this.find(t);if(i)try{i.updateByOp(e,r,{shared:o})}catch(a){console.error(a)}}updateTreeByOp(t,e){if(t.path.length===0&&t.type===7){let r=t.parent===null?this.group:this.find(t.parent);r!==void 0&&r instanceof gr&&(this.createObject(t.id,t.data,t.children,r,t.localIndex,e),r.requestRender())}else if(t.path.length===0&&t.type===8){let r=this.find(t.id);if(r!==void 0&&r.parent!==void 0&&r.parent instanceof gr){let o=r.parent;r.resetBBoxNeedsUpdate(),o?.remove(r),o?.requestRender()}}else if(t.path.length===0&&t.type===9){let r=this.find(t.id);if(r!==void 0){let o=r.parent,i=t.parent===null?this:this.find(t.parent);if(i===void 0&&!1&&console.error("unexpected",i,t),i instanceof gr||i===this){i.add(r);let a=t.localIndex;i.children.splice(a,0,i.children.pop()),r.updateWorldMatrix(!0,!1,!0),o?.requestRender(),r.requestRender()}r.resetBBoxNeedsUpdate()}}}add(t){this.group.add(t)}remove(t){this.group.remove(t)}traverse(t){this.group.traverse(e=>{e!==this.group&&t(e)})}intersectsChildren(t,e,r,o=!1,i=[]){return this.group.intersectsChildren(t,e,r,o,i)}find(t){return this.group.find(t)}get children(){return this.group.children}project(t,e){return this.group.project(t,e)}getWithSortKey(t){let e=this.find(t);if(e===void 0)return;let r=[],o=e;for(;o!==this.group;){let i=o;o=o.parent;let a=o.children.indexOf(i);r.splice(0,0,a)}return{entity:e,sortKey:r}}getAllSorted(t){let e=[];for(let r of t){let o=this.getWithSortKey(r.id);o!==void 0&&e.push(o)}return e.sort((r,o)=>Oc(r.sortKey,o.sortKey)),e.map(r=>r.entity)}},Ui=Mh;Ui.GROUP_ID="scene2d";function Ih({constraints:n,newParentWidth:t,newParentHeight:e,initialParentWidth:r,initialParentHeight:o,objectInitialWidth:i,objectInitialHeight:a,objectInitialPosition:s}){let{horizontalConstraint:l,verticalConstraint:u}=n,c=t-r,d=e-o,p=i,f=a,h=s[0],m=s[1];if(l!==0){if(l===1)h+=c;else if(l===3)h+=c/2;else if(l===2)p=Math.max(1,p+c);else if(l===4){let y=t/r;p*=y,h*=y}}if(u!==0){if(u===1)m+=d;else if(u===3)m+=d/2;else if(u===2)f=Math.max(1,f+d);else if(u===4){let y=e/o;f*=y,m*=y}}return{width:p,height:f,position:[h,m]}}var uI=hr(zv(),1);var Wte={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{mm:1,px:1,cm:1,in:1,pt:1,pc:1}};var Gv=require("three"),dI=$e.identity(),Js=class{constructor(t,e,r,o){this.uuid=t;this.width=e;this.height=r;this.context=o;this.enabled=!0;this.isScreenSpace=!1;this.isFrameDirty=!1;this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.context.shared.requestRender()};this.onFrameOverrideObjectEvent=t=>{if(t.target?.uuid!==void 0){let e=this.frameRoot?.find(t.target.uuid);e&&e.dispatchEvent({...t,target:e})}};this.scene2d=new Ui(Gv.MathUtils.generateUUID(),Ru.defaultData,{dpr:window.devicePixelRatio,shared:o.shared}),this.canvas=document.createElement("canvas"),this.renderer=new fc(this.canvas),o.shared.addCanvas(this.uuid,this.canvas),this.textureHolder=o.shared.canvas(this.uuid),this.promise=this.init()}async init(){this.renderer instanceof fc&&(this.renderer.wasmURL=Pb.skiaWasmUrl),await this.renderer.init()}render(){this.isFrameDirty&&(this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.textureHolder?.setNeedsUpdate(!0),this.isFrameDirty=!1)}updateEntity2DByOp(t,e,r,o){this.scene2d.updateEntityByOp(t,e,r,o),this.applySize()}updateTreeByOp(t,e){this.scene2d.updateTreeByOp(t,e),this.applySize()}applyOverrides(t){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=t?.width??this.width,r=t?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=r,this.frameOverride.localMatrix=dI,this.isScreenSpace&&(this.frameOverride.fill.color=Be.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:r},kv({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(t){let e=t?.width??this.width,r=t?.height??this.height;this.width=e,this.height=r,this.renderer.dpr=this.isScreenSpace?window.devicePixelRatio:Math.floor(2048/Math.max(e,r)),this.renderer.setSize(e,r),this.textureHolder?.dispose(),this.applyOverrides(t),this.frameOverride?.requestRender()}applyFrame(t){let e=this.context.scene.find2D(t);if(!(!e||!(e instanceof qr)))return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.textureHolder?.dispose(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(r=>{r.addEventListener("beginState",this.onFrameOverrideObjectEvent)}),this.frameOverride.traverse(r=>{r.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(t){return this.scene2d.find(t)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(t=>{t.removeEventListener("beginStateChange",this.onFrameOverrideObjectEvent)}),this.frameOverride?.traverse(t=>{t.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function kv({objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i}){if(n instanceof qr&&t instanceof qr)for(let a=0,s=n.children.length;a<s;a++){let l=n.children[a],u=t.children[a];l&&u&&l.uuid===u.uuid&&pI({objectOverride:l,objectRoot:u,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i})}}function pI({objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i}){let{width:a,height:s,position:l}=Ih({constraints:n.data,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i,objectInitialWidth:Nh(t)?t.width:0,objectInitialHeight:Nh(t)?t.height:0,objectInitialPosition:t.position});if(n.position=l,n.data={...n.data,position:l},n.states)for(let u in n.states)fI({stateId:u,objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i});Nh(n)&&(n.width=a,n.height=s,n.data={...n.data,width:a,height:s},kv({objectOverride:n,objectRoot:t,newParentWidth:n.width,newParentHeight:n.height,initialParentWidth:t.width,initialParentHeight:t.height}))}function fI({stateId:n,objectOverride:t,objectRoot:e,newParentWidth:r,newParentHeight:o,initialParentWidth:i,initialParentHeight:a}){let s=t.states?.[n],l=e.states?.[n];if(s&&l){let{width:u,height:c,position:d}=Ih({constraints:t.data,newParentWidth:r,newParentHeight:o,initialParentWidth:i,initialParentHeight:a,objectInitialWidth:pn.isResizeable(l)?l.width:0,objectInitialHeight:pn.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(t.states[n],{position:d}),pn.isResizeable(s)&&Object.assign(t.states[n],{width:u,height:c})}}function Nh(n){return n instanceof Qo||n instanceof qr||n instanceof ii||n instanceof ai}var io=class extends $a(Fv.Scene){constructor(e,r,o){super();this.data=r;this.bgColor=new Yt(1,1,1,1);this.fog=null;this.backupFog=new el.Fog(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new el.Color;this.penumbraSizeArrayCache=null;this.super_Entity(e,r),this.personalCamera=new wn(zn,{..._i.defaultData,...r.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new el.HemisphereLight(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),r.uiScene?this.uiScene=new Ui((Array.isArray(e)?e[0]:e)+"-ui",r.uiScene,{dpr:window.devicePixelRatio,shared:o.shared}):r.uiFrame&&this.createUICanvas(r.uiFrame,o)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(e,r){this.uiCanvas=new Js(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,r),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,r){e.color!==void 0&&(this.ambientLight.color=ur(e.color,r)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(r=>{r instanceof Er&&r.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof Dr)if(Array.isArray(e.material))for(let r of e.material)r.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&gv(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,r){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let o=this.scene;o.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=ur(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,r){e.aoColor!==void 0&&(this.aoColor=ur(e.aoColor,r))}updateByOp(e,r,o,i){let a=this.data.uiFrame;super.updateByOp(e,r,o,i);let s=r;ke(e.path,["fog"])?this.updateFog(s.fog,o.shared):ke(e.path,["ao"])?this.updateAo(s.ao,o.shared):ke(e.path,["ambient"])?this.updateAmbientLight(s.ambient,o.shared):ke(e.path,["shadow"])?this.updateShadow(s.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||a!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,o)}updateUIFrame(e,r){e?(this.uiCanvas||this.createUICanvas(e,r),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,r){this.updateState_Entity(e,r),e.backgroundColor!==void 0&&this.setBackgroundColor(ur(e.backgroundColor,r.shared)),e.fog!==void 0&&this.updateFog(e.fog,r.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,r.shared),e.ao!==void 0&&this.updateAo(e.ao,r.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,r){}raycast(e,r){super.raycast(e,r)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,r=0;this.traverseEntity(o=>{if(!o.visible)return!0;o instanceof Xs&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize,e+=1),o instanceof Qs&&o.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+r]=o.data.penumbraSize,r+=1)})}raycastWithClones(e){let r=[],o=i=>{for(let a of i.children){let s=a.cloner;Fe.is(a)&&(a.visible||s?.object.data.visible)&&((ri(a)||cc(a)&&this.scene.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),yc(a,e,r,!0)),o(a))}};return o(this),r}updateEntity2DByOp(e,r,o,i){this.uiCanvas?.updateEntity2DByOp(e,r,o,i)}};var Lr=require("three");var Gd=class extends qs(Lr.PointLight,Ys){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let a=new Lr.Vector3(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new Lr.Vector3(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),l=new Lr.Box3(a,s),u=new Lr.Box3Helper(l,new Lr.Color(16755200));u.visible=!1,this.gizmos.shadowmap=u,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let e=this.gizmos[t];if(e instanceof Lr.Box3Helper){let r=this.shadow.camera,o=new Lr.Vector3(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),i=new Lr.Vector3(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);e.box.set(o,i),e.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var kd=class extends Ot{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?jl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var tl=class extends Ot{constructor(e,r,o){super(e,r,o);this._shapeId=null;this._context=o}updateState(e,r){super.updateState(e,r),this.updateShape()}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let i in e)typeof e[i]=="string"&&(e[i]=this._context.shared.getVariable(e[i],[this.uuid,"geometry","extrusion","shape",i]));let r;if(e.type==="Custom"){let i=e.shapeId;if(i!==this._shapeId&&this.detachShape(),i){this._shapeId=i;let a=this._context.scene.find(i);a?.data&&(a.attachedPaths.add(this),r=a.geometry.userData?.shape),r||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let i;switch(e.type){case"Rectangle":i=ns;break;case"Ellipse":i=ts;break;case"Polygon":i=Zu;break;case"Star":i=Ju;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=i.create({parameters:e}).userData.shape}let o=this.geometry;r&&o.inputs&&(o.inputs.shapeData=r,o.build(),this.attachedSurfaceCloners.forEach(i=>i.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,r){return super.updateTransformState(e,r)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.updateShape()}updateEntityBoxSize(e,r){let o=this.geometry.getAttribute("position");o!==void 0?jl(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,r):super.updateEntityBoxSize(e,r)}};var rl=require("three");var Pn=class extends to(rl.Group,oo){constructor(e,r,o){super();r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,o)),this.super_Entity(e,r),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,r){let o=Va.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(o){let i,a;for(let s of Ro.rootOverrideProps)e[s]===void 0?(i===void 0&&(i={...e}),i[s]=o.data[s]):(a===void 0&&(a={}),a[s]=e[s],i===void 0&&(i={...e}),i[s]=Io.apply(o.data[s],e[s]));return this.overrideData=a,i}else return{...Ht.defaultData,...e,...uo(Ht.defaultData,Ro.rootOverrideProps)}}updateByOp(e,r,o,i){let a;if(this.isInstanceRoot&&!i){if(r=this.transformAssignData(r,o),e.type===0&&e.path.length===0&&this.component)for(let s of Ro.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&Ro.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:r[s]}})}}super.updateByOp(a??e,r,o,i)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let o=e.scene.find(r.component)??null,i=!1;if(o!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(Fe.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Fd(s),a+=1;else break;this.children.splice(0,a)}i=!0}if(o){let a={};Uv(e,[this.uuid],r.overrides,this,o,o,0,i,a);for(let s of this.children)if(Fe.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(u=>{if(u instanceof Ot&&u.isSkinnedMesh){let c=u.dataPatched;if(c.bones&&c.boneInverses){let d=c.bones.map(h=>e.scene.find(a[h])),p=c.boneInverses.map(h=>new rl.Matrix4().fromArray(h)),f=new rl.Skeleton(d,p);u.bind(f,u.bindMatrix)}}else u.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function Fd(n){if(n.component){let t=n.component.instances.indexOf(n);t>=0&&n.component.instances.splice(t,1);for(let e of n.children)Fe.is(e)&&Fd(e)}}function jv(n,t,e,r){return n.component===t&&gp(n.identity,r)?n.overrideData===e?2:1:0}function Uv(n,t,e,r,o,i,a,s,l){if(a>50)return!1;if(r.component!==o){if(r.component){let c=r.component.instances.indexOf(r);c>=0&&r.component.instances.splice(c,1)}o.instances.push(r),r.component=o}o instanceof Pn&&o.isInstanceRoot&&o.expandInstanceChildren(n);let u=0;for(let c of o.children)if(Fe.is(c)){let d=[...t,...typeof c.identity=="string"?[c.identity]:c.identity],p=La.resolve(e,d,1);if(p!=null&&!(p instanceof dt)){if(!1)debugger;Object.setPrototypeOf(p,dt.prototype),console.error("wrong prototype")}let f=null,h;if(!s){let m=r.children[u];if(f=Fe.is(m)?m:null,f!==null){let y=jv(f,c,p,d);h=y>=1?f.stateSelection:void 0,y!==2&&(f=null)}if(f===null&&(f=n.scene.findInstance(d)??null,f!==null)){let y=jv(f,c,p,d);if(h=y>=1?f.stateSelection:void 0,y!==2)f=null;else{let g=f.parent.children.indexOf(f);f.parent.children.splice(g,1),r.children.splice(u,0,f),f.parent===r?(g<=u&&console.error("not possible"),void 0):(f.parent=r,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),n.pendingDeletes.delete(f),void 0)}}}if(f===null){let m=p?Io.apply(c.data,p):c.data;po.is(m.type)&&(m={...m,type:"Empty"}),f=mo.createEntity(d,m,n),f.overrideData=p,r.add(f),r.children.splice(r.children.length-1,1),r.children.splice(u,0,f),f.updateState(f.data,n),h&&f.changeSelectedState(h,n),n.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let m=f.identity[f.identity.length-1];l[m]=f.uuid}u+=1,Uv(n,t,e,f,c,i,a+1,s,l)}if(!s){let c=u;for(;;){let d=r.children[u];if(Fe.is(d))n.pendingDeletes.add(d);else break;u+=1}r.children.splice(c,u-c)}return!0}var Hv=require("three");var jd=class extends to(Hv.Bone,oo){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(t,e){this.updateState_Entity(t,e)}};var qi=class extends Ot{constructor(e,r,o){super(e,r,o);this.onBeforeRender=()=>{this.uiCanvas.render()};this.uiCanvas=new Js(e+"-canvas",r.geometry.width,r.geometry.height,o),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,o.shared)})}updateByPatchedOpGeometry(e,r,o){super.updateByPatchedOpGeometry(e,r,o),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,o.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,o.shared))}applySize(e,r){let o=e?.width??this.dataPatched.geometry.width,i=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:o,height:i}),this.applyGeometryParametersFromFrame(r)}applyFrame(e,r){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(r),this.applyMaterialParametersFromFrame({shared:r})}applyGeometryParametersFromFrame(e){let r=this.frame;r&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:r.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:r.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=gn(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let r=this.frame;if(r){let o=r.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),this.material.reset(this.dataPatched.material,e,!0)}}updateEntity2DByOp(e,r,o,i){this.uiCanvas.updateEntity2DByOp(e,r,o,i),e===this.frameId&&r.type===0&&(r.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(i):ke(r.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:i}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.applySize({width:e.width,height:e.height},r)}};var Le=require("three"),mS=require("three/examples/jsm/misc/GPUComputationRenderer.js");var Qt=require("three"),qv=require("three/examples/jsm/math/MeshSurfaceSampler.js");function Wv(n){let t=new Float32Array(n*n*2);for(let e=0;e<n;e++)for(let r=0;r<n;r++){let o=e*n+r;t[o*2+0]=e/(n-1),t[o*2+1]=r/(n-1)}return t}function $v(n){let t=Math.ceil(Math.sqrt(n));return Math.max(t,1)}function Yv(n,t){let e=new Qt.Mesh(n.geometry,n.material),r=[],o=[],i=new Qt.Vector3,a=new Qt.Vector3;e.geometry.index!==null&&(e.geometry=e.geometry.toNonIndexed());let s=new qv.MeshSurfaceSampler(e).build();for(let c=0;c<t;c++)s.sample(i,a),r.push(i.x,i.y,i.z),o.push(a.x,a.y,a.z);let l=new Float32Array(r),u=new Float32Array(o);return{positions:l,normals:u}}function Dh(n,t){let e=n,r=new Float32Array(4*t*t);for(let i=0;i<t*t;i++)r[4*i]=e[3*i],r[4*i+1]=e[3*i+1],r[4*i+2]=e[3*i+2],r[4*i+3]=0;let o=new Qt.DataTexture(r,t,t,Qt.RGBAFormat,Qt.FloatType);return o.needsUpdate=!0,o}function Xv({size:n}){let t=new Float32Array(4*n*n);for(let r=0;r<n*n;r++)t[4*r]=r,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let e=new Qt.DataTexture(t,n,n,Qt.RGBAFormat,Qt.FloatType);return e.needsUpdate=!0,e}function Qv(n){let t=new Float32Array(4*n*n);for(let r=0;r<n*n;r++)t[4*r]=0,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let e=new Qt.DataTexture(t,n,n,Qt.RGBAFormat,Qt.FloatType);return e.needsUpdate=!0,e}var Kv=`
2615
2616
  // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
2616
2617
  // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
2617
2618
  // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
@@ -2680,7 +2681,7 @@ void main() {
2680
2681
  gl_FragColor = mix(vec4(0.0), activeColor, isActive);
2681
2682
 
2682
2683
  }
2683
- `;var iv=`
2684
+ `;var Zv=`
2684
2685
 
2685
2686
  vec3 mod289(vec3 x) {
2686
2687
  return x - floor(x * (1.0 / 289.0)) * 289.0;
@@ -2882,7 +2883,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
2882
2883
  );
2883
2884
  }
2884
2885
 
2885
- `;var av=`
2886
+ `;var Jv=`
2886
2887
  #ifdef USE_COLLIDER
2887
2888
  float restitution = max(uBounce * 2., .01); // Energy Loss
2888
2889
  // SPHERE COLLIDER
@@ -2950,7 +2951,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
2950
2951
  #endif
2951
2952
  #endif
2952
2953
  // END COLLIDER
2953
- `;var sv=`
2954
+ `;var eS=`
2954
2955
  #ifdef USE_ATTRACTOR
2955
2956
 
2956
2957
  #ifdef USE_SPHERE_COLLIDER
@@ -3024,7 +3025,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
3024
3025
  velocity *= uForceDamping;
3025
3026
  #endif
3026
3027
  #endif
3027
- `;var lv=`
3028
+ `;var tS=`
3028
3029
  #ifdef USE_VORTEX
3029
3030
  // Box dimensions
3030
3031
  vec3 boxHalfSize = uColliderSize / 2.0;
@@ -3063,7 +3064,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
3063
3064
  velocity += applyForce( originDirection * uSpeed * (1. - uForceDamping) , mass * .5);
3064
3065
  }
3065
3066
  #endif
3066
- `;var cv=`
3067
+ `;var rS=`
3067
3068
  // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
3068
3069
  // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
3069
3070
  // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
@@ -3089,7 +3090,7 @@ uniform float uForceDamping;
3089
3090
  uniform float uForceIntensity;
3090
3091
 
3091
3092
 
3092
- `+iv+`
3093
+ `+Zv+`
3093
3094
  float rand(vec2 co){
3094
3095
  return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
3095
3096
  }
@@ -3167,11 +3168,11 @@ void main() {
3167
3168
  #endif
3168
3169
 
3169
3170
  // COLLIDER
3170
- ${av}
3171
+ ${Jv}
3171
3172
  // ATTRACTION
3172
- ${sv}
3173
+ ${eS}
3173
3174
  // VORTEX
3174
- ${lv}
3175
+ ${tS}
3175
3176
  }
3176
3177
  // End isActive
3177
3178
 
@@ -3189,7 +3190,7 @@ void main() {
3189
3190
 
3190
3191
  gl_FragColor = vec4(velocity, collisionFlag);
3191
3192
  }
3192
- `;var yv=require("three");var Kf=`
3193
+ `;var cS=require("three");var Eh=`
3193
3194
 
3194
3195
  // Linear Fade In
3195
3196
  float linearFadeIn(float t) {
@@ -3222,7 +3223,7 @@ void main() {
3222
3223
  float constant(float t) {
3223
3224
  return 1.0;
3224
3225
  }
3225
- `;var uv=`
3226
+ `;var oS=`
3226
3227
 
3227
3228
  float rand(vec3 co){
3228
3229
  return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
@@ -3237,7 +3238,7 @@ vec3 applyForce(vec3 force, float mass) {
3237
3238
 
3238
3239
  return acceleration;
3239
3240
  }
3240
- `;var dv=`
3241
+ `;var nS=`
3241
3242
  vec3 rgb2xyz (in vec3 rgb) {
3242
3243
  float r = rgb.r;
3243
3244
  float g = rgb.g;
@@ -3328,7 +3329,7 @@ vec3 lab2rgb (in vec3 lab) {
3328
3329
  return(rgb);
3329
3330
  }
3330
3331
 
3331
- `;var pv=`
3332
+ `;var iS=`
3332
3333
  uniform sampler2D uPosition;
3333
3334
  uniform float uSize;
3334
3335
  uniform float uSizeEnd;
@@ -3349,9 +3350,9 @@ vec3 lab2rgb (in vec3 lab) {
3349
3350
  varying vec2 vUv;
3350
3351
  varying vec2 vRef;
3351
3352
 
3352
- ${uv}
3353
- ${Kf}
3354
- `,fv=({easeSize:n="linearFadeOut"})=>`
3353
+ ${oS}
3354
+ ${Eh}
3355
+ `,aS=({easeSize:n="linearFadeOut"})=>`
3355
3356
  vUv = uv;
3356
3357
  vRef = ref;
3357
3358
  // Normalized LifeTime 1 to 0
@@ -3403,7 +3404,7 @@ vec3 lab2rgb (in vec3 lab) {
3403
3404
  mvPosition = modelViewMatrix * instanceMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
3404
3405
  mvPosition.xy += rotatedPosition;
3405
3406
  gl_Position = projectionMatrix * mvPosition;
3406
- `,hv=`
3407
+ `,sS=`
3407
3408
  uniform vec4 uColor; // start color
3408
3409
  uniform vec4 uColor2; // end color
3409
3410
  uniform sampler2D uTexture; // texture
@@ -3414,10 +3415,10 @@ vec3 lab2rgb (in vec3 lab) {
3414
3415
  float random(vec2 co) {
3415
3416
  return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
3416
3417
  }
3417
- `+Kf+`
3418
- ${dv}
3418
+ `+Eh+`
3419
+ ${nS}
3419
3420
 
3420
- `,mv=({easeOpacity:n="linearFadeOut"})=>`
3421
+ `,lS=({easeOpacity:n="linearFadeOut"})=>`
3421
3422
  // if Particle is dead, hide it
3422
3423
  if (v_LifeLeft <= 0.005 ) {
3423
3424
  discard;
@@ -3438,7 +3439,7 @@ vec3 lab2rgb (in vec3 lab) {
3438
3439
 
3439
3440
  gl_FragColor = vec4(finalColor, finalAlpha);
3440
3441
 
3441
- `;var gd=class extends yv.ShaderMaterial{constructor(e,r){super();this.needsJitter=!0;this.type="ParticleMaterial";this.easeOpacity="linearFadeIn";this.easeSize="linearFadeIn";this.useSizeEnd=!1;this.isColoringRandom=!1;this.init(e,r),this.context=r}reset(){}init(e,r){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],this.lightLayer=new cr(0,"",{...Mt.defaultData("light","phong"),visible:!1},new ln,{},r.shared),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new Ka;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(Ox),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(Cx),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(pv),e.addFragmentParsCode(hv),e.addVertexFinalCode(fv({easeSize:this.easeSize})),e.addFragmentFinalCode(mv({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.extensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}};var Xr=require("three");var gv=require("three"),xv=require("three"),bv=require("three"),Vs=class{constructor(t,e,r,o){this.type="SphereEmitterShape";this.targetMesh=void 0;this.size=t,this.type=r,this.textureSize=ev(e);let i=1;this.targetMesh=o?.type==="Mesh"&&o?o:this.getMesh(r,i);let{positions:a,dataTexture:s,dataTextureNormals:l}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(r,i));this.positionsTexture=s,this.positionsAttribute=a,this.directionsTexture=l}createPositions(t,e){let{positions:r,normals:o}=tv(e,t*t),i=Qf(r,t),a=Qf(o,t);return{dataTexture:i,positions:r,dataTextureNormals:a}}getMesh(t,e){let r=null;switch(t){case"SphereEmitterShape":{r=new Xr.SphereGeometry(e*.5,32,32);break}case"TorusEmitterShape":{r=new xv.TorusGeometry(e*.5,.3,15,40);break}case"ConeEmitterShape":{r=new Xr.ConeGeometry(e,e,15);break}case"BoxEmitterShape":{r=new Xr.BoxGeometry(e,e,e);break}case"PlaneEmitterShape":{r=new bv.PlaneGeometry(e,e),r.rotateX(-Math.PI/2);break}case"MeshEmitterShape":{r=new Xr.SphereGeometry(e,32,32);break}default:{r=new Xr.SphereGeometry(e,32,32);break}}return new gv.Mesh(r,new Xr.MeshBasicMaterial({color:16711680}))}applyToShader(t,e){this.size=new Xr.Vector3().fromArray(e.size),t.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function Ni(n){let t={...n},e=pa.defaultData;t.forceFieldObjectId&&(t.colliderEntityId=t.forceFieldObjectId);let r={...e.shape,...t.shape},o={...e.renderMaterial,...t.renderMaterial};return{...e,...t,shape:r,renderMaterial:o}}var vv=`
3442
+ `;var Ud=class extends cS.ShaderMaterial{constructor(e,r){super();this.needsJitter=!0;this.type="ParticleMaterial";this.easeOpacity="linearFadeIn";this.easeSize="linearFadeIn";this.useSizeEnd=!1;this.isColoringRandom=!1;this.init(e,r),this.context=r}reset(){}init(e,r){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],this.lightLayer=new Ar(0,"",{...kt.defaultData("light","phong"),visible:!1},new xn,{},r.shared),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new ys;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(mb),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(yb),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(iS),e.addFragmentParsCode(sS),e.addVertexFinalCode(aS({easeSize:this.easeSize})),e.addFragmentFinalCode(lS({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.extensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}};var ao=require("three");var uS=require("three"),dS=require("three"),pS=require("three"),ol=class{constructor(t,e,r,o){this.type="SphereEmitterShape";this.targetMesh=void 0;this.size=t,this.type=r,this.textureSize=$v(e);let i=1;this.targetMesh=o?.type==="Mesh"&&o?o:this.getMesh(r,i);let{positions:a,dataTexture:s,dataTextureNormals:l}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(r,i));this.positionsTexture=s,this.positionsAttribute=a,this.directionsTexture=l}createPositions(t,e){let{positions:r,normals:o}=Yv(e,t*t),i=Dh(r,t),a=Dh(o,t);return{dataTexture:i,positions:r,dataTextureNormals:a}}getMesh(t,e){let r=null;switch(t){case"SphereEmitterShape":{r=new ao.SphereGeometry(e*.5,32,32);break}case"TorusEmitterShape":{r=new dS.TorusGeometry(e*.5,.3,15,40);break}case"ConeEmitterShape":{r=new ao.ConeGeometry(e,e,15);break}case"BoxEmitterShape":{r=new ao.BoxGeometry(e,e,e);break}case"PlaneEmitterShape":{r=new pS.PlaneGeometry(e,e),r.rotateX(-Math.PI/2);break}case"MeshEmitterShape":{r=new ao.SphereGeometry(e,32,32);break}default:{r=new ao.SphereGeometry(e,32,32);break}}return new uS.Mesh(r,new ao.MeshBasicMaterial({color:16711680}))}applyToShader(t,e){this.size=new ao.Vector3().fromArray(e.size),t.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function Wi(n){let t={...n},e=Ia.defaultData;t.forceFieldObjectId&&(t.colliderEntityId=t.forceFieldObjectId);let r={...e.shape,...t.shape},o={...e.renderMaterial,...t.renderMaterial};return{...e,...t,shape:r,renderMaterial:o}}var fS=`
3442
3443
  // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
3443
3444
  // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
3444
3445
  // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
@@ -3485,15 +3486,15 @@ void main() {
3485
3486
 
3486
3487
 
3487
3488
  }
3488
- `;var Zf=10,xd=class extends Ce.Object3D{constructor(e,r){super();this.type="ParticleEmitter";this.debugMode=!1;this.worldSpace=!0;this.rootObject=null;this.gpuCompute=null;this.positionSimRT=null;this.velocitySimRT=null;this.emissionRateSimRT=null;this.emitterShape=void 0;this.isEmitting=!1;this.hasBeenReset=!1;this.emittedParticlesAmount=0;this.lastEmitTime=0;this.globalTime=0;this.targetFPS=60;this.previousRatio=1;this.lerpFactor=.4;this.particlesAmount=0;this.noiseStrength=0;this.noiseScale=0;this.isBillboardBased=!0;this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1};this.textureLoader=new Ce.TextureLoader;this.currentWorldPosition=new Ce.Vector3;this.systemQuaternion=new Ce.Quaternion;this.worldGravity=new Ce.Vector3(0,0,0);this.directionAxis=new Ce.Vector3(0,0,0);this.colliderV3=new Ce.Vector3(0,0,0);this.colliderQuaternion=new Ce.Quaternion(0,0,0,1);this.matrixAutoUpdate=!0,this.renderer=e,this.system=r,this.shared=r.context.shared;let o=r.data;this.material=new gd(o.renderMaterial,r.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:o.renderMaterial.color},uColor2:{value:o.renderMaterial.color2},uPosition:{value:new Ce.Vector3(0,0,0)},uEmissionData:{value:new Ce.Vector3(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new Ce.Vector3(0,0,0)},uWorldQuaternion:{value:new Ce.Vector4(0,0,0,1)},uRandScaleFactor:{value:o.randomScale??0},uRandRotationFactor:{value:o.randomRotation??0},uRotation:{value:o.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:o.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,o.renderMaterial.texture),this.init(o)}setTexture(e,r){let o=r.data;if(typeof r=="string"){let i=this.shared.image(r),a=new Ce.Texture(i.img);a.needsUpdate=!0,e.uTexture.value=a;return}if(typeof o!="string"){let i=new Image;i.onload=()=>{let l=new Ce.Texture(i);l.needsUpdate=!0,e.uTexture.value=l};let a=new Blob([o],{type:"image/*"}),s=URL.createObjectURL(a);i.src=s}}updateGeometryAttributes(e,r){let o=Jb(r);!this.emitterShape?.positionsAttribute||e.geometry.setAttribute("ref",new Ce.InstancedBufferAttribute(o,2))}applyWorldSpace(){if(!this.system.started||!this.worldSpace||!this.positionSimRT||!this.velocitySimRT)return;let e=this.system;e.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),e.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(e,r){if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset){this.reset();return}this.applyWorldSpace(),this.globalTime=e,this.positionSimRT.material.uniforms.uTime.value=e,this.emissionRateSimRT.material.uniforms.uTime.value=e;let o=1e3/r,i=this.targetFPS/o,a=this.previousRatio+(i-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=a,this.previousRatio=a;let s=this.isEmitting?this.GoEmitSomeParticles(e,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=s,this.material.uniforms.uPosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT)?.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let e=this.system.colliderEntities[0];if(!e)return;e.getWorldPosition(this.colliderV3),this.colliderV3.y===0&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let r=e.data.size;this.colliderV3.fromArray(r),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),e.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(e){!this.velocitySimRT||!this.positionSimRT||(e.renderMaterial&&this.updateMaterialState(e.renderMaterial),this.updateParticleState(e))}updateVariableState(e,r){if(!this.velocitySimRT||!this.positionSimRT)return;r[2]==="size"&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),r[2]==="sizeEnd"&&this.material.updateState({size:[this.material.uniforms.uSize.value,e]});let o=(i,a)=>{let s=[...this.system.data.shape.size];s[i]=a,this.updateParticleState({shape:{...this.system.data.shape,size:s}})};r[2]==="shape_size_0"&&o(0,e),r[2]==="shape_size_1"&&o(1,e),r[2]==="shape_size_2"&&o(2,e),r[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/Zf),r[2]==="gravity"&&this.worldGravity.set(0,e/100,0),r[2]==="noiseStrength"&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),r[2]==="noiseScale"&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),r[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),r[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),r[2]==="direction_z"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(e)]))}updateMaterialState(e){this.material.updateState({...e,size:e.size?[Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),e.texture&&(this.setTexture(this.material.uniforms,e.texture),this.material.needsUpdate=!0)}updateParticleState(e){if(!(!this.positionSimRT||!this.velocitySimRT)){if(this.shouldReInitGPUCompute(e)&&this.init(Ni(this.system.data)),e.life!==void 0&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=e.life),e.speed!==void 0&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/Zf),e.collisionBounce!==void 0&&(this.velocitySimRT.material.uniforms.uBounce.value=e.collisionBounce),e.noiseStrength!==void 0&&(this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),e.noiseScale!==void 0&&(this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),e.noiseSeed!==void 0&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=e.noiseSeed),e.randomMass!==void 0&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=e.randomMass),e.renderMaterial?.size!==void 0){let r=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(r)}if(e.renderMaterial?.spriteRotation!==void 0&&(this.material.uniforms.uRotation.value=e.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=e.renderMaterial.spriteRotation[1]),e.shape!==void 0){let r=e.shape.size??this.system.data.shape.size,o=[Number(this.shared.getVariable(r[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(r[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(r[2],[this.uuid,"particles","shape_size_2"]))],i={...Ni(this.system.data).shape,size:o};this.emitterShape?.applyToShader(this.positionSimRT.material.uniforms,i)}if(e.gravity!==void 0&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),e.direction!==void 0){let r=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(r),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}e.randomRotation!==void 0&&(this.material.uniforms.uRandRotationFactor.value=e.randomRotation),e.randomScale!==void 0&&(this.material.uniforms.uRandScaleFactor.value=e.randomScale)}}updateForceFieldParameters(e){!this.velocitySimRT||(e.forceIntensity!==void 0&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=e.forceIntensity),e.forceDambing!==void 0&&(this.velocitySimRT.material.uniforms.uForceDamping.value=e.forceDambing))}getDirectionAxis(e){let r=[Number(e[0])*Ce.MathUtils.DEG2RAD,Number(e[1])*Ce.MathUtils.DEG2RAD,Number(e[2])*Ce.MathUtils.DEG2RAD],o=new Ce.Euler(r[0],r[1],r[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(o).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(e){let{birthRatePerSec:r,rootObjectType:o,colliderEntityId:i,shape:a,emitTimeDuration:s,emitTimeCycle:l,life:u,directionMode:c,noiseType:d}=e;return r!==void 0||o!==void 0||(i||i===null)||l!==void 0||a!==void 0||u!==void 0||s!==void 0||c!==void 0||d!==void 0}init(e){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:e.birthRatePerSec,particleMaxLifeTime:e.life,loopDuration:e.emitTimeCycle==="infinity"?0:e.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn(`The maximum number of particles is limited to ${1e5}.`),this.particlesAmount=1e5),this.emitterShape=this.createShape(e.shape,this.particlesAmount);let r=setInterval(()=>{if(!!this.emitterShape)if(isNaN(this.emitterShape.positionsTexture.source.data.data[0])){this.init(e);return}else clearInterval(r)},100);if(!this.emitterShape)return;let o=new wv.GPUComputationRenderer(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),i=this.updateSimulationDefinition(e),a=o.addVariable("uCurrentPosition",i+nv,this.emitterShape.positionsTexture),s=o.addVariable("uCurrentVelocity",i+cv,this.emitterShape.directionsTexture),l=o.addVariable("uCurrentEmissionRate",vv,ov(this.emitterShape.textureSize));o.setVariableDependencies(a,[a,s,l]),o.setVariableDependencies(s,[a,s,l]),o.setVariableDependencies(l,[a,s,l]);let u=rv({size:this.emitterShape.textureSize}),c={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new Ce.Vector3(0,0,0)},uWorldQuaternion:{value:new Ce.Vector4(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:e.life},uEmitterSize:{value:new Ce.Vector3(Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"])))},particleSize:{value:0}};a.material.uniforms=c;let d=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(d),this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"]));let p=e.colliderEntityId&&this.system.getColliderData(e.colliderEntityId),f={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new Ce.Vector4(0,0,0,1)},uColliderPos:{value:new Ce.Vector3(0,0,0)},uColliderSize:{value:new Ce.Vector3(0,0,0)},uForceIntensity:{value:p?p.forceIntensity:0},uForceDamping:{value:p?p.forceDambing:0},uColliderQuaternion:{value:new Ce.Vector4(0,0,0,1)},uColliderQuaternionInvert:{value:new Ce.Vector4(0,0,0,1)},particleSize:{value:0},uGravity:{value:this.worldGravity},uNoiseStrength:{value:this.noiseStrength},uNoiseScale:{value:this.noiseScale},uNoiseSeed:{value:e.noiseSeed},uRandomMassFactor:{value:e.randomMass},uBounce:{value:e.collisionBounce},uSpeed:{value:Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/Zf}};s.material.uniforms=f;let h={uIndex:{value:u},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};l.material.uniforms=h;let m=[Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"]))],y={...Ni(this.system.data).shape,size:m};this.emitterShape.applyToShader(a.material.uniforms,y),o.init(),this.gpuCompute=o,this.positionSimRT=a,this.velocitySimRT=s,this.emissionRateSimRT=l,this.rootObject=this.createPrimaryEmitter(this.emitterShape.textureSize),this.add(this.rootObject),this.material.needsUpdate=!0}getDirectionFromVariable(e){let r=Number(this.shared.getVariable(e[0],[this.uuid,"particles","direction_x"])),o=Number(this.shared.getVariable(e[1],[this.uuid,"particles","direction_y"])),i=Number(this.shared.getVariable(e[2],[this.uuid,"particles","direction_z"]));return[r,o,i]}updateSimulationDefinition(e){if(this.simFeaturesDefinition.USE_COLLIDER=!1,this.simFeaturesDefinition.USE_ATTRACTOR=!1,this.simFeaturesDefinition.USE_VORTEX=!1,this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!1,this.simFeaturesDefinition.USE_BOX_COLLIDER=!1,this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!1,this.simFeaturesDefinition.USE_NORMALS=!1,this.simFeaturesDefinition.USE_CURL_NOISE=!1,this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!1,this.simFeaturesDefinition.USE_FBM_NOISE=!1,e.colliderEntityId&&this.system.colliderEntities.length>0){let o=this.system.getColliderData(e.colliderEntityId);switch(o?.forceType){case"attractor":this.simFeaturesDefinition.USE_ATTRACTOR=!0;break;case"collider":this.simFeaturesDefinition.USE_COLLIDER=!0;break;case"vortex":this.simFeaturesDefinition.USE_VORTEX=!0;break}let i=o?.colliderType;i==="sphere"&&(this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!0),i==="box"&&(this.simFeaturesDefinition.USE_BOX_COLLIDER=!0),o?.forceRange==="helper"&&(this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!0)}e.directionMode==="normals"&&(this.simFeaturesDefinition.USE_NORMALS=!0),e.noiseType==="curl"&&(this.simFeaturesDefinition.USE_CURL_NOISE=!0),e.noiseType==="simplex"&&(this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!0),e.noiseType==="fbm"&&(this.simFeaturesDefinition.USE_FBM_NOISE=!0);let r="";for(let[o,i]of Object.entries(this.simFeaturesDefinition))i&&(r+=`#define ${o}
3489
- `);return r}createShape(e,r){this.emitterShape&&this.emitterShape.dispose();let o=new Ce.Vector3(Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.size[2],[this.uuid,"particles","shape_size_2"])));if(e.type==="MeshEmitterShape"){let i=null;return this.system.context.scene.traverseEntity(a=>{a.uuid===e.fromMeshId&&(i=a)}),i?new Vs(o,r,e.type,i):new Vs(o,r,"SphereEmitterShape")}else return new Vs(o,r,e.type)}createPrimaryEmitter(e){let r,o=e*e;return r=new Ce.InstancedMesh(new Ce.PlaneGeometry(1,1,1),this.material,o),this.updateGeometryAttributes(r,e),this.material.needsUpdate=!0,r.onBeforeRender=()=>{this.applyWorldSpace()},r}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:r,loopDuration:o=0}){return Math.ceil(e*(r+o))}dispose(){!this.gpuCompute||(this.rootObject?.parent?.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),this.emitterShape?.dispose())}GoEmitSomeParticles(e,r){let o=e-this.lastEmitTime,i=1/r;if(o>=i){let a=Math.max(1,Math.floor(o/i));return this.lastEmitTime=e,this.emittedParticlesAmount+a>this.particlesAmount&&(this.emittedParticlesAmount=0),this.emittedParticlesAmount+=a,a}return 0}checkIfAllParticlesAreDead(){return this.lastEmitTime+this.system.data.life+1<this.globalTime}reset(){this.hasBeenReset=!0,this.lastEmitTime=0,this.emittedParticlesAmount=0,this.gpuCompute&&this.init(Ni(this.system.data))}startEmitting(){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=this.globalTime}stopEmitting(){this.isEmitting=!1}};var vd=require("three");var bd=class extends Bt{constructor(e,r,o){super(e,r);this.type="ParticleSystem";this.geometry=new vd.BufferGeometry;this.actualTime=0;this.currentLoopTime=0;this.started=!1;this.stopped=!1;this.isFrozen=!1;this.isIdle=!0;this.emitter=null;this.colliderEntities=[];this.renderer=null;this.isPreWarm=!1;this._hasOnAfterRenderBeenCalled=!1;this.onAfterRender=e=>{this._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(e))};this.context=o,this.data={...r,...Ni(r)},this.geometry.setAttribute("position",new vd.Float32BufferAttribute([],3)),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new xd(e,this),this.add(this.emitter),this.updateParticleState(this.data)}update(e){if(!this.isReady||!this.started||this.isFrozen||this.isIdle)return;this.actualTime+=e,this.stopped||(this.currentLoopTime+=e);let r=this.data.emitTimeCycle==="one_time";if((this.data.emitTimeCycle==="loop"||r)&&this.currentLoopTime>this.data.emitTimeDuration*1e3&&(this.stopped||(this.stop(),r||this.start(this.data.emitTimeLoopDelayStart==="start"?0:this.data.emitTimeDelay*1e3))),this.emitter&&this.started){let i=this.actualTime/1e3;this.emitter.update(i,e)}this.scale.set(1,1,1),this.updateMatrix()}isReady(){return!!this.emitter}hasCollider(e){return this.colliderEntities.some(r=>r.identity===e)}getColliderData(e){let r=this.colliderEntities.find(o=>o.identity===e);return r?r.data:null}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),Ne(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...pt.drop(e,1).props}}),Ne(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...pt.drop(e,1).props}})}updateState(e,r){super.updateState(e,r),this.updateParticleState(e)}updateParticleState(e){if(!!this.emitter){if(e.colliderEntityId!==void 0&&e.colliderEntityId!==null){let r=this.context.scene.find(e.colliderEntityId);this.colliderEntities=r?[r]:[]}e.colliderEntityId===null&&(this.colliderEntities=[]),this.emitter.updateState(e),e.emitTimeCycle&&this.started&&this.start()}}updateFromColliderEntity(e){!this.emitter||(this.emitter.updateForceFieldParameters(e),this.stop(),this.start())}start(e=0){if(this.currentLoopTime=0,e){setTimeout(()=>{this.start(0)},e);return}this.started=!0,this.stopped=!1,this.isFrozen=!1,this.emitter?.startEmitting()}froze(){this.isFrozen=!0}unFroze(){this.isFrozen=!1}stop(){this.stopped=!0,this.currentLoopTime=0,this.emitter?.stopEmitting()}reset(){this.started=!1,this.stopped=!1,this.emitter?.reset()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}};function lM(n,t,e){let r;return t.geometry.type==="TextGeometry"?new vs(n,t,e):(t.geometry.type==="SubdivGeometry"?r=new Oi(n,t,e):t.geometry.type==="PathGeometry"?r=new Ls(n,t,e):t.geometry.type==="VectorGeometry"?r=new hd(n,t,e):t.geometry.type==="BooleanGeometry"?r=new wr(n,t,e):t.geometry.type==="UIGeometry"?r=new Ii(n,t,e):r=new yt(n,t,e),r)}function Sd(n,t,e){return console.assert(t.type!==void 0),t.type==="Mesh"?lM(n,t,e):t.type==="Empty"?new $n(n,t):t.type==="Particle"?new bd(n,t,e):t.type==="ParticleCollider"?new id(n,t,e):t.type==="Splat"?new $n(n,t):t.type==="Bone"?new yd(n,t):t.type==="Page"?new Yr(n,t,e):t.type==="PointLight"?new fd(n,t,e):t.type==="SpotLight"?new Ns(n,t,e):t.type==="DirectionalLight"?new Is(n,t,e):t.type==="Component"||t.type==="Instance"?new mn(n,t,e):Jr.is(t.type)?new pn(n,t):(console.error(t),new $n(n,t))}ro.createEntity=Sd;function cM(n,t,e){let r=Sd(n.identity,t,e),o=n.children,i=n.attachedPaths,a=n.parent,s=n.component,l=n.instances,u=n.overrideData,c=n.uuid,d=n.stateSelection;n.dispose();for(let p of Object.keys(n))delete n[p];Object.setPrototypeOf(n,Object.getPrototypeOf(r));for(let p of Object.keys(r))n[p]=r[p];n.children=[...n.children,...o],n.attachedPaths=i,n.parent=a,n.component=s,n.instances=l,n.uuid=c,n.overrideData=u,n.updateState(n.data,e),d&&n.changeSelectedState(d,e),n.resetBBoxNeedsUpdate()}ro.changeEntityProptotype=cM;ro.Cloner=_s;function _v(n,t,e,r){n.updateByOp(t,e,r,!1)}var zs=require("three");function Av(n,t){let e=!1,r=t.getLayersOfType("transmission"),o=t.getLayersOfType("outline");return o.length>0&&(n.layers.set(8),r.length>0&&n.layers.enable(3),e=!0,xs(n),gs(n)),r.length===0&&o.length===0&&n.layers.set(0),n instanceof Sr&&n.needsAO&&n.layers.enable(5),e}function Pv(n,t){if(!t.layers)return!1;let e=!1,r=t.getLayersOfType("transmission").filter(i=>i.data.visible),o=t.getLayersOfType("outline").filter(i=>i.data.visible);return r.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),r.length===0&&o.length===0&&n.layers.set(0),n.needsAO&&n.layers.enable(5),e}function Ov(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Sr)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Av(e,e.material[r])&&(t=!0);else Av(e,e.material)&&(t=!0)}),t}function Cv(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Sr)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Pv(e,e.material[r])&&(t=!0);else Pv(e,e.material)&&(t=!0)}),t}var pM=new zs.Raycaster,fM=new zs.Matrix4,hM=new zs.Ray;function Xl(n,t,e,r=!1){let o=n.cloner;if(o)for(let i of o.children){let a=fM.copy(i.matrixWorld).invert(),s=hM.copy(t.ray).applyMatrix4(a),l=n.matrixWorld;s.applyMatrix4(l);let u=pM;u.set(s.origin,s.direction),u.near=t.near,u.far=t.far;let c=u.intersectObject(n,!1);c.length>0&&e.push({...c[0],object:r?i:n})}}var wd=class{constructor(){this._constraints=new Map}setConstraint(t,e){e===null?this._constraints.delete(t):this._constraints.set(t,e)}removeDependencies(t){this._constraints.delete(t)}applyConstraints(t){let e=new Set;this._constraints.forEach((r,o)=>{let i=[o,r],a=r;for(;this._constraints.has(a);)a=this._constraints.get(a),e.has(a)||i.push(a);for(let s=i.length-2;s>=0;s--)if(!e.has(i[s])){let l=t.find(i[s]);l?l.applyPathSnapping(t):console.warn(`missing entity ${i[s]}`),e.add(i[s])}})}findDependency(t,e){let r=t;for(;this._constraints.has(r);)if(r=this._constraints.get(r),r===e)return!0;return!1}};var mo=nr(Gs()),ko=nr(ks());var _t=nr(Gs()),de=nr(ks()),Kn=class{constructor(t,e,r){this._dataNormalized=t,this._minD=e,this._maxD=r}static createFromUnnormalized(t){let e=de.sup(t),r=de.inf(t),o=(0,_t.default)(new Float32Array(t.size),t.shape),i=e-r;return i<1e-4?de.assigns(o,0):(de.subs(o,t,r),de.divs(o,o,i)),new Kn(o,r,e)}get data(){return this._dataNormalized}get minD(){return this._minD}get maxD(){return this._maxD}denormalize(){let t=(0,_t.default)(new Float32Array(this._dataNormalized.size),this._dataNormalized.shape);return de.muls(t,this._dataNormalized,this._maxD-this._minD),de.adds(t,t,this._minD),t}},ot=class{constructor(t,e){this._quantized=t,this._method=e}get quantized(){return this._quantized}static maxIntBits(t){return 2**t-1}static fromNormalized(t,e){let r=t.data,o;if(e==="norm8x"){let i=ot.maxIntBits(8),a=(0,_t.default)(new Float32Array(r.size),r.shape);de.muls(a,r,i),de.roundeq(a),o=(0,_t.default)(new Uint8Array(a.data),r.shape)}else if(e==="norm565"){let i=(0,_t.default)(new Float32Array(r.size),r.shape);de.assign(i,r),de.mulseq(i.pick(null,0),ot.maxIntBits(5)),de.mulseq(i.pick(null,1),ot.maxIntBits(6)),de.mulseq(i.pick(null,2),ot.maxIntBits(5)),de.roundeq(i);let a=(0,_t.default)(new Uint16Array(i.data),r.shape),s=(0,_t.default)(new Uint16Array(r.shape[0]),[r.shape[0]]),l=(0,_t.default)(new Uint16Array(r.shape[0]),[r.shape[0]]);de.lshifts(s,a.pick(null,0),11),de.lshifts(l,a.pick(null,1),5),de.boreq(s,l),de.boreq(s,a.pick(null,2)),o=s}else{let i=(0,_t.default)(new Float32Array(r.size),r.shape);de.assign(i,r),de.mulseq(i.pick(null,0),ot.maxIntBits(11)),de.mulseq(i.pick(null,1),ot.maxIntBits(10)),de.mulseq(i.pick(null,2),ot.maxIntBits(11)),de.roundeq(i);let a=(0,_t.default)(new Uint32Array(i.data),r.shape),s=(0,_t.default)(new Uint32Array(r.shape[0]),[r.shape[0]]),l=(0,_t.default)(new Uint32Array(r.shape[0]),[r.shape[0]]);de.lshifts(s,a.pick(null,0),21),de.lshifts(l,a.pick(null,1),11),de.boreq(s,l),de.boreq(s,a.pick(null,2)),o=s}return new ot(o,e)}dequantize(t,e){let r=this._method,o,i=this._quantized;if(r==="norm8x"){let a=ot.maxIntBits(8);o=(0,_t.default)(new Float32Array(i.size),i.shape),de.muls(o,i,1/a)}else if(r==="norm565"){let a=(0,_t.default)(new Uint8Array(i.shape[0]),[i.shape[0]]),s=(0,_t.default)(new Uint8Array(i.shape[0]),[i.shape[0]]),l=(0,_t.default)(new Uint8Array(i.shape[0]),[i.shape[0]]);de.rrshifts(a,i,11),de.rrshifts(s,i,5),de.bandseq(s,ot.maxIntBits(6)),de.bands(l,i,ot.maxIntBits(5)),o=(0,_t.default)(new Float32Array(i.shape[0]*3),[i.shape[0],3]),de.muls(o.pick(null,0),a,1/ot.maxIntBits(5)),de.muls(o.pick(null,1),s,1/ot.maxIntBits(6)),de.muls(o.pick(null,2),l,1/ot.maxIntBits(5))}else{let a=(0,_t.default)(new Uint16Array(i.shape[0]),[i.shape[0]]),s=(0,_t.default)(new Uint16Array(i.shape[0]),[i.shape[0]]),l=(0,_t.default)(new Uint16Array(i.shape[0]),[i.shape[0]]);de.rrshifts(a,i,21),de.rrshifts(s,i,11),de.bandseq(s,ot.maxIntBits(10)),de.bands(l,i,ot.maxIntBits(11)),o=(0,_t.default)(new Float32Array(i.shape[0]*3),[i.shape[0],3]),de.muls(o.pick(null,0),a,1/ot.maxIntBits(11)),de.muls(o.pick(null,1),s,1/ot.maxIntBits(10)),de.muls(o.pick(null,2),l,1/ot.maxIntBits(11))}return new Kn(o,t,e)}};var nt=class{constructor(t,e,r,o,i,a=!1){this._quantized=t,this._minMaxMatrix=e,this._chunkSize=r,this._quantizationMethod=o,this._variableChunkSize=i,this._isDynamicChunks=a}get length(){return this._quantized.shape[0]}get nchunks(){return this._minMaxMatrix.shape[0]}get quantized(){return this._quantized}get method(){return this._quantizationMethod}get minmaxMatrix(){return this._minMaxMatrix}_createPrunedMinMax(t){let e=t.length,r=this.minmaxMatrix.shape[0]-e,o=(0,mo.default)(new Float32Array(r*2),[r,2]),i=0,a=r,s=0,l=this.minmaxMatrix.shape[0];for(let u=0;u<t.length;u++)l=t[u],a=l-s+i,a>i&&ko.assign(o.hi(a,2).lo(i,0),this.minmaxMatrix.hi(l,2).lo(s,0)),i=a,s=l+1;return i<r&&ko.assign(o.lo(i,0),this.minmaxMatrix.lo(s,0)),o}_createPrunedQuantized(t){let e=t.length,r=this.quantized.shape[0]-e,o=this._quantizationMethod,i,a;if(o==="norm8x"){a=this._quantized.shape[1];let d=a?r*a:r;i=(0,mo.default)(new Uint8Array(d),a?[r,a]:[r,1])}else o==="norm565"?i=(0,mo.default)(new Uint16Array(r),[r]):i=(0,mo.default)(new Uint32Array(r),[r]);let s=0,l=r,u=0,c=i.shape[0];for(let d=0;d<t.length;d++)c=t[d],l=c-u+s,l>s&&(a?ko.assign(i.hi(l,a).lo(s,0),this._quantized.hi(c,a).lo(u,0)):ko.assign(i.hi(l).lo(s),this._quantized.hi(c).lo(u))),s=l,u=c+1;return s<r&&(a?ko.assign(i.lo(s,0),this._quantized.lo(u,0)):ko.assign(i.lo(s),this._quantized.lo(u))),i}pruneFeature(t,e,r){let o=this._createPrunedQuantized(t),i=this._createPrunedMinMax(e);return new nt(o,i,this._chunkSize,this._quantizationMethod,r,!0)}static getRequiredNChunks(t,e){return Math.floor(t/e)}static fromArray(t,e,r){let o=t.shape[0],i=Math.floor(o/r),a=(0,mo.default)(new Float32Array(i*2),[i,2],[2,1]),s;e==="norm8x"?s=(0,mo.default)(new Uint8Array(t.size),t.shape):e==="norm565"?s=(0,mo.default)(new Uint16Array(t.shape[0]),[t.shape[0]]):s=(0,mo.default)(new Uint32Array(t.shape[0]),[t.shape[0]]);for(let l=0;l<i;l++){let u=l*r,c=l+1<i?(l+1)*r:o,d;t.shape.length>1?d=Kn.createFromUnnormalized(t.hi(c,t.shape[1]).lo(u,0)):d=Kn.createFromUnnormalized(t.hi(c).lo(u)),a.set(l,0,d.minD),a.set(l,1,d.maxD),s.shape.length>1?ko.assign(s.hi(c,s.shape[1]).lo(u,0),ot.fromNormalized(d,e).quantized):ko.assign(s.hi(c).lo(u),ot.fromNormalized(d,e).quantized)}return new nt(s,a,r,e)}denormDequant(){let t=this._minMaxMatrix.shape[0],e=this._quantized,r=e.shape[0],o=this._quantizationMethod,i=this._chunkSize,a;if(this._isDynamicChunks){if(!this._variableChunkSize)throw new Error("variable chunk must exists if chunkSize isDynamic");a=this._variableChunkSize}let s;o==="norm8x"?s=(0,mo.default)(new Float32Array(e.size),e.shape):s=(0,mo.default)(new Float32Array(r*3),[r,3]);let l=0,u=i;for(let c=0;c<t;c++){let[d,p]=[this._minMaxMatrix.get(c,0),this._minMaxMatrix.get(c,1)];this._isDynamicChunks&&(u=a[c]);let f=c+1<t?l+u:r,h;e.shape.length>1?h=new ot(e.hi(f,e.shape[1]).lo(l,0),o):h=new ot(e.hi(f).lo(l),o),ko.assign(s.hi(f,s.shape[1]).lo(l,0),h.dequantize(d,p).denormalize()),l=f}return s}static async fetchArrayBuffer(t){return await(await fetch(t,{mode:"cors"})).arrayBuffer()}};var yn=nr(Gs()),Be=nr(ks());var Xv="http://127.0.0.1:8000";var Di=nr(Gs()),et=nr(ks());var Qv=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9];function Kv(n){return n<1e5?n<100?n<10?0:1:n<1e4?n<1e3?2:3:4:n<1e7?n<1e6?5:6:n<1e9?n<1e8?7:8:9}function Zv(n,t){if(n===t)return 0;if(~~n===n&&~~t===t){if(n===0||t===0)return n<t?-1:1;if(n<0||t<0){if(t>=0)return-1;if(n>=0)return 1;n=-n,t=-t}let o=Kv(n),i=Kv(t),a=0;return o<i?(n*=Qv[i-o-1],t/=10,a=-1):o>i&&(t*=Qv[o-i-1],n/=10,a=1),n===t?a:n<t?-1:1}let e=String(n),r=String(t);return e===r?0:e<r?-1:1}function GM(n){let t=0;for(;n>=32;)t|=n&1,n>>=1;return n+t}function Jv(n,t,e,r){let o=t+1;if(o===e)return 1;if(r(n[o++],n[t])<0){for(;o<e&&r(n[o],n[o-1])<0;)o++;kM(n,t,o)}else for(;o<e&&r(n[o],n[o-1])>=0;)o++;return o-t}function kM(n,t,e){for(e--;t<e;){let r=n[t];n[t++]=n[e],n[e--]=r}}function eS(n,t,e,r,o){for(r===t&&r++;r<e;r++){let i=n[r],a=t,s=r;for(;a<s;){let u=a+s>>>1;o(i,n[u])<0?s=u:a=u+1}let l=r-a;switch(l){case 3:n[a+3]=n[a+2];case 2:n[a+2]=n[a+1];case 1:n[a+1]=n[a];break;default:for(;l>0;)n[a+l]=n[a+l-1],l--}n[a]=i}}function th(n,t,e,r,o,i){let a=0,s=0,l=1;if(i(n,t[e+o])>0){for(s=r-o;l<s&&i(n,t[e+o+l])>0;)a=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s),a+=o,l+=o}else{for(s=o+1;l<s&&i(n,t[e+o-l])<=0;)a=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s);let u=a;a=o-l,l=o-u}for(a++;a<l;){let u=a+(l-a>>>1);i(n,t[e+u])>0?a=u+1:l=u}return l}function rh(n,t,e,r,o,i){let a=0,s=0,l=1;if(i(n,t[e+o])<0){for(s=o+1;l<s&&i(n,t[e+o-l])<0;)a=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s);let u=a;a=o-l,l=o-u}else{for(s=r-o;l<s&&i(n,t[e+o+l])>=0;)a=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s),a+=o,l+=o}for(a++;a<l;){let u=a+(l-a>>>1);i(n,t[e+u])<0?l=u:a=u+1}return l}var oh=class{constructor(t,e){Gt(this,"array",null);Gt(this,"compare",null);Gt(this,"minGallop",7);Gt(this,"length",0);Gt(this,"tmpStorageLength",256);Gt(this,"stackLength",0);Gt(this,"runStart",null);Gt(this,"runLength",null);Gt(this,"stackSize",0);this.array=t,this.compare=e,this.length=t.length,this.length<2*256&&(this.tmpStorageLength=this.length>>>1),this.tmp=new Array(this.tmpStorageLength),this.stackLength=this.length<120?5:this.length<1542?10:this.length<119151?19:40,this.runStart=new Array(this.stackLength),this.runLength=new Array(this.stackLength)}pushRun(t,e){this.runStart[this.stackSize]=t,this.runLength[this.stackSize]=e,this.stackSize+=1}mergeRuns(){for(;this.stackSize>1;){let t=this.stackSize-2;if(t>=1&&this.runLength[t-1]<=this.runLength[t]+this.runLength[t+1]||t>=2&&this.runLength[t-2]<=this.runLength[t]+this.runLength[t-1])this.runLength[t-1]<this.runLength[t+1]&&t--;else if(this.runLength[t]>this.runLength[t+1])break;this.mergeAt(t)}}forceMergeRuns(){for(;this.stackSize>1;){let t=this.stackSize-2;t>0&&this.runLength[t-1]<this.runLength[t+1]&&t--,this.mergeAt(t)}}mergeAt(t){let e=this.compare,r=this.array,o=this.runStart[t],i=this.runLength[t],a=this.runStart[t+1],s=this.runLength[t+1];this.runLength[t]=i+s,t===this.stackSize-3&&(this.runStart[t+1]=this.runStart[t+2],this.runLength[t+1]=this.runLength[t+2]),this.stackSize--;let l=rh(r[a],r,o,i,0,e);o+=l,i-=l,i!==0&&(s=th(r[o+i-1],r,a,s,s-1,e),s!==0&&(i<=s?this.mergeLow(o,i,a,s):this.mergeHigh(o,i,a,s)))}mergeLow(t,e,r,o){let i=this.compare,a=this.array,s=this.tmp,l=0;for(l=0;l<e;l++)s[l]=a[t+l];let u=0,c=r,d=t;if(a[d++]=a[c++],--o===0){for(l=0;l<e;l++)a[d+l]=s[u+l];return}if(e===1){for(l=0;l<o;l++)a[d+l]=a[c+l];a[d+o]=s[u];return}let p=this.minGallop;for(;;){let f=0,h=0,m=!1;do if(i(a[c],s[u])<0){if(a[d++]=a[c++],h++,f=0,--o===0){m=!0;break}}else if(a[d++]=s[u++],f++,h=0,--e===1){m=!0;break}while((f|h)<p);if(m)break;do{if(f=rh(a[c],s,u,e,0,i),f!==0){for(l=0;l<f;l++)a[d+l]=s[u+l];if(d+=f,u+=f,e-=f,e<=1){m=!0;break}}if(a[d++]=a[c++],--o===0){m=!0;break}if(h=th(s[u],a,c,o,0,i),h!==0){for(l=0;l<h;l++)a[d+l]=a[c+l];if(d+=h,c+=h,o-=h,o===0){m=!0;break}}if(a[d++]=s[u++],--e===1){m=!0;break}p--}while(f>=7||h>=7);if(m)break;p<0&&(p=0),p+=2}if(this.minGallop=p,p<1&&(this.minGallop=1),e===1){for(l=0;l<o;l++)a[d+l]=a[c+l];a[d+o]=s[u]}else{if(e===0)throw new Error("mergeLow preconditions were not respected");for(l=0;l<e;l++)a[d+l]=s[u+l]}}mergeHigh(t,e,r,o){let i=this.compare,a=this.array,s=this.tmp,l=0;for(l=0;l<o;l++)s[l]=a[r+l];let u=t+e-1,c=o-1,d=r+o-1,p=0,f=0;if(a[d--]=a[u--],--e===0){for(p=d-(o-1),l=0;l<o;l++)a[p+l]=s[l];return}if(o===1){for(d-=e,u-=e,f=d+1,p=u+1,l=e-1;l>=0;l--)a[f+l]=a[p+l];a[d]=s[c];return}let h=this.minGallop;for(;;){let m=0,y=0,g=!1;do if(i(s[c],a[u])<0){if(a[d--]=a[u--],m++,y=0,--e===0){g=!0;break}}else if(a[d--]=s[c--],y++,m=0,--o===1){g=!0;break}while((m|y)<h);if(g)break;do{if(m=e-rh(s[c],a,t,e,e-1,i),m!==0){for(d-=m,u-=m,e-=m,f=d+1,p=u+1,l=m-1;l>=0;l--)a[f+l]=a[p+l];if(e===0){g=!0;break}}if(a[d--]=s[c--],--o===1){g=!0;break}if(y=o-th(a[u],s,0,o,o-1,i),y!==0){for(d-=y,c-=y,o-=y,f=d+1,p=c+1,l=0;l<y;l++)a[f+l]=s[p+l];if(o<=1){g=!0;break}}if(a[d--]=a[u--],--e===0){g=!0;break}h--}while(m>=7||y>=7);if(g)break;h<0&&(h=0),h+=2}if(this.minGallop=h,h<1&&(this.minGallop=1),o===1){for(d-=e,u-=e,f=d+1,p=u+1,l=e-1;l>=0;l--)a[f+l]=a[p+l];a[d]=s[c]}else{if(o===0)throw new Error("mergeHigh preconditions were not respected");for(p=d-(o-1),l=0;l<o;l++)a[p+l]=s[l]}}};function tS(n,t,e,r){if(!Array.isArray(n))throw new TypeError("Can only sort arrays");t?typeof t!="function"&&(r=e,e=t,t=Zv):t=Zv,e||(e=0),r||(r=n.length);let o=r-e;if(o<2)return;let i=0;if(o<32){i=Jv(n,e,r,t),eS(n,e,r,e+i,t);return}let a=new oh(n,t),s=GM(o);do{if(i=Jv(n,e,r,t),i<s){let l=o;l>s&&(l=s),eS(n,e,e+l,e+i,t),i=l}a.pushRun(e,i),a.mergeRuns(),o-=i,e+=i}while(o!==0);a.forceMergeRuns()}function nh(n){let t=(0,Di.default)(new Int32Array(n.shape[0]),[n.shape[0]]),e=(0,Di.default)(new Int32Array(n.shape[0]),[n.shape[0]]);return et.bands(t,n,1023),et.lshifts(e,t,16),et.bxoreq(t,e),et.bandseq(t,4278190335),et.lshifts(e,t,8),et.bxoreq(t,e),et.bandseq(t,50393103),et.lshifts(e,t,4),et.bxoreq(t,e),et.bandseq(t,51130563),et.lshifts(e,t,2),et.bxoreq(t,e),et.bandseq(t,153391689),t}function FM(n){let t=nh(n.pick(null,0)),e=nh(n.pick(null,1));et.lshiftseq(e,1);let r=nh(n.pick(null,2));return et.lshiftseq(r,2),et.boreq(t,e),et.boreq(t,r),t}function Zn(n,t){if(n.shape[0]!==t.shape[0])throw new Error("wrong length");let e=(0,Di.default)(new Float32Array(n.size),n.shape,n.stride,n.offset);for(let r=0;r<t.shape[0];r++){let o=t.get(r);if(n.shape.length>1)for(let i=0;i<n.shape[1];i++)e.set(r,i,n.get(o,i));else e.set(r,n.get(o))}return e}function ih(n){let t=et.sup(n),e=et.inf(n),r=1e3/Math.min(1e3,t-e),o=(0,Di.default)(new Float32Array(n.data),n.shape);et.mulseq(o,r);let i=(0,Di.default)(new Int32Array(o.data),n.shape),a=FM(i),l=Array.from(a.data).map((d,p)=>[d,p]);tS(l,(d,p)=>d[0]-p[0]);let u=l.map(([d,p])=>p);return(0,Di.default)(Uint32Array.from(u))}var Qr=class{constructor(t,e,r,o,i,a,s,l,u,c){this.propertyDescs=t,this.format=e,this.nsplats=r,this.xyz=o,this.colors=i,this.harmonics=a,this.opacity=s,this.scaling=l,this.rotation=u,this.maxSHDegree=c}getPlyBinary(){let t=Qr._generateHeaderString(this.propertyDescs,this.format,this.nsplats),e=new TextEncoder().encode(t),r=Object.keys(this.propertyDescs).length,o=(0,yn.default)(new Float32Array(this.nsplats*r),[this.nsplats,r]);if(Be.assign(o.pick(null,this.propertyDescs.x.index),this.xyz.pick(null,0)),Be.assign(o.pick(null,this.propertyDescs.y.index),this.xyz.pick(null,1)),Be.assign(o.pick(null,this.propertyDescs.z.index),this.xyz.pick(null,2)),Be.assign(o.pick(null,this.propertyDescs.f_dc_0.index),this.colors.pick(null,0)),Be.assign(o.pick(null,this.propertyDescs.f_dc_1.index),this.colors.pick(null,1)),Be.assign(o.pick(null,this.propertyDescs.f_dc_2.index),this.colors.pick(null,2)),Be.assign(o.pick(null,this.propertyDescs.opacity.index),this.opacity.pick(null,0)),Be.assign(o.pick(null,this.propertyDescs.scale_0.index),this.scaling.pick(null,0)),Be.assign(o.pick(null,this.propertyDescs.scale_1.index),this.scaling.pick(null,1)),Be.assign(o.pick(null,this.propertyDescs.scale_2.index),this.scaling.pick(null,2)),Be.assign(o.pick(null,this.propertyDescs.rot_0.index),this.rotation.pick(null,0)),Be.assign(o.pick(null,this.propertyDescs.rot_1.index),this.rotation.pick(null,1)),Be.assign(o.pick(null,this.propertyDescs.rot_2.index),this.rotation.pick(null,2)),Be.assign(o.pick(null,this.propertyDescs.rot_3.index),this.rotation.pick(null,3)),this.harmonics&&this.harmonics.length>0)for(let s=0;s<this.harmonics.length;s++){let l=s*3;Be.assign(o.pick(null,this.propertyDescs[`f_rest_${l}`].index),this.harmonics[s].pick(null,0)),Be.assign(o.pick(null,this.propertyDescs[`f_rest_${l+1}`].index),this.harmonics[s].pick(null,1)),Be.assign(o.pick(null,this.propertyDescs[`f_rest_${l+2}`].index),this.harmonics[s].pick(null,2))}let i=new Uint8Array(o.data.buffer),a=new Uint8Array(i.length+e.length);return a.set(e),a.set(i,e.length),a.buffer}save(t,e){let r=this.getPlyBinary(),o=new Blob([r],{type:"application/octet-stream"}),i=new File([o],t),a=new FormData;a.append("file",i),a.append("filename",t),a.append("basedir",e),fetch(`${Xv}/push_file`,{method:"POST",body:a})}static async loadFile(t){return await(await fetch(t)).arrayBuffer()}mortonPositionSplatsSort(){let t=ih(this.xyz),e=Zn(this.xyz,t),r=Zn(this.colors,t),o=Zn(this.opacity,t),i=Zn(this.scaling,t),a=Zn(this.rotation,t),s=[];for(let l=0;l<this.harmonics.length;l++)s.push(Zn(this.harmonics[l],t));return new Qr(this.propertyDescs,this.format,this.nsplats,e,r,s,o,i,a,this.maxSHDegree)}static _generateHeaderString(t,e,r){let o=`ply
3489
+ `;var Bh=10,Hd=class extends Le.Object3D{constructor(e,r){super();this.type="ParticleEmitter";this.debugMode=!1;this.worldSpace=!0;this.rootObject=null;this.gpuCompute=null;this.positionSimRT=null;this.velocitySimRT=null;this.emissionRateSimRT=null;this.emitterShape=void 0;this.isEmitting=!1;this.hasBeenReset=!1;this.emittedParticlesAmount=0;this.lastEmitTime=0;this.globalTime=0;this.targetFPS=60;this.previousRatio=1;this.lerpFactor=.4;this.particlesAmount=0;this.noiseStrength=0;this.noiseScale=0;this.isBillboardBased=!0;this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1};this.textureLoader=new Le.TextureLoader;this.currentWorldPosition=new Le.Vector3;this.systemQuaternion=new Le.Quaternion;this.worldGravity=new Le.Vector3(0,0,0);this.directionAxis=new Le.Vector3(0,0,0);this.colliderV3=new Le.Vector3(0,0,0);this.colliderQuaternion=new Le.Quaternion(0,0,0,1);this.matrixAutoUpdate=!0,this.renderer=e,this.system=r,this.shared=r.context.shared;let o=r.data;this.material=new Ud(o.renderMaterial,r.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:o.renderMaterial.color},uColor2:{value:o.renderMaterial.color2},uPosition:{value:new Le.Vector3(0,0,0)},uEmissionData:{value:new Le.Vector3(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new Le.Vector3(0,0,0)},uWorldQuaternion:{value:new Le.Vector4(0,0,0,1)},uRandScaleFactor:{value:o.randomScale??0},uRandRotationFactor:{value:o.randomRotation??0},uRotation:{value:o.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:o.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,o.renderMaterial.texture),this.init(o)}setTexture(e,r){let o=r.data;if(typeof r=="string"){let i=this.shared.image(r),a=new Le.Texture(i.img);a.needsUpdate=!0,e.uTexture.value=a;return}if(typeof o!="string"){let i=new Image;i.onload=()=>{let l=new Le.Texture(i);l.needsUpdate=!0,e.uTexture.value=l};let a=new Blob([o],{type:"image/*"}),s=URL.createObjectURL(a);i.src=s}}updateGeometryAttributes(e,r){let o=Wv(r);!this.emitterShape?.positionsAttribute||e.geometry.setAttribute("ref",new Le.InstancedBufferAttribute(o,2))}applyWorldSpace(){if(!this.system.started||!this.worldSpace||!this.positionSimRT||!this.velocitySimRT)return;let e=this.system;e.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),e.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(e,r){if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset){this.reset();return}this.applyWorldSpace(),this.globalTime=e,this.positionSimRT.material.uniforms.uTime.value=e,this.emissionRateSimRT.material.uniforms.uTime.value=e;let o=1e3/r,i=this.targetFPS/o,a=this.previousRatio+(i-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=a,this.previousRatio=a;let s=this.isEmitting?this.GoEmitSomeParticles(e,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=s,this.material.uniforms.uPosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT)?.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let e=this.system.colliderEntities[0];if(!e)return;e.getWorldPosition(this.colliderV3),this.colliderV3.y===0&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let r=e.data.size;this.colliderV3.fromArray(r),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),e.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(e){!this.velocitySimRT||!this.positionSimRT||(e.renderMaterial&&this.updateMaterialState(e.renderMaterial),this.updateParticleState(e))}updateVariableState(e,r){if(!this.velocitySimRT||!this.positionSimRT)return;r[2]==="size"&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),r[2]==="sizeEnd"&&this.material.updateState({size:[this.material.uniforms.uSize.value,e]});let o=(i,a)=>{let s=[...this.system.data.shape.size];s[i]=a,this.updateParticleState({shape:{...this.system.data.shape,size:s}})};r[2]==="shape_size_0"&&o(0,e),r[2]==="shape_size_1"&&o(1,e),r[2]==="shape_size_2"&&o(2,e),r[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/Bh),r[2]==="gravity"&&this.worldGravity.set(0,e/100,0),r[2]==="noiseStrength"&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),r[2]==="noiseScale"&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),r[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),r[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),r[2]==="direction_z"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(e)]))}updateMaterialState(e){this.material.updateState({...e,size:e.size?[Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),e.texture&&(this.setTexture(this.material.uniforms,e.texture),this.material.needsUpdate=!0)}updateParticleState(e){if(!(!this.positionSimRT||!this.velocitySimRT)){if(this.shouldReInitGPUCompute(e)&&this.init(Wi(this.system.data)),e.life!==void 0&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=e.life),e.speed!==void 0&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/Bh),e.collisionBounce!==void 0&&(this.velocitySimRT.material.uniforms.uBounce.value=e.collisionBounce),e.noiseStrength!==void 0&&(this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),e.noiseScale!==void 0&&(this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),e.noiseSeed!==void 0&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=e.noiseSeed),e.randomMass!==void 0&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=e.randomMass),e.renderMaterial?.size!==void 0){let r=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(r)}if(e.renderMaterial?.spriteRotation!==void 0&&(this.material.uniforms.uRotation.value=e.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=e.renderMaterial.spriteRotation[1]),e.shape!==void 0){let r=e.shape.size??this.system.data.shape.size,o=[Number(this.shared.getVariable(r[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(r[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(r[2],[this.uuid,"particles","shape_size_2"]))],i={...Wi(this.system.data).shape,size:o};this.emitterShape?.applyToShader(this.positionSimRT.material.uniforms,i)}if(e.gravity!==void 0&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),e.direction!==void 0){let r=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(r),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}e.randomRotation!==void 0&&(this.material.uniforms.uRandRotationFactor.value=e.randomRotation),e.randomScale!==void 0&&(this.material.uniforms.uRandScaleFactor.value=e.randomScale)}}updateForceFieldParameters(e){!this.velocitySimRT||(e.forceIntensity!==void 0&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=e.forceIntensity),e.forceDambing!==void 0&&(this.velocitySimRT.material.uniforms.uForceDamping.value=e.forceDambing))}getDirectionAxis(e){let r=[Number(e[0])*Le.MathUtils.DEG2RAD,Number(e[1])*Le.MathUtils.DEG2RAD,Number(e[2])*Le.MathUtils.DEG2RAD],o=new Le.Euler(r[0],r[1],r[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(o).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(e){let{birthRatePerSec:r,rootObjectType:o,colliderEntityId:i,shape:a,emitTimeDuration:s,emitTimeCycle:l,life:u,directionMode:c,noiseType:d}=e;return r!==void 0||o!==void 0||(i||i===null)||l!==void 0||a!==void 0||u!==void 0||s!==void 0||c!==void 0||d!==void 0}init(e){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:e.birthRatePerSec,particleMaxLifeTime:e.life,loopDuration:e.emitTimeCycle==="infinity"?0:e.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn(`The maximum number of particles is limited to ${1e5}.`),this.particlesAmount=1e5),this.emitterShape=this.createShape(e.shape,this.particlesAmount);let r=setInterval(()=>{if(!!this.emitterShape)if(isNaN(this.emitterShape.positionsTexture.source.data.data[0])){this.init(e);return}else clearInterval(r)},100);if(!this.emitterShape)return;let o=new mS.GPUComputationRenderer(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),i=this.updateSimulationDefinition(e),a=o.addVariable("uCurrentPosition",i+Kv,this.emitterShape.positionsTexture),s=o.addVariable("uCurrentVelocity",i+rS,this.emitterShape.directionsTexture),l=o.addVariable("uCurrentEmissionRate",fS,Qv(this.emitterShape.textureSize));o.setVariableDependencies(a,[a,s,l]),o.setVariableDependencies(s,[a,s,l]),o.setVariableDependencies(l,[a,s,l]);let u=Xv({size:this.emitterShape.textureSize}),c={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new Le.Vector3(0,0,0)},uWorldQuaternion:{value:new Le.Vector4(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:e.life},uEmitterSize:{value:new Le.Vector3(Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"])))},particleSize:{value:0}};a.material.uniforms=c;let d=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(d),this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"]));let p=e.colliderEntityId&&this.system.getColliderData(e.colliderEntityId),f={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new Le.Vector4(0,0,0,1)},uColliderPos:{value:new Le.Vector3(0,0,0)},uColliderSize:{value:new Le.Vector3(0,0,0)},uForceIntensity:{value:p?p.forceIntensity:0},uForceDamping:{value:p?p.forceDambing:0},uColliderQuaternion:{value:new Le.Vector4(0,0,0,1)},uColliderQuaternionInvert:{value:new Le.Vector4(0,0,0,1)},particleSize:{value:0},uGravity:{value:this.worldGravity},uNoiseStrength:{value:this.noiseStrength},uNoiseScale:{value:this.noiseScale},uNoiseSeed:{value:e.noiseSeed},uRandomMassFactor:{value:e.randomMass},uBounce:{value:e.collisionBounce},uSpeed:{value:Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/Bh}};s.material.uniforms=f;let h={uIndex:{value:u},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};l.material.uniforms=h;let m=[Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"]))],y={...Wi(this.system.data).shape,size:m};this.emitterShape.applyToShader(a.material.uniforms,y),o.init(),this.gpuCompute=o,this.positionSimRT=a,this.velocitySimRT=s,this.emissionRateSimRT=l,this.rootObject=this.createPrimaryEmitter(this.emitterShape.textureSize),this.add(this.rootObject),this.material.needsUpdate=!0}getDirectionFromVariable(e){let r=Number(this.shared.getVariable(e[0],[this.uuid,"particles","direction_x"])),o=Number(this.shared.getVariable(e[1],[this.uuid,"particles","direction_y"])),i=Number(this.shared.getVariable(e[2],[this.uuid,"particles","direction_z"]));return[r,o,i]}updateSimulationDefinition(e){if(this.simFeaturesDefinition.USE_COLLIDER=!1,this.simFeaturesDefinition.USE_ATTRACTOR=!1,this.simFeaturesDefinition.USE_VORTEX=!1,this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!1,this.simFeaturesDefinition.USE_BOX_COLLIDER=!1,this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!1,this.simFeaturesDefinition.USE_NORMALS=!1,this.simFeaturesDefinition.USE_CURL_NOISE=!1,this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!1,this.simFeaturesDefinition.USE_FBM_NOISE=!1,e.colliderEntityId&&this.system.colliderEntities.length>0){let o=this.system.getColliderData(e.colliderEntityId);switch(o?.forceType){case"attractor":this.simFeaturesDefinition.USE_ATTRACTOR=!0;break;case"collider":this.simFeaturesDefinition.USE_COLLIDER=!0;break;case"vortex":this.simFeaturesDefinition.USE_VORTEX=!0;break}let i=o?.colliderType;i==="sphere"&&(this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!0),i==="box"&&(this.simFeaturesDefinition.USE_BOX_COLLIDER=!0),o?.forceRange==="helper"&&(this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!0)}e.directionMode==="normals"&&(this.simFeaturesDefinition.USE_NORMALS=!0),e.noiseType==="curl"&&(this.simFeaturesDefinition.USE_CURL_NOISE=!0),e.noiseType==="simplex"&&(this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!0),e.noiseType==="fbm"&&(this.simFeaturesDefinition.USE_FBM_NOISE=!0);let r="";for(let[o,i]of Object.entries(this.simFeaturesDefinition))i&&(r+=`#define ${o}
3490
+ `);return r}createShape(e,r){this.emitterShape&&this.emitterShape.dispose();let o=new Le.Vector3(Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.size[2],[this.uuid,"particles","shape_size_2"])));if(e.type==="MeshEmitterShape"){let i=null;return this.system.context.scene.traverseEntity(a=>{a.uuid===e.fromMeshId&&(i=a)}),i?new ol(o,r,e.type,i):new ol(o,r,"SphereEmitterShape")}else return new ol(o,r,e.type)}createPrimaryEmitter(e){let r,o=e*e;return r=new Le.InstancedMesh(new Le.PlaneGeometry(1,1,1),this.material,o),this.updateGeometryAttributes(r,e),this.material.needsUpdate=!0,r.onBeforeRender=()=>{this.applyWorldSpace()},r}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:r,loopDuration:o=0}){return Math.ceil(e*(r+o))}dispose(){!this.gpuCompute||(this.rootObject?.parent?.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),this.emitterShape?.dispose())}GoEmitSomeParticles(e,r){let o=e-this.lastEmitTime,i=1/r;if(o>=i){let a=Math.max(1,Math.floor(o/i));return this.lastEmitTime=e,this.emittedParticlesAmount+a>this.particlesAmount&&(this.emittedParticlesAmount=0),this.emittedParticlesAmount+=a,a}return 0}checkIfAllParticlesAreDead(){return this.lastEmitTime+this.system.data.life+1<this.globalTime}reset(){this.hasBeenReset=!0,this.lastEmitTime=0,this.emittedParticlesAmount=0,this.gpuCompute&&this.init(Wi(this.system.data))}startEmitting(){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=this.globalTime}stopEmitting(){this.isEmitting=!1}};var nl=require("three");var qd=class extends Wt{constructor(e,r,o){super(e,r);this.type="ParticleSystem";this.geometry=new nl.BufferGeometry;this.actualTime=0;this.currentLoopTime=0;this.started=!1;this.stopped=!1;this.isFrozen=!1;this.isIdle=!0;this.emitter=null;this.colliderEntities=[];this.renderer=null;this.isPreWarm=!1;this._hasOnAfterRenderBeenCalled=!1;this.onAfterRender=e=>{this._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(e))};this.context=o,this.data={...r,...Wi(r)},this.geometry.setAttribute("position",new nl.Float32BufferAttribute([],3)),this.material=new nl.MeshBasicMaterial({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new Hd(e,this),this.add(this.emitter),this.updateParticleState(this.data)}update(e){if(!this.isReady||!this.started||this.isFrozen||this.isIdle)return;this.actualTime+=e,this.stopped||(this.currentLoopTime+=e);let r=this.data.emitTimeCycle==="one_time";if((this.data.emitTimeCycle==="loop"||r)&&this.currentLoopTime>this.data.emitTimeDuration*1e3&&(this.stopped||(this.stop(),r||this.start(this.data.emitTimeLoopDelayStart==="start"?0:this.data.emitTimeDelay*1e3))),this.emitter&&this.started){let i=this.actualTime/1e3;this.emitter.update(i,e)}this.scale.set(1,1,1),this.updateMatrix()}isReady(){return!!this.emitter}hasCollider(e){return this.colliderEntities.some(r=>r.identity===e)}getColliderData(e){let r=this.colliderEntities.find(o=>o.identity===e);return r?r.data:null}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),ke(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...wt.drop(e,1).props}}),ke(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...wt.drop(e,1).props}})}updateState(e,r){super.updateState(e,r),this.updateParticleState(e)}updateParticleState(e){if(!!this.emitter){if(e.colliderEntityId!==void 0&&e.colliderEntityId!==null){let r=this.context.scene.find(e.colliderEntityId);this.colliderEntities=r?[r]:[]}e.colliderEntityId===null&&(this.colliderEntities=[]),this.emitter.updateState(e),e.emitTimeCycle&&this.started&&this.start()}}updateFromColliderEntity(e){!this.emitter||(this.emitter.updateForceFieldParameters(e),this.stop(),this.start())}start(e=0){if(this.currentLoopTime=0,e){setTimeout(()=>{this.start(0)},e);return}this.started=!0,this.stopped=!1,this.isFrozen=!1,this.emitter?.startEmitting()}froze(){this.isFrozen=!0}unFroze(){this.isFrozen=!1}stop(){this.stopped=!0,this.currentLoopTime=0,this.emitter?.stopEmitting()}reset(){this.started=!1,this.stopped=!1,this.emitter?.reset()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}};function hI(n,t,e){let r;return t.geometry.type==="TextGeometry"?new Gs(n,t,e):(t.geometry.type==="SubdivGeometry"?r=new ki(n,t,e):t.geometry.type==="PathGeometry"?r=new tl(n,t,e):t.geometry.type==="VectorGeometry"?r=new kd(n,t,e):t.geometry.type==="BooleanGeometry"?r=new Er(n,t,e):t.geometry.type==="UIGeometry"?r=new qi(n,t,e):r=new Ot(n,t,e),r)}function Wd(n,t,e){return console.assert(t.type!==void 0),t.type==="Mesh"?hI(n,t,e):t.type==="Empty"?new oi(n,t):t.type==="Particle"?new qd(n,t,e):t.type==="ParticleCollider"?new Id(n,t,e):t.type==="Splat"?new oi(n,t):t.type==="Bone"?new jd(n,t):t.type==="Page"?new io(n,t,e):t.type==="PointLight"?new Gd(n,t,e):t.type==="SpotLight"?new Qs(n,t,e):t.type==="DirectionalLight"?new Xs(n,t,e):t.type==="Component"||t.type==="Instance"?new Pn(n,t,e):po.is(t.type)?new wn(n,t):(console.error(t),new oi(n,t))}mo.createEntity=Wd;function mI(n,t,e){let r=Wd(n.identity,t,e),o=n.children,i=n.attachedPaths,a=n.parent,s=n.component,l=n.instances,u=n.overrideData,c=n.uuid,d=n.stateSelection;n.dispose();for(let p of Object.keys(n))delete n[p];Object.setPrototypeOf(n,Object.getPrototypeOf(r));for(let p of Object.keys(r))n[p]=r[p];n.children=[...n.children,...o],n.attachedPaths=i,n.parent=a,n.component=s,n.instances=l,n.uuid=c,n.overrideData=u,n.updateState(n.data,e),d&&n.changeSelectedState(d,e),n.resetBBoxNeedsUpdate()}mo.changeEntityProptotype=mI;mo.Cloner=js;function yS(n,t,e,r){n.updateByOp(t,e,r,!1)}var il=require("three");function gS(n,t){let e=!1,r=t.getLayersOfType("transmission"),o=t.getLayersOfType("outline");return o.length>0&&(n.layers.set(8),r.length>0&&n.layers.enable(3),e=!0,Vs(n),Rs(n)),r.length===0&&o.length===0&&n.layers.set(0),n instanceof Dr&&n.needsAO&&n.layers.enable(5),e}function xS(n,t){if(!t.layers)return!1;let e=!1,r=t.getLayersOfType("transmission").filter(i=>i.data.visible),o=t.getLayersOfType("outline").filter(i=>i.data.visible);return r.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),r.length===0&&o.length===0&&n.layers.set(0),n.needsAO&&n.layers.enable(5),e}function bS(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Dr)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)gS(e,e.material[r])&&(t=!0);else gS(e,e.material)&&(t=!0)}),t}function vS(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Dr)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)xS(e,e.material[r])&&(t=!0);else xS(e,e.material)&&(t=!0)}),t}var xI=new il.Raycaster,bI=new il.Matrix4,vI=new il.Ray;function yc(n,t,e,r=!1){let o=n.cloner;if(o)for(let i of o.children){let a=bI.copy(i.matrixWorld).invert(),s=vI.copy(t.ray).applyMatrix4(a),l=n.matrixWorld;s.applyMatrix4(l);let u=xI;u.set(s.origin,s.direction),u.near=t.near,u.far=t.far;let c=u.intersectObject(n,!1);c.length>0&&e.push({...c[0],object:r?i:n})}}var $d=class{constructor(){this._constraints=new Map}setConstraint(t,e){e===null?this._constraints.delete(t):this._constraints.set(t,e)}removeDependencies(t){this._constraints.delete(t)}applyConstraints(t){let e=new Set;this._constraints.forEach((r,o)=>{let i=[o,r],a=r;for(;this._constraints.has(a);)a=this._constraints.get(a),e.has(a)||i.push(a);for(let s=i.length-2;s>=0;s--)if(!e.has(i[s])){let l=t.find(i[s]);l?l.applyPathSnapping(t):console.warn(`missing entity ${i[s]}`),e.add(i[s])}})}findDependency(t,e){let r=t;for(;this._constraints.has(r);)if(r=this._constraints.get(r),r===e)return!0;return!1}};var Co=hr(al()),Ko=hr(sl());var Bt=hr(al()),ve=hr(sl()),si=class{constructor(t,e,r){this._dataNormalized=t,this._minD=e,this._maxD=r}static createFromUnnormalized(t){let e=ve.sup(t),r=ve.inf(t),o=(0,Bt.default)(new Float32Array(t.size),t.shape),i=e-r;return i<1e-4?ve.assigns(o,0):(ve.subs(o,t,r),ve.divs(o,o,i)),new si(o,r,e)}get data(){return this._dataNormalized}get minD(){return this._minD}get maxD(){return this._maxD}denormalize(){let t=(0,Bt.default)(new Float32Array(this._dataNormalized.size),this._dataNormalized.shape);return ve.muls(t,this._dataNormalized,this._maxD-this._minD),ve.adds(t,t,this._minD),t}},pt=class{constructor(t,e){this._quantized=t,this._method=e}get quantized(){return this._quantized}static maxIntBits(t){return 2**t-1}static fromNormalized(t,e){let r=t.data,o;if(e==="norm8x"){let i=pt.maxIntBits(8),a=(0,Bt.default)(new Float32Array(r.size),r.shape);ve.muls(a,r,i),ve.roundeq(a),o=(0,Bt.default)(new Uint8Array(a.data),r.shape)}else if(e==="norm565"){let i=(0,Bt.default)(new Float32Array(r.size),r.shape);ve.assign(i,r),ve.mulseq(i.pick(null,0),pt.maxIntBits(5)),ve.mulseq(i.pick(null,1),pt.maxIntBits(6)),ve.mulseq(i.pick(null,2),pt.maxIntBits(5)),ve.roundeq(i);let a=(0,Bt.default)(new Uint16Array(i.data),r.shape),s=(0,Bt.default)(new Uint16Array(r.shape[0]),[r.shape[0]]),l=(0,Bt.default)(new Uint16Array(r.shape[0]),[r.shape[0]]);ve.lshifts(s,a.pick(null,0),11),ve.lshifts(l,a.pick(null,1),5),ve.boreq(s,l),ve.boreq(s,a.pick(null,2)),o=s}else{let i=(0,Bt.default)(new Float32Array(r.size),r.shape);ve.assign(i,r),ve.mulseq(i.pick(null,0),pt.maxIntBits(11)),ve.mulseq(i.pick(null,1),pt.maxIntBits(10)),ve.mulseq(i.pick(null,2),pt.maxIntBits(11)),ve.roundeq(i);let a=(0,Bt.default)(new Uint32Array(i.data),r.shape),s=(0,Bt.default)(new Uint32Array(r.shape[0]),[r.shape[0]]),l=(0,Bt.default)(new Uint32Array(r.shape[0]),[r.shape[0]]);ve.lshifts(s,a.pick(null,0),21),ve.lshifts(l,a.pick(null,1),11),ve.boreq(s,l),ve.boreq(s,a.pick(null,2)),o=s}return new pt(o,e)}dequantize(t,e){let r=this._method,o,i=this._quantized;if(r==="norm8x"){let a=pt.maxIntBits(8);o=(0,Bt.default)(new Float32Array(i.size),i.shape),ve.muls(o,i,1/a)}else if(r==="norm565"){let a=(0,Bt.default)(new Uint8Array(i.shape[0]),[i.shape[0]]),s=(0,Bt.default)(new Uint8Array(i.shape[0]),[i.shape[0]]),l=(0,Bt.default)(new Uint8Array(i.shape[0]),[i.shape[0]]);ve.rrshifts(a,i,11),ve.rrshifts(s,i,5),ve.bandseq(s,pt.maxIntBits(6)),ve.bands(l,i,pt.maxIntBits(5)),o=(0,Bt.default)(new Float32Array(i.shape[0]*3),[i.shape[0],3]),ve.muls(o.pick(null,0),a,1/pt.maxIntBits(5)),ve.muls(o.pick(null,1),s,1/pt.maxIntBits(6)),ve.muls(o.pick(null,2),l,1/pt.maxIntBits(5))}else{let a=(0,Bt.default)(new Uint16Array(i.shape[0]),[i.shape[0]]),s=(0,Bt.default)(new Uint16Array(i.shape[0]),[i.shape[0]]),l=(0,Bt.default)(new Uint16Array(i.shape[0]),[i.shape[0]]);ve.rrshifts(a,i,21),ve.rrshifts(s,i,11),ve.bandseq(s,pt.maxIntBits(10)),ve.bands(l,i,pt.maxIntBits(11)),o=(0,Bt.default)(new Float32Array(i.shape[0]*3),[i.shape[0],3]),ve.muls(o.pick(null,0),a,1/pt.maxIntBits(11)),ve.muls(o.pick(null,1),s,1/pt.maxIntBits(10)),ve.muls(o.pick(null,2),l,1/pt.maxIntBits(11))}return new si(o,t,e)}};var ft=class{constructor(t,e,r,o,i,a=!1){this._quantized=t,this._minMaxMatrix=e,this._chunkSize=r,this._quantizationMethod=o,this._variableChunkSize=i,this._isDynamicChunks=a}get length(){return this._quantized.shape[0]}get nchunks(){return this._minMaxMatrix.shape[0]}get quantized(){return this._quantized}get method(){return this._quantizationMethod}get minmaxMatrix(){return this._minMaxMatrix}_createPrunedMinMax(t){let e=t.length,r=this.minmaxMatrix.shape[0]-e,o=(0,Co.default)(new Float32Array(r*2),[r,2]),i=0,a=r,s=0,l=this.minmaxMatrix.shape[0];for(let u=0;u<t.length;u++)l=t[u],a=l-s+i,a>i&&Ko.assign(o.hi(a,2).lo(i,0),this.minmaxMatrix.hi(l,2).lo(s,0)),i=a,s=l+1;return i<r&&Ko.assign(o.lo(i,0),this.minmaxMatrix.lo(s,0)),o}_createPrunedQuantized(t){let e=t.length,r=this.quantized.shape[0]-e,o=this._quantizationMethod,i,a;if(o==="norm8x"){a=this._quantized.shape[1];let d=a?r*a:r;i=(0,Co.default)(new Uint8Array(d),a?[r,a]:[r,1])}else o==="norm565"?i=(0,Co.default)(new Uint16Array(r),[r]):i=(0,Co.default)(new Uint32Array(r),[r]);let s=0,l=r,u=0,c=i.shape[0];for(let d=0;d<t.length;d++)c=t[d],l=c-u+s,l>s&&(a?Ko.assign(i.hi(l,a).lo(s,0),this._quantized.hi(c,a).lo(u,0)):Ko.assign(i.hi(l).lo(s),this._quantized.hi(c).lo(u))),s=l,u=c+1;return s<r&&(a?Ko.assign(i.lo(s,0),this._quantized.lo(u,0)):Ko.assign(i.lo(s),this._quantized.lo(u))),i}pruneFeature(t,e,r){let o=this._createPrunedQuantized(t),i=this._createPrunedMinMax(e);return new ft(o,i,this._chunkSize,this._quantizationMethod,r,!0)}static getRequiredNChunks(t,e){return Math.floor(t/e)}static fromArray(t,e,r){let o=t.shape[0],i=Math.floor(o/r),a=(0,Co.default)(new Float32Array(i*2),[i,2],[2,1]),s;e==="norm8x"?s=(0,Co.default)(new Uint8Array(t.size),t.shape):e==="norm565"?s=(0,Co.default)(new Uint16Array(t.shape[0]),[t.shape[0]]):s=(0,Co.default)(new Uint32Array(t.shape[0]),[t.shape[0]]);for(let l=0;l<i;l++){let u=l*r,c=l+1<i?(l+1)*r:o,d;t.shape.length>1?d=si.createFromUnnormalized(t.hi(c,t.shape[1]).lo(u,0)):d=si.createFromUnnormalized(t.hi(c).lo(u)),a.set(l,0,d.minD),a.set(l,1,d.maxD),s.shape.length>1?Ko.assign(s.hi(c,s.shape[1]).lo(u,0),pt.fromNormalized(d,e).quantized):Ko.assign(s.hi(c).lo(u),pt.fromNormalized(d,e).quantized)}return new ft(s,a,r,e)}denormDequant(){let t=this._minMaxMatrix.shape[0],e=this._quantized,r=e.shape[0],o=this._quantizationMethod,i=this._chunkSize,a;if(this._isDynamicChunks){if(!this._variableChunkSize)throw new Error("variable chunk must exists if chunkSize isDynamic");a=this._variableChunkSize}let s;o==="norm8x"?s=(0,Co.default)(new Float32Array(e.size),e.shape):s=(0,Co.default)(new Float32Array(r*3),[r,3]);let l=0,u=i;for(let c=0;c<t;c++){let[d,p]=[this._minMaxMatrix.get(c,0),this._minMaxMatrix.get(c,1)];this._isDynamicChunks&&(u=a[c]);let f=c+1<t?l+u:r,h;e.shape.length>1?h=new pt(e.hi(f,e.shape[1]).lo(l,0),o):h=new pt(e.hi(f).lo(l),o),Ko.assign(s.hi(f,s.shape[1]).lo(l,0),h.dequantize(d,p).denormalize()),l=f}return s}static async fetchArrayBuffer(t){return await(await fetch(t,{mode:"cors"})).arrayBuffer()}};var On=hr(al()),Ue=hr(sl());var jS="http://127.0.0.1:8000";var $i=hr(al()),ct=hr(sl());var US=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9];function HS(n){return n<1e5?n<100?n<10?0:1:n<1e4?n<1e3?2:3:4:n<1e7?n<1e6?5:6:n<1e9?n<1e8?7:8:9}function qS(n,t){if(n===t)return 0;if(~~n===n&&~~t===t){if(n===0||t===0)return n<t?-1:1;if(n<0||t<0){if(t>=0)return-1;if(n>=0)return 1;n=-n,t=-t}let o=HS(n),i=HS(t),a=0;return o<i?(n*=US[i-o-1],t/=10,a=-1):o>i&&(t*=US[o-i-1],n/=10,a=1),n===t?a:n<t?-1:1}let e=String(n),r=String(t);return e===r?0:e<r?-1:1}function qI(n){let t=0;for(;n>=32;)t|=n&1,n>>=1;return n+t}function WS(n,t,e,r){let o=t+1;if(o===e)return 1;if(r(n[o++],n[t])<0){for(;o<e&&r(n[o],n[o-1])<0;)o++;WI(n,t,o)}else for(;o<e&&r(n[o],n[o-1])>=0;)o++;return o-t}function WI(n,t,e){for(e--;t<e;){let r=n[t];n[t++]=n[e],n[e--]=r}}function $S(n,t,e,r,o){for(r===t&&r++;r<e;r++){let i=n[r],a=t,s=r;for(;a<s;){let u=a+s>>>1;o(i,n[u])<0?s=u:a=u+1}let l=r-a;switch(l){case 3:n[a+3]=n[a+2];case 2:n[a+2]=n[a+1];case 1:n[a+1]=n[a];break;default:for(;l>0;)n[a+l]=n[a+l-1],l--}n[a]=i}}function Vh(n,t,e,r,o,i){let a=0,s=0,l=1;if(i(n,t[e+o])>0){for(s=r-o;l<s&&i(n,t[e+o+l])>0;)a=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s),a+=o,l+=o}else{for(s=o+1;l<s&&i(n,t[e+o-l])<=0;)a=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s);let u=a;a=o-l,l=o-u}for(a++;a<l;){let u=a+(l-a>>>1);i(n,t[e+u])>0?a=u+1:l=u}return l}function zh(n,t,e,r,o,i){let a=0,s=0,l=1;if(i(n,t[e+o])<0){for(s=o+1;l<s&&i(n,t[e+o-l])<0;)a=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s);let u=a;a=o-l,l=o-u}else{for(s=r-o;l<s&&i(n,t[e+o+l])>=0;)a=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s),a+=o,l+=o}for(a++;a<l;){let u=a+(l-a>>>1);i(n,t[e+u])<0?l=u:a=u+1}return l}var Gh=class{constructor(t,e){Kt(this,"array",null);Kt(this,"compare",null);Kt(this,"minGallop",7);Kt(this,"length",0);Kt(this,"tmpStorageLength",256);Kt(this,"stackLength",0);Kt(this,"runStart",null);Kt(this,"runLength",null);Kt(this,"stackSize",0);this.array=t,this.compare=e,this.length=t.length,this.length<2*256&&(this.tmpStorageLength=this.length>>>1),this.tmp=new Array(this.tmpStorageLength),this.stackLength=this.length<120?5:this.length<1542?10:this.length<119151?19:40,this.runStart=new Array(this.stackLength),this.runLength=new Array(this.stackLength)}pushRun(t,e){this.runStart[this.stackSize]=t,this.runLength[this.stackSize]=e,this.stackSize+=1}mergeRuns(){for(;this.stackSize>1;){let t=this.stackSize-2;if(t>=1&&this.runLength[t-1]<=this.runLength[t]+this.runLength[t+1]||t>=2&&this.runLength[t-2]<=this.runLength[t]+this.runLength[t-1])this.runLength[t-1]<this.runLength[t+1]&&t--;else if(this.runLength[t]>this.runLength[t+1])break;this.mergeAt(t)}}forceMergeRuns(){for(;this.stackSize>1;){let t=this.stackSize-2;t>0&&this.runLength[t-1]<this.runLength[t+1]&&t--,this.mergeAt(t)}}mergeAt(t){let e=this.compare,r=this.array,o=this.runStart[t],i=this.runLength[t],a=this.runStart[t+1],s=this.runLength[t+1];this.runLength[t]=i+s,t===this.stackSize-3&&(this.runStart[t+1]=this.runStart[t+2],this.runLength[t+1]=this.runLength[t+2]),this.stackSize--;let l=zh(r[a],r,o,i,0,e);o+=l,i-=l,i!==0&&(s=Vh(r[o+i-1],r,a,s,s-1,e),s!==0&&(i<=s?this.mergeLow(o,i,a,s):this.mergeHigh(o,i,a,s)))}mergeLow(t,e,r,o){let i=this.compare,a=this.array,s=this.tmp,l=0;for(l=0;l<e;l++)s[l]=a[t+l];let u=0,c=r,d=t;if(a[d++]=a[c++],--o===0){for(l=0;l<e;l++)a[d+l]=s[u+l];return}if(e===1){for(l=0;l<o;l++)a[d+l]=a[c+l];a[d+o]=s[u];return}let p=this.minGallop;for(;;){let f=0,h=0,m=!1;do if(i(a[c],s[u])<0){if(a[d++]=a[c++],h++,f=0,--o===0){m=!0;break}}else if(a[d++]=s[u++],f++,h=0,--e===1){m=!0;break}while((f|h)<p);if(m)break;do{if(f=zh(a[c],s,u,e,0,i),f!==0){for(l=0;l<f;l++)a[d+l]=s[u+l];if(d+=f,u+=f,e-=f,e<=1){m=!0;break}}if(a[d++]=a[c++],--o===0){m=!0;break}if(h=Vh(s[u],a,c,o,0,i),h!==0){for(l=0;l<h;l++)a[d+l]=a[c+l];if(d+=h,c+=h,o-=h,o===0){m=!0;break}}if(a[d++]=s[u++],--e===1){m=!0;break}p--}while(f>=7||h>=7);if(m)break;p<0&&(p=0),p+=2}if(this.minGallop=p,p<1&&(this.minGallop=1),e===1){for(l=0;l<o;l++)a[d+l]=a[c+l];a[d+o]=s[u]}else{if(e===0)throw new Error("mergeLow preconditions were not respected");for(l=0;l<e;l++)a[d+l]=s[u+l]}}mergeHigh(t,e,r,o){let i=this.compare,a=this.array,s=this.tmp,l=0;for(l=0;l<o;l++)s[l]=a[r+l];let u=t+e-1,c=o-1,d=r+o-1,p=0,f=0;if(a[d--]=a[u--],--e===0){for(p=d-(o-1),l=0;l<o;l++)a[p+l]=s[l];return}if(o===1){for(d-=e,u-=e,f=d+1,p=u+1,l=e-1;l>=0;l--)a[f+l]=a[p+l];a[d]=s[c];return}let h=this.minGallop;for(;;){let m=0,y=0,g=!1;do if(i(s[c],a[u])<0){if(a[d--]=a[u--],m++,y=0,--e===0){g=!0;break}}else if(a[d--]=s[c--],y++,m=0,--o===1){g=!0;break}while((m|y)<h);if(g)break;do{if(m=e-zh(s[c],a,t,e,e-1,i),m!==0){for(d-=m,u-=m,e-=m,f=d+1,p=u+1,l=m-1;l>=0;l--)a[f+l]=a[p+l];if(e===0){g=!0;break}}if(a[d--]=s[c--],--o===1){g=!0;break}if(y=o-Vh(a[u],s,0,o,o-1,i),y!==0){for(d-=y,c-=y,o-=y,f=d+1,p=c+1,l=0;l<y;l++)a[f+l]=s[p+l];if(o<=1){g=!0;break}}if(a[d--]=a[u--],--e===0){g=!0;break}h--}while(m>=7||y>=7);if(g)break;h<0&&(h=0),h+=2}if(this.minGallop=h,h<1&&(this.minGallop=1),o===1){for(d-=e,u-=e,f=d+1,p=u+1,l=e-1;l>=0;l--)a[f+l]=a[p+l];a[d]=s[c]}else{if(o===0)throw new Error("mergeHigh preconditions were not respected");for(p=d-(o-1),l=0;l<o;l++)a[p+l]=s[l]}}};function YS(n,t,e,r){if(!Array.isArray(n))throw new TypeError("Can only sort arrays");t?typeof t!="function"&&(r=e,e=t,t=qS):t=qS,e||(e=0),r||(r=n.length);let o=r-e;if(o<2)return;let i=0;if(o<32){i=WS(n,e,r,t),$S(n,e,r,e+i,t);return}let a=new Gh(n,t),s=qI(o);do{if(i=WS(n,e,r,t),i<s){let l=o;l>s&&(l=s),$S(n,e,e+l,e+i,t),i=l}a.pushRun(e,i),a.mergeRuns(),o-=i,e+=i}while(o!==0);a.forceMergeRuns()}function kh(n){let t=(0,$i.default)(new Int32Array(n.shape[0]),[n.shape[0]]),e=(0,$i.default)(new Int32Array(n.shape[0]),[n.shape[0]]);return ct.bands(t,n,1023),ct.lshifts(e,t,16),ct.bxoreq(t,e),ct.bandseq(t,4278190335),ct.lshifts(e,t,8),ct.bxoreq(t,e),ct.bandseq(t,50393103),ct.lshifts(e,t,4),ct.bxoreq(t,e),ct.bandseq(t,51130563),ct.lshifts(e,t,2),ct.bxoreq(t,e),ct.bandseq(t,153391689),t}function $I(n){let t=kh(n.pick(null,0)),e=kh(n.pick(null,1));ct.lshiftseq(e,1);let r=kh(n.pick(null,2));return ct.lshiftseq(r,2),ct.boreq(t,e),ct.boreq(t,r),t}function li(n,t){if(n.shape[0]!==t.shape[0])throw new Error("wrong length");let e=(0,$i.default)(new Float32Array(n.size),n.shape,n.stride,n.offset);for(let r=0;r<t.shape[0];r++){let o=t.get(r);if(n.shape.length>1)for(let i=0;i<n.shape[1];i++)e.set(r,i,n.get(o,i));else e.set(r,n.get(o))}return e}function Fh(n){let t=ct.sup(n),e=ct.inf(n),r=1e3/Math.min(1e3,t-e),o=(0,$i.default)(new Float32Array(n.data),n.shape);ct.mulseq(o,r);let i=(0,$i.default)(new Int32Array(o.data),n.shape),a=$I(i),l=Array.from(a.data).map((d,p)=>[d,p]);YS(l,(d,p)=>d[0]-p[0]);let u=l.map(([d,p])=>p);return(0,$i.default)(Uint32Array.from(u))}var so=class{constructor(t,e,r,o,i,a,s,l,u,c){this.propertyDescs=t,this.format=e,this.nsplats=r,this.xyz=o,this.colors=i,this.harmonics=a,this.opacity=s,this.scaling=l,this.rotation=u,this.maxSHDegree=c}getPlyBinary(){let t=so._generateHeaderString(this.propertyDescs,this.format,this.nsplats),e=new TextEncoder().encode(t),r=Object.keys(this.propertyDescs).length,o=(0,On.default)(new Float32Array(this.nsplats*r),[this.nsplats,r]);if(Ue.assign(o.pick(null,this.propertyDescs.x.index),this.xyz.pick(null,0)),Ue.assign(o.pick(null,this.propertyDescs.y.index),this.xyz.pick(null,1)),Ue.assign(o.pick(null,this.propertyDescs.z.index),this.xyz.pick(null,2)),Ue.assign(o.pick(null,this.propertyDescs.f_dc_0.index),this.colors.pick(null,0)),Ue.assign(o.pick(null,this.propertyDescs.f_dc_1.index),this.colors.pick(null,1)),Ue.assign(o.pick(null,this.propertyDescs.f_dc_2.index),this.colors.pick(null,2)),Ue.assign(o.pick(null,this.propertyDescs.opacity.index),this.opacity.pick(null,0)),Ue.assign(o.pick(null,this.propertyDescs.scale_0.index),this.scaling.pick(null,0)),Ue.assign(o.pick(null,this.propertyDescs.scale_1.index),this.scaling.pick(null,1)),Ue.assign(o.pick(null,this.propertyDescs.scale_2.index),this.scaling.pick(null,2)),Ue.assign(o.pick(null,this.propertyDescs.rot_0.index),this.rotation.pick(null,0)),Ue.assign(o.pick(null,this.propertyDescs.rot_1.index),this.rotation.pick(null,1)),Ue.assign(o.pick(null,this.propertyDescs.rot_2.index),this.rotation.pick(null,2)),Ue.assign(o.pick(null,this.propertyDescs.rot_3.index),this.rotation.pick(null,3)),this.harmonics&&this.harmonics.length>0)for(let s=0;s<this.harmonics.length;s++){let l=s*3;Ue.assign(o.pick(null,this.propertyDescs[`f_rest_${l}`].index),this.harmonics[s].pick(null,0)),Ue.assign(o.pick(null,this.propertyDescs[`f_rest_${l+1}`].index),this.harmonics[s].pick(null,1)),Ue.assign(o.pick(null,this.propertyDescs[`f_rest_${l+2}`].index),this.harmonics[s].pick(null,2))}let i=new Uint8Array(o.data.buffer),a=new Uint8Array(i.length+e.length);return a.set(e),a.set(i,e.length),a.buffer}save(t,e){let r=this.getPlyBinary(),o=new Blob([r],{type:"application/octet-stream"}),i=new File([o],t),a=new FormData;a.append("file",i),a.append("filename",t),a.append("basedir",e),fetch(`${jS}/push_file`,{method:"POST",body:a})}static async loadFile(t){return await(await fetch(t)).arrayBuffer()}mortonPositionSplatsSort(){let t=Fh(this.xyz),e=li(this.xyz,t),r=li(this.colors,t),o=li(this.opacity,t),i=li(this.scaling,t),a=li(this.rotation,t),s=[];for(let l=0;l<this.harmonics.length;l++)s.push(li(this.harmonics[l],t));return new so(this.propertyDescs,this.format,this.nsplats,e,r,s,o,i,a,this.maxSHDegree)}static _generateHeaderString(t,e,r){let o=`ply
3490
3491
  format ${e.format} ${e.version}
3491
3492
  element vertex ${r}`,i=Object.keys(t).length,a=Array(i);for(let s in t){let l=t[s];a[l.index]={name:s,dtype:l.dtype}}for(let s=0;s<a.length;s++)o=`${o}
3492
3493
  property ${a[s].dtype} ${a[s].name}`;return`${o}
3493
3494
  end_header
3494
- `}static fromArrayBuffer(t,e=3){let{splatCount:r,vertexData:o,propertiesDesc:i,format:a}=Qr.decodeHeader(t),s=o.buffer.slice(o.byteOffset),l=Object.keys(i).length,u=(0,yn.default)(new Float32Array(s),[r,l]),c=0,d={},p={double:8,int:4,uint:4,float:4,short:2,ushort:2,uchar:1};for(let v in i)if(i.hasOwnProperty(v)){let _=i[v].dtype;d[v]=c,c+=p[_]}let f=(0,yn.default)(new Float32Array(r*3),[r,3]);Be.assign(f.pick(null,0),u.pick(null,d.x/4)),Be.assign(f.pick(null,1),u.pick(null,d.y/4)),Be.assign(f.pick(null,2),u.pick(null,d.z/4));let h=(0,yn.default)(new Float32Array(r*3),[r,3]);Be.assign(h.pick(null,0),u.pick(null,d.scale_0/4)),Be.assign(h.pick(null,1),u.pick(null,d.scale_1/4)),Be.assign(h.pick(null,2),u.pick(null,d.scale_2/4));let m=(0,yn.default)(new Float32Array(r*3),[r,3]);Be.assign(m.pick(null,0),u.pick(null,d.f_dc_0/4)),Be.assign(m.pick(null,1),u.pick(null,d.f_dc_1/4)),Be.assign(m.pick(null,2),u.pick(null,d.f_dc_2/4));let y=(0,yn.default)(new Float32Array(r*4),[r,4]);Be.assign(y.pick(null,0),u.pick(null,d.rot_1/4)),Be.assign(y.pick(null,1),u.pick(null,d.rot_2/4)),Be.assign(y.pick(null,2),u.pick(null,d.rot_3/4)),Be.assign(y.pick(null,3),u.pick(null,d.rot_0/4));for(let v=0;v<r;v++){let _=y.pick(v,null),A=Math.sqrt(_.get(0)**2+_.get(1)**2+_.get(2)**2+_.get(3)**2);Be.divseq(_,A)}let g=(0,yn.default)(new Float32Array(r*1),[r,1]);Be.assign(g.pick(null,0),u.pick(null,d.opacity/4));let S=(Math.min(Math.max(e,0),3)+1)**2-1,w=[];for(let v=0;v<S;v++){let _=(0,yn.default)(new Float32Array(r*3),[r,3]),A=v*3;Be.assign(_.pick(null,0),u.pick(null,d[`f_rest_${A}`]/4)),Be.assign(_.pick(null,1),u.pick(null,d[`f_rest_${A+1}`]/4)),Be.assign(_.pick(null,2),u.pick(null,d[`f_rest_${A+2}`]/4)),w.push(_)}return new Qr(i,a,r,f,m,w,g,h,y,e)}static async fromPLYFile(t,e=3){let r=await Qr.loadFile(t);return Qr.fromArrayBuffer(r,e)}static decodeHeader(t){let e=new TextDecoder,r=0,o="",i=100;for(;;){if(r+i>=t.byteLength)throw new Error("End of file reached while searching for end of header");let h=new Uint8Array(t,r,i);o+=e.decode(h),r+=i;let m=r-i*2,y=new Uint8Array(t,Math.max(0,m),m>0?i*2:i);if(e.decode(y).includes("end_header"))break}let a=o.split(`
3495
- `),s=0,l={},u={},c=0,d;for(let h=0;h<a.length;h++){let m=a[h].trim();if(m.startsWith("element vertex")){let y=m.match(/\d+/);y&&(s=parseInt(y[0]))}else if(m.startsWith("property")){let y=m.match(/(\w+)\s+(\w+)\s+(\w+)/);if(y){let g=y[2],b=y[3];l[b]=c,u[b]={dtype:g,index:c},c++}}else if(m.startsWith("format")){let y=m.match(/(\w+)\s+(\w+)\s+(\d+\.?\d*)/);y&&(d={format:y[2],version:y[3]})}else if(m==="end_header")break}let p=o.indexOf("end_header")+10+1,f=new DataView(t,p);return{splatCount:s,vertexData:f,headerOffset:r,propertiesDesc:u,format:d}}};var Ei=class{constructor(t,e,r,o,i,a,s,l){this.config=t,this.xyz=e,this.scaling=r,this.color=o,this.opacity=i,this.harmonics=s,this.quaternion=a,this.variableChunkSize=l}get isDynamicChunks(){return this.variableChunkSize&&this.variableChunkSize.length>0}get nchunks(){return this.xyz.nchunks}get nsplats(){return this.xyz.length}get chunkSize(){return this.config.chunkSize}static compressFromGaussianData(t,e){let r=nt.fromArray(t.xyz,e.xyz,e.chunkSize),o=nt.fromArray(t.scaling,e.scaling,e.chunkSize),i=nt.fromArray(t.colors,e.color,e.chunkSize),a=nt.fromArray(t.opacity,e.opacity,e.chunkSize),s=nt.fromArray(t.rotation,e.quaternion,e.chunkSize),l=t.harmonics,u=[];if(e.harmonics)for(let c=0;c<l.length;c++){let d=nt.fromArray(l[c],e.harmonics,e.chunkSize);u.push(d)}return new Ei(e,r,o,i,a,s,u)}_countIndexesInChunks(t){let e=[],r=this.nchunks,o=this.chunkSize,i=this.nsplats,a=nt.getRequiredNChunks(i,o);if(r===a)for(let s=0;s<t.length;s++){let l=t[s],u=Math.floor(l/this.chunkSize);u in e?e[u].push(l):e[u]=[l]}else{let s=this.variableChunkSize,l={},u=0;for(let c=0;c<r;c++)l[c]=u,u+=s[c];for(let c=0;c<t.length;c++){let d=t[c],p=Math.min(Math.floor(d/o),r-1);for(;d>=l[p]+s[p];)p++;p in e?e[p].push(d):e[p]=[d]}}return e}pruneSplats(t){let e=this._countIndexesInChunks(t),r,o=[];return e.length>0&&(r=this.variableChunkSize?[...this.variableChunkSize]:Array(this.nchunks).fill(this.chunkSize),e.forEach((i,a)=>{r[a]-=i.length,r[a]<=0&&o.push(a)}),r=r.filter(i=>i>0)),new Ei(this.config,this.xyz.pruneFeature(t,o,r),this.scaling.pruneFeature(t,o,r),this.color.pruneFeature(t,o,r),this.opacity.pruneFeature(t,o,r),this.quaternion.pruneFeature(t,o,r),this.harmonics?this.harmonics.map(i=>i.pruneFeature(t,o,this.variableChunkSize)):void 0,r)}static async loadConfig(t){return await(await fetch(t,{method:"GET",mode:"cors",headers:{Accept:"application/json"}})).json()}toGaussians(){let t={format:"binary_little_endian",version:"1.0"},e={},r=0;if(e.x={dtype:"float",index:r},r++,e.y={dtype:"float",index:r},r++,e.z={dtype:"float",index:r},r++,e.f_dc_0={dtype:"float",index:r},r++,e.f_dc_1={dtype:"float",index:r},r++,e.f_dc_2={dtype:"float",index:r},r++,this.harmonics&&this.harmonics.length>0)for(let a=0;a<this.harmonics.length;a++)e[`f_rest_${a}`]={dtype:"float",index:r},r++,e[`f_rest_${a+1}`]={dtype:"float",index:r},r++,e[`f_rest_${a+2}`]={dtype:"float",index:r},r++;e.opacity={dtype:"float",index:r},r++,e.scale_0={dtype:"float",index:r},r++,e.scale_1={dtype:"float",index:r},r++,e.scale_2={dtype:"float",index:r},r++,e.rot_0={dtype:"float",index:r},r++,e.rot_1={dtype:"float",index:r},r++,e.rot_2={dtype:"float",index:r},r++,e.rot_3={dtype:"float",index:r},r++;let o=this.harmonics?.map(a=>a.denormDequant());return new Qr(e,t,this.xyz.length,this.xyz.denormDequant(),this.color.denormDequant(),o||[],this.opacity.denormDequant(),this.scaling.denormDequant(),this.quaternion.denormDequant(),3)}};var Bi=nr(Gs()),It=nr(ks());var Jn=require("three"),rS={xyz:3,color:3,opacity:1,scaling:3,quaternion:4,harmonics:3},ei=class{constructor(t){this._buffer=t}get buffer(){return this._buffer}get decoded(){return this._decoded||(this._decoded=this.decodeBuffer()),this._decoded}get colorsA(){let t=.28209479177387814,e=this.decoded.color.denormDequant(),r=this.decoded.opacity.denormDequant(),o=(0,Bi.default)(new Float32Array(e.shape[0]*4),[e.shape[0],4]);return It.mulseq(e,t),It.addseq(e,.5),It.mulseq(e,255),It.maxseq(e,0),It.minseq(e,255),It.negeq(r),It.expeq(r),It.addseq(r,1),It.recipeq(r),It.mulseq(r,255),It.assign(o.hi(e.shape[0],3).lo(0,0),e),It.assign(o.hi(e.shape[0],4).lo(0,3),r),(0,Bi.default)(new Uint8Array(o.data),[e.shape[0],4]).data}get nsplats(){return this.decoded.nsplats}getSplatCount(){return this.decoded.nsplats}get precomputedCovarianceBufferData(){return this._precomputedCovarianceBufferData}decodeBuffer(){let{splatCount:t,chunkCount:e,chunkSize:r,typeChunks:o,vertexData:i,propertiesDesc:a}=this.decodeHeader(),s={xyz:a.xyz.compressionMethod,color:a.color.compressionMethod,opacity:a.opacity.compressionMethod,scaling:a.scaling.compressionMethod,quaternion:a.quaternion.compressionMethod,chunkSize:r};a.harmonics_0&&(s.harmonics=a.harmonics_0.compressionMethod);let l=i.byteOffset,u=Array(Object.keys(a).length);for(let g in a)u[a[g].index]={name:g,method:a[g].compressionMethod};let c=e*2*4,d=l,p=o==="dynamic"?e*2:0,f,h=!1;if(p>0){let g=new Uint16Array(i.buffer.slice(d,d+p));d+=p,f=Array.from(g),h=!0}let m={};for(let g of u){let b=0,S=!0;if(g.method==="norm8x")b=t*1*rS[g.name];else if(g.method==="norm11")b=t*4;else if(g.method==="norm565")b=t*2;else throw S=!1,new Error(`Not Implemented format: ${g.method}`);let w;if(S){let A=i.buffer.slice(d,d+c);w=(0,Bi.default)(new Float32Array(A),[e,2]),d+=c}else throw new Error("loading chunk byt hasnot minmax!");let v=i.buffer.slice(d,d+b);d+=b;let _;if(g.method==="norm8x")_=(0,Bi.default)(new Uint8Array(v),[t,rS[g.name]]);else if(g.method==="norm11")_=(0,Bi.default)(new Uint32Array(v));else if(g.method==="norm565")_=(0,Bi.default)(new Uint16Array(v));else throw new Error(`Not Implemented format: ${g.method}`);m[g.name]=new nt(_,w,r,g.method,f,h)}let y=[];for(let g=0;g<15;g++){let b=m[`harmonics_${g}`];b&&(y.push(b),delete m[`harmonics_${g}`])}return y.length>0&&(m.harmonics=y),new Ei(s,m.xyz,m.scaling,m.color,m.opacity,m.quaternion,m.harmonics,f)}buildPreComputedBuffers(){let r=this.decoded,o=r.nsplats,i=new ArrayBuffer(24*o),a=new Float32Array(i),s=r.scaling.denormDequant(),l=r.quaternion.denormDequant(),u=new Jn.Quaternion,c=new Jn.Matrix3,d=new Jn.Matrix3,p=new Jn.Matrix3,f=new Jn.Matrix4;for(let h=0;h<o;h++){f.makeScale(Math.exp(s.get(h,0)),Math.exp(s.get(h,1)),Math.exp(s.get(h,2))),d.setFromMatrix4(f),u.set(l.get(h,0),l.get(h,1),l.get(h,2),l.get(h,3)),f.makeRotationFromQuaternion(u),c.setFromMatrix4(f),p.copy(c).multiply(d);let m=p.elements;a[6*h]=m[0]*m[0]+m[3]*m[3]+m[6]*m[6],a[6*h+1]=m[0]*m[1]+m[3]*m[4]+m[6]*m[7],a[6*h+2]=m[0]*m[2]+m[3]*m[5]+m[6]*m[8],a[6*h+3]=m[1]*m[1]+m[4]*m[4]+m[7]*m[7],a[6*h+4]=m[1]*m[2]+m[4]*m[5]+m[7]*m[8],a[6*h+5]=m[2]*m[2]+m[5]*m[5]+m[8]*m[8]}this._precomputedCovarianceBufferData=i}decodeHeader(){let t=this._buffer,e=new TextDecoder,r=0,o="",i=100;for(;;){if(r+i>=t.byteLength)throw new Error("End of file reached while searching for end of header");let m=new Uint8Array(t,r,i);o+=e.decode(m),r+=i;let y=r-i*2,g=new Uint8Array(t,Math.max(0,y),y>=0?i*2:i);if(e.decode(g).includes("end_header"))break}let a=o.split(`
3496
- `),s=0,l=0,u=0,c=0,d="",p={};for(let m=0;m<a.length;m++){let y=a[m].trim();if(y.startsWith("element vertex")){let g=y.match(/\d+/);g&&(s=parseInt(g[0]))}else if(y.startsWith("property")){let g=y.match(/(\w+)\s+(\w+)\s+(\w+)/);if(g){let b=g[2],S=g[3];p[b]={compressionMethod:S,index:c},c++}}else if(y.startsWith("element chunks")){let g=y.match(/\d+/);g&&(l=parseInt(g[0]))}else if(y.startsWith("element chunkSize")){let g=y.match(/\d+/);g&&(u=parseInt(g[0]))}else if(y.startsWith("element typeChunks")){let g=y.match(/(\w+)\s+(\w+)\s+(\w+)/);g&&(d=g[3])}else if(y==="end_header")break}let f=o.indexOf("end_header")+10+1,h=new DataView(t,f);return{splatCount:s,chunkCount:l,chunkSize:u,typeChunks:d,vertexData:h,propertiesDesc:p}}pruneSplats(t){let r=this.decodeBuffer().pruneSplats(t);return ei.fromCompressedGaussianSplats(r)}static fromCompressedGaussianSplats(t){let e=t.xyz.length,r=t.xyz.nchunks,o=`gspline
3495
+ `}static fromArrayBuffer(t,e=3){let{splatCount:r,vertexData:o,propertiesDesc:i,format:a}=so.decodeHeader(t),s=o.buffer.slice(o.byteOffset),l=Object.keys(i).length,u=(0,On.default)(new Float32Array(s),[r,l]),c=0,d={},p={double:8,int:4,uint:4,float:4,short:2,ushort:2,uchar:1};for(let S in i)if(i.hasOwnProperty(S)){let P=i[S].dtype;d[S]=c,c+=p[P]}let f=(0,On.default)(new Float32Array(r*3),[r,3]);Ue.assign(f.pick(null,0),u.pick(null,d.x/4)),Ue.assign(f.pick(null,1),u.pick(null,d.y/4)),Ue.assign(f.pick(null,2),u.pick(null,d.z/4));let h=(0,On.default)(new Float32Array(r*3),[r,3]);Ue.assign(h.pick(null,0),u.pick(null,d.scale_0/4)),Ue.assign(h.pick(null,1),u.pick(null,d.scale_1/4)),Ue.assign(h.pick(null,2),u.pick(null,d.scale_2/4));let m=(0,On.default)(new Float32Array(r*3),[r,3]);Ue.assign(m.pick(null,0),u.pick(null,d.f_dc_0/4)),Ue.assign(m.pick(null,1),u.pick(null,d.f_dc_1/4)),Ue.assign(m.pick(null,2),u.pick(null,d.f_dc_2/4));let y=(0,On.default)(new Float32Array(r*4),[r,4]);Ue.assign(y.pick(null,0),u.pick(null,d.rot_1/4)),Ue.assign(y.pick(null,1),u.pick(null,d.rot_2/4)),Ue.assign(y.pick(null,2),u.pick(null,d.rot_3/4)),Ue.assign(y.pick(null,3),u.pick(null,d.rot_0/4));for(let S=0;S<r;S++){let P=y.pick(S,null),O=Math.sqrt(P.get(0)**2+P.get(1)**2+P.get(2)**2+P.get(3)**2);Ue.divseq(P,O)}let g=(0,On.default)(new Float32Array(r*1),[r,1]);Ue.assign(g.pick(null,0),u.pick(null,d.opacity/4));let w=(Math.min(Math.max(e,0),3)+1)**2-1,_=[];for(let S=0;S<w;S++){let P=(0,On.default)(new Float32Array(r*3),[r,3]),O=S*3;Ue.assign(P.pick(null,0),u.pick(null,d[`f_rest_${O}`]/4)),Ue.assign(P.pick(null,1),u.pick(null,d[`f_rest_${O+1}`]/4)),Ue.assign(P.pick(null,2),u.pick(null,d[`f_rest_${O+2}`]/4)),_.push(P)}return new so(i,a,r,f,m,_,g,h,y,e)}static async fromPLYFile(t,e=3){let r=await so.loadFile(t);return so.fromArrayBuffer(r,e)}static decodeHeader(t){let e=new TextDecoder,r=0,o="",i=100;for(;;){if(r+i>=t.byteLength)throw new Error("End of file reached while searching for end of header");let h=new Uint8Array(t,r,i);o+=e.decode(h),r+=i;let m=r-i*2,y=new Uint8Array(t,Math.max(0,m),m>0?i*2:i);if(e.decode(y).includes("end_header"))break}let a=o.split(`
3496
+ `),s=0,l={},u={},c=0,d;for(let h=0;h<a.length;h++){let m=a[h].trim();if(m.startsWith("element vertex")){let y=m.match(/\d+/);y&&(s=parseInt(y[0]))}else if(m.startsWith("property")){let y=m.match(/(\w+)\s+(\w+)\s+(\w+)/);if(y){let g=y[2],b=y[3];l[b]=c,u[b]={dtype:g,index:c},c++}}else if(m.startsWith("format")){let y=m.match(/(\w+)\s+(\w+)\s+(\d+\.?\d*)/);y&&(d={format:y[2],version:y[3]})}else if(m==="end_header")break}let p=o.indexOf("end_header")+10+1,f=new DataView(t,p);return{splatCount:s,vertexData:f,headerOffset:r,propertiesDesc:u,format:d}}};var Yi=class{constructor(t,e,r,o,i,a,s,l){this.config=t,this.xyz=e,this.scaling=r,this.color=o,this.opacity=i,this.harmonics=s,this.quaternion=a,this.variableChunkSize=l}get isDynamicChunks(){return this.variableChunkSize&&this.variableChunkSize.length>0}get nchunks(){return this.xyz.nchunks}get nsplats(){return this.xyz.length}get chunkSize(){return this.config.chunkSize}static compressFromGaussianData(t,e){let r=ft.fromArray(t.xyz,e.xyz,e.chunkSize),o=ft.fromArray(t.scaling,e.scaling,e.chunkSize),i=ft.fromArray(t.colors,e.color,e.chunkSize),a=ft.fromArray(t.opacity,e.opacity,e.chunkSize),s=ft.fromArray(t.rotation,e.quaternion,e.chunkSize),l=t.harmonics,u=[];if(e.harmonics)for(let c=0;c<l.length;c++){let d=ft.fromArray(l[c],e.harmonics,e.chunkSize);u.push(d)}return new Yi(e,r,o,i,a,s,u)}_countIndexesInChunks(t){let e=[],r=this.nchunks,o=this.chunkSize,i=this.nsplats,a=ft.getRequiredNChunks(i,o);if(r===a)for(let s=0;s<t.length;s++){let l=t[s],u=Math.floor(l/this.chunkSize);u in e?e[u].push(l):e[u]=[l]}else{let s=this.variableChunkSize,l={},u=0;for(let c=0;c<r;c++)l[c]=u,u+=s[c];for(let c=0;c<t.length;c++){let d=t[c],p=Math.min(Math.floor(d/o),r-1);for(;d>=l[p]+s[p];)p++;p in e?e[p].push(d):e[p]=[d]}}return e}pruneSplats(t){let e=this._countIndexesInChunks(t),r,o=[];return e.length>0&&(r=this.variableChunkSize?[...this.variableChunkSize]:Array(this.nchunks).fill(this.chunkSize),e.forEach((i,a)=>{r[a]-=i.length,r[a]<=0&&o.push(a)}),r=r.filter(i=>i>0)),new Yi(this.config,this.xyz.pruneFeature(t,o,r),this.scaling.pruneFeature(t,o,r),this.color.pruneFeature(t,o,r),this.opacity.pruneFeature(t,o,r),this.quaternion.pruneFeature(t,o,r),this.harmonics?this.harmonics.map(i=>i.pruneFeature(t,o,this.variableChunkSize)):void 0,r)}static async loadConfig(t){return await(await fetch(t,{method:"GET",mode:"cors",headers:{Accept:"application/json"}})).json()}toGaussians(){let t={format:"binary_little_endian",version:"1.0"},e={},r=0;if(e.x={dtype:"float",index:r},r++,e.y={dtype:"float",index:r},r++,e.z={dtype:"float",index:r},r++,e.f_dc_0={dtype:"float",index:r},r++,e.f_dc_1={dtype:"float",index:r},r++,e.f_dc_2={dtype:"float",index:r},r++,this.harmonics&&this.harmonics.length>0)for(let a=0;a<this.harmonics.length;a++)e[`f_rest_${a}`]={dtype:"float",index:r},r++,e[`f_rest_${a+1}`]={dtype:"float",index:r},r++,e[`f_rest_${a+2}`]={dtype:"float",index:r},r++;e.opacity={dtype:"float",index:r},r++,e.scale_0={dtype:"float",index:r},r++,e.scale_1={dtype:"float",index:r},r++,e.scale_2={dtype:"float",index:r},r++,e.rot_0={dtype:"float",index:r},r++,e.rot_1={dtype:"float",index:r},r++,e.rot_2={dtype:"float",index:r},r++,e.rot_3={dtype:"float",index:r},r++;let o=this.harmonics?.map(a=>a.denormDequant());return new so(e,t,this.xyz.length,this.xyz.denormDequant(),this.color.denormDequant(),o||[],this.opacity.denormDequant(),this.scaling.denormDequant(),this.quaternion.denormDequant(),3)}};var Xi=hr(al()),Ft=hr(sl());var ci=require("three"),XS={xyz:3,color:3,opacity:1,scaling:3,quaternion:4,harmonics:3},ui=class{constructor(t){this._buffer=t}get buffer(){return this._buffer}get decoded(){return this._decoded||(this._decoded=this.decodeBuffer()),this._decoded}get colorsA(){let t=.28209479177387814,e=this.decoded.color.denormDequant(),r=this.decoded.opacity.denormDequant(),o=(0,Xi.default)(new Float32Array(e.shape[0]*4),[e.shape[0],4]);return Ft.mulseq(e,t),Ft.addseq(e,.5),Ft.mulseq(e,255),Ft.maxseq(e,0),Ft.minseq(e,255),Ft.negeq(r),Ft.expeq(r),Ft.addseq(r,1),Ft.recipeq(r),Ft.mulseq(r,255),Ft.assign(o.hi(e.shape[0],3).lo(0,0),e),Ft.assign(o.hi(e.shape[0],4).lo(0,3),r),(0,Xi.default)(new Uint8Array(o.data),[e.shape[0],4]).data}get nsplats(){return this.decoded.nsplats}getSplatCount(){return this.decoded.nsplats}get precomputedCovarianceBufferData(){return this._precomputedCovarianceBufferData}decodeBuffer(){let{splatCount:t,chunkCount:e,chunkSize:r,typeChunks:o,vertexData:i,propertiesDesc:a}=this.decodeHeader(),s={xyz:a.xyz.compressionMethod,color:a.color.compressionMethod,opacity:a.opacity.compressionMethod,scaling:a.scaling.compressionMethod,quaternion:a.quaternion.compressionMethod,chunkSize:r};a.harmonics_0&&(s.harmonics=a.harmonics_0.compressionMethod);let l=i.byteOffset,u=Array(Object.keys(a).length);for(let g in a)u[a[g].index]={name:g,method:a[g].compressionMethod};let c=e*2*4,d=l,p=o==="dynamic"?e*2:0,f,h=!1;if(p>0){let g=new Uint16Array(i.buffer.slice(d,d+p));d+=p,f=Array.from(g),h=!0}let m={};for(let g of u){let b=0,w=!0;if(g.method==="norm8x")b=t*1*XS[g.name];else if(g.method==="norm11")b=t*4;else if(g.method==="norm565")b=t*2;else throw w=!1,new Error(`Not Implemented format: ${g.method}`);let _;if(w){let O=i.buffer.slice(d,d+c);_=(0,Xi.default)(new Float32Array(O),[e,2]),d+=c}else throw new Error("loading chunk byt hasnot minmax!");let S=i.buffer.slice(d,d+b);d+=b;let P;if(g.method==="norm8x")P=(0,Xi.default)(new Uint8Array(S),[t,XS[g.name]]);else if(g.method==="norm11")P=(0,Xi.default)(new Uint32Array(S));else if(g.method==="norm565")P=(0,Xi.default)(new Uint16Array(S));else throw new Error(`Not Implemented format: ${g.method}`);m[g.name]=new ft(P,_,r,g.method,f,h)}let y=[];for(let g=0;g<15;g++){let b=m[`harmonics_${g}`];b&&(y.push(b),delete m[`harmonics_${g}`])}return y.length>0&&(m.harmonics=y),new Yi(s,m.xyz,m.scaling,m.color,m.opacity,m.quaternion,m.harmonics,f)}buildPreComputedBuffers(){let r=this.decoded,o=r.nsplats,i=new ArrayBuffer(24*o),a=new Float32Array(i),s=r.scaling.denormDequant(),l=r.quaternion.denormDequant(),u=new ci.Quaternion,c=new ci.Matrix3,d=new ci.Matrix3,p=new ci.Matrix3,f=new ci.Matrix4;for(let h=0;h<o;h++){f.makeScale(Math.exp(s.get(h,0)),Math.exp(s.get(h,1)),Math.exp(s.get(h,2))),d.setFromMatrix4(f),u.set(l.get(h,0),l.get(h,1),l.get(h,2),l.get(h,3)),f.makeRotationFromQuaternion(u),c.setFromMatrix4(f),p.copy(c).multiply(d);let m=p.elements;a[6*h]=m[0]*m[0]+m[3]*m[3]+m[6]*m[6],a[6*h+1]=m[0]*m[1]+m[3]*m[4]+m[6]*m[7],a[6*h+2]=m[0]*m[2]+m[3]*m[5]+m[6]*m[8],a[6*h+3]=m[1]*m[1]+m[4]*m[4]+m[7]*m[7],a[6*h+4]=m[1]*m[2]+m[4]*m[5]+m[7]*m[8],a[6*h+5]=m[2]*m[2]+m[5]*m[5]+m[8]*m[8]}this._precomputedCovarianceBufferData=i}decodeHeader(){let t=this._buffer,e=new TextDecoder,r=0,o="",i=100;for(;;){if(r+i>=t.byteLength)throw new Error("End of file reached while searching for end of header");let m=new Uint8Array(t,r,i);o+=e.decode(m),r+=i;let y=r-i*2,g=new Uint8Array(t,Math.max(0,y),y>=0?i*2:i);if(e.decode(g).includes("end_header"))break}let a=o.split(`
3497
+ `),s=0,l=0,u=0,c=0,d="",p={};for(let m=0;m<a.length;m++){let y=a[m].trim();if(y.startsWith("element vertex")){let g=y.match(/\d+/);g&&(s=parseInt(g[0]))}else if(y.startsWith("property")){let g=y.match(/(\w+)\s+(\w+)\s+(\w+)/);if(g){let b=g[2],w=g[3];p[b]={compressionMethod:w,index:c},c++}}else if(y.startsWith("element chunks")){let g=y.match(/\d+/);g&&(l=parseInt(g[0]))}else if(y.startsWith("element chunkSize")){let g=y.match(/\d+/);g&&(u=parseInt(g[0]))}else if(y.startsWith("element typeChunks")){let g=y.match(/(\w+)\s+(\w+)\s+(\w+)/);g&&(d=g[3])}else if(y==="end_header")break}let f=o.indexOf("end_header")+10+1,h=new DataView(t,f);return{splatCount:s,chunkCount:l,chunkSize:u,typeChunks:d,vertexData:h,propertiesDesc:p}}pruneSplats(t){let r=this.decodeBuffer().pruneSplats(t);return ui.fromCompressedGaussianSplats(r)}static fromCompressedGaussianSplats(t){let e=t.xyz.length,r=t.xyz.nchunks,o=`gspline
3497
3498
  element vertex ${e}
3498
3499
  element chunks ${r}
3499
3500
  element chunkSize ${t.chunkSize}
@@ -3502,10 +3503,10 @@ property xyz ${t.xyz.method}
3502
3503
  property color ${t.color.method}
3503
3504
  property opacity ${t.opacity.method}
3504
3505
  property scaling ${t.scaling.method}
3505
- property quaternion ${t.quaternion.method}`;if(t.harmonics&&t.harmonics.length>0)for(let T=0;T<t.harmonics.length;T++)o=`${o}
3506
- property harmonics_${T} ${t.harmonics[T].method}`;o=`${o}
3506
+ property quaternion ${t.quaternion.method}`;if(t.harmonics&&t.harmonics.length>0)for(let D=0;D<t.harmonics.length;D++)o=`${o}
3507
+ property harmonics_${D} ${t.harmonics[D].method}`;o=`${o}
3507
3508
  end_header
3508
- `;let a=new TextEncoder().encode(o),s=r*2*4,l=t.xyz.quantized.data.buffer.byteLength,u=t.xyz instanceof nt?s:0,c=t.color.quantized.data.buffer.byteLength,d=t.color instanceof nt?s:0,p=t.opacity.quantized.data.buffer.byteLength,f=t.opacity instanceof nt?s:0,h=t.scaling.quantized.data.buffer.byteLength,m=t.scaling instanceof nt?s:0,y=t.quaternion.quantized.data.buffer.byteLength,g=t.quaternion instanceof nt?s:0,b=t.variableChunkSize?Uint16Array.from(t.variableChunkSize):void 0,S=b?b.byteLength:0,w=a.byteLength+S+l+u+c+d+p+f+h+m+y+g,v=0,_=0;if(t.harmonics&&t.harmonics.length>0)for(let T=0;T<t.harmonics.length;T++)v+=t.harmonics[T].quantized.data.buffer.byteLength,_+=t.harmonics[T]instanceof nt?s:0;v=0,_=0,w+=v+_;let A=new Uint8Array(w),x=0;if(A.set(a,x),x+=a.byteLength,S>0&&(A.set(new Uint8Array(b.buffer),x),x+=S),t.xyz instanceof nt&&(A.set(new Uint8Array(t.xyz.minmaxMatrix.data.buffer),x),x+=s),A.set(new Uint8Array(t.xyz.quantized.data.buffer),x),x+=l,t.color instanceof nt&&(A.set(new Uint8Array(t.color.minmaxMatrix.data.buffer),x),x+=s),A.set(new Uint8Array(t.color.quantized.data.buffer),x),x+=c,t.opacity instanceof nt&&(A.set(new Uint8Array(t.opacity.minmaxMatrix.data.buffer),x),x+=s),A.set(new Uint8Array(t.opacity.quantized.data.buffer),x),x+=p,t.scaling instanceof nt&&(A.set(new Uint8Array(t.scaling.minmaxMatrix.data.buffer),x),x+=s),A.set(new Uint8Array(t.scaling.quantized.data.buffer),x),x+=h,t.quaternion instanceof nt&&(A.set(new Uint8Array(t.quaternion.minmaxMatrix.data.buffer),x),x+=s),A.set(new Uint8Array(t.quaternion.quantized.data.buffer),x),x+=y,v>0&&t.harmonics&&t.harmonics.length>0)for(let T=0;T<t.harmonics.length;T++){let C=t.harmonics[T];C instanceof nt&&(A.set(new Uint8Array(C.minmaxMatrix.data.buffer),x),x+=s),A.set(new Uint8Array(C.quantized.data.buffer),x),x+=C.quantized.data.byteLength}return new ei(A.buffer)}};var oS="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL";var Fo=class{};Gt(Fo,"DepthMapRange",1<<16),Gt(Fo,"MemoryPageSize",65536),Gt(Fo,"BytesPerFloat",4),Gt(Fo,"BytesPerInt",4);function jM(n){let t,e,r,o,i,a,s,l,u,c,d,p,f,h,m,y;function g(P){let O=new Float64Array(c,a,16);for(let I=0;I<16;I++)O[I]=P[I];let M;if(r>1){t.exports.sortIndexes(o,i,u,a,s,l,p.DepthMapRange,r);let I=new Uint32Array(r);M=I.buffer,I.set(new Uint32Array(c,l,r))}else if(r===1){let I=new Uint32Array(r);I[0]=new Uint32Array(c,o,e)[0],M=I.buffer}else M=new ArrayBuffer(0);n.postMessage({sortDone:!0,indexesBuffer:M},[M])}function b(P,O,M){let I=new Float32Array(c,i,e*3);r=0;let N=new Uint32Array(c,o,e);for(let B=0;B<M.length-1;B++){let D=O[B],G=P[B].elements,L=D.filter(z=>z.enabled&&z.mode==="Include").map(z=>z.type==="Box"?_(z):T(z)),V=D.filter(z=>z.enabled&&z.mode==="Exclude").map(z=>z.type==="Box"?_(z):T(z));for(let z=M[B];z<M[B+1];z++){let F=f[z*3],$=f[z*3+1],q=f[z*3+2];if((L.length===0||w(F,$,q,L))&&(V.length===0||!w(F,$,q,V))){let H=1/(G[3]*F+G[7]*$+G[11]*q+G[15]);I[r*3]=(G[0]*F+G[4]*$+G[8]*q+G[12])*H,I[r*3+1]=(G[1]*F+G[5]*$+G[9]*q+G[13])*H,I[r*3+2]=(G[2]*F+G[6]*$+G[10]*q+G[14])*H,N[r]=z,r++}}}}function S(P,O){let M=[],I=O.filter(D=>D.enabled&&D.mode==="Include").map(D=>D.type==="Box"?_(D):T(D)),N=O.filter(D=>D.enabled&&D.mode==="Exclude").map(D=>D.type==="Box"?_(D):T(D)),B=P.length;for(let D=0;D<B;D+=3){let G=P[D],L=P[D+1],V=P[D+2];(I.length===0||w(G,L,V,I))&&(N.length===0||!w(G,L,V,N))||M.push(D/3)}return console.log(M),M}function w(P,O,M,I,N){return I[N==="Intersect"?"every":"some"](B=>{let D=v(P,O,M,B.invRotationMatrix,B.cropCenter);return Array.isArray(B)?x(D.x,D.y,D.z,B):C(D.x,D.y,D.z,B)})}function v(P,O,M,I,N){let B=P-N[0],D=O-N[1],G=M-N[2],L=1/(I[3]*B+I[7]*D+I[11]*G+I[15]);return{x:(I[0]*B+I[4]*D+I[8]*G+I[12])*L+N[0],y:(I[1]*B+I[5]*D+I[9]*G+I[13])*L+N[1],z:(I[2]*B+I[6]*D+I[10]*G+I[14])*L+N[2]}}function _(P){let O=P.cropSize[0]/2,M=P.cropSize[1]/2,I=P.cropSize[2]/2,N=[P.cropCenter[0]-O,P.cropCenter[1]-M,P.cropCenter[2]-I,P.cropCenter[0]+O,P.cropCenter[1]+M,P.cropCenter[2]+I],B=A(P.cropRotation);return Object.assign(N,{invRotationMatrix:B,cropCenter:P.cropCenter})}function A(P){let O=[],M=P[0]*Math.PI/180,I=P[1]*Math.PI/180,N=P[2]*Math.PI/180,B=Math.cos(M),D=Math.sin(M),G=Math.cos(I),L=Math.sin(I),V=Math.cos(N),z=Math.sin(N),F=B*V,$=B*z,q=D*V,H=D*z;return O[0]=G*V,O[1]=-G*z,O[2]=L,O[4]=$+q*L,O[5]=F-H*L,O[6]=-D*G,O[8]=H-F*L,O[9]=q+$*L,O[10]=B*G,O[12]=0,O[13]=0,O[14]=0,O[3]=0,O[7]=0,O[11]=0,O[15]=1,O}function x(P,O,M,I){return P>=I[0]&&P<=I[3]&&O>=I[1]&&O<=I[4]&&M>=I[2]&&M<=I[5]}function T(P){let O=2/P.cropSize[0],M=2/P.cropSize[1],I=2/P.cropSize[2],N=A(P.cropRotation);return{invRadiusX:O,invRadiusY:M,invRadiusZ:I,cropCenter:P.cropCenter,invRotationMatrix:N}}function C(P,O,M,I){let N=(P-I.cropCenter[0])*I.invRadiusX,B=(O-I.cropCenter[1])*I.invRadiusY,D=(M-I.cropCenter[2])*I.invRadiusZ;return N*N+B*B+D*D<=1}n.onmessage=P=>{if(P.data.getCroppedIndexes){let O=new Uint32Array(S(new Float32Array(P.data.positions),P.data.crops)).buffer;n.postMessage({outOfBoundsIndexes:O},[O])}else if(P.data.positions)d=P.data.positions,f=new Float32Array(d),m=P.data.meshMatrixWorlds,y=P.data.cropsArray,h=P.data.meshIndexIntervals,b(m,y,h),n.postMessage({sortSetupComplete:!0});else if(P.data.sort||P.data.newMatrixWorlds||P.data.newCropsArray)(P.data.newMatrixWorlds||P.data.newCropsArray)&&(y=P.data.newCropsArray||y,m=P.data.newMatrixWorlds||m,b(m,y,h)),g(P.data.sort.view,P.data.sort.cameraPosition);else if(P.data.init){p=P.data.init.Constants,e=P.data.init.splatCount;let O=p.BytesPerInt,M=p.BytesPerFloat*3,I=new Uint8Array(P.data.init.sorterWasmBytes),N=O+M,B=e*N,D=e*p.BytesPerInt*2+p.DepthMapRange*p.BytesPerInt*2,G=p.MemoryPageSize*32,L=B+D+G,V=Math.floor(L/p.MemoryPageSize)+1,z={module:{},env:{memory:new WebAssembly.Memory({initial:V*2,maximum:V*3,shared:!0})}};WebAssembly.compile(I).then(F=>WebAssembly.instantiate(F,z)).then(F=>{t=F,o=0,i=e*O,a=i+e*M,u=a+16*p.BytesPerFloat*2,s=u+e*p.BytesPerInt,l=s+p.DepthMapRange*p.BytesPerInt,c=z.env.memory.buffer,n.postMessage({sortSetupPhase1Complete:!0})})}}}function nS(n){let t=new Worker(URL.createObjectURL(new Blob(["(",jM.toString(),")(self)"],{type:"application/javascript"}))),e=atob(oS),r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e.charCodeAt(o);return t.postMessage({init:{sorterWasmBytes:r.buffer,splatCount:n,Constants:{BytesPerFloat:Fo.BytesPerFloat,BytesPerInt:Fo.BytesPerInt,DepthMapRange:Fo.DepthMapRange,MemoryPageSize:Fo.MemoryPageSize}}}),t}var Pr=require("three");var be=require("three");var Pd=function(){let n=new Float32Array(1),t=new Int32Array(n.buffer);return function(e){return n[0]=e,t[0]}}(),iS=function(n,t,e,r){return n+(t<<8)+(e<<16)+(r<<24)};var Od=new be.Vector2,ti=class extends be.Mesh{constructor(e,r,o,i,a=!1,s=1,l,u){super(o,i);this.splatCount=r,this.meshIndexIntervals=l,this.meshMatrixWorlds=u,this.splatBuffers=e,this.geometry=o,this.material=i,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=a,this.devicePixelRatio=s,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,r,o=!1,i=1,a,s){let l=ti.buildGeomtery(r),u=ti.buildMaterial(a);return new ti(e,r,l,u,o,i,a,s)}static buildMaterial(e){let r=`
3509
+ `;let a=new TextEncoder().encode(o),s=r*2*4,l=t.xyz.quantized.data.buffer.byteLength,u=t.xyz instanceof ft?s:0,c=t.color.quantized.data.buffer.byteLength,d=t.color instanceof ft?s:0,p=t.opacity.quantized.data.buffer.byteLength,f=t.opacity instanceof ft?s:0,h=t.scaling.quantized.data.buffer.byteLength,m=t.scaling instanceof ft?s:0,y=t.quaternion.quantized.data.buffer.byteLength,g=t.quaternion instanceof ft?s:0,b=t.variableChunkSize?Uint16Array.from(t.variableChunkSize):void 0,w=b?b.byteLength:0,_=a.byteLength+w+l+u+c+d+p+f+h+m+y+g,S=0,P=0;if(t.harmonics&&t.harmonics.length>0)for(let D=0;D<t.harmonics.length;D++)S+=t.harmonics[D].quantized.data.buffer.byteLength,P+=t.harmonics[D]instanceof ft?s:0;S=0,P=0,_+=S+P;let O=new Uint8Array(_),x=0;if(O.set(a,x),x+=a.byteLength,w>0&&(O.set(new Uint8Array(b.buffer),x),x+=w),t.xyz instanceof ft&&(O.set(new Uint8Array(t.xyz.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(t.xyz.quantized.data.buffer),x),x+=l,t.color instanceof ft&&(O.set(new Uint8Array(t.color.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(t.color.quantized.data.buffer),x),x+=c,t.opacity instanceof ft&&(O.set(new Uint8Array(t.opacity.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(t.opacity.quantized.data.buffer),x),x+=p,t.scaling instanceof ft&&(O.set(new Uint8Array(t.scaling.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(t.scaling.quantized.data.buffer),x),x+=h,t.quaternion instanceof ft&&(O.set(new Uint8Array(t.quaternion.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(t.quaternion.quantized.data.buffer),x),x+=y,S>0&&t.harmonics&&t.harmonics.length>0)for(let D=0;D<t.harmonics.length;D++){let N=t.harmonics[D];N instanceof ft&&(O.set(new Uint8Array(N.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(N.quantized.data.buffer),x),x+=N.quantized.data.byteLength}return new ui(O.buffer)}};var QS="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL";var Zo=class{};Kt(Zo,"DepthMapRange",1<<16),Kt(Zo,"MemoryPageSize",65536),Kt(Zo,"BytesPerFloat",4),Kt(Zo,"BytesPerInt",4);function YI(n){let t,e,r,o,i,a,s,l,u,c,d,p,f,h,m,y;function g(T){let I=new Float64Array(c,a,16);for(let B=0;B<16;B++)I[B]=T[B];let E;if(r>1){t.exports.sortIndexes(o,i,u,a,s,l,p.DepthMapRange,r);let B=new Uint32Array(r);E=B.buffer,B.set(new Uint32Array(c,l,r))}else if(r===1){let B=new Uint32Array(r);B[0]=new Uint32Array(c,o,e)[0],E=B.buffer}else E=new ArrayBuffer(0);n.postMessage({sortDone:!0,indexesBuffer:E},[E])}function b(T,I,E){let B=new Float32Array(c,i,e*3);r=0;let R=new Uint32Array(c,o,e);for(let k=0;k<E.length-1;k++){let V=I[k],q=T[k].elements,F=V.filter(H=>H.enabled&&H.mode==="Include").map(H=>H.type==="Box"?P(H):D(H)),U=V.filter(H=>H.enabled&&H.mode==="Exclude").map(H=>H.type==="Box"?P(H):D(H));for(let H=E[k];H<E[k+1];H++){let $=f[H*3],J=f[H*3+1],K=f[H*3+2];if((F.length===0||_($,J,K,F))&&(U.length===0||!_($,J,K,U))){let X=1/(q[3]*$+q[7]*J+q[11]*K+q[15]);B[r*3]=(q[0]*$+q[4]*J+q[8]*K+q[12])*X,B[r*3+1]=(q[1]*$+q[5]*J+q[9]*K+q[13])*X,B[r*3+2]=(q[2]*$+q[6]*J+q[10]*K+q[14])*X,R[r]=H,r++}}}}function w(T,I){let E=[],B=I.filter(V=>V.enabled&&V.mode==="Include").map(V=>V.type==="Box"?P(V):D(V)),R=I.filter(V=>V.enabled&&V.mode==="Exclude").map(V=>V.type==="Box"?P(V):D(V)),k=T.length;for(let V=0;V<k;V+=3){let q=T[V],F=T[V+1],U=T[V+2];(B.length===0||_(q,F,U,B))&&(R.length===0||!_(q,F,U,R))||E.push(V/3)}return console.log(E),E}function _(T,I,E,B,R){return B[R==="Intersect"?"every":"some"](k=>{let V=S(T,I,E,k.invRotationMatrix,k.cropCenter);return Array.isArray(k)?x(V.x,V.y,V.z,k):N(V.x,V.y,V.z,k)})}function S(T,I,E,B,R){let k=T-R[0],V=I-R[1],q=E-R[2],F=1/(B[3]*k+B[7]*V+B[11]*q+B[15]);return{x:(B[0]*k+B[4]*V+B[8]*q+B[12])*F+R[0],y:(B[1]*k+B[5]*V+B[9]*q+B[13])*F+R[1],z:(B[2]*k+B[6]*V+B[10]*q+B[14])*F+R[2]}}function P(T){let I=T.cropSize[0]/2,E=T.cropSize[1]/2,B=T.cropSize[2]/2,R=[T.cropCenter[0]-I,T.cropCenter[1]-E,T.cropCenter[2]-B,T.cropCenter[0]+I,T.cropCenter[1]+E,T.cropCenter[2]+B],k=O(T.cropRotation);return Object.assign(R,{invRotationMatrix:k,cropCenter:T.cropCenter})}function O(T){let I=[],E=T[0]*Math.PI/180,B=T[1]*Math.PI/180,R=T[2]*Math.PI/180,k=Math.cos(E),V=Math.sin(E),q=Math.cos(B),F=Math.sin(B),U=Math.cos(R),H=Math.sin(R),$=k*U,J=k*H,K=V*U,X=V*H;return I[0]=q*U,I[1]=-q*H,I[2]=F,I[4]=J+K*F,I[5]=$-X*F,I[6]=-V*q,I[8]=X-$*F,I[9]=K+J*F,I[10]=k*q,I[12]=0,I[13]=0,I[14]=0,I[3]=0,I[7]=0,I[11]=0,I[15]=1,I}function x(T,I,E,B){return T>=B[0]&&T<=B[3]&&I>=B[1]&&I<=B[4]&&E>=B[2]&&E<=B[5]}function D(T){let I=2/T.cropSize[0],E=2/T.cropSize[1],B=2/T.cropSize[2],R=O(T.cropRotation);return{invRadiusX:I,invRadiusY:E,invRadiusZ:B,cropCenter:T.cropCenter,invRotationMatrix:R}}function N(T,I,E,B){let R=(T-B.cropCenter[0])*B.invRadiusX,k=(I-B.cropCenter[1])*B.invRadiusY,V=(E-B.cropCenter[2])*B.invRadiusZ;return R*R+k*k+V*V<=1}n.onmessage=T=>{if(T.data.getCroppedIndexes){let I=new Uint32Array(w(new Float32Array(T.data.positions),T.data.crops)).buffer;n.postMessage({outOfBoundsIndexes:I},[I])}else if(T.data.positions)d=T.data.positions,f=new Float32Array(d),m=T.data.meshMatrixWorlds,y=T.data.cropsArray,h=T.data.meshIndexIntervals,b(m,y,h),n.postMessage({sortSetupComplete:!0});else if(T.data.sort||T.data.newMatrixWorlds||T.data.newCropsArray)(T.data.newMatrixWorlds||T.data.newCropsArray)&&(y=T.data.newCropsArray||y,m=T.data.newMatrixWorlds||m,b(m,y,h)),g(T.data.sort.view,T.data.sort.cameraPosition);else if(T.data.init){p=T.data.init.Constants,e=T.data.init.splatCount;let I=p.BytesPerInt,E=p.BytesPerFloat*3,B=new Uint8Array(T.data.init.sorterWasmBytes),R=I+E,k=e*R,V=e*p.BytesPerInt*2+p.DepthMapRange*p.BytesPerInt*2,q=p.MemoryPageSize*32,F=k+V+q,U=Math.floor(F/p.MemoryPageSize)+1,H={module:{},env:{memory:new WebAssembly.Memory({initial:U*2,maximum:U*3,shared:!0})}};WebAssembly.compile(B).then($=>WebAssembly.instantiate($,H)).then($=>{t=$,o=0,i=e*I,a=i+e*E,u=a+16*p.BytesPerFloat*2,s=u+e*p.BytesPerInt,l=s+p.DepthMapRange*p.BytesPerInt,c=H.env.memory.buffer,n.postMessage({sortSetupPhase1Complete:!0})})}}}function KS(n){let t=new Worker(URL.createObjectURL(new Blob(["(",YI.toString(),")(self)"],{type:"application/javascript"}))),e=atob(QS),r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e.charCodeAt(o);return t.postMessage({init:{sorterWasmBytes:r.buffer,splatCount:n,Constants:{BytesPerFloat:Zo.BytesPerFloat,BytesPerInt:Zo.BytesPerInt,DepthMapRange:Zo.DepthMapRange,MemoryPageSize:Zo.MemoryPageSize}}}),t}var Vr=require("three");var Pe=require("three");var Qd=function(){let n=new Float32Array(1),t=new Int32Array(n.buffer);return function(e){return n[0]=e,t[0]}}(),ZS=function(n,t,e,r){return n+(t<<8)+(e<<16)+(r<<24)};var Kd=new Pe.Vector2,di=class extends Pe.Mesh{constructor(e,r,o,i,a=!1,s=1,l,u){super(o,i);this.splatCount=r,this.meshIndexIntervals=l,this.meshMatrixWorlds=u,this.splatBuffers=e,this.geometry=o,this.material=i,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=a,this.devicePixelRatio=s,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,r,o=!1,i=1,a,s){let l=di.buildGeomtery(r),u=di.buildMaterial(a);return new di(e,r,l,u,o,i,a,s)}static buildMaterial(e){let r=`
3509
3510
  precision highp float;
3510
3511
  #include <common>
3511
3512
 
@@ -3659,4 +3660,4 @@ end_header
3659
3660
  A = exp(A) * vColor.a;
3660
3661
  gl_FragColor = vec4(color.rgb, A);
3661
3662
  gVelocity = vec4(0.0); // so it is ignored by TAA
3662
- }`,i={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new be.Vector2},viewport:{type:"v2",value:new be.Vector2},basisViewport:{type:"v2",value:new be.Vector2},debugColor:{type:"v3",value:new be.Color},covariancesTextureSize:{type:"v2",value:new be.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new be.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new be.ShaderMaterial({uniforms:i,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:be.NormalBlending,depthTest:!0,depthWrite:!1,side:be.DoubleSide})}static buildGeomtery(e){let r=new be.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new be.BufferAttribute(o,3);r.setAttribute("position",i),i.setXYZ(0,-1,-1,0),i.setXYZ(1,-1,1,0),i.setXYZ(2,1,1,0),i.setXYZ(3,1,-1,0),i.needsUpdate=!0;let a=new be.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new be.InstancedBufferAttribute(s,1,!1);return l.setUsage(be.DynamicDrawUsage),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(i=>i.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let i of this.splatBuffers){let a=i.nsplats;this.colors.subarray(e,e+a*4).set(i.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(i.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(i.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,i=new be.Vector2(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new be.Vector2(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(i.x*i.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=be.DataUtils.toHalfFloat(this.covariances[h]);s=new be.DataTexture(l,i.x,i.y,be.RGFormat,be.HalfFloatType)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new be.DataTexture(l,i.x,i.y,be.RGFormat,be.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(i);let u=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,g=h*4;u[g]=iS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),u[g+1]=Pd(this.centers[y]),u[g+2]=Pd(this.centers[y+1]),u[g+3]=Pd(this.centers[y+2])}let c=new be.DataTexture(u,a.x,a.y,be.RGBAIntegerFormat,be.UnsignedIntType);c.internalFormat="RGBA32UI",c.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=c,this.material.uniforms.centersColorsTextureSize.value.copy(a);let d=256*4,p=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)p.set(this.meshMatrixWorlds[h].elements,h*16);let f=new be.DataTexture(p,d,1,be.RGBAFormat,be.FloatType);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:i},centerColors:{data:u,texture:c,size:a},meshMatrixWorlds:{data:p,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,i){this.splatCount>0&&(Od.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Od),this.material.uniforms.basisViewport.value.set(2/Od.x,2/Od.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=i,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose())}};var Ql=class{constructor(t={}){Gt(this,"updateSplatMeshUniforms",function(){let t=new Pr.Vector2;return function(){if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(this.renderer.getSize(t),this.cameraFocalLengthX=this.camera.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=this.camera.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,this.camera.isPerspectiveCamera?-1:this.camera.zoom*this.devicePixelRatio))}}());Gt(this,"updateView",function(){let t=new Pr.Matrix4,e=[],r=new Pr.Vector3(0,0,-1),o=new Pr.Vector3(0,0,-1),i=new Pr.Vector3,a=new Pr.Vector3;return function(s=!1){let l=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(this.camera.quaternion);let d=!1,p=!1;if(o.dot(r)<=.95&&(d=!0),a.copy(this.camera.position).sub(i).length()>=1&&(p=!0),!d&&!p&&!l&&!u)return}i.copy(this.camera.position),r.copy(o),t.copy(this.camera.matrixWorld).invert(),t.premultiply(this.camera.perspCamera.projectionMatrix),e[0]=this.camera.position.x,e[1]=this.camera.position.y,e[2]=this.camera.position.z;let c={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...l?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=c:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(c))}}());this.scene=t.scene,this.currentPage=null,this.renderer=t.renderer,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.splatRenderingInitialized=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null}get camera(){return this.scene.activeCamera}reloadSplats(){this.splatRenderingInitialized=!1;let t=this.loadSplat();this.renderer.pipeline.opaquePass.splatViewer=t?this:null}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new Pr.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new Pr.Quaternion().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseEntity(a=>{if(a.data.type==="Splat"){let s=a.visible;a.traverseAncestors(l=>{s&&(s=l.visible)}),s&&e.push(a)}}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new ei(new Uint8Array(a.data.buffer).buffer)),o=0,i=[0];for(let a of r)o+=a.getSplatCount(),i.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,i,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,i)=>{this.cropsArray[r][i]===void 0?(t=!0,this.cropsArray[r][i]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,u)=>l!==this.cropsArray[r][i][a][u])?(t=!0,this.cropsArray[r][i][a]=s):s!==this.cropsArray[r][i]?.[a]&&(t=!0,this.cropsArray[r][i][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new Pr.Vector3,o=new Pr.Quaternion,i=!1,a=1,s,l){this.splatMesh=ti.buildMesh(t,e,i,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=10,this.updateSplatMeshUniforms(),this.splatRenderCount=e}setupSortWorker(t){this.sortWorker=nS(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.updateView(!0,!0),this.splatRenderingInitialized=!0)}}update(){this.splatRenderingInitialized!==!1&&(this.updateSplatMeshUniforms(),this.updateView())}getSplatMesh(){return this.splatMesh}};var UM=new Kr.MeshBasicMaterial;UM.wireframe=!0;var aS=new Kr.Vector3,Cd=class extends Kr.Scene{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new wd;this.invisibleObjects=new $n("jflkdsafjasdifjaslk",{...tu.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Yr("fdasfa",{...Xo.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Cv(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Ov(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Yr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],i=r;for(;i!==this;){let a=i;i=i.parent;let s=i.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&r.push(i)}return r.sort((o,i)=>tc(o.sortKey,i.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===Tn)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof Yr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Yr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Ii&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Yr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let i=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);i.updateVisible(this),i.resetBBoxNeedsUpdate(),Wn(i)&&Fl(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty(),i.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),Fl(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Wn(o)&&(o.freeBooleanPointer(),i instanceof wr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Ls&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),Wn(o)&&(o.invalidateUpstreamBooleanData(),Fl(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof wr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Yr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,i){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{_v(a,r,o,{scene:this,shared:i}),a instanceof yt&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,i,a,s=[]){e.updateEntityByOp(r,o,i,a),this.traverseEntity(l=>{(l instanceof Ii||l instanceof Yr)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,i,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((i,a)=>({data:i[1].asset.data,children:i[1].asset.children,id:i[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(i=>{i instanceof pn&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){De.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{De.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,i,a,s,l){if(e){let u=i.find(e);u&&u!==i&&a.forInstancesRec(c=>{c.data=wn(c.data,d=>{let p=d.events.data(l.id),f=c.goUp(s);if(f){let h=[...ec(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=dt.zoom(p,r);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,i,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,i,a,s):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...r,l.id],"object",o,i,a,s)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof mn&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(i=>{if(i.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=wn(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of iu.list)this.rewriteActions(i.data.gameActions[s],["gameActions",s],e,r,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,r,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,r,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,r,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,r,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,r,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,r,o,i)})}),!0})}expandInstances(e,r,o){let i=new Set;this.traverseEntity(a=>{if(a instanceof mn&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),md(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof mn&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)De.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],i=a=>{for(let s of a.children){let l=s.cloner;if(De.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let u=[];if(e.intersectObject(s,!0,u),u.length){let c=u[0];c.object=s,c.point.applyMatrix4(c.object.matrixWorld);let d=s.matrixWorld.clone().invert();c.point.applyMatrix4(d),o.push(c)}}else(Wn(s)||jl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Xl(s,e,o)),i(s)}};return i(this.activePage),o}raycastWithClones(e){let r=[],o=i=>{for(let a of i.children){let s=a.cloner;De.is(a)&&(a.visible||s?.object.data.visible)&&((Wn(a)||jl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Xl(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)De.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)De.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)De.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof yt&&o.data.type==="Mesh"&&o.data.geometry.type==="TextGeometry"&&o.data.geometry.font===e){let i=o.geometry,a=o.data.geometry;i.updateFont(e,r).then(()=>{i.update(a);let s=o.invalidateDownstreamBooleanData();Fl(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)Aa.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)De.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let i=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,i,o),i+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,i,a,s){let l={scene:this,shared:s},u=Sd(e,r,l);return u&&(this.entityByUuid[e]=u,i.add(u),i.children.splice(a,0,i.children.pop()),o.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,u,s)),u.updateState(r,l),u instanceof yt&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(this),u.cloner&&this.toExpandCloner.add(u),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&u.traverseEntity(c=>{let d=c.dataPatched;if(c instanceof yt&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new Kr.Matrix4().fromArray(m)),h=new Kr.Skeleton(p,f);c.bind(h,c.bindMatrix)}else c.matrixAutoUpdate=!0}),u}getCenter(e){let r=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:l}=e[i],u=this.find(s),c=l?u.recursiveBBox:u.singleBBox;r.push(...c.vertices)}let o=new Kr.Box3;return o.setFromPoints(r),o.getCenter(aS),aS}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Bt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof vr&&e(r.material[o]);else r.material instanceof vr&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(i=>{i instanceof pn&&i.setViewplaneSize(e,r,o)})}initializeSplatViewer(e){this.splatViewer=new Ql({scene:this,renderer:e}),this.reloadSplats()}reloadSplats(){this.splatViewer?.reloadSplats()}};var sS=require("three/examples/jsm/loaders/DRACOLoader.js");var ri;function HM(){return ri||(ri=new sS.DRACOLoader,ri.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),ri.decoderPending}async function qM(n){if(ri){let t={attributeIDs:ri.defaultAttributeIDs,attributeTypes:ri.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await ri.decodeGeometry(new Int8Array(n).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function lS(n,t){let[e,r]=jd(jc.deserialize(new Uint8Array(n)));su(e);let o=[];e.scene.objects.traverse((i,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&a.geometry.data.draco!==void 0&&o.push(a)}),o.length&&await HM();for(let i of o){let a=await qM(ft(i.geometry.data.draco));if(a){a.index&&(i.geometry.data.index={array:a.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let s={};a.attributes.forEach(({name:l,array:u,itemSize:c})=>{s[l]={array:u,itemSize:c,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=s,i.geometry.data.draco=void 0}}return t&&t(e),r.result().data}var WM=require("three"),$M=require("three/examples/jsm/utils/BufferGeometryUtils.js");function cS(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}var Kl=require("three");function uS(n){let t=new Set;return n.traverse(e=>{if(e instanceof Sr)if(xt(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(YM(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Kl.Color,specularColor:new Kl.Color});let o=0;e.onBeforeCompile=(i,a)=>{r&&r(i,a),i.uniforms=Object.assign({},Kl.ShaderLib.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(i.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=Lx(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else XM(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function YM(n){return n.getLayersOfType("transmission").length>0}function XM(n){let t=0;for(let e of n.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function dS(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function pS(n){let t=[],e=(r,o=0)=>{let i=o>0?r+o:r;return t.includes(i)?e(r,o+1):i};return n.traverse(r=>{if(t.includes(r.name)){let o=r.name,i=e(r.name);if(r.name=i,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,i)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,i))}}t.push(r.name)}),n}var fS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function hS(n){let t=[];return n.traverse(e=>{e instanceof _s&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(u){console.error(u)}return l!==void 0&&s.matrix.determinant()<0&&cS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Bt&&a.unshift(r.geometry),a.length){let s=(0,fS.mergeBufferGeometries)(a);r instanceof Bt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:n,shared:Qx})}),n}function mS(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function yS(n){Object.values(n.shared.materials).forEach(t=>{ah(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?ah(e.material):"materials"in e&&e.materials.forEach(r=>{ah(r)})})}function ah(n){if(typeof n=="string")return;let t=[];n.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{n.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var SS=nr(xS(),1);function bS(n){return n.traverseMaterial(t=>{t.needsJitter=!1}),n}var vS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Td=class extends Md.Loader{load(t,e,r,o=console.error){let i=new Md.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(vS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(vS),i.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await lS(t,yS);e.version&&(0,SS.default)(e.version,"1.0.21")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([tb(e)&&ax(),pb(e)&&Yx(),Hb(e)&&Fb()].filter(Boolean));let r=new Pi(e.shared);Object.values(r.getMaterials()).forEach(a=>Object.assign(a,{isAsset:!0}));let o=new Cd(e.scene,r),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=hS(o),o=uS(o),o=dS(o),o=pS(o),o=mS(o),o=bS(o),o}};
3663
+ }`,i={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Pe.Vector2},viewport:{type:"v2",value:new Pe.Vector2},basisViewport:{type:"v2",value:new Pe.Vector2},debugColor:{type:"v3",value:new Pe.Color},covariancesTextureSize:{type:"v2",value:new Pe.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Pe.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Pe.ShaderMaterial({uniforms:i,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:Pe.NormalBlending,depthTest:!0,depthWrite:!1,side:Pe.DoubleSide})}static buildGeomtery(e){let r=new Pe.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new Pe.BufferAttribute(o,3);r.setAttribute("position",i),i.setXYZ(0,-1,-1,0),i.setXYZ(1,-1,1,0),i.setXYZ(2,1,1,0),i.setXYZ(3,1,-1,0),i.needsUpdate=!0;let a=new Pe.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new Pe.InstancedBufferAttribute(s,1,!1);return l.setUsage(Pe.DynamicDrawUsage),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(i=>i.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let i of this.splatBuffers){let a=i.nsplats;this.colors.subarray(e,e+a*4).set(i.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(i.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(i.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,i=new Pe.Vector2(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new Pe.Vector2(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(i.x*i.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=Pe.DataUtils.toHalfFloat(this.covariances[h]);s=new Pe.DataTexture(l,i.x,i.y,Pe.RGFormat,Pe.HalfFloatType)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new Pe.DataTexture(l,i.x,i.y,Pe.RGFormat,Pe.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(i);let u=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,g=h*4;u[g]=ZS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),u[g+1]=Qd(this.centers[y]),u[g+2]=Qd(this.centers[y+1]),u[g+3]=Qd(this.centers[y+2])}let c=new Pe.DataTexture(u,a.x,a.y,Pe.RGBAIntegerFormat,Pe.UnsignedIntType);c.internalFormat="RGBA32UI",c.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=c,this.material.uniforms.centersColorsTextureSize.value.copy(a);let d=256*4,p=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)p.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Pe.DataTexture(p,d,1,Pe.RGBAFormat,Pe.FloatType);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:i},centerColors:{data:u,texture:c,size:a},meshMatrixWorlds:{data:p,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,i){this.splatCount>0&&(Kd.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Kd),this.material.uniforms.basisViewport.value.set(2/Kd.x,2/Kd.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=i,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose())}};var gc=class{constructor(t={}){Kt(this,"updateSplatMeshUniforms",function(){let t=new Vr.Vector2;return function(){if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(this.renderer.getSize(t),this.cameraFocalLengthX=this.camera.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=this.camera.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,this.camera.isPerspectiveCamera?-1:this.camera.zoom*this.devicePixelRatio))}}());Kt(this,"updateView",function(){let t=new Vr.Matrix4,e=[],r=new Vr.Vector3(0,0,-1),o=new Vr.Vector3(0,0,-1),i=new Vr.Vector3,a=new Vr.Vector3;return function(s=!1){let l=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(this.camera.quaternion);let d=!1,p=!1;if(o.dot(r)<=.95&&(d=!0),a.copy(this.camera.position).sub(i).length()>=1&&(p=!0),!d&&!p&&!l&&!u)return}i.copy(this.camera.position),r.copy(o),t.copy(this.camera.matrixWorld).invert(),t.premultiply(this.camera.perspCamera.projectionMatrix),e[0]=this.camera.position.x,e[1]=this.camera.position.y,e[2]=this.camera.position.z;let c={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...l?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=c:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(c))}}());this.scene=t.scene,this.currentPage=null,this.renderer=t.renderer,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.splatRenderingInitialized=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null}get camera(){return this.scene.activeCamera}reloadSplats(){this.splatRenderingInitialized=!1;let t=this.loadSplat();this.renderer.pipeline.opaquePass.splatViewer=t?this:null}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new Vr.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new Vr.Quaternion().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseEntity(a=>{if(a.data.type==="Splat"){let s=a.visible;a.traverseAncestors(l=>{s&&(s=l.visible)}),s&&e.push(a)}}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new ui(new Uint8Array(a.data.buffer).buffer)),o=0,i=[0];for(let a of r)o+=a.getSplatCount(),i.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,i,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,i)=>{this.cropsArray[r][i]===void 0?(t=!0,this.cropsArray[r][i]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,u)=>l!==this.cropsArray[r][i][a][u])?(t=!0,this.cropsArray[r][i][a]=s):s!==this.cropsArray[r][i]?.[a]&&(t=!0,this.cropsArray[r][i][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new Vr.Vector3,o=new Vr.Quaternion,i=!1,a=1,s,l){this.splatMesh=di.buildMesh(t,e,i,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=10,this.updateSplatMeshUniforms(),this.splatRenderCount=e}setupSortWorker(t){this.sortWorker=KS(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.updateView(!0,!0),this.splatRenderingInitialized=!0)}}update(){this.splatRenderingInitialized!==!1&&(this.updateSplatMeshUniforms(),this.updateView())}getSplatMesh(){return this.splatMesh}};var XI=new lo.MeshBasicMaterial;XI.wireframe=!0;var JS=new lo.Vector3,Zd=class extends lo.Scene{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new $d;this.invisibleObjects=new oi("jflkdsafjasdifjaslk",{...Ou.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new io("fdasfa",{...an.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=vS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=bS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof io&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],i=r;for(;i!==this;){let a=i;i=i.parent;let s=i.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&r.push(i)}return r.sort((o,i)=>Oc(o.sortKey,i.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===zn)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof io&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof io&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof qi&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof io&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let i=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);i.updateVisible(this),i.resetBBoxNeedsUpdate(),ri(i)&&lc(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty(),i.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),lc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),ri(o)&&(o.freeBooleanPointer(),i instanceof Er&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof tl&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),ri(o)&&(o.invalidateUpstreamBooleanData(),lc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof Er&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof io&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,i){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{yS(a,r,o,{scene:this,shared:i}),a instanceof Ot&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,i,a,s=[]){e.updateEntityByOp(r,o,i,a),this.traverseEntity(l=>{(l instanceof qi||l instanceof io)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,i,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((i,a)=>({data:i[1].asset.data,children:i[1].asset.children,id:i[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(i=>{i instanceof wn&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Fe.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Fe.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,i,a,s,l){if(e){let u=i.find(e);u&&u!==i&&a.forInstancesRec(c=>{c.data=Dn(c.data,d=>{let p=d.events.data(l.id),f=c.goUp(s);if(f){let h=[...Pc(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=St.zoom(p,r);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,i,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,i,a,s):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...r,l.id],"object",o,i,a,s)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Pn&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(i=>{if(i.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=Dn(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of Iu.list)this.rewriteActions(i.data.gameActions[s],["gameActions",s],e,r,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,r,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,r,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,r,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,r,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,r,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,r,o,i)})}),!0})}expandInstances(e,r,o){let i=new Set;this.traverseEntity(a=>{if(a instanceof Pn&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Fd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Pn&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)Fe.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],i=a=>{for(let s of a.children){let l=s.cloner;if(Fe.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let u=[];if(e.intersectObject(s,!0,u),u.length){let c=u[0];c.object=s,c.point.applyMatrix4(c.object.matrixWorld);let d=s.matrixWorld.clone().invert();c.point.applyMatrix4(d),o.push(c)}}else(ri(s)||cc(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),yc(s,e,o)),i(s)}};return i(this.activePage),o}raycastWithClones(e){let r=[],o=i=>{for(let a of i.children){let s=a.cloner;Fe.is(a)&&(a.visible||s?.object.data.visible)&&((ri(a)||cc(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),yc(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Fe.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Fe.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Fe.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof Ot&&o.data.type==="Mesh"&&o.data.geometry.type==="TextGeometry"&&o.data.geometry.font===e){let i=o.geometry,a=o.data.geometry;i.updateFont(e,r).then(()=>{i.update(a);let s=o.invalidateDownstreamBooleanData();lc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)Ua.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Fe.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let i=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,i,o),i+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,i,a,s){let l={scene:this,shared:s},u=Wd(e,r,l);return u&&(this.entityByUuid[e]=u,i.add(u),i.children.splice(a,0,i.children.pop()),o.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,u,s)),u.updateState(r,l),u instanceof Ot&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(this),u.cloner&&this.toExpandCloner.add(u),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&u.traverseEntity(c=>{let d=c.dataPatched;if(c instanceof Ot&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new lo.Matrix4().fromArray(m)),h=new lo.Skeleton(p,f);c.bind(h,c.bindMatrix)}else c.matrixAutoUpdate=!0}),u}getCenter(e){let r=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:l}=e[i],u=this.find(s),c=l?u.recursiveBBox:u.singleBBox;r.push(...c.vertices)}let o=new lo.Box3;return o.setFromPoints(r),o.getCenter(JS),JS}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Wt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Nr&&e(r.material[o]);else r.material instanceof Nr&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(i=>{i instanceof wn&&i.setViewplaneSize(e,r,o)})}initializeSplatViewer(e){this.splatViewer=new gc({scene:this,renderer:e}),this.reloadSplats()}reloadSplats(){this.splatViewer?.reloadSplats()}};var e1=require("three/examples/jsm/loaders/DRACOLoader.js");var pi;function QI(){return pi||(pi=new e1.DRACOLoader,pi.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),pi.decoderPending}async function KI(n){if(pi){let t={attributeIDs:pi.defaultAttributeIDs,attributeTypes:pi.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await pi.decodeGeometry(new Int8Array(n).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function t1(n,t){let[e,r]=Ap(fu.deserialize(new Uint8Array(n)));Du(e);let o=[];e.scene.objects.traverse((i,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&a.geometry.data.draco!==void 0&&o.push(a)}),o.length&&await QI();for(let i of o){let a=await KI(At(i.geometry.data.draco));if(a){a.index&&(i.geometry.data.index={array:a.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let s={};a.attributes.forEach(({name:l,array:u,itemSize:c})=>{s[l]={array:u,itemSize:c,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=s,i.geometry.data.draco=void 0}}return t&&t(e),r.result().data}var ZI=require("three"),JI=require("three/examples/jsm/utils/BufferGeometryUtils.js");function r1(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}var xc=require("three");function o1(n){let t=new Set;return n.traverse(e=>{if(e instanceof Dr)if(Mt(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(e3(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new xc.Color,specularColor:new xc.Color});let o=0;e.onBeforeCompile=(i,a)=>{r&&r(i,a),i.uniforms=Object.assign({},xc.ShaderLib.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(i.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=_b(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else t3(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function e3(n){return n.getLayersOfType("transmission").length>0}function t3(n){let t=0;for(let e of n.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function n1(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function i1(n){let t=[],e=(r,o=0)=>{let i=o>0?r+o:r;return t.includes(i)?e(r,o+1):i};return n.traverse(r=>{if(t.includes(r.name)){let o=r.name,i=e(r.name);if(r.name=i,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,i)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,i))}}t.push(r.name)}),n}var a1=require("three/examples/jsm/utils/BufferGeometryUtils.js");function s1(n){let t=[];return n.traverse(e=>{e instanceof js&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(u){console.error(u)}return l!==void 0&&s.matrix.determinant()<0&&r1(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Wt&&a.unshift(r.geometry),a.length){let s=(0,a1.mergeBufferGeometries)(a);r instanceof Wt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:n,shared:Gb})}),n}function l1(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function c1(n){Object.values(n.shared.materials).forEach(t=>{jh(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?jh(e.material):"materials"in e&&e.materials.forEach(r=>{jh(r)})})}function jh(n){if(typeof n=="string")return;let t=[];n.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{n.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var h1=hr(d1(),1);function p1(n){return n.traverseMaterial(t=>{t.needsJitter=!1}),n}var f1="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Jd=class extends ep.Loader{load(t,e,r,o=console.error){let i=new ep.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(f1+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(f1),i.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await t1(t,c1);e.version&&(0,h1.default)(e.version,"1.0.23")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([Hb(e)&&Xx(),tv(e)&&Vb(),Ev(e)&&Iv()].filter(Boolean));let r=new Gi(e.shared);Object.values(r.getMaterials()).forEach(a=>Object.assign(a,{isAsset:!0}));let o=new Zd(e.scene,r),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=s1(o),o=o1(o),o=n1(o),o=i1(o),o=l1(o),o=p1(o),o}};