@splinetool/loader 1.0.62 → 1.0.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/SplineLoader.cjs +175 -208
- package/build/SplineLoader.js +175 -208
- package/build/gaussian-splat-compression.js +34 -0
- package/package.json +1 -1
package/build/SplineLoader.cjs
CHANGED
|
@@ -1,31 +1,17 @@
|
|
|
1
|
-
"use strict";var L1=Object.create;var cl=Object.defineProperty;var R1=Object.getOwnPropertyDescriptor;var V1=Object.getOwnPropertyNames;var z1=Object.getPrototypeOf,G1=Object.prototype.hasOwnProperty;var F1=(n,t,e)=>t in n?cl(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var hr=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),em=(n,t)=>{for(var e in t)cl(n,e,{get:t[e],enumerable:!0})},tm=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of V1(t))!G1.call(n,o)&&o!==e&&cl(n,o,{get:()=>t[o],enumerable:!(r=R1(t,o))||r.enumerable});return n};var ar=(n,t,e)=>(e=n!=null?L1(z1(n)):{},tm(t||!n||!n.__esModule?cl(e,"default",{value:n,enumerable:!0}):e,n)),k1=n=>tm(cl({},"__esModule",{value:!0}),n);var Zt=(n,t,e)=>(F1(n,typeof t!="symbol"?t+"":t,e),e);var R0=hr((tf,L0)=>{(function(n,t){typeof tf=="object"?L0.exports=t():typeof define=="function"&&define.amd?define(t):n.Alea=t()})(tf,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 j0=hr((Gu,k0)=>{(function(n,t){typeof Gu=="object"&&typeof k0<"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 A=[],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(A[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[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*A[s]}}m<(y=Math.abs(N[x])+Math.abs(A[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=A[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(A[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*A[x],A[x]=c*A[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=A[s-1])-(f=A[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=A[x],y=N[x],f=h*p,p*=c,g=Math.sqrt(d*d+f*f),d=m*(c=d/(A[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}A[l]=0,A[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 xx=hr((Sf,wf)=>{(function(n,t){typeof Sf=="object"&&typeof wf<"u"?wf.exports=t():typeof define=="function"&&define.amd?define(t):(n=n||self,n.TinyQueue=t())})(Sf,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 vx=hr((q4,Af)=>{"use strict";var Hu=xx();Hu.default&&(Hu=Hu.default);Af.exports=bx;Af.exports.default=bx;function bx(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,ET),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=LT(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 A=h.pop();A.d>g.d&&(g=A,e&&console.log("found best %d after %d probes",Math.round(1e4*A.d)/1e4,w)),!(A.max-g.d<=t)&&(p=A.h/2,h.push(new $n(A.x-p,A.y-p,p,n)),h.push(new $n(A.x+p,A.y-p,p,n)),h.push(new $n(A.x-p,A.y+p,p,n)),h.push(new $n(A.x+p,A.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 ET(n,t){return t.max-n.max}function $n(n,t,e,r){this.x=n,this.y=t,this.h=e,this.d=BT(n,t,r),this.max=this.d+this.h*Math.SQRT2}function BT(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,RT(n,t,c,d))}return o===0?0:(r?1:-1)*Math.sqrt(o)}function LT(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 RT(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 Db=hr(xd=>{(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),A=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),A!==1/0&&(p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),A)),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),A):(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),A=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))},A)},_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,A=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),A)),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 A=c.playing(f)?t.ctx.currentTime-y._playStart:0,S=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(S+A*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 xd<"u"&&(xd.Howler=t,xd.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 Vv=hr((ste,Rv)=>{"use strict";function pI(n,t){function e(){this.constructor=n}e.prototype=t.prototype,n.prototype=new e}function Ui(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,Ui)}pI(Ui,Error);Ui.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 fI(n,t){t=t!==void 0?t:{};var e={},r={svg_path:ll},o=ll,i=function(v){if(!v)return[];for(var _=[],L=0;L<v.length;L++)_=_.concat.apply(_,v[L]);var M=_[0];return M&&M.code=="m"&&(delete M.relative,M.code="M"),_},a=function(v,_){return B1(v,_)},s=/^[Mm]/,l=at(["M","m"],!1,!1),u=function(v,_,L){var M=Zi(v,[_]);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,_){return Zi(v,_)},y=/^[Hh]/,g=at(["H","h"],!1,!1),b=function(v,_){return Zi(v,_.map(function(L){return{x:L}}))},w=/^[Vv]/,A=at(["V","v"],!1,!1),S=function(v,_){return Zi(v,_.map(function(L){return{y:L}}))},P=/^[Cc]/,O=at(["C","c"],!1,!1),x=function(v,_,L){return{x1:v.x,y1:v.y,x2:_.x,y2:_.y,x:L.x,y:L.y}},D=/^[Ss]/,N=at(["S","s"],!1,!1),T=function(v,_){return{x2:v.x,y2:v.y,x:_.x,y:_.y}},I=/^[Qq]/,E=at(["Q","q"],!1,!1),B=function(v,_){return{x1:v.x,y1:v.y,x:_.x,y:_.y}},R=/^[Tt]/,F=at(["T","t"],!1,!1),V=/^[Aa]/,q=at(["A","a"],!1,!1),k=function(v,_,L,M,z,oe){return{rx:v,ry:_,xAxisRotation:L,largeArc:M,sweep:z,x:oe.x,y:oe.y}},U=function(v,_){return{x:v,y:_}},H=function(v){return v*1},Y=function(v){return v.join("")*1},J=/^[01]/,Z=at(["0","1"],!1,!1),X=function(v){return v=="1"},te=function(){return""},$=",",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 mi(ie,C)}function Ut(v,_){throw _=_!==void 0?_:mi(ie,C),$r([np(v)],n.substring(ie,C),_)}function hi(v,_){throw _=_!==void 0?_:mi(ie,C),ip(v,_)}function vt(v,_){return{type:"literal",text:v,ignoreCase:_}}function at(v,_,L){return{type:"class",parts:v,inverted:_,ignoreCase:L}}function co(){return{type:"any"}}function op(){return{type:"end"}}function np(v){return{type:"other",description:v}}function bc(v){var _=Ve[v],L;if(_)return _;for(L=v-1;!Ve[L];)L--;for(_=Ve[L],_={line:_.line,column:_.column};L<v;)n.charCodeAt(L)===10?(_.line++,_.column=1):_.column++,L++;return Ve[v]=_,_}function mi(v,_){var L=bc(v),M=bc(_);return{start:{offset:v,line:L.line,column:L.column},end:{offset:_,line:M.line,column:M.column}}}function Tt(v){C<He||(C>He&&(He=C,ze=[]),ze.push(v))}function ip(v,_){return new Ui(v,null,null,_)}function $r(v,_,L){return new Ui(Ui.buildMessage(v,_),v,_,L)}function ll(){var v,_,L,M,z;for(v=C,_=[],L=qe();L!==e;)_.push(L),L=qe();if(_!==e)if(L=fr(),L===e&&(L=null),L!==e){for(M=[],z=qe();z!==e;)M.push(z),z=qe();M!==e?(ie=v,_=i(L),v=_):(C=v,v=e)}else C=v,v=e;else C=v,v=e;return v}function fr(){var v,_,L,M,z,oe;if(v=C,_=yi(),_!==e){for(L=[],M=C,z=[],oe=qe();oe!==e;)z.push(oe),oe=qe();for(z!==e?(oe=yi(),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=yi(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e)}L!==e?(ie=v,_=a(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function yi(){var v,_,L,M,z,oe;if(v=C,_=Qi(),_!==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(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function vc(){var v;return v=b1(),v===e&&(v=v1(),v===e&&(v=S1(),v===e&&(v=w1(),v===e&&(v=A1(),v===e&&(v=P1(),v===e&&(v=C1(),v===e&&(v=M1(),v===e&&(v=N1())))))))),v}function Qi(){var v,_,L,M,z,oe,Ji;if(v=C,s.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,Oe===0&&Tt(l)),_!==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=Wh(),Ji!==e?(oe=[oe,Ji],z=oe):(C=z,z=e)):(C=z,z=e),z===e&&(z=null),z!==e?(ie=v,_=u(_,M,z),v=_):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function b1(){var v,_;return v=C,c.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,Oe===0&&Tt(d)),_!==e&&(ie=v,_=p()),v=_,v}function v1(){var v,_,L,M;if(v=C,f.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,Oe===0&&Tt(h)),_!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=Wh(),M!==e?(ie=v,_=m(_,M),v=_):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function Wh(){var v,_,L,M,z,oe;if(v=C,_=xr(),_!==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(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function S1(){var v,_,L,M;if(v=C,y.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,Oe===0&&Tt(g)),_!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=$h(),M!==e?(ie=v,_=b(_,M),v=_):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function $h(){var v,_,L,M,z,oe;if(v=C,_=Ki(),_!==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(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function w1(){var v,_,L,M;if(v=C,w.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,Oe===0&&Tt(A)),_!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=$h(),M!==e?(ie=v,_=S(_,M),v=_):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function A1(){var v,_,L,M;if(v=C,P.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,Oe===0&&Tt(O)),_!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=_1(),M!==e?(ie=v,_=m(_,M),v=_):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function _1(){var v,_,L,M,z,oe;if(v=C,_=ap(),_!==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(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function ap(){var v,_,L,M,z,oe;return v=C,_=xr(),_!==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,_=x(_,M,oe),v=_):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function P1(){var v,_,L,M;if(v=C,D.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,Oe===0&&Tt(N)),_!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=O1(),M!==e?(ie=v,_=m(_,M),v=_):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function O1(){var v,_,L,M,z,oe;if(v=C,_=sp(),_!==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(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function sp(){var v,_,L,M;return v=C,_=xr(),_!==e?(L=yt(),L===e&&(L=null),L!==e?(M=xr(),M!==e?(ie=v,_=T(_,M),v=_):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function C1(){var v,_,L,M;if(v=C,I.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,Oe===0&&Tt(E)),_!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=T1(),M!==e?(ie=v,_=m(_,M),v=_):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function T1(){var v,_,L,M,z,oe;if(v=C,_=lp(),_!==e){for(L=[],M=C,z=yt(),z===e&&(z=null),z!==e?(oe=lp(),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=lp(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,_=a(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function lp(){var v,_,L,M;return v=C,_=xr(),_!==e?(L=yt(),L===e&&(L=null),L!==e?(M=xr(),M!==e?(ie=v,_=B(_,M),v=_):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function M1(){var v,_,L,M;if(v=C,R.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,Oe===0&&Tt(F)),_!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=I1(),M!==e?(ie=v,_=m(_,M),v=_):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function I1(){var v,_,L,M,z,oe;if(v=C,_=xr(),_!==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(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function N1(){var v,_,L,M;if(v=C,V.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,Oe===0&&Tt(q)),_!==e){for(L=[],M=qe();M!==e;)L.push(M),M=qe();L!==e?(M=D1(),M!==e?(ie=v,_=m(_,M),v=_):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function D1(){var v,_,L,M,z,oe;if(v=C,_=cp(),_!==e){for(L=[],M=C,z=yt(),z===e&&(z=null),z!==e?(oe=cp(),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=cp(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,_=a(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function cp(){var v,_,L,M,z,oe,Ji,dp,wc,pp,Ac,fp;return v=C,_=Yh(),_!==e?(L=yt(),L===e&&(L=null),L!==e?(M=Yh(),M!==e?(z=yt(),z===e&&(z=null),z!==e?(oe=Ki(),oe!==e?(Ji=yt(),Ji!==e?(dp=Xh(),dp!==e?(wc=yt(),wc===e&&(wc=null),wc!==e?(pp=Xh(),pp!==e?(Ac=yt(),Ac===e&&(Ac=null),Ac!==e?(fp=xr(),fp!==e?(ie=v,_=k(_,M,oe,dp,pp,fp),v=_):(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,_,L,M;return v=C,_=Ki(),_!==e?(L=yt(),L===e&&(L=null),L!==e?(M=Ki(),M!==e?(ie=v,_=U(_,M),v=_):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function Yh(){var v,_;return v=C,_=Kh(),_===e&&(_=gi()),_!==e&&(ie=v,_=H(_)),v=_,v}function Ki(){var v,_,L,M;return v=C,_=C,L=up(),L===e&&(L=null),L!==e?(M=Kh(),M!==e?(L=[L,M],_=L):(C=_,_=e)):(C=_,_=e),_===e&&(_=C,L=up(),L===e&&(L=null),L!==e?(M=gi(),M!==e?(L=[L,M],_=L):(C=_,_=e)):(C=_,_=e)),_!==e&&(ie=v,_=Y(_)),v=_,v}function Xh(){var v,_;return v=C,J.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,Oe===0&&Tt(Z)),_!==e&&(ie=v,_=X(_)),v=_,v}function yt(){var v,_,L,M,z;if(v=C,_=[],L=qe(),L!==e)for(;L!==e;)_.push(L),L=qe();else _=e;if(_!==e)if(L=Qh(),L===e&&(L=null),L!==e){for(M=[],z=qe();z!==e;)M.push(z),z=qe();M!==e?(_=[_,L,M],v=_):(C=v,v=e)}else C=v,v=e;else C=v,v=e;if(v===e){if(v=C,_=C,L=Qh(),L!==e){for(M=[],z=qe();z!==e;)M.push(z),z=qe();M!==e?(L=[L,M],_=L):(C=_,_=e)}else C=_,_=e;_!==e&&(ie=v,_=te()),v=_}return v}function Qh(){var v;return n.charCodeAt(C)===44?(v=$,C++):(v=e,Oe===0&&Tt(ee)),v}function Kh(){var v,_,L,M;return v=C,_=C,L=E1(),L!==e?(M=Zh(),M===e&&(M=null),M!==e?(L=[L,M],_=L):(C=_,_=e)):(C=_,_=e),_===e&&(_=C,L=gi(),L!==e?(M=Zh(),M!==e?(L=[L,M],_=L):(C=_,_=e)):(C=_,_=e)),_!==e&&(ie=v,_=Q(_)),v=_,v}function E1(){var v,_,L,M,z;return v=C,_=C,L=gi(),L===e&&(L=null),L!==e?(n.charCodeAt(C)===46?(M=W,C++):(M=e,Oe===0&&Tt(ue)),M!==e?(z=gi(),z!==e?(L=[L,M,z],_=L):(C=_,_=e)):(C=_,_=e)):(C=_,_=e),_===e&&(_=C,L=gi(),L!==e?(n.charCodeAt(C)===46?(M=W,C++):(M=e,Oe===0&&Tt(ue)),M!==e?(L=[L,M],_=L):(C=_,_=e)):(C=_,_=e)),_!==e&&(ie=v,_=Q(_)),v=_,v}function Zh(){var v,_,L,M,z;return v=C,_=C,le.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Oe===0&&Tt(ne)),L!==e?(M=up(),M===e&&(M=null),M!==e?(z=gi(),z!==e?(L=[L,M,z],_=L):(C=_,_=e)):(C=_,_=e)):(C=_,_=e),_!==e&&(ie=v,_=Q(_)),v=_,v}function up(){var v;return ce.test(n.charAt(C))?(v=n.charAt(C),C++):(v=e,Oe===0&&Tt(ae)),v}function gi(){var v,_,L;if(v=C,_=[],me.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Oe===0&&Tt(fe)),L!==e)for(;L!==e;)_.push(L),me.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Oe===0&&Tt(fe));else _=e;return _!==e&&(ie=v,_=he(_)),v=_,v}function qe(){var v,_;return v=C,xe.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,Oe===0&&Tt(ye)),_!==e&&(ie=v,_=te()),v=_,v}function B1(v,_){if(!_)return[v];for(var L=[v],M=0,z=_.length;M<z;M++)L[M+1]=_[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 Jh in Sc)Sc[Jh.toUpperCase()]=Sc[Jh];function Zi(v,_){_||(_=[{}]);for(var L=_.length;L--;){var M={code:v,command:Sc[v]};v==v.toLowerCase()&&(M.relative=!0);for(var z in _[L])M[z]=_[L][z];_[L]=M}return _}if(jt=o(),jt!==e&&C===n.length)return jt;throw jt!==e&&C<n.length&&Tt(op()),$r(ze,He<n.length?n.charAt(He):null,He<n.length?mi(He,He+1):mi(He,He))}Rv.exports={SyntaxError:Ui,parse:fI}});var Nh=hr((lte,zv)=>{var Fd=Vv().parse;Fd.parseSVG=Fd;Fd.makeAbsolute=hI;zv.exports=Fd;function hI(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 OS=hr((Aie,PS)=>{"use strict";function CI(n){for(var t=new Array(n),e=0;e<n;++e)t[e]=e;return t}PS.exports=CI});var MS=hr((_ie,TS)=>{TS.exports=function(n){return n!=null&&(CS(n)||TI(n)||!!n._isBuffer)};function CS(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function TI(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&CS(n.slice(0,0))}});var al=hr((Pie,IS)=>{var MI=OS(),II=MS(),NI=typeof Float64Array<"u";function DI(n,t){return n[0]-t[0]}function EI(){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(DI);var r=new Array(t.length);for(e=0;e<r.length;++e)r[e]=t[e][1];return r}function BI(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(Qd[n][0])}var o=["'use strict'"],i=MI(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
|
-
|
|
4
|
-
`)}function kI(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(ES(t,e,r));for(var u=n;u<o;++u)l.push("}");return l.join(`
|
|
5
|
-
|
|
6
|
-
`),r,i.join(`
|
|
7
|
-
`)].join(`
|
|
8
|
-
`).trim()}function UI(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 HI(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=FI([].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(zh(n.pre,n,o));var A=zh(n.body,n,o),S=jI(c);S<e?h.push(kI(S,c[0],n,A)):h.push(ES(c[0],n,A)),n.post.body.length>3&&h.push(zh(n.post,n,o)),n.debug&&console.log("-----Generated cwise routine for ",t,`:
|
|
9
|
-
`+h.join(`
|
|
10
|
-
`)+`
|
|
11
|
-
----------`);var P=[n.funcName||"unnamed","_cwise_loop_",r[0].join("s"),"m",S,UI(o)].join(""),O=new Function(["function ",P,"(",f.join(","),"){",h.join(`
|
|
12
|
-
`),"} return ",P].join(""));return O()}BS.exports=HI});var VS=hr((Tie,RS)=>{"use strict";var qI=LS();function WI(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:
|
|
13
|
-
`+t.join(`
|
|
14
|
-
`)+`
|
|
15
|
-
----------`);var d=new Function("compile",t.join(`
|
|
16
|
-
`));return d(qI.bind(void 0,n))}RS.exports=WI});var GS=hr((Mie,zS)=>{"use strict";var $I=VS();function YI(){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 XI(n){var t=new YI;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,$I(t)}zS.exports=XI});var sl=hr(je=>{"use strict";var Vr=GS(),Kd={body:"",args:[],thisVars:[],localVars:[]};function Gh(n){if(!n)return Kd;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 QI(n){return Vr({args:n.args,pre:Gh(n.pre),body:Gh(n.body),post:Gh(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(QI(n))}var FS={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var n in FS){var t=FS[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 kS={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var n in kS){var t=kS[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 jS={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var n in jS){var t=jS[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 US=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var n=0;n<US.length;++n){var t=US[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 HS=["max","min","atan2","pow"];(function(){for(var n=0;n<HS.length;++n){var t=HS[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 qS=["atan2","pow"];(function(){for(var n=0;n<qS.length;++n){var t=qS[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=Vr({args:["array"],pre:Kd,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=Vr({args:["array"],pre:Kd,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=Vr({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=Vr({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=Vr({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=Vr({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=Vr({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=Vr({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=Vr({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=Vr({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=Vr({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=Vr({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=Vr({args:["array","array"],pre:Kd,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 m1=hr((ile,h1)=>{h1.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 l3={};em(l3,{default:()=>tp});module.exports=k1(l3);var rp=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 j1=typeof global=="object"&&global&&global.Object===Object&&global,Cc=j1;var U1=typeof self=="object"&&self&&self.Object===Object&&self,H1=Cc||U1||Function("return this")(),Gt=H1;var q1=Gt.Symbol,Jt=q1;var rm=Object.prototype,W1=rm.hasOwnProperty,$1=rm.toString,ul=Jt?Jt.toStringTag:void 0;function Y1(n){var t=W1.call(n,ul),e=n[ul];try{n[ul]=void 0;var r=!0}catch{}var o=$1.call(n);return r&&(t?n[ul]=e:delete n[ul]),o}var om=Y1;var X1=Object.prototype,Q1=X1.toString;function K1(n){return Q1.call(n)}var nm=K1;var Z1="[object Null]",J1="[object Undefined]",im=Jt?Jt.toStringTag:void 0;function ew(n){return n==null?n===void 0?J1:Z1:im&&im in Object(n)?om(n):nm(n)}var Gr=ew;function tw(n){return n!=null&&typeof n=="object"}var sr=tw;var rw="[object Symbol]";function ow(n){return typeof n=="symbol"||sr(n)&&Gr(n)==rw}var ea=ow;function nw(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=nw;var iw=Array.isArray,Mt=iw;var aw=1/0,am=Jt?Jt.prototype:void 0,sm=am?am.toString:void 0;function lm(n){if(typeof n=="string")return n;if(Mt(n))return Tc(n,lm)+"";if(ea(n))return sm?sm.call(n):"";var t=n+"";return t=="0"&&1/n==-aw?"-0":t}var cm=lm;function sw(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var Fr=sw;function lw(n){return n}var um=lw;var cw="[object AsyncFunction]",uw="[object Function]",dw="[object GeneratorFunction]",pw="[object Proxy]";function fw(n){if(!Fr(n))return!1;var t=Gr(n);return t==uw||t==dw||t==cw||t==pw}var Mc=fw;var hw=Gt["__core-js_shared__"],Ic=hw;var dm=function(){var n=/[^.]+$/.exec(Ic&&Ic.keys&&Ic.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function mw(n){return!!dm&&dm in n}var pm=mw;var yw=Function.prototype,gw=yw.toString;function xw(n){if(n!=null){try{return gw.call(n)}catch{}try{return n+""}catch{}}return""}var Jo=xw;var bw=/[\\^$.*+?()[\]{}|]/g,vw=/^\[object .+?Constructor\]$/,Sw=Function.prototype,ww=Object.prototype,Aw=Sw.toString,_w=ww.hasOwnProperty,Pw=RegExp("^"+Aw.call(_w).replace(bw,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ow(n){if(!Fr(n)||pm(n))return!1;var t=Mc(n)?Pw:vw;return t.test(Jo(n))}var fm=Ow;function Cw(n,t){return n?.[t]}var hm=Cw;function Tw(n,t){var e=hm(n,t);return fm(e)?e:void 0}var Or=Tw;var Mw=Or(Gt,"WeakMap"),Nc=Mw;var mm=Object.create,Iw=function(){function n(){}return function(t){if(!Fr(t))return{};if(mm)return mm(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),ym=Iw;function Nw(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 gm=Nw;function Dw(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}var xm=Dw;var Ew=800,Bw=16,Lw=Date.now;function Rw(n){var t=0,e=0;return function(){var r=Lw(),o=Bw-(r-e);if(e=r,o>0){if(++t>=Ew)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var bm=Rw;function Vw(n){return function(){return n}}var vm=Vw;var zw=function(){try{var n=Or(Object,"defineProperty");return n({},"",{}),n}catch{}}(),ta=zw;var Gw=ta?function(n,t){return ta(n,"toString",{configurable:!0,enumerable:!1,value:vm(t),writable:!0})}:um,Sm=Gw;var Fw=bm(Sm),wm=Fw;function kw(n,t){for(var e=-1,r=n==null?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}var Am=kw;var jw=9007199254740991,Uw=/^(?:0|[1-9]\d*)$/;function Hw(n,t){var e=typeof n;return t=t??jw,!!t&&(e=="number"||e!="symbol"&&Uw.test(n))&&n>-1&&n%1==0&&n<t}var ra=Hw;function qw(n,t,e){t=="__proto__"&&ta?ta(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}var Dc=qw;function Ww(n,t){return n===t||n!==n&&t!==t}var oa=Ww;var $w=Object.prototype,Yw=$w.hasOwnProperty;function Xw(n,t,e){var r=n[t];(!(Yw.call(n,t)&&oa(r,e))||e===void 0&&!(t in n))&&Dc(n,t,e)}var na=Xw;function Qw(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=Qw;var _m=Math.max;function Kw(n,t,e){return t=_m(t===void 0?n.length-1:t,0),function(){for(var r=arguments,o=-1,i=_m(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),gm(n,this,s)}}var Pm=Kw;var Zw=9007199254740991;function Jw(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=Zw}var ia=Jw;function e2(n){return n!=null&&ia(n.length)&&!Mc(n)}var Ec=e2;var t2=Object.prototype;function r2(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||t2;return n===e}var aa=r2;function o2(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var Om=o2;var n2="[object Arguments]";function i2(n){return sr(n)&&Gr(n)==n2}var hp=i2;var Cm=Object.prototype,a2=Cm.hasOwnProperty,s2=Cm.propertyIsEnumerable,l2=hp(function(){return arguments}())?hp:function(n){return sr(n)&&a2.call(n,"callee")&&!s2.call(n,"callee")},sa=l2;function c2(){return!1}var Tm=c2;var Nm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mm=Nm&&typeof module=="object"&&module&&!module.nodeType&&module,u2=Mm&&Mm.exports===Nm,Im=u2?Gt.Buffer:void 0,d2=Im?Im.isBuffer:void 0,p2=d2||Tm,xi=p2;var f2="[object Arguments]",h2="[object Array]",m2="[object Boolean]",y2="[object Date]",g2="[object Error]",x2="[object Function]",b2="[object Map]",v2="[object Number]",S2="[object Object]",w2="[object RegExp]",A2="[object Set]",_2="[object String]",P2="[object WeakMap]",O2="[object ArrayBuffer]",C2="[object DataView]",T2="[object Float32Array]",M2="[object Float64Array]",I2="[object Int8Array]",N2="[object Int16Array]",D2="[object Int32Array]",E2="[object Uint8Array]",B2="[object Uint8ClampedArray]",L2="[object Uint16Array]",R2="[object Uint32Array]",gt={};gt[T2]=gt[M2]=gt[I2]=gt[N2]=gt[D2]=gt[E2]=gt[B2]=gt[L2]=gt[R2]=!0;gt[f2]=gt[h2]=gt[O2]=gt[m2]=gt[C2]=gt[y2]=gt[g2]=gt[x2]=gt[b2]=gt[v2]=gt[S2]=gt[w2]=gt[A2]=gt[_2]=gt[P2]=!1;function V2(n){return sr(n)&&ia(n.length)&&!!gt[Gr(n)]}var Dm=V2;function z2(n){return function(t){return n(t)}}var la=z2;var Em=typeof exports=="object"&&exports&&!exports.nodeType&&exports,dl=Em&&typeof module=="object"&&module&&!module.nodeType&&module,G2=dl&&dl.exports===Em,mp=G2&&Cc.process,F2=function(){try{var n=dl&&dl.require&&dl.require("util").types;return n||mp&&mp.binding&&mp.binding("util")}catch{}}(),en=F2;var Bm=en&&en.isTypedArray,k2=Bm?la(Bm):Dm,Bc=k2;var j2=Object.prototype,U2=j2.hasOwnProperty;function H2(n,t){var e=Mt(n),r=!e&&sa(n),o=!e&&!r&&xi(n),i=!e&&!r&&!o&&Bc(n),a=e||r||o||i,s=a?Om(n.length,String):[],l=s.length;for(var u in n)(t||U2.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=H2;function q2(n,t){return function(e){return n(t(e))}}var Rc=q2;var W2=Rc(Object.keys,Object),Lm=W2;var $2=Object.prototype,Y2=$2.hasOwnProperty;function X2(n){if(!aa(n))return Lm(n);var t=[];for(var e in Object(n))Y2.call(n,e)&&e!="constructor"&&t.push(e);return t}var Rm=X2;function Q2(n){return Ec(n)?Lc(n):Rm(n)}var ca=Q2;function K2(n){var t=[];if(n!=null)for(var e in Object(n))t.push(e);return t}var Vm=K2;var Z2=Object.prototype,J2=Z2.hasOwnProperty;function eA(n){if(!Fr(n))return Vm(n);var t=aa(n),e=[];for(var r in n)r=="constructor"&&(t||!J2.call(n,r))||e.push(r);return e}var zm=eA;function tA(n){return Ec(n)?Lc(n,!0):zm(n)}var ua=tA;var rA=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,oA=/^\w*$/;function nA(n,t){if(Mt(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||ea(n)?!0:oA.test(n)||!rA.test(n)||t!=null&&n in Object(t)}var Gm=nA;var iA=Or(Object,"create"),tn=iA;function aA(){this.__data__=tn?tn(null):{},this.size=0}var Fm=aA;function sA(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var km=sA;var lA="__lodash_hash_undefined__",cA=Object.prototype,uA=cA.hasOwnProperty;function dA(n){var t=this.__data__;if(tn){var e=t[n];return e===lA?void 0:e}return uA.call(t,n)?t[n]:void 0}var jm=dA;var pA=Object.prototype,fA=pA.hasOwnProperty;function hA(n){var t=this.__data__;return tn?t[n]!==void 0:fA.call(t,n)}var Um=hA;var mA="__lodash_hash_undefined__";function yA(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=tn&&t===void 0?mA:t,this}var Hm=yA;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=Fm;da.prototype.delete=km;da.prototype.get=jm;da.prototype.has=Um;da.prototype.set=Hm;var yp=da;function gA(){this.__data__=[],this.size=0}var qm=gA;function xA(n,t){for(var e=n.length;e--;)if(oa(n[e][0],t))return e;return-1}var Cn=xA;var bA=Array.prototype,vA=bA.splice;function SA(n){var t=this.__data__,e=Cn(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():vA.call(t,e,1),--this.size,!0}var Wm=SA;function wA(n){var t=this.__data__,e=Cn(t,n);return e<0?void 0:t[e][1]}var $m=wA;function AA(n){return Cn(this.__data__,n)>-1}var Ym=AA;function _A(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 Xm=_A;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=qm;pa.prototype.delete=Wm;pa.prototype.get=$m;pa.prototype.has=Ym;pa.prototype.set=Xm;var Tn=pa;var PA=Or(Gt,"Map"),Mn=PA;function OA(){this.size=0,this.__data__={hash:new yp,map:new(Mn||Tn),string:new yp}}var Qm=OA;function CA(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var Km=CA;function TA(n,t){var e=n.__data__;return Km(t)?e[typeof t=="string"?"string":"hash"]:e.map}var In=TA;function MA(n){var t=In(this,n).delete(n);return this.size-=t?1:0,t}var Zm=MA;function IA(n){return In(this,n).get(n)}var Jm=IA;function NA(n){return In(this,n).has(n)}var ey=NA;function DA(n,t){var e=In(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var ty=DA;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=Qm;fa.prototype.delete=Zm;fa.prototype.get=Jm;fa.prototype.has=ey;fa.prototype.set=ty;var bi=fa;var EA="Expected a function";function gp(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(EA);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(gp.Cache||bi),e}gp.Cache=bi;var ry=gp;var BA=500;function LA(n){var t=ry(n,function(r){return e.size===BA&&e.clear(),r}),e=t.cache;return t}var oy=LA;var RA=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,VA=/\\(\\)?/g,zA=oy(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(RA,function(e,r,o,i){t.push(o?i.replace(VA,"$1"):r||e)}),t}),ny=zA;function GA(n){return n==null?"":cm(n)}var iy=GA;function FA(n,t){return Mt(n)?n:Gm(n,t)?[n]:ny(iy(n))}var Yr=FA;var kA=1/0;function jA(n){if(typeof n=="string"||ea(n))return n;var t=n+"";return t=="0"&&1/n==-kA?"-0":t}var Nn=jA;function UA(n,t){t=Yr(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=UA;function HA(n,t){for(var e=-1,r=t.length,o=n.length;++e<r;)n[o+e]=t[e];return n}var ha=HA;var ay=Jt?Jt.isConcatSpreadable:void 0;function qA(n){return Mt(n)||sa(n)||!!(ay&&n&&n[ay])}var sy=qA;function ly(n,t,e,r,o){var i=-1,a=n.length;for(e||(e=sy),o||(o=[]);++i<a;){var s=n[i];t>0&&e(s)?t>1?ly(s,t-1,e,r,o):ha(o,s):r||(o[o.length]=s)}return o}var cy=ly;function WA(n){var t=n==null?0:n.length;return t?cy(n,1):[]}var uy=WA;function $A(n){return wm(Pm(n,void 0,uy),n+"")}var zc=$A;var YA=Rc(Object.getPrototypeOf,Object),ma=YA;var XA="[object Object]",QA=Function.prototype,KA=Object.prototype,dy=QA.toString,ZA=KA.hasOwnProperty,JA=dy.call(Object);function e_(n){if(!sr(n)||Gr(n)!=XA)return!1;var t=ma(n);if(t===null)return!0;var e=ZA.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&dy.call(e)==JA}var py=e_;function t_(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 fy=t_;function r_(){this.__data__=new Tn,this.size=0}var hy=r_;function o_(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var my=o_;function n_(n){return this.__data__.get(n)}var yy=n_;function i_(n){return this.__data__.has(n)}var gy=i_;var a_=200;function s_(n,t){var e=this.__data__;if(e instanceof Tn){var r=e.__data__;if(!Mn||r.length<a_-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new bi(r)}return e.set(n,t),this.size=e.size,this}var xy=s_;function ya(n){var t=this.__data__=new Tn(n);this.size=t.size}ya.prototype.clear=hy;ya.prototype.delete=my;ya.prototype.get=yy;ya.prototype.has=gy;ya.prototype.set=xy;var ga=ya;function l_(n,t){return n&&To(t,ca(t),n)}var by=l_;function c_(n,t){return n&&To(t,ua(t),n)}var vy=c_;var _y=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Sy=_y&&typeof module=="object"&&module&&!module.nodeType&&module,u_=Sy&&Sy.exports===_y,wy=u_?Gt.Buffer:void 0,Ay=wy?wy.allocUnsafe:void 0;function d_(n,t){if(t)return n.slice();var e=n.length,r=Ay?Ay(e):new n.constructor(e);return n.copy(r),r}var Py=d_;function p_(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 Oy=p_;function f_(){return[]}var Gc=f_;var h_=Object.prototype,m_=h_.propertyIsEnumerable,Cy=Object.getOwnPropertySymbols,y_=Cy?function(n){return n==null?[]:(n=Object(n),Oy(Cy(n),function(t){return m_.call(n,t)}))}:Gc,xa=y_;function g_(n,t){return To(n,xa(n),t)}var Ty=g_;var x_=Object.getOwnPropertySymbols,b_=x_?function(n){for(var t=[];n;)ha(t,xa(n)),n=ma(n);return t}:Gc,Fc=b_;function v_(n,t){return To(n,Fc(n),t)}var My=v_;function S_(n,t,e){var r=t(n);return Mt(n)?r:ha(r,e(n))}var kc=S_;function w_(n){return kc(n,ca,xa)}var pl=w_;function A_(n){return kc(n,ua,Fc)}var jc=A_;var __=Or(Gt,"DataView"),Uc=__;var P_=Or(Gt,"Promise"),Hc=P_;var O_=Or(Gt,"Set"),qc=O_;var Iy="[object Map]",C_="[object Object]",Ny="[object Promise]",Dy="[object Set]",Ey="[object WeakMap]",By="[object DataView]",T_=Jo(Uc),M_=Jo(Mn),I_=Jo(Hc),N_=Jo(qc),D_=Jo(Nc),vi=Gr;(Uc&&vi(new Uc(new ArrayBuffer(1)))!=By||Mn&&vi(new Mn)!=Iy||Hc&&vi(Hc.resolve())!=Ny||qc&&vi(new qc)!=Dy||Nc&&vi(new Nc)!=Ey)&&(vi=function(n){var t=Gr(n),e=t==C_?n.constructor:void 0,r=e?Jo(e):"";if(r)switch(r){case T_:return By;case M_:return Iy;case I_:return Ny;case N_:return Dy;case D_:return Ey}return t});var rn=vi;var E_=Object.prototype,B_=E_.hasOwnProperty;function L_(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&B_.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Ly=L_;var R_=Gt.Uint8Array,ba=R_;function V_(n){var t=new n.constructor(n.byteLength);return new ba(t).set(new ba(n)),t}var va=V_;function z_(n,t){var e=t?va(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Ry=z_;var G_=/\w*$/;function F_(n){var t=new n.constructor(n.source,G_.exec(n));return t.lastIndex=n.lastIndex,t}var Vy=F_;var zy=Jt?Jt.prototype:void 0,Gy=zy?zy.valueOf:void 0;function k_(n){return Gy?Object(Gy.call(n)):{}}var Fy=k_;function j_(n,t){var e=t?va(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var ky=j_;var U_="[object Boolean]",H_="[object Date]",q_="[object Map]",W_="[object Number]",$_="[object RegExp]",Y_="[object Set]",X_="[object String]",Q_="[object Symbol]",K_="[object ArrayBuffer]",Z_="[object DataView]",J_="[object Float32Array]",eP="[object Float64Array]",tP="[object Int8Array]",rP="[object Int16Array]",oP="[object Int32Array]",nP="[object Uint8Array]",iP="[object Uint8ClampedArray]",aP="[object Uint16Array]",sP="[object Uint32Array]";function lP(n,t,e){var r=n.constructor;switch(t){case K_:return va(n);case U_:case H_:return new r(+n);case Z_:return Ry(n,e);case J_:case eP:case tP:case rP:case oP:case nP:case iP:case aP:case sP:return ky(n,e);case q_:return new r;case W_:case X_:return new r(n);case $_:return Vy(n);case Y_:return new r;case Q_:return Fy(n)}}var jy=lP;function cP(n){return typeof n.constructor=="function"&&!aa(n)?ym(ma(n)):{}}var Uy=cP;var uP="[object Map]";function dP(n){return sr(n)&&rn(n)==uP}var Hy=dP;var qy=en&&en.isMap,pP=qy?la(qy):Hy,Wy=pP;var fP="[object Set]";function hP(n){return sr(n)&&rn(n)==fP}var $y=hP;var Yy=en&&en.isSet,mP=Yy?la(Yy):$y,Xy=mP;var yP=1,gP=2,xP=4,Qy="[object Arguments]",bP="[object Array]",vP="[object Boolean]",SP="[object Date]",wP="[object Error]",Ky="[object Function]",AP="[object GeneratorFunction]",_P="[object Map]",PP="[object Number]",Zy="[object Object]",OP="[object RegExp]",CP="[object Set]",TP="[object String]",MP="[object Symbol]",IP="[object WeakMap]",NP="[object ArrayBuffer]",DP="[object DataView]",EP="[object Float32Array]",BP="[object Float64Array]",LP="[object Int8Array]",RP="[object Int16Array]",VP="[object Int32Array]",zP="[object Uint8Array]",GP="[object Uint8ClampedArray]",FP="[object Uint16Array]",kP="[object Uint32Array]",ht={};ht[Qy]=ht[bP]=ht[NP]=ht[DP]=ht[vP]=ht[SP]=ht[EP]=ht[BP]=ht[LP]=ht[RP]=ht[VP]=ht[_P]=ht[PP]=ht[Zy]=ht[OP]=ht[CP]=ht[TP]=ht[MP]=ht[zP]=ht[GP]=ht[FP]=ht[kP]=!0;ht[wP]=ht[Ky]=ht[IP]=!1;function Wc(n,t,e,r,o,i){var a,s=t&yP,l=t&gP,u=t&xP;if(e&&(a=o?e(n,r,o,i):e(n)),a!==void 0)return a;if(!Fr(n))return n;var c=Mt(n);if(c){if(a=Ly(n),!s)return xm(n,a)}else{var d=rn(n),p=d==Ky||d==AP;if(xi(n))return Py(n,s);if(d==Zy||d==Qy||p&&!o){if(a=l||p?{}:Uy(n),!s)return l?My(n,vy(a,n)):Ty(n,by(a,n))}else{if(!ht[d])return o?n:{};a=jy(n,d,s)}}i||(i=new ga);var f=i.get(n);if(f)return f;i.set(n,a),Xy(n)?n.forEach(function(y){a.add(Wc(y,t,e,y,n,i))}):Wy(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 Am(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 jP=1,UP=4;function HP(n){return $c(n,jP|UP)}var on=HP;var qP="__lodash_hash_undefined__";function WP(n){return this.__data__.set(n,qP),this}var Jy=WP;function $P(n){return this.__data__.has(n)}var eg=$P;function Yc(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new bi;++t<e;)this.add(n[t])}Yc.prototype.add=Yc.prototype.push=Jy;Yc.prototype.has=eg;var tg=Yc;function YP(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 rg=YP;function XP(n,t){return n.has(t)}var og=XP;var QP=1,KP=2;function ZP(n,t,e,r,o,i){var a=e&QP,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&KP?new tg: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(!rg(t,function(g,b){if(!og(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=ZP;function JP(n){var t=-1,e=Array(n.size);return n.forEach(function(r,o){e[++t]=[o,r]}),e}var ng=JP;function eO(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var ig=eO;var tO=1,rO=2,oO="[object Boolean]",nO="[object Date]",iO="[object Error]",aO="[object Map]",sO="[object Number]",lO="[object RegExp]",cO="[object Set]",uO="[object String]",dO="[object Symbol]",pO="[object ArrayBuffer]",fO="[object DataView]",ag=Jt?Jt.prototype:void 0,xp=ag?ag.valueOf:void 0;function hO(n,t,e,r,o,i,a){switch(e){case fO:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case pO:return!(n.byteLength!=t.byteLength||!i(new ba(n),new ba(t)));case oO:case nO:case sO:return oa(+n,+t);case iO:return n.name==t.name&&n.message==t.message;case lO:case uO:return n==t+"";case aO:var s=ng;case cO:var l=r&tO;if(s||(s=ig),n.size!=t.size&&!l)return!1;var u=a.get(n);if(u)return u==t;r|=rO,a.set(n,t);var c=Xc(s(n),s(t),r,o,i,a);return a.delete(n),c;case dO:if(xp)return xp.call(n)==xp.call(t)}return!1}var sg=hO;var mO=1,yO=Object.prototype,gO=yO.hasOwnProperty;function xO(n,t,e,r,o,i){var a=e&mO,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:gO.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 A=n.constructor,S=t.constructor;A!=S&&"constructor"in n&&"constructor"in t&&!(typeof A=="function"&&A instanceof A&&typeof S=="function"&&S instanceof S)&&(m=!1)}return i.delete(n),i.delete(t),m}var lg=xO;var bO=1,cg="[object Arguments]",ug="[object Array]",Qc="[object Object]",vO=Object.prototype,dg=vO.hasOwnProperty;function SO(n,t,e,r,o,i){var a=Mt(n),s=Mt(t),l=a?ug:rn(n),u=s?ug:rn(t);l=l==cg?Qc:l,u=u==cg?Qc:u;var c=l==Qc,d=u==Qc,p=l==u;if(p&&xi(n)){if(!xi(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):sg(n,t,l,e,r,o,i);if(!(e&bO)){var f=c&&dg.call(n,"__wrapped__"),h=d&&dg.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),lg(n,t,e,r,o,i)):!1}var pg=SO;function fg(n,t,e,r,o){return n===t?!0:n==null||t==null||!sr(n)&&!sr(t)?n!==n&&t!==t:pg(n,t,e,r,fg,o)}var hg=fg;function wO(n,t){return n!=null&&t in Object(n)}var mg=wO;function AO(n,t,e){t=Yr(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 yg=AO;function _O(n,t){return n!=null&&yg(n,t,mg)}var gg=_O;function PO(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var xg=PO;function OO(n,t){return t.length<2?n:Vc(n,fy(t,0,-1))}var bg=OO;function CO(n,t){return hg(n,t)}var bp=CO;function TO(n,t){return t=Yr(t,n),n=bg(n,t),n==null||delete n[Nn(xg(t))]}var vg=TO;function MO(n){return py(n)?void 0:n}var Sg=MO;var IO=1,NO=2,DO=4,EO=zc(function(n,t){var e={};if(n==null)return e;var r=!1;t=Tc(t,function(i){return i=Yr(i,n),r||(r=i.length>1),i}),To(n,jc(n),e),r&&(e=$c(e,IO|NO|DO,Sg));for(var o=t.length;o--;)vg(e,t[o]);return e}),Sa=EO;function BO(n,t,e,r){if(!Fr(n))return n;t=Yr(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=Fr(c)?c:ra(t[o+1])?[]:{})}na(s,l,u),s=s[l]}return n}var wg=BO;function LO(n,t,e){for(var r=-1,o=t.length,i={};++r<o;){var a=t[r],s=Vc(n,a);e(s,a)&&wg(i,Yr(a,n),s)}return i}var Ag=LO;function RO(n,t){return Ag(n,t,function(e,r){return gg(n,r)})}var _g=RO;var VO=zc(function(n,t){return n==null?{}:_g(n,t)}),uo=VO;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 Pg(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 Og(){return typeof process<"u"}function Cg(n,t){for(let e of n)t(e.id,e.data)!==!0&&Cg(e.children,t)}function Tg(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)Tg(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&&Tg(o,r)}}traverse(e){Cg(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)=>Pg(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 Og()||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 Sp(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=vp([i],l);return u?(console.log(u),u):i}else return i}r.filterOp=e})(Io||(Io={}));function vp(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=vp(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 zO(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=vp(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof we)return zO(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 Sp(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 Sp(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=Sp(n===void 0?void 0:n[o],t===void 0?void 0:t[o]);r[o]=i}return r}function Mg(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 GO(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Ig(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=Ig(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 FO(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=Ig(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof we)return FO(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&&GO(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]=Mg(d,{[h.id]:m});d=b;for(let A=0;A<w.length;A++){let S=w[A],P=S.pop();if(typeof P=="number"){let O=[P];for(let D=A+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 Ng=Symbol(),kO=Symbol(),tu=Symbol(),Si=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]}}}},Ap=class extends Si{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)}},_p=class extends Si{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))}},Dg={get(n,t){if(t===tu)return()=>{n._parent=null};if(t===Ng)return n._current;if(t===kO)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]}}},jO={...Dg,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}},UO={...Dg,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 Si{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 Si{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 wp(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 Si{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){wp(this.ts,e,t),wp(this.actual,r,t),wp(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 _p(n,t,e),UO):e!==null&&typeof e=="object"?Aa(e)?e:new Proxy(new Ap(n,t,e),jO):e}function Pp(n){let t=new eu(n);return[ru(t,"",n),t]}function Dn(n,t){let[e,r]=Pp(n);return t(e),r.result()}function At(n){return n instanceof Ca||n instanceof Ta?n._current:n!==null&&typeof n=="object"?n[Ng]: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 Eg(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 Fe(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 Cp;try{Cp=new TextDecoder}catch{}var de,Bn,G=0;var kg=[],Tp=kg,Mp=0,Cr={},Je,En,Xr=0,No=0,kr,nn,vr=[],rt,Bg={useRecords:!1,mapsAsObjects:!0},bl=class{},Np=new bl;Np.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 Wg(()=>(iu(),this?this.unpack(t,e):Do.prototype.unpack.call(Bg,t,e)));Bn=e>-1?e:t.length,G=0,Mp=0,No=0,En=null,Tp=kg,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(Cr=this,this.structures)return Je=this.structures,nu();(!Je||Je.length>0)&&(Je=[])}else Cr=Bg,(!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(!Cr.trusted&&!Ma){let t=Je.sharedLength||0;t<Je.length&&(Je.length=t)}let n=It();if(G==Bn)Je.restoreStructures&&Lg(),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&&Lg(),iu(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Lg(){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]||Cr.getStructures&&jg()[n&63];return t?(t.read||(t.read=Dp(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,Cr.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Hg()]=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-Xr,(G+=t)-Xr);if(No==0&&Bn<140){let e=t<16?Ep(t):Ug(t);if(e!=null)return e}return Ip(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)):Np;case 194:return!1;case 195:return!0;case 196:return Op(de[G++]);case 197:return t=rt.getUint16(G),G+=2,Op(t);case 198:return t=rt.getUint32(G),G+=4,Op(t);case 199:return wi(de[G++]);case 200:return t=rt.getUint16(G),G+=2,wi(t);case 201:return t=rt.getUint32(G),G+=4,wi(t);case 202:if(t=rt.getFloat32(G),Cr.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 Cr.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 Cr.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 Fg(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++,Fg(de[G++]&63,de[G++])):wi(2);case 214:return wi(4);case 215:return wi(8);case 216:return wi(16);case 217:return t=de[G++],No>=G?En.slice(G-Xr,(G+=t)-Xr):qO(t);case 218:return t=rt.getUint16(G),G+=2,No>=G?En.slice(G-Xr,(G+=t)-Xr):WO(t);case 219:return t=rt.getUint32(G),G+=4,No>=G?En.slice(G-Xr,(G+=t)-Xr):$O(t);case 220:return t=rt.getUint16(G),G+=2,Vg(t);case 221:return t=rt.getUint32(G),G+=4,Vg(t);case 222:return t=rt.getUint16(G),G+=2,zg(t);case 223:return t=rt.getUint32(G),G+=4,zg(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 HO=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Dp(n,t){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>HO.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(It);return n.highByte===0&&(n.read=Rg(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?Rg(t,e):e}var Rg=(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]||jg()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=Dp(o,n)),o.read()};function jg(){let n=Wg(()=>(de=null,Cr.getStructures()));return Je=Cr._mergeStructures(n,Je)}var Ip=au,qO=au,WO=au,$O=au;function au(n){let t;if(n<16&&(t=Ep(n)))return t;if(n>64&&Cp)return Cp.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+=er.apply(String,r),r.length=0)}return r.length>0&&(t+=er.apply(String,r)),t}function Vg(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=It();return t}function zg(n){if(Cr.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Hg()]=It();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(It(),It());return t}}var er=String.fromCharCode;function Ug(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 er.apply(String,e)}function Ep(n){if(n<4)if(n<2){if(n===0)return"";{let t=de[G++];if((t&128)>1){G-=1;return}return er(t)}}else{let t=de[G++],e=de[G++];if((t&128)>0||(e&128)>0){G-=2;return}if(n<3)return er(t,e);let r=de[G++];if((r&128)>0){G-=3;return}return er(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 er(t,e,r,o);{let i=de[G++];if((i&128)>0){G-=5;return}return er(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 er(t,e,r,o,i,a);let s=de[G++];if((s&128)>0){G-=7;return}return er(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 er(t,e,r,o,i,a,s,l);{let u=de[G++];if((u&128)>0){G-=9;return}return er(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 er(t,e,r,o,i,a,s,l,u,c);let d=de[G++];if((d&128)>0){G-=11;return}return er(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 er(t,e,r,o,i,a,s,l,u,c,d,p);{let f=de[G++];if((f&128)>0){G-=13;return}return er(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 er(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 er(t,e,r,o,i,a,s,l,u,c,d,p,f,h,m)}}}}}function Op(n){return Cr.copyBuffers?Uint8Array.prototype.slice.call(de,G,G+=n):de.subarray(G,G+=n)}function wi(n){let t=de[G++];if(vr[t])return vr[t](de.subarray(G,G+=n));throw new Error("Unknown extension type "+t)}var Gg=new Array(4096);function Hg(){let n=de[G++];if(n>=160&&n<192){if(n=n-160,No>=G)return En.slice(G-Xr,(G+=n)-Xr);if(!(No==0&&Bn<180))return Ip(n)}else return G--,It();let t=(n<<5^(n>1?rt.getUint16(G):n>0?de[G]:0))&4095,e=Gg[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=[],Gg[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?Ep(n):Ug(n);return s!=null?e.string=s:e.string=Ip(n)}var Fg=(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=Dp(e,r),e.read()},qg=typeof self=="object"?self:global;vr[0]=()=>{};vr[0].noBuffer=!0;vr[101]=()=>{let n=It();return(qg[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 Bp=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");vr[116]=n=>{let t=n[0],e=Bp[t];if(!e)throw new Error("Could not find typed array for code "+t);return new qg[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 Wg(n){let t=Bn,e=G,r=Mp,o=Xr,i=No,a=En,s=Tp,l=nn,u=kr,c=new Uint8Array(de.slice(0,Bn)),d=Je,p=Je.slice(0,Je.length),f=Cr,h=Ma,m=n();return Bn=t,G=e,Mp=r,Xr=o,No=i,En=a,Tp=s,nn=l,kr=u,de=c,Ma=h,Je=d,Je.splice(0,Je.length,...p),Cr=f,rt=new DataView(de.buffer,de.byteOffset,de.byteLength),m}function iu(){de=null,nn=null,Je=null}function $g(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}),YO=lu.unpack,XO=lu.unpackMultiple,QO=lu.unpack,cu={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},KO=new Float32Array(1),CG=new Uint8Array(KO.buffer,0,4);var uu;try{uu=new TextEncoder}catch{}var du,Rp,pu=typeof Buffer<"u",Lp=pu?Buffer.allocUnsafeSlow:Uint8Array,Kg=pu?Buffer:Uint8Array,Yg=pu?4294967296:2144337920,K,Lt,j=0,Eo,Bo=null,ZO=/[\u0080-\uFFFF]/,vl=Symbol("record-id"),Ai=class extends Do{constructor(t){super(t),this.offset=0;let e,r,o,i,a,s,l=0,u=Kg.prototype.utf8Write?function(x,D,N){return K.utf8Write(x,D,N)}:uu&&uu.encodeInto?function(x,D){return uu.encodeInto(x,K.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,A=0;this.pack=this.encode=function(x,D){if(K||(K=new Lp(8192),Lt=new DataView(K.buffer,0,8192),j=0),Eo=K.length-10,Eo-j<2048?(K=new Lp(K.length),Lt=new DataView(K.buffer,0,K.length),Eo=K.length-10,j=0):j=j+7&2147483640,r=j,s=c.structuredClone?new Map:null,c.bundleStrings?(Bo=["",""],K[j++]=214,K[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,F=I.length;R<F;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=eC(K.subarray(r,j),s.idsToInsert);return s=null,N}return D&Jg?(K.start=r,K.end=j,K):K.subarray(r,j)}finally{if(o){if(A<10&&A++,w>1e4)o.transitions=null,A=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=K.subarray(r,j);return c.saveStructures(o,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(x)):(l=N,T)}}D&sC&&(j=r)}};let S=x=>{j>Eo&&(K=O(j));var D=typeof x,N;if(D==="string"){let T=x.length;if(Bo&&T>=8&&T<4096){let B=ZO.test(x);Bo[B?0:1]+=x,K[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&&(K=O(j+E)),T<64||!u){let B,R,F,V=j+I;for(B=0;B<T;B++)R=x.charCodeAt(B),R<128?K[V++]=R:R<2048?(K[V++]=R>>6|192,K[V++]=R&63|128):(R&64512)===55296&&((F=x.charCodeAt(B+1))&64512)===56320?(R=65536+((R&1023)<<10)+(F&1023),B++,K[V++]=R>>18|240,K[V++]=R>>12&63|128,K[V++]=R>>6&63|128,K[V++]=R&63|128):(K[V++]=R>>12|224,K[V++]=R>>6&63|128,K[V++]=R&63|128);N=V-j-I}else N=u(x,j+I,E);N<32?K[j++]=160|N:N<256?(I<2&&K.copyWithin(j+2,j+1,j+1+N),K[j++]=217,K[j++]=N):N<65536?(I<3&&K.copyWithin(j+3,j+2,j+2+N),K[j++]=218,K[j++]=N>>8,K[j++]=N&255):(I<5&&K.copyWithin(j+5,j+3,j+3+N),K[j++]=219,Lt.setUint32(j,N),j+=4),j+=N}else if(D==="number")if(x>>>0===x)x<64?K[j++]=x:x<256?(K[j++]=204,K[j++]=x):x<65536?(K[j++]=205,K[j++]=x>>8,K[j++]=x&255):(K[j++]=206,Lt.setUint32(j,x),j+=4);else if(x>>0===x)x>=-32?K[j++]=256+x:x>=-128?(K[j++]=208,K[j++]=x+256):x>=-32768?(K[j++]=209,Lt.setInt16(j,x),j+=2):(K[j++]=210,Lt.setInt32(j,x),j+=4);else{let T;if((T=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){K[j++]=202,Lt.setFloat32(j,x);let I;if(T<4||(I=x*su[(K[j]&127)<<1|K[j+1]>>7])>>0===I){j+=4;return}else j--}K[j++]=203,Lt.setFloat64(j,x),j+=8}else if(D==="object")if(!x)K[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)}K[j++]=214,K[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?K[j++]=144|N:N<65536?(K[j++]=220,K[j++]=N>>8,K[j++]=N&255):(K[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?K[j++]=128|N:N<65536?(K[j++]=222,K[j++]=N>>8,K[j++]=N&255):(K[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=Rp[I];if(x instanceof B){let R=du[I];if(R.write){R.type&&(K[j++]=212,K[j++]=R.type,K[j++]=0),S(R.write.call(this,x));return}let F=K,V=Lt,q=j;K=null;let k;try{k=R.pack.call(this,x,U=>(K=F,F=null,j+=U,j>Eo&&O(j),{target:K,targetView:Lt,position:j-U}),S)}finally{F&&(K=F,Lt=V,j=q,Eo=K.length-10)}k&&(k.length+j>Eo&&O(k.length+j),j=JO(k,K,j,R.type));return}}P(x,!x.hasOwnProperty)}}else if(D==="boolean")K[j++]=x?195:194;else if(D==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))K[j++]=211,Lt.setBigInt64(j,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)K[j++]=207,Lt.setBigUint64(j,x);else if(this.largeBigIntToFloat)K[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?K[j++]=192:(K[j++]=212,K[j++]=0,K[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?K[j++]=128|N:N<65536?(K[j++]=222,K[j++]=N>>8,K[j++]=N&255):(K[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)=>{K[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++);K[N+++r]=T>>8,K[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 F=D[B];N=T[F],N||(N=T[F]=Object.create(null),I++),T=N}let E=T[vl];if(E)E>=96&&m?(K[j++]=((E-=96)&31)+96,K[j++]=E>>5):K[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?(K[j++]=(E&31)+96,K[j++]=B):K[j++]=E):(B>=0?(K[j++]=213,K[j++]=114,K[j++]=(E&31)+96,K[j++]=B):(K[j++]=212,K[j++]=114,K[j++]=E),I&&(w+=A*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>Yg)throw new Error("Packed buffer would be larger than maximum buffer size");D=Math.min(Yg,Math.round(Math.max((x-r)*(x>67108864?1.25:2),4194304)/4096)*4096)}else D=(Math.max(x-r<<2,K.length-1)>>12)+1<<12;let N=new Lp(D);return Lt=new DataView(N.buffer,0,D),K.copy?K.copy(N,0,r,x):N.set(K.slice(r,x)),j-=r,r=0,Eo=N.length-10,K=N}}useBuffer(t){K=t,Lt=new DataView(K.buffer,K.byteOffset,K.byteLength),j=0}};Rp=[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?Xg(n,16,t):Qg(pu?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==Kg&&this.structuredClone?Xg(n,Bp.indexOf(e.name),t):Qg(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function Xg(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 Qg(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 JO(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 eC(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)");Rp.unshift(n.Class),du.unshift(n)}$g(n)}var Zg=new Ai({useRecords:!1}),tC=Zg.pack,rC=Zg.pack;var{NEVER:oC,ALWAYS:nC,DECIMAL_ROUND:iC,DECIMAL_FIT:aC}=cu,Jg=512,sC=1024;var e0=new Ai({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 lC(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 Vp(n){if(Aa(n))return n;if(Array.isArray(n))return n.map(Vp);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=Vp(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var fu;(r=>{function n(o){return e0.pack(o)}r.serialize=n;function t(o){return e0.unpack(o)}r.deserialize=t;function e(o){return lC(n(Vp(o))).toString()}r.checksum=e})(fu||(fu={}));var zn="personal camera",Gn="a218fcc3-276b-49b9-b485-49037fd14f5f",i0=2960946,Rt=5526619;var Ia;(f=>{function n(h,m){return h[0]===m[0]&&h[1]===m[1]}f.isEqual=n;function t(h,m,y){return[h[0]+(m[0]-h[0])*y,h[1]+(m[1]-h[1])*y]}f.lerp=t;function e(h,m){return[h[0]+m[0],h[1]+m[1]]}f.add=e;function r(h,m){return[h[0]-m[0],h[1]-m[1]]}f.sub=r;function o(h,m){return[h[0]*m[0],h[1]*m[1]]}f.multiply=o;function i(h,m){return[h[0]/m[0],h[1]/m[1]]}f.divide=i;function a(h,m){return Math.pow(m[0]-h[0],2)+Math.pow(m[1]-h[1],2)}f.distanceSquared=a;function s(h,m){return Math.sqrt(a(h,m))}f.distance=s;function l(h,m){return h[0]*m[0]+h[1]*m[1]}f.dot=l;function u(h,m){return[h[0]*m,h[1]*m]}f.scalarMultiply=u;function c(h,m,y){let g=f.sub(m,h),b=f.sub(y,h),w=f.dot(g,b)/f.dot(g,g),A=f.scalarMultiply(g,w);return f.add(h,A)}f.projectionOnto=c;function d(h,m,y){return s(h,c(h,m,y))}f.projectionOntoDistance=d;function p(h,m){return[(h[0]+m[0])*.5,(h[1]+m[1])*.5]}f.center=p})(Ia||(Ia={}));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 t0;(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})(t0||(t0={}));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 Ht;(d=>{function n(p){return typeof p=="object"&&typeof p.r=="number"&&typeof p.g=="number"&&typeof p.b=="number"}d.isRGB=n,d.white={r:1,g:1,b:1},d.red={r:1,g:0,b:0},d.black={r:0,g:0,b:0};function o(p){return{r:Math.round(p.r*255),g:Math.round(p.g*255),b:Math.round(p.b*255),a:1}}d.toRgb255a1=o;function i(p){return{r:p.r,g:p.g,b:p.b}}d.clone=i;function a(p){return p=Math.floor(p),{r:(p>>16&255)/255,g:(p>>8&255)/255,b:(p&255)/255}}d.fromHex=a;function s(p){return Math.round(p.r*255)*65536+Math.round(p.g*255)*256+Math.round(p.b*255)}d.toHex=s;function l(p,f){return p.r===f.r&&p.g===f.g&&p.b===f.b}d.equals=l;function u(p,f){return p.r.toFixed(2)===f.r.toFixed(2)&&p.g.toFixed(2)===f.g.toFixed(2)&&p.b.toFixed(2)===f.b.toFixed(2)}d.equalsFixed=u;function c(p,f,h){return{r:p.r+(f.r-p.r)*h,g:p.g+(f.g-p.g)*h,b:p.b+(f.b-p.b)*h}}d.lerp=c})(Ht||(Ht={}));var Be;(u=>{u.white={...Ht.white,a:1},u.transparent={...Ht.white,a:0};function e(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}u.from0to1=e;function r(c,d){return{...Ht.fromHex(c),a:d}}u.fromHexAndA=r;function o(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:c.a}}u.toRgb255a1=o;function i(c,d){return Ht.equals(c,d)&&c.a===d.a}u.equals=i;function a(c,d){return Ht.equalsFixed(c,d)&&c.a.toFixed(2)===d.a.toFixed(2)}u.equalsFixed=a;function s(c,d,p){return{r:c.r+(d.r-c.r)*p,g:c.g+(d.g-c.g)*p,b:c.b+(d.b-c.b)*p,a:c.a+(d.a-c.a)*p}}u.lerp=s;function l({r:c,g:d,b:p,a:f}=u.white){return`rgba(${c*255}, ${d*255}, ${p*255}, ${f})`}u.toStyle=l})(Be||(Be={}));var hu;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(hu||(hu={}));var r0;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(r0||(r0={}));var o0;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(o0||(o0={}));var n0;(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]))(n0||(n0={}));function zp(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 Fn;(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??1:i.orthographic?.zoom??1}o.getZoom=r})(Fn||(Fn={}));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(cC.forEach(a=>{Object.assign(i,{[a]:o[a]??r[a]})}),i.radial={...r.radial},o.radial){let a=r.radial,s=o.radial;uC.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;dC.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;pC.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;fC.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;hC.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 cC=["count"],uC=["radius","start","end","position","scale","rotation"],dC=["position","scale","rotation"],pC=["count","size"],fC=["count","position","scale","rotation"],hC=["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 Na;(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}))(Na||(Na={}));var kn;(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]})(kn||(kn={}));var Gp;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}e.equals=t})(Gp||(Gp={}));var Fp;(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})(Fp||(Fp={}));var xu;(t=>t.defaultData={...Fp.defaultData,...Gp.defaultData})(xu||(xu={}));var a0;(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})(a0||(a0={}));var Da;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Da||(Da={}));var s0;(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})(s0||(s0={}));function c0(n){return n.type!=="displace"}var l0;(t=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=n})(l0||(l0={}));var u0=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],d0=["wrapping","image","video","name","minFilter"],Ft;(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],rotation:0,minFilter:1008},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Da.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},crop:!1};case"color":return{...a,type:"color",color:Ht.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:{...Ht.fromHex(6710886),a:1},colorB:{...Ht.fromHex(6710886),a:1},colorC:{...Ht.fromHex(16777215),a:1},colorD:{...Ht.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],rotation: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:{...Ht.fromHex(0),a:1},colorB:{...Ht.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}}}})(Ft||(Ft={}));var lr;(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:Ft.defaultData("light",c),id:d}),f.push({fi:1,data:Ft.defaultData("color"),id:p}),{layers:f}}u.defaultTwoLayerData=i;function a(c){let d=Ft.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:{...Ft.defaultData("transmission"),alpha:1},id:"layer2"}),p.push({fi:2,data:{...Ft.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:p}}u.defaultUIObjectMaterial=a;function s(c,d="phong",p="layer1",f="layer2"){let h=Ft.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:Ft.defaultData("light",d),id:f}),{layers:m}}u.defaultTwoLayerTextureData=s;function l(c,d="phong",p="layer1",f="layer2"){let h=Ft.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:Ft.defaultData("light",d),id:f}),{layers:m}}u.defaultTwoLayerVideoTextureData=l})(lr||(lr={}));var Ea;(t=>{function n(){return{points:new we,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(Ea||(Ea={}));var Ba;(t=>{function n(){return{points:new we,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=n})(Ba||(Ba={}));var kp={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var bu;(t=>{function n(e,r){let o={...e};return mC.forEach(i=>{Object.assign(o,{[i]:r[i]??e[i]})}),o}t.merge=n})(bu||(bu={}));var vu={shape:kp,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},mC=["depth","offset","angle","twist","startScale","endScale"];var Sl;(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})(Sl||(Sl={}));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:Ba.defaultData(),extrusion:vu};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Ea.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:Ht.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 jp;(t=>t.defaultData={softShadowQuality:"low"})(jp||(jp={}));var Up;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Up||(Up={}));var Hp;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Hp||(Hp={}));var wl;(t=>t.defaultData={usePhysics:!1,gravity:-10})(wl||(wl={}));var qp;(t=>t.defaultData={playCamera:zn,gameControlObject:null})(qp||(qp={}));var _u;(t=>t.defaultData={backgroundColor:Be.fromHexAndA(i0,1),postprocessing:Au.defaultData,fog:wu.defaultData,globalPhysics:wl.defaultData,ambient:Up.defaultData,ao:Hp.defaultData,shadow:jp.defaultData,publish:qp.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 p0;(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(p0||(p0={}));var La;(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})(La||(La={}));var qt;(t=>t.defaultData={states:new we,events:new we,visible:!0,raycastLock:!1,physics:kn.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...La.identity,cloner:null})(qt||(qt={}));var Ou;(t=>t.defaultData={type:"Empty",...qt.defaultData})(Ou||(Ou={}));var f0;(t=>t.defaultData={type:"ParticleCollider",...Pu.defaultData,...qt.defaultData})(f0||(f0={}));var h0;(t=>t.defaultData={type:"Component",...qt.defaultData})(h0||(h0={}));var m0;(t=>t.defaultData={type:"Particle",...qt.defaultData,...Na.defaultData})(m0||(m0={}));var _i;(t=>t.defaultData={type:"Mesh",...qt.defaultData,...xu.defaultData})(_i||(_i={}));var Pi;(t=>t.defaultData={...qt.defaultData,...La.identity,position:[0,0,Fn.DefaultTargetOffset],...Fn.defaultData})(Pi||(Pi={}));var Cu;(e=>{function n(r){return{...qt.defaultData,...gu.defaultData(r)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Cu||(Cu={}));var Ra;(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})(Ra||(Ra={}));var Ro;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function r(a,s){return{...qt.defaultData,...s,component:a,overrides:new dt,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=r;function o(a){let s=La.fromObject(a.data);return r(a.id,s)}i.fromComponentData=o})(Ro||(Ro={}));var an;(e=>{e.defaultData={type:"Page",...qt.defaultData,physics:{...kn.defaultData,fusedBody:!1},..._u.defaultData,camera:Pi.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:kn.defaultData,states:new we,events:new we,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Fn.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",...qt.defaultData,..._i.defaultData,geometry:jn.defaultData("RectangleGeometry"),material:lr.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...qt.defaultData,..._i.defaultData,geometry:jn.defaultData("BooleanGeometry"),material:lr.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...qt.defaultData,..._i.defaultData,geometry:jn.defaultData("TextGeometry"),material:lr.defaultTwoLayerData("phong","layer1","layer2")}))(Tu||(Tu={}));var Oi;(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&&Ft.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&&Ft.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,La.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=Ht.clone(l.color))}return s}o.patch=r})(Oi||(Oi={}));var Va;(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})(Va||(Va={}));var fo;(t=>t.defaultData={orbitControls:Va.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 Wp;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Wp||(Wp={}));var $p;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})($p||($p={}));var sn;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Wp.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:$p.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(sn||(sn={}));var y0;(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=za.getComponentData(r,s.component)?.data;l&&i(a,s,l.events)}else i(a,s,s.events)})}e.traverseModuleInstances=t})(y0||(y0={}));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 Ga;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Ga||(Ga={}));var Fa;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Fa||(Fa={}));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 Yp;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(Yp||(Yp={}));var g0;(t=>t.all=[...Yp.all,"components"])(g0||(g0={}));var x0;(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})(x0||(x0={}));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 Kr;(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"]={...Fa.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})(Kr||(Kr={}));var Al=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 b0(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]=lr.defaultData(),o=r.materials[i]),typeof o!="string"&&t(o)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=lr.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=lr.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 yC(n){Object.assign(n.scene.publish,{orbitControls:{...Va.defaultData,...At(n.scene.publish.orbitControls)}})}function gC(n){Object.assign(n.scene.publish.settings,{video:{...fo.defaultData.settings.video,...At(n.scene.publish.settings.video)}})}function xC(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((u0.includes(o)||typeof i=="boolean")&&delete r[o],o==="texture")for(let[a,s]of Object.entries(i))(d0.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 bC(n){n.scene.publish.withBackground=!0}function vC(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function SC(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 wC(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 AC(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 _C(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 PC(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 v0(n){n.layers===void 0&&Object.assign(n,lr.defaultTwoLayerData("lambert"))}function Xp(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 OC(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function S0(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&Xp(r)}):"material"in e&&typeof e.material!="string"&&Xp(e.material)}),Object.values(n.shared.materials).forEach(t=>Xp(t))}function CC(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 TC(n){n.shared.audios=br({},be.prototype)}function MC(n){n.shared.videos=br({},be.prototype)}function IC(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 NC(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 DC(n){n.scene.publish.settings.web.preload=!1}function w0(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 A0(n){n.layers&&n.layers.forEach(t=>{c0(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 EC(n){n.shared.fonts=br({},be.prototype)}function BC(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 LC(n){let t=[];n.scene.objects.traverse((e,r)=>{let o=r;if(o.type==="TextFrame"){let i=lr.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=BC(o.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let l={name:o.name,...qt.defaultData,..._i.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 RC(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:Al.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:Al.MathUtils.generateUUID(),data:u},{fi:1,id:Al.MathUtils.generateUUID(),data:p})};i.push({fi:l,id:s,data:f})}),delete o.targets)}})})}function VC(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:Al.MathUtils.generateUUID(),data:{type:o,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function _0(n){let t=n.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Ft.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function P0(n){un(n,_0),dn(n,_0)}function zC(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function GC(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 FC(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=lr.defaultTwoLayerData("phong"))})}function kC(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 jC(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 UC(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 HC(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function qC(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function WC(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function $C(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Nu.defaultDataThirdPerson.navmesh)})})}function YC(n){n.scene.styles||(n.scene.styles=sn.defaultData())}function O0(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function XC(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,O0),un(n,O0)}function QC(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new we})})})}function KC(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function C0(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function T0(n,t){if(t<1&&(dn(n,b0),un(n,b0),n.schema=1),t<2&&(yC(n),n.schema=2),t<3&&(xC(n),n.schema=3),t<4&&(bC(n),n.schema=4),t<5&&(vC(n),n.schema=5),t<6&&(SC(n),n.schema=6),t<7&&(wC(n),n.schema=7),t<8&&(n.schema=8),t<9&&(S0(n),n.schema=9),t<10&&(OC(n),n.schema=10),t<11&&(CC(n),n.schema=11),t<12&&(S0(n),n.schema=12),t<13&&(TC(n),n.schema=13),t<14&&(IC(n),n.schema=14),t<15&&(NC(n),n.schema=15),t<16&&(DC(n),n.schema=16),t<17&&(dn(n,w0),un(n,w0),n.schema=17),t<18&&(dn(n,v0),un(n,v0),n.schema=18),t<19&&(gC(n),n.schema=19),t<20&&(EC(n),LC(n),n.schema=20),t<21&&(RC(n),VC(n),n.schema=21),t<22&&(P0(n),n.schema=22),t<23&&(zC(n),n.schema=23),t<24&&(GC(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(MC(n),t<25&&(n.schema=25)),t<26&&(AC(n),n.schema=26),t<27&&(_C(n),n.schema=27),t<28&&(P0(n),n.schema=28),t<29&&(PC(n),n.schema=29),t<30&&(FC(n),n.schema=30),t<31&&(kC(n),n.schema=31),t<33&&(jC(n),n.schema=33),t<34&&(UC(n),n.schema=34),t<35&&(HC(n),n.schema=35),t<36&&(qC(n),n.schema=36),t<37&&(WC(n),n.schema=37),t<38&&(dn(n,A0),un(n,A0),n.schema=38),t<39&&($C(n),n.schema=39),t<40&&(YC(n),n.schema=40),t<41&&(XC(n),n.schema=41),t<42&&(QC(n),n.schema=42),t<43&&(KC(n),n.schema=43),t<99){dn(n,C0),un(n,C0),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:{...wl.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,kn.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),n.schema=99}}function M0(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function ZC(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 JC(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 I0(n){n.rotation=n.rotation.slice(0,3).map(t=>t*ka)}function N0(n){I0(n),n.type==="Page"&&I0(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 eT(n){n.shared.variables=br({},be.prototype)}function tT(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 D0(n,t){t(n.data);for(let e of n.children)D0(e,t)}function rT(n){let t=n.schema??104;t!==Vo&&t<105&&(D0(n.asset,N0),n.schema=105)}function oT(n){n.shared.particles=br({},be.prototype),n.shared.lib&&(n.shared.lib.particles=cn.defaultData().particles)}function nT(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),T0(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=fo.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(dn(n,M0),un(n,M0),n.schema=101),t<102&&(ZC(n),n.schema=102),t<104&&(n.shared.catelogs=new be,n.shared.lib=cn.defaultData(),n.schema=104),t<105&&(eT(n),n.scene.objects.traverse((e,r)=>{N0(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))rT(e);t<106&&(tT(n),n.schema=106),t<107&&(n.shared.lib.variables=cn.defaultData().variables,n.schema=107),t<109&&(oT(n),n.schema=109),t<110&&(nT(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{JC(r)}),n.schema=111)}}var za;(l=>{l.defaultData={schema:Vo,scene:ln.defaultData,frames:new be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ga.defaultData),shared:{...Kr.emptyData(),colors:Kr.defaultColors()}},l.emptyDataForImports=function(u){let c=ln.emptyDataWithPage(u);return{schema:Vo,scene:c,frames:new be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ga.defaultData),shared:{...Kr.emptyData(),colors:Kr.defaultColors(),images:Kr.defaultImages(u)}}},l.emptyData=function(){return{schema:Vo,scene:ln.emptyDataWithPage(),frames:new be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ga.defaultData),shared:Kr.emptyData()}},l.clipboard2dData=function(){return{schema:Vo,scene:ln.emptyData(),frames:new be,shared:Kr.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})(za||(za={}));var E0;(t=>{function n(e){return!0}t.is=n})(E0||(E0={}));var Eu;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(o,i){return{position:i?.position??o.position,rotation:i?.rotation??o.rotation,scale:i?.scale??o.scale,shear:i?.shear??o.shear}}r.merge=t;function e(o,i){return _c({position:Ia.isEqual(o.position,i.position)?void 0:i.position,rotation:o.rotation===i.rotation?void 0:i.rotation,scale:Ia.isEqual(o.scale,i.scale)?void 0:i.scale,shear:o.shear&&i.shear&&Ia.isEqual(o.shear,i.shear)?void 0:i.shear})}r.diff=e})(Eu||(Eu={}));var Qp;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(Qp||(Qp={}));var Bu;(t=>t.defaultData={opacity:1,fill:{color:Be.fromHexAndA(Rt,1),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 Ci;(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})(Ci||(Ci={}));var _l;(t=>t.defaultData={...Eu.defaultData,...Qp.defaultData,states:new we,events:new we,visible:!0,raycastLock:!1})(_l||(_l={}));var ja;(t=>t.defaultData={..._l.defaultData,...Bu.defaultData})(ja||(ja={}));var Lu;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(Lu||(Lu={}));var Kp;(t=>t.defaultData={...ja.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(Kp||(Kp={}));var Ua;(t=>t.defaultData={...ja.defaultData,...Lu.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Ua||(Ua={}));var Zp;(t=>t.defaultData={...ja.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"})(Zp||(Zp={}));var Jp;(t=>t.defaultData={...ja.defaultData,type:"path2d",path:"",name:"Path"})(Jp||(Jp={}));var B0;(t=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=n})(B0||(B0={}));var Pl;(t=>t.defaultData={..._l.defaultData,name:"Group",type:"group2d"})(Pl||(Pl={}));var ef;(t=>t.defaultData={..._l.defaultData,...Lu.defaultData,...Bu.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Be.fromHexAndA(4737101,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}})(ef||(ef={}));var pn;(o=>{function n(i){switch(i){case"rectangle2d":return{...Ua.defaultData};case"ellipse2d":return{...Kp.defaultData};case"text2d":return{...Zp.defaultData};case"vector2d":return{...Ua.defaultData};case"path2d":return{...Jp.defaultData};case"frame2d":return{...ef.defaultData};case"group2d":return{...Pl.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"),js=ar(R0());var iT=.5*(Math.sqrt(3)-1),Ol=(3-Math.sqrt(3))/6,aT=1/3,zo=1/6,bU=(Math.sqrt(5)-1)/4,vU=(5-Math.sqrt(5))/20,Cl=n=>Math.floor(n)|0,V0=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]),rf=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=G0(n),e=new Float64Array(t).map(o=>V0[o%12*2]),r=new Float64Array(t).map(o=>V0[o%12*2+1]);return function(i,a){let s=0,l=0,u=0,c=(i+a)*iT,d=Cl(i+c),p=Cl(a+c),f=(d+p)*Ol,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 A=y-b+Ol,S=g-w+Ol,P=y-1+2*Ol,O=g-1+2*Ol,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-A*A-S*S;if(T>=0){let E=x+b+t[D+w],B=e[E],R=r[E];T*=T,l=T*T*(B*A+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 z0(n=Math.random){let t=G0(n),e=new Float64Array(t).map(i=>rf[i%12*3]),r=new Float64Array(t).map(i=>rf[i%12*3+1]),o=new Float64Array(t).map(i=>rf[i%12*3+2]);return function(a,s,l){let u,c,d,p,f=(a+s+l)*aT,h=Cl(a+f),m=Cl(s+f),y=Cl(l+f),g=(h+m+y)*zo,b=h-g,w=m-g,A=y-g,S=a-b,P=s-w,O=l-A,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,F=O-N+zo,V=S-T+2*zo,q=P-I+2*zo,k=O-E+2*zo,U=S-1+3*zo,H=P-1+3*zo,Y=O-1+3*zo,J=h&255,Z=m&255,X=y&255,te=.6-S*S-P*P-O*O;if(te<0)u=0;else{let W=J+t[Z+t[X]];te*=te,u=te*te*(e[W]*S+r[W]*P+o[W]*O)}let $=.6-B*B-R*R-F*F;if($<0)c=0;else{let W=J+x+t[Z+D+t[X+N]];$*=$,c=$*$*(e[W]*B+r[W]*R+o[W]*F)}let ee=.6-V*V-q*q-k*k;if(ee<0)d=0;else{let W=J+T+t[Z+I+t[X+E]];ee*=ee,d=ee*ee*(e[W]*V+r[W]*q+o[W]*k)}let Q=.6-U*U-H*H-Y*Y;if(Q<0)p=0;else{let W=J+1+t[Z+1+t[X+1]];Q*=Q,p=Q*Q*(e[W]*U+r[W]*H+o[W]*Y)}return 32*(u+c+d+p)}}function G0(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 F0=require("three"),ho=new F0.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 H0=require("three");var jr=require("three"),U0=ar(j0()),sT=new jr.Matrix4,lT=new jr.Matrix4,cT=new jr.Matrix4,Ha;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(Ha||(Ha={}));var qa=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new jr.Matrix4;this.copyPreviousMatrix=!0;this.hiddenMatrix=new jr.Matrix4;this.matrixWorldRigid=new jr.Matrix4;this.shearScale=new jr.Matrix4;this.shearScaleInv=new jr.Matrix4}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof jr.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)Ha.is(i)&&i.traverseObject(r,o+1)}traverseObject(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Ha.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,U0.SVD)(o),l=sT.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=lT.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=cT.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 jr.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 jr.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 of=class extends qa(H0.Object3D){},uT=n=>n.type==="Mesh",fn=class extends of{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 uT(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 ps=require("three");var nd=require("three");var mr=require("three");var Nt=require("three"),Ti=new Nt.Vector3,Mi=new Nt.Vector3,Wa=new Nt.Matrix4,W0=[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)],dT=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],pT=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],q0=(n,t,e)=>{n.updateEntityBoxSize(Ti,Mi),Wa.copy(t).multiply(n.matrixWorld),Mi.x===0&&Mi.y===0&&Mi.z===0?e.push(new Nt.Vector3(Ti.x,Ti.y,Ti.z).applyMatrix4(Wa)):W0.forEach(r=>{e.push(r.clone().multiply(Mi).add(Ti).applyMatrix4(Wa))})},Tl=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}q0(a,r,i)}}):q0(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(Wa.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Mi).multiplyScalar(.5),this.getCenter(Ti),Wa.copy(this.matrix).setPosition(Ti),this.vertices=W0.map(e=>e.clone().multiply(Mi).applyMatrix4(Wa))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=dT.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=pT.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var mo={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var tr=require("three"),af=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 sf=.001;function lf(n,t,e){return t.clone().sub(n).cross(t.clone().sub(e)).length()<=sf}function nf(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 lf(e,r,i)&&lf(e,o,i)}function Fu(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++)lf(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,A=new tr.Vector3(...b.position),S=new tr.Vector3(...w.position),P=A.clone().sub(p).normalize(),O=S.clone().sub(p).normalize();Object.assign(m,{prevDir:P,nextDir:O});let x=nf(b,d),D=nf(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(!nf(e[d].data,e[p].data))f.position.distanceTo(h.position)>sf&&(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)>sf&&(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),A=y.clone().multiplyScalar(-m).add(w),S=p.distanceTo(A)/p.distanceTo(g),P=d.prevDir.clone().multiplyScalar(S*p.distanceTo(f)).add(p),O=P.clone().lerp(A,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 af;return l.forEach(c=>{c&&u.add(c)}),u}var ke;(t=>{function n(e){return e&&e.__isEntity}t.is=n})(ke||(ke={}));var $a=n=>ke.is(n),fT={type:"completeState",isfromEntity:!0},hT=["x","y","z"],cf=new mr.Vector3,mT=new mr.Vector3().set(0,1,0),Ya=n=>class extends qa(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 Tl;this._recursiveBBox=new Tl;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(ke.is(o))return o}entityChildrenCount(){let r=this.children.length;for(;r--;)if(ke.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(ke.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)Oi.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=Oi.patch(this.data,a),Oi.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=>{$a(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(ke.is(o[i]))return o[i];if(ke.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&ke.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)$a(o)&&r(o)}traverseEntityAncestors(r){this.traverseAncestors(o=>{ke.is(o)&&r(o)})}traverseConcreteEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)$a(a)&&a.isConcreteEntity&&a.traverseEntity(r,o+1)}traverseEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)$a(a)&&a.traverseEntity(r,o+1)}traverseVisibleEntity(r){r(this);for(let o of this.children)$a(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=>$a(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,hT[s]])??a)}updateTransformState(r,o){let i=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,o)),i=!0),r.rotation&&(cf.fromArray(this.getTransformValues("rotation",r,o)).multiplyScalar(mr.MathUtils.DEG2RAD),this.rotation.setFromVector3(cf),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)ke.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{ke.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=Fe(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,Oi.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),Fe(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=Ra.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(Fe(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)ke.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),Fe(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Fe(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=Fu(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,mT),w=cf.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(fT)})}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"),Y0=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 Ml(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 $0(n){return new st.Vector2(n.y,-n.x)}var Ml=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,A=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 F=P.clone();F.x-=E;let V=Math.PI-I.angle(),q=I.angle(),k=Math.tan(q/2),U=Math.tan(V/2),H=k+U,Y=p?H:U,J=p?H:k;if(u=Math.min(u,(t-B)/Y,I.length()/H),c=Math.min(c,(e-R)/J,I.length()/H),u>0){let Q=u/k;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,F.sub(I.clone().setLength(Q)))}I=P.clone().sub(O);let Z=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?($(W,ne,D.x,0,-1),te(W,ue,ne,q,c,D,-1,!1)):a||$(W,ne,e,R,-1);let ce=$0(I).normalize();if(Un(ce,ne,A),!Z)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(A.x,A.y,A.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),$(W,ne,x.x,0,1)):a||$(W,ne,t,B,1),p&&!Z){let ae=$0(I).multiplyScalar(-1).normalize();Un(ae,ne,A);for(let me=0;me<=i;me++){let fe=me/i,he=I.clone().multiplyScalar(-fe).add(F);Un(he,ne,S),m.push(S.x,S.y,S.z),y.push(A.x,A.y,A.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,A),y.push(A.x,A.y,A.z),g.push(W,.5+S.y/r),Q.push(b++)}}function $(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 X0=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 Ml(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 Tr=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,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 Tr.BoxGeometry(t,e,r,o,i,a):u=new df(t,e,r,o,i,a,s,l),Object.assign(u,{userData:{...n,type:"CubeGeometry"}})}},uf=Math.PI/2,df=class extends Tr.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 Tr.Float32BufferAttribute(d,3)),this.setAttribute("normal",new Tr.Float32BufferAttribute(p,3)),this.setAttribute("uv",new Tr.Float32BufferAttribute(f,2));function y(w,A,S,P,O,x,D,N,T,I,E){let B=(x-2*s)/T,R=(D-2*s)/I,F=x/2-s,V=D/2-s,q=N/2,k=T+1,U=I+1,H=0,Y=0,J=new Tr.Vector3;for(let Z=0;Z<U;Z++){let X=Z*R-V;for(let te=0;te<k;te++){let $=te*B-F;J[w]=$*P,J[A]=X*O,J[S]=q,d.push(J.x,J.y,J.z),J[w]=0,J[A]=0,J[S]=N>0?1:-1,p.push(J.x,J.y,J.z),f.push(te/T),f.push(1-Z/I),H+=1}}for(let Z=0;Z<I;Z++)for(let X=0;X<T;X++){let te=h+X+k*Z,$=h+X+k*(Z+1),ee=h+(X+1)+k*(Z+1),Q=h+(X+1)+k*Z;c.push(te,$,Q),c.push($,ee,Q),Y+=6}u.addGroup(m,Y,E),m+=Y,h+=H}function g(w,A,S,P,O,x,D,N,T,I,E){let B=(D-2*s)/I,R=D/2-s,F=N/2-s,V=T/2,q=I+1,k=0,U=0,H=new Tr.Vector3,Y=new Tr.Vector3;for(let J=0;J<l+1;J++){let Z=J/l*uf,X=Math.sin(Z)*s,te=(1-Math.cos(Z))*s,$=Math.sin(Z),ee=Math.cos(Z);H[A]=(F+X)*O,H[S]=(V-te)*x,Y[w]=0,Y[A]=$*Math.sign(H[A]),Y[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(Y.x,Y.y,Y.z),f.push(Q/I),f.push(0),k+=1}}for(let J=0;J<l;J++)for(let Z=0;Z<I;Z++){let X=h+Z+q*J,te=h+Z+q*(J+1),$=h+(Z+1)+q*(J+1),ee=h+(Z+1)+q*J;c.push(X,te,ee),c.push(te,$,ee),U+=6}u.addGroup(m,U,E),m+=U,h+=k}function b(w,A,S){let P=new Tr.Vector3,O=new Tr.Vector3(t/2,e/2,r/2);O.subScalar(s);let x=[],D=w*A*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=uf*(1-T/l),B=Math.cos(E),R=Math.sin(E),F=0;for(let V=0;V<=T;V++){let q=Math.cos(F),k=Math.sin(F);P.x=B*q,P.y=R,P.z=B*k;let U=O.clone().addScaledVector(P,s);d.push(w*U.x,A*U.y,S*U.z),p.push(w*P.x,A*P.y,S*P.z),f.push(0,0),I.push(h++),F+=uf/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,A=new Dt.Vector3,S=(k,U)=>A.subVectors(k,U).normalize(),P=(k,U)=>Array(k).fill(void 0).map(U),O=P(t.length/3,(k,U)=>new Dt.Vector3().fromArray(t,U*3).setLength(o)),x=[],D=1e6;for(let k=0;k<O.length;k++){let U=O[k],H=[],Y,J,Z,X=1e10,te=-1;for(;(te=e.indexOf(k,te+1))!=-1;){let W=te-te%3;Y=e[W+(te+1)%3],J=e[W+(te+2)%3],Z=U.distanceToSquared(O[Y]),X=Math.min(X,Z),H.push([Y,J,Z])}X+=1e-6;let $=[],ee=0,Q=H.length;for(let W=0;W<Q;W++){[Y,J,Z]=H[ee];let ue=x[Y]?.includes(k)==!0;Z<=X&&$.push(Y+ +ue*D),ee=H.findIndex(le=>le[0]==J)}x.push($)}let N=[];{let k=0,U=0,H,Y,J=f==3;for(let Z=0;Z<=a;Z++){H=Z*(Z+1)/2,Y=(Z+1)*(Z+2)/2;for(let X=0;X<a-Z;X++)[k,U]=[H+X+Z+2,Y+X+Z+3],N.push(H,Y,...J?[U,H]:[k,Y],U,k),[H,Y]=[k,U];N.push(H,Y,H+a+2)}}let T=h.clone(),I=h.clone(),E=h.clone(),B=h.clone(),R=h.clone(),F=[],V=P(O.length,()=>P(f,()=>h.clone()));for(let k=0;k<O.length;k++){h.copy(O[k]).normalize(),T.copy(h).multiplyScalar(b);let U=x[k];for(let $=0;$<U.length;$++){let ee=U[$],Q=U[($+1)%f];y.setFromPointsAndIndices(O,k,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[k][$])}let H=[],Y=[],J=[],Z=new Dt.Vector3;a==0&&[...V[k]].reduce(($,ee)=>$.add(ee),Z).multiplyScalar(1/f);for(let $=0;$<f;$++){let ee=[],Q=($-1+f)%f,W=V[k][Q],ue=V[k][$];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(Z):I.copy(T).setLength(b+ce),Y.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(),A.clone()]))}me&&(S(he,T),ee.push([he,A.clone()]))}J.push(ee)}F.push(J);let X=2*w,te=2;for(let $=0;$<f;$++){let ee=X*$,Q=X*(($+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),[A.x,A.y,A.z])).flat())}}let q=[];for(let k=0;k<x.length;k++)for(let U=0;U<f;U++){let H=x[k][U];if(H<D){let Y=x[H].findIndex(X=>X%D==k),J=F[k][U],Z=F[H][Y];for(let X=0;X<w;X++){let te=J[X],$=Z[w-X],ee=J[X+1],Q=Z[w-(X+1)];[te,$,ee,ee,$,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],Z[w][0],J[w][0],Z[0][0])}}for(;q.length;){let k,U,H,Y;[k,U]=q.splice(0,2);let J=[k];for(;k!=U;)J.push(U),H=q.indexOf(U),Y=H%2,U=q.splice(H-Y,2)[1-Y];A.subVectors(J[0],J[1]).cross(h.subVectors(J[0],J[2])).normalize();let Z=A.dot(J[0])<0;Z&&A.negate();for(let X=1;X<=J.length-2;X++)[J[X+ +Z],J[X+1-+Z],J[0]].forEach(te=>{s.push(te.x,te.y,te.z),u.push(A.x,A.y,A.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,A=(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);A(g,x+0,f,D),A(b,x+2,h,D),A(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 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,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 Il(t*.5,i,a):new K0.DodecahedronGeometry(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},Il=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 Il(t.radius,t.corner,t.cornerSides)}};var Ke=require("three");var Ne=require("three"),Nl=1e-12,Xa=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 Xa(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Qa=class extends Xa{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Qa(this.parent).copy(this)}},yo=class extends Xa{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Qa(this),new Qa(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&&(J0(o,e),J0(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 J0(n,t=new Ne.Vector2){let e=n.length();return t.set(-n.y/e,n.x/e)}var ff=n=>n,Ka=new Ne.Vector2,ku=new Ne.Vector2,yT=new Ne.Vector2,gT=new Ne.Vector2,xT=new Ne.Vector2,bT=new Ne.Vector2,tx=new Ne.Vector3,rx=new Ne.Vector3;function ox(n){let t=new Ne.Vector2;t.addVectors(n.v0,Ka.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Ne.Vector2;return e.addVectors(n.v2,ku.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new Ne.CubicBezierCurve(n.v0,t,e,n.v2)}function Dl(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function vT(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function ST(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function hf(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 nx(n,t,e){return ex(n,t)&&ex(t,e)&&pf(n.position,t.position,e.position)}function pf(n,t,e){return Ka.copy(t).sub(n).cross(ku.copy(e).sub(n))===0}function ix(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 ax(n,t,e){let r=n.distanceTo(e),o=t.distanceTo(e);return r<o?t:n}function sx(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 hf(t,n,e)>Math.PI&&(c*=-1),Dl(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 mf(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function ex(n,t){return pf(n.position,n.controls[1].position,t.position)&&pf(n.position,t.controls[0].position,t.position)}function lx(n,t,e,r,o=.5){let i=Ka.subVectors(t,n).multiplyScalar(o).add(n),a=ku.subVectors(e,t).multiplyScalar(o).add(t),s=yT.subVectors(r,e).multiplyScalar(o).add(e),l=i,u=gT.subVectors(a,i).multiplyScalar(o).add(i),c=xT.subVectors(s,a).multiplyScalar(o).add(a),d=s,p=bT.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 cx(n,t,e=12,r=!0){let o=rx.set(0,0,0),i,a=0,s=[];for(let l=0;l<t.length;l++){let u=ff(t[l]),c=Ka,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&&ST(i,o))continue;i===void 0&&(i=tx),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 ux(n,t,e,r=12,o=!0){let i=rx.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=ff(t[l]),d=Ka,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=tx:(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 yf(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 dx(n,t,e=12,r=!0){let o,i=0;for(let a=0;a<t.length;a++){let s=ff(t[a]),l=Wn(s,e),u=Ka;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&&vT(o,u,Nl))continue;o===void 0&&(o=ku),o.copy(u),n.push(u.x,u.y),i++}}return Dl(n[0],n[n.length-2],Nl)&&Dl(n[1],n[n.length-1],Nl)&&(n.pop(),n.pop()),r&&i>1&&!(Dl(n[i-1],n[1],Nl)&&Dl(n[i-2],n[0],Nl))&&(n.push(n[0],n[1]),i++),n}var gf=new Ke.Vector2,wT=new Ke.Vector2,AT=new Ke.Vector2,_T=new Ke.Vector2,PT=new Ke.Vector2,OT=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=gf.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 cx(e,o?this.roundedCurves:this.curves,r,this.autoClose),i.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=yf(this.points,e,!1),this.roundedCurveDivisions=yf(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,o=12){return ux(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),dx(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(mf(i,a)){let d=i.position.distanceTo(a.position);return i.position.distanceTo(gf.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){mf(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&&nx(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),A=1-w/m,S=w/y,P=d.getPointAt(A,gf),O=p.getPointAt(S,wT);this._subSplitCurve(d,f,A,P,void 0),this._subSplitCurve(p,h,S,void 0,O);let x;if(this.useCubicForRoundedCorners){let D=hf(P,a.position,O)/2,N=Math.tan(D)*P.distanceTo(a.position),[T,I]=ix(P,O,N,AT,_T),E=ax(T,I,a.position),[B,R]=sx(E,P,O,N,PT,OT);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=lx(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]=ox(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 bf=Math.PI*2;function xf({x:n,y:t},e,r,o,i){return{x:n*e+o,y:t*r+i}}function CT(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 px(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 TT(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,A=(s-y)/i,S=(-a-m)/o,P=(-s-y)/i,O=px(1,0,w,A),x=px(w,A,S,P);return!u&&x>0&&(x-=bf),u&&x<0&&(x+=bf),{centerx:g,centery:b,ang1:O,ang2:x}}function fx({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=TT(n,t,e,r,o,i,u,c,a,s),{ang1:f,ang2:h}=p,{centerx:m,centery:y}=p,g=Math.abs(h)/(bf/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(CT(f,h)),f+=h;return l.map(w=>{let{x:A,y:S}=xf(w[0],o,i,m,y),{x:P,y:O}=xf(w[1],o,i,m,y),{x,y:D}=xf(w[2],o,i,m,y);return{x1:A,y1:S,x2:P,y2:O,x,y:D}})}var Ii=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}(),El=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}(),Za=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}(),hx=function(){function n(){var t=new Za,e=new El,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 Za,e=new Za,r=new El,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 Za;this.makeVertex_(i,e,t.Org),t.Org.anEdge=t}if(!r){var a=new El;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 El;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 Za;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 El;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}(),mx=function(){function n(){this.handle=null}return n}(),yx=function(){function n(){this.key=null,this.node=0}return n}(),MT=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 mx,this.handles[r]=new yx;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 mx;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new yx}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}(),vf=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}(),gx=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),IT=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new gx,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 gx;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}(),NT=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 vf;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 Za,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 vf;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 vf,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 IT(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 MT(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}(),DT=function(){function n(){this.mesh=new hx,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 hx),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_(),NT.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 DT;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 L4=Ye.ODD,R4=Ye.NONZERO,V4=Ye.POSITIVE,z4=Ye.NEGATIVE,G4=Ye.ABS_GEQ_TWO,F4=_t.POLYGONS,k4=_t.CONNECTED_POLYGONS,j4=_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)}},Bl=Uu;Bl.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Sx=ar(vx()),Ll={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Pf={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Of={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},_f=(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],F=I[B-0];E.push(R,F)}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,Sx.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=Ll}let m;try{m=go({windingRule:Ye.ODD,elementType:_t.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]})}catch{m=Pf}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,A=-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>A&&(A=R)}this._minX=g,this._minY=w,this._width=b-g,this._height=A-w,this._buffer=new Bl(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],F=B+R,V={start:B,count:R,normals:[],continuous:[],concave:[]},q=B,k=F-1,U=B+1,H=this._shape.roundedCurves.length;do{let te=q-B,$=h.vertices[k*2+0],ee=h.vertices[k*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-$,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),[k,q,U]=[q,U,U+1],U>=F&&(U-=R)}while(U!==B+1);let Y=[];Y.push({bevelI:0,angle:0,size:0,boundary:{vertices:h.vertices.slice(B*2,F*2),vertexCount:R,vertexIndices:new Array(R).fill(!0).map((te,$)=>[$,$]),elements:[0,R],elementCount:1,mesh:null},reverseMap:[],insetPoints:h.vertices.slice(B*2,F*2)});let J=0;for(let te=1;te<=this._bevelSegments;te++){let $=te/this._bevelSegments*Math.PI/2,ee=(1-Math.cos($))*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,hi=Math.sin(zt)*ee;Q[2*ne+0]=he+Ut,Q[2*ne+1]=xe+hi,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}}}Y.push({bevelI:te,angle:$,size:ee,boundary:ce,reverseMap:le,insetPoints:Q})}let Z=(te,$,ee)=>{let Q=0,W=te.boundary.vertexIndices.length;for(;Q<W&&ee(te.boundary.vertexIndices[$]);)$=($+1)%W,Q++;return Q},X=S.length;for(let te=1;te<Y.length;te++){let $=Y[te-1],ee=Y[te],Q=$.boundary.vertexIndices.length,W=ee.boundary.vertexIndices.length;if(!Q||!W)break;let ue=V.concave.length,le=0,ne=_f(le,R);for(;!$.boundary.vertexIndices.filter(ne).length||!ee.boundary.vertexIndices.filter(ne).length;)le++,ne=_f(le,R);let ce=$.boundary.vertexIndices.findIndex(ne),ae=ee.boundary.vertexIndices.findIndex(ne);do ce=(ce+1)%Q;while(ne($.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,$,(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=_f(le,R);let ze=Z($,ce,ne),Oe=Z(ee,ae,ne),jt=He;if(He=!1,ze&&!Oe){for(let Ee=0;Ee<ze;Ee++)ie=this._buildBevelVert(V,$,(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,$,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,$,(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,$,(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,$,(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(Y,V,S),I){let te=[];for(let $=S.length-1;$>=X+2;$-=3){let ee=S[$-2],Q=S[$-1],W=S[$-0];te.push(W,Q,ee)}S.splice(X,S.length-X,...te)}if(I){let te=[];for(let $=Y[Y.length-1].boundary.vertices.length-1;$>=1;$-=2){let ee=Y[Y.length-1].boundary.vertices[$-1],Q=Y[Y.length-1].boundary.vertices[$-0];te.push(ee,Q)}P.push(te)}if(!I){let te=Y[Y.length-1],$;try{$=go({windingRule:Y.length>1?Ye.POSITIVE:Ye.ODD,elementType:_t.POLYGONS,vertexSize:2,strict:!0,contours:[te.insetPoints,...P]})}catch{$=Of}if(!$)throw new Error("Error generating geometry for surface");c.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let ee=0;ee<$.elementCount*3;ee+=3){let Q=this._buildSurfaceVert($,$.elements[ee+0],J),W=this._buildSurfaceVert($,$.elements[ee+1],J),ue=this._buildSurfaceVert($,$.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],A=r.boundary.vertices[y+1],S=(1-m)*this._bevel,P=(w-this._minX)/this._width,O=(A-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 F=N-x,V=T-D;x=x+F*(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]=A,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]=A,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]=A,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]=A,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 Ja=class extends Ii.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=Ll}let p=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new Ii.BufferAttribute(new Float32Array(p*3),3),this._normalAttribute=new Ii.BufferAttribute(new Float32Array(p*3),3),this._uvAttribute=new Ii.BufferAttribute(new Float32Array(p*2),2),this._indexAttribute=new Ii.BufferAttribute(new Uint32Array(f*3),1),s){let h=1/0,m=-1/0,y=1/0,g=-1/0;for(let A=0,S=p;A<S;A++){let P=A*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 A=0,S=p;A<S;A++){let P=A*2,O=s.vertices[P+0],x=s.vertices[P+1],D=(O-h)/b,N=(x-y)/w;this._positionAttribute.setXYZ(A,O,x,0),this._normalAttribute.setXYZ(A,0,0,1),this._uvAttribute.setXY(A,D,N)}for(let A=0,S=f;A<S;A++){let P=A*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 Ja(this._shape,this._curveSegments);return e.userData=on(this.userData),e}};var es=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 es(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=on(this.userData),e}};var Mr=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 Ja(n.shape,o,{windingRule:a}):s=new es(n.shape,t,e,o,r,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};var bo=require("three"),Ax=Math.PI*2,rs=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=VT(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=Mr.create({shape:u,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function VT(n,t,e,r,o,i){if(r>=Ax)return o>30||o%4===0?(GT(n,t,e,i),Math.round(o/4)):wx(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=fx({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?zT(n,a.x,a.y,u,o,t,e,i):wx(n,r,o,t,e,i)}function zT(n,t,e,r,o,i,a,s){let l=Math.round(o/r.length);n.addPoint(ts(t,e));for(let u=0,c=r.length;u<c;u++){let d=r[u],p=n.points[u],f=ts(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?_x(n,i,a,s):n.addPoint(ts(0,0)),l}function wx(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(ts(u,c))}return t<Ax?i>0?_x(n,r,o,i):n.addPoint(ts(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&Px(n,r,o,i)),1}function GT(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&&Px(n,t,e,r)}function ts(n,t){return new yo(bo.MathUtils.generateUUID(),new bo.Vector2(n,t))}function qu(n,t,e,r,o,i){let a=ts(n,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(o,i),a}function _x(n,t,e,r){Ox(n,t,e,r).forEach(i=>n.addPoint(i))}function Px(n,t,e,r){let o=Ox(n,t,e,r),i=new Qe;o.forEach(a=>i.addPoint(a)),i.isClosed=!0,n.shapeHoles.push(i)}function Ox(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"),Cx=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 Rl(!1,t,e,r,o,i,a,s,l,u,c,d);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},Cf=new vo.Uint32BufferAttribute([0,0,0],1),Rl=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,A,S,P,O,x,D,N,T=h(),I=h(),E=h(),B=h(),R=h(),F=h(),V=h(),q=h(),k=r-2*l+.001,U=k/a,H=Math.ceil(s*a),Y=H+1,J=k/H,Z=-k/2,X=c+1,te=2*Math.PI/c,$=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*Y,me=Math.max(0,X*(Y+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+=Z,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),F.copy(g).setComponent(+t+1,0).normalize(),V.crossVectors(q,F).normalize();let at=vt===0,co=vt===H,op=at?3*Math.PI/2:$,np=at?Oe:jt,bc=at?X:ae,mi=at?0:me-X,Tt=q.clone().multiplyScalar(at?-W:W).add(g),ip=q.clone().multiplyScalar(at?-1:1).normalize();for(let $r=0;$r<X;$r++){let ll=$r*te;if(I.addVectors(m.copy(F).multiplyScalar(l*Math.cos(ll)),y.copy(V).multiplyScalar(l*Math.sin(ll))),E.copy(I).normalize(),at||co){f||(ue=mi+$r,[0,1,2].forEach(fr=>{fe[ue*3+fr]=Tt.getComponent(fr),he[ue*3+fr]=ip.getComponent(fr)}),xe[ue*2]=+co,xe[ue*2+1]=$r/c),y.copy(E).multiplyScalar(Q),b.addVectors(g,y);for(let fr=0;fr<p;fr++){let yi=fr*$+op;B.addVectors(m.copy(q).multiplyScalar(W*Math.sin(yi)),y.copy(E).multiplyScalar(W*Math.cos(yi))),R.copy(B).normalize(),y.addVectors(b,B),B.normalize(),ue=bc+fr*X+$r,[0,1,2].forEach(Qi=>{fe[ue*3+Qi]=y.getComponent(Qi),he[ue*3+Qi]=R.getComponent(Qi)});let vc=+at+Math.sin(yi);xe[ue*2]=(np+W*vc)/ze,xe[ue*2+1]=$r/c}}y.addVectors(g,I),ue=ce+vt*X+$r,[0,1,2].forEach(fr=>{fe[ue*3+fr]=y.getComponent(fr),he[ue*3+fr]=E.getComponent(fr)}),xe[ue*2]=(He+vt*Ve)/ze,xe[ue*2+1]=$r/c}}let Ee=Y+2*p+le,zt=1,[Ut,hi]=[+f,Ee-1];for(let vt=Ut;vt<=hi-1;vt++){let at=f&&vt===hi-1;for(let co=0;co<X-1;co++)w=vt*X+co,A=w+1,S=(at?co:w)+X,P=(at?co+1:A)+X,vt===0?ye.push(A,P,S):vt===Ee-2?ye.push(w,A,S):ye.push(w,A,S,A,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,Cf.array=o,Cf.count=o.length,Cf}};var Tx=require("three");var Mx=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 Vl(t*.5,i,a):new Tx.IcosahedronGeometry(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},Vl=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 Vl(t.radius,t.corner,t.cornerSides)}};var Wu=require("three"),Ix=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 Fo=require("three");var hn=require("three");var pe=require("three"),Go=new pe.Matrix4,Tf=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 Tf.lookAt(t),Tf.updateMatrix(),this.applyMatrix4(Tf.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 os(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 os(h.a+i,h.b+i,h.c+i);w.normal.copy(h.normal),o!==void 0&&w.normal.applyMatrix3(o).normalize();for(let A=0,S=g.length;A<S;A++)m=g[A].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),w.vertexNormals.push(m);w.color.copy(h.color);for(let A=0,S=b.length;A<S;A++)y=b[A],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,A=g.length;w<A;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,A=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,A),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)),A){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,A=g.length;w<A;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 Mf().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",Nx.call(new pe.BufferAttribute(o,3),t.colors))}if(t.uvs.length>0){let o=new Float32Array(t.uvs.length*2);e.setAttribute("uv",Dx.call(new pe.BufferAttribute(o,2),t.uvs))}if(t.uvs2.length>0){let o=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",Dx.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",Ex.call(o,t.skinIndices))}if(t.skinWeights.length>0){let o=new pe.Float32BufferAttribute(t.skinWeights.length*4,4);e.setAttribute("skinWeight",Ex.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",Nx.call(i,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let a=new pe.Float32BufferAttribute(r.lineDistances.length,1);e.setAttribute("lineDistance",FT.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 Mf=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 A=b.vertexColors;if(A.length===3)this.colors.push(A[0],A[1],A[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}},os=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 FT(n){return this.array.set(n),this}function Nx(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 Dx(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 Ex(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 kT=["a","b","c"];function jT(n,t){switch(t){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function If(n,t,e){let r=Math.min(n,t),o=Math.max(n,t),i=r+"_"+o;return e.get(i)}function Nf(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 UT(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],Nf(a.a,a.b,n,r,a,e),Nf(a.b,a.c,n,r,a,e),Nf(a.c,a.a,n,r,a,e)}function Xu(n,t,e,r,o){n.push(new os(t,e,r,void 0,void 0,o))}function ns(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;UT(l,u,p,f);let h=[],m,y,g,b,w,A,S;for(let ee of Array.from(f.keys())){for(y=f.get(ee),g=new hn.Vector3,w=3/8,A=1/8,S=y.faces.length,S!=2&&(w=.5,A=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[jT(b,kT[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(A),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,F,V,q,k=[],U=[],H,Y,J,Z,X=new hn.Vector2,te=new hn.Vector2,$=new hn.Vector2;for(o=0,i=u.length;o<i;o++)b=u[o],F=Number(If(b.a,b.b,f).newEdge)+R,V=Number(If(b.b,b.c,f).newEdge)+R,q=Number(If(b.c,b.a,f).newEdge)+R,Xu(k,F,V,q,b.materialIndex),Xu(k,b.a,F,q,b.materialIndex),Xu(k,b.b,V,F,b.materialIndex),Xu(k,b.c,q,V,b.materialIndex),d&&(H=c[o],Y=H[0],J=H[1],Z=H[2],X.set(ns(Y.x,J.x),ns(Y.y,J.y)),te.set(ns(J.x,Z.x),ns(J.y,Z.y)),$.set(ns(Y.x,Z.x),ns(Y.y,Z.y)),Qu(U,X,te,$),Qu(U,Y,X,$),Qu(U,J,te,X),Qu(U,Z,$,te));t.vertices=B,t.faces=k,d&&(t.faceVertexUvs[0]=U)}};var Wt=new Fo.Vector3,Bx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.geometry??t?.geometry??new Fo.BufferGeometry().copy(new Fo.BoxGeometry(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Wt),r={width:Wt.x,height:Wt.y,depth:Wt.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 Fo.BufferGeometry().copy(new Fo.BoxGeometry(100,100,100)),a=i.userData.parameters;a===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(Wt)):Wt.set(a.width,a.height,a.depth),(t!==Wt.x||e!==Wt.y||r!==Wt.z)&&i.scale(Wt.x===0?1:t/Wt.x,Wt.y===0?1:e/Wt.y,Wt.z===0?1:r/Wt.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 Fo.BufferGeometryLoader(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(Wt);let a=100/Wt.x;Object.assign(i.parameters,{width:100,height:Wt.y*a,depth:Wt.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=Mr.create({shape:l,parameters:{roundness:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(h,{userData:{...n,type:"PolygonGeometry"}})}};var We=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,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 Ef(t*.5,e,o,i,a,s,l);return u.scale(1,1,r/t),Object.assign(u,{userData:{...n,type:"PyramidGeometry"}})}};function zl(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function Df(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 HT(n,t,e){let r=n.clone().sub(t),o=e.clone().sub(t);return r.projectOnVector(o),r.add(t)}var Ef=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),A=new We.Vector3(0,f,0),S=new We.Vector2(t,-f),P=new We.Vector2(m,-f),O=new We.Vector2(0,A.y).sub(P),x=new We.Vector2(0,A.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),F=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=[],Y=S.clone(),J=B/Math.cos(Math.PI/r);Y.x-=J;for(let Z=0;Z<r;Z++){let X=Z/r*Math.PI*2+h,te=new We.Vector2(Math.sin(X),Math.cos(X));zl(Y,te,F),u.push(F.x,F.y,F.z),c.push(0,-1,0),d.push(0,0),H.push(p++)}for(let Z=0;Z<H.length;Z++)l.push(H[Z],U,H[(Z+1)%H.length])}let V=[];{let U=new We.Vector3,H=new We.Vector3,Y=new We.Vector3,J=new We.Vector3,Z=new We.Vector3,X=new We.Vector3;for(let te=0;te<r;te++){let $=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($),Math.cos($)),ue=new We.Vector2(Math.sin(ee),Math.cos(ee)),le=new We.Vector2(Math.sin(Q),Math.cos(Q));zl(S,W,H),zl(S,le,Y),zl(D,ue,U),Df(A,H,Y,R,R,J),u.push(J.x,J.y,J.z),Df(H,A,Y,R,B,Z),u.push(Z.x,Z.y,Z.z),Df(Y,H,A,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(Y).multiplyScalar(.5),xe=A.clone().sub(he).normalize(),C=w.clone().sub(he).normalize().add(xe).normalize().multiplyScalar(-1),ie=X.clone().sub(Z);q(he,ie,C,O.angle())}let me,fe;{let he=new We.Vector3;zl(N,le,he);let xe=X.clone().add(J).multiplyScalar(.5);xe=HT(xe,Y,A);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);k(he,xe,ye,C)}V.concat(fe);{let he=O.angle(),xe=Math.PI-he,ye=A.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 hi=Math.cos(zt),vt=Math.sin(zt);U.x=jt*vt,U.y=Ee,U.z=jt*hi,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,Y,J,Z){let X=-J/2,te=(Math.PI-J)/2,$=H.clone().normalize().cross(Y);U.addScaledVector(Y,-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($,Math.sin(ce)),Q.addScaledVector(Y,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),Z!=null){let fe=Math.max(0,ee.y-Z);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 k(U,H,Y,J){let Z=Math.PI/2,X=x.angle()-Z,te=[],$=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=(Z+he)*le,ye=Math.cos(xe),C=Math.sin(xe);$.set(0,0,0),$.addScaledVector(H,C*me),$.addScaledVector(Y,ye),$.addScaledVector(J,C*fe),ee.copy(U).addScaledVector($,a),u.push(ee.x,ee.y,ee.z),c.push($.x,$.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 is=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(A,S,P){return S>e&&P>r?Math.min(A*e/S,A*r/P):S>e?A*e/S:P>r?A*r/P:A}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 A=0,S=t.points.length;A<S;A++)t.points[A].roundness=f[A],A>0&&f[A]!==f[A-1]&&(b=!1);b&&(t.roundness=f[0]),t.useCubicForRoundedCorners=i!==1,t.update();let w=Mr.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...n,type:"RectangleGeometry"}})}};var mn=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,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 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,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 Vx.PlaneGeometry(t,e,r,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};var Qn=require("three"),Gx=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 Bf(t,e,r,o,i,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},Bf=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,A=+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 F=(Math.PI-o)/a;for(let ee=0;ee<=a;ee++){let Q=p+o+ee*F;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(F/2)*E*2,q=d.length-1,k=d[0][0].distanceTo(d[1][0]),U=d[q-1][0].distanceTo(d[q][0]),H=k+V*a+U;d[0].push(1);for(let ee=0;ee<=a;ee++)d[ee+1].push(1-(k+ee*V)/H);d[q].push(0);let[Y,J,Z]=d[0],X,te,$;for(let ee=1;ee<d.length;ee++)[X,te,$]=d[ee],s.push(w,Y.y,Y.z,w,X.y,X.z,A,Y.y,Y.z,A,Y.y,Y.z,w,X.y,X.z,A,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,Z,0,$,1,Z,1,Z,0,$,1,$),[Y,J,Z]=[X,te,$];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 A=0;A<o;A++){let S=m*A,P=f+Math.sin(S)*d,O=h+Math.cos(S)*p;c.addPoint(c.createPoint(P,O))}}else for(let A=0;A<o;A++){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,A<=o,c.addPoint(c.createPoint(S,P)),y+=m}c.isClosed=!0;for(let A=0,S=c.points.length;A<S;A++)c.points[A].roundness=i;c.roundness=i,c.update();let w=Mr.create({shape:c,parameters:{roundness:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(w,{userData:{...n,type:"StarGeometry"}})}};var Fx=require("three"),kx=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 Fx.PlaneGeometry(t,e);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};var as=require("three");var jx=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=qT(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 qT(n,t,e,r,o,i,a,s,l,u,c){[t,e]=[e,t],a=t/2;let d=as.MathUtils.clamp(o/360,0,1);if(d===0){let p=new as.BufferGeometry;return p.setAttribute("position",new as.Float32BufferAttribute([],3)),p}return d===1&&(u=0),new Rl(!0,n,t,e,r,d,i,a,s,l,u,c)}var Ux=require("three"),Hx=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 Ux.TorusKnotGeometry(s,e,r,o,i,a);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var qx=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=Mr.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 Wx(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var WT=new Me.Matrix4,$T=new Me.Matrix4;function YT(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 $x=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??rs.create({parameters:kp}).userData.shape;return{path:n.path??Ba.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 Lf(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new Me.BufferGeometry,{userData:{...n,type:"PathGeometry"}})}},Lf=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)||!Wx(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 k=0;k<u;k++){let U=this.inputs.path.isClosed?(k+s)%e.length:Math.min(k+s,e.length-1);c.push(e[U].clone()),d.push(r[U].clone())}let p=(k,U,H)=>{c[k]=c[k].clone().lerp(c[U],H),d[k]=YT(d[k],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 k=c.length-1;c[k].copy(c[0]),d[k].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",A=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(A=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:P,vertices:O}=this._computeShapePoints(A),x=0,D;w==="round"&&(D=new Yn(this.inputs.shapeData,2*g,g,A,b,void 0,!0),x=D.getAttribute("position").count);let N=0,T=0;P.sort((k,U)=>k.start-U.start),P.forEach(k=>{k.verticesStart=N,k.verticesCount=k.continuous.reduce((U,H,Y)=>U+(Y===0||!H?2:1),0),T+=k.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=Of}B=E.vertexCount}let R=I+2*B+x*2,F=I+2*B,V={positions:new Float32Array(R*3),normals:new Float32Array(R*3),uvs:new Float32Array(R*2)},q=[];if(P.forEach(k=>{this._extrudeRegion(k,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,F*3),V.normals.set(D.getAttribute("normal").array,F*3),V.uvs.set(D.getAttribute("uv").array,F*2);let k=q.length;q.push(...D.getIndex().array.map(Y=>Y+F)),F+=x,V.positions.set(D.getAttribute("position").array,F*3),V.normals.set(D.getAttribute("normal").array,F*3),V.uvs.set(D.getAttribute("uv").array,F*2);let U=q.length;q.push(...D.getIndex().array.map(Y=>Y+F)),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=WT;H.copy(d[d.length-1]).setPosition(c[c.length-1]),this.applyMatrix4OnRange(H,F,R),H.copy(d[0]).setPosition(c[0]).multiply($T.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,F-x,F),this.reverseIndicesOnRange(k,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=Fu(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 A=g.clone().sub(b).normalize(),S=w.clone().sub(g).normalize(),P=A.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],A=y[b-0];g.push(w,A)}return g}),s;try{s=go({windingRule:r,elementType:_t.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{s=Ll}let l;try{l=go({windingRule:Ye.ODD,elementType:_t.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Pf}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],A=b+w,S={start:b,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let P=b,O=A-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],F=s.vertices[x*2+1],V=E-T,q=B-I,k=Math.sqrt(V*V+q*q);V/=k,q/=k;let U=E-R,H=B-F,Y=Math.sqrt(U*U+H*H);U/=Y,H/=Y,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[Z,X]=o.getCurveIndexFromVertexId(J-1,!0);if(X>0&&X<1)S.continuous[N]=!0;else{let te=X===1?Z+1:Z-1;te=(te+D)%D;let $=X===1?0:1,ee=o.roundedCurves[Z].getTangent(X),Q=o.roundedCurves[te].getTangent($);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>=A&&(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 A=(e.start+w)*2;if(u.set(r[A+0],r[A+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:A-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:A+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 A=w===e.count-1?0:b+1,S=y+b,P=y+A,O=g+A,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 Ni=require("three"),Yx=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Xx(){let n=new Ni.BufferGeometry;return n.setAttribute("position",new Ni.BufferAttribute(new Float32Array([]),3)),n.setIndex(new Ni.BufferAttribute(new Uint16Array([]),1)),n}var QT=Xx().attributes,KT=12,ZT=1,ss=class extends Ni.BufferGeometry{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,QT),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=JT(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 A=w.map(P=>Mr.create({shape:P,parameters:{depth:a,extrudeBevelSegments:l,extrudeBevelSize:s,windingRule:a<=0?Ye.NONZERO:Ye.ODD,subdivisions:this.isLowResolution&&a>0?ZT:KT}})),S=A.length?(0,Yx.mergeBufferGeometries)(A):Xx();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 Ni.BufferGeometry,ss.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 JT(n,t,e){let r=[""],o="";for(let i of e)o+=i,i===" "||i===`
|
|
17
|
-
`?(r[r.length-1]+=o,o="",i===`
|
|
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 Kx,td=new Promise(n=>{Kx=n}),Qx=!1;var ed;function Zx(){if(Qx)return;if(ed)return ed;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.0.62/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});Kx(l),Qx=!0}return ed=n(),ed}var Jx=require("three");var eM=["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];zp(d)&&!eM.includes(o)&&(c[o]=t.getVariable(d,[r.uuid,"geometry",...u,o]),zp(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 Jx.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 ss(i,t);if(i.type==="UIGeometry")return is.create({parameters:{width:i.width,height:i.height,cornerRadius:i.cornerRadius,cornerType:i.cornerType}})}let l;try{l=Rf(s)}catch(u){console.error(u)}if(!l){let u=Qe.createFromState(Ea.defaultData(),100,100);s.shape=u,l=Rf(s)}return l}var eb=require("three"),tM=new eb.Matrix4;function Gl(n,t,e,r){let o=n.position.array,i=n.normal.array,a=tM.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,ls=new lt.Vector3,Ae;td.then(n=>{Ae=n});var tb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),rb=new Uint32Array([0,1,2,3]),ob=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&&Gl(this.subdividedGeometry.attributes,...i),this.originalGeometry&&Gl(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(ls.fromArray(i));let s=ls.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(ls);let i={width:ls.x,height:ls.y,depth:ls.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:tb,indexWASM:rb,verticesPerFaceWASM:ob},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}=Ff(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}=kf(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=tb,i=rb,a=ob);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 A;e?.scaleBaked?.some(P=>P!==1)&&(A=new lt.Matrix4().makeScale(...e.scaleBaked)),r&&(A?A.premultiply(r):A=r);let S=A?Ae.alloc_subdivision_surface2(g,u,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,d,A.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 A=new lt.BufferGeometry;if(A.setIndex(new lt.Uint32BufferAttribute(w,1)),A.setAttribute("position",new lt.Float32BufferAttribute(f,3)),A.setAttribute("normal",new lt.Float32BufferAttribute(m,3)),r){A.setAttribute("faceMap",new lt.Uint32BufferAttribute(g,1));let S=new Float32Array(m.length/3*4).fill(0);A.setAttribute("color",new lt.BufferAttribute(S,4))}return Ae.free_mesh_data(s),A.userData.type="SubdivGeometry",A}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 nb=["getX","getY","getZ"];function Ff(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[nb[p]](c)*s)},`;if(d in e)i.push(e[d]);else{for(let p=0;p<3;p++)a.push(n[nb[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,Vf=new lt.Vector3,zf=new lt.Vector3,Gf=new lt.Vector3;function kf(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]),Vf.set(n[t[s+1]*3],n[t[s+1]*3+1],n[t[s+1]*3+2]),zf.set(n[t[s+4]*3],n[t[s+4]*3+1],n[t[s+4]*3+2]),Gf.set(n[t[s+5]*3],n[t[s+5]*3+1],n[t[s+5]*3+2]),Vf.sub(od).normalize(),zf.sub(od).normalize(),Gf.sub(od).normalize();let l=Vf.cross(zf).dot(Gf);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 Zr={};em(Zr,{calcBoolean:()=>iM,calcBooleanTopological:()=>nM,freeMeshSet:()=>cM,getMeshSet:()=>aM,hasOpenEdges:()=>sM,transformMeshSet:()=>lM});var rM,ib=new Promise(n=>{rM=n});var Fl=require("three");var Re,cs;ib.then(n=>Re=n);function oM(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}=Ff(n.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:u}=kf(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 ab(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 sb(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 nM(n,t){cs===void 0&&(cs=Re.init_csg());let e=ab(n),r=Re.csg_calc_topological(cs,e,n.length,sb(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 iM(n,t,e,r){cs===void 0&&(cs=Re.init_csg());let o=ab(n),i=Re.csg_calc(cs,o,n.length,r,sb(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.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Re.free_mesh_data(i),h}function aM(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,A=0;b<g.verticesPerFace.length;b++){o[A++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[A++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:i}=oM(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 sM(n){return Re.has_open_edges(n)}function lM(n,t){Re.transform_csg_mesh(n,t.elements)}function cM(n){Re.free_csg_mesh(n)}var uM={ConeGeometry:X0,CubeGeometry:Q0,CylinderGeometry:Y0,DodecahedronGeometry:Z0,EllipseGeometry:rs,HelixGeometry:Cx,IcosahedronGeometry:Mx,LatheGeometry:Ix,NonParametricGeometry:Bx,PolygonGeometry:Zu,PyramidGeometry:Lx,RectangleGeometry:is,SphereGeometry:Rx,PlaneGeometry:zx,BackdropGeometry:Gx,StarGeometry:Ju,TextFrameGeometry:kx,TorusGeometry:jx,TorusKnotGeometry:Hx,TriangleGeometry:qx,PathGeometry:$x,VectorGeometry:Mr},Rf=n=>uM[n.type].create(n);function us(n){return n!==null&&"booleanOp"in n}var ds=class extends Ya(nd.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new nd.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!us(this.parent)&&this.visible,us(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Zr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),us(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof ds&&(e.freeBooleanPointer(),us(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&us(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),us(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var id=new ps.Box3;function kl(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 dM=new ps.BufferGeometry,pM=new ps.MeshBasicMaterial,$t=class extends ds{constructor(t,e){super(dM,pM),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?kl(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 qr=require("three");var Nb=require("three");var wo=require("three");var jl=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 lb=require("three"),rr=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=lb.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 jf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Yt=new jf;var Uf=require("three");var cb=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=cb.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 Uf.Vector2?e:new Uf.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 Hf=require("three");var cr=class extends ot{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Hf.Vector3?e:new Hf.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 ub=require("three"),Xt=class extends ub.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 Ir=class extends ot{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Xt?e:new Xt(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 fM=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,db=/[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=db.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&&Yt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Yt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Yt.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&&Yt.contains(m)&&e.include(Yt.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=fM.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(db);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 hM=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,qf=class extends ge{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||qf.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=hM.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=qf;Xe.PI="PI",Xe.PI2="PI2",Xe.RECIPROCAL_PI="RECIPROCAL_PI",Xe.RECIPROCAL_PI2="RECIPROCAL_PI2",Xe.LOG2="LOG2",Xe.EPSILON="EPSILON";var mM=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
19
|
-
)*?)}`,"gim"),yM=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),fs=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=mM.exec(e);if(r){let o=r[2],i;for(;i=yM.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=r[1]}else this.name="";this.type=this.name}};var hs=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)}};Yt.addKeyword("uv",function(){return new hs});Yt.addKeyword("uv2",function(){return new hs(1)});var ad=require("three");var Di=class extends ge{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??Di.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=Di.Nodes[this.method],s=e.include(a);if(s===Di.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=Di.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=Di.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},Sr=Di;Sr.Nodes={LinearToLinear:new re(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
1
|
+
"use strict";var VS=Object.create;var js=Object.defineProperty;var zS=Object.getOwnPropertyDescriptor;var GS=Object.getOwnPropertyNames;var jS=Object.getPrototypeOf,FS=Object.prototype.hasOwnProperty;var US=(n,r,e)=>r in n?js(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e;var Qn=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),Ch=(n,r)=>{for(var e in r)js(n,e,{get:r[e],enumerable:!0})},Th=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of GS(r))!FS.call(n,o)&&o!==e&&js(n,o,{get:()=>r[o],enumerable:!(t=zS(r,o))||t.enumerable});return n};var Ei=(n,r,e)=>(e=n!=null?VS(jS(n)):{},Th(r||!n||!n.__esModule?js(e,"default",{value:n,enumerable:!0}):e,n)),kS=n=>Th(js({},"__esModule",{value:!0}),n);var Zn=(n,r,e)=>(US(n,typeof r!="symbol"?r+"":r,e),e);var s0=Qn((Dp,a0)=>{(function(n,r){typeof Dp=="object"?a0.exports=r():typeof define=="function"&&define.amd?define(r):n.Alea=r()})(Dp,function(){"use strict";return n.importState=function(e){var t=new n;return t.importState(e),t},n;function n(){return function(e){var t=0,o=0,i=0,a=1;e.length==0&&(e=[+new Date]);var s=r();t=s(" "),o=s(" "),i=s(" ");for(var l=0;l<e.length;l++)t-=s(e[l]),t<0&&(t+=1),o-=s(e[l]),o<0&&(o+=1),i-=s(e[l]),i<0&&(i+=1);s=null;var c=function(){var u=2091639*t+a*23283064365386963e-26;return t=o,o=i,i=u-(a=u|0)};return c.next=c,c.uint32=function(){return c()*4294967296},c.fract53=function(){return c()+(c()*2097152|0)*11102230246251565e-32},c.version="Alea 0.9",c.args=e,c.exportState=function(){return[t,o,i,a]},c.importState=function(u){t=+u[0]||0,o=+u[1]||0,i=+u[2]||0,a=+u[3]||0},c}(Array.prototype.slice.call(arguments))}function r(){var e=4022871197,t=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 t.version="Mash 0.9",t}})});var f0=Qn((yu,p0)=>{(function(n,r){typeof yu=="object"&&typeof p0<"u"?r(yu):typeof define=="function"&&define.amd?define(["exports"],r):r((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(yu,function(n){"use strict";n.SVD=function(r,e,t,o,i){if(e=e===void 0||e,t=t===void 0||t,i=1e-64/(o=o||Math.pow(2,-52)),!r)throw new TypeError("Matrix a is not defined");var a,s,l,c,u,p,d,h,f,m,y,g,v=r[0].length,O=r.length;if(O<v)throw new TypeError("Invalid matrix: m < n");for(var P=[],S=[],T=[],I=e==="f"?O:v,x=m=d=0;x<O;x++)S[x]=new Array(I).fill(0);for(x=0;x<v;x++)T[x]=new Array(v).fill(0);var _,D=new Array(v).fill(0);for(x=0;x<O;x++)for(a=0;a<v;a++)S[x][a]=r[x][a];for(x=0;x<v;x++){for(P[x]=d,f=0,l=x+1,a=x;a<O;a++)f+=Math.pow(S[a][x],2);if(f<i)d=0;else for(h=(p=S[x][x])*(d=p<0?Math.sqrt(f):-Math.sqrt(f))-f,S[x][x]=p-d,a=l;a<v;a++){for(f=0,s=x;s<O;s++)f+=S[s][x]*S[s][a];for(p=f/h,s=x;s<O;s++)S[s][a]=S[s][a]+p*S[s][x]}for(D[x]=d,f=0,a=l;a<v;a++)f+=Math.pow(S[x][a],2);if(f<i)d=0;else{for(h=(p=S[x][x+1])*(d=p<0?Math.sqrt(f):-Math.sqrt(f))-f,S[x][x+1]=p-d,a=l;a<v;a++)P[a]=S[x][a]/h;for(a=l;a<O;a++){for(f=0,s=l;s<v;s++)f+=S[a][s]*S[x][s];for(s=l;s<v;s++)S[a][s]=S[a][s]+f*P[s]}}m<(y=Math.abs(D[x])+Math.abs(P[x]))&&(m=y)}if(t)for(x=v-1;0<=x;x--){if(d!==0){for(h=S[x][x+1]*d,a=l;a<v;a++)T[a][x]=S[x][a]/h;for(a=l;a<v;a++){for(f=0,s=l;s<v;s++)f+=S[x][s]*T[s][a];for(s=l;s<v;s++)T[s][a]=T[s][a]+f*T[s][x]}}for(a=l;a<v;a++)T[x][a]=0,T[a][x]=0;T[x][x]=1,d=P[x],l=x}if(e){if(e==="f")for(x=v;x<O;x++){for(a=v;a<O;a++)S[x][a]=0;S[x][x]=1}for(x=v-1;0<=x;x--){for(l=x+1,d=D[x],a=l;a<I;a++)S[x][a]=0;if(d!==0){for(h=S[x][x]*d,a=l;a<I;a++){for(f=0,s=l;s<O;s++)f+=S[s][x]*S[s][a];for(p=f/h,s=x;s<O;s++)S[s][a]=S[s][a]+p*S[s][x]}for(a=x;a<O;a++)S[a][x]=S[a][x]/d}else for(a=x;a<O;a++)S[a][x]=0;S[x][x]=S[x][x]+1}}for(o*=m,s=v-1;0<=s;s--)for(var A=0;A<50;A++){for(_=!1,l=s;0<=l;l--){if(Math.abs(P[l])<=o){_=!0;break}if(Math.abs(D[l-1])<=o)break}if(!_){for(u=0,c=l-(f=1),x=l;x<s+1&&(p=f*P[x],P[x]=u*P[x],!(Math.abs(p)<=o));x++)if(d=D[x],D[x]=Math.sqrt(p*p+d*d),u=d/(h=D[x]),f=-p/h,e)for(a=0;a<O;a++)y=S[a][c],g=S[a][x],S[a][c]=y*u+g*f,S[a][x]=-y*f+g*u}if(g=D[s],l===s){if(g<0&&(D[s]=-g,t))for(a=0;a<v;a++)T[a][s]=-T[a][s];break}for(m=D[l],p=(((y=D[s-1])-g)*(y+g)+((d=P[s-1])-(h=P[s]))*(d+h))/(2*h*y),d=Math.sqrt(p*p+1),p=((m-g)*(m+g)+h*(y/(p<0?p-d:p+d)-h))/m,x=l+(f=u=1);x<s+1;x++){if(d=P[x],y=D[x],h=f*d,d*=u,g=Math.sqrt(p*p+h*h),p=m*(u=p/(P[x-1]=g))+d*(f=h/g),d=-m*f+d*u,h=y*f,y*=u,t)for(a=0;a<v;a++)m=T[a][x-1],g=T[a][x],T[a][x-1]=m*u+g*f,T[a][x]=-m*f+g*u;if(g=Math.sqrt(p*p+h*h),p=(u=p/(D[x-1]=g))*d+(f=h/g)*y,m=-f*d+u*y,e)for(a=0;a<O;a++)y=S[a][x-1],g=S[a][x],S[a][x-1]=y*u+g*f,S[a][x]=-y*f+g*u}P[l]=0,P[s]=p,D[s]=m}for(x=0;x<v;x++)D[x]<o&&(D[x]=0);return{u:S,q:D,v:T}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var k0=Qn((Kp,Qp)=>{(function(n,r){typeof Kp=="object"&&typeof Qp<"u"?Qp.exports=r():typeof define=="function"&&define.amd?define(r):(n=n||self,n.TinyQueue=r())})(Kp,function(){"use strict";var n=function(t,o){if(t===void 0&&(t=[]),o===void 0&&(o=r),this.data=t,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(t){this.data.push(t),this.length++,this._up(this.length-1)},n.prototype.pop=function(){if(this.length!==0){var t=this.data[0],o=this.data.pop();return this.length--,this.length>0&&(this.data[0]=o,this._down(0)),t}},n.prototype.peek=function(){return this.data[0]},n.prototype._up=function(t){for(var o=this,i=o.data,a=o.compare,s=i[t];t>0;){var l=t-1>>1,c=i[l];if(a(s,c)>=0)break;i[t]=c,t=l}i[t]=s},n.prototype._down=function(t){for(var o=this,i=o.data,a=o.compare,s=this.length>>1,l=i[t];t<s;){var c=(t<<1)+1,u=i[c],p=c+1;if(p<this.length&&a(i[p],u)<0&&(c=p,u=i[p]),a(u,l)>=0)break;i[t]=u,t=c}i[t]=l};function r(e,t){return e<t?-1:e>t?1:0}return n})});var W0=Qn((vk,Zp)=>{"use strict";var Su=k0();Su.default&&(Su=Su.default);Zp.exports=H0;Zp.exports.default=H0;function H0(n,r,e){r=r||1;for(var t,o,i,a,s=0;s<n[0].length;s++){var l=n[0][s];(!s||l[0]<t)&&(t=l[0]),(!s||l[1]<o)&&(o=l[1]),(!s||l[0]>i)&&(i=l[0]),(!s||l[1]>a)&&(a=l[1])}var c=i-t,u=a-o,p=Math.min(c,u),d=p/2;if(p===0){var h=[t,o];return h.distance=0,h}for(var f=new Su(void 0,LA),m=t;m<i;m+=p)for(var y=o;y<a;y+=p)f.push(new Nn(m+d,y+d,d,n));var g=VA(n),v=new Nn(t+c/2,o+u/2,0,n);v.d>g.d&&(g=v);for(var O=f.length;f.length;){var P=f.pop();P.d>g.d&&(g=P,e&&console.log("found best %d after %d probes",Math.round(1e4*P.d)/1e4,O)),!(P.max-g.d<=r)&&(d=P.h/2,f.push(new Nn(P.x-d,P.y-d,d,n)),f.push(new Nn(P.x+d,P.y-d,d,n)),f.push(new Nn(P.x-d,P.y+d,d,n)),f.push(new Nn(P.x+d,P.y+d,d,n)),O+=4)}e&&(console.log("num probes: "+O),console.log("best distance: "+g.d));var S=[g.x,g.y];return S.distance=g.d,S}function LA(n,r){return r.max-n.max}function Nn(n,r,e,t){this.x=n,this.y=r,this.h=e,this.d=RA(n,r,t),this.max=this.d+this.h*Math.SQRT2}function RA(n,r,e){for(var t=!1,o=1/0,i=0;i<e.length;i++)for(var a=e[i],s=0,l=a.length,c=l-1;s<l;c=s++){var u=a[s],p=a[c];u[1]>r!=p[1]>r&&n<(p[0]-u[0])*(r-u[1])/(p[1]-u[1])+u[0]&&(t=!t),o=Math.min(o,zA(n,r,u,p))}return o===0?0:(t?1:-1)*Math.sqrt(o)}function VA(n){for(var r=0,e=0,t=0,o=n[0],i=0,a=o.length,s=a-1;i<a;s=i++){var l=o[i],c=o[s],u=l[0]*c[1]-c[0]*l[1];e+=(l[0]+c[0])*u,t+=(l[1]+c[1])*u,r+=u*3}return r===0?new Nn(o[0][0],o[0][1],0,n):new Nn(e/r,t/r,0,n)}function zA(n,r,e,t){var o=e[0],i=e[1],a=t[0]-o,s=t[1]-i;if(a!==0||s!==0){var l=((n-o)*a+(r-i)*s)/(a*a+s*s);l>1?(o=t[0],i=t[1]):l>0&&(o+=a*l,i+=s*l)}return a=n-o,s=r-i,a*a+s*s}});var lv=Qn((VJ,sv)=>{"use strict";function mI(n,r){function e(){this.constructor=n}e.prototype=r.prototype,n.prototype=new e}function Oi(n,r,e,t){this.message=n,this.expected=r,this.found=e,this.location=t,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Oi)}mI(Oi,Error);Oi.buildMessage=function(n,r){var e={literal:function(c){return'"'+o(c.text)+'"'},class:function(c){var u="",p;for(p=0;p<c.parts.length;p++)u+=c.parts[p]instanceof Array?i(c.parts[p][0])+"-"+i(c.parts[p][1]):i(c.parts[p]);return"["+(c.inverted?"^":"")+u+"]"},any:function(c){return"any character"},end:function(c){return"end of input"},other:function(c){return c.description}};function t(c){return c.charCodeAt(0).toString(16).toUpperCase()}function o(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+t(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+t(u)})}function i(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+t(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+t(u)})}function a(c){return e[c.type](c)}function s(c){var u=new Array(c.length),p,d;for(p=0;p<c.length;p++)u[p]=a(c[p]);if(u.sort(),u.length>0){for(p=1,d=1;p<u.length;p++)u[p-1]!==u[p]&&(u[d]=u[p],d++);u.length=d}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}function l(c){return c?'"'+o(c)+'"':"end of input"}return"Expected "+s(n)+" but "+l(r)+" found."};function yI(n,r){r=r!==void 0?r:{};var e={},t={svg_path:Gs},o=Gs,i=function(b){if(!b)return[];for(var w=[],L=0;L<b.length;L++)w=w.concat.apply(w,b[L]);var M=w[0];return M&&M.code=="m"&&(delete M.relative,M.code="M"),w},a=function(b,w){return RS(b,w)},s=/^[Mm]/,l=ot(["M","m"],!1,!1),c=function(b,w,L){var M=Ni(b,[w]);return L&&(M=M.concat(Ni(b=="M"?"L":"l",L[1]))),M},u=/^[Zz]/,p=ot(["Z","z"],!1,!1),d=function(){return Ni("Z")},h=/^[Ll]/,f=ot(["L","l"],!1,!1),m=function(b,w){return Ni(b,w)},y=/^[Hh]/,g=ot(["H","h"],!1,!1),v=function(b,w){return Ni(b,w.map(function(L){return{x:L}}))},O=/^[Vv]/,P=ot(["V","v"],!1,!1),S=function(b,w){return Ni(b,w.map(function(L){return{y:L}}))},T=/^[Cc]/,I=ot(["C","c"],!1,!1),x=function(b,w,L){return{x1:b.x,y1:b.y,x2:w.x,y2:w.y,x:L.x,y:L.y}},_=/^[Ss]/,D=ot(["S","s"],!1,!1),A=function(b,w){return{x2:b.x,y2:b.y,x:w.x,y:w.y}},N=/^[Qq]/,E=ot(["Q","q"],!1,!1),B=function(b,w){return{x1:b.x,y1:b.y,x:w.x,y:w.y}},V=/^[Tt]/,j=ot(["T","t"],!1,!1),R=/^[Aa]/,W=ot(["A","a"],!1,!1),F=function(b,w,L,M,z,oe){return{rx:b,ry:w,xAxisRotation:L,largeArc:M,sweep:z,x:oe.x,y:oe.y}},k=function(b,w){return{x:b,y:w}},H=function(b){return b*1},$=function(b){return b.join("")*1},J=/^[01]/,Z=ot(["0","1"],!1,!1),X=function(b){return b=="1"},te=function(){return""},Y=",",ee=ht(",",!1),K=function(b){return b.join("")},q=".",ue=ht(".",!1),le=/^[eE]/,ne=ot(["e","E"],!1,!1),ce=/^[+\-]/,ae=ot(["+","-"],!1,!1),me=/^[0-9]/,fe=ot([["0","9"]],!1,!1),he=function(b){return b.join("")},xe=/^[ \t\n\r]/,ye=ot([" "," ",`
|
|
2
|
+
`,"\r"],!1,!1),C=0,ie=0,Re=[{line:1,column:1}],Fe=0,Ve=[],Ce=0,_t;if("startRule"in r){if(!(r.startRule in t))throw new Error(`Can't start parsing from rule "`+r.startRule+'".');o=t[r.startRule]}function Ee(){return n.substring(ie,C)}function Nt(){return Yn(ie,C)}function Bt(b,w){throw w=w!==void 0?w:Yn(ie,C),Br([Bd(b)],n.substring(ie,C),w)}function $n(b,w){throw w=w!==void 0?w:Yn(ie,C),Ld(b,w)}function ht(b,w){return{type:"literal",text:b,ignoreCase:w}}function ot(b,w,L){return{type:"class",parts:b,inverted:w,ignoreCase:L}}function Xr(){return{type:"any"}}function _d(){return{type:"end"}}function Bd(b){return{type:"other",description:b}}function Kl(b){var w=Re[b],L;if(w)return w;for(L=b-1;!Re[L];)L--;for(w=Re[L],w={line:w.line,column:w.column};L<b;)n.charCodeAt(L)===10?(w.line++,w.column=1):w.column++,L++;return Re[b]=w,w}function Yn(b,w){var L=Kl(b),M=Kl(w);return{start:{offset:b,line:L.line,column:L.column},end:{offset:w,line:M.line,column:M.column}}}function vt(b){C<Fe||(C>Fe&&(Fe=C,Ve=[]),Ve.push(b))}function Ld(b,w){return new Oi(b,null,null,w)}function Br(b,w,L){return new Oi(Oi.buildMessage(b,w),b,w,L)}function Gs(){var b,w,L,M,z;for(b=C,w=[],L=Ue();L!==e;)w.push(L),L=Ue();if(w!==e)if(L=rr(),L===e&&(L=null),L!==e){for(M=[],z=Ue();z!==e;)M.push(z),z=Ue();M!==e?(ie=b,w=i(L),b=w):(C=b,b=e)}else C=b,b=e;else C=b,b=e;return b}function rr(){var b,w,L,M,z,oe;if(b=C,w=Xn(),w!==e){for(L=[],M=C,z=[],oe=Ue();oe!==e;)z.push(oe),oe=Ue();for(z!==e?(oe=Xn(),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=Ue();oe!==e;)z.push(oe),oe=Ue();z!==e?(oe=Xn(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e)}L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function Xn(){var b,w,L,M,z,oe;if(b=C,w=Mi(),w!==e){for(L=[],M=C,z=[],oe=Ue();oe!==e;)z.push(oe),oe=Ue();for(z!==e?(oe=Ql(),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=Ue();oe!==e;)z.push(oe),oe=Ue();z!==e?(oe=Ql(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e)}L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function Ql(){var b;return b=SS(),b===e&&(b=wS(),b===e&&(b=PS(),b===e&&(b=OS(),b===e&&(b=CS(),b===e&&(b=AS(),b===e&&(b=IS(),b===e&&(b=DS(),b===e&&(b=_S())))))))),b}function Mi(){var b,w,L,M,z,oe,Di;if(b=C,s.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&vt(l)),w!==e){for(L=[],M=Ue();M!==e;)L.push(M),M=Ue();L!==e?(M=ar(),M!==e?(z=C,oe=ut(),oe===e&&(oe=null),oe!==e?(Di=gh(),Di!==e?(oe=[oe,Di],z=oe):(C=z,z=e)):(C=z,z=e),z===e&&(z=null),z!==e?(ie=b,w=c(w,M,z),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function SS(){var b,w;return b=C,u.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&vt(p)),w!==e&&(ie=b,w=d()),b=w,b}function wS(){var b,w,L,M;if(b=C,h.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&vt(f)),w!==e){for(L=[],M=Ue();M!==e;)L.push(M),M=Ue();L!==e?(M=gh(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function gh(){var b,w,L,M,z,oe;if(b=C,w=ar(),w!==e){for(L=[],M=C,z=ut(),z===e&&(z=null),z!==e?(oe=ar(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=ut(),z===e&&(z=null),z!==e?(oe=ar(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function PS(){var b,w,L,M;if(b=C,y.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&vt(g)),w!==e){for(L=[],M=Ue();M!==e;)L.push(M),M=Ue();L!==e?(M=xh(),M!==e?(ie=b,w=v(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function xh(){var b,w,L,M,z,oe;if(b=C,w=Ii(),w!==e){for(L=[],M=C,z=ut(),z===e&&(z=null),z!==e?(oe=Ii(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=ut(),z===e&&(z=null),z!==e?(oe=Ii(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function OS(){var b,w,L,M;if(b=C,O.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&vt(P)),w!==e){for(L=[],M=Ue();M!==e;)L.push(M),M=Ue();L!==e?(M=xh(),M!==e?(ie=b,w=S(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function CS(){var b,w,L,M;if(b=C,T.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&vt(I)),w!==e){for(L=[],M=Ue();M!==e;)L.push(M),M=Ue();L!==e?(M=TS(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function TS(){var b,w,L,M,z,oe;if(b=C,w=Rd(),w!==e){for(L=[],M=C,z=ut(),z===e&&(z=null),z!==e?(oe=Rd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=ut(),z===e&&(z=null),z!==e?(oe=Rd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function Rd(){var b,w,L,M,z,oe;return b=C,w=ar(),w!==e?(L=ut(),L===e&&(L=null),L!==e?(M=ar(),M!==e?(z=ut(),z===e&&(z=null),z!==e?(oe=ar(),oe!==e?(ie=b,w=x(w,M,oe),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function AS(){var b,w,L,M;if(b=C,_.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&vt(D)),w!==e){for(L=[],M=Ue();M!==e;)L.push(M),M=Ue();L!==e?(M=MS(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function MS(){var b,w,L,M,z,oe;if(b=C,w=Vd(),w!==e){for(L=[],M=C,z=ut(),z===e&&(z=null),z!==e?(oe=Vd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=ut(),z===e&&(z=null),z!==e?(oe=Vd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function Vd(){var b,w,L,M;return b=C,w=ar(),w!==e?(L=ut(),L===e&&(L=null),L!==e?(M=ar(),M!==e?(ie=b,w=A(w,M),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function IS(){var b,w,L,M;if(b=C,N.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&vt(E)),w!==e){for(L=[],M=Ue();M!==e;)L.push(M),M=Ue();L!==e?(M=NS(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function NS(){var b,w,L,M,z,oe;if(b=C,w=zd(),w!==e){for(L=[],M=C,z=ut(),z===e&&(z=null),z!==e?(oe=zd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=ut(),z===e&&(z=null),z!==e?(oe=zd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function zd(){var b,w,L,M;return b=C,w=ar(),w!==e?(L=ut(),L===e&&(L=null),L!==e?(M=ar(),M!==e?(ie=b,w=B(w,M),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function DS(){var b,w,L,M;if(b=C,V.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&vt(j)),w!==e){for(L=[],M=Ue();M!==e;)L.push(M),M=Ue();L!==e?(M=ES(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function ES(){var b,w,L,M,z,oe;if(b=C,w=ar(),w!==e){for(L=[],M=C,z=ut(),z===e&&(z=null),z!==e?(oe=ar(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=ut(),z===e&&(z=null),z!==e?(oe=ar(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function _S(){var b,w,L,M;if(b=C,R.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&vt(W)),w!==e){for(L=[],M=Ue();M!==e;)L.push(M),M=Ue();L!==e?(M=BS(),M!==e?(ie=b,w=m(w,M),b=w):(C=b,b=e)):(C=b,b=e)}else C=b,b=e;return b}function BS(){var b,w,L,M,z,oe;if(b=C,w=Gd(),w!==e){for(L=[],M=C,z=ut(),z===e&&(z=null),z!==e?(oe=Gd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=ut(),z===e&&(z=null),z!==e?(oe=Gd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=b,w=a(w,L),b=w):(C=b,b=e)}else C=b,b=e;return b}function Gd(){var b,w,L,M,z,oe,Di,Fd,Jl,Ud,ec,kd;return b=C,w=bh(),w!==e?(L=ut(),L===e&&(L=null),L!==e?(M=bh(),M!==e?(z=ut(),z===e&&(z=null),z!==e?(oe=Ii(),oe!==e?(Di=ut(),Di!==e?(Fd=vh(),Fd!==e?(Jl=ut(),Jl===e&&(Jl=null),Jl!==e?(Ud=vh(),Ud!==e?(ec=ut(),ec===e&&(ec=null),ec!==e?(kd=ar(),kd!==e?(ie=b,w=F(w,M,oe,Fd,Ud,kd),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function ar(){var b,w,L,M;return b=C,w=Ii(),w!==e?(L=ut(),L===e&&(L=null),L!==e?(M=Ii(),M!==e?(ie=b,w=k(w,M),b=w):(C=b,b=e)):(C=b,b=e)):(C=b,b=e),b}function bh(){var b,w;return b=C,w=wh(),w===e&&(w=Kn()),w!==e&&(ie=b,w=H(w)),b=w,b}function Ii(){var b,w,L,M;return b=C,w=C,L=jd(),L===e&&(L=null),L!==e?(M=wh(),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e),w===e&&(w=C,L=jd(),L===e&&(L=null),L!==e?(M=Kn(),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e)),w!==e&&(ie=b,w=$(w)),b=w,b}function vh(){var b,w;return b=C,J.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&vt(Z)),w!==e&&(ie=b,w=X(w)),b=w,b}function ut(){var b,w,L,M,z;if(b=C,w=[],L=Ue(),L!==e)for(;L!==e;)w.push(L),L=Ue();else w=e;if(w!==e)if(L=Sh(),L===e&&(L=null),L!==e){for(M=[],z=Ue();z!==e;)M.push(z),z=Ue();M!==e?(w=[w,L,M],b=w):(C=b,b=e)}else C=b,b=e;else C=b,b=e;if(b===e){if(b=C,w=C,L=Sh(),L!==e){for(M=[],z=Ue();z!==e;)M.push(z),z=Ue();M!==e?(L=[L,M],w=L):(C=w,w=e)}else C=w,w=e;w!==e&&(ie=b,w=te()),b=w}return b}function Sh(){var b;return n.charCodeAt(C)===44?(b=Y,C++):(b=e,Ce===0&&vt(ee)),b}function wh(){var b,w,L,M;return b=C,w=C,L=LS(),L!==e?(M=Ph(),M===e&&(M=null),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e),w===e&&(w=C,L=Kn(),L!==e?(M=Ph(),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e)),w!==e&&(ie=b,w=K(w)),b=w,b}function LS(){var b,w,L,M,z;return b=C,w=C,L=Kn(),L===e&&(L=null),L!==e?(n.charCodeAt(C)===46?(M=q,C++):(M=e,Ce===0&&vt(ue)),M!==e?(z=Kn(),z!==e?(L=[L,M,z],w=L):(C=w,w=e)):(C=w,w=e)):(C=w,w=e),w===e&&(w=C,L=Kn(),L!==e?(n.charCodeAt(C)===46?(M=q,C++):(M=e,Ce===0&&vt(ue)),M!==e?(L=[L,M],w=L):(C=w,w=e)):(C=w,w=e)),w!==e&&(ie=b,w=K(w)),b=w,b}function Ph(){var b,w,L,M,z;return b=C,w=C,le.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Ce===0&&vt(ne)),L!==e?(M=jd(),M===e&&(M=null),M!==e?(z=Kn(),z!==e?(L=[L,M,z],w=L):(C=w,w=e)):(C=w,w=e)):(C=w,w=e),w!==e&&(ie=b,w=K(w)),b=w,b}function jd(){var b;return ce.test(n.charAt(C))?(b=n.charAt(C),C++):(b=e,Ce===0&&vt(ae)),b}function Kn(){var b,w,L;if(b=C,w=[],me.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Ce===0&&vt(fe)),L!==e)for(;L!==e;)w.push(L),me.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,Ce===0&&vt(fe));else w=e;return w!==e&&(ie=b,w=he(w)),b=w,b}function Ue(){var b,w;return b=C,xe.test(n.charAt(C))?(w=n.charAt(C),C++):(w=e,Ce===0&&vt(ye)),w!==e&&(ie=b,w=te()),b=w,b}function RS(b,w){if(!w)return[b];for(var L=[b],M=0,z=w.length;M<z;M++)L[M+1]=w[M][1];return L}var Zl={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 Oh in Zl)Zl[Oh.toUpperCase()]=Zl[Oh];function Ni(b,w){w||(w=[{}]);for(var L=w.length;L--;){var M={code:b,command:Zl[b]};b==b.toLowerCase()&&(M.relative=!0);for(var z in w[L])M[z]=w[L][z];w[L]=M}return w}if(_t=o(),_t!==e&&C===n.length)return _t;throw _t!==e&&C<n.length&&vt(_d()),Br(Ve,Fe<n.length?n.charAt(Fe):null,Fe<n.length?Yn(Fe,Fe+1):Yn(Fe,Fe))}sv.exports={SyntaxError:Oi,parse:yI}});var sh=Qn((zJ,cv)=>{var yd=lv().parse;yd.parseSVG=yd;yd.makeAbsolute=gI;cv.exports=yd;function gI(n){var r,e={x:0,y:0},t={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return n.forEach(function(o){o.command==="moveto"&&(r=o),o.x0=e.x,o.y0=e.y;for(var i in t)i in o&&(o[i]+=o.relative?o[t[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=r.x,o.y=r.y),e=o}),n}});var gS=Qn((rae,yS)=>{yS.exports=function(r,e){for(var t=r.split("."),o=e.split("."),i=0;i<3;i++){var a=Number(t[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 VI={};Ch(VI,{default:()=>Dd});module.exports=kS(VI);var Ed=require("three");function tc(n){for(let r of Object.keys(n))n[r]===void 0&&delete n[r];return n}function sr(n,r){return Object.setPrototypeOf(n,r),n}function rc(n){return Array.isArray(n)?n:[n]}function oc(n,r){let e=0;for(;e<n.length&&e<r.length;){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1;e+=1}return e!==r.length?-1:e!==n.length?1:0}var HS=typeof global=="object"&&global&&global.Object===Object&&global,nc=HS;var WS=typeof self=="object"&&self&&self.Object===Object&&self,qS=nc||WS||Function("return this")(),Dt=qS;var $S=Dt.Symbol,kt=$S;var Ah=Object.prototype,YS=Ah.hasOwnProperty,XS=Ah.toString,Fs=kt?kt.toStringTag:void 0;function KS(n){var r=YS.call(n,Fs),e=n[Fs];try{n[Fs]=void 0;var t=!0}catch{}var o=XS.call(n);return t&&(r?n[Fs]=e:delete n[Fs]),o}var Mh=KS;var QS=Object.prototype,ZS=QS.toString;function JS(n){return ZS.call(n)}var Ih=JS;var e1="[object Null]",t1="[object Undefined]",Nh=kt?kt.toStringTag:void 0;function r1(n){return n==null?n===void 0?t1:e1:Nh&&Nh in Object(n)?Mh(n):Ih(n)}var Tr=r1;function o1(n){return n!=null&&typeof n=="object"}var Kt=o1;var n1="[object Symbol]";function i1(n){return typeof n=="symbol"||Kt(n)&&Tr(n)==n1}var _i=i1;function a1(n,r){for(var e=-1,t=n==null?0:n.length,o=Array(t);++e<t;)o[e]=r(n[e],e,n);return o}var ic=a1;var s1=Array.isArray,St=s1;var l1=1/0,Dh=kt?kt.prototype:void 0,Eh=Dh?Dh.toString:void 0;function _h(n){if(typeof n=="string")return n;if(St(n))return ic(n,_h)+"";if(_i(n))return Eh?Eh.call(n):"";var r=n+"";return r=="0"&&1/n==-l1?"-0":r}var Bh=_h;function c1(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}var Ar=c1;function u1(n){return n}var Lh=u1;var d1="[object AsyncFunction]",p1="[object Function]",f1="[object GeneratorFunction]",h1="[object Proxy]";function m1(n){if(!Ar(n))return!1;var r=Tr(n);return r==p1||r==f1||r==d1||r==h1}var ac=m1;var y1=Dt["__core-js_shared__"],sc=y1;var Rh=function(){var n=/[^.]+$/.exec(sc&&sc.keys&&sc.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function g1(n){return!!Rh&&Rh in n}var Vh=g1;var x1=Function.prototype,b1=x1.toString;function v1(n){if(n!=null){try{return b1.call(n)}catch{}try{return n+""}catch{}}return""}var Vo=v1;var S1=/[\\^$.*+?()[\]{}|]/g,w1=/^\[object .+?Constructor\]$/,P1=Function.prototype,O1=Object.prototype,C1=P1.toString,T1=O1.hasOwnProperty,A1=RegExp("^"+C1.call(T1).replace(S1,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function M1(n){if(!Ar(n)||Vh(n))return!1;var r=ac(n)?A1:w1;return r.test(Vo(n))}var zh=M1;function I1(n,r){return n?.[r]}var Gh=I1;function N1(n,r){var e=Gh(n,r);return zh(e)?e:void 0}var mr=N1;var D1=mr(Dt,"WeakMap"),lc=D1;var jh=Object.create,E1=function(){function n(){}return function(r){if(!Ar(r))return{};if(jh)return jh(r);n.prototype=r;var e=new n;return n.prototype=void 0,e}}(),Fh=E1;function _1(n,r,e){switch(e.length){case 0:return n.call(r);case 1:return n.call(r,e[0]);case 2:return n.call(r,e[0],e[1]);case 3:return n.call(r,e[0],e[1],e[2])}return n.apply(r,e)}var Uh=_1;function B1(n,r){var e=-1,t=n.length;for(r||(r=Array(t));++e<t;)r[e]=n[e];return r}var kh=B1;var L1=800,R1=16,V1=Date.now;function z1(n){var r=0,e=0;return function(){var t=V1(),o=R1-(t-e);if(e=t,o>0){if(++r>=L1)return arguments[0]}else r=0;return n.apply(void 0,arguments)}}var Hh=z1;function G1(n){return function(){return n}}var Wh=G1;var j1=function(){try{var n=mr(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Bi=j1;var F1=Bi?function(n,r){return Bi(n,"toString",{configurable:!0,enumerable:!1,value:Wh(r),writable:!0})}:Lh,qh=F1;var U1=Hh(qh),$h=U1;function k1(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}var Yh=k1;var H1=9007199254740991,W1=/^(?:0|[1-9]\d*)$/;function q1(n,r){var e=typeof n;return r=r??H1,!!r&&(e=="number"||e!="symbol"&&W1.test(n))&&n>-1&&n%1==0&&n<r}var Li=q1;function $1(n,r,e){r=="__proto__"&&Bi?Bi(n,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[r]=e}var cc=$1;function Y1(n,r){return n===r||n!==n&&r!==r}var Ri=Y1;var X1=Object.prototype,K1=X1.hasOwnProperty;function Q1(n,r,e){var t=n[r];(!(K1.call(n,r)&&Ri(t,e))||e===void 0&&!(r in n))&&cc(n,r,e)}var Vi=Q1;function Z1(n,r,e,t){var o=!e;e||(e={});for(var i=-1,a=r.length;++i<a;){var s=r[i],l=t?t(e[s],n[s],s,e,n):void 0;l===void 0&&(l=n[s]),o?cc(e,s,l):Vi(e,s,l)}return e}var fo=Z1;var Xh=Math.max;function J1(n,r,e){return r=Xh(r===void 0?n.length-1:r,0),function(){for(var t=arguments,o=-1,i=Xh(t.length-r,0),a=Array(i);++o<i;)a[o]=t[r+o];o=-1;for(var s=Array(r+1);++o<r;)s[o]=t[o];return s[r]=e(a),Uh(n,this,s)}}var Kh=J1;var ew=9007199254740991;function tw(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=ew}var zi=tw;function rw(n){return n!=null&&zi(n.length)&&!ac(n)}var uc=rw;var ow=Object.prototype;function nw(n){var r=n&&n.constructor,e=typeof r=="function"&&r.prototype||ow;return n===e}var Gi=nw;function iw(n,r){for(var e=-1,t=Array(n);++e<n;)t[e]=r(e);return t}var Qh=iw;var aw="[object Arguments]";function sw(n){return Kt(n)&&Tr(n)==aw}var Hd=sw;var Zh=Object.prototype,lw=Zh.hasOwnProperty,cw=Zh.propertyIsEnumerable,uw=Hd(function(){return arguments}())?Hd:function(n){return Kt(n)&&lw.call(n,"callee")&&!cw.call(n,"callee")},ji=uw;function dw(){return!1}var Jh=dw;var rm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,em=rm&&typeof module=="object"&&module&&!module.nodeType&&module,pw=em&&em.exports===rm,tm=pw?Dt.Buffer:void 0,fw=tm?tm.isBuffer:void 0,hw=fw||Jh,Jn=hw;var mw="[object Arguments]",yw="[object Array]",gw="[object Boolean]",xw="[object Date]",bw="[object Error]",vw="[object Function]",Sw="[object Map]",ww="[object Number]",Pw="[object Object]",Ow="[object RegExp]",Cw="[object Set]",Tw="[object String]",Aw="[object WeakMap]",Mw="[object ArrayBuffer]",Iw="[object DataView]",Nw="[object Float32Array]",Dw="[object Float64Array]",Ew="[object Int8Array]",_w="[object Int16Array]",Bw="[object Int32Array]",Lw="[object Uint8Array]",Rw="[object Uint8ClampedArray]",Vw="[object Uint16Array]",zw="[object Uint32Array]",dt={};dt[Nw]=dt[Dw]=dt[Ew]=dt[_w]=dt[Bw]=dt[Lw]=dt[Rw]=dt[Vw]=dt[zw]=!0;dt[mw]=dt[yw]=dt[Mw]=dt[gw]=dt[Iw]=dt[xw]=dt[bw]=dt[vw]=dt[Sw]=dt[ww]=dt[Pw]=dt[Ow]=dt[Cw]=dt[Tw]=dt[Aw]=!1;function Gw(n){return Kt(n)&&zi(n.length)&&!!dt[Tr(n)]}var om=Gw;function jw(n){return function(r){return n(r)}}var Fi=jw;var nm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Us=nm&&typeof module=="object"&&module&&!module.nodeType&&module,Fw=Us&&Us.exports===nm,Wd=Fw&&nc.process,Uw=function(){try{var n=Us&&Us.require&&Us.require("util").types;return n||Wd&&Wd.binding&&Wd.binding("util")}catch{}}(),zo=Uw;var im=zo&&zo.isTypedArray,kw=im?Fi(im):om,dc=kw;var Hw=Object.prototype,Ww=Hw.hasOwnProperty;function qw(n,r){var e=St(n),t=!e&&ji(n),o=!e&&!t&&Jn(n),i=!e&&!t&&!o&&dc(n),a=e||t||o||i,s=a?Qh(n.length,String):[],l=s.length;for(var c in n)(r||Ww.call(n,c))&&!(a&&(c=="length"||o&&(c=="offset"||c=="parent")||i&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Li(c,l)))&&s.push(c);return s}var pc=qw;function $w(n,r){return function(e){return n(r(e))}}var fc=$w;var Yw=fc(Object.keys,Object),am=Yw;var Xw=Object.prototype,Kw=Xw.hasOwnProperty;function Qw(n){if(!Gi(n))return am(n);var r=[];for(var e in Object(n))Kw.call(n,e)&&e!="constructor"&&r.push(e);return r}var sm=Qw;function Zw(n){return uc(n)?pc(n):sm(n)}var Ui=Zw;function Jw(n){var r=[];if(n!=null)for(var e in Object(n))r.push(e);return r}var lm=Jw;var e2=Object.prototype,t2=e2.hasOwnProperty;function r2(n){if(!Ar(n))return lm(n);var r=Gi(n),e=[];for(var t in n)t=="constructor"&&(r||!t2.call(n,t))||e.push(t);return e}var cm=r2;function o2(n){return uc(n)?pc(n,!0):cm(n)}var ki=o2;var n2=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i2=/^\w*$/;function a2(n,r){if(St(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||_i(n)?!0:i2.test(n)||!n2.test(n)||r!=null&&n in Object(r)}var um=a2;var s2=mr(Object,"create"),Go=s2;function l2(){this.__data__=Go?Go(null):{},this.size=0}var dm=l2;function c2(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}var pm=c2;var u2="__lodash_hash_undefined__",d2=Object.prototype,p2=d2.hasOwnProperty;function f2(n){var r=this.__data__;if(Go){var e=r[n];return e===u2?void 0:e}return p2.call(r,n)?r[n]:void 0}var fm=f2;var h2=Object.prototype,m2=h2.hasOwnProperty;function y2(n){var r=this.__data__;return Go?r[n]!==void 0:m2.call(r,n)}var hm=y2;var g2="__lodash_hash_undefined__";function x2(n,r){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Go&&r===void 0?g2:r,this}var mm=x2;function Hi(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}Hi.prototype.clear=dm;Hi.prototype.delete=pm;Hi.prototype.get=fm;Hi.prototype.has=hm;Hi.prototype.set=mm;var qd=Hi;function b2(){this.__data__=[],this.size=0}var ym=b2;function v2(n,r){for(var e=n.length;e--;)if(Ri(n[e][0],r))return e;return-1}var un=v2;var S2=Array.prototype,w2=S2.splice;function P2(n){var r=this.__data__,e=un(r,n);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():w2.call(r,e,1),--this.size,!0}var gm=P2;function O2(n){var r=this.__data__,e=un(r,n);return e<0?void 0:r[e][1]}var xm=O2;function C2(n){return un(this.__data__,n)>-1}var bm=C2;function T2(n,r){var e=this.__data__,t=un(e,n);return t<0?(++this.size,e.push([n,r])):e[t][1]=r,this}var vm=T2;function Wi(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}Wi.prototype.clear=ym;Wi.prototype.delete=gm;Wi.prototype.get=xm;Wi.prototype.has=bm;Wi.prototype.set=vm;var dn=Wi;var A2=mr(Dt,"Map"),pn=A2;function M2(){this.size=0,this.__data__={hash:new qd,map:new(pn||dn),string:new qd}}var Sm=M2;function I2(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}var wm=I2;function N2(n,r){var e=n.__data__;return wm(r)?e[typeof r=="string"?"string":"hash"]:e.map}var fn=N2;function D2(n){var r=fn(this,n).delete(n);return this.size-=r?1:0,r}var Pm=D2;function E2(n){return fn(this,n).get(n)}var Om=E2;function _2(n){return fn(this,n).has(n)}var Cm=_2;function B2(n,r){var e=fn(this,n),t=e.size;return e.set(n,r),this.size+=e.size==t?0:1,this}var Tm=B2;function qi(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}qi.prototype.clear=Sm;qi.prototype.delete=Pm;qi.prototype.get=Om;qi.prototype.has=Cm;qi.prototype.set=Tm;var ei=qi;var L2="Expected a function";function $d(n,r){if(typeof n!="function"||r!=null&&typeof r!="function")throw new TypeError(L2);var e=function(){var t=arguments,o=r?r.apply(this,t):t[0],i=e.cache;if(i.has(o))return i.get(o);var a=n.apply(this,t);return e.cache=i.set(o,a)||i,a};return e.cache=new($d.Cache||ei),e}$d.Cache=ei;var Am=$d;var R2=500;function V2(n){var r=Am(n,function(t){return e.size===R2&&e.clear(),t}),e=r.cache;return r}var Mm=V2;var z2=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,G2=/\\(\\)?/g,j2=Mm(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(z2,function(e,t,o,i){r.push(o?i.replace(G2,"$1"):t||e)}),r}),Im=j2;function F2(n){return n==null?"":Bh(n)}var Nm=F2;function U2(n,r){return St(n)?n:um(n,r)?[n]:Im(Nm(n))}var Lr=U2;var k2=1/0;function H2(n){if(typeof n=="string"||_i(n))return n;var r=n+"";return r=="0"&&1/n==-k2?"-0":r}var hn=H2;function W2(n,r){r=Lr(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[hn(r[e++])];return e&&e==t?n:void 0}var hc=W2;function q2(n,r){for(var e=-1,t=r.length,o=n.length;++e<t;)n[o+e]=r[e];return n}var $i=q2;var Dm=kt?kt.isConcatSpreadable:void 0;function $2(n){return St(n)||ji(n)||!!(Dm&&n&&n[Dm])}var Em=$2;function _m(n,r,e,t,o){var i=-1,a=n.length;for(e||(e=Em),o||(o=[]);++i<a;){var s=n[i];r>0&&e(s)?r>1?_m(s,r-1,e,t,o):$i(o,s):t||(o[o.length]=s)}return o}var Bm=_m;function Y2(n){var r=n==null?0:n.length;return r?Bm(n,1):[]}var Lm=Y2;function X2(n){return $h(Kh(n,void 0,Lm),n+"")}var mc=X2;var K2=fc(Object.getPrototypeOf,Object),Yi=K2;var Q2="[object Object]",Z2=Function.prototype,J2=Object.prototype,Rm=Z2.toString,eP=J2.hasOwnProperty,tP=Rm.call(Object);function rP(n){if(!Kt(n)||Tr(n)!=Q2)return!1;var r=Yi(n);if(r===null)return!0;var e=eP.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&Rm.call(e)==tP}var Vm=rP;function oP(n,r,e){var t=-1,o=n.length;r<0&&(r=-r>o?0:o+r),e=e>o?o:e,e<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var i=Array(o);++t<o;)i[t]=n[t+r];return i}var zm=oP;function nP(){this.__data__=new dn,this.size=0}var Gm=nP;function iP(n){var r=this.__data__,e=r.delete(n);return this.size=r.size,e}var jm=iP;function aP(n){return this.__data__.get(n)}var Fm=aP;function sP(n){return this.__data__.has(n)}var Um=sP;var lP=200;function cP(n,r){var e=this.__data__;if(e instanceof dn){var t=e.__data__;if(!pn||t.length<lP-1)return t.push([n,r]),this.size=++e.size,this;e=this.__data__=new ei(t)}return e.set(n,r),this.size=e.size,this}var km=cP;function Xi(n){var r=this.__data__=new dn(n);this.size=r.size}Xi.prototype.clear=Gm;Xi.prototype.delete=jm;Xi.prototype.get=Fm;Xi.prototype.has=Um;Xi.prototype.set=km;var Ki=Xi;function uP(n,r){return n&&fo(r,Ui(r),n)}var Hm=uP;function dP(n,r){return n&&fo(r,ki(r),n)}var Wm=dP;var Xm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,qm=Xm&&typeof module=="object"&&module&&!module.nodeType&&module,pP=qm&&qm.exports===Xm,$m=pP?Dt.Buffer:void 0,Ym=$m?$m.allocUnsafe:void 0;function fP(n,r){if(r)return n.slice();var e=n.length,t=Ym?Ym(e):new n.constructor(e);return n.copy(t),t}var Km=fP;function hP(n,r){for(var e=-1,t=n==null?0:n.length,o=0,i=[];++e<t;){var a=n[e];r(a,e,n)&&(i[o++]=a)}return i}var Qm=hP;function mP(){return[]}var yc=mP;var yP=Object.prototype,gP=yP.propertyIsEnumerable,Zm=Object.getOwnPropertySymbols,xP=Zm?function(n){return n==null?[]:(n=Object(n),Qm(Zm(n),function(r){return gP.call(n,r)}))}:yc,Qi=xP;function bP(n,r){return fo(n,Qi(n),r)}var Jm=bP;var vP=Object.getOwnPropertySymbols,SP=vP?function(n){for(var r=[];n;)$i(r,Qi(n)),n=Yi(n);return r}:yc,gc=SP;function wP(n,r){return fo(n,gc(n),r)}var ey=wP;function PP(n,r,e){var t=r(n);return St(n)?t:$i(t,e(n))}var xc=PP;function OP(n){return xc(n,Ui,Qi)}var ks=OP;function CP(n){return xc(n,ki,gc)}var bc=CP;var TP=mr(Dt,"DataView"),vc=TP;var AP=mr(Dt,"Promise"),Sc=AP;var MP=mr(Dt,"Set"),wc=MP;var ty="[object Map]",IP="[object Object]",ry="[object Promise]",oy="[object Set]",ny="[object WeakMap]",iy="[object DataView]",NP=Vo(vc),DP=Vo(pn),EP=Vo(Sc),_P=Vo(wc),BP=Vo(lc),ti=Tr;(vc&&ti(new vc(new ArrayBuffer(1)))!=iy||pn&&ti(new pn)!=ty||Sc&&ti(Sc.resolve())!=ry||wc&&ti(new wc)!=oy||lc&&ti(new lc)!=ny)&&(ti=function(n){var r=Tr(n),e=r==IP?n.constructor:void 0,t=e?Vo(e):"";if(t)switch(t){case NP:return iy;case DP:return ty;case EP:return ry;case _P:return oy;case BP:return ny}return r});var jo=ti;var LP=Object.prototype,RP=LP.hasOwnProperty;function VP(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&RP.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var ay=VP;var zP=Dt.Uint8Array,Zi=zP;function GP(n){var r=new n.constructor(n.byteLength);return new Zi(r).set(new Zi(n)),r}var Ji=GP;function jP(n,r){var e=r?Ji(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var sy=jP;var FP=/\w*$/;function UP(n){var r=new n.constructor(n.source,FP.exec(n));return r.lastIndex=n.lastIndex,r}var ly=UP;var cy=kt?kt.prototype:void 0,uy=cy?cy.valueOf:void 0;function kP(n){return uy?Object(uy.call(n)):{}}var dy=kP;function HP(n,r){var e=r?Ji(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var py=HP;var WP="[object Boolean]",qP="[object Date]",$P="[object Map]",YP="[object Number]",XP="[object RegExp]",KP="[object Set]",QP="[object String]",ZP="[object Symbol]",JP="[object ArrayBuffer]",eO="[object DataView]",tO="[object Float32Array]",rO="[object Float64Array]",oO="[object Int8Array]",nO="[object Int16Array]",iO="[object Int32Array]",aO="[object Uint8Array]",sO="[object Uint8ClampedArray]",lO="[object Uint16Array]",cO="[object Uint32Array]";function uO(n,r,e){var t=n.constructor;switch(r){case JP:return Ji(n);case WP:case qP:return new t(+n);case eO:return sy(n,e);case tO:case rO:case oO:case nO:case iO:case aO:case sO:case lO:case cO:return py(n,e);case $P:return new t;case YP:case QP:return new t(n);case XP:return ly(n);case KP:return new t;case ZP:return dy(n)}}var fy=uO;function dO(n){return typeof n.constructor=="function"&&!Gi(n)?Fh(Yi(n)):{}}var hy=dO;var pO="[object Map]";function fO(n){return Kt(n)&&jo(n)==pO}var my=fO;var yy=zo&&zo.isMap,hO=yy?Fi(yy):my,gy=hO;var mO="[object Set]";function yO(n){return Kt(n)&&jo(n)==mO}var xy=yO;var by=zo&&zo.isSet,gO=by?Fi(by):xy,vy=gO;var xO=1,bO=2,vO=4,Sy="[object Arguments]",SO="[object Array]",wO="[object Boolean]",PO="[object Date]",OO="[object Error]",wy="[object Function]",CO="[object GeneratorFunction]",TO="[object Map]",AO="[object Number]",Py="[object Object]",MO="[object RegExp]",IO="[object Set]",NO="[object String]",DO="[object Symbol]",EO="[object WeakMap]",_O="[object ArrayBuffer]",BO="[object DataView]",LO="[object Float32Array]",RO="[object Float64Array]",VO="[object Int8Array]",zO="[object Int16Array]",GO="[object Int32Array]",jO="[object Uint8Array]",FO="[object Uint8ClampedArray]",UO="[object Uint16Array]",kO="[object Uint32Array]",lt={};lt[Sy]=lt[SO]=lt[_O]=lt[BO]=lt[wO]=lt[PO]=lt[LO]=lt[RO]=lt[VO]=lt[zO]=lt[GO]=lt[TO]=lt[AO]=lt[Py]=lt[MO]=lt[IO]=lt[NO]=lt[DO]=lt[jO]=lt[FO]=lt[UO]=lt[kO]=!0;lt[OO]=lt[wy]=lt[EO]=!1;function Pc(n,r,e,t,o,i){var a,s=r&xO,l=r&bO,c=r&vO;if(e&&(a=o?e(n,t,o,i):e(n)),a!==void 0)return a;if(!Ar(n))return n;var u=St(n);if(u){if(a=ay(n),!s)return kh(n,a)}else{var p=jo(n),d=p==wy||p==CO;if(Jn(n))return Km(n,s);if(p==Py||p==Sy||d&&!o){if(a=l||d?{}:hy(n),!s)return l?ey(n,Wm(a,n)):Jm(n,Hm(a,n))}else{if(!lt[p])return o?n:{};a=fy(n,p,s)}}i||(i=new Ki);var h=i.get(n);if(h)return h;i.set(n,a),vy(n)?n.forEach(function(y){a.add(Pc(y,r,e,y,n,i))}):gy(n)&&n.forEach(function(y,g){a.set(g,Pc(y,r,e,g,n,i))});var f=c?l?bc:ks:l?ki:Ui,m=u?void 0:f(n);return Yh(m||n,function(y,g){m&&(g=y,y=n[g]),Vi(a,g,Pc(y,r,e,g,n,i))}),a}var Oc=Pc;var HO=1,WO=4;function qO(n){return Oc(n,HO|WO)}var Fo=qO;var $O="__lodash_hash_undefined__";function YO(n){return this.__data__.set(n,$O),this}var Oy=YO;function XO(n){return this.__data__.has(n)}var Cy=XO;function Cc(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new ei;++r<e;)this.add(n[r])}Cc.prototype.add=Cc.prototype.push=Oy;Cc.prototype.has=Cy;var Ty=Cc;function KO(n,r){for(var e=-1,t=n==null?0:n.length;++e<t;)if(r(n[e],e,n))return!0;return!1}var Ay=KO;function QO(n,r){return n.has(r)}var My=QO;var ZO=1,JO=2;function eC(n,r,e,t,o,i){var a=e&ZO,s=n.length,l=r.length;if(s!=l&&!(a&&l>s))return!1;var c=i.get(n),u=i.get(r);if(c&&u)return c==r&&u==n;var p=-1,d=!0,h=e&JO?new Ty:void 0;for(i.set(n,r),i.set(r,n);++p<s;){var f=n[p],m=r[p];if(t)var y=a?t(m,f,p,r,n,i):t(f,m,p,n,r,i);if(y!==void 0){if(y)continue;d=!1;break}if(h){if(!Ay(r,function(g,v){if(!My(h,v)&&(f===g||o(f,g,e,t,i)))return h.push(v)})){d=!1;break}}else if(!(f===m||o(f,m,e,t,i))){d=!1;break}}return i.delete(n),i.delete(r),d}var Tc=eC;function tC(n){var r=-1,e=Array(n.size);return n.forEach(function(t,o){e[++r]=[o,t]}),e}var Iy=tC;function rC(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Ny=rC;var oC=1,nC=2,iC="[object Boolean]",aC="[object Date]",sC="[object Error]",lC="[object Map]",cC="[object Number]",uC="[object RegExp]",dC="[object Set]",pC="[object String]",fC="[object Symbol]",hC="[object ArrayBuffer]",mC="[object DataView]",Dy=kt?kt.prototype:void 0,Yd=Dy?Dy.valueOf:void 0;function yC(n,r,e,t,o,i,a){switch(e){case mC:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case hC:return!(n.byteLength!=r.byteLength||!i(new Zi(n),new Zi(r)));case iC:case aC:case cC:return Ri(+n,+r);case sC:return n.name==r.name&&n.message==r.message;case uC:case pC:return n==r+"";case lC:var s=Iy;case dC:var l=t&oC;if(s||(s=Ny),n.size!=r.size&&!l)return!1;var c=a.get(n);if(c)return c==r;t|=nC,a.set(n,r);var u=Tc(s(n),s(r),t,o,i,a);return a.delete(n),u;case fC:if(Yd)return Yd.call(n)==Yd.call(r)}return!1}var Ey=yC;var gC=1,xC=Object.prototype,bC=xC.hasOwnProperty;function vC(n,r,e,t,o,i){var a=e&gC,s=ks(n),l=s.length,c=ks(r),u=c.length;if(l!=u&&!a)return!1;for(var p=l;p--;){var d=s[p];if(!(a?d in r:bC.call(r,d)))return!1}var h=i.get(n),f=i.get(r);if(h&&f)return h==r&&f==n;var m=!0;i.set(n,r),i.set(r,n);for(var y=a;++p<l;){d=s[p];var g=n[d],v=r[d];if(t)var O=a?t(v,g,d,r,n,i):t(g,v,d,n,r,i);if(!(O===void 0?g===v||o(g,v,e,t,i):O)){m=!1;break}y||(y=d=="constructor")}if(m&&!y){var P=n.constructor,S=r.constructor;P!=S&&"constructor"in n&&"constructor"in r&&!(typeof P=="function"&&P instanceof P&&typeof S=="function"&&S instanceof S)&&(m=!1)}return i.delete(n),i.delete(r),m}var _y=vC;var SC=1,By="[object Arguments]",Ly="[object Array]",Ac="[object Object]",wC=Object.prototype,Ry=wC.hasOwnProperty;function PC(n,r,e,t,o,i){var a=St(n),s=St(r),l=a?Ly:jo(n),c=s?Ly:jo(r);l=l==By?Ac:l,c=c==By?Ac:c;var u=l==Ac,p=c==Ac,d=l==c;if(d&&Jn(n)){if(!Jn(r))return!1;a=!0,u=!1}if(d&&!u)return i||(i=new Ki),a||dc(n)?Tc(n,r,e,t,o,i):Ey(n,r,l,e,t,o,i);if(!(e&SC)){var h=u&&Ry.call(n,"__wrapped__"),f=p&&Ry.call(r,"__wrapped__");if(h||f){var m=h?n.value():n,y=f?r.value():r;return i||(i=new Ki),o(m,y,e,t,i)}}return d?(i||(i=new Ki),_y(n,r,e,t,o,i)):!1}var Vy=PC;function zy(n,r,e,t,o){return n===r?!0:n==null||r==null||!Kt(n)&&!Kt(r)?n!==n&&r!==r:Vy(n,r,e,t,zy,o)}var Gy=zy;function OC(n,r){return n!=null&&r in Object(n)}var jy=OC;function CC(n,r,e){r=Lr(r,n);for(var t=-1,o=r.length,i=!1;++t<o;){var a=hn(r[t]);if(!(i=n!=null&&e(n,a)))break;n=n[a]}return i||++t!=o?i:(o=n==null?0:n.length,!!o&&zi(o)&&Li(a,o)&&(St(n)||ji(n)))}var Fy=CC;function TC(n,r){return n!=null&&Fy(n,r,jy)}var Uy=TC;function AC(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}var ky=AC;function MC(n,r){return r.length<2?n:hc(n,zm(r,0,-1))}var Hy=MC;function IC(n,r){return Gy(n,r)}var Xd=IC;function NC(n,r){return r=Lr(r,n),n=Hy(n,r),n==null||delete n[hn(ky(r))]}var Wy=NC;function DC(n){return Vm(n)?void 0:n}var qy=DC;var EC=1,_C=2,BC=4,LC=mc(function(n,r){var e={};if(n==null)return e;var t=!1;r=ic(r,function(i){return i=Lr(i,n),t||(t=i.length>1),i}),fo(n,bc(n),e),t&&(e=Oc(e,EC|_C|BC,qy));for(var o=r.length;o--;)Wy(e,r[o]);return e}),ea=LC;function RC(n,r,e,t){if(!Ar(n))return n;r=Lr(r,n);for(var o=-1,i=r.length,a=i-1,s=n;s!=null&&++o<i;){var l=hn(r[o]),c=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return n;if(o!=a){var u=s[l];c=t?t(u,l,s):void 0,c===void 0&&(c=Ar(u)?u:Li(r[o+1])?[]:{})}Vi(s,l,c),s=s[l]}return n}var $y=RC;function VC(n,r,e){for(var t=-1,o=r.length,i={};++t<o;){var a=r[t],s=hc(n,a);e(s,a)&&$y(i,Lr(a,n),s)}return i}var Yy=VC;function zC(n,r){return Yy(n,r,function(e,t){return Uy(n,t)})}var Xy=zC;var GC=mc(function(n,r){return n==null?{}:Xy(n,r)}),Kr=GC;var be=class{modifyById(r,e){let t=this;if(t[r]===void 0)throw new Error("not expected");{let i={...t,[r]:e};return Object.setPrototypeOf(i,be.prototype),i}}add(r,e){return this.runOp({type:1,id:r,data:e})?.data??this}runOp(r){let e=this;if(r.type===1){let t=e[r.id],o;t===void 0?o={type:2,id:r.id}:o={type:1,id:r.id,data:t};let{id:i,data:a}=r,s={...e,[i]:a};return Object.setPrototypeOf(s,be.prototype),{data:s,actual:r,reverse:o}}else if(r.type===2){let{id:t}=r,o=e[t];if(o===void 0)return null;{let i={...e};return Object.setPrototypeOf(i,be.prototype),delete i[t],{data:i,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function Hs(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let r=Object.getOwnPropertyNames(n);for(let e of r){let t=n[e];t&&typeof t=="object"&&Hs(t)}return Object.freeze(n)}function Ky(n,r){let e=0;for(;e<n.length&&e<r.length;){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1;e+=1}return e!==r.length?-1:e!==n.length?1:0}var ta=class extends Error{};function Mc(n){let r={...n};return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function ho(n,r,e){if(n===void 0?r===void 0?(n=0,r=10):n=r-10:r===void 0&&(r=n+10),n>r){let i=n;n=r,r=i}let t=[],o=1/(e+1);for(let i=0;i<e;i++){let a=n+(r-n)*(i+.75+Math.random()*.5)*o;t.push(a)}return t}function ra(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 Qy(){return typeof process<"u"}function Zy(n,r){for(let e of n)r(e.id,e.data)!==!0&&Zy(e.children,r)}function Jy(n,r){if(r(n.id,n.data)!==!0)for(let e of n.children)Jy(e,r)}var at=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,at.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Hs(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);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,t){if(!this.has(e))return!0;for(;e;){let o=this.parent(e);if(o===t)return!0;e=o}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let o=this.parent(e);if(o===t)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,t){if(e===null)this.traverse(t);else{let o=this.get(e);o&&Jy(o,t)}}traverse(e){Zy(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),a=this.childrenArray(i),s=a.findIndex(u=>u.id===e);if(s<0)throw new Error("not expected");let l=a[s];return a=[...a],a[s]={...l,data:t},this.modifyArrayBy(i,a)}}modifyArrayBy(e,t){let o=e,i=t;for(;o!==null;){let s=i,l=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let c=i.findIndex(u=>u.id===l);if(c<0)throw new Error;i=[...i],i[c]={...i[c],children:s}}Object.setPrototypeOf(i,at.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:t}){if(this.get(e)!==void 0)return!0;for(let o of t)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:t,fi:o,id:i,data:a,children:s}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=t,c=this.childrenArray(l),u={fi:o,id:i,data:a,children:s};return c=[...c,u],c.sort((d,h)=>d.fi-h.fi),e.localIndex=c.indexOf(u),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:i}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let o=this.parent(t);if(o===void 0)return null;let i=this.childrenArray(o),a=i.findIndex(c=>c.id===t);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:t,fi:o,id:i}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:i});if(t!==null){let h=t;for(;h!==null;){if(h===void 0)throw new Error;if(h===i)throw new ta("cyclic tree");h=this.parent(h)}}let a=this.parent(i);if(a===void 0)return null;let s=a,l=this.childrenArray(a),c=l.findIndex(h=>h.id===i);l=[...l];let u=l.splice(c,1)[0],p=this.modifyArrayBy(a,l);a=t,l=p.childrenArray(a);let d=u.fi;return u={...u,fi:o},l=[...l,u],l.sort((h,f)=>h.fi-f.fi),e.localIndex=l.indexOf(u),p=p.modifyArrayBy(a,l),{data:p,actual:e,reverse:{type:9,parent:s,fi:d,id:i}}}previous(e,t){if(t===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===t)return o;o=i.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let o=this.childrenArray(t),i=o.findIndex(a=>a.id===e)+1;if(i<o.length)return o[i].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let o=this.childrenArray(t),i=o.findIndex(a=>a.id===e)-1;return i>=0?this.traverseSortPrevious(o[i].id):t}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push({...o,...i})}t.sort((o,i)=>Ky(o.sortKey,i.sortKey));for(let o of t)delete o.sortKey;return t}getWithSortKey(e){var t=e;let o=[],i=this.get(t),a=i;if(i!==void 0){for(;t;)o.splice(0,0,i.fi),t=this.parent(t),t!==null&&(i=this.get(t));return{...a,sortKey:o}}}insertBeforeHelper(e,t,o){return this.insertAfterHelper(e,this.previous(e,t),o)}insertAfterHelper(e,t,o){let i=this.childrenArray(e);if(t===null){if(i.length===0)return ho(0,o,o);{let a=i[0].fi;return ho(a-o,a,o)}}else{let a=this.get(t);if(a===void 0||this.parent(t)!==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 ho(l,l+o,o)}else return ho(a.fi,s.fi,o)}}};var oa;(r=>{function n(e,t){if(t.type!==0)return null;if(Array.isArray(e)){let o=t.props,i={},a=[...e],s=!1;if(o)for(let l of Object.keys(o)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");i[l]=a[c],a[c]=o[l],s=!0}return s?{data:a,actual:t,reverse:{type:0,props:i}}:null}else{let o=t.props,i={},a={...e},s=!1;if(o)for(let l of Object.keys(o)){i[l]=a[l];let c=o[l];c===void 0?delete a[l]:a[l]=c,s=!0}return s?{data:a,actual:t,reverse:{type:0,props:i}}:null}}r.runOp=n})(oa||(oa={}));var Se=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Se.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Hs(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,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,a=i.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let s=i[a];return i=[...i],i[a]={...s,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,Se.prototype);let t=e;return Qy()||t.fillCaches(),t}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:t,id:o,data:i}=e,a=this,s={fi:t,id:o,data:i};return a=[...a,s],a.sort((c,u)=>c.fi-u.fi),e.localIndex=a.indexOf(s),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:o}}}deleteOp(e){let{id:t}=e,o=this,i=o.findIndex(l=>l.id===t);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:t,id:o}=e,i=this;i=[...i];let a=i.findIndex(u=>u.id===o);if(a===-1)return null;let s=i[a].fi,l={...i[a],fi:t};return i[a]=l,i.sort((u,p)=>u.fi-p.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 t=null;for(let o of this){if(o.id===e)return t;t=o.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let o=this;if(e===null){if(o.length===0)return ho(0,t,t);{let i=o[0].fi;return ho(i-t,i,t)}}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 ho(s,s+t,t)}else return ho(i.fi,a.fi,t)}}};function na(n){return n&&typeof n=="object"&&n instanceof st}var st=class{unusedFunOverridesTable(r){}runOp(r){let e=[],t=this,o=0,i={};for(;o<r.path.length;){if(e.push(t),t=t===void 0?void 0:t[r.path[o]],t!==void 0&&!na(t))return null;o+=1}t=t?Mc(t):new st;for(let[l,c]of Object.entries(r.props)){let u=t[l];i[l]=u,c===void 0?delete t[l]:t[l]=c}for(;o>0;){if(Object.keys(t).length===0){let l=e[o-1];l&&(t=Mc(l),delete t[r.path[o-1]])}else{let l=e[o-1];if(l){let c=Mc(l);c[r.path[o-1]]=t,t=c}else{let c=new st;c[r.path[o-1]]=t,t=c}}o-=1}let a=Object.setPrototypeOf(t,st.prototype),s={...r,props:i};return{data:a,actual:r,reverse:s}}},mo;(t=>{function n(o,i){return Ws(o,i)??o}t.apply=n;function r(o,i){return Qd(o,i)}t.merge=r;function e(o,i){let a=0,s=i.path,l=o;for(;a<s.length&&l!==void 0;){if(l=mt.zoomOnce(l,s[a]),l===void 0)return i;if(!na(l))return;a+=1}if(l===void 0)return i;if(!!na(l))if(i.type===0){let c={...i.props};for(let u of Object.keys(l))delete c[u];return{...i,props:c}}else if(i.type===1||i.type===4||i.type===7){let c=Kd([i],l);return c?(console.log(c),c):i}else return i}t.filterOp=e})(mo||(mo={}));function Kd(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,a=Ws(o.data,r[i]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=Kd(o.children,r);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 t}function jC(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,a=Ws(o.data,r[i]);return e=e||a!==void 0,a===void 0&&(a=o.data),{...o,id:i,data:a}});if(e)return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function Ws(n,r){if(!na(r))return r;if(n instanceof at){let e=Kd(n,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof Se)return jC(n,r);if(Array.isArray(n)){let e=!1,t=n.map((o,i)=>{let a=Ws(o,r[i]);return e=e||a!==void 0,a===void 0&&(a=o),a});return e?(Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t):void 0}else{if(n instanceof st)return Qd(n,r);if(n&&typeof n=="object"){let e={},t=!1;for(let[o,i]of Object.entries(n)){let a=Ws(i,r[o]);t=t||a!==void 0,a===void 0&&(a=i),e[o]=a}return t?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function Qd(n,r){if(n===void 0)return r;if(r===void 0)return n;if(!na(r))return r;if(!na(n))return mo.apply(n,r);let e=new Set;for(let o of Object.keys(n))e.add(o);for(let o of Object.keys(r))e.add(o);let t=new st;for(let o of e){let i=Qd(n===void 0?void 0:n[o],r===void 0?void 0:r[o]);t[o]=i}return t}function eg(n,r){let e={cur:[],result:[],len:0};return n=qs(n,r,e)??n,[n,e.result]}function Ic(n,r){return n===null?null:(n.cur[n.len]=r,n.len+=1,n)}function Nc(n){n&&(n.len-=1)}function FC(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function tg(n,r,e){let t=!1,o=n.map(i=>{let a=i.id,s=r[a];if(s!==void 0&&typeof s=="string"&&(t=!0,a=s,e!==null))throw new Error("not supported");let l=qs(i.data,r,Ic(e,a));Nc(e),t=t||l!==void 0,l===void 0&&(l=i.data);let c=tg(i.children,r,e);return c!==void 0?t=!0:c=i.children,{...i,id:a,data:l,children:c}});if(t)return o}function UC(n,r,e){let t=!1,o=n.map(i=>{let a=i.id,s=r[a];if(s!==void 0&&typeof s=="string"&&(t=!0,a=s,e!==null))throw new Error("not supported");let l=qs(i.data,r,Ic(e,a));return Nc(e),t=t||l!==void 0,l===void 0&&(l=i.data),{...i,id:a,data:l}});if(t)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}function qs(n,r,e){if(n instanceof at){let t=tg(n,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else{if(n instanceof Se)return UC(n,r,e);if(Array.isArray(n)){let t=!1,o=n.map((i,a)=>{let s=qs(i,r,Ic(e,a));return Nc(e),t=t||s!==void 0,s===void 0&&(s=i),s});return t?(Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o):void 0}else if(n&&typeof n=="object"&&!ra(n)){let t={},o=!1;for(let[i,a]of Object.entries(n))if(i!=="name"){let s=r[i];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,i=s}let l=qs(a,r,Ic(e,i));Nc(e),o=o||l!==void 0,l===void 0&&(l=a),t[i]=l}else t[i]=a;return o?(Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t):void 0}else if(typeof n=="string"){let t=r[n];return t!==void 0&&FC(e),t}else return}}var ia;(r=>{function n(e,t){let o=mt.zoom(t,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:{}}}r.replaceProps=n})(ia||(ia={}));var yt;(s=>{function n(l,c){return{...l,path:l.path.slice(c)}}s.drop=n;function r(l,c){return e(l,c)?.data??l}s.applySimple=r;function e(l,c){let u=c.path;for(var p=[];;){let d;if(l instanceof st&&c.type===0&&(d=l.runOp({...c,path:u.slice(p.length)}),d===null&&(d=void 0)),d===void 0&&p.length===u.length&&(l instanceof at||l instanceof Se||l instanceof be?d=l.runOp(c):d=oa.runOp(l,c)),d!==void 0)if(d!==null){let m=d.data;for(let y=p.length-1;y>=0;y--){let g=u[y],v=p[y];if(v instanceof at){if(typeof g=="number")throw new Error("illegal arg");m=v.modifyById(g,m)}else if(v instanceof Se){if(typeof g=="number")throw new Error("illegal arg");m=v.modifyById(g,m)}else if(v instanceof be){if(typeof g=="number")throw new Error("illegal arg");m=v.modifyById(g,m)}else if(v instanceof st){let O={...v,[g]:m};m=Object.setPrototypeOf(O,st.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let O=m;m=[...v],m[g]=O}else m={...v,[g]:m};else return null}return{data:m,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let h=u[p.length],f;if(l instanceof at){if(typeof h=="number")throw new Error("");f=l.get(h)?.data}else if(l instanceof Se){if(typeof h=="number")throw new Error("");f=l.get(h)?.data}else l!==null&&(f=l[h]);if(f!==void 0)p.push(l),l=f;else return null}}s.apply=e;function t(l,c){for(let u=0;u<l.length&&u<c.length;u++)if(l[u]!==c[u])return!0;return!1}s.pathDisjoint=t;function o(l,c){if(l.length!==c.length)return!1;for(let u=0;u<l.length;u++)if(l[u]!==c[u])return!1;return!0}s.pathEq=o;function i(l,c){return t(l.path,c.path)}s.commutative=i;function a(l,c){return l.type===0&&c.type===0&&o(l.path,c.path)?Object.keys(l.props).every(u=>c.props[u]!==void 0):!1}s.subsumed=a})(yt||(yt={}));var $s;(l=>{function n(){return[]}l.empty=n;function r(c,u){let p=[];for(let d of c){let[h,...f]=d.path;h===u&&p.push({...d,path:f})}return p}l.removePrefix=r;function e(c,u){return c.map(p=>({...p,path:[u,...p.path]}))}l.addPrefix=e;function t(c,u){return[...c,...u]}l.concat=t;function o(c,u){return[...c.filter(d=>!u.some(h=>yt.subsumed(d,h))),...u]}l.compress=o;function i(c,u){return c.every(p=>u.every(d=>yt.commutative(p,d)))}l.commutative=i;function a(c,u){for(let p of u){let d=s(c,p);d!==null&&(c=d.data)}return c}l.applyAll=a;function s(c,u){var p=c;let d=[],h=[];for(let f of u)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let m,y,g;if(f.type===3?(m=mt.zoom(p,[...f.path,f.id]),g=yt.apply(p,{...f,type:2})):(m=mt.zoom(p,[...f.path,f.id,"value"]),g=yt.apply(p,f)),g!==null){p=g.data;let[v,O]=eg(p,{[f.id]:m});p=v;for(let P=0;P<O.length;P++){let S=O[P],T=S.pop();if(typeof T=="number"){let I=[T];for(let _=P+1;_<O.length;_++){let D=O[_],A=D[D.length-1];if(typeof A=="number"&&mt.equal(S,D.slice(0,D.length-1)))I.push(A),O.splice(_,1);else break}let x=mt.zoom(p,S);y=x.map((_,D)=>I.includes(D)?f.id:_),m=x,T=S.pop()}else{if(T==="alphaOverride"||T==="alpha"){m/=100;let I=m,x=mt.zoom(p,S.slice(0,S.length-2)),_=x.layers.map(D=>D.id===S[S.length-1]?{...D,data:{...D.data,[T]:I}}:D);Object.setPrototypeOf(_,Object.getPrototypeOf(x.layers)),x.layers=_}y=f.id}d.push({type:0,path:S,props:{[T]:m}}),h.push({type:0,path:S,props:{[T]:y}})}h.push(g.reverse),d.push(g.actual)}}else{let m=yt.apply(p,f);m!==null&&(d.push(m.actual),p=m.data,h.push(m.reverse))}}catch(m){if(m instanceof ta)return null;throw m}return{data:p,actual:d,reverse:h.reverse()}}l.apply=s})($s||($s={}));var rg=Symbol(),kC=Symbol(),Ec=Symbol(),ri=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let i=t;for(;!(o instanceof Dc);){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,r,e.actual,e.reverse)}deleteChildren(r){if(this._children){let e=this._children[r];if(e){let t=e[Ec];t&&t(),delete this._children[r]}}}},Jd=class extends ri{constructor(r,e,t){super(),this._parent=r,this._path=e,this._current=t}update(r,e){if(Array.isArray(this._current)){if(typeof r=="string"&&(r=parseInt(r),isNaN(r)))throw new Error("Invalid path");this._current=[...this._current],this._current[r]=e}else this._current={...this._current,[r]:e}}runOp(r){this.reportOp(r,oa.runOp(this._current,r),r.path)}},ep=class extends ri{constructor(r,e,t){super(),this._parent=r,this._path=e,this._current=t}update(r,e){this._current={...this._current,[r]:e},Object.setPrototypeOf(this._current,be.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},og={get(n,r){if(r===Ec)return()=>{n._parent=null};if(r===rg)return n._current;if(r===kC)return n;let{_current:e,_children:t}=n;if(r==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e[r],a=_c(n,r,i);return a!==i?(t===void 0&&(t={},n._children=t),t[r]=a,a):i},has(n,r){return r 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,r){let e=n._current,t=Reflect.getOwnPropertyDescriptor(e,r);return t&&{writable:!0,configurable:!0,enumerable:t.enumerable,value:e[r]}}},HC={...og,set(n,r,e){let t={type:0,props:{[r]:wt(e)??e}};return n.deleteChildren(r),n.runOp(t),!0},deleteProperty(n,r){let e={type:0,props:{[r]:void 0}};return n.deleteChildren(r),n.runOp(e),!0}},WC={...og,set(n,r,e){return e===void 0?this.deleteProperty(n,r):(n.deleteChildren(r),n.runOp({type:1,id:r,data:e})),!0},deleteProperty(n,r){return n.runOp({type:2,id:r}),!0}},aa=class extends ri{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Ec]=()=>{this._parent=null}}unproxy(){return this._current}update(r,e){this._current=this._current.modifyById(r,e)}runOp(r){this.reportOp(r,this._current.runOp(r))}randomId(){return this._current.randomId()}isDescendantOf(r,e){return this._current.isDescendantOf(r,e)}childrenOf(r){return this._current.childrenOf(r)}traverse(r){return this._current.traverse(r)}get(r){return this._current.get(r)}parent(r){return this._current.parent(r)}traverse(r){this._current.traverse((e,t)=>{r(e,this.data(e))})}data(r){let{_current:e,_children:t}=this,o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e.get(r)?.data,a=_c(this,r,i);return a!==i?(t===void 0&&(t={},this._children=t),t[r]=a,a):i}add(r,e,t,o,i){this.runOp({type:7,parent:r,fi:e,id:t,data:o,children:i})}move(r,e,t){this.runOp({type:9,parent:r,fi:e,id:t})}insertAfter(r,e,t){let o=this._current.insertAfterHelper(r,e,t.length);for(let i=0;i<t.length;i++){let a=t[i];this.add(r,o[i],a.id,a.data,a.children)}}insertBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let i=0;i<t.length;i++){let a=t[i];this.add(r,o[i],a.id,a.data,a.children)}}moveAfter(r,e,t){let o=this._current.insertAfterHelper(r,e,t.length);for(let i=0;i<t.length;i++){let a=t[i];this.move(r,o[i],a)}}moveBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let i=0;i<t.length;i++){let a=t[i];this.move(r,o[i],a)}}delete(r){this.deleteChildren(r),this.runOp({type:8,id:r})}sortNext(r){return this._current.sortNext(r)}sortPrevious(r){return this._current.sortPrevious(r)}getAllSorted(r){return this._current.getAllSorted(r)}},sa=class extends ri{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Ec]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(r){let e=this.length;for(let t=0;t<e;t++){let o=this._current[t].id,i=this._current[t].fi;r(this.data(this._current[t].id),o,i)}}find(r){let e=this.length;for(let t=0;t<e;t++){let o=this._current[t].id;if(r(this.data(o),o))return this.get(o)}}update(r,e){this._current=this._current.modifyById(r,e)}randomId(){return this._current.randomId()}get(r){return{...this._current.get(r),data:this.data(r)}}data(r){let{_current:e,_children:t}=this,o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e.get(r)?.data,a=_c(this,r,i);return a!==i?(t===void 0&&(t={},this._children=t),t[r]=a,a):i}runOp(r){this.reportOp(r,this._current.runOp(r))}add(r,e,t){this.runOp({type:4,fi:r,id:e,data:t})}move(r,e){this.runOp({type:6,fi:r,id:e})}insertAfter(r,e){let t=this._current.insertAfterHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(t[o],i.id,i.data)}}insertBefore(r,e){let t=this._current.insertBeforeHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(t[o],i.id,i.data)}}moveAfter(r,e){let t=this._current.insertAfterHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(t[o],i)}}moveBefore(r,e){let t=this._current.insertBeforeHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(t[o],i)}}delete(r){this.deleteChildren(r),this.runOp({type:5,id:r})}};function Zd(n,r,e){if(n.length>0){let t=n[n.length-1];if(t.type===0&&r.type===0&&mt.equal(t.path,e)){Object.assign(t.props,r.props);return}}n.push({...r,path:e})}var Dc=class extends ri{constructor(r){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=r}update(r,e){if(r!=="")throw new Error("");this._current=e}push(r,e,t,o){Zd(this.ts,e,r),Zd(this.actual,t,r),Zd(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function _c(n,r,e){return e instanceof at?new aa(n,r,e):e instanceof Se?new sa(n,r,e):e instanceof be?new Proxy(new ep(n,r,e),WC):e!==null&&typeof e=="object"?ra(e)?e:new Proxy(new Jd(n,r,e),HC):e}function tp(n){let r=new Dc(n);return[_c(r,"",n),r]}function mn(n,r){let[e,t]=tp(n);return r(e),t.result()}function wt(n){return n instanceof aa||n instanceof sa?n._current:n!==null&&typeof n=="object"?n[rg]:n}var mt;(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 r(i,a,s){let l=t(s,i);if(l!==void 0&&typeof l=="object"&&l!==null){let c={...a};return Object.keys(l).forEach(u=>{delete c[u]}),c}else return a}o.removeOverridden=r;function e(i,a){if((i instanceof at||i instanceof aa)&&typeof a=="string")return i.data(a);if((i instanceof Se||i instanceof sa)&&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 t(i,a,s=0){for(;s<a.length&&i!==void 0;)i=e(i,a[s]),s+=1;return i}o.zoom=t})(mt||(mt={}));function ng(n,r){let e=[];if(r.length===n.length)for(var t=0;t<n.length;){if(r[t]==="*")e.push(n[t]);else if(n[t]!==r[t])return null;t+=1}else return null;return e}function Ge(n,r){let e=[];if(r.length<=n.length)for(var t=0;t<r.length;){if(r[t]==="*")e.push(n[t]);else if(n[t]!==r[t])return null;t+=1}else return null;return e}var Bc=class{},Ys=class extends Bc{constructor(e){super();this.id=e}},Xs=class extends Bc{constructor(e){super();this.data=e}};var op;try{op=new TextDecoder}catch{}var de,gn,G=0;var pg=[],np=pg,ip=0,yr={},Ke,yn,Rr=0,yo=0,Mr,Uo,lr=[],Je,ig={useRecords:!1,mapsAsObjects:!0},Ks=class{},sp=new Ks;sp.name="MessagePack 0xC1";var la=!1,go=class{constructor(r){r&&(r.useRecords===!1&&r.mapsAsObjects===void 0&&(r.mapsAsObjects=!0),r.structures?r.structures.sharedLength=r.structures.length:r.getStructures&&((r.structures=[]).uninitialized=!0,r.structures.sharedLength=0)),Object.assign(this,r)}unpack(r,e){if(de)return gg(()=>(Rc(),this?this.unpack(r,e):go.prototype.unpack.call(ig,r,e)));gn=e>-1?e:r.length,G=0,ip=0,yo=0,yn=null,np=pg,Mr=null,de=r;try{Je=r.dataView||(r.dataView=new DataView(r.buffer,r.byteOffset,r.byteLength))}catch(t){throw de=null,r instanceof Uint8Array?t:new Error("Source must be a Uint8Array or Buffer but was a "+(r&&typeof r=="object"?r.constructor.name:typeof r))}if(this instanceof go){if(yr=this,this.structures)return Ke=this.structures,Lc();(!Ke||Ke.length>0)&&(Ke=[])}else yr=ig,(!Ke||Ke.length>0)&&(Ke=[]);return Lc()}unpackMultiple(r,e){let t,o=0;try{la=!0;let i=r.length,a=this?this.unpack(r,i):Gc.unpack(r,i);if(e){for(e(a);G<i;)if(o=G,e(Lc())===!1)return}else{for(t=[a];G<i;)o=G,t.push(Lc());return t}}catch(i){throw i.lastPosition=o,i.values=t,i}finally{la=!1,Rc()}}_mergeStructures(r,e){r=r||[];for(let t=0,o=r.length;t<o;t++){let i=r[t];i&&(i.isShared=!0,t>=32&&(i.highByte=t-32>>5))}r.sharedLength=r.length;for(let t in e||[])if(t>=0){let o=r[t],i=e[t];i&&(o&&((r.restoreStructures||(r.restoreStructures=[]))[t]=o),r[t]=i)}return this.structures=r}decode(r,e){return this.unpack(r,e)}};function Lc(){try{if(!yr.trusted&&!la){let r=Ke.sharedLength||0;r<Ke.length&&(Ke.length=r)}let n=Pt();if(G==gn)Ke.restoreStructures&&ag(),Ke=null,de=null,Uo&&(Uo=null);else if(G>gn){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}else if(!la)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Ke.restoreStructures&&ag(),Rc(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function ag(){for(let n in Ke.restoreStructures)Ke[n]=Ke.restoreStructures[n];Ke.restoreStructures=null}function Pt(){let n=de[G++];if(n<160)if(n<128){if(n<64)return n;{let r=Ke[n&63]||yr.getStructures&&fg()[n&63];return r?(r.read||(r.read=lp(r,n&63)),r.read()):n}}else if(n<144)if(n-=128,yr.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[mg()]=Pt();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(Pt(),Pt());return r}else{n-=144;let r=new Array(n);for(let e=0;e<n;e++)r[e]=Pt();return r}else if(n<192){let r=n-160;if(yo>=G)return yn.slice(G-Rr,(G+=r)-Rr);if(yo==0&&gn<140){let e=r<16?cp(r):hg(r);if(e!=null)return e}return ap(r)}else{let r;switch(n){case 192:return null;case 193:return Mr?(r=Pt(),r>0?Mr[1].slice(Mr.position1,Mr.position1+=r):Mr[0].slice(Mr.position0,Mr.position0-=r)):sp;case 194:return!1;case 195:return!0;case 196:return rp(de[G++]);case 197:return r=Je.getUint16(G),G+=2,rp(r);case 198:return r=Je.getUint32(G),G+=4,rp(r);case 199:return oi(de[G++]);case 200:return r=Je.getUint16(G),G+=2,oi(r);case 201:return r=Je.getUint32(G),G+=4,oi(r);case 202:if(r=Je.getFloat32(G),yr.useFloat32>2){let e=zc[(de[G]&127)<<1|de[G+1]>>7];return G+=4,(e*r+(r>0?.5:-.5)>>0)/e}return G+=4,r;case 203:return r=Je.getFloat64(G),G+=8,r;case 204:return de[G++];case 205:return r=Je.getUint16(G),G+=2,r;case 206:return r=Je.getUint32(G),G+=4,r;case 207:return yr.int64AsNumber?(r=Je.getUint32(G)*4294967296,r+=Je.getUint32(G+4)):r=Je.getBigUint64(G),G+=8,r;case 208:return Je.getInt8(G++);case 209:return r=Je.getInt16(G),G+=2,r;case 210:return r=Je.getInt32(G),G+=4,r;case 211:return yr.int64AsNumber?(r=Je.getInt32(G)*4294967296,r+=Je.getUint32(G+4)):r=Je.getBigInt64(G),G+=8,r;case 212:if(r=de[G++],r==114)return dg(de[G++]&63);{let e=lr[r];if(e)return e.read?(G++,e.read(Pt())):e.noBuffer?(G++,e()):e(de.subarray(G,++G));throw new Error("Unknown extension "+r)}case 213:return r=de[G],r==114?(G++,dg(de[G++]&63,de[G++])):oi(2);case 214:return oi(4);case 215:return oi(8);case 216:return oi(16);case 217:return r=de[G++],yo>=G?yn.slice(G-Rr,(G+=r)-Rr):$C(r);case 218:return r=Je.getUint16(G),G+=2,yo>=G?yn.slice(G-Rr,(G+=r)-Rr):YC(r);case 219:return r=Je.getUint32(G),G+=4,yo>=G?yn.slice(G-Rr,(G+=r)-Rr):XC(r);case 220:return r=Je.getUint16(G),G+=2,lg(r);case 221:return r=Je.getUint32(G),G+=4,lg(r);case 222:return r=Je.getUint16(G),G+=2,cg(r);case 223:return r=Je.getUint32(G),G+=4,cg(r);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 qC=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function lp(n,r){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>qC.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(Pt);return n.highByte===0&&(n.read=sg(r,n.read)),o()}let t={};for(let o=0,i=n.length;o<i;o++){let a=n[o];t[a]=Pt()}return t}return e.count=0,n.highByte===0?sg(r,e):e}var sg=(n,r)=>function(){let e=de[G++];if(e===0)return r();let t=n<32?-(n+(e<<5)):n+(e<<5),o=Ke[t]||fg()[t];if(!o)throw new Error("Record id is not defined for "+t);return o.read||(o.read=lp(o,n)),o.read()};function fg(){let n=gg(()=>(de=null,yr.getStructures()));return Ke=yr._mergeStructures(n,Ke)}var ap=Vc,$C=Vc,YC=Vc,XC=Vc;function Vc(n){let r;if(n<16&&(r=cp(n)))return r;if(n>64&&op)return op.decode(de.subarray(G,G+=n));let e=G+n,t=[];for(r="";G<e;){let o=de[G++];if((o&128)===0)t.push(o);else if((o&224)===192){let i=de[G++]&63;t.push((o&31)<<6|i)}else if((o&240)===224){let i=de[G++]&63,a=de[G++]&63;t.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,t.push(l>>>10&1023|55296),l=56320|l&1023),t.push(l)}else t.push(o);t.length>=4096&&(r+=Ht.apply(String,t),t.length=0)}return t.length>0&&(r+=Ht.apply(String,t)),r}function lg(n){let r=new Array(n);for(let e=0;e<n;e++)r[e]=Pt();return r}function cg(n){if(yr.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[mg()]=Pt();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(Pt(),Pt());return r}}var Ht=String.fromCharCode;function hg(n){let r=G,e=new Array(n);for(let t=0;t<n;t++){let o=de[G++];if((o&128)>0){G=r;return}e[t]=o}return Ht.apply(String,e)}function cp(n){if(n<4)if(n<2){if(n===0)return"";{let r=de[G++];if((r&128)>1){G-=1;return}return Ht(r)}}else{let r=de[G++],e=de[G++];if((r&128)>0||(e&128)>0){G-=2;return}if(n<3)return Ht(r,e);let t=de[G++];if((t&128)>0){G-=3;return}return Ht(r,e,t)}else{let r=de[G++],e=de[G++],t=de[G++],o=de[G++];if((r&128)>0||(e&128)>0||(t&128)>0||(o&128)>0){G-=4;return}if(n<6){if(n===4)return Ht(r,e,t,o);{let i=de[G++];if((i&128)>0){G-=5;return}return Ht(r,e,t,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 Ht(r,e,t,o,i,a);let s=de[G++];if((s&128)>0){G-=7;return}return Ht(r,e,t,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 Ht(r,e,t,o,i,a,s,l);{let c=de[G++];if((c&128)>0){G-=9;return}return Ht(r,e,t,o,i,a,s,l,c)}}else if(n<12){let c=de[G++],u=de[G++];if((c&128)>0||(u&128)>0){G-=10;return}if(n<11)return Ht(r,e,t,o,i,a,s,l,c,u);let p=de[G++];if((p&128)>0){G-=11;return}return Ht(r,e,t,o,i,a,s,l,c,u,p)}else{let c=de[G++],u=de[G++],p=de[G++],d=de[G++];if((c&128)>0||(u&128)>0||(p&128)>0||(d&128)>0){G-=12;return}if(n<14){if(n===12)return Ht(r,e,t,o,i,a,s,l,c,u,p,d);{let h=de[G++];if((h&128)>0){G-=13;return}return Ht(r,e,t,o,i,a,s,l,c,u,p,d,h)}}else{let h=de[G++],f=de[G++];if((h&128)>0||(f&128)>0){G-=14;return}if(n<15)return Ht(r,e,t,o,i,a,s,l,c,u,p,d,h,f);let m=de[G++];if((m&128)>0){G-=15;return}return Ht(r,e,t,o,i,a,s,l,c,u,p,d,h,f,m)}}}}}function rp(n){return yr.copyBuffers?Uint8Array.prototype.slice.call(de,G,G+=n):de.subarray(G,G+=n)}function oi(n){let r=de[G++];if(lr[r])return lr[r](de.subarray(G,G+=n));throw new Error("Unknown extension type "+r)}var ug=new Array(4096);function mg(){let n=de[G++];if(n>=160&&n<192){if(n=n-160,yo>=G)return yn.slice(G-Rr,(G+=n)-Rr);if(!(yo==0&&gn<180))return ap(n)}else return G--,Pt();let r=(n<<5^(n>1?Je.getUint16(G):n>0?de[G]:0))&4095,e=ug[r],t=G,o=G+n-3,i,a=0;if(e&&e.bytes==n){for(;t<o;){if(i=Je.getUint32(t),i!=e[a++]){t=1879048192;break}t+=4}for(o+=3;t<o;)if(i=de[t++],i!=e[a++]){t=1879048192;break}if(t===o)return G=t,e.string;o-=3,t=G}for(e=[],ug[r]=e,e.bytes=n;t<o;)i=Je.getUint32(t),e.push(i),t+=4;for(o+=3;t<o;)i=de[t++],e.push(i);let s=n<16?cp(n):hg(n);return s!=null?e.string=s:e.string=ap(n)}var dg=(n,r)=>{var e=Pt();let t=n;r!==void 0&&(n=n<32?-((r<<5)+n):(r<<5)+n,e.highByte=r);let o=Ke[n];return o&&o.isShared&&((Ke.restoreStructures||(Ke.restoreStructures=[]))[n]=o),Ke[n]=e,e.read=lp(e,t),e.read()},yg=typeof self=="object"?self:global;lr[0]=()=>{};lr[0].noBuffer=!0;lr[101]=()=>{let n=Pt();return(yg[n[0]]||Error)(n[1])};lr[105]=n=>{let r=Je.getUint32(G-4);Uo||(Uo=new Map);let e=de[G],t;e>=144&&e<160||e==220||e==221?t=[]:t={};let o={target:t};Uo.set(r,o);let i=Pt();return o.used?Object.assign(t,i):(o.target=i,i)};lr[112]=n=>{let r=Je.getUint32(G-4),e=Uo.get(r);return e.used=!0,e.target};lr[115]=()=>new Set(Pt());var up=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");lr[116]=n=>{let r=n[0],e=up[r];if(!e)throw new Error("Could not find typed array for code "+r);return new yg[e](Uint8Array.prototype.slice.call(n,1).buffer)};lr[120]=()=>{let n=Pt();return new RegExp(n[0],n[1])};lr[98]=n=>{let r=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=G;G+=r-4,Mr=[Pt(),Pt()],Mr.position0=0,Mr.position1=0;let t=G;G=e;try{return Pt()}finally{G=t}};lr[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 gg(n){let r=gn,e=G,t=ip,o=Rr,i=yo,a=yn,s=np,l=Uo,c=Mr,u=new Uint8Array(de.slice(0,gn)),p=Ke,d=Ke.slice(0,Ke.length),h=yr,f=la,m=n();return gn=r,G=e,ip=t,Rr=o,yo=i,yn=a,np=s,Uo=l,Mr=c,de=u,la=f,Ke=p,Ke.splice(0,Ke.length,...d),yr=h,Je=new DataView(de.buffer,de.byteOffset,de.byteLength),m}function Rc(){de=null,Uo=null,Ke=null}function xg(n){n.unpack?lr[n.type]=n.unpack:lr[n.type]=n}var zc=new Array(147);for(let n=0;n<256;n++)zc[n]=+("1e"+Math.floor(45.15-n*.30103));var Gc=new go({useRecords:!1}),KC=Gc.unpack,QC=Gc.unpackMultiple,ZC=Gc.unpack,jc={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},JC=new Float32Array(1),rz=new Uint8Array(JC.buffer,0,4);var Fc;try{Fc=new TextEncoder}catch{}var Uc,pp,kc=typeof Buffer<"u",dp=kc?Buffer.allocUnsafeSlow:Uint8Array,wg=kc?Buffer:Uint8Array,bg=kc?4294967296:2144337920,Q,At,U=0,xo,bo=null,eT=/[\u0080-\uFFFF]/,Qs=Symbol("record-id"),ni=class extends go{constructor(r){super(r),this.offset=0;let e,t,o,i,a,s,l=0,c=wg.prototype.utf8Write?function(x,_,D){return Q.utf8Write(x,_,D)}:Fc&&Fc.encodeInto?function(x,_){return Fc.encodeInto(x,Q.subarray(_)).written}:!1,u=this;r||(r={});let p=r&&r.sequential,d=r.structures||r.saveStructures,h=r.maxSharedStructures;if(h==null&&(h=d?32:0),h>8160)throw new Error("Maximum maxSharedStructure is 8160");let f=r.maxOwnStructures;f==null&&(f=d?32:64),p&&!r.saveStructures&&(this.structures=[]);let m=h>32||f+h>64,y=h+64,g=h+f+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],O=0,P=0;this.pack=this.encode=function(x,_){if(Q||(Q=new dp(8192),At=new DataView(Q.buffer,0,8192),U=0),xo=Q.length-10,xo-U<2048?(Q=new dp(Q.length),At=new DataView(Q.buffer,0,Q.length),xo=Q.length-10,U=0):U=U+7&2147483640,t=U,s=u.structuredClone?new Map:null,u.bundleStrings?(bo=["",""],Q[U++]=214,Q[U++]=98,bo.position=U-t,U+=4):bo=null,o=u.structures,o){o.uninitialized&&(o=u._mergeStructures(u.getStructures()));let D=o.sharedLength||0;if(D>h)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 A=0;A<D;A++){let N=o[A];if(!N)continue;let E,B=o.transitions;for(let V=0,j=N.length;V<j;V++){let R=N[V];E=B[R],E||(E=B[R]=Object.create(null)),B=E}B[Qs]=A+64}l=D}p||(o.nextId=D+64)}i&&(i=!1),a=o||[];try{if(S(x),bo){At.setUint32(bo.position+t,U-bo.position-t);let D=bo;bo=null,S(D[0]),S(D[1])}if(u.offset=U,s&&s.idsToInsert){U+=s.idsToInsert.length*6,U>xo&&I(U),u.offset=U;let D=rT(Q.subarray(t,U),s.idsToInsert);return s=null,D}return _&Og?(Q.start=t,Q.end=U,Q):Q.subarray(t,U)}finally{if(o){if(P<10&&P++,O>1e4)o.transitions=null,P=0,O=0,v.length>0&&(v=[]);else if(v.length>0&&!p){for(let D=0,A=v.length;D<A;D++)v[D][Qs]=0;v=[]}if(i&&u.saveStructures){let D=o.sharedLength||h;o.length>D&&(o=o.slice(0,D));let A=Q.subarray(t,U);return u.saveStructures(o,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(x)):(l=D,A)}}_&cT&&(U=t)}};let S=x=>{U>xo&&(Q=I(U));var _=typeof x,D;if(_==="string"){let A=x.length;if(bo&&A>=8&&A<4096){let B=eT.test(x);bo[B?0:1]+=x,Q[U++]=193,S(B?-A:A);return}let N;A<32?N=1:A<256?N=2:A<65536?N=3:N=5;let E=A*3;if(U+E>xo&&(Q=I(U+E)),A<64||!c){let B,V,j,R=U+N;for(B=0;B<A;B++)V=x.charCodeAt(B),V<128?Q[R++]=V:V<2048?(Q[R++]=V>>6|192,Q[R++]=V&63|128):(V&64512)===55296&&((j=x.charCodeAt(B+1))&64512)===56320?(V=65536+((V&1023)<<10)+(j&1023),B++,Q[R++]=V>>18|240,Q[R++]=V>>12&63|128,Q[R++]=V>>6&63|128,Q[R++]=V&63|128):(Q[R++]=V>>12|224,Q[R++]=V>>6&63|128,Q[R++]=V&63|128);D=R-U-N}else D=c(x,U+N,E);D<32?Q[U++]=160|D:D<256?(N<2&&Q.copyWithin(U+2,U+1,U+1+D),Q[U++]=217,Q[U++]=D):D<65536?(N<3&&Q.copyWithin(U+3,U+2,U+2+D),Q[U++]=218,Q[U++]=D>>8,Q[U++]=D&255):(N<5&&Q.copyWithin(U+5,U+3,U+3+D),Q[U++]=219,At.setUint32(U,D),U+=4),U+=D}else if(_==="number")if(x>>>0===x)x<64?Q[U++]=x:x<256?(Q[U++]=204,Q[U++]=x):x<65536?(Q[U++]=205,Q[U++]=x>>8,Q[U++]=x&255):(Q[U++]=206,At.setUint32(U,x),U+=4);else if(x>>0===x)x>=-32?Q[U++]=256+x:x>=-128?(Q[U++]=208,Q[U++]=x+256):x>=-32768?(Q[U++]=209,At.setInt16(U,x),U+=2):(Q[U++]=210,At.setInt32(U,x),U+=4);else{let A;if((A=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){Q[U++]=202,At.setFloat32(U,x);let N;if(A<4||(N=x*zc[(Q[U]&127)<<1|Q[U+1]>>7])>>0===N){U+=4;return}else U--}Q[U++]=203,At.setFloat64(U,x),U+=8}else if(_==="object")if(!x)Q[U++]=192;else{if(s){let N=s.get(x);if(N){if(!N.id){let E=s.idsToInsert||(s.idsToInsert=[]);N.id=E.push(N)}Q[U++]=214,Q[U++]=112,At.setUint32(U,N.id),U+=4;return}else s.set(x,{offset:U-t})}let A=x.constructor;if(A===Object)T(x,!0);else if(A===Array){D=x.length,D<16?Q[U++]=144|D:D<65536?(Q[U++]=220,Q[U++]=D>>8,Q[U++]=D&255):(Q[U++]=221,At.setUint32(U,D),U+=4);for(let N=0;N<D;N++)S(x[N])}else if(A===Map){D=x.size,D<16?Q[U++]=128|D:D<65536?(Q[U++]=222,Q[U++]=D>>8,Q[U++]=D&255):(Q[U++]=223,At.setUint32(U,D),U+=4);for(let[N,E]of x)S(N),S(E)}else{for(let N=0,E=Uc.length;N<E;N++){let B=pp[N];if(x instanceof B){let V=Uc[N];if(V.write){V.type&&(Q[U++]=212,Q[U++]=V.type,Q[U++]=0),S(V.write.call(this,x));return}let j=Q,R=At,W=U;Q=null;let F;try{F=V.pack.call(this,x,k=>(Q=j,j=null,U+=k,U>xo&&I(U),{target:Q,targetView:At,position:U-k}),S)}finally{j&&(Q=j,At=R,U=W,xo=Q.length-10)}F&&(F.length+U>xo&&I(F.length+U),U=tT(F,Q,U,V.type));return}}T(x,!x.hasOwnProperty)}}else if(_==="boolean")Q[U++]=x?195:194;else if(_==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))Q[U++]=211,At.setBigInt64(U,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)Q[U++]=207,At.setBigUint64(U,x);else if(this.largeBigIntToFloat)Q[U++]=203,At.setFloat64(U,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");U+=8}else if(_==="undefined")this.encodeUndefinedAsNil?Q[U++]=192:(Q[U++]=212,Q[U++]=0,Q[U++]=0);else if(_==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+_)},T=this.useRecords===!1?this.variableMapSize?x=>{let _=Object.keys(x),D=_.length;D<16?Q[U++]=128|D:D<65536?(Q[U++]=222,Q[U++]=D>>8,Q[U++]=D&255):(Q[U++]=223,At.setUint32(U,D),U+=4);let A;for(let N=0;N<D;N++)S(A=_[N]),S(x[A])}:(x,_)=>{Q[U++]=222;let D=U-t;U+=2;let A=0;for(let N in x)(_||x.hasOwnProperty(N))&&(S(N),S(x[N]),A++);Q[D+++t]=A>>8,Q[D+t]=A&255}:x=>{let _=Object.keys(x),D,A=a.transitions||(a.transitions=Object.create(null)),N=0;for(let B=0,V=_.length;B<V;B++){let j=_[B];D=A[j],D||(D=A[j]=Object.create(null),N++),A=D}let E=A[Qs];if(E)E>=96&&m?(Q[U++]=((E-=96)&31)+96,Q[U++]=E>>5):Q[U++]=E;else{E=a.nextId,E||(E=64),E<y&&this.shouldShareStructure&&!this.shouldShareStructure(_)?(E=a.nextOwnId,E<g||(E=y),a.nextOwnId=E+1):(E>=g&&(E=y),a.nextId=E+1);let B=_.highByte=E>=96&&m?E-96>>5:-1;A[Qs]=E,a[E-64]=_,E<y?(_.isShared=!0,a.sharedLength=E-63,i=!0,B>=0?(Q[U++]=(E&31)+96,Q[U++]=B):Q[U++]=E):(B>=0?(Q[U++]=213,Q[U++]=114,Q[U++]=(E&31)+96,Q[U++]=B):(Q[U++]=212,Q[U++]=114,Q[U++]=E),N&&(O+=P*N),v.length>=f&&(v.shift()[Qs]=0),v.push(A),S(_))}for(let B=0,V=_.length;B<V;B++)S(x[_[B]])},I=x=>{let _;if(x>16777216){if(x-t>bg)throw new Error("Packed buffer would be larger than maximum buffer size");_=Math.min(bg,Math.round(Math.max((x-t)*(x>67108864?1.25:2),4194304)/4096)*4096)}else _=(Math.max(x-t<<2,Q.length-1)>>12)+1<<12;let D=new dp(_);return At=new DataView(D.buffer,0,_),Q.copy?Q.copy(D,0,t,x):D.set(Q.slice(t,x)),U-=t,t=0,xo=D.length-10,Q=D}}useBuffer(r){Q=r,At=new DataView(Q.buffer,Q.byteOffset,Q.byteLength),U=0}};pp=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Ks];Uc=[{pack(n,r,e){let t=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&t>=0&&t<4294967296){let{target:o,targetView:i,position:a}=r(6);o[a++]=214,o[a++]=255,i.setUint32(a,t)}else if(t>0&&t<17179869184){let{target:o,targetView:i,position:a}=r(10);o[a++]=215,o[a++]=255,i.setUint32(a,n.getMilliseconds()*4e6+(t/1e3/4294967296>>0)),i.setUint32(a+4,t)}else if(isNaN(t)){if(this.onInvalidDate)return r(0),e(this.onInvalidDate());let{target:o,targetView:i,position:a}=r(3);o[a++]=212,o[a++]=255,o[a++]=255}else{let{target:o,targetView:i,position:a}=r(15);o[a++]=199,o[a++]=12,o[a++]=255,i.setUint32(a,n.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(t)))}}},{pack(n,r,e){let t=Array.from(n),{target:o,position:i}=r(this.structuredClone?3:0);this.structuredClone&&(o[i++]=212,o[i++]=115,o[i++]=0),e(t)}},{pack(n,r,e){let{target:t,position:o}=r(this.structuredClone?3:0);this.structuredClone&&(t[o++]=212,t[o++]=101,t[o++]=0),e([n.name,n.message])}},{pack(n,r,e){let{target:t,position:o}=r(this.structuredClone?3:0);this.structuredClone&&(t[o++]=212,t[o++]=120,t[o++]=0),e([n.source,n.flags])}},{pack(n,r){this.structuredClone?vg(n,16,r):Sg(kc?Buffer.from(n):new Uint8Array(n),r)}},{pack(n,r){let e=n.constructor;e!==wg&&this.structuredClone?vg(n,up.indexOf(e.name),r):Sg(n,r)}},{pack(n,r){let{target:e,position:t}=r(1);e[t]=193}}];function vg(n,r,e,t){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++]=r,i.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),a)}function Sg(n,r){let e=n.byteLength;var t,o;if(e<256){var{target:t,position:o}=r(e+2);t[o++]=196,t[o++]=e}else if(e<65536){var{target:t,position:o}=r(e+3);t[o++]=197,t[o++]=e>>8,t[o++]=e&255}else{var{target:t,position:o,targetView:i}=r(e+5);t[o++]=198,i.setUint32(o,e),o+=4}t.set(n,o)}function tT(n,r,e,t){let o=n.length;switch(o){case 1:r[e++]=212;break;case 2:r[e++]=213;break;case 4:r[e++]=214;break;case 8:r[e++]=215;break;case 16:r[e++]=216;break;default:o<256?(r[e++]=199,r[e++]=o):o<65536?(r[e++]=200,r[e++]=o>>8,r[e++]=o&255):(r[e++]=201,r[e++]=o>>24,r[e++]=o>>16&255,r[e++]=o>>8&255,r[e++]=o&255)}return r[e++]=t,r.set(n,e),e+=o,e}function rT(n,r){let e,t=r.length*6,o=n.length-t;for(r.sort((i,a)=>i.offset>a.offset?1:-1);e=r.pop();){let i=e.offset,a=e.id;n.copyWithin(i+t,i,o),t-=6;let s=i+t;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 xn(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)");pp.unshift(n.Class),Uc.unshift(n)}xg(n)}var Pg=new ni({useRecords:!1}),oT=Pg.pack,nT=Pg.pack;var{NEVER:iT,ALWAYS:aT,DECIMAL_ROUND:sT,DECIMAL_FIT:lT}=jc,Og=512,cT=1024;var Cg=new ni({structuredClone:!0});xn({Class:be.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,be.prototype),n}});xn({Class:Se.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Se.prototype),n}});xn({Class:at.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,at.prototype),n}});xn({Class:Ys.prototype.constructor,type:4,write(n){return n.id},read(n){return new Ys(n)}});xn({Class:Xs.prototype.constructor,type:5,write(n){return n.data},read(n){return new Xs(n)}});xn({Class:st.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,st.prototype),n}});function uT(n){var r=0;if(n.length===0)return r;for(let e=0;e<n.length;e++){let t=n[e];r=(r<<5)-r+t,r=r&r}return r}function fp(n){if(ra(n))return n;if(Array.isArray(n))return n.map(fp);if(typeof n=="object"&&n!==null){let r={};for(let e of Object.keys(n).sort())r[e]=fp(n[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else return n}var Hc;(t=>{function n(o){return Cg.pack(o)}t.serialize=n;function r(o){return Cg.unpack(o)}t.deserialize=r;function e(o){return uT(n(fp(o))).toString()}t.checksum=e})(Hc||(Hc={}));var Sn="personal camera",wn="a218fcc3-276b-49b9-b485-49037fd14f5f",Ng=2960946,Mt=5526619;var ca;(h=>{function n(f,m){return f[0]===m[0]&&f[1]===m[1]}h.isEqual=n;function r(f,m,y){return[f[0]+(m[0]-f[0])*y,f[1]+(m[1]-f[1])*y]}h.lerp=r;function e(f,m){return[f[0]+m[0],f[1]+m[1]]}h.add=e;function t(f,m){return[f[0]-m[0],f[1]-m[1]]}h.sub=t;function o(f,m){return[f[0]*m[0],f[1]*m[1]]}h.multiply=o;function i(f,m){return[f[0]/m[0],f[1]/m[1]]}h.divide=i;function a(f,m){return Math.pow(m[0]-f[0],2)+Math.pow(m[1]-f[1],2)}h.distanceSquared=a;function s(f,m){return Math.sqrt(a(f,m))}h.distance=s;function l(f,m){return f[0]*m[0]+f[1]*m[1]}h.dot=l;function c(f,m){return[f[0]*m,f[1]*m]}h.scalarMultiply=c;function u(f,m,y){let g=h.sub(m,f),v=h.sub(y,f),O=h.dot(g,v)/h.dot(g,g),P=h.scalarMultiply(g,O);return h.add(f,P)}h.projectionOnto=u;function p(f,m,y){return s(f,u(f,m,y))}h.projectionOntoDistance=p;function d(f,m){return[(f[0]+m[0])*.5,(f[1]+m[1])*.5]}h.center=d})(ca||(ca={}));var bn;(s=>{function n(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}s.isEqual=n;function r(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]}s.add=r;function e(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]}s.sub=e;function t(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]}s.div=t;function o(l,c){return[l[0]*c[0],l[1]*c[1],l[2]*c[2]]}s.mul=o;function i(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])}s.dist=i;function a(l,c,u){return[l[0]+(c[0]-l[0])*u,l[1]+(c[1]-l[1])*u,l[2]+(c[2]-l[2])*u]}s.lerp=a})(bn||(bn={}));var Tg;(e=>{function n(t,o){return t[0]===o[0]&&t[1]===o[1]&&t[2]===o[2]&&t[3]===o[3]}e.isEqual=n;function r(t,o,i){return[t[0]+(o[0]-t[0])*i,t[1]+(o[1]-t[1])*i,t[2]+(o[2]-t[2])*i,t[3]+(o[3]-t[3])*i]}e.lerp=r})(Tg||(Tg={}));var vn;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function r(i,a){for(let s=0;s<16;s++)if(i[s]!==a[s])return!1;return!0}o.isEqual=r;function e(i){return i??o.identity}o.simplify=e;function t(i,a){let s=a.slice(0);for(var l=0,c=a.length;l<c;l+=3){let u=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])/u,s[l+1]=(i[1]*a[l]+i[5]*a[l+1]+i[9]*a[l+2]+i[13])/u,s[l+2]=(i[2]*a[l]+i[6]*a[l+1]+i[10]*a[l+2]+i[14])/u}return s}o.applyMatrix4=t})(vn||(vn={}));var Lt;(p=>{function n(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}p.isRGB=n,p.white={r:1,g:1,b:1},p.red={r:1,g:0,b:0},p.black={r:0,g:0,b:0};function o(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}p.toRgb255a1=o;function i(d){return{r:d.r,g:d.g,b:d.b}}p.clone=i;function a(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}p.fromHex=a;function s(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}p.toHex=s;function l(d,h){return d.r===h.r&&d.g===h.g&&d.b===h.b}p.equals=l;function c(d,h){return d.r.toFixed(2)===h.r.toFixed(2)&&d.g.toFixed(2)===h.g.toFixed(2)&&d.b.toFixed(2)===h.b.toFixed(2)}p.equalsFixed=c;function u(d,h,f){return{r:d.r+(h.r-d.r)*f,g:d.g+(h.g-d.g)*f,b:d.b+(h.b-d.b)*f}}p.lerp=u})(Lt||(Lt={}));var _e;(c=>{c.white={...Lt.white,a:1},c.transparent={...Lt.white,a:0};function e(u){return{r:u[0],g:u[1],b:u[2],a:u[3]}}c.from0to1=e;function t(u,p){return{...Lt.fromHex(u),a:p}}c.fromHexAndA=t;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}}c.toRgb255a1=o;function i(u,p){return Lt.equals(u,p)&&u.a===p.a}c.equals=i;function a(u,p){return Lt.equalsFixed(u,p)&&u.a.toFixed(2)===p.a.toFixed(2)}c.equalsFixed=a;function s(u,p,d){return{r:u.r+(p.r-u.r)*d,g:u.g+(p.g-u.g)*d,b:u.b+(p.b-u.b)*d,a:u.a+(p.a-u.a)*d}}c.lerp=s;function l({r:u,g:p,b:d,a:h}=c.white){return`rgba(${u*255}, ${p*255}, ${d*255}, ${h})`}c.toStyle=l})(_e||(_e={}));var Wc;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Wc||(Wc={}));var Ag;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(Ag||(Ag={}));var Mg;(r=>r.defaultData={control1:[.5,0],control2:[.5,1]})(Mg||(Mg={}));var Ig;(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]))(Ig||(Ig={}));function hp(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 Qr;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(Qr||(Qr={}));var Pn;(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 t(i){return i.type==="PerspectiveCamera"?i.perspective?.zoom??1:i.orthographic?.zoom??1}o.getZoom=t})(Pn||(Pn={}));var vo;(e=>{function n(t,o=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[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:[t[0]+t[0]*o,0,0]},grid:{count:[2,2,2],size:t.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 r(t,o){let i={...t};if(dT.forEach(a=>{Object.assign(i,{[a]:o[a]??t[a]})}),i.radial={...t.radial},o.radial){let a=t.radial,s=o.radial;pT.forEach(l=>{Object.assign(i.radial,{[l]:s[l]??a[l]})})}if(i.linear={...t.linear},o.linear){let a=t.linear,s=o.linear;fT.forEach(l=>{Object.assign(i.linear,{[l]:s[l]??a[l]})})}if(i.grid={...t.grid},o.grid){let a=t.grid,s=o.grid;hT.forEach(l=>{Object.assign(i.grid,{[l]:s[l]??a[l]})})}if(i.toObject={...t.toObject},o.toObject){let a=t.toObject,s=o.toObject;mT.forEach(l=>{Object.assign(i.toObject,{[l]:s[l]??a[l]})})}if(i.randomnessObject={...t.randomnessObject},o.randomnessObject){let a=t.randomnessObject,s=o.randomnessObject;yT.forEach(l=>{Object.assign(i.randomnessObject,{[l]:s[l]??a[l]})})}return i}e.merge=r})(vo||(vo={}));var qc;(t=>{t.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let r=["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 r){let l=o[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...i,s],props:l})}return a}t.toOps=e})(qc||(qc={}));var dT=["count"],pT=["radius","start","end","position","scale","rotation"],fT=["position","scale","rotation"],hT=["count","size"],mT=["count","position","scale","rotation"],yT=["strength","scale","rotation","position","movement","seed","freqScale"];var $c;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function r(t){return e.all.includes(t)}e.is=r})($c||($c={}));var Yc;(e=>{function n(t){return r(t)}e.defaultData=n;function r(t){if(t==="PointLight")return{type:t,color:_e.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(t==="SpotLight")return{type:t,color:_e.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(t==="DirectionalLight")return{type:t,color:_e.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Yc||(Yc={}));var ua;(t=>(t.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},t.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},t.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:t.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeLoopDelayStart:"end",emitTimeDuration:1,...t.defaultCollisionData}))(ua||(ua={}));var On;(r=>r.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]})(On||(On={}));var mp;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function r(t,o){return t.castShadow===o.castShadow&&t.receiveShadow===o.receiveShadow}e.equals=r})(mp||(mp={}));var yp;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function r(t,o){return t.flatShading===o.flatShading&&t.side===o.side&&t.wireframe===o.wireframe}e.equals=r})(yp||(yp={}));var Xc;(r=>r.defaultData={...yp.defaultData,...mp.defaultData})(Xc||(Xc={}));var Dg;(r=>{function n(e,t){let o=[];if("material"in e){let i=typeof e.material=="string"?t.materials[e.material]??t.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"?t.materials[i]??t.lib.materials[i]?.asset:i;a&&o.push(a)}return o}r.getMaterialData=n})(Dg||(Dg={}));var da;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(da||(da={}));var Eg;(r=>{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"}r.is=n})(Eg||(Eg={}));function Bg(n){return n.type!=="displace"}var _g;(r=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}r.is=n})(_g||(_g={}));var Lg=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],Rg=["wrapping","image","video","name","minFilter"],Et;(o=>{function n(i,a){let{texture:s,...l}=a;if(Object.assign(i,l),s){let c=i.texture;c&&Object.assign(c,s)}}o.patch=n;function r(i,a){return i==="light"&&a?e(a):t(i)}o.defaultData=r;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 t(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],rotation:0,minFilter:1008},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:da.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},crop:!1};case"color":return{...a,type:"color",color:Lt.fromHex(Mt)};case"depth":return{...a,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Lt.fromHex(6710886),a:1},colorB:{...Lt.fromHex(6710886),a:1},colorC:{...Lt.fromHex(16777215),a:1},colorD:{...Lt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:_e.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:_e.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:_e.fromHexAndA(0,1),contourColor:_e.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],rotation: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:{...Lt.fromHex(0),a:1},colorB:{...Lt.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(Et||(Et={}));var Qt;(c=>{function n(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}c.isMergable=n;function r(u){let p="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([h,f])=>{p+=`${h}${f}`,Array.isArray(f)?f.forEach(m=>p+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?p+=`${m.toFixed(4)}`:p+=`${m}`}):p+=`${f}`})}),p}c.getHash=r;function e(){return{layers:new Se}}c.defaultEmptyData=e;function t(u="layer1",p="layer2"){return i("phong",u,p)}c.defaultData=t;function o(u,p){return{...u,name:p}}c.withName=o;function i(u,p="layer1",d="layer2"){let h=new Se;return h.push({fi:0,data:Et.defaultData("light",u),id:p}),h.push({fi:1,data:Et.defaultData("color"),id:d}),{layers:h}}c.defaultTwoLayerData=i;function a(u){let p=Et.defaultData("texture");u&&Object.assign(p.texture,{image:u});let d=new Se;return d.push({fi:0,data:p,id:"layer1"}),d.push({fi:1,data:{...Et.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...Et.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}c.defaultUIObjectMaterial=a;function s(u,p="phong",d="layer1",h="layer2"){let f=Et.defaultData("texture");Object.assign(f.texture,{image:u});let m=new Se;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Et.defaultData("light",p),id:h}),{layers:m}}c.defaultTwoLayerTextureData=s;function l(u,p="phong",d="layer1",h="layer2"){let f=Et.defaultData("video");Object.assign(f.texture,{video:u});let m=new Se;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Et.defaultData("light",p),id:h}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})(Qt||(Qt={}));var pa;(r=>{function n(){return{points:new Se,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n})(pa||(pa={}));var fa;(r=>{function n(){return{points:new Se,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}r.defaultData=n})(fa||(fa={}));var gp={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Kc;(r=>{function n(e,t){let o={...e};return gT.forEach(i=>{Object.assign(o,{[i]:t[i]??e[i]})}),o}r.merge=n})(Kc||(Kc={}));var Qc={shape:gp,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},gT=["depth","offset","angle","twist","startScale","endScale"];var Zs;(e=>{function n(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"||t==="UIGeometry"}e.is2DParametricMesh=n;function r(t){return t==="PolygonGeometry"||t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"||t==="PathGeometry"||t==="VectorGeometry"||t==="ConeGeometry"||t==="CubeGeometry"||t==="CylinderGeometry"||t==="DodecahedronGeometry"||t==="HelixGeometry"||t==="IcosahedronGeometry"||t==="LatheGeometry"||t==="PyramidGeometry"||t==="SphereGeometry"||t==="PlaneGeometry"||t==="BackdropGeometry"||t==="TorusGeometry"||t==="TorusKnotGeometry"||t==="BooleanGeometry"||t==="TextGeometry"}e.isParametricMesh=r})(Zs||(Zs={}));var Zc;(r=>{function n(e,t){let o={...e};return Object.assign(o,t),o.type==="PathGeometry"&&"extrusion"in t&&t.extrusion&&(o.extrusion={...e.extrusion},Object.assign(o.extrusion,Kc.merge(o.extrusion,t.extrusion))),o}r.merge=n})(Zc||(Zc={}));var Cn;(r=>{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:fa.defaultData(),extrusion:Qc};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:pa.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")}r.defaultData=n})(Cn||(Cn={}));var Jc;(r=>r.defaultData={enabled:!1,useBackgroundColor:!1,color:Lt.white,near:.1,far:2e3})(Jc||(Jc={}));var eu;(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}}})(eu||(eu={}));var xp;(r=>r.defaultData={softShadowQuality:"low"})(xp||(xp={}));var bp;(r=>r.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(bp||(bp={}));var vp;(r=>r.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(vp||(vp={}));var Js;(r=>r.defaultData={usePhysics:!1,gravity:-10})(Js||(Js={}));var Sp;(r=>r.defaultData={playCamera:Sn,gameControlObject:null})(Sp||(Sp={}));var tu;(r=>r.defaultData={backgroundColor:_e.fromHexAndA(Ng,1),postprocessing:eu.defaultData,fog:Jc.defaultData,globalPhysics:Js.defaultData,ambient:bp.defaultData,ao:vp.defaultData,shadow:xp.defaultData,publish:Sp.defaultData})(tu||(tu={}));var ru;(r=>r.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(ru||(ru={}));var Vg;(e=>{function n(t){return t==="Component"||t==="Instance"}e.isComponentRelated=n;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(Vg||(Vg={}));var ha;(o=>{o.identity={...Wc.identity,hiddenMatrix:vn.identity};function r(i){return{position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix}}o.fromObject=r;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 t(i,a){return tc({position:bn.isEqual(i.position,a.position)?void 0:a.position,rotation:bn.isEqual(i.rotation,a.rotation)?void 0:a.rotation,scale:bn.isEqual(i.scale,a.scale)?null:a.scale,hiddenMatrix:vn.isEqual(i.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=t})(ha||(ha={}));var Rt;(r=>r.defaultData={states:new Se,events:new Se,visible:!0,raycastLock:!1,physics:On.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...ha.identity,cloner:null})(Rt||(Rt={}));var ou;(r=>r.defaultData={type:"Empty",...Rt.defaultData})(ou||(ou={}));var zg;(r=>r.defaultData={type:"ParticleCollider",...ru.defaultData,...Rt.defaultData})(zg||(zg={}));var Gg;(r=>r.defaultData={type:"Component",...Rt.defaultData})(Gg||(Gg={}));var jg;(r=>r.defaultData={type:"Particle",...Rt.defaultData,...ua.defaultData})(jg||(jg={}));var ii;(r=>r.defaultData={type:"Mesh",...Rt.defaultData,...Xc.defaultData})(ii||(ii={}));var ai;(r=>r.defaultData={...Rt.defaultData,...ha.identity,position:[0,0,Pn.DefaultTargetOffset],...Pn.defaultData})(ai||(ai={}));var nu;(e=>{function n(t){return{...Rt.defaultData,...Yc.defaultData(t)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(nu||(nu={}));var ma;(e=>{function n(t,o,i=0){for(;i<o.length;){let a=t?t[o[i]]:void 0;if(o.length===i+1)return a;if(a)t=a.descendants,i+=1;else return}}e.resolveWithDes=n;function r(t,o,i=0){let a=n(t,o,i);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=r})(ma||(ma={}));var So;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function t(a,s){return{...Rt.defaultData,...s,component:a,overrides:new st,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=t;function o(a){let s=ha.fromObject(a.data);return t(a.id,s)}i.fromComponentData=o})(So||(So={}));var ko;(e=>{e.defaultData={type:"Page",...Rt.defaultData,physics:{...On.defaultData,fusedBody:!1},...tu.defaultData,camera:ai.defaultData};function r(t){return t.uiScene!==void 0}e.isUIPage=r})(ko||(ko={}));var iu;(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:On.defaultData,states:new Se,events:new Se,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Pn.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",...Rt.defaultData,...ii.defaultData,geometry:Cn.defaultData("RectangleGeometry"),material:Qt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...Rt.defaultData,...ii.defaultData,geometry:Cn.defaultData("BooleanGeometry"),material:Qt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...Rt.defaultData,...ii.defaultData,geometry:Cn.defaultData("TextGeometry"),material:Qt.defaultTwoLayerData("phong","layer1","layer2")}))(iu||(iu={}));var si;(o=>{function n(i,a){let s={name:a};return i.type==="Mesh"?(s.geometry={},"material"in i&&(s.material={layers:new st}),"materials"in i&&(s.materials=i.materials.map(l=>({layers:new st})))):Qr.is(i.type)&&(s.perspective={},s.orthographic={}),s}o.newEmpty=n;function r(i,a){if(a===void 0)return i;let s={...i};return"material"in s&&"material"in a&&a.material&&(s.material=mn(s.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(a.material.layers)){let p=l.layers.data(c);p&&Et.patch(p,u)}}).data),s.materials&&a.materials&&(s.materials=mn(s.materials,l=>{for(let c=0;c<s.materials.length;c++){let u=a.materials[c];if(typeof u!="string")for(let[p,d]of Object.entries(u.layers)){let h=l[c]?.layers?.data(p);h&&Et.patch(h,d)}}}).data),s}function e(i,a){let s,l=[],c={orthographic:0,perspective:0,geometry:0};function u(p,d){for(let[h,f]of Object.entries(d.layers)){let{texture:m,...y}=f;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...p,"layers",h,"texture"],props:m,type:0};l.push(g)}if(Object.keys(y).length>0){let g={path:[...p,"layers",h],props:y,type:0};l.push(g)}}}for(let[p,d]of Object.entries(a))if(p!=="name")if(p==="cloner")l.push(...qc.toOps(d,["cloner"]));else if(p==="pathSnapping")l.push({path:[p],props:{slide:d.slide,offset:d.offset},type:0});else if(p==="material")u(["material"],d);else if(p==="materials")for(let[h,f]of Object.entries(d))u(["materials",h],f);else if(c[p]===0){if(p==="geometry"&&d.extrusion!==void 0){let h={path:[p,"extrusion"],props:d.extrusion,type:0};l.push(h),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let h={path:[p],props:d,type:0};l.push(h)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[p]=d;return l}o.toOps=e;function t(i,a){if(a===void 0)return i;let s={...i};if(Object.assign(s,ha.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})}),Qr.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:Zc.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=r(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:vo.merge(s.cloner,a.cloner)});else if(i.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:vo.merge(s.cloner,a.cloner)});else if($c.is(i.type)){let l=a;l.intensity!==void 0&&(s.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?s.color=l.color:s.color=Lt.clone(l.color))}return s}o.patch=t})(si||(si={}));var ya;(r=>r.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})(ya||(ya={}));var Zr;(r=>r.defaultData={orbitControls:ya.defaultData,playPage:wn,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,t)=>{let o=0,i=0;return t<5?i=-30:t<10&&(i=30),t===0||t===10||t===5?o=30:(t===4||t===11||t===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})(Zr||(Zr={}));var wp;(r=>r.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(wp||(wp={}));var Pp;(r=>r.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Pp||(Pp={}));var Ho;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...wp.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Pp.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Ho||(Ho={}));var Fg;(e=>{function n(t){return t.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=n;function r(t,o,i){t.scene.objects.traverseFrom(o,(a,s)=>{if(s.type==="Instance"){let l=ga.getComponentData(t,s.component)?.data;l&&i(a,s,l.events)}else i(a,s,s.events)})}e.traverseModuleInstances=r})(Fg||(Fg={}));var Wo;(l=>{l.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function r(c={withLight:!0,withSquare:!0}){let u=[],p=iu.defaultMeshObject;c.withLight===!0&&u.push({fi:-1,data:nu.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),c.withSquare===!0&&u.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:p,children:[]});let d=new at;return d.push({fi:1,id:wn,data:{...ko.defaultData,name:"Scene 1"},children:u}),d}l.defaultData={objects:r(),publish:Zr.defaultData,styles:Ho.defaultData()},l.emptyDataWithoutPage=function(){return{objects:new at,publish:Zr.defaultData,styles:Ho.defaultData()}},l.emptyDataWithPage=function(c){return{objects:r(c),publish:Zr.defaultData,styles:Ho.defaultData()}},l.emptyData=function(){return{objects:new at,publish:{...Zr.defaultData},styles:Ho.defaultData()}};function a(c){return{...l.defaultData,objects:sr(c,at.prototype)}}l.withObjs=a;function s(c,u){return a([{id:c,data:u,children:[],fi:0}])}l.withObj=s})(Wo||(Wo={}));var xa;(r=>r.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(xa||(xa={}));var ba;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(ba||(ba={}));var au;(i=>{function n(a){return a.textValue!==void 0}i.isTextValue=n;function r(a){return typeof a=="number"}i.isNumber=r;function e(a){return typeof a=="boolean"}i.isBoolean=e;function t(a){return n(a)?"string":e(a)?"boolean":"number"}i.typeOfVariable=t;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})(au||(au={}));var Op;(r=>r.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(Op||(Op={}));var Ug;(r=>r.all=[...Op.all,"components"])(Ug||(Ug={}));var kg;(r=>{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}}r.defaultData=n})(kg||(kg={}));var qo;(r=>{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}}r.defaultData=n})(qo||(qo={}));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"},sr(a,be.prototype)}i.defaultColors=n;function r(a){let s={};return a?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...ba.emptyImage,name:"AI generated image"}),sr(s,be.prototype)}i.defaultImages=r;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 Se,lib:qo.defaultData()}}i.emptyData=e;function t(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=t;function o(a,s){if(s.format==="HH:mm:ss"){let l=Math.floor(a/3600),c=Math.floor((a-l*3600)/60),u=Math.round(a-l*3600-c*60);return{textValue:[l,c,u]}}else if(s.format==="mm:ss"){let l=Math.floor(a/60),c=Math.round(a-l*60);return{textValue:[l,c]}}else return s.format==="number"?a=Math.round(a):a=Math.round(a*1e3)/1e3,a}i.getFormattedTimerTime=o})(zr||(zr={}));var el=require("three");var su;(r=>r.list=["idle","move","jump","run"])(su||(su={}));var lu;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new Se,move:new Se,jump:new Se,run:new Se},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:_e.fromHexAndA(3728051,1)}}))(lu||(lu={}));function Hg(n){n.layers.forEach(r=>{if(r.type==="depth"&&r.colorA!==void 0){let e=r.colorA,t=r.colorB,o=[[e.r,e.g,e.b,e.a],[t.r,t.g,t.b,t.a]],i=[0,1];for(let s=2;s<10;s++)o.push(o[1]),i.push(1);let a={...Kr(wt(r),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,r.near),far:Math.max(0,r.far),colors:o,steps:i,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(r,a)}else if(r.type==="depth"&&r.gradientType===1&&(r.near<0||r.far<0)){let e={...wt(r),near:Math.max(r.near,0),far:Math.max(r.far,0)};Object.assign(r,e)}})}function $o(n,r){Object.values(n.shared.materials).forEach(e=>r(e))}function Yo(n,r){n.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach((o,i)=>{o===void 0&&(t.materials[i]=Qt.defaultData(),o=t.materials[i]),typeof o!="string"&&r(o)}):"material"in t?typeof t.material!="string"&&(t.material===void 0&&(t.material=Qt.defaultData()),r(t.material)):t.type==="Mesh"&&(t.material===void 0&&(t.material=Qt.defaultData()),r(t.material)),"overrides"in t&&Object.values(t.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&Object.getPrototypeOf(o.material)!==st.prototype&&r(o.material)})})}function xT(n){Object.assign(n.scene.publish,{orbitControls:{...ya.defaultData,...wt(n.scene.publish.orbitControls)}})}function bT(n){Object.assign(n.scene.publish.settings,{video:{...Zr.defaultData.settings.video,...wt(n.scene.publish.settings.video)}})}function vT(n){function r(e){if(e.layers){for(let t of Object.values(e.layers))if(t){for(let[o,i]of Object.entries(t))if((Lg.includes(o)||typeof i=="boolean")&&delete t[o],o==="texture")for(let[a,s]of Object.entries(i))(Rg.includes(a)||typeof s=="boolean")&&delete i[a]}}}n.scene.objects.traverse((e,t)=>{t.states.forEach(o=>{let i=o;i.material?r(i.material):i.materials&&i.materials.forEach(a=>{r(a)})})})}function ST(n){n.scene.publish.withBackground=!0}function wT(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function PT(n){n.scene.objects.traverse((r,e)=>{let t=e.cloner;t&&(t.radial.scale=t.radial.scale.map(o=>o+1),t.linear.scale=t.linear.scale.map(o=>o+1))})}function OT(n){n.scene.objects.traverse((r,e)=>{let t=e.geometry;t&&(t.type==="DodecahedronGeometry"||t.type==="IcosahedronGeometry")&&(t.detail=Math.round(t.detail))})}function CT(n){n.scene.objects.traverse((r,e)=>{let t=n.scene.objects.unproxy().parent(r);if(t){let o=wt(n.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=wt(e).booleanExclude!==!0)}})}function TT(n){n.scene.objects.traverse((r,e)=>{if(e.type==="Mesh"){let t=e;e.geometry.type==="NonParametricGeometry"?t.material!==void 0&&delete t.material:t.materials!==void 0&&delete t.materials}})}function AT(n){function r(t){Object.setPrototypeOf(t,st.prototype),t.texture&&Object.setPrototypeOf(t.texture,st.prototype)}function e(t){Object.setPrototypeOf(t,st.prototype);for(let o in t)r(t[o])}n.scene.objects.traverse((t,o)=>{o.states.forEach(i=>{let a=i;if(a.material){let s=wt(a.material).layers;e(s),a.material.layers=s}if(a.materials)for(let s=0;s<a.materials.length;s++){let l=a.materials[s],c=wt(l).layers;e(c),l.layers=c}})})}function Wg(n){n.layers===void 0&&Object.assign(n,Qt.defaultTwoLayerData("lambert"))}function Cp(n){!n.layers||n.layers.forEach(r=>{if(r.type==="depth"&&r.colors.length===10){let e=[...r.colors];e.push(r.colors[9]);let t=[...r.steps];t.push(r.steps[9]);let o={...wt(r),colors:e,steps:t};Object.assign(r,o)}})}function MT(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function qg(n){n.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&Cp(t)}):"material"in e&&typeof e.material!="string"&&Cp(e.material)}),Object.values(n.shared.materials).forEach(r=>Cp(r))}function IT(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((r,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 NT(n){n.shared.audios=sr({},be.prototype)}function DT(n){n.shared.videos=sr({},be.prototype)}function ET(n){let r=n.shared.materials;Object.entries(r).forEach(([e,t])=>{if(!t.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(r,{[e]:o})}})}function _T(n){Object.entries(wt(n.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.images[t]}),Object.entries(wt(n.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.audios[t]})}function BT(n){n.scene.publish.settings.web.preload=!1}function $g(n){n.layers&&n.layers.forEach(r=>{r.type==="depth"&&r.num!==void 0&&(r.colors=r.colors.slice(0,r.num),r.steps=r.steps.slice(0,r.num),delete r.num)})}function Yg(n){n.layers&&n.layers.forEach(r=>{Bg(r)&&r.isMask===void 0&&(r.isMask=!1),(r.type==="texture"||r.type==="video")&&r.blending===void 0&&(r.blending=0),(r.type==="noise"||r.type==="displace"&&r.displacementType==="noise")&&(r.voronoiStyle===void 0&&(r.voronoiStyle=0),r.highCut===void 0&&(r.highCut=1),r.lowCut===void 0&&(r.lowCut=0),r.smoothness===void 0&&(r.smoothness=.3),r.seed===void 0&&(r.seed=0),r.quality===void 0&&(r.quality=1))})}function LT(n){n.shared.fonts=sr({},be.prototype)}function RT(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 VT(n){let r=[];n.scene.objects.traverse((e,t)=>{let o=t;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=RT(o.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let l={name:o.name,...Rt.defaultData,...ii.defaultData,flatShading:!1,wireframe:!1,geometry:{...Cn.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:wt(o.states),events:wt(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},c=wt(n.scene.objects).parent(e);n.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),r.push(e)}}),r.forEach(e=>{n.scene.objects.delete(e)})}function zT(n){let r={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,t)=>{t.events.forEach(o=>{if(!!r[Number(o.type)])if(Object.assign(o,{type:r[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 Se,move:new Se,jump:new Se}});else{let i=new Se;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:el.MathUtils.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((a,s,l)=>{let c={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(u,Kr(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(u,{control1:{...a.control1},control2:{...a.control2}});let p={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},d={state:a.state,...p,...u},h={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Se({fi:0,id:el.MathUtils.generateUUID(),data:c},{fi:1,id:el.MathUtils.generateUUID(),data:d})};i.push({fi:l,id:s,data:h})}),delete o.targets)}})})}function GT(n){n.scene.objects.traverse((r,e)=>{function t(o,i){let a=new Se,s=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===i){let p;s.push(c),l.interaction==="play"?p={...Kr(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")&&(p={...Kr(l,"interaction","delay","object","playAudio"),type:"Audio"}),p&&a.push({fi:u,id:c,data:p})}}),s.forEach(l=>e.events.delete(l)),a.length){let l=e.events.find(c=>c.type===o)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):e.events.insertBefore(null,[{id:el.MathUtils.generateUUID(),data:{type:o,actions:a}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function Xg(n){let r=n.layers.find(e=>e.type==="light")?.data;if(r?.category==="basic"){let e=Et.defaultData("light","phong"),t=r;Object.assign(t,e),t.visible=!1}}function Kg(n){$o(n,Xg),Yo(n,Xg)}function jT(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function FT(n){n.scene.objects.traverse((r,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 UT(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Qt.defaultTwoLayerData("phong"))})}function kT(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((r,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 HT(n){n.scene.objects.traverse((r,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 WT(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 qT(n){let{video:r}=n.scene.publish.settings;r.format==="gif"&&r.fps>48&&(r.fps=15)}function $T(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.resetYPosition=Math.abs(t.resetYPosition-e.position[1]))})})}function YT(n){let r=n.scene.environment.usePhysics;n.scene.objects.traverse((e,t)=>{r&&t.physics===null?t.collision=!1:t.collision="visibility"})}function XT(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.navmesh=lu.defaultDataThirdPerson.navmesh)})})}function KT(n){n.scene.styles||(n.scene.styles=Ho.defaultData())}function Qg(n){n.layers.forEach(r=>{r.type==="light"&&r.category!=="toon"&&r.occlusion===void 0&&(r.occlusion=!0)})}function QT(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}),Yo(n,Qg),$o(n,Qg)}function ZT(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&Object.assign(t.gameActions,{run:new Se})})})}function JT(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.keyAssignments=[...t.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function Zg(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.bumpMapIntensity===void 0&&(r.bumpMapIntensity=5)})}function Jg(n,r){if(r<1&&(Yo(n,Hg),$o(n,Hg),n.schema=1),r<2&&(xT(n),n.schema=2),r<3&&(vT(n),n.schema=3),r<4&&(ST(n),n.schema=4),r<5&&(wT(n),n.schema=5),r<6&&(PT(n),n.schema=6),r<7&&(OT(n),n.schema=7),r<8&&(n.schema=8),r<9&&(qg(n),n.schema=9),r<10&&(MT(n),n.schema=10),r<11&&(IT(n),n.schema=11),r<12&&(qg(n),n.schema=12),r<13&&(NT(n),n.schema=13),r<14&&(ET(n),n.schema=14),r<15&&(_T(n),n.schema=15),r<16&&(BT(n),n.schema=16),r<17&&(Yo(n,$g),$o(n,$g),n.schema=17),r<18&&(Yo(n,Wg),$o(n,Wg),n.schema=18),r<19&&(bT(n),n.schema=19),r<20&&(LT(n),VT(n),n.schema=20),r<21&&(zT(n),GT(n),n.schema=21),r<22&&(Kg(n),n.schema=22),r<23&&(jT(n),n.schema=23),r<24&&(FT(n),n.schema=24),(r<25||n.shared.videos===void 0)&&(DT(n),r<25&&(n.schema=25)),r<26&&(CT(n),n.schema=26),r<27&&(TT(n),n.schema=27),r<28&&(Kg(n),n.schema=28),r<29&&(AT(n),n.schema=29),r<30&&(UT(n),n.schema=30),r<31&&(kT(n),n.schema=31),r<33&&(HT(n),n.schema=33),r<34&&(WT(n),n.schema=34),r<35&&(qT(n),n.schema=35),r<36&&($T(n),n.schema=36),r<37&&(YT(n),n.schema=37),r<38&&(Yo(n,Yg),$o(n,Yg),n.schema=38),r<39&&(XT(n),n.schema=39),r<40&&(KT(n),n.schema=40),r<41&&(QT(n),n.schema=41),r<42&&(ZT(n),n.schema=42),r<43&&(JT(n),n.schema=43),r<99){Yo(n,Zg),$o(n,Zg),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=Sn);let e=wt(n.scene.objects),t=n.scene.objects;n.scene.publish.playPage=wn,t.insertBefore(null,null,[{id:wn,data:{...ko.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:Kr(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:Kr(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Js.defaultData,...Kr(n.scene.environment,"usePhysics","gravity")},camera:wt(n.scene.ownerCamera)??ko.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==Wo.TRASH_CAN_ID&&t.move(wn,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,On.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),n.schema=99}}function e0(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.alphaOverride===void 0&&(r.alphaOverride=1)})}function eA(n){n.scene.objects.traverse((r,e)=>{let t=e.geometry;t&&t.type==="PathGeometry"&&(t.extrusion.capType="flat",t.extrusion.bevel=50,t.extrusion.bevelSides=6,t.extrusion.shape.type==="Custom"&&(t.extrusion.shape.shapeQuality="low"))})}function tA(n){Array.isArray(wt(n.events))&&n.events?.forEach(r=>{"disabled"in r||(r.disabled=!1),(r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress")&&(r.mode=r.mode||"Object")})}var va=180/Math.PI;function t0(n){n.rotation=n.rotation.slice(0,3).map(r=>r*va)}function r0(n){t0(n),n.type==="Page"&&t0(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(t=>t*va))});let r=n.geometry;r&&r.type==="SphereGeometry"&&(r.thetaLength=(r.thetaLength??180)*va),r&&r.type==="TorusGeometry"&&(r.arc=r.arc*va),r&&r.type==="PathGeometry"&&(r.extrusion.angle*=va,r.extrusion.twist*=va),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(wt(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 rA(n){n.shared.variables=sr({},be.prototype)}function oA(n){let r=wt(n.shared.variables);n.shared.variables=sr(Object.entries(r??{}).map(([e,t],o)=>({fi:o,id:e,data:t})),Se.prototype)}var wo=111;function o0(n,r){r(n.data);for(let e of n.children)o0(e,r)}function nA(n){let r=n.schema??104;r!==wo&&r<105&&(o0(n.asset,r0),n.schema=105)}function iA(n){n.shared.particles=sr({},be.prototype),n.shared.lib&&(n.shared.lib.particles=qo.defaultData().particles)}function aA(n){n.scene.objects.traverse((r,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function cu(n){let r=n.schema??0;if(r!==wo){console.warn("updating from ",r,"to ",wo),Jg(n,r),r<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Zr.defaultData.joystickSizeAndXYOffset),n.schema=100),r<101&&(Yo(n,e0),$o(n,e0),n.schema=101),r<102&&(eA(n),n.schema=102),r<104&&(n.shared.catelogs=new be,n.shared.lib=qo.defaultData(),n.schema=104),r<105&&(rA(n),n.scene.objects.traverse((e,t)=>{r0(t)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))nA(e);r<106&&(oA(n),n.schema=106),r<107&&(n.shared.lib.variables=qo.defaultData().variables,n.schema=107),r<109&&(iA(n),n.schema=109),r<110&&(aA(n),n.schema=110),r<111&&(n.scene.objects.traverse((e,t)=>{tA(t)}),n.schema=111)}}var ga;(l=>{l.defaultData={schema:wo,scene:Wo.defaultData,frames:new be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",xa.defaultData),shared:{...zr.emptyData(),colors:zr.defaultColors()}},l.emptyDataForImports=function(c){let u=Wo.emptyDataWithPage(c);return{schema:wo,scene:u,frames:new be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",xa.defaultData),shared:{...zr.emptyData(),colors:zr.defaultColors(),images:zr.defaultImages(c)}}},l.emptyData=function(){return{schema:wo,scene:Wo.emptyDataWithPage(),frames:new be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",xa.defaultData),shared:zr.emptyData()}},l.clipboard2dData=function(){return{schema:wo,scene:Wo.emptyData(),frames:new be,shared:zr.emptyData()}},l.collabHelper={...$s,updateSchema(c){return(c.schema??0)<wo?mn(c,cu):(c.schema??0)-wo}};function i(c){let u=l.collabHelper.updateSchema(c);return typeof u=="number"?u===0?c:null:u.data}l.updateSchemaDirectly=i;function a(c){return{...c,shared:{...c.shared,lib:qo.defaultData()}}}l.withoutLib=a;function s(c,u){let p=c.scene.objects.get(u);if(p&&p.data.type==="Component")return p;{let d=c.shared.lib.components[u];if(d)return d.asset}}l.getComponentData=s})(ga||(ga={}));var n0;(r=>{function n(e){return!0}r.is=n})(n0||(n0={}));var uu;(t=>{t.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function r(o,i){return{position:i?.position??o.position,rotation:i?.rotation??o.rotation,scale:i?.scale??o.scale,shear:i?.shear??o.shear}}t.merge=r;function e(o,i){return tc({position:ca.isEqual(o.position,i.position)?void 0:i.position,rotation:o.rotation===i.rotation?void 0:i.rotation,scale:ca.isEqual(o.scale,i.scale)?void 0:i.scale,shear:o.shear&&i.shear&&ca.isEqual(o.shear,i.shear)?void 0:i.shear})}t.diff=e})(uu||(uu={}));var Tp;(r=>r.defaultData={horizontalConstraint:0,verticalConstraint:0})(Tp||(Tp={}));var du;(r=>r.defaultData={opacity:1,fill:{color:_e.fromHexAndA(Mt,1),enabled:!0},stroke:{color:_e.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:_e.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:_e.from0to1([0,0,0,1]),enabled:!1,spread:0}})(du||(du={}));var li;(i=>{function n(a,s){return{name:s}}i.newEmpty=n;function r(a,s){if(s===void 0)return a;let l={...a},c=["width","height","cornerRadius"];for(let u of c)u in l&&u in s&&s[u]!==void 0&&Object.assign(l,{[u]:s[u]});return l}function e(a,s){if(s===void 0)return a;let l={...a};return"fill"in l&&"fill"in s&&s.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...s.fill}}),"stroke"in l&&"stroke"in s&&s.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...s.stroke}}),"layerBlur"in l&&"layerBlur"in s&&s.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...s.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in s&&s.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...s.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in s&&s.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...s.dropShadow}}),"innerShadow"in l&&"innerShadow"in s&&s.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...s.innerShadow}}),l}function t(a,s){if(s===void 0)return a;let l={...a};return Object.assign(l,uu.merge(l,s)),l=r(l,s),l=e(l,s),l}i.patch=t;function o(a,s){let l,c=[];for(let[u,p]of Object.entries(s))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[u]=p);return c}i.toOps=o})(li||(li={}));var tl;(r=>r.defaultData={...uu.defaultData,...Tp.defaultData,states:new Se,events:new Se,visible:!0,raycastLock:!1})(tl||(tl={}));var Sa;(r=>r.defaultData={...tl.defaultData,...du.defaultData})(Sa||(Sa={}));var pu;(r=>r.defaultData={cornerRadius:[0,0,0,0]})(pu||(pu={}));var Ap;(r=>r.defaultData={...Sa.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(Ap||(Ap={}));var wa;(r=>r.defaultData={...Sa.defaultData,...pu.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(wa||(wa={}));var Mp;(r=>r.defaultData={...Sa.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 Ip;(r=>r.defaultData={...Sa.defaultData,type:"path2d",path:"",name:"Path"})(Ip||(Ip={}));var i0;(r=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}r.is=n})(i0||(i0={}));var rl;(r=>r.defaultData={...tl.defaultData,name:"Group",type:"group2d"})(rl||(rl={}));var Np;(r=>r.defaultData={...tl.defaultData,...pu.defaultData,...du.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:_e.fromHexAndA(4737101,1),enabled:!0},stroke:{color:_e.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}})(Np||(Np={}));var Xo;(o=>{function n(i){switch(i){case"rectangle2d":return{...wa.defaultData};case"ellipse2d":return{...Ap.defaultData};case"text2d":return{...Mp.defaultData};case"vector2d":return{...wa.defaultData};case"path2d":return{...Ip.defaultData};case"frame2d":return{...Np.defaultData};case"group2d":return{...rl.defaultData}}}o.defaultData=n;function r(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=r;function e(i){return i.type==="rectangle2d"||i.type==="ellipse2d"||i.type==="text2d"||i.type==="frame2d"}o.isResizeable=e;function t(i){return i.type==="rectangle2d"||i.type==="frame2d"}o.hasCorners=t})(Xo||(Xo={}));var fu;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new at},e.emptyData=function(){return{type:"scene2d",objects:new at}}))(fu||(fu={}));var Ze=require("three"),Ss=Ei(s0());var sA=.5*(Math.sqrt(3)-1),ol=(3-Math.sqrt(3))/6,lA=1/3,Po=1/6,YF=(Math.sqrt(5)-1)/4,XF=(5-Math.sqrt(5))/20,nl=n=>Math.floor(n)|0,l0=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]),Ep=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 hu(n=Math.random){let r=u0(n),e=new Float64Array(r).map(o=>l0[o%12*2]),t=new Float64Array(r).map(o=>l0[o%12*2+1]);return function(i,a){let s=0,l=0,c=0,u=(i+a)*sA,p=nl(i+u),d=nl(a+u),h=(p+d)*ol,f=p-h,m=d-h,y=i-f,g=a-m,v,O;y>g?(v=1,O=0):(v=0,O=1);let P=y-v+ol,S=g-O+ol,T=y-1+2*ol,I=g-1+2*ol,x=p&255,_=d&255,D=.5-y*y-g*g;if(D>=0){let E=x+r[_],B=e[E],V=t[E];D*=D,s=D*D*(B*y+V*g)}let A=.5-P*P-S*S;if(A>=0){let E=x+v+r[_+O],B=e[E],V=t[E];A*=A,l=A*A*(B*P+V*S)}let N=.5-T*T-I*I;if(N>=0){let E=x+1+r[_+1],B=e[E],V=t[E];N*=N,c=N*N*(B*T+V*I)}return 70*(s+l+c)}}function c0(n=Math.random){let r=u0(n),e=new Float64Array(r).map(i=>Ep[i%12*3]),t=new Float64Array(r).map(i=>Ep[i%12*3+1]),o=new Float64Array(r).map(i=>Ep[i%12*3+2]);return function(a,s,l){let c,u,p,d,h=(a+s+l)*lA,f=nl(a+h),m=nl(s+h),y=nl(l+h),g=(f+m+y)*Po,v=f-g,O=m-g,P=y-g,S=a-v,T=s-O,I=l-P,x,_,D,A,N,E;S>=T?T>=I?(x=1,_=0,D=0,A=1,N=1,E=0):S>=I?(x=1,_=0,D=0,A=1,N=0,E=1):(x=0,_=0,D=1,A=1,N=0,E=1):T<I?(x=0,_=0,D=1,A=0,N=1,E=1):S<I?(x=0,_=1,D=0,A=0,N=1,E=1):(x=0,_=1,D=0,A=1,N=1,E=0);let B=S-x+Po,V=T-_+Po,j=I-D+Po,R=S-A+2*Po,W=T-N+2*Po,F=I-E+2*Po,k=S-1+3*Po,H=T-1+3*Po,$=I-1+3*Po,J=f&255,Z=m&255,X=y&255,te=.6-S*S-T*T-I*I;if(te<0)c=0;else{let q=J+r[Z+r[X]];te*=te,c=te*te*(e[q]*S+t[q]*T+o[q]*I)}let Y=.6-B*B-V*V-j*j;if(Y<0)u=0;else{let q=J+x+r[Z+_+r[X+D]];Y*=Y,u=Y*Y*(e[q]*B+t[q]*V+o[q]*j)}let ee=.6-R*R-W*W-F*F;if(ee<0)p=0;else{let q=J+A+r[Z+N+r[X+E]];ee*=ee,p=ee*ee*(e[q]*R+t[q]*W+o[q]*F)}let K=.6-k*k-H*H-$*$;if(K<0)d=0;else{let q=J+1+r[Z+1+r[X+1]];K*=K,d=K*K*(e[q]*k+t[q]*H+o[q]*$)}return 32*(c+u+p+d)}}function u0(n){let e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){let o=t+~~(n()*(256-t)),i=e[t];e[t]=e[o],e[o]=i}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var d0=require("three"),Jr=new d0.Triangle,mu=class{constructor(r){this.weightAttribute=null;let e=r.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 r=this.positionAttribute,e=new Float32Array(r.count/3);for(let o=0;o<r.count;o+=3){let i=1;Jr.a.fromBufferAttribute(r,o),Jr.b.fromBufferAttribute(r,o+1),Jr.c.fromBufferAttribute(r,o+2),i*=Jr.getArea(),e[o/3]=i}this.distribution=new Float32Array(r.count/3);let t=0;for(let o=0;o<e.length;o++)t+=e[o],this.distribution[o]=t;return this}setRandomGenerator(r){return this.randomFunction=r,this}sample(r,e){if(this.distribution){let t=this.distribution[this.distribution.length-1],o=this.binarySearch(this.randomFunction()*t);return this.sampleFace(o,r,e)}}binarySearch(r){if(!this.distribution)return 0;let e=this.distribution,t=0,o=e.length-1,i=-1;for(;t<=o;){let a=Math.ceil((t+o)/2);if(a===0||e[a-1]<=r&&e[a]>r){i=a;break}else r<e[a]?o=a-1:t=a+1}return i}sampleFace(r,e,t){let o=this.randomFunction(),i=this.randomFunction();return o+i>1&&(o=1-o,i=1-i),Jr.a.fromBufferAttribute(this.positionAttribute,r*3),Jr.b.fromBufferAttribute(this.positionAttribute,r*3+1),Jr.c.fromBufferAttribute(this.positionAttribute,r*3+2),e.set(0,0,0).addScaledVector(Jr.a,o).addScaledVector(Jr.b,i).addScaledVector(Jr.c,1-(o+i)),Jr.getNormal(t),this}};var m0=require("three");var Ir=require("three"),h0=Ei(f0()),cA=new Ir.Matrix4,uA=new Ir.Matrix4,dA=new Ir.Matrix4,Pa;(r=>{function n(e){return e&&e.__isSPEObject}r.is=n})(Pa||(Pa={}));var Oa=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(t){t instanceof Ir.Object3D&&(t=t.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===t)return!0;o=o.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let o of this.children)o.updateMatrixWorld(t)}updateWorldMatrix(t,o){let i=this.parent;if(t&&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(t,o=0){for(let i of this.children)Pa.is(i)&&i.traverseObject(t,o+1)}traverseObject(t,o=0){if(t(this,o)!==!0)for(let a of this.children)Pa.is(a)&&a.traverseObject(t,o+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,o=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:i,v:a,q:s}=(0,h0.SVD)(o),l=cA.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),c=uA.set(a[0][0],a[0][1],a[0][2],0,a[1][0],a[1][1],a[1][2],0,a[2][0],a[2][1],a[2][2],0,0,0,0,1),u=dA.copy(c).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(u).premultiply(c),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,u).copyPosition(this.matrixWorld),s.every(p=>Math.abs(s[0]-p)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,o){this.updateWorldMatrix(!0,!1);let i=new Ir.Matrix4().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof Ir.Matrix4?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),o!==void 0&&(this.children.pop(),this.children.splice(o,0,t)),this}copy(t,o=!1){return super.copy(t,o),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,o,i,a,s,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var _p=class extends Oa(m0.Object3D){},pA=n=>n.type==="Mesh",Ko=class extends _p{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let o=this.children[e];o?.object!==t&&(o&&this.remove(o),o=new Ko(t),this.add(o),this.children.splice(e,0,this.children.pop()),o.matrixWorldNeedsUpdate=!0,o.matrixAutoUpdate=!1,o.matrix=t.matrix,o.hiddenMatrix=t.hiddenMatrix),o.expand(),e+=1,t=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 pA(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 Lu=require("three");var or=require("three");var Ot=require("three"),ci=new Ot.Vector3,ui=new Ot.Vector3,Ca=new Ot.Matrix4,g0=[new Ot.Vector3(-1,1,1),new Ot.Vector3(-1,-1,1),new Ot.Vector3(1,-1,1),new Ot.Vector3(1,1,1),new Ot.Vector3(-1,1,-1),new Ot.Vector3(-1,-1,-1),new Ot.Vector3(1,-1,-1),new Ot.Vector3(1,1,-1)],fA=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],hA=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],y0=(n,r,e)=>{n.updateEntityBoxSize(ci,ui),Ca.copy(r).multiply(n.matrixWorld),ui.x===0&&ui.y===0&&ui.z===0?e.push(new Ot.Vector3(ci.x,ci.y,ci.z).applyMatrix4(Ca)):g0.forEach(t=>{e.push(t.clone().multiply(ui).add(ci).applyMatrix4(Ca))})},il=class extends Ot.Box3{constructor(){super(...arguments);this.matrix=new Ot.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(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let o=new Ot.Matrix4().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,t)}expandByObjectSize(e,t,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 Ot.Vector3);return}y0(a,t,i)}}):y0(e,t,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(Ca.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(ui).multiplyScalar(.5),this.getCenter(ci),Ca.copy(this.matrix).setPosition(ci),this.vertices=g0.map(e=>e.clone().multiply(ui).applyMatrix4(Ca))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=fA.map(([e,t])=>new Ot.Line3(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new Ot.Vector3))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=hA.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var eo={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var Wt=require("three"),Lp=class extends Wt.CurvePath{constructor(){super()}getPoints(r=12){let e=[],t,o=this.getCurveLengths(),a=o[o.length-1]/o.length;for(let s=0,l=this.curves;s<l.length;s++){let c=l[s],u=s===0?o[s]:o[s]-o[s-1],p=Math.ceil(r*u/a),d=c.getPoints(p);for(let h=0;h<d.length;h++){let f=d[h];t&&t.equals(f)||(e.push(f),t=f)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var Rp=.001;function Vp(n,r,e){return r.clone().sub(n).cross(r.clone().sub(e)).length()<=Rp}function Bp(n,r){let e=new Wt.Vector3(...n.position),t=new Wt.Vector3(...n.controlNext.position),o=new Wt.Vector3(...r.controlPrevious.position),i=new Wt.Vector3(...r.position);return Vp(e,t,i)&&Vp(e,o,i)}function gu(n){let r=n.points.map(u=>new Wt.Vector3(...u.data.position)),e=[n.points[0]],t=new Wt.Vector3(...e[0].data.position);for(let u=0;u<n.points.length-1;u++)Vp(t,r[u],r[u+1])||(e.push(n.points[u]),t=r[u]);e.push(n.points[n.points.length-1]);let o=n.isClosed,i=e.length-(o?0:1),a=e.length,s=[];for(let u=0;u<a;u++){let p=e[u].data,d=new Wt.Vector3(...p.position),h=new Wt.Vector3(...p.controlPrevious.position),f=new Wt.Vector3(...p.controlNext.position),m={position:d,baseRoundness:p.roundness,controlPrevious:h,controlNext:f};if(p.roundness===0||!n.isClosed&&(u===0||u===a-1)){s[u]={...m,removedLength:0};continue}let y=o&&u==0?a-1:u-1,g=o&&u==a-1?0:u+1,v=e[y].data,O=e[g].data,P=new Wt.Vector3(...v.position),S=new Wt.Vector3(...O.position),T=P.clone().sub(d).normalize(),I=S.clone().sub(d).normalize();Object.assign(m,{prevDir:T,nextDir:I});let x=Bp(v,p),_=Bp(p,O);if(!x||!_)s[u]={...m,removedLength:0};else{let D=T.clone().add(I).normalize(),A=D.clone().cross(T).length()/T.dot(D);s[u]={...m,tan:A,removedLength:p.roundness/A}}}for(let u=0;u<i;u++){let p=u,d=o&&u===a-1?0:u+1,h=s[p],f=s[d];if(h.removedLength!==0||f.removedLength!==0){let m=h.position.distanceTo(f.position);h.removedLength=Math.min(h.removedLength,m/2),f.removedLength=Math.min(f.removedLength,m/2)}}let l=[];for(let u=0;u<i;u++){let p=u,d=o&&u===a-1?0:u+1,h=s[p],f=s[d],m=null;if(!Bp(e[p].data,e[d].data))h.position.distanceTo(f.position)>Rp&&(m=new Wt.CubicBezierCurve3(h.position,h.controlNext,f.controlPrevious,f.position));else{let y=h.position.clone(),g=f.position.clone();(h.removedLength!==0||f.removedLength!==0)&&(h.nextDir&&y.add(h.nextDir.clone().setLength(h.removedLength)),f.prevDir&&g.add(f.prevDir.clone().setLength(f.removedLength))),y.distanceTo(g)>Rp&&(m=new Wt.CubicBezierCurve3(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}l[2*u+1]=m}for(let u=0;u<a;u++){let p=s[u];if(p.removedLength===0){l[2*u]=null;continue}let d=p.position,h=p.prevDir.clone().multiplyScalar(p.removedLength).add(d),f=p.nextDir.clone().multiplyScalar(p.removedLength).add(d),m=p.tan*p.removedLength,y=p.prevDir.clone().add(p.nextDir).normalize(),g=h.clone().lerp(f,.5),v=h.distanceTo(f)/2,O=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(v,2))).add(g),P=y.clone().multiplyScalar(-m).add(O),S=d.distanceTo(P)/d.distanceTo(g),T=p.prevDir.clone().multiplyScalar(S*d.distanceTo(h)).add(d),I=T.clone().lerp(P,2),x=h.clone().lerp(T,4/3),_=f.clone().lerp(I,4/3);l[2*u]=new Wt.CubicBezierCurve3(h,x,_,f)}let c=new Lp;return l.forEach(u=>{u&&c.add(u)}),c}var je;(r=>{function n(e){return e&&e.__isEntity}r.is=n})(je||(je={}));var Ta=n=>je.is(n),mA={type:"completeState",isfromEntity:!0},yA=["x","y","z"],zp=new or.Vector3,gA=new or.Vector3().set(0,1,0),Aa=n=>class extends Oa(n){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.destroyedInAction=!1;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new il;this._recursiveBBox=new il;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let o=this.children[t];if(je.is(o))return o}entityChildrenCount(){let t=this.children.length;for(;t--;)if(je.is(this.children[t]))return t+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 t=this;for(;t.data.type!=="Instance";){let o=t.parent;if(je.is(o))t=o;else return}return t}forInstancesRec(t){this.instances.forEach(o=>{o.disposed||t(o),o.forInstancesRec(t)})}super_Entity(t,o){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=o,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,o,i=!1){if(!(this.data.states.length===0&&!i)){for(let a of this.data.states)si.toOps(this.data,a.data).forEach(l=>{let c=ia.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(c,this.data,o)});if(t!==null){let a=this.data.states.data(t);a&&(this.dataPatched=si.patch(this.data,a),si.toOps(this.data,a).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,o)}))}i&&this.updateTransformState(this.dataPatched,o),this.stateSelection=t,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(t,o){t.setScalar(0),o.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{Ta(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let o;return this.traverseEntity(i=>{i.uuid===t&&(o=i)}),o}traverseSortNextHelper(){let t=this.parent;if(t){let o=t.children,i=o.indexOf(this)+1;if(je.is(o[i]))return o[i];if(je.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&je.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let o=this;for(;t>0&&o!==null;)o=o.parent,t-=1;return o}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let o=this.parent;for(;o;){if(t===o)return!0;o=o.parent}return!1}countToAccestor(t){let o=0,i=this;for(;i!==t;){if(i===null)return-1;i=i.parent,o+=1}return o}forEachEntity(t){for(let o of this.children)Ta(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{je.is(o)&&t(o)})}traverseConcreteEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)Ta(a)&&a.isConcreteEntity&&a.traverseEntity(t,o+1)}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)Ta(a)&&a.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)Ta(o)&&o.visible&&o.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,o=!1){return super.copy(t,o),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>Ta(t))}isAncestorOf(t){if(this.uuid===t)return!1;let o=!1;return this.traverseEntity(i=>{i.uuid===t&&(o=!0)}),o}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x*or.MathUtils.RAD2DEG,this.rotation.y*or.MathUtils.RAD2DEG,this.rotation.z*or.MathUtils.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ea(o,t)}getTransformValues(t,o,i){return o[t].map((a,s)=>i?.shared.getVariable(a,[this.uuid,t,yA[s]])??a)}updateTransformState(t,o){let i=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,o)),i=!0),t.rotation&&(zp.fromArray(this.getTransformValues("rotation",t,o)).multiplyScalar(or.MathUtils.DEG2RAD),this.rotation.setFromVector3(zp),i=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,o)),i=!0),t.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??vn.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(a=>{a.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}onVariableUpdate(t=!1){if(t){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 t of this.children)je.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{je.is(t)&&t.disposeRecursively()})}toState(t=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return ea(o,t)}updateByObjUpdateOp(t,o){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},o,!1)}updateByOp(t,o,i,a){let s=this.data;this.data=o;let l=t,c=Ge(t.path,["states","*"]);if(c!==null){if(t.type===0){let[u]=c;if(this?.stateSelection===u){let p={...t.props};if(delete p.name,Object.values(t.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let h=mt.zoom(d,t.path.slice(2));if(h)for(let f in t.props)t.props[f]===void 0&&f in h&&(p[f]=h[f])}}l={...t,props:p,path:t.path.slice(2)}}}}else if(t.type===0){let u=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(u!==void 0){if(t.props.name!==void 0&&u.name){let{name:d,...h}=u;u=h}if(t.props.material!==void 0&&"material"in u){let{material:d,...h}=u;u=h}let p=mt.removeOverridden(t.path,t.props,u);l={...t,props:p}}}if(this.updateByPatchedOpBase(l,si.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),Ge(t.path,["overrides"])){let u=[],p=[...t.path];for(u.push(p[1]),p.splice(0,2);p.length>0&&p[0]==="descendants";)u.push(p[1]),p.splice(0,2);if(u[u.length-1]===void 0){if(t.type===0)for(let d of Object.keys(t.props)){u[u.length-1]=d;let h=i.scene.findInstance([this.uuid,...u]);h&&(h.overrideData=t.props[d],h.updateState(mo.apply(h.component.data,h.overrideData),i))}}else{let d=i.scene.findInstance([this.uuid,...u]);if(d){let h=mt.zoom(d.component.data,p);if(t={...t,path:p},t.type===0){let f=t.props;if(h)for(let[m,y]of Object.entries(t.props))y===void 0&&(f===t.props&&(f={...t.props}),f[m]=h[m]);t={...t,props:f}}d.overrideData=ma.resolve(o.overrides,u),d.updateByOp(t,yt.applySimple(d.data,t),i,!1)}}}else if(this.instances.length>0){let u;if(t.path.length===0&&t.type===0){let p;for(let d of So.rootOverrideProps)d in t.props&&(p===void 0&&(p={}),p[d]=t.props[d]);p&&(u={...t,props:p})}else for(let p of So.rootOverrideProps)if(Ge(t.path,[p])){u=t;break}u!==void 0&&this.instances.forEach(p=>{if(p.isInstanceRoot){let d=mo.filterOp(p.overrideData,u);d&&p.updateByOp(d,yt.applySimple(p.data,d),i,!0)}}),this.instances.forEach(p=>{if(!p.isInstanceRoot){let d=mo.filterOp(p.overrideData,t);if(d){let h;s===p.data&&t===d?h=o:h=yt.applySimple(p.data,d),p.updateByOp(d,h,i,!0)}}})}}updateByPatchedOpBase(t,o,i){if(this.dataPatched=o,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Qr.is(t.props.type)&&eo.changeEntityProptotype(this,o,i);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){eo.changeEntityProptotype(this,o,i);for(let a of this.children)je.is(a)&&a.updateVisible(i.scene)}this.updateByPatchedOp(t,o,i)}updateByPatchedOp(t,o,i){if(t.path.length===0&&t.type===0&&this.updateState(t.props,i),Ge(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Ge(t.path,["cloner"])!==null){let a=yt.drop(t,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(t=this.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){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=t.find(o);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let c=l.data;if(c.geometry.path.points.length<=1)return;let u=gu(c.geometry.path),p=(i+a)%1;i+a===1&&p===0&&(p=1);let d=u.getPointAt(p);if(d===null)return;let h=this.parent?this.parent?.matrixWorld:new or.Matrix4;l.updateMatrixWorld();let f=new or.Matrix4().multiplyMatrices(h.clone().invert(),l.matrixWorld);d.applyMatrix4(f);let m={position:d.toArray(),rotation:c.rotation};if(s==="tangential"){let y=new or.Matrix4().extractRotation(l.matrixWorld),g=u.getTangentAt(p).applyMatrix4(y).add(d),v=new or.Matrix4().lookAt(d,g,gA),O=zp.setFromEuler(new or.Euler().setFromRotationMatrix(v)).multiplyScalar(or.MathUtils.RAD2DEG);m={...m,rotation:O.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(mA)})}updateVisible(t){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!t)return;let o=!1;this.traverseEntity(i=>{if(i.data.type==="Splat")return o=!0,!0}),o&&t.reloadSplats()}updateState_Entity(t,o){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(o?.scene),this.resetBBoxNeedsUpdate()),o&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,o),this.updateVisible(o.scene)),this.updateTransformState(t,o)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof eo.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,o){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new eo.Cloner(this,t),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,o.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}};var An=require("three");var nt=require("three"),b0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);e.thetaLength=nt.MathUtils.clamp(e.thetaLength,0,360);let t=e.width/2,o=e.radiusTop??t,i=e.radiusBottom??t;return o===i?(o=t,i=t):o>i?(o=t,i=i*t/o):(o=o*t/i,i=t),{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:r,depth:e,height:t,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:p,cornerSegments:d,hollow:h}=n.parameters,f;return l===0?(f=new nt.BufferGeometry,f.setAttribute("position",new nt.Float32BufferAttribute([],3))):p||h?f=new al(c,u,t,o,i,a,s,l*Math.PI/180,p,p,d,h):f=new nt.CylinderGeometry(c,u,t,o,i,a,s,l*Math.PI/180),f.scale(1,1,e/r),Object.assign(f,{userData:{...n,type:"CylinderGeometry"}})}};function Tn(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function x0(n){return new nt.Vector2(n.y,-n.x)}var al=class extends nt.BufferGeometry{constructor(r,e,t,o,i,a,s,l,c,u,p,d,h=!1){super(),this.type="RoundedCylinderBufferGeometry",r=r!==void 0?r:1,e=e!==void 0?e:1,t=t||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&&(c=0,u=0);let f=[],m=[],y=[],g=[],v=0,O=t/2,P=new nt.Vector3,S=new nt.Vector3;h&&r==0&&(r=c),h&&e==0&&(e=u);let T=new nt.Vector2(r,O),I=new nt.Vector2(e,-O),x=null,_=null,D=null,A=null,N=T.clone().sub(I),E=0,B=0,V=0;d>0&&(E=Math.min(r,e)*(1-d),B=r-E,V=e-E);let j=T.clone();j.x-=E;let R=Math.PI-N.angle(),W=N.angle(),F=Math.tan(W/2),k=Math.tan(R/2),H=F+k,$=d?H:k,J=d?H:F;if(c=Math.min(c,(r-B)/$,N.length()/H),u=Math.min(u,(e-V)/J,N.length()/H),c>0){let K=c/F;x=T.clone().sub(new nt.Vector2(K,c)),d&&(D=x.clone(),D.x-=E-H*c),T.sub(N.clone().setLength(K))}if(u>0){let K=u/k;_=I.clone().sub(new nt.Vector2(K,-u)),I.add(N.clone().setLength(K)),d&&(A=_.clone(),A.x-=E-H*u,j.sub(N.clone().setLength(K)))}N=T.clone().sub(I);let Z=N.length()<.5,X=[];for(let K=0;K<=o;K++){let q=[],ue=K/o,le=ue*l+s,ne=new nt.Vector2(Math.sin(le),Math.cos(le));A&&_?(te(q,ue,ne,R,u,A,-1,!0),te(q,ue,ne,W,u,_,-1,!1)):_?(Y(q,ne,_.x,0,-1),te(q,ue,ne,W,u,_,-1,!1)):a||Y(q,ne,e,V,-1);let ce=x0(N).normalize();if(Tn(ce,ne,P),!Z)for(let ae=0;ae<=i;ae++){let me=ae/i,fe=N.clone().multiplyScalar(me).add(I);Tn(fe,ne,S),m.push(S.x,S.y,S.z),y.push(P.x,P.y,P.z),g.push(ue,.5+S.y/t),q.push(v++)}if(D&&x?(te(q,ue,ne,R,c,x,1,!1),te(q,ue,ne,W,c,D,1,!0)):x?(te(q,ue,ne,R,c,x,1,!1),Y(q,ne,x.x,0,1)):a||Y(q,ne,r,B,1),d&&!Z){let ae=x0(N).multiplyScalar(-1).normalize();Tn(ae,ne,P);for(let me=0;me<=i;me++){let fe=me/i,he=N.clone().multiplyScalar(-fe).add(j);Tn(he,ne,S),m.push(S.x,S.y,S.z),y.push(P.x,P.y,P.z),g.push(ue,.5+S.y/t),q.push(v++)}}d&&!a&&q.push(q[0]),X.push(q)}for(let K=0;K<X.length-1;K++)for(let q=0;q<X[0].length-1;q++){if(a&&d&&q==i)continue;let ue=X[K][q],le=X[K+1][q],ne=X[K+1][q+1],ce=X[K][q+1],ae=m[ne*3+0],me=m[ne*3+2];f.push(ue,le,ce),(ae!=0||me!=0)&&f.push(le,ne,ce)}l<Math.PI*2&&(ee(-1,X[0],s),ee(1,X[X.length-1],s+l)),this.setIndex(f),this.setAttribute("position",new nt.Float32BufferAttribute(m,3)),this.setAttribute("normal",new nt.Float32BufferAttribute(y,3)),this.setAttribute("uv",new nt.Float32BufferAttribute(g,2));function te(K,q,ue,le,ne,ce,ae,me){for(let fe=0;fe<p+1;fe++){let he=fe/p,xe=ae<0?he:1-he;me&&(xe-=1),xe*=le;let ye=new nt.Vector2(Math.sin(xe),Math.cos(xe)*ae),C=ye.clone().multiplyScalar(ne).add(ce);Tn(C,ue,S),m.push(S.x,S.y,S.z),Tn(ye,ue,P),y.push(P.x,P.y,P.z),g.push(q,.5+S.y/t),K.push(v++)}}function Y(K,q,ue,le,ne){let ce=new nt.Vector3,ae=new nt.Vector2,me=[ue,le];ne<0&&me.reverse();for(let fe of me)ae.set(fe,O*ne),Tn(ae,q,ce),m.push(ce.x,ce.y,ce.z),y.push(0,ne,0),g.push(.5,.5),K.push(v++)}function ee(K,q,ue){let le=new nt.Vector2(Math.sin(ue),Math.cos(ue)),ne=new nt.Vector2(-Math.cos(ue),Math.sin(ue)),ce=new nt.Vector3,ae=K<0?(he,xe,ye)=>f.push(he,xe,ye):(he,xe,ye)=>f.push(he,ye,xe),me=new nt.Vector2((r+e+B+V)/4,0);Tn(me,le,ce),m.push(ce.x,ce.y,ce.z),y.push(ne.x,0,ne.y),g.push(.5,.5);let fe=v++;for(let he of q){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),v++}for(let he=fe+1;he<v-1;he++)ae(fe,he,he+1);ae(fe,v-1,fe+1)}}};var v0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},n.parameters);return e.thetaLength=An.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:r,depth:e,height:t,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:u,cornerSegments:p}=n.parameters,d;return l===0?(d=new An.BufferGeometry,d.setAttribute("position",new An.Float32BufferAttribute([],3))):c>0||u>0||l<360?d=new al(0,r/2,t,o,i,a,s,l*Math.PI/180,c,u,p,0,!0):d=new An.ConeGeometry(r/2,t,o,i,a),d.scale(1,1,e/r),Object.assign(d,{userData:{...n,type:"ConeGeometry"}})}};var gr=require("three"),S0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.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:r,height:e,depth:t,widthSegments:o,heightSegments:i,depthSegments:a,cornerRadius:s,cornerSegments:l}=n.parameters,c;return s==0?c=new gr.BoxGeometry(r,e,t,o,i,a):c=new jp(r,e,t,o,i,a,s,l),Object.assign(c,{userData:{...n,type:"CubeGeometry"}})}},Gp=Math.PI/2,jp=class extends gr.BufferGeometry{constructor(r=1,e=1,t=1,o=1,i=1,a=1,s=0,l=4){super(),this.type="BoxGeometry";let c=this;o=Math.floor(o),i=Math.floor(i),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,r/2,e/2,t/2);let u=[],p=[],d=[],h=[],f=0,m=0;y("z","y","x",-1,-1,t,e,r,a,i,0),y("z","y","x",1,-1,t,e,-r,a,i,1),y("x","z","y",1,1,r,t,e,o,a,2),y("x","z","y",1,-1,r,t,-e,o,a,3),y("x","y","z",1,-1,r,e,t,o,i,4),y("x","y","z",-1,-1,r,e,-t,o,i,5),s>0&&(g("z","y","x",-1,-1,1,t,e,r,a,0),g("z","y","x",1,-1,-1,t,e,r,a,1),g("z","y","x",-1,1,-1,t,e,r,a,1),g("z","y","x",1,1,1,t,e,r,a,0),g("x","y","z",-1,-1,-1,r,e,t,o,0),g("x","y","z",1,-1,1,r,e,t,o,1),g("x","y","z",-1,1,1,r,e,t,o,0),g("x","y","z",1,1,-1,r,e,t,o,1),g("y","x","z",-1,-1,1,e,r,t,i,0),g("y","x","z",1,-1,-1,e,r,t,i,1),g("y","x","z",1,1,1,e,r,t,i,1),g("y","x","z",-1,1,-1,e,r,t,i,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(u),this.setAttribute("position",new gr.Float32BufferAttribute(p,3)),this.setAttribute("normal",new gr.Float32BufferAttribute(d,3)),this.setAttribute("uv",new gr.Float32BufferAttribute(h,2));function y(O,P,S,T,I,x,_,D,A,N,E){let B=(x-2*s)/A,V=(_-2*s)/N,j=x/2-s,R=_/2-s,W=D/2,F=A+1,k=N+1,H=0,$=0,J=new gr.Vector3;for(let Z=0;Z<k;Z++){let X=Z*V-R;for(let te=0;te<F;te++){let Y=te*B-j;J[O]=Y*T,J[P]=X*I,J[S]=W,p.push(J.x,J.y,J.z),J[O]=0,J[P]=0,J[S]=D>0?1:-1,d.push(J.x,J.y,J.z),h.push(te/A),h.push(1-Z/N),H+=1}}for(let Z=0;Z<N;Z++)for(let X=0;X<A;X++){let te=f+X+F*Z,Y=f+X+F*(Z+1),ee=f+(X+1)+F*(Z+1),K=f+(X+1)+F*Z;u.push(te,Y,K),u.push(Y,ee,K),$+=6}c.addGroup(m,$,E),m+=$,f+=H}function g(O,P,S,T,I,x,_,D,A,N,E){let B=(_-2*s)/N,V=_/2-s,j=D/2-s,R=A/2,W=N+1,F=0,k=0,H=new gr.Vector3,$=new gr.Vector3;for(let J=0;J<l+1;J++){let Z=J/l*Gp,X=Math.sin(Z)*s,te=(1-Math.cos(Z))*s,Y=Math.sin(Z),ee=Math.cos(Z);H[P]=(j+X)*I,H[S]=(R-te)*x,$[O]=0,$[P]=Y*Math.sign(H[P]),$[S]=ee*Math.sign(H[S]);for(let K=0;K<W;K++){let q=K*B-V;H[O]=q*T,p.push(H.x,H.y,H.z),d.push($.x,$.y,$.z),h.push(K/N),h.push(0),F+=1}}for(let J=0;J<l;J++)for(let Z=0;Z<N;Z++){let X=f+Z+W*J,te=f+Z+W*(J+1),Y=f+(Z+1)+W*(J+1),ee=f+(Z+1)+W*J;u.push(X,te,ee),u.push(te,Y,ee),k+=6}c.addGroup(m,k,E),m+=k,f+=F}function v(O,P,S){let T=new gr.Vector3,I=new gr.Vector3(r/2,e/2,t/2);I.subScalar(s);let x=[],_=O*P*S>0?(A,N,E)=>u.push(A,N,E):(A,N,E)=>u.push(A,E,N);for(let A=0;A<=l;A++){let N=[],E=Gp*(1-A/l),B=Math.cos(E),V=Math.sin(E),j=0;for(let R=0;R<=A;R++){let W=Math.cos(j),F=Math.sin(j);T.x=B*W,T.y=V,T.z=B*F;let k=I.clone().addScaledVector(T,s);p.push(O*k.x,P*k.y,S*k.z),d.push(O*T.x,P*T.y,S*T.z),h.push(0,0),N.push(f++),j+=Gp/A}x.push(N)}let D=x.length-1;for(let A=0;A<D;A++){let N=x[A],E=x[A+1],B=N.length-1;_(N[0],E[1],E[0]);for(let V=1;V<=B;V++)_(N[V-1],N[V],E[V]),_(N[V],E[V+1],E[V])}}}};var Ct=require("three"),Mn=class extends Ct.BufferGeometry{constructor(r=[],e=[],t="",o=1,i=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],c=[];u(),p(),this.setAttribute("position",new Ct.Float32BufferAttribute(s,3)),this.setAttribute("normal",new Ct.Float32BufferAttribute(c,3)),this.setAttribute("uv",new Ct.Float32BufferAttribute(l,2));return;function u(){i=Math.min(1-1e-5,i),i==0&&(a=0);let h={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[t],f=new Ct.Vector3,m=f.clone(),y=new Ct.Triangle,g=i*o,v=o-g,O=a+1,P=new Ct.Vector3,S=(F,k)=>P.subVectors(F,k).normalize(),T=(F,k)=>Array(F).fill(void 0).map(k),I=T(r.length/3,(F,k)=>new Ct.Vector3().fromArray(r,k*3).setLength(o)),x=[],_=1e6;for(let F=0;F<I.length;F++){let k=I[F],H=[],$,J,Z,X=1e10,te=-1;for(;(te=e.indexOf(F,te+1))!=-1;){let q=te-te%3;$=e[q+(te+1)%3],J=e[q+(te+2)%3],Z=k.distanceToSquared(I[$]),X=Math.min(X,Z),H.push([$,J,Z])}X+=1e-6;let Y=[],ee=0,K=H.length;for(let q=0;q<K;q++){[$,J,Z]=H[ee];let ue=x[$]?.includes(F)==!0;Z<=X&&Y.push($+ +ue*_),ee=H.findIndex(le=>le[0]==J)}x.push(Y)}let D=[];{let F=0,k=0,H,$,J=h==3;for(let Z=0;Z<=a;Z++){H=Z*(Z+1)/2,$=(Z+1)*(Z+2)/2;for(let X=0;X<a-Z;X++)[F,k]=[H+X+Z+2,$+X+Z+3],D.push(H,$,...J?[k,H]:[F,$],k,F),[H,$]=[F,k];D.push(H,$,H+a+2)}}let A=f.clone(),N=f.clone(),E=f.clone(),B=f.clone(),V=f.clone(),j=[],R=T(I.length,()=>T(h,()=>f.clone()));for(let F=0;F<I.length;F++){f.copy(I[F]).normalize(),A.copy(f).multiplyScalar(v);let k=x[F];for(let Y=0;Y<k.length;Y++){let ee=k[Y],K=k[(Y+1)%h];y.setFromPointsAndIndices(I,F,ee%_,K%_),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(A,R[F][Y])}let H=[],$=[],J=[],Z=new Ct.Vector3;a==0&&[...R[F]].reduce((Y,ee)=>Y.add(ee),Z).multiplyScalar(1/h);for(let Y=0;Y<h;Y++){let ee=[],K=(Y-1+h)%h,q=R[F][K],ue=R[F][Y];f.copy(q).sub(A),m.copy(ue).sub(A);let le=A.angleTo(f),ne=f.angleTo(m),ce=Math.cos(le)*g;a==0?N.copy(Z):N.copy(A).setLength(v+ce),$.push(ce);let ae=[N,q,ue];for(let me=0;me<2;me++){let fe=ae[me],he=ae[me+1];B.subVectors(fe,A),V.subVectors(he,A),E.crossVectors(B,V).normalize();for(let xe=0;xe<O;xe++){let ye=[le,ne][me]*xe/O;f.copy(B).applyAxisAngle(E,ye).add(A),H.push(f.clone()),me&&(S(f,A),ee.push([xe==0?fe:f.clone(),P.clone()]))}me&&(S(he,A),ee.push([he,P.clone()]))}J.push(ee)}j.push(J);let X=2*O,te=2;for(let Y=0;Y<h;Y++){let ee=X*Y,K=X*((Y+1)%h),q=[H[ee]];for(let le=1;le<O;le++){B=H[ee+le],V=H[K+le],q.push(B);for(let ne=1,ce=le-te+1;ne<=ce;ne++)f.lerpVectors(B,V,ne/(ce+1)),f.sub(A).setLength($[Y]).add(A),q.push(f.clone());q.push(V)}for(let le=0;le<O;le++)q.push(H[le+O+ee]);q.push(H[K+O]);let ue=D.map(le=>q[le]);s.push(...ue.map(le=>[le.x,le.y,le.z]).flat()),c.push(...ue.map(le=>(S(le,A),[P.x,P.y,P.z])).flat())}}let W=[];for(let F=0;F<x.length;F++)for(let k=0;k<h;k++){let H=x[F][k];if(H<_){let $=x[H].findIndex(X=>X%_==F),J=j[F][k],Z=j[H][$];for(let X=0;X<O;X++){let te=J[X],Y=Z[O-X],ee=J[X+1],K=Z[O-(X+1)];[te,Y,ee,ee,Y,K].forEach(q=>{s.push(q[0].x,q[0].y,q[0].z),c.push(q[1].x,q[1].y,q[1].z)})}W.push(J[0][0],Z[O][0],J[O][0],Z[0][0])}}for(;W.length;){let F,k,H,$;[F,k]=W.splice(0,2);let J=[F];for(;F!=k;)J.push(k),H=W.indexOf(k),$=H%2,k=W.splice(H-$,2)[1-$];P.subVectors(J[0],J[1]).cross(f.subVectors(J[0],J[2])).normalize();let Z=P.dot(J[0])<0;Z&&P.negate();for(let X=1;X<=J.length-2;X++)[J[X+ +Z],J[X+1-+Z],J[0]].forEach(te=>{s.push(te.x,te.y,te.z),c.push(P.x,P.y,P.z)})}}function p(){let d=new Ct.Vector3;for(let I=0;I<s.length;I+=3){d.x=s[I+0],d.y=s[I+1],d.z=s[I+2];let x=S(d)/2/Math.PI+.5,_=T(d)/Math.PI+.5;l.push(x,1-_)}let h=new Ct.Vector3,f=new Ct.Vector3,m=new Ct.Vector3,y=new Ct.Vector3,g=new Ct.Vector2,v=new Ct.Vector2,O=new Ct.Vector2,P=(I,x,_,D)=>{D<0&&I.x===1&&(l[x]=I.x-1),_.x===0&&_.z===0&&(l[x]=D/2/Math.PI+.5)};for(let I=0,x=0;I<s.length;I+=9,x+=6){h.set(s[I+0],s[I+1],s[I+2]),f.set(s[I+3],s[I+4],s[I+5]),m.set(s[I+6],s[I+7],s[I+8]),g.set(l[x+0],l[x+1]),v.set(l[x+2],l[x+3]),O.set(l[x+4],l[x+5]),y.copy(h).add(f).add(m).divideScalar(3);let _=S(y);P(g,x+0,h,_),P(v,x+2,f,_),P(O,x+4,m,_)}for(let I=0;I<l.length;I+=6){let x=l[I+0],_=l[I+2],D=l[I+4],A=Math.max(x,_,D),N=Math.min(x,_,D);A>.9&&N<.1&&(x<.2&&(l[I+0]+=1),_<.2&&(l[I+2]+=1),D<.2&&(l[I+4]+=1))}function S(I){return Math.atan2(I.z,-I.x)}function T(I){return Math.atan2(-I.y,Math.sqrt(I.x*I.x+I.z*I.z))}}}static fromJSON(r){return new Mn(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};var w0=require("three"),P0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.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:r,height:e,depth:t,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new sl(r*.5,i,a):new w0.DodecahedronGeometry(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},sl=class extends Mn{constructor(r=1,e=.2,t=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,r,e,t),this.type=l}static fromJSON(r){return new sl(r.radius,r.corner,r.cornerSides)}};var Ye=require("three");var Ne=require("three"),ll=1e-12,Ma=class{constructor(r){this.position=new Ne.Vector2;this.startPosition=new Ne.Vector2;this.uuid=Ne.MathUtils.generateUUID();this.position=r.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(r){this.position.copy(this.startPosition).add(r)}copy(r){return this.position.copy(r.position),this.startPosition.copy(r.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)}},to=class extends Ma{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Ia(this),new Ia(this))}static create(e,t){let o=new to(e,new Ne.Vector2(...t.position));return o.controls[0].position.set(...t.controlPrevious.position),o.controls[1].position.set(...t.controlNext.position),o.roundness=t.roundness,o.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,o}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let o=0,i=this.controls.length;o<i;o++){let a=this.controls[o];this.position.distanceTo(a.position)<=t?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 to(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),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new Ne.Vector2,t=new Ne.Vector2){let[o,i]=this.computeTangents();return o&&i&&(O0(o,e),O0(i,t)),[e,t]}computeTangent(e=new Ne.Vector2){let[t,o]=this.computeTangents();return t&&o&&e.copy(t).add(o).normalize(),e}computeNormal(e=new Ne.Vector2){let[t,o]=this.computeNormals();return e.copy(t).add(o).normalize(),e}};function O0(n,r=new Ne.Vector2){let e=n.length();return r.set(-n.y/e,n.x/e)}var Up=n=>n,Na=new Ne.Vector2,xu=new Ne.Vector2,xA=new Ne.Vector2,bA=new Ne.Vector2,vA=new Ne.Vector2,SA=new Ne.Vector2,T0=new Ne.Vector3,A0=new Ne.Vector3;function M0(n){let r=new Ne.Vector2;r.addVectors(n.v0,Na.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Ne.Vector2;return e.addVectors(n.v2,xu.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new Ne.CubicBezierCurve(n.v0,r,e,n.v2)}function cl(n,r,e=Number.EPSILON){return Math.abs(n-r)<e}function wA(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function PA(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function kp(n,r,e){let t=Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2)),o=Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.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+t*t-i*i)/(2*o*t))}function I0(n,r,e){return C0(n,r)&&C0(r,e)&&Fp(n.position,r.position,e.position)}function Fp(n,r,e){return Na.copy(r).sub(n).cross(xu.copy(e).sub(n))===0}function N0(n,r,e,t,o){let i=Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2)),a=(n.y+r.y)/2,s=(n.x+r.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(n.y-r.y)/i,c=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(r.x-n.x)/i;return t.set(s+l,a+c),o.set(s-l,a-c),[t,o]}function D0(n,r,e){let t=n.distanceTo(e),o=r.distanceTo(e);return t<o?r:n}function E0(n,r,e,t,o,i){let a=r.x-n.x,s=r.y-n.y,l=e.x-n.x,c=e.y-n.y,u=Math.sqrt((a+l)*(a+l)+(s+c)*(s+c)),p;return kp(r,n,e)>Math.PI&&(u*=-1),cl(c,s)?p=(s+c)*(t/u-.5)*8/3/(a-l):p=(a+l)*(t/u-.5)*8/3/(c-s),o.set(r.x-p*s,r.y+p*a),i.set(e.x+p*c,e.y-p*l),[o,i]}function Hp(n,r){return n.position.equals(n.controls[1].position)&&r.position.equals(r.controls[0].position)}function C0(n,r){return Fp(n.position,n.controls[1].position,r.position)&&Fp(n.position,r.controls[0].position,r.position)}function _0(n,r,e,t,o=.5){let i=Na.subVectors(r,n).multiplyScalar(o).add(n),a=xu.subVectors(e,r).multiplyScalar(o).add(r),s=xA.subVectors(t,e).multiplyScalar(o).add(e),l=i,c=bA.subVectors(a,i).multiplyScalar(o).add(i),u=vA.subVectors(s,a).multiplyScalar(o).add(a),p=s,d=SA.subVectors(u,c).multiplyScalar(o).add(c);return[n.x,n.y,l.x,l.y,c.x,c.y,d.x,d.y,u.x,u.y,p.x,p.y,t.x,t.y]}function B0(n,r,e=12,t=!0){let o=A0.set(0,0,0),i,a=0,s=[];for(let l=0;l<r.length;l++){let c=Up(r[l]),u=Na,p=In(c,e);s.push(p);for(let d=0;d<=p;d++)if(c instanceof Ne.CubicBezierCurve||c instanceof Ne.QuadraticBezierCurve||c instanceof Ne.LineCurve){if(c.getPoint(d/p,u),o.set(u.x,u.y,0),i!==void 0&&PA(i,o))continue;i===void 0&&(i=T0),i.copy(o),n.setXYZ(a,o.x,o.y,o.z),a++}}return t&&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 L0(n,r,e,t=12,o=!0){let i=A0.set(0,0,0),a=0,s=[];for(let l=0;l<r.length;l++){if(e[l]===!1)continue;let c,u=Up(r[l]),p=Na,d=In(u,t);s.push(d);for(let h=0;h<=d;h++)if(u instanceof Ne.CubicBezierCurve||u instanceof Ne.QuadraticBezierCurve||u instanceof Ne.LineCurve){if(u.getPoint(h/d,p),i.set(p.x,p.y,0),c?.equals(i))continue;c===void 0?c=T0:(n.setXYZ(a,c.x,c.y,c.z),a++,n.setXYZ(a,i.x,i.y,i.z),a++),c.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 Wp(n,r=12,e=!1){let t=[];for(let o=0,i=n.length;o<i;o++){let a=n[o],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=In(a.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=In(a.curveAfter,r)),t.push(s)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(t[n.length-1]+=In(n[0].roundedCurveCorner,r)*.5),t}function In(n,r=12){return n&&n instanceof Ne.EllipseCurve?r*2:n&&(n instanceof Ne.LineCurve||n instanceof Ne.LineCurve3)?1:n&&n instanceof Ne.SplineCurve?r*n.points.length:r}function R0(n,r,e=12,t=!0){let o,i=0;for(let a=0;a<r.length;a++){let s=Up(r[a]),l=In(s,e),c=Na;for(let u=0;u<=l;u++)if(s instanceof Ne.CubicBezierCurve||s instanceof Ne.QuadraticBezierCurve||s instanceof Ne.LineCurve){if(s.getPoint(u/l,c),o!==void 0&&wA(o,c,ll))continue;o===void 0&&(o=xu),o.copy(c),n.push(c.x,c.y),i++}}return cl(n[0],n[n.length-2],ll)&&cl(n[1],n[n.length-1],ll)&&(n.pop(),n.pop()),t&&i>1&&!(cl(n[i-1],n[1],ll)&&cl(n[i-2],n[0],ll))&&(n.push(n[0],n[1]),i++),n}var qp=new Ye.Vector2,OA=new Ye.Vector2,CA=new Ye.Vector2,TA=new Ye.Vector2,AA=new Ye.Vector2,MA=new Ye.Vector2,$e=class extends Ye.Shape{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new Ye.Plane(new Ye.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=Ye.MathUtils.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,o){let i=new $e;return i.isClosed=e.isClosed,i.points=e.points.map(a=>to.create(a.id,a.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(a=>$e.createFromState(a)),t!==void 0&&o!==void 0&&i.applySize(t,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 t=0,o=this.points.length;t<o;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,o=this.points.findIndex(i=>i.uuid===e);if(o<0){let i=t;for(let a=0,s=this.shapeHoles.length;a<s;a++){let l=this.shapeHoles[a],c=l.points.length,u=l.getPointIndexById(e);if(u<0)i+=c;else return u+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 t=this.points.length;for(let o=0,i=this.shapeHoles.length;o<i;o++){let a=this.shapeHoles[o],s=e-t;if(s<=a.points.length-1)return a.points[s];t+=a.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let o=0,i=this.shapeHoles.length;o<i;o++){let a=this.shapeHoles[o],s=a.points.indexOf(e);if(s>=0)return t+s;t+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let o=qp.set(e,t);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,t);this._update()}createPoint(e,t=0,o=Ye.MathUtils.generateUUID()){let i;e instanceof Ye.Vector2?i=e:i=new Ye.Vector2(e,t);let a=new to(o,i);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,o=this.points.length;t<o;t++){let i=this.points[t];if(i.uuid===e)return i}for(let t=0,o=this.shapeHoles.length;t<o;t++){let a=this.shapeHoles[t].getPointByUuid(e);if(a)return a}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(o=>o.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,o=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let i=o?this.roundedCurveDivisions:this.curveDivisions;return B0(e,o?this.roundedCurves:this.curves,t,this.autoClose),i.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Wp(this.points,e,!1),this.roundedCurveDivisions=Wp(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,o=12){return L0(e,this.curves,t,o,this.autoClose).reduce((a,s)=>a+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),R0(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let i=t?this.roundedCurveDivisions:this.curveDivisions,a=0;t&&this.points[0].roundedCurveCorner!==void 0&&(a=In(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=i.reduce((l,c)=>l+c,0));for(let l=0,c=i.length;l<c;l++){let u=i[l];if(s<o+u)return[l,(s-o+1)/u];o+=u}return[0,1]}getCurveT(e,t,o){let i=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(Hp(i,a)){let p=i.position.distanceTo(a.position);return i.position.distanceTo(qp.set(o.x,o.y))/p}let c=0;for(let p=0;p<e;p++)c+=s[p];return(t-c)/l}dispose(){}_applyCurveForPoint(e,t){Hp(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let o=this.curves[this.curves.length-1];e.curveBefore=o,t.curveAfter=o;let i=o.clone();e.roundedCurveBefore=i,t.roundedCurveAfter=i,e.roundedCurveCorner=void 0,this.roundedCurves.push(i)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,o=this.points.length;t<o;t++){let i=this.points[t];if(t===0)this.moveTo(i.position.x,i.position.y);else{let a=this.points[t-1];this._applyCurveForPoint(i,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],o=this.points[this.points.length-1];this._applyCurveForPoint(t,o)}if(this.points.length>2){let t=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],c=a.roundness,u=s&&l&&I0(s,a,l);if(!a.controlsMoved()&&c>0&&!u){let p=a.curveBefore,d=a.curveAfter;if(p===void 0||d===void 0)continue;let h=a.roundedCurveBefore,f=a.roundedCurveAfter,m=p.getLength(),y=d.getLength(),g=Math.min(c,m*.499),v=Math.min(c,y*.499),O=Math.min(g,v),P=1-O/m,S=O/y,T=p.getPointAt(P,qp),I=d.getPointAt(S,OA);this._subSplitCurve(p,h,P,T,void 0),this._subSplitCurve(d,f,S,void 0,I);let x;if(this.useCubicForRoundedCorners){let _=kp(T,a.position,I)/2,D=Math.tan(_)*T.distanceTo(a.position),[A,N]=N0(T,I,D,CA,TA),E=D0(A,N,a.position),[B,V]=E0(E,T,I,D,AA,MA);x=new Ye.CubicBezierCurve(T.clone(),B.clone(),V.clone(),I.clone())}else x=new Ye.QuadraticBezierCurve(T.clone(),a.position.clone(),I.clone());a.roundedCurveCorner=x,this.roundedCurves.splice(o+t,0,x),t++}}}}_subSplitCurve(e,t,o,i,a){if(e instanceof Ye.LineCurve)i!==void 0&&t.v2.copy(i),a!==void 0&&t.v1.copy(a);else{let s=e,l=t,c=s.getUtoTmapping(o,0),u=_0(s.v0,s.v1,s.v2,s.v3,c);return i!==void 0&&(l.v0.set(u[0],u[1]),l.v1.set(u[2],u[3]),l.v2.set(u[4],u[5]),l.v3.set(u[6],u[7])),a!==void 0&&(l.v0.set(u[6],u[7]),l.v1.set(u[8],u[9]),l.v2.set(u[10],u[11]),l.v3.set(u[12],u[13])),l}return t}clone(){let e=new $e(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let o=0;o<t;o++){let i=o*7,a=e.points[i+0],s=e.points[i+1],l=e.points[i+2],c=e.points[i+3],u=e.points[i+4],p=e.points[i+5],d=e.points[i+6],h=new to(Ye.MathUtils.generateUUID(),new Ye.Vector2(a,s));h.controls[0].position.set(l,c),h.controls[1].position.set(u,p),h.roundness=d,this.points.push(h)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new $e;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let o=(a,s)=>{s instanceof Ye.CubicBezierCurve&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},i=a=>{let s=[],l,c;for(l=0,c=a.length;l<c;l++)a[l]instanceof Ye.QuadraticBezierCurve&&(a[l]=M0(a[l]));for(l=0,c=a.length;l<c;l++){let d=a[l],h=l>0?a[l-1]:null,f;d instanceof Ye.CubicBezierCurve?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Ye.LineCurve&&(f=this.createPoint(d.v1)),f!==void 0&&(h!==null&&o(f,h),s.push(f))}let u=a[a.length-1],p=!1;return u instanceof Ye.CubicBezierCurve?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),p=!0):u instanceof Ye.LineCurve&&u.v2.equals(s[0].position)&&(p=!0),this.isClosed=p,s};return this.points=i(e.curves),e instanceof Ye.Shape&&(this.shapeHoles=e.holes.map(a=>{let s=new $e;return s.fromShape(a),s})),this.update(),this}updatePoint(e,t){let o=this.getPointByUuid(e);o&&(t.position!==void 0&&o.position.fromArray(t.position),t.roundness!==void 0&&(o.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(o.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}};var Yp=Math.PI*2;function $p({x:n,y:r},e,t,o,i){return{x:n*e+o,y:r*t+i}}function IA(n,r){let e=r===1.5707963267948966?.551915024494:r===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(r/4),t=Math.cos(n),o=Math.sin(n),i=Math.cos(n+r),a=Math.sin(n+r);return[{x:t-o*e,y:o+t*e},{x:i+a*e,y:a-i*e},{x:i,y:a}]}function V0(n,r,e,t){let o=n*t-r*e<0?-1:1,i=Math.min(1,Math.max(-1,n*e+r*t));return o*Math.acos(i)}function NA(n,r,e,t,o,i,a,s,l,c){let u=Math.pow(o,2),p=Math.pow(i,2),d=Math.pow(a,2),h=Math.pow(s,2),f=u*p-u*h-p*d;f<0&&(f=0),f/=u*h+p*d,f=Math.sqrt(f)*(l===c?-1:1);let m=f*o/i*s,y=f*-i/o*a,g=m+(n+e)/2,v=y+(r+t)/2,O=(a-m)/o,P=(s-y)/i,S=(-a-m)/o,T=(-s-y)/i,I=V0(1,0,O,P),x=V0(O,P,S,T);return!c&&x>0&&(x-=Yp),c&&x<0&&(x+=Yp),{centerx:g,centery:v,ang1:I,ang2:x}}function z0({px:n,py:r,cx:e,cy:t,rx:o,ry:i,largeArcFlag:a,sweepFlag:s}){let l=[];if(o===0||i===0)return[];let c=(n-e)/2,u=(r-t)/2;if(c===0&&u===0)return[];o=Math.abs(o),i=Math.abs(i);let p=Math.pow(c,2)/Math.pow(o,2)+Math.pow(u,2)/Math.pow(i,2);p>1&&(o*=Math.sqrt(p),i*=Math.sqrt(p));let d=NA(n,r,e,t,o,i,c,u,a,s),{ang1:h,ang2:f}=d,{centerx:m,centery:y}=d,g=Math.abs(f)/(Yp/4);Math.abs(1-g)<1e-7&&(g=1);let v=Math.max(Math.ceil(g),1);f/=v;for(let O=0;O<v;O++)l.push(IA(h,f)),h+=f;return l.map(O=>{let{x:P,y:S}=$p(O[0],o,i,m,y),{x:T,y:I}=$p(O[1],o,i,m,y),{x,y:_}=$p(O[2],o,i,m,y);return{x1:P,y1:S,x2:T,y2:I,x,y:_}})}var di=require("three");var We;(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"})(We||(We={}));var gt;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(gt||(gt={}));function Pe(n,r){if(!n)throw r||"Assertion Failed!"}var ve=function(){function n(){}return n.vertEq=function(r,e){return r.s===e.s&&r.t===e.t},n.vertLeq=function(r,e){return r.s<e.s||r.s===e.s&&r.t<=e.t},n.transLeq=function(r,e){return r.t<e.t||r.t===e.t&&r.s<=e.s},n.edgeGoesLeft=function(r){return n.vertLeq(r.Dst,r.Org)},n.edgeGoesRight=function(r){return n.vertLeq(r.Org,r.Dst)},n.vertL1dist=function(r,e){return Math.abs(r.s-e.s)+Math.abs(r.t-e.t)},n.edgeEval=function(r,e,t){Pe(n.vertLeq(r,e)&&n.vertLeq(e,t));var o=e.s-r.s,i=t.s-e.s;return o+i>0?o<i?e.t-r.t+(r.t-t.t)*(o/(o+i)):e.t-t.t+(t.t-r.t)*(i/(o+i)):0},n.edgeSign=function(r,e,t){Pe(n.vertLeq(r,e)&&n.vertLeq(e,t));var o=e.s-r.s,i=t.s-e.s;return o+i>0?(e.t-t.t)*o+(e.t-r.t)*i:0},n.transEval=function(r,e,t){Pe(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?o<i?e.s-r.s+(r.s-t.s)*(o/(o+i)):e.s-t.s+(t.s-r.s)*(i/(o+i)):0},n.transSign=function(r,e,t){Pe(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?(e.s-t.s)*o+(e.s-r.s)*i:0},n.vertCCW=function(r,e,t){return r.s*(e.t-t.t)+e.s*(t.t-r.t)+t.s*(r.t-e.t)>=0},n.interpolate=function(r,e,t,o){return r=r<0?0:r,t=t<0?0:t,r<=t?t===0?(e+o)/2:e+(o-e)*(r/(r+t)):o+(e-o)*(t/(r+t))},n.intersect=function(r,e,t,o,i){var a,s,l;n.vertLeq(r,e)||(l=r,r=e,e=l),n.vertLeq(t,o)||(l=t,t=o,o=l),n.vertLeq(r,t)||(l=r,r=t,t=l,l=e,e=o,o=l),n.vertLeq(t,e)?n.vertLeq(e,o)?(a=n.edgeEval(r,t,e),s=n.edgeEval(t,e,o),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,t.s,s,e.s)):(a=n.edgeSign(r,t,e),s=-n.edgeSign(r,o,e),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,t.s,s,o.s)):i.s=(t.s+e.s)/2,n.transLeq(r,e)||(l=r,r=e,e=l),n.transLeq(t,o)||(l=t,t=o,o=l),n.transLeq(r,t)||(l=r,r=t,t=l,l=e,e=o,o=l),n.transLeq(t,e)?n.transLeq(e,o)?(a=n.transEval(r,t,e),s=n.transEval(t,e,o),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,t.t,s,e.t)):(a=n.transSign(r,t,e),s=-n.transSign(r,o,e),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,t.t,s,o.t)):i.t=(t.t+e.t)/2},n}(),ul=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}(),bu=function(){function n(r){this.side=r,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(r){this.Sym.Lface=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(r){this.Sym.Org=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(r){this.Sym.Lnext=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(r){this.Onext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(r){this.Lnext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(r){this.Sym.Onext=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(r){this.Sym.Onext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(r){this.Sym.Lnext.Sym=r},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}(),G0=function(){function n(){var r=new Da,e=new ul,t=new bu(0),o=new bu(1);r.next=r.prev=r,r.anEdge=null,e.next=e.prev=e,t.next=t,t.Sym=o,o.next=o,o.Sym=t,this.vHead=r,this.fHead=e,this.eHead=t,this.eHeadSym=o}return n.prototype.makeEdge_=function(r){var e=new bu(0),t=new bu(1);r.Sym.side<r.side&&(r=r.Sym);var o=r.Sym.next;return t.next=o,o.Sym.next=e,e.next=r,r.Sym.next=t,e.Sym=t,e.Onext=e,e.Lnext=t,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,t.Sym=e,t.Onext=t,t.Lnext=e,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,e},n.prototype.splice_=function(r,e){var t=r.Onext,o=e.Onext;t.Sym.Lnext=e,o.Sym.Lnext=r,r.Onext=o,e.Onext=t},n.prototype.makeVertex_=function(r,e,t){var o=r;Pe(o,"Vertex can't be null!");var i=t.prev;o.prev=i,i.next=o,o.next=t,t.prev=o,o.anEdge=e;var a=e;do a.Org=o,a=a.Onext;while(a!==e)},n.prototype.makeFace_=function(r,e,t){var o=r;Pe(o,"Face can't be null");var i=t.prev;o.prev=i,i.next=o,o.next=t,t.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=t.inside;var a=e;do a.Lface=o,a=a.Lnext;while(a!==e)},n.prototype.killEdge_=function(r){r.Sym.side<r.side&&(r=r.Sym);var e=r.next,t=r.Sym.next;e.Sym.next=t,t.Sym.next=e},n.prototype.killVertex_=function(r,e){var t=r.anEdge,o=t;do o.Org=e,o=o.Onext;while(o!==t);var i=r.prev,a=r.next;a.prev=i,i.next=a},n.prototype.killFace_=function(r,e){var t=r.anEdge,o=t;do o.Lface=e,o=o.Lnext;while(o!==t);var i=r.prev,a=r.next;a.prev=i,i.next=a},n.prototype.makeEdge=function(){var r=new Da,e=new Da,t=new ul,o=this.makeEdge_(this.eHead);return this.makeVertex_(r,o,this.vHead),this.makeVertex_(e,o.Sym,this.vHead),this.makeFace_(t,o,this.fHead),o},n.prototype.splice=function(r,e){var t=!1,o=!1;if(r!==e){if(e.Org!==r.Org&&(o=!0,this.killVertex_(e.Org,r.Org)),e.Lface!==r.Lface&&(t=!0,this.killFace_(e.Lface,r.Lface)),this.splice_(e,r),!o){var i=new Da;this.makeVertex_(i,e,r.Org),r.Org.anEdge=r}if(!t){var a=new ul;this.makeFace_(a,e,r.Lface),r.Lface.anEdge=r}}},n.prototype.delete=function(r){var e=r.Sym,t=!1;if(r.Lface!==r.Rface&&(t=!0,this.killFace_(r.Lface,r.Rface)),r.Onext===r)this.killVertex_(r.Org,null);else if(r.Rface.anEdge=r.Oprev,r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev),!t){var o=new ul;this.makeFace_(o,r,r.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(r.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(r)},n.prototype.addEdgeVertex=function(r){var e=this.makeEdge_(r),t=e.Sym;this.splice_(e,r.Lnext),e.Org=r.Dst;var o=new Da;return this.makeVertex_(o,t,e.Org),e.Lface=t.Lface=r.Lface,e},n.prototype.splitEdge=function(r){var e=this.addEdgeVertex(r),t=e.Sym;return this.splice_(r.Sym,r.Sym.Oprev),this.splice_(r.Sym,t),r.Dst=t.Org,t.Dst.anEdge=t.Sym,t.Rface=r.Rface,t.winding=r.winding,t.Sym.winding=r.Sym.winding,t.idx=r.idx,t.Sym.idx=r.Sym.idx,t},n.prototype.connect=function(r,e){var t=!1,o=this.makeEdge_(r),i=o.Sym;if(e.Lface!==r.Lface&&(t=!0,this.killFace_(e.Lface,r.Lface)),this.splice_(o,r.Lnext),this.splice_(i,e),o.Org=r.Dst,i.Org=e.Org,o.Lface=i.Lface=r.Lface,r.Lface.anEdge=i,!t){var a=new ul;this.makeFace_(a,o,r.Lface)}return o},n.prototype.zapFace=function(r){var e=r.anEdge,t,o,i,a,s;o=e.Lnext;do t=o,o=t.Lnext,t.Lface=null,t.Rface===null&&(t.Onext===t?this.killVertex_(t.Org,null):(t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),i=t.Sym,i.Onext===i?this.killVertex_(i.Org,null):(i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t));while(t!=e);a=r.prev,s=r.next,s.prev=a,a.next=s},n.prototype.countFaceVerts_=function(r){var e=r.anEdge,t=0;do t++,e=e.Lnext;while(e!==r.anEdge);return t},n.prototype.mergeConvexFaces=function(r){var e,t,o,i,a,s,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(t=e.anEdge,a=t.Org;o=t.Lnext,i=t.Sym,i&&i.Lface&&i.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(i.Lface),s+l-2<=r&&ve.vertCCW(t.Lprev.Org,t.Org,i.Lnext.Lnext.Org)&&ve.vertCCW(i.Lprev.Org,i.Org,t.Lnext.Lnext.Org)&&(o=i.Lnext,this.delete(i),t=null,i=null)),!(t&&t.Lnext.Org===a);)t=o;return!0},n.prototype.check=function(){var r=this.fHead,e=this.vHead,t=this.eHead,o,i,a,s,l,c;for(i=r,i=r;(o=i.next)!==r;i=o){Pe(o.prev===i),l=o.anEdge;do Pe(l.Sym!==l),Pe(l.Sym.Sym===l),Pe(l.Lnext.Onext.Sym===l),Pe(l.Onext.Sym.Lnext===l),Pe(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(Pe(o.prev===i&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){Pe(a.prev===s),l=a.anEdge;do Pe(l.Sym!==l),Pe(l.Sym.Sym===l),Pe(l.Lnext.Onext.Sym===l),Pe(l.Onext.Sym.Lnext===l),Pe(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(Pe(a.prev===s&&a.anEdge===null),c=t,c=t;(l=c.next)!==t;c=l)Pe(l.Sym.next===c.Sym),Pe(l.Sym!==l),Pe(l.Sym.Sym===l),Pe(l.Org!==null),Pe(l.Dst!==null),Pe(l.Lnext.Onext.Sym===l),Pe(l.Onext.Sym.Lnext===l);Pe(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},n}(),j0=function(){function n(){this.handle=null}return n}(),F0=function(){function n(){this.key=null,this.node=0}return n}(),DA=function(){function n(r,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=r,this.nodes=[],this.handles=[];for(var t=0;t<r+1;t++)this.nodes[t]=new j0,this.handles[t]=new F0;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(r){var e=this.nodes,t=this.handles,o,i,a;for(o=e[r].handle;;){if(a=r<<1,a<this.size&&this.leq(t[e[a+1].handle].key,t[e[a].handle].key)&&++a,Pe(a<=this.max),i=e[a].handle,a>this.size||this.leq(t[o].key,t[i].key)){e[r].handle=o,t[o].node=r;break}e[r].handle=i,t[i].node=r,r=a}},n.prototype.floatUp_=function(r){var e=this.nodes,t=this.handles,o,i,a;for(o=e[r].handle;;){if(a=r>>1,i=e[a].handle,a===0||this.leq(t[i].key,t[o].key)){e[r].handle=o,t[o].node=r;break}e[r].handle=i,t[i].node=r,r=a}},n.prototype.init=function(){for(var r=this.size;r>=1;--r)this.floatDown_(r);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(r){var e,t;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 j0;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new F0}return this.freeList===0?t=e:(t=this.freeList,this.freeList=this.handles[t].node),this.nodes[e].handle=t,this.handles[t].node=e,this.handles[t].key=r,this.initialized&&this.floatUp_(e),t},n.prototype.extractMin=function(){var r=this.nodes,e=this.handles,t=r[1].handle,o=e[t].key;return this.size>0&&(r[1].handle=r[this.size].handle,e[r[1].handle].node=1,e[t].key=null,e[t].node=this.freeList,this.freeList=t,--this.size,this.size>0&&this.floatDown_(1)),o},n.prototype.delete=function(r){var e=this.nodes,t=this.handles,o;Pe(r>=1&&r<=this.max&&t[r].key!==null),o=t[r].node,e[o].handle=e[this.size].handle,t[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(t[e[o>>1].handle].key,t[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),t[r].key=null,t[r].node=this.freeList,this.freeList=r},n}(),Xp=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}(),U0=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),EA=function(){function n(r,e){this.frame=r,this.leq=e,this.head=new U0,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(r){return this.insertBefore(this.head,r)},n.prototype.search=function(r){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,r,e.key));return e},n.prototype.insertBefore=function(r,e){do r=r.prev;while(r.key!==null&&!this.leq(this.frame,r.key,e));var t=new U0;return t.key=e,t.next=r.next,r.next.prev=t,t.prev=r,r.next=t,t},n.prototype.delete=function(r){r.next.prev=r.prev,r.prev.next=r.next},n}(),_A=function(){function n(){}return n.regionBelow=function(r){return r.nodeUp.prev.key},n.regionAbove=function(r){return r.nodeUp.next.key},n.debugEvent=function(r){},n.addWinding=function(r,e){r.winding+=e.winding,r.Sym.winding+=e.Sym.winding},n.edgeLeq=function(r,e,t){var o=r.event,i=e.eUp,a=t.eUp;if(i.Dst===o)return a.Dst===o?ve.vertLeq(i.Org,a.Org)?ve.edgeSign(a.Dst,i.Org,a.Org)<=0:ve.edgeSign(i.Dst,a.Org,i.Org)>=0:ve.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return ve.edgeSign(i.Dst,o,i.Org)>=0;var s=ve.edgeEval(i.Dst,o,i.Org),l=ve.edgeEval(a.Dst,o,a.Org);return s>=l},n.deleteRegion=function(r,e){e.fixUpperEdge&&Pe(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},n.fixUpperEdge=function(r,e,t){Pe(e.fixUpperEdge),r.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=t,t.activeRegion=e},n.topLeftRegion=function(r,e){var t=e.eUp.Org,o;do e=n.regionAbove(e);while(e.eUp.Org===t);if(e.fixUpperEdge){if(o=r.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;n.fixUpperEdge(r,e,o),e=n.regionAbove(e)}return e},n.topRightRegion=function(r){var e=r.eUp.Dst;do r=n.regionAbove(r);while(r.eUp.Dst===e);return r},n.addRegionBelow=function(r,e,t){var o=new Xp;return o.eUp=t,o.nodeUp=r.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,t.activeRegion=o,o},n.isWindingInside=function(r,e){switch(r.windingRule){case We.ODD:return(e&1)!==0;case We.NONZERO:return e!==0;case We.POSITIVE:return e>0;case We.NEGATIVE:return e<0;case We.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(r,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(r,e.windingNumber)},n.finishRegion=function(r,e){var t=e.eUp,o=t.Lface;o.inside=e.inside,o.anEdge=t,n.deleteRegion(r,e)},n.finishLeftRegions=function(r,e,t){for(var o,i=null,a=e,s=e.eUp;a!==t;){if(a.fixUpperEdge=!1,i=n.regionBelow(a),o=i.eUp,o.Org!=s.Org){if(!i.fixUpperEdge){n.finishRegion(r,a);break}o=r.mesh.connect(s.Lprev,o.Sym),n.fixUpperEdge(r,i,o)}s.Onext!==o&&(r.mesh.splice(o.Oprev,o),r.mesh.splice(s,o)),n.finishRegion(r,a),s=i.eUp,a=i}return s},n.addRightEdges=function(r,e,t,o,i,a){var s,l,c,u,p=!0;c=t;do Pe(ve.vertLeq(c.Org,c.Dst)),n.addRegionBelow(r,e,c.Sym),c=c.Onext;while(c!==o);for(i===null&&(i=n.regionBelow(e).eUp.Rprev),l=e,u=i;s=n.regionBelow(l),c=s.eUp.Sym,c.Org===u.Org;)c.Onext!==u&&(r.mesh.splice(c.Oprev,c),r.mesh.splice(u.Oprev,c)),s.windingNumber=l.windingNumber-c.winding,s.inside=n.isWindingInside(r,s.windingNumber),l.dirty=!0,!p&&n.checkForRightSplice(r,l)&&(n.addWinding(c,u),n.deleteRegion(r,l),r.mesh.delete(u)),p=!1,l=s,u=c;l.dirty=!0,Pe(l.windingNumber-c.winding===s.windingNumber),a&&n.walkDirtyRegions(r,l)},n.spliceMergeVertices=function(r,e,t){r.mesh.splice(e,t)},n.vertexWeights=function(r,e,t){var o=ve.vertL1dist(e,r),i=ve.vertL1dist(t,r),a=.5*i/(o+i),s=.5*o/(o+i);r.coords[0]+=a*e.coords[0]+s*t.coords[0],r.coords[1]+=a*e.coords[1]+s*t.coords[1],r.coords[2]+=a*e.coords[2]+s*t.coords[2]},n.getIntersectData=function(r,e,t,o,i,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,t,o),n.vertexWeights(e,i,a)},n.checkForRightSplice=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp;if(ve.vertLeq(o.Org,i.Org)){if(ve.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;ve.vertEq(o.Org,i.Org)?o.Org!==i.Org&&(r.pq.delete(o.Org.pqHandle),n.spliceMergeVertices(r,i.Oprev,o)):(r.mesh.splitEdge(i.Sym),r.mesh.splice(o,i.Oprev),e.dirty=t.dirty=!0)}else{if(ve.edgeSign(o.Dst,i.Org,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,r.mesh.splitEdge(o.Sym),r.mesh.splice(i.Oprev,o)}return!0},n.checkForLeftSplice=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp,a;if(Pe(!ve.vertEq(o.Dst,i.Dst)),ve.vertLeq(o.Dst,i.Dst)){if(ve.edgeSign(o.Dst,i.Dst,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,a=r.mesh.splitEdge(o),r.mesh.splice(i.Sym,a),a.Lface.inside=e.inside}else{if(ve.edgeSign(i.Dst,o.Dst,i.Org)>0)return!1;e.dirty=t.dirty=!0,a=r.mesh.splitEdge(i),r.mesh.splice(o.Lnext,i.Sym),a.Rface.inside=e.inside}return!0},n.checkForIntersect=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp,a=o.Org,s=i.Org,l=o.Dst,c=i.Dst,u,p,d=new Da,h,f;if(Pe(!ve.vertEq(c,l)),Pe(ve.edgeSign(l,r.event,a)<=0),Pe(ve.edgeSign(c,r.event,s)>=0),Pe(a!==r.event&&s!==r.event),Pe(!e.fixUpperEdge&&!t.fixUpperEdge),a===s||(u=Math.min(a.t,l.t),p=Math.max(s.t,c.t),u>p))return!1;if(ve.vertLeq(a,s)){if(ve.edgeSign(c,a,s)>0)return!1}else if(ve.edgeSign(l,s,a)<0)return!1;return n.debugEvent(r),ve.intersect(l,a,c,s,d),Pe(Math.min(a.t,l.t)<=d.t),Pe(d.t<=Math.max(s.t,c.t)),Pe(Math.min(c.s,l.s)<=d.s),Pe(d.s<=Math.max(s.s,a.s)),ve.vertLeq(d,r.event)&&(d.s=r.event.s,d.t=r.event.t),h=ve.vertLeq(a,s)?a:s,ve.vertLeq(h,d)&&(d.s=h.s,d.t=h.t),ve.vertEq(d,a)||ve.vertEq(d,s)?(n.checkForRightSplice(r,e),!1):!ve.vertEq(l,r.event)&&ve.edgeSign(l,r.event,d)>=0||!ve.vertEq(c,r.event)&&ve.edgeSign(c,r.event,d)<=0?c===r.event?(r.mesh.splitEdge(o.Sym),r.mesh.splice(i.Sym,o),e=n.topLeftRegion(r,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(r,n.regionBelow(e),t),n.addRightEdges(r,e,o.Oprev,o,o,!0),!0):l===r.event?(r.mesh.splitEdge(i.Sym),r.mesh.splice(o.Lnext,i.Oprev),t=e,e=n.topRightRegion(e),f=n.regionBelow(e).eUp.Rprev,t.eUp=i.Oprev,i=n.finishLeftRegions(r,t,null),n.addRightEdges(r,e,i.Onext,o.Rprev,f,!0),!0):(ve.edgeSign(l,r.event,d)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,r.mesh.splitEdge(o.Sym),o.Org.s=r.event.s,o.Org.t=r.event.t),ve.edgeSign(c,r.event,d)<=0&&(e.dirty=t.dirty=!0,r.mesh.splitEdge(i.Sym),i.Org.s=r.event.s,i.Org.t=r.event.t),!1):(r.mesh.splitEdge(o.Sym),r.mesh.splitEdge(i.Sym),r.mesh.splice(i.Oprev,o),o.Org.s=d.s,o.Org.t=d.t,o.Org.pqHandle=r.pq.insert(o.Org),n.getIntersectData(r,o.Org,a,l,s,c),n.regionAbove(e).dirty=e.dirty=t.dirty=!0,!1)},n.walkDirtyRegions=function(r,e){for(var t=n.regionBelow(e),o,i;;){for(;t.dirty;)e=t,t=n.regionBelow(t);if(!e.dirty&&(t=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,i=t.eUp,o.Dst!==i.Dst&&n.checkForLeftSplice(r,e)&&(t.fixUpperEdge?(n.deleteRegion(r,t),r.mesh.delete(i),t=n.regionBelow(e),i=t.eUp):e.fixUpperEdge&&(n.deleteRegion(r,e),r.mesh.delete(o),e=n.regionAbove(t),o=e.eUp)),o.Org!==i.Org)if(o.Dst!==i.Dst&&!e.fixUpperEdge&&!t.fixUpperEdge&&(o.Dst===r.event||i.Dst===r.event)){if(n.checkForIntersect(r,e))return}else n.checkForRightSplice(r,e);o.Org===i.Org&&o.Dst===i.Dst&&(n.addWinding(i,o),n.deleteRegion(r,e),r.mesh.delete(o),e=n.regionAbove(t))}},n.connectRightVertex=function(r,e,t){var o,i=t.Onext,a=n.regionBelow(e),s=e.eUp,l=a.eUp,c=!1;if(s.Dst!==l.Dst&&n.checkForIntersect(r,e),ve.vertEq(s.Org,r.event)&&(r.mesh.splice(i.Oprev,s),e=n.topLeftRegion(r,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(r,n.regionBelow(e),a),c=!0),ve.vertEq(l.Org,r.event)&&(r.mesh.splice(t,l.Oprev),t=n.finishLeftRegions(r,a,null),c=!0),c){n.addRightEdges(r,e,t.Onext,i,i,!0);return}ve.vertLeq(l.Org,s.Org)?o=l.Oprev:o=s,o=r.mesh.connect(t.Lprev,o),n.addRightEdges(r,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(r,e)},n.connectLeftDegenerate=function(r,e,t){var o,i,a,s,l;if(o=e.eUp,ve.vertEq(o.Org,t)){Pe(!1),n.spliceMergeVertices(r,o,t.anEdge);return}if(!ve.vertEq(o.Dst,t)){r.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(r.mesh.delete(o.Onext),e.fixUpperEdge=!1),r.mesh.splice(t.anEdge,o),n.sweepEvent(r,t);return}Pe(!1),e=n.topRightRegion(e),l=n.regionBelow(e),a=l.eUp.Sym,i=s=a.Onext,l.fixUpperEdge&&(Pe(i!==a),n.deleteRegion(r,l),r.mesh.delete(a),a=i.Oprev),r.mesh.splice(t.anEdge,a),ve.edgeGoesLeft(i)||(i=null),n.addRightEdges(r,e,a.Onext,s,i,!0)},n.connectLeftVertex=function(r,e){var t,o,i,a,s,l,c=new Xp;if(c.eUp=e.anEdge.Sym,t=r.dict.search(c).key,o=n.regionBelow(t),!!o){if(a=t.eUp,s=o.eUp,ve.edgeSign(a.Dst,e,a.Org)===0){n.connectLeftDegenerate(r,t,e);return}if(i=ve.vertLeq(s.Dst,a.Dst)?t:o,t.inside||i.fixUpperEdge){if(i===t)l=r.mesh.connect(e.anEdge.Sym,a.Lnext);else{var u=r.mesh.connect(s.Dnext,e.anEdge);l=u.Sym}i.fixUpperEdge?n.fixUpperEdge(r,i,l):n.computeWinding(r,n.addRegionBelow(r,t,l)),n.sweepEvent(r,e)}else n.addRightEdges(r,t,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(r,e){r.event=e,n.debugEvent(r);for(var t=e.anEdge;t.activeRegion===null;)if(t=t.Onext,t===e.anEdge){n.connectLeftVertex(r,e);return}var o=n.topLeftRegion(r,t.activeRegion);Pe(o!==null);var i=n.regionBelow(o),a=i.eUp,s=n.finishLeftRegions(r,i,null);s.Onext===a?n.connectRightVertex(r,o,s):n.addRightEdges(r,o,s.Onext,a,a,!0)},n.addSentinel=function(r,e,t,o){var i=new Xp,a=r.mesh.makeEdge();a.Org.s=t,a.Org.t=o,a.Dst.s=e,a.Dst.t=o,r.event=a.Dst,i.eUp=a,i.windingNumber=0,i.inside=!1,i.fixUpperEdge=!1,i.sentinel=!0,i.dirty=!1,i.nodeUp=r.dict.insert(i)},n.initEdgeDict=function(r){r.dict=new EA(r,n.edgeLeq);var e=r.bmax[0]-r.bmin[0],t=r.bmax[1]-r.bmin[1],o=r.bmin[0]-e,i=r.bmax[0]+e,a=r.bmin[1]-t,s=r.bmax[1]+t;n.addSentinel(r,o,i,a),n.addSentinel(r,o,i,s)},n.doneEdgeDict=function(r){for(var e,t=0;(e=r.dict.min().key)!==null;)e.sentinel||(Pe(e.fixUpperEdge),Pe(++t===1)),Pe(e.windingNumber===0),n.deleteRegion(r,e)},n.removeDegenerateEdges=function(r){var e,t,o,i=r.mesh.eHead;for(e=i.next;e!==i;e=t)t=e.next,o=e.Lnext,ve.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(r,o,e),r.mesh.delete(e),e=o,o=e.Lnext),o.Lnext===e&&(o!==e&&((o===t||o===t.Sym)&&(t=t.next),r.mesh.delete(o)),(e===t||e===t.Sym)&&(t=t.next),r.mesh.delete(e))},n.initPriorityQ=function(r){var e,t,o,i=0;for(o=r.mesh.vHead,t=o.next;t!==o;t=t.next)i++;for(i+=8,e=r.pq=new DA(i,ve.vertLeq),o=r.mesh.vHead,t=o.next;t!==o;t=t.next)t.pqHandle=e.insert(t);return t!==o?!1:(e.init(),!0)},n.donePriorityQ=function(r){r.pq=null},n.removeDegenerateFaces=function(r,e){var t,o,i;for(t=e.fHead.next;t!==e.fHead;t=o)o=t.next,i=t.anEdge,Pe(i.Lnext!==i),i.Lnext.Lnext===i&&(n.addWinding(i.Onext,i),r.mesh.delete(i));return!0},n.computeInterior=function(r,e){e===void 0&&(e=!0);var t,o;if(n.removeDegenerateEdges(r),!n.initPriorityQ(r))return!1;for(n.initEdgeDict(r);(t=r.pq.extractMin())!==null;){for(;o=r.pq.min(),!(o===null||!ve.vertEq(o,t));)o=r.pq.extractMin(),n.spliceMergeVertices(r,t.anEdge,o.anEdge);n.sweepEvent(r,t)}return r.event=r.dict.min().key.eUp.Org,n.debugEvent(r),n.doneEdgeDict(r),n.donePriorityQ(r),n.removeDegenerateFaces(r,r.mesh)?(e&&r.mesh.check(),!0):!1},n}(),BA=function(){function n(){this.mesh=new G0,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=We.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(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]},n.prototype.normalize_=function(r){var e=r[0]*r[0]+r[1]*r[1]+r[2]*r[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),r[0]/=e,r[1]/=e,r[2]/=e},n.prototype.longAxis_=function(r){var e=0;return Math.abs(r[1])>Math.abs(r[0])&&(e=1),Math.abs(r[2])>Math.abs(r[e])&&(e=2),e},n.prototype.computeNormal_=function(r){var e,t,o,i,a,s,l=[0,0,0],c=[0,0,0],u=[0,0,0],p=[0,0,0],d=[0,0,0],h=[null,null,null],f=[null,null,null],m=this.mesh.vHead;e=m.next;for(var y=0;y<3;++y)i=e.coords[y],c[y]=i,f[y]=e,l[y]=i,h[y]=e;for(e=m.next;e!==m;e=e.next)for(var g=0;g<3;++g)i=e.coords[g],i<c[g]&&(c[g]=i,f[g]=e),i>l[g]&&(l[g]=i,h[g]=e);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){r[0]=0,r[1]=0,r[2]=1;return}for(s=0,t=f[v],o=h[v],u[0]=t.coords[0]-o.coords[0],u[1]=t.coords[1]-o.coords[1],u[2]=t.coords[2]-o.coords[2],e=m.next;e!==m;e=e.next)p[0]=e.coords[0]-o.coords[0],p[1]=e.coords[1]-o.coords[1],p[2]=e.coords[2]-o.coords[2],d[0]=u[1]*p[2]-u[2]*p[1],d[1]=u[2]*p[0]-u[0]*p[2],d[2]=u[0]*p[1]-u[1]*p[0],a=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],a>s&&(s=a,r[0]=d[0],r[1]=d[1],r[2]=d[2]);s<=0&&(r[0]=r[1]=r[2]=0,r[this.longAxis_(u)]=1)},n.prototype.checkOrientation_=function(){for(var r=this.mesh.fHead,e,t=this.mesh.vHead,o,i=0,a=r.next;a!==r;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=t.next;e!==t;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 r=this.mesh.vHead,e=[0,0,0],t,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),t=this.sUnit,o=this.tUnit;var a=this.longAxis_(e);t[a]=0,t[(a+1)%3]=1,t[(a+2)%3]=0,o[a]=0,o[(a+1)%3]=0,o[(a+2)%3]=e[a]>0?1:-1;for(var s=r.next;s!==r;s=s.next)s.s=this.dot_(s.coords,t),s.t=this.dot_(s.coords,o);i&&this.checkOrientation_();for(var l=!0,c=r.next;c!==r;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},n.prototype.addWinding_=function(r,e){r.winding+=e.winding,r.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(r,e){var t,o;if(t=e.anEdge,!(t.Lnext!==t&&t.Lnext.Lnext!==t))throw"Mono region invalid";for(;ve.vertLeq(t.Dst,t.Org);t=t.Lprev);for(;ve.vertLeq(t.Org,t.Dst);t=t.Lnext);o=t.Lprev;for(var i=void 0;t.Lnext!==o;)if(ve.vertLeq(t.Dst,o.Org)){for(;o.Lnext!==t&&(ve.edgeGoesLeft(o.Lnext)||ve.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)i=r.connect(o.Lnext,o),o=i.Sym;o=o.Lprev}else{for(;o.Lnext!==t&&(ve.edgeGoesRight(t.Lprev)||ve.edgeSign(t.Dst,t.Org,t.Lprev.Org)>=0);)i=r.connect(t,t.Lprev),t=i.Sym;t=t.Lnext}if(o.Lnext===t)throw"Mono region invalid";for(;o.Lnext.Lnext!==t;)i=r.connect(o.Lnext,o),o=i.Sym;return!0},n.prototype.tessellateInterior_=function(r){for(var e,t=r.fHead.next;t!==r.fHead;t=e)if(e=t.next,t.inside&&!this.tessellateMonoRegion_(r,t))return!1;return!0},n.prototype.discardExterior_=function(r){for(var e,t=r.fHead.next;t!==r.fHead;t=e)e=t.next,t.inside||r.zapFace(t)},n.prototype.setWindingNumber_=function(r,e,t){for(var o,i=r.eHead.next;i!==r.eHead;i=o)o=i.next,i.Rface.inside!==i.Lface.inside?i.winding=i.Lface.inside?e:-e:t?r.delete(i):i.winding=0},n.prototype.getNeighbourFace_=function(r){return!r.Rface||!r.Rface.inside?-1:r.Rface.n},n.prototype.outputPolymesh_=function(r,e,t,o){var i,a=0,s=0,l;t>3&&r.mergeConvexFaces(t);for(var c=r.vHead.next;c!==r.vHead;c=c.next)c.n=-1;for(var u=r.fHead.next;u!==r.fHead;u=u.next)if(u.n=-1,!!u.inside){i=u.anEdge,l=0;do{var c=i.Org;c.n===-1&&(c.n=s,s++),l++,i=i.Lnext}while(i!==u.anEdge);if(l>t)throw"Face vertex greater that support polygon";u.n=a,++a}this.elementCount=a,e===gt.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*t,this.vertexCount=s,this.vertices=[],this.vertices.length=s*o,this.vertexIndices=[],this.vertexIndices.length=s;for(var c=r.vHead.next;c!==r.vHead;c=c.next)if(c.n!==-1){var p=c.n*o;this.vertices[p+0]=c.coords[0],this.vertices[p+1]=c.coords[1],o>2&&(this.vertices[p+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var d=0,u=r.fHead.next;u!==r.fHead;u=u.next)if(!!u.inside){i=u.anEdge,l=0;do{var c=i.Org;this.elements[d++]=c.n,l++,i=i.Lnext}while(i!==u.anEdge);for(var h=l;h<t;++h)this.elements[d++]=-1;if(e===gt.CONNECTED_POLYGONS){i=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==u.anEdge);for(var f=l;f<t;++f)this.elements[d++]=-1}}},n.prototype.outputContours_=function(r,e){var t,o,i=0,a=0;this.vertexCount=0,this.elementCount=0;for(var s=r.fHead.next;s!==r.fHead;s=s.next)if(!!s.inside){o=t=s.anEdge;do this.vertexCount++,t=t.Lnext;while(t!==o);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,u=0;i=0;for(var s=r.fHead.next;s!==r.fHead;s=s.next)if(!!s.inside){a=0,o=t=s.anEdge;do this.vertices[l++]=t.Org.coords[0],this.vertices[l++]=t.Org.coords[1],e>2&&(this.vertices[l++]=t.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(t):t.Org.idx,a++,t=t.Lnext;while(t!==o);this.elements[u++]=i,this.elements[u++]=a,i+=a}},n.prototype.addContour=function(r,e){this.mesh===null&&(this.mesh=new G0),r<2&&(r=2),r>3&&(r=3);for(var t=null,o=0;o<e.length;o+=r)t===null?(t=this.mesh.makeEdge(),this.mesh.splice(t,t.Sym)):(this.mesh.splitEdge(t),t=t.Lnext),t.Org.coords[0]=e[o+0],t.Org.coords[1]=e[o+1],r>2?t.Org.coords[2]=e[o+2]:t.Org.coords[2]=0,t.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(t),t.winding=1,t.Sym.winding=-1},n.prototype.tesselate=function(r,e,t,o,i,a){if(r===void 0&&(r=We.ODD),e===void 0&&(e=gt.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=r,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),_A.computeInterior(this,a);var s=this.mesh;return e===gt.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===gt.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,t,o),!0},n}();function ro(n){var r=n.windingRule,e=r===void 0?We.ODD:r,t=n.elementType,o=t===void 0?gt.POLYGONS:t,i=n.polySize,a=i===void 0?3:i,s=n.vertexSize,l=s===void 0?2:s,c=n.normal,u=c===void 0?[0,0,1]:c,p=n.contours,d=p===void 0?[]:p,h=n.strict,f=h===void 0?!0:h,m=n.debug,y=m===void 0?!1:m;if(!d&&f)throw new Error("Contours can't be empty");if(!!d){var g=new BA;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var v=0;v<d.length;v++)g.addContour(l||2,d[v]);return g.tesselate(e,o,a,l,u,f),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var uk=We.ODD,dk=We.NONZERO,pk=We.POSITIVE,fk=We.NEGATIVE,hk=We.ABS_GEQ_TWO,mk=gt.POLYGONS,yk=gt.CONNECTED_POLYGONS,gk=gt.BOUNDARY_CONTOURS;var oo=require("three");var vu=class{constructor(r=256,e=!1){this.capacity=r,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${r}`);let t=r*vu.eSize;this.buffer=new ArrayBuffer(t);let o=Float32Array.BYTES_PER_ELEMENT,i=0;this.positions=new Float32Array(this.buffer,i*o,3*r),i+=3*r,this.normals=new Float32Array(this.buffer,i*o,3*r),i+=3*r,this.uvs=new Float32Array(this.buffer,i*o,2*r)}realloc(r,e=!1){if(r<this.size)throw Error("cannot shrink buffer");if(r<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${r}`);let t=r*vu.eSize,o=new ArrayBuffer(t),i=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*i,3*r);a+=3*r;let l=new Float32Array(o,a*i,3*r);a+=3*r;let c=new Float32Array(o,a*i,2*r);e?(s.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),c.set(this.uvs.subarray(0,this.size*2))):(s.set(this.positions),l.set(this.normals),c.set(this.uvs)),this.buffer=o,this.positions=s,this.normals=l,this.uvs=c,this.capacity=r}get(r=1){let e=this.size+r;if(e>this.capacity){let o=this.capacity;for(;e>o;)o*=2;this.realloc(o)}let t=this.size;return this.size=e,t}reserve(r){let e=this.size+r;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},dl=vu;dl.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var q0=Ei(W0()),pl={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},ef={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},tf={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},Jp=(n,r)=>([e,t])=>(t<e&&(t+=r),(n>=e?n:n+r)<=t),Dn=class extends oo.BufferGeometry{constructor(e,t,o=0,i=12,a=3,s=We.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._curveSegments=i,this._bevelSegmentsInput=a;let c=this._shape.extractShapePointsToFlatArray([],i),u=this._shape.shapeHoles.map(A=>{let N=A.extractShapePointsToFlatArray([],i),E=[];for(let B=N.length-1;B>=1;B-=2){let V=N[B-1],j=N[B-0];E.push(V,j)}return E}),p=[],d=[];for(let A=0;A<c.length;A+=2)d.push([c[A],c[A+1]]);p.push(d);for(let A=0;A<u.length;A++){let N=u[A],E=[];for(let B=0;B<N.length;B+=2)E.push([N[B],N[B+1]]);p.push(E)}let h;e.isText?h=new oo.Box2().setFromPoints(e.points.map(N=>N.position)).getSize(new oo.Vector2).length()*.1:p[0].length===0?h=o:h=(0,q0.default)(p).distance,o<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(o,h,t/2),this._bevelSegments=Math.floor(a));let f;try{f=ro({windingRule:s,elementType:gt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{f=pl}let m;try{m=ro({windingRule:We.ODD,elementType:gt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{m=ef}if(!f)throw new Error("error generating geometry");let y=f.elementCount;if(m){f.elementCount+=m.elementCount;for(let A=0;A<m.elements.length;A++){let N=m.elements[A],E=A%2===0?f.vertexCount:0;f.elements.push(N+E)}for(let A=0;A<m.vertexIndices.length;A++){let N=m.vertexIndices[A],E=f.vertexCount;f.vertexIndices.push(N+E)}for(let A=0;A<m.vertices.length;A++){let N=m.vertices[A];f.vertices.push(N)}}let g=1/0,v=-1/0,O=1/0,P=-1/0;for(let A=0,N=f.vertexCount;A<N;A++){let E=A*2,B=f.vertices[E+0],V=f.vertices[E+1];B<g&&(g=B),B>v&&(v=B),V<O&&(O=V),V>P&&(P=V)}this._minX=g,this._minY=O,this._width=v-g,this._height=P-O,this._buffer=new dl(this._computeBufferEstimatedSize(f));let S=[],T=[];for(let A=f.elementCount-1;A>=0;A--){let N=A>=y,E=A*2,B=f.elements[E+0],V=f.elements[E+1],j=B+V,R={start:B,count:V,normals:[],continuous:[],concave:[]},W=B,F=j-1,k=B+1,H=this._shape.roundedCurves.length;do{let te=W-B,Y=f.vertices[F*2+0],ee=f.vertices[F*2+1],K=f.vertices[W*2+0],q=f.vertices[W*2+1],ue=f.vertices[k*2+0],le=f.vertices[k*2+1],ne=K-Y,ce=q-ee,ae=Math.sqrt(ne*ne+ce*ce);ne/=ae,ce/=ae;let me=K-ue,fe=q-le,he=Math.sqrt(me*me+fe*fe);me/=he,fe/=he,R.normals[te*2+0]=-fe,R.normals[te*2+1]=me,R.concave[te]=ne*fe-ce*me>0;let xe=f.vertexIndices[W];if(Array.isArray(xe))R.continuous[te]=!1;else{let[ye,C]=this._shape.getCurveIndexFromVertexId(xe-1,!0);if(C>0&&C<1)R.continuous[te]=!0;else{let ie=C===1?ye+1:ye-1;ie=(ie+H)%H;let Re=C===1?0:1,Fe=this._shape.roundedCurves[ye].getTangent(C),Ve=this._shape.roundedCurves[ie].getTangent(Re);R.continuous[te]=Fe.dot(Ve)>.95}}N&&(R.normals[te*2+0]*=-1,R.normals[te*2+1]*=-1),[F,W,k]=[W,k,k+1],k>=j&&(k-=V)}while(k!==B+1);let $=[];$.push({bevelI:0,angle:0,size:0,boundary:{vertices:f.vertices.slice(B*2,j*2),vertexCount:V,vertexIndices:new Array(V).fill(!0).map((te,Y)=>[Y,Y]),elements:[0,V],elementCount:1,mesh:null},reverseMap:[],insetPoints:f.vertices.slice(B*2,j*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,K=[],q=[],ue=[],le=[],ne=0;for(let ae=0;ae<V;ae++){let me=ae*2,fe=(ae-1+V)%V*2,he=f.vertices[R.start*2+me+0],xe=f.vertices[R.start*2+me+1],ye=-R.normals[fe+0]*ee,C=-R.normals[fe+1]*ee,ie=-R.normals[me+0]*ee,Re=-R.normals[me+1]*ee;if(R.concave[ae]||!R.concave[ae]&&N){let Fe=Math.atan2(C,ye),Ve=Math.atan2(Re,ie);Ve>Fe&&(Ve-=Math.PI*2);let Ce=Ve-Fe;if(R.continuous[ae]||N){let _t=Fe+Ce/2,Ee=Math.cos(_t)*ee,Nt=Math.sin(_t)*ee;K[2*ne+0]=he+Ee*(N?-1:1),K[2*ne+1]=xe+Nt*(N?-1:1),le[ne]=ae,ne++}else{let _t=Math.max(1,Math.floor(i/4*Math.abs(Ce)/Math.PI));for(let Ee=0;Ee<=_t;Ee++){let Nt=Fe+Ce*(Ee/_t),Bt=Math.cos(Nt)*ee,$n=Math.sin(Nt)*ee;K[2*ne+0]=he+Bt,K[2*ne+1]=xe+$n,le[ne]=ae,ne++}}}else K[2*ne+0]=he+ye,K[2*ne+1]=xe+C,le[ne]=ae,q[ae]=ne,ne++,K[2*ne+0]=he,K[2*ne+1]=xe,le[ne]=ae,ne++,K[2*ne+0]=he+ie,K[2*ne+1]=xe+Re,le[ne]=ae,ue[ae]=ne,ne++}let ce=ro({windingRule:We.POSITIVE,elementType:gt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[K],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+=V);for(let xe=me;xe<he;xe++){let ye=xe%V,C=(xe+1)%V;if(!R.continuous[ye]||!R.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:K})}let Z=(te,Y,ee)=>{let K=0,q=te.boundary.vertexIndices.length;for(;K<q&&ee(te.boundary.vertexIndices[Y]);)Y=(Y+1)%q,K++;return K},X=S.length;for(let te=1;te<$.length;te++){let Y=$[te-1],ee=$[te],K=Y.boundary.vertexIndices.length,q=ee.boundary.vertexIndices.length;if(!K||!q)break;let ue=R.concave.length,le=0,ne=Jp(le,V);for(;!Y.boundary.vertexIndices.filter(ne).length||!ee.boundary.vertexIndices.filter(ne).length;)le++,ne=Jp(le,V);let ce=Y.boundary.vertexIndices.findIndex(ne),ae=ee.boundary.vertexIndices.findIndex(ne);do ce=(ce+1)%K;while(ne(Y.boundary.vertexIndices[ce]));do ae=(ae+1)%q;while(ne(ee.boundary.vertexIndices[ae]));le=(le+1)%V;let me=le,fe=0,he=this._buildBevelVert(R,Y,(ce-1+K)%K,void 0,fe),xe=this._buildBevelVert(R,ee,(ae-1+q)%q,void 0,fe),ye=he,C=xe,ie,Re,Fe=!1;do{fe=(le||ue)/ue,ne=Jp(le,V);let Ve=Z(Y,ce,ne),Ce=Z(ee,ae,ne),_t=Fe;if(Fe=!1,Ve&&!Ce){for(let Ee=0;Ee<Ve;Ee++)ie=this._buildBevelVert(R,Y,(ce+Ee)%K,Ee/(Ve-1),fe),S.push(ye.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,ye.bottomN,C.bottomN),ye=ie;Fe=!0}else if(!Ve&&Ce)for(let Ee=0;Ee<Ce;Ee++)Re=this._buildBevelVert(R,ee,(ae+Ee)%q,Ee/(Ce-1),fe),S.push(C.topN,ye.topP,Re.topP),l===!1&&S.push(ye.bottomP,C.bottomN,Re.bottomP),C=Re;else if(Ve&&Ce)if(ie=this._buildBevelVert(R,Y,ce,0,fe),Re=this._buildBevelVert(R,ee,ae,0,fe),_t?(S.push(ye.topN,Re.topP,C.topN),S.push(ye.topN,ie.topP,Re.topP),l===!1&&(S.push(Re.bottomP,ye.bottomN,C.bottomN),S.push(Re.bottomP,ie.bottomP,ye.bottomN))):(S.push(C.topN,ye.topN,ie.topP),S.push(C.topN,ie.topP,Re.topP),l===!1&&(S.push(ie.bottomP,ye.bottomN,C.bottomN),S.push(ie.bottomP,C.bottomN,Re.bottomP))),ye=ie,C=Re,Ve===Ce)for(let Ee=1;Ee<Ve;Ee++)ie=this._buildBevelVert(R,Y,(ce+Ee)%K,Ee/(Ve-1),fe),Re=this._buildBevelVert(R,ee,(ae+Ee)%q,Ee/(Ce-1),fe),S.push(ye.topN,ie.topP,C.topN),S.push(C.topN,ie.topP,Re.topP),l===!1&&(S.push(ie.bottomP,ye.bottomN,C.bottomN),S.push(ie.bottomP,C.bottomN,Re.bottomP)),ye=ie,C=Re;else if(Ve>Ce){let Ee=Ve/Ce,Nt=0;for(let Bt=1;Bt<Ve;Bt++)ie=this._buildBevelVert(R,Y,(ce+Bt)%K,Bt/(Ve-1),fe),S.push(ye.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,ye.bottomN,C.bottomN),ye=ie,Bt>(Nt+1)*Ee&&(Nt++,Re=this._buildBevelVert(R,ee,(ae+Nt)%q,Nt/(Ce-1),fe),S.push(C.topN,ie.topP,Re.topP),l===!1&&S.push(ie.bottomP,C.bottomN,Re.bottomP),C=Re)}else{let Ee=Ce/Ve,Nt=0;for(let Bt=1;Bt<Ce;Bt++)Re=this._buildBevelVert(R,ee,(ae+Bt)%q,Bt/(Ce-1),fe),S.push(C.topN,ie.topP,Re.topP),l===!1&&S.push(ie.bottomP,C.bottomN,Re.bottomP),C=Re,Bt>(Nt+1)*Ee&&(Nt++,ie=this._buildBevelVert(R,Y,(ce+Nt)%K,Nt/(Ve-1),fe),S.push(ye.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,ye.bottomN,C.bottomN),ye=ie)}ce=(ce+Ve)%K,ae=(ae+Ce)%q,le=(le+1)%ue}while(le!==me)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall($,R,S),N){let te=[];for(let Y=S.length-1;Y>=X+2;Y-=3){let ee=S[Y-2],K=S[Y-1],q=S[Y-0];te.push(q,K,ee)}S.splice(X,S.length-X,...te)}if(N){let te=[];for(let Y=$[$.length-1].boundary.vertices.length-1;Y>=1;Y-=2){let ee=$[$.length-1].boundary.vertices[Y-1],K=$[$.length-1].boundary.vertices[Y-0];te.push(ee,K)}T.push(te)}if(!N){let te=$[$.length-1],Y;try{Y=ro({windingRule:$.length>1?We.POSITIVE:We.ODD,elementType:gt.POLYGONS,vertexSize:2,strict:!0,contours:[te.insetPoints,...T]})}catch{Y=tf}if(!Y)throw new Error("Error generating geometry for surface");u.length===0&&this._bevel<h&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let ee=0;ee<Y.elementCount*3;ee+=3){let K=this._buildSurfaceVert(Y,Y.elements[ee+0],J),q=this._buildSurfaceVert(Y,Y.elements[ee+1],J),ue=this._buildSurfaceVert(Y,Y.elements[ee+2],J);S.push(K.top,q.top,ue.top),l===!1&&S.push(ue.bottom,q.bottom,K.bottom)}}this.vertexCache={}}this._buffer.shrink();let I=new oo.BufferAttribute(Uint32Array.from(S),1),x=new oo.BufferAttribute(this._buffer.positions,3),_=new oo.BufferAttribute(this._buffer.normals,3),D=new oo.BufferAttribute(this._buffer.uvs,2);x.needsUpdate=!0,_.needsUpdate=!0,D.needsUpdate=!0,I.needsUpdate=!0,this.setAttribute("position",x),this.setAttribute("normal",_),this.setAttribute("uv",D),this.setIndex(I)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(t,i,a),c=this._buildBevelVert(t,i,(a+1)%s);o.push(c.topP,l.topN,l.bottomN),o.push(c.topP,l.bottomN,c.bottomP)}}_buildSurfaceVert(e,t,o){let i=t.toString();if(i in this.vertexCache)return this.vertexCache[i];let a=e.vertices[t*2+0],s=e.vertices[t*2+1],l=(a-this._minX)/this._width,c=(s-this._minY)/this._height;this.forPathBevel&&(c=1);let u=this._buffer.get(this.forPathBevel?1:2),p=u*3,d=u*2,h={top:u+0,bottom:u+1};return this._buffer.positions[p+0]=a,this._buffer.positions[p+1]=s,this._buffer.positions[p+2]=this.forPathBevel?this._bevel:this._depth-o,this._buffer.normals[p+0]=0,this._buffer.normals[p+1]=0,this._buffer.normals[p+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=c,this.forPathBevel===!1&&(this._buffer.positions[p+3]=a,this._buffer.positions[p+4]=s,this._buffer.positions[p+5]=o,this._buffer.normals[p+3]=0,this._buffer.normals[p+4]=0,this._buffer.normals[p+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=c),this.vertexCache[i]=h,h}_buildBevelVert(e,t,o,i=1,a){let s=`${t.bevelI}:${o}`;if(s in this.vertexCache&&a!==0&&a!==1&&(!a||a===this.vertexCache[s].pathBevelUCoord))return this.vertexCache[s];let[l,c]=t.boundary.vertexIndices[o],u,p,d,h;l!==c?(p=l,u=c,h=!1,d=e.continuous[p]&&e.continuous[u]):(u=l,p=(u-1+e.count)%e.count,h=e.concave[u]&&t.bevelI>0,d=e.continuous[u]||h);let f=Math.cos(t.angle),m=Math.sin(t.angle),y=o*2,g=u*2,v=p*2,O=t.boundary.vertices[y+0],P=t.boundary.vertices[y+1],S=(1-m)*this._bevel,T=(O-this._minX)/this._width,I=(P-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(T=a),I=1);let x=e.normals[g+0],_=e.normals[g+1],D=e.normals[v+0],A=e.normals[v+1];if(h){let j=D-x,R=A-_;x=x+j*(1-i),_=_+R*(1-i);let W=Math.sqrt(x*x+_*_);x/=W,_/=W}let N=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),E=N*3,B=N*2,V={i:o,fi:u,topP:N+0,topN:N+0,bottomP:N+1,bottomN:N+1,pathBevelUCoord:a};return this._buffer.positions[E+0]=O,this._buffer.positions[E+1]=P,this._buffer.positions[E+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[E+0]=x*f,this._buffer.normals[E+1]=_*f,this._buffer.normals[E+2]=m,this._buffer.uvs[B+0]=T,this._buffer.uvs[B+1]=I,this.forPathBevel===!1&&(this._buffer.positions[E+3]=O,this._buffer.positions[E+4]=P,this._buffer.positions[E+5]=S,this._buffer.normals[E+3]=x*f,this._buffer.normals[E+4]=_*f,this._buffer.normals[E+5]=-m,this._buffer.uvs[B+2]=I,this._buffer.uvs[B+3]=T),d||(this.forPathBevel?(N+=1,E+=3,B+=2):(N+=2,E+=6,B+=4),V.topP=N+0,V.bottomP=N+1,this._buffer.positions[E+0]=O,this._buffer.positions[E+1]=P,this._buffer.positions[E+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[E+0]=D*f,this._buffer.normals[E+1]=A*f,this._buffer.normals[E+2]=m,this._buffer.uvs[B+0]=T,this._buffer.uvs[B+1]=I,this.forPathBevel===!1&&(this._buffer.positions[E+3]=O,this._buffer.positions[E+4]=P,this._buffer.positions[E+5]=S,this._buffer.normals[E+3]=D*f,this._buffer.normals[E+4]=A*f,this._buffer.normals[E+5]=-m,this._buffer.uvs[B+2]=I,this._buffer.uvs[B+3]=T)),this.vertexCache[s]=V,V}clone(){let e=new Dn(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Fo(this.userData),e}};var Ea=class extends di.BufferGeometry{constructor(e,t=12,o={}){super();this.type="ShapeGeometry";this.windingRule=We.ODD;this.elementType=gt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:We.ODD,elementType:gt.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let i=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(f=>f.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,c=!0,u,p;for(let f=0,m=i.length/2;f<m;f++){let y=f*2,g=i[y+0],v=i[y+1];if(u!==void 0&&g!==u&&(l=!1),p!==void 0&&v!==p&&(c=!1),u=g,p=v,!l&&!c)break}if(!l&&!c)try{s=ro({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=pl}let d=s?.vertexCount??1,h=s?.elementCount??1;if(this._positionAttribute=new di.BufferAttribute(new Float32Array(d*3),3),this._normalAttribute=new di.BufferAttribute(new Float32Array(d*3),3),this._uvAttribute=new di.BufferAttribute(new Float32Array(d*2),2),this._indexAttribute=new di.BufferAttribute(new Uint32Array(h*3),1),s){let f=1/0,m=-1/0,y=1/0,g=-1/0;for(let P=0,S=d;P<S;P++){let T=P*2,I=s.vertices[T+0],x=s.vertices[T+1];I<f&&(f=I),I>m&&(m=I),x<y&&(y=x),x>g&&(g=x)}let v=m-f,O=g-y;for(let P=0,S=d;P<S;P++){let T=P*2,I=s.vertices[T+0],x=s.vertices[T+1],_=(I-f)/v,D=(x-y)/O;this._positionAttribute.setXYZ(P,I,x,0),this._normalAttribute.setXYZ(P,0,0,1),this._uvAttribute.setXY(P,_,D)}for(let P=0,S=h;P<S;P++){let T=P*3,I=s.elements[T+0],x=s.elements[T+1],_=s.elements[T+2];this._indexAttribute.setX(T+0,I),this._indexAttribute.setX(T+1,x),this._indexAttribute.setX(T+2,_)}}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=Fo(this.userData),e}};var _a=class extends Dn{constructor(e,t,o=0,i=12,a=3,s=We.ODD){super(e,t,o,i,a,s);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(t,i,a),c=this._buildBevelVert(t,i,(a+1)%s);o.push(c.topP,l.topN,l.bottomN),o.push(c.topP,l.bottomN,c.bottomP)}}clone(){let e=new _a(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Fo(this.userData),e}};var xr=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:We.ODD},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=n.shape??r?.shape,s=a?.roundness??e.roundness;a!==void 0&&(a instanceof $e?(a.width!==t||a.height!==o)&&a.applySize(t,o):a=new $e(t,o).fromJSON(a),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&a.update());let l=a??new $e(t,o);return{parameters:Object.assign(e,{width:t,height:o,depth:i,roundness:s}),shape:l}}static build(n){let{depth:r,extrudeBevelSize:e,extrudeBevelSegments:t,subdivisions:o,roundness:i,windingRule:a}=n.parameters;n.shape.roundness=i;let s;return r<=0?s=new Ea(n.shape,o,{windingRule:a}):s=new _a(n.shape,r,e,o,t,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};var no=require("three"),Y0=Math.PI*2,La=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return e.angle=no.MathUtils.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof $e?n.shape:new $e,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:r,height:e,spikes:t,angle:o,innerRadius:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,c=n.shape,u=r*.5,p=e*.5,d=GA(c,u,p,o*Math.PI/180,t,i);c.isClosed=!0,c.update();let h;return o===0?(h=new no.BufferGeometry,h.setAttribute("position",new no.Float32BufferAttribute([],3))):h=xr.create({shape:c,parameters:{subdivisions:d,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(h,{userData:{...n,type:"EllipseGeometry"}})}};function GA(n,r,e,t,o,i){if(t>=Y0)return o>30||o%4===0?(FA(n,r,e,i),Math.round(o/4)):$0(n,t,o,r,e,i);t=Math.max(t,.001);let a={x:0,y:e},s=t+Math.PI*.5,l={x:Math.cos(s)*r,y:Math.sin(s)*e},c=z0({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:r,ry:e,largeArcFlag:t>Math.PI,sweepFlag:!0});return o>30||o%c.length===0?jA(n,a.x,a.y,c,o,r,e,i):$0(n,t,o,r,e,i)}function jA(n,r,e,t,o,i,a,s){let l=Math.round(o/t.length);n.addPoint(Ba(r,e));for(let c=0,u=t.length;c<u;c++){let p=t[c],d=n.points[c],h=Ba(p.x,p.y);d.controls[1].position.set(p.x1,p.y1),h.controls[0].position.set(p.x2,p.y2),n.addPoint(h)}return s>0?X0(n,i,a,s):n.addPoint(Ba(0,0)),l}function $0(n,r,e,t,o,i){let a=-r/e;for(let s=0;s<=e;s++){let l=a*s,c=Math.sin(l)*t,u=Math.cos(l)*o;n.addPoint(Ba(c,u))}return r<Y0?i>0?X0(n,t,o,i):n.addPoint(Ba(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&K0(n,t,o,i)),1}function FA(n,r,e,t=0,o=0,i=0){let a=.5522847498,s=r*a,l=e*a;n.addPoint(wu(o-r,i,o-r,i-l,o-r,i+l)),n.addPoint(wu(o,i+e,o-s,i+e,o+s,i+e)),n.addPoint(wu(o+r,i,o+r,i+l,o+r,i-l)),n.addPoint(wu(o,i-e,o+s,i-e,o-s,i-e)),t>0&&K0(n,r,e,t)}function Ba(n,r){return new to(no.MathUtils.generateUUID(),new no.Vector2(n,r))}function wu(n,r,e,t,o,i){let a=Ba(n,r);return a.controls[0].position.set(e,t),a.controls[1].position.set(o,i),a}function X0(n,r,e,t){Q0(n,r,e,t).forEach(i=>n.addPoint(i))}function K0(n,r,e,t){let o=Q0(n,r,e,t),i=new $e;o.forEach(a=>i.addPoint(a)),i.isClosed=!0,n.shapeHoles.push(i)}function Q0(n,r,e,t){let o=t*r/100,i=o*(Math.abs(e)/Math.abs(r)),a=new no.Vector2(o/r,i/e),s=n.points.map(l=>{let c=l.clone();return c.uuid=no.MathUtils.generateUUID(),c}).reverse();return s.forEach(l=>{l.position.multiply(a);let c=l.controls[0].position.clone().multiply(a),u=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(u),l.controls[1].position.copy(c)}),s}var io=require("three"),Z0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??t),i=Math.abs(e.depth??t),a=Math.abs(Math.min(t,i))/2;return{parameters:Object.assign(e,{width:t,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:r,height:e,depth:t,radius:o,revolutions:i,segments:a,pathRadius:s,pathType:l,pathSegments:c,cornerRadius:u,cornerSegments:p}=n.parameters,d=new fl(!1,r,e,t,o,i,a,s,l,c,u,p);return Object.assign(d,{userData:{...n,type:"HelixGeometry"}})}},rf=new io.Uint32BufferAttribute([0,0,0],1),fl=class extends io.BufferGeometry{constructor(r=!0,e=1,t=1,o=1,i=1,a=1,s=1,l=1,c=1,u=1,p=1,d=1){if(super(),a===0)return;let h=r&&a===1;h&&(d=0),p>100&&(p=100),p===0&&(d=0);let f=()=>new io.Vector3,m=new io.Vector3,y=f(),g=f(),v=f(),O,P,S,T,I,x,_,D,A=f(),N=f(),E=f(),B=f(),V=f(),j=f(),R=f(),W=f(),F=t-2*l+.001,k=F/a,H=Math.ceil(s*a),$=H+1,J=F/H,Z=-F/2,X=u+1,te=2*Math.PI/u,Y=Math.PI/2/d,ee=.01,K=Math.min((1-p/100)*l,l-ee),q=l-K,ue=0,le=2,ne=d*le+le,ce=X*ne/le,ae=ce+X*$,me=Math.max(0,X*($+ne)),[fe,he,xe]=[3,3,2].map(ht=>Array(me*ht).fill(0)),ye=[],C=i-l;function ie(ht,ot){let Xr=Math.PI/2;x=ot*J,D=2*Math.PI*(x%k)/k+Xr,x+=Z,_=Math.sin(D)*C,I=Math.cos(D)*C,r?ht.set(I,_,x):ht.set(I,x,_)}ie(m,-1e-10),ie(y,0),A.copy(m),ie(m,1);let Re=m.distanceTo(y),Fe=h?0:q+K,Ve=Re*H+2*Fe,Ce=K,_t=Ve-Fe;for(let ht=0;ht<=H;ht++){ie(g,ht),W.subVectors(g,A).normalize(),A.copy(g),j.copy(g).setComponent(+r+1,0).normalize(),R.crossVectors(W,j).normalize();let ot=ht===0,Xr=ht===H,_d=ot?3*Math.PI/2:Y,Bd=ot?Ce:_t,Kl=ot?X:ae,Yn=ot?0:me-X,vt=W.clone().multiplyScalar(ot?-q:q).add(g),Ld=W.clone().multiplyScalar(ot?-1:1).normalize();for(let Br=0;Br<X;Br++){let Gs=Br*te;if(N.addVectors(m.copy(j).multiplyScalar(l*Math.cos(Gs)),y.copy(R).multiplyScalar(l*Math.sin(Gs))),E.copy(N).normalize(),ot||Xr){h||(ue=Yn+Br,[0,1,2].forEach(rr=>{fe[ue*3+rr]=vt.getComponent(rr),he[ue*3+rr]=Ld.getComponent(rr)}),xe[ue*2]=+Xr,xe[ue*2+1]=Br/u),y.copy(E).multiplyScalar(K),v.addVectors(g,y);for(let rr=0;rr<d;rr++){let Xn=rr*Y+_d;B.addVectors(m.copy(W).multiplyScalar(q*Math.sin(Xn)),y.copy(E).multiplyScalar(q*Math.cos(Xn))),V.copy(B).normalize(),y.addVectors(v,B),B.normalize(),ue=Kl+rr*X+Br,[0,1,2].forEach(Mi=>{fe[ue*3+Mi]=y.getComponent(Mi),he[ue*3+Mi]=V.getComponent(Mi)});let Ql=+ot+Math.sin(Xn);xe[ue*2]=(Bd+q*Ql)/Ve,xe[ue*2+1]=Br/u}}y.addVectors(g,N),ue=ce+ht*X+Br,[0,1,2].forEach(rr=>{fe[ue*3+rr]=y.getComponent(rr),he[ue*3+rr]=E.getComponent(rr)}),xe[ue*2]=(Fe+ht*Re)/Ve,xe[ue*2+1]=Br/u}}let Ee=$+2*d+le,Nt=1,[Bt,$n]=[+h,Ee-1];for(let ht=Bt;ht<=$n-1;ht++){let ot=h&&ht===$n-1;for(let Xr=0;Xr<X-1;Xr++)O=ht*X+Xr,P=O+1,S=(ot?Xr:O)+X,T=(ot?Xr+1:P)+X,ht===0?ye.push(P,T,S):ht===Ee-2?ye.push(O,P,S):ye.push(O,P,S,P,T,S)}this.setIndex(ye),this.setAttribute("position",new io.Float32BufferAttribute(fe,3)),this.setAttribute("normal",new io.Float32BufferAttribute(he,3)),this.setAttribute("uv",new io.Float32BufferAttribute(xe,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let r=this.userData.parameters,e=Math.ceil(r.tubularSegments),t=r.radialSegments+1,o=Array.from(this.getIndex().array),i,a,s,l,c=6*(e-1)*r.radialSegments,u=e,p=u===e;for(let d=0;d<r.radialSegments;d++)i=u*t+d,a=i+1,s=(p?d:i)+t,l=(p?d+1:a)+t,o[c++]=i,o[c++]=a,o[c++]=s,o[c++]=a,o[c++]=l,o[c++]=s;return o.length=c,rf.array=o,rf.count=o.length,rf}};var J0=require("three");var ex=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.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:r,height:e,depth:t,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new hl(r*.5,i,a):new J0.IcosahedronGeometry(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},hl=class extends Mn{constructor(r=1,e=.2,t=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,r,e,t),this.type=s}static fromJSON(r){return new hl(r.radius,r.corner,r.cornerSides)}};var Pu=require("three"),tx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){(n.parameters?.points??[]).forEach(t=>{Array.isArray(t)&&(t.x=t[0],t.y=t[1])});let e=Object.assign({},r?.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:r,segments:e,verticalSegments:t}=n.parameters,o=new Pu.Shape;o.moveTo(r[0].x,r[0].y),o.bezierCurveTo(r[1].x,r[1].y,r[2].x,r[2].y,r[3].x,r[3].y);let i=new Pu.LatheGeometry(o.extractPoints(t).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};var Co=require("three");var Qo=require("three");var pe=require("three"),Oo=new pe.Matrix4,of=new pe.Object3D,Ou=new pe.Vector3,En=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(r){let e=new pe.Matrix3().getNormalMatrix(r);for(let t=0,o=this.vertices.length;t<o;t++)this.vertices[t].applyMatrix4(r);for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t];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(r){return Oo.makeRotationX(r),this.applyMatrix4(Oo),this}rotateY(r){return Oo.makeRotationY(r),this.applyMatrix4(Oo),this}rotateZ(r){return Oo.makeRotationZ(r),this.applyMatrix4(Oo),this}translate(r,e,t){return Oo.makeTranslation(r,e,t),this.applyMatrix4(Oo),this}scale(r,e,t){return Oo.makeScale(r,e,t),this.applyMatrix4(Oo),this}lookAt(r){return of.lookAt(r),of.updateMatrix(),this.applyMatrix4(of.matrix),this}fromBufferGeometry(r){let e=this,t=r.index!==null?r.index:void 0,o=r.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,c=o.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<i.count;d++)e.vertices.push(new pe.Vector3().fromBufferAttribute(i,d)),s!==void 0&&e.colors.push(new pe.Color().fromBufferAttribute(s,d));function u(d,h,f,m){let y=s===void 0?[]:[e.colors[d].clone(),e.colors[h].clone(),e.colors[f].clone()],g=a===void 0?[]:[new pe.Vector3().fromBufferAttribute(a,d),new pe.Vector3().fromBufferAttribute(a,h),new pe.Vector3().fromBufferAttribute(a,f)],v=new Ra(d,h,f,g,y,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new pe.Vector2().fromBufferAttribute(l,d),new pe.Vector2().fromBufferAttribute(l,h),new pe.Vector2().fromBufferAttribute(l,f)]),c!==void 0&&e.faceVertexUvs[1].push([new pe.Vector2().fromBufferAttribute(c,d),new pe.Vector2().fromBufferAttribute(c,h),new pe.Vector2().fromBufferAttribute(c,f)])}let p=r.groups;if(p.length>0)for(let d=0;d<p.length;d++){let h=p[d],f=h.start,m=h.count;for(let y=f,g=f+m;y<g;y+=3)t!==void 0?u(t.getX(y),t.getX(y+1),t.getX(y+2),h.materialIndex):u(y,y+1,y+2,h.materialIndex)}else if(t!==void 0)for(let d=0;d<t.count;d+=3)u(t.getX(d),t.getX(d+1),t.getX(d+2));else for(let d=0;d<i.count;d+=3)u(d,d+1,d+2);return this.computeFaceNormals(),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ou).negate(),this.translate(Ou.x,Ou.y,Ou.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new pe.Matrix4;return o.set(t,0,0,-t*r.x,0,t,0,-t*r.y,0,0,t,-t*r.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let r=new pe.Vector3,e=new pe.Vector3;for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],a=this.vertices[i.a],s=this.vertices[i.b],l=this.vertices[i.c];r.subVectors(l,s),e.subVectors(a,s),r.cross(e),r.normalize(),i.normal.copy(r)}}computeVertexNormals(r=!0){let e=new Array(this.vertices.length);for(let t=0,o=this.vertices.length;t<o;t++)e[t]=new pe.Vector3;if(r){let t=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],c=this.vertices[s.b],u=this.vertices[s.c];t.subVectors(u,c),o.subVectors(l,c),t.cross(o),e[s.a].add(t),e[s.b].add(t),e[s.c].add(t)}}else{this.computeFaceNormals();for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t];e[i.a].add(i.normal),e[i.b].add(i.normal),e[i.c].add(i.normal)}}for(let t=0,o=this.vertices.length;t<o;t++)e[t].normalize();for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],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 r=0,e=this.faces.length;r<e;r++){let t=this.faces[r],o=t.vertexNormals;o.length===3?(o[0].copy(t.normal),o[1].copy(t.normal),o[2].copy(t.normal)):(o[0]=t.normal.clone(),o[1]=t.normal.clone(),o[2]=t.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,t=this.faces.length;e<t;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 r=new En;r.faces=this.faces;for(let e=0,t=this.morphTargets.length;e<t;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 c=new pe.Vector3,u={a:new pe.Vector3,b:new pe.Vector3,c:new pe.Vector3};i.push(c),a.push(u)}}let o=this.morphNormals[e];r.vertices=this.morphTargets[e].vertices,r.computeFaceNormals(),r.computeVertexNormals();for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=o.faceNormals[i],c=o.vertexNormals[i];l.copy(s.normal),c.a.copy(s.vertexNormals[0]),c.b.copy(s.vertexNormals[1]),c.c.copy(s.vertexNormals[2])}}for(let e=0,t=this.faces.length;e<t;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(r,e,t=0){if(!(r&&r.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",r);return}let o,i=this.vertices.length,a=this.vertices,s=r.vertices,l=this.faces,c=r.faces,u=this.colors,p=r.colors;e!==void 0&&(o=new pe.Matrix3().getNormalMatrix(e));for(let d=0,h=s.length;d<h;d++){let m=s[d].clone();e!==void 0&&m.applyMatrix4(e),a.push(m)}for(let d=0,h=p.length;d<h;d++)u.push(p[d].clone());for(let d=0,h=c.length;d<h;d++){let f=c[d],m,y,g=f.vertexNormals,v=f.vertexColors,O=new Ra(f.a+i,f.b+i,f.c+i);O.normal.copy(f.normal),o!==void 0&&O.normal.applyMatrix3(o).normalize();for(let P=0,S=g.length;P<S;P++)m=g[P].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),O.vertexNormals.push(m);O.color.copy(f.color);for(let P=0,S=v.length;P<S;P++)y=v[P],O.vertexColors.push(y.clone());O.materialIndex=f.materialIndex+t,l.push(O)}for(let d=0,h=r.faceVertexUvs.length;d<h;d++){let f=r.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,y=f.length;m<y;m++){let g=f[m],v=[];for(let O=0,P=g.length;O<P;O++)v.push(g[O].clone());this.faceVertexUvs[d].push(v)}}}mergeMesh(r){if(!(r&&r.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",r);return}r.matrixAutoUpdate&&r.updateMatrix(),this.merge(r.geometry,r.matrix)}mergeVertices(r=4){let e={},t=[],o=[],i=Math.pow(10,r);for(let l=0,c=this.vertices.length;l<c;l++){let u=this.vertices[l],p=Math.round(u.x*i)+"_"+Math.round(u.y*i)+"_"+Math.round(u.z*i);e[p]===void 0?(e[p]=l,t.push(this.vertices[l]),o[l]=t.length-1):o[l]=o[e[p]]}let a=[];for(let l=0,c=this.faces.length;l<c;l++){let u=this.faces[l];u.a=o[u.a],u.b=o[u.b],u.c=o[u.c];let p=[u.a,u.b,u.c];for(let d=0;d<3;d++)if(p[d]===p[(d+1)%3]){a.push(l);break}}for(let l=a.length-1;l>=0;l--){let c=a[l];this.faces.splice(c,1);for(let u=0,p=this.faceVertexUvs.length;u<p;u++)this.faceVertexUvs[u].splice(c,1)}let s=this.vertices.length-t.length;return this.vertices=t,s}setFromPoints(r){this.vertices=[];for(let e=0,t=r.length;e<t;e++){let o=r[e];this.vertices.push(new pe.Vector3(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let r=this.faces,e=r.length;for(let l=0;l<e;l++)r[l]._id=l;function t(l,c){return l.materialIndex-c.materialIndex}r.sort(t);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 c=r[l]._id;a&&a.push(o[c]),s&&s.push(i[c])}a&&(this.faceVertexUvs[0]=a),s&&(this.faceVertexUvs[1]=s)}toJSON(){let r={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.parameters!==void 0){let f=this.parameters;for(let m in f)f[m]!==void 0&&(r[m]=f[m]);return r}let e=[];for(let f=0;f<this.vertices.length;f++){let m=this.vertices[f];e.push(m.x,m.y,m.z)}let t=[],o=[],i={},a=[],s={},l=[],c={};for(let f=0;f<this.faces.length;f++){let m=this.faces[f],y=!0,g=!1,v=this.faceVertexUvs[0][f]!==void 0,O=m.normal.length()>0,P=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,T=m.vertexColors.length>0,I=0;if(I=u(I,0,0),I=u(I,1,y),I=u(I,2,g),I=u(I,3,v),I=u(I,4,O),I=u(I,5,P),I=u(I,6,S),I=u(I,7,T),t.push(I),t.push(m.a,m.b,m.c),t.push(m.materialIndex),v){let x=this.faceVertexUvs[0][f];t.push(h(x[0]),h(x[1]),h(x[2]))}if(O&&t.push(p(m.normal)),P){let x=m.vertexNormals;t.push(p(x[0]),p(x[1]),p(x[2]))}if(S&&t.push(d(m.color)),T){let x=m.vertexColors;t.push(d(x[0]),d(x[1]),d(x[2]))}}function u(f,m,y){return y?f|1<<m:f&~(1<<m)}function p(f){let m=f.x.toString()+f.y.toString()+f.z.toString();return i[m]!==void 0||(i[m]=o.length/3,o.push(f.x,f.y,f.z)),i[m]}function d(f){let m=f.r.toString()+f.g.toString()+f.b.toString();return s[m]!==void 0||(s[m]=a.length,a.push(f.getHex())),s[m]}function h(f){let m=f.x.toString()+f.y.toString();return c[m]!==void 0||(c[m]=l.length/2,l.push(f.x,f.y)),c[m]}return r.data={},r.data.vertices=e,r.data.normals=o,a.length>0&&(r.data.colors=a),l.length>0&&(r.data.uvs=[l]),r.data.faces=t,r}clone(){return new En().copy(this)}copy(r){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=r.name;let e=r.vertices;for(let d=0,h=e.length;d<h;d++)this.vertices.push(e[d].clone());let t=r.colors;for(let d=0,h=t.length;d<h;d++)this.colors.push(t[d].clone());let o=r.faces;for(let d=0,h=o.length;d<h;d++)this.faces.push(o[d].clone());for(let d=0,h=r.faceVertexUvs.length;d<h;d++){let f=r.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,y=f.length;m<y;m++){let g=f[m],v=[];for(let O=0,P=g.length;O<P;O++){let S=g[O];v.push(S.clone())}this.faceVertexUvs[d].push(v)}}let i=r.morphTargets;for(let d=0,h=i.length;d<h;d++){let f={};if(f.name=i[d].name,i[d].vertices!==void 0){f.vertices=[];for(let m=0,y=i[d].vertices.length;m<y;m++)f.vertices.push(i[d].vertices[m].clone())}if(i[d].normals!==void 0){f.normals=[];for(let m=0,y=i[d].normals.length;m<y;m++)f.normals.push(i[d].normals[m].clone())}this.morphTargets.push(f)}let a=r.morphNormals;for(let d=0,h=a.length;d<h;d++){let f={};if(a[d].vertexNormals!==void 0){f.vertexNormals=[];for(let m=0,y=a[d].vertexNormals.length;m<y;m++){let g=a[d].vertexNormals[m],v={};v.a=g.a.clone(),v.b=g.b.clone(),v.c=g.c.clone(),f.vertexNormals.push(v)}}if(a[d].faceNormals!==void 0){f.faceNormals=[];for(let m=0,y=a[d].faceNormals.length;m<y;m++)f.faceNormals.push(a[d].faceNormals[m].clone())}this.morphNormals.push(f)}let s=r.skinWeights;for(let d=0,h=s.length;d<h;d++)this.skinWeights.push(s[d].clone());let l=r.skinIndices;for(let d=0,h=l.length;d<h;d++)this.skinIndices.push(l[d].clone());let c=r.lineDistances;for(let d=0,h=c.length;d<h;d++)this.lineDistances.push(c[d]);let u=r.boundingBox;u!==null&&(this.boundingBox=u.clone());let p=r.boundingSphere;return p!==null&&(this.boundingSphere=p.clone()),this.elementsNeedUpdate=r.elementsNeedUpdate,this.verticesNeedUpdate=r.verticesNeedUpdate,this.uvsNeedUpdate=r.uvsNeedUpdate,this.normalsNeedUpdate=r.normalsNeedUpdate,this.colorsNeedUpdate=r.colorsNeedUpdate,this.lineDistancesNeedUpdate=r.lineDistancesNeedUpdate,this.groupsNeedUpdate=r.groupsNeedUpdate,this}toBufferGeometry(){let r=new nf().fromGeometry(this),e=new pe.BufferGeometry,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",Cu.call(new pe.BufferAttribute(t,3),r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",Cu.call(new pe.BufferAttribute(o,3),r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",rx.call(new pe.BufferAttribute(o,3),r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",ox.call(new pe.BufferAttribute(o,2),r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",ox.call(new pe.BufferAttribute(o,2),r.uvs2))}e.groups=r.groups;for(let o in r.morphTargets){let i=[],a=r.morphTargets[o];for(let s=0,l=a.length;s<l;s++){let c=a[s],u=new pe.Float32BufferAttribute(c.data.length*3,3);u.name=c.name,i.push(Cu.call(u,c.data))}e.morphAttributes[o]=i}if(r.skinIndices.length>0){let o=new pe.Float32BufferAttribute(r.skinIndices.length*4,4);e.setAttribute("skinIndex",nx.call(o,r.skinIndices))}if(r.skinWeights.length>0){let o=new pe.Float32BufferAttribute(r.skinWeights.length*4,4);e.setAttribute("skinWeight",nx.call(o,r.skinWeights))}return r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.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(r){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(r)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(r){let e=new pe.BufferGeometry,t=r.geometry;if(r.isPoints||r.isLine){let o=new pe.Float32BufferAttribute(t.vertices.length*3,3),i=new pe.Float32BufferAttribute(t.colors.length*3,3);if(e.setAttribute("position",Cu.call(o,t.vertices)),e.setAttribute("color",rx.call(i,t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let a=new pe.Float32BufferAttribute(t.lineDistances.length,1);e.setAttribute("lineDistance",UA.call(a,t.lineDistances))}t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone())}else r.isMesh&&(e=t.toBufferGeometry());return e}};En.prototype.isGeometry=!0;var nf=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(r){let e=[],t,o,i,a=r.faces;for(o=0;o<a.length;o++){let s=a[o];s.materialIndex!==i&&(i=s.materialIndex,t!==void 0&&(t.count=o*3-t.start,e.push(t)),t={start:o*3,materialIndex:i})}t!==void 0&&(t.count=o*3-t.start,e.push(t)),this.groups=e}fromGeometry(r){let e=r.faces,t=r.vertices,o=r.faceVertexUvs,i=o[0]&&o[0].length>0,a=o[1]&&o[1].length>0,s=r.morphTargets,l=s.length,c;if(l>0){c=[];for(let g=0;g<l;g++)c[g]={name:s[g].name,data:[]};this.morphTargets.position=c}let u=r.morphNormals,p=u.length,d;if(p>0){d=[];for(let g=0;g<p;g++)d[g]={name:u[g].name,data:[]};this.morphTargets.normal=d}let h=r.skinIndices,f=r.skinWeights,m=h.length===t.length,y=f.length===t.length;t.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<e.length;g++){let v=e[g];this.vertices.push(t[v.a],t[v.b],t[v.c]);let O=v.vertexNormals;if(O.length===3)this.normals.push(O[0],O[1],O[2]);else{let S=v.normal;this.normals.push(S,S,S)}let P=v.vertexColors;if(P.length===3)this.colors.push(P[0],P[1],P[2]);else{let S=v.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 T=s[S].vertices;c[S].data.push(T[v.a],T[v.b],T[v.c])}for(let S=0;S<p;S++){let T=u[S].vertexNormals[g];d[S].data.push(T.a,T.b,T.c)}m&&this.skinIndices.push(h[v.a],h[v.b],h[v.c]),y&&this.skinWeights.push(f[v.a],f[v.b],f[v.c])}return this.computeGroups(r),this.verticesNeedUpdate=r.verticesNeedUpdate,this.normalsNeedUpdate=r.normalsNeedUpdate,this.colorsNeedUpdate=r.colorsNeedUpdate,this.uvsNeedUpdate=r.uvsNeedUpdate,this.groupsNeedUpdate=r.groupsNeedUpdate,r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),this}},Ra=class{constructor(r,e,t,o,i,a=0){this.a=r,this.b=e,this.c=t,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(r){this.a=r.a,this.b=r.b,this.c=r.c,this.normal.copy(r.normal),this.color.copy(r.color),this.materialIndex=r.materialIndex;for(let e=0,t=r.vertexNormals.length;e<t;e++)this.vertexNormals[e]=r.vertexNormals[e].clone();for(let e=0,t=r.vertexColors.length;e<t;e++)this.vertexColors[e]=r.vertexColors[e].clone();return this}};function UA(n){return this.array.set(n),this}function rx(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",t),i=new pe.Color),r[e++]=i.r,r[e++]=i.g,r[e++]=i.b}return this}function ox(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",t),i=new pe.Vector2),r[e++]=i.x,r[e++]=i.y}return this}function Cu(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",t),i=new pe.Vector3),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z}return this}function nx(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",t),i=new pe.Vector4),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z,r[e++]=i.w}return this}var kA=["a","b","c"];function HA(n,r){switch(r){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function af(n,r,e){let t=Math.min(n,r),o=Math.max(n,r),i=t+"_"+o;return e.get(i)}function sf(n,r,e,t,o,i){let a=Math.min(n,r),s=Math.max(n,r),l=a+"_"+s,c;if(t.has(l))c=t.get(l);else{let u=e[a],p=e[s];c={a:u,b:p,newEdge:null,faces:[]},t.set(l,c)}c.faces.push(o),i[n].edges.push(c),i[r].edges.push(c)}function WA(n,r,e,t){let o,i,a;for(o=0,i=n.length;o<i;o++)e[o]={edges:[]};for(o=0,i=r.length;o<i;o++)a=r[o],sf(a.a,a.b,n,t,a,e),sf(a.b,a.c,n,t,a,e),sf(a.c,a.a,n,t,a,e)}function Tu(n,r,e,t,o){n.push(new Ra(r,e,t,void 0,void 0,o))}function Va(n,r){return Math.abs(r-n)/2+Math.min(n,r)}function Au(n,r,e,t){n.push([r.clone(),e.clone(),t.clone()])}var Mu=class{constructor(r=1){this.subdivisions=r}modify(r){r instanceof Qo.BufferGeometry?r=new En().fromBufferGeometry(r):r=r.clone(),r.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(r);return r.computeFaceNormals(),r.computeVertexNormals(),r}_smooth(r){let e=new Qo.Vector3,t,o,i,a,s,l=r.vertices,c=r.faces,u=r.faceVertexUvs[0],p=u!==void 0&&u.length>0,d=[],h=new Map;WA(l,c,d,h);let f=[],m,y,g,v,O,P,S;for(let ee of Array.from(h.keys())){for(y=h.get(ee),g=new Qo.Vector3,O=3/8,P=1/8,S=y.faces.length,S!=2&&(O=.5,P=0,S!=1),g.addVectors(y.a,y.b).multiplyScalar(O),e.set(0,0,0),a=0;a<S;a++){for(v=y.faces[a],s=0;s<3&&(m=l[HA(v,kA[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(P),g.add(e),y.newEdge=f.length,f.push(g)}let T,I,x,_,D,A,N,E=[];for(o=0,i=l.length;o<i;o++){for(A=l[o],D=d[o].edges,t=D.length,t==3?T=3/16:t>3&&(T=3/(8*t)),I=1-t*Number(T),x=T,t<=2&&(t==2?(I=3/4,x=1/8):t==1||t==0),N=A.clone().multiplyScalar(I),e.set(0,0,0),a=0;a<t;a++)_=D[a],m=_.a!==A?_.a:_.b,e.add(m);e.multiplyScalar(Number(x)),N.add(e),E.push(N)}let B=E.concat(f),V=E.length,j,R,W,F=[],k=[],H,$,J,Z,X=new Qo.Vector2,te=new Qo.Vector2,Y=new Qo.Vector2;for(o=0,i=c.length;o<i;o++)v=c[o],j=Number(af(v.a,v.b,h).newEdge)+V,R=Number(af(v.b,v.c,h).newEdge)+V,W=Number(af(v.c,v.a,h).newEdge)+V,Tu(F,j,R,W,v.materialIndex),Tu(F,v.a,j,W,v.materialIndex),Tu(F,v.b,R,j,v.materialIndex),Tu(F,v.c,W,R,v.materialIndex),p&&(H=u[o],$=H[0],J=H[1],Z=H[2],X.set(Va($.x,J.x),Va($.y,J.y)),te.set(Va(J.x,Z.x),Va(J.y,Z.y)),Y.set(Va($.x,Z.x),Va($.y,Z.y)),Au(k,X,te,Y),Au(k,$,X,Y),Au(k,J,te,X),Au(k,Z,Y,te));r.vertices=B,r.faces=F,p&&(r.faceVertexUvs[0]=k)}};var Vt=new Co.Vector3,ix=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=n.geometry??r?.geometry??new Co.BufferGeometry().copy(new Co.BoxGeometry(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Vt),t={width:Vt.x,height:Vt.y,depth:Vt.z,subdivisions:0}):t=r.parameters;let o={...t,...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:r,height:e,depth:t,subdivisions:o}=n.parameters,i=n.geometry??new Co.BufferGeometry().copy(new Co.BoxGeometry(100,100,100)),a=i.userData.parameters;a===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(Vt)):Vt.set(a.width,a.height,a.depth),(r!==Vt.x||e!==Vt.y||t!==Vt.z)&&i.scale(Vt.x===0?1:r/Vt.x,Vt.y===0?1:e/Vt.y,Vt.z===0?1:t/Vt.z);let s=i.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=i),i=new Mu(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,r,e){new Co.BufferGeometryLoader(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(Vt);let a=100/Vt.x;Object.assign(i.parameters,{width:100,height:Vt.y*a,depth:Vt.z*a}),r(this.build(i))})}};var Iu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof $e?n.shape:new $e,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:r,height:e,spikes:t,cornerRadius:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}=n.parameters,l=n.shape,c=r*.5,u=e*.5,p=0,d=0,h=2*Math.PI/t;for(let m=0;m<t;m++){let y=h*m,g=p+Math.sin(y)*c,v=d+Math.cos(y)*u;l.addPoint(l.createPoint(g,v))}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 f=xr.create({shape:l,parameters:{roundness:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(f,{userData:{...n,type:"PolygonGeometry"}})}};var ke=require("three"),ax=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.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:r,height:e,depth:t,radialSegments:o,heightSegments:i,openEnded:a,cornerRadius:s,cornerSegments:l}=n.parameters,c=new cf(r*.5,e,o,i,a,s,l);return c.scale(1,1,t/r),Object.assign(c,{userData:{...n,type:"PyramidGeometry"}})}};function ml(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function lf(n,r,e,t,o,i){let a=r.clone().sub(n),s=e.clone().sub(n),l=a.angleTo(s);if(a.normalize(),s.normalize(),t===o){let c=a.add(s).normalize();i.copy(n).addScaledVector(c,t/Math.sin(l/2))}else{let c=a.angleTo(s);i.copy(n),i.addScaledVector(a,o/Math.sin(c)),i.addScaledVector(s,t/Math.sin(c))}}function qA(n,r,e){let t=n.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var cf=class extends ke.BufferGeometry{constructor(r=.5,e=1,t=4,o=1,i=!1,a=0,s=4){super(),t=Math.floor(Math.max(3,t)),o=Math.floor(o),s=Math.floor(s);let l=[],c=[],u=[],p=[],d=0,h=e/2,f=Math.PI/t,m=r*Math.cos(Math.PI/t),y=2*Math.PI/t,g=(t-2)*Math.PI/t,v=Math.PI-g,O=new ke.Vector3(0,-h,0),P=new ke.Vector3(0,h,0),S=new ke.Vector2(r,-h),T=new ke.Vector2(m,-h),I=new ke.Vector2(0,P.y).sub(T),x=new ke.Vector2(0,P.y).sub(S),_=new ke.Vector2(I.y,-I.x).normalize(),D=new ke.Vector2(x.y,-x.x).normalize(),N=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-I.angle())/2)-1e-8;a=Math.min(a,N);let E;{let k=new ke.Vector3(_.x,_.y,0),H=new ke.Vector3(Math.cos(y)*k.x,k.y,Math.sin(y)*k.x);E=k.angleTo(H)}let B=a/Math.tan((Math.PI-I.angle())/2),V=a/Math.tan((Math.PI-E)/2),j=new ke.Vector3;if(!i){c.push(O.x,O.y,O.z),u.push(0,-1,0),p.push(0,0);let k=d++,H=[],$=S.clone(),J=B/Math.cos(Math.PI/t);$.x-=J;for(let Z=0;Z<t;Z++){let X=Z/t*Math.PI*2+f,te=new ke.Vector2(Math.sin(X),Math.cos(X));ml($,te,j),c.push(j.x,j.y,j.z),u.push(0,-1,0),p.push(0,0),H.push(d++)}for(let Z=0;Z<H.length;Z++)l.push(H[Z],k,H[(Z+1)%H.length])}let R=[];{let k=new ke.Vector3,H=new ke.Vector3,$=new ke.Vector3,J=new ke.Vector3,Z=new ke.Vector3,X=new ke.Vector3;for(let te=0;te<t;te++){let Y=te/t*Math.PI*2+f,ee=(te+.5)/t*Math.PI*2+f,K=(te+1)/t*Math.PI*2+f,q=new ke.Vector2(Math.sin(Y),Math.cos(Y)),ue=new ke.Vector2(Math.sin(ee),Math.cos(ee)),le=new ke.Vector2(Math.sin(K),Math.cos(K));ml(S,q,H),ml(S,le,$),ml(_,ue,k),lf(P,H,$,V,V,J),c.push(J.x,J.y,J.z),lf(H,P,$,V,B,Z),c.push(Z.x,Z.y,Z.z),lf($,H,P,B,V,X),c.push(X.x,X.y,X.z),u.push(k.x,k.y,k.z),u.push(k.x,k.y,k.z),u.push(k.x,k.y,k.z),p.push(0,0),p.push(0,0),p.push(0,0);let ne=d++,ce=d++,ae=d++;if(l.push(ne,ce,ae),a>0){{let he=H.clone().add($).multiplyScalar(.5),xe=P.clone().sub(he).normalize(),C=O.clone().sub(he).normalize().add(xe).normalize().multiplyScalar(-1),ie=X.clone().sub(Z);W(he,ie,C,I.angle())}let me,fe;{let he=new ke.Vector3;ml(D,le,he);let xe=X.clone().add(J).multiplyScalar(.5);xe=qA(xe,$,P);let ye=X.clone().sub(J);[me,fe]=W(xe,ye,he,E,J.y)}{let he=me,xe=he.clone().setY(0).normalize(),ye=new ke.Vector3(0,-1,0),C=xe.clone().cross(ye);F(he,xe,ye,C)}R.concat(fe);{let he=I.angle(),xe=Math.PI-he,ye=P.clone();ye.y-=a/Math.sin(he-Math.PI/2);let C=new ke.Vector3,ie=[];for(let Fe=0;Fe<s;Fe++){let Ve=[],Ce=Math.PI/2-xe*Fe/s,_t=Math.cos(Ce),Ee=Math.sin(Ce),Nt=ee;for(let Bt=0;Bt<=Fe;Bt++){let $n=Math.cos(Nt),ht=Math.sin(Nt);k.x=_t*ht,k.y=Ee,k.z=_t*$n,C.copy(ye).addScaledVector(k,a),c.push(C.x,C.y,C.z),u.push(k.x,k.y,k.z),p.push(0,0),Ve.push(d++),Nt+=Math.PI*2/Fe/t}ie.push(Ve)}fe.reverse(),ie.push(fe);let Re=ie.length-1;for(let Fe=0;Fe<Re;Fe++){let Ve=ie[Fe],Ce=ie[Fe+1],_t=Ve.length-1;l.push(Ce[1],Ve[0],Ce[0]);for(let Ee=1;Ee<=_t;Ee++)l.push(Ve[Ee],Ve[Ee-1],Ce[Ee]),l.push(Ce[Ee+1],Ve[Ee],Ce[Ee])}}}}}this.setIndex(l),this.setAttribute("position",new ke.Float32BufferAttribute(c,3)),this.setAttribute("normal",new ke.Float32BufferAttribute(u,3)),this.setAttribute("uv",new ke.Float32BufferAttribute(p,2));function W(k,H,$,J,Z){let X=-J/2,te=(Math.PI-J)/2,Y=H.clone().normalize().cross($);k.addScaledVector($,-a/Math.sin(te));let ee=new ke.Vector3,K=new ke.Vector3,q=1,ue=d,le=[];for(let ne=0;ne<=s;ne++){let ce=X+ne/s*J;K.set(0,0,0),K.addScaledVector(Y,Math.sin(ce)),K.addScaledVector($,Math.cos(ce));for(let ae=0;ae<=q;ae++){let me=ae/q-.5;if(ee.copy(k),ee.addScaledVector(H,me),ee.addScaledVector(K,a),Z!=null){let fe=Math.max(0,ee.y-Z);ee.addScaledVector(H,-fe/H.y)}c.push(ee.x,ee.y,ee.z),u.push(K.x,K.y,K.z),p.push(0,0),ae===0&&le.push(d),d++}}for(let ne=0;ne<s;ne++)for(let ce=0;ce<q;ce++){let ae=ue+ce+(q+1)*ne,me=ae+(q+1),fe=me+1,he=ae+1;l.push(ae,me,he),l.push(me,fe,he)}return[k.clone().addScaledVector(H,.5),le]}function F(k,H,$,J){let Z=Math.PI/2,X=x.angle()-Z,te=[],Y=new ke.Vector3,ee=new ke.Vector3;for(let q=0;q<=s;q++){let ue=[],le=q/s;for(let ne=0;ne<=q;ne++){let ae=((q?ne/q:0)-.5)*v,me=Math.cos(ae),fe=Math.sin(ae),he=Math.atan(Math.tan(X)*me),xe=(Z+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(k).addScaledVector(Y,a),c.push(ee.x,ee.y,ee.z),u.push(Y.x,Y.y,Y.z),p.push(0,0),ue.push(d++)}te.push(ue)}let K=te.length-1;for(let q=0;q<K;q++){let ue=te[q],le=te[q+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 za=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),t=Object.assign(r?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof $e?n.shape:new $e,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:t}}static build(n){let r=n.shape,{width:e,height:t,cornerRadius:o,cornerType:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,c={x:e*.5,y:t*.5},u={x:-c.x,y:-c.y},p={x:c.x,y:c.y};function d(P,S,T){return S>e&&T>t?Math.min(P*e/S,P*t/T):S>e?P*e/S:T>t?P*t/T:P}let h=[];h[0]=o[0]===0?0:d(o[0],o[0]+o[3],o[0]+o[1]),h[1]=o[1]===0?0:d(o[1],o[1]+o[2],o[1]+o[0]),h[2]=o[2]===0?0:d(o[2],o[2]+o[1],o[2]+o[3]),h[3]=o[3]===0?0:d(o[3],o[3]+o[0],o[3]+o[2]);let f=u.x,m=p.x,y=p.y,g=u.y;r.addPoint(r.createPoint(f,y)),r.addPoint(r.createPoint(m,y)),r.addPoint(r.createPoint(m,g)),r.addPoint(r.createPoint(f,g)),r.isClosed=!0;let v=!0;for(let P=0,S=r.points.length;P<S;P++)r.points[P].roundness=h[P],P>0&&h[P]!==h[P-1]&&(v=!1);v&&(r.roundness=h[0]),r.useCubicForRoundedCorners=i!==1,r.update();let O=xr.create({shape:r,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(O,{userData:{...n,type:"RectangleGeometry"}})}};var Zo=require("three"),sx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},n.parameters);return e.thetaLength=Zo.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:r=100,height:e=r,depth:t=r,widthSegments:o=64,heightSegments:i=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:c}=n.parameters,u;return c===0?(u=new Zo.BufferGeometry,u.setAttribute("position",new Zo.Float32BufferAttribute([],3))):u=new Zo.SphereGeometry(.5*r,o,i,a,s,l,c*Zo.MathUtils.DEG2RAD),u.scale(1,e/r,t/r),Object.assign(u,{userData:{...n,type:"SphereGeometry"}})}};var lx=require("three"),cx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.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:r=100,height:e=r,widthSegments:t=8,heightSegments:o=8}=n.parameters,i=new lx.PlaneGeometry(r,e,t,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};var _n=require("three"),ux=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.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:r,height:e,depth:t,angle:o,cornerRadius:i,cornerSegments:a}=n.parameters,s=new uf(r,e,t,o,i,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},uf=class extends _n.BufferGeometry{constructor(r=1,e=1,t=1,o=90,i=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],c=[],u=.001;i==0&&(a=1),a=Math.max(1,Math.floor(a)),i=Math.min(i,100),o=Math.min(180-u,o),o*=Math.PI/180;let p=[],d=Math.PI/2,h=(ee=0,K=0,q=0)=>new _n.Vector3(ee,K,q),f=h(),m=h(),[y,g,v]=[e/2,r/2,t/2],O=-g,P=+g,[S,T,I]=[h(O,-y,+v),h(O,-y,-v),h(O,+y,-v)],x=(ee,K=!1)=>Math.sin(ee-Math.PI/(1+ +K)),_=(ee,K=!1)=>Math.cos(ee-Math.PI/(1+ +K));I.y=Math.sin(o)*e-y;let D=Math.cos(o)*e-v,A=S.z-u;o<=d?(I.z=Math.min(D,A),I.z==A&&(I.y-=(D-A)/Math.tan(d-o))):T.z=Math.min(T.z-D-v,S.z-u),f.subVectors(S,T),m.subVectors(I,T);let N=Math.min(f.length(),m.length())*i/100,E=N*Math.tan(o/2),B=N/Math.cos(o/2),V=f.clone().normalize().add(m.normalize()).setLength(B).add(T);f.set(0,x(o,!0),_(o,!0)),p.push([I,f.clone()]);let j=(Math.PI-o)/a;for(let ee=0;ee<=a;ee++){let K=d+o+ee*j;f.set(0,Math.sin(K)*E,Math.cos(K)*E),f.add(V),m.set(0,x(K),_(K)),p.push([f.clone(),m.clone()])}p.push([S,h(0,1,0)]);let R=Math.sin(j/2)*E*2,W=p.length-1,F=p[0][0].distanceTo(p[1][0]),k=p[W-1][0].distanceTo(p[W][0]),H=F+R*a+k;p[0].push(1);for(let ee=0;ee<=a;ee++)p[ee+1].push(1-(F+ee*R)/H);p[W].push(0);let[$,J,Z]=p[0],X,te,Y;for(let ee=1;ee<p.length;ee++)[X,te,Y]=p[ee],s.push(O,$.y,$.z,O,X.y,X.z,P,$.y,$.z,P,$.y,$.z,O,X.y,X.z,P,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),c.push(0,Z,0,Y,1,Z,1,Z,0,Y,1,Y),[$,J,Z]=[X,te,Y];this.setAttribute("position",new _n.Float32BufferAttribute(s,3)),this.setAttribute("normal",new _n.Float32BufferAttribute(l,3)),this.setAttribute("uv",new _n.Float32BufferAttribute(c,2))}};var Nu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.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 $e?n.shape:new $e,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:r,height:e,innerRadiusPercent:t,spikes:o,cornerRadius:i,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}=n.parameters,u=n.shape,p=r*.5,d=e*.5,h=0,f=0,m=a*Math.PI/360/o,y=Math.PI/2*3*-1,g=p*t/100,v=d*t/100;if(o===3&&t===50){m=2*Math.PI/o;for(let P=0;P<o;P++){let S=m*P,T=h+Math.sin(S)*p,I=f+Math.cos(S)*d;u.addPoint(u.createPoint(T,I))}}else for(let P=0;P<o;P++){let S=h+Math.cos(y)*p,T=f+Math.sin(y)*d;u.addPoint(u.createPoint(S,T)),y+=m,S=h+Math.cos(y)*g,T=f+Math.sin(y)*v,P<=o,u.addPoint(u.createPoint(S,T)),y+=m}u.isClosed=!0;for(let P=0,S=u.points.length;P<S;P++)u.points[P].roundness=i;u.roundness=i,u.update();let O=xr.create({shape:u,parameters:{roundness:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(O,{userData:{...n,type:"StarGeometry"}})}};var dx=require("three"),px=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.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:r,height:e}=n.parameters,t=new dx.PlaneGeometry(r,e);return Object.assign(t,{userData:{...n,type:"TextFrameGeometry"}})}};var Ga=require("three");var fx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},n.parameters),t=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:t,height:o,depth:i})}}static build(n){let{width:r,height:e,depth:t,radialSegments:o,tubularSegments:i,arc:a,cornerRadius:s,cornerSegments:l}=n.parameters,c=$A(r,e,t,r*.5,a,i,0,0,o,s,l);return c.scale(1,e/r,1),Object.assign(c,{userData:{...n,type:"TorusGeometry"}})}};function $A(n,r,e,t,o,i,a,s,l,c,u){[r,e]=[e,r],a=r/2;let p=Ga.MathUtils.clamp(o/360,0,1);if(p===0){let d=new Ga.BufferGeometry;return d.setAttribute("position",new Ga.Float32BufferAttribute([],3)),d}return p===1&&(c=0),new fl(!0,n,r,e,t,p,i,a,s,l,c,u)}var hx=require("three"),mx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.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:r,tube:e,tubularSegments:t,radialSegments:o,p:i,q:a}=n.parameters,s=r*.5;s!==e&&(s-=e);let l=new hx.TorusKnotGeometry(s,e,t,o,i,a);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var yx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof $e?n.shape:new $e,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:r=100,height:e,cornerRadius:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a,isRect:s}=n.parameters,l=n.shape,c=r*.5,u=e*.5;s?(l.addPoint(l.createPoint(-c,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))):(l.addPoint(l.createPoint(0,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))),l.isClosed=!0;for(let d=0,h=l.points.length;d<h;d++)l.points[d].roundness=t;l.roundness=t,l.update();let p=xr.create({shape:l,parameters:{roundness:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...n,type:"TriangleGeometry"}})}};var Me=require("three");function gx(n,r){let e=2*Math.PI;return(n%e+e)%e===(r%e+e)%e}var YA=new Me.Matrix4,XA=new Me.Matrix4;function KA(n,r,e){let t=[new Me.Vector3,new Me.Vector3,new Me.Vector3],o=[new Me.Vector3,new Me.Vector3,new Me.Vector3];return n.extractBasis(t[0],t[1],t[2]),r.extractBasis(o[0],o[1],o[2]),t.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(t[0],t[1],t[2])}var xx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=r?.shapeData??La.create({parameters:gp}).userData.shape;return{path:n.path??fa.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:i,extrusion:{...Qc,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new df(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new Me.BufferGeometry,{userData:{...n,type:"PathGeometry"}})}},df=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)||!gx(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=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),c=Math.min(Math.max(2,l-s+1),a+2),u=[],p=[];for(let F=0;F<c;F++){let k=this.inputs.path.isClosed?(F+s)%e.length:Math.min(F+s,e.length-1);u.push(e[k].clone()),p.push(t[k].clone())}let d=(F,k,H)=>{u[F]=u[F].clone().lerp(u[k],H),p[F]=KA(p[F],p[k],H)},h=0,f=i*a%1;(!this.inputs.path.isClosed||o<=1)&&(f||i===0)&&(h=f,d(0,1,h));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,d(u.length-1,u.length-2,1-m)),o===0){let F=u.length-1;u[F].copy(u[0]),p[F].copy(p[0])}this._applyPathModifiers(p,h,m);let{bevel:g,bevelSides:v}=this.inputs.parameters.extrusion,O=g>0?this.inputs.parameters.extrusion.capType:"flat",P=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(P=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:I}=this._computeShapePoints(P),x=0,_;O==="round"&&(_=new Dn(this.inputs.shapeData,2*g,g,P,v,void 0,!0),x=_.getAttribute("position").count);let D=0,A=0;T.sort((F,k)=>F.start-k.start),T.forEach(F=>{F.verticesStart=D,F.verticesCount=F.continuous.reduce((k,H,$)=>k+($===0||!H?2:1),0),A+=F.verticesCount,D=A});let N=A*c,E,B=0;if(this._isOpenEnded()&&O==="flat"){try{E=ro({windingRule:We.ODD,elementType:gt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{E=tf}B=E.vertexCount}let V=N+2*B+x*2,j=N+2*B,R={positions:new Float32Array(V*3),normals:new Float32Array(V*3),uvs:new Float32Array(V*2)},W=[];if(T.forEach(F=>{this._extrudeRegion(F,I,p,u,R,W,this._isGeometryClosed()&&!this._isOpenEnded())}),E&&(this._closeEnd(E,N,W,R,p[0],u[0],!1),this._closeEnd(E,N+B,W,R,p[p.length-1],u[u.length-1],!0)),_){R.positions.set(_.getAttribute("position").array,j*3),R.normals.set(_.getAttribute("normal").array,j*3),R.uvs.set(_.getAttribute("uv").array,j*2);for(let $=j;$<j+x;$++)R.uvs[$*2+1]=1e-4;let F=W.length;W.push(..._.getIndex().array.map($=>$+j)),j+=x,R.positions.set(_.getAttribute("position").array,j*3),R.normals.set(_.getAttribute("normal").array,j*3),R.uvs.set(_.getAttribute("uv").array,j*2);let k=W.length;W.push(..._.getIndex().array.map($=>$+j)),this.setAttribute("position",new Me.BufferAttribute(R.positions,3)),this.setAttribute("normal",new Me.BufferAttribute(R.normals,3)),this.setAttribute("uv",new Me.BufferAttribute(R.uvs,2)),this.setIndex(W);let H=YA;H.copy(p[p.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,j,V),H.copy(p[0]).setPosition(u[0]).multiply(XA.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,j-x,j),this.reverseIndicesOnRange(F,k)}else this.setAttribute("position",new Me.BufferAttribute(R.positions,3)),this.setAttribute("normal",new Me.BufferAttribute(R.normals,3)),this.setAttribute("uv",new Me.BufferAttribute(R.uvs,2)),this.setIndex(W)}_extractPathPoints(){let t=gu(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(t.length<2)return[];let o=[t[0]];return t.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 t=[],o=e.length,i=this.inputs.path.isClosed,a=new Me.Vector3,s=new Me.Vector3,l=new Me.Vector3,c=new Me.Vector3,u=new Me.Vector3(0,1,0);for(let y=0;y<o;y++){let g=e[y],v;y===0?v=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let O;y===o-1?O=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):O=e[y+1];let P=g.clone().sub(v).normalize(),S=O.clone().sub(g).normalize(),T=P.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let I=u.clone().cross(T).normalize(),x=T.clone().cross(I).normalize();u.copy(x),c.copy(I),y===0&&(a.copy(x),s.copy(T));let _=new Me.Matrix4().makeBasis(I,x,T);t.push(_)}let p=i?s:l,d=i?a:new Me.Vector3(0,1,0),h=p.clone().cross(c).normalize(),f=Math.acos(d.dot(h));if(isNaN(f))return t;let m=d.clone().cross(h);p.dot(m)>0&&(f*=-1);for(let y=1;y<t.length;y++){let g=new Me.Matrix4().makeRotationZ(f*y/t.length);t[y].multiply(g)}return t}_applyPathModifiers(e,t,o){let i=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new Me.Matrix4,p=new Me.Matrix4;return e.forEach((d,h)=>{let f=h===0?0:h===i-1?1:(h-t)/(i-(o===0?0:1)-(t+(1-o)));u.makeRotationZ(Me.MathUtils.lerp(a,a+s,f)*Me.MathUtils.DEG2RAD);let m=Me.MathUtils.lerp(l,c,f);p.makeScale(m,m,m),d.multiply(u).multiply(p)}),e}_computeShapePoints(e=12,t=We.ODD){let o=this.inputs.shapeData,i=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let v=y.length-1;v>=1;v-=2){let O=y[v-1],P=y[v-0];g.push(O,P)}return g}),s;try{s=ro({windingRule:t,elementType:gt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{s=pl}let l;try{l=ro({windingRule:We.ODD,elementType:gt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=ef}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let u=1/0,p=-1/0,d=1/0,h=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,v=s.vertices[g+0],O=s.vertices[g+1];v<u&&(u=v),v>p&&(p=v),O<d&&(d=O),O>h&&(h=O)}let f=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,v=s.elements[g+0],O=s.elements[g+1],P=v+O,S={start:v,count:O,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};f.push(S);let T=v,I=P-1,x=v+1,_=o.roundedCurves.length;do{let D=T-v,A=s.vertices[I*2+0],N=s.vertices[I*2+1],E=s.vertices[T*2+0],B=s.vertices[T*2+1],V=s.vertices[x*2+0],j=s.vertices[x*2+1],R=E-A,W=B-N,F=Math.sqrt(R*R+W*W);R/=F,W/=F;let k=E-V,H=B-j,$=Math.sqrt(k*k+H*H);k/=$,H/=$,S.normals[D*2+0]=-H,S.normals[D*2+1]=k;let J=s.vertexIndices[T];if(Array.isArray(J))S.continuous[D]=!1;else{let[Z,X]=o.getCurveIndexFromVertexId(J-1,!0);if(X>0&&X<1)S.continuous[D]=!0;else{let te=X===1?Z+1:Z-1;te=(te+_)%_;let Y=X===1?0:1,ee=o.roundedCurves[Z].getTangent(X),K=o.roundedCurves[te].getTangent(Y);S.continuous[D]=ee.dot(K)>.95}}y&&(S.normals[D*2+0]*=-1,S.normals[D*2+1]*=-1),[I,T,x]=[T,x,x+1],x>=P&&(x-=O)}while(x!==v+1)}return{regions:[i,...a],infos:f,vertices:s.vertices}}_insertVertex(e,t,o,i,a){let s=t*2,l=t*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,t,o,i,a,s,l){let c=new Me.Vector3,u=new Me.Vector3,p=new Me.Vector3,d=new Me.Vector3,h=new Me.Vector2;o.forEach((m,y)=>{let g=i[y],v=e.verticesStart*o.length+e.verticesCount*y;for(let O=0;O<e.count;O++){let P=(e.start+O)*2;if(c.set(t[P+0],t[P+1],0),p.copy(c).applyMatrix4(m).add(g),e.continuous[O])d.set(e.normals[O*2+0],e.normals[O*2+1],0);else{let S=O===0?(e.start+e.count-1)*2:P-2;u.set(t[S+0],t[S+1],0),d.copy(c).sub(u),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(m).normalize(),h.set(O===0?1:O/e.count,y/(o.length-1)),this._insertVertex(a,v,p,d,h),v++,!e.continuous[O]||O===0){if(O===0)d.set(e.normals[O*2+0],e.normals[O*2+1],0),h.set(0,y/(o.length-1));else{let S=O===e.count-1?e.start*2:P+2;u.set(t[S+0],t[S+1],0),d.copy(u).sub(c),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(m).normalize(),this._insertVertex(a,v,p,d,h),v++}}});let f=o.length-1;for(let m=0;m<f;m++){let y=e.verticesStart*o.length+e.verticesCount*m,g=e.verticesStart*o.length+e.verticesCount*(m+1),v=0;for(let O=0;O<e.count;O++){(!e.continuous[O]||O===0)&&v++;let P=O===e.count-1?0:v+1,S=y+v,T=y+P,I=g+P,x=g+v;e.isHole?s.push(S,I,T,S,x,I):s.push(S,T,I,S,I,x),v++}}}_closeEnd(e,t,o,i,a,s,l){let c=e.vertexCount,u=new Me.Vector3(0,0,l?-1:1).applyMatrix4(a),p=new Me.Vector3,d=new Me.Vector2;for(let f=0;f<c;f++){let m=2*f;p.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(i,t+f,p,u,d)}let h=e.elements;for(let f=0;f<e.elementCount;f++){let m=3*f,y=h[m+0]+t,g=h[m+(l?1:2)]+t,v=h[m+(l?2:1)]+t;o.push(y,g,v)}}applyMatrix4OnRange(e,t,o){let i=e.elements,a=new Me.Matrix3().getNormalMatrix(e).elements,s,l,c,u,p=this.attributes.position,d=this.attributes.normal;if(!p||!d)return;let h=p.array,f=d.array,m=p.itemSize;for(let y=t*m,g=o*m;y<g;y+=m){if(y===t)debugger;s=h[y+0],l=h[y+1],c=h[y+2],u=1/(i[3]*s+i[7]*l+i[11]*c+i[15]),h[y+0]=(i[0]*s+i[4]*l+i[8]*c+i[12])*u,h[y+1]=(i[1]*s+i[5]*l+i[9]*c+i[13])*u,h[y+2]=(i[2]*s+i[6]*l+i[10]*c+i[14])*u,s=f[y+0],l=f[y+1],c=f[y+2],f[y+0]=a[0]*s+a[3]*l+a[6]*c,f[y+1]=a[1]*s+a[4]*l+a[7]*c,f[y+2]=a[2]*s+a[5]*l+a[8]*c}p.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,t){let o=this.index;if(o){for(let i=e;i<t;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 pi=require("three"),bx=require("three/examples/jsm/utils/BufferGeometryUtils.js");function vx(){let n=new pi.BufferGeometry;return n.setAttribute("position",new pi.BufferAttribute(new Float32Array([]),3)),n.setIndex(new pi.BufferAttribute(new Uint16Array([]),1)),n}var ZA=vx().attributes,JA=12,eM=1,ja=class extends pi.BufferGeometry{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,ZA),this.userData={parameters:e,type:"TextGeometry"};let o=t.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let o=t.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.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:c,textTransform:u}=e,p=au.getDisplayedValue(c),d=u===2?p.toUpperCase():u===3?p.toLowerCase():p,h=tM(e,t,d),{shapes:f,charWidths:m,charCoords:y}=t.generateShapes(h,e),g=(typeof o=="number"?o:1)*.5,v=(typeof i=="number"?i:1)*.5,O=f.map(T=>new $e().fromShape(T,!0));this.vectorShapes=O;let P=O.map(T=>xr.create({shape:T,parameters:{depth:a,extrudeBevelSegments:l,extrudeBevelSize:s,windingRule:a<=0?We.NONZERO:We.ODD,subdivisions:this.isLowResolution&&a>0?eM:JA}})),S=P.length?(0,bx.mergeBufferGeometries)(P):vx();S.translate(-g,v,0),this.dispose(),this.wrappedText=h,this.charCoords=y,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(S.attributes).forEach(([T,I])=>{this.setAttribute(T,I)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=sr(new pi.BufferGeometry,ja.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,o])=>{this.setAttribute(t,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 tM(n,r,e){let t=[""],o="";for(let i of e)o+=i,i===" "||i===`
|
|
3
|
+
`?(t[t.length-1]+=o,o="",i===`
|
|
4
|
+
`&&t.push("")):r.getTextWidth(t[t.length-1]+o,n)>n.width&&(t[t.length-1].length&&t.push(""),r.getTextWidth(t[t.length-1]+o,n)>n.width&&(o.length===1?(t[t.length-1]+=o,o=""):(t[t.length-1]+=o.slice(0,-1),o=o[o.length-1],t.push(""))));return t[t.length-1]+=o,t}var it=require("three");var wx,Eu=new Promise(n=>{wx=n}),Sx=!1;var Du;function Px(){if(Sx)return;if(Du)return Du;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.0.64/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(c=>c.arrayBuffer())]),s=i.default,l=await s({wasmBinary:a});wx(l),Sx=!0}return Du=n(),Du}var Ox=require("three");var rM=["font"];function en(n,r,e,t){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let c of a){let u=i;for(let p of c)u=u[p];for(o in u){let p=u[o];hp(p)&&!rM.includes(o)&&(u[o]=r.getVariable(p,[t.uuid,"geometry",...c,o]),hp(u[o])&&(u[o]=1))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let c=$e.createFromState(i.shape,i.width,i.height);s.shape=c}else if(i.type==="NonParametricGeometry")i.data.groups&&i.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new Ox.BufferGeometryLoader().parse(i);else if(i.type==="SubdivGeometry"){let c=new It(i,e);return c.data=n,c}else{if(i.type==="TextGeometry")return new ja(i,r);if(i.type==="UIGeometry")return za.create({parameters:{width:i.width,height:i.height,cornerRadius:i.cornerRadius,cornerType:i.cornerType}})}let l;try{l=pf(s)}catch(c){console.error(c)}if(!l){let c=$e.createFromState(pa.defaultData(),100,100);s.shape=c,l=pf(s)}return l}var Cx=require("three"),oM=new Cx.Matrix4;function yl(n,r,e,t){let o=n.position.array,i=n.normal.array,a=oM.makeScale(r,e,t).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=r,o[u+1]*=e,o[u+2]*=t,s=i[u],l=i[u+1],c=i[u+2],i[u]=a[0]*s+a[4]*l+a[8]*c,i[u+1]=a[1]*s+a[5]*l+a[9]*c,i[u+2]=a[2]*s+a[6]*l+a[10]*c;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var _u=new it.Box3,Fa=new it.Vector3,we;Eu.then(n=>{we=n});var Tx=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Ax=new Uint32Array([0,1,2,3]),Mx=new Uint8Array([4]),It=class extends it.BufferGeometry{constructor(e,t){super();this.data=e;this.flatShading=t;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let o=this.data.scaleBaked,i=bn.div(t,o);this.subdividedGeometry&&yl(this.subdividedGeometry.attributes,...i),this.originalGeometry&&yl(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(Fa.fromArray(i));let s=Fa.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,t,o;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:o}=It.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new it.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(It.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new it.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;_u.setFromBufferAttribute(t),_u.getCenter(o),e.boundingSphere.radius=o.distanceTo(_u.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),_u.getSize(Fa);let i={width:Fa.x,height:Fa.y,depth:Fa.z};return this.userData.parameters=i,i}static build(e,t,o,i){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),t&&(we.free_bvh(t),we.free_subdivision_surface(t));try{a=It.allocate(e,i)}catch(u){console.error(u,e),a=It.allocate({positionWASM:Tx,indexWASM:Ax,verticesPerFaceWASM:Mx},i)}if(we.set_destination_refinement_level(a,0),s=It.buildLevel(a,!0,c),e.subdivisions>0)try{we.set_destination_refinement_level(a,e.subdivisions),l=It.buildLevel(a,!1,c)}catch{try{we.set_destination_refinement_level(a,e.subdivisions-1),l=It.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,t,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?t.geometry:en(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,l,c,u;({positions:s,triIndices:u}=yf(i.getAttribute("position"),a));let p;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,h=d+e.radialSegments*3;p=[d,h]}return{indices:l,verticesPerFace:c}=gf(s,u,i,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,t){let o,i,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=Tx,i=Ax,a=Mx);let c=o.length,u=i.length,p=a.length,d=o.length+s.length+l.length,h=i.length+a.length,f=d*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,y=h*Uint32Array.BYTES_PER_ELEMENT,g=we._malloc(f),v=new Float32Array(we.HEAPF32.buffer,g,d),O=new Uint32Array(we.HEAPU32.buffer,g+m,h);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),O.set(i,0),O.set(a,i.length);let P;e?.scaleBaked?.some(T=>T!==1)&&(P=new it.Matrix4().makeScale(...e.scaleBaked)),t&&(P?P.premultiply(t):P=t);let S=P?we.alloc_subdivision_surface2(g,c,g+m,u,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p,P.elements):we.alloc_subdivision_surface(g,c,g+m,u,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p);return we._free(g),S}static buildLevel(e,t,o,i,a){let s=a?we.get_mesh_data2(e,t?we.Level.CONTROL:we.Level.REFINED,o,a.elements):we.get_mesh_data(e,t?we.Level.CONTROL:we.Level.REFINED,o),l=8,c=we.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=we.HEAPU32[c[p]>>2],h=we.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let f=we.HEAPU32[c[p]>>2],m=we.HEAPF32.subarray(f>>2,(f>>2)+u[p]);p++;let y=we.HEAPU32[c[p]>>2],g=we.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=we.HEAPU32[c[p]>>2],O=we.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,i===void 0){let P=new it.BufferGeometry;if(P.setIndex(new it.Uint32BufferAttribute(O,1)),P.setAttribute("position",new it.Float32BufferAttribute(h,3)),P.setAttribute("normal",new it.Float32BufferAttribute(m,3)),t){P.setAttribute("faceMap",new it.Uint32BufferAttribute(g,1));let S=new Float32Array(m.length/3*4).fill(0);P.setAttribute("color",new it.BufferAttribute(S,4))}return we.free_mesh_data(s),P.userData.type="SubdivGeometry",P}i.getAttribute("position").copyArray(h),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,we.free_mesh_data(s)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),c=0,u=we.HEAPU32[s[c]>>2],p=we.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=we.HEAPU32[s[c]>>2],h=we.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(t===void 0){let f=new it.BufferGeometry;f.setAttribute("position",new it.Float32BufferAttribute(p,3));let m=new Float32Array(p.length);for(let y=0,g=p.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return f.setAttribute("color",new it.BufferAttribute(m,3)),f.setIndex(new it.Uint32BufferAttribute(h,1)),we.free_wireframe_data_for_base_level(i),f}t.getAttribute("position").copyArray(p),t.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||we.set_destination_refinement_level(e,t);let a=o?we.get_topological_data2(e,i?we.Level.CONTROL:we.Level.REFINED,o.elements):we.get_topological_data(e,i?we.Level.CONTROL:we.Level.REFINED),s=6,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=we.HEAPU32[l[u]>>2],d=new Float32Array(we.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let h=we.HEAPU32[l[u]>>2],f=new Uint32Array(we.HEAPU32.subarray(h>>2,(h>>2)+c[u]));u++;let m=we.HEAPU32[l[u]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return we.free_topological_data(a),{positions:d,indices:f,verticesPerFace:y}}};var Ix=["getX","getY","getZ"];function yf(n,r){let e={},t=r?r.count:n.count,o=0,i=[],a=[],s=1e4;for(let c=0;c<t;c++){let u=r?r.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(n[Ix[d]](u)*s)},`;if(p in e)i.push(e[p]);else{for(let d=0;d<3;d++)a.push(n[Ix[d]](u));e[p]=o,i.push(o),o++}}let l=[];for(let c=0;c<i.length;c+=3)i[c]===i[c+1]||i[c]===i[c+2]||i[c+1]===i[c+2]||l.push(i[c],i[c+1],i[c+2]);return{positions:a,triIndices:l}}var Bu=new it.Vector3,ff=new it.Vector3,hf=new it.Vector3,mf=new it.Vector3;function gf(n,r,e,t){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([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/c;l=l.filter((h,f)=>Math.floor(f/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);n.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)n.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)n.push(l[d],l[d+1],0),o.push(p++);return i.push(p),{indices:o,verticesPerFace:i}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<r.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[r[s]*3+2]===a||n[r[s]*3+2]===0)&&l++,(n[r[s+1]*3+2]===a||n[r[s+1]*3+2]===0)&&l++,(n[r[s+2]*3+2]===a||n[r[s+2]*3+2]===0)&&l++,l===3)break}if(r[s+1]===r[s+3]&&r[s+2]===r[s+5]||r[s+0]===r[s+3]&&r[s+2]===r[s+4]){Bu.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),ff.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),hf.set(n[r[s+4]*3],n[r[s+4]*3+1],n[r[s+4]*3+2]),mf.set(n[r[s+5]*3],n[r[s+5]*3+1],n[r[s+5]*3+2]),ff.sub(Bu).normalize(),hf.sub(Bu).normalize(),mf.sub(Bu).normalize();let l=ff.cross(hf).dot(mf);Math.abs(l)>.005||t&&t.some((c,u)=>u%2===1?!1:s>=t[u]&&s<t[u+1])?(o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3):(o.push(r[s],r[s+1],r[s+4],r[s+5]),i.push(4),s+=6)}else o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<n.length;p+=3,d++)n[p+2]===0&&(l.push(d),u++),n[p+2]===a&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let p=c[0];c[0]=c[1],c[1]=p}l.reverse(),o.push(...l,...c),i.push(u,u)}return{indices:o,verticesPerFace:i}}var Gr={};Ch(Gr,{calcBoolean:()=>sM,calcBooleanTopological:()=>aM,freeMeshSet:()=>dM,getMeshSet:()=>lM,hasOpenEdges:()=>cM,transformMeshSet:()=>uM});var nM,Nx=new Promise(n=>{nM=n});var gl=require("three");var Le,Ua;Nx.then(n=>Le=n);function iM(n,r,e){let t,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:a}=yf(n.getAttribute("position"),o),s;if(r&&e){let{indices:l,verticesPerFace:c}=gf(i,a,n);s=c.length,t=[];for(let u=0,p=0;u<s;u++){t.push(c[u]);for(let d=0;d<c[u];d++)t.push(l[p++])}}else{let l=a.length;t=Array(l+l/3),s=0;for(let c=0,u=0;u<t.length;)t[u++]=3,s++,t[u++]=a[c++],t[u++]=a[c++],t[u++]=a[c++]}return{positions:i,faceIndices:t,nFaces:s}}function Dx(n){let r=n.length,e=r*Uint32Array.BYTES_PER_ELEMENT,t=r*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:t,i=Le._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Le.HEAPU32.buffer,i,r):new Float32Array(Le.HEAPF32.buffer,i,r)).set(n,0),i}function Ex(n){switch(n){case 0:return Le.OP.UNION;case 1:return Le.OP.INTERSECTION;case 2:return Le.OP.A_MINUS_B;case 3:return Le.OP.B_MINUS_A;case 4:return Le.OP.SYMMETRIC_DIFFERENCE;case 5:return Le.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function aM(n,r){Ua===void 0&&(Ua=Le.init_csg());let e=Dx(n),t=Le.csg_calc_topological(Ua,e,n.length,Ex(r));Le._free(e);let o=6,i=Le.HEAPU32.subarray(t>>2,(t>>2)+o),a=i.subarray(3,3+3),s=0,l=Le.HEAPU32[i[s]>>2],c=new Float32Array(Le.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Le.HEAPU32[i[s]>>2],p=new Uint32Array(Le.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Le.HEAPU32[i[s]>>2],h=new Uint8Array(Le.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Le.free_mesh_data(t),{positions:c,indices:p,verticesPerFace:h}}function sM(n,r,e,t){Ua===void 0&&(Ua=Le.init_csg());let o=Dx(n),i=Le.csg_calc(Ua,o,n.length,t,Ex(r));Le._free(o);let a=5,s=Le.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),c=0,u=Le.HEAPU32[s[c]>>2],p=Le.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Le.HEAPU32[s[c]>>2],h=Le.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let f=l[c];e.setAttribute("position",new gl.Float32BufferAttribute(p,3)),e.setAttribute("normal",new gl.Float32BufferAttribute(h,3));let m=Le.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new gl.Sphere),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Le.free_mesh_data(i),f}function lM(n,r,e){if(Le===void 0)return-1;let t,o,i;if(r&&n.userData.positions!==void 0){let g=n.userData;i=g.verticesPerFace.length,t=g.positions,o=Array(g.verticesPerFace.reduce((v,O)=>v+O,0)+i);for(let v=0,O=0,P=0;v<g.verticesPerFace.length;v++){o[P++]=g.verticesPerFace[v];for(let S=0;S<g.verticesPerFace[v];S++)o[P++]=g.indices[O++]}}else({positions:t,faceIndices:o,nFaces:i}=iM(n,r,e));let a=t.length,s=o.length,l=t.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,h=Le._malloc(u),f=new Float32Array(Le.HEAPF32.buffer,h,l),m=new Uint32Array(Le.HEAPU32.buffer,h+p,c);f.set(t,0),m.set(o,0);let y=Le.get_csg_mesh(h,a,h+p,s,i);return Le._free(h),y}function cM(n){return Le.has_open_edges(n)}function uM(n,r){Le.transform_csg_mesh(n,r.elements)}function dM(n){Le.free_csg_mesh(n)}var pM={ConeGeometry:v0,CubeGeometry:S0,CylinderGeometry:b0,DodecahedronGeometry:P0,EllipseGeometry:La,HelixGeometry:Z0,IcosahedronGeometry:ex,LatheGeometry:tx,NonParametricGeometry:ix,PolygonGeometry:Iu,PyramidGeometry:ax,RectangleGeometry:za,SphereGeometry:sx,PlaneGeometry:cx,BackdropGeometry:ux,StarGeometry:Nu,TextFrameGeometry:px,TorusGeometry:fx,TorusKnotGeometry:mx,TriangleGeometry:yx,PathGeometry:xx,VectorGeometry:xr},pf=n=>pM[n.type].create(n);function ka(n){return n!==null&&"booleanOp"in n}var Ha=class extends Aa(Lu.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new Lu.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!ka(this.parent)&&this.visible,ka(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(),ka(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Ha&&(e.freeBooleanPointer(),ka(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let o=super.updateTransformState(e,t);return o&&ka(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),ka(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Ru=new Wa.Box3;function xl(n,r=0,e=n.count,t,o){let i=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=r;p<e;p++){let d=n.getX(p),h=n.getY(p),f=n.getZ(p);d<i&&(i=d),h<a&&(a=h),f<s&&(s=f),d>l&&(l=d),h>c&&(c=h),f>u&&(u=f)}Ru.min.set(i,a,s),Ru.max.set(l,c,u),Ru.getCenter(t),Ru.getSize(o).multiplyScalar(.5)}var fM=new Wa.BufferGeometry,hM=new Wa.MeshBasicMaterial,zt=class extends Ha{constructor(r,e){super(fM,hM),this.super_Entity(r,e)}updateState(r,e){this.updateState_Entity(r,e)}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?xl(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var on=require("three");var Er=require("three");var rb=require("three");var so=require("three");var bl=class{constructor(r){r=r??{},this.name=r.name,this.type=r.type,this.node=r.node,this.size=r.size,this.needsUpdate=r.needsUpdate}get value(){return this.node.value}set value(r){this.node.value=r}};var _x=require("three"),qt=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=_x.MathUtils.generateUUID(),this.type=r,this.name=""}analyze(r,e){e=e??{},r.analyzing=!0,this.build(r.addFlow(e.slot,e.cache,e.context),"v4"),r.clearVertexNodeCode(),r.clearFragmentNodeCode(),r.removeFlow(),r.analyzing=!1}analyzeAndFlow(r,e,t){return t=t??{},this.analyze(r,t),this.flow(r,e,t)}flow(r,e,t){t=t??{},r.addFlow(t.slot,t.cache,t.context);let o={result:this.build(r,e),code:r.clearNodeCode(),extra:r.context.extra};return r.removeFlow(),o}build(r,e,t){e=e??this.getType(r,e);let o=r.getNodeData(t??this);return r.analyzing&&this.appendDepsNode(r,o,e),r.nodes.indexOf(this)===-1&&r.nodes.push(this),this.updateFrame!==void 0&&r.updaters.indexOf(this)===-1&&r.updaters.push(this),this.generate(r,e,t)}updateFrame(r){}generateReadonly(r,e,t,o,i,a){return""}generate(r,e,t,o,i){return""}parse(r,e,t,o){}appendDepsNode(r,e,t){e.deps=(e.deps||0)+1;let o=r.getTypeLength(t);(o>(e.outputMax||0)||this.getType(r,t))&&(e.outputMax=o,e.output=t)}setName(r){this.name=r}getName(){return this.name}getType(r,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let r="{",e,t;for(e in this)t=this[e],t instanceof qt&&(r+='"'+e+'":'+t.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)e=this.hashProperties[o],t=this[e],r+='"'+e+'":"'+String(t)+'",';return r+='"id":"'+this.uuid+'"}',r}};var xf=class{constructor(){this.nodes={};this.keywords={}}add(r){this.nodes[r.name]=r}addKeyword(r,e,t){t=t!==void 0?t:!0,this.keywords[r]={callback:e,cache:t}}remove(r){delete this.nodes[r.name]}removeKeyword(r){delete this.keywords[r]}get(r){return this.nodes[r]}getKeyword(r,e){return this.keywords[r].callback(e)}getKeywordData(r){return this.keywords[r]}contains(r){return this.nodes[r]!==void 0}containsKeyword(r){return this.keywords[r]!==void 0}},Gt=new xf;var bf=require("three");var Bx=require("three"),ge=class extends qt{constructor(e,t){super(e);this.scope="";t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,o,i){if(t=t??this.getType(e),this.getShared(e,t)){let a=this.getUnique(e,t);a&&this.uuid===void 0&&(this.uuid=Bx.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,t),this.generate(e,t,o)):super.build(e,t,o);if(a)return s.name=s.name||super.build(e,t,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,t,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,t);{c=super.generate(e,t,o,s.output,i);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,t)}}return super.build(e,t,o)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let o=e.getVars()[t];return o?o.name:void 0}generate(e,t,o,i,a){return this.getShared(e,t)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),a,this.getLabel()).name}};var et=class extends ge{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,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,t,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,t)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,t))}};var xt=class extends et{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof bf.Vector2?e:new bf.Vector2(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,o,i,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}};var vf=require("three");var Zt=class extends et{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof vf.Vector3?e:new vf.Vector3(e,t,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,t,o,i,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}};var Lx=require("three"),jt=class extends Lx.Color{constructor(e,t,o,i){super(e,t,o);this.isColorA=!0;this.a=i}setRGBA(e,t,o,i){super.setRGB(e,t,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,t="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,t);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,t);break}}return super.setStyle(e,t)}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 br=class extends et{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof jt?e:new jt(e.r,e.g,e.b,e.a)}generateReadonly(e,t,o,i,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}};var mM=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Rx=/[a-z_0-9]+/gi,re=class extends ge{constructor(e,t,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,t,o,i)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,o,i,a){let s,l=0,c=this.src;if(this.includes)for(let p=0;p<this.includes.length;p++)e.include(this.includes[p],this);for(let p in this.extensions)e.extensions[p]=!0;let u=[];for(;s=Rx.exec(this.src);)u.push(s);for(let p=0;p<u.length;p++){let d=u[p],h=d[0],f=this.isMethod?!this.getInputByName(h):!0,m=h;if(this.keywords[h]||this.useKeywords&&f&&Gt.containsKeyword(h)){let y=this.keywords[h];if(!y){let g=Gt.getKeywordData(h);g.cache&&(y=e.keywords[h]),y=y||Gt.getKeyword(h,e),g.cache&&(e.keywords[h]=y)}m=y.build(e)}h!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+h.length+l),l+=m.length-h.length),this.getIncludeByName(m)===void 0&&Gt.contains(m)&&e.include(Gt.get(m))}return t==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),t)}parse(e,t,o,i){if(this.src=e||"",this.includes=t??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let a=mM.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Rx);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let p=s[l++];this.inputs.push({name:p,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var yM=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Sf=class extends ge{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Sf.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,o,i,a){this.src=e||"";let s,l,c="",u=yM.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,o,i,a){return e.format(this.name,this.getType(e),t)}},qe=Sf;qe.PI="PI",qe.PI2="PI2",qe.RECIPROCAL_PI="RECIPROCAL_PI",qe.RECIPROCAL_PI2="RECIPROCAL_PI2",qe.LOG2="LOG2",qe.EPSILON="EPSILON";var gM=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
5
|
+
)*?)}`,"gim"),xM=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),qa=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 t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,o,i,a){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=gM.exec(e);if(t){let o=t[2],i;for(;i=xM.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}};var $a=class extends ge{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,t){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),t)}};Gt.addKeyword("uv",function(){return new $a});Gt.addKeyword("uv2",function(){return new $a(1)});var Vu=require("three");var fi=class extends ge{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??fi.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Vu.LinearEncoding:return["Linear"];case Vu.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),i=this.getType(e),a=fi.Nodes[this.method],s=e.include(a);if(s===fi.LINEAR_TO_LINEAR)return e.format(o,i,t);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",i,t)}else return e.format(s+"( "+o+" )",i,t)}fromEncoding(e){let t=fi.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=fi.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},cr=fi;cr.Nodes={LinearToLinear:new re(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
20
6
|
`)),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
7
|
`)),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
|
-
`))},
|
|
8
|
+
`))},cr.LINEAR_TO_LINEAR="LinearToLinear",cr.SRGB_TO_LINEAR="sRGBToLinear",cr.LINEAR_TO_SRGB="LinearTosRGB";var Xe=class extends re{constructor(e="",t,o,i,a){super(e,a,i,o,t);this.nodeType="Expression"}};var Vx=require("three"),ur=class extends et{constructor(e=new Vx.Texture,t,o,i){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t??new $a,this.bias=o,this.project=i!==void 0?i:!1}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){if(t==="sampler2D")return this.getTexture(e,t);let o=this.getTexture(e,t),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 c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new cr(new Xe("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,u),e.removeContext(),e.format(l,u,t)}};var se=class extends et{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,t,o,i,a,s){return e.format(this.value+(this.value%1?"":".0"),i,t)}};var vl=class extends ge{constructor(e,t){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=t??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,o,i,a){i=this.getType(e);let s=this.value,l=s.build(e,t)+"( ",c=[];if(s.inputs){for(let u=0;u<s.inputs.length;u++){let p=s.inputs[u],d=this.inputs[u]||this.inputs[p.name];c.push(d.build(e,e.getTypeByFormat(p.type)))}l+=c.join(", ")+" )"}return e.format(l,i,t)}};var wf=class extends ge{constructor(e,t,o=wf.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=t,this.op=o}getType(e){let t=this.a.getType(e),o=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(o)>e.getTypeLength(t)?o:t}generate(e,t){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,t)}},$t=wf;$t.ADD="+",$t.SUB="-",$t.MUL="*",$t.DIV="/";var tt=class extends ge{constructor(e,t=tt.ABS,o,i){super();this.nodeType="Math";this.a=e,typeof t!="string"?this.b=t:i=t,typeof o!="string"?this.c=o:i=o,this.method=i,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case tt.MIX:case tt.CLAMP:case tt.REFRACT:case tt.SMOOTHSTEP:case tt.FACEFORWARD:return 3;case tt.MIN:case tt.MAX:case tt.MOD:case tt.STEP:case tt.REFLECT:case tt.DISTANCE:case tt.DOT:case tt.CROSS:case tt.POW:return 2;default:return 1}}getInputType(e){let t=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 t>o&&t>i?this.a.getType(e):o>i?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case tt.LENGTH:case tt.DISTANCE:case tt.DOT:return"f";case tt.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let o,i,a,s=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,c=this.c?e.getTypeLength(this.c.getType(e)):0,u=this.getInputType(e),p=this.getType(e);switch(this.type=p,this.method){case tt.NEGATE:return e.format("( -"+this.a.build(e,u)+" )",u,t);case tt.INVERT:return e.format("( 1.0 - "+this.a.build(e,u)+" )",u,t);case tt.CROSS:o=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case tt.STEP:o=this.a.build(e,s===1?"f":u),i=this.b.build(e,u);break;case tt.MIN:case tt.MAX:case tt.MOD:o=this.a.build(e,u),i=this.b.build(e,l===1?"f":u);break;case tt.REFRACT:o=this.a.build(e,u),i=this.b.build(e,u),a=this.c.build(e,"f");break;case tt.MIX:o=this.a.build(e,u),i=this.b.build(e,u),a=this.c.build(e,c===1?"f":u);break;default:o=this.a.build(e,u),this.b&&(i=this.b.build(e,u)),this.c&&(a=this.c.build(e,u));break}let d=[];d.push(o),i&&d.push(i),a&&d.push(a);let h=this.getNumInputs(e);if(d.length!==h)throw Error(`Arguments not match used in "${this.method}". Require ${h}, currently ${d.length}.`);return e.format(this.method+"( "+d.join(", ")+" )",p,t)}},Te=tt;Te.RAD="radians",Te.DEG="degrees",Te.EXP="exp",Te.EXP2="exp2",Te.LOG="log",Te.LOG2="log2",Te.SQRT="sqrt",Te.INV_SQRT="inversesqrt",Te.FLOOR="floor",Te.CEIL="ceil",Te.NORMALIZE="normalize",Te.FRACT="fract",Te.SATURATE="saturate",Te.SIN="sin",Te.COS="cos",Te.TAN="tan",Te.ASIN="asin",Te.ACOS="acos",Te.ARCTAN="atan",Te.ABS="abs",Te.SIGN="sign",Te.LENGTH="length",Te.NEGATE="negate",Te.INVERT="invert",Te.MIN="min",Te.MAX="max",Te.MOD="mod",Te.STEP="step",Te.REFLECT="reflect",Te.DISTANCE="distance",Te.DOT="dot",Te.CROSS="cross",Te.POW="pow",Te.MIX="mix",Te.CLAMP="clamp",Te.REFRACT="refract",Te.SMOOTHSTEP="smoothstep",Te.FACEFORWARD="faceforward";var Ya=class extends ge{constructor(e,t,o){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=t,this.bias=o}bilinearCubeUV(e,t,o,i){let a=new vl(Ya.Nodes.bilinearCubeUV,[t,o,i]);this.colorSpaceTL=this.colorSpaceTL??new cr(new Xe("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new cr(new Xe("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new cr(new Xe("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new cr(new Xe("","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 Xe(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Xe(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Xe(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Xe(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new Xe("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,t){if(e.isShader("fragment")){let o=this.uv,i=this.bias||e.context.roughness,a=new vl(Ya.Nodes.roughnessToMip,[i]),s=new Te(a,Ya.Nodes.m0,Ya.Nodes.cubeUV_maxMipLevel,Te.CLAMP),l=new Te(s,Te.FLOOR),c=new Te(s,Te.FRACT),u=this.bilinearCubeUV(e,this.value,o,l),p=this.bilinearCubeUV(e,this.value,o,new $t(l,new se(1).setReadonly(!0),$t.ADD)),d=new Te(u,p,c,Te.MIX);return e.format(d.build(e),"v4",t)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)}},Xa=Ya;Xa.Nodes=function(){let e=new qa(`struct TextureCubeUVData {
|
|
23
9
|
vec4 tl;
|
|
24
10
|
vec4 tr;
|
|
25
11
|
vec4 br;
|
|
26
12
|
vec4 bl;
|
|
27
13
|
vec2 f;
|
|
28
|
-
}`),
|
|
14
|
+
}`),t=new qe("float cubeUV_maxMipLevel 8.0",!0),o=new qe("float cubeUV_minMipLevel 4.0",!0),i=new qe("float cubeUV_maxTileSize 256.0",!0),a=new qe("float cubeUV_minTileSize 16.0",!0),s=new re(`float getFace(vec3 direction) {
|
|
29
15
|
vec3 absDirection = abs(direction);
|
|
30
16
|
float face = -1.0;
|
|
31
17
|
if (absDirection.x > absDirection.z) {
|
|
@@ -56,7 +42,7 @@
|
|
|
56
42
|
uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z
|
|
57
43
|
}
|
|
58
44
|
return 0.5 * (uv + 1.0);
|
|
59
|
-
}`);l.useKeywords=!1;let
|
|
45
|
+
}`);l.useKeywords=!1;let c=new re(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
|
|
60
46
|
float face = getFace(direction);
|
|
61
47
|
float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
|
|
62
48
|
mipInt = max(mipInt, cubeUV_minMipLevel);
|
|
@@ -84,7 +70,7 @@
|
|
|
84
70
|
uv.x -= texelSize;
|
|
85
71
|
vec4 bl = texture2D(envMap, uv);
|
|
86
72
|
return TextureCubeUVData( tl, tr, br, bl, f );
|
|
87
|
-
}`,[e,s,l,
|
|
73
|
+
}`,[e,s,l,t,o,i,a]);c.useKeywords=!1;let u=new qe("float r0 1.0",!0),p=new qe("float v0 0.339",!0),d=new qe("float m0 -2.0",!0),h=new qe("float r1 0.8",!0),f=new qe("float v1 0.276",!0),m=new qe("float m1 -1.0",!0),y=new qe("float r4 0.4",!0),g=new qe("float v4 0.046",!0),v=new qe("float m4 2.0",!0),O=new qe("float r5 0.305",!0),P=new qe("float v5 0.016",!0),S=new qe("float m5 3.0",!0),T=new qe("float r6 0.21",!0),I=new qe("float v6 0.0038",!0),x=new qe("float m6 4.0",!0),_=[u,p,d,h,f,m,y,g,v,O,P,S,T,I,x],D=new re(`float roughnessToMip(float roughness) {
|
|
88
74
|
float mip = 0.0;
|
|
89
75
|
if (roughness >= r1) {
|
|
90
76
|
mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
|
|
@@ -98,7 +84,7 @@
|
|
|
98
84
|
mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
|
|
99
85
|
}
|
|
100
86
|
return mip;
|
|
101
|
-
}`,
|
|
87
|
+
}`,_);return{bilinearCubeUV:c,roughnessToMip:D,m0:d,cubeUV_maxMipLevel:t}}();var hi=class extends ge{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??hi.VIEW}getShared(){return this.scope===hi.WORLD}build(e,t,o,i){let a=e.context[this.scope+"Normal"];return a?a.build(e,t,o,i):super.build(e,t,o)}generate(e,t,o,i,a){let s;switch(this.scope){case hi.VIEW:e.isShader("vertex")?s="transformedNormal":s="geometryNormal";break;case hi.LOCAL:e.isShader("vertex")?s="objectNormal":(e.requires.normal=!0,s="vObjectNormal");break;case hi.WORLD:e.isShader("vertex")?s="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,s="vWNormal");break}return e.format(s,this.getType(e),t)}},Yt=hi;Yt.LOCAL="local",Yt.WORLD="world",Yt.VIEW="view",Yt.NORMAL="normal";Gt.addKeyword("viewNormal",function(){return new Yt(Yt.VIEW)});Gt.addKeyword("localNormal",function(){return new Yt(Yt.NORMAL)});Gt.addKeyword("worldNormal",function(){return new Yt(Yt.WORLD)});var To=class extends ge{constructor(e){super("v3");this.nodeType="Position";this.scope=e??To.LOCAL}getType(){switch(this.scope){case To.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case To.LOCAL:case To.WORLD:return!1}return!0}generate(e,t,o,i,a){let s;switch(this.scope){case To.LOCAL:e.isShader("vertex")?s="transformed":(e.requires.position=!0,s="vPosition");break;case To.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,s="vWPosition";break;case To.VIEW:s=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case To.PROJECTION:s=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(s,this.getType(),t)}},vr=To;vr.LOCAL="local",vr.WORLD="world",vr.VIEW="view",vr.PROJECTION="projection";Gt.addKeyword("position",function(){return new vr});Gt.addKeyword("worldPosition",function(){return new vr(vr.WORLD)});Gt.addKeyword("viewPosition",function(){return new vr(vr.VIEW)});var ao=class extends ge{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??ao.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case ao.SPHERE:return"v2"}return this.type}generate(e,t){let o=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case ao.VECTOR:{let a=new Yt(Yt.VIEW),s=e.context.roughness,l=a.build(e,"v3"),c=new vr(vr.VIEW).build(e,"v3"),u=s?s.build(e,"f"):void 0,p=`reflect( -normalize( ${c} ), ${l} )`;u&&(p=`normalize( mix( ${p}, ${l}, ${u} * ${u} ) )`);let d=`inverseTransformDirection( ${p}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${d};`),i="reflectVec"):i=d;break}case ao.CUBE:{let a=new ao(ao.VECTOR).build(e,"v3"),s="vec3( -"+a+".x, "+a+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${s};`),i="reflectCubeVec"):i=s;break}case ao.SPHERE:{let s="normalize( ( viewMatrix * vec4( "+new ao(ao.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(),t)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}},Ao=ao;Ao.CUBE="cube",Ao.SPHERE="sphere",Ao.VECTOR="vector";var zu=class extends ge{constructor(e=new ur,t,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Xa(this.value,t??new Ao(Ao.VECTOR),o),this.irradianceNode=new Xa(this.value,new Yt(Yt.WORLD),new se(1).setReadonly(!0))}generate(e,t){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}};var zx=require("three");var Gu=class extends et{constructor(e=new zx.CubeTexture,t,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t??new Ao,this.bias=o}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){if(t==="samplerCube")return this.getTexture(e,t);let o=this.getTexture(e,t),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},c=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new cr(new Xe("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(s),s=this.colorSpace.build(e,c),e.removeContext(),e.format(s,c,t)}};var Gx=`
|
|
102
88
|
uniform int frameIndex;
|
|
103
89
|
uniform vec2 resolution;
|
|
104
90
|
uniform mat4 previousModelViewMatrix;
|
|
@@ -106,7 +92,7 @@ uniform mat4 previousProjectionMatrix;
|
|
|
106
92
|
|
|
107
93
|
varying vec4 vCurrentPosition;
|
|
108
94
|
varying vec4 vPreviousPosition;
|
|
109
|
-
`,
|
|
95
|
+
`,jx=`
|
|
110
96
|
layout(location = 1) out vec4 gVelocity;
|
|
111
97
|
|
|
112
98
|
uniform int frameIndex;
|
|
@@ -148,7 +134,7 @@ float getNoiseInterleavedGradient(vec2 screenPos) {
|
|
|
148
134
|
return fract(magic.z * fract(dot(screenPos, magic.xy)));
|
|
149
135
|
}
|
|
150
136
|
|
|
151
|
-
`,
|
|
137
|
+
`,Fx=`
|
|
152
138
|
// TODO: This could be generated CPU side and passed to the shader every frame
|
|
153
139
|
const vec2 haltonSequence[16] = vec2[16](
|
|
154
140
|
vec2( 0.000000,-0.333334),
|
|
@@ -185,7 +171,7 @@ vPreviousPosition.xy += OUTLINE_COMPENSATION;
|
|
|
185
171
|
#endif
|
|
186
172
|
gl_Position = currentPositionJittered;
|
|
187
173
|
|
|
188
|
-
`,
|
|
174
|
+
`,Ux=`
|
|
189
175
|
vec2 oldPos = vPreviousPosition.xy;
|
|
190
176
|
oldPos /= vPreviousPosition.w;
|
|
191
177
|
oldPos.xy = (oldPos.xy+1.)/2.0;
|
|
@@ -200,14 +186,14 @@ vec2 velocity = (newPos - oldPos);
|
|
|
200
186
|
if (gl_FragColor.a <= 0.0) discard;
|
|
201
187
|
|
|
202
188
|
gVelocity = vec4(velocity, 0.0, 1.0);
|
|
203
|
-
`,
|
|
189
|
+
`,kx=`
|
|
204
190
|
layout(location = 1) out vec4 gVelocity;
|
|
205
|
-
`,
|
|
191
|
+
`,Hx=`
|
|
206
192
|
// Discard fully transparent pixels
|
|
207
193
|
if (gl_FragColor.a <= 0.0) discard;
|
|
208
194
|
|
|
209
195
|
gVelocity = vec4(0.0, 0.0, 0.0, 1.0);
|
|
210
|
-
`;var
|
|
196
|
+
`;var Wx=["x","y","z","w"],bM=["float","vec2","vec3","vec4"],vM={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},SM={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 r(e,t){return e.deps.length-t.deps.length}return function(t,o){let i=this.getIncludes(t,o);if(!i)return"";let a="";i=i.sort(r);for(let s=0;s<i.length;s++)i[s].src&&(a+=i[s].src+`
|
|
211
197
|
`);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",`
|
|
212
198
|
// NOTE: Include Spline's blending modes. This could be part of BlendNode
|
|
213
199
|
#define SPE_BLENDING_NORMAL 0
|
|
@@ -245,20 +231,20 @@ layout(location = 1) out vec4 gVelocity;
|
|
|
245
231
|
`),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
|
|
246
232
|
accumAlpha += (1.0 - accumAlpha) * alpha;
|
|
247
233
|
}`,""].join(`
|
|
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(
|
|
249
|
-
`}addVertexNodeCode(
|
|
250
|
-
`}clearNodeCode(
|
|
251
|
-
`}addVertexParsCode(
|
|
252
|
-
`}addVaryCode(
|
|
253
|
-
`)}getVarListCode(
|
|
254
|
-
`:
|
|
255
|
-
`}return
|
|
234
|
+
`)},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(r,e){this.addVertexParsCode(Gx),this.addFragmentParsCode(jx),this.buildShader("vertex",r),this.buildShader("fragment",e);for(let t=0;t<this.requires.uv.length;t++)if(this.requires.uv[t]){let o=t>0?t+1:"";this.addVaryCode("varying vec2 vUv"+o+";"),t>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(Fx),this.addFragmentFinalCode(Ux)),this}buildShader(r,e){this.resultCode[r]=e.build(this.setShader(r),"v4")}setMaterial(r,e){return this.defines={},this}addFlow(r,e,t){return this.addSlot(r).addCache(e).addContext(t)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(r){return this.cache=r??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(r){return this.context=Object.assign({},this.context,r),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(r){return this.slot=r||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(r,e){this.fragmentVariables[r]===void 0&&(this.addFragmentCode(`${e} ${r};`),this.fragmentVariables[r]="")}addFragmentParsVariable(r,e){this.fragmentParsVariables[r]===void 0&&(this.addFragmentParsCode(`${e} ${r};`),this.fragmentParsVariables[r]="")}addVertexParsVariable(r,e){this.vertexParsVariables[r]===void 0&&(this.addVertexParsCode(`${e} ${r};`),this.vertexParsVariables[r]="")}addVertexCode(r){this.addCode(r,"vertex")}addFragmentCode(r){this.addCode(r,"fragment")}addCode(r,e){this.code[e??this.shader]+=r+`
|
|
235
|
+
`}addVertexNodeCode(r){this.addNodeCode(r,"vertex")}addFragmentNodeCode(r){this.addNodeCode(r,"fragment")}addNodeCode(r,e){this.nodeCode[e??this.shader]+=r+`
|
|
236
|
+
`}clearNodeCode(r){r=r??this.shader;let e=this.nodeCode[r];return this.nodeCode[r]="",e}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(r){this.addFinalCode(r,"vertex")}addFragmentFinalCode(r){this.addFinalCode(r,"fragment")}addFinalCode(r,e){this.finalCode[e??this.shader]+=r+`
|
|
237
|
+
`}addVertexParsCode(r){this.addParsCode(r,"vertex")}addFragmentParsCode(r){this.addParsCode(r,"fragment")}addParsCode(r,e){this.parsCode[e??this.shader]+=r+`
|
|
238
|
+
`}addVaryCode(r){this.addVertexParsCode(r),this.addFragmentParsCode(r)}isCache(r){return this.caches.indexOf(r)!==-1}isSlot(r){return this.slots.indexOf(r)!==-1}define(r,e){this.defines[r]=e===void 0?1:e}require(r){this.requires[r]=!0}isDefined(r){return this.defines[r]!==void 0}getVar(r,e,t,o="varying",i="V",a=""){let s=this.getVars(o),l=s[r];if(!l){let c=s.length;l={name:t||"node"+i+c+(a?"_"+a:""),type:e},s.push(l),s[r]=l}return l}getTempVar(r,e,t,o){return this.getVar(r,e,t,this.shader,"T",o)}getAttribute(r,e){if(!this.attributes[r]){let t=this.getVar(r,e);this.addVertexParsCode("attribute "+e+" "+r+";"),this.addVertexFinalCode(t.name+" = "+r+";"),this.attributes[r]={varying:t,name:r,type:e}}return this.attributes[r]}getCode(r){return[this.prefixCode,this.parsCode[r],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[r],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[r],"uniform"),this.getIncludesCode("consts",r),this.getIncludesCode("structs",r),this.getIncludesCode("functions",r),"void main() {",this.getVarListCode(this.getVars(r)),this.code[r],this.resultCode[r],this.finalCode[r],"}"].join(`
|
|
239
|
+
`)}getVarListCode(r,e){e=e??"";let t="";for(let o=0,i=r.length;o<i;++o){let a=r[o],s=a.type,l=a.name,c=a.size,u=this.getFormatByType(s);if(u===void 0)throw new Error("Node pars "+u+" not found.");u.includes("[]")?t+=e+" "+u.substring(0,u.length-2)+" "+l+`[${c}];
|
|
240
|
+
`:t+=e+" "+u+" "+l+`;
|
|
241
|
+
`}return t}getVars(r){return this.inputs.vars[r??this.shader]}getNodeData(r){let e=r instanceof qt?r.uuid:r;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(r,e,t,o,i,a){if(e.includes("[]")){let s=this.inputs.arrayUniforms,l=s.list.length,c=new bl({type:e,size:t.size,name:o||"nodeUA"+l+(a?"_"+a:""),node:t,needsUpdate:i});return s.list.push(c),s[r].push(c),s[r][c.name]=c,this.uniforms[c.name]=c,c}else{let s=this.inputs.uniforms,l=s.list.length,c=new bl({type:e,name:o||"nodeU"+l+(a?"_"+a:""),node:t,needsUpdate:i});return s.list.push(c),s[r].push(c),s[r][c.name]=c,this.uniforms[c.name]=c,c}}createVertexUniform(r,e,t,o,i){return this.createUniform("vertex",r,e,t,o,i)}createFragmentUniform(r,e,t,o,i){return this.createUniform("fragment",r,e,t,o,i)}include(r,e,t){let o;if(r=typeof r=="string"?Gt.get(r):r,this.context.include===!1)return r.name;r instanceof re?o=this.includes.functions:r instanceof qe?o=this.includes.consts:r instanceof qa&&(o=this.includes.structs);let i=o[this.shader]=o[this.shader]||[];if(r){let a=i[r.name];if(a||(a=i[r.name]={node:r,deps:[]},i.push(a),a.src=r.build(this,"source")),r instanceof re&&e&&i[e.name]&&i[e.name].deps.indexOf(r)===-1&&(i[e.name].deps.push(r),r.includes?.length)){let s=0;do this.include(r.includes[s++],e);while(s<r.includes.length)}return t&&(a.src=t),r.name}else throw new Error("Include not found.")}colorToVectorProperties(r){return r.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(r){return r.replace(/c/g,"v3")}getIncludes(r,e){return this.includes[r][e||this.shader]}getConstructorFromLength(r){return bM[r-1]}isTypeMatrix(r){return/^m/.test(r)}getTypeLength(r){return r==="f"?1:parseInt(this.colorToVector(r).substr(1))}getTypeFromLength(r){return r===1?"f":"v"+r}findNode(...r){for(let e=0;e<arguments.length;e++){let t=r[e];if(t?.isNode)return t}}resolve(...r){for(let e=0;e<arguments.length;e++){let t=r[e];if(t!==void 0){if(t.isNode)return t;if(t.isTexture)switch(t.mapping){case so.CubeReflectionMapping:case so.CubeRefractionMapping:return new Gu(t);case so.CubeUVReflectionMapping:return new zu(new ur(t));default:return new ur(t)}else{if(t.isVector2)return new xt(t);if(t.isVector3)return new Zt(t);if(t.isVector4)return new br(t)}}}}format(r,e,t){switch(this.colorToVector(t+" <- "+e)){case"f <- v2":return r+".x";case"f <- v3":return r+".x";case"f <- v4":return r+".x";case"f <- i":case"f <- b":return"float( "+r+" )";case"v2 <- f":return"vec2( "+r+" )";case"v2 <- v3":return r+".xy";case"v2 <- v4":return r+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+r+" ) )";case"v3 <- f":return"vec3( "+r+" )";case"v3 <- v2":return"vec3( "+r+", 0.0 )";case"v3 <- v4":return r+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+r+" ) )";case"v4 <- f":return"vec4( "+r+" )";case"v4 <- v2":return"vec4( "+r+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+r+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+r+" ) )";case"i <- f":case"i <- b":return"int( "+r+" )";case"i <- v2":return"int( "+r+".x )";case"i <- v3":return"int( "+r+".x )";case"i <- v4":return"int( "+r+".x )";case"b <- f":return"( "+r+" != 0.0 )";case"b <- v2":return"( "+r+" != vec2( 0.0 ) )";case"b <- v3":return"( "+r+" != vec3( 0.0 ) )";case"b <- v4":return"( "+r+" != vec4( 0.0 ) )";case"b <- i":return"( "+r+" != 0 )"}return r}getTypeByFormat(r){return vM[r]||r}getFormatByType(r){return SM[r]||r}getUUID(r,e){return e=e!==void 0?e:!0,e&&this.cache&&(r=this.cache+"-"+r),r}getElementByIndex(r){return Wx[r]}getIndexByElement(r){return Wx.indexOf(r)}isShader(r){return this.shader===r}setShader(r){return this.shader=r,this}mergeDefines(r){for(let e in r)this.defines[e]=r[e];return this.defines}mergeUniform(r){for(let e in r)this.uniforms[e]=r[e];return this.uniforms}getTextureEncodingFromMap(r){let e;return r?r.isTexture&&(e=r.encoding):e=so.LinearEncoding,e===so.LinearEncoding&&this.context.gamma&&(e=so.sRGBEncoding),e}};var rt=require("three");var Qe=class extends et{constructor(e=0,t,o,i){super("c");this.nodeType="Color";this.value=e instanceof jt?e:new jt(e||0,t,o,i)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o),c=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let u=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${u};`)}return c?this.generateReadonly(e,t,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,t)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,t))}generateReadonly(e,t,o,i,a,s){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",i,t)}};var ze=class extends et{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,t,o,i,a,s){return e.format(this.value.toString(),i,t)}};var Uu=require("three");var Tt=class extends et{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,t,o,i){return e.format(this.value?"true":"false",i,t)}};var lo=class extends et{constructor(e=1,t){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(t)?t:typeof t=="number"?new Array(e).fill(t):new Array(e).fill(0)}};var qx=require("three");var Bn=class extends et{};var ju=class extends Bn{constructor(e){super("v3");this.image=e;this._value=new qx.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 mi=class extends Bn{constructor(e,t,o=1008){super("t");this.image=e;this.wrap=t;this.minFilter=o}get value(){return this.image.getTexture(this.wrap,this.minFilter)}};var $x=require("three");var Qa=class extends et{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new $x.Matrix3}generateReadonly(e,t,o,i,a,s){return e.format("mat3("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Yx=require("three");var Jt=class extends et{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new Yx.Matrix4}generateReadonly(e,t,o,i,a,s){return e.format("mat4("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Sl=require("three");function Xx(n,r,e,t=0){n.setUvTransform(e[0],e[1],r[0],r[1],0,0,0).premultiply(new Sl.Matrix3().makeRotation(t*Sl.MathUtils.DEG2RAD))}var Fu=class extends Qa{constructor(e,t,o=0){super(new Sl.Matrix3);this.repeat=e;this.offset=t;this.rotation=o;Xx(this.value,e,t,o)}updateMatrix(){Xx(this.value,this.repeat,this.offset,this.rotation)}};var Pf=require("three");var co=class extends et{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof Pf.Vector4?new Array(e).fill(t):new Array(e).fill(new Pf.Vector4(0))}};var Za=class extends ge{constructor(e,t,o,i){super("v3");this.nodeType="Blend";this.a=e,this.b=t,this.alpha=o,this.mode=i}generate(e,t){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),t)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}};var Of=class extends ge{constructor(e,t){super("v3");this.nodeType="CustomColor";this.color=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let o=e.include(Of.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),t)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},yi=Of;yi.Nodes=function(){return{customColor:new re(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
|
|
256
242
|
float lalpha = alpha * mask;
|
|
257
243
|
calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
|
|
258
244
|
accumAlpha += (1.0 - accumAlpha) * lalpha;
|
|
259
245
|
|
|
260
246
|
return color;
|
|
261
|
-
}`)}}();var
|
|
247
|
+
}`)}}();var Cf=class extends ge{constructor(e,t){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let o=e.include(Cf.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),t)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ja=Cf;Ja.Nodes=function(){return{customNormal:new re(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
|
|
262
248
|
vec3 normal = packNormalToRGB( norm ).rgb;
|
|
263
249
|
normal *= step( vec3(0.5), cnormal );
|
|
264
250
|
|
|
@@ -267,7 +253,7 @@ layout(location = 1) out vec4 gVelocity;
|
|
|
267
253
|
accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
|
|
268
254
|
|
|
269
255
|
return normal;
|
|
270
|
-
}`)}}();var
|
|
256
|
+
}`)}}();var es=class extends ge{constructor(e,t,o,i,a,s,l,c,u,p,d,h){super("v3");this.nodeType="CustomTexture";this.texture=e,this.textureSize=t,this.crop=o,this.projection=i,this.axis=a,this.side=s,this.size=l,this.blending=c,this.mat=u,this.isMask=h,this.alpha=p,this.mode=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){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(es.Nodes.cylindrical);break;case 2:i=e.include(es.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],c=new re(`
|
|
271
257
|
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) {
|
|
272
258
|
vec2 projected = (1. + (position.${l})) / 2.;
|
|
273
259
|
vec2 uvs = ( mat * vec3( (projected * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
|
|
@@ -291,7 +277,7 @@ layout(location = 1) out vec4 gVelocity;
|
|
|
291
277
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
292
278
|
|
|
293
279
|
return col;
|
|
294
|
-
}`);i=e.include(
|
|
280
|
+
}`);i=e.include(c);break;case 4:i=e.include(es.Nodes.triplanar);break;default:i=e.include(es.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",c=s+"1",u=s+"2",p=`${o}_triplanarWeights`;e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(c,"vec2"),e.addFragmentVariable(u,"vec2"),e.addFragmentVariable(p,"vec3"),a.push(l),a.push(c),a.push(u),a.push(p)}else{let s=`${o}_writeUvs`;e.addFragmentVariable(s,"vec2"),a.push(s)}return e.format(i+"("+a.join(",")+")",this.getType(e),t)}},Ln=es;Ln.Nodes=function(){let e=new re(`
|
|
295
281
|
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) {
|
|
296
282
|
vec3 posN = normalize(position);
|
|
297
283
|
float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
|
|
@@ -326,7 +312,7 @@ vec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop
|
|
|
326
312
|
|
|
327
313
|
return col;
|
|
328
314
|
}
|
|
329
|
-
`),
|
|
315
|
+
`),t=new re(`
|
|
330
316
|
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) {
|
|
331
317
|
vec3 posN = normalize(vPosition);
|
|
332
318
|
float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
|
|
@@ -446,7 +432,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
446
432
|
|
|
447
433
|
return col;//n * 0.5 + 0.5;
|
|
448
434
|
}
|
|
449
|
-
`);return{cylindrical:e,spherical:
|
|
435
|
+
`);return{cylindrical:e,spherical:t,uv:o,triplanar:i}}();var ts=class extends ge{constructor(e,t,o,i,a,s,l,c,u,p,d,h){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=t,this.near=o,this.far=i,this.isVector=a,this.isWorldSpace=s,this.origin=l,this.direction=c,this.colors=u,this.steps=p,this.isMask=h,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){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) {
|
|
450
436
|
vec4 color = colors[0];
|
|
451
437
|
#ifdef ${o}_IS_VECTOR
|
|
452
438
|
#ifdef ${o}_LINEAR
|
|
@@ -486,11 +472,11 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
486
472
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
487
473
|
|
|
488
474
|
return color.rgb;
|
|
489
|
-
}`,[
|
|
475
|
+
}`,[ts.Nodes.vectorLinearWorldSpaceDepth,ts.Nodes.vectorLinearObjectSpaceDepth,ts.Nodes.vectorSphericalObjectSpaceDepth,ts.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),t)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},rs=ts;rs.Nodes=function(){let e=new re(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
|
|
490
476
|
vec3 n = normalize(direction);
|
|
491
477
|
float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
|
|
492
478
|
return ( dist - near ) / ( far - near );
|
|
493
|
-
}`),
|
|
479
|
+
}`),t=new re(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
|
|
494
480
|
vec3 n = normalize(direction);
|
|
495
481
|
float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));
|
|
496
482
|
return ( dist - near ) / ( far - near );
|
|
@@ -500,7 +486,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
500
486
|
}`),i=new re(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
|
|
501
487
|
float dist = length(position - origin);
|
|
502
488
|
return ( dist - near ) / ( far - near );
|
|
503
|
-
}`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:
|
|
489
|
+
}`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:t,vectorSphericalWorldSpaceDepth:o,vectorSphericalObjectSpaceDepth:i}}();var wl=class extends ge{constructor(e,t,o,i,a,s,l,c){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=t,this.scale=o,this.intensity=i,this.factor=a,this.isMask=c,this.alpha=s,this.mode=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){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) {
|
|
504
490
|
float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );
|
|
505
491
|
|
|
506
492
|
float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;
|
|
@@ -508,7 +494,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
508
494
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
509
495
|
|
|
510
496
|
return color;
|
|
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),
|
|
497
|
+
}`),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),t)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}};var Tf=class extends ge{constructor(e,t,o,i,a,s,l,c,u){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=t,this.colors=o,this.steps=i,this.offset=a,this.morph=s,this.angle=l,this.isMask=u,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){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(Tf.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),t)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},os=Tf;os.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) {
|
|
512
498
|
vec4 color = colors[0];
|
|
513
499
|
vec2 m = morph / vUv.xy;
|
|
514
500
|
vec2 rot = vec2( 0.5 + m.x, m.y );
|
|
@@ -550,7 +536,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
550
536
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
551
537
|
|
|
552
538
|
return color.xyz;
|
|
553
|
-
}`)}}();var
|
|
539
|
+
}`)}}();var Af=class extends ge{constructor(e,t,o,i,a){super("v3");this.nodeType="Matcap";this.texture=e,this.isMask=i,this.alpha=t,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`,this.rotation=a}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(Af.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),i.push(this.rotation.build(e,"f")),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},ns=Af;ns.Nodes=function(){return{matcap:new re(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {
|
|
554
540
|
vec3 viewDir = normalize( vViewPosition );
|
|
555
541
|
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
|
556
542
|
vec3 y = cross( viewDir, x );
|
|
@@ -564,7 +550,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
564
550
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
565
551
|
|
|
566
552
|
return matcapColor.rgb;
|
|
567
|
-
}`)}}();var
|
|
553
|
+
}`)}}();var Pl=(a=>(a.SIMPLEX="simplex3d",a.SIMPLEX_FRACTAL="simplex3dFractal",a.ASHIMA="simplexAshima",a.FBM="fbm",a.PERLIN="perlin",a.VORONOI="voronoi",a))(Pl||{}),Xt=function(){let r=new re(`vec3 random3(vec3 c) {
|
|
568
554
|
float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
|
|
569
555
|
vec3 r;
|
|
570
556
|
r.z = fract(512.0*j);
|
|
@@ -604,7 +590,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
604
590
|
d *= w;
|
|
605
591
|
|
|
606
592
|
return dot(d, vec4(52.0));
|
|
607
|
-
}`,[
|
|
593
|
+
}`,[r]);e.keywords.F3=new qe("float F3 0.3333333"),e.keywords.G3=new qe("float G3 0.1666667");let t=new re(`float simplex3dFractal(vec3 m) {
|
|
608
594
|
mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);
|
|
609
595
|
mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);
|
|
610
596
|
mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);
|
|
@@ -657,7 +643,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
657
643
|
m = m * m;
|
|
658
644
|
return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
|
|
659
645
|
dot(p2,x2), dot(p3,x3) ) );
|
|
660
|
-
}`,[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]),
|
|
646
|
+
}`,[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]),c=new re(`float noise(vec3 p){
|
|
661
647
|
vec3 a = floor(p);
|
|
662
648
|
vec3 d = p - a;
|
|
663
649
|
d = d * d * (3.0 - 2.0 * d);
|
|
@@ -672,7 +658,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
672
658
|
vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
|
|
673
659
|
vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
|
|
674
660
|
return o4.y * d.y + o4.x * (1.0 - d.y);
|
|
675
|
-
}`,[l]),
|
|
661
|
+
}`,[l]),u=new re(`float fbm(vec3 x) {
|
|
676
662
|
float v = 0.0;
|
|
677
663
|
float a = 0.5;
|
|
678
664
|
vec3 shift = vec3(100);
|
|
@@ -682,7 +668,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
682
668
|
a *= 0.5;
|
|
683
669
|
}
|
|
684
670
|
return v;
|
|
685
|
-
}`,[
|
|
671
|
+
}`,[c]);u.keywords.NUM_OCTAVES=new qe(`int NUM_OCTAVES ${5}`);let p=new re("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),d=new re(`float perlin(vec3 P){
|
|
686
672
|
vec3 Pi0 = floor(P);
|
|
687
673
|
vec3 Pi1 = Pi0 + vec3(1.0);
|
|
688
674
|
Pi0 = mod(Pi0, 289.0);
|
|
@@ -741,12 +727,12 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
741
727
|
vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
|
|
742
728
|
float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
|
|
743
729
|
return 2.2 * n_xyz;
|
|
744
|
-
}`,[o,i,
|
|
730
|
+
}`,[o,i,p]),h=new re(`float hashwithoutsine13(vec3 p3)
|
|
745
731
|
{
|
|
746
732
|
p3 = fract(p3 * .1031);
|
|
747
733
|
p3 += dot(p3, p3.yzx + 33.33);
|
|
748
734
|
return fract((p3.x + p3.y) * p3.z);
|
|
749
|
-
}`),
|
|
735
|
+
}`),f=new re(`vec3 hashwithoutsine33(vec3 p3)
|
|
750
736
|
{
|
|
751
737
|
p3 = fract(p3 * vec3(.1031, .1030, .0973));
|
|
752
738
|
p3 += dot(p3, p3.yxz+33.33);
|
|
@@ -769,7 +755,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
769
755
|
float h = smoothstep(1.0, 0.0, 0.5 + 0.5 * (a - b) / k);
|
|
770
756
|
float correction = k * h * (1.0 - h);
|
|
771
757
|
return mix(a, b, h) + correction;
|
|
772
|
-
}`),
|
|
758
|
+
}`),v=new re(`float remap(float value, float input_min, float input_max, float output_min, float output_max) {
|
|
773
759
|
// Compute width of each interval
|
|
774
760
|
float input_width = input_max - input_min;
|
|
775
761
|
float output_width = output_max - output_min;
|
|
@@ -779,7 +765,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
779
765
|
|
|
780
766
|
// Convert the 0-1 range into a value in output range
|
|
781
767
|
return output_min + (scaled * output_width);
|
|
782
|
-
}`),
|
|
768
|
+
}`),O=new re(`float voronoi(in vec3 x, in int style, in float smoothness, in float seed, in int quality)
|
|
783
769
|
{
|
|
784
770
|
// Integer and fractional parts of this point's coordinates
|
|
785
771
|
ivec3 p = ivec3(floor(x));
|
|
@@ -917,7 +903,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
917
903
|
return hashwithoutsine13(vec3(p + mb) + seed);
|
|
918
904
|
}
|
|
919
905
|
}
|
|
920
|
-
`,[f,
|
|
906
|
+
`,[h,f,m,y,g,v]);return{simplex:e,simplexFractal:t,simplexAshima:a,fbm:u,perlin:d,voronoi:O}}();var is=class extends ge{constructor(e,t,o,i,a,s,l,c,u,p,d,h,f,m,y,g,v,O,P){super("v3");this.nodeType="Noise";this.scale=e,this.size=t,this.move=o,this.fA=i,this.fB=a,this.distortion=s,this.colorA=l,this.colorB=c,this.colorC=u,this.colorD=p,this.noiseType=h,this.voronoiStyle=m,this.highCut=y,this.lowCut=g,this.smoothness=v,this.seed=O,this.quality=P,this.isMask=f,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t,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"?`
|
|
921
907
|
float v = ${s}(st + move, voronoiStyle, smoothness, seed, quality);
|
|
922
908
|
|
|
923
909
|
// Apply clipping to colors
|
|
@@ -939,7 +925,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
939
925
|
color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));
|
|
940
926
|
color = mix(color, colorC, clamp(length(q), 0.0, 1.0));
|
|
941
927
|
color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0));
|
|
942
|
-
`,
|
|
928
|
+
`,c=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)
|
|
943
929
|
{
|
|
944
930
|
// Prevent scale of zero
|
|
945
931
|
scale = max(abs(scale), 0.001);
|
|
@@ -954,7 +940,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
954
940
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
955
941
|
|
|
956
942
|
return clamp(color, 0.0, 1.0).rgb;
|
|
957
|
-
}`,[
|
|
943
|
+
}`,[Xt.simplex,Xt.simplexFractal,Xt.simplexAshima,Xt.fbm,Xt.perlin,Xt.voronoi]),u=e.include(c),p=[];return p.push(this.scale.build(e,"f")),p.push(this.size.build(e,"v3")),p.push(this.move.build(e,"f")),p.push(this.fA.build(e,"v2")),p.push(this.fB.build(e,"v2")),p.push(this.distortion.build(e,"v2")),p.push(this.colorA.build(e,"v4")),p.push(this.colorB.build(e,"v4")),p.push(this.colorC.build(e,"v4")),p.push(this.colorD.build(e,"v4")),p.push(this.voronoiStyle.build(e,"i")),p.push(this.highCut.build(e,"f")),p.push(this.lowCut.build(e,"f")),p.push(this.smoothness.build(e,"f")),p.push(this.seed.build(e,"f")),p.push(this.quality.build(e,"i")),p.push(this.isMask.build(e,"b")),p.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),p.push(this.alpha.build(e,"f")),p.push(this.calpha),e.format(u+"("+p.join(",")+")",this.getType(e),t)}};is.numOctaves=5;var Mf=class extends ge{constructor(e,t,o,i,a,s,l,c,u,p,d,h,f,m,y,g){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=t,this.outlineWidth=o,this.contourWidth=i,this.contourThreshold=a,this.outlineThreshold=s,this.contourFrequency=l,this.outlineSmoothing=c,this.contourDirection=u,this.positionalLines=p,this.compensation=d,this.resolution=h,this.normalMap=f,this.depthMap=m,this.pixelRatio=y,this.alpha=g,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){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(`
|
|
958
944
|
vID = randomColor.r;
|
|
959
945
|
vec2 ${o}_offset = vec2(0.0);
|
|
960
946
|
if (${s}) {
|
|
@@ -969,7 +955,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
969
955
|
// if this offset is the biggest of all the potential offsets
|
|
970
956
|
gl_Position = ${o}_clipPosition;
|
|
971
957
|
}
|
|
972
|
-
`)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(
|
|
958
|
+
`)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(Mf.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),t)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},as=Mf;as.Nodes=function(){let e=new re(`
|
|
973
959
|
float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)
|
|
974
960
|
{
|
|
975
961
|
vec2 halton = haltonSequence[frameIndex];
|
|
@@ -1118,7 +1104,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1118
1104
|
accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
|
|
1119
1105
|
|
|
1120
1106
|
return result;
|
|
1121
|
-
}`,[e])}}();var
|
|
1107
|
+
}`,[e])}}();var Mo=class extends ge{constructor(e,t,o,i,a,s,l,c,u,p,d,h,f,m,y,g,v,O){super("v3");this.nodeType="Pattern";this.style=e,this.projection=t,this.axis=o,this.blending=i,this.offset=a,this.colorA=s,this.colorB=l,this.frequency=c,this.size=u,this.variation=p,this.smoothness=d,this.zigzag=h,this.rotation=f,this.vertical=m,this.horizontal=y,this.sides=g,this.isMask=O,this.alpha=v,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){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)
|
|
1122
1108
|
{
|
|
1123
1109
|
vec3 p3 = fract(vec3(p.xyx) * .1031);
|
|
1124
1110
|
p3 += dot(p3, p3.yzx + 33.33);
|
|
@@ -1132,7 +1118,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1132
1118
|
cos(radians) * (uv.y - mid) - sin(radians) * (uv.x - mid) + mid
|
|
1133
1119
|
);
|
|
1134
1120
|
return repeat ? fract(rotated): rotated;
|
|
1135
|
-
}`),l="";if(this.projection.value===4){let
|
|
1121
|
+
}`),l="";if(this.projection.value===4){let d=this.style.value===2?`${o}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${o}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,h=this.style.value===2?`${o}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${o}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,f=this.style.value===2?`${o}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${o}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation)`;l=`
|
|
1136
1122
|
vec3 p = position;
|
|
1137
1123
|
float factor = 0.0125;
|
|
1138
1124
|
vec2 uv0 = fract(p.xy * factor);
|
|
@@ -1143,9 +1129,9 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1143
1129
|
uv1 = rotate_uv(uv1 + offset, rotation, true);
|
|
1144
1130
|
uv2 = rotate_uv(uv2 + offset, rotation, true);
|
|
1145
1131
|
|
|
1146
|
-
float d0 = ${
|
|
1147
|
-
float d1 = ${
|
|
1148
|
-
float d2 = ${
|
|
1132
|
+
float d0 = ${d};
|
|
1133
|
+
float d1 = ${h};
|
|
1134
|
+
float d2 = ${f};
|
|
1149
1135
|
|
|
1150
1136
|
// Range from 3 to 128 seems to be good
|
|
1151
1137
|
float exponent = (1.0 - blending) * 125.0 + 3.0;
|
|
@@ -1160,27 +1146,27 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1160
1146
|
float draw = d0 + d1 + d2;
|
|
1161
1147
|
|
|
1162
1148
|
vec2 custom_uv = uv0 * weights.z + uv1 * weights.x + uv2 * weights.y;
|
|
1163
|
-
`}else{let
|
|
1149
|
+
`}else{let d=this.style.value===2?`${o}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${o}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,h="";this.axis.value===0?h=`float radius = length(p);
|
|
1164
1150
|
float theta = atan(p.y, p.z);
|
|
1165
|
-
float phi = acos(p.x / radius);`:this.axis.value===1?
|
|
1151
|
+
float phi = acos(p.x / radius);`:this.axis.value===1?h=`float radius = length(p);
|
|
1166
1152
|
float theta = atan(p.x, p.z);
|
|
1167
|
-
float phi = acos(p.y / radius);`:(this.axis.value,
|
|
1153
|
+
float phi = acos(p.y / radius);`:(this.axis.value,h=`float radius = length(p);
|
|
1168
1154
|
float theta = atan(p.y, p.x);
|
|
1169
|
-
float phi = acos(p.z / radius);`);let
|
|
1155
|
+
float phi = acos(p.z / radius);`);let f="";switch(this.projection.value){case 0:f="custom_uv = vUv.st;";break;case 1:break;case 2:f=`
|
|
1170
1156
|
vec3 p = position;
|
|
1171
|
-
${
|
|
1157
|
+
${h}
|
|
1172
1158
|
custom_uv = vec2(theta, phi);
|
|
1173
1159
|
custom_uv /= PI;
|
|
1174
1160
|
`;break;case 3:break;default:break}l=`
|
|
1175
1161
|
vec2 custom_uv;
|
|
1176
|
-
${
|
|
1162
|
+
${f}
|
|
1177
1163
|
|
|
1178
1164
|
custom_uv += offset;
|
|
1179
1165
|
custom_uv = fract(custom_uv);
|
|
1180
1166
|
custom_uv = rotate_uv(custom_uv, rotation, true);
|
|
1181
1167
|
|
|
1182
|
-
float draw = ${
|
|
1183
|
-
`}let
|
|
1168
|
+
float draw = ${d};
|
|
1169
|
+
`}let c=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) {
|
|
1184
1170
|
const float TWO_PI = PI * 2.0;
|
|
1185
1171
|
float smoothness_remapped = pow(smoothness, 5.0);
|
|
1186
1172
|
|
|
@@ -1204,11 +1190,11 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1204
1190
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
1205
1191
|
|
|
1206
1192
|
return clamp(color, 0.0, 1.0).rgb;
|
|
1207
|
-
}`,[s,a,
|
|
1193
|
+
}`,[s,a,Mo.DrawFunctions.circle,Mo.DrawFunctions.ring,Mo.DrawFunctions.polygon,Mo.DrawFunctions.cross,Mo.DrawFunctions.diamond,Mo.DrawFunctions.checkerboard,Mo.DrawFunctions.line,Mo.DrawFunctions.wave]),u=e.include(c),p=[];return p.push("normal"),p.push(this.blending.build(e,"f")),p.push(this.style.build(e,"i")),p.push(this.offset.build(e,"v2")),p.push(this.colorA.build(e,"v4")),p.push(this.colorB.build(e,"v4")),p.push(this.frequency.build(e,"v2")),p.push(this.size.build(e,"f")),p.push(this.variation.build(e,"f")),p.push(this.smoothness.build(e,"f")),p.push(this.zigzag.build(e,"f")),p.push(this.rotation.build(e,"f")),p.push(this.vertical.build(e,"v2")),p.push(this.horizontal.build(e,"v2")),p.push(this.sides.build(e,"i")),p.push(this.isMask.build(e,"b")),p.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),p.push(this.alpha.build(e,"f")),p.push(this.calpha),e.format(u+"("+p.join(",")+")",this.getType(e),t)}else return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),t)}},ss=Mo;ss.DrawFunctions=function(){let e=new re(`float hashwithoutsine12(vec2 p) {
|
|
1208
1194
|
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
1209
1195
|
p3 += dot(p3, p3.yzx + 33.33);
|
|
1210
1196
|
return fract((p3.x + p3.y) * p3.z);
|
|
1211
|
-
}`),
|
|
1197
|
+
}`),t=new re(`vec2 tile_and_center(in vec2 uv, in vec2 frequency, in float variation, in float zigzag, in float rotation) {
|
|
1212
1198
|
// Create tiles in UV-space
|
|
1213
1199
|
uv *= frequency;
|
|
1214
1200
|
|
|
@@ -1244,7 +1230,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1244
1230
|
smoothness,
|
|
1245
1231
|
length(f) - size
|
|
1246
1232
|
);
|
|
1247
|
-
}`,[
|
|
1233
|
+
}`,[t]),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) {
|
|
1248
1234
|
vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
|
|
1249
1235
|
|
|
1250
1236
|
float d = length(f);
|
|
@@ -1253,7 +1239,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1253
1239
|
float outer = smoothstep(-smoothness, smoothness, d - size);
|
|
1254
1240
|
float inner = smoothstep(-smoothness, smoothness, d - size * inner_width);
|
|
1255
1241
|
return outer + (1.0 - inner);
|
|
1256
|
-
}`,[
|
|
1242
|
+
}`,[t]),a=new re(`float sdf_ngon(in vec2 p, in float r, in int n) {
|
|
1257
1243
|
float an = (PI * 2.0) / float(n);
|
|
1258
1244
|
float he = r * tan(0.5 * an);
|
|
1259
1245
|
|
|
@@ -1270,7 +1256,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1270
1256
|
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) {
|
|
1271
1257
|
vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
|
|
1272
1258
|
return smoothstep(-smoothness, smoothness, sdf_ngon(f, size, sides));
|
|
1273
|
-
}`,[
|
|
1259
|
+
}`,[t]),s=new re(`float sdf_cross(in vec2 p, in vec2 b, float r ) {
|
|
1274
1260
|
p = abs(p);
|
|
1275
1261
|
p = (p.y > p.x) ? p.yx : p.xy;
|
|
1276
1262
|
vec2 q = p - b;
|
|
@@ -1283,7 +1269,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1283
1269
|
float xcross(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
|
|
1284
1270
|
vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
|
|
1285
1271
|
return smoothstep(-smoothness, smoothness, sdf_cross(f, vec2(size, size * 0.25), smoothness));
|
|
1286
|
-
}`,[
|
|
1272
|
+
}`,[t]),l=new re(`float ndot(vec2 a, vec2 b) {
|
|
1287
1273
|
return a.x*b.x - a.y*b.y;
|
|
1288
1274
|
}
|
|
1289
1275
|
|
|
@@ -1297,7 +1283,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1297
1283
|
float diamond(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
|
|
1298
1284
|
vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
|
|
1299
1285
|
return smoothstep(-smoothness, smoothness, sdf_diamond(f, vec2(size)));
|
|
1300
|
-
}`,[
|
|
1286
|
+
}`,[t]),c=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) {
|
|
1301
1287
|
uv *= frequency;
|
|
1302
1288
|
vec2 i = floor(uv);
|
|
1303
1289
|
|
|
@@ -1307,7 +1293,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1307
1293
|
float x = floor(uv.x);
|
|
1308
1294
|
|
|
1309
1295
|
return mod(x, 2.0);
|
|
1310
|
-
}`),
|
|
1296
|
+
}`),u=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) {
|
|
1311
1297
|
vec2 f = tile_and_center(uv, frequency, 0.0, zigzag, rotation);
|
|
1312
1298
|
|
|
1313
1299
|
// Different approach for variation param here
|
|
@@ -1320,7 +1306,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1320
1306
|
s + smoothness,
|
|
1321
1307
|
abs(f.y)
|
|
1322
1308
|
);
|
|
1323
|
-
}`,[
|
|
1309
|
+
}`,[t]),p=new re(`// Uses bisection
|
|
1324
1310
|
float udf_cos(in vec2 p, in float a, in float b, in float c, in float d) {
|
|
1325
1311
|
// Convert all data to a primitive cosine wave
|
|
1326
1312
|
p = c * (p - vec2(d, a));
|
|
@@ -1369,7 +1355,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1369
1355
|
float s = mix(size, size * rand, variation);
|
|
1370
1356
|
|
|
1371
1357
|
return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);
|
|
1372
|
-
}`);return{tileAndCenter:
|
|
1358
|
+
}`);return{tileAndCenter:t,circle:o,ring:i,polygon:a,cross:s,diamond:l,checkerboard:c,line:u,wave:p}}();var If=class extends ge{constructor(e,t,o,i,a,s,l,c){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=t,this.wavelengths=o,this.noiseStrength=i,this.noiseScale=a,this.offset=s,this.isMask=c,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){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(If.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),t)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},ls=If;ls.Nodes=function(){let e=new re(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
|
|
1373
1359
|
vec3 st = position / noiseScale;
|
|
1374
1360
|
vec3 q = vec3(simplex3d(st),
|
|
1375
1361
|
simplex3d(st + vec3(1.0)),
|
|
@@ -1382,7 +1368,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1382
1368
|
float noise = simplex3d(st + r);
|
|
1383
1369
|
|
|
1384
1370
|
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);
|
|
1385
|
-
}`,[
|
|
1371
|
+
}`,[Xt.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) {
|
|
1386
1372
|
vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);
|
|
1387
1373
|
|
|
1388
1374
|
float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);
|
|
@@ -1392,9 +1378,9 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1392
1378
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
1393
1379
|
|
|
1394
1380
|
return res;
|
|
1395
|
-
}`,[e])}}();var
|
|
1381
|
+
}`,[e])}}();var Nf=class extends ge{constructor(e,t,o,i,a,s,l,c,u,p){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=t,this.steps=o,this.source=i,this.isWorldSpace=a,this.noiseStrength=s,this.noiseScale=l,this.shadowColor=c,this.offset=u,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let o=e.include(Nf.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),t)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},cs=Nf;cs.Nodes=function(){let e=new re(`float rand(float n) {
|
|
1396
1382
|
return fract(sin(n) * 43758.5453123);
|
|
1397
|
-
}`),
|
|
1383
|
+
}`),t=new re(`float hash1(float p) {
|
|
1398
1384
|
p = fract(p * 0.011);
|
|
1399
1385
|
p *= p + 7.5;
|
|
1400
1386
|
p *= p + p;
|
|
@@ -1414,7 +1400,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1414
1400
|
mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y),
|
|
1415
1401
|
mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x),
|
|
1416
1402
|
mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);
|
|
1417
|
-
}`,[
|
|
1403
|
+
}`,[t]),i=new re(`vec3 hash3(vec3 x) {
|
|
1418
1404
|
x = vec3(dot(x,vec3(127.1, 311.7, 74.7)),
|
|
1419
1405
|
dot(x,vec3(269.5, 183.3, 246.1)),
|
|
1420
1406
|
dot(x,vec3(113.5, 271.9, 124.6)));
|
|
@@ -1628,7 +1614,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1628
1614
|
|
|
1629
1615
|
return color.xyz;
|
|
1630
1616
|
|
|
1631
|
-
}`,[
|
|
1617
|
+
}`,[Xt.simplex,e,o,a])}}();var Df=require("three");var Kx=function(){return{textureBicubic:new re(`float w0( float a ) {
|
|
1632
1618
|
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
|
|
1633
1619
|
}
|
|
1634
1620
|
|
|
@@ -1692,7 +1678,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1692
1678
|
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
|
|
1693
1679
|
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
|
|
1694
1680
|
return mix( fSample, cSample, fract( lod ) );
|
|
1695
|
-
}`)}}();function
|
|
1681
|
+
}`)}}();function Qx(n,r){return n>=r?new Df.Vector2(r/n,1):new Df.Vector2(1,n/r)}var Ef=class extends ge{constructor(e,t,o,i,a,s,l,c){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=t,this.roughness=o,this.transmissionSamplerSize=i,this.transmissionSamplerMap=a,this.transmissionDepthMap=s,this.aspectRatio=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){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(Ef.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),t)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},us=Ef;us.Nodes=function(){let e=new re(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
|
|
1696
1682
|
// Slightly modified version of this:
|
|
1697
1683
|
// https://www.shadertoy.com/view/ltScRG
|
|
1698
1684
|
|
|
@@ -1725,7 +1711,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1725
1711
|
res += textureLod(sp, uv, lod).rgb;
|
|
1726
1712
|
}
|
|
1727
1713
|
return res / float(NUM_SAMPLES);
|
|
1728
|
-
}`),
|
|
1714
|
+
}`),t=new re(`vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
|
|
1729
1715
|
// Direction of refracted light.
|
|
1730
1716
|
vec3 refractionVector = refract( -v, n, 1.0 / ior );
|
|
1731
1717
|
|
|
@@ -1752,7 +1738,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1752
1738
|
float lod = applyIorToRoughness(roughness, ior);
|
|
1753
1739
|
return blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
|
|
1754
1740
|
#endif
|
|
1755
|
-
}`,[
|
|
1741
|
+
}`,[Kx.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 ) {
|
|
1756
1742
|
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
|
|
1757
1743
|
vec3 refractedRayExit = position + transmissionRay;
|
|
1758
1744
|
|
|
@@ -1769,7 +1755,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1769
1755
|
|
|
1770
1756
|
// Sample framebuffer to get pixel the refracted ray hits.
|
|
1771
1757
|
return getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );
|
|
1772
|
-
}`,[i,
|
|
1758
|
+
}`,[i,t]);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) {
|
|
1773
1759
|
vec3 v = vec3(0.);
|
|
1774
1760
|
if (isOrthographic) {
|
|
1775
1761
|
v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
@@ -1783,9 +1769,9 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1783
1769
|
accumAlpha += ( 1.0 - accumAlpha ) * alpha;
|
|
1784
1770
|
|
|
1785
1771
|
return transmission;
|
|
1786
|
-
}`,[a])}}();var
|
|
1772
|
+
}`,[a])}}();var _f=(e=>(e.NOISE="noise",e.MAP="map",e))(_f||{}),Bf=class extends ge{constructor(e,t,o,i,a,s,l,c,u,p,d){super("v3");this.displacementTypeIndex=new ze(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=t,Object.values(_f)[this.displacementTypeIndex.value]==="map"&&(this.mat=new Qa(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=p,this.noiseFunctionIndex=d,this.voronoiStyle=i,this.smoothness=a,this.seed=s,this.highCut=l,this.lowCut=c,this.quality=u}generate(e,t){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let o,i=[];switch(i.push("displaced_position"),i.push("displaced_normal"),Object.values(_f)[this.displacementTypeIndex.value]){case"map":{o=e.include(Bf.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 re(`vec3 orthogonal(vec3 v) {
|
|
1787
1773
|
return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
|
|
1788
|
-
}`),
|
|
1774
|
+
}`),c=s=="voronoi"?`
|
|
1789
1775
|
float v = ${s}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);
|
|
1790
1776
|
v = remap(v, lowCut, highCut, 0.0, 1.0);
|
|
1791
1777
|
v = smax(v, 0.0, smoothness * 0.25);
|
|
@@ -1794,9 +1780,9 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1794
1780
|
return p + n * v * intensity;
|
|
1795
1781
|
`:`
|
|
1796
1782
|
return p + n * ${s}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
|
|
1797
|
-
`,
|
|
1798
|
-
${
|
|
1799
|
-
}`,[
|
|
1783
|
+
`,u=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) {
|
|
1784
|
+
${c}
|
|
1785
|
+
}`,[Xt.simplex,Xt.simplexFractal,Xt.simplexAshima,Xt.fbm,Xt.perlin,Xt.voronoi]),p=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) {
|
|
1800
1786
|
vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
|
|
1801
1787
|
vec3 tangent1 = orthogonal(normal);
|
|
1802
1788
|
vec3 tangent2 = normalize(cross(normal, tangent1));
|
|
@@ -1812,9 +1798,9 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1812
1798
|
vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
|
|
1813
1799
|
displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
|
|
1814
1800
|
return displaced_position;
|
|
1815
|
-
}`,[
|
|
1801
|
+
}`,[u,l]);o=e.include(p),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),t)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},ds=Bf;ds.Nodes=function(){let e=new re(`vec3 orthogonal(vec3 v) {
|
|
1816
1802
|
return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
|
|
1817
|
-
}`),
|
|
1803
|
+
}`),t=new re(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
|
|
1818
1804
|
vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
|
|
1819
1805
|
vec4 tmp = texture2D(tex, uvs);
|
|
1820
1806
|
vec3 col = tmp.rgb;
|
|
@@ -1834,7 +1820,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1834
1820
|
vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
|
|
1835
1821
|
displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
|
|
1836
1822
|
return displaced_position;
|
|
1837
|
-
}`,[e,
|
|
1823
|
+
}`,[e,t])}}();var De={normalRenderTarget:new ur,normalRenderTargetDepth:new ur,transmissionRenderTarget:new ur,aspectRatio:new xt,transmissionSize:new xt(2048,2048),transmissionRenderTargetDepth:new ur,aoRenderTarget:new ur,aoEnabled:new Tt,pixelRatioNode:new se(1),resolution:new xt,penumbraSize:new lo(5,.5),frameIndex:new ze(0),transmissionLod:new ze(2)};for(let n of Object.values(De))n.isRenderGlobal=!0;var Zx={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.0.64/build/ui.wasm"};var tn=class extends qt{constructor(){super("basic");this.nodeType="Basic";this.color=new Qe(Mt),this.shadingAlpha=new se(1),this.shadingBlend=new ze(0),this.previousModelViewMatrix=new Jt,this.previouseProjectionMatrix=new Jt}get category(){return"phong"}generate(e){let t;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(Uu.UniformsUtils.merge([Uu.UniformsLib.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
|
|
1838
1824
|
`));let i=["#include <beginnormal_vertex>",`
|
|
1839
1825
|
#if !defined( USE_LAYER_DISPLACE )
|
|
1840
1826
|
#include <defaultnormal_vertex>
|
|
@@ -1851,10 +1837,10 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1851
1837
|
#if !defined( USE_LAYER_DISPLACE )
|
|
1852
1838
|
#include <begin_vertex>
|
|
1853
1839
|
#endif /* !USE_LAYER_DISPLACE */
|
|
1854
|
-
`];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;"),
|
|
1855
|
-
`)}else{this.color===void 0&&(this.color=new
|
|
1856
|
-
`));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
|
|
1857
|
-
`)}return
|
|
1840
|
+
`];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;"),t=i.join(`
|
|
1841
|
+
`)}else{this.color===void 0&&(this.color=new Qe(Mt)),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(`
|
|
1842
|
+
`));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 c="1.0";this.mask&&(this.mask.analyze(e),c=`luminance(${this.mask.flow(e,"v3").result})`),i?l.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${i.result} * ${c} );`):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>"),t=l.join(`
|
|
1843
|
+
`)}return t}};var Ol=require("three");var Cl=class extends qt{constructor(){super("lambert");this.nodeType="Lambert";this.color=new Qe(Mt),this.emissive=new Qe(0),this.emissiveIntensity=new se(1),this.previousModelViewMatrix=new Jt,this.previouseProjectionMatrix=new Jt,this.shadingAlpha=new se(1),this.shadingBlend=new ze(0),this.occlusion=new Tt(!0)}get category(){return"lambert"}build(e){let t;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(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(`
|
|
1858
1844
|
`));let i=["#include <beginnormal_vertex>",`
|
|
1859
1845
|
#ifndef USE_LAYER_DISPLACE
|
|
1860
1846
|
#include <defaultnormal_vertex>
|
|
@@ -1946,24 +1932,24 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1946
1932
|
}
|
|
1947
1933
|
#pragma unroll_loop_end
|
|
1948
1934
|
#endif
|
|
1949
|
-
`," #include <shadowmap_vertex>"," #include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),
|
|
1950
|
-
`)}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
|
|
1951
|
-
`));let
|
|
1935
|
+
`," #include <shadowmap_vertex>"," #include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join(`
|
|
1936
|
+
`)}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 Qe(Mt)),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"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=p!==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(`
|
|
1937
|
+
`));let h=["#include <normal_fragment_begin>",`
|
|
1952
1938
|
// NOTE: gl_FrontFacing alternative using face normal estimation.
|
|
1953
1939
|
vec3 viewdx = dFdx(vViewPosition);
|
|
1954
1940
|
vec3 viewdy = dFdy(vViewPosition);
|
|
1955
1941
|
vec3 faceNormal = normalize(cross(viewdx, viewdy));
|
|
1956
1942
|
bool isFrontFacing = (dot(normal, faceNormal) >= 0.0);
|
|
1957
|
-
`,"#include <clipping_planes_fragment>"];
|
|
1943
|
+
`,"#include <clipping_planes_fragment>"];h.push(o.code,"vec3 diffuseColor = "+o.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),p&&h.push(p.code,"#ifdef ALPHATEST","if ( "+p.result+" <= ALPHATEST ) discard;","#endif"),h.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include <lightmap_fragment>","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),i&&h.push(i.code,"reflectedLight.directDiffuse += "+i.result+" * "+a.result+";"),h.push("vec3 ao = aoEnabled && "+s.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) ;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),h.push(`
|
|
1958
1944
|
if (outgoingLight != diffuseColor) {
|
|
1959
1945
|
float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
|
|
1960
|
-
accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * ${
|
|
1961
|
-
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result} * ${
|
|
1946
|
+
accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * ${f} * lightAccu;
|
|
1947
|
+
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result} * ${f}, ${c.result} );
|
|
1962
1948
|
|
|
1963
1949
|
outgoingLight *= ao;
|
|
1964
1950
|
}
|
|
1965
|
-
`),
|
|
1966
|
-
`)}return
|
|
1951
|
+
`),u&&h.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),p?h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result} );`):h.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&h.push(`gl_FragColor.a *= ${d.result};`),h.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=h.join(`
|
|
1952
|
+
`)}return t}};var Tl=require("three");var rn=function(){let n=new re(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {
|
|
1967
1953
|
|
|
1968
1954
|
// Gradient of UVs w.r.t. X coordinate (in screen-space)
|
|
1969
1955
|
vec2 dSTdx = dFdx(bumpMapUv);
|
|
@@ -1977,7 +1963,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1977
1963
|
float dBy = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdy).rgb) - Hll;
|
|
1978
1964
|
|
|
1979
1965
|
return vec2( dBx, dBy );
|
|
1980
|
-
}`),
|
|
1966
|
+
}`),r=new re(`vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
|
1981
1967
|
vec3 vSigmaX = dFdx( surf_pos.xyz );
|
|
1982
1968
|
vec3 vSigmaY = dFdy( surf_pos.xyz );
|
|
1983
1969
|
vec3 vN = surf_norm; // normalized
|
|
@@ -1994,7 +1980,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1994
1980
|
|
|
1995
1981
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
1996
1982
|
return normalize( abs( fDet ) * vN - vGrad );
|
|
1997
|
-
}`);return{dHdxy:n,perturbNormalArb:
|
|
1983
|
+
}`);return{dHdxy:n,perturbNormalArb:r}}();var Al=class extends qt{constructor(){super("phong");this.nodeType="Phong";this.color=new Qe(Mt),this.specular=new Qe(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new Jt,this.previouseProjectionMatrix=new Jt,this.shadingAlpha=new se(1),this.shadingBlend=new ze(0),this.occlusion=new Tt(!0)}get category(){return"phong"}build(e){let t;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(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(`
|
|
1998
1984
|
`));let i=["#include <beginnormal_vertex>",`
|
|
1999
1985
|
#include <skinbase_vertex>
|
|
2000
1986
|
#include <skinnormal_vertex>
|
|
@@ -2014,9 +2000,9 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2014
2000
|
#ifndef USE_LAYER_DISPLACE
|
|
2015
2001
|
#include <begin_vertex>
|
|
2016
2002
|
#endif
|
|
2017
|
-
`];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;"),
|
|
2018
|
-
`)}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
|
|
2019
|
-
`));let
|
|
2003
|
+
`];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;"),t=i.join(`
|
|
2004
|
+
`)}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 Qe(Mt)),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"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=p!==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(`
|
|
2005
|
+
`));let h=["#include <normal_fragment_begin>",`
|
|
2020
2006
|
// NOTE: gl_FrontFacing alternative using face normal estimation.
|
|
2021
2007
|
vec3 viewdx = dFdx(vViewPosition);
|
|
2022
2008
|
vec3 viewdy = dFdy(vViewPosition);
|
|
@@ -2024,7 +2010,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2024
2010
|
if (dot(normal, faceNormal) < 0.0) {
|
|
2025
2011
|
normal *= -1.0;
|
|
2026
2012
|
}
|
|
2027
|
-
`," BlinnPhongMaterial material;"];if(this.bumpMap){e.include(
|
|
2013
|
+
`," BlinnPhongMaterial material;"];if(this.bumpMap){e.include(rn.dHdxy),e.include(rn.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",v="";this.bumpMap.projection.value===4?v=`
|
|
2028
2014
|
vec3 bumpNormal = vec3(0.0);
|
|
2029
2015
|
{
|
|
2030
2016
|
vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
|
|
@@ -2046,23 +2032,23 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2046
2032
|
}
|
|
2047
2033
|
|
|
2048
2034
|
normal = bumpNormal;
|
|
2049
|
-
`:
|
|
2035
|
+
`:v=`
|
|
2050
2036
|
vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
|
|
2051
2037
|
vec2 grad = dHdxy(${m.result}, bumpMapCachedUv, ${g});
|
|
2052
2038
|
normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
|
|
2053
|
-
`,
|
|
2039
|
+
`,h.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
|
|
2054
2040
|
${y.result};
|
|
2055
|
-
${
|
|
2056
|
-
`)}
|
|
2041
|
+
${v}
|
|
2042
|
+
`)}h.push(i.code," vec3 diffuseColor = "+i.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",a.code," vec3 specular = "+a.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),p&&h.push(p.code,"#ifdef ALPHATEST","if ( "+p.result+" <= ALPHATEST ) discard;","#endif"),h.push("material.diffuseColor = diffuseColor;"),h.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),h.push("vec3 ao = aoEnabled && "+o.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),h.push(`
|
|
2057
2043
|
if (outgoingLight != diffuseColor) {
|
|
2058
2044
|
float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
|
|
2059
|
-
accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * ${
|
|
2060
|
-
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result} * ${
|
|
2045
|
+
accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * ${f} * lightAccu;
|
|
2046
|
+
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result} * ${f}, ${c.result} );
|
|
2061
2047
|
|
|
2062
2048
|
outgoingLight *= ao;
|
|
2063
2049
|
}
|
|
2064
|
-
`),
|
|
2065
|
-
`)}return
|
|
2050
|
+
`),u&&h.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),p?h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result});`):h.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&h.push(`gl_FragColor.a *= ${d.result};`),h.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=h.join(`
|
|
2051
|
+
`)}return t}};var ps=require("three");var Ml=class extends qt{constructor(){super("standard");this.nodeType="Standard";this.color=new Qe(Mt),this.roughness=new se(.3),this.metalness=new se(0),this.reflectivity=new se(.5),this.previousModelViewMatrix=new Jt,this.previouseProjectionMatrix=new Jt,this.shadingAlpha=new se(1),this.shadingBlend=new ze(0),this.occlusion=new Tt(!0)}get category(){return"physical"}build(e){let t;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(ps.UniformsUtils.merge([ps.UniformsLib.fog,ps.UniformsLib.lights])),ps.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(`
|
|
2066
2052
|
`));let i=["#include <beginnormal_vertex>",`
|
|
2067
2053
|
#if !defined( USE_LAYER_DISPLACE )
|
|
2068
2054
|
#include <defaultnormal_vertex>
|
|
@@ -2079,8 +2065,8 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2079
2065
|
#if !defined( USE_LAYER_DISPLACE )
|
|
2080
2066
|
#include <begin_vertex>
|
|
2081
2067
|
#endif /* !USE_LAYER_DISPLACE */
|
|
2082
|
-
`];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;"),
|
|
2083
|
-
`)}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
|
|
2068
|
+
`];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;"),t=i.join(`
|
|
2069
|
+
`)}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 Qe(Mt)),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"),c=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),p=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,h=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,f=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=d!==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(`
|
|
2084
2070
|
`));let m=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
|
|
2085
2071
|
// NOTE: gl_FrontFacing alternative using face normal estimation.
|
|
2086
2072
|
vec3 viewdx = dFdx(vViewPosition);
|
|
@@ -2089,7 +2075,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2089
2075
|
if (dot(normal, faceNormal) < 0.0) {
|
|
2090
2076
|
normal *= -1.0;
|
|
2091
2077
|
}
|
|
2092
|
-
`," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(
|
|
2078
|
+
`," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(rn.dHdxy),e.include(rn.perturbNormalArb);let g=this.bumpMap.texture.flow(e,"t"),v=this.bumpMap.flow(e,"v3"),O=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",P="";this.bumpMap.projection.value===4?P=`
|
|
2093
2079
|
vec3 bumpNormal = vec3(0.0);
|
|
2094
2080
|
{
|
|
2095
2081
|
vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
|
|
@@ -2097,13 +2083,13 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2097
2083
|
vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
|
|
2098
2084
|
vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
|
|
2099
2085
|
|
|
2100
|
-
vec2 grad0 = dHdxy(${g.result}, uv0, ${
|
|
2086
|
+
vec2 grad0 = dHdxy(${g.result}, uv0, ${O});
|
|
2101
2087
|
vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);
|
|
2102
2088
|
|
|
2103
|
-
vec2 grad1 = dHdxy(${g.result}, uv1, ${
|
|
2089
|
+
vec2 grad1 = dHdxy(${g.result}, uv1, ${O});
|
|
2104
2090
|
vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);
|
|
2105
2091
|
|
|
2106
|
-
vec2 grad2 = dHdxy(${g.result}, uv2, ${
|
|
2092
|
+
vec2 grad2 = dHdxy(${g.result}, uv2, ${O});
|
|
2107
2093
|
vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);
|
|
2108
2094
|
|
|
2109
2095
|
bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;
|
|
@@ -2111,14 +2097,14 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2111
2097
|
}
|
|
2112
2098
|
|
|
2113
2099
|
normal = bumpNormal;
|
|
2114
|
-
`:
|
|
2100
|
+
`:P=`
|
|
2115
2101
|
vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
|
|
2116
|
-
vec2 grad = dHdxy(${g.result}, bumpMapCachedUv, ${
|
|
2102
|
+
vec2 grad = dHdxy(${g.result}, bumpMapCachedUv, ${O});
|
|
2117
2103
|
normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
|
|
2118
2104
|
`,m.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
|
|
2119
|
-
${
|
|
2120
|
-
${
|
|
2121
|
-
`)}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"),
|
|
2105
|
+
${v.result};
|
|
2106
|
+
${P}
|
|
2107
|
+
`)}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"),v=this.roughnessMap.flow(e,"v3"),O="";this.roughnessMap.projection.value===4?O=`
|
|
2122
2108
|
float roughnessChange = 1.0;
|
|
2123
2109
|
{
|
|
2124
2110
|
vec2 uv0 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
|
|
@@ -2133,27 +2119,27 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2133
2119
|
roughnessChange = (r0 * weights.z + r1 * weights.x + r2 * weights.y);
|
|
2134
2120
|
}
|
|
2135
2121
|
float roughnessFactor = roughnessChange * ${s.result};
|
|
2136
|
-
`:
|
|
2122
|
+
`:O=`
|
|
2137
2123
|
vec2 roughnessMapCachedUv = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs;
|
|
2138
2124
|
|
|
2139
2125
|
vec4 vals = texture(${g.result}, roughnessMapCachedUv);
|
|
2140
2126
|
float roughnessFactor = luminance(vals.rgb) * ${s.result};
|
|
2141
2127
|
`,m.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
|
|
2142
|
-
${
|
|
2128
|
+
${v.result};
|
|
2143
2129
|
|
|
2144
2130
|
const float roughnessScale = 1.0;
|
|
2145
2131
|
|
|
2146
|
-
${
|
|
2147
|
-
`)}else m.push(s.code," float roughnessFactor = "+s.result+";");
|
|
2132
|
+
${O}
|
|
2133
|
+
`)}else m.push(s.code," float roughnessFactor = "+s.result+";");d&&m.push(d.code,"#ifdef ALPHATEST"," if ( "+d.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 );"),f?m.push(f.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+f.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(`
|
|
2148
2134
|
if (outgoingLight != diffuseColor) {
|
|
2149
2135
|
float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
|
|
2150
|
-
accumAlpha += ( 1.0 - accumAlpha ) * ${
|
|
2151
|
-
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${
|
|
2136
|
+
accumAlpha += ( 1.0 - accumAlpha ) * ${c.result} * ${y} * lightAccu;
|
|
2137
|
+
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${c.result} * ${y}, ${u.result} );
|
|
2152
2138
|
|
|
2153
2139
|
outgoingLight *= ao;
|
|
2154
2140
|
}
|
|
2155
|
-
`),
|
|
2156
|
-
`)}return
|
|
2141
|
+
`),p&&m.push(p.code,`outgoingLight = spe_blend(outgoingLight, ${p.result}, 1.0, SPE_BLENDING_NORMAL);`),d?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),h&&m.push(`gl_FragColor.a *= ${h.result};`),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=m.join(`
|
|
2142
|
+
`)}return t}};var Il=require("three");var Nl=class extends qt{constructor(){super("toon");this.nodeType="Toon";this.color=new Qe(Mt),this.specular=new Qe(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new Jt,this.previouseProjectionMatrix=new Jt,this.shadingAlpha=new se(1),this.shadingBlend=new ze(0)}get category(){return"toon"}build(e){let t;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(Il.UniformsUtils.merge([Il.UniformsLib.fog,Il.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(`
|
|
2157
2143
|
`));let i=["#include <beginnormal_vertex>",`
|
|
2158
2144
|
#ifndef USE_LAYER_DISPLACE
|
|
2159
2145
|
#include <defaultnormal_vertex>
|
|
@@ -2170,8 +2156,8 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2170
2156
|
#ifndef USE_LAYER_DISPLACE
|
|
2171
2157
|
#include <begin_vertex>
|
|
2172
2158
|
#endif
|
|
2173
|
-
`];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;"),
|
|
2174
|
-
`)}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
|
|
2159
|
+
`];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;"),t=i.join(`
|
|
2160
|
+
`)}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 Qe(Mt)),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"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,u=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=u!==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>",`
|
|
2175
2161
|
varying vec3 vViewPosition;
|
|
2176
2162
|
struct ToonMaterial {
|
|
2177
2163
|
vec3 diffuseColor;
|
|
@@ -2192,7 +2178,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2192
2178
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
|
|
2193
2179
|
#define Material_LightProbeLOD( material ) (0)
|
|
2194
2180
|
`,"#include <shadowmap_pars_fragment>","#include <bumpmap_pars_fragment>","#include <normalmap_pars_fragment>"].join(`
|
|
2195
|
-
`));let
|
|
2181
|
+
`));let d=["#include <normal_fragment_begin>",`
|
|
2196
2182
|
// NOTE: gl_FrontFacing alternative using face normal estimation.
|
|
2197
2183
|
vec3 viewdx = dFdx(vViewPosition);
|
|
2198
2184
|
vec3 viewdy = dFdy(vViewPosition);
|
|
@@ -2200,7 +2186,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2200
2186
|
if (dot(normal, faceNormal) < 0.0) {
|
|
2201
2187
|
normal *= -1.0;
|
|
2202
2188
|
}
|
|
2203
|
-
`," ToonMaterial material;"];if(this.bumpMap){e.include(
|
|
2189
|
+
`," ToonMaterial material;"];if(this.bumpMap){e.include(rn.dHdxy),e.include(rn.perturbNormalArb);let f=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=`
|
|
2204
2190
|
vec3 bumpNormal = vec3(0.0);
|
|
2205
2191
|
{
|
|
2206
2192
|
vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
|
|
@@ -2208,13 +2194,13 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2208
2194
|
vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
|
|
2209
2195
|
vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
|
|
2210
2196
|
|
|
2211
|
-
vec2 grad0 = dHdxy(${
|
|
2197
|
+
vec2 grad0 = dHdxy(${f.result}, uv0, ${y});
|
|
2212
2198
|
vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);
|
|
2213
2199
|
|
|
2214
|
-
vec2 grad1 = dHdxy(${
|
|
2200
|
+
vec2 grad1 = dHdxy(${f.result}, uv1, ${y});
|
|
2215
2201
|
vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);
|
|
2216
2202
|
|
|
2217
|
-
vec2 grad2 = dHdxy(${
|
|
2203
|
+
vec2 grad2 = dHdxy(${f.result}, uv2, ${y});
|
|
2218
2204
|
vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);
|
|
2219
2205
|
|
|
2220
2206
|
bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;
|
|
@@ -2224,23 +2210,23 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2224
2210
|
normal = bumpNormal;
|
|
2225
2211
|
`:g=`
|
|
2226
2212
|
vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
|
|
2227
|
-
vec2 grad = dHdxy(${
|
|
2213
|
+
vec2 grad = dHdxy(${f.result}, bumpMapCachedUv, ${y});
|
|
2228
2214
|
normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
|
|
2229
|
-
`,
|
|
2215
|
+
`,d.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
|
|
2230
2216
|
${m.result};
|
|
2231
2217
|
${g}
|
|
2232
|
-
`)}
|
|
2218
|
+
`)}d.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",i.code," vec3 specular = "+i.result+";",a.code," float shininess = max( 0.0001, "+a.result+" );"," float specularStrength = 1.0;"),u&&d.push(u.code,"#ifdef ALPHATEST","if ( "+u.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),d.push("vec3 ao = aoEnabled ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * ao) + reflectedLight.directSpecular;");let h="1.0";this.mask&&(this.mask.analyze(e),h=`luminance(${this.mask.flow(e,"v3").result})`),d.push(`
|
|
2233
2219
|
if (outgoingLight != diffuseColor) {
|
|
2234
2220
|
float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
|
|
2235
|
-
accumAlpha += ( 1.0 - accumAlpha ) * ${s.result} * ${
|
|
2236
|
-
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result} * ${
|
|
2221
|
+
accumAlpha += ( 1.0 - accumAlpha ) * ${s.result} * ${h} * lightAccu;
|
|
2222
|
+
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result} * ${h}, ${l.result} );
|
|
2237
2223
|
}
|
|
2238
|
-
`),
|
|
2239
|
-
`)}return r}};var Ls=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 ah=class extends pd{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},ih;function Tb(n){return typeof n=="string"?n:(ih||(ih=new ah),ih.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 Bs=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=Tb(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 Ls.CanvasTexture(this.img,void 0,e,e,void 0,r)),this.isVideo?i=new Ls.VideoTexture(this.img,void 0,e,e):i=new Ls.Texture(this.img,void 0,e,e,void 0,r),this.loaded&&(i.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),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 Ur=class extends Bs{};var mt=require("three");function dr(n,t){return t.color(n)}function Mb(n,t){switch(n.type){case"fresnel":return wM(n,t);case"gradient":return AM(n,t);case"depth":return _M(n,t);case"normal":return PM(n,t);case"noise":return OM(n,t);case"rainbow":return CM(n,t);case"toon":return TM(n,t);case"outline":return MM(n,t);case"transmission":return IM(n,t);case"color":return SM(n,t);case"pattern":return NM(n,t)}}function vM(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{...vM(n),alpha:i,mode:r,isMask:o}}function SM(n,t){return{...Po(n,t),color:dr(n.color,t)}}function wM(n,t){let{bias:e,scale:r,intensity:o,factor:i,color:a}=n;return{...Po(n,t),color:dr(a,t),bias:e,scale:r,intensity:o,factor:i}}function AM(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 _M(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 PM(n,t){let{cnormal:e}=n;return{...Po(n,t),cnormal:new mt.Vector3(e[0],e[1],e[2])}}function OM(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:dr(n.colorA,t),colorB:dr(n.colorB,t),colorC:dr(n.colorC,t),colorD:dr(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 CM(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 TM(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:dr(n.shadowColor,t),offset:new mt.Vector3(...n.offset)}}function MM(n,t){return{...Po(n,t),outlineColor:dr(n.outlineColor,t),contourColor:dr(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 IM(n,t){return{...Po(n,t),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function NM(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:dr(n.colorA,t),colorB:dr(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 Xt{};var md=require("three");var sh={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},lh={depth:["colors"]};function DM(n,t,e){if(t==="isMask")return!0;let r=sh[n.type],o=lh[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 ch(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 Ur||l.image.deref(),l.image=s}if("video"in i){let a=i.video,s=t.video(a),l=r;l.image instanceof Ur||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("rotation"in i&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(i.rotation??0)*md.MathUtils.DEG2RAD,o;if("repeat"in i||"offset"in i||"rotation"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),"rotation"in i&&(s.rotation=i.rotation??0),s.updateMatrix()}return o}function Ib(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(uh(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||DM(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 Xt(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case Ir: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 Xt(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 cr:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case wr:{ch(a,t,e);break}case _o:{s.value=a.map(l=>new md.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)uh(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 Bi(i,r.texture.wrapping,r.texture.minFilter??1008),s=new cd(i),l=new ud(r.texture.repeat,r.texture.offset,r.texture.rotation??0),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 Bi(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 se(r.texture.rotation??0),d=new Ps(a,s,l,u,c),p=new Ze(d.calpha,"f");return new xt(t,e,r,{texture:a,alpha:s,mode:l,isMask:u,rotation:c},d,l,p,u,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let i=new cr(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 Ds(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 LM(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):Ib(o.props,r.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?ch(o.props,r.shared,this):!0;return!1}dispose(){if(EM(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof Ur||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 EM(n){let t=n instanceof Ho?n.type:n;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Jr(n){return{alpha:new se(n.alpha??1),mode:new Ge(n.mode??0),isMask:new Et(n.isMask??!1)}}function BM(n,t,e,r,o){switch(n.type){case"color":{let i=new et(r.color??Rt),a=Jr(r),s=new Li(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=Jr(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 cr(r.wavelengths??new it.Vector3(0,0,0)),l=new se(r.noiseStrength??0),u=new se(r.noiseScale??1),c=new cr(r.offset??new it.Vector3(0,0,0)),d=Jr(r),p=new Ms(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=Jr(r),m=new Ns(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 cr(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 Ir(r.shadowColor),f=new cr(r.offset??new it.Vector3(0,0,0)),h=Jr(r),m=new Is(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 cr(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,A=Jr(r),S=new Cs(i,a,s,l,u,c,d,p,f,h,m,w,y,g,b,A.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,...A},S,A.mode,P,A.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 cr(r.origin??new it.Vector3),p=new cr(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=Jr(r),y=new As(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 cr(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 Ir(r.colorA),p=new Ir(r.colorB),f=new Ir(r.colorC),h=new Ir(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),A=new se(r.seed??.5),S=new Ge(r.quality??1),P=Jr(r),O=new Os(i,a,s,l,u,c,d,p,f,h,P.alpha,m,P.isMask,y,g,b,w,A,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:A,quality:S},O,P.mode,x,P.isMask,o)}case"normal":{let i=new cr(r.cnormal??new it.Vector3(1,1,1)),a=Jr(r),s=new vs(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=Jr(r),f=new _s(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 Ir(r.colorA),d=new Ir(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)),A=new Ge(r.sides??6),S=Jr(r),P=new Ts(i,a,s,l,u,c,d,p,f,h,m,y,g,b,w,A,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:A,...S},P,S.mode,O,S.isMask,o)}default:{let i=new et(1,0,0,1),a=Jr(r),s=new Li(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 LM(n,t,e,r){let o=Mb(e,r);return BM(e,n,t,o,r)}function uh(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 yd(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 Dr=class extends Nb.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}},gd=class extends Dr{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()}},Vi=class extends Dr{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 gd(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??lr.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=yd(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=yd(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=yd(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,"",{...Ft.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=yd(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 bs(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 bs(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=(sh[r.type]??[]).map(u=>r[u]),i=(lh[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 gs;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 Bi&&!r.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(Dr.prototype,{properties:{get:function(){return this.fragment.properties}}});var zi=class extends Vi{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var Lb=ar(Db());var Eb=new Map;function Bb(n){if(typeof n=="string")return n;let t=Eb.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},Eb.set(n,t)),t.url}var Gi=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:Bb(t),format:"wav"},this.sound=new Lb.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 Qt=require("three"),bd=class{constructor(){this.type="ShapePath";this.color=new Qt.Color;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new Qt.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,A=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=(A-w)*(O-D)-(x-O)*(w-S),E=(N-D)*(A-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 F=0;F<2;F++)if(i(F===0?g:b,m,y),r.loc===e.ORIGIN){let V=F===0?g:b;return{x:V.x,y:V.y,t:r.t}}else if(r.loc===e.BETWEEN){let V=+(w+r.t*(A-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 k=q===0?g:b;return{x:k.x,y:k.y,t:r.t}}let F=+(w+B*(A-w)).toPrecision(10),V=+(O+B*(x-O)).toPrecision(10);return{x:F,y:V,t:B}}}function i(m,y,g){let b=g.x-y.x,w=g.y-y.y,A=m.x-y.x,S=m.y-y.y,P=b*S-A*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*A<0||w*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(b*b+w*w)<Math.sqrt(A*A+S*S)){r.loc=e.BEYOND;return}let O;b!==0?O=A/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 A=m[w-1],S=m[w];for(let P=1;P<y.length;P++){let O=y[P-1],x=y[P],D=o(A,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 Qt.Vector2(D.x,D.y)))}}return b}function s(m,y,g){let b=new Qt.Vector2;y.getCenter(b);let w=[];return g.forEach(A=>{A.boundingBox.containsPoint(b)&&a(m,A.points).forEach(P=>{w.push({identifier:A.identifier,isCW:A.isCW,point:P})})}),w.sort((A,S)=>A.point.x-S.point.x),w}function l(m,y,g,b,w){(w==null||w==="")&&(w="nonzero");let A=new Qt.Vector2;m.boundingBox.getCenter(A);let S=[new Qt.Vector2(g,A.y),new Qt.Vector2(b,A.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 F=N[R];y[F]&&(I?(B=y[F].isCW,I=!1,E=F):B!==y[F].isCW&&(B=y[F].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,A=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<A&&(A=P.x)}d<=w&&(d=w+1),c>=A&&(c=A-1),y.length&&p.push({curves:m.curves,points:y,isCW:Qt.ShapeUtils.isClockWise(y),identifier:u++,boundingBox:new Qt.Box2(new Qt.Vector2(A,b),new Qt.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 Qt.Shape;g.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let A=p[w.identifier],S=new Qt.Path;S.curves=A.curves,g.holes.push(S)}}),h.push(g)}}),h}};var dh=!1,Vb,ph=new Promise(n=>{Vb=n}),Rb=!1;var vd;function zb(){if(dh=!0,Rb)return;if(vd)return vd;async function n(){let e=await import("./opentype.js");Vb(e),Rb=!0}return vd=n(),vd}var tc=class{async load(t,e,r=()=>{}){let{load:o}=await ph;o(t,(i,a)=>{i||!a?r(i??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await ph;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 RM(n){return await(await fetch(n)).arrayBuffer()}var VM=new tc;async function fh(n){let t,e,r=!1;if(n.url?(t=await RM(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(dh){let o=await VM.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 Rs=require("three");function zM(n,t){return t.state.glyphIndex===n||t.state.fina===n||t.state.medi===n||t.state.init===n}var Sd=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=fh(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=fh(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(zM(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(`
|
|
2240
|
-
`,e),
|
|
2241
|
-
`:x.unicode?String.fromCharCode(x.unicode):void 0,
|
|
2242
|
-
`)E=
|
|
2243
|
-
`)>=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 bd,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=GM(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 GM(n){if(n.length){let t=n[0];if(t instanceof Rs.LineCurve)return t.v1;if(t instanceof Rs.CubicBezierCurve||t instanceof Rs.QuadraticBezierCurve)return t.v0}}var hh=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 hh{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 Gb={markNeedsUpdateRendererDirty:()=>{}};var mh=require("three"),yh=class extends hd{constructor(e){super();this.shared=e}create(e){return new Bs(e,this.shared)}},Fi=class{constructor(t,e={}){this.data=t;this.geometryCache=new rc(!0);this.geometryCache2=new rc(!1);this.imageHolderCache=new yh(this);this.thisContext={scene:Gb,shared:this};this.deletedMaterial=new zi(lr.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new Ur(Fa.emptyImage,this);this.deletedVideo=new Ur(Da.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 zi(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 Vi(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 Ur(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 Ur(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 Ur(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 Xt(0,0,0,0))}else return"a"in t?new Xt(t.r,t.g,t.b,t.a):new Xt(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 Gi)return e;{let r=new Gi({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 Gi&&e.dispose(),delete this.audios[t])}addFont(t,e){this.fonts[t]=new Sd(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 Gi&&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*mh.MathUtils.DEG2RAD:s[a[a.length-1]]=r}if(s=o.find(a[0]),s.type==="ParticleEmitter"&&s.updateVariableState(r,a),ke.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 this.requestRender(),!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*=mh.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)}}},Fb=new Fi(Kr.emptyData());var Er=class extends $t{updateByPatchedOp(e,r,o){if(super.updateByPatchedOp(e,r,o),Eg(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(Fe(e.path,["material"])&&this.material instanceof Dr)"material"in r&&typeof r.material!="string"&&this.material.updateByOp(wt.drop(e,1),r.material,o);else if(Fe(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 Dr&&(e instanceof zi||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var Hr=require("three");var kb=new Hr.Vector3,jb=new Hr.Vector4,Ub=new Hr.Vector4,kM=new Hr.Vector3,Hb=new Hr.Matrix4,Ot=class extends Er{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 Hr.Matrix4().fromArray(r.bindMatrix),this.bindMatrixInverse=new Hr.Matrix4)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof Hr.BufferGeometry&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Fi){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 Sl.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return Sl.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),Fe(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&&Gl(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 Hr.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;jb.fromBufferAttribute(i.attributes.skinIndex,e),Ub.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=Ub.getComponent(a);if(s!==0){let l=jb.getComponent(a);Hb.multiplyMatrices(o.bones[l].matrixWorld,o.boneInverses[l]),r.addScaledVector(kM.copy(kb).applyMatrix4(Hb),s)}}return r.applyMatrix4(this.bindMatrixInverse)}};function jM(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 qr.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 qr.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 qr.Float32BufferAttribute(i,3))}function UM(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 qr.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 qr.Float32BufferAttribute(r,3))}function Vs(n){if(Array.isArray(n.material)){for(let t of n.material)if(t.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof Dr)||n.material.getLayersOfType("outline").length===0)return;n instanceof Ot&&n.is2DAndNoDepth?UM(n):jM(n)}function zs(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=[qr.MathUtils.seededRandom(o),qr.MathUtils.seededRandom(o+1e4),qr.MathUtils.seededRandom(o+2e4)];for(let a=0;a<e.length;a++)r[a]=i[a%3];n.geometry.setAttribute("randomColor",new qr.BufferAttribute(r,3))}var qo=new vn.Box3,oc=new vn.Vector3;function qb(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,Vs(this),zs(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,$t.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"),Wb=-1,HM=1,$b={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},Yb={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-Wb)*(e-r)/(HM-Wb)+r};function Xb(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 qM=new Wo.Vector3,wd=new Wo.Vector3,WM=new Wo.Vector3,$M=new Wo.Vector3;function Gs(n,t){let e=WM.fromArray(n),r=$M.fromArray(t);wd.copy(r).sub(e);let o=wd.length();return wd.normalize().multiplyScalar(o*.5),qM.copy(e).add(wd).toArray()}var eo=new Wo.Triangle,Ad=new Wo.Vector3,_d=new Wo.Vector3,ji=new Wo.Vector3;function Qb(n){let t=[];for(let e=0;e<=n.index.count;e++)if(Ad.fromArray(n.index.array,e*3),eo.setFromAttributeAndIndices(n.attributes.position,Ad.x,Ad.y,Ad.z),eo.getNormal(_d),eo.getMidpoint(ji),!(isNaN(ji.x)||isNaN(ji.y)||isNaN(ji.z))){let{a:r,b:o,c:i}=eo,a=r.toArray(),s=o.toArray(),l=i.toArray(),u=r.distanceTo(o),c=o.distanceTo(i),d=i.distanceTo(r),p=Gs(a,s),f=Gs(s,l),h=Gs(l,a),m=[u,c,d],y=Math.max(...m),g=m.filter(A=>Math.round(A)===Math.round(y)).length>1,b=[],w=eo.getMidpoint(ji).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:eo.getNormal(_d).toArray()})}return t}function Kb(n){let t=[],{position:e}=n.attributes;for(let r=0;r<e.count;r++){eo.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),eo.getNormal(_d),eo.getMidpoint(ji);let o=eo.a.toArray(),i=eo.b.toArray(),a=eo.c.toArray();t.push({vertices:[o,i,a],faceCenters:[Gs(o,i),Gs(i,a),Gs(a,o)],midpoint:ji.toArray(),norm:_d.toArray()})}return t}var YM=4,XM=.5,gh=n=>.5*(1-Math.cos(n*Math.PI)),xh=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<YM;g++){let b=o+(i<<4)+(a<<8);c=gh(s),d=gh(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+=gh(u)*(m-h),p+=h*f,f*=XM,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()}},Zb=xh;var ks=require("three");var Jb=new ks.Vector3,ev=new ks.Matrix4,tv=new ks.Ray;function rv(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="TextGeometry"&&(t=!0)}),t}var Fs=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)&&(ev.copy(o).invert(),tv.copy(e.ray).applyMatrix4(ev),tv.intersectBox(this.singleBBox,Jb))){let i=Jb.applyMatrix4(o),a=e.ray.origin.distanceTo(i);r.push({distance:a,point:i.clone(),object:this})}}};var _r=1e-4,$o,iv,av,sv,ov=new tt.Vector3,nv=new tt.Vector3;td.then(n=>{$o=n,iv=[$o.get_face_center,$o.get_edge_midpoint,$o.get_vertex_position],av=[$o.get_face_normal,$o.get_edge_normal,$o.get_vertex_normal],sv=[$o.face_count,$o.edge_count,$o.vertex_count]});var QM=new tt.Matrix4,KM=new tt.Matrix4,ti=new tt.Vector3,Pd=new tt.Vector3,ic=new tt.Vector3,bh=new tt.Vector3,ZM=new tt.Vector3,JM=new tt.Vector3;var Sn=new Zb,Us=class extends qa(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,js.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])),A=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+A,h.rotation.z+=s.z+S):h.rotation.set(s.x+w,s.y+A,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,js.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=z0((0,js.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,js.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 Fs)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),A=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,A/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=Xb(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=$b[r.axis],y=this.children;h.setRandomGenerator((0,js.default)(this.object.uuid+r.seed));for(let[g,b]of y.entries()){let w=g*(i.freqScale/10)+i.movement,A=a?Sn.noise(w):s(w,w),S=g+1,P=l(S,Ie(A,i.rotation[0])),O=l(S,Ie(A,i.rotation[1])),x=l(S,Ie(A,i.rotation[2]));r.spreadType==="random"?h.sample(ic,bh):(f.length&&(ic.fromArray(f[g].pos),bh.fromArray(f[g].norm)),this.objectForSample instanceof ki&&ic.applyMatrix4(QM.copy(this.objectForSample.matrixWorld).invert())),ic.applyMatrix4(this.object.hiddenMatrix.clone().invert()),b.position.copy(ic),ti.fromArray(m);let D=r.align==="normal"?bh:this.object.getWorldDirection(JM),N=Pd.fromArray(r.position);Pd.x+=l(S,Ie(A,i.position[0])),Pd.y+=l(S,Ie(A,i.position[1])),Pd.z+=l(S,Ie(A,i.position[2]));let T=Math.acos(D.dot(ti)),I=ZM.crossVectors(ti,D).normalize(),E=KM.makeRotationAxis(I,T),B=D.clone().cross(this.object.up).normalize(),R=B.clone().cross(D).normalize(),F=new tt.Matrix4().makeBasis(B,D,R),V=new tt.Vector3(ti.y,ti.z,ti.x).normalize(),q=V.clone().cross(ti).normalize(),k=new tt.Matrix4().makeBasis(V,ti,q).invert(),U=new tt.Matrix4().multiplyMatrices(F,k);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(A,i.scale[0]))||_r,b.scale.y=b.scale.y+r.scale[1]+l(S,Ie(A,i.scale[1]))||_r,b.scale.z=b.scale.z+r.scale[2]+l(S,Ie(A,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=Yb[e],i=sv[o],a=iv[o],s=av[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);ov.fromArray(d).applyMatrix4(r.matrixWorld),nv.fromArray(p),l.push({pos:ov.toArray(),norm:nv.toArray()})}return l}else return(this.objectForSample.geometry.index?Qb(this.objectForSample.geometry):Kb(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 $t?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 pr=require("three");var lv=require("three"),Yo=n=>{var t;return t=class extends n{},t.geometryHelper=new lv.BoxGeometry(30,30,30),t};var yr=require("three"),Od=new yr.Ray,vh=new yr.Sphere,cv=new yr.Matrix4,Xo=(n,t,e,r,o=!1)=>{let i=t,a=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),vh.copy(i.boundingSphere),vh.applyMatrix4(a),e.ray.intersectsSphere(vh)===!1||(cv.copy(a).invert(),Od.copy(e.ray).applyMatrix4(cv),i.boundingBox!==null&&Od.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,Od,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,A=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),A.fromBufferAttribute(b,E+1),Od.distanceSqToSegment(w,A,P,S)>N)continue;P.applyMatrix4(n.matrixWorld);let F=e.ray.origin.distanceTo(P);F<e.near||F>e.far||r.push({distance:F,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(g,b,w,A,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(A,S),D.fromBufferAttribute(A,P),N.fromBufferAttribute(A,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 Cd=new pr.Vector3,to=new pr.Camera,Sh=class extends pr.LineSegments{constructor(e){let r=new pr.BufferGeometry,o=new pr.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],a=[],s={},l=new pr.Color(15711266),u=new pr.Color(15711266),c=new pr.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 pr.Float32BufferAttribute(i,3)),r.setAttribute("color",new pr.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;to.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,to,-i,-a,s),Oo("n2",r,e,to,i,-a,s),Oo("n3",r,e,to,-i,a,s),Oo("n4",r,e,to,i,a,s);let l=s;Oo("f1",r,e,to,-i,-a,l),Oo("f2",r,e,to,i,-a,l),Oo("f3",r,e,to,-i,a,l),Oo("f4",r,e,to,i,a,l);let u=l,c=.5;Oo("u1",r,e,to,i*.7*c,a*1.1,u),Oo("u2",r,e,to,-i*.7*c,a*1.1,u),Oo("u3",r,e,to,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){Cd.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],Cd.x,Cd.y,Cd.z)}}var Td=class extends Yo(Sh){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 Md;(t=>t.is=e=>"objectHelper"in e)(Md||(Md={}));var ro=(n,t)=>class extends Ya(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 Id=790,Hs=new bt.Vector3,wh=new bt.Vector3,Ah=new bt.Quaternion,_h=new bt.Vector3,sc=new bt.Vector3,Ph=new bt.Vector3,wn=class extends ro(bt.Camera,Td){constructor(e="",r={...Pi.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Fn.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(Hs),this.targetOffset=Hs.distanceTo(e)}getTarget(e=new bt.Vector3){return this.getWorldDirection(wh),this.getWorldPosition(Hs),wh.multiplyScalar(this.targetOffset),e.copy(Hs).add(wh),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Hs),Hs.distanceTo(e)}updateUp(){this.getWorldQuaternion(Ah),_h.set(0,0,1).applyQuaternion(Ah),sc.copy(bt.Object3D.DEFAULT_UP),this.isUpVectorFlipped&&sc.negate(),sc.applyQuaternion(Ah),Ph.copy(bt.Object3D.DEFAULT_UP).projectOnPlane(_h),this.angleOffsetFromUp=Ph.angleTo(sc),this.angleOffsetFromUp*=Ph.cross(sc).dot(_h)>=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=-Id*.5*i,this.right=Id*.5*i,this.top=Id*.5*(1/a),this.bottom=-Id*.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 rI=require("three");var ri=require("three");var qs=new ri.Matrix4,tI=new ri.Matrix4;var Br=class extends Er{constructor(e,r,o){super(e,r);this.data=r;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new ri.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 Br&&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 $t&&a.dataPatched.visible===!0&&a.geometry.attributes.position?.count>0&&a.geometry.drawRange.count>0&&a.booleanMeshSetAddress!==0){qs.multiplyMatrices(a.hiddenMatrix,a.matrix);try{if(a.booleanMeshSetAddress===-1){if((a.geometry.index??a.geometry.getAttribute("position")).count/3<15e5&&(a.booleanMeshSetAddress=Zr.getMeshSet(a.geometry,e===!0,r)),a.booleanMeshSetAddress===-1)return;Zr.transformMeshSet(a.booleanMeshSetAddress,qs),a.booleanMatrixInvOld.copy(qs).invert(),a.booleanWasTransformed=!1}else a instanceof Br&&a.needsTransformForDownstream===!0?(Zr.transformMeshSet(a.booleanMeshSetAddress,qs),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(Zr.transformMeshSet(a.booleanMeshSetAddress,tI.multiplyMatrices(qs,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(qs).invert(),a.booleanWasTransformed=!1)}catch(s){console.error(s),a.booleanMeshSetAddress=0,a.geometry.userData.booleanOperationDidFail=!0;continue}Zr.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 ri.Float32BufferAttribute([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Zr.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new ri.BufferGeometry,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=Zr.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,Vs(this),zs(this)}dispose(){super.dispose(),this.geometry.dispose()}};var dv=require("three");var uv;(t=>{function n(e){return ke.is(e)&&e instanceof dv.Light}t.is=n})(uv||(uv={}));var Ws=(n,t)=>class extends ro(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 oi=n=>n instanceof $t,lc=n=>n!==null&&n instanceof Br;var cc=n=>Md.is(n);var fv=require("three");var pv=require("three");var oo=class extends Yo(pv.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 ni=class extends ro(fv.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 hv=require("three");var Nd=class extends ro(hv.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 $s=require("three"),oI=n=>`
|
|
2224
|
+
`),c&&d.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),u?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p&&d.push(`gl_FragColor.a *= ${p.result};`),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
|
|
2225
|
+
`)}return t}};var hs=require("three");var ku=class{constructor(r=1e3*10){this.timeout=r;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(...r){}remove(r){let e=this.cache.get(r);e&&(this.dispose(r,e.data),this.cache.delete(r),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 r=Date.now(),e=this.head.next;for(;e.time<r-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(r){return this.cache.get(r)?.data}load(r){let e=Date.now(),t=this.cache.get(r);return t===void 0?(t={data:this.create(r),src:r,time:e,next:null,prev:null},this.cache.set(r,t)):(t.time=e,t.prev.next=t.next,t.next.prev=t.prev),t.prev=this.tail.prev,t.next=this.tail,this.tail.prev.next=t,this.tail.prev=t,this.scheduleCleanup(),t.data}};var Rf=class extends ku{create(r){return URL.createObjectURL(new Blob([r]))}dispose(r,e){URL.revokeObjectURL(e)}},Lf;function Jx(n){return typeof n=="string"?n:(Lf||(Lf=new Rf),Lf.load(n))}var Hu=class{constructor(r,e){this.data=r;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")}},Wu=class{constructor(){this.cache=new Map}remove(r){if(this.cache.delete(r.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(r){let e=this.cache.get(r);return e===void 0&&(e=this.create(r),this.cache.set(r,e)),e.refCount+=1,e}};var fs=class extends Hu{constructor(e,t){super(e,t.imageHolderCache);this.data=e;this.shared=t;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 t=()=>{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=()=>{t()}}else this.img=new Image,this.img.src=Jx(e),this.img.onload=t}getTexture(e,t=1008){let o=this._cache[e]?.[t];if(o)return o;{let i;return this.isCanvas&&(i=new hs.CanvasTexture(this.img,void 0,e,e,void 0,t)),this.isVideo?i=new hs.VideoTexture(this.img,void 0,e,e):i=new hs.Texture(this.img,void 0,e,e,void 0,t),this.loaded&&(i.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][t]=i,i}}setNeedsUpdate(e){for(let t of Object.values(this._cache))for(let o of Object.values(t))o&&(o.needsUpdate=e)}disposeTextures(){for(let[e,t]of Object.entries(this._cache))for(let[o,i]of Object.entries(t))i?.dispose(),this._cache[e][o]=void 0}dispose(){super.dispose(),this.disposeTextures()}};var Nr=class extends fs{};var ct=require("three");function er(n,r){return r.color(n)}function eb(n,r){switch(n.type){case"fresnel":return OM(n,r);case"gradient":return CM(n,r);case"depth":return TM(n,r);case"normal":return AM(n,r);case"noise":return MM(n,r);case"rainbow":return IM(n,r);case"toon":return NM(n,r);case"outline":return DM(n,r);case"transmission":return EM(n,r);case"color":return PM(n,r);case"pattern":return _M(n,r)}}function wM(n){return{type:n.type}}function uo(n,r){let{alpha:e,mode:t,isMask:o}=n,i=typeof e=="string"?(Number(r.getVariable(e))??100)/100:e;return{...wM(n),alpha:i,mode:t,isMask:o}}function PM(n,r){return{...uo(n,r),color:er(n.color,r)}}function OM(n,r){let{bias:e,scale:t,intensity:o,factor:i,color:a}=n;return{...uo(n,r),color:er(a,r),bias:e,scale:t,intensity:o,factor:i}}function CM(n,r){let{gradientType:e,smooth:t,colors:o,steps:i,angle:a,offset:s,morph:l}=n;return{...uo(n,r),gradientType:e,smooth:t,colors:o.map(c=>new ct.Vector4(c[0],c[1],c[2],c[3])),num:o.length,steps:i,offset:new ct.Vector2(...s),morph:new ct.Vector2(...l),angle:a}}function TM(n,r){let{gradientType:e,near:t,far:o,isVector:i,isWorldSpace:a,origin:s,direction:l,colors:c,steps:u,smooth:p}=n;return{...uo(n,r),gradientType:e,near:t,far:o,isVector:i,isWorldSpace:a,origin:new ct.Vector3(...s),direction:l?new ct.Vector3(...l):new ct.Vector3(1,0,0),colors:c.map(d=>d!==void 0?new ct.Vector4(d[0],d[1],d[2],d[3]):new ct.Vector4(0,0,0,0)),steps:u.slice(0,c.length),smooth:p}}function AM(n,r){let{cnormal:e}=n;return{...uo(n,r),cnormal:new ct.Vector3(e[0],e[1],e[2])}}function MM(n,r){return{...uo(n,r),scale:n.scale,move:n.move,fA:new ct.Vector2(...n.fA),fB:new ct.Vector2(...n.fB),size:new ct.Vector3(...n.size),distortion:new ct.Vector2(...n.distortion),colorA:er(n.colorA,r),colorB:er(n.colorB,r),colorC:er(n.colorC,r),colorD:er(n.colorD,r),noiseType:n.noiseType,voronoiStyle:n.voronoiStyle,highCut:n.highCut,lowCut:n.lowCut,smoothness:n.smoothness,seed:n.seed,quality:n.quality}}function IM(n,r){return{...uo(n,r),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new ct.Vector3(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new ct.Vector3(...n.offset)}}function NM(n,r){return{...uo(n,r),positioning:n.positioning,colors:n.colors.map(e=>new ct.Vector4(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new ct.Vector3(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:er(n.shadowColor,r),offset:new ct.Vector3(...n.offset)}}function DM(n,r){return{...uo(n,r),outlineColor:er(n.outlineColor,r),contourColor:er(n.contourColor,r),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new ct.Vector3(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function EM(n,r){return{...uo(n,r),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function _M(n,r){return{...uo(n,r),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new ct.Vector2(...n.offset),colorA:er(n.colorA,r),colorB:er(n.colorB,r),frequency:new ct.Vector2(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new ct.Vector2(...n.vertical),horizontal:new ct.Vector2(...n.horizontal),sides:n.sides}}var Rn=class extends jt{};var qu=require("three");var Vf={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},zf={depth:["colors"]};function BM(n,r,e){if(r==="isMask")return!0;let t=Vf[n.type],o=zf[n.type];if(o!==void 0){let i=n.color;if(o.includes(r)){let a=i[r]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return t!==void 0?t.includes(r):!1}function Gf(n,r,e){let t=e.uniforms[`f${e.id}_texture`];if(!t)return!1;let o=!1,i=n;if("image"in i){let a=i.image,s=r.image(a),l=t;l.image instanceof Nr||l.image.deref(),l.image=s}if("video"in i){let a=i.video,s=r.video(a),l=t;l.image instanceof Nr||l.image.deref(),l.image=s}if("wrapping"in i){let a=t;a.wrap=i.wrapping}if("minFilter"in i){let a=t;a.minFilter=i.minFilter}if("rotation"in i&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(i.rotation??0)*qu.MathUtils.DEG2RAD,o;if("repeat"in i||"offset"in i||"rotation"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),"rotation"in i&&(s.rotation=i.rotation??0),s.updateMatrix()}return o}function tb(n,r,e,t){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(jf(i,e,t,r)){i==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=t.visible;let s=e.uniforms[`f${e.id}_${i}`];if(!!s&&!(s instanceof Bn))switch(o=o||BM(e,i,a),s.constructor){case Qe:if(typeof a=="string"){let l=r.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Rn?s.value=new jt(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case br:if(typeof a=="string"){let l=r.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Rn?s.value=new jt(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case xt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case Zt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case ur:{Gf(a,r,e);break}case co:{s.value=a.map(l=>new qu.Vector4(...l));break}default:{s.value=a;break}}}return o}var Vn=(n,r,e)=>Math.max(0,Math.min(1,Number(r.getVariable(typeof n=="number"?n*100:n,e)??100)/100))??1,Io=class{constructor(r,e,t,o,i){this.id=r;this.uuid=e;this.data=t;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in t)jf(a,this,t,i)}get type(){return this.data.type}static create(r,e,t,o){if(t.type==="light")return dr.createLigherLayer(r,e,t,o);if(t.type==="texture"||t.type==="video"){let i=t.type==="texture"?o.canvas(t.texture.image)??o.image(t.texture.image):o.video(t.texture.video),a=new mi(i,t.texture.wrapping,t.texture.minFilter??1008),s=new ju(i),l=new Fu(t.texture.repeat,t.texture.offset,t.texture.rotation??0),c=new se(t.crop?1:0),u=new ze(t.projection??0),p=new ze(["x","y","z"].indexOf(t.axis)??0),d=new ze(t.side??0),h=new xt(t.size?new rt.Vector2(t.size[0],t.size[1]):new rt.Vector2(100,100)),f=new se(t.blending??0),m=new se(Vn(t.alpha,o)),y=new ze(t.mode??0),g=new Tt(t.isMask??!1),v=new Ln(a,s,c,u,p,d,h,f,l,m,y,g),O=new Xe(v.calpha,"f");return new pt(r,e,t,{texture:a,textureSize:s,crop:c,projection:u,axis:p,side:d,size:h,blending:f,mat:l,alpha:m,mode:y,isMask:g},v,y,O,g,o)}else if(t.type==="matcap"){let i=o.image(t.texture.image),a=new mi(i,t.texture.wrapping,t.texture.minFilter??1008),s=new se(Vn(t.alpha,o)),l=new ze(t.mode??0),c=new Tt(t.isMask??!1),u=new se(t.texture.rotation??0),p=new ns(a,s,l,c,u),d=new Xe(p.calpha,"f");return new pt(r,e,t,{texture:a,alpha:s,mode:l,isMask:c,rotation:u},p,l,d,c,o)}else if(t.type==="displace")if(t.displacementType==="noise"){let i=new Zt(new rt.Vector3(...t.offset)),a=new se(t.scale??10),s=new se(t.intensity??8),l=new se(t.movement??1),c=new ze(t.noiseType??0),u=new ze(t.voronoiStyle??0),p=new se(t.smoothness??.5),d=new se(t.seed??0),h=new se(t.highCut??1),f=new se(t.lowCut??0),m=new ze(t.quality??1),y=new ds(s,l,i,u,p,d,h,f,m,a,c);return new Dl(r,e,t,{offset:i,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:u,smoothness:p,seed:d,highCut:h,lowCut:f,quality:m},y,o)}else throw new Error;else return VM(r,e,t,o)}updateByOp(r,e,t){let o=r;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props?(t.scene.markNeedsUpdateRendererDirty(),!0):tb(o.props,t.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Gf(o.props,t.shared,this):!0;return!1}dispose(){if(LM(this)){let r=this.uniforms[`f${this.id}_texture`];if(!r)return!1;let e=r;e.image instanceof Nr||e.image.deref()}}hasValueByKey(r){return this.uniforms[r]!==void 0}hasValue(r){return this.hasValueByKey(`f${this.id}_${r}`)}setValue(r,e){let t=`f${this.id}_${r}`;this.hasValueByKey(t)&&e!==void 0&&(this.uniforms[t].value=e)}getNode(r){let e=`f${this.id}_${r}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(r){let e=`f${this.id}_${r}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(r){let t=/f\d+_(.*)/.exec(r);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${r}`)}getNames(){let r=[];for(let e in this.uniforms){let t=this.getName(e);t&&r.push(t)}return r}},pt=class extends Io{constructor(e,t,o,i,a,s,l,c,u){super(e,t,o,i,u);this.params=i;this.color=a;this.mode=s;this.alpha=l;this.isMask=c}},Dl=class extends Io{constructor(e,t,o,i,a,s){super(e,t,o,i,s);this.position=a}},dr=class extends Io{constructor(e,t,o,i,a,s){super(e,t,o,a,s);this.node=i}static createLigherLayer(e,t,o,i){let a,s=new se(Vn(o.alpha,i)),l=new ze(o.mode),c=new se(o.bumpMapIntensity),u=new se(Vn(o.alphaOverride,i)),p;if(!o.visible)a=new tn,p={};else if(o.category==="lambert"){a=new Cl;let d=new Qe(i.color(o.emissive)??0),h=new Tt(o.occlusion??!0);p={emissive:d,occlusion:h},a.emissive=d,a.occlusion=h}else if(o.category==="toon"){a=new Nl;let d=new se(o.shininess??30),h=new Qe(i.color(o.specular)??1118481);p={shininess:d,specular:h},a.shininess=d,a.specular=h}else if(o.category==="physical"){a=new Ml;let d=new se(o.roughness??.3),h=new se(o.metalness??0),f=new se(o.reflectivity??.5),m=new Tt(o.occlusion??!0);p={roughness:d,metalness:h,reflectivity:f,occlusion:m},a.roughness=d,a.metalness=h,a.reflectivity=f,a.occlusion=m}else{a=new Al;let d=new se(o.shininess??30),h=new Qe(o.specular!==void 0?i.color(o.specular)??1118481:1118481),f=new Tt(o.occlusion??!0);p={shininess:d,specular:h,occlusion:f},a.shininess=d,a.specular=h,a.occlusion=f}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=c,a.alphaOverride=u,p.alpha=a.shadingAlpha,p.mode=a.shadingBlend,p.bumpMapIntensity=a.bumpMapIntensity,p.alphaOverride=a.alphaOverride,new dr(e,t,o,a,p,i)}get category(){return this.node.category}};function LM(n){let r=n instanceof Io?n.type:n;return r==="texture"||r==="video"||r==="displace_map"||r==="matcap"}function jr(n){return{alpha:new se(n.alpha??1),mode:new ze(n.mode??0),isMask:new Tt(n.isMask??!1)}}function RM(n,r,e,t,o){switch(n.type){case"color":{let i=new Qe(t.color??Mt),a=jr(t),s=new yi(i,a.alpha),l=new Xe(s.calpha,"f");return new pt(r,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let i=new Qe(t.color??16777215),a=new se(t.bias??.1),s=new se(t.scale??1),l=new se(t.intensity??2),c=new se(t.factor??1),u=jr(t),p=new wl(i,a,s,l,c,u.alpha,u.mode,u.isMask),d=new Xe(p.calpha,"f");return new pt(r,e,n,{color:i,bias:a,scale:s,intensity:l,factor:c,...u},p,u.mode,d,u.isMask,o)}case"rainbow":{let i=new se(t.filmThickness??30),a=new se(t.movement??0),s=new Zt(t.wavelengths??new rt.Vector3(0,0,0)),l=new se(t.noiseStrength??0),c=new se(t.noiseScale??1),u=new Zt(t.offset??new rt.Vector3(0,0,0)),p=jr(t),d=new ls(i,a,s,l,c,u,p.alpha,p.isMask),h=new Xe(d.calpha,"f");return new pt(r,e,n,{filmThickness:i,movement:a,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...p},d,p.mode,h,p.isMask,o)}case"transmission":{let i=new se(t.thickness??10),a=new se(t.ior??1.5),s=new se(t.roughness??.5),l=De.transmissionSize,c=De.transmissionRenderTarget,u=De.transmissionRenderTargetDepth,p=window.innerWidth,d=window.innerHeight,h=p>=d?new xt(d/p,1):new xt(1,p/d),f=jr(t),m=new us(i,a,s,l,c,u,h,f.alpha),y=new Xe(m.calpha,"f");return new pt(r,e,n,{thickness:i,ior:a,roughness:s,aspectRatio:h,...f},m,f.mode,y,f.isMask,o)}case"toon":{let i=new ze(t.positioning??0),a;t.colors?a=new co(t.colors.length,t.colors):(a=new co(10,new rt.Vector4(0,0,0,1)),a.value[1]=new rt.Vector4(1,1,1,1));let s;t.steps?s=new lo(t.steps.length,t.steps):(s=new lo(10,1),s.value[0]=0);let l=new Zt(t.source??new rt.Vector3(0,0,0)),c=new Tt(t.isWorldSpace??!0),u=new se(t.noiseStrength??0),p=new se(t.noiseScale??1),d=new br(t.shadowColor),h=new Zt(t.offset??new rt.Vector3(0,0,0)),f=jr(t),m=new cs(i,a,s,l,c,u,p,d,h,f.alpha),y=new Xe(m.calpha,"f");return new pt(r,e,n,{positioning:i,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:p,shadowColor:d,offset:h,...f},m,f.mode,y,f.isMask,o)}case"outline":{let i=new Qe(t.outlineColor??16777215),a=new Qe(t.contourColor??16777215),s=new se(t.outlineWidth??.1),l=new se(t.contourWidth??.1),c=new se(t.outlineThreshold??.1),u=new se(t.contourThreshold??.1),p=new se(t.outlineSmoothing??.1),d=new se(t.contourFrequency??.1),h=new Zt(t.contourDirection??new rt.Vector3(0,1,0)),f=new Tt(t.positionalLines??!1),m=new Tt(t.compensation??!0),y=De.normalRenderTarget,g=De.normalRenderTargetDepth,v=De.pixelRatioNode,O=De.resolution,P=jr(t),S=new as(i,a,s,l,c,u,p,d,h,f,m,O,y,g,v,P.alpha),T=new Xe(S.calpha,"f");return new pt(r,e,n,{outlineColor:i,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:p,contourFrequency:d,contourDirection:h,positionalLines:f,compensation:m,...P},S,P.mode,T,P.isMask,o)}case"depth":{let i=new ze(t.gradientType??0),a=new Tt(t.smooth??!1),s=new se(t.near??50),l=new se(t.far??200),c=new se(t.isVector??1),u=new se(t.isWorldSpace??0),p=new Zt(t.origin??new rt.Vector3),d=new Zt(t.direction??new rt.Vector3),h;t.colors?h=new co(t.colors.length,t.colors):(h=new co(2,new rt.Vector4(0,0,0,1)),h.value[1]=new rt.Vector4(1,1,1,1));let f;t.steps?f=new lo(t.steps.length,t.steps):(f=new lo(2,1),f.value[0]=0);let m=jr(t),y=new rs(i,a,s,l,c,u,p,d,h,f,m.alpha,m.isMask),g=new Xe(y.calpha,"f");return new pt(r,e,n,{gradientType:i,smooth:a,near:s,far:l,isVector:c,isWorldSpace:u,origin:p,direction:d,colors:h,steps:f,...m},y,m.mode,g,m.isMask,o)}case"noise":{let i=new se(t.scale??1),a=new Zt(t.size??new rt.Vector3(100,100,100)),s=new se(t.move??1),l=new xt(t.fA??new rt.Vector2(1.7,9.2)),c=new xt(t.fB??new rt.Vector2(8.3,2.8)),u=new xt(t.distortion??new rt.Vector2(1,1)),p=new br(t.colorA),d=new br(t.colorB),h=new br(t.colorC),f=new br(t.colorD),m=new ze(t.noiseType??0),y=new ze(t.voronoiStyle??0),g=new se(t.highCut??1),v=new se(t.lowCut??0),O=new se(t.smoothness??.5),P=new se(t.seed??.5),S=new ze(t.quality??1),T=jr(t),I=new is(i,a,s,l,c,u,p,d,h,f,T.alpha,m,T.isMask,y,g,v,O,P,S),x=new Xe(I.calpha,"f");return new pt(r,e,n,{scale:i,size:a,move:s,fA:l,fB:c,distortion:u,colorA:p,colorB:d,colorC:h,colorD:f,noiseType:m,...T,voronoiStyle:y,highCut:g,lowCut:v,smoothness:O,seed:P,quality:S},I,T.mode,x,T.isMask,o)}case"normal":{let i=new Zt(t.cnormal??new rt.Vector3(1,1,1)),a=jr(t),s=new Ja(i,a.alpha),l=new Xe(s.calpha,"f");return new pt(r,e,n,{cnormal:i,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let i=new ze(t.gradientType??0),a=new Tt(t.smooth??!1),s;t.colors?s=new co(t.colors.length,t.colors):(s=new co(10,new rt.Vector4(0,0,0,1)),s.value[1]=new rt.Vector4(1,1,1,1));let l;t.steps?l=new lo(t.steps.length,t.steps):(l=new lo(10,1),l.value[0]=0);let c=new xt(t.offset??new rt.Vector2(0,0)),u=new xt(t.morph??new rt.Vector2(0,0)),p=new se(t.angle??0),d=jr(t),h=new os(i,a,s,l,c,u,p,d.alpha,d.isMask),f=new Xe(h.calpha,"f");return new pt(r,e,n,{gradientType:i,smooth:a,colors:s,steps:l,offset:c,morph:u,angle:p,...d},h,d.mode,f,d.isMask,o)}case"pattern":{let i=new ze(t.style??0),a=new ze(t.projection??0),s=new ze(["x","y","z"].indexOf(t.axis)??0),l=new se(t.blending??0),c=new xt(t.offset??new rt.Vector2(0,0)),u=new br(t.colorA),p=new br(t.colorB),d=new xt(t.frequency??new rt.Vector2(10,10)),h=new se(t.size??.5),f=new se(t.variation??0),m=new se(t.smoothness??.5),y=new se(t.zigzag??0),g=new se(t.rotation??0),v=new xt(t.vertical??new rt.Vector2(0,1)),O=new xt(t.horizontal??new rt.Vector2(0,1)),P=new ze(t.sides??6),S=jr(t),T=new ss(i,a,s,l,c,u,p,d,h,f,m,y,g,v,O,P,S.alpha,S.isMask),I=new Xe(T.calpha,"f");return new pt(r,e,n,{style:i,projection:a,axis:s,blending:l,offset:c,colorA:u,colorB:p,frequency:d,size:h,variation:f,smoothness:m,zigzag:y,rotation:g,vertical:v,horizontal:O,sides:P,...S},T,S.mode,I,S.isMask,o)}default:{let i=new Qe(1,0,0,1),a=jr(t),s=new yi(i,a.alpha),l=new Xe(s.calpha,"f");return new pt(r,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}}}function VM(n,r,e,t){let o=eb(e,t);return RM(e,n,r,o,t)}function jf(n,r,e,t){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let o=r.uniforms[`f${r.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=r.uniforms[`f${r.id}_alpha`];if(!o)return;if(o.value=Vn(e.alpha,t)*(e.visible?1:0),e.type==="outline"&&n==="visible"){let i=r.uniforms[`f${r.id}_compensation`];i&&(i.value=e.compensation&&e.visible)}return o}}function $u(n,r){let e=0,t=n.layers.find(o=>o.data.type==="light");if(t){let o=t.data,i=Number(r.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(r.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=r.color(o.data.colorA).a,s=r.color(o.data.colorB).a,l=r.color(o.data.colorC).a,c=r.color(o.data.colorD).a,u=Math.min(a,Math.min(s,Math.min(l,c)));u<1&&(i=u)}e+=(1-e)*i}}return e<1}var Sr=class extends rb.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}},Yu=class extends Sr{constructor(e,t,o,i){super();this.flatShading=e;this.side=t;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,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,o){return this.root.getFlavor(e,t,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,t,o){this.root.updateByOp(e,t,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},xi=class extends Sr{constructor(e,t,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.reset0(e,t)}get nodeMaterial(){return this}getFlavor(e,t,o){let i=o?6:(e?3:0)+t;if(i===0)return this;this.flavors===void 0&&(this.flavors=[]),i-=1;let a=this.flavors[i];return a===void 0&&(a=new Yu(e,t,o,this),this.flavors[i]=a,a.flatShading=e,a.side=t,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,t,o=!1){(this.data!==e||o)&&this.reset0(e,t)}reset0(e,t){this.data=e;let o=e.layers??Qt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(i=>Io.create(this.layerIdGen++,i.id,i.data,t.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(t.shared),this.transparent=$u(e,t.shared),this.saveVariableLocations(t)}onVariableUpdate(e,t,o){if(e[0]==="alphaOverride")this.transparent=$u(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/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=$u(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(t)/100,1)))):s.setValue(a,t))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers.find(o=>o.data.type==="light");t&&e.shared.getVariable(t.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(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(e){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(t=>t instanceof dr),this.lightLayer===void 0&&(this.lightLayer=new dr(0,"",{...Et.defaultData("light","phong"),visible:!1},new tn,{},e)),this.dispose();for(let t of this.flavors)t&&t.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(a=>a instanceof dr);if(!e)return;let t=e.data,o=t.bumpMap,i=t.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 pt&&s.color instanceof Ln&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===i&&(e.node.roughnessMap=s.color))}}updateByOp(e,t,o){if(t!==void 0?this.data=t:t=this.data,this.transparent=$u(t,o.shared),e.path[0]==="layers"){this.data=t;let i=o.shared,a=e.path[1];if(a===void 0){if(this.layers.reverse(),e.type===4){let s=Io.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(c=>c.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=t.layers.data(a),c;if(e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?c={...e.props,alpha:Vn(e.props.alpha,i,["material",this.uuid,"layer",a,"alpha"])}:c={...e.props,alphaOverride:Vn(e.props.alphaOverride,i,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...c?{props:c}:{},path:e.path.slice(2)},l,o)){let p=Io.create(this.layerIdGen++,a,l,i);this.layers.splice(this.layers.findIndex(d=>d.uuid===a),1,p),this.onUpdate(o.shared)}}}}else this.reset(t,o)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof pt?t.color.mask=void 0:t instanceof dr&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof pt&&t.isMask.value&&t.data.visible&&e>0){let o=e-1,i=this.layers[o];i instanceof dr?i.node.mask=new $t(t.color,t.alpha,$t.MUL):i instanceof pt&&(i.isMask.value||(i.color.mask=new $t(t.color,t.alpha,$t.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof pt),t=this.layers.findIndex(o=>o instanceof dr);if(e!==-1&&e<t){let o=this.layers[e].color;for(let i=e+1;i<t;++i){let a=this.layers[i];if(a instanceof pt){if(a.isMask.value)continue;o=new Za(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Xe("outgoingLight","f"),t=this.layers.findIndex(o=>o instanceof dr);if(this.layers.length>t+1){for(let o=t+1;o<this.layers.length;++o){let i=this.layers[o];if(i instanceof pt){if(i.isMask.value)continue;e=new Za(e,i.color,i.alpha,i.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof Dl);if(e.length>0){let t=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(t=new $t(t,e[o].position,$t.ADD),t=new $t(t,new se(.5).setReadonly(!0),$t.MUL));this.fragment.position=t}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,t){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,t);i.uniforms[`f${i.id}_intensity`].value=a}}computeCacheKey(){let e="[";for(let{data:t}of this.data.layers)if(t.type==="light")e+=`"${t.visible?t.category.toUpperCase():"Basic"}"`;else{let o=(Vf[t.type]??[]).map(c=>t[c]),i=(zf[t.type]??[]).map(c=>t[c]?.length??0),a=[...o,...i],s="isMask"in t&&t.isMask,l=`"${t.type}-${t.visible}-${s}"`;a.length?e+=`[${l}, "${a.join('","')}"],`:e+=l}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}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 t of this.flavors)t&&t.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 pt){let t=e.params.texture;if(t instanceof mi&&!t.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(Sr.prototype,{properties:{get:function(){return this.fragment.properties}}});var bi=class extends xi{constructor(r,e,t){super(r,e,!1),this.uuid=t,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var ob=new Map;function nb(n){if(typeof n=="string")return n;let r=ob.get(n);return r||(r={url:URL.createObjectURL(new Blob([n]))},ob.set(n,r)),r.url}var zM,ib=new Promise(n=>{zM=n});var ab;ib.then(n=>ab=n);var vi=class{constructor({src:r,volume:e,delay:t,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 r=="string"?i={src:r}:i={src:nb(r),format:"wav"},this.sound=new ab.Howl(i),this.sound.on("end",this.onEnd),this.src=r,e!==void 0&&(this.volume=e),t!==void 0&&(this.delay=t),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(r){this._volume=r,this.sound.volume(r)}get loop(){return this._loop}set loop(r){this._loop=r,this.loopsRemaining=r}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(r,e=1e3){r?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},r)):this.sound.fade(this._volume,0,e)}on(r,e,t){this.sound.on(r,e,t)}off(r,e,t){this.sound.off(r,e,t)}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(r=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var Ft=require("three"),Xu=class{constructor(){this.type="ShapePath";this.color=new Ft.Color;this.subPaths=[];this.currentPath=null}moveTo(r,e){return this.currentPath=new Ft.Path,this.subPaths.push(this.currentPath),this.currentPath.moveTo(r,e),this}lineTo(r,e){return this.currentPath?.lineTo(r,e),this}quadraticCurveTo(r,e,t,o){return this.currentPath?.quadraticCurveTo(r,e,t,o),this}bezierCurveTo(r,e,t,o,i,a){return this.currentPath?.bezierCurveTo(r,e,t,o,i,a),this}splineThru(r){return this.currentPath?.splineThru(r),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function o(m,y,g,v){let O=m.x,P=y.x,S=g.x,T=v.x,I=m.y,x=y.y,_=g.y,D=v.y,A=(T-S)*(I-_)-(D-_)*(O-S),N=(P-O)*(I-_)-(x-I)*(O-S),E=(D-_)*(P-O)-(T-S)*(x-I),B=A/E,V=N/E;if(E===0&&A!==0||B<=0||B>=1||V<0||V>1)return null;if(A===0&&E===0){for(let j=0;j<2;j++)if(i(j===0?g:v,m,y),t.loc===e.ORIGIN){let R=j===0?g:v;return{x:R.x,y:R.y,t:t.t}}else if(t.loc===e.BETWEEN){let R=+(O+t.t*(P-O)).toPrecision(10),W=+(I+t.t*(x-I)).toPrecision(10);return{x:R,y:W,t:t.t}}return null}else{for(let W=0;W<2;W++)if(i(W===0?g:v,m,y),t.loc===e.ORIGIN){let F=W===0?g:v;return{x:F.x,y:F.y,t:t.t}}let j=+(O+B*(P-O)).toPrecision(10),R=+(I+B*(x-I)).toPrecision(10);return{x:j,y:R,t:B}}}function i(m,y,g){let v=g.x-y.x,O=g.y-y.y,P=m.x-y.x,S=m.y-y.y,T=v*S-P*O;if(m.x===y.x&&m.y===y.y){t.loc=e.ORIGIN,t.t=0;return}if(m.x===g.x&&m.y===g.y){t.loc=e.DESTINATION,t.t=1;return}if(T<-Number.EPSILON){t.loc=e.LEFT;return}if(T>Number.EPSILON){t.loc=e.RIGHT;return}if(v*P<0||O*S<0){t.loc=e.BEHIND;return}if(Math.sqrt(v*v+O*O)<Math.sqrt(P*P+S*S)){t.loc=e.BEYOND;return}let I;v!==0?I=P/v:I=S/O,t.loc=e.BETWEEN,t.t=I}function a(m,y){let g=[],v=[];for(let O=1;O<m.length;O++){let P=m[O-1],S=m[O];for(let T=1;T<y.length;T++){let I=y[T-1],x=y[T],_=o(P,S,I,x);_!==null&&g.find(D=>D.t<=_.t+Number.EPSILON&&D.t>=_.t-Number.EPSILON)===void 0&&(g.push(_),v.push(new Ft.Vector2(_.x,_.y)))}}return v}function s(m,y,g){let v=new Ft.Vector2;y.getCenter(v);let O=[];return g.forEach(P=>{P.boundingBox.containsPoint(v)&&a(m,P.points).forEach(T=>{O.push({identifier:P.identifier,isCW:P.isCW,point:T})})}),O.sort((P,S)=>P.point.x-S.point.x),O}function l(m,y,g,v,O){(O==null||O==="")&&(O="nonzero");let P=new Ft.Vector2;m.boundingBox.getCenter(P);let S=[new Ft.Vector2(g,P.y),new Ft.Vector2(v,P.y)],T=s(S,m.boundingBox,y);T.sort((N,E)=>N.point.x-E.point.x);let I=[],x=[];T.forEach(N=>{N.identifier===m.identifier?I.push(N):x.push(N)});let _=I[0].point.x,D=[],A=0;for(;A<x.length&&x[A].point.x<_;)D.length>0&&D[D.length-1]===x[A].identifier?D.pop():D.push(x[A].identifier),A++;if(D.push(m.identifier),O==="evenodd"){let N=D.length%2===0,E=D[D.length-2];return{identifier:m.identifier,isHole:N,for:E}}else if(O==="nonzero"){let N=!0,E=null,B=null;for(let V=0;V<D.length;V++){let j=D[V];y[j]&&(N?(B=y[j].isCW,N=!1,E=j):B!==y[j].isCW&&(B=y[j].isCW,N=!0))}return{identifier:m.identifier,isHole:N,for:E}}else console.warn('fill-rule: "'+O+'" is currently not implemented.')}let c=0,u=999999999,p=-999999999,d=[];this.subPaths.forEach(m=>{let y=m.getPoints(),g=-999999999,v=999999999,O=-999999999,P=999999999;for(let S=0;S<y.length;S++){let T=y[S];T.y>g&&(g=T.y),T.y<v&&(v=T.y),T.x>O&&(O=T.x),T.x<P&&(P=T.x)}p<=O&&(p=O+1),u>=P&&(u=P-1),y.length&&d.push({curves:m.curves,points:y,isCW:Ft.ShapeUtils.isClockWise(y),identifier:c++,boundingBox:new Ft.Box2(new Ft.Vector2(P,v),new Ft.Vector2(O,g))})});let h=d.map(m=>l(m,d,u,p,this.userData?.style.fillRule)),f=[];return d.forEach(m=>{let y=h[m.identifier];if(y&&!y.isHole){let g=new Ft.Shape;g.curves=m.curves,h.filter(O=>O?.isHole&&O.for===m.identifier).forEach(O=>{if(O){let P=d[O.identifier],S=new Ft.Path;S.curves=P.curves,g.holes.push(S)}}),f.push(g)}}),f}};var Ff=!1,lb,Uf=new Promise(n=>{lb=n}),sb=!1;var Ku;function cb(){if(Ff=!0,sb)return;if(Ku)return Ku;async function n(){let e=await import("./opentype.js");lb(e),sb=!0}return Ku=n(),Ku}var El=class{async load(r,e,t=()=>{}){let{load:o}=await Uf;o(r,(i,a)=>{i||!a?t(i??"Something went wrong"):e(a)})}async parse(r){let{parse:e,Bidi:t}=await Uf;try{let o=e(r),i=new t,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 GM(n){return await(await fetch(n)).arrayBuffer()}var jM=new El;async function kf(n){let r,e,t=!1;if(n.url?(r=await GM(n.url),e=n.url,t=n.url.startsWith("/")):n.data&&(r=n.data.buffer.slice(n.data.byteOffset,n.data.byteOffset+n.data.byteLength)),r)if(Ff){let o=await jM.parse(r);if(o)return{font:o.font,url:e,intercepted:t,arr:r,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:t,arr:r,bidi:null}}var ms=require("three");function FM(n,r){return r.state.glyphIndex===n||r.state.fina===n||r.state.medi===n||r.state.init===n}var Qu=class{constructor(r){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=r.isUserFont??!1,this._loadingPromise=kf(r).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(r){this._isLoaded=!1,this._isUserFont=r.isUserFont??!1,this._loadingPromise=kf(r).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(r,e,t){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let i=o.tokenizer.tokens,a=[],s=0,l=t.length===i.length;for(let c=0;c<t.length;c++){let u=t[c].index,p=String.fromCharCode(t[c].unicode),d=i[s];if(FM(u,d)||l)a.push({char:p,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),s++;else{let h=d.char,f="",m=[d.state.glyphIndex],y=[],g=!1;for(;!g;)s++,f=e.charAt(s),h+=f,m.push(r.charToGlyphIndex(f)),y=r.stringToGlyphs(h),y.length===1&&y[0].index===u&&(g=!0),s>e.length&&(g=!0);a.push({char:p,index:u,replacements:m,replacementChars:Array.from(h)}),s++}}return a}generateShapes(r,e){if(!this._isLoaded)return;let t=this.font,o=e.fontSize/this.unitsPerEm,i=e.fontSize*e.lineHeight,a=r.map(v=>this.getTextWidth(v,e)),s=e.width,l=this.getCharWidth(`
|
|
2226
|
+
`,e),c=e.horizontalAlign===1?l:0,u=this.computeSpaceWidthForLine(r,0,e),p=this.getLineInitialOffsetX(a[0],s,e.horizontalAlign,r[0],l),d=this.getLineInitialOffsetY(i,r.length,e.height,o,e.verticalAlign),h=[],f=r.map(v=>[]),m=r.map(v=>[]),y;for(let v=0;v<r.length;v++){let O=r[v],P={features:{liga:!0}},S=[];try{S=t.stringToGlyphs(O,P)}catch(I){console.warn(I)}p=this.getLineInitialOffsetX(a[v],s,e.horizontalAlign,O,l);let T=[];try{T=this.reverseLigaturesTable(t,O,S)}catch(I){console.warn(I)}u=this.computeSpaceWidthForLine(r,v,e);for(let I=0;I<S.length;I++){let x=S[I],_=x.index===0?`
|
|
2227
|
+
`:x.unicode?String.fromCharCode(x.unicode):void 0,D=T[I],A=0,N=0;I===0&&e.horizontalAlign===2&&x.leftSideBearing!==void 0&&(N=-x.leftSideBearing*o),y&&(A=t.getKerningValue(x,y)*o),p+=N+A;let E=0;if(_===`
|
|
2228
|
+
`)E=c;else if(_===" ")E=u;else{let B=this.createPath(x,o,p,d,e);B&&(E=B.offsetX-(A+N),h.push(B.path))}if(D.replacements.length===1)m[v].push([p,d]),f[v].push(E);else{let B=D.replacements.map(W=>(t.glyphs.get(W).advanceWidth??0)*o),V=B.reduce((W,F)=>W+=F,0),j=B.map(W=>W/V),R=p;for(let W=0;W<j.length;W++){let F=E*j[W];m[v].push([R,d]),f[v].push(F),R+=F}}p+=E,y=x}d-=i}let g=[];for(let v=0,O=h.length;v<O;v++)g.push(...h[v].toShapes());return{shapes:g,charWidths:f,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(r,e,t,o,i){return(t===3||t===2)&&o.indexOf(`
|
|
2229
|
+
`)>=0&&(r-=i),t===3?e*.5-r*.5:t===2?e-r:0}getLineInitialOffsetY(r,e,t,o,i){let a=e*r,s=Math.abs(this.ascender-this.descender)*o,l=r-s,c=-this.ascender*o-l/2;return i===3?-(t-a-c):i===2?-(t*.5-a*.5-c):c}createPath(r,e,t,o,i){let a=r.getPath(t,-o,i.fontSize,{kerning:!1,letterSpacing:i.letterSpacing});if(!a){console.error('THREE.Font: character "'+r+'" does not exists in font family '+this.familyName+".");return}let s=new Xu,l=(r.advanceWidth??1)*e;if(r)for(let c of a.commands){let u=s.currentPath?.currentPoint;if(!(u&&c.type!=="Z"&&u.x===c.x&&-u.y===c.y))switch(c.type){case"M":s.moveTo(c.x,-c.y);break;case"L":s.lineTo(c.x,-c.y);break;case"Q":s.quadraticCurveTo(c.x1,-c.y1,c.x,-c.y);break;case"C":s.bezierCurveTo(c.x1,-c.y1,c.x2,-c.y2,c.x,-c.y);break}}return s.subPaths.forEach(c=>{let u=UM(c.curves);u!==void 0&&c.currentPoint.distanceTo(u)>0&&c.lineTo(u.x,u.y)}),{offsetX:l+i.fontSize*i.letterSpacing,path:s}}getCharWidth(r,e){return this.font?.getAdvanceWidth(r,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(r,e){return this.font?.getAdvanceWidth(r,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(r,e,t){let o=this.getCharWidth(" ",t),i=r[e];if(i){let a=this.countSpaces(i.trimEnd());if(t.horizontalAlign===4&&e<r.length-1&&a){let s=t.width,l=this.getTextWidth(i,t);return(s-(l-a*o))/a}}return o}countSpaces(r){return(r.match(/ /g)||[]).length}};function UM(n){if(n.length){let r=n[0];if(r instanceof ms.LineCurve)return r.v1;if(r instanceof ms.CubicBezierCurve||r instanceof ms.QuadraticBezierCurve)return r.v0}}var Hf=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(r){return this.objects.get(r)}get size(){return this.objects.size}get(r,e,t){let o=this.objects.get(r);return o===void 0?(o=this.createObject(r,e,t),this.objects.set(r,o)):o.isShared=!0,o}forceDelete(r){let e=this.objects.get(r);e&&(this.disposeObject(e),this.objects.delete(r))}mutateIfUnique(r,e){let t=this.objects.get(r);if(t&&t.isShared!==!0)return this.objects.delete(r),this.objects.set(e,t),t}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(r,e){let t=this.objects.get(r);e===t?this.unreachable.delete(r):!1&&console.warn("Reachable but deleted",r)}endGc(){this.unreachable.forEach(r=>{this.disposeObject(this.objects.get(r)),this.objects.delete(r)}),this.unreachable.clear()}dispose(){this.objects.forEach(r=>{this.disposeObject(r)}),this.objects.clear()}},_l=class extends Hf{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t,o){let i=en(e,t,this.flatShading,o);return i.computeBoundingSphere(),i}};var ub={markNeedsUpdateRendererDirty:()=>{}};var Wf=require("three"),qf=class extends Wu{constructor(e){super();this.shared=e}create(e){return new fs(e,this.shared)}},Si=class{constructor(r,e={}){this.data=r;this.geometryCache=new _l(!0);this.geometryCache2=new _l(!1);this.imageHolderCache=new qf(this);this.thisContext={scene:ub,shared:this};this.deletedMaterial=new bi(Qt.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new Nr(ba.emptyImage,this);this.deletedVideo=new Nr(da.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[t,o]of Object.entries(e.images))this.addImage(t,o);if(e.videos)for(let[t,o]of Object.entries(e.videos))this.addVideo(t,o);if(e.audios)for(let[t,o]of Object.entries(e.audios))this.addAudio(t,o);if(e.particles)for(let[t,o]of Object.entries(e.particles))this.addParticle(t,o);this.reset(r)}setRequestRender(r){this._requestRender=r}setEntityOpContext(r){this.entityOpContext=r}reset(r,e=!1){this.resetLib(r.lib);for(let{id:t,data:o}of r.variables)this.addVariableHolder(t,o),e&&this.updateVariableHolder(t,o);for(let[t,o]of Object.entries(r.images))this.addImage(t,o);for(let[t,o]of Object.entries(r.videos))this.addVideo(t,o);for(let[t,o]of Object.entries(r.colors))this.addColor(t,o);for(let[t,o]of Object.entries(r.materials))this.addMaterial(t,o);for(let[t,o]of Object.entries(r.audios))this.addAudio(t,o);for(let[t,o]of Object.entries(r.particles))this.addParticle(t,o);for(let[t,o]of Object.entries(r.fonts))this.addFont(t,o)}addMaterial(r,e){if(this.materials[r]){let t=this.materials[r];t.reset(e,this.thisContext),t.dispose()}else{let t=new bi(e,this.thisContext,r);this.materials[r]=t}}deleteMaterial(r){this.materials[r]&&(this.materials[r].nodeMaterialDispose(),delete this.materials[r])}getMaterial(r){let e=this.materials[r];return e}getMaterialOrDeletedPlaceholder(r){return this.materials[r]??this.deletedMaterial}material(r){return typeof r=="string"?this.getMaterialOrDeletedPlaceholder(r):r==null?(console.error("material is undefined or null"),this.deletedMaterial):new xi(r,this.thisContext)}getMaterials(){return this.materials}addImage(r,e){return this.images[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[r].updateSrc(e.data),!0):(this.images[r]=new Nr(e,this),!1)}deleteImage(r){let e=this.images[r];e&&(e.dispose(),delete this.images[r])}getDefaultImage(){return this.images.image_0}getImage(r){return this.images[r]??this.deletedImage}image(r){return typeof r=="string"?this.getImage(r):this.imageHolderCache.load(r)}addCanvas(r,e){return this.canvases[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.canvases[r].updateSrc(e),!0):(this.canvases[r]=new Nr(e,this),!1)}canvas(r){return this.canvases[r]}addVideo(r,e){return this.videos[r]?(this.videos[r].updateSrc(e.data),!0):(this.videos[r]=new Nr(e,this),!1)}deleteVideo(r){let e=this.videos[r];e&&(e.dispose(),delete this.videos[r])}getVideo(r){return this.videos[r]??this.deletedVideo}video(r){return typeof r=="string"?this.getVideo(r):this.imageHolderCache.load(r)}addColor(r,e){return this.colors[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[r].setRGBA(e.r,e.g,e.b,e.a):this.colors[r].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[r]=new Rn(e.r,e.g,e.b,e.a):this.colors[r]=new Rn(e.r,e.g,e.b,1),!1)}updateColor(r,e){if(this.colors[r]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let t=this.colors[r];return this.colors[r].r=e.r??t.r,this.colors[r].g=e.g??t.g,this.colors[r].b=e.b??t.b,this.colors[r].a=e.a??t.a,!0}return!1}deleteColor(r){this.colors[r]&&delete this.colors[r]}getColor(r){return this.colors[r]}color(r){let e;if(typeof r=="string"){let t=this.getColor(r);t?e=t:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new jt(0,0,0,0))}else return"a"in r?new jt(r.r,r.g,r.b,r.a):new jt(r.r,r.g,r.b,1);return e}addAudio(r,e){this.audios[r]=e}getAudio(r){let e=this.audios[r];if(e instanceof vi)return e;{let t=new vi({src:e.data});return this.audios[r]=t,t}}addParticle(r,e){this.particles[r]=e}getParticle(r){return this.particles[r]}deleteParticle(r){this.particles[r]&&delete this.particles[r]}deleteAudio(r){let e=this.audios[r];e&&(e instanceof vi&&e.dispose(),delete this.audios[r])}addFont(r,e){this.fonts[r]=new Qu(e),this.fonts[r].loadingPromise.then(()=>this.requestRender())}getFont(r){return this.fonts[r]}deleteFont(r){this.fonts[r]&&delete this.fonts[r]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof vi&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(r,e){return this.variables[r]===void 0?(this.variables[r]={value:e.value,locations:[]},"dynamicVariableType"in e&&(this.variables[r].dynamicVariablePlayState="Playing",this.variables[r].dynamicVariableToggleIsForward=void 0),!0):(this.variables[r].value=e.value,!1)}resetDynamicVariablePlayState(){for(let r in this.variables)this.variables[r].dynamicVariablePlayState!==void 0&&(this.variables[r].dynamicVariablePlayState="Playing",this.variables[r].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(r,e){this.updateVariable(r,e.value)}updateVariable(r,e){if(this.variables[r]===void 0)return!1;this.variables[r].value=e;let t=e;for(;typeof t=="string";)t=this.variables[t].value;let o=this.entityOpContext.scene;for(let i=this.variables[r].locations.length-1;i>=0;i--){let a=this.variables[r].locations[i];if(a[0]==="material"){let s=a[1],l=t,c={scene:o,shared:this},u=a.slice(2);o.traverseMaterial(d=>{let h=d.root??d;h.uuid===s&&h.onVariableUpdate(u,l,c)});let p=this.materials[s];p&&p.onVariableUpdate(u,l,c)}else{let s=o.find(a[0]);if(s===void 0){this.variables[r].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]]=t*Wf.MathUtils.DEG2RAD:s[a[a.length-1]]=t}if(s=o.find(a[0]),s.type==="ParticleEmitter"&&s.updateVariableState(t,a),je.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 c=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(c.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.instances.forEach(u=>{let p=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(p.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0)})}}}}return this.requestRender(),!0}deleteVariable(r){this.variables[r]&&delete this.variables[r]}getVariable(r,e){if(Array.isArray(r)){if(r[0]==="mouse")return this.mouseProperty?.[r[1]]??0;if(r[0]==="raycast")return this.raycastProperty?.[r[1]]??0;let t=this.entityOpContext.scene.find(r[0]);if(r[1]==="width"||r[1]==="height"||r[1]==="depth")return t.geometry.userData.parameters[r[1]];for(let o=1;o<r.length;o++)t=t[r[o]];return r[1]==="rotation"&&(t*=Wf.MathUtils.RAD2DEG),t}for(let t in this.variables){if(e===void 0)break;let o=this.variables[t],i=o.locations?.findIndex(a=>mt.equal(a,e));i!==void 0&&i!==-1&&o.locations.splice(i,1)}if(typeof r=="string"){let t=r,o=r;do{if(o=t,this.variables[t]===void 0)break;t=this.variables[t].value}while(typeof t=="string");return e&&this.variables[o]!==void 0&&this.variables[o].locations.push(e),t}else return r}getVariables(){return this.variables}getDynamicVariablePlayState(r){return this.variables[r]?.dynamicVariablePlayState}setDynamicVariablePlayState(r,e){this.variables[r]!==void 0&&(this.variables[r].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(r){return this.variables[r]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(r,e){this.variables[r]!==void 0&&(this.variables[r].dynamicVariableToggleIsForward=e)}resetLib(r){for(let[e,t]of Object.entries(r.images))this.addImage(e,t.asset);for(let[e,t]of Object.entries(r.audios))this.addAudio(e,t.asset);for(let[e,t]of Object.entries(r.particles))this.addParticle(e,t.asset);for(let[e,t]of Object.entries(r.colors))this.addColor(e,t.asset);for(let[e,t]of Object.entries(r.fonts))this.addFont(e,t.asset);for(let[e,t]of Object.entries(r.materials))this.addMaterial(e,t.asset);for(let[e,t]of Object.entries(r.videos))this.addVideo(e,t.asset);for(let[e,t]of Object.entries(r.variables))this.addVariableHolder(e,t.asset)}updateLibByOp(r,e){r.path[0]==="images"?r.path.length===1&&r.type===1?this.addImage(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteImage(r.id):r.path[0]==="videos"?r.path.length===1&&r.type===1?this.addVideo(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteVideo(r.id):r.path[0]==="audios"?r.path.length===1&&r.type===1?this.addAudio(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteAudio(r.id):r.path[0]==="particles"?r.path.length===1&&r.type===1?this.addParticle(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteParticle(r.id):r.path[0]==="colors"?r.path.length===1&&r.type===1?this.addColor(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteColor(r.id):r.path[0]==="materials"?r.path.length===1&&r.type===1?this.addMaterial(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteMaterial(r.id):r.path[0]==="fonts"?r.path.length===1&&r.type===1?this.addFont(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteFont(r.id):r.path[0]==="variables"?r.path.length===1&&r.type===1?this.addVariableHolder(r.id,r.data.asset):r.path.length===1&&r.type===2&&this.deleteVariable(r.id):r.path[0]==="components"&&e.updateByLibOp(r,this)}updateByOp(r,e,t){this.data=e,r.path[0]==="images"?r.path.length===2&&r.type===0?r.props.data&&this.getImage(r.path[1]).updateSrc(r.props.data):r.path.length===1&&r.type===1?this.addImage(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteImage(r.id):r.path[0]==="videos"?r.path.length===2&&r.type===0?r.props.data&&this.getVideo(r.path[1]).updateSrc(r.props.data):r.path.length===1&&r.type===1?this.addVideo(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteVideo(r.id):r.path[0]==="audios"?r.path.length===2&&r.type===0?r.props.data&&this.addAudio(r.path[1],e.audios[r.path[1]]):r.path.length===1&&r.type===1?this.addAudio(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteAudio(r.id):r.path[0]==="particles"?r.path.length===2&&r.type===0?r.props.data&&this.addParticle(r.path[1],e.particles[r.path[1]]):r.path.length===1&&r.type===1?this.addParticle(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteParticle(r.id):r.path[0]==="colors"?r.path.length===2&&r.type===0?this.updateColor(r.path[1],r.props):r.path.length===1&&r.type===1?this.addColor(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteColor(r.id):r.path[0]==="materials"?r.path.length===1&&r.type===1?this.addMaterial(r.id,r.data):r.path.length===1&&r.type===2?this.deleteMaterial(r.id):r.path.length>1&&this.getMaterial(r.path[1]).updateByOp(yt.drop(r,2),e.materials[r.path[1]],{shared:this,scene:t}):r.path[0]==="fonts"?r.path.length===2&&r.type===0?this.updateFont(r.path[1],r,t):r.path.length===1&&r.type===1?this.addFont(r.id,r.data):r.path.length===1&&r.type===2&&this.deleteFont(r.id):r.path[0]==="variables"?r.path.length===2&&r.type===0&&"value"in r.props?this.updateVariable(r.path[1],r.props.value):r.path.length===1&&r.type===4?this.addVariableHolder(r.id,r.data):r.path.length===1&&r.type===5&&this.deleteVariable(r.id):r.path[0]==="lib"&&this.updateLibByOp(yt.drop(r,1),t)}updateFont(r,e,t){if(e.props.url){let o=this.getFont(r),i={...this.data.fonts[r],url:e.props.url};o.update(i),o.loadingPromise.then(()=>this.requestRender()),t.updateFont(r,this)}}},db=new Si(zr.emptyData());var wr=class extends zt{updateByPatchedOp(e,t,o){if(super.updateByPatchedOp(e,t,o),ng(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(Ge(e.path,["material"])&&this.material instanceof Sr)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(yt.drop(e,1),t.material,o);else if(Ge(e.path,["materials","*"])&&Array.isArray(this.material)){let i=e.path[1];if("materials"in t&&i<this.material.length){let a=t.materials[i];typeof a!="string"&&this.material[i].updateByOp(yt.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,t){super.updateState(e,t),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=t.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe),t.scene.markNeedsUpdateRendererDirty()),(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(i=>t.shared.material(i).getFlavor(o.flatShading,o.side,o.wireframe)),t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[t.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe)],t.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&&rc(this.material).forEach(e=>{e instanceof Sr&&(e instanceof bi||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var Dr=require("three");var pb=new Dr.Vector3,fb=new Dr.Vector4,hb=new Dr.Vector4,HM=new Dr.Vector3,mb=new Dr.Matrix4,bt=class extends wr{constructor(e,t,o){super(e,t);this.data=t;this.isSkinnedMesh=!1;this.localGeometry=void 0,t.bindMode&&t.bindMatrix&&(this.bindMode=t.bindMode,this.bindMatrix=new Dr.Matrix4().fromArray(t.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 Si){let e=this.geometryCreateDeleyed,t=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=t.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return Zs.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return Zs.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),Ge(e.path,["geometry"])&&this.updateByPatchedOpGeometry(yt.drop(e,1),t.geometry,o)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,t){this.invalidateDownstreamBooleanData();let o=this.data.geometry.type;if(o==="NonParametricGeometry"||o==="SubdivGeometry"){let i=e;if(this.localGeometry===void 0){let u={...this.data.geometry,...i};this.localGeometry=en(u,t,this.data.flatShading,this)}let a,s,l;i.scaleBaked?[a,s,l]=i.scaleBaked:{width:a,height:s,depth:l}=i;let c=this.localGeometry.userData;c.sxPrev!==void 0&&yl(this.localGeometry.attributes,a/c.sxPrev,s/c.syPrev,l/c.szPrev),c.sxPrev=a,c.syPrev=s,c.szPrev=l}else{let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=en(i,t,this.data.flatShading,this)}}refreshAttachedCloners(e){for(let t of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(t.object)}refreshAttachedPaths(e){for(let t of this.attachedPaths)e.scene.addPendingCommand(()=>t.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,t,o){let i=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof It&&this.chooseGeoemtryCache(o.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(i=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(t,e.props.scaleBaked),this.refreshAttachedCloners(o),this.refreshAttachedPaths(o)),i||(o.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(o)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,t){this.createGeometryDelayed(t)}updateState(e,t){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,t),super.updateState(e,t)}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,t){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),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)):e.setScalar(0),t.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,t){this.skeleton=e,this.isSkinnedMesh=!0,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let t=new Dr.Vector4,o=this.geometry.attributes.skinWeight;for(let i=0,a=o.count;i<a;i++){t.fromBufferAttribute(o,i);let s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),o.setXYZW(i,t.x,t.y,t.z,t.w)}}boneTransform(e,t){let o=this.skeleton;if(o===void 0)return;let i=this.geometry;fb.fromBufferAttribute(i.attributes.skinIndex,e),hb.fromBufferAttribute(i.attributes.skinWeight,e),pb.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let a=0;a<4;a++){let s=hb.getComponent(a);if(s!==0){let l=fb.getComponent(a);mb.multiplyMatrices(o.bones[l].matrixWorld,o.boneInverses[l]),t.addScaledVector(HM.copy(pb).applyMatrix4(mb),s)}}return t.applyMatrix4(this.bindMatrixInverse)}};function WM(n){if(n.geometry.attributes.extrudeNormal||!n.geometry.attributes.position||!n.geometry.attributes.normal)return;let r=new Map,e=n.geometry.attributes,t=e.position.array,o=e.normal.array,i=new Float32Array(t.length);for(let a=0;a<t.length;a+=3){let s=`${t[a]}_${t[a+1]}_${t[a+2]}`,l=new Er.Vector3(o[a],o[a+1],o[a+2]);r.has(s)?r.get(s)?.normals.push(l):r.set(s,{normals:[l],result:new Er.Vector3})}r.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<t.length;a+=3){let s=`${t[a]}_${t[a+1]}_${t[a+2]}`,l=r.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 qM(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,t=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(),t[i]=o.x,t[i+1]=o.y,t[i+2]=o.z;n.geometry.setAttribute("extrudeNormal",new Er.Float32BufferAttribute(t,3))}function ys(n){if(Array.isArray(n.material)){for(let r of n.material)if(r.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof Sr)||n.material.getLayersOfType("outline").length===0)return;n instanceof bt&&n.is2DAndNoDepth?qM(n):WM(n)}function gs(n){if(!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,t=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++)t[a]=i[a%3];n.geometry.setAttribute("randomColor",new Er.BufferAttribute(t,3))}var No=new on.Box3,Bl=new on.Vector3;function yb(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="SubdivGeometry"&&(r=!0)}),r}var wi=class extends bt{constructor(e,t,o){super(e,t,o);this.data=t;this.hiddenMatrixOld=new on.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,t){let o=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let t=this.localGeometry?.uuid,{originalGeometry:o,subdividedGeometry:i,subdivPointer:a}=It.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,ys(this),gs(this),this.calcBoundingBox(),t&&(this.localGeometry.uuid=t)}updateState(e,t){if(super.updateState(e,t),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(t)}}updateMesh(e=!1){It.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&It.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=It.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=It.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,t){let o=this.localGeometry;this.localGeometry=this.originalGeometryNew,zt.prototype.raycast.call(this,e,t),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 on.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;No.setFromBufferAttribute(t),No.getCenter(o),e.boundingSphere.radius=o.distanceTo(No.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),No.getSize(Bl),this.hasNonUniformScale&&Bl.divide(this.scale);let i={width:Bl.x,height:Bl.y,depth:Bl.z};return this.geometry.userData.parameters=i,i}updateBoundingSphere(e){let t=this.originalGeometry;No.min.set(e[0],e[2],e[4]),No.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(No.min.applyMatrix4(this.shearScaleInv),No.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new on.Sphere);let o=t.boundingSphere.center;No.getCenter(o),t.boundingSphere.radius=o.distanceTo(No.max)}freeSubdivPointer(){this.subdivPointer&&(It.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,t,o){super.updateByPatchedOpGeometry(e,t,o),this.localGeometry&&this.createGeometryByControls(t)}};var Do=require("three"),gb=-1,$M=1,xb={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},bb={polygon_center:0,edge:1,vertex:2},Ll=(n,r)=>(e,t)=>!r||e===0||n===0?0:n*t/100,Ie=(n,r)=>{let e=Math.abs(r),t=e*-1;return(n-gb)*(e-t)/($M-gb)+t};function vb(n){let r=[],e={};for(var t=0,o=n.length;t<o;t++){var i=JSON.stringify(n[t].pos.map(a=>Math.round(a*1e4)/1e4));e[i]||(r.push(n[t]),e[i]=!0)}return r}var YM=new Do.Vector3,Zu=new Do.Vector3,XM=new Do.Vector3,KM=new Do.Vector3;function xs(n,r){let e=XM.fromArray(n),t=KM.fromArray(r);Zu.copy(t).sub(e);let o=Zu.length();return Zu.normalize().multiplyScalar(o*.5),YM.copy(e).add(Zu).toArray()}var Fr=new Do.Triangle,Ju=new Do.Vector3,ed=new Do.Vector3,Pi=new Do.Vector3;function Sb(n){let r=[];for(let e=0;e<=n.index.count;e++)if(Ju.fromArray(n.index.array,e*3),Fr.setFromAttributeAndIndices(n.attributes.position,Ju.x,Ju.y,Ju.z),Fr.getNormal(ed),Fr.getMidpoint(Pi),!(isNaN(Pi.x)||isNaN(Pi.y)||isNaN(Pi.z))){let{a:t,b:o,c:i}=Fr,a=t.toArray(),s=o.toArray(),l=i.toArray(),c=t.distanceTo(o),u=o.distanceTo(i),p=i.distanceTo(t),d=xs(a,s),h=xs(s,l),f=xs(l,a),m=[c,u,p],y=Math.max(...m),g=m.filter(P=>Math.round(P)===Math.round(y)).length>1,v=[],O=Fr.getMidpoint(Pi).toArray();y===c&&!g&&(v=[h,f,f],O=d),y===u&&!g&&(v=[d,f,f],O=h),y===p&&!g&&(v=[d,h,h],O=f),g&&(v=[d,h,f]),r.push({vertices:[a,s,l],faceCenters:v,midpoint:O,norm:Fr.getNormal(ed).toArray()})}return r}function wb(n){let r=[],{position:e}=n.attributes;for(let t=0;t<e.count;t++){Fr.setFromAttributeAndIndices(e,t*3,t*3+1,t*3+2),Fr.getNormal(ed),Fr.getMidpoint(Pi);let o=Fr.a.toArray(),i=Fr.b.toArray(),a=Fr.c.toArray();r.push({vertices:[o,i,a],faceCenters:[xs(o,i),xs(i,a),xs(a,o)],midpoint:Pi.toArray(),norm:ed.toArray()})}return r}var QM=4,ZM=.5,$f=n=>.5*(1-Math.cos(n*Math.PI)),Yf=class{constructor(){this.perlin=new Array(4095+1)}noise(r,e=0,t=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}r<0&&(r=-r),e<0&&(e=-e),t<0&&(t=-t);let o=Math.floor(r),i=Math.floor(e),a=Math.floor(t),s=r-o,l=e-i,c=t-a,u,p,d=0,h=.5,f,m,y;for(let g=0;g<QM;g++){let v=o+(i<<4)+(a<<8);u=$f(s),p=$f(l),f=this.perlin[v&4095],f+=u*(this.perlin[v+1&4095]-f),m=this.perlin[v+16&4095],m+=u*(this.perlin[v+16+1&4095]-m),f+=p*(m-f),v+=256,m=this.perlin[v&4095],m+=u*(this.perlin[v+1&4095]-m),y=this.perlin[v+16&4095],y+=u*(this.perlin[v+16+1&4095]-y),m+=p*(y-m),f+=$f(c)*(m-f),d+=f*h,h*=ZM,o<<=1,s*=2,i<<=1,l*=2,a<<=1,c*=2,s>=1&&(o++,s--),l>=1&&(i++,l--),c>=1&&(a++,c--)}return d}noiseSeed(r){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(r),this.perlin=new Array(4095+1);for(let t=0;t<4095+1;t++)this.perlin[t]=e.rand()}},Pb=Yf;var vs=require("three");var Ob=new vs.Vector3,Cb=new vs.Matrix4,Tb=new vs.Ray;function Ab(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(r=!0)}),r}var bs=class extends bt{constructor(e,t,o){super(e,t,o);this.data=t}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,t){let{matrixWorld:o}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(Cb.copy(o).invert(),Tb.copy(e.ray).applyMatrix4(Cb),Tb.intersectBox(this.singleBBox,Ob))){let i=Ob.applyMatrix4(o),a=e.ray.origin.distanceTo(i);t.push({distance:a,point:i.clone(),object:this})}}};var pr=1e-4,Eo,Nb,Db,Eb,Mb=new Ze.Vector3,Ib=new Ze.Vector3;Eu.then(n=>{Eo=n,Nb=[Eo.get_face_center,Eo.get_edge_midpoint,Eo.get_vertex_position],Db=[Eo.get_face_normal,Eo.get_edge_normal,Eo.get_vertex_normal],Eb=[Eo.face_count,Eo.edge_count,Eo.vertex_count]});var JM=new Ze.Matrix4,eI=new Ze.Matrix4,zn=new Ze.Vector3,td=new Ze.Vector3,Rl=new Ze.Vector3,Xf=new Ze.Vector3,tI=new Ze.Vector3,rI=new Ze.Vector3;var nn=new Pb,ws=class extends Oa(Ze.Object3D){constructor(e,t){super();this.parameters=t;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 t of this.children)t instanceof Ko&&t.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(t=>{t instanceof Ko&&t.object===e&&(t.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 t;if(e!==void 0?t=e:t=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&&(t=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===t)return;if(o.length<t)for(let i=0,a=t-o.length;i<a;++i){let s=new Ko(this.object);s.expand(),this.add(s)}else for(let i=0,a=o.length-t;i<a;++i)this.remove(o[i])}else{if(this.children.length===t)return;if(this.children.length<t)for(let o=0,i=t-this.children.length;o<i;++o){let a=new Ko(this.object);a.expand(),this.add(a)}else for(let o=0,i=this.children.length-t;o<i;++o)this.remove(this.children[0])}}_updateRadial(e){let t=e.radial,o=t.start*Ze.MathUtils.DEG2RAD,i=t.end*Ze.MathUtils.DEG2RAD,a=o-i,s=new Ze.Euler(t.rotation[0],t.rotation[1],t.rotation[2]),l;switch(t.axis){case"z":l=new Ze.Vector3(0,0,1);break;case"y":l=new Ze.Vector3(0,1,0);break;default:case"x":l=new Ze.Vector3(1,0,0);break}let c=e.randomnessObject??vo.defaultData([1,1,1]).randomnessObject,u=c.noiseType==="perlin";nn.noiseSeed(c.seed);let p=hu((0,Ss.default)(c.seed)),d=Ll(c.strength,this.parameters.randomness);for(let[h,f]of this.children.entries()){let m=h*(c.freqScale/10)+c.movement,y=u?nn.noise(m):p(m,m),g=h+1;f.scale.x=t.scale[0]+d(g,Ie(y,c.scale[0]))||pr,f.scale.y=t.scale[1]+d(g,Ie(y,c.scale[1]))||pr,f.scale.z=t.scale[2]+d(g,Ie(y,c.scale[2]))||pr,f.position.setScalar(0);let v=a/e.count*h-o;switch(t.axis){case"x":f.rotation.set(0,v,0);break;case"y":f.rotation.set(0,0,v);break;case"z":f.rotation.set(v,0,0);break}f.translateOnAxis(l,t.radius),f.position.x+=t.position[0]+d(g,Ie(y,c.position[0])),f.position.y+=t.position[1]+d(g,Ie(y,c.position[1])),f.position.z+=t.position[2]+d(g,Ie(y,c.position[2]));let O=d(g,Ie(y,c.rotation[0])),P=d(g,Ie(y,c.rotation[1])),S=d(g,Ie(y,c.rotation[2]));t.alignment===!0?(f.rotation.x+=s.x+O,f.rotation.y+=s.y+P,f.rotation.z+=s.z+S):f.rotation.set(s.x+O,s.y+P,s.z+S)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,o=new Ze.Euler(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??vo.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";nn.noiseSeed(i.seed);let s=hu((0,Ss.default)(i.seed)),l=Ll(i.strength,this.parameters.randomness);for(let[c,u]of this.children.entries()){let p=c*(i.freqScale/10)+i.movement,d=a?nn.noise(p):s(p,p),h=c+1,f=l(h,Ie(d,i.rotation[0])),m=l(h,Ie(d,i.rotation[1])),y=l(h,Ie(d,i.rotation[2]));u.scale.x=1+(t.scale[0]-1)*c+l(h,Ie(d,i.scale[0]))||pr,u.scale.y=1+(t.scale[1]-1)*c+l(h,Ie(d,i.scale[1]))||pr,u.scale.z=1+(t.scale[2]-1)*c+l(h,Ie(d,i.scale[2]))||pr,u.rotation.x=o.x*c+f,u.rotation.y=o.y*c+m,u.rotation.z=o.z*c+y,u.position.x=t.position[0]*c+l(h,Ie(d,i.position[0])),u.position.y=t.position[1]*c+l(h,Ie(d,i.position[1])),u.position.z=t.position[2]*c+l(h,Ie(d,i.position[2]))}}_updateGrid(e){let t=0,o=e.grid,i=e.randomnessObject??vo.defaultData([1,1,1]).randomnessObject,a=Ll(i.strength,this.parameters.randomness),s=i.noiseType==="perlin";nn.noiseSeed(i.seed);let l=c0((0,Ss.default)(i.seed));if(o.useCenter===!0){let c={x:o.count[0]%2===0?2:1,y:o.count[1]%2===0?2:1,z:o.count[2]%2===0?2:1},u=new Ze.Vector3(o.size[0]*(o.count[0]-c.x)*.5,o.size[1]*(o.count[1]-c.y)*.5,o.size[2]*(o.count[2]-c.z)*.5);for(let p=0;p<o.count[0];p++)for(let d=0;d<o.count[1];d++)for(let h=0;h<o.count[2];h++){let f=[(p+1)*(i.freqScale/10)+i.movement,(d+1)*(i.freqScale/10)+i.movement,(h+1)*(i.freqScale/10)+i.movement],m=s?nn.noise(...f):l(...f),y=this.children[t++];y.scale.x=1+a(t,Ie(m,i.scale[0]))||pr,y.scale.y=1+a(t,Ie(m,i.scale[1]))||pr,y.scale.z=1+a(t,Ie(m,i.scale[2]))||pr;let g=a(t,Ie(m,i.rotation[0])),v=a(t,Ie(m,i.rotation[1])),O=a(t,Ie(m,i.rotation[2]));y.rotation.set(g,v,O),y.position.x=o.size[0]*p-u.x+a(t,Ie(m,i.position[0])),y.position.y=o.size[1]*d-u.y+a(t,Ie(m,i.position[1])),y.position.z=o.size[2]*h-u.z+a(t,Ie(m,i.position[2]))}}else for(let c=0;c<o.count[0];c++)for(let u=0;u<o.count[1];u++)for(let p=0;p<o.count[2];p++){let d=[(c+1)*(i.freqScale/10)+i.movement,(u+1)*(i.freqScale/10)+i.movement,(p+1)*(i.freqScale/10)+i.movement],h=s?nn.noise(...d):l(...d),f=this.children[t++];f.scale.x=1+a(t,Ie(h,i.scale[0]))||pr,f.scale.y=1+a(t,Ie(h,i.scale[1]))||pr,f.scale.z=1+a(t,Ie(h,i.scale[2]))||pr;let m=a(t,Ie(h,i.rotation[0])),y=a(t,Ie(h,i.rotation[1])),g=a(t,Ie(h,i.rotation[2]));f.rotation.set(m,y,g),f.position.x=o.size[0]*c+a(t,Ie(h,i.position[0])),f.position.y=-o.size[1]*u+a(t,Ie(h,i.position[1])),f.position.z=-o.size[2]*p+a(t,Ie(h,i.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:t}=e,o=new Ze.Euler(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??vo.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";nn.noiseSeed(i.seed);let s=hu((0,Ss.default)(i.seed)),l=Ll(i.strength,this.parameters.randomness);if(!t.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 bs)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 c=this.getSubdivData(),u=[],p=g=>{let v=g.length,O=g.map(T=>T[0]).reduce((T,I)=>T+I,0),P=g.map(T=>T[1]).reduce((T,I)=>T+I,0),S=g.map(T=>T[2]).reduce((T,I)=>T+I,0);return[O/v,P/v,S/v]},d=g=>Math.round(g*1e6)/1e6;c.forEach(g=>{let v=c.filter(O=>d(g.pos[0])===d(O.pos[0])&&d(g.pos[1])===d(O.pos[1])&&d(g.pos[2])===d(O.pos[2]));v.length>1?u.push({pos:g.pos,norm:p(v.map(O=>O.norm))}):u.push(g)});let h=vb(u);if(h.length>0){let g=Math.round(h.length*t.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 f=new mu(this.objectForSample).build(),m=xb[t.axis],y=this.children;f.setRandomGenerator((0,Ss.default)(this.object.uuid+t.seed));for(let[g,v]of y.entries()){let O=g*(i.freqScale/10)+i.movement,P=a?nn.noise(O):s(O,O),S=g+1,T=l(S,Ie(P,i.rotation[0])),I=l(S,Ie(P,i.rotation[1])),x=l(S,Ie(P,i.rotation[2]));t.spreadType==="random"?f.sample(Rl,Xf):(h.length&&(Rl.fromArray(h[g].pos),Xf.fromArray(h[g].norm)),this.objectForSample instanceof wi&&Rl.applyMatrix4(JM.copy(this.objectForSample.matrixWorld).invert())),Rl.applyMatrix4(this.object.hiddenMatrix.clone().invert()),v.position.copy(Rl),zn.fromArray(m);let _=t.align==="normal"?Xf:this.object.getWorldDirection(rI),D=td.fromArray(t.position);td.x+=l(S,Ie(P,i.position[0])),td.y+=l(S,Ie(P,i.position[1])),td.z+=l(S,Ie(P,i.position[2]));let A=Math.acos(_.dot(zn)),N=tI.crossVectors(zn,_).normalize(),E=eI.makeRotationAxis(N,A),B=_.clone().cross(this.object.up).normalize(),V=B.clone().cross(_).normalize(),j=new Ze.Matrix4().makeBasis(B,_,V),R=new Ze.Vector3(zn.y,zn.z,zn.x).normalize(),W=R.clone().cross(zn).normalize(),F=new Ze.Matrix4().makeBasis(R,zn,W).invert(),k=new Ze.Matrix4().multiplyMatrices(j,F);v.rotation.setFromRotationMatrix(k),D.applyMatrix4(E),v.position.add(D),v.rotation.x=v.rotation.x+o.x+T,v.rotation.y=v.rotation.y+o.y+I,v.rotation.z=v.rotation.z+o.z+x,v.scale.setScalar(1),v.scale.x=v.scale.x+t.scale[0]+l(S,Ie(P,i.scale[0]))||pr,v.scale.y=v.scale.y+t.scale[1]+l(S,Ie(P,i.scale[1]))||pr,v.scale.z=v.scale.z+t.scale[2]+l(S,Ie(P,i.scale[2]))||pr,v.scale.multiply(this.object.scale),v.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof wi){let t=this.objectForSample,o=bb[e],i=Eb[o],a=Nb[o],s=Db[o],l=[],c=i(t.subdivPointerNew);for(let u=0;u<=c-1;u++){let p=a(t.subdivPointerNew,u),d=s(t.subdivPointerNew,u);Mb.fromArray(p).applyMatrix4(t.matrixWorld),Ib.fromArray(d),l.push({pos:Mb.toArray(),norm:Ib.toArray()})}return l}else return(this.objectForSample.geometry.index?Sb(this.objectForSample.geometry):wb(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,t){if(this.parameters=Fo(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=t.find(this.parameters.toObject.object);o instanceof zt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new Ze.Matrix4,this.hiddenMatrix=new Ze.Matrix4,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};var Yr=require("three");var ft=require("three");var tr=require("three");var _b=require("three"),_o=n=>{var r;return r=class extends n{},r.geometryHelper=new _b.BoxGeometry(30,30,30),r};var nr=require("three"),rd=new nr.Ray,Kf=new nr.Sphere,Bb=new nr.Matrix4,Bo=(n,r,e,t,o=!1)=>{let i=r,a=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),Kf.copy(i.boundingSphere),Kf.applyMatrix4(a),e.ray.intersectsSphere(Kf)===!1||(Bb.copy(a).invert(),rd.copy(e.ray).applyMatrix4(Bb),i.boundingBox!==null&&rd.intersectsBox(i.boundingBox)===!1))return;let s,l,c,u,p=i.index,d=i.attributes.position,h=i.drawRange,f,m;if(o===!1){let g=Math.max(0,h.start),v=Math.min(p.count,h.start+h.count);for(f=g,m=v;f<m;f+=3)if(l=p.getX(f),c=p.getX(f+1),u=p.getX(f+2),s=y(n,e,rd,d,l,c,u),s){s.faceIndex=Math.floor(f/3),t.push(s);return}}else{let v=i.attributes.position,O=new nr.Vector3,P=new nr.Vector3,S=new nr.Vector3,T=new nr.Vector3,I=2,_=1/((n.scale.x+n.scale.y+n.scale.z)/3),D=_*_,A=Math.max(0,h.start),N=Math.min(v.count,h.start+h.count);for(let E=A,B=N-1;E<B;E+=I){if(O.fromBufferAttribute(v,E),P.fromBufferAttribute(v,E+1),rd.distanceSqToSegment(O,P,T,S)>D)continue;T.applyMatrix4(n.matrixWorld);let j=e.ray.origin.distanceTo(T);j<e.near||j>e.far||t.push({distance:j,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(g,v,O,P,S,T,I){let x=new nr.Vector3,_=new nr.Vector3,D=new nr.Vector3,A=new nr.Vector3,N=new nr.Vector3;if(x.fromBufferAttribute(P,S),_.fromBufferAttribute(P,T),D.fromBufferAttribute(P,I),O.intersectTriangle(x,_,D,!1,A)===null)return null;N.copy(A),N.applyMatrix4(g.matrixWorld);let B=v.ray.origin.distanceTo(N);return B<v.near||B>v.far?null:{faceIndex:1,distance:B,point:N.clone(),object:g}}};var od=new tr.Vector3,Ur=new tr.Camera,Qf=class extends tr.LineSegments{constructor(e){let t=new tr.BufferGeometry,o=new tr.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],a=[],s={},l=new tr.Color(15711266),c=new tr.Color(15711266),u=new tr.Color(2857471);p("n1","n2",l),p("n2","n4",l),p("n4","n3",l),p("n3","n1",l),p("f1","f2",l),p("f2","f4",l),p("f4","f3",l),p("f3","f1",l),p("n1","f1",l),p("n2","f2",l),p("n3","f3",l),p("n4","f4",l),p("p","n1",c),p("p","n2",c),p("p","n3",c),p("p","n4",c),p("u1","u2",u),p("u2","u3",u),p("u3","u1",u);function p(h,f,m){d(h,m),d(f,m)}function d(h,f){i.push(0,0,0),a.push(f.r,f.g,f.b),s[h]===void 0&&(s[h]=[]),s[h].push(i.length/3-1)}t.setAttribute("position",new tr.Float32BufferAttribute(i,3)),t.setAttribute("color",new tr.Float32BufferAttribute(a,3));super(t,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,t=this.pointMap,o=!0;Ur.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;po("n1",t,e,Ur,-i,-a,s),po("n2",t,e,Ur,i,-a,s),po("n3",t,e,Ur,-i,a,s),po("n4",t,e,Ur,i,a,s);let l=s;po("f1",t,e,Ur,-i,-a,l),po("f2",t,e,Ur,i,-a,l),po("f3",t,e,Ur,-i,a,l),po("f4",t,e,Ur,i,a,l);let c=l,u=.5;po("u1",t,e,Ur,i*.7*u,a*1.1,c),po("u2",t,e,Ur,-i*.7*u,a*1.1,c),po("u3",t,e,Ur,0,a*(1.1+.9*u),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function po(n,r,e,t,o,i,a){od.set(o,i,a).unproject(t);let s=r[n];if(s!==void 0){let l=e.getAttribute("position");for(let c=0,u=s.length;c<u;c++)l.setXYZ(s[c],od.x,od.y,od.z)}}var nd=class extends _o(Qf){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,t){Bo(this.object,this.geometry,e,t,!0)}};var Vl=require("three");var id;(r=>r.is=e=>"objectHelper"in e)(id||(id={}));var kr=(n,r)=>class extends Aa(n){constructor(){super(...arguments);this.objectHelper=new r(this);this.gizmos={}}get geometryHelper(){return r.geometryHelper}raycast(o,i){this.objectHelper.raycast(o,i)}showGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof Vl.Box3Helper&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof Vl.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 Vl.Box3Helper&&(i.visible=!1)}}};var ad=790,Ps=new ft.Vector3,Zf=new ft.Vector3,Jf=new ft.Quaternion,eh=new ft.Vector3,zl=new ft.Vector3,th=new ft.Vector3,an=class extends kr(ft.Camera,nd){constructor(e="",t={...ai.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Pn.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,t),this.previousProjectionMatrix=new ft.Matrix4,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,i=this.height;this.orthoCamera=new ft.OrthographicCamera(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4),this.perspCamera=new ft.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,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,t,o){typeof e=="number"&&(e=new ft.Vector3(e,t,o)),super.lookAt(e),this.getWorldPosition(Ps),this.targetOffset=Ps.distanceTo(e)}getTarget(e=new ft.Vector3){return this.getWorldDirection(Zf),this.getWorldPosition(Ps),Zf.multiplyScalar(this.targetOffset),e.copy(Ps).add(Zf),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Ps),Ps.distanceTo(e)}updateUp(){this.getWorldQuaternion(Jf),eh.set(0,0,1).applyQuaternion(Jf),zl.copy(ft.Object3D.DEFAULT_UP),this.isUpVectorFlipped&&zl.negate(),zl.applyQuaternion(Jf),th.copy(ft.Object3D.DEFAULT_UP).projectOnPlane(eh),this.angleOffsetFromUp=th.angleTo(zl),this.angleOffsetFromUp*=th.cross(zl).dot(eh)>=0?1:-1}updateTransformState(e,t){let o=super.updateTransformState(e,t);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),o}getViewFrontToObject(e){let t=e.getWorldPosition(new ft.Vector3),i=e.getWorldDirection(new ft.Vector3).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToTarget(e){let o=this.getWorldDirection(new ft.Vector3).multiplyScalar(this.targetOffset);return{position:e.clone().sub(o),target:e}}getViewToObject(e){let t=new ft.Vector3,o=e.getWorldPosition(t);return this.getViewToTarget(t)}setViewplaneSize(e,t,o=!1){if(this.aspect=e/t,o){let i=e>t?this.aspect:1,a=e>t?1:this.aspect;this.left=-ad*.5*i,this.right=ad*.5*i,this.top=ad*.5*(1/a),this.bottom=-ad*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.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,t,o,i,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,o,i,a,s):this.orthoCamera.setViewOffset(e,t,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,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),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 t={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return ea(t,e)}updateCameraSubtype(e,t){let o=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";t.zoom!==void 0&&this.setZoom(o,t.zoom),t.near!==void 0&&this.setNear(o,t.near),t.fov!==void 0&&o==="PerspectiveCamera"&&(this.fov=t.fov)}updateState(e,t){this.updateCameraState(e,t)}updateCameraState(e,t){this.updateState_Entity(e,t),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,t,o){super.updateByPatchedOp(e,t,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 iI=require("three");var Gn=require("three");var Os=new Gn.Matrix4,nI=new Gn.Matrix4;var Pr=class extends wr{constructor(e,t,o){super(e,t);this.data=t;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new Gn.BufferGeometry;this.onAfterRender=(e,t,o,i,a,s)=>{super.onAfterRender(e,t,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,t,o){super.updateByPatchedOp(e,t,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,t=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let i=0;i<this.children.length;i++){let a=this.children[i];a instanceof Pr&&a.dataPatched.visible===!0&&a.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let a=this.children[i];if(a instanceof zt&&a.dataPatched.visible===!0&&a.geometry.attributes.position?.count>0&&a.geometry.drawRange.count>0&&a.booleanMeshSetAddress!==0){Os.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,t)),a.booleanMeshSetAddress===-1)return;Gr.transformMeshSet(a.booleanMeshSetAddress,Os),a.booleanMatrixInvOld.copy(Os).invert(),a.booleanWasTransformed=!1}else a instanceof Pr&&a.needsTransformForDownstream===!0?(Gr.transformMeshSet(a.booleanMeshSetAddress,Os),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(Gr.transformMeshSet(a.booleanMeshSetAddress,nI.multiplyMatrices(Os,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(Os).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 Gn.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 Gn.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,ys(this),gs(this)}dispose(){super.dispose(),this.geometry.dispose()}};var Rb=require("three");var Lb;(r=>{function n(e){return je.is(e)&&e instanceof Rb.Light}r.is=n})(Lb||(Lb={}));var Cs=(n,r)=>class extends kr(n,r){updateState_Light(t,o){this.updateState_Entity(t,o),t.color!==void 0&&(this.color=o.shared.color(t.color)),t.intensity!==void 0&&(this.intensity=t.intensity),t.depth!==void 0&&(this.shadow.camera.far=t.depth,this.shadow.needsUpdate=!0),t.shadows!==void 0&&(this.castShadow=t.shadows)}};var jn=n=>n instanceof zt,Gl=n=>n!==null&&n instanceof Pr;var jl=n=>id.is(n);var zb=require("three");var Vb=require("three");var Hr=class extends _o(Vb.AxesHelper){constructor(e,t=15){super(t);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,t){Bo(this.object,Hr.geometryHelper,e,t)}update(){}};var Fn=class extends kr(zb.Group,Hr){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update()}updateState(r,e){this.updateState_Entity(r,e),"buffer"in r&&Object.keys(r).length===1&&e.scene.reloadSplats()}};var Gb=require("three");var sd=class extends kr(Gb.Group,Hr){constructor(e,t,o){super();this.super_Entity(e,t),this.context=o,this.objectHelper.update()}updateState(e,t){this.updateState_Entity(e,t)}};var _s=require("three");var Ts=require("three"),aI=n=>`
|
|
2244
2230
|
|
|
2245
2231
|
// PCSS implementation based on:
|
|
2246
2232
|
// https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
|
|
@@ -2614,7 +2600,7 @@ float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, floa
|
|
|
2614
2600
|
}
|
|
2615
2601
|
|
|
2616
2602
|
#endif
|
|
2617
|
-
`,nI=$s.ShaderChunk.lights_fragment_begin,iI=$s.ShaderChunk.shadowmask_pars_fragment,mv=null,aI=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},yv=(n="medium")=>{if(mv===n)return!1;mv=n;let t=aI(n);$s.ShaderChunk.shadowmap_pars_fragment=oI(t);let e=nI.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 ]"),$s.ShaderChunk.lights_fragment_begin=e;let r=iI.slice();return r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),$s.ShaderChunk.shadowmask_pars_fragment=r,!0};var dc=require("three");var gv=require("three");var Ys=class extends Yo(gv.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,Ys.geometryHelper,e,r)}};var xv=require("three");var Xs=class extends Yo(xv.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,Xs.geometryHelper,e,r)}};var Ed=require("three");var Dd=class extends Yo(Ed.SpotLightHelper){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){Xo(this.object,Dd.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=Dd._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=Dd;uc._vector=new Ed.Vector3;function sI(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 Qs=class extends Ws(dc.DirectionalLight,Ys){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&&sI(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 qv=require("three");var no=require("three");var bv=new no.Vector3,vv=new no.Vector3,Sv=new no.Quaternion,Ks=class extends Ws(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),vv.setFromMatrixPosition(this.matrixWorld),Sv.setFromRotationMatrix(this.matrixWorld),bv.copy(this.up).applyQuaternion(Sv).negate().multiplyScalar(this.distance),this.target.position.copy(vv).add(bv),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))}};function lI(n){let t=(n[0][0]+n[1][1])/2,e=(n[0][0]-n[1][1])/2,r=(n[1][0]+n[0][1])/2,o=(n[1][0]-n[0][1])/2,i=Math.sqrt(t*t+o*o),a=Math.sqrt(e*e+r*r),s=i+a,l=i-a,u=Math.atan2(r,e),c=Math.atan2(o,t),d=(c-u)/2,p=(c+u)/2,f=[[Math.cos(p),Math.sin(p)],[-Math.sin(p),Math.cos(p)]],h=[[s,0],[0,l]],m=[[Math.cos(d),Math.sin(d)],[-Math.sin(d),Math.cos(d)]];return f[0][0]*=-1,f[0][1]*=-1,m[0][0]*=-1,m[1][0]*=-1,[f,h,m]}function Bd(n,t){return[[n[0][0]*t[0][0]+n[0][1]*t[1][0],n[0][0]*t[0][1]+n[0][1]*t[1][1]],[n[1][0]*t[0][0]+n[1][1]*t[1][0],n[1][0]*t[0][1]+n[1][1]*t[1][1]]]}function wv(n){return[[n[0][0],n[1][0]],[n[0][1],n[1][1]]]}function Av(n){let[t,e,r]=lI(n),o=Bd(t,wv(r)),i=Bd(Bd(r,e),wv(r)),a=Math.atan2(o[1][0],o[0][0]),s=[i[0][0],i[1][1]],l=[i[0][1]/i[1][1],i[1][0]/i[0][0]];return{rotation:a,scale:s,shear:l}}function _v({rotation:n,scale:t,shear:e}){let r=Math.cos(n),o=Math.sin(n),i=[[r,-o],[o,r]],a=[[t[0],e[0]*t[1]],[e[1]*t[0],t[1]]],s=Bd(i,a);return[s[0][0],s[1][0],s[0][1],s[1][1]]}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,F,V,q,k]=a(O),U=B*x+R*N,H=B*D+R*T,Y=F*x+V*N,J=F*D+V*T,Z=q*x+k*N+I,X=q*D+k*T+E;return S.create(U,H,Y,J,Z,X)}S.append=o;function i(P,O){let[x,D,N,T,I,E]=a(P),[B,R,F,V,q,k]=a(O),U=x,H=D,Y=N,J=T;(B!==1||R!==0||F!==0||V!==1)&&(U=x*B+D*F,H=x*R+D*V,Y=N*B+T*F,J=N*R+T*V);let Z=I*B+E*F+q,X=I*R+E*V+k;return S.create(U,H,Y,J,Z,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,F=-D/E,V=O/E,q=(D*I-N*T)/E,k=-(O*I-x*T)/E;return S.create(B,R,F,V,q,k)}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,F]=P;return[T*B*R+-N*B*F+(E*N-I*T)*B,x*B*F+-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),{rotation:B,scale:R,shear:F}=Av([[x,N],[D,T]]);return{position:[I+(O[0]*x+O[1]*N)-O[0],E+(O[0]*D+O[1]*T)-O[1]],scale:R,rotation:B,shear:F,pivot:O}}S.decompose=w;function A(P,O,x,D,N=[0,0]){let[T,I]=P,[E,B]=D,[R,F,V,q]=_v({rotation:x,scale:O,shear:N}),k=T-(E*R+B*V)+E,U=I-(E*F+B*q)+B;return S.create(R,F,V,q,k,U)}S.compose=A})($e||($e={}));var cI=Math.PI/180,PJ=180/Math.PI;function Pv(n,t,e,r,o,i){let a=n-e,s=t-r;return a*a/(o*o)+s*s/(i*i)<=1}function Ov(n){return n*cI}function Ch(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 ii;this._recursiveBBox=new ii;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.shear=[0,0];this.emitter=Ch();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,o=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([t,e],r),o)}intersectsInLocalSpace(t,e,r=!1){let{min:o,max:i}=r?this.recursiveBBox:this.singleBBox;return t>=o[0]&&t<=i[0]&&e>=o[1]&&e<=i[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,Ov(this.rotation),pn.getPivot(this.dataPatched),this.shear)}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),t.shear!==void 0&&(e=!0,this.shear=t.shear),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=Fe(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,Ci.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)Ci.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=Ci.patch(this.data,o),Ci.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=[],s=!1){for(let l of this.children){let u=l instanceof Pr;if(l instanceof gr&&!u&&s&&l.intersectsChildren(e,r,o,i,a,!1),l.intersects(e,r,o,u)&&(a.push(l),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}},Pr=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 Pr(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}};function uI(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 Tv=[[-1,1],[-1,-1],[1,-1],[1,1]],Cv=(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)):Tv.forEach(a=>{let s=[a[0]*o[0]+r[0],a[1]*o[1]+r[1]];e.push($e.apply(s,i))})},ii=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&&Cv(i,e,o)}):Cv(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=Tv.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(uI(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 ii;return t.copy(this),t}};var Iv,Nv=new Promise(n=>{Iv=n}),Mv=!1;var Ld;function Dv(){if(Mv)return;if(Ld)return Ld;async function n(){let e=await import("./ui.js");Iv(e.default??e),Mv=!0}return Ld=n(),Ld}function Lv(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,Th;async function dI(n){let t=await Nv;Te||(Th||(Th=t({locateFile:()=>n})),Te=await Th)}var Ev=$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=Ev,this._currentTransform=new Float32Array(Ev)}async init(){if(!this.wasmURL)throw Error("Your must set the wasm binary url with renderer.wasmURL = ... before you can call renderer.init");await dI(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(Rd(t),Te.ColorSpace.DISPLAY_P3)}set fillColor(t){this._paintFill&&this._paintFill.setColor(Rd(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(Rd(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(Rd(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(!Bv([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(!!Bv(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 Bv(n){for(let t=0;t<n.length;t++)if(n[t]!==void 0&&!Number.isFinite(n[t]))return!1;return!0}function Rd({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 Vd=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 zd=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 Lr=class extends An{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.autoClose=!0;this.fill=new Vd(e+"-fill",r.fill,o),this.stroke=new zd(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&&(Fe(e.path,["fill"])?this.fill.update(e.props):Fe(e.path,["stroke"])?this.stroke.update(e.props):Fe(e.path,["dropShadow"])?this.dropShadow.update(e.props):Fe(e.path,["innerShadow"])?this.innerShadow.update(e.props):Fe(e.path,["layerBlur"])?this.layerBlur.update(e.props):Fe(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 Lr(this.uuid,this.data,e);return r.parent=void 0,r}};var ai=class extends Lr{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 Pv(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 ai(this.uuid,this.data,e);return r.parent=void 0,r}};var Qo=class extends Lr{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 si=class extends Lr{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 si(this.uuid,this.data,e);return r.parent=void 0,r}};var Zs=class extends Lr{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=>Gd.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};Gd.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 Zs(this.uuid,this.data,e);return r.parent=void 0,r}},Gd;(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=Mh.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})(Gd||(Gd={}));var Mh;(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=Ih.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})(Mh||(Mh={}));var Ih;(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})(Ih||(Ih={}));var Wr=class extends gr{constructor(e,r,o){super(e,r,o);this.uuid=e;this.width=0;this.height=0;this.clipped=!0;this.background=new Qo(e+"-background",Ua.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),this.clipped&&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),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.type===0&&(Fe(e.path,["fill"])?this.fill.update(e.props):Fe(e.path,["stroke"])?this.stroke.update(e.props):Fe(e.path,["dropShadow"])?this.dropShadow.update(e.props):Fe(e.path,["innerShadow"])?this.innerShadow.update(e.props):Fe(e.path,["layerBlur"])?this.layerBlur.update(e.props):Fe(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let r=new Wr(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}};var Gv=ar(Nh(),1),_n=class extends Lr{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this._pathBBox=new DOMRect;this.path="";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.path),e.appendChild(r),this._pathBBox=r.getBBox(),e.remove()}innerDraw(e){e.path(this.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.path=e.path,this.computeSVGBBox())}clone(e){let r=new _n(this.uuid,this.data,e);return r.parent=void 0,r}};function Fv(n,t=1,e=1){if(t<=0||e<=0)return n;let o=(0,Gv.parseSVG)(n).map(i=>{let a={...i};return"x"in a&&(a.x=a.x*t),"y"in a&&(a.y=a.y*e),"x1"in a&&(a.x1=a.x1*t),"x2"in a&&(a.x2=a.x2*t),"y1"in a&&(a.y1=a.y1*e),"y2"in a&&(a.y2=a.y2*e),"rx"in a&&(a.rx=a.rx*t),"ry"in a&&(a.ry=a.ry*e),a});return kv(o)}function kv(n){let t=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],e;return n.map(r=>{let o=[];t.forEach(a=>{if(a in r){let s=r[a]*1;o.length&&s>=0&&o.push(","),o.push(s)}});let i=(e===r.code?o[0]<0?"":",":r.code)+o.join("");return e=r.code,i}).join("")}function jv(n,t,e){switch(t.type){case"ellipse2d":return new ai(n,t,e);case"rectangle2d":return new Qo(n,t,e);case"text2d":return new si(n,t,e);case"vector2d":return new Zs(n,t,e);case"path2d":return new _n(n,t,e);case"frame2d":return new Wr(n,t,e);case"group2d":default:return new Pr(n,t,e)}}var Dh=class{constructor(t,e,r){this.uuid=t;this.data=e;this.group=new Pr(Dh.GROUP_ID,{...Pl.defaultData},r),this.createChildrenObjects(e.objects,this.group,r)}createObject(t,e,r,o,i,a){let s=jv(t,e,a);s&&(o.add(s),o.children.splice(i,0,o.children.pop()),s.updateWorldMatrix(),r.length>0&&(s instanceof Pr||s instanceof Wr)&&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,!0)}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)}},Hi=Dh;Hi.GROUP_ID="scene2d";function Eh({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 mI=ar(Nh(),1);var tre={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 Uv=require("three");var yI=$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 Hi(Uv.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=Cb.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=yI,this.isScreenSpace&&(this.frameOverride.fill.color=Be.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:r},Hv({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 Wr)))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 Hv({objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i}){if(n instanceof Wr&&t instanceof Wr||n instanceof Pr&&t instanceof Pr)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&&xI({objectOverride:l,objectRoot:u,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i})}}function gI(n){if(Bh(n))return[n.width,n.height];if(n instanceof _n){let[t,e]=n.getHalfSize();return[t*2,e*2]}else if(n instanceof Pr){let[t,e]=n.recursiveBBox.getHalfSize();return[t*2,e*2]}return[0,0]}function xI({objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i}){let[a,s]=gI(t),{width:l,height:u,position:c}=Eh({constraints:n.data,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i,objectInitialWidth:a,objectInitialHeight:s,objectInitialPosition:t.position});if(n.position=c,n.data={...n.data,position:c},n.states)for(let d in n.states)bI({stateId:d,objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i});if(Bh(n)||n instanceof Pr)Bh(n)&&(n.width=l,n.height=u,n.data={...n.data,width:l,height:u}),Hv({objectOverride:n,objectRoot:t,newParentWidth:l,newParentHeight:u,initialParentWidth:a,initialParentHeight:s});else if(n instanceof _n){let d=t,p=a!==0?l/a:1,f=s!==0?u/s:1;n.path=Fv(d.path,p,f),n.data={...n.data,path:n.path}}}function bI({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}=Eh({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 Bh(n){return n instanceof Qo||n instanceof Wr||n instanceof ai||n instanceof si}var io=class extends Ya(qv.Scene){constructor(e,r,o){super();this.data=r;this.bgColor=new Xt(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,{...Pi.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 Hi((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=dr(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 Br&&r.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof Er)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&&yv(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=dr(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,r){e.aoColor!==void 0&&(this.aoColor=dr(e.aoColor,r))}updateByOp(e,r,o,i){let a=this.data.uiFrame;super.updateByOp(e,r,o,i);let s=r;Fe(e.path,["fog"])?this.updateFog(s.fog,o.shared):Fe(e.path,["ao"])?this.updateAo(s.ao,o.shared):Fe(e.path,["ambient"])?this.updateAmbientLight(s.ambient,o.shared):Fe(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(dr(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 Qs&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize,e+=1),o instanceof Ks&&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;ke.is(a)&&(a.visible||s?.object.data.visible)&&((oi(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 Rr=require("three");var kd=class extends Ws(Rr.PointLight,Xs){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 Rr.Vector3(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new Rr.Vector3(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),l=new Rr.Box3(a,s),u=new Rr.Box3Helper(l,new Rr.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 Rr.Box3Helper){let r=this.shadow.camera,o=new Rr.Vector3(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),i=new Rr.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 jd=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?kl(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=is;break;case"Ellipse":i=rs;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?kl(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 ro(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=za.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{...qt.defaultData,...e,...uo(qt.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(ke.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Ud(s),a+=1;else break;this.children.splice(0,a)}i=!0}if(o){let a={};$v(e,[this.uuid],r.overrides,this,o,o,0,i,a);for(let s of this.children)if(ke.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 Ud(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)ke.is(e)&&Ud(e)}}function Wv(n,t,e,r){return n.component===t&&bp(n.identity,r)?n.overrideData===e?2:1:0}function $v(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.find(c=>c===r)||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(ke.is(c)){let d=[...t,...typeof c.identity=="string"?[c.identity]:c.identity],p=Ra.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=ke.is(m)?m:null,f!==null){let y=Wv(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=Wv(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,$v(n,t,e,f,c,i,a+1,s,l)}if(!s){let c=u;for(;;){let d=r.children[u];if(ke.is(d))n.pendingDeletes.add(d);else break;u+=1}r.children.splice(c,u-c)}return!0}var Yv=require("three");var Hd=class extends ro(Yv.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):Fe(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"),bS=require("three/examples/jsm/misc/GPUComputationRenderer.js");var Kt=require("three"),Xv=require("three/examples/jsm/math/MeshSurfaceSampler.js");function Qv(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 Kv(n){let t=Math.ceil(Math.sqrt(n));return Math.max(t,1)}function Zv(n,t){let e=new Kt.Mesh(n.geometry,n.material),r=[],o=[],i=new Kt.Vector3,a=new Kt.Vector3;e.geometry.index!==null&&(e.geometry=e.geometry.toNonIndexed());let s=new Xv.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 Lh(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 Kt.DataTexture(r,t,t,Kt.RGBAFormat,Kt.FloatType);return o.needsUpdate=!0,o}function Jv({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 Kt.DataTexture(t,n,n,Kt.RGBAFormat,Kt.FloatType);return e.needsUpdate=!0,e}function eS(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 Kt.DataTexture(t,n,n,Kt.RGBAFormat,Kt.FloatType);return e.needsUpdate=!0,e}var tS=`
|
|
2603
|
+
`,sI=Ts.ShaderChunk.lights_fragment_begin,lI=Ts.ShaderChunk.shadowmask_pars_fragment,jb=null,cI=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},Fb=(n="medium")=>{if(jb===n)return!1;jb=n;let r=cI(n);Ts.ShaderChunk.shadowmap_pars_fragment=aI(r);let e=sI.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 ]"),Ts.ShaderChunk.lights_fragment_begin=e;let t=lI.slice();return t=t.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),Ts.ShaderChunk.shadowmask_pars_fragment=t,!0};var Ul=require("three");var Ub=require("three");var As=class extends _o(Ub.DirectionalLightHelper){constructor(e,t=15,o=10066329){super(e,t,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Bo(this.object,As.geometryHelper,e,t)}};var kb=require("three");var Ms=class extends _o(kb.PointLightHelper){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Bo(this.object,Ms.geometryHelper,e,t)}};var cd=require("three");var ld=class extends _o(cd.SpotLightHelper){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Bo(this.object,ld.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=ld._vector,t=this.object.distance?this.object.distance:1e3,o=t*Math.tan(this.object.angle);this.cone.scale.set(o,o,t),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)}}},Fl=ld;Fl._vector=new cd.Vector3;function uI(n,r){n.shadow.camera.right=r/2,n.shadow.camera.left=-r/2,n.shadow.camera.top=r/2,n.shadow.camera.bottom=-r/2,n.shadow.needsUpdate=!0}var Is=class extends Cs(Ul.DirectionalLight,As){constructor(r,e,t){super(),this.super_Entity(r,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 Ul.CameraHelper(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof Ul.CameraHelper&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e);let t=r.depth!==void 0&&r.depth!==this.shadow.camera.far||r.size!==void 0&&r.size/2!==this.shadow.camera.right;r.size!==void 0&&uI(this,r.size),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),r.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t&&this.update()}};var yv=require("three");var Wr=require("three");var Hb=new Wr.Vector3,Wb=new Wr.Vector3,qb=new Wr.Quaternion,Ns=class extends Cs(Wr.SpotLight,Fl){constructor(r,e,t){super(),this.super_Entity(r,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 r in this.gizmos){let e=this.gizmos[r];e instanceof Wr.CameraHelper&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),Wb.setFromMatrixPosition(this.matrixWorld),qb.setFromRotationMatrix(this.matrixWorld),Hb.copy(this.up).applyQuaternion(qb).negate().multiplyScalar(this.distance),this.target.position.copy(Wb).add(Hb),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.angle!==void 0&&(this.angle=r.angle),r.penumbra!==void 0&&(this.penumbra=r.penumbra),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};function dI(n){let r=(n[0][0]+n[1][1])/2,e=(n[0][0]-n[1][1])/2,t=(n[1][0]+n[0][1])/2,o=(n[1][0]-n[0][1])/2,i=Math.sqrt(r*r+o*o),a=Math.sqrt(e*e+t*t),s=i+a,l=i-a,c=Math.atan2(t,e),u=Math.atan2(o,r),p=(u-c)/2,d=(u+c)/2,h=[[Math.cos(d),Math.sin(d)],[-Math.sin(d),Math.cos(d)]],f=[[s,0],[0,l]],m=[[Math.cos(p),Math.sin(p)],[-Math.sin(p),Math.cos(p)]];return h[0][0]*=-1,h[0][1]*=-1,m[0][0]*=-1,m[1][0]*=-1,[h,f,m]}function ud(n,r){return[[n[0][0]*r[0][0]+n[0][1]*r[1][0],n[0][0]*r[0][1]+n[0][1]*r[1][1]],[n[1][0]*r[0][0]+n[1][1]*r[1][0],n[1][0]*r[0][1]+n[1][1]*r[1][1]]]}function $b(n){return[[n[0][0],n[1][0]],[n[0][1],n[1][1]]]}function Yb(n){let[r,e,t]=dI(n),o=ud(r,$b(t)),i=ud(ud(t,e),$b(t)),a=Math.atan2(o[1][0],o[0][0]),s=[i[0][0],i[1][1]],l=[i[0][1]/i[1][1],i[1][0]/i[0][0]];return{rotation:a,scale:s,shear:l}}function Xb({rotation:n,scale:r,shear:e}){let t=Math.cos(n),o=Math.sin(n),i=[[t,-o],[o,t]],a=[[r[0],e[0]*r[1]],[e[1]*r[0],r[1]]],s=ud(i,a);return[s[0][0],s[1][0],s[0][1],s[1][1]]}var He;(S=>{function n(){return[1,0,0,0,1,0,0,0,1]}S.identity=n;function r(T,I=S.identity()){for(let x=0,_=T.length;x<_;x++)I[x]=T[x];return I}S.copy=r;function e(T,I,x,_,D,A){return S.setAbcdef(S.identity(),T,I,x,_,D,A)}S.create=e;function t(T,I,x,_,D,A,N){return T[0]=I,T[1]=_,T[2]=A,T[3]=x,T[4]=D,T[5]=N,T}S.setAbcdef=t;function o(T,I){let[x,_,D,A,N,E]=a(T),[B,V,j,R,W,F]=a(I),k=B*x+V*D,H=B*_+V*A,$=j*x+R*D,J=j*_+R*A,Z=W*x+F*D+N,X=W*_+F*A+E;return S.create(k,H,$,J,Z,X)}S.append=o;function i(T,I){let[x,_,D,A,N,E]=a(T),[B,V,j,R,W,F]=a(I),k=x,H=_,$=D,J=A;(B!==1||V!==0||j!==0||R!==1)&&(k=x*B+_*j,H=x*V+_*R,$=D*B+A*j,J=D*V+A*R);let Z=N*B+E*j+W,X=N*V+E*R+F;return S.create(k,H,$,J,Z,X)}S.prepend=i;function a(T){return[T[0],T[3],T[1],T[4],T[2],T[5]]}S.getAbcdef=a;function s(T){let[I,x,_,D,A,N]=S.getAbcdef(T),E=I*D-x*_,B=D/E,V=-x/E,j=-_/E,R=I/E,W=(_*N-D*A)/E,F=-(I*N-x*A)/E;return S.create(B,V,j,R,W,F)}S.invert=s;function l([T,I],x){let[_,D,A,N,E,B]=S.getAbcdef(x);return[_*T+A*I+E,D*T+N*I+B]}S.apply=l;function c(T,I){let[x,_,D,A,N,E]=S.getAbcdef(I),B=1/(x*A+D*-_),[V,j]=T;return[A*B*V+-D*B*j+(E*D-N*A)*B,x*B*j+-_*B*V+(-E*x+N*_)*B]}S.applyInverse=c;function u(T,I,x=I){let[_,D,A,N,E,B]=S.getAbcdef(T);return S.setAbcdef(T,_*I,D*x,A*I,N*x,E*I,B*x),T}S.scale=u;function p(T,I){let x=Math.cos(I),_=Math.sin(I),[D,A,N,E,B,V]=S.getAbcdef(T);return S.setAbcdef(T,D*x-A*_,D*_+A*x,N*x-E*_,N*_+E*x,B*x-V*_,B*_+V*x),T}S.rotate=p;function d(T,I,x){let[_,D]=x,A=S.translate(T,-_,-D);return A=S.rotate(A,I),A=S.translate(A,_,D),A}S.rotateAround=d;function h(T,I,x){let[_,D,A,N,E,B]=S.getAbcdef(T);return S.setAbcdef(T,_,D,A,N,E+I,B+x),T}S.translate=h;function f(T,I,x){let[_,D,A,N]=S.getAbcdef(T);return S.setAbcdef(T,_,D,A,N,I,x),T}S.setTranslate=f;function m(T,I,x){let[_,D,A,N]=S.getAbcdef(T);return S.setAbcdef(T,_,D,A,N,I,x),T}S.setPosition=m;function y(T){let[I,x,_,D]=S.getAbcdef(T),A=Math.sqrt(I*I+x*x),N=Math.sqrt(_*_+D*D);return[A,N]}S.getScale=y;function g(T){let[,,,,I,x]=S.getAbcdef(T);return[I,x]}S.getPosition=g;function v(T,I){return S.decompose(T,I).rotation}S.getRotation=v;function O(T,I){let[x,_,D,A,N,E]=S.getAbcdef(T),{rotation:B,scale:V,shear:j}=Yb([[x,D],[_,A]]);return{position:[N+(I[0]*x+I[1]*D)-I[0],E+(I[0]*_+I[1]*A)-I[1]],scale:V,rotation:B,shear:j,pivot:I}}S.decompose=O;function P(T,I,x,_,D=[0,0]){let[A,N]=T,[E,B]=_,[V,j,R,W]=Xb({rotation:x,scale:I,shear:D}),F=A-(E*V+B*R)+E,k=N-(E*j+B*W)+B;return S.create(V,j,R,W,F,k)}S.compose=P})(He||(He={}));var pI=Math.PI/180,tZ=180/Math.PI;function Kb(n,r,e,t,o,i){let a=n-e,s=r-t;return a*a/(o*o)+s*s/(i*i)<=1}function Qb(n){return n*pI}function oh(n){return{all:n=n||new Map,on:function(r,e){var t=n.get(r);t?t.push(e):n.set(r,[e])},off:function(r,e){var t=n.get(r);t&&(e?t.splice(t.indexOf(e)>>>0,1):n.set(r,[]))},emit:function(r,e){var t=n.get(r);t&&t.slice().map(function(o){o(e)}),(t=n.get("*"))&&t.slice().map(function(o){o(r,e)})}}}var sn=class{constructor(r,e,t){this.uuid=r;this.data=e;this.localMatrix=He.identity();this.worldMatrix=He.identity();this.ignoreCameraZoom=!1;this.visible=!0;this._singleBBox=new Un;this._recursiveBBox=new Un;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.shear=[0,0];this.emitter=oh();this.dpr=t.dpr??1,this.dataPatched=e}project(r,e){let t=this.worldMatrix;return e&&(t=He.append(e.worldMatrix,t)),He.applyInverse(r,t)}intersects(r,e,t,o=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([r,e],t),o)}intersectsInLocalSpace(r,e,t=!1){let{min:o,max:i}=t?this.recursiveBBox:this.singleBBox;return r>=o[0]&&r<=i[0]&&e>=o[1]&&e<=i[1]}applyTransforms(r){r.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=He.compose(this.position,this.scale,Qb(this.rotation),Xo.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(r,e,t){let o=this.parent;e&&o!==null&&o!==void 0&&o.updateWorldMatrix(r,!0,!1),r&&this.updateLocalMatrix(),this.parent?this.worldMatrix=He.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=He.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return Xo.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(r=>{r.resetBBoxNeedsUpdateSelf()})}updateTransformState(r){let e=!1;r.position!==void 0&&(e=!0,this.position=r.position),r.rotation!==void 0&&(e=!0,this.rotation=r.rotation),r.scale!==void 0&&(e=!0,this.scale=r.scale),r.shear!==void 0&&(e=!0,this.shear=r.shear),e&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(r,e,t){r.type===0&&r.props.visible!==void 0&&(this.visible=r.props.visible),this.data=e,this.data=e;let o=r,i=Ge(r.path,["states","*"]);if(i!==null){if(r.type===0){let[a]=i;if(this?.stateSelection===a){let s={...r.props};if(delete s.name,Object.values(r.props).some(l=>l===void 0)){let l=this.data;if(l!==void 0){let c=mt.zoom(l,r.path.slice(2));if(c)for(let u in r.props)r.props[u]===void 0&&u in c&&(s[u]=c[u])}}o={...r,props:s,path:r.path.slice(2)}}}}else if(r.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(r.props.name!==void 0&&a.name){let{name:l,...c}=a;a=c}let s=mt.removeOverridden(r.path,r.props,a);o={...r,props:s}}}this.updateByPatchedOpBase(o,li.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),t)}changeSelectedState(r,e,t=!1){if(!(this.data.states.length===0&&!t)){for(let o of this.data.states)li.toOps(this.data,o.data).forEach(a=>{let s=ia.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,e)});if(r!==null){let o=this.data.states.data(r);o&&(this.dataPatched=li.patch(this.data,o),li.toOps(this.data,o).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,e)}))}t&&this.updateTransformState(this.dataPatched),this.stateSelection=r}}updateState(r,e){r.name!==void 0&&(this.name=r.name),r.visible!==void 0&&(this.visible=r.visible),this.updateTransformState(r)}updateByPatchedOpBase(r,e,t){this.dataPatched=e,this.updateByPatchedOp(r,e,t)}updateByPatchedOp(r,e,t){r.path.length===0&&r.type===0&&this.updateState(r.props,t),this.requestRender()}traverseFrameAncestors(r){this.traverseAncestors(e=>{e.data.type==="frame2d"&&r(e)})}traverseAncestors(r){let e=this.parent;for(;e;)r(e),e=e.parent}requestRender(){this.traverseFrameAncestors(r=>{r.requestRender()})}clone(r){let e=new sn(this.uuid,this.data,r);return e.parent=void 0,e}addEventListener(r,e){this.emitter.on(r,e)}removeEventListener(r,e){this.emitter.off(r,e)}dispatchEvent(r){this.emitter.emit(r.type,{...r,target:r.target??this})}traverseSortNextHelper(){let r=this.parent;if(r){let e=r.children;if(e){let t=e.indexOf(this)+1;return e[t]?e[t]:r.traverseSortNextHelper()}}}sortNext(){let r=this.children;return r&&r.length>0&&r[0]?r[0]:this.traverseSortNextHelper()}isDescendantOf(r){r instanceof sn&&(r=r.uuid);let e=this;for(;e.parent;){if(e.parent.uuid===r)return!0;e=e.parent}return!1}};var ir=class extends sn{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.context=o;this.children=[]}add(e){e.parent&&e.parent instanceof ir&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let t=this.children.indexOf(e);t>=0&&(this.children.splice(t,1),e.parent=void 0)}traverse(e){let t=e(this);if(t!==!0)for(let o of this.children)o instanceof ir?o.traverse(e):t=e(o)}intersectsChildren(e,t,o,i=!1,a=[],s=!1){for(let l of this.children){let c=l instanceof fr;if(l instanceof ir&&!c&&s&&l.intersectsChildren(e,t,o,i,a,!1),l.intersects(e,t,o,c)&&(a.push(l),i))break}return a}updateWorldMatrix(e,t,o){if(super.updateWorldMatrix(e,t,o),o&&this.children)for(let i of this.children)i.updateWorldMatrix(e,!1,!0)}find(e){let t;return this.traverse(o=>{o.uuid===e&&(t=o)}),t}innerDrawChildren(e){for(let t=this.children.length-1;t>=0;t--)this.children[t].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let t=new ir(this.uuid,this.data,e);t.parent=void 0;for(let o of this.children)t.add(o.clone(e));return t}},fr=class extends ir{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.updateState(t,o)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let t=new fr(this.uuid,this.data,e);t.parent=void 0;for(let o of this.children)t.add(o.clone(e));return t}};function fI(n,r){let[[e,t],[o,i]]=n,[[a,s],[l,c]]=r,u=(e-o)*(s-c)-(t-i)*(a-l);if(u===0)return!1;let p=((e-a)*(s-c)-(t-s)*(a-l))/u,d=-((e-o)*(t-s)-(t-i)*(e-a))/u;return p>=0&&p<=1&&d>=0&&d<=1}var Jb=[[-1,1],[-1,-1],[1,-1],[1,1]],Zb=(n,r,e)=>{let t=n.getCenter(),o=n.getHalfSize(),i=He.append(r,n.worldMatrix);o[0]===0&&o[1]===0?e.push(He.apply(t,i)):Jb.forEach(a=>{let s=[a[0]*o[0]+t[0],a[1]*o[1]+t[1]];e.push(He.apply(s,i))})},Un=class{constructor(){this.matrix=He.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(r,e=!1){r.updateWorldMatrix(),this.makeEmpty(),He.copy(r.worldMatrix,this.matrix);let t=He.invert(r.worldMatrix);this.expandByObjectSize(r,t,e)}expandByObjectSize(r,e,t=!1){let o=[];t===!0&&r instanceof ir?r.traverse(i=>{i.visible&&Zb(i,e,o)}):Zb(r,e,o),this.setFromPoints(o)}getCenter(){let[r,e]=this.min,[t,o]=this.getHalfSize();return He.apply([r+t,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(r){this.makeEmpty();for(let e of r)this.expandByPoint(e)}expandByPoint(r){this.min=[Math.min(this.min[0],r[0]),Math.min(this.min[1],r[1])],this.max=[Math.max(this.max[0],r[0]),Math.max(this.max[1],r[1])]}computeVertices(){let[r,e]=this.getHalfSize(),t=this.getCenter(),[o,i,a,s]=He.getAbcdef(this.matrix),l=He.create(o,i,a,s,t[0],t[1]);this.vertices=Jb.map(([c,u])=>He.apply([c*r,u*e],l))}computeEdges(){this.edges=[];for(let r=0,e=this.vertices.length;r<e;++r)this.edges.push([this.vertices[r],this.vertices[(r+1)%e]])}project(r,e){let t=this.matrix;return e&&(t=He.append(e.worldMatrix,t)),He.applyInverse(r,t)}intersects(r,e,t){return this.intersectsInLocalSpace(...this.project([r,e],t))}intersectsInLocalSpace(r,e){let{min:t,max:o}=this;return r>=t[0]&&r<=o[0]&&e>=t[1]&&e<=o[1]}containsPoint(r){let[e,t]=r,[o,i]=this.min,[a,s]=this.max;return e>=o&&e<=a&&t>=i&&t<=s}intersectsBBox2D(r){for(let e=0,t=this.edges.length;e<t;e++){let o=this.edges[e];for(let i=0,a=r.edges.length;i<a;i++){let s=r.edges[i];if(fI(o,s))return!0}}for(let e=0,t=r.vertices.length;e<t;e++){let o=r.vertices[e];if(this.containsPoint(o))return!0}return!1}ensureMinMax(){let r=this.min,e=this.max;this.min=[Math.min(r[0],e[0]),Math.min(r[1],e[1])],this.max=[Math.max(r[0],e[0]),Math.max(r[1],e[1])]}copy(r){this.min=[...r.min],this.max=[...r.max],He.copy(r.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let r=new Un;return r.copy(this),r}};var tv,rv=new Promise(n=>{tv=n}),ev=!1;var dd;function ov(){if(ev)return;if(dd)return dd;async function n(){let e=await import("./ui.js");tv(e.default??e),ev=!0}return dd=n(),dd}function av(n){let r=!1;return n.scene.objects.traverse((e,t)=>{(t.type==="Mesh"&&t.geometry.type==="UIGeometry"||t.type==="Page"&&t.uiFrame!==void 0)&&(r=!0)}),r}var Ae,nh;async function hI(n){let r=await rv;Ae||(nh||(nh=r({locateFile:()=>n})),Ae=await nh)}var nv=He.identity(),Hl=class{constructor(r,e=1){this.canvas=r;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=_e.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=_e.transparent;this._fonts=new Map;try{let t=r.getBoundingClientRect();r.width=t.width*e,r.height=t.height*e}catch{console.log(r.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 hI(this.wasmURL),this._surface=Ae.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas(),this._paint=new Ae.Paint,this._paint.setAntiAlias(!0),this._paintFill=this._paint.copy(),this._paintFill.setStyle(Ae.PaintStyle.Fill),this._paintStroke=this._paint.copy(),this._paintStroke.setStyle(Ae.PaintStyle.Stroke),this.ctx?.scale(this.dpr,this.dpr)}get currentTransform(){return this._currentM3Transform}get currentTransformBuffer(){return this._currentTransform}set currentTransform(r){this._currentM3Transform=r,this._currentTransform.set(r)}async loadFont(r,e){let t=await(await fetch(r)).arrayBuffer();this.registerFont(t,e)}registerFont(r,e){if(this._fonts.has(e))return;let t=Ae.FontMgr.FromData(r);if(t)this._fonts.set(e,t);else throw new Error("Invalid font data for "+e)}get width(){return this._width}get height(){return this._height}set strokeColor(r){this._paintStroke&&this._paintStroke.setColor(pd(r),Ae.ColorSpace.DISPLAY_P3)}set fillColor(r){this._paintFill&&this._paintFill.setColor(pd(r),Ae.ColorSpace.DISPLAY_P3)}set lineWidth(r){this._paintStroke&&this._paintStroke.setStrokeWidth(this._strokeMode==="center"?r:r*2)}set strokeMode(r){this._strokeMode=r}set dropShadowBlur(r){this._dropShadowBlur=r}set dropShadowColor(r){this._dropShadowColor=r}set dropShadowOffsetX(r){this._dropShadowOffsetX=r}set dropShadowOffsetY(r){this._dropShadowOffsetY=r}set innerShadowBlur(r){this._innerShadowBlur=r}set innerShadowColor(r){this._innerShadowColor=r}set innerShadowOffsetX(r){this._innerShadowOffsetX=r}set innerShadowOffsetY(r){this._innerShadowOffsetY=r}set innerShadowSpread(r){this._innerShadowSpread=r}set layerBlur(r){this._layerBlur=r}set backgroundBlur(r){this._backgroundBlur=r}clear(){this.ctx?.clear(Ae.TRANSPARENT)}save(){this.ctx?.save()}restore(){this.ctx?.restore()}beginPath(){this._currentPath?.delete(),this._currentPath=new Ae.Path}closePath(){let r=this._currentPath;if(r){if(r.isEmpty())return;let e=r.getBounds();(e[3]-e[1]||e[2]-e[0])&&r.close()}}fill(){this._paintInner(this._paintFill,!0)}stroke(){this._paintInner(this._paintStroke,!1)}clipRect(r,e,t,o,i=0,a=0,s=0,l=0){let c=Ae.XYWHRect(r,e,t,o);if(i===0&&a===0&&l===0&&s===0)this.ctx?.clipRect(c,Ae.ClipOp.Intersect,!0);else{let u=Ae.RRectXY(c,i,i);u[4]=u[5]=i,u[6]=u[7]=a,u[8]=u[9]=s,u[10]=u[11]=l,this.ctx?.clipRRect(u,Ae.ClipOp.Intersect,!0)}}_applyShadowOffsetMatrix(){if(this.ctx){let r=He.invert(this.currentTransform);this.ctx.concat(r);let e=He.translate(He.identity(),this._dropShadowOffsetX,this._dropShadowOffsetY);this.ctx.concat(e),this.ctx.concat(this._currentTransform)}}_applyEffectsToPaint(r,e,t=!0){if(this.ctx&&this._currentPath){let o,i=!1;if(t&&this._hasDropShadow()){let a=r.copy();a.setColor(pd(this._dropShadowColor));let s;this._dropShadowBlur>0&&(s=Ae.MaskFilter.MakeBlur(Ae.BlurStyle.Normal,this._dropShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s)),this.ctx.save(),this.ctx.clipPath(this._currentPath,Ae.ClipOp.Difference,!0),this._applyShadowOffsetMatrix(),e(a),this.ctx.restore(),a.delete(),s?.delete()}if(this._backgroundBlur>0&&t){this.ctx.save(),this.ctx.clipPath(this._currentPath,Ae.ClipOp.Intersect,!0);let a=Ae.ImageFilter.MakeBlur(this._backgroundBlur,this._backgroundBlur,Ae.TileMode.Clamp,null),s=r.copy();s.setImageFilter(a),s.setAlphaf(1);let l=this._currentPath.computeTightBounds();this.ctx.saveLayer(s,l,null,Ae.SaveLayerInitWithPrevious),this.ctx.drawColor(r.getColor()),this.ctx.restore(),this.ctx.restore(),s.delete(),a.delete(),i=!0}if(this._layerBlur>0){let a=r.copy();o=Ae.MaskFilter.MakeBlur(Ae.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(r),t&&this._hasInnerShadow()){let a=new Ae.Paint;a.setAntiAlias(!0),a.setStyle(Ae.PaintStyle.Fill),a.setColor(pd(this._innerShadowColor));let s;this._innerShadowBlur>0&&(s=Ae.MaskFilter.MakeBlur(Ae.BlurStyle.Normal,this._innerShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s));let l=this._currentPath.computeTightBounds(),[c,u,p,d]=l,h=p-c,f=d-u;this.ctx.save(),this.ctx.clipPath(this._currentPath,Ae.ClipOp.Intersect,!0),this.ctx.saveLayer(a,l,null,Ae.SaveLayerInitWithPrevious),this.ctx?.translate(this._innerShadowOffsetX,this._innerShadowOffsetY),this.ctx.drawRect(Ae.XYWHRect(-1e3-this._innerShadowOffsetX,-1e3-this._innerShadowOffsetY,2e3+h+Math.abs(this._innerShadowOffsetX*2),2e3+f+Math.abs(this._innerShadowOffsetY*2)),a),a.setBlendMode(Ae.BlendMode.Clear),this.ctx.drawPath(this._currentPath,a),this.ctx.restore(),this.ctx.restore(),a.delete(),s?.delete()}}}_paintInner(r,e=!0){if(this.ctx&&this._currentPath&&r){let t=this.ctx,o=this._currentPath;this._applyEffectsToPaint(r,i=>{let a=!1;!e&&this._strokeMode!=="center"&&(t.save(),t.clipPath(o,this._strokeMode==="outside"?Ae.ClipOp.Difference:Ae.ClipOp.Intersect,!0),a=!0),t.drawPath(o,i),a&&t.restore()},e)}}_hasDropShadow(){return this._dropShadowColor?.a>0}_hasInnerShadow(){return this._innerShadowColor?.a>0}path(r){this._currentPath?.addPath(Ae.Path.MakeFromSVGString(r))}ellipse(r,e,t,o,i,a,s,l){if(!iv([r,e,t,o])||!this._currentPath)return;if(t<0||o<0)throw Error("radii cannot be negative");let c=Ae.XYWHRect(r-t,e-o,t*2,o*2);this._currentPath?.addOval(c)}rect(r,e,t,o,i=0,a=0,s=0,l=0){let c=Ae.XYWHRect(r,e,t,o);if(!!iv(c))if(i===0&&a===0&&l===0&&s===0)this._currentPath?.addRect(c);else{let u=Ae.RRectXY(c,i,i);u[4]=u[5]=i,u[6]=u[7]=a,u[8]=u[9]=s,u[10]=u[11]=l,this._currentPath?.addRRect(u)}}getHorizontalAlign(r){switch(r){case 2:return Ae.TextAlign.Right;case 3:return Ae.TextAlign.Center;case 4:return Ae.TextAlign.Justify;case 1:default:return Ae.TextAlign.Left}}drawTextInner(r,e,t,[o,i,a,s],l,c,u=!0){let p=0,{ctx:d}=this;if(!d)return p;let h=c.copy(),f=c.copy();return f.setAlphaf(0),this._applyEffectsToPaint(h,m=>{e.pushPaintStyle(t,m,f),e.addText(r);let y=e.build();y.layout(a);let g=i;l===2?g+=(s-y.getHeight())/2:l===3&&(g+=s-y.getHeight()),d.drawParagraph(y,o,g),p=y.getHeight(),e.reset(),y.delete()},u),h.delete(),f.delete(),p}drawText(r,e){let t=0,o=this._fonts.get(e.font),{ctx:i,_paintFill:a,_paintStroke:s}=this;if(o&&i){let l=new Ae.TextStyle({fontFamilies:[e.font],fontSize:e.fontSize,heightMultiplier:e.lineHeight,letterSpacing:e.letterSpacing}),c=new Ae.ParagraphStyle({textStyle:l,textAlign:this.getHorizontalAlign(e.horizontalAlign)}),u=Ae.XYWHRect(e.x,e.y,e.width,e.height),p=Ae.ParagraphBuilder.Make(c,o);a&&(t=this.drawTextInner(r,p,l,u,e.verticalAlign,a,!0)),s&&(t=this.drawTextInner(r,p,l,u,e.verticalAlign,s,!1)),p.delete()}return{height:t}}render(){this._surface?.flush()}moveTo(r,e){this._currentPath?.moveTo(r,e)}lineTo(r,e){this._currentPath?.lineTo(r,e)}bezierCurveTo(r,e,t,o,i,a){this._currentPath?.cubicTo(r,e,t,o,i,a)}quadraticCurveTo(r,e,t,o){this._currentPath?.quadTo(r,e,t,o)}setTransform(r,e=!1){if(!this.ctx)return;let t=this.ctx.getTotalMatrix(),o=He.invert(t);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=He.getScale(this.camera.worldMatrix);this.ctx?.scale(1/i[0],1/i[1])}this.ctx?.concat(r),this.currentTransform=r}transform(r){this.ctx?.concat(r)}setSize(r,e){r===this._width&&e===this._height||(this._width=r,this._height=e,this.canvas.style.width=r+"px",this.canvas.style.height=e+"px",this.canvas.width=r*this.dpr,this.canvas.height=e*this.dpr,this._surface&&(this._surface=Ae.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas()))}};function iv(n){for(let r=0;r<n.length;r++)if(n[r]!==void 0&&!Number.isFinite(n[r]))return!1;return!0}function pd({r:n,g:r,b:e,a:t}){return Ae.Color4f(n,r,e,t)}var Wl=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.color=_e.transparent;this.blurRadius=0;this.offset=[0,0];this.spread=0;this.update(e)}update(r){r.color!==void 0&&(this.color=r.color),r.enabled!==void 0&&(this.enabled=r.enabled),r.blurRadius!==void 0&&(this.blurRadius=r.blurRadius),r.offset!==void 0&&(this.offset=r.offset),r.spread!==void 0&&(this.spread=r.spread)}};var ql=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.radius=0;this.update(e)}update(r){r.enabled!==void 0&&(this.enabled=r.enabled),r.radius!==void 0&&(this.radius=r.radius)}};var fd=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.color=_e.transparent;this.update(e)}update(r){r.enabled!==void 0&&(this.enabled=r.enabled),r.color!==void 0&&(this.color=r.color)}};var hd=class{constructor(r,e,t){this.uuid=r;this.data=e;this.enabled=!1;this.color=_e.transparent;this.thickness=0;this.mode="inside";this.update(e)}update(r){r.enabled!==void 0&&(this.enabled=r.enabled),r.color!==void 0&&(this.color=r.color),r.thickness!==void 0&&(this.thickness=r.thickness),r.mode!==void 0&&(this.mode=r.mode)}};var Or=class extends sn{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.autoClose=!0;this.fill=new fd(e+"-fill",t.fill,o),this.stroke=new hd(e+"-stroke",t.stroke,o),this.dropShadow=new Wl(e+"-dropShadow",t.dropShadow,o),this.innerShadow=new Wl(e+"-innerShadow",t.innerShadow,o),this.backgroundBlur=new ql(e+"-backgroundBlur",t.backgroundBlur,o),this.layerBlur=new ql(e+"-layerBlur",t.layerBlur,o)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:_e.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:_e.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=_e.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=_e.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,t,o){super.updateByPatchedOp(e,t,o),e.type===0&&(Ge(e.path,["fill"])?this.fill.update(e.props):Ge(e.path,["stroke"])?this.stroke.update(e.props):Ge(e.path,["dropShadow"])?this.dropShadow.update(e.props):Ge(e.path,["innerShadow"])?this.innerShadow.update(e.props):Ge(e.path,["layerBlur"])?this.layerBlur.update(e.props):Ge(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,t){super.updateState(e,t),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 t=new Or(this.uuid,this.data,e);return t.parent=void 0,t}};var kn=class extends Or{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.width=0;this.height=0;this.updateState(t,o)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,t){return Kb(e,t,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 t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e)}clone(e){let t=new kn(this.uuid,this.data,e);return t.parent=void 0,t}};var Lo=class extends Or{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.width=0;this.height=0;this.cornerRadius=[0,0,0,0];this.updateState(t,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 t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let t=new Lo(this.uuid,this.data,e);return t.parent=void 0,t}};var Hn=class extends Or{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this._textHeight=0;this._textHeightDirty=!0;this.width=0;this.height=0;this.updateState(t,o)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:_e.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:_e.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 t=this.data.textTransform,o=this.data.text.textValue.toString(),i=t===2?o.toUpperCase():t===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 t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:t}){e.font!==void 0&&(this._fontHolder=t.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateFontState(e,t)}clone(e){let t=new Hn(this.uuid,this.data,e);return t.parent=void 0,t}};var Ds=class extends Or{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this.curves=[];this.extremasBBox={min:[0,0],max:[0,0]};this.updateState(t,o)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(i=>md.extremas(i)),t=[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]<t[0]&&(t[0]=s[0][0]),s[0][1]<t[1]&&(t[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=[t[0],t[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,t=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let o={start:t.position,cp1:t.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(o)}}getCenter(){let[e,t]=this.extremasBBox.min,[o,i]=this.getHalfSize();return[e+o,t+i]}getHalfSize(){let{min:e,max:t}=this.extremasBBox;return[(t[0]-e[0])*.5,(t[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,c]=s.position;e.moveTo(l,c)}else{let l=this.data.points[i-1].data,[c,u]=l.controlNext.position,[p,d]=s.controlPrevious.position,[h,f]=s.position,m={start:l.position,cp1:l.controlNext.position,cp2:s.controlPrevious.position,end:s.position};md.derive(m),e.bezierCurveTo(c,u,p,d,h,f)}}let t=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]=t.controlPrevious.position,[c,u]=t.position;e.bezierCurveTo(i,a,s,l,c,u)}}updateState(e,t){super.updateState(e,t),this.computeExtremas()}clone(e){let t=new Ds(this.uuid,this.data,e);return t.parent=void 0,t}},md;(i=>{function n(a){let s=a.start,l=a.cp1,c=a.cp2,u=a.end,p=[3*(l[0]-s[0]),3*(l[1]-s[1])],d=[3*(c[0]-l[0]),3*(c[1]-l[1])],h=[3*(u[0]-c[0]),3*(u[1]-c[1])],f={start:p,cp:d,end:h};return a.derivative=f,f.derivative=ih.derive(f),f}i.derive=n;function r(a,s,l,c=!1){let u=a-2*s+l;if(u!==0){let p=-Math.sqrt(Math.abs(s*s-a*l)),d=-a+s,h=-(p+d)/u,f=-(-p+d)/u;return[h,f]}else if(s!==l&&u===0)return[(2*s-l)/(2*(s-l))];return[]}function e(a){let s=a.derivative??i.derive(a),l=s.start,c=s.cp,u=s.end;return[r(l[0],c[0],u[0]),r(l[1],c[1],u[1])]}i.droot=e;function t(a){let[s,l]=i.droot(a),c=[a.start[0],a.end[0]],u=[a.start[1],a.end[1]];for(let p of s)c.push(i.compute(a,Math.min(1,Math.max(0,p)))[0]);for(let p of l)u.push(i.compute(a,Math.min(1,Math.max(0,p)))[1]);return c.sort((p,d)=>p-d),u.sort((p,d)=>p-d),[[c[0],u[0]],[c[c.length-1],u[u.length-1]]]}i.extremas=t;function o(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let l=1-s,c=l*l,u=s*s,p=c*l,d=c*s*3,h=l*u*3,f=s*u;return[p*a.start[0]+d*a.cp1[0]+h*a.cp2[0]+f*a.end[0],p*a.start[1]+d*a.cp1[1]+h*a.cp2[1]+f*a.end[1]]}i.compute=o})(md||(md={}));var ih;(t=>{function n(o){let i=o.start,a=o.cp,s=o.end,l=[2*(a[0]-i[0]),2*(a[1]-i[1])],c=[2*(s[0]-a[0]),2*(s[1]-a[1])],u={start:l,end:c};return u.derivative=ah.derive(u),o.derivative=u,u}t.derive=n;function r(o){let i=o.derivative??t.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]}t.droot=r;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,c=s,u=a*i*2,p=l;return[c*o.start[0]+u*o.cp[0]+p*o.end[0],c*o.start[1]+u*o.cp[1]+p*o.end[1]]}t.compute=e})(ih||(ih={}));var ah;(e=>{function n(t){let o=t.start,i=t.end,a=[i[0]-o[0],i[1]-o[1]];return t.derivative=a,t.derivative}e.derive=n;function r(t,o){if(o===0)return[...t.start];if(o===1)return[...t.end];let i=t.start,a=t.end;return[i[0]+(a[0]-i[0])*o,i[1]+(a[1]-i[1])*o]}e.compute=r})(ah||(ah={}));var _r=class extends ir{constructor(e,t,o){super(e,t,o);this.uuid=e;this.width=0;this.height=0;this.clipped=!0;this.background=new Lo(e+"-background",wa.defaultData,o),this.background.parent=this,this.updateState(t,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,t,o){super.updateWorldMatrix(e,t,o),this.background?.updateWorldMatrix(e,t,o)}draw(e){if(!this.visible)return;e.save();let t=this.width,o=this.height;this.applyTransforms(e),this.background.width=t,this.background.height=o,this.background.draw(e),this.clipped&&e.clipRect(0,0,t,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 t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),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),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.type===0&&(Ge(e.path,["fill"])?this.fill.update(e.props):Ge(e.path,["stroke"])?this.stroke.update(e.props):Ge(e.path,["dropShadow"])?this.dropShadow.update(e.props):Ge(e.path,["innerShadow"])?this.innerShadow.update(e.props):Ge(e.path,["layerBlur"])?this.layerBlur.update(e.props):Ge(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let t=new _r(this.uuid,this.data,e);t.parent=void 0;for(let o of this.children)t.add(o.clone(e));return t}};var uv=Ei(sh(),1),ln=class extends Or{constructor(e,t,o){super(e,t,o);this.uuid=e;this.data=t;this._pathBBox=new DOMRect;this.path="";this.updateState(t,o),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg"),t=document.createElementNS("http://www.w3.org/2000/svg","path");document.body.appendChild(e),t.setAttribute("d",this.path),e.appendChild(t),this._pathBBox=t.getBBox(),e.remove()}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,t){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&t>=this._pathBBox.y&&t<=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,t){super.updateState(e,t),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let t=new ln(this.uuid,this.data,e);return t.parent=void 0,t}};function dv(n,r=1,e=1){if(r<=0||e<=0)return n;let o=(0,uv.parseSVG)(n).map(i=>{let a={...i};return"x"in a&&(a.x=a.x*r),"y"in a&&(a.y=a.y*e),"x1"in a&&(a.x1=a.x1*r),"x2"in a&&(a.x2=a.x2*r),"y1"in a&&(a.y1=a.y1*e),"y2"in a&&(a.y2=a.y2*e),"rx"in a&&(a.rx=a.rx*r),"ry"in a&&(a.ry=a.ry*e),a});return pv(o)}function pv(n){let r=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],e;return n.map(t=>{let o=[];r.forEach(a=>{if(a in t){let s=t[a]*1;o.length&&s>=0&&o.push(","),o.push(s)}});let i=(e===t.code?o[0]<0?"":",":t.code)+o.join("");return e=t.code,i}).join("")}function fv(n,r,e){switch(r.type){case"ellipse2d":return new kn(n,r,e);case"rectangle2d":return new Lo(n,r,e);case"text2d":return new Hn(n,r,e);case"vector2d":return new Ds(n,r,e);case"path2d":return new ln(n,r,e);case"frame2d":return new _r(n,r,e);case"group2d":default:return new fr(n,r,e)}}var lh=class{constructor(r,e,t){this.uuid=r;this.data=e;this.group=new fr(lh.GROUP_ID,{...rl.defaultData},t),this.createChildrenObjects(e.objects,this.group,t)}createObject(r,e,t,o,i,a){let s=fv(r,e,a);s&&(o.add(s),o.children.splice(i,0,o.children.pop()),s.updateWorldMatrix(),t.length>0&&(s instanceof fr||s instanceof _r)&&this.createChildrenObjects(t,s,a))}createChildrenObjects(r,e,t){let o=0;for(let i of r)this.createObject(i.id,i.data,i.children,e,o,t),o+=1}draw(r){this.group.draw(r)}updateEntityByOp(r,e,t,o){let i=this.find(r);if(i)try{i.updateByOp(e,t,{shared:o})}catch(a){console.error(a)}}updateTreeByOp(r,e){if(r.path.length===0&&r.type===7){let t=r.parent===null?this.group:this.find(r.parent);t!==void 0&&t instanceof ir&&(this.createObject(r.id,r.data,r.children,t,r.localIndex,e),t.requestRender())}else if(r.path.length===0&&r.type===8){let t=this.find(r.id);if(t!==void 0&&t.parent!==void 0&&t.parent instanceof ir){let o=t.parent;t.resetBBoxNeedsUpdate(),o?.remove(t),o?.requestRender()}}else if(r.path.length===0&&r.type===9){let t=this.find(r.id);if(t!==void 0){let o=t.parent,i=r.parent===null?this:this.find(r.parent);if(i===void 0&&!1&&console.error("unexpected",i,r),i instanceof ir||i===this){i.add(t);let a=r.localIndex;i.children.splice(a,0,i.children.pop()),t.updateWorldMatrix(!0,!1,!0),o?.requestRender(),t.requestRender()}t.resetBBoxNeedsUpdate()}}}add(r){this.group.add(r)}remove(r){this.group.remove(r)}traverse(r){this.group.traverse(e=>{e!==this.group&&r(e)})}intersectsChildren(r,e,t,o=!1,i=[]){return this.group.intersectsChildren(r,e,t,o,i,!0)}find(r){return this.group.find(r)}get children(){return this.group.children}project(r,e){return this.group.project(r,e)}getWithSortKey(r){let e=this.find(r);if(e===void 0)return;let t=[],o=e;for(;o!==this.group;){let i=o;o=o.parent;let a=o.children.indexOf(i);t.splice(0,0,a)}return{entity:e,sortKey:t}}getAllSorted(r){let e=[];for(let t of r){let o=this.getWithSortKey(t.id);o!==void 0&&e.push(o)}return e.sort((t,o)=>oc(t.sortKey,o.sortKey)),e.map(t=>t.entity)}},Ci=lh;Ci.GROUP_ID="scene2d";function ch({constraints:n,newParentWidth:r,newParentHeight:e,initialParentWidth:t,initialParentHeight:o,objectInitialWidth:i,objectInitialHeight:a,objectInitialPosition:s}){let{horizontalConstraint:l,verticalConstraint:c}=n,u=r-t,p=e-o,d=i,h=a,f=s[0],m=s[1];if(l!==0){if(l===1)f+=u;else if(l===3)f+=u/2;else if(l===2)d=Math.max(1,d+u);else if(l===4){let y=r/t;d*=y,f*=y}}if(c!==0){if(c===1)m+=p;else if(c===3)m+=p/2;else if(c===2)h=Math.max(1,h+p);else if(c===4){let y=e/o;h*=y,m*=y}}return{width:d,height:h,position:[f,m]}}var xI=Ei(sh(),1);var Dee={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 hv=require("three");var bI=He.identity(),Es=class{constructor(r,e,t,o){this.uuid=r;this.width=e;this.height=t;this.context=o;this.enabled=!0;this.isScreenSpace=!1;this.isFrameDirty=!1;this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.context.shared.requestRender()};this.onFrameOverrideObjectEvent=r=>{if(r.target?.uuid!==void 0){let e=this.frameRoot?.find(r.target.uuid);e&&e.dispatchEvent({...r,target:e})}};this.scene2d=new Ci(hv.MathUtils.generateUUID(),fu.defaultData,{dpr:window.devicePixelRatio,shared:o.shared}),this.canvas=document.createElement("canvas"),this.renderer=new Hl(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 Hl&&(this.renderer.wasmURL=Zx.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(r,e,t,o){this.scene2d.updateEntityByOp(r,e,t,o),this.applySize()}updateTreeByOp(r,e){this.scene2d.updateTreeByOp(r,e),this.applySize()}applyOverrides(r){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=r?.width??this.width,t=r?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=t,this.frameOverride.localMatrix=bI,this.isScreenSpace&&(this.frameOverride.fill.color=_e.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:t},mv({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(r){let e=r?.width??this.width,t=r?.height??this.height;this.width=e,this.height=t,this.renderer.dpr=this.isScreenSpace?window.devicePixelRatio:Math.floor(2048/Math.max(e,t)),this.renderer.setSize(e,t),this.textureHolder?.dispose(),this.applyOverrides(r),this.frameOverride?.requestRender()}applyFrame(r){let e=this.context.scene.find2D(r);if(!(!e||!(e instanceof _r)))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(t=>{t.addEventListener("beginState",this.onFrameOverrideObjectEvent)}),this.frameOverride.traverse(t=>{t.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(r){return this.scene2d.find(r)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(r=>{r.removeEventListener("beginStateChange",this.onFrameOverrideObjectEvent)}),this.frameOverride?.traverse(r=>{r.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function mv({objectOverride:n,objectRoot:r,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:i}){if(n instanceof _r&&r instanceof _r||n instanceof fr&&r instanceof fr)for(let a=0,s=n.children.length;a<s;a++){let l=n.children[a],c=r.children[a];l&&c&&l.uuid===c.uuid&&SI({objectOverride:l,objectRoot:c,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:i})}}function vI(n){if(uh(n))return[n.width,n.height];if(n instanceof ln){let[r,e]=n.getHalfSize();return[r*2,e*2]}else if(n instanceof fr){let[r,e]=n.recursiveBBox.getHalfSize();return[r*2,e*2]}return[0,0]}function SI({objectOverride:n,objectRoot:r,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:i}){let[a,s]=vI(r),{width:l,height:c,position:u}=ch({constraints:n.data,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:i,objectInitialWidth:a,objectInitialHeight:s,objectInitialPosition:r.position});if(n.position=u,n.data={...n.data,position:u},n.states)for(let p in n.states)wI({stateId:p,objectOverride:n,objectRoot:r,newParentWidth:e,newParentHeight:t,initialParentWidth:o,initialParentHeight:i});if(uh(n)||n instanceof fr)uh(n)&&(n.width=l,n.height=c,n.data={...n.data,width:l,height:c}),mv({objectOverride:n,objectRoot:r,newParentWidth:l,newParentHeight:c,initialParentWidth:a,initialParentHeight:s});else if(n instanceof ln){let p=r,d=a!==0?l/a:1,h=s!==0?c/s:1;n.path=dv(p.path,d,h),n.data={...n.data,path:n.path}}}function wI({stateId:n,objectOverride:r,objectRoot:e,newParentWidth:t,newParentHeight:o,initialParentWidth:i,initialParentHeight:a}){let s=r.states?.[n],l=e.states?.[n];if(s&&l){let{width:c,height:u,position:p}=ch({constraints:r.data,newParentWidth:t,newParentHeight:o,initialParentWidth:i,initialParentHeight:a,objectInitialWidth:Xo.isResizeable(l)?l.width:0,objectInitialHeight:Xo.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(r.states[n],{position:p}),Xo.isResizeable(s)&&Object.assign(r.states[n],{width:c,height:u})}}function uh(n){return n instanceof Lo||n instanceof _r||n instanceof kn||n instanceof Hn}var qr=class extends Aa(yv.Scene){constructor(e,t,o){super();this.data=t;this.bgColor=new jt(1,1,1,1);this.fog=null;this.backupFog=new _s.Fog(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new _s.Color;this.penumbraSizeArrayCache=null;this.super_Entity(e,t),this.personalCamera=new an(Sn,{...ai.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new _s.HemisphereLight(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),t.uiScene?this.uiScene=new Ci((Array.isArray(e)?e[0]:e)+"-ui",t.uiScene,{dpr:window.devicePixelRatio,shared:o.shared}):t.uiFrame&&this.createUICanvas(t.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,t){this.uiCanvas=new Es(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,t),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,t){e.color!==void 0&&(this.ambientLight.color=er(e.color,t)),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(t=>{t instanceof Pr&&t.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof wr)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&Fb(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,t){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=er(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=er(e.aoColor,t))}updateByOp(e,t,o,i){let a=this.data.uiFrame;super.updateByOp(e,t,o,i);let s=t;Ge(e.path,["fog"])?this.updateFog(s.fog,o.shared):Ge(e.path,["ao"])?this.updateAo(s.ao,o.shared):Ge(e.path,["ambient"])?this.updateAmbientLight(s.ambient,o.shared):Ge(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,t){e?(this.uiCanvas||this.createUICanvas(e,t),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(er(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,t){}raycast(e,t){super.raycast(e,t)}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,t=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+t]=o.data.penumbraSize,t+=1)})}raycastWithClones(e){let t=[],o=i=>{for(let a of i.children){let s=a.cloner;je.is(a)&&(a.visible||s?.object.data.visible)&&((jn(a)||jl(a)&&this.scene.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),$l(a,e,t,!0)),o(a))}};return o(this),t}updateEntity2DByOp(e,t,o,i){this.uiCanvas?.updateEntity2DByOp(e,t,o,i)}};var Cr=require("three");var gd=class extends Cs(Cr.PointLight,Ms){constructor(r,e,t){super(),this.super_Entity(r,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 Cr.Vector3(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new Cr.Vector3(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),l=new Cr.Box3(a,s),c=new Cr.Box3Helper(l,new Cr.Color(16755200));c.visible=!1,this.gizmos.shadowmap=c,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let r in this.gizmos){let e=this.gizmos[r];if(e instanceof Cr.Box3Helper){let t=this.shadow.camera,o=new Cr.Vector3(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),i=new Cr.Vector3(t.far+this.position.x,t.far+this.position.y,t.far+this.position.z);e.box.set(o,i),e.updateMatrixWorld(!0)}}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var xd=class extends bt{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?xl(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var Bs=class extends bt{constructor(e,t,o){super(e,t,o);this._shapeId=null;this._context=o}updateState(e,t){super.updateState(e,t),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 t;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),t=a.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let i;switch(e.type){case"Rectangle":i=za;break;case"Ellipse":i=La;break;case"Polygon":i=Iu;break;case"Star":i=Nu;break;default:throw new Error(`Unknown shape type: ${e.type}`)}t=i.create({parameters:e}).userData.shape}let o=this.geometry;t&&o.inputs&&(o.inputs.shapeData=t,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,t){return super.updateTransformState(e,t)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let o=this.geometry.getAttribute("position");o!==void 0?xl(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,t):super.updateEntityBoxSize(e,t)}};var Ls=require("three");var cn=class extends kr(Ls.Group,Hr){constructor(e,t,o){super();t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,o)),this.super_Entity(e,t),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,t){let o=ga.getComponentData({scene:t.scene.data,shared:t.shared.data},e.component);if(o){let i,a;for(let s of So.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]=mo.apply(o.data[s],e[s]));return this.overrideData=a,i}else return{...Rt.defaultData,...e,...Kr(Rt.defaultData,So.rootOverrideProps)}}updateByOp(e,t,o,i){let a;if(this.isInstanceRoot&&!i){if(t=this.transformAssignData(t,o),e.type===0&&e.path.length===0&&this.component)for(let s of So.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&&So.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:t[s]}})}}super.updateByOp(a??e,t,o,i)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){let o=e.scene.find(t.component)??null,i=!1;if(o!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(je.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),bd(s),a+=1;else break;this.children.splice(0,a)}i=!0}if(o){let a={};xv(e,[this.uuid],t.overrides,this,o,o,0,i,a);for(let s of this.children)if(je.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(c=>{if(c instanceof bt&&c.isSkinnedMesh){let u=c.dataPatched;if(u.bones&&u.boneInverses){let p=u.bones.map(f=>e.scene.find(a[f])),d=u.boneInverses.map(f=>new Ls.Matrix4().fromArray(f)),h=new Ls.Skeleton(p,d);c.bind(h,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function bd(n){if(n.component){let r=n.component.instances.indexOf(n);r>=0&&n.component.instances.splice(r,1);for(let e of n.children)je.is(e)&&bd(e)}}function gv(n,r,e,t){return n.component===r&&Xd(n.identity,t)?n.overrideData===e?2:1:0}function xv(n,r,e,t,o,i,a,s,l){if(a>50)return!1;if(t.component!==o){if(t.component){let u=t.component.instances.indexOf(t);u>=0&&t.component.instances.splice(u,1)}o.instances.find(u=>u===t)||o.instances.push(t),t.component=o}o instanceof cn&&o.isInstanceRoot&&o.expandInstanceChildren(n);let c=0;for(let u of o.children)if(je.is(u)){let p=[...r,...typeof u.identity=="string"?[u.identity]:u.identity],d=ma.resolve(e,p,1);if(d!=null&&!(d instanceof st)){if(!1)debugger;Object.setPrototypeOf(d,st.prototype),console.error("wrong prototype")}let h=null,f;if(!s){let m=t.children[c];if(h=je.is(m)?m:null,h!==null){let y=gv(h,u,d,p);f=y>=1?h.stateSelection:void 0,y!==2&&(h=null)}if(h===null&&(h=n.scene.findInstance(p)??null,h!==null)){let y=gv(h,u,d,p);if(f=y>=1?h.stateSelection:void 0,y!==2)h=null;else{let g=h.parent.children.indexOf(h);h.parent.children.splice(g,1),t.children.splice(c,0,h),h.parent===t?(g<=c&&console.error("not possible"),void 0):(h.parent=t,h.matrixWorldNeedsUpdate=!0,h.resetBBoxNeedsUpdate(),h.updateVisible(),n.pendingDeletes.delete(h),void 0)}}}if(h===null){let m=d?mo.apply(u.data,d):u.data;Qr.is(m.type)&&(m={...m,type:"Empty"}),h=eo.createEntity(p,m,n),h.overrideData=d,t.add(h),t.children.splice(t.children.length-1,1),t.children.splice(c,0,h),h.updateState(h.data,n),f&&h.changeSelectedState(f,n),n.scene.registerInstanceAndSetUuid(h)}if(h.isBone){let m=h.identity[h.identity.length-1];l[m]=h.uuid}c+=1,xv(n,r,e,h,u,i,a+1,s,l)}if(!s){let u=c;for(;;){let p=t.children[c];if(je.is(p))n.pendingDeletes.add(p);else break;c+=1}t.children.splice(u,c-u)}return!0}var bv=require("three");var vd=class extends kr(bv.Bone,Hr){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(r,e){this.updateState_Entity(r,e)}};var Ti=class extends bt{constructor(e,t,o){super(e,t,o);this.onBeforeRender=()=>{this.uiCanvas.render()};this.uiCanvas=new Es(e+"-canvas",t.geometry.width,t.geometry.height,o),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,o.shared)})}updateByPatchedOpGeometry(e,t,o){super.updateByPatchedOpGeometry(e,t,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,t){let o=e?.width??this.dataPatched.geometry.width,i=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:o,height:i}),this.applyGeometryParametersFromFrame(t)}applyFrame(e,t){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(t),this.applyMaterialParametersFromFrame({shared:t})}applyGeometryParametersFromFrame(e){let t=this.frame;t&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=en(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let t=this.frame;if(t){let o=t.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,t,o,i){this.uiCanvas.updateEntity2DByOp(e,t,o,i),e===this.frameId&&t.type===0&&(t.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(i):Ge(t.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,t){super.updateGeometryInteractions(e,t),this.applySize({width:e.width,height:e.height},t)}};var Be=require("three"),Hv=require("three/examples/jsm/misc/GPUComputationRenderer.js");var Ut=require("three"),vv=require("three/examples/jsm/math/MeshSurfaceSampler.js");function Sv(n){let r=new Float32Array(n*n*2);for(let e=0;e<n;e++)for(let t=0;t<n;t++){let o=e*n+t;r[o*2+0]=e/(n-1),r[o*2+1]=t/(n-1)}return r}function wv(n){let r=Math.ceil(Math.sqrt(n));return Math.max(r,1)}function Pv(n,r){let e=new Ut.Mesh(n.geometry,n.material),t=[],o=[],i=new Ut.Vector3,a=new Ut.Vector3;e.geometry.index!==null&&(e.geometry=e.geometry.toNonIndexed());let s=new vv.MeshSurfaceSampler(e).build();for(let u=0;u<r;u++)s.sample(i,a),t.push(i.x,i.y,i.z),o.push(a.x,a.y,a.z);let l=new Float32Array(t),c=new Float32Array(o);return{positions:l,normals:c}}function dh(n,r){let e=n,t=new Float32Array(4*r*r);for(let i=0;i<r*r;i++)t[4*i]=e[3*i],t[4*i+1]=e[3*i+1],t[4*i+2]=e[3*i+2],t[4*i+3]=0;let o=new Ut.DataTexture(t,r,r,Ut.RGBAFormat,Ut.FloatType);return o.needsUpdate=!0,o}function Ov({size:n}){let r=new Float32Array(4*n*n);for(let t=0;t<n*n;t++)r[4*t]=t,r[4*t+1]=0,r[4*t+2]=0,r[4*t+3]=0;let e=new Ut.DataTexture(r,n,n,Ut.RGBAFormat,Ut.FloatType);return e.needsUpdate=!0,e}function Cv(n){let r=new Float32Array(4*n*n);for(let t=0;t<n*n;t++)r[4*t]=0,r[4*t+1]=0,r[4*t+2]=0,r[4*t+3]=0;let e=new Ut.DataTexture(r,n,n,Ut.RGBAFormat,Ut.FloatType);return e.needsUpdate=!0,e}var Tv=`
|
|
2618
2604
|
// uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
|
|
2619
2605
|
// uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
|
|
2620
2606
|
// uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
|
|
@@ -2683,7 +2669,7 @@ void main() {
|
|
|
2683
2669
|
gl_FragColor = mix(vec4(0.0), activeColor, isActive);
|
|
2684
2670
|
|
|
2685
2671
|
}
|
|
2686
|
-
`;var
|
|
2672
|
+
`;var Av=`
|
|
2687
2673
|
|
|
2688
2674
|
vec3 mod289(vec3 x) {
|
|
2689
2675
|
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
|
@@ -2885,7 +2871,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
|
|
|
2885
2871
|
);
|
|
2886
2872
|
}
|
|
2887
2873
|
|
|
2888
|
-
`;var
|
|
2874
|
+
`;var Mv=`
|
|
2889
2875
|
#ifdef USE_COLLIDER
|
|
2890
2876
|
float restitution = max(uBounce * 2., .01); // Energy Loss
|
|
2891
2877
|
// SPHERE COLLIDER
|
|
@@ -2953,7 +2939,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
|
|
|
2953
2939
|
#endif
|
|
2954
2940
|
#endif
|
|
2955
2941
|
// END COLLIDER
|
|
2956
|
-
`;var
|
|
2942
|
+
`;var Iv=`
|
|
2957
2943
|
#ifdef USE_ATTRACTOR
|
|
2958
2944
|
|
|
2959
2945
|
#ifdef USE_SPHERE_COLLIDER
|
|
@@ -3027,7 +3013,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
|
|
|
3027
3013
|
velocity *= uForceDamping;
|
|
3028
3014
|
#endif
|
|
3029
3015
|
#endif
|
|
3030
|
-
`;var
|
|
3016
|
+
`;var Nv=`
|
|
3031
3017
|
#ifdef USE_VORTEX
|
|
3032
3018
|
// Box dimensions
|
|
3033
3019
|
vec3 boxHalfSize = uColliderSize / 2.0;
|
|
@@ -3066,7 +3052,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
|
|
|
3066
3052
|
velocity += applyForce( originDirection * uSpeed * (1. - uForceDamping) , mass * .5);
|
|
3067
3053
|
}
|
|
3068
3054
|
#endif
|
|
3069
|
-
`;var
|
|
3055
|
+
`;var Dv=`
|
|
3070
3056
|
// uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
|
|
3071
3057
|
// uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
|
|
3072
3058
|
// uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
|
|
@@ -3092,7 +3078,7 @@ uniform float uForceDamping;
|
|
|
3092
3078
|
uniform float uForceIntensity;
|
|
3093
3079
|
|
|
3094
3080
|
|
|
3095
|
-
`+
|
|
3081
|
+
`+Av+`
|
|
3096
3082
|
float rand(vec2 co){
|
|
3097
3083
|
return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
|
|
3098
3084
|
}
|
|
@@ -3170,11 +3156,11 @@ void main() {
|
|
|
3170
3156
|
#endif
|
|
3171
3157
|
|
|
3172
3158
|
// COLLIDER
|
|
3173
|
-
${
|
|
3159
|
+
${Mv}
|
|
3174
3160
|
// ATTRACTION
|
|
3175
|
-
${
|
|
3161
|
+
${Iv}
|
|
3176
3162
|
// VORTEX
|
|
3177
|
-
${
|
|
3163
|
+
${Nv}
|
|
3178
3164
|
}
|
|
3179
3165
|
// End isActive
|
|
3180
3166
|
|
|
@@ -3192,7 +3178,7 @@ void main() {
|
|
|
3192
3178
|
|
|
3193
3179
|
gl_FragColor = vec4(velocity, collisionFlag);
|
|
3194
3180
|
}
|
|
3195
|
-
`;var
|
|
3181
|
+
`;var zv=require("three");var ph=`
|
|
3196
3182
|
|
|
3197
3183
|
// Linear Fade In
|
|
3198
3184
|
float linearFadeIn(float t) {
|
|
@@ -3225,7 +3211,7 @@ void main() {
|
|
|
3225
3211
|
float constant(float t) {
|
|
3226
3212
|
return 1.0;
|
|
3227
3213
|
}
|
|
3228
|
-
`;var
|
|
3214
|
+
`;var Ev=`
|
|
3229
3215
|
|
|
3230
3216
|
float rand(vec3 co){
|
|
3231
3217
|
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
|
@@ -3240,7 +3226,7 @@ vec3 applyForce(vec3 force, float mass) {
|
|
|
3240
3226
|
|
|
3241
3227
|
return acceleration;
|
|
3242
3228
|
}
|
|
3243
|
-
`;var
|
|
3229
|
+
`;var _v=`
|
|
3244
3230
|
vec3 rgb2xyz (in vec3 rgb) {
|
|
3245
3231
|
float r = rgb.r;
|
|
3246
3232
|
float g = rgb.g;
|
|
@@ -3331,7 +3317,7 @@ vec3 lab2rgb (in vec3 lab) {
|
|
|
3331
3317
|
return(rgb);
|
|
3332
3318
|
}
|
|
3333
3319
|
|
|
3334
|
-
`;var
|
|
3320
|
+
`;var Bv=`
|
|
3335
3321
|
uniform sampler2D uPosition;
|
|
3336
3322
|
uniform float uSize;
|
|
3337
3323
|
uniform float uSizeEnd;
|
|
@@ -3352,9 +3338,9 @@ vec3 lab2rgb (in vec3 lab) {
|
|
|
3352
3338
|
varying vec2 vUv;
|
|
3353
3339
|
varying vec2 vRef;
|
|
3354
3340
|
|
|
3355
|
-
${
|
|
3356
|
-
${
|
|
3357
|
-
`,
|
|
3341
|
+
${Ev}
|
|
3342
|
+
${ph}
|
|
3343
|
+
`,Lv=({easeSize:n="linearFadeOut"})=>`
|
|
3358
3344
|
vUv = uv;
|
|
3359
3345
|
vRef = ref;
|
|
3360
3346
|
// Normalized LifeTime 1 to 0
|
|
@@ -3406,7 +3392,7 @@ vec3 lab2rgb (in vec3 lab) {
|
|
|
3406
3392
|
mvPosition = modelViewMatrix * instanceMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
3407
3393
|
mvPosition.xy += rotatedPosition;
|
|
3408
3394
|
gl_Position = projectionMatrix * mvPosition;
|
|
3409
|
-
`,
|
|
3395
|
+
`,Rv=`
|
|
3410
3396
|
uniform vec4 uColor; // start color
|
|
3411
3397
|
uniform vec4 uColor2; // end color
|
|
3412
3398
|
uniform sampler2D uTexture; // texture
|
|
@@ -3417,10 +3403,10 @@ vec3 lab2rgb (in vec3 lab) {
|
|
|
3417
3403
|
float random(vec2 co) {
|
|
3418
3404
|
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
|
|
3419
3405
|
}
|
|
3420
|
-
`+
|
|
3421
|
-
${
|
|
3406
|
+
`+ph+`
|
|
3407
|
+
${_v}
|
|
3422
3408
|
|
|
3423
|
-
`,
|
|
3409
|
+
`,Vv=({easeOpacity:n="linearFadeOut"})=>`
|
|
3424
3410
|
// if Particle is dead, hide it
|
|
3425
3411
|
if (v_LifeLeft <= 0.005 ) {
|
|
3426
3412
|
discard;
|
|
@@ -3441,7 +3427,7 @@ vec3 lab2rgb (in vec3 lab) {
|
|
|
3441
3427
|
|
|
3442
3428
|
gl_FragColor = vec4(finalColor, finalAlpha);
|
|
3443
3429
|
|
|
3444
|
-
`;var
|
|
3430
|
+
`;var Sd=class extends zv.ShaderMaterial{constructor(e,t){super();this.needsJitter=!0;this.type="ParticleMaterial";this.easeOpacity="linearFadeIn";this.easeSize="linearFadeIn";this.useSizeEnd=!1;this.isColoringRandom=!1;this.init(e,t),this.context=t}reset(){}init(e,t){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],this.lightLayer=new dr(0,"",{...Et.defaultData("light","phong"),visible:!1},new tn,{},t.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(kx),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(Hx),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(Bv),e.addFragmentParsCode(Rv),e.addVertexFinalCode(Lv({easeSize:this.easeSize})),e.addFragmentFinalCode(Vv({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 $r=require("three");var Gv=require("three"),jv=require("three"),Fv=require("three"),Rs=class{constructor(r,e,t,o){this.type="SphereEmitterShape";this.targetMesh=void 0;this.size=r,this.type=t,this.textureSize=wv(e);let i=1;this.targetMesh=o?.type==="Mesh"&&o?o:this.getMesh(t,i);let{positions:a,dataTexture:s,dataTextureNormals:l}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(t,i));this.positionsTexture=s,this.positionsAttribute=a,this.directionsTexture=l}createPositions(r,e){let{positions:t,normals:o}=Pv(e,r*r),i=dh(t,r),a=dh(o,r);return{dataTexture:i,positions:t,dataTextureNormals:a}}getMesh(r,e){let t=null;switch(r){case"SphereEmitterShape":{t=new $r.SphereGeometry(e*.5,32,32);break}case"TorusEmitterShape":{t=new jv.TorusGeometry(e*.5,.3,15,40);break}case"ConeEmitterShape":{t=new $r.ConeGeometry(e,e,15);break}case"BoxEmitterShape":{t=new $r.BoxGeometry(e,e,e);break}case"PlaneEmitterShape":{t=new Fv.PlaneGeometry(e,e),t.rotateX(-Math.PI/2);break}case"MeshEmitterShape":{t=new $r.SphereGeometry(e,32,32);break}default:{t=new $r.SphereGeometry(e,32,32);break}}return new Gv.Mesh(t,new $r.MeshBasicMaterial({color:16711680}))}applyToShader(r,e){this.size=new $r.Vector3().fromArray(e.size),r.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function Ai(n){let r={...n},e=ua.defaultData;r.forceFieldObjectId&&(r.colliderEntityId=r.forceFieldObjectId);let t={...e.shape,...r.shape},o={...e.renderMaterial,...r.renderMaterial};return{...e,...r,shape:t,renderMaterial:o}}var Uv=`
|
|
3445
3431
|
// uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
|
|
3446
3432
|
// uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
|
|
3447
3433
|
// uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
|
|
@@ -3488,27 +3474,8 @@ void main() {
|
|
|
3488
3474
|
|
|
3489
3475
|
|
|
3490
3476
|
}
|
|
3491
|
-
`;var Vh=10,Wd=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 qd(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=Qv(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/Vh),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"]))/Vh),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 bS.GPUComputationRenderer(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),i=this.updateSimulationDefinition(e),a=o.addVariable("uCurrentPosition",i+tS,this.emitterShape.positionsTexture),s=o.addVariable("uCurrentVelocity",i+aS,this.emitterShape.directionsTexture),l=o.addVariable("uCurrentEmissionRate",gS,eS(this.emitterShape.textureSize));o.setVariableDependencies(a,[a,s,l]),o.setVariableDependencies(s,[a,s,l]),o.setVariableDependencies(l,[a,s,l]);let u=Jv({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"]))/Vh}};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}
|
|
3492
|
-
`);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(e){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=e}stopEmitting(){this.isEmitting=!1}};var nl=require("three");var $d=class extends $t{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 Wd(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),Fe(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...wt.drop(e,1).props}}),Fe(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(this.actualTime/1e3)}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 vI(n,t,e){let r;return t.geometry.type==="TextGeometry"?new Fs(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 jd(n,t,e):t.geometry.type==="BooleanGeometry"?r=new Br(n,t,e):t.geometry.type==="UIGeometry"?r=new qi(n,t,e):r=new Ot(n,t,e),r)}function Yd(n,t,e){return console.assert(t.type!==void 0),t.type==="Mesh"?vI(n,t,e):t.type==="Empty"?new ni(n,t):t.type==="Particle"?new $d(n,t,e):t.type==="ParticleCollider"?new Nd(n,t,e):t.type==="Splat"?new ni(n,t):t.type==="Bone"?new Hd(n,t):t.type==="Page"?new io(n,t,e):t.type==="PointLight"?new kd(n,t,e):t.type==="SpotLight"?new Ks(n,t,e):t.type==="DirectionalLight"?new Qs(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 ni(n,t))}mo.createEntity=Yd;function SI(n,t,e){let r=Yd(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=SI;mo.Cloner=Us;function vS(n,t,e,r){n.updateByOp(t,e,r,!1)}var il=require("three");function SS(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,zs(n),Vs(n)),r.length===0&&o.length===0&&n.layers.set(0),n instanceof Er&&n.needsAO&&n.layers.enable(5),e}function wS(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 AS(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Er)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)SS(e,e.material[r])&&(t=!0);else SS(e,e.material)&&(t=!0)}),t}function _S(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Er)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)wS(e,e.material[r])&&(t=!0);else wS(e,e.material)&&(t=!0)}),t}var _I=new il.Raycaster,PI=new il.Matrix4,OI=new il.Ray;function yc(n,t,e,r=!1){let o=n.cloner;if(o)for(let i of o.children){let a=PI.copy(i.matrixWorld).invert(),s=OI.copy(t.ray).applyMatrix4(a),l=n.matrixWorld;s.applyMatrix4(l);let u=_I;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 Xd=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=ar(al()),Ko=ar(sl());var Bt=ar(al()),ve=ar(sl()),li=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 li(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 li(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=li.createFromUnnormalized(t.hi(c,t.shape[1]).lo(u,0)):d=li.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=ar(al()),Ue=ar(sl());var WS="http://127.0.0.1:8000";var $i=ar(al()),ct=ar(sl());var $S=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9];function YS(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 XS(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=YS(n),i=YS(t),a=0;return o<i?(n*=$S[i-o-1],t/=10,a=-1):o>i&&(t*=$S[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 KI(n){let t=0;for(;n>=32;)t|=n&1,n>>=1;return n+t}function QS(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++;ZI(n,t,o)}else for(;o<e&&r(n[o],n[o-1])>=0;)o++;return o-t}function ZI(n,t,e){for(e--;t<e;){let r=n[t];n[t++]=n[e],n[e--]=r}}function KS(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 Fh(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 kh(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 jh=class{constructor(t,e){Zt(this,"array",null);Zt(this,"compare",null);Zt(this,"minGallop",7);Zt(this,"length",0);Zt(this,"tmpStorageLength",256);Zt(this,"stackLength",0);Zt(this,"runStart",null);Zt(this,"runLength",null);Zt(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=kh(r[a],r,o,i,0,e);o+=l,i-=l,i!==0&&(s=Fh(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=kh(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=Fh(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-kh(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-Fh(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 ZS(n,t,e,r){if(!Array.isArray(n))throw new TypeError("Can only sort arrays");t?typeof t!="function"&&(r=e,e=t,t=XS):t=XS,e||(e=0),r||(r=n.length);let o=r-e;if(o<2)return;let i=0;if(o<32){i=QS(n,e,r,t),KS(n,e,r,e+i,t);return}let a=new jh(n,t),s=KI(o);do{if(i=QS(n,e,r,t),i<s){let l=o;l>s&&(l=s),KS(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 Uh(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 JI(n){let t=Uh(n.pick(null,0)),e=Uh(n.pick(null,1));ct.lshiftseq(e,1);let r=Uh(n.pick(null,2));return ct.lshiftseq(r,2),ct.boreq(t,e),ct.boreq(t,r),t}function ci(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 Hh(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=JI(i),l=Array.from(a.data).map((d,p)=>[d,p]);ZS(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(`${WS}/push_file`,{method:"POST",body:a})}static async loadFile(t){return await(await fetch(t)).arrayBuffer()}mortonPositionSplatsSort(){let t=Hh(this.xyz),e=ci(this.xyz,t),r=ci(this.colors,t),o=ci(this.opacity,t),i=ci(this.scaling,t),a=ci(this.rotation,t),s=[];for(let l=0;l<this.harmonics.length;l++)s.push(ci(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
|
|
3493
|
-
format ${e.format} ${e.version}
|
|
3494
|
-
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}
|
|
3495
|
-
property ${a[s].dtype} ${a[s].name}`;return`${o}
|
|
3496
|
-
end_header
|
|
3497
|
-
`}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,A=[];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)),A.push(P)}return new so(i,a,r,f,m,A,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(`
|
|
3498
|
-
`),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=ar(al()),kt=ar(sl());var ui=require("three"),JS={xyz:3,color:3,opacity:1,scaling:3,quaternion:4,harmonics:3},di=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 kt.mulseq(e,t),kt.addseq(e,.5),kt.mulseq(e,255),kt.maxseq(e,0),kt.minseq(e,255),kt.negeq(r),kt.expeq(r),kt.addseq(r,1),kt.recipeq(r),kt.mulseq(r,255),kt.assign(o.hi(e.shape[0],3).lo(0,0),e),kt.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*JS[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 A;if(w){let O=i.buffer.slice(d,d+c);A=(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,JS[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,A,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 ui.Quaternion,c=new ui.Matrix3,d=new ui.Matrix3,p=new ui.Matrix3,f=new ui.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(`
|
|
3499
|
-
`),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 di.fromCompressedGaussianSplats(r)}static fromCompressedGaussianSplats(t){let e=t.xyz.length,r=t.xyz.nchunks,o=`gspline
|
|
3500
|
-
element vertex ${e}
|
|
3501
|
-
element chunks ${r}
|
|
3502
|
-
element chunkSize ${t.chunkSize}
|
|
3503
|
-
element typeChunks ${t.isDynamicChunks?"dynamic":"static"}
|
|
3504
|
-
property xyz ${t.xyz.method}
|
|
3505
|
-
property color ${t.color.method}
|
|
3506
|
-
property opacity ${t.opacity.method}
|
|
3507
|
-
property scaling ${t.scaling.method}
|
|
3508
|
-
property quaternion ${t.quaternion.method}`;if(t.harmonics&&t.harmonics.length>0)for(let D=0;D<t.harmonics.length;D++)o=`${o}
|
|
3509
|
-
property harmonics_${D} ${t.harmonics[D].method}`;o=`${o}
|
|
3510
|
-
end_header
|
|
3511
|
-
`;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=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,A+=S+P;let O=new Uint8Array(A),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 di(O.buffer)}};var e1="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL";var Zo=class{};Zt(Zo,"DepthMapRange",1<<16),Zt(Zo,"MemoryPageSize",65536),Zt(Zo,"BytesPerFloat",4),Zt(Zo,"BytesPerInt",4);function e3(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 F=0;F<E.length-1;F++){let V=I[F],q=T[F].elements,k=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[F];H<E[F+1];H++){let Y=f[H*3],J=f[H*3+1],Z=f[H*3+2];if((k.length===0||A(Y,J,Z,k))&&(U.length===0||!A(Y,J,Z,U))){let X=1/(q[3]*Y+q[7]*J+q[11]*Z+q[15]);B[r*3]=(q[0]*Y+q[4]*J+q[8]*Z+q[12])*X,B[r*3+1]=(q[1]*Y+q[5]*J+q[9]*Z+q[13])*X,B[r*3+2]=(q[2]*Y+q[6]*J+q[10]*Z+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)),F=T.length;for(let V=0;V<F;V+=3){let q=T[V],k=T[V+1],U=T[V+2];(B.length===0||A(q,k,U,B))&&(R.length===0||!A(q,k,U,R))||E.push(V/3)}return console.log(E),E}function A(T,I,E,B,R){return B[R==="Intersect"?"every":"some"](F=>{let V=S(T,I,E,F.invRotationMatrix,F.cropCenter);return Array.isArray(F)?x(V.x,V.y,V.z,F):N(V.x,V.y,V.z,F)})}function S(T,I,E,B,R){let F=T-R[0],V=I-R[1],q=E-R[2],k=1/(B[3]*F+B[7]*V+B[11]*q+B[15]);return{x:(B[0]*F+B[4]*V+B[8]*q+B[12])*k+R[0],y:(B[1]*F+B[5]*V+B[9]*q+B[13])*k+R[1],z:(B[2]*F+B[6]*V+B[10]*q+B[14])*k+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],F=O(T.cropRotation);return Object.assign(R,{invRotationMatrix:F,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,F=Math.cos(E),V=Math.sin(E),q=Math.cos(B),k=Math.sin(B),U=Math.cos(R),H=Math.sin(R),Y=F*U,J=F*H,Z=V*U,X=V*H;return I[0]=q*U,I[1]=-q*H,I[2]=k,I[4]=J+Z*k,I[5]=Y-X*k,I[6]=-V*q,I[8]=X-Y*k,I[9]=Z+J*k,I[10]=F*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,F=(I-B.cropCenter[1])*B.invRadiusY,V=(E-B.cropCenter[2])*B.invRadiusZ;return R*R+F*F+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,F=e*R,V=e*p.BytesPerInt*2+p.DepthMapRange*p.BytesPerInt*2,q=p.MemoryPageSize*32,k=F+V+q,U=Math.floor(k/p.MemoryPageSize)+1,H={module:{},env:{memory:new WebAssembly.Memory({initial:U*2,maximum:U*3,shared:!0})}};WebAssembly.compile(B).then(Y=>WebAssembly.instantiate(Y,H)).then(Y=>{t=Y,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 t1(n){let t=new Worker(URL.createObjectURL(new Blob(["(",e3.toString(),")(self)"],{type:"application/javascript"}))),e=atob(e1),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 zr=require("three");var Pe=require("three");var Zd=function(){let n=new Float32Array(1),t=new Int32Array(n.buffer);return function(e){return n[0]=e,t[0]}}(),r1=function(n,t,e,r){return n+(t<<8)+(e<<16)+(r<<24)};var Jd=new Pe.Vector2,pi=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=pi.buildGeomtery(r),u=pi.buildMaterial(a);return new pi(e,r,l,u,o,i,a,s)}static buildMaterial(e){let r=`
|
|
3477
|
+
`;var fh=10,wd=class extends Be.Object3D{constructor(e,t){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 Be.TextureLoader;this.currentWorldPosition=new Be.Vector3;this.systemQuaternion=new Be.Quaternion;this.worldGravity=new Be.Vector3(0,0,0);this.directionAxis=new Be.Vector3(0,0,0);this.colliderV3=new Be.Vector3(0,0,0);this.colliderQuaternion=new Be.Quaternion(0,0,0,1);this.matrixAutoUpdate=!0,this.renderer=e,this.system=t,this.shared=t.context.shared;let o=t.data;this.material=new Sd(o.renderMaterial,t.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:o.renderMaterial.color},uColor2:{value:o.renderMaterial.color2},uPosition:{value:new Be.Vector3(0,0,0)},uEmissionData:{value:new Be.Vector3(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new Be.Vector3(0,0,0)},uWorldQuaternion:{value:new Be.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,t){let o=t.data;if(typeof t=="string"){let i=this.shared.image(t),a=new Be.Texture(i.img);a.needsUpdate=!0,e.uTexture.value=a;return}if(typeof o!="string"){let i=new Image;i.onload=()=>{let l=new Be.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,t){let o=Sv(t);!this.emitterShape?.positionsAttribute||e.geometry.setAttribute("ref",new Be.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,t){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/t,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 t=e.data.size;this.colliderV3.fromArray(t),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,t){if(!this.velocitySimRT||!this.positionSimRT)return;t[2]==="size"&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),t[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}})};t[2]==="shape_size_0"&&o(0,e),t[2]==="shape_size_1"&&o(1,e),t[2]==="shape_size_2"&&o(2,e),t[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/fh),t[2]==="gravity"&&this.worldGravity.set(0,e/100,0),t[2]==="noiseStrength"&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),t[2]==="noiseScale"&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),t[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),t[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),t[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(Ai(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"]))/fh),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 t=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(t)}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 t=e.shape.size??this.system.data.shape.size,o=[Number(this.shared.getVariable(t[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(t[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(t[2],[this.uuid,"particles","shape_size_2"]))],i={...Ai(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 t=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(t),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 t=[Number(e[0])*Be.MathUtils.DEG2RAD,Number(e[1])*Be.MathUtils.DEG2RAD,Number(e[2])*Be.MathUtils.DEG2RAD],o=new Be.Euler(t[0],t[1],t[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:t,rootObjectType:o,colliderEntityId:i,shape:a,emitTimeDuration:s,emitTimeCycle:l,life:c,directionMode:u,noiseType:p}=e;return t!==void 0||o!==void 0||(i||i===null)||l!==void 0||a!==void 0||c!==void 0||s!==void 0||u!==void 0||p!==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 t=setInterval(()=>{if(!!this.emitterShape)if(isNaN(this.emitterShape.positionsTexture.source.data.data[0])){this.init(e);return}else clearInterval(t)},100);if(!this.emitterShape)return;let o=new Hv.GPUComputationRenderer(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),i=this.updateSimulationDefinition(e),a=o.addVariable("uCurrentPosition",i+Tv,this.emitterShape.positionsTexture),s=o.addVariable("uCurrentVelocity",i+Dv,this.emitterShape.directionsTexture),l=o.addVariable("uCurrentEmissionRate",Uv,Cv(this.emitterShape.textureSize));o.setVariableDependencies(a,[a,s,l]),o.setVariableDependencies(s,[a,s,l]),o.setVariableDependencies(l,[a,s,l]);let c=Ov({size:this.emitterShape.textureSize}),u={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new Be.Vector3(0,0,0)},uWorldQuaternion:{value:new Be.Vector4(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:e.life},uEmitterSize:{value:new Be.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=u;let p=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(p),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 d=e.colliderEntityId&&this.system.getColliderData(e.colliderEntityId),h={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new Be.Vector4(0,0,0,1)},uColliderPos:{value:new Be.Vector3(0,0,0)},uColliderSize:{value:new Be.Vector3(0,0,0)},uForceIntensity:{value:d?d.forceIntensity:0},uForceDamping:{value:d?d.forceDambing:0},uColliderQuaternion:{value:new Be.Vector4(0,0,0,1)},uColliderQuaternionInvert:{value:new Be.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"]))/fh}};s.material.uniforms=h;let f={uIndex:{value:c},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};l.material.uniforms=f;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={...Ai(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 t=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[t,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 t="";for(let[o,i]of Object.entries(this.simFeaturesDefinition))i&&(t+=`#define ${o}
|
|
3478
|
+
`);return t}createShape(e,t){this.emitterShape&&this.emitterShape.dispose();let o=new Be.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 Rs(o,t,e.type,i):new Rs(o,t,"SphereEmitterShape")}else return new Rs(o,t,e.type)}createPrimaryEmitter(e){let t,o=e*e;return t=new Be.InstancedMesh(new Be.PlaneGeometry(1,1,1),this.material,o),this.updateGeometryAttributes(t,e),this.material.needsUpdate=!0,t.onBeforeRender=()=>{this.applyWorldSpace()},t}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:t,loopDuration:o=0}){return Math.ceil(e*(t+o))}dispose(){!this.gpuCompute||(this.rootObject?.parent?.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),this.emitterShape?.dispose())}GoEmitSomeParticles(e,t){let o=e-this.lastEmitTime,i=1/t;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(Ai(this.system.data))}startEmitting(e){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=e}stopEmitting(){this.isEmitting=!1}};var Vs=require("three");var Pd=class extends zt{constructor(e,t,o){super(e,t);this.type="ParticleSystem";this.geometry=new Vs.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={...t,...Ai(t)},this.geometry.setAttribute("position",new Vs.Float32BufferAttribute([],3)),this.material=new Vs.MeshBasicMaterial({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new wd(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 t=this.data.emitTimeCycle==="one_time";if((this.data.emitTimeCycle==="loop"||t)&&this.currentLoopTime>this.data.emitTimeDuration*1e3&&(this.stopped||(this.stop(),t||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(t=>t.identity===e)}getColliderData(e){let t=this.colliderEntities.find(o=>o.identity===e);return t?t.data:null}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),Ge(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...yt.drop(e,1).props}}),Ge(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...yt.drop(e,1).props}})}updateState(e,t){super.updateState(e,t),this.updateParticleState(e)}updateParticleState(e){if(!!this.emitter){if(e.colliderEntityId!==void 0&&e.colliderEntityId!==null){let t=this.context.scene.find(e.colliderEntityId);this.colliderEntities=t?[t]:[]}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(this.actualTime/1e3)}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 PI(n,r,e){let t;return r.geometry.type==="TextGeometry"?new bs(n,r,e):(r.geometry.type==="SubdivGeometry"?t=new wi(n,r,e):r.geometry.type==="PathGeometry"?t=new Bs(n,r,e):r.geometry.type==="VectorGeometry"?t=new xd(n,r,e):r.geometry.type==="BooleanGeometry"?t=new Pr(n,r,e):r.geometry.type==="UIGeometry"?t=new Ti(n,r,e):t=new bt(n,r,e),t)}function Od(n,r,e){return console.assert(r.type!==void 0),r.type==="Mesh"?PI(n,r,e):r.type==="Empty"?new Fn(n,r):r.type==="Particle"?new Pd(n,r,e):r.type==="ParticleCollider"?new sd(n,r,e):r.type==="Splat"?new Fn(n,r):r.type==="Bone"?new vd(n,r):r.type==="Page"?new qr(n,r,e):r.type==="PointLight"?new gd(n,r,e):r.type==="SpotLight"?new Ns(n,r,e):r.type==="DirectionalLight"?new Is(n,r,e):r.type==="Component"||r.type==="Instance"?new cn(n,r,e):Qr.is(r.type)?new an(n,r):(console.error(r),new Fn(n,r))}eo.createEntity=Od;function OI(n,r,e){let t=Od(n.identity,r,e),o=n.children,i=n.attachedPaths,a=n.parent,s=n.component,l=n.instances,c=n.overrideData,u=n.uuid,p=n.stateSelection;n.dispose();for(let d of Object.keys(n))delete n[d];Object.setPrototypeOf(n,Object.getPrototypeOf(t));for(let d of Object.keys(t))n[d]=t[d];n.children=[...n.children,...o],n.attachedPaths=i,n.parent=a,n.component=s,n.instances=l,n.uuid=u,n.overrideData=c,n.updateState(n.data,e),p&&n.changeSelectedState(p,e),n.resetBBoxNeedsUpdate()}eo.changeEntityProptotype=OI;eo.Cloner=ws;function Wv(n,r,e,t){n.updateByOp(r,e,t,!1)}var zs=require("three");function qv(n,r){let e=!1,t=r.getLayersOfType("transmission"),o=r.getLayersOfType("outline");return o.length>0&&(n.layers.set(8),t.length>0&&n.layers.enable(3),e=!0,gs(n),ys(n)),t.length===0&&o.length===0&&n.layers.set(0),n instanceof wr&&n.needsAO&&n.layers.enable(5),e}function $v(n,r){if(!r.layers)return!1;let e=!1,t=r.getLayersOfType("transmission").filter(i=>i.data.visible),o=r.getLayersOfType("outline").filter(i=>i.data.visible);return t.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),t.length===0&&o.length===0&&n.layers.set(0),n.needsAO&&n.layers.enable(5),e}function Yv(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof wr)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)qv(e,e.material[t])&&(r=!0);else qv(e,e.material)&&(r=!0)}),r}function Xv(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof wr)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)$v(e,e.material[t])&&(r=!0);else $v(e,e.material)&&(r=!0)}),r}var AI=new zs.Raycaster,MI=new zs.Matrix4,II=new zs.Ray;function $l(n,r,e,t=!1){let o=n.cloner;if(o)for(let i of o.children){let a=MI.copy(i.matrixWorld).invert(),s=II.copy(r.ray).applyMatrix4(a),l=n.matrixWorld;s.applyMatrix4(l);let c=AI;c.set(s.origin,s.direction),c.near=r.near,c.far=r.far;let u=c.intersectObject(n,!1);u.length>0&&e.push({...u[0],object:t?i:n})}}var Cd=class{constructor(){this._constraints=new Map}setConstraint(r,e){e===null?this._constraints.delete(r):this._constraints.set(r,e)}removeDependencies(r){this._constraints.delete(r)}applyConstraints(r){let e=new Set;this._constraints.forEach((t,o)=>{let i=[o,t],a=t;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=r.find(i[s]);l?l.applyPathSnapping(r):console.warn(`missing entity ${i[s]}`),e.add(i[s])}})}findDependency(r,e){let t=r;for(;this._constraints.has(t);)if(t=this._constraints.get(t),t===e)return!0;return!1}};var Kv="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL";var Ro=class{};Zn(Ro,"DepthMapRange",1<<16),Zn(Ro,"MemoryPageSize",65536),Zn(Ro,"BytesPerFloat",4),Zn(Ro,"BytesPerInt",4);function NI(n){let r,e,t,o,i,a,s,l,c,u,p,d,h,f,m,y;function g(A){let N=new Float64Array(u,a,16);for(let B=0;B<16;B++)N[B]=A[B];let E;if(t>1){r.exports.sortIndexes(o,i,c,a,s,l,d.DepthMapRange,t);let B=new Uint32Array(t);E=B.buffer,B.set(new Uint32Array(u,l,t))}else if(t===1){let B=new Uint32Array(t);B[0]=new Uint32Array(u,o,e)[0],E=B.buffer}else E=new ArrayBuffer(0);n.postMessage({sortDone:!0,indexesBuffer:E},[E])}function v(A,N,E){let B=new Float32Array(u,i,e*3);t=0;let V=new Uint32Array(u,o,e);for(let j=0;j<E.length-1;j++){let R=N[j],W=A[j].elements,F=R.filter(H=>H.enabled&&H.mode==="Include").map(H=>H.type==="Box"?T(H):_(H)),k=R.filter(H=>H.enabled&&H.mode==="Exclude").map(H=>H.type==="Box"?T(H):_(H));for(let H=E[j];H<E[j+1];H++){let $=h[H*3],J=h[H*3+1],Z=h[H*3+2];if((F.length===0||P($,J,Z,F))&&(k.length===0||!P($,J,Z,k))){let X=1/(W[3]*$+W[7]*J+W[11]*Z+W[15]);B[t*3]=(W[0]*$+W[4]*J+W[8]*Z+W[12])*X,B[t*3+1]=(W[1]*$+W[5]*J+W[9]*Z+W[13])*X,B[t*3+2]=(W[2]*$+W[6]*J+W[10]*Z+W[14])*X,V[t]=H,t++}}}}function O(A,N){let E=[],B=N.filter(R=>R.enabled&&R.mode==="Include").map(R=>R.type==="Box"?T(R):_(R)),V=N.filter(R=>R.enabled&&R.mode==="Exclude").map(R=>R.type==="Box"?T(R):_(R)),j=A.length;for(let R=0;R<j;R+=3){let W=A[R],F=A[R+1],k=A[R+2];(B.length===0||P(W,F,k,B))&&(V.length===0||!P(W,F,k,V))||E.push(R/3)}return E}function P(A,N,E,B,V){return B[V==="Intersect"?"every":"some"](j=>{let R=S(A,N,E,j.invRotationMatrix,j.cropCenter);return Array.isArray(j)?x(R.x,R.y,R.z,j):D(R.x,R.y,R.z,j)})}function S(A,N,E,B,V){let j=A-V[0],R=N-V[1],W=E-V[2],F=1/(B[3]*j+B[7]*R+B[11]*W+B[15]);return{x:(B[0]*j+B[4]*R+B[8]*W+B[12])*F+V[0],y:(B[1]*j+B[5]*R+B[9]*W+B[13])*F+V[1],z:(B[2]*j+B[6]*R+B[10]*W+B[14])*F+V[2]}}function T(A){let N=A.cropSize[0]/2,E=A.cropSize[1]/2,B=A.cropSize[2]/2,V=[A.cropCenter[0]-N,A.cropCenter[1]-E,A.cropCenter[2]-B,A.cropCenter[0]+N,A.cropCenter[1]+E,A.cropCenter[2]+B],j=I(A.cropRotation);return Object.assign(V,{invRotationMatrix:j,cropCenter:A.cropCenter})}function I(A){let N=[],E=A[0]*Math.PI/180,B=A[1]*Math.PI/180,V=A[2]*Math.PI/180,j=Math.cos(E),R=Math.sin(E),W=Math.cos(B),F=Math.sin(B),k=Math.cos(V),H=Math.sin(V),$=j*k,J=j*H,Z=R*k,X=R*H;return N[0]=W*k,N[1]=-W*H,N[2]=F,N[4]=J+Z*F,N[5]=$-X*F,N[6]=-R*W,N[8]=X-$*F,N[9]=Z+J*F,N[10]=j*W,N[12]=0,N[13]=0,N[14]=0,N[3]=0,N[7]=0,N[11]=0,N[15]=1,N}function x(A,N,E,B){return A>=B[0]&&A<=B[3]&&N>=B[1]&&N<=B[4]&&E>=B[2]&&E<=B[5]}function _(A){let N=2/A.cropSize[0],E=2/A.cropSize[1],B=2/A.cropSize[2],V=I(A.cropRotation);return{invRadiusX:N,invRadiusY:E,invRadiusZ:B,cropCenter:A.cropCenter,invRotationMatrix:V}}function D(A,N,E,B){let V=(A-B.cropCenter[0])*B.invRadiusX,j=(N-B.cropCenter[1])*B.invRadiusY,R=(E-B.cropCenter[2])*B.invRadiusZ;return V*V+j*j+R*R<=1}n.onmessage=A=>{if(A.data.getCroppedIndexes){let N=new Uint32Array(O(new Float32Array(A.data.positions),A.data.crops)).buffer;n.postMessage({outOfBoundsIndexes:N},[N])}else if(A.data.positions)p=A.data.positions,h=new Float32Array(p),m=A.data.meshMatrixWorlds,y=A.data.cropsArray,f=A.data.meshIndexIntervals,v(m,y,f),n.postMessage({sortSetupComplete:!0});else if(A.data.sort||A.data.newMatrixWorlds||A.data.newCropsArray)(A.data.newMatrixWorlds||A.data.newCropsArray)&&(y=A.data.newCropsArray||y,m=A.data.newMatrixWorlds||m,v(m,y,f)),g(A.data.sort.view,A.data.sort.cameraPosition);else if(A.data.init){d=A.data.init.Constants,e=A.data.init.splatCount;let N=d.BytesPerInt,E=d.BytesPerFloat*3,B=new Uint8Array(A.data.init.sorterWasmBytes),V=N+E,j=e*V,R=e*d.BytesPerInt*2+d.DepthMapRange*d.BytesPerInt*2,W=d.MemoryPageSize*32,F=j+R+W,k=Math.floor(F/d.MemoryPageSize)+1,H={module:{},env:{memory:new WebAssembly.Memory({initial:k*2,maximum:k*3,shared:!0})}};WebAssembly.compile(B).then($=>WebAssembly.instantiate($,H)).then($=>{r=$,o=0,i=e*N,a=i+e*E,c=a+16*d.BytesPerFloat*2,s=c+e*d.BytesPerInt,l=s+d.DepthMapRange*d.BytesPerInt,u=H.env.memory.buffer,n.postMessage({sortSetupPhase1Complete:!0})})}}}function Qv(n){let r=new Worker(URL.createObjectURL(new Blob(["(",NI.toString(),")(self)"],{type:"application/javascript"}))),e=atob(Kv),t=new Uint8Array(e.length);for(let o=0;o<e.length;o++)t[o]=e.charCodeAt(o);return r.postMessage({init:{sorterWasmBytes:t.buffer,splatCount:n,Constants:{BytesPerFloat:Ro.BytesPerFloat,BytesPerInt:Ro.BytesPerInt,DepthMapRange:Ro.DepthMapRange,MemoryPageSize:Ro.MemoryPageSize}}}),r}var hr=require("three");var Oe=require("three");var Td=function(){let n=new Float32Array(1),r=new Int32Array(n.buffer);return function(e){return n[0]=e,r[0]}}(),Zv=function(n,r,e,t){return n+(r<<8)+(e<<16)+(t<<24)};var Ad=new Oe.Vector2;function Md(n){let r=!1;return n.scene.objects.traverse((e,t)=>{if(t.visible===!1)return!0;t.type==="Splat"&&(r=!0)}),r}var Wn=class extends Oe.Mesh{constructor(e,t,o,i,a=!1,s=1,l,c){super(o,i);this.splatCount=t,this.meshIndexIntervals=l,this.meshMatrixWorlds=c,this.splatBuffers=e,this.geometry=o,this.material=i,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=a,this.devicePixelRatio=s,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,t,o=!1,i=1,a,s){let l=Wn.buildGeomtery(t),c=Wn.buildMaterial(a);return new Wn(e,t,l,c,o,i,a,s)}static buildMaterial(e){let t=`
|
|
3512
3479
|
precision highp float;
|
|
3513
3480
|
#include <common>
|
|
3514
3481
|
|
|
@@ -3662,4 +3629,4 @@ end_header
|
|
|
3662
3629
|
A = exp(A) * vColor.a;
|
|
3663
3630
|
gl_FragColor = vec4(color.rgb, A);
|
|
3664
3631
|
gVelocity = vec4(0.0); // so it is ignored by TAA
|
|
3665
|
-
}`,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]=r1(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),u[g+1]=Zd(this.centers[y]),u[g+2]=Zd(this.centers[y+1]),u[g+3]=Zd(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&&(Jd.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Jd),this.material.uniforms.basisViewport.value.set(2/Jd.x,2/Jd.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={}){Zt(this,"updateSplatMeshUniforms",function(){let t=new zr.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))}}());Zt(this,"updateView",function(){let t=new zr.Matrix4,e=[],r=new zr.Vector3(0,0,-1),o=new zr.Vector3(0,0,-1),i=new zr.Vector3,a=new zr.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 zr.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new zr.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 di(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 zr.Vector3,o=new zr.Quaternion,i=!1,a=1,s,l){this.splatMesh=pi.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=t1(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 t3=new lo.MeshBasicMaterial;t3.wireframe=!0;var o1=new lo.Vector3,ep=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 Xd;this.invisibleObjects=new ni("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=_S(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=AS(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(),oi(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()),oi(o)&&(o.freeBooleanPointer(),i instanceof Br&&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()),oi(o)&&(o.invalidateUpstreamBooleanData(),lc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof Br&&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{vS(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){ke.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{ke.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),Ud(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)ke.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(ke.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(oi(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;ke.is(a)&&(a.visible||s?.object.data.visible)&&((oi(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)ke.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)ke.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)ke.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)Ha.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)ke.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=Yd(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(o1),o1}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 $t)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Dr&&e(r.material[o]);else r.material instanceof Dr&&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 n1=require("three/examples/jsm/loaders/DRACOLoader.js");var fi;function r3(){return fi||(fi=new n1.DRACOLoader,fi.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),fi.decoderPending}async function o3(n){if(fi){let t={attributeIDs:fi.defaultAttributeIDs,attributeTypes:fi.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await fi.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 i1(n,t){let[e,r]=Pp(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 r3();for(let i of o){let a=await o3(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 n3=require("three"),i3=require("three/examples/jsm/utils/BufferGeometryUtils.js");function a1(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 s1(n){let t=new Set;return n.traverse(e=>{if(e instanceof Er)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(a3(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=Ob(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else s3(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function a3(n){return n.getLayersOfType("transmission").length>0}function s3(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 l1(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function c1(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 u1=require("three/examples/jsm/utils/BufferGeometryUtils.js");function d1(n){let t=[];return n.traverse(e=>{e instanceof Us&&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&&a1(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof $t&&a.unshift(r.geometry),a.length){let s=(0,u1.mergeBufferGeometries)(a);r instanceof $t&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:n,shared:Fb})}),n}function p1(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function f1(n){Object.values(n.shared.materials).forEach(t=>{qh(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?qh(e.material):"materials"in e&&e.materials.forEach(r=>{qh(r)})})}function qh(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 x1=ar(m1(),1);function y1(n){return n.traverseMaterial(t=>{t.needsJitter=!1}),n}var g1="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",tp=class extends rp.Loader{load(t,e,r,o=console.error){let i=new rp.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(g1+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(g1),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 i1(t,f1);e.version&&(0,x1.default)(e.version,"1.0.62")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([qb(e)&&Zx(),rv(e)&&zb(),Lv(e)&&Dv()].filter(Boolean));let r=new Fi(e.shared);Object.values(r.getMaterials()).forEach(a=>Object.assign(a,{isAsset:!0}));let o=new ep(e.scene,r),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=d1(o),o=s1(o),o=l1(o),o=c1(o),o=p1(o),o=y1(o),o}};
|
|
3632
|
+
}`,i={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Oe.Vector2},viewport:{type:"v2",value:new Oe.Vector2},basisViewport:{type:"v2",value:new Oe.Vector2},debugColor:{type:"v3",value:new Oe.Color},covariancesTextureSize:{type:"v2",value:new Oe.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Oe.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Oe.ShaderMaterial({uniforms:i,vertexShader:t,fragmentShader:o,transparent:!0,alphaTest:1,blending:Oe.NormalBlending,depthTest:!0,depthWrite:!1,side:Oe.DoubleSide})}static buildGeomtery(e){let t=new Oe.BufferGeometry;t.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new Oe.BufferAttribute(o,3);t.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 Oe.InstancedBufferGeometry().copy(t),s=new Uint32Array(e),l=new Oe.InstancedBufferAttribute(s,1,!1);return l.setUsage(Oe.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,t=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(t,t+a*3).set(i.decoded.xyz.denormDequant().data),t+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(i.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,i=new Oe.Vector2(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new Oe.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 f=0;f<this.covariances.length;f++)l[f]=Oe.DataUtils.toHalfFloat(this.covariances[f]);s=new Oe.DataTexture(l,i.x,i.y,Oe.RGFormat,Oe.HalfFloatType)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new Oe.DataTexture(l,i.x,i.y,Oe.RGFormat,Oe.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(i);let c=new Uint32Array(a.x*a.y*4);for(let f=0;f<o;f++){let m=f*4,y=f*3,g=f*4;c[g]=Zv(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=Td(this.centers[y]),c[g+2]=Td(this.centers[y+1]),c[g+3]=Td(this.centers[y+2])}let u=new Oe.DataTexture(c,a.x,a.y,Oe.RGBAIntegerFormat,Oe.UnsignedIntType);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let p=256*4,d=new Float32Array(256*16);for(let f=0;f<this.meshMatrixWorlds.length;f++)d.set(this.meshMatrixWorlds[f].elements,f*16);let h=new Oe.DataTexture(d,p,1,Oe.RGBAFormat,Oe.FloatType);h.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=h,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:i},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:h}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,o,i){this.splatCount>0&&(Ad.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Ad),this.material.uniforms.basisViewport.value.set(2/Ad.x,2/Ad.y),this.material.uniforms.focal.value.set(t,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()),this.removeFromParent()}};var eS,hh=new Promise(n=>{eS=n}),Jv=!1;var Id;function mh(){if(Jv)return;if(Id)return Id;async function n(){let e=await import("./gaussian-splat-compression.js");eS(e),Jv=!0}return Id=n(),Id}var tS;hh.then(n=>tS=n);var Yl=class{constructor(r={}){Zn(this,"updateView",function(){let r=new hr.Matrix4,e=[],t=new hr.Vector3(0,0,-1),o=new hr.Vector3(0,0,-1),i=new hr.Vector3,a=new hr.Vector3;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,h=!1;if(o.dot(t)<=.95&&(d=!0),a.copy(l.position).sub(i).length()>=1&&(h=!0),!d&&!h&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,i.copy(l.position),t.copy(o),r.copy(l.matrixWorld).invert(),r.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:r.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=p:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(p))}}());this.scene=r.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new hr.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(r,e){let t=new hr.Vector2;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(r.getSize(t),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(r={}){this.activePage=this.scene.activePage,r.position&&(r.position=new hr.Vector3().fromArray(r.position)),r.orientation&&(r.orientation=new hr.Quaternion().fromArray(r.orientation)),r.halfPrecisionCovariances=!!r.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let t=e.map(a=>new tS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,i=[0];for(let a of t)o+=a.getSplatCount(),i.push(o);return this.setupSplatMesh(t,o,r.position,r.orientation,r.halfPrecisionCovariances,this.devicePixelRatio,i,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let r=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)r.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,t)=>e.equals(this.meshMatrixWorldsOld[t]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let r=!1;return this.splatEntries.forEach((e,t)=>{e.data.crops.forEach((o,i)=>{this.cropsArray[t][i]===void 0?(r=!0,this.cropsArray[t][i]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[t][i][a][c])?(r=!0,this.cropsArray[t][i][a]=s):s!==this.cropsArray[t][i]?.[a]&&(r=!0,this.cropsArray[t][i][a]=s)})}),e.data.crops.length!==this.cropsArray[t]?.length&&(this.cropsArray[t].length=e.data.crops.length,r=!0)}),r}setupSplatMesh(r,e,t=new hr.Vector3,o=new hr.Quaternion,i=!1,a=1,s,l){this.splatMesh=Wn.buildMesh(r,e,i,a,s,l),this.splatMesh.position.copy(t),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,p)=>this.update(c,p)}setupSortWorker(r){this.sortWorker=Qv(r),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(r,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(r,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var DI=new Yr.MeshBasicMaterial;DI.wireframe=!0;var rS=new Yr.Vector3,Nd=class extends Yr.Scene{constructor(e,t){super();this.data=e;this.sharedAssets=t;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 Cd;this.invisibleObjects=new Fn("jflkdsafjasdifjaslk",{...ou.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new qr("fdasfa",{...ko.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Xv(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Yv(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),o=this.entityIdentityToEntity[t];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof qr&&(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 t=this.find(e);if(t===void 0)return;let o=[],i=t;for(;i!==this;){let a=i;i=i.parent;let s=i.children.indexOf(a);o.splice(0,0,s)}return{entity:t,sortKey:o}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push(i)}return t.sort((o,i)=>oc(o.sortKey,i.sortKey)),t.map(o=>o.entity)}nonExistOrDescendantOf(e,t){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===t)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===Sn)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}find2D(e){for(let t of this.children)if(t instanceof qr&&t.uiScene){let o=t.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof qr&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(o=>{t===void 0&&o instanceof Ti&&(t=o.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof qr&&t.uiScene&&t.uiScene.traverse(e)}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.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(t=>{this.toExpandCloner.add(t)})}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,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){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,t);i.updateVisible(this),i.resetBBoxNeedsUpdate(),jn(i)&&Gl(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),Gl(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),jn(o)&&(o.freeBooleanPointer(),i instanceof Pr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Bs&&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()),jn(o)&&(o.invalidateUpstreamBooleanData(),Gl(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof Pr&&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 t of this.children)t instanceof qr&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,t,o,i){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:s}=t.props;t={...t,props:s},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let a=this.find(e);if(a)try{Wv(a,t,o,{scene:this,shared:i}),a instanceof bt&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,t,o,i,a,s=[]){e.updateEntityByOp(t,o,i,a),this.traverseEntity(l=>{(l instanceof Ti||l instanceof qr)&&(s.includes(l.frameId??"")||l.frameId===t)&&l.updateEntity2DByOp(t,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,t){let o=Object.entries(t.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:t}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(i=>{i instanceof an&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){je.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{je.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,i,a,s,l){if(e){let c=i.find(e);c&&c!==i&&a.forInstancesRec(u=>{u.data=mn(u.data,p=>{let d=p.events.data(l.id),h=u.goUp(s);if(h){let f=[...rc(h.identity),e].join("-"),m=this.entityIdentityToEntity[f];if(m){let y=m.uuid,g=mt.zoom(d,t);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,t,o,i,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...t,l.id],"object",o,i,a,s):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...t,l.id],"object",o,i,a,s)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof cn&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(i=>{if(i.data.type==="GameControl"){let a=!1;if(t.forInstancesRec(s=>{s.data=mn(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of su.list)this.rewriteActions(i.data.gameActions[s],["gameActions",s],e,t,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,t,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,t,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,t,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,t,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,t,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,t,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,t,o,i)})}),!0})}expandInstances(e,t,o){let i=new Set;this.traverseEntity(a=>{if(a instanceof cn&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),t||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),bd(a)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof cn&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let o=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[o]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[o]),t.dispose()})}clearScene(){for(let e of this.children)je.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let o=[],i=a=>{for(let s of a.children){let l=s.cloner;if(je.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(t===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let p=s.matrixWorld.clone().invert();u.point.applyMatrix4(p),o.push(u)}}else(jn(s)||jl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),$l(s,e,o)),i(s)}};return i(this.activePage),o}raycastWithClones(e){let t=[],o=i=>{for(let a of i.children){let s=a.cloner;je.is(a)&&(a.visible||s?.object.data.visible)&&((jn(a)||jl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),$l(a,e,t,!0)),o(a))}};return o(this),t}forEachEntity(e){for(let t of this.children)je.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)je.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)je.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(o=>{if(o instanceof bt&&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,t).then(()=>{i.update(a);let s=o.invalidateDownstreamBooleanData();Gl(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)Pa.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)je.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,o){let i=0;for(let a of e)this.createObject(a.id,a.data,a.children,t,i,o),i+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,o,i,a,s){let l={scene:this,shared:s},c=Od(e,t,l);return c&&(this.entityByUuid[e]=c,i.add(c),i.children.splice(a,0,i.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(t,l),c instanceof bt&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof bt&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),h=p.boneInverses.map(m=>new Yr.Matrix4().fromArray(m)),f=new Yr.Skeleton(d,h);u.bind(f,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let t=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:l}=e[i],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;t.push(...u.vertices)}let o=new Yr.Box3;return o.setFromPoints(t),o.getCenter(rS),rS}copyMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e);o?t.copy(o.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e)?.parent;o?t.copy(o.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof zt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof Sr&&e(t.material[o]);else t.material instanceof Sr&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(i=>{i instanceof an&&i.setViewplaneSize(e,t,o)})}initializeSplatViewer(){this.splatViewer=new Yl({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var oS=require("three/examples/jsm/loaders/DRACOLoader.js");var qn;function nS(){return qn||(qn=new oS.DRACOLoader,qn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),qn.decoderPending}async function EI(n){if(qn){let r={attributeIDs:qn.defaultAttributeIDs,attributeTypes:qn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await qn.decodeGeometry(new Int8Array(n).buffer,r)}catch(t){console.error(t)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([t,o])=>({name:t,itemSize:o.itemSize,array:o.array}))}}return null}async function iS(n,r){let[e,t]=tp(Hc.deserialize(new Uint8Array(n)));return cu(e),r&&r(e),t.result().data}function aS(n){let r=[];return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="NonParametricGeometry"&&t.geometry.data.draco!==void 0&&r.push(t)}),r}async function sS(n){for(let r of n){let e=await EI(r.geometry.data.draco);if(e){let t=r.geometry.data;e.index&&(t.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:i,array:a,itemSize:s})=>{o[i]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),t.attributes=o,t.draco=void 0}}}var _I=require("three"),BI=require("three/examples/jsm/utils/BufferGeometryUtils.js");function lS(n){let r;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)r=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=r}var Xl=require("three");function cS(n){let r=new Set;return n.traverse(e=>{if(e instanceof wr)if(St(e.material))e.material.forEach(t=>{let o=t;r.has(o)||r.add(o)});else{let t=e.material;r.has(t)||r.add(t)}}),r.forEach(e=>{if(e instanceof Array)return;let t=e.onBeforeCompile.bind(e);if(LI(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Xl.Color,specularColor:new Xl.Color});let o=0;e.onBeforeCompile=(i,a)=>{t&&t(i,a),i.uniforms=Object.assign({},Xl.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=Qx(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else RI(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function LI(n){return n.getLayersOfType("transmission").length>0}function RI(n){let r=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&&(r+=(1-r)*o.value)}}return r<1}function uS(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function dS(n){let r=[],e=(t,o=0)=>{let i=o>0?t+o:t;return r.includes(i)?e(t,o+1):i};return n.traverse(t=>{if(r.includes(t.name)){let o=t.name,i=e(t.name);if(t.name=i,t.isMesh){let a=t;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))}}r.push(t.name)}),n}var pS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function fS(n){let r=[];return n.traverse(e=>{e instanceof ws&&r.push(e)}),r.forEach(e=>{let t=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&lS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&t instanceof zt&&a.unshift(t.geometry),a.length){let s=(0,pS.mergeBufferGeometries)(a);t instanceof zt&&(t.geometry=s)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:db})}),n}function hS(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function mS(n){Object.values(n.shared.materials).forEach(r=>{yh(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?yh(e.material):"materials"in e&&e.materials.forEach(t=>{yh(t)})})}function yh(n){if(typeof n=="string")return;let r=[];n.layers.forEach((e,t)=>{e.type==="outline"&&r.push(t)}),r.reverse().forEach(e=>{n.layers.delete(e)}),r.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var vS=Ei(gS(),1);function xS(n){return n.traverseMaterial(r=>{r.needsJitter=!1}),n}var bS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Dd=class extends Ed.Loader{load(r,e,t,o=console.error){let i=new Ed.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(bS+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(bS),i.load(r,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)}},t,o)}async parse(r){let e=await iS(r,mS),t=aS(e);e.version&&(0,vS.default)(e.version,"1.0.64")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([t.length&&nS(),yb(e)&&Px(),Ab(e)&&cb(),av(e)&&ov(),Md(e)&&mh()].filter(Boolean)),t.length&&await sS(t);let o=new Si(e.shared);Object.values(o.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let i=new Nd(e.scene,o);Md(e)&&i.initializeSplatViewer();let a=i.activeCamera;return a&&Object.assign(a,{makeDefault:!0}),i=fS(i),i=cS(i),i=uS(i),i=dS(i),i=hS(i),i=xS(i),i}};
|